Title: WP_Customize_Manager::remove_frameless_preview_messenger_channel
Published: December 7, 2016
Last modified: August 20, 2026

---

# WP_Customize_Manager::remove_frameless_preview_messenger_channel()

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_customize_manager/remove_frameless_preview_messenger_channel/?output_format=md#description)
 * [Source](https://developer.wordpress.org/reference/classes/wp_customize_manager/remove_frameless_preview_messenger_channel/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_customize_manager/remove_frameless_preview_messenger_channel/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_customize_manager/remove_frameless_preview_messenger_channel/?output_format=md#changelog)

Removes customize_messenger_channel query parameter from the preview window when
it is not in an iframe.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_customize_manager/remove_frameless_preview_messenger_channel/?output_format=md#description)󠁿

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.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_customize_manager/remove_frameless_preview_messenger_channel/?output_format=md#source)󠁿

    ```php
    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() ) . "\n//# sourceURL=" . rawurlencode( __METHOD__ ) );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-customize-manager.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/class-wp-customize-manager.php#L2089)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/class-wp-customize-manager.php#L2089-L2109)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_customize_manager/remove_frameless_preview_messenger_channel/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_remove_surrounding_empty_script_tags()](https://developer.wordpress.org/reference/functions/wp_remove_surrounding_empty_script_tags/)`wp-includes/script-loader.php` |

Removes leading and trailing _empty_ script tags.

  | 
| [wp_print_inline_script_tag()](https://developer.wordpress.org/reference/functions/wp_print_inline_script_tag/)`wp-includes/script-loader.php` |

Prints an inline script tag.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_customize_manager/remove_frameless_preview_messenger_channel/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.7.0](https://developer.wordpress.org/reference/since/4.7.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_customize_manager%2Fremove_frameless_preview_messenger_channel%2F)
before being able to contribute a note or feedback.