Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-plugins-list-table.php

    r18811 r20853  
    1414
    1515                $status = 'all';
    16                 if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'active', 'inactive', 'recently_activated', 'upgrade', 'network', 'mustuse', 'dropins', 'search' ) ) )
     16                if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search' ) ) )
    1717                        $status = $_REQUEST['plugin_status'];
    1818
    … …  
    6666                                $plugins['dropins'] = get_dropins();
    6767
    68                         $current = get_site_transient( 'update_plugins' );
    69                         foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) {
    70                                 if ( isset( $current->response[ $plugin_file ] ) )
    71                                         $plugins['upgrade'][ $plugin_file ] = $plugin_data;
     68                        if ( current_user_can( 'update_plugins' ) ) {
     69                                $current = get_site_transient( 'update_plugins' );
     70                                foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) {
     71                                        if ( isset( $current->response[ $plugin_file ] ) ) {
     72                                                $plugins['all'][ $plugin_file ]['update'] = true;
     73                                                $plugins['upgrade'][ $plugin_file ] = $plugins['all'][ $plugin_file ];
     74                                        }
     75                                }
    7276                        }
    7377                }
    … …  
    7579                set_transient( 'plugin_slugs', array_keys( $plugins['all'] ), 86400 );
    7680
    77                 $recently_activated = get_option( 'recently_activated', array() );
    78 
    79                 $one_week = 7*24*60*60;
    80                 foreach ( $recently_activated as $key => $time )
    81                         if ( $time + $one_week < time() )
    82                                 unset( $recently_activated[$key] );
    83                 update_option( 'recently_activated', $recently_activated );
     81                if ( ! $screen->is_network ) {
     82                        $recently_activated = get_option( 'recently_activated', array() );
     83
     84                        $one_week = 7*24*60*60;
     85                        foreach ( $recently_activated as $key => $time )
     86                                if ( $time + $one_week < time() )
     87                                        unset( $recently_activated[$key] );
     88                        update_option( 'recently_activated', $recently_activated );
     89                }
    8490
    8591                foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) {
    8692                        // Filter into individual sections
    87                         if ( is_multisite() && is_network_only_plugin( $plugin_file ) && !$screen->is_network ) {
    88                                 unset( $plugins['all'][ $plugin_file] );
    89                         } elseif ( is_plugin_active_for_network($plugin_file) && !$screen->is_network ) {
     93                        if ( ! $screen->is_network && is_plugin_active_for_network( $plugin_file ) ) {
    9094                                unset( $plugins['all'][ $plugin_file ] );
    91                         } elseif ( is_multisite() && is_network_only_plugin( $plugin_file ) && !current_user_can( 'manage_network_plugins' ) ) {
    92                                 $plugins['network'][ $plugin_file ] = $plugin_data;
    93                         } elseif ( ( !$screen->is_network && is_plugin_active( $plugin_file ) )
     95                        } elseif ( ( ! $screen->is_network && is_plugin_active( $plugin_file ) )
    9496                                || ( $screen->is_network && is_plugin_active_for_network( $plugin_file ) ) ) {
    9597                                $plugins['active'][ $plugin_file ] = $plugin_data;
    … …  
    101103                }
    102104
    103                 if ( !current_user_can( 'update_plugins' ) )
    104                         $plugins['upgrade'] = array();
    105 
    106105                if ( $s ) {
    107106                        $status = 'search';
    … …  
    214213                                case 'inactive':
    215214                                        $text = _n( 'Inactive <span class="count">(%s)</span>', 'Inactive <span class="count">(%s)</span>', $count );
    216                                         break;
    217                                 case 'network':
    218                                         $text = _n( 'Network <span class="count">(%s)</span>', 'Network <span class="count">(%s)</span>', $count );
    219215                                        break;
    220216                                case 'mustuse':
    … …  
    248244                $screen = get_current_screen();
    249245
    250                 if ( 'active' != $status ) {
    251                         $action = $screen->is_network ? 'network-activate-selected' : 'activate-selected';
    252                         $actions[ $action ] = __( 'Activate' );
    253                 }
     246                if ( 'active' != $status )
     247                        $actions['activate-selected'] = $screen->is_network ? __( 'Network Activate' ) : __( 'Activate' );
    254248
    255249                if ( 'inactive' != $status && 'recent' != $status )
    256                         $actions['deactivate-selected'] = __( 'Deactivate' );
     250                        $actions['deactivate-selected'] = $screen->is_network ? __( 'Network Deactivate' ) : __( 'Deactivate' );
    257251
    258252                if ( !is_multisite() || $screen->is_network ) {
    … …  
    283277                echo '<div class="alignleft actions">';
    284278
    285                 if ( 'recently_activated' == $status )
     279                $screen = get_current_screen();
     280
     281                if ( ! $screen->is_network && 'recently_activated' == $status )
    286282                        submit_button( __( 'Clear List' ), 'secondary', 'clear-recent-list', false );
    287283                elseif ( 'top' == $which && 'mustuse' == $status )
    … …  
    313309
    314310        function single_row( $plugin_file, $plugin_data ) {
    315                 global $status, $page, $s;
     311                global $status, $page, $s, $totals;
    316312
    317313                $context = $status;
    … …  
    321317                // preorder
    322318                $actions = array(
    323                         'network_deactivate' => '', 'deactivate' => '',
    324                         'network_only' => '', 'activate' => '',
    325                         'network_activate' => '',
     319                        'deactivate' => '',
     320                        'activate' => '',
    326321                        'edit' => '',
    327322                        'delete' => '',
    … …  
    348343                                $description .= '<p>' . $plugin_data['Description'] . '</p>';
    349344                } else {
    350                         $is_active_for_network = is_plugin_active_for_network($plugin_file);
    351345                        if ( $screen->is_network )
    352                                 $is_active = $is_active_for_network;
     346                                $is_active = is_plugin_active_for_network( $plugin_file );
    353347                        else
    354348                                $is_active = is_plugin_active( $plugin_file );
    355349
    356                         if ( $is_active_for_network && !is_super_admin() && !$screen->is_network )
    357                                 return;
    358 
    359350                        if ( $screen->is_network ) {
    360                                 if ( $is_active_for_network ) {
     351                                if ( $is_active ) {
    361352                                        if ( current_user_can( 'manage_network_plugins' ) )
    362                                                 $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 . '&amp;s=' . $s, 'deactivate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Deactivate this plugin') . '">' . __('Network Deactivate') . '</a>';
     353                                                $actions['deactivate'] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'deactivate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Deactivate this plugin') . '">' . __('Network Deactivate') . '</a>';
    363354                                } else {
    364355                                        if ( current_user_can( 'manage_network_plugins' ) )
    365                                                 $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 . '&amp;s=' . $s, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin for all sites in this network') . '" class="edit">' . __('Network Activate') . '</a>';
     356                                                $actions['activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin for all sites in this network') . '" class="edit">' . __('Network Activate') . '</a>';
    366357                                        if ( current_user_can( 'delete_plugins' ) && ! is_plugin_active( $plugin_file ) )
    367358                                                $actions['delete'] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&amp;checked[]=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'bulk-plugins') . '" title="' . esc_attr__('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>';
    … …  
    395386
    396387                $id = sanitize_title( $plugin_name );
     388                if ( ! empty( $totals['upgrade'] ) && ! empty( $plugin_data['update'] ) )
     389                        $class .= ' update';
    397390
    398391                echo "<tr id='$id' class='$class'>";
    … …  
    449442        }
    450443}
    451 
    452 ?>
Note: See TracChangeset for help on using the changeset viewer.