Ticket #20241: allow_plugin_to_register_other_plugins.patch

File allow_plugin_to_register_other_plugins.patch, 1.9 KB (added by magnus78, 14 months ago)

proposed fix

  • wp-admin/includes/plugin.php

     
    522522                        do_action( 'activate_plugin', $plugin, $network_wide ); 
    523523                        do_action( 'activate_' . $plugin, $network_wide ); 
    524524                } 
     525                 
     526                // Check active_plugins again - the activated plugin may have activated 
     527                // other plugins during activation. 
     528                $current = get_option( 'active_plugins', array() ); 
    525529 
    526530                if ( $network_wide ) { 
    527531                        $current[$plugin] = time(); 
     
    560564function deactivate_plugins( $plugins, $silent = false ) { 
    561565        if ( is_multisite() ) 
    562566                $network_current = get_site_option( 'active_sitewide_plugins', array() ); 
    563         $current = get_option( 'active_plugins', array() ); 
    564567        $do_blog = $do_network = false; 
    565568 
    566569        foreach ( (array) $plugins as $plugin ) { 
     
    573576                if ( ! $silent ) 
    574577                        do_action( 'deactivate_plugin', $plugin, $network_wide ); 
    575578 
     579                if ( ! $silent ) { 
     580                        do_action( 'deactivate_' . $plugin, $network_wide ); 
     581                        do_action( 'deactivated_plugin', $plugin, $network_wide ); 
     582                } 
     583                 
     584                // Check active_plugins now, not earlier - the activated plugin may have  
     585                // deactivated other plugins during deactivation. 
     586                $current = get_option( 'active_plugins', array() ); 
     587 
    576588                if ( $network_wide ) { 
    577589                        $do_network = true; 
    578590                        unset( $network_current[ $plugin ] ); 
     
    583595                                array_splice( $current, $key, 1 ); 
    584596                        } 
    585597                } 
    586  
    587                 if ( ! $silent ) { 
    588                         do_action( 'deactivate_' . $plugin, $network_wide ); 
    589                         do_action( 'deactivated_plugin', $plugin, $network_wide ); 
    590                 } 
     598                 
     599                if ( $do_blog ) 
     600                  update_option('active_plugins', $current); 
     601                if ( $do_network ) 
     602                  update_site_option( 'active_sitewide_plugins', $network_current ); 
    591603        } 
    592  
    593         if ( $do_blog ) 
    594                 update_option('active_plugins', $current); 
    595         if ( $do_network ) 
    596                 update_site_option( 'active_sitewide_plugins', $network_current ); 
    597604} 
    598605 
    599606/**