Ticket #9527: 9527.5.diff
| File 9527.5.diff, 6.0 KB (added by , 17 years ago) |
|---|
-
wp-admin/plugins.php
211 211 <?php 212 212 213 213 $all_plugins = get_plugins(); 214 $search_plugins = array(); 214 215 $active_plugins = array(); 215 216 $inactive_plugins = array(); 216 217 $recent_plugins = array(); 217 $recently_activated = (array) get_option('recently_activated');218 $recently_activated = get_option('recently_activated', array()); 218 219 $upgrade_plugins = array(); 219 220 220 221 set_transient( 'plugin_slugs', array_keys($all_plugins), 86400 ); … … 245 246 $upgrade_plugins[ $plugin_file ] = $plugin_data; 246 247 } 247 248 248 $total_ plugins = count($all_plugins);249 $total_all_plugins = count($all_plugins); 249 250 $total_inactive_plugins = count($inactive_plugins); 250 251 $total_active_plugins = count($active_plugins); 251 252 $total_recent_plugins = count($recent_plugins); 252 253 $total_upgrade_plugins = count($upgrade_plugins); 253 254 254 $status = ( isset($_GET['plugin_status']) ) ? $_GET['plugin_status'] : 'all'; 255 if ( !in_array($status, array('all', 'active', 'inactive', 'recent', 'upgrade')) ) 255 //Searching. 256 if ( isset($_GET['s']) ) { 257 function _search_plugins_filter_callback($plugin) { 258 static $term; 259 if ( is_null($term) ) 260 $term = stripslashes($_GET['s']); 261 if ( stripos($plugin['Name'], $term) !== false || 262 stripos($plugin['Description'], $term) !== false || 263 stripos($plugin['Author'], $term) !== false || 264 stripos($plugin['PluginURI'], $term) !== false || 265 stripos($plugin['AuthorURI'], $term) !== false || 266 stripos($plugin['Version'], $term) !== false ) 267 return true; 268 else 269 return false; 270 } 271 $_GET['plugin_status'] = 'search'; 272 $search_plugins = array_filter($all_plugins, '_search_plugins_filter_callback'); 273 $total_search_plugins = count($search_plugins); 274 } 275 276 $status = isset($_GET['plugin_status']) ? $_GET['plugin_status'] : 'all'; 277 if ( !in_array($status, array('all', 'active', 'inactive', 'recent', 'upgrade', 'search')) ) 256 278 $status = 'all'; 257 279 $plugin_array_name = "${status}_plugins"; 258 280 $plugins = &$$plugin_array_name; 259 281 282 //Paging. 283 $page = isset($_GET['paged']) ? $_GET['paged'] : 1; 284 $total_this_page = "total_{$status}_plugins"; 285 $total_this_page = $$total_this_page; 286 $plugins_per_page = apply_filters('plugins_per_page', 20, $status); 287 288 $start = ($page - 1) * $plugins_per_page; 289 290 $page_links = paginate_links( array( 291 'base' => add_query_arg( 'paged', '%#%' ), 292 'format' => '', 293 'prev_text' => __('«'), 294 'next_text' => __('»'), 295 'total' => ceil($total_this_page / $plugins_per_page), 296 'current' => $page 297 )); 298 $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s', 299 number_format_i18n( $start + 1 ), 300 number_format_i18n( min( $page * $plugins_per_page, $total_this_page ) ), 301 '<span class="total-type-count">' . number_format_i18n( $total_this_page ) . '</span>', 302 $page_links 303 ); 304 260 305 /** 261 306 * @ignore 262 307 * … … 362 407 } 363 408 ?> 364 409 410 <form method="get" action=""> 411 <p class="search-box"> 412 <label class="hidden" for="plugin-search-input"><?php _e( 'Search Plugins' ); ?>:</label> 413 <input type="text" id="plugin-search-input" name="s" value="<?php _admin_search_query(); ?>" /> 414 <input type="submit" value="<?php _e( 'Search Plugins' ); ?>" class="button" /> 415 </p> 416 </form> 417 365 418 <form method="post" action="<?php echo admin_url('plugins.php') ?>"> 366 419 <?php wp_nonce_field('bulk-manage-plugins') ?> 367 420 … … 369 422 <?php 370 423 $status_links = array(); 371 424 $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>';425 $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>'; 373 426 if ( ! empty($active_plugins) ) { 374 427 $class = ( 'active' == $status ) ? ' class="current"' : ''; 375 428 $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>'; … … 386 439 $class = ( 'upgrade' == $status ) ? ' class="current"' : ''; 387 440 $status_links[] = "<li><a href='plugins.php?plugin_status=upgrade' $class>" . sprintf( _n( 'Upgrade Available <span class="count">(%s)</span>', 'Upgrade Available <span class="count">(%s)</span>', $total_upgrade_plugins ), number_format_i18n( $total_upgrade_plugins ) ) . '</a>'; 388 441 } 442 if ( ! empty($search_plugins) ) { 443 $class = ( 'search' == $status ) ? ' class="current"' : ''; 444 $term = isset($_REQUEST['s']) ? urlencode(stripslashes($_REQUEST['s'])) : ''; 445 $status_links[] = "<li><a href='plugins.php?s=$term' $class>" . sprintf( _n( 'Search Results <span class="count">(%s)</span>', 'Search Results <span class="count">(%s)</span>', $total_search_plugins ), number_format_i18n( $total_search_plugins ) ) . '</a>'; 446 } 389 447 echo implode( " |</li>\n", $status_links ) . '</li>'; 390 448 unset( $status_links ); 391 449 ?> 392 450 </ul> 393 451 394 452 <div class="tablenav"> 395 <?php print_plugin_actions($status) ?> 453 <?php 454 if ( $page_links ) 455 echo '<div class="tablenav-pages">', $page_links_text, '</div>'; 456 457 print_plugin_actions($status); 458 ?> 396 459 </div> 397 460 <div class="clear"></div> 398 <?php print_plugins_table($plugins, $status) ?> 461 <?php 462 if ( $total_this_page > $plugins_per_page ) 463 $plugins = array_slice($plugins, $start, $plugins_per_page); 464 465 print_plugins_table($plugins, $status); 466 ?> 467 <div class="tablenav"> 468 <?php 469 if ( $page_links ) 470 echo "<div class='tablenav-pages'>$page_links_text</div>"; 471 ?> 472 <div class="alignleft actions"> 473 <!-- TODO lower bulk actions. --> 474 </div> 475 </div> 399 476 </form> 400 477 401 478 <?php if ( empty($all_plugins) ) : ?>