Make WordPress Core

Ticket #14718: 14718.2.diff

File 14718.2.diff, 2.9 KB (added by nacin, 14 years ago)
  • wp-includes/load.php

     
    458458}
    459459
    460460/**
     461 * Returns array of network plugin files to be included in global scope.
     462 *
     463 * The default directory is wp-content/plugins. To change the default directory
     464 * manually, define <code>WP_PLUGIN_DIR</code> and <code>WP_PLUGIN_URL</code>
     465 * in wp-config.php.
     466 *
     467 * @access private
     468 * @since 3.1.0
     469 * @return array Files to include
     470 */
     471function wp_get_active_network_plugins() {
     472        if ( ! is_multisite() )
     473                return array();
     474
     475        $active_plugins = (array) get_site_option( 'active_sitewide_plugins', array() );
     476        if ( empty( $active_plugins ) )
     477                return array();
     478
     479        $active_plugins = array_keys( $active_plugins );
     480        sort( $active_plugins );
     481
     482        foreach ( $active_plugins as $plugin ) {
     483                if ( ! validate_file( $plugin ) // $plugin must validate as file
     484                        && '.php' == substr( $plugin, -4 ) // $plugin must end with '.php'
     485                        && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist
     486                        )
     487                $plugins[] = WP_PLUGIN_DIR . '/' . $plugin;
     488        }
     489        return $plugins;
     490}
     491
     492/**
    461493 * Returns array of plugin files to be included in global scope.
    462494 *
    463495 * The default directory is wp-content/plugins. To change the default directory
     
    472504        $plugins = array();
    473505        $active_plugins = (array) get_option( 'active_plugins', array() );
    474506
    475         // Get active network plugins
    476         if ( is_multisite() ) {
    477                 $active_sitewide_plugins = (array) get_site_option( 'active_sitewide_plugins', array() );
    478                 if ( !empty($active_sitewide_plugins) ) {
    479                         $active_plugins = array_merge( $active_plugins, array_keys( $active_sitewide_plugins ) );
    480                         sort( $active_plugins );
    481                 }
    482         }
    483 
    484507        // Check for hacks file if the option is enabled
    485508        if ( get_option( 'hack_file' ) && file_exists( ABSPATH . 'my-hacks.php' ) ) {
    486509                _deprecated_file( 'my-hacks.php', '1.5' );
     
    490513        if ( empty( $active_plugins ) || defined( 'WP_INSTALLING' ) )
    491514                return $plugins;
    492515
     516        $network_plugins = wp_get_active_network_plugins();
     517
    493518        foreach ( $active_plugins as $plugin ) {
    494519                if ( ! validate_file( $plugin ) // $plugin must validate as file
    495520                        && '.php' == substr( $plugin, -4 ) // $plugin must end with '.php'
    496521                        && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist
     522                        // not already included as a network plugin
     523                        && ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins )
    497524                        )
    498525                $plugins[] = WP_PLUGIN_DIR . '/' . $plugin;
    499526        }
  • wp-settings.php

     
    152152}
    153153unset( $mu_plugin );
    154154
     155foreach( wp_get_active_network_plugins() as $network_plugin ) {
     156        include_once( $network_plugin );
     157}
     158unset( $network_plugin );
     159
    155160do_action( 'muplugins_loaded' );
    156161
    157162if ( is_multisite() )