WordPress.org

Make WordPress Core

Changeset 28389


Ignore:
Timestamp:
05/13/2014 05:26:34 AM (7 years ago)
Author:
wonderboymusic
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-list-table.php

    r28387 r28389  
    518518     */
    519519    function pagination( $which ) {
    520         if ( empty( $this->_pagination_args ) )
     520        if ( empty( $this->_pagination_args ) ) {
    521521            return;
    522 
    523         extract( $this->_pagination_args, EXTR_SKIP );
     522        }
     523
     524        $total_items = $this->_pagination_args['total_items'];
     525        $total_pages = $this->_pagination_args['total_pages'];
     526        $infinite_scroll = false;
     527        if ( isset( $this->_pagination_args['infinite_scroll'] ) ) {
     528            $infinite_scroll = $this->_pagination_args['infinite_scroll'];
     529        }
    524530
    525531        $output = '<span class="displaying-num">' . sprintf( _n( '1 item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>';
     
    534540
    535541        $disable_first = $disable_last = '';
    536         if ( $current == 1 )
     542        if ( $current == 1 ) {
    537543            $disable_first = ' disabled';
    538         if ( $current == $total_pages )
     544        }
     545        if ( $current == $total_pages ) {
    539546            $disable_last = ' disabled';
    540 
     547        }
    541548        $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
    542549            'first-page' . $disable_first,
     
    553560        );
    554561
    555         if ( 'bottom' == $which )
     562        if ( 'bottom' == $which ) {
    556563            $html_current_page = $current;
    557         else
     564        } else {
    558565            $html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name='paged' value='%s' size='%d' />",
    559566                esc_attr__( 'Current page' ),
     
    561568                strlen( $total_pages )
    562569            );
    563 
     570        }
    564571        $html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
    565572        $page_links[] = '<span class="paging-input">' . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . '</span>';
     
    580587
    581588        $pagination_links_class = 'pagination-links';
    582         if ( ! empty( $infinite_scroll ) )
     589        if ( ! empty( $infinite_scroll ) ) {
    583590            $pagination_links_class = ' hide-if-js';
     591        }
    584592        $output .= "\n<span class='$pagination_links_class'>" . join( "\n", $page_links ) . '</span>';
    585593
    586         if ( $total_pages )
     594        if ( $total_pages ) {
    587595            $page_class = $total_pages < 2 ? ' one-page' : '';
    588         else
     596        } else {
    589597            $page_class = ' no-pages';
    590 
     598        }
    591599        $this->_pagination = "<div class='tablenav-pages{$page_class}'>$output</div>";
    592600
Note: See TracChangeset for help on using the changeset viewer.