Make WordPress Core


Ignore:
Timestamp:
06/06/2009 08:14:41 AM (15 years ago)
Author:
azaozz
Message:

WP Upgrader improvements, props DD32, fixes #9836

File:
1 edited

Legend:

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

    r11506 r11525  
    392392        $current = get_transient( 'update_plugins' );
    393393        if ( !isset( $current->response[ $plugin ] ) ) {
     394            $this->skin->set_result(false);
    394395            $this->skin->error('up_to_date');
     396            $this->skin->after();
    395397            return false;
    396             //return new WP_Error('up_to_date', $this->strings['up_to_date']);
    397398        }
    398399
     
    554555        // Is an update available?
    555556        $current = get_transient( 'update_themes' );
    556         if ( !isset( $current->response[ $theme ] ) )
    557             return new WP_Error('up_to_date', $this->strings['up_to_date']);
    558 
     557        if ( !isset( $current->response[ $theme ] ) ) {
     558            $this->skin->set_result(false);
     559            $this->skin->error('up_to_date');
     560            $this->skin->after();
     561            return false;
     562        }
     563       
    559564        $r = $current->response[ $theme ];
    560565
     
    985990    function after() {
    986991
    987         if ( empty($this->upgrader->result['destination_name']) )
    988             return;
    989 
    990         $theme_info = $this->upgrader->theme_info();
    991         if ( empty($theme_info) )
    992             return;
    993         $name = $theme_info['Name'];
    994         $stylesheet = $this->upgrader->result['destination_name'];
    995         $template = !empty($theme_info['Template']) ? $theme_info['Template'] : $stylesheet;
    996 
    997         $preview_link = htmlspecialchars( add_query_arg( array('preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'TB_iframe' => 'true' ), trailingslashit(esc_url(get_option('home'))) ) );
    998         $activate_link = wp_nonce_url("themes.php?action=activate&template=" . urlencode($template) . "&stylesheet=" . urlencode($stylesheet), 'switch-theme_' . $template);
    999 
    1000         $update_actions =  array(
    1001             'preview' => '<a href="' . $preview_link . '" class="thickbox thickbox-preview" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $name)) . '">' . __('Preview') . '</a>',
    1002             'activate' => '<a href="' . $activate_link .  '" class="activatelink" title="' . esc_attr( sprintf( __('Activate &#8220;%s&#8221;'), $name ) ) . '">' . __('Activate') . '</a>',
    1003             'themes_page' => '<a href="' . admin_url('themes.php') . '" title="' . esc_attr__('Return to Themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>',
    1004         );
    1005         if ( ( ! $this->result || is_wp_error($this->result) ) || $stylesheet == get_stylesheet() )
    1006             unset($update_actions['preview'], $update_actions['activate']);
     992        if ( !empty($this->upgrader->result['destination_name']) &&
     993            ($theme_info = $this->upgrader->theme_info()) &&
     994            !empty($theme_info) ) {
     995
     996            $name = $theme_info['Name'];
     997            $stylesheet = $this->upgrader->result['destination_name'];
     998            $template = !empty($theme_info['Template']) ? $theme_info['Template'] : $stylesheet;
     999   
     1000            $preview_link = htmlspecialchars( add_query_arg( array('preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'TB_iframe' => 'true' ), trailingslashit(esc_url(get_option('home'))) ) );
     1001            $activate_link = wp_nonce_url("themes.php?action=activate&amp;template=" . urlencode($template) . "&amp;stylesheet=" . urlencode($stylesheet), 'switch-theme_' . $template);
     1002   
     1003            $update_actions =  array(
     1004                'preview' => '<a href="' . $preview_link . '" class="thickbox thickbox-preview" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $name)) . '">' . __('Preview') . '</a>',
     1005                'activate' => '<a href="' . $activate_link .  '" class="activatelink" title="' . esc_attr( sprintf( __('Activate &#8220;%s&#8221;'), $name ) ) . '">' . __('Activate') . '</a>',
     1006            );
     1007            if ( ( ! $this->result || is_wp_error($this->result) ) || $stylesheet == get_stylesheet() )
     1008                unset($update_actions['preview'], $update_actions['activate']);
     1009        }
     1010
     1011        $update_actions['themes_page'] = '<a href="' . admin_url('themes.php') . '" title="' . esc_attr__('Return to Themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>';
    10071012
    10081013        $update_actions = apply_filters('update_theme_complete_actions', $update_actions, $this->theme);
Note: See TracChangeset for help on using the changeset viewer.