is_random_header_image

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

WordPress Version: 6.5

/**
 * Checks if random header image is in use.
 *
 * Always true if user expressly chooses the option in Appearance > Header.
 * Also true if theme has multiple header images registered, no specific header image
 * is chosen, and theme turns on random headers with add_theme_support().
 *
 * @since 3.2.0
 *
 * @param string $type The random pool to use. Possible values include 'any',
 *                     'default', 'uploaded'. Default 'any'.
 * @return bool
 */
function is_random_header_image($type = 'any')
{
    $header_image_mod = get_theme_mod('header_image', get_theme_support('custom-header', 'default-image'));
    if ('any' === $type) {
        if ('random-default-image' === $header_image_mod || 'random-uploaded-image' === $header_image_mod || empty($header_image_mod) && '' !== get_random_header_image()) {
            return true;
        }
    } else if ("random-{$type}-image" === $header_image_mod) {
        return true;
    } elseif ('default' === $type && empty($header_image_mod) && '' !== get_random_header_image()) {
        return true;
    }
    return false;
}

WordPress Version: 5.5

/**
 * Checks if random header image is in use.
 *
 * Always true if user expressly chooses the option in Appearance > Header.
 * Also true if theme has multiple header images registered, no specific header image
 * is chosen, and theme turns on random headers with add_theme_support().
 *
 * @since 3.2.0
 *
 * @param string $type The random pool to use. Possible values include 'any',
 *                     'default', 'uploaded'. Default 'any'.
 * @return bool
 */
function is_random_header_image($type = 'any')
{
    $header_image_mod = get_theme_mod('header_image', get_theme_support('custom-header', 'default-image'));
    if ('any' === $type) {
        if ('random-default-image' === $header_image_mod || 'random-uploaded-image' === $header_image_mod || '' !== get_random_header_image() && empty($header_image_mod)) {
            return true;
        }
    } else if ("random-{$type}-image" === $header_image_mod) {
        return true;
    } elseif ('default' === $type && empty($header_image_mod) && '' !== get_random_header_image()) {
        return true;
    }
    return false;
}

WordPress Version: 4.3

/**
 * Check if random header image is in use.
 *
 * Always true if user expressly chooses the option in Appearance > Header.
 * Also true if theme has multiple header images registered, no specific header image
 * is chosen, and theme turns on random headers with add_theme_support().
 *
 * @since 3.2.0
 *
 * @param string $type The random pool to use. any|default|uploaded
 * @return bool
 */
function is_random_header_image($type = 'any')
{
    $header_image_mod = get_theme_mod('header_image', get_theme_support('custom-header', 'default-image'));
    if ('any' == $type) {
        if ('random-default-image' == $header_image_mod || 'random-uploaded-image' == $header_image_mod || '' != get_random_header_image() && empty($header_image_mod)) {
            return true;
        }
    } else if ("random-{$type}-image" == $header_image_mod) {
        return true;
    } elseif ('default' == $type && empty($header_image_mod) && '' != get_random_header_image()) {
        return true;
    }
    return false;
}

WordPress Version: 3.7

/**
 * Check if random header image is in use.
 *
 * Always true if user expressly chooses the option in Appearance > Header.
 * Also true if theme has multiple header images registered, no specific header image
 * is chosen, and theme turns on random headers with add_theme_support().
 *
 * @since 3.2.0
 *
 * @param string $type The random pool to use. any|default|uploaded
 * @return boolean
 */
function is_random_header_image($type = 'any')
{
    $header_image_mod = get_theme_mod('header_image', get_theme_support('custom-header', 'default-image'));
    if ('any' == $type) {
        if ('random-default-image' == $header_image_mod || 'random-uploaded-image' == $header_image_mod || '' != get_random_header_image() && empty($header_image_mod)) {
            return true;
        }
    } else if ("random-{$type}-image" == $header_image_mod) {
        return true;
    } elseif ('default' == $type && empty($header_image_mod) && '' != get_random_header_image()) {
        return true;
    }
    return false;
}