get_header_video_url

The timeline below displays how wordpress function get_header_video_url has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Retrieves header video URL for custom header.
 *
 * Uses a local video if present, or falls back to an external video.
 *
 * @since 4.7.0
 *
 * @return string|false Header video URL or false if there is no video.
 */
function get_header_video_url()
{
    $id = absint(get_theme_mod('header_video'));
    if ($id) {
        // Get the file URL from the attachment ID.
        $url = wp_get_attachment_url($id);
    } else {
        $url = get_theme_mod('external_header_video');
    }
    /**
     * Filters the header video URL.
     *
     * @since 4.7.3
     *
     * @param string $url Header video URL, if available.
     */
    $url = apply_filters('get_header_video_url', $url);
    if (!$id && !$url) {
        return false;
    }
    return sanitize_url(set_url_scheme($url));
}

WordPress Version: 5.5

/**
 * Retrieves header video URL for custom header.
 *
 * Uses a local video if present, or falls back to an external video.
 *
 * @since 4.7.0
 *
 * @return string|false Header video URL or false if there is no video.
 */
function get_header_video_url()
{
    $id = absint(get_theme_mod('header_video'));
    if ($id) {
        // Get the file URL from the attachment ID.
        $url = wp_get_attachment_url($id);
    } else {
        $url = get_theme_mod('external_header_video');
    }
    /**
     * Filters the header video URL.
     *
     * @since 4.7.3
     *
     * @param string $url Header video URL, if available.
     */
    $url = apply_filters('get_header_video_url', $url);
    if (!$id && !$url) {
        return false;
    }
    return esc_url_raw(set_url_scheme($url));
}

WordPress Version: 5.4

/**
 * Retrieve header video URL for custom header.
 *
 * Uses a local video if present, or falls back to an external video.
 *
 * @since 4.7.0
 *
 * @return string|false Header video URL or false if there is no video.
 */
function get_header_video_url()
{
    $id = absint(get_theme_mod('header_video'));
    if ($id) {
        // Get the file URL from the attachment ID.
        $url = wp_get_attachment_url($id);
    } else {
        $url = get_theme_mod('external_header_video');
    }
    /**
     * Filters the header video URL.
     *
     * @since 4.7.3
     *
     * @param string $url Header video URL, if available.
     */
    $url = apply_filters('get_header_video_url', $url);
    if (!$id && !$url) {
        return false;
    }
    return esc_url_raw(set_url_scheme($url));
}

WordPress Version: 4.8

/**
 * Retrieve header video URL for custom header.
 *
 * Uses a local video if present, or falls back to an external video.
 *
 * @since 4.7.0
 *
 * @return string|false Header video URL or false if there is no video.
 */
function get_header_video_url()
{
    $id = absint(get_theme_mod('header_video'));
    $url = esc_url(get_theme_mod('external_header_video'));
    if ($id) {
        // Get the file URL from the attachment ID.
        $url = wp_get_attachment_url($id);
    }
    /**
     * Filters the header video URL.
     *
     * @since 4.7.3
     *
     * @param string $url Header video URL, if available.
     */
    $url = apply_filters('get_header_video_url', $url);
    if (!$id && !$url) {
        return false;
    }
    return esc_url_raw(set_url_scheme($url));
}

WordPress Version: 7.3

/* Retrieve header video URL for custom header.
 *
 * Uses a local video if present, or falls back to an external video. Returns false if there is no video.
 *
 * @since 4.7.0
 *
 * @return string|false
 */
function get_header_video_url()
{
    $id = absint(get_theme_mod('header_video'));
    $url = esc_url(get_theme_mod('external_header_video'));
    if ($id) {
        // Get the file URL from the attachment ID.
        $url = wp_get_attachment_url($id);
    }
    /**
     * Filters the header video URL.
     *
     * @since 4.7.3
     *
     * @param string $url Header video URL, if available.
     */
    $url = apply_filters('get_header_video_url', $url);
    if (!$id && !$url) {
        return false;
    }
    return esc_url_raw(set_url_scheme($url));
}

WordPress Version: 4.7

/* Retrieve header video URL for custom header.
 *
 * Uses a local video if present, or falls back to an external video. Returns false if there is no video.
 *
 * @since 4.7.0
 *
 * @return string|false
 */
function get_header_video_url()
{
    $id = absint(get_theme_mod('header_video'));
    $url = esc_url(get_theme_mod('external_header_video'));
    if (!$id && !$url) {
        return false;
    }
    if ($id) {
        // Get the file URL from the attachment ID.
        $url = wp_get_attachment_url($id);
    }
    return esc_url_raw(set_url_scheme($url));
}