diff --git a/wp-admin/includes/plugin.php b/wp-admin/includes/plugin.php index f257e9b592..3afaed92e9 100644 --- a/wp-admin/includes/plugin.php +++ b/wp-admin/includes/plugin.php @@ -32,12 +32,13 @@ function get_plugin_data( $plugin_file ) { } function get_plugins($plugin_folder = '') { - global $wp_plugins; - - if ( isset( $wp_plugins ) ) { - return $wp_plugins; - } - + + if ( ! $cache_plugins = wp_cache_get('plugins', 'plugins') ) + $cached_plugins = array(); + + if ( isset($cache_plugins[ $plugin_folder ]) ) + return $cache_plugins[ $plugin_folder ]; + $wp_plugins = array (); $plugin_root = WP_PLUGIN_DIR; if( !empty($plugin_folder) ) @@ -85,6 +86,9 @@ function get_plugins($plugin_folder = '') { uasort( $wp_plugins, create_function( '$a, $b', 'return strnatcasecmp( $a["Name"], $b["Name"] );' )); + $cache_plugins[ $plugin_folder ] = $wp_plugins; + wp_cache_set('plugins', $cache_plugins, 'plugins'); + return $wp_plugins; } diff --git a/wp-admin/plugins.php b/wp-admin/plugins.php index 148cdd7754..a3e7c005d6 100644 --- a/wp-admin/plugins.php +++ b/wp-admin/plugins.php @@ -82,16 +82,9 @@ if( !empty($action) ) { $parent_file = 'plugins.php'; $delete_result = delete_plugins($plugins); - - //HACK TIME! - // Proper way needed, perhaps get_plugins() to convert to wp_cache_get() any reason why it hasnt allready? - // This clears the cached plugin list - global $wp_plugins; - $wp_plugins = null; - - - - //TODO: Implement!.. STAT! + + wp_cache_delete('plugins', 'plugins'); + break; default: var_dump("Unknown Action $action"); diff --git a/wp-settings.php b/wp-settings.php index 0a52377de8..b16c4a2d88 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -222,7 +222,7 @@ else wp_cache_init(); if ( function_exists('wp_cache_add_global_groups') ) { wp_cache_add_global_groups(array ('users', 'userlogins', 'usermeta')); - wp_cache_add_non_persistent_groups(array( 'comment', 'counts' )); + wp_cache_add_non_persistent_groups(array( 'comment', 'counts', 'plugins' )); } require (ABSPATH . WPINC . '/plugin.php');