Removes customize_messenger_channel query parameter from the preview window when it is not in an iframe.
This ensures that the admin bar will be shown. It also ensures that link navigation will work as expected since the parent frame is not being sent the URL to navigate to.
public function remove_frameless_preview_messenger_channel() {
if ( ! $this->messenger_channel ) {
return;
}
ob_start();
?>
<script>
( function() {
if ( parent !== window ) {
return;
}
const url = new URL( location.href );
if ( url.searchParams.has( 'customize_messenger_channel' ) ) {
url.searchParams.delete( 'customize_messenger_channel' );
location.replace( url );
}
} )();
</script>
<?php
wp_print_inline_script_tag( wp_remove_surrounding_empty_script_tags( ob_get_clean() ) );
}
| Version | Description |
|---|---|
| 4.7.0 | Introduced. |
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_customize_manager/remove_frameless_preview_messenger_channel