When showing already installed themes in the theme installer list, indicate in the row actions that the theme is installed and offer an update link if updates are available.
Props SergeyBiryukov Fixes #20618 git-svn-id: https://develop.svn.wordpress.org/trunk@20751 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
81918eaf4a
commit
0bed53f213
|
@ -203,7 +203,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
||||||
break;
|
break;
|
||||||
case 'latest_installed':
|
case 'latest_installed':
|
||||||
case 'newer_installed':
|
case 'newer_installed':
|
||||||
$action_links[] = '<span title="' . esc_attr__( 'This plugin is already installed and is up to date' ) . ' ">' . __( 'Installed' ) . '</span>';
|
$action_links[] = '<span title="' . esc_attr__( 'This plugin is already installed and is up to date' ) . ' ">' . _x( 'Installed', 'plugin' ) . '</span>';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,7 +198,27 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
|
||||||
'action' => 'install-theme',
|
'action' => 'install-theme',
|
||||||
'theme' => $theme->slug,
|
'theme' => $theme->slug,
|
||||||
), self_admin_url( 'update.php' ) );
|
), self_admin_url( 'update.php' ) );
|
||||||
$actions[] = '<a class="install-now" href="' . wp_nonce_url( $install_url, 'install-theme_' . $theme->slug ) . '" title="' . esc_attr( sprintf( __( 'Install %s' ), $name ) ) . '">' . __( 'Install Now' ) . '</a>';
|
|
||||||
|
$update_url = add_query_arg( array(
|
||||||
|
'action' => 'upgrade-theme',
|
||||||
|
'theme' => $theme->slug,
|
||||||
|
), self_admin_url( 'update.php' ) );
|
||||||
|
|
||||||
|
$status = $this->_get_theme_status( $theme );
|
||||||
|
|
||||||
|
switch ( $status ) {
|
||||||
|
default:
|
||||||
|
case 'install':
|
||||||
|
$actions[] = '<a class="install-now" href="' . esc_url( wp_nonce_url( $install_url, 'install-theme_' . $theme->slug ) ) . '" title="' . esc_attr( sprintf( __( 'Install %s' ), $name ) ) . '">' . __( 'Install Now' ) . '</a>';
|
||||||
|
break;
|
||||||
|
case 'update_available':
|
||||||
|
$actions[] = '<a class="install-now" href="' . esc_url( wp_nonce_url( $update_url, 'upgrade-theme_' . $theme->slug ) ) . '" title="' . esc_attr( sprintf( __( 'Update to version %s' ), $theme->version ) ) . '">' . __( 'Update' ) . '</a>';
|
||||||
|
break;
|
||||||
|
case 'newer_installed':
|
||||||
|
case 'latest_installed':
|
||||||
|
$actions[] = '<span class="install-now" title="' . esc_attr__( 'This theme is already installed and is up to date' ) . '">' . _x( 'Installed', 'theme' ) . '</span>';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$actions[] = '<a class="install-theme-preview" href="#" title="' . esc_attr( sprintf( __( 'Preview %s' ), $name ) ) . '">' . __( 'Preview' ) . '</a>';
|
$actions[] = '<a class="install-theme-preview" href="#" title="' . esc_attr( sprintf( __( 'Preview %s' ), $name ) ) . '">' . __( 'Preview' ) . '</a>';
|
||||||
|
|
||||||
|
@ -290,9 +310,28 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
|
||||||
'theme' => $theme->slug,
|
'theme' => $theme->slug,
|
||||||
), self_admin_url( 'update.php' ) );
|
), self_admin_url( 'update.php' ) );
|
||||||
|
|
||||||
|
$update_url = add_query_arg( array(
|
||||||
|
'action' => 'upgrade-theme',
|
||||||
|
'theme' => $theme->slug,
|
||||||
|
), self_admin_url( 'update.php' ) );
|
||||||
|
|
||||||
|
$status = $this->_get_theme_status( $theme );
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<div class="install-theme-info">
|
<div class="install-theme-info"><?php
|
||||||
<a class="theme-install button-primary" href="<?php echo wp_nonce_url( $install_url, 'install-theme_' . $theme->slug ); ?>"><?php _e( 'Install' ); ?></a>
|
switch ( $status ) {
|
||||||
|
default:
|
||||||
|
case 'install':
|
||||||
|
echo '<a class="theme-install button-primary" href="' . esc_url( wp_nonce_url( $install_url, 'install-theme_' . $theme->slug ) ) . '">' . __( 'Install' ) . '</a>';
|
||||||
|
break;
|
||||||
|
case 'update_available':
|
||||||
|
echo '<a class="theme-install button-primary" href="' . esc_url( wp_nonce_url( $update_url, 'upgrade-theme_' . $theme->slug ) ) . '" title="' . esc_attr( sprintf( __( 'Update to version %s' ), $theme->version ) ) . '">' . __( 'Update' ) . '</a>';
|
||||||
|
break;
|
||||||
|
case 'newer_installed':
|
||||||
|
case 'latest_installed':
|
||||||
|
echo '<span class="theme-install" title="' . esc_attr__( 'This theme is already installed and is up to date' ) . '">' . _x( 'Installed', 'theme' ) . '</span>';
|
||||||
|
break;
|
||||||
|
} ?>
|
||||||
<h3 class="theme-name"><?php echo $name; ?></h3>
|
<h3 class="theme-name"><?php echo $name; ?></h3>
|
||||||
<span class="theme-by"><?php printf( __( 'By %s' ), $author ); ?></span>
|
<span class="theme-by"><?php printf( __( 'By %s' ), $author ); ?></span>
|
||||||
<?php if ( isset( $theme->screenshot_url ) ): ?>
|
<?php if ( isset( $theme->screenshot_url ) ): ?>
|
||||||
|
@ -328,4 +367,29 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
|
||||||
global $tab, $type;
|
global $tab, $type;
|
||||||
parent::_js_vars( compact( 'tab', 'type' ) );
|
parent::_js_vars( compact( 'tab', 'type' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check to see if the theme is already installed.
|
||||||
|
*
|
||||||
|
* @since 3.4
|
||||||
|
* @access private
|
||||||
|
*
|
||||||
|
* @param object $theme - A WordPress.org Theme API object.
|
||||||
|
* @return string Theme status.
|
||||||
|
*/
|
||||||
|
private function _get_theme_status( $theme ) {
|
||||||
|
$status = 'install';
|
||||||
|
|
||||||
|
$installed_theme = wp_get_theme( $theme->slug );
|
||||||
|
if ( $installed_theme->exists() ) {
|
||||||
|
if ( version_compare( $installed_theme->get('Version'), $theme->version, '=' ) )
|
||||||
|
$status = 'latest_installed';
|
||||||
|
elseif ( version_compare( $installed_theme->get('Version'), $theme->version, '>' ) )
|
||||||
|
$status = 'newer_installed';
|
||||||
|
else
|
||||||
|
$status = 'update_available';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue