On this page
is_random_header_image( string $type = 'any' ): bool
Checks if random header image is in use.
Description
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() .
Parameters
$typestring Optional-
The random pool to use. Possible values include
'any','default','uploaded'. Default'any'.Default:
'any'
Return
bool
Source
File: wp-includes/theme.php. View all references
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;
}
Related
Uses
| Uses | Description |
|---|---|
| get_theme_support() wp-includes/theme.php | Gets the theme support arguments passed when registering that support. |
| get_random_header_image() wp-includes/theme.php | Gets random header image URL from registered images in theme. |
| get_theme_mod() wp-includes/theme.php | Retrieves theme modification value for the active theme. |
Used By
| Used By | Description |
|---|---|
| get_media_states() wp-admin/includes/template.php | Retrieves an array of media states from an attachment. |
| Custom_Image_Header::show_header_selector() wp-admin/includes/class-custom-image-header.php | Display UI for selecting one of several default headers. |
| get_header_image() wp-includes/theme.php | Retrieves header image for custom header. |
| get_custom_header() wp-includes/theme.php | Gets the header image data. |
Changelog
| Version | Description |
|---|---|
| 3.2.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/is_random_header_image