From df6d81af5bf45d2388f8dbde8d3d030b6aeb5630 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Wed, 7 Nov 2012 20:12:47 +0000 Subject: [PATCH] Allow get_custom_header() to handle a default registered header that has yet to be saved to the database. fixes #22221. git-svn-id: https://develop.svn.wordpress.org/trunk@22436 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/theme.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/wp-includes/theme.php b/wp-includes/theme.php index 63e6e0a883..782c04cafb 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -1025,7 +1025,27 @@ function get_uploaded_header_images() { * @return object */ function get_custom_header() { - $data = is_random_header_image()? _get_random_header_data() : get_theme_mod( 'header_image_data' ); + 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() ); + $default_image = vsprintf( get_theme_support( 'custom-header', 'default-image' ), $directory_args ); + foreach ( $_wp_default_headers as $header => $details ) { + $url = vsprintf( $details['url'], $directory_args ); + if ( $default_image == $url ) { + $data = $details; + $data['url'] = $url; + $data['thumbnail_url'] = vsprintf( $data['thumbnail_url'], $directory_args ); + break; + } + } + } + } + $default = array( 'url' => '', 'thumbnail_url' => '',