WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/14/2016 06:40:08 PM (4 years ago)
Author:
westonruter
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/theme.php

    r39209 r39227  
    14111411 * Retrieve the markup for a custom header.
    14121412 *
     1413 * The container div will always be returned in the Customizer preview.
     1414 *
    14131415 * @since 4.7.0
    14141416 *
    1415  * @return string|false The markup for a custom header on success. False if not.
     1417 * @return string The markup for a custom header on success.
    14161418 */
    14171419function get_custom_header_markup() {
    1418     if ( ! has_custom_header() ) {
    1419         return false;
     1420    if ( ! has_custom_header() && ! is_customize_preview() ) {
     1421        return '';
    14201422    }
    14211423
     
    14291431 * Print the markup for a custom header.
    14301432 *
     1433 * A container div will always be printed in the Customizer preview.
     1434 *
    14311435 * @since 4.7.0
    14321436 */
    14331437function the_custom_header_markup() {
    1434     if ( ! $custom_header = get_custom_header_markup() ) {
     1438    $custom_header = get_custom_header_markup();
     1439    if ( empty( $custom_header ) ) {
    14351440        return;
    14361441    }
     1442
    14371443    echo $custom_header;
    14381444
    1439     if ( has_header_video() && is_front_page() ) {
     1445    if ( is_front_page() && ( has_header_video() || is_customize_preview() ) ) {
    14401446        wp_enqueue_script( 'wp-custom-header' );
    14411447        wp_localize_script( 'wp-custom-header', '_wpCustomHeaderSettings', get_header_video_settings() );
Note: See TracChangeset for help on using the changeset viewer.