diff --git a/wp-admin/includes/plugin.php b/wp-admin/includes/plugin.php index 942b5dfc28..07e721117f 100644 --- a/wp-admin/includes/plugin.php +++ b/wp-admin/includes/plugin.php @@ -258,8 +258,8 @@ function get_plugins($plugin_folder = '') { * @param string $plugin Base plugin path from plugins directory. * @return bool True, if in the active plugins list. False, not in the list. */ -function is_plugin_active($plugin) { - return in_array( $plugin, apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ); +function is_plugin_active( $plugin ) { + return in_array( $plugin, apply_filters( 'active_plugins', get_option( 'active_plugins', array() ) ) ); } /** @@ -286,9 +286,9 @@ function is_plugin_active($plugin) { * @param string $redirect Optional. URL to redirect to. * @return WP_Error|null WP_Error on invalid file or null on success. */ -function activate_plugin($plugin, $redirect = '') { - $current = get_option('active_plugins'); - $plugin = plugin_basename(trim($plugin)); +function activate_plugin( $plugin, $redirect = '' ) { + $current = get_option( 'active_plugins', array() ); + $plugin = plugin_basename( trim( $plugin ) ); $valid = validate_plugin($plugin); if ( is_wp_error($valid) ) @@ -322,13 +322,10 @@ function activate_plugin($plugin, $redirect = '') { * @param string|array $plugins Single plugin or list of plugins to deactivate. * @param bool $silent Optional, default is false. Prevent calling deactivate hook. */ -function deactivate_plugins($plugins, $silent= false) { - $current = get_option('active_plugins'); +function deactivate_plugins( $plugins, $silent = false ) { + $current = get_option( 'active_plugins', array() ); - if ( !is_array($plugins) ) - $plugins = array($plugins); - - foreach ( $plugins as $plugin ) { + foreach ( (array) $plugins as $plugin ) { $plugin = plugin_basename($plugin); if ( ! is_plugin_active($plugin) ) continue; @@ -475,26 +472,32 @@ function delete_plugins($plugins, $redirect = '' ) { return true; } +/** + * validate active plugins + * + * validate all active plugins, deactivates invalid and + * returns an array of deactived ones. + * + * @since unknown + * @return array invalid plugins, plugin as key, error as value + */ function validate_active_plugins() { - $check_plugins = apply_filters( 'active_plugins', get_option('active_plugins') ); + $plugins = apply_filters( 'active_plugins', get_option( 'active_plugins', array() ) ); - // Sanity check. If the active plugin list is not an array, make it an - // empty array. - if ( !is_array($check_plugins) ) { + // validate vartype: array + if ( !is_array( $plugins ) ) { update_option('active_plugins', array()); return; } - //Invalid is any plugin that is deactivated due to error. $invalid = array(); - // If a plugin file does not exist, remove it from the list of active - // plugins. - foreach ( $check_plugins as $check_plugin ) { - $result = validate_plugin($check_plugin); + // invalid plugins get deactivated + foreach ( $plugins as $plugin ) { + $result = validate_plugin( $plugin ); if ( is_wp_error( $result ) ) { - $invalid[$check_plugin] = $result; - deactivate_plugins( $check_plugin, true); + $invalid[$plugin] = $result; + deactivate_plugins( $plugin, true ); } } return $invalid; diff --git a/wp-admin/plugin-editor.php b/wp-admin/plugin-editor.php index e62c0815a8..9b8137c82d 100644 --- a/wp-admin/plugin-editor.php +++ b/wp-admin/plugin-editor.php @@ -208,7 +208,7 @@ foreach ( $plugin_files as $plugin_file ) :
Warning: Making changes to active plugins is not recommended. If your changes cause a fatal error, the plugin will be automatically deactivated.'); ?>
diff --git a/wp-admin/plugins.php b/wp-admin/plugins.php index aff423108c..00edbc26dd 100644 --- a/wp-admin/plugins.php +++ b/wp-admin/plugins.php @@ -113,7 +113,7 @@ if ( !empty($action) ) { require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); require_once( 'admin-header.php' ); - + $url = 'plugins.php?action=upgrade-selected&plugins=' . urlencode( join( ',', $plugins ) ); $title = __( 'Upgrade Plugins' ); $nonce = 'bulk-manage-plugins'; @@ -283,9 +283,9 @@ add_contextual_help($current_screen, $help); if ( is_multisite() && is_super_admin() ) { $menu_perms = get_site_option('menu_items', array()); - if ( !$menu_perms['plugins'] ) { + if ( empty($menu_perms['plugins']) ) add_action( 'admin_notices', '_admin_notice_multisite_activate_plugins_page' ); - } + unset($menu_perms); } $title = __('Manage Plugins'); diff --git a/wp-includes/load.php b/wp-includes/load.php index 476d09bc4a..05a6a55218 100644 --- a/wp-includes/load.php +++ b/wp-includes/load.php @@ -404,7 +404,7 @@ function wp_plugins_to_load() { if ( get_option( 'hack_file' ) && file_exists( ABSPATH . 'my-hacks.php' ) ) $plugins[] = ABSPATH . 'my-hacks.php'; - $active_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) ); + $active_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins', array() ) ); if ( !is_array( $active_plugins ) || defined( 'WP_INSTALLING' ) ) return $plugins; foreach ( $active_plugins as $plugin ) { diff --git a/wp-includes/ms-deprecated.php b/wp-includes/ms-deprecated.php index 3f4579bc0b..7ee59d83d9 100644 --- a/wp-includes/ms-deprecated.php +++ b/wp-includes/ms-deprecated.php @@ -110,4 +110,11 @@ function get_user_details( $username ) { return get_user_by('login', $username); } +/** + * @deprecated 3.0 + */ +function clear_global_post_cache( $post_id ) { + _deprecated_function( __FUNCTION__, '3.0', 'clean_post_cache' ); +} + ?> \ No newline at end of file diff --git a/wp-includes/ms-functions.php b/wp-includes/ms-functions.php index b30634b661..d4b6267216 100644 --- a/wp-includes/ms-functions.php +++ b/wp-includes/ms-functions.php @@ -725,11 +725,6 @@ function get_blog_post( $blog_id, $post_id ) { return $post; } -// deprecated, see clean_post_cache() -function clear_global_post_cache( $post_id ) { - return; -} - function add_user_to_blog( $blog_id, $user_id, $role ) { switch_to_blog($blog_id); @@ -1986,13 +1981,6 @@ function is_user_option_local( $key, $user_id = 0, $blog_id = 0 ) { return false; } -function fix_active_plugins( $value ) { - if ( false == is_array( $value ) ) - $value = array(); - return $value; -} -add_filter( "option_active_plugins", "fix_active_plugins" ); - if ( !function_exists('rss_gc') ) : function rss_gc() { global $wpdb; diff --git a/wp-includes/update.php b/wp-includes/update.php index fbdb76b6cd..ab012a78d1 100644 --- a/wp-includes/update.php +++ b/wp-includes/update.php @@ -112,7 +112,7 @@ function wp_update_plugins() { require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); $plugins = get_plugins(); - $active = get_option( 'active_plugins' ); + $active = get_option( 'active_plugins', array() ); $current = get_site_transient( 'update_plugins' ); if ( ! is_object($current) ) $current = new stdClass; @@ -147,7 +147,7 @@ function wp_update_plugins() { $current->last_checked = time(); set_site_transient( 'update_plugins', $current ); - $to_send = (object)compact('plugins', 'active'); + $to_send = (object) compact('plugins', 'active'); $options = array( 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3),