WooCommerce Code Reference

Pagination
in package

Pagination class.

Table of Contents

add_headers()  : WP_REST_Response
Add pagination headers to a response object.
add_page_link()  : mixed
Add a page link.
get_current_page()  : int
Get current page.
get_link_base()  : string
Get base for links from the request object.

Methods

add_headers()

Add pagination headers to a response object.

public add_headers(WP_REST_Response $response, WP_REST_Request $request, int $total_items, int $total_pages) : WP_REST_Response
Parameters
$response : WP_REST_Response

Reference to the response object.

$request : WP_REST_Request

The request object.

$total_items : int

Total items found.

$total_pages : int

Total pages found.

Return values
WP_REST_Response

Add a page link.

protected add_page_link(WP_REST_Response &$response, string $name, int $page, string $link_base) : mixed
Parameters
$response : WP_REST_Response

Reference to the response object.

$name : string

Page link name. e.g. prev.

$page : int

Page number.

$link_base : string

Base URL.

Return values
mixed

get_current_page()

Get current page.

protected get_current_page(WP_REST_Request $request) : int
Parameters
$request : WP_REST_Request

The request object.

Return values
intGet the page from the request object.

Get base for links from the request object.

protected get_link_base(WP_REST_Request $request) : string
Parameters
$request : WP_REST_Request

The request object.

Return values
string