From af8f9bf98dac7143940de5240e1f9147479f7689 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 24 Nov 2010 00:19:38 +0000 Subject: [PATCH] Load network plugins for wp-activate.php. Restore MU load order. Props blamenacin. fixes #14718 git-svn-id: https://develop.svn.wordpress.org/trunk@16558 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/load.php | 13 ++++--------- wp-includes/ms-load.php | 29 +++++++++++++++++++++++++++++ wp-settings.php | 8 ++++++++ 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/wp-includes/load.php b/wp-includes/load.php index 5489f4a62f..a384f1e3de 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 b12f9a5374..6eea741a34 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 cb72c0d76a..2cd12c1c12 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() )