Update the Themes screen, merging THX into core.

* Name: THX38
 * Description: Update the Themes screen with a new design and experience.
 * Tags: visually-focused, bigger-screenshots, fast, mobile-friendly, backbone-driven
 * Author: matveb, shaunandrews, melchoyce, designsimply, shelob9
 * URI: http://wordpress.org/plugins/thx38/

fixes #25948



git-svn-id: https://develop.svn.wordpress.org/trunk@26141 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin
2013-11-13 20:57:29 +00:00
parent e00060118b
commit 12ccb6d136
6 changed files with 1144 additions and 381 deletions

View File

@@ -345,3 +345,60 @@ function themes_api( $action, $args = null ) {
*/
return apply_filters( 'themes_api_result', $res, $action, $args );
}
/**
* Prepare themes for JavaScript.
*
* @since 3.8.0
*
* @param array $themes Optional. Array of WP_Theme objects to prepare.
* Defaults to all allowed themes.
*
* @return array An associative array of theme data.
*/
function wp_prepare_themes_for_js( $themes = null ) {
if ( null === $themes ) {
$themes = wp_get_themes( array( 'allowed' => true ) );
}
$prepared_themes = array();
$current_theme = get_stylesheet();
$updates = array();
if ( current_user_can( 'update_themes' ) ) {
$updates = get_site_transient( 'update_themes' );
$updates = $updates->response;
}
foreach( $themes as $slug => $theme ) {
$parent = false;
if ( $theme->parent() ) {
$parent = $theme->parent()->display( 'Name' );
}
$encoded_slug = urlencode( $slug );
$prepared_themes[] = array(
'id' => $slug,
'name' => $theme->display( 'Name' ),
'screenshot' => array( $theme->get_screenshot() ), // @todo multiple
'description' => $theme->display( 'Description' ),
'author' => $theme->get( 'Author' ),
'authorURI' => $theme->get( 'AuthorURI' ),
'version' => $theme->get( 'Version' ),
'tags' => $theme->get( 'Tags' ),
'parent' => $parent,
'active' => $slug === $current_theme,
'hasUpdate' => isset( $updates[ $slug ] ),
'update' => 'New version available', // @todo complete this
'actions' => array(
'activate' => wp_nonce_url( 'themes.php?action=activate&stylesheet=' . $encoded_slug, 'switch-theme_' . $slug ),
'customize'=> admin_url( 'customize.php?theme=' . $encoded_slug ),
'delete' => wp_nonce_url( 'themes.php?action=delete&stylesheet=' . $encoded_slug, 'delete-theme_' . $slug ),
),
);
}
// var_dump( $prepared_themes );
return $prepared_themes;
}