Make WordPress Core

Changeset 20096


Ignore:
Timestamp:
03/02/2012 10:26:58 PM (14 years ago)
Author:
nacin
Message:

Use sanitize_key() for theme search tags/features. sanitize_title_with_dashes() is overkill. see #19815.

File:
1 edited

Legend:

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

    r20094 r20096  
    88 * @access private
    99 */
    10 class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
     10class WP_Theme_Install_List_Table extends WP_List_Table {
    1111
    12         var $features = array();
     12        function __construct() {
     13                parent::__construct( array(
     14                        'ajax' => true,
     15                ) );
     16        }
    1317
    1418        function ajax_user_can() {
    15                 return current_user_can( 'install_themes' );
     19                return current_user_can('install_themes');
    1620        }
    1721
     
    1923                include( ABSPATH . 'wp-admin/includes/theme-install.php' );
    2024
    21                 global $tabs, $tab, $paged, $type, $theme_field_defaults;
     25                global $tabs, $tab, $paged, $type, $term, $theme_field_defaults;
     26
    2227                wp_reset_vars( array( 'tab' ) );
    23 
    24                 $search_terms = array();
    25                 $search_string = '';
    26                 if ( ! empty( $_REQUEST['s'] ) ){
    27                         $search_string = strtolower( stripslashes( $_REQUEST['s'] ) );
    28                         $search_terms = array_unique( array_filter( array_map( 'trim', explode( ',', $search_string ) ) ) );
    29                 }
    30 
    31                 if ( ! empty( $_REQUEST['features'] ) )
    32                         $this->features = $_REQUEST['features'];
    3328
    3429                $paged = $this->get_pagenum();
     
    6156                        case 'search':
    6257                                $type = isset( $_REQUEST['type'] ) ? stripslashes( $_REQUEST['type'] ) : '';
     58                                $term = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
     59
    6360                                switch ( $type ) {
    6461                                        case 'tag':
    65                                                 $args['tag'] = array_map( 'sanitize_title_with_dashes', $search_terms );
     62                                                $terms = explode( ',', $term );
     63                                                $terms = array_map( 'trim', $terms );
     64                                                $terms = array_map( 'sanitize_key', $terms );
     65                                                $args['tag'] = $terms;
    6666                                                break;
    6767                                        case 'term':
    68                                                 $args['search'] = $search_string;
     68                                                $args['search'] = $term;
    6969                                                break;
    7070                                        case 'author':
    71                                                 $args['author'] = $search_string;
     71                                                $args['author'] = $term;
    7272                                                break;
    7373                                }
    7474
    75                                 if ( ! empty( $this->features ) ) {
    76                                         $args['tag'] = $this->features;
    77                                         $_REQUEST['s'] = implode( ',', $this->features );
     75                                if ( !empty( $_REQUEST['features'] ) ) {
     76                                        $terms = $_REQUEST['features'];
     77                                        $terms = array_map( 'trim', $terms );
     78                                        $terms = array_map( 'sanitize_key', $terms );
     79                                        $args['tag'] = $terms;
     80                                        $_REQUEST['s'] = implode( ',', $terms );
    7881                                        $_REQUEST['type'] = 'tag';
    7982                                }
     
    9396                }
    9497
    95                 if ( ! $args )
     98                if ( !$args )
    9699                        return;
    97100
     
    106109                        'total_items' => $api->info['results'],
    107110                        'per_page' => $per_page,
    108                         'infinite_scroll' => true,
    109111                ) );
    110112        }
     
    127129        }
    128130
     131        function get_columns() {
     132                return array();
     133        }
     134
    129135        function display() {
     136
    130137                wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
    131138?>
     
    143150                </div>
    144151
    145                 <?php
    146                 parent::tablenav( 'bottom' );
     152                <div class="tablenav bottom themes">
     153                        <?php $this->pagination( 'bottom' ); ?>
     154                        <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading list-ajax-loading" alt="" />
     155                        <br class="clear" />
     156                </div>
     157<?php
    147158        }
    148159
     
    160171                <?php } // end foreach $theme_names
    161172        }
    162 
    163         /**
    164          * Send required variables to JavaScript land
    165          *
    166          * @since 3.4
    167          * @access private
    168          *
    169          * @uses $tab Global; current tab within Themes->Install screen
    170          * @uses $type Global; type of search.
    171          */
    172         function _js_vars() {
    173                 global $tab, $type;
    174                 parent::_js_vars( compact( $tab, $type ) );
    175         }
    176173}
Note: See TracChangeset for help on using the changeset viewer.