Make WordPress Core


Ignore:
Timestamp:
10/27/2010 01:20:53 PM (14 years ago)
Author:
scribu
Message:

Pass $network_wide flag to de/activation hooks. See #14170

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/plugin.php

    r15754 r16011  
    465465 */
    466466function activate_plugin( $plugin, $redirect = '', $network_wide = false) {
    467     $plugin  = plugin_basename( trim( $plugin ) );
     467    $plugin = plugin_basename( trim( $plugin ) );
    468468
    469469    if ( is_multisite() && ( $network_wide || is_network_only_plugin($plugin) ) ) {
     
    483483        ob_start();
    484484        include(WP_PLUGIN_DIR . '/' . $plugin);
    485         do_action( 'activate_plugin', trim( $plugin) );
    486         do_action( 'activate_' . trim( $plugin ) );
     485        do_action( 'activate_plugin', $plugin, $network_wide );
     486        do_action( 'activate_' . $plugin, $network_wide );
    487487        if ( $network_wide ) {
    488488            $current[$plugin] = time();
     
    493493            update_option('active_plugins', $current);
    494494        }
    495         do_action( 'activated_plugin', trim( $plugin) );
     495        do_action( 'activated_plugin', $plugin, $network_wide );
    496496        if ( ob_get_length() > 0 ) {
    497497            $output = ob_get_clean();
     
    522522
    523523    foreach ( (array) $plugins as $plugin ) {
    524         $plugin = plugin_basename($plugin);
     524        $plugin = plugin_basename( trim( $plugin ) );
    525525        if ( ! is_plugin_active($plugin) )
    526526            continue;
     527
     528        $network_wide = is_plugin_active_for_network( $plugin );
     529
    527530        if ( ! $silent )
    528             do_action( 'deactivate_plugin', trim( $plugin ) );
    529 
    530         if ( is_plugin_active_for_network($plugin) ) {
    531             // Deactivate network wide
     531            do_action( 'deactivate_plugin', $plugin, $network_wide );
     532
     533        if ( $network_wide ) {
    532534            $do_network = true;
    533535            unset( $network_current[ $plugin ] );
    534536        } else {
    535             // Deactivate for this blog only
    536             $key = array_search( $plugin, (array) $current );
     537            $key = array_search( $plugin, $current );
    537538            if ( false !== $key ) {
    538539                $do_blog = true;
     
    541542        }
    542543
    543         //Used by Plugin updater to internally deactivate plugin, however, not to notify plugins of the fact to prevent plugin output.
    544544        if ( ! $silent ) {
    545             do_action( 'deactivate_' . trim( $plugin ) );
    546             do_action( 'deactivated_plugin', trim( $plugin ) );
     545            do_action( 'deactivate_' . $plugin, $network_wide );
     546            do_action( 'deactivated_plugin', $plugin, $network_wide );
    547547        }
    548548    }
Note: See TracChangeset for help on using the changeset viewer.