WordPress.org

Make WordPress Core

Changeset 8068


Ignore:
Timestamp:
06/10/2008 04:57:33 PM (14 years ago)
Author:
ryan
Message:

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

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/plugin.php

    r8049 r8068  
    3333
    3434function get_plugins($plugin_folder = '') {
    35     global $wp_plugins;
    36 
    37     if ( isset( $wp_plugins ) ) {
    38         return $wp_plugins;
    39     }
    40 
     35   
     36    if ( ! $cache_plugins = wp_cache_get('plugins', 'plugins') )
     37        $cached_plugins = array();
     38   
     39    if ( isset($cache_plugins[ $plugin_folder ]) )
     40        return $cache_plugins[ $plugin_folder ];
     41   
    4142    $wp_plugins = array ();
    4243    $plugin_root = WP_PLUGIN_DIR;
     
    8687    uasort( $wp_plugins, create_function( '$a, $b', 'return strnatcasecmp( $a["Name"], $b["Name"] );' ));
    8788
     89    $cache_plugins[ $plugin_folder ] = $wp_plugins;
     90    wp_cache_set('plugins', $cache_plugins, 'plugins');
     91
    8892    return $wp_plugins;
    8993}
  • trunk/wp-admin/plugins.php

    r8060 r8068  
    8383
    8484            $delete_result = delete_plugins($plugins);
    85            
    86             //HACK TIME!
    87             // Proper way needed, perhaps get_plugins() to convert to wp_cache_get() any reason why it hasnt allready?
    88             // This clears the cached plugin list
    89             global $wp_plugins;
    90             $wp_plugins = null;
    91            
    92            
    93                
    94             //TODO: Implement!.. STAT!
     85
     86            wp_cache_delete('plugins', 'plugins');
     87
    9588            break;
    9689        default:
  • trunk/wp-settings.php

    r8006 r8068  
    223223if ( function_exists('wp_cache_add_global_groups') ) {
    224224    wp_cache_add_global_groups(array ('users', 'userlogins', 'usermeta'));
    225     wp_cache_add_non_persistent_groups(array( 'comment', 'counts' ));
     225    wp_cache_add_non_persistent_groups(array( 'comment', 'counts', 'plugins' ));
    226226}
    227227
Note: See TracChangeset for help on using the changeset viewer.