Make WordPress Core

Changeset 15655


Ignore:
Timestamp:
09/24/2010 03:28:28 PM (14 years ago)
Author:
ryan
Message:

get_theme_feature_list() replaces install_themes_feature_list(). Does translation and works if feature_list is not accessible from api.wordpress.org. see #14936

Location:
trunk/wp-admin/includes
Files:
2 edited

Legend:

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

    r15519 r15655  
    7070 *
    7171 * @since 2.8.0
     72 *
     73 * @deprecated since 3.1.0  Use get_theme_feature_list() instead.
    7274 *
    7375 * @return array
     
    125127<p class="install-help"><?php _e('Find a theme based on specific features') ?></p>
    126128    <?php
    127     $feature_list = install_themes_feature_list( );
     129    $feature_list = get_theme_feature_list( );
    128130    echo '<div class="feature-filter">';
    129     $trans = array ('Colors' => __('Colors'), 'black' => __('Black'), 'blue' => __('Blue'), 'brown' => __('Brown'),
    130         'green' => __('Green'), 'orange' => __('Orange'), 'pink' => __('Pink'), 'purple' => __('Purple'), 'red' => __('Red'),
    131         'silver' => __('Silver'), 'tan' => __('Tan'), 'white' => __('White'), 'yellow' => __('Yellow'), 'dark' => __('Dark'),
    132         'light' => __('Light'), 'Columns' => __('Columns'), 'one-column' => __('One Column'), 'two-columns' => __('Two Columns'),
    133         'three-columns' => __('Three Columns'), 'four-columns' => __('Four Columns'), 'left-sidebar' => __('Left Sidebar'),
    134         'right-sidebar' => __('Right Sidebar'), 'Width' => __('Width'), 'fixed-width' => __('Fixed Width'), 'flexible-width' => __('Flexible Width'),
    135         'Features' => __('Features'), 'custom-colors' => __('Custom Colors'), 'custom-header' => __('Custom Header'), 'theme-options' => __('Theme Options'),
    136         'threaded-comments' => __('Threaded Comments'), 'sticky-post' => __('Sticky Post'), 'microformats' => __('Microformats'),
    137         'Subject' => __('Subject'), 'holiday' => __('Holiday'), 'photoblogging' => __('Photoblogging'), 'seasonal' => __('Seasonal'),
    138     );
    139131
    140132    foreach ( (array) $feature_list as $feature_name => $features ) {
    141         if ( isset($trans[$feature_name]) )
    142              $feature_name = $trans[$feature_name];
    143133        $feature_name = esc_html( $feature_name );
    144134        echo '<div class="feature-name">' . $feature_name . '</div>';
    145135
    146136        echo '<ol style="float: left; width: 725px;" class="feature-group">';
    147         foreach ( $features as $feature ) {
    148             $feature_name = $feature;
    149             if ( isset($trans[$feature]) )
    150                 $feature_name = $trans[$feature];
     137        foreach ( $features as $feature => $feature_name ) {
    151138            $feature_name = esc_html( $feature_name );
    152139            $feature = esc_attr($feature);
  • trunk/wp-admin/includes/theme.php

    r15300 r15655  
    251251}
    252252
     253/**
     254 * Retrieve list of WordPress theme features (aka theme tags)
     255 *
     256 * @since 3.1.0
     257 *
     258 * @return array  Array of features keyed by category with translations keyed by slug.
     259 */
     260function get_theme_feature_list() {
     261    // Hard-coded list is used if api not accessible.
     262    $features = array(
     263            __('Colors') => array(
     264                'black'   => __( 'Black' ),
     265                'blue'    => __( 'Blue' ),
     266                'brown'   => __( 'Brown' ),
     267                'green'   => __( 'Green' ),
     268                'orange'  => __( 'Orange' ),
     269                'pink'    => __( 'Pink' ),
     270                'purple'  => __( 'Purple' ),
     271                'red'     => __( 'Red' ),
     272                'silver'  => __( 'Silver' ),
     273                'tan'     => __( 'Tan' ),
     274                'white'   => __( 'White' ),
     275                'yellow'  => __( 'Yellow' ),
     276                'dark'    => __( 'Dark' ),
     277                'light'   => __( 'Light ')
     278            ),
     279
     280        __('Columns') => array(
     281            'one-column'    => __( 'One Column' ),
     282            'two-columns'   => __( 'Two Columns' ),
     283            'three-columns' => __( 'Three Columns' ),
     284            'four-columns'  => __( 'Four Columns' ),
     285            'left-sidebar'  => __( 'Left Sidebar' ),
     286            'right-sidebar' => __( 'Right Sidebar' )
     287        ),
     288
     289        __('Width') => array(
     290            'fixed-width'    => __( 'Fixed Width' ),
     291            'flexible-width' => __( 'Flexible Width' )
     292        ),
     293
     294        __( 'Features' ) => array(
     295            'blavatar'             => __( 'Blavatar' ),
     296            'buddypress'           => __( 'BuddyPress' ),
     297            'custom-background'    => __( 'Custom Background' ),
     298            'custom-colors'        => __( 'Custom Colors' ),
     299            'custom-header'        => __( 'Custom Header' ),
     300            'custom-menu'          => __( 'Custom Menu' ),
     301            'editor-style'         => __( 'Editor Style' ),
     302            'front-page-post-form' => __( 'Front Page Posting' ),
     303            'microformats'         => __( 'Microformats' ),
     304            'sticky-post'          => __( 'Sticky Post' ),
     305            'theme-options'        => __( 'Theme Options' ),
     306            'threaded-comments'    => __( 'Threaded Comments' ),
     307            'translation-ready'    => __( 'Translation Ready' ),
     308            'rtl-language-support' => __( 'RTL Language Support' )
     309        ),
     310
     311        __( 'Subject' )  => array(
     312            'holiday' => __( 'Holiday' ),
     313            'photoblogging' => __( 'Photoblogging' ),
     314            'seasonal' => __( 'Seasonal' )
     315        )
     316    );
     317
     318    if ( !current_user_can('install_themes') )
     319        return $features;
     320
     321    if ( !$feature_list = get_site_transient( 'wporg_theme_feature_list' ) )
     322        set_site_transient( 'wporg_theme_feature_list', array( ),  10800);
     323
     324    if ( !$feature_list ) {
     325        $feature_list = themes_api( 'feature_list', array( ) );
     326        if ( is_wp_error( $feature_list ) )
     327            return $features;
     328    }
     329
     330    if ( !$feature_list )
     331        return $features;
     332
     333    set_site_transient( 'wporg_theme_feature_list', $feature_list, 10800 );
     334
     335    $category_translations = array( 'Colors' => __('Colors'), 'Columns' => __('Columns'), 'Width' => __('Width'),
     336                                   'Features' => __('Features'), 'Subject' => __('Subject') );
     337
     338    // Loop over the wporg canonical list and apply translations
     339    $wporg_features = array();
     340    foreach ( (array) $feature_list as $feature_category => $feature_items ) {
     341        if ( isset($category_translations[$feature_category]) )
     342            $feature_category = $category_translations[$feature_category];
     343        $wporg_features[$feature_category] = array();
     344
     345        foreach ( $feature_items as $feature ) {
     346            if ( isset($features[$feature_category][$feature]) )
     347                $wporg_features[$feature_category][$feature] = $features[$feature_category][$feature];
     348            else
     349                $wporg_features[$feature_category][$feature] = $feature;
     350        }
     351    }
     352
     353    return $wporg_features;
     354}
     355
    253356?>
Note: See TracChangeset for help on using the changeset viewer.