wppaste
WordPress

WP_List_Table::pagination( string $which )

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

Parameters

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

Uses · 10

Used by · 3

Source

	protected function pagination( $which ) {		if ( empty( $this->_pagination_args['total_items'] ) ) {			// translators: Number is a fixed value. This is default text when no items are found.			echo '<div class="tablenav-pages no-pages"><span class="displaying-num">' . __( '0 items' ) . '</span></div>';			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;'			);		}

History

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.1.0 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.