WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/20/2016 04:31:50 PM (4 years ago)
Author:
ocean90
Message:

Plugins: Improve Ajax search of new plugins.

Fixes a few accessibility issues, restores the "Search Results" tab and the search type selector, and improves compatibility with older browsers.

Props rahulsprajapati, swissspidy, adamsilverstein, ocean90
See #37233.

File:
1 edited

Legend:

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

    r38025 r38119  
    215215    <?php display_plugins_table(); ?>
    216216
     217    <div class="plugins-popular-tags-wrapper">
    217218    <h2><?php _e( 'Popular tags' ) ?></h2>
    218219    <p><?php _e( 'You may also browse based on the most popular tags in the Plugin Directory:' ) ?></p>
     
    240241        echo wp_generate_tag_cloud($tags, array( 'single_text' => __('%s plugin'), 'multiple_text' => __('%s plugins') ) );
    241242    }
    242     echo '</p><br class="clear" />';
    243 }
    244 
    245 /**
    246  * Display search form for searching plugins.
     243    echo '</p><br class="clear" /></div>';
     244}
     245
     246/**
     247 * Displays a search form for searching plugins.
    247248 *
    248249 * @since 2.7.0
    249  *
    250  * @param bool $type_selector
    251  */
    252 function install_search_form( $type_selector = true ) {
    253     $type = isset($_REQUEST['type']) ? wp_unslash( $_REQUEST['type'] ) : 'term';
    254     $term = isset($_REQUEST['s']) ? wp_unslash( $_REQUEST['s'] ) : '';
    255     $input_attrs = '';
    256     $button_type = 'button screen-reader-text';
    257 
    258     // assume no $type_selector means it's a simplified search form
    259     if ( ! $type_selector ) {
    260         $input_attrs = 'class="wp-filter-search" placeholder="' . esc_attr__( 'Search Plugins' ) . '" ';
    261     }
    262 
     250 * @since 4.6.0 The `$type_selector` parameter was deprecated.
     251 *
     252 * @param bool $deprecated Not used.
     253 */
     254function install_search_form( $deprecated = true ) {
     255    $type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term';
     256    $term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : '';
    263257    ?><form class="search-form search-plugins" method="get">
    264258        <input type="hidden" name="tab" value="search" />
    265         <?php if ( $type_selector ) : ?>
     259        <label class="screen-reader-text" for="typeselector"><?php _e( 'Search plugins by:' ); ?></label>
    266260        <select name="type" id="typeselector">
    267             <option value="term"<?php selected('term', $type) ?>><?php _e('Keyword'); ?></option>
    268             <option value="author"<?php selected('author', $type) ?>><?php _e('Author'); ?></option>
    269             <option value="tag"<?php selected('tag', $type) ?>><?php _ex('Tag', 'Plugin Installer'); ?></option>
     261            <option value="term"<?php selected( 'term', $type ); ?>><?php _e( 'Keyword' ); ?></option>
     262            <option value="author"<?php selected( 'author', $type ); ?>><?php _e( 'Author' ); ?></option>
     263            <option value="tag"<?php selected( 'tag', $type ); ?>><?php _ex( 'Tag', 'Plugin Installer' ); ?></option>
    270264        </select>
    271         <?php endif; ?>
    272         <label><span class="screen-reader-text"><?php _e('Search Plugins'); ?></span>
    273             <input type="search" name="s" value="<?php echo esc_attr($term) ?>" <?php echo $input_attrs; ?>/>
     265        <label><span class="screen-reader-text"><?php _e( 'Search Plugins' ); ?></span>
     266            <input type="search" name="s" value="<?php echo esc_attr( $term ) ?>" class="wp-filter-search" placeholder="<?php esc_attr_e( 'Search Plugins' ); ?>" />
    274267        </label>
    275         <?php submit_button( __( 'Search Plugins' ), $button_type, false, false, array( 'id' => 'search-submit' ) ); ?>
     268        <?php submit_button( __( 'Search Plugins' ), 'button hide-if-js', false, false, array( 'id' => 'search-submit' ) ); ?>
    276269    </form><?php
    277270}
Note: See TracChangeset for help on using the changeset viewer.