Cache get_plugins() list. Props DD32. fixes #7113

git-svn-id: http://svn.automattic.com/wordpress/trunk@8068 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-06-10 16:57:33 +00:00
parent 7939970055
commit b666a1c910
3 changed files with 14 additions and 17 deletions

View File

@ -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;
}

View File

@ -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");

View File

@ -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');