Make WordPress Core

Ticket #37233: 37233.2.diff

File 37233.2.diff, 9.2 KB (added by swissspidy, 9 years ago)
  • src/wp-admin/includes/ajax-actions.php

    diff --git src/wp-admin/includes/ajax-actions.php src/wp-admin/includes/ajax-actions.php
    index 9751bc5..f4487c0 100644
    function wp_ajax_search_install_plugins() { 
    38513851
    38523852        ob_start();
    38533853        $wp_list_table->display();
     3854        $status['count'] = (int) $wp_list_table->get_pagination_arg( 'total_items' );
    38543855        $status['items'] = ob_get_clean();
    38553856
    38563857        wp_send_json_success( $status );
  • src/wp-admin/includes/class-wp-plugin-install-list-table.php

    diff --git src/wp-admin/includes/class-wp-plugin-install-list-table.php src/wp-admin/includes/class-wp-plugin-install-list-table.php
    index d917fbd..5c9d6cf 100644
    class WP_Plugin_Install_List_Table extends WP_List_Table { 
    285285                ?>
    286286        </ul>
    287287
    288         <?php install_search_form( isset( $views['plugin-install-search'] ) ); ?>
     288        <?php install_search_form(); ?>
    289289</div>
    290290<?php
    291291        }
  • src/wp-admin/includes/plugin-install.php

    diff --git src/wp-admin/includes/plugin-install.php src/wp-admin/includes/plugin-install.php
    index f99cfce..d6c3ffe 100644
    function install_dashboard() { 
    246246 * Display search form for searching plugins.
    247247 *
    248248 * @since 2.7.0
     249 * @since 4.6.0 The optional `$type_selector` parameter was deprecated and renamed to `$deprecated`.
    249250 *
    250  * @param bool $type_selector
     251 * @param bool $deprecated Not used.
    251252 */
    252 function install_search_form( $type_selector = true ) {
     253function install_search_form( $deprecated = true ) {
    253254        $type = isset($_REQUEST['type']) ? wp_unslash( $_REQUEST['type'] ) : 'term';
    254255        $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 
    263256        ?><form class="search-form search-plugins" method="get">
    264257                <input type="hidden" name="tab" value="search" />
    265                 <?php if ( $type_selector ) : ?>
    266258                <select name="type" id="typeselector">
    267259                        <option value="term"<?php selected('term', $type) ?>><?php _e('Keyword'); ?></option>
    268260                        <option value="author"<?php selected('author', $type) ?>><?php _e('Author'); ?></option>
    269261                        <option value="tag"<?php selected('tag', $type) ?>><?php _ex('Tag', 'Plugin Installer'); ?></option>
    270262                </select>
    271                 <?php endif; ?>
    272263                <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; ?>/>
     264                        <input type="search" name="s" value="<?php echo esc_attr($term) ?>" class="wp-filter-search" placeholder="<?php esc_attr__( 'Search Plugins' ); ?>" />
    274265                </label>
    275                 <?php submit_button( __( 'Search Plugins' ), $button_type, false, false, array( 'id' => 'search-submit' ) ); ?>
     266                <input type="submit" id="search-submit" class="button hide-if-js" value="<?php echo esc_attr__( 'Search Plugins' ); ?>">
    276267        </form><?php
    277268}
    278269
  • src/wp-admin/js/updates.js

    diff --git src/wp-admin/js/updates.js src/wp-admin/js/updates.js
    index 24a8186..24db8af 100644
     
    15901590        };
    15911591
    15921592        $( function() {
    1593                 var $pluginFilter    = $( '#plugin-filter' ),
    1594                         $bulkActionForm  = $( '#bulk-action-form' ),
    1595                         $filesystemModal = $( '#request-filesystem-credentials-dialog' ),
    1596                         $pluginSearch    = $( '.plugins-php .wp-filter-search' );
     1593                var $pluginFilter        = $( '#plugin-filter' ),
     1594                    $bulkActionForm      = $( '#bulk-action-form' ),
     1595                    $filesystemModal     = $( '#request-filesystem-credentials-dialog' ),
     1596                    $pluginSearch        = $( '.plugins-php .wp-filter-search' ),
     1597                    $pluginInstallSearch = $( '.plugin-install-php .wp-filter-search' );
    15971598
    15981599                /*
    15991600                 * Whether a user needs to submit filesystem credentials.
     
    19751976                        wp.updates.queueChecker();
    19761977                } );
    19771978
     1979                if ( $pluginInstallSearch.length > 0 ) {
     1980                        $pluginInstallSearch.attr( 'aria-describedby', 'live-search-desc' );
     1981                }
     1982
    19781983                /**
    19791984                 * Handles changes to the plugin search box on the new-plugin page,
    19801985                 * searching the repository dynamically.
    19811986                 *
    19821987                 * @since 4.6.0
    19831988                 */
    1984                 $( '.plugin-install-php .wp-filter-search' ).on( 'keyup search', _.debounce( function() {
    1985                         var $form = $( '#plugin-filter' ).empty(),
    1986                                 data  = _.extend( {
    1987                                         _ajax_nonce: wp.updates.ajaxNonce,
    1988                                         s:           $( '<p />' ).html( $( this ).val() ).text(),
    1989                                         tab:         'search',
    1990                                         type:        $( '#typeselector' ).val()
    1991                                 }, { type: 'term' } );
     1989                $pluginInstallSearch.on( 'keyup search', _.debounce( function( event ) {
     1990                        var $form          = $( '#plugin-filter' ),
     1991                            $searchTab     = $( '.plugin-install-search' ),
     1992                            data           = {
     1993                                    _ajax_nonce: wp.updates.ajaxNonce,
     1994                                    s:           event.target.value,
     1995                                    tab:         'search',
     1996                                    type:        $( '#typeselector' ).val()
     1997                            },
     1998                            searchLocation = location.href.split( '?' )[ 0 ] + '?' + $.param( _.omit( data, '_ajax_nonce' ) );
     1999
     2000                        // Clear on escape.
     2001                        if ( 'keyup' === event.type && 27 === event.which ) {
     2002                                event.target.value = '';
     2003                        }
    19922004
    19932005                        if ( wp.updates.searchTerm === data.s ) {
    19942006                                return;
    19952007                        } else {
     2008                                $form.empty();
    19962009                                wp.updates.searchTerm = data.s;
    19972010                        }
    19982011
    19992012                        if ( history.pushState ) {
    2000                                 history.pushState( null, '', location.href.split( '?' )[ 0 ] + '?' + $.param( _.omit( data, '_ajax_nonce' ) ) );
     2013                                history.pushState( null, '', searchLocation );
     2014                        }
     2015
     2016                        if ( ! $searchTab.length ) {
     2017                                $searchTab = $( '<li class="plugin-install-search"><a></a></li>' );
     2018                                $searchTab.find( 'a' )
     2019                                        .addClass( 'current' )
     2020                                        .attr( 'href', searchLocation )
     2021                                        .text( wp.updates.l10n.searchResultsLabel );
     2022
     2023                                $( '.wp-filter .filter-links .current' )
     2024                                        .removeClass( 'current' )
     2025                                        .parents( '.filter-links' )
     2026                                        .prepend( $searchTab );
    20012027                        }
    20022028
    20032029                        if ( 'undefined' !== typeof wp.updates.searchRequest ) {
     
    20092035                                $( 'body' ).removeClass( 'loading-content' );
    20102036                                $form.append( response.items );
    20112037                                delete wp.updates.searchRequest;
     2038
     2039                                if ( 0 === response.count ) {
     2040                                        wp.a11y.speak( wp.updates.l10n.noPluginsFound );
     2041                                } else {
     2042                                        wp.a11y.speak( wp.updates.l10n.pluginsFound.replace( '%d', response.count ) );
     2043                                }
    20122044                        } );
    20132045                }, 500 ) );
    20142046
  • src/wp-admin/plugin-install.php

    diff --git src/wp-admin/plugin-install.php src/wp-admin/plugin-install.php
    index 2d28248..1981e77 100644
    get_current_screen()->add_help_tab( array( 
    7070'id'            => 'overview',
    7171'title'         => __('Overview'),
    7272'content'       =>
    73         '<p>' . sprintf(__('Plugins hook into WordPress to extend its functionality with custom features. Plugins are developed independently from the core WordPress application by thousands of developers all over the world. All plugins in the official <a href="%s" target="_blank">WordPress Plugin Directory</a> are compatible with the license WordPress uses. You can find new plugins to install by searching or browsing the Directory right here in your own Plugins section.'), 'https://wordpress.org/plugins/') . '</p>'
     73        '<p>' . sprintf( __('Plugins hook into WordPress to extend its functionality with custom features. Plugins are developed independently from the core WordPress application by thousands of developers all over the world. All plugins in the official <a href="%s" target="_blank">WordPress Plugin Directory</a> are compatible with the license WordPress uses.' ), 'https://wordpress.org/plugins/' ) . '</p>' .
     74        '<p>' . __( 'You can find new plugins to install by searching or browsing the Directory right here in your own Plugins section.' ) . ' <span id="live-search-desc" class="hide-if-no-js">' . __( 'The search results will be updated as you type.' ) . '</span></p>'
     75
    7476) );
    7577get_current_screen()->add_help_tab( array(
    7678'id'            => 'adding-plugins',
  • src/wp-includes/script-loader.php

    diff --git src/wp-includes/script-loader.php src/wp-includes/script-loader.php
    index c2dadf2..8678dd7 100644
    function wp_default_scripts( &$scripts ) { 
    600600                        'l10n'       => array(
    601601                                /* translators: %s: Search string */
    602602                                'searchResults'              => __( 'Search results for &#8220;%s&#8221;' ),
     603                                'searchResultsLabel'         => __( 'Search Results' ),
    603604                                'noPlugins'                  => __( 'You do not appear to have any plugins available at this time.' ),
    604605                                'noItemsSelected'            => __( 'Please select at least one item to perform this action on.' ),
    605606                                'updating'                   => __( 'Updating...' ), // No ellipsis.
  • tests/qunit/fixtures/updates.js

    diff --git tests/qunit/fixtures/updates.js tests/qunit/fixtures/updates.js
    index 8332039..8b2bd85 100644
    window._wpUpdatesSettings = { 
    22        'ajax_nonce': '719b10f05d',
    33        'l10n': {
    44                'searchResults': 'Search results for &#8220;%s&#8221;',
     5                'searchResultsLabel': 'Search Results',
    56                'noPlugins': 'You do not appear to have any plugins available at this time.',
    67                'noItemsSelected': 'Please select at least one item to perform this action on.',
    78                'updating': 'Updating...',