WordPress.org

Make WordPress Core

Changeset 22436


Ignore:
Timestamp:
11/07/12 20:12:47 (17 months ago)
Author:
nacin
Message:

Allow get_custom_header() to handle a default registered header that has yet to be saved to the database. fixes #22221.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/theme.php

    r22313 r22436  
    10261026 */ 
    10271027function get_custom_header() { 
    1028     $data = is_random_header_image()? _get_random_header_data() : get_theme_mod( 'header_image_data' ); 
     1028    global $_wp_default_headers; 
     1029 
     1030    if ( is_random_header_image() ) { 
     1031        $data = _get_random_header_data(); 
     1032    } else { 
     1033        $data = get_theme_mod( 'header_image_data' ); 
     1034        if ( ! $data && current_theme_supports( 'custom-header', 'default-image' ) ) { 
     1035            $directory_args = array( get_template_directory_uri(), get_stylesheet_directory_uri() ); 
     1036            $default_image = vsprintf( get_theme_support( 'custom-header', 'default-image' ), $directory_args ); 
     1037            foreach ( $_wp_default_headers as $header => $details ) { 
     1038                $url = vsprintf( $details['url'], $directory_args ); 
     1039                if ( $default_image == $url ) { 
     1040                    $data = $details; 
     1041                    $data['url'] = $url; 
     1042                    $data['thumbnail_url'] = vsprintf( $data['thumbnail_url'], $directory_args ); 
     1043                    break; 
     1044                } 
     1045            } 
     1046        } 
     1047    } 
     1048 
    10291049    $default = array( 
    10301050        'url'           => '', 
Note: See TracChangeset for help on using the changeset viewer.