diff --git a/wp-admin/css/wp-admin.dev.css b/wp-admin/css/wp-admin.dev.css index a0c26600b8..94d22b7d6a 100644 --- a/wp-admin/css/wp-admin.dev.css +++ b/wp-admin/css/wp-admin.dev.css @@ -5366,10 +5366,17 @@ body.full-overlay-active { display: none; } +#theme-installer.single-theme { + display: block; +} + .install-theme-info { display: none; padding: 45px 20px 15px; } +.single-theme .install-theme-info { + padding-top: 15px; +} #theme-installer .install-theme-info { display: block; diff --git a/wp-admin/includes/class-wp-theme-install-list-table.php b/wp-admin/includes/class-wp-theme-install-list-table.php index 7b8b493c79..7c66c88c49 100644 --- a/wp-admin/includes/class-wp-theme-install-list-table.php +++ b/wp-admin/includes/class-wp-theme-install-list-table.php @@ -151,14 +151,70 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table { $theme_names = array_keys( $themes ); foreach ( $theme_names as $theme_name ) { - $class = array( 'available-theme' ); ?> -
theme_installer(); + } + + + + /* + * Prints a theme from the WordPress.org API. + * + * @param object $theme An object that contains theme data returned by the WordPress.org API. + * + * Example theme data: + * object(stdClass)[59] + * public 'name' => string 'Magazine Basic' (length=14) + * public 'slug' => string 'magazine-basic' (length=14) + * public 'version' => string '1.1' (length=3) + * public 'author' => string 'tinkerpriest' (length=12) + * public 'preview_url' => string 'http://wp-themes.com/?magazine-basic' (length=36) + * public 'screenshot_url' => string 'http://wp-themes.com/wp-content/themes/magazine-basic/screenshot.png' (length=68) + * public 'rating' => float 80 + * public 'num_ratings' => int 1 + * public 'homepage' => string 'http://wordpress.org/extend/themes/magazine-basic' (length=49) + * public 'description' => string 'A basic magazine style layout with a fully customizable layout through a backend interface. Designed by c.bavota of Tinker Priest Media.' (length=214) + * public 'download_link' => string 'http://wordpress.org/extend/themes/download/magazine-basic.1.1.zip' (length=66) + */ + function single_row( $theme ) { + global $themes_allowedtags; + + if ( empty( $theme ) ) + return; + + $name = wp_kses( $theme->name, $themes_allowedtags ); + $author = wp_kses( $theme->author, $themes_allowedtags ); + + $preview_title = sprintf( __('Preview “%s”'), $name ); + $preview_url = add_query_arg( array( + 'tab' => 'theme-information', + 'theme' => $theme->slug, + ) ); + + ?> + + + + +

by %2$s' ), $name, $author ); + ?>

+ + install_theme_info( $theme ); + } + + /* + * Prints the wrapper for the theme installer. + */ + function theme_installer() { ?>
@@ -172,6 +228,73 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table { +
+
+ install_theme_info( $theme ); ?> +
+
+ +
+
+ name, $themes_allowedtags ); + $author = wp_kses( $theme->author, $themes_allowedtags ); + + $num_ratings = sprintf( _n( '(based on %s rating)', '(based on %s ratings)', $theme->num_ratings ), number_format_i18n( $theme->num_ratings ) ); + + $install_url = add_query_arg( array( + 'action' => 'install-theme', + 'theme' => $theme->slug, + ), self_admin_url( 'update.php' ) ); + + ?> +
+ +

+ + screenshot_url ) ): ?> + + +
+
+
+
+ + version, $themes_allowedtags ); ?> +
+
+ description, $themes_allowedtags ); ?> +
+ +
+ string 'Magazine Basic' (length=14) - * public 'slug' => string 'magazine-basic' (length=14) - * public 'version' => string '1.1' (length=3) - * public 'author' => string 'tinkerpriest' (length=12) - * public 'preview_url' => string 'http://wp-themes.com/?magazine-basic' (length=36) - * public 'screenshot_url' => string 'http://wp-themes.com/wp-content/themes/magazine-basic/screenshot.png' (length=68) - * public 'rating' => float 80 - * public 'num_ratings' => int 1 - * public 'homepage' => string 'http://wordpress.org/extend/themes/magazine-basic' (length=49) - * public 'description' => string 'A basic magazine style layout with a fully customizable layout through a backend interface. Designed by c.bavota of Tinker Priest Media.' (length=214) - * public 'download_link' => string 'http://wordpress.org/extend/themes/download/magazine-basic.1.1.zip' (length=66) */ function display_theme( $theme ) { - global $themes_allowedtags; + global $wp_list_table; - if ( empty( $theme ) ) - return; - - $name = wp_kses( $theme->name, $themes_allowedtags ); - $author = wp_kses( $theme->author, $themes_allowedtags ); - - $num_ratings = sprintf( _n( '(based on %s rating)', '(based on %s ratings)', $theme->num_ratings ), number_format_i18n( $theme->num_ratings ) ); - - $preview_url = add_query_arg( 'theme_preview', '1' ); - $preview_title = sprintf( __('Preview “%s”'), $name ); - - $install_url = add_query_arg( array( - 'action' => 'install-theme', - 'theme' => $theme->slug, - ), self_admin_url( 'update.php' ) ); - - ?> - - - - -

by %2$s' ), $name, $author ); - ?>

- -
- -

- - -
-
-
-
- - version, $themes_allowedtags ); ?> -
-
- description, $themes_allowedtags ); ?> -
- -
- single_row( $theme ); } /** @@ -216,104 +159,13 @@ add_action('install_themes_updated', 'display_themes'); * @since 2.8.0 */ function install_theme_information() { - //TODO: This function needs a LOT of UI work :) - global $tab, $themes_allowedtags; + global $tab, $themes_allowedtags, $wp_list_table; - $api = themes_api('theme_information', array('slug' => stripslashes( $_REQUEST['theme'] ) )); + $theme = themes_api( 'theme_information', array( 'slug' => stripslashes( $_REQUEST['theme'] ) ) ); - if ( is_wp_error($api) ) - wp_die($api); + if ( is_wp_error( $theme ) ) + wp_die( $theme ); - // Sanitize HTML - foreach ( (array)$api->sections as $section_name => $content ) - $api->sections[$section_name] = wp_kses($content, $themes_allowedtags); - - foreach ( array('version', 'author', 'requires', 'tested', 'homepage', 'downloaded', 'slug') as $key ) { - if ( isset($api->$key) ) - $api->$key = wp_kses($api->$key, $themes_allowedtags); - } - - iframe_header( __('Theme Install') ); - - if ( empty($api->download_link) ) { - echo '

' . __('ERROR: This theme is currently not available. Please try again later.') . '

'; - iframe_footer(); - exit; - } - - if ( !empty($api->tested) && version_compare($GLOBALS['wp_version'], $api->tested, '>') ) - echo '

' . __('Warning: This theme has not been tested with your current version of WordPress.') . '

'; - else if ( !empty($api->requires) && version_compare($GLOBALS['wp_version'], $api->requires, '<') ) - echo '

' . __('Warning: This theme has not been marked as compatible with your version of WordPress.') . '

'; - - // Default to a "new" theme - $type = 'install'; - // Check to see if this theme is known to be installed, and has an update awaiting it. - $update_themes = get_site_transient('update_themes'); - if ( is_object($update_themes) && isset($update_themes->response) ) { - foreach ( (array)$update_themes->response as $theme_slug => $theme_info ) { - if ( $theme_slug === $api->slug ) { - $type = 'update_available'; - $update_file = $theme_slug; - break; - } - } - } - - $theme = wp_get_theme( $api->slug ); - if ( is_a( $theme, 'WP_Theme' ) ) { - switch ( version_compare( $theme->get('Version'), $api->version ) ) { - case 0; // equal - $type = 'latest_installed'; - case 1: // installed theme > api version - $type = 'newer_installed'; - $newer_version = $theme->get('Version'); - } - } -?> - -
- -

name; ?>

-

author); ?>

-

version); ?>

- -' . __('Cancel') . ' '; - -switch ( $type ) { -default: -case 'install': - if ( current_user_can('install_themes') ) : - $buttons .= '' . __('Install Now') . ''; - endif; - break; -case 'update_available': - if ( current_user_can('update_themes') ) : - $buttons .= '' . __('Install Update Now') . ''; - endif; - break; -case 'newer_installed': - if ( current_user_can('install_themes') || current_user_can('update_themes') ) : - ?>

-
-
- -

- -
-

- -theme_installer_single( $theme ); } add_action('install_themes_pre_theme-information', 'install_theme_information'); diff --git a/wp-admin/js/theme.dev.js b/wp-admin/js/theme.dev.js index 36e1389752..65addc9270 100644 --- a/wp-admin/js/theme.dev.js +++ b/wp-admin/js/theme.dev.js @@ -22,7 +22,7 @@ jQuery( function($) { event.preventDefault(); }); - $('#availablethemes').on( 'click', '.available-theme', function( event ) { + $('#availablethemes').on( 'click', '.installable-theme', function( event ) { var src; info.html( $(this).find('.install-theme-info').html() );