mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
Eliminate use of extract()
in WP_List_Table::pagination()
:
* Set variables instead of extracting `$this->_pagination_args` * Weird: `$infinite_scroll` is only presently set in subclasses of `WP_List_Table` and never initialized otherwise. See #22400. Built from https://develop.svn.wordpress.org/trunk@28389 git-svn-id: http://core.svn.wordpress.org/trunk@28217 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
530a107ec9
commit
aef35fe6a2
@ -517,10 +517,16 @@ class WP_List_Table {
|
||||
* @access protected
|
||||
*/
|
||||
function pagination( $which ) {
|
||||
if ( empty( $this->_pagination_args ) )
|
||||
if ( empty( $this->_pagination_args ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
extract( $this->_pagination_args, EXTR_SKIP );
|
||||
$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'];
|
||||
}
|
||||
|
||||
$output = '<span class="displaying-num">' . sprintf( _n( '1 item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>';
|
||||
|
||||
@ -533,11 +539,12 @@ class WP_List_Table {
|
||||
$page_links = array();
|
||||
|
||||
$disable_first = $disable_last = '';
|
||||
if ( $current == 1 )
|
||||
if ( $current == 1 ) {
|
||||
$disable_first = ' disabled';
|
||||
if ( $current == $total_pages )
|
||||
}
|
||||
if ( $current == $total_pages ) {
|
||||
$disable_last = ' disabled';
|
||||
|
||||
}
|
||||
$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
|
||||
'first-page' . $disable_first,
|
||||
esc_attr__( 'Go to the first page' ),
|
||||
@ -552,15 +559,15 @@ class WP_List_Table {
|
||||
'‹'
|
||||
);
|
||||
|
||||
if ( 'bottom' == $which )
|
||||
if ( 'bottom' == $which ) {
|
||||
$html_current_page = $current;
|
||||
else
|
||||
} else {
|
||||
$html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name='paged' value='%s' size='%d' />",
|
||||
esc_attr__( 'Current page' ),
|
||||
$current,
|
||||
strlen( $total_pages )
|
||||
);
|
||||
|
||||
}
|
||||
$html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
|
||||
$page_links[] = '<span class="paging-input">' . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . '</span>';
|
||||
|
||||
@ -579,15 +586,16 @@ class WP_List_Table {
|
||||
);
|
||||
|
||||
$pagination_links_class = 'pagination-links';
|
||||
if ( ! empty( $infinite_scroll ) )
|
||||
if ( ! empty( $infinite_scroll ) ) {
|
||||
$pagination_links_class = ' hide-if-js';
|
||||
}
|
||||
$output .= "\n<span class='$pagination_links_class'>" . join( "\n", $page_links ) . '</span>';
|
||||
|
||||
if ( $total_pages )
|
||||
if ( $total_pages ) {
|
||||
$page_class = $total_pages < 2 ? ' one-page' : '';
|
||||
else
|
||||
} else {
|
||||
$page_class = ' no-pages';
|
||||
|
||||
}
|
||||
$this->_pagination = "<div class='tablenav-pages{$page_class}'>$output</div>";
|
||||
|
||||
echo $this->_pagination;
|
||||
|
Loading…
Reference in New Issue
Block a user