WordPress.org

Make WordPress Core

Ticket #10839: active_plugins_filtering.diff

File active_plugins_filtering.diff, 1.8 KB (added by apeatling, 5 years ago)
  • wp-settings.php

     
    552552                require(ABSPATH . 'my-hacks.php'); 
    553553} 
    554554 
    555 $current_plugins = get_option('active_plugins'); 
     555$current_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) ); 
    556556if ( is_array($current_plugins) && !defined('WP_INSTALLING') ) { 
    557557        foreach ( $current_plugins as $plugin ) { 
    558558                // check the $plugin filename 
  • wp-admin/includes/plugin.php

     
    272272 * @return bool True, if in the active plugins list. False, not in the list. 
    273273 */ 
    274274function is_plugin_active($plugin) { 
    275         return in_array($plugin, get_option('active_plugins')); 
     275        return in_array( $plugin, apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ); 
    276276} 
    277277 
    278278/** 
     
    347347                        continue; 
    348348                if ( ! $silent ) 
    349349                        do_action( 'deactivate_plugin', trim( $plugin ) ); 
    350                 array_splice($current, array_search( $plugin, $current), 1 ); // Fixed Array-fu! 
     350                         
     351                $key = array_search( $plugin, (array) $current ); 
     352                 
     353                if ( false !== $key ) 
     354                        array_splice( $current, $key, 1 ); 
     355                         
    351356                //Used by Plugin updater to internally deactivate plugin, however, not to notify plugins of the fact to prevent plugin output. 
    352357                if ( ! $silent ) { 
    353358                        do_action( 'deactivate_' . trim( $plugin ) ); 
     
    484489} 
    485490 
    486491function validate_active_plugins() { 
    487         $check_plugins = get_option('active_plugins'); 
     492        $check_plugins = apply_filters( 'active_plugins', get_option('active_plugins') );  
    488493 
    489494        // Sanity check.  If the active plugin list is not an array, make it an 
    490495        // empty array.