mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-07 22:24:36 +00:00
Customize: Use selective refresh for custom header changes when possible.
* Use `postMessage` transport for header image settings by default when video headers are supported, and thus `the_custom_header_markup()` will necessarily be used (and thus a selective refresh partial will be available). * Ensure that `the_custom_header_markup()` always outputs a container element in the customizer preview even if the header is empty. * Ensure that edit shortcut appearing for custom header does not get positioned off-screen. Props bradyvercher, westonruter. See #38639. Fixes #38737. git-svn-id: https://develop.svn.wordpress.org/trunk@39227 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1410,13 +1410,15 @@ function has_custom_header() {
|
||||
/**
|
||||
* Retrieve the markup for a custom header.
|
||||
*
|
||||
* The container div will always be returned in the Customizer preview.
|
||||
*
|
||||
* @since 4.7.0
|
||||
*
|
||||
* @return string|false The markup for a custom header on success. False if not.
|
||||
* @return string The markup for a custom header on success.
|
||||
*/
|
||||
function get_custom_header_markup() {
|
||||
if ( ! has_custom_header() ) {
|
||||
return false;
|
||||
if ( ! has_custom_header() && ! is_customize_preview() ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return sprintf(
|
||||
@@ -1428,15 +1430,19 @@ function get_custom_header_markup() {
|
||||
/**
|
||||
* Print the markup for a custom header.
|
||||
*
|
||||
* A container div will always be printed in the Customizer preview.
|
||||
*
|
||||
* @since 4.7.0
|
||||
*/
|
||||
function the_custom_header_markup() {
|
||||
if ( ! $custom_header = get_custom_header_markup() ) {
|
||||
$custom_header = get_custom_header_markup();
|
||||
if ( empty( $custom_header ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo $custom_header;
|
||||
|
||||
if ( has_header_video() && is_front_page() ) {
|
||||
if ( is_front_page() && ( has_header_video() || is_customize_preview() ) ) {
|
||||
wp_enqueue_script( 'wp-custom-header' );
|
||||
wp_localize_script( 'wp-custom-header', '_wpCustomHeaderSettings', get_header_video_settings() );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user