Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (7 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

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

    r41289 r42343  
    77 */
    88
    9 $themes_allowedtags = array('a' => array('href' => array(), 'title' => array(), 'target' => array()),
    10     'abbr' => array('title' => array()), 'acronym' => array('title' => array()),
    11     'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(),
    12     'div' => array(), 'p' => array(), 'ul' => array(), 'ol' => array(), 'li' => array(),
    13     'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(),
    14     'img' => array('src' => array(), 'class' => array(), 'alt' => array())
     9$themes_allowedtags = array(
     10    'a'       => array(
     11        'href'   => array(),
     12        'title'  => array(),
     13        'target' => array(),
     14    ),
     15    'abbr'    => array( 'title' => array() ),
     16    'acronym' => array( 'title' => array() ),
     17    'code'    => array(),
     18    'pre'     => array(),
     19    'em'      => array(),
     20    'strong'  => array(),
     21    'div'     => array(),
     22    'p'       => array(),
     23    'ul'      => array(),
     24    'ol'      => array(),
     25    'li'      => array(),
     26    'h1'      => array(),
     27    'h2'      => array(),
     28    'h3'      => array(),
     29    'h4'      => array(),
     30    'h5'      => array(),
     31    'h6'      => array(),
     32    'img'     => array(
     33        'src'   => array(),
     34        'class' => array(),
     35        'alt'   => array(),
     36    ),
    1537);
    1638
    17 $theme_field_defaults = array( 'description' => true, 'sections' => false, 'tested' => true, 'requires' => true,
    18     'rating' => true, 'downloaded' => true, 'downloadlink' => true, 'last_updated' => true, 'homepage' => true,
    19     'tags' => true, 'num_ratings' => true
     39$theme_field_defaults = array(
     40    'description'  => true,
     41    'sections'     => false,
     42    'tested'       => true,
     43    'requires'     => true,
     44    'rating'       => true,
     45    'downloaded'   => true,
     46    'downloadlink' => true,
     47    'last_updated' => true,
     48    'homepage'     => true,
     49    'tags'         => true,
     50    'num_ratings'  => true,
    2051);
    2152
     
    3263    _deprecated_function( __FUNCTION__, '3.1.0', 'get_theme_feature_list()' );
    3364
    34     if ( !$cache = get_transient( 'wporg_theme_feature_list' ) )
     65    if ( ! $cache = get_transient( 'wporg_theme_feature_list' ) ) {
    3566        set_transient( 'wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS );
    36 
    37     if ( $cache )
     67    }
     68
     69    if ( $cache ) {
    3870        return $cache;
     71    }
    3972
    4073    $feature_list = themes_api( 'feature_list', array() );
    41     if ( is_wp_error( $feature_list ) )
     74    if ( is_wp_error( $feature_list ) ) {
    4275        return array();
     76    }
    4377
    4478    set_transient( 'wporg_theme_feature_list', $feature_list, 3 * HOUR_IN_SECONDS );
     
    5791    $type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term';
    5892    $term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : '';
    59     if ( ! $type_selector )
     93    if ( ! $type_selector ) {
    6094        echo '<p class="install-help">' . __( 'Search for themes by keyword.' ) . '</p>';
     95    }
    6196    ?>
    6297<form id="search-themes" method="get">
    6398    <input type="hidden" name="tab" value="search" />
    6499    <?php if ( $type_selector ) : ?>
    65     <label class="screen-reader-text" for="typeselector"><?php _e('Type of search'); ?></label>
     100    <label class="screen-reader-text" for="typeselector"><?php _e( 'Type of search' ); ?></label>
    66101    <select name="type" id="typeselector">
    67     <option value="term" <?php selected('term', $type) ?>><?php _e('Keyword'); ?></option>
    68     <option value="author" <?php selected('author', $type) ?>><?php _e('Author'); ?></option>
    69     <option value="tag" <?php selected('tag', $type) ?>><?php _ex('Tag', 'Theme Installer'); ?></option>
     102    <option value="term" <?php selected( 'term', $type ); ?>><?php _e( 'Keyword' ); ?></option>
     103    <option value="author" <?php selected( 'author', $type ); ?>><?php _e( 'Author' ); ?></option>
     104    <option value="tag" <?php selected( 'tag', $type ); ?>><?php _ex( 'Tag', 'Theme Installer' ); ?></option>
    70105    </select>
    71     <label class="screen-reader-text" for="s"><?php
     106    <label class="screen-reader-text" for="s">
     107    <?php
    72108    switch ( $type ) {
    73109        case 'term':
     
    81117            break;
    82118    }
    83     ?></label>
     119    ?>
     120    </label>
    84121    <?php else : ?>
    85     <label class="screen-reader-text" for="s"><?php _e('Search by keyword'); ?></label>
     122    <label class="screen-reader-text" for="s"><?php _e( 'Search by keyword' ); ?></label>
    86123    <?php endif; ?>
    87     <input type="search" name="s" id="s" size="30" value="<?php echo esc_attr($term) ?>" autofocus="autofocus" />
     124    <input type="search" name="s" id="s" size="30" value="<?php echo esc_attr( $term ); ?>" autofocus="autofocus" />
    88125    <?php submit_button( __( 'Search' ), '', 'search', false ); ?>
    89126</form>
     
    99136    install_theme_search_form( false );
    100137?>
    101 <h4><?php _e('Feature Filter') ?></h4>
     138<h4><?php _e( 'Feature Filter' ); ?></h4>
    102139<p class="install-help"><?php _e( 'Find a theme based on specific features.' ); ?></p>
    103140
     
    115152        foreach ( $features as $feature => $feature_name ) {
    116153            $feature_name = esc_html( $feature_name );
    117             $feature = esc_attr($feature);
     154            $feature      = esc_attr( $feature );
    118155?>
    119156
     
    127164<br class="clear" />
    128165<?php
    129     } ?>
     166    }
     167    ?>
    130168
    131169</div>
     
    141179function install_themes_upload() {
    142180?>
    143 <p class="install-help"><?php _e('If you have a theme in a .zip format, you may install it by uploading it here.'); ?></p>
    144 <form method="post" enctype="multipart/form-data" class="wp-upload-form" action="<?php echo self_admin_url('update.php?action=upload-theme'); ?>">
     181<p class="install-help"><?php _e( 'If you have a theme in a .zip format, you may install it by uploading it here.' ); ?></p>
     182<form method="post" enctype="multipart/form-data" class="wp-upload-form" action="<?php echo self_admin_url( 'update.php?action=upload-theme' ); ?>">
    145183    <?php wp_nonce_field( 'theme-upload' ); ?>
    146184    <label class="screen-reader-text" for="themezip"><?php _e( 'Theme zip file' ); ?></label>
     
    164202    global $wp_list_table;
    165203    if ( ! isset( $wp_list_table ) ) {
    166         $wp_list_table = _get_list_table('WP_Theme_Install_List_Table');
     204        $wp_list_table = _get_list_table( 'WP_Theme_Install_List_Table' );
    167205    }
    168206    $wp_list_table->prepare_items();
     
    181219
    182220    if ( ! isset( $wp_list_table ) ) {
    183         $wp_list_table = _get_list_table('WP_Theme_Install_List_Table');
     221        $wp_list_table = _get_list_table( 'WP_Theme_Install_List_Table' );
    184222    }
    185223    $wp_list_table->prepare_items();
     
    200238    $theme = themes_api( 'theme_information', array( 'slug' => wp_unslash( $_REQUEST['theme'] ) ) );
    201239
    202     if ( is_wp_error( $theme ) )
     240    if ( is_wp_error( $theme ) ) {
    203241        wp_die( $theme );
    204 
    205     iframe_header( __('Theme Installation') );
     242    }
     243
     244    iframe_header( __( 'Theme Installation' ) );
    206245    if ( ! isset( $wp_list_table ) ) {
    207         $wp_list_table = _get_list_table('WP_Theme_Install_List_Table');
     246        $wp_list_table = _get_list_table( 'WP_Theme_Install_List_Table' );
    208247    }
    209248    $wp_list_table->theme_installer_single( $theme );
Note: See TracChangeset for help on using the changeset viewer.