WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/30/2010 08:34:54 PM (10 years ago)
Author:
ryan
Message:

Network Admin, first pass. see #14435

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/plugins.php

    r15324 r15481  
    123123            $parent_file = 'plugins.php';
    124124
    125             require_once( './admin-header.php' );
     125            require_once( ABSPATH . 'wp-admin/admin-header.php' );
    126126
    127127            echo '<div class="wrap">';
     
    220220            if ( ! isset($_REQUEST['verify-delete']) ) {
    221221                wp_enqueue_script('jquery');
    222                 require_once('./admin-header.php');
     222                require_once(ABSPATH . 'wp-admin/admin-header.php');
    223223                ?>
    224224            <div class="wrap">
     
    328328$title = __('Plugins');
    329329
    330 require_once('./admin-header.php');
     330require_once(ABSPATH . 'wp-admin/admin-header.php');
    331331
    332332$invalid = validate_active_plugins();
     
    346346    <?php
    347347        if ( !isset($_GET['charsout']) && wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?>
    348     <iframe style="border:0" width="100%" height="70px" src="<?php echo admin_url('plugins.php?action=error_scrape&amp;plugin=' . esc_attr($plugin) . '&amp;_wpnonce=' . esc_attr($_GET['_error_nonce'])); ?>"></iframe>
     348    <iframe style="border:0" width="100%" height="70px" src="<?php echo 'plugins.php?action=error_scrape&amp;plugin=' . esc_attr($plugin) . '&amp;_wpnonce=' . esc_attr($_GET['_error_nonce']); ?>"></iframe>
    349349    <?php
    350350        }
     
    385385$recently_activated = get_option('recently_activated', array());
    386386$upgrade_plugins = array();
    387 $network_plugins = array();
    388387$mustuse_plugins = $dropins_plugins = array();
    389 if ( ! is_multisite() || current_user_can('manage_network_plugins') ) {
     388if ( ! is_multisite() || ( is_network_admin() && current_user_can('manage_network_plugins') ) ) {
    390389    if ( apply_filters( 'show_advanced_plugins', true, 'mustuse' ) )
    391390        $mustuse_plugins = get_mu_plugins();
     
    414413
    415414foreach ( (array) $all_plugins as $plugin_file => $plugin_data) {
     415    if ( is_network_admin() )
     416        $is_active = is_plugin_active_for_network($plugin_file);
     417    else
     418        $is_active = is_plugin_active($plugin_file);
    416419    // Filter into individual sections
    417     if ( is_multisite() && is_network_only_plugin( $plugin_file ) && !current_user_can( 'manage_network_plugins' ) ) {
     420    if ( is_plugin_active_for_network($plugin_file) && !is_network_admin() ) {
    418421        unset( $all_plugins[ $plugin_file ] );
    419422        continue;
    420     } elseif ( is_plugin_active_for_network($plugin_file) ) {
    421         $network_plugins[ $plugin_file ] = $plugin_data;
    422     } elseif ( is_plugin_active($plugin_file) ) {
     423    } elseif ( is_multisite() && is_network_only_plugin( $plugin_file ) && !current_user_can( 'manage_network_plugins' ) ) {
     424        unset( $all_plugins[ $plugin_file ] );
     425        continue;
     426    } elseif ( $is_active ) {
    423427        $active_plugins[ $plugin_file ] = $plugin_data;
    424428    } else {
    425         if ( isset( $recently_activated[ $plugin_file ] ) ) // Was the plugin recently activated?
     429        if ( !is_network_admin() && isset( $recently_activated[ $plugin_file ] ) ) // Was the plugin recently activated?
    426430            $recent_plugins[ $plugin_file ] = $plugin_data;
    427431        $inactive_plugins[ $plugin_file ] = $plugin_data;
     
    440444$total_recent_plugins = count($recent_plugins);
    441445$total_upgrade_plugins = count($upgrade_plugins);
    442 $total_network_plugins = count($network_plugins);
    443446$total_mustuse_plugins = count($mustuse_plugins);
    444447$total_dropins_plugins = count($dropins_plugins);
     
    544547
    545548        if ( 'mustuse' == $context ) {
     549            if ( is_multisite() && !is_network_admin() )
     550                continue;
    546551            $is_active = true;
    547552        } elseif ( 'dropins' == $context ) {
     553            if ( is_multisite() && !is_network_admin() )
     554                continue;
    548555            $dropins = _get_dropins();
    549556            $plugin_name = $plugin_file;
     
    564571        } else {
    565572            $is_active_for_network = is_plugin_active_for_network($plugin_file);
    566             $is_active = $is_active_for_network || is_plugin_active( $plugin_file );
    567             if ( $is_active_for_network && !is_super_admin() )
     573            if ( is_network_admin() )
     574                $is_active = $is_active_for_network;
     575            else
     576                $is_active = is_plugin_active( $plugin_file );
     577
     578            if ( $is_active_for_network && !is_super_admin() && !is_network_admin() )
    568579                continue;
    569580
    570             if ( $is_active ) {
     581            if ( is_network_admin() ) {
    571582                if ( $is_active_for_network ) {
    572                     if ( is_super_admin() )
     583                    if ( current_user_can( 'manage_network_plugins' ) )
    573584                        $actions['network_deactivate'] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&amp;networkwide=1&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '">' . __('Network Deactivate') . '</a>';
    574585                } else {
    575                     $actions['deactivate'] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '">' . __('Deactivate') . '</a>';
     586                    if ( current_user_can( 'manage_network_plugins' ) )
     587                        $actions['network_activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;networkwide=1&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin for all sites in this network') . '" class="edit">' . __('Network Activate') . '</a>';
     588                    if ( current_user_can('delete_plugins') )
     589                        $actions['delete'] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&amp;checked[]=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page, 'bulk-manage-plugins') . '" title="' . __('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>';
    576590                }
    577591            } else {
    578                 if ( is_multisite() && is_network_only_plugin( $plugin_file ) )
    579                     $actions['network_only'] = '<span title="' . __('This plugin can only be activated for all sites in a network') . '">' . __('Network Only') . '</span>';
    580                 else
     592                if ( $is_active ) {
     593                    $actions['deactivate'] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '">' . __('Deactivate') . '</a>';
     594                } else {
     595                    if ( is_network_only_plugin( $plugin_file ) && !is_network_admin() )
     596                        continue;
     597
    581598                    $actions['activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin') . '" class="edit">' . __('Activate') . '</a>';
    582599
    583                 if ( is_multisite() && current_user_can( 'manage_network_plugins' ) )
    584                     $actions['network_activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;networkwide=1&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin for all sites in this network') . '" class="edit">' . __('Network Activate') . '</a>';
    585 
    586                 if ( current_user_can('delete_plugins') )
    587                     $actions['delete'] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&amp;checked[]=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page, 'bulk-manage-plugins') . '" title="' . __('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>';
    588             } // end if $is_active
     600                    if ( current_user_can('delete_plugins') )
     601                        $actions['delete'] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&amp;checked[]=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page, 'bulk-manage-plugins') . '" title="' . __('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>';
     602                } // end if $is_active
     603             } // end if is_network_admin()
    589604
    590605            if ( current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) )
     
    690705<?php do_action( 'pre_current_active_plugins', $all_plugins ) ?>
    691706
    692 <form method="post" action="<?php echo admin_url('plugins.php') ?>">
     707<form method="post" action="plugins.php">
    693708<?php wp_nonce_field('bulk-manage-plugins') ?>
    694709<input type="hidden" name="plugin_status" value="<?php echo esc_attr($status) ?>" />
     
    784799
    785800<?php
    786 include('./admin-footer.php');
    787 ?>
     801include(ABSPATH . 'wp-admin/admin-footer.php');
     802?>
Note: See TracChangeset for help on using the changeset viewer.