diff --git src/wp-includes/class-wp-customize-manager.php src/wp-includes/class-wp-customize-manager.php
index d047620..d6325ed 100644
|
|
|
final class WP_Customize_Manager {
|
| 1353 | 1353 | |
| 1354 | 1354 | wp_enqueue_script( 'customize-preview' ); |
| 1355 | 1355 | add_action( 'wp_head', array( $this, 'customize_preview_loading_style' ) ); |
| | 1356 | add_action( 'wp_head', array( $this, 'remove_frameless_preview_messenger_channel' ) ); |
| 1356 | 1357 | add_action( 'wp_footer', array( $this, 'customize_preview_settings' ), 20 ); |
| 1357 | 1358 | add_filter( 'get_edit_post_link', '__return_empty_string' ); |
| 1358 | 1359 | |
| … |
… |
final class WP_Customize_Manager {
|
| 1488 | 1489 | } |
| 1489 | 1490 | |
| 1490 | 1491 | /** |
| | 1492 | * Remove customize_messenger_channel query parameter from the preview window when it is not in an iframe. |
| | 1493 | * |
| | 1494 | * This ensures that the admin bar will be shown. It also ensures that link navigation will |
| | 1495 | * work as expected since the parent frame is not being sent the URL to navigate to. |
| | 1496 | * |
| | 1497 | * @since 4.7.0 |
| | 1498 | * @access public |
| | 1499 | */ |
| | 1500 | public function remove_frameless_preview_messenger_channel( ){ |
| | 1501 | if ( ! $this->messenger_channel ) { |
| | 1502 | return; |
| | 1503 | } |
| | 1504 | ?> |
| | 1505 | <script> |
| | 1506 | ( function() { |
| | 1507 | var urlParser, oldQueryParams, newQueryParams, i; |
| | 1508 | if ( parent !== window ) { |
| | 1509 | return; |
| | 1510 | } |
| | 1511 | urlParser = document.createElement( 'a' ); |
| | 1512 | urlParser.href = location.href; |
| | 1513 | oldQueryParams = urlParser.search.substr( 1 ).split( /&/ ); |
| | 1514 | newQueryParams = []; |
| | 1515 | for ( i = 0; i < oldQueryParams.length; i += 1 ) { |
| | 1516 | if ( ! /^customize_messenger_channel=/.test( oldQueryParams[ i ] ) ) { |
| | 1517 | newQueryParams.push( oldQueryParams[ i ] ); |
| | 1518 | } |
| | 1519 | } |
| | 1520 | urlParser.search = newQueryParams.join( '&' ); |
| | 1521 | if ( urlParser.search !== location.search ) { |
| | 1522 | location.replace( urlParser.href ); |
| | 1523 | } |
| | 1524 | } )(); |
| | 1525 | </script> |
| | 1526 | <?php |
| | 1527 | } |
| | 1528 | |
| | 1529 | /** |
| 1491 | 1530 | * Print JavaScript settings for preview frame. |
| 1492 | 1531 | * |
| 1493 | 1532 | * @since 3.4.0 |
diff --git tests/phpunit/tests/customize/manager.php tests/phpunit/tests/customize/manager.php
index 54128f8..b138a35 100644
|
|
|
class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
| 460 | 460 | $this->assertEquals( $did_action_customize_preview_init + 1, did_action( 'customize_preview_init' ) ); |
| 461 | 461 | |
| 462 | 462 | $this->assertEquals( 10, has_action( 'wp_head', 'wp_no_robots' ) ); |
| | 463 | $this->assertEquals( 10, has_action( 'wp_head', array( $wp_customize, 'remove_frameless_preview_messenger_channel' ) ) ); |
| 463 | 464 | $this->assertEquals( 10, has_filter( 'wp_headers', array( $wp_customize, 'filter_iframe_security_headers' ) ) ); |
| 464 | 465 | $this->assertEquals( 10, has_filter( 'wp_redirect', array( $wp_customize, 'add_state_query_params' ) ) ); |
| 465 | 466 | $this->assertTrue( wp_script_is( 'customize-preview', 'enqueued' ) ); |