diff --git a/wp-includes/load.php b/wp-includes/load.php
index 5489f4a62..a384f1e3d 100644
--- a/wp-includes/load.php
+++ b/wp-includes/load.php
@@ -472,15 +472,6 @@ function wp_get_active_and_valid_plugins() {
$plugins = array();
$active_plugins = (array) get_option( 'active_plugins', array() );
- // Get active network plugins
- if ( is_multisite() ) {
- $active_sitewide_plugins = (array) get_site_option( 'active_sitewide_plugins', array() );
- if ( !empty($active_sitewide_plugins) ) {
- $active_plugins = array_merge( $active_plugins, array_keys( $active_sitewide_plugins ) );
- sort( $active_plugins );
- }
- }
-
// Check for hacks file if the option is enabled
if ( get_option( 'hack_file' ) && file_exists( ABSPATH . 'my-hacks.php' ) ) {
_deprecated_file( 'my-hacks.php', '1.5' );
@@ -490,10 +481,14 @@ function wp_get_active_and_valid_plugins() {
if ( empty( $active_plugins ) || defined( 'WP_INSTALLING' ) )
return $plugins;
+ $network_plugins = is_multisite() ? wp_get_active_network_plugins() : false;
+
foreach ( $active_plugins as $plugin ) {
if ( ! validate_file( $plugin ) // $plugin must validate as file
&& '.php' == substr( $plugin, -4 ) // $plugin must end with '.php'
&& file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist
+ // not already included as a network plugin
+ && ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins ) )
)
$plugins[] = WP_PLUGIN_DIR . '/' . $plugin;
}
diff --git a/wp-includes/ms-load.php b/wp-includes/ms-load.php
index b12f9a537..6eea741a3 100644
--- a/wp-includes/ms-load.php
+++ b/wp-includes/ms-load.php
@@ -25,6 +25,35 @@ function is_subdomain_install() {
return false;
}
+/**
+ * Returns array of network plugin files to be included in global scope.
+ *
+ * The default directory is wp-content/plugins. To change the default directory
+ * manually, define WP_PLUGIN_DIR
and WP_PLUGIN_URL
+ * in wp-config.php.
+ *
+ * @access private
+ * @since 3.1.0
+ * @return array Files to include
+ */
+function wp_get_active_network_plugins() {
+ $active_plugins = (array) get_site_option( 'active_sitewide_plugins', array() );
+ if ( empty( $active_plugins ) )
+ return array();
+
+ $active_plugins = array_keys( $active_plugins );
+ sort( $active_plugins );
+
+ foreach ( $active_plugins as $plugin ) {
+ if ( ! validate_file( $plugin ) // $plugin must validate as file
+ && '.php' == substr( $plugin, -4 ) // $plugin must end with '.php'
+ && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist
+ )
+ $plugins[] = WP_PLUGIN_DIR . '/' . $plugin;
+ }
+ return $plugins;
+}
+
/**
* Checks status of current blog.
*
diff --git a/wp-settings.php b/wp-settings.php
index cb72c0d76..2cd12c1c1 100644
--- a/wp-settings.php
+++ b/wp-settings.php
@@ -155,6 +155,14 @@ foreach ( wp_get_mu_plugins() as $mu_plugin ) {
}
unset( $mu_plugin );
+// Load network activated plugins.
+if ( is_multisite() ) {
+ foreach( wp_get_active_network_plugins() as $network_plugin ) {
+ include_once( $network_plugin );
+ }
+ unset( $network_plugin );
+}
+
do_action( 'muplugins_loaded' );
if ( is_multisite() )