diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php index fbe0df4621..640ff79272 100644 --- a/src/wp-admin/includes/ajax-actions.php +++ b/src/wp-admin/includes/ajax-actions.php @@ -3881,6 +3881,7 @@ function wp_ajax_search_install_plugins() { ob_start(); $wp_list_table->display(); + $status['count'] = (int) $wp_list_table->get_pagination_arg( 'total_items' ); $status['items'] = ob_get_clean(); wp_send_json_success( $status ); diff --git a/src/wp-admin/includes/class-wp-plugin-install-list-table.php b/src/wp-admin/includes/class-wp-plugin-install-list-table.php index 5f5b56281b..99aad1210b 100644 --- a/src/wp-admin/includes/class-wp-plugin-install-list-table.php +++ b/src/wp-admin/includes/class-wp-plugin-install-list-table.php @@ -285,7 +285,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table { ?> - + +
'; } /** - * Display search form for searching plugins. + * Displays a search form for searching plugins. * * @since 2.7.0 + * @since 4.6.0 The `$type_selector` parameter was deprecated. * - * @param bool $type_selector + * @param bool $deprecated Not used. */ -function install_search_form( $type_selector = true ) { - $type = isset($_REQUEST['type']) ? wp_unslash( $_REQUEST['type'] ) : 'term'; - $term = isset($_REQUEST['s']) ? wp_unslash( $_REQUEST['s'] ) : ''; - $input_attrs = ''; - $button_type = 'button screen-reader-text'; - - // assume no $type_selector means it's a simplified search form - if ( ! $type_selector ) { - $input_attrs = 'class="wp-filter-search" placeholder="' . esc_attr__( 'Search Plugins' ) . '" '; - } - +function install_search_form( $deprecated = true ) { + $type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term'; + $term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : ''; ?>' ) + .append( $( '', { + 'class': 'current', + 'href': searchLocation, + 'text': wp.updates.l10n.searchResultsLabel + } ) ); + + $( '.wp-filter .filter-links .current' ) + .removeClass( 'current' ) + .parents( '.filter-links' ) + .prepend( $searchTab ); + + $pluginFilter.prev( 'p' ).remove(); + $( '.plugins-popular-tags-wrapper' ).remove(); } if ( 'undefined' !== typeof wp.updates.searchRequest ) { @@ -2054,12 +2084,18 @@ wp.updates.searchRequest = wp.ajax.post( 'search-install-plugins', data ).done( function( response ) { $( 'body' ).removeClass( 'loading-content' ); - $form.append( response.items ); + $pluginFilter.append( response.items ); delete wp.updates.searchRequest; + + if ( 0 === response.count ) { + wp.a11y.speak( wp.updates.l10n.noPluginsFound ); + } else { + wp.a11y.speak( wp.updates.l10n.pluginsFound.replace( '%d', response.count ) ); + } } ); }, 500 ) ); - if ( $pluginSearch.length > 0 ) { + if ( $pluginSearch.length ) { $pluginSearch.attr( 'aria-describedby', 'live-search-desc' ); } @@ -2087,8 +2123,8 @@ wp.updates.searchTerm = data.s; } - if ( history.pushState ) { - history.pushState( null, '', location.href.split( '?' )[ 0 ] + '?s=' + data.s ); + if ( window.history && window.history.pushState ) { + window.history.pushState( null, '', location.href.split( '?' )[ 0 ] + '?s=' + data.s ); } if ( 'undefined' !== typeof wp.updates.searchRequest ) { @@ -2132,7 +2168,7 @@ $document.on( 'submit', '.search-plugins', function( event ) { event.preventDefault(); - $( 'input.wp-filter-search' ).trigger( 'search' ); + $( 'input.wp-filter-search' ).trigger( 'input' ); } ); /** @@ -2141,7 +2177,11 @@ * @since 4.6.0 */ $( '#typeselector' ).on( 'change', function() { - $( 'input[name="s"]' ).trigger( 'search' ); + var $search = $( 'input[name="s"]' ); + + if ( $search.val().length ) { + $search.trigger( 'input', 'typechange' ); + } } ); /** diff --git a/src/wp-admin/plugin-install.php b/src/wp-admin/plugin-install.php index 2d28248ac1..0a123d634a 100644 --- a/src/wp-admin/plugin-install.php +++ b/src/wp-admin/plugin-install.php @@ -70,7 +70,9 @@ get_current_screen()->add_help_tab( array( 'id' => 'overview', 'title' => __('Overview'), 'content' => - '' . 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 WordPress Plugin Directory 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/') . '
' + '' . 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 WordPress Plugin Directory are compatible with the license WordPress uses.' ), 'https://wordpress.org/plugins/' ) . '
' . + '' . __( 'You can find new plugins to install by searching or browsing the directory right here in your own Plugins section.' ) . '
' + ) ); get_current_screen()->add_help_tab( array( 'id' => 'adding-plugins', diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index e79406af39..d5f6a86014 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -609,6 +609,7 @@ function wp_default_scripts( &$scripts ) { 'l10n' => array( /* translators: %s: Search string */ 'searchResults' => __( 'Search results for “%s”' ), + 'searchResultsLabel' => __( 'Search Results' ), 'noPlugins' => __( 'You do not appear to have any plugins available at this time.' ), 'noItemsSelected' => __( 'Please select at least one item to perform this action on.' ), 'updating' => __( 'Updating...' ), // No ellipsis. diff --git a/tests/qunit/fixtures/updates.js b/tests/qunit/fixtures/updates.js index 82a8311d60..3a0ce374bf 100644 --- a/tests/qunit/fixtures/updates.js +++ b/tests/qunit/fixtures/updates.js @@ -2,6 +2,7 @@ window._wpUpdatesSettings = { 'ajax_nonce': '719b10f05d', 'l10n': { 'searchResults': 'Search results for “%s”', + 'searchResultsLabel': 'Search Results', 'noPlugins': 'You do not appear to have any plugins available at this time.', 'noItemsSelected': 'Please select at least one item to perform this action on.', 'updating': 'Updating...',