On this page
_get_random_header_data(): object
This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
Gets random header image data from registered images in theme.
Return
object
Source
File: wp-includes/theme.php. View all references
function _get_random_header_data() {
global $_wp_default_headers;
static $_wp_random_header = null;
if ( empty( $_wp_random_header ) ) {
$header_image_mod = get_theme_mod( 'header_image', '' );
$headers = array();
if ( 'random-uploaded-image' === $header_image_mod ) {
$headers = get_uploaded_header_images();
} elseif ( ! empty( $_wp_default_headers ) ) {
if ( 'random-default-image' === $header_image_mod ) {
$headers = $_wp_default_headers;
} else {
if ( current_theme_supports( 'custom-header', 'random-default' ) ) {
$headers = $_wp_default_headers;
}
}
}
if ( empty( $headers ) ) {
return new stdClass;
}
$_wp_random_header = (object) $headers[ array_rand( $headers ) ];
$_wp_random_header->url = sprintf(
$_wp_random_header->url,
get_template_directory_uri(),
get_stylesheet_directory_uri()
);
$_wp_random_header->thumbnail_url = sprintf(
$_wp_random_header->thumbnail_url,
get_template_directory_uri(),
get_stylesheet_directory_uri()
);
}
return $_wp_random_header;
}
Related
Uses
| Uses | Description |
|---|---|
| get_theme_mod() wp-includes/theme.php | Retrieves theme modification value for the active theme. |
| get_uploaded_header_images() wp-includes/theme.php | Gets the header images uploaded for the active theme. |
| get_template_directory_uri() wp-includes/theme.php | Retrieves template directory URI for the active theme. |
| get_stylesheet_directory_uri() wp-includes/theme.php | Retrieves stylesheet directory URI for the active theme. |
| current_theme_supports() wp-includes/theme.php | Checks a theme’s support for a given feature. |
Used By
| Used By | Description |
|---|---|
| get_random_header_image() wp-includes/theme.php | Gets random header image URL from registered images in theme. |
| get_custom_header() wp-includes/theme.php | Gets the header image data. |
Changelog
| Version | Description |
|---|---|
| 3.4.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/_get_random_header_data