Make WordPress Core

Changeset 12673


Ignore:
Timestamp:
01/08/2010 08:49:55 PM (15 years ago)
Author:
ryan
Message:

Convert update_themes, update_plugins, update_core, and dismissed_update_core into site transients/plugins. Remove no longer need compat code.

Location:
trunk
Files:
13 edited

Legend:

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

    r12533 r12673  
    399399
    400400        // Force refresh of plugin update information
    401         delete_transient('update_plugins');
     401        delete_site_transient('update_plugins');
    402402
    403403    }
     
    408408        $this->upgrade_strings();
    409409
    410         $current = get_transient( 'update_plugins' );
     410        $current = get_site_transient( 'update_plugins' );
    411411        if ( !isset( $current->response[ $plugin ] ) ) {
    412412            $this->skin->set_result(false);
     
    441441
    442442        // Force refresh of plugin update information
    443         delete_transient('update_plugins');
     443        delete_site_transient('update_plugins');
    444444    }
    445445
     
    450450        $this->upgrade_strings();
    451451
    452         $current = get_transient( 'update_plugins' );
     452        $current = get_site_transient( 'update_plugins' );
    453453
    454454        add_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'), 10, 4);
     
    509509
    510510        // Force refresh of plugin update information
    511         delete_transient('update_plugins');
     511        delete_site_transient('update_plugins');
    512512
    513513        return $results;
     
    628628
    629629        // Force refresh of theme update information
    630         delete_transient('update_themes');
     630        delete_site_transient('update_themes');
    631631
    632632        if ( empty($result['destination_name']) )
     
    642642
    643643        // Is an update available?
    644         $current = get_transient( 'update_themes' );
     644        $current = get_site_transient( 'update_themes' );
    645645        if ( !isset( $current->response[ $theme ] ) ) {
    646646            $this->skin->set_result(false);
     
    672672
    673673        // Force refresh of theme update information
    674         delete_transient('update_themes');
     674        delete_site_transient('update_themes');
    675675
    676676        return true;
  • trunk/wp-admin/includes/plugin-install.php

    r11585 r12673  
    444444            $type = 'install';
    445445            //Check to see if this plugin is known to be installed, and has an update awaiting it.
    446             $update_plugins = get_transient('update_plugins');
     446            $update_plugins = get_site_transient('update_plugins');
    447447            if ( is_object( $update_plugins ) ) {
    448448                foreach ( (array)$update_plugins->response as $file => $plugin ) {
     
    465465                    } else {
    466466                        //If the above update check failed, Then that probably means that the update checker has out-of-date information, force a refresh
    467                         delete_transient('update_plugins');
     467                        delete_site_transient('update_plugins');
    468468                        $update_file = $api->slug . '/' . $key; //This code branch only deals with a plugin which is in a folder the same name as its slug, Doesnt support plugins which have 'non-standard' names
    469469                        $type = 'update_available';
  • trunk/wp-admin/includes/plugin.php

    r12636 r12673  
    468468
    469469    // Force refresh of plugin update information
    470     if ( $current = get_transient('update_plugins') ) {
     470    if ( $current = get_site_transient('update_plugins') ) {
    471471        unset( $current->response[ $plugin_file ] );
    472         set_transient('update_plugins', $current);
     472        set_site_transient('update_plugins', $current);
    473473    }
    474474
  • trunk/wp-admin/includes/theme-install.php

    r11497 r12673  
    477477    $type = 'install';
    478478    // Check to see if this theme is known to be installed, and has an update awaiting it.
    479     $update_themes = get_transient('update_themes');
     479    $update_themes = get_site_transient('update_themes');
    480480    if ( is_object($update_themes) && isset($update_themes->response) ) {
    481481        foreach ( (array)$update_themes->response as $theme_slug => $theme_info ) {
  • trunk/wp-admin/includes/theme.php

    r12253 r12673  
    9898
    9999    // Force refresh of theme update information
    100     delete_transient('update_themes');
     100    delete_site_transient('update_themes');
    101101
    102102    return true;
  • trunk/wp-admin/includes/update-core.php

    r12564 r12673  
    279279
    280280    // Force refresh of update information
    281     if ( function_exists('delete_transient') )
    282         delete_transient('update_core');
     281    if ( function_exists('delete_site_transient') )
     282        delete_site_transient('update_core');
    283283    else
    284284        delete_option('update_core');
  • trunk/wp-admin/includes/update.php

    r12066 r12673  
    3232function get_core_updates( $options = array() ) {
    3333    $options = array_merge( array('available' => true, 'dismissed' => false ), $options );
    34     $dismissed = get_option( 'dismissed_update_core' );
     34    $dismissed = get_site_option( 'dismissed_update_core' );
    3535    if ( !is_array( $dismissed ) ) $dismissed = array();
    36     $from_api = get_transient( 'update_core' );
     36    $from_api = get_site_transient( 'update_core' );
    3737    if ( empty($from_api) )
    3838        return false;
     
    5858
    5959function dismiss_core_update( $update ) {
    60     $dismissed = get_option( 'dismissed_update_core' );
     60    $dismissed = get_site_option( 'dismissed_update_core' );
    6161    $dismissed[ $update->current.'|'.$update->locale ] = true;
    62     return update_option( 'dismissed_update_core', $dismissed );
     62    return update_site_option( 'dismissed_update_core', $dismissed );
    6363}
    6464
    6565function undismiss_core_update( $version, $locale ) {
    66     $dismissed = get_option( 'dismissed_update_core' );
     66    $dismissed = get_site_option( 'dismissed_update_core' );
    6767    $key = $version.'|'.$locale;
    6868    if ( !isset( $dismissed[$key] ) ) return false;
    6969    unset( $dismissed[$key] );
    70     return update_option( 'dismissed_update_core', $dismissed );
     70    return update_site_option( 'dismissed_update_core', $dismissed );
    7171}
    7272
    7373function find_core_update( $version, $locale ) {
    74     $from_api = get_transient( 'update_core' );
     74    $from_api = get_site_transient( 'update_core' );
    7575    if ( !is_array( $from_api->updates ) ) return false;
    7676    $updates = $from_api->updates;
     
    149149    $all_plugins = get_plugins();
    150150    $upgrade_plugins = array();
    151     $current = get_transient( 'update_plugins' );
     151    $current = get_site_transient( 'update_plugins' );
    152152    foreach ( (array)$all_plugins as $plugin_file => $plugin_data) {
    153153        if ( isset( $current->response[ $plugin_file ] ) ) {
     
    161161
    162162function wp_plugin_update_rows() {
    163     $plugins = get_transient( 'update_plugins' );
     163    $plugins = get_site_transient( 'update_plugins' );
    164164    if ( isset($plugins->response) && is_array($plugins->response) ) {
    165165        $plugins = array_keys( $plugins->response );
     
    172172
    173173function wp_plugin_update_row( $file, $plugin_data ) {
    174     $current = get_transient( 'update_plugins' );
     174    $current = get_site_transient( 'update_plugins' );
    175175    if ( !isset( $current->response[ $file ] ) )
    176176        return false;
     
    208208function get_theme_updates() {
    209209    $themes = get_themes();
    210     $current = get_transient('update_themes');
     210    $current = get_site_transient('update_themes');
    211211    $update_themes = array();
    212212
  • trunk/wp-admin/menu.php

    r12629 r12673  
    105105        $submenu['themes.php'][15] = array(__('Add New Themes'), 'install_themes', 'theme-install.php');
    106106
    107 $update_plugins = get_transient( 'update_plugins' );
     107$update_plugins = get_site_transient( 'update_plugins' );
    108108$update_count = 0;
    109109if ( !empty($update_plugins->response) )
  • trunk/wp-admin/plugins.php

    r12636 r12673  
    303303if ( $recently_activated != get_option('recently_activated') ) //If array changed, update it.
    304304    update_option('recently_activated', $recently_activated);
    305 $current = get_transient( 'update_plugins' );
     305$current = get_site_transient( 'update_plugins' );
    306306
    307307foreach ( (array)$all_plugins as $plugin_file => $plugin_data) {
  • trunk/wp-admin/themes.php

    r12546 r12673  
    9999    static $themes_update;
    100100    if ( !isset($themes_update) )
    101         $themes_update = get_transient('update_themes');
     101        $themes_update = get_site_transient('update_themes');
    102102
    103103    if ( is_object($theme) && isset($theme->stylesheet) )
  • trunk/wp-admin/upgrade.php

    r12577 r12673  
    2121require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    2222
    23 delete_transient('update_core');
     23delete_site_transient('update_core');
    2424
    2525if ( isset( $_GET['step'] ) )
  • trunk/wp-includes/ms-functions.php

    r12672 r12673  
    20892089}
    20902090
    2091 /* Short circuit the update checks. Make sure update informtion is
    2092    stored in wp_sitemeta rather than the options table of individual blogs */
    2093 
    2094 // update_plugins (transient)
    2095 function site_delete_update_plugins() {
    2096     return update_site_option( 'update_plugins', false );
    2097 }
    2098 add_action( 'delete_transient_update_plugins', 'site_delete_update_plugins' );
    2099 
    2100 function site_pre_update_plugins() {
    2101     return get_site_option( 'update_plugins' );
    2102 }
    2103 add_filter( 'pre_transient_update_plugins', 'site_pre_update_plugins' );
    2104 
    2105 function site_pre_set_transient_update_plugins( $value ) {
    2106     update_site_option( 'update_plugins', $value );
    2107     return $value;
    2108 }
    2109 add_filter( 'pre_set_transient_update_plugins', 'site_pre_set_transient_update_plugins' );
    2110 
    2111 add_action( 'add_option__transient_update_plugins', 'site_add_option__transient_update');
    2112 
    2113 // update_themes (transient)
    2114 function site_delete_update_themes() {
    2115     return update_site_option( 'update_themes', false );
    2116 }
    2117 add_action( 'delete_transient_update_themes', 'site_delete_update_themes' );
    2118 
    2119 function site_pre_update_themes() {
    2120     return get_site_option( 'update_themes' );
    2121 }
    2122 add_filter( 'pre_transient_update_themes', 'site_pre_update_themes' );
    2123 
    2124 function site_pre_set_transient_update_themes( $value ) {
    2125     update_site_option( 'update_themes', $value );
    2126     return $value;
    2127 }
    2128 add_filter( 'pre_set_transient_update_themes', 'site_pre_set_transient_update_themes' );
    2129 
    2130 add_action( 'add_option__transient_update_themes', 'site_add_option__transient_update');
    2131 
    2132 // update_core (transient)
    2133 function site_delete_update_core() {
    2134     return update_site_option( 'update_core', false );
    2135 }
    2136 add_action( 'delete_transient_update_core', 'site_delete_update_core' );
    2137 
    2138 function site_pre_update_core() {
    2139     return get_site_option( 'update_core' );
    2140 }
    2141 add_filter( 'pre_transient_update_core', 'site_pre_update_core' );
    2142 
    2143 function site_pre_set_transient_update_core( $value ) {
    2144     update_site_option( 'update_core', $value );
    2145     return $value;
    2146 }
    2147 add_filter( 'pre_set_transient_update_core', 'site_pre_set_transient_update_core' );
    2148 
    2149 add_action( 'add_option__transient_update_core', 'site_add_option__transient_update');
    2150 
    2151 // dismissed_update_core (option, not a transient)
    2152 function site_pre_dismissed_update_core() {
    2153     return get_site_option( 'dismissed_update_core' );
    2154 }
    2155 add_filter( 'pre_option_dismissed_update_core', 'site_pre_dismissed_update_core' );
    2156 
    2157 function site_pre_update_option_dismissed_update_core( $newvalue, $oldvalue ) {
    2158     update_site_option( 'dismissed_update_core', $newvalue );
    2159     delete_option('dismissed_update_core');
    2160     // Return the old value so the update_option() call is aborted after this filter is run. It's in sitemeta now.
    2161     return $oldvalue;
    2162 }
    2163 add_filter( 'pre_update_option_dismissed_update_core', 'site_pre_update_option_dismissed_update_core', 10, 2 );
    2164 
    2165 
    2166 
    2167 function site_add_option__transient_update($name) {
    2168     delete_option($name);
    2169 }
    2170 
    21712091/* Redirect all hits to "dashboard" blog to wp-admin/ Dashboard. */
    21722092function redirect_mu_dashboard() {
  • trunk/wp-includes/update.php

    r12523 r12673  
    2727    $php_version = phpversion();
    2828
    29     $current = get_transient( 'update_core' );
     29    $current = get_site_transient( 'update_core' );
    3030    if ( ! is_object($current) ) {
    3131        $current = new stdClass;
     
    3838    // Update last_checked for current to prevent multiple blocking requests if request hangs
    3939    $current->last_checked = time();
    40     set_transient( 'update_core', $current );
     40    set_site_transient( 'update_core', $current );
    4141
    4242    if ( method_exists( $wpdb, 'db_version' ) )
     
    8686    $updates->last_checked = time();
    8787    $updates->version_checked = $wp_version;
    88     set_transient( 'update_core',  $updates);
     88    set_site_transient( 'update_core',  $updates);
    8989}
    9090
     
    114114    $plugins = get_plugins();
    115115    $active  = get_option( 'active_plugins' );
    116     $current = get_transient( 'update_plugins' );
     116    $current = get_site_transient( 'update_plugins' );
    117117    if ( ! is_object($current) )
    118118        $current = new stdClass;
     
    146146    // Update last_checked for current to prevent multiple blocking requests if request hangs
    147147    $current->last_checked = time();
    148     set_transient( 'update_plugins', $current );
     148    set_site_transient( 'update_plugins', $current );
    149149
    150150    $to_send = (object)compact('plugins', 'active');
     
    171171        $new_option->response = array();
    172172
    173     set_transient( 'update_plugins', $new_option );
     173    set_site_transient( 'update_plugins', $new_option );
    174174}
    175175
     
    197197
    198198    $installed_themes = get_themes( );
    199     $current_theme = get_transient( 'update_themes' );
     199    $current_theme = get_site_transient( 'update_themes' );
    200200    if ( ! is_object($current_theme) )
    201201        $current_theme = new stdClass;
     
    240240    // Update last_checked for current to prevent multiple blocking requests if request hangs
    241241    $current_theme->last_checked = time();
    242     set_transient( 'update_themes', $current_theme );
     242    set_site_transient( 'update_themes', $current_theme );
    243243
    244244    $current_theme->template = get_option( 'template' );
     
    264264    }
    265265
    266     set_transient( 'update_themes', $new_option );
     266    set_site_transient( 'update_themes', $new_option );
    267267}
    268268
     
    270270    global $wp_version;
    271271
    272     $current = get_transient( 'update_core' );
     272    $current = get_site_transient( 'update_core' );
    273273
    274274    if ( isset( $current->last_checked ) &&
     
    291291 */
    292292function _maybe_update_plugins() {
    293     $current = get_transient( 'update_plugins' );
     293    $current = get_site_transient( 'update_plugins' );
    294294    if ( isset( $current->last_checked ) && 43200 > ( time() - $current->last_checked ) )
    295295        return;
     
    307307 */
    308308function _maybe_update_themes( ) {
    309     $current = get_transient( 'update_themes' );
     309    $current = get_site_transient( 'update_themes' );
    310310    if( isset( $current->last_checked ) && 43200 > ( time( ) - $current->last_checked ) )
    311311        return;
Note: See TracChangeset for help on using the changeset viewer.