Add 'Install now', 'Preview', and 'Details' links to theme install list items. fixes #20403.

git-svn-id: http://core.svn.wordpress.org/trunk@20730 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
koopersmith 2012-05-06 23:06:47 +00:00
parent 3c9a06672e
commit 8d3c911831
3 changed files with 51 additions and 21 deletions

View File

@ -5373,28 +5373,27 @@ body.full-overlay-active {
border: 1px solid #ccc;
}
.install-theme-info .theme-version {
.theme-details .theme-version {
margin: 15px 0;
float: right;
float: left;
}
.install-theme-info .theme-rating {
.theme-details .theme-rating {
margin: 14px 0;
width: 100px;
height: 17px;
float: left;
float: right;
background: url('../images/stars.png?ver=20120307') repeat-x bottom left;
}
.install-theme-info .theme-rating div {
.theme-details .theme-rating div {
background: url('../images/stars.png?ver=20120307') repeat-x top left;
height: 17px;
float: left;
}
.install-theme-info .theme-description {
margin-top: 34px;
padding-top: 1em;
.theme-details .theme-description {
float: left;
color: #777;
line-height: 20px;
}

View File

@ -192,14 +192,35 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
'theme' => $theme->slug,
) );
$actions = array();
$install_url = add_query_arg( array(
'action' => 'install-theme',
'theme' => $theme->slug,
), 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>';
$actions[] = '<a class="install-theme-preview" href="#" title="' . esc_attr( sprintf( __( 'Preview %s' ), $name ) ) . '">' . __( 'Preview' ) . '</a>';
$actions = apply_filters( 'theme_install_actions', $actions, $theme );
?>
<a class="screenshot" href="<?php echo esc_url( $preview_url ); ?>" title="<?php echo esc_attr( $preview_title ); ?>">
<a class="screenshot install-theme-preview" href="<?php echo esc_url( $preview_url ); ?>" title="<?php echo esc_attr( $preview_title ); ?>">
<img src='<?php echo esc_url( $theme->screenshot_url ); ?>' width='150' />
</a>
<h3><?php echo $name; ?></h3>
<div class="theme-author"><?php printf( __( 'By %s' ), $author ); ?></div>
<div class="action-links">
<ul>
<?php foreach ( $actions as $action ): ?>
<li><?php echo $action; ?></li>
<?php endforeach; ?>
<li class="hide-if-no-js"><a href="#" class="theme-detail" tabindex='4'><?php _e('Details') ?></a></li>
</ul>
</div>
<?php
$this->install_theme_info( $theme );
}
@ -277,15 +298,17 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
<?php if ( isset( $theme->screenshot_url ) ): ?>
<img class="theme-screenshot" src="<?php echo esc_url( $theme->screenshot_url ); ?>" />
<?php endif; ?>
<div class="theme-rating" title="<?php echo esc_attr( $num_ratings ); ?>">
<div style="width:<?php echo esc_attr( intval( $theme->rating ) . 'px' ); ?>;"></div>
</div>
<div class="theme-version">
<strong><?php _e('Version:') ?> </strong>
<?php echo wp_kses( $theme->version, $themes_allowedtags ); ?>
</div>
<div class="theme-description">
<?php echo wp_kses( $theme->description, $themes_allowedtags ); ?>
<div class="theme-details">
<div class="theme-rating" title="<?php echo esc_attr( $num_ratings ); ?>">
<div style="width:<?php echo esc_attr( intval( $theme->rating ) . 'px' ); ?>;"></div>
</div>
<div class="theme-version">
<strong><?php _e('Version:') ?> </strong>
<?php echo wp_kses( $theme->version, $themes_allowedtags ); ?>
</div>
<div class="theme-description">
<?php echo wp_kses( $theme->description, $themes_allowedtags ); ?>
</div>
</div>
<input class="theme-preview-url" type="hidden" value="<?php echo esc_url( $theme->preview_url ); ?>" />
</div>

View File

@ -5,7 +5,15 @@
*/
jQuery( function($) {
$('#availablethemes').on( 'click', '.theme-detail', function (event) {
$(this).parents('.action-links').siblings('.themedetaildiv').toggle();
var theme = $(this).closest('.available-theme'),
details = theme.find('.themedetaildiv');
if ( ! details.length ) {
details = theme.find('.install-theme-info .theme-details');
details = details.clone().addClass('themedetaildiv').appendTo( theme ).hide();
}
details.toggle();
event.preventDefault();
});
});
@ -34,10 +42,10 @@ jQuery( function($) {
event.preventDefault();
});
$('#availablethemes').on( 'click', '.installable-theme', function( event ) {
$('#availablethemes').on( 'click', '.install-theme-preview', function( event ) {
var src;
info.html( $(this).find('.install-theme-info').html() );
info.html( $(this).closest('.installable-theme').find('.install-theme-info').html() );
src = info.find( '.theme-preview-url' ).val();
panel.html( '<iframe src="' + src + '" />');
preview.fadeIn( 200, function() {