Ticket #11644: wpmu_sitewide_plugins.diff
File wpmu_sitewide_plugins.diff, 5.5 KB (added by , 11 years ago) |
---|
-
wp-admin/includes/plugin.php
544 544 } 545 545 546 546 /** 547 * validate active plugins547 * Validate active plugins 548 548 * 549 * validate all active plugins, deactivates invalid and550 * returns an array of deactiv ed ones.549 * Validate all active plugins, deactivates invalid and 550 * returns an array of deactivated ones. 551 551 * 552 552 * @since unknown 553 553 * @return array invalid plugins, plugin as key, error as value 554 554 */ 555 555 function validate_active_plugins() { 556 556 $plugins = apply_filters( 'active_plugins', get_option( 'active_plugins', array() ) ); 557 558 557 // validate vartype: array 559 if ( ! is_array( $plugins ) ) {560 update_option( 'active_plugins', array());561 return;558 if ( ! is_array( $plugins ) ) { 559 update_option( 'active_plugins', array() ); 560 $plugins = array(); 562 561 } 563 562 563 if ( is_multisite() && is_super_admin() ) { 564 $network_plugins = (array) get_site_option( 'active_sitewide_plugins', array() ); 565 $plugins = array_merge( (array) $plugins, $network_plugins ); 566 } 567 568 if ( empty( $plugins ) ) 569 return; 570 564 571 $invalid = array(); 565 572 566 573 // invalid plugins get deactivated -
wp-includes/load.php
374 374 * @since 3.0.0 375 375 * @return array Files to include 376 376 */ 377 function wp_ muplugins_to_load() {377 function wp_load_mu_plugins() { 378 378 $mu_plugins = array(); 379 379 if ( !is_dir( WPMU_PLUGIN_DIR ) ) 380 380 return $mu_plugins; … … 399 399 * 400 400 * @access private 401 401 * @since 3.0.0 402 * @param bool $network Whether to return network-wide plugins. Default false. 402 403 * @return array Files to include 403 404 */ 404 function wp_ plugins_to_load() {405 function wp_load_plugins( $network = false ) { 405 406 $plugins = array(); 406 407 407 408 // Check for hacks file if the option is enabled 408 409 if ( get_option( 'hack_file' ) && file_exists( ABSPATH . 'my-hacks.php' ) ) 409 410 $plugins[] = ABSPATH . 'my-hacks.php'; 410 411 411 $active_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins', array() ) ); 412 if ( !is_array( $active_plugins ) || defined( 'WP_INSTALLING' ) ) 412 if ( $network && is_multisite() ) 413 $active_plugins = (array) get_site_option( 'active_sitewide_plugins', array() ); 414 else 415 $active_plugins = (array) apply_filters( 'active_plugins', get_option( 'active_plugins', array() ) ); 416 417 if ( empty( $active_plugins ) || defined( 'WP_INSTALLING' ) ) 413 418 return $plugins; 419 414 420 foreach ( $active_plugins as $plugin ) { 415 if ( validate_file( $plugin ) // $plugin must validate as file416 || '.php' != substr( $plugin, -4 ) // $plugin must end with '.php'417 || !file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist421 if ( ! validate_file( $plugin ) // $plugin must validate as file 422 && '.php' == substr( $plugin, -4 ) // $plugin must end with '.php' 423 && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist 418 424 ) 419 continue;420 425 $plugins[] = WP_PLUGIN_DIR . '/' . $plugin; 421 426 } 422 427 return $plugins; -
wp-includes/ms-load.php
23 23 } 24 24 25 25 /** 26 * Returns array of sitewide plugin files to be included in global scope.27 *28 * @access private29 * @since 3.0.030 * @return array Files to include31 */32 function ms_network_plugins() {33 $network_plugins = array();34 $deleted_sitewide_plugins = array();35 $wpmu_sitewide_plugins = (array) maybe_unserialize( get_site_option( 'wpmu_sitewide_plugins' ) );36 foreach ( $wpmu_sitewide_plugins as $plugin_file => $activation_time ) {37 if ( !$plugin_file )38 continue;39 40 if ( !file_exists( WP_PLUGIN_DIR . '/' . $plugin_file ) )41 $deleted_sitewide_plugins[] = $plugin_file;42 else43 $network_plugins[] = WP_PLUGIN_DIR . '/' . $plugin_file;44 }45 46 if ( !empty( $deleted_sitewide_plugins ) ) {47 $active_sitewide_plugins = maybe_unserialize( get_site_option( 'active_sitewide_plugins' ) );48 49 /* Remove any deleted plugins from the wpmu_sitewide_plugins array */50 foreach ( $deleted_sitewide_plugins as $plugin_file ) {51 unset( $wpmu_sitewide_plugins[$plugin_file] );52 unset( $active_sitewide_plugins[$plugin_file] );53 }54 55 update_site_option( 'wpmu_sitewide_plugins', $wpmu_sitewide_plugins );56 update_site_option( 'active_sitewide_plugins', $wpmu_sitewide_plugins );57 }58 59 return $network_plugins;60 }61 62 /**63 26 * Checks status of current blog. 64 27 * 65 28 * Checks if the blog is deleted, inactive, archived, or spammed. -
wp-settings.php
136 136 wp_default_constants( 'wp_included' ); 137 137 138 138 // Load must-use plugins. 139 foreach( wp_ muplugins_to_load() as $mu_plugin )139 foreach( wp_load_mu_plugins() as $mu_plugin ) { 140 140 include_once( $mu_plugin ); 141 } 141 142 unset( $mu_plugin ); 142 143 143 144 // Load network-wide plugins if multisite. 144 145 if ( is_multisite() ) { 145 foreach ( ms_network_plugins() as $plugin_file )146 foreach ( wp_load_plugins( true ) as $plugin_file ) { 146 147 include_once( $plugin_file ); 148 } 147 149 unset( $plugin_file ); 148 150 } 149 151 … … 170 172 create_initial_taxonomies(); 171 173 172 174 // Load active plugins. 173 foreach( wp_ plugins_to_load() as $plugin )175 foreach( wp_load_plugins() as $plugin ) 174 176 include_once( $plugin ); 175 177 unset( $plugin ); 176 178