WordPress.org

Make WordPress Core

Ticket #38738: 38738.8.diff

File 38738.8.diff, 3.6 KB (added by joemcgill, 2 years ago)
  • src/wp-includes/class-wp-customize-manager.php

    diff --git src/wp-includes/class-wp-customize-manager.php src/wp-includes/class-wp-customize-manager.php
    index 54c3f0e..1a9c1c5 100644
    final class WP_Customize_Manager { 
    34913491                                'frame_title'  => __( 'Select Video' ),
    34923492                                'frame_button' => __( 'Choose Video' ),
    34933493                        ),
    3494                         'active_callback' => 'is_front_page',
     3494                        'active_callback' => 'is_header_video_active',
    34953495                ) ) );
    34963496
    34973497                $this->add_control( 'external_header_video', array(
  • src/wp-includes/theme.php

    diff --git src/wp-includes/theme.php src/wp-includes/theme.php
    index 66e10b2..9ca5273 100644
    function get_header_video_settings() { 
    14001400 * @return bool True if a custom header is set. False if not.
    14011401 */
    14021402function has_custom_header() {
    1403         if ( has_header_image() || ( is_front_page() && has_header_video() ) ) {
     1403        if ( has_header_image() || ( has_header_video() && is_header_video_active() ) ) {
    14041404                return true;
    14051405        }
    14061406
    function has_custom_header() { 
    14081408}
    14091409
    14101410/**
     1411 * Checks whether the custom header video is eligible to show on the current page.
     1412 *
     1413 * @since 4.7.0
     1414 *
     1415 * @return bool True if the custom header video should be shown. False if not.
     1416 */
     1417function is_header_video_active() {
     1418        if ( ! get_theme_support( 'custom-header', 'video' ) ) {
     1419                return false;
     1420        }
     1421
     1422        $video_active_cb = get_theme_support( 'custom-header', 'video-active-callback' );
     1423
     1424        if ( empty( $video_active_cb ) || ! is_callable( $video_active_cb ) ) {
     1425                $show_video = true;
     1426        } else {
     1427                $show_video = call_user_func( $video_active_cb );
     1428        }
     1429
     1430        /**
     1431         * Modify whether the custom header video is eligible to show on the current page.
     1432         *
     1433         * @since 4.7.0
     1434         *
     1435         * @param bool $show_video Whether the custom header video should be shown. Returns the value
     1436         *                         of the theme setting for the `custom-header`'s `video-active-callback`.
     1437         *                         If no callback is set, the default value is that of `is_front_page()`.
     1438         */
     1439        return apply_filters( 'is_header_video_active', $show_video );
     1440}
     1441
     1442/**
    14111443 * Retrieve the markup for a custom header.
    14121444 *
    14131445 * The container div will always be returned in the Customizer preview.
    function the_custom_header_markup() { 
    14421474
    14431475        echo $custom_header;
    14441476
    1445         if ( is_front_page() && ( has_header_video() || is_customize_preview() ) ) {
     1477        if ( is_header_video_active() && ( has_header_video() || is_customize_preview() ) ) {
    14461478                wp_enqueue_script( 'wp-custom-header' );
    14471479                wp_localize_script( 'wp-custom-header', '_wpCustomHeaderSettings', get_header_video_settings() );
    14481480        }
    function add_theme_support( $feature ) { 
    20582090                                'admin-head-callback' => '',
    20592091                                'admin-preview-callback' => '',
    20602092                                'video' => false,
     2093                                'video-active-callback' => 'is_front_page',
    20612094                        );
    20622095
    20632096                        $jit = isset( $args[0]['__jit'] );
    function _remove_theme_support( $feature ) { 
    23192352                        if ( ! did_action( 'wp_loaded' ) )
    23202353                                break;
    23212354                        $support = get_theme_support( 'custom-header' );
    2322                         if ( $support[0]['wp-head-callback'] )
     2355                        if ( isset( $support[0]['wp-head-callback'] ) ) {
    23232356                                remove_action( 'wp_head', $support[0]['wp-head-callback'] );
    2324                         remove_action( 'admin_menu', array( $GLOBALS['custom_image_header'], 'init' ) );
    2325                         unset( $GLOBALS['custom_image_header'] );
     2357                        }
     2358                        if ( isset( $GLOBALS['custom_image_header'] ) ) {
     2359                                remove_action( 'admin_menu', array( $GLOBALS['custom_image_header'], 'init' ) );
     2360                                unset( $GLOBALS['custom_image_header'] );
     2361                        }
    23262362                        break;
    23272363
    23282364                case 'custom-background' :