mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Customize: Harden and modernize URL manipulation in WP_Customize_Manager::remove_frameless_preview_messenger_channel().
Since IE11 is no longer supported, the `URL` and `URLSearchParams` APIs can now be leveraged for simpler and more robust URL manipulation. This was done similarly in [56383] for `embed.js`. Props nicolefurlan, dmsnell, westonruter. Fixes #59480. git-svn-id: https://develop.svn.wordpress.org/trunk@56749 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
8c0adc93df
commit
1427d84abc
@ -2089,22 +2089,13 @@ final class WP_Customize_Manager {
|
||||
?>
|
||||
<script>
|
||||
( function() {
|
||||
var urlParser, oldQueryParams, newQueryParams, i;
|
||||
if ( parent !== window ) {
|
||||
return;
|
||||
}
|
||||
urlParser = document.createElement( 'a' );
|
||||
urlParser.href = location.href;
|
||||
oldQueryParams = urlParser.search.substr( 1 ).split( /&/ );
|
||||
newQueryParams = [];
|
||||
for ( i = 0; i < oldQueryParams.length; i += 1 ) {
|
||||
if ( ! /^customize_messenger_channel=/.test( oldQueryParams[ i ] ) ) {
|
||||
newQueryParams.push( oldQueryParams[ i ] );
|
||||
}
|
||||
}
|
||||
urlParser.search = newQueryParams.join( '&' );
|
||||
if ( urlParser.search !== location.search ) {
|
||||
location.replace( urlParser.href );
|
||||
const url = new URL( location.href );
|
||||
if ( url.searchParams.has( 'customize_messenger_channel' ) ) {
|
||||
url.searchParams.delete( 'customize_messenger_channel' );
|
||||
location.replace( url );
|
||||
}
|
||||
} )();
|
||||
</script>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user