diff --git src/wp-includes/class-wp-customize-manager.php src/wp-includes/class-wp-customize-manager.php
index c658198..a762134 100644
|
|
final class WP_Customize_Manager { |
424 | 424 | add_action( 'wp_head', array( $this, 'customize_preview_base' ) ); |
425 | 425 | add_action( 'wp_head', array( $this, 'customize_preview_html5' ) ); |
426 | 426 | add_action( 'wp_footer', array( $this, 'customize_preview_settings' ), 20 ); |
| 427 | add_action( 'wp_footer', array( $this, 'customize_preview_base_hash_url_fix' ), 30 ); |
427 | 428 | add_action( 'shutdown', array( $this, 'customize_preview_signature' ), 1000 ); |
428 | 429 | add_filter( 'wp_die_handler', array( $this, 'remove_preview_signature' ) ); |
429 | 430 | |
… |
… |
final class WP_Customize_Manager { |
461 | 462 | * @since 3.4.0 |
462 | 463 | */ |
463 | 464 | public function customize_preview_base() { |
464 | | ?><base href="<?php echo home_url( '/' ); ?>" /><?php |
| 465 | // Note: we cannot just pass $_SERVER[REQUEST_URI] directly to home_url() because of subdirectory installs |
| 466 | $host = parse_url( home_url(), PHP_URL_HOST ); |
| 467 | $base_href = '//' . $host . wp_unslash( $_SERVER['REQUEST_URI'] ); |
| 468 | ?><base href="<?php echo esc_url( $base_href ); ?>" /><?php |
465 | 469 | } |
466 | 470 | |
467 | 471 | /** |
… |
… |
final class WP_Customize_Manager { |
516 | 520 | } |
517 | 521 | |
518 | 522 | /** |
| 523 | * Print script to allow hash URLs to work as expected |
| 524 | * |
| 525 | * @since 4.1 |
| 526 | */ |
| 527 | public function customize_preview_base_hash_url_fix() { |
| 528 | wp_print_scripts( array( 'jquery' ) ); |
| 529 | ?><script> |
| 530 | (function( $ ){ |
| 531 | var base = $( 'head > base[href]:last' ), |
| 532 | baseUrl = base.prop( 'href' ).replace( /#.*/, '' ); |
| 533 | $( 'a[href^="#"]' ).attr( 'href', function ( i, hash ) { |
| 534 | return baseUrl + hash; |
| 535 | } ); |
| 536 | })( jQuery ); |
| 537 | </script><?php |
| 538 | } |
| 539 | |
| 540 | /** |
519 | 541 | * Prints a signature so we can ensure the customizer was properly executed. |
520 | 542 | * |
521 | 543 | * @since 3.4.0 |