WordPress.org

Make WordPress Core

Ticket #11644: wpmu_sitewide_plugins.2.diff

File wpmu_sitewide_plugins.2.diff, 3.4 KB (added by nacin, 4 years ago)

Removes active_plugins filter from core (added only for MU in r11966) and updates a few places that relied on the filter to be exposed to sitewide plugins. Also adds missing global to upgrade_network() and unless I'm missing something the old options should be deleted, not emptied.

  • wp-admin/includes/plugin.php

     
    259259 * @return bool True, if in the active plugins list. False, not in the list. 
    260260 */ 
    261261function is_plugin_active( $plugin ) { 
    262         return in_array( $plugin, apply_filters( 'active_plugins', get_option( 'active_plugins', array() ) ) ); 
     262        return in_array( $plugin, (array) get_option( 'active_plugins', array() ) || is_plugin_active_for_network( $plugin ); 
    263263} 
    264264 
    265265/** 
     
    270270 * @param string $plugin Base plugin path from plugins directory. 
    271271 * @return bool True, if active for the network, otherwise false. 
    272272 */ 
    273 function is_plugin_active_for_network( $plugin ){ 
     273function is_plugin_active_for_network( $plugin ) { 
    274274        if ( !is_multisite() ) 
    275275                return false; 
    276276 
     
    553553 * @return array invalid plugins, plugin as key, error as value 
    554554 */ 
    555555function validate_active_plugins() { 
    556         $plugins = apply_filters( 'active_plugins', get_option( 'active_plugins', array() ) ); 
     556        $plugins = get_option( 'active_plugins', array() ); 
    557557        // validate vartype: array 
    558558        if ( ! is_array( $plugins ) ) { 
    559559                update_option( 'active_plugins', array() ); 
     
    562562 
    563563        if ( is_multisite() && is_super_admin() ) { 
    564564                $network_plugins = (array) get_site_option( 'active_sitewide_plugins', array() ); 
    565                 $plugins = array_merge( (array) $plugins, $network_plugins ); 
     565                $plugins = array_merge( $plugins, $network_plugins ); 
    566566        } 
    567567 
    568568        if ( empty( $plugins ) ) 
  • wp-admin/includes/upgrade.php

     
    10741074 * @since 3.0.0 
    10751075 */ 
    10761076function upgrade_network() { 
     1077        global $wp_current_db_version; 
    10771078        // 2.8 
    10781079        if ( $wp_current_db_version < 11549 ) { 
    10791080                $wpmu_sitewide_plugins = get_site_option( 'wpmu_sitewide_plugins' ); 
     
    10861087 
    10871088                        update_site_option( 'active_sitewide_plugins', $sitewide_plugins ); 
    10881089                } 
    1089                 update_site_option( 'wpmu_sitewide_plugins', '' ); 
    1090                 update_site_option( 'deactivated_sitewide_plugins', '' ); 
     1090                delete_site_option( 'wpmu_sitewide_plugins' ); 
     1091                delete_site_option( 'deactivated_sitewide_plugins' ); 
    10911092        } 
    10921093} 
    10931094 
  • wp-includes/load.php

     
    403403 */ 
    404404function wp_load_plugins() { 
    405405        $plugins = array(); 
     406        $active_plugins = (array) get_option( 'active_plugins', array() ); 
    406407 
    407         // Check for hacks file if the option is enabled 
    408         if ( get_option( 'hack_file' ) && file_exists( ABSPATH . 'my-hacks.php' ) ) 
    409                         $plugins[] = ABSPATH . 'my-hacks.php'; 
    410  
    411         $active_plugins = (array) apply_filters( 'active_plugins', get_option( 'active_plugins', array() ) ); 
    412  
    413408        // Get active network plugins 
    414409        if ( is_multisite() ) { 
    415410                $active_sitewide_plugins = (array) get_site_option( 'active_sitewide_plugins', array() ); 
     
    419414                } 
    420415        } 
    421416 
     417        // Check for hacks file if the option is enabled 
     418        if ( get_option( 'hack_file' ) && file_exists( ABSPATH . 'my-hacks.php' ) ) { 
     419                _deprecated_file( 'my-hacks.php', '1.5' ); 
     420                array_unshift( $plugins, ABSPATH . 'my-hacks.php' ); 
     421        } 
     422 
    422423        if ( empty( $active_plugins ) || defined( 'WP_INSTALLING' ) ) 
    423424                return $plugins; 
    424425