Make WordPress Core

10/27/2016 09:50:56 PM (7 years ago)

Themes: Enable video in custom headers.

This adds the ability for themes to add support for videos in custom headers
by passing 'video' => true as an argument when adding theme support for
custom headers.

Custom video headers are managed through the “Header Visuals” (i.e. “Header Image”)
panel in the Customizer where you can select a video from the media library or set a
URL to an external video (YouTube for now) for use in custom headers.

This introduces several new functions:

has_header_video() – Check whether a header video is set or not.
get_header_video_url() – Retrieve header video URL for custom header.
the_header_video_url() – Display header video URL.
get_header_video_settings() – Retrieve header video settings.
has_custom_header() – Check whether a custom header is set or not.
get_custom_header_markup() – Retrieve the markup for a custom header.
the_custom_header_markup() – Print the markup for a custom header.

And a new file, wp-includes/js/wp-custom-header.js that handles loading videos
in custom headers.

This also enables video headers in the Twenty Seventeen and Twenty Fourteen themes.

Props davidakennedy, celloexpressions, bradyvercher, laurelfulford, joemcgill.
Fixes #38172.

1 edited


  • trunk/src/wp-includes/customize/class-wp-customize-header-image-control.php

    r38881 r38985  
    167167        ?>
    168168        <div class="customize-control-content">
    169             <p class="customizer-section-intro">
     169            <?php if ( current_theme_supports( 'custom-header', 'video' ) ) {
     170                echo '<span class="customize-control-title">' . $this->label . '</span>';
     171            } ?>
     172            <p class="customizer-section-intro customize-control-description">
    170173                <?php
    171                 if ( $width && $height ) {
     174                if ( current_theme_supports( 'custom-header', 'video' ) ) {
     175                    _e( 'While you can crop images to your liking after clicking <strong>Add new image</strong>, we recommend matching the size of your video.' );
     176                } elseif ( $width && $height ) {
    172177                    /* translators: %s: header size in pixels */
    173178                    printf( __( 'While you can crop images to your liking after clicking <strong>Add new image</strong>, your theme recommends a header size of %s pixels.' ),
Note: See TracChangeset for help on using the changeset viewer.