Changeset 11003
- Timestamp:
- 04/19/2009 06:50:22 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/wp-admin/plugins.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/plugins.php
r11002 r11003 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 … … 232 233 //Translate, Apply Markup, Sanitize HTML 233 234 $plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, true, true); 235 $all_plugins[ $plugin_file ] = $plugin_data; 234 236 235 237 //Filter into individual sections … … 246 248 } 247 249 248 $total_ plugins = count($all_plugins);250 $total_all_plugins = count($all_plugins); 249 251 $total_inactive_plugins = count($inactive_plugins); 250 252 $total_active_plugins = count($active_plugins); … … 252 254 $total_upgrade_plugins = count($upgrade_plugins); 253 255 254 $status = ( isset($_GET['plugin_status']) ) ? $_GET['plugin_status'] : 'all'; 255 if ( !in_array($status, array('all', 'active', 'inactive', 'recent', 'upgrade')) ) 256 //Searching. 257 if ( isset($_GET['s']) ) { 258 function _search_plugins_filter_callback($plugin) { 259 static $term; 260 if ( is_null($term) ) 261 $term = stripslashes($_GET['s']); 262 if ( stripos($plugin['Name'], $term) !== false || 263 stripos($plugin['Description'], $term) !== false || 264 stripos($plugin['Author'], $term) !== false || 265 stripos($plugin['PluginURI'], $term) !== false || 266 stripos($plugin['AuthorURI'], $term) !== false || 267 stripos($plugin['Version'], $term) !== false ) 268 return true; 269 else 270 return false; 271 } 272 $_GET['plugin_status'] = 'search'; 273 $search_plugins = array_filter($all_plugins, '_search_plugins_filter_callback'); 274 $total_search_plugins = count($search_plugins); 275 } 276 277 $status = isset($_GET['plugin_status']) ? $_GET['plugin_status'] : 'all'; 278 if ( !in_array($status, array('all', 'active', 'inactive', 'recent', 'upgrade', 'search')) ) 256 279 $status = 'all'; 257 280 $plugin_array_name = "${status}_plugins"; 258 281 $plugins = &$$plugin_array_name; 282 283 //Paging. 284 $page = isset($_GET['paged']) ? $_GET['paged'] : 1; 285 $total_this_page = "total_{$status}_plugins"; 286 $total_this_page = $$total_this_page; 287 $plugins_per_page = apply_filters('plugins_per_page', 20, $status); 288 289 $start = ($page - 1) * $plugins_per_page; 290 291 $page_links = paginate_links( array( 292 'base' => add_query_arg( 'paged', '%#%' ), 293 'format' => '', 294 'prev_text' => __('«'), 295 'next_text' => __('»'), 296 'total' => ceil($total_this_page / $plugins_per_page), 297 'current' => $page 298 )); 299 $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s', 300 number_format_i18n( $start + 1 ), 301 number_format_i18n( min( $page * $plugins_per_page, $total_this_page ) ), 302 '<span class="total-type-count">' . number_format_i18n( $total_this_page ) . '</span>', 303 $page_links 304 ); 259 305 260 306 /** … … 363 409 ?> 364 410 411 <form method="get" action=""> 412 <p class="search-box"> 413 <label class="hidden" for="plugin-search-input"><?php _e( 'Search Plugins' ); ?>:</label> 414 <input type="text" id="plugin-search-input" name="s" value="<?php _admin_search_query(); ?>" /> 415 <input type="submit" value="<?php _e( 'Search Plugins' ); ?>" class="button" /> 416 </p> 417 </form> 418 365 419 <form method="post" action="<?php echo admin_url('plugins.php') ?>"> 366 420 <?php wp_nonce_field('bulk-manage-plugins') ?> … … 370 424 $status_links = array(); 371 425 $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>';426 $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 427 if ( ! empty($active_plugins) ) { 374 428 $class = ( 'active' == $status ) ? ' class="current"' : ''; … … 387 441 $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 442 } 443 if ( ! empty($search_plugins) ) { 444 $class = ( 'search' == $status ) ? ' class="current"' : ''; 445 $term = isset($_REQUEST['s']) ? urlencode(stripslashes($_REQUEST['s'])) : ''; 446 $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>'; 447 } 389 448 echo implode( " |</li>\n", $status_links ) . '</li>'; 390 449 unset( $status_links ); … … 393 452 394 453 <div class="tablenav"> 395 <?php print_plugin_actions($status) ?> 454 <?php 455 if ( $page_links ) 456 echo '<div class="tablenav-pages">', $page_links_text, '</div>'; 457 458 print_plugin_actions($status); 459 ?> 396 460 </div> 397 461 <div class="clear"></div> 398 <?php print_plugins_table($plugins, $status) ?> 462 <?php 463 if ( $total_this_page > $plugins_per_page ) 464 $plugins = array_slice($plugins, $start, $plugins_per_page); 465 466 print_plugins_table($plugins, $status); 467 ?> 468 <div class="tablenav"> 469 <?php 470 if ( $page_links ) 471 echo "<div class='tablenav-pages'>$page_links_text</div>"; 472 ?> 473 <div class="alignleft actions"> 474 <!-- TODO lower bulk actions. --> 475 </div> 476 </div> 399 477 </form> 400 478
Note: See TracChangeset
for help on using the changeset viewer.