get_custom_header

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

WordPress Version: 5.5

/**
 * Gets the header image data.
 *
 * @since 3.4.0
 *
 * @global array $_wp_default_headers
 *
 * @return object
 */
function get_custom_header()
{
    global $_wp_default_headers;
    if (is_random_header_image()) {
        $data = _get_random_header_data();
    } else {
        $data = get_theme_mod('header_image_data');
        if (!$data && current_theme_supports('custom-header', 'default-image')) {
            $directory_args = array(get_template_directory_uri(), get_stylesheet_directory_uri());
            $data = array();
            $data['url'] = vsprintf(get_theme_support('custom-header', 'default-image'), $directory_args);
            $data['thumbnail_url'] = $data['url'];
            if (!empty($_wp_default_headers)) {
                foreach ((array) $_wp_default_headers as $default_header) {
                    $url = vsprintf($default_header['url'], $directory_args);
                    if ($data['url'] == $url) {
                        $data = $default_header;
                        $data['url'] = $url;
                        $data['thumbnail_url'] = vsprintf($data['thumbnail_url'], $directory_args);
                        break;
                    }
                }
            }
        }
    }
    $default = array('url' => '', 'thumbnail_url' => '', 'width' => get_theme_support('custom-header', 'width'), 'height' => get_theme_support('custom-header', 'height'), 'video' => get_theme_support('custom-header', 'video'));
    return (object) wp_parse_args($data, $default);
}

WordPress Version: 5.3

/**
 * Get the header image data.
 *
 * @since 3.4.0
 *
 * @global array $_wp_default_headers
 *
 * @return object
 */
function get_custom_header()
{
    global $_wp_default_headers;
    if (is_random_header_image()) {
        $data = _get_random_header_data();
    } else {
        $data = get_theme_mod('header_image_data');
        if (!$data && current_theme_supports('custom-header', 'default-image')) {
            $directory_args = array(get_template_directory_uri(), get_stylesheet_directory_uri());
            $data = array();
            $data['url'] = vsprintf(get_theme_support('custom-header', 'default-image'), $directory_args);
            $data['thumbnail_url'] = $data['url'];
            if (!empty($_wp_default_headers)) {
                foreach ((array) $_wp_default_headers as $default_header) {
                    $url = vsprintf($default_header['url'], $directory_args);
                    if ($data['url'] == $url) {
                        $data = $default_header;
                        $data['url'] = $url;
                        $data['thumbnail_url'] = vsprintf($data['thumbnail_url'], $directory_args);
                        break;
                    }
                }
            }
        }
    }
    $default = array('url' => '', 'thumbnail_url' => '', 'width' => get_theme_support('custom-header', 'width'), 'height' => get_theme_support('custom-header', 'height'), 'video' => get_theme_support('custom-header', 'video'));
    return (object) wp_parse_args($data, $default);
}

WordPress Version: 4.7

/**
 * Get the header image data.
 *
 * @since 3.4.0
 *
 * @global array $_wp_default_headers
 *
 * @return object
 */
function get_custom_header()
{
    global $_wp_default_headers;
    if (is_random_header_image()) {
        $data = _get_random_header_data();
    } else {
        $data = get_theme_mod('header_image_data');
        if (!$data && current_theme_supports('custom-header', 'default-image')) {
            $directory_args = array(get_template_directory_uri(), get_stylesheet_directory_uri());
            $data = array();
            $data['url'] = $data['thumbnail_url'] = vsprintf(get_theme_support('custom-header', 'default-image'), $directory_args);
            if (!empty($_wp_default_headers)) {
                foreach ((array) $_wp_default_headers as $default_header) {
                    $url = vsprintf($default_header['url'], $directory_args);
                    if ($data['url'] == $url) {
                        $data = $default_header;
                        $data['url'] = $url;
                        $data['thumbnail_url'] = vsprintf($data['thumbnail_url'], $directory_args);
                        break;
                    }
                }
            }
        }
    }
    $default = array('url' => '', 'thumbnail_url' => '', 'width' => get_theme_support('custom-header', 'width'), 'height' => get_theme_support('custom-header', 'height'), 'video' => get_theme_support('custom-header', 'video'));
    return (object) wp_parse_args($data, $default);
}

WordPress Version: 4.3

/**
 * Get the header image data.
 *
 * @since 3.4.0
 *
 * @global array $_wp_default_headers
 *
 * @return object
 */
function get_custom_header()
{
    global $_wp_default_headers;
    if (is_random_header_image()) {
        $data = _get_random_header_data();
    } else {
        $data = get_theme_mod('header_image_data');
        if (!$data && current_theme_supports('custom-header', 'default-image')) {
            $directory_args = array(get_template_directory_uri(), get_stylesheet_directory_uri());
            $data = array();
            $data['url'] = $data['thumbnail_url'] = vsprintf(get_theme_support('custom-header', 'default-image'), $directory_args);
            if (!empty($_wp_default_headers)) {
                foreach ((array) $_wp_default_headers as $default_header) {
                    $url = vsprintf($default_header['url'], $directory_args);
                    if ($data['url'] == $url) {
                        $data = $default_header;
                        $data['url'] = $url;
                        $data['thumbnail_url'] = vsprintf($data['thumbnail_url'], $directory_args);
                        break;
                    }
                }
            }
        }
    }
    $default = array('url' => '', 'thumbnail_url' => '', 'width' => get_theme_support('custom-header', 'width'), 'height' => get_theme_support('custom-header', 'height'));
    return (object) wp_parse_args($data, $default);
}

WordPress Version: 3.7

/**
 * Get the header image data.
 *
 * @since 3.4.0
 *
 * @return object
 */
function get_custom_header()
{
    global $_wp_default_headers;
    if (is_random_header_image()) {
        $data = _get_random_header_data();
    } else {
        $data = get_theme_mod('header_image_data');
        if (!$data && current_theme_supports('custom-header', 'default-image')) {
            $directory_args = array(get_template_directory_uri(), get_stylesheet_directory_uri());
            $data = array();
            $data['url'] = $data['thumbnail_url'] = vsprintf(get_theme_support('custom-header', 'default-image'), $directory_args);
            if (!empty($_wp_default_headers)) {
                foreach ((array) $_wp_default_headers as $default_header) {
                    $url = vsprintf($default_header['url'], $directory_args);
                    if ($data['url'] == $url) {
                        $data = $default_header;
                        $data['url'] = $url;
                        $data['thumbnail_url'] = vsprintf($data['thumbnail_url'], $directory_args);
                        break;
                    }
                }
            }
        }
    }
    $default = array('url' => '', 'thumbnail_url' => '', 'width' => get_theme_support('custom-header', 'width'), 'height' => get_theme_support('custom-header', 'height'));
    return (object) wp_parse_args($data, $default);
}