wppaste
WordPress

WP_List_Table::pagination( string $which )

Since
3.1.0
Source
wp-admin/includes/class-wp-list-table.php:1018
Displays the pagination.

Compatibility

WordPress
since 3.1.0
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.

Parameters

$whichstring
The location of the pagination: Either 'top' or 'bottom'.

Performance profile

How much work a call to WP_List_Table::pagination() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Trivial

Touches nothing outside its own arguments.

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
126–217

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 242.

Plugin surface
None

Nothing here hands control to plugin code.

Called by
3

3 places in core call this, so the cost is paid more often than your own code shows.

What it touches

  • hookthird-party callbacksapply_filters()one call below WP_List_Table::pagination()

Further down the call graph this can also reach query, option, cache, serialize and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.

What one call costs · 24 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_List_Table::pagination() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
!empty($value)126–143_n(), number_format_i18n(), sprintf(), ->get_pagenum(), wp_removable_query_args(), set_url_scheme(), remove_query_arg(), __(), number_format_i18n(), _x(), sprintf()
!empty($value) && !isset($value) && $which === "top" && $total_pages132–145->render_screen_reader_content(), _n(), number_format_i18n(), sprintf(), ->get_pagenum(), wp_removable_query_args(), set_url_scheme(), remove_query_arg(), __(), number_format_i18n(), _x(), sprintf()
!empty($value)143–160_n(), number_format_i18n(), sprintf(), ->get_pagenum(), wp_removable_query_args(), set_url_scheme(), remove_query_arg(), remove_query_arg(), esc_url(), __(), __(), number_format_i18n(), _x(), sprintf()
!empty($value)143–162_n(), number_format_i18n(), sprintf(), ->get_pagenum(), wp_removable_query_args(), set_url_scheme(), remove_query_arg(), __(), number_format_i18n(), _x(), sprintf(), add_query_arg(), esc_url(), __()
!empty($value)145–162_n(), number_format_i18n(), sprintf(), ->get_pagenum(), wp_removable_query_args(), set_url_scheme(), remove_query_arg(), add_query_arg(), esc_url(), __(), __(), number_format_i18n(), _x(), sprintf()
!empty($value) && $which === "top" && $total_pages149–162->render_screen_reader_content(), _n(), number_format_i18n(), sprintf(), ->get_pagenum(), wp_removable_query_args(), set_url_scheme(), remove_query_arg(), remove_query_arg(), esc_url(), __(), __(), number_format_i18n(), _x(), sprintf()
!empty($value) && $which === "top" && $total_pages149–164->render_screen_reader_content(), _n(), number_format_i18n(), sprintf(), ->get_pagenum(), wp_removable_query_args(), set_url_scheme(), remove_query_arg(), __(), number_format_i18n(), _x(), sprintf(), add_query_arg(), esc_url(), __()
!empty($value) && $which === "top" && $total_pages151–164->render_screen_reader_content(), _n(), number_format_i18n(), sprintf(), ->get_pagenum(), wp_removable_query_args(), set_url_scheme(), remove_query_arg(), add_query_arg(), esc_url(), __(), __(), number_format_i18n(), _x(), sprintf()
!empty($value)160–179_n(), number_format_i18n(), sprintf(), ->get_pagenum(), wp_removable_query_args(), set_url_scheme(), remove_query_arg(), remove_query_arg(), esc_url(), __(), __(), number_format_i18n(), _x(), sprintf(), add_query_arg(), esc_url(), __()
!empty($value)162–179_n(), number_format_i18n(), sprintf(), ->get_pagenum(), wp_removable_query_args(), set_url_scheme(), remove_query_arg(), remove_query_arg(), esc_url(), __(), add_query_arg(), esc_url(), __(), __(), number_format_i18n(), _x(), sprintf()
!empty($value)162–181_n(), number_format_i18n(), sprintf(), ->get_pagenum(), wp_removable_query_args(), set_url_scheme(), remove_query_arg(), add_query_arg(), esc_url(), __(), __(), number_format_i18n(), _x(), sprintf(), add_query_arg(), esc_url(), __()
!empty($value)162–179_n(), number_format_i18n(), sprintf(), ->get_pagenum(), wp_removable_query_args(), set_url_scheme(), remove_query_arg(), __(), number_format_i18n(), _x(), sprintf(), add_query_arg(), esc_url(), __(), add_query_arg(), esc_url(), __()
12 further outcomes, up to 217 instructions
!empty($value) && $which === "top" && $total_pages166–181->render_screen_reader_content(), _n(), number_format_i18n(), sprintf(), ->get_pagenum(), wp_removable_query_args(), set_url_scheme(), remove_query_arg(), remove_query_arg(), esc_url(), __(), __(), number_format_i18n(), _x(), sprintf(), add_query_arg(), esc_url(), __()
!empty($value) && $which === "top" && $total_pages168–181->render_screen_reader_content(), _n(), number_format_i18n(), sprintf(), ->get_pagenum(), wp_removable_query_args(), set_url_scheme(), remove_query_arg(), remove_query_arg(), esc_url(), __(), add_query_arg(), esc_url(), __(), __(), number_format_i18n(), _x(), sprintf()
!empty($value) && $which === "top" && $total_pages168–183->render_screen_reader_content(), _n(), number_format_i18n(), sprintf(), ->get_pagenum(), wp_removable_query_args(), set_url_scheme(), remove_query_arg(), add_query_arg(), esc_url(), __(), __(), number_format_i18n(), _x(), sprintf(), add_query_arg(), esc_url(), __()
!empty($value) && $which === "top" && $total_pages168–181->render_screen_reader_content(), _n(), number_format_i18n(), sprintf(), ->get_pagenum(), wp_removable_query_args(), set_url_scheme(), remove_query_arg(), __(), number_format_i18n(), _x(), sprintf(), add_query_arg(), esc_url(), __(), add_query_arg(), esc_url(), __()
!empty($value)179–198_n(), number_format_i18n(), sprintf(), ->get_pagenum(), wp_removable_query_args(), set_url_scheme(), remove_query_arg(), remove_query_arg(), esc_url(), __(), add_query_arg(), esc_url(), __(), __(), number_format_i18n(), _x(), sprintf(), add_query_arg(), esc_url(), __()
!empty($value)179–196_n(), number_format_i18n(), sprintf(), ->get_pagenum(), wp_removable_query_args(), set_url_scheme(), remove_query_arg(), remove_query_arg(), esc_url(), __(), __(), number_format_i18n(), _x(), sprintf(), add_query_arg(), esc_url(), __(), add_query_arg(), esc_url(), __()
!empty($value)181–198_n(), number_format_i18n(), sprintf(), ->get_pagenum(), wp_removable_query_args(), set_url_scheme(), remove_query_arg(), add_query_arg(), esc_url(), __(), __(), number_format_i18n(), _x(), sprintf(), add_query_arg(), esc_url(), __(), add_query_arg(), esc_url(), __()
!empty($value) && $which === "top" && $total_pages185–200->render_screen_reader_content(), _n(), number_format_i18n(), sprintf(), ->get_pagenum(), wp_removable_query_args(), set_url_scheme(), remove_query_arg(), remove_query_arg(), esc_url(), __(), add_query_arg(), esc_url(), __(), __(), number_format_i18n(), _x(), sprintf(), add_query_arg(), esc_url(), __()
!empty($value) && $which === "top" && $total_pages185–198->render_screen_reader_content(), _n(), number_format_i18n(), sprintf(), ->get_pagenum(), wp_removable_query_args(), set_url_scheme(), remove_query_arg(), remove_query_arg(), esc_url(), __(), __(), number_format_i18n(), _x(), sprintf(), add_query_arg(), esc_url(), __(), add_query_arg(), esc_url(), __()
!empty($value) && $which === "top" && $total_pages187–200->render_screen_reader_content(), _n(), number_format_i18n(), sprintf(), ->get_pagenum(), wp_removable_query_args(), set_url_scheme(), remove_query_arg(), add_query_arg(), esc_url(), __(), __(), number_format_i18n(), _x(), sprintf(), add_query_arg(), esc_url(), __(), add_query_arg(), esc_url(), __()
!empty($value)198–215_n(), number_format_i18n(), sprintf(), ->get_pagenum(), wp_removable_query_args(), set_url_scheme(), remove_query_arg(), remove_query_arg(), esc_url(), __(), add_query_arg(), esc_url(), __(), __(), number_format_i18n(), _x(), sprintf(), add_query_arg(), esc_url(), __(), add_query_arg(), esc_url(), __()
!empty($value) && $which === "top" && $total_pages204–217->render_screen_reader_content(), _n(), number_format_i18n(), sprintf(), ->get_pagenum(), wp_removable_query_args(), set_url_scheme(), remove_query_arg(), remove_query_arg(), esc_url(), __(), add_query_arg(), esc_url(), __(), __(), number_format_i18n(), _x(), sprintf(), add_query_arg(), esc_url(), __(), add_query_arg(), esc_url(), __()

