Ticket #11861: 11861.1.mu.diff
File 11861.1.mu.diff, 10.2 KB (added by , 14 years ago) |
---|
-
wp-admin/plugins.php
27 27 if ( empty($default_status) ) 28 28 $default_status = 'all'; 29 29 $status = isset($_REQUEST['plugin_status']) ? $_REQUEST['plugin_status'] : $default_status; 30 if ( !in_array($status, array('all', 'active', 'inactive', 'recent', 'upgrade', 'search' )) )30 if ( !in_array($status, array('all', 'active', 'inactive', 'recent', 'upgrade', 'search', 'advanced')) ) 31 31 $status = 'all'; 32 32 if ( $status != $default_status && 'search' != $status ) 33 33 update_usermeta($current_user->ID, 'plugins_last_view', $status); … … 287 287 <?php 288 288 289 289 $all_plugins = get_plugins(); 290 $advanced_plugins = get_mu_plugins(); 290 291 $search_plugins = array(); 291 292 $active_plugins = array(); 292 293 $inactive_plugins = array(); … … 323 324 $upgrade_plugins[ $plugin_file ] = $plugin_data; 324 325 } 325 326 327 foreach ( (array)$advanced_plugins as $plugin_file => $plugin_data) { 328 //Translate, Apply Markup, Sanitize HTML 329 $plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true); 330 $advanced_plugins[ $plugin_file ] = $plugin_data; 331 } 332 326 333 $total_all_plugins = count($all_plugins); 334 $total_advanced_plugins = count($advanced_plugins); 327 335 $total_inactive_plugins = count($inactive_plugins); 328 336 $total_active_plugins = count($active_plugins); 329 337 $total_recent_plugins = count($recent_plugins); … … 391 399 */ 392 400 function print_plugins_table($plugins, $context = '') { 393 401 global $page; 402 if ( empty( $plugins ) ) { 403 echo '<p>' . __('No plugins to show') . '</p>'; 404 return; 405 } 394 406 ?> 395 407 <table class="widefat" cellspacing="0" id="<?php echo $context ?>-plugins-table"> 396 408 <thead> 397 409 <tr> 398 <th scope="col" class="manage-column check-column">< input type="checkbox" /></th>410 <th scope="col" class="manage-column check-column"><?php if ( 'advanced' != $context ) { ?><input type="checkbox" /><?php } ?></th> 399 411 <th scope="col" class="manage-column"><?php _e('Plugin'); ?></th> 400 412 <th scope="col" class="manage-column"><?php _e('Description'); ?></th> 401 413 </tr> … … 403 415 404 416 <tfoot> 405 417 <tr> 406 <th scope="col" class="manage-column check-column">< input type="checkbox" /></th>418 <th scope="col" class="manage-column check-column"><?php if ( 'advanced' != $context ) { ?><input type="checkbox" /><?php } ?></th> 407 419 <th scope="col" class="manage-column"><?php _e('Plugin'); ?></th> 408 420 <th scope="col" class="manage-column"><?php _e('Description'); ?></th> 409 421 </tr> … … 411 423 412 424 <tbody class="plugins"> 413 425 <?php 414 415 if ( empty($plugins) ) {416 echo '<tr>417 <td colspan="3">' . __('No plugins to show') . '</td>418 </tr>';419 }420 426 foreach ( (array)$plugins as $plugin_file => $plugin_data) { 421 427 $actions = array(); 422 $is_active = is_plugin_active($plugin_file); 428 if ( 'advanced' == $context ) { 429 $is_active = true; 430 } else { 431 $is_active = is_plugin_active($plugin_file); 423 432 424 if ( $is_active )425 $actions[] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '">' . __('Deactivate') . '</a>';426 else427 $actions[] = '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin') . '" class="edit">' . __('Activate') . '</a>';433 if ( $is_active ) 434 $actions[] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '">' . __('Deactivate') . '</a>'; 435 else 436 $actions[] = '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin') . '" class="edit">' . __('Activate') . '</a>'; 428 437 429 if ( current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) )430 $actions[] = '<a href="plugin-editor.php?file=' . $plugin_file . '" title="' . __('Open this file in the Plugin Editor') . '" class="edit">' . __('Edit') . '</a>';438 if ( current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) ) 439 $actions[] = '<a href="plugin-editor.php?file=' . $plugin_file . '" title="' . __('Open this file in the Plugin Editor') . '" class="edit">' . __('Edit') . '</a>'; 431 440 432 if ( ! $is_active && current_user_can('delete_plugins') )433 $actions[] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&checked[]=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'bulk-manage-plugins') . '" title="' . __('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>';441 if ( ! $is_active && current_user_can('delete_plugins') ) 442 $actions[] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&checked[]=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'bulk-manage-plugins') . '" title="' . __('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>'; 434 443 435 $actions = apply_filters( 'plugin_action_links', $actions, $plugin_file, $plugin_data, $context ); 436 $actions = apply_filters( "plugin_action_links_$plugin_file", $actions, $plugin_file, $plugin_data, $context ); 444 $actions = apply_filters( 'plugin_action_links', $actions, $plugin_file, $plugin_data, $context ); 445 $actions = apply_filters( "plugin_action_links_$plugin_file", $actions, $plugin_file, $plugin_data, $context ); 446 } 437 447 $action_count = count($actions); 438 448 $class = $is_active ? 'active' : 'inactive'; 439 449 echo " 440 450 <tr class='$class'> 441 <th scope='row' class='check-column'> <input type='checkbox' name='checked[]' value='" . esc_attr($plugin_file) . "' /></th>451 <th scope='row' class='check-column'>" . ( 'advanced' != $context ? "<input type='checkbox' name='checked[]' value='" . esc_attr($plugin_file) . "' />" : '' ) . "</th> 442 452 <td class='plugin-title'><strong>{$plugin_data['Name']}</strong></td> 443 453 <td class='desc'><p>{$plugin_data['Description']}</p></td> 444 454 </tr> … … 546 556 $term = isset($_REQUEST['s']) ? urlencode(stripslashes($_REQUEST['s'])) : ''; 547 557 $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>'; 548 558 } 559 if ( ! empty($advanced_plugins) ) { 560 $class = ( 'advanced' == $status ) ? ' class="current"' : ''; 561 $status_links[] = "<li><a href='plugins.php?plugin_status=advanced' $class>" . sprintf( _n( 'Advanced Plugins <span class="count">(%s)</span>', 'Advanced Plugins <span class="count">(%s)</span>', $total_advanced_plugins ), number_format_i18n( $total_advanced_plugins ) ) . '</a>'; 562 } 549 563 echo implode( " |</li>\n", $status_links ) . '</li>'; 550 564 unset( $status_links ); 551 565 ?> 552 566 </ul> 553 567 <div class="clear"></div> 568 <?php 569 if ( 'advanced' == $status ) { 570 echo '<h3>' . __('Must-Use Plugins') . '</h3>'; 571 echo '<p>' . __('Files in the <code>wp-content/mu-plugins</code> directory are executed automatically.') . '</p>'; 572 } 573 if ( $page_links && 'advanced' != $status ) : ?> 554 574 <div class="tablenav"> 555 <?php 556 if ( $page_links ) 557 echo '<div class="tablenav-pages">', $page_links_text, '</div>'; 558 559 print_plugin_actions($status); 560 ?> 575 <div class="tablenav-pages"><?php $page_links_text; ?></div> 576 <?php print_plugin_actions($status, "action2"); ?> 561 577 </div> 562 578 <div class="clear"></div> 563 <?php 579 <?php endif; 580 564 581 if ( $total_this_page > $plugins_per_page ) 565 582 $plugins = array_slice($plugins, $start, $plugins_per_page); 566 583 567 584 print_plugins_table($plugins, $status); 568 ?> 585 586 if ( $page_links && 'advanced' != $status ) : ?> 569 587 <div class="tablenav"> 570 <?php 571 if ( $page_links ) 572 echo "<div class='tablenav-pages'>$page_links_text</div>"; 573 574 print_plugin_actions($status, "action2"); 575 ?> 588 <div class="tablenav-pages"><?php $page_links_text; ?></div> 589 <?php print_plugin_actions($status, "action2"); ?> 576 590 </div> 591 <?php endif; ?> 577 592 </form> 578 593 579 <?php if ( empty($all_plugins) ) : ?>594 <?php if ( empty($all_plugins) && empty($advanced_plugins) ) : ?> 580 595 <p><?php _e('You do not appear to have any plugins available at this time.') ?></p> 581 596 <?php endif; ?> 582 597 -
wp-admin/includes/plugin.php
Index: wp-admin/includes/plugin.php
251 251 } 252 252 253 253 /** 254 * Check the mu-plugins directory and retrieve all mu-plugin files with any plugin data. 255 * 256 * WordPress only includes mu-plugin files in the base mu-plugins directory (wp-content/mu-plugins). 257 * 258 * @since 3.0.0 259 * @return array Key is the mu-plugin file path and the value is an array of the mu-plugin data. 260 */ 261 function get_mu_plugins() { 262 263 $wp_plugins = array (); 264 // Files in wp-content/mu-plugins directory 265 $plugin_files = array(); 266 267 if ( ! is_dir( WPMU_PLUGIN_DIR ) ) 268 return $wp_plugins; 269 if ( $plugins_dir = @ opendir( WPMU_PLUGIN_DIR ) ) { 270 while ( ( $file = readdir( $plugins_dir ) ) !== false ) { 271 if ( substr( $file, -4 ) == '.php' ) 272 $plugin_files[] = $file; 273 } 274 } 275 276 @closedir( $plugins_dir ); 277 278 if ( !$plugins_dir || empty($plugin_files) ) 279 return $wp_plugins; 280 281 foreach ( $plugin_files as $plugin_file ) { 282 if ( !is_readable( WPMU_PLUGIN_DIR . "/$plugin_file" ) ) 283 continue; 284 285 $plugin_data = get_plugin_data( WPMU_PLUGIN_DIR . "/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached. 286 287 if ( empty ( $plugin_data['Name'] ) ) 288 $plugin_data['Name'] = $plugin_file; 289 290 $wp_plugins[ $plugin_file ] = $plugin_data; 291 } 292 293 if ( isset( $wp_plugins['index.php'] ) && filesize( WPMU_PLUGIN_DIR . '/index.php') <= 30 ) // silence is golden 294 unset( $wp_plugins['index.php'] ); 295 296 uasort( $wp_plugins, create_function( '$a, $b', 'return strnatcasecmp( $a["Name"], $b["Name"] );' )); 297 298 return $wp_plugins; 299 } 300 301 /** 254 302 * Check whether the plugin is active by checking the active_plugins list. 255 303 * 256 304 * @since 2.5.0