Make WordPress Core


Ignore:
Timestamp:
11/13/2013 08:57:29 PM (11 years ago)
Author:
nacin
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/theme.php

    r25961 r26141  
    346346    return apply_filters( 'themes_api_result', $res, $action, $args );
    347347}
     348
     349/**
     350 * Prepare themes for JavaScript.
     351 *
     352 * @since 3.8.0
     353 *
     354 * @param array $themes Optional. Array of WP_Theme objects to prepare.
     355 *                      Defaults to all allowed themes.
     356 *
     357 * @return array An associative array of theme data.
     358 */
     359function wp_prepare_themes_for_js( $themes = null ) {
     360    if ( null === $themes ) {
     361        $themes = wp_get_themes( array( 'allowed' => true ) );
     362    }
     363
     364    $prepared_themes = array();
     365    $current_theme = get_stylesheet();
     366
     367    $updates = array();
     368    if ( current_user_can( 'update_themes' ) ) {
     369        $updates = get_site_transient( 'update_themes' );
     370        $updates = $updates->response;
     371    }
     372
     373    foreach( $themes as $slug => $theme ) {
     374        $parent = false;
     375        if ( $theme->parent() ) {
     376            $parent = $theme->parent()->display( 'Name' );
     377        }
     378
     379        $encoded_slug = urlencode( $slug );
     380
     381        $prepared_themes[] = array(
     382            'id'           => $slug,
     383            'name'         => $theme->display( 'Name' ),
     384            'screenshot'   => array( $theme->get_screenshot() ), // @todo multiple
     385            'description'  => $theme->display( 'Description' ),
     386            'author'       => $theme->get( 'Author' ),
     387            'authorURI'    => $theme->get( 'AuthorURI' ),
     388            'version'      => $theme->get( 'Version' ),
     389            'tags'         => $theme->get( 'Tags' ),
     390            'parent'       => $parent,
     391            'active'       => $slug === $current_theme,
     392            'hasUpdate'    => isset( $updates[ $slug ] ),
     393            'update'       => 'New version available', // @todo complete this
     394            'actions'      => array(
     395                'activate' => wp_nonce_url( 'themes.php?action=activate&stylesheet=' . $encoded_slug, 'switch-theme_' . $slug ),
     396                'customize'=> admin_url( 'customize.php?theme=' . $encoded_slug ),
     397                'delete'   => wp_nonce_url( 'themes.php?action=delete&stylesheet=' . $encoded_slug, 'delete-theme_' . $slug ),
     398            ),
     399        );
     400    }
     401    // var_dump( $prepared_themes );
     402
     403    return $prepared_themes;
     404}
Note: See TracChangeset for help on using the changeset viewer.