On this page
get_custom_header(): object
Gets the header image data.
Return
object
Source
File: wp-includes/theme.php. View all references
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 );
}
Related
Uses
| Uses | Description |
|---|---|
| get_theme_support() wp-includes/theme.php | Gets the theme support arguments passed when registering that support. |
| is_random_header_image() wp-includes/theme.php | Checks if random header image is in use. |
| _get_random_header_data() wp-includes/theme.php | Gets random header image data from registered images in theme. |
| get_theme_mod() wp-includes/theme.php | Retrieves theme modification value 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. |
| wp_parse_args() wp-includes/functions.php | Merges user defined arguments into defaults array. |
Used By
| Used By | Description |
|---|---|
| get_header_video_settings() wp-includes/theme.php | Retrieves header video settings. |
| get_header_image_tag() wp-includes/theme.php | Creates image tag markup for a custom header image. |
| Custom_Image_Header::step_1() wp-admin/includes/class-custom-image-header.php | Display first step of custom header image page. |
Changelog
| Version | Description |
|---|---|
| 3.4.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_custom_header