WP_List_Table::pagination( string $which )
- Since
- 3.1.0
- Source
wp-admin/includes/class-wp-list-table.php:1018
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
- Scaling
- Constant
- Instructions
- 126–217
- Plugin surface
- None
- Called by
- 3
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 242.
Nothing here hands control to plugin code.
3 places in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
apply_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.
| When | Instructions | Calls 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_pages | 132–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_pages | 149–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_pages | 149–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_pages | 151–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_pages | 166–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_pages | 168–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_pages | 168–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_pages | 168–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_pages | 185–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_pages | 185–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_pages | 187–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_pages | 204–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
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 242 | 126–217 | 14 | |
| 8.5 | 242 | 126–217 | 14 | |
| 8.4 | 242 | 126–217 | 14 | 7 fewer instructions than PHP 8.3 |
| 8.3 | 249 | 132–223 | 14 | |
| 8.2 | 249 | 132–223 | 14 | |
| 8.1 | 249 | 132–223 | 14 | |
| 7.4 | 249 | 132–223 | 14 |
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
- _n()Translates and retrieves the singular or plural form based on the supplied number.
- number_format_i18n()Converts float number to format based on the locale.
- wp_removable_query_args()Returns an array of single-use query variable names that can be removed from a URL.
- set_url_scheme()Sets the scheme for a URL.
- remove_query_arg()Removes an item or items from a query string.
- esc_url()Checks and cleans a URL.
- __()Retrieves the translation of $text.
- add_query_arg()Retrieves a modified URL query string.
- _x()Retrieves translated string with gettext context.
- WP_List_Table::get_pagenum()Gets the current page number.
Used by · 3
- WP_List_Table::display_tablenav()Generates the table navigation above or below the table
- WP_MS_Sites_List_Table::pagination()Displays the pagination.
- WP_MS_Users_List_Table::pagination()
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">«</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' ), '«' ); } if ( $disable_prev ) { $page_links[] = '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">‹</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' ), '‹' ); } if ( 'bottom' === $which ) { $html_current_page = $current;Changelog
Introduced in 3.1.0. Unchanged from 6.7.7 through 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.