Changeset 13233 for trunk/wp-admin/plugins.php
- Timestamp:
- 02/19/2010 09:16:14 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/plugins.php
r13167 r13233 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', 'network', ' search')) )30 if ( !in_array($status, array('all', 'active', 'inactive', 'recent', 'upgrade', 'network', 'mustuse', 'dropins', 'search')) ) 31 31 $status = 'all'; 32 32 if ( $status != $default_status && 'search' != $status ) … … 366 366 $upgrade_plugins = array(); 367 367 $network_plugins = array(); 368 $mustuse_plugins = get_mu_plugins(); 369 $dropins_plugins = get_dropins(); 368 370 369 371 set_transient( 'plugin_slugs', array_keys($all_plugins), 86400 ); … … 377 379 $current = get_site_transient( 'update_plugins' ); 378 380 379 foreach ( (array)$all_plugins as $plugin_file => $plugin_data) { 380 381 // Translate, Apply Markup, Sanitize HTML 382 $plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true); 383 $all_plugins[ $plugin_file ] = $plugin_data; 384 381 foreach ( array( 'all_plugins', 'mustuse_plugins', 'dropins_plugins' ) as $plugin_array_name) { 382 foreach ( (array) $$plugin_array_name as $plugin_file => $plugin_data ) { 383 // Translate, Apply Markup, Sanitize HTML 384 $plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true); 385 $$plugin_array_name[ $plugin_file ] = $plugin_data; 386 } 387 } 388 unset( $plugin_array_name ); 389 390 foreach ( (array) $all_plugins as $plugin_file => $plugin_data) { 385 391 // Filter into individual sections 386 392 if ( is_plugin_active_for_network($plugin_file) && is_super_admin() ) { … … 407 413 $total_upgrade_plugins = count($upgrade_plugins); 408 414 $total_network_plugins = count($network_plugins); 415 $total_mustuse_plugins = count($mustuse_plugins); 416 $total_dropins_plugins = count($dropins_plugins); 409 417 410 418 //Searching. … … 470 478 function print_plugins_table($plugins, $context = '') { 471 479 global $page; 480 $checkbox = ! in_array( $context, array( 'mustuse', 'dropins' ) ) ? '<input type="checkbox" />' : ''; 472 481 ?> 473 482 <table class="widefat" cellspacing="0" id="<?php echo $context ?>-plugins-table"> 474 483 <thead> 475 484 <tr> 476 <th scope="col" class="manage-column check-column">< input type="checkbox" /></th>485 <th scope="col" class="manage-column check-column"><?php echo $checkbox; ?></th> 477 486 <th scope="col" class="manage-column"><?php _e('Plugin'); ?></th> 478 487 <th scope="col" class="manage-column"><?php _e('Description'); ?></th> … … 482 491 <tfoot> 483 492 <tr> 484 <th scope="col" class="manage-column check-column">< input type="checkbox" /></th>493 <th scope="col" class="manage-column check-column"><?php echo $checkbox; ?></th> 485 494 <th scope="col" class="manage-column"><?php _e('Plugin'); ?></th> 486 495 <th scope="col" class="manage-column"><?php _e('Description'); ?></th> … … 498 507 foreach ( (array)$plugins as $plugin_file => $plugin_data) { 499 508 $actions = array(); 500 $is_active_for_network = is_plugin_active_for_network($plugin_file); 501 $is_active = $is_active_for_network || is_plugin_active( $plugin_file ); 502 503 if ( $is_active_for_network && !is_super_admin() ) 504 continue; 505 506 if ( $is_active ) { 507 if ( $is_active_for_network ) { 508 if ( is_super_admin() ) 509 $actions[] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&networkwide=1&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '">' . __('Network Deactivate') . '</a>'; 509 if ( 'mustuse' == $context ) { 510 $is_active = true; 511 } elseif ( 'dropins' == $context ) { 512 $dropins = _get_dropins(); 513 $plugin_name = $plugin_file; 514 if ( $plugin_file != $plugin_data['Name'] ) 515 $plugin_name .= '<br/>' . $plugin_data['Name']; 516 if ( true === ( $dropins[ $plugin_file ][1] ) ) { // Doesn't require a constant 517 $is_active = true; 518 $description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>'; 519 } elseif ( constant( $dropins[ $plugin_file ][1] ) ) { // Constant is true 520 $is_active = true; 521 $description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>'; 510 522 } else { 511 $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>'; 512 } 523 $is_active = false; 524 $description = '<strong>' . $dropins[ $plugin_file ][0] . ' <span class="attention">' . __('Inactive:') . '</span></strong> ' . sprintf( __( 'Requires <code>%s</code> in <code>wp-config.php</code>.' ), "define('" . $dropins[ $plugin_file ][1] . "', true);" ) . '</p>'; 525 } 526 $description .= '<p>' . $plugin_data['Description'] . '</p>'; 513 527 } else { 528 $is_active_for_network = is_plugin_active_for_network($plugin_file); 529 $is_active = $is_active_for_network || is_plugin_active( $plugin_file ); 530 if ( $is_active_for_network && !is_super_admin() ) 531 continue; 532 533 if ( $is_active ) { 534 if ( $is_active_for_network ) { 535 if ( is_super_admin() ) 536 $actions[] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&networkwide=1&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '">' . __('Network Deactivate') . '</a>'; 537 } else { 538 $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>'; 539 } 540 } else { 541 $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>'; 542 if ( is_multisite() && is_super_admin() ) 543 $actions[] = '<a href="' . wp_nonce_url('plugins.php?action=activate&networkwide=1&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin for all sites in this network') . '" class="edit">' . __('Network Activate') . '</a>'; 544 } 545 514 546 if ( is_multisite() && is_network_only_plugin( $plugin_file ) ) 515 547 $actions[] = '<span title="' . __('This plugin can only be activated for all sites in a network') . '">' . __('Network Only') . '</span>'; … … 518 550 if ( is_multisite() && is_super_admin() ) 519 551 $actions[] = '<a href="' . wp_nonce_url('plugins.php?action=activate&networkwide=1&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin for all sites in this network') . '" class="edit">' . __('Network Activate') . '</a>'; 552 553 if ( !is_multisite() && current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) ) 554 $actions[] = '<a href="plugin-editor.php?file=' . $plugin_file . '" title="' . __('Open this file in the Plugin Editor') . '" class="edit">' . __('Edit') . '</a>'; 555 556 if ( ! $is_active && current_user_can('delete_plugins') ) 557 $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>'; 558 520 559 } 521 522 if ( !is_multisite() && current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) )523 $actions[] = '<a href="plugin-editor.php?file=' . $plugin_file . '" title="' . __('Open this file in the Plugin Editor') . '" class="edit">' . __('Edit') . '</a>';524 525 if ( ! $is_active && current_user_can('delete_plugins') )526 $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>';527 560 528 561 $actions = apply_filters( 'plugin_action_links', $actions, $plugin_file, $plugin_data, $context ); 529 562 $actions = apply_filters( "plugin_action_links_$plugin_file", $actions, $plugin_file, $plugin_data, $context ); 530 $action_count = count($actions); 563 531 564 $class = $is_active ? 'active' : 'inactive'; 565 $checkbox = in_array( $context, array( 'mustuse', 'dropins' ) ) ? '' : "<input type='checkbox' name='checked[]' value='" . esc_attr($plugin_file) . "' />"; 566 if ( 'dropins' != $context ) { 567 $description = '<p>' . $plugin_data['Description'] . '</p>'; 568 $plugin_name = $plugin_data['Name']; 569 } 532 570 echo " 533 571 <tr class='$class'> 534 <th scope='row' class='check-column'> <input type='checkbox' name='checked[]' value='" . esc_attr($plugin_file) . "' /></th>535 <td class='plugin-title'><strong> {$plugin_data['Name']}</strong></td>536 <td class='desc'> <p>{$plugin_data['Description']}</p></td>572 <th scope='row' class='check-column'>$checkbox</th> 573 <td class='plugin-title'><strong>$plugin_name</strong></td> 574 <td class='desc'>$description</td> 537 575 </tr> 538 576 <tr class='$class second'> … … 578 616 */ 579 617 function print_plugin_actions($context, $field_name = 'action' ) { 618 if ( in_array( $context, array( 'mustuse', 'dropins' ) ) ) 619 return; 580 620 ?> 581 621 <div class="alignleft actions"> … … 643 683 $status_links[] = "<li><a href='plugins.php?plugin_status=network' $class>" . sprintf( _n( 'Network <span class="count">(%s)</span>', 'Network <span class="count">(%s)</span>', $total_network_plugins ), number_format_i18n( $total_network_plugins ) ) . '</a>'; 644 684 } 685 if ( ! empty($mustuse_plugins) ) { 686 $class = ( 'mustuse' == $status ) ? ' class="current"' : ''; 687 $status_links[] = "<li><a href='plugins.php?plugin_status=mustuse' $class>" . sprintf( _n( 'Must-Use <span class="count">(%s)</span>', 'Must-Use <span class="count">(%s)</span>', $total_mustuse_plugins ), number_format_i18n( $total_mustuse_plugins ) ) . '</a>'; 688 } 689 if ( ! empty($dropins_plugins) ) { 690 $class = ( 'dropins' == $status ) ? ' class="current"' : ''; 691 $status_links[] = "<li><a href='plugins.php?plugin_status=dropins' $class>" . sprintf( _n( 'Drop-ins <span class="count">(%s)</span>', 'Drop-ins <span class="count">(%s)</span>', $total_dropins_plugins ), number_format_i18n( $total_dropins_plugins ) ) . '</a>'; 692 } 645 693 if ( ! empty($upgrade_plugins) ) { 646 694 $class = ( 'upgrade' == $status ) ? ' class="current"' : ''; … … 657 705 </ul> 658 706 659 <?php if ( ! empty( $plugins ) ) { ?> 660 707 <?php 708 if ( 'mustuse' == $status ) 709 echo '<div class="clear"><p>' . __( 'Files in the <code>wp-content/mu-plugins</code> directory are executed automatically.' ) . '</p>'; 710 elseif ( 'dropins' == $status ) 711 echo '<div class="clear"><p>' . __( 'Drop-ins are advanced plugins in the <code>wp-content</code> directory that replace WordPress functionality when present.' ) . '</p>'; 712 713 if ( !empty( $plugins ) && ( ! in_array( $status, array( 'mustuse', 'dropins' ) ) || $page_links ) ) : 714 ?> 661 715 <div class="tablenav"> 662 716 <?php … … 669 723 <div class="clear"></div> 670 724 <?php 671 if ( $total_this_page > $plugins_per_page ) 672 $plugins = array_slice($plugins, $start, $plugins_per_page); 673 674 print_plugins_table($plugins, $status); 725 endif; 726 727 if ( $total_this_page > $plugins_per_page ) 728 $plugins = array_slice($plugins, $start, $plugins_per_page); 729 730 print_plugins_table($plugins, $status); 731 732 if ( !empty( $plugins ) && ! in_array( $status, array( 'mustuse', 'dropins' ) ) || $page_links ) { 675 733 ?> 676 734 <div class="tablenav">
Note: See TracChangeset
for help on using the changeset viewer.