WP Upgrader improvements, props DD32, fixes #9836

git-svn-id: http://svn.automattic.com/wordpress/trunk@11525 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2009-06-06 08:14:41 +00:00
parent 782b2624e3
commit d35438efe3
3 changed files with 30 additions and 30 deletions

View File

@ -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' => '<a href="' . $preview_link . '" class="thickbox thickbox-preview" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $name)) . '">' . __('Preview') . '</a>',
'activate' => '<a href="' . $activate_link . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate &#8220;%s&#8221;'), $name ) ) . '">' . __('Activate') . '</a>',
);
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&amp;template=" . urlencode($template) . "&amp;stylesheet=" . urlencode($stylesheet), 'switch-theme_' . $template);
$update_actions = array(
'preview' => '<a href="' . $preview_link . '" class="thickbox thickbox-preview" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $name)) . '">' . __('Preview') . '</a>',
'activate' => '<a href="' . $activate_link . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate &#8220;%s&#8221;'), $name ) ) . '">' . __('Activate') . '</a>',
'themes_page' => '<a href="' . admin_url('themes.php') . '" title="' . esc_attr__('Return to Themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>',
);
if ( ( ! $this->result || is_wp_error($this->result) ) || $stylesheet == get_stylesheet() )
unset($update_actions['preview'], $update_actions['activate']);
$update_actions['themes_page'] = '<a href="' . admin_url('themes.php') . '" title="' . esc_attr__('Return to Themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>';
$update_actions = apply_filters('update_theme_complete_actions', $update_actions, $this->theme);
if ( ! empty($update_actions) )

View File

@ -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( '<p>' . __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s Details</a>.') . '</p>', $theme_name, $details_url, $update['new_version']);
printf( '<p><strong>' . __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s Details</a>.') . '</strong></p>', $theme_name, $details_url, $update['new_version']);
else if ( empty($update->package) )
printf( '<p>' . __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s Details</a> <em>automatic upgrade unavailable for this theme</em>.') . '</p>', $theme_name, $details_url, $update['new_version']);
printf( '<p><strong>' . __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s Details</a> <em>automatic upgrade unavailable for this theme</em>.') . '</strong></p>', $theme_name, $details_url, $update['new_version']);
else
printf( '<p>' . __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s Details</a> or <a href="%4$s" %5$s >upgrade automatically</a>.') . '</p>', $theme_name, $details_url, $update['new_version'], $update_url, $update_onclick );
printf( '<p><strong>' . __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s Details</a> or <a href="%4$s" %5$s >upgrade automatically</a>.') . '</strong></p>', $theme_name, $details_url, $update['new_version'], $update_url, $update_onclick );
}
}

View File

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