From 0e475b2e29e8ce268a6833cdaeb9c1131f6914b5 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Sat, 6 Jun 2009 08:14:41 +0000 Subject: [PATCH] WP Upgrader improvements, props DD32, fixes #9836 git-svn-id: https://develop.svn.wordpress.org/trunk@11525 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/class-wp-upgrader.php | 49 ++++++++++++++----------- wp-admin/themes.php | 6 +-- wp-admin/wp-admin.css | 5 --- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/wp-admin/includes/class-wp-upgrader.php b/wp-admin/includes/class-wp-upgrader.php index 1ffe0bcaee..76b11fe83c 100644 --- a/wp-admin/includes/class-wp-upgrader.php +++ b/wp-admin/includes/class-wp-upgrader.php @@ -391,9 +391,10 @@ class Plugin_Upgrader extends WP_Upgrader { $current = get_transient( 'update_plugins' ); if ( !isset( $current->response[ $plugin ] ) ) { + $this->skin->set_result(false); $this->skin->error('up_to_date'); + $this->skin->after(); return false; - //return new WP_Error('up_to_date', $this->strings['up_to_date']); } // Get the URL to the zip file @@ -553,9 +554,13 @@ class Theme_Upgrader extends WP_Upgrader { // Is an update available? $current = get_transient( 'update_themes' ); - if ( !isset( $current->response[ $theme ] ) ) - return new WP_Error('up_to_date', $this->strings['up_to_date']); - + if ( !isset( $current->response[ $theme ] ) ) { + $this->skin->set_result(false); + $this->skin->error('up_to_date'); + $this->skin->after(); + return false; + } + $r = $current->response[ $theme ]; add_filter('upgrader_pre_install', array(&$this, 'current_before'), 10, 2); @@ -984,26 +989,26 @@ class Theme_Upgrader_Skin extends WP_Upgrader_Skin { function after() { - if ( empty($this->upgrader->result['destination_name']) ) - return; + if ( !empty($this->upgrader->result['destination_name']) && + ($theme_info = $this->upgrader->theme_info()) && + !empty($theme_info) ) { - $theme_info = $this->upgrader->theme_info(); - if ( empty($theme_info) ) - return; - $name = $theme_info['Name']; - $stylesheet = $this->upgrader->result['destination_name']; - $template = !empty($theme_info['Template']) ? $theme_info['Template'] : $stylesheet; + $name = $theme_info['Name']; + $stylesheet = $this->upgrader->result['destination_name']; + $template = !empty($theme_info['Template']) ? $theme_info['Template'] : $stylesheet; + + $preview_link = htmlspecialchars( add_query_arg( array('preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'TB_iframe' => 'true' ), trailingslashit(esc_url(get_option('home'))) ) ); + $activate_link = wp_nonce_url("themes.php?action=activate&template=" . urlencode($template) . "&stylesheet=" . urlencode($stylesheet), 'switch-theme_' . $template); + + $update_actions = array( + 'preview' => '' . __('Preview') . '', + 'activate' => '' . __('Activate') . '', + ); + if ( ( ! $this->result || is_wp_error($this->result) ) || $stylesheet == get_stylesheet() ) + unset($update_actions['preview'], $update_actions['activate']); + } - $preview_link = htmlspecialchars( add_query_arg( array('preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'TB_iframe' => 'true' ), trailingslashit(esc_url(get_option('home'))) ) ); - $activate_link = wp_nonce_url("themes.php?action=activate&template=" . urlencode($template) . "&stylesheet=" . urlencode($stylesheet), 'switch-theme_' . $template); - - $update_actions = array( - 'preview' => '' . __('Preview') . '', - 'activate' => '' . __('Activate') . '', - 'themes_page' => '' . __('Return to Themes page') . '', - ); - if ( ( ! $this->result || is_wp_error($this->result) ) || $stylesheet == get_stylesheet() ) - unset($update_actions['preview'], $update_actions['activate']); + $update_actions['themes_page'] = '' . __('Return to Themes page') . ''; $update_actions = apply_filters('update_theme_complete_actions', $update_actions, $this->theme); if ( ! empty($update_actions) ) diff --git a/wp-admin/themes.php b/wp-admin/themes.php index 752b12bbe5..6550dfda95 100644 --- a/wp-admin/themes.php +++ b/wp-admin/themes.php @@ -112,11 +112,11 @@ function theme_update_available( $theme ) { $update_onclick = 'onclick="if ( confirm(\'' . esc_js( __("Upgrading this theme will lose any customizations you have made. 'Cancel' to stop, 'OK' to upgrade.") ) . '\') ) {return true;}return false;"'; if ( ! current_user_can('update_themes') ) - printf( '

' . __('There is a new version of %1$s available. View version %3$s Details.') . '

', $theme_name, $details_url, $update['new_version']); + printf( '

' . __('There is a new version of %1$s available. View version %3$s Details.') . '

', $theme_name, $details_url, $update['new_version']); else if ( empty($update->package) ) - printf( '

' . __('There is a new version of %1$s available. View version %3$s Details automatic upgrade unavailable for this theme.') . '

', $theme_name, $details_url, $update['new_version']); + printf( '

' . __('There is a new version of %1$s available. View version %3$s Details automatic upgrade unavailable for this theme.') . '

', $theme_name, $details_url, $update['new_version']); else - printf( '

' . __('There is a new version of %1$s available. View version %3$s Details or upgrade automatically.') . '

', $theme_name, $details_url, $update['new_version'], $update_url, $update_onclick ); + printf( '

' . __('There is a new version of %1$s available. View version %3$s Details or upgrade automatically.') . '

', $theme_name, $details_url, $update['new_version'], $update_url, $update_onclick ); } } diff --git a/wp-admin/wp-admin.css b/wp-admin/wp-admin.css index ed824344f9..662b305c77 100644 --- a/wp-admin/wp-admin.css +++ b/wp-admin/wp-admin.css @@ -815,11 +815,6 @@ td.media-icon img { font-weight: bold; } -#update-nag a, -.plugin-update a { - font-size: 1.1em; -} - #pass-strength-result { border-style: solid; border-width: 1px;