This body has more branch combinations than are worth enumerating, so the table covers the outcomes found first rather than every one that exists.

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev242126–21714
8.5242126–21714
8.4242126–217147 fewer instructions than PHP 8.3
8.3249132–22314
8.2249132–22314
8.1249132–22314
7.4249132–22314

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Uses · 10

Used by · 3

Source code

	protected function pagination( $which ) {		if ( empty( $this->_pagination_args['total_items'] ) ) {			return;		} 		$total_items     = $this->_pagination_args['total_items'];		$total_pages     = $this->_pagination_args['total_pages'];		$infinite_scroll = false;		if ( isset( $this->_pagination_args['infinite_scroll'] ) ) {			$infinite_scroll = $this->_pagination_args['infinite_scroll'];		} 		if ( 'top' === $which && $total_pages > 1 ) {			$this->screen->render_screen_reader_content( 'heading_pagination' );		} 		$output = '<span class="displaying-num">' . sprintf(			/* translators: %s: Number of items. */			_n( '%s item', '%s items', $total_items ),			number_format_i18n( $total_items )		) . '</span>'; 		$current              = $this->get_pagenum();		$removable_query_args = wp_removable_query_args(); 		$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); 		$current_url = remove_query_arg( $removable_query_args, $current_url ); 		$page_links = array(); 		$total_pages_before = '<span class="paging-input">';		$total_pages_after  = '</span></span>'; 		$disable_first = false;		$disable_last  = false;		$disable_prev  = false;		$disable_next  = false; 		if ( 1 === $current ) {			$disable_first = true;			$disable_prev  = true;		}		if ( $total_pages === $current ) {			$disable_last = true;			$disable_next = true;		} 		if ( $disable_first ) {			$page_links[] = '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">&laquo;</span>';		} else {			$page_links[] = sprintf(				"<a class='first-page button' href='%s'>" .					"<span class='screen-reader-text'>%s</span>" .					"<span aria-hidden='true'>%s</span>" .				'</a>',				esc_url( remove_query_arg( 'paged', $current_url ) ),				/* translators: Hidden accessibility text. */				__( 'First page' ),				'&laquo;'			);		} 		if ( $disable_prev ) {			$page_links[] = '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">&lsaquo;</span>';		} else {			$page_links[] = sprintf(				"<a class='prev-page button' href='%s'>" .					"<span class='screen-reader-text'>%s</span>" .					"<span aria-hidden='true'>%s</span>" .				'</a>',				esc_url( add_query_arg( 'paged', max( 1, $current - 1 ), $current_url ) ),				/* translators: Hidden accessibility text. */				__( 'Previous page' ),				'&lsaquo;'			);		} 		if ( 'bottom' === $which ) {			$html_current_page  = $current;

Changelog

Introduced in 3.1.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.0.4 tag, from src/wp-admin/includes/class-wp-list-table.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.