Make WordPress Core

Changeset 38033


Ignore:
Timestamp:
07/11/2016 09:49:30 PM (9 years ago)
Author:
swissspidy
Message:

Plugins: Improve Ajax search of installed plugins.

Fixes a few accessibility issues, tweaks the design of the search form to match other Ajax search fields and improves compatibility with older browsers.

See #37230.

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/css/common.css

    r37968 r38033  
    583583    font-size: 14px;
    584584    font-weight: 400;
     585    line-height: 1;
    585586}
    586587
  • trunk/src/wp-admin/css/forms.css

    r37740 r38033  
    565565}
    566566
     567.js.plugins-php .search-box .wp-filter-search {
     568    margin: 0;
     569    width: 280px;
     570    font-size: 16px;
     571    font-weight: 300;
     572    line-height: 1.5;
     573    padding: 3px 5px;
     574    height: 32px;
     575}
     576
    567577input[type="text"].ui-autocomplete-loading,
    568578input[type="email"].ui-autocomplete-loading {
  • trunk/src/wp-admin/includes/ajax-actions.php

    r38028 r38033  
    38113811    ob_start();
    38123812    $wp_list_table->display();
     3813    $status['count'] = count( $wp_list_table->items );
    38133814    $status['items'] = ob_get_clean();
    38143815
  • trunk/src/wp-admin/includes/class-wp-plugins-list-table.php

    r37961 r38033  
    340340        else
    341341            _e( 'You do not appear to have any plugins available at this time.' );
     342    }
     343
     344    /**
     345     * Display the search box.
     346     *
     347     * @since 4.6.0
     348     * @access public
     349     *
     350     * @param string $text The search button text
     351     * @param string $input_id The search input id
     352     */
     353    public function search_box( $text, $input_id ) {
     354        if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) {
     355            return;
     356        }
     357
     358        $input_id = $input_id . '-search-input';
     359
     360        if ( ! empty( $_REQUEST['orderby'] ) ) {
     361            echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
     362        }
     363        if ( ! empty( $_REQUEST['order'] ) ) {
     364            echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
     365        }
     366        ?>
     367        <p class="search-box">
     368            <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
     369            <input type="search" id="<?php echo $input_id ?>" class="wp-filter-search" name="s" value="<?php _admin_search_query(); ?>" placeholder="<?php echo esc_attr( 'Search installed plugins...' ); ?>"/>
     370            <input type="submit" id="search-submit" class="button hide-if-js" value="<?php echo esc_attr( $text ); ?>">
     371        </p>
     372        <?php
    342373    }
    343374
  • trunk/src/wp-admin/js/updates.js

    r37976 r38033  
    15851585        var $pluginFilter    = $( '#plugin-filter' ),
    15861586            $bulkActionForm  = $( '#bulk-action-form' ),
    1587             $filesystemModal = $( '#request-filesystem-credentials-dialog' );
     1587            $filesystemModal = $( '#request-filesystem-credentials-dialog' ),
     1588            $pluginSearch    = $( '.plugins-php .wp-filter-search' );
    15881589
    15891590        /*
     
    19731974         * @since 4.6.0
    19741975         */
    1975         $( 'input.wp-filter-search, .wp-filter input[name="s"]' ).on( 'keyup search', _.debounce( function() {
     1976        $( '.plugin-install-php .wp-filter-search' ).on( 'keyup search', _.debounce( function() {
    19761977            var $form = $( '#plugin-filter' ).empty(),
    19771978                data  = _.extend( {
     
    19881989            }
    19891990
    1990             history.pushState( null, '', location.href.split( '?' )[0] + '?' + $.param( _.omit( data, '_ajax_nonce' ) ) );
     1991            if ( history.pushState ) {
     1992                history.pushState( null, '', location.href.split( '?' )[ 0 ] + '?' + $.param( _.omit( data, '_ajax_nonce' ) ) );
     1993            }
    19911994
    19921995            if ( 'undefined' !== typeof wp.updates.searchRequest ) {
     
    20022005        }, 500 ) );
    20032006
     2007        if ( $pluginSearch.length > 0 ) {
     2008            $pluginSearch.attr( 'aria-describedby', 'live-search-desc' );
     2009        }
     2010
    20042011        /**
    20052012         * Handles changes to the plugin search box on the Installed Plugins screen,
     
    20082015         * @since 4.6.0
    20092016         */
    2010         $( '#plugin-search-input' ).on( 'keyup search', _.debounce( function() {
     2017        $pluginSearch.on( 'keyup input', _.debounce( function( event ) {
    20112018            var data = {
    20122019                _ajax_nonce: wp.updates.ajaxNonce,
    2013                 s:           $( '<p />' ).html( $( this ).val() ).text()
     2020                s:           event.target.value
    20142021            };
     2022
     2023            // Clear on escape.
     2024            if ( 'keyup' === event.type && 27 === event.which ) {
     2025                event.target.value = '';
     2026            }
    20152027
    20162028            if ( wp.updates.searchTerm === data.s ) {
     
    20202032            }
    20212033
    2022             history.pushState( null, '', location.href.split( '?' )[0] + '?s=' + data.s );
     2034            if ( history.pushState ) {
     2035                history.pushState( null, '', location.href.split( '?' )[ 0 ] + '?s=' + data.s );
     2036            }
    20232037
    20242038            if ( 'undefined' !== typeof wp.updates.searchRequest ) {
     
    20462060                $bulkActionForm.append( response.items );
    20472061                delete wp.updates.searchRequest;
     2062
     2063                if ( 0 === response.count ) {
     2064                    wp.a11y.speak( wp.updates.l10n.noPluginsFound );
     2065                } else {
     2066                    wp.a11y.speak( wp.updates.l10n.pluginsFound.replace( '%d', response.count ) );
     2067                }
    20482068            } );
    20492069        }, 500 ) );
  • trunk/src/wp-admin/plugins.php

    r37914 r38033  
    372372'content'   =>
    373373    '<p>' . __('Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.') . '</p>' .
     374    '<p>' . __( 'The search for installed plugins will search for terms in their name, description, or author.' ) . ' <span id="live-search-desc" class="hide-if-no-js">' . __( 'The search results will be updated as you type.' ) . '</span></p>' .
    374375    '<p>' . sprintf(
    375376        /* translators: %s: WordPress Plugin Directory URL */
  • trunk/src/wp-includes/script-loader.php

    r37940 r38033  
    654654                'activateImporter'           => __( 'Activate importer' ),
    655655                'unknownError'               => __( 'An unknown error occured' ),
     656                'pluginsFound'               => __( 'Number of plugins found: %d' ),
     657                'noPluginsFound'             => __( 'No plugins found. Try a different search.' ),
    656658            ),
    657659        ) );
  • trunk/tests/qunit/fixtures/updates.js

    r37714 r38033  
    4040        'activateTheme': 'Activate',
    4141        'activateImporter': 'Activate importer',
    42         'unknownError': 'An unknown error occured'
     42        'unknownError': 'An unknown error occured',
     43        'pluginsFound': 'Number of plugins found: %d',
     44        'noPluginsFound': 'No plugins found. Try a different search.'
    4345    }
    4446};
Note: See TracChangeset for help on using the changeset viewer.