Make WordPress Core

Ticket #38557: 38557.3.diff

File 38557.3.diff, 5.2 KB (added by bradyvercher, 8 years ago)
  • src/wp-admin/custom-header.php

     
    246246                }
    247247
    248248                $this->default_headers = $_wp_default_headers;
    249                 $template_directory_uri = get_template_directory_uri();
    250                 $stylesheet_directory_uri = get_stylesheet_directory_uri();
    251                 foreach ( array_keys($this->default_headers) as $header ) {
    252                         $this->default_headers[$header]['url'] =  sprintf( $this->default_headers[$header]['url'], $template_directory_uri, $stylesheet_directory_uri );
    253                         $this->default_headers[$header]['thumbnail_url'] =  sprintf( $this->default_headers[$header]['thumbnail_url'], $template_directory_uri, $stylesheet_directory_uri );
    254                 }
    255249        }
    256250
    257251        /**
     
    10801074                        $this->remove_header_image();
    10811075                        return;
    10821076                }
    1083                 $default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() );
    10841077
    10851078                $default_data = array();
    10861079                foreach ( $this->default_headers as $header => $details ) {
     
    13331326                        return $this->default_headers; // easy peasy.
    13341327                }
    13351328
    1336                 $default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() );
    13371329                $already_has_default = false;
    13381330
    13391331                foreach ( $this->default_headers as $k => $h ) {
  • src/wp-includes/class-wp-customize-manager.php

     
    34403440                ) ) );
    34413441
    34423442                $this->add_setting( new WP_Customize_Header_Image_Setting( $this, 'header_image_data', array(
    3443                         // 'default'        => get_theme_support( 'custom-header', 'default-image' ),
    34443443                        'theme_supports' => 'custom-header',
    34453444                ) ) );
    34463445
  • src/wp-includes/theme.php

     
    11131113                $header_image_mod = get_theme_mod( 'header_image', '' );
    11141114                $headers = array();
    11151115
    1116                 if ( 'random-uploaded-image' == $header_image_mod )
     1116                if ( 'random-uploaded-image' == $header_image_mod ) {
    11171117                        $headers = get_uploaded_header_images();
    1118                 elseif ( ! empty( $_wp_default_headers ) ) {
    1119                         if ( 'random-default-image' == $header_image_mod ) {
     1118                } elseif ( ! empty( $_wp_default_headers ) ) {
     1119                        if ( 'random-default-image' == $header_image_mod || current_theme_supports( 'custom-header', 'random-default' ) ) {
    11201120                                $headers = $_wp_default_headers;
    1121                         } else {
    1122                                 if ( current_theme_supports( 'custom-header', 'random-default' ) )
    1123                                         $headers = $_wp_default_headers;
    11241121                        }
    11251122                }
    11261123
     
    11281125                        return new stdClass;
    11291126
    11301127                $_wp_random_header = (object) $headers[ array_rand( $headers ) ];
    1131 
    1132                 $_wp_random_header->url =  sprintf( $_wp_random_header->url, get_template_directory_uri(), get_stylesheet_directory_uri() );
    1133                 $_wp_random_header->thumbnail_url =  sprintf( $_wp_random_header->thumbnail_url, get_template_directory_uri(), get_stylesheet_directory_uri() );
    11341128        }
    11351129        return $_wp_random_header;
    11361130}
     
    12421236        } else {
    12431237                $data = get_theme_mod( 'header_image_data' );
    12441238                if ( ! $data && current_theme_supports( 'custom-header', 'default-image' ) ) {
    1245                         $directory_args = array( get_template_directory_uri(), get_stylesheet_directory_uri() );
    12461239                        $data = array();
    1247                         $data['url'] = $data['thumbnail_url'] = vsprintf( get_theme_support( 'custom-header', 'default-image' ), $directory_args );
     1240                        $data['url'] = $data['thumbnail_url'] = get_theme_support( 'custom-header', 'default-image' );
    12481241                        if ( ! empty( $_wp_default_headers ) ) {
    12491242                                foreach ( (array) $_wp_default_headers as $default_header ) {
    1250                                         $url = vsprintf( $default_header['url'], $directory_args );
    1251                                         if ( $data['url'] == $url ) {
     1243                                        if ( $data['url'] == $default_header['url'] ) {
    12521244                                                $data = $default_header;
    1253                                                 $data['url'] = $url;
    1254                                                 $data['thumbnail_url'] = vsprintf( $data['thumbnail_url'], $directory_args );
    12551245                                                break;
    12561246                                        }
    12571247                                }
     
    12811271function register_default_headers( $headers ) {
    12821272        global $_wp_default_headers;
    12831273
     1274        $directories = array( get_template_directory_uri(), get_stylesheet_directory_uri() );
     1275
     1276        foreach ( (array) $headers as $key => $header ) {
     1277                if ( isset( $header['url'] ) ) {
     1278                        $headers[ $key ]['url'] = vsprintf( $header['url'], $directories );
     1279                }
     1280
     1281                if ( isset( $header['thumbnail_url'] ) ) {
     1282                        $headers[ $key ]['thumbnail_url'] = vsprintf( $header['thumbnail_url'], $directories );
     1283                }
     1284        }
     1285
    12841286        $_wp_default_headers = array_merge( (array) $_wp_default_headers, (array) $headers );
    12851287}
    12861288
     
    22382240                case 'custom-logo' :
    22392241                case 'custom-header' :
    22402242                case 'custom-background' :
    2241                         if ( isset( $_wp_theme_features[ $feature ][0][ $args[0] ] ) )
    2242                                 return $_wp_theme_features[ $feature ][0][ $args[0] ];
     2243                        if ( isset( $_wp_theme_features[ $feature ][0][ $args[0] ] ) ) {
     2244                                $value = $_wp_theme_features[ $feature ][0][ $args[0] ];
     2245                                if ( 'default-image' === $args[0] ) {
     2246                                        $value = sprintf( $value, get_template_directory_uri(), get_stylesheet_directory_uri() );
     2247                                }
     2248                                return $value;
     2249                        }
    22432250                        return false;
    22442251
    22452252                default :