bp_sanitize_pagination_arg( string $page_arg = '', int $page = 1 )

Sanitizes a pagination argument based on both the request override and the original value submitted via a query argument, likely to a template class responsible for limiting the resultset of a template loop.

Description

Parameters

$page_arg

(Optional) The $_REQUEST argument to look for.

Default value: ''

$page

(Optional) The original page value to fall back to.

Default value: 1

Return

(int) A sanitized integer value, good for pagination.

Source

File: bp-core/bp-core-functions.php

function bp_sanitize_pagination_arg( $page_arg = '', $page = 1 ) {

	// Check if request overrides exist.
	if ( isset( $_REQUEST[ $page_arg ] ) ) {

		// Get the absolute integer value of the override.
		$int = absint( $_REQUEST[ $page_arg ] );

		// If override is 0, do not use it. This prevents unlimited result sets.
		// @see https://buddypress.trac.wordpress.org/ticket/5796.
		if ( $int ) {
			$page = $int;
		}
	}

	return intval( $page );
}

Changelog

Changelog
Version Description
BuddyPress 2.2.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.