WordPress.org

Make WordPress Core

Ticket #9527: 9527.3.diff

File 9527.3.diff, 3.4 KB (added by DD32, 6 years ago)

Paging

  • wp-admin/plugins.php

     
    245245        $upgrade_plugins[ $plugin_file ] = $plugin_data; 
    246246} 
    247247 
    248 $total_plugins = count($all_plugins); 
     248$total_all_plugins = count($all_plugins); 
    249249$total_inactive_plugins = count($inactive_plugins); 
    250250$total_active_plugins = count($active_plugins); 
    251251$total_recent_plugins = count($recent_plugins); 
    252252$total_upgrade_plugins = count($upgrade_plugins); 
    253253 
    254 $status = ( isset($_GET['plugin_status']) ) ? $_GET['plugin_status'] : 'all'; 
     254$status = isset($_GET['plugin_status']) ? $_GET['plugin_status'] : 'all'; 
    255255if ( !in_array($status, array('all', 'active', 'inactive', 'recent', 'upgrade')) ) 
    256256        $status = 'all'; 
    257257$plugin_array_name = "${status}_plugins"; 
    258258$plugins = &$$plugin_array_name; 
    259259 
     260 
     261//Paging. 
     262$page = isset($_GET['paged']) ? $_GET['paged'] : 1; 
     263$total_this_page = "total_{$status}_plugins"; 
     264$total_this_page = $$total_this_page; 
     265$plugins_per_page = apply_filters('plugins_per_page', 20, $status); 
     266 
     267$start = ($page - 1) * $plugins_per_page; 
     268 
     269$page_links = paginate_links( array( 
     270        'base' => add_query_arg( 'paged', '%#%' ), 
     271        'format' => '', 
     272        'prev_text' => __('«'), 
     273        'next_text' => __('»'), 
     274        'total' => ceil($total_this_page / $plugins_per_page), 
     275        'current' => $page 
     276)); 
     277$page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s', 
     278        number_format_i18n( $start + 1 ), 
     279        number_format_i18n( min( $page * $plugins_per_page, $total_this_page ) ), 
     280        '<span class="total-type-count">' . number_format_i18n( $total_this_page ) . '</span>', 
     281        $page_links 
     282); 
     283 
    260284/** 
    261285 * @ignore 
    262286 * 
     
    369393<?php 
    370394$status_links = array(); 
    371395$class = ( 'all' == $status ) ? ' class="current"' : ''; 
    372 $status_links[] = "<li><a href='plugins.php' $class>" . sprintf( _n( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_plugins ), number_format_i18n( $total_plugins ) ) . '</a>'; 
     396$status_links[] = "<li><a href='plugins.php' $class>" . sprintf( _n( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_all_plugins ), number_format_i18n( $total_all_plugins ) ) . '</a>'; 
    373397if ( ! empty($active_plugins) ) { 
    374398        $class = ( 'active' == $status ) ? ' class="current"' : ''; 
    375399        $status_links[] = "<li><a href='plugins.php?plugin_status=active' $class>" . sprintf( _n( 'Active <span class="count">(%s)</span>', 'Active <span class="count">(%s)</span>', $total_active_plugins ), number_format_i18n( $total_active_plugins ) ) . '</a>'; 
     
    392416</ul> 
    393417 
    394418<div class="tablenav"> 
    395 <?php print_plugin_actions($status) ?> 
     419<?php 
     420if ( $page_links ) 
     421        echo '<div class="tablenav-pages">', $page_links_text, '</div>'; 
     422 
     423print_plugin_actions($status); 
     424?> 
    396425</div> 
    397426<div class="clear"></div> 
    398 <?php print_plugins_table($plugins, $status) ?> 
     427<?php 
     428        if ( $total_this_page > $plugins_per_page ) 
     429                $plugins = array_slice($plugins, $start, $plugins_per_page); 
     430         
     431        print_plugins_table($plugins, $status); 
     432?> 
     433<div class="tablenav"> 
     434<?php 
     435if ( $page_links ) 
     436        echo "<div class='tablenav-pages'>$page_links_text</div>"; 
     437?> 
     438<div class="alignleft actions"> 
     439<!-- TODO lower bulk actions. --> 
     440</div> 
     441</div> 
    399442</form> 
    400443 
    401444<?php if ( empty($all_plugins) ) : ?>