WordPress.org

Make WordPress Core


Ignore:
Timestamp:
04/19/2012 03:41:29 AM (10 years ago)
Author:
nacin
Message:

Clean up plugins.php with regards to recently edited files, deactivations, and the network admin. see #20468, #20104.

  • Limit recently_activated to the site dashboard, and properly remove bulk-activated plugins from the array.
  • Remove code used from before the network admin, such as the unused 'network' plugin_status.
  • Don't try to deactivate a plugin already deactivated.
  • Use more specific caps (manage_network_plugins) rather than is_super_admin().
File:
1 edited

Legend:

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

    r20229 r20525  
    573573 *
    574574 * @param string|array $plugins Single plugin or list of plugins to deactivate.
     575 * @param mixed $network_wide Whether to deactivate the plugin for all sites in the network.
     576 *  A value of null (the default) will deactivate plugins for both the site and the network.
    575577 * @param bool $silent Prevent calling deactivation hooks. Default is false.
    576578 */
    577 function deactivate_plugins( $plugins, $silent = false ) {
     579function deactivate_plugins( $plugins, $silent = false, $network_wide = null ) {
    578580    if ( is_multisite() )
    579581        $network_current = get_site_option( 'active_sitewide_plugins', array() );
     
    586588            continue;
    587589
    588         $network_wide = is_plugin_active_for_network( $plugin );
     590        $network_deactivating = false !== $network_wide && is_plugin_active_for_network( $plugin );
    589591
    590592        if ( ! $silent )
    591             do_action( 'deactivate_plugin', $plugin, $network_wide );
    592 
    593         if ( $network_wide ) {
     593            do_action( 'deactivate_plugin', $plugin, $network_deactivating );
     594
     595        if ( false !== $network_wide ) {
     596            if ( ! is_plugin_active_for_network( $plugin ) )
     597                continue;
    594598            $do_network = true;
    595599            unset( $network_current[ $plugin ] );
    596         } else {
     600        }
     601
     602        if ( true !== $network_wide ) {
    597603            $key = array_search( $plugin, $current );
    598604            if ( false !== $key ) {
     
    603609
    604610        if ( ! $silent ) {
    605             do_action( 'deactivate_' . $plugin, $network_wide );
    606             do_action( 'deactivated_plugin', $plugin, $network_wide );
     611            do_action( 'deactivate_' . $plugin, $network_deactivating );
     612            do_action( 'deactivated_plugin', $plugin, $network_deactivating );
    607613        }
    608614    }
Note: See TracChangeset for help on using the changeset viewer.