diff --git a/src/wp-admin/js/updates.js b/src/wp-admin/js/updates.js
index e1d963a..c0a36da 100644
a
|
b
|
|
2033 | 2033 | * @since 4.6.0 |
2034 | 2034 | */ |
2035 | 2035 | $pluginInstallSearch.on( 'keyup input', _.debounce( function( event, eventtype ) { |
2036 | | var $searchTab = $( '.plugin-install-search' ), data, searchLocation; |
| 2036 | var $searchTab = $( '.plugin-install-search' ), data, searchLocation, currentLocation = location.href, urlSearchString = wp.urlParam( 's', currentLocation ); |
2037 | 2037 | |
2038 | 2038 | data = { |
2039 | 2039 | _ajax_nonce: wp.updates.ajaxNonce, |
… |
… |
|
2042 | 2042 | type: $( '#typeselector' ).val(), |
2043 | 2043 | pagenow: pagenow |
2044 | 2044 | }; |
2045 | | searchLocation = location.href.split( '?' )[ 0 ] + '?' + $.param( _.omit( data, [ '_ajax_nonce', 'pagenow' ] ) ); |
| 2045 | searchLocation = currentLocation.split( '?' )[ 0 ] + '?' + $.param( _.omit( data, [ '_ajax_nonce', 'pagenow' ] ) ); |
2046 | 2046 | |
2047 | 2047 | // Clear on escape. |
2048 | 2048 | if ( 'keyup' === event.type && 27 === event.which ) { |
… |
… |
|
2056 | 2056 | wp.updates.searchTerm = data.s; |
2057 | 2057 | } |
2058 | 2058 | |
2059 | | if ( window.history && window.history.pushState ) { |
| 2059 | |
| 2060 | if ( urlSearchString != event.target.value && window.history && window.history.pushState ) { |
2060 | 2061 | window.history.pushState( null, '', searchLocation ); |
2061 | 2062 | } |
2062 | 2063 | |
… |
… |
|
2106 | 2107 | * @since 4.6.0 |
2107 | 2108 | */ |
2108 | 2109 | $pluginSearch.on( 'keyup input', _.debounce( function( event ) { |
| 2110 | var currentLocation = location.href, urlSearchString = wp.urlParam( 's', currentLocation ); |
2109 | 2111 | var data = { |
2110 | 2112 | _ajax_nonce: wp.updates.ajaxNonce, |
2111 | 2113 | s: event.target.value, |
… |
… |
|
2123 | 2125 | wp.updates.searchTerm = data.s; |
2124 | 2126 | } |
2125 | 2127 | |
2126 | | if ( window.history && window.history.pushState ) { |
| 2128 | if ( urlSearchString != event.target.value && window.history && window.history.pushState ) { |
2127 | 2129 | window.history.pushState( null, '', location.href.split( '?' )[ 0 ] + '?s=' + data.s ); |
2128 | 2130 | } |
2129 | 2131 | |
… |
… |
|
2298 | 2300 | * @since 4.2.0 |
2299 | 2301 | */ |
2300 | 2302 | $( window ).on( 'beforeunload', wp.updates.beforeunload ); |
| 2303 | |
| 2304 | /** |
| 2305 | * Window popstate for search plugins |
| 2306 | */ |
| 2307 | $( window ).on( 'popstate', function ( event ) { |
| 2308 | |
| 2309 | var bodyElem = $( 'body' ), currentLocation = location.href, urlSearchString = wp.urlParam( 's', currentLocation ); |
| 2310 | |
| 2311 | if ( bodyElem.hasClass( "plugins-php" ) ) { |
| 2312 | $pluginSearch.val( urlSearchString ); |
| 2313 | $pluginSearch.trigger( 'input' ); |
| 2314 | } |
| 2315 | |
| 2316 | if ( bodyElem.hasClass( "plugin-install-php" ) ) { |
| 2317 | $pluginInstallSearch.val( urlSearchString ); |
| 2318 | $pluginInstallSearch.trigger( 'input' ); |
| 2319 | } |
| 2320 | } ); |
2301 | 2321 | } ); |
2302 | 2322 | })( jQuery, window.wp, _.extend( window._wpUpdatesSettings, window._wpUpdatesItemCounts || {} ) ); |
diff --git a/src/wp-includes/js/wp-util.js b/src/wp-includes/js/wp-util.js
index 527441d..d90d615 100644
a
|
b
|
window.wp = window.wp || {}; |
35 | 35 | }; |
36 | 36 | }); |
37 | 37 | |
| 38 | /** |
| 39 | * wp.urlParam( name, url ) |
| 40 | * |
| 41 | * Fetch parameters from given URL |
| 42 | * |
| 43 | * @param {string} name A parameter name to fetch value from url. |
| 44 | * For example, "param1" for example.com?param1=value1¶m2=value2 |
| 45 | * |
| 46 | * @param {string} url Url to fetch parameters |
| 47 | * For example, example.com?param1=value1¶m2=value2 |
| 48 | * |
| 49 | * @return {string} Return value of given parameter name from url |
| 50 | */ |
| 51 | wp.urlParam = function ( name, url ) { |
| 52 | var results = new RegExp( '[\?&]' + name + '=([^&#]*)' ).exec( url ); |
| 53 | if ( 'undefined' === typeof results || null == results ) { |
| 54 | return ""; |
| 55 | } |
| 56 | return results[1] || ""; |
| 57 | }; |
| 58 | |
38 | 59 | // wp.ajax |
39 | 60 | // ------ |
40 | 61 | // |