<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[20212] trunk: Introduce new registration methods for custom headers and custom backgrounds.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/20212">20212</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2012-03-19 17:12:44 +0000 (Mon, 19 Mar 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Introduce new registration methods for custom headers and custom backgrounds. Backwards compatible, but old methods will be deprecated. see <a href="http://core.trac.wordpress.org/ticket/20249">#20249</a>. see <a href="http://core.trac.wordpress.org/ticket/17242">#17242</a>.

Custom header: Use add_theme_support('custom-header', $args) instead of add_custom_image_header(). Deprecates all use of constants.
 * HEADER_TEXTCOLOR is now (string) 'default-text-color'.
 * NO_HEADER_TEXT is nowi ! (bool) 'header-text'.
 * HEADER_IMAGE_WIDTH (and _HEIGHT) are now (int) 'width' and 'height'.
 * HEADER_IMAGE is now (string) 'default-image'.
 * The 3.4 arguments 'suggested-width' and 'suggested-height' are now just 'width' and 'height' (they are &quot;suggested&quot; when flex-width and flex-height are set).
 * Callback arguments for add_custom_image_header() can now be passed to add_theme_support().

Custom background: Use add_theme_support('custom-background, $args) instead of add_custom_background(). Deprecates all use of constants.
 * BACKGROUND_COLOR is now (string) 'default-color'.
 * BACKGROUND_IMAGE is now (string) 'default-image'.
 * Callback arguments for add_custom_background() can now be passed to add_theme_support().

Inheritance: add_theme_support() arguments for custom headers and custom backgrounds is a first-one-wins situation. This is not an unusual paradigm for theming as a child theme (which is included first) overrides a parent theme.
 * Once an argument is explicitly set, it cannot be overridden. You must hook in earlier and set it first.
 * Any argument that is not explicitly set before WP is loaded will inherit the default value for that argument.
 * It is therefore possible for a child theme to pass minimal arguments as long as the parent theme specifies others that may be necessary.
 * Allows for a child theme to alter callbacks for &lt;head&gt; and preview (previously, calling add_custom_image_header more than once broke things).
 * The just-in-time bits ensure that arguments fall back to default values, that the values of all constants are considered (such as one defined after an old add_custom_image_header call), and that all constants are defined (so as to be backwards compatible).

get_theme_support(): Introduce new second argument, which headers and backgrounds leverage to return an argument. current_theme_supports() already supported checking the truthiness of the argument.
 * For example, get_theme_support( 'custom-header', 'width' ) will return the width specified during registration.
 * If you had wanted the default image, use get_theme_support( 'custom-header', 'default-image' ) instead of HEADER_IMAGE. 

Deprecate remove_custom_image_header(), remove_custom_background(). Use remove_theme_support('custom-header'), 'custom-background'.

Deprecate short-lived custom-header-uploads internal support; this is now (bool) 'uploads' for add_theme_support().

New 3.4 functions renamed or removed: Rename get_current_header_data() to get_custom_header(). Remove get_header_image_width() and _height() in favor of get_custom_header()-&gt;width and height.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmincustombackgroundphp">trunk/wp-admin/custom-background.php</a></li>
<li><a href="#trunkwpadmincustomheaderphp">trunk/wp-admin/custom-header.php</a></li>
<li><a href="#trunkwpincludesclasswpcustomizephp">trunk/wp-includes/class-wp-customize.php</a></li>
<li><a href="#trunkwpincludesthemephp">trunk/wp-includes/theme.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmincustombackgroundphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/custom-background.php (20211 => 20212)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/custom-background.php        2012-03-19 14:45:29 UTC (rev 20211)
+++ trunk/wp-admin/custom-background.php        2012-03-19 17:12:44 UTC (rev 20212)
</span><span class="lines">@@ -53,6 +53,8 @@
</span><span class="cx">         function __construct($admin_header_callback = '', $admin_image_div_callback = '') {
</span><span class="cx">                 $this-&gt;admin_header_callback = $admin_header_callback;
</span><span class="cx">                 $this-&gt;admin_image_div_callback = $admin_image_div_callback;
</span><ins>+
+                add_action( 'admin_menu', array( $this, 'init' ) );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="lines">@@ -226,7 +228,7 @@
</span><span class="cx"> &lt;/tr&gt;
</span><span class="cx"> &lt;?php endif; ?&gt;
</span><span class="cx"> 
</span><del>-&lt;?php if ( defined( 'BACKGROUND_IMAGE' ) ) : // Show only if a default background image exists ?&gt;
</del><ins>+&lt;?php if ( get_theme_support( 'custom-background', 'default-image' ) ) : ?&gt;
</ins><span class="cx"> &lt;tr valign=&quot;top&quot;&gt;
</span><span class="cx"> &lt;th scope=&quot;row&quot;&gt;&lt;?php _e('Restore Original Image'); ?&gt;&lt;/th&gt;
</span><span class="cx"> &lt;td&gt;
</span></span></pre></div>
<a id="trunkwpadmincustomheaderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/custom-header.php (20211 => 20212)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/custom-header.php        2012-03-19 14:45:29 UTC (rev 20211)
+++ trunk/wp-admin/custom-header.php        2012-03-19 17:12:44 UTC (rev 20212)
</span><span class="lines">@@ -71,6 +71,8 @@
</span><span class="cx">         function __construct($admin_header_callback, $admin_image_div_callback = '') {
</span><span class="cx">                 $this-&gt;admin_header_callback = $admin_header_callback;
</span><span class="cx">                 $this-&gt;admin_image_div_callback = $admin_image_div_callback;
</span><ins>+
+                add_action( 'admin_menu', array( $this, 'init' ) );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="lines">@@ -140,7 +142,7 @@
</span><span class="cx">         function js_includes() {
</span><span class="cx">                 $step = $this-&gt;step();
</span><span class="cx"> 
</span><del>-                if ( ( 1 == $step || 3 == $step ) &amp;&amp; $this-&gt;header_text() )
</del><ins>+                if ( ( 1 == $step || 3 == $step ) &amp;&amp; current_theme_supports( 'custom-header', 'header-text' ) )
</ins><span class="cx">                         wp_enqueue_script('farbtastic');
</span><span class="cx">                 elseif ( 2 == $step )
</span><span class="cx">                         wp_enqueue_script('imgareaselect');
</span><span class="lines">@@ -154,25 +156,13 @@
</span><span class="cx">         function css_includes() {
</span><span class="cx">                 $step = $this-&gt;step();
</span><span class="cx"> 
</span><del>-                if ( ( 1 == $step || 3 == $step ) &amp;&amp; $this-&gt;header_text() )
</del><ins>+                if ( ( 1 == $step || 3 == $step ) &amp;&amp; current_theme_supports( 'custom-header', 'header-text' ) )
</ins><span class="cx">                         wp_enqueue_style('farbtastic');
</span><span class="cx">                 elseif ( 2 == $step )
</span><span class="cx">                         wp_enqueue_style('imgareaselect');
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * Check if header text is allowed
-         *
-         * @since 3.0.0
-         */
-        function header_text() {
-                if ( defined( 'NO_HEADER_TEXT' ) &amp;&amp; NO_HEADER_TEXT )
-                        return false;
-
-                return true;
-        }
-
-        /**
</del><span class="cx">          * Execute custom header modification.
</span><span class="cx">          *
</span><span class="cx">          * @since 2.6.0
</span><span class="lines">@@ -189,7 +179,7 @@
</span><span class="cx">                 if ( isset( $_POST['resetheader'] ) ) {
</span><span class="cx">                         check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' );
</span><span class="cx">                         $this-&gt;process_default_headers();
</span><del>-                        $default = defined( 'HEADER_IMAGE' ) ? HEADER_IMAGE : '';
</del><ins>+                        $default = get_theme_support( 'custom-header', 'default-image' );
</ins><span class="cx">                         $default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() );
</span><span class="cx">                         foreach ( $this-&gt;default_headers as $header =&gt; $details ) {
</span><span class="cx">                                 if ( $details['url'] == $default ) {
</span><span class="lines">@@ -199,9 +189,9 @@
</span><span class="cx">                         }
</span><span class="cx">                         set_theme_mod( 'header_image', $default );
</span><span class="cx">                         if ( empty( $default_data['width'] ) )
</span><del>-                                $default_data['width'] = HEADER_IMAGE_WIDTH;
</del><ins>+                                $default_data['width'] = get_theme_support( 'custom-header', 'width' );
</ins><span class="cx">                         if ( empty( $default_data['height'] ) )
</span><del>-                                $default_data['height'] = HEADER_IMAGE_HEIGHT;
</del><ins>+                                $default_data['height'] = get_theme_support( 'custom-header', 'height' );
</ins><span class="cx">                         set_theme_mod( 'header_image_data', (object) $default_data );
</span><span class="cx">                         return;
</span><span class="cx">                 }
</span><span class="lines">@@ -245,9 +235,9 @@
</span><span class="cx">                                 } elseif ( isset( $this-&gt;default_headers[$_POST['default-header']] ) ) {
</span><span class="cx">                                         set_theme_mod( 'header_image', esc_url( $this-&gt;default_headers[$_POST['default-header']]['url'] ) );
</span><span class="cx">                                         if ( empty( $this-&gt;default_headers[$_POST['default-header']]['width'] ) )
</span><del>-                                                $this-&gt;default_headers[$_POST['default-header']]['width'] = HEADER_IMAGE_WIDTH;
</del><ins>+                                                $this-&gt;default_headers[$_POST['default-header']]['width'] = get_theme_support( 'custom-header', 'width' );
</ins><span class="cx">                                         if ( empty( $this-&gt;default_headers[$_POST['default-header']]['height'] ) )
</span><del>-                                                $this-&gt;default_headers[$_POST['default-header']]['height'] = HEADER_IMAGE_HEIGHT;
</del><ins>+                                                $this-&gt;default_headers[$_POST['default-header']]['height'] = get_theme_support( 'custom-header', 'height' );
</ins><span class="cx">                                         set_theme_mod( 'header_image_data', (object) $this-&gt;default_headers[$_POST['default-header']] );
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="lines">@@ -325,7 +315,7 @@
</span><span class="cx">          */
</span><span class="cx">         function js() {
</span><span class="cx">                 $step = $this-&gt;step();
</span><del>-                if ( ( 1 == $step || 3 == $step ) &amp;&amp; $this-&gt;header_text() )
</del><ins>+                if ( ( 1 == $step || 3 == $step ) &amp;&amp; current_theme_supports( 'custom-header', 'header-text' ) )
</ins><span class="cx">                         $this-&gt;js_1();
</span><span class="cx">                 elseif ( 2 == $step )
</span><span class="cx">                         $this-&gt;js_2();
</span><span class="lines">@@ -341,7 +331,7 @@
</span><span class="cx"> /* &lt;![CDATA[ */
</span><span class="cx">         var text_objects = ['#name', '#desc', '#text-color-row'];
</span><span class="cx">         var farbtastic;
</span><del>-        var default_color = '#&lt;?php echo HEADER_TEXTCOLOR; ?&gt;';
</del><ins>+        var default_color = '#&lt;?php echo get_theme_support( 'custom-header', 'default-text-color' ); ?&gt;';
</ins><span class="cx">         var old_color = null;
</span><span class="cx"> 
</span><span class="cx">         function pickColor(color) {
</span><span class="lines">@@ -411,11 +401,11 @@
</span><span class="cx">                 });
</span><span class="cx"> 
</span><span class="cx">                 farbtastic = jQuery.farbtastic('#color-picker', function(color) { pickColor(color); });
</span><del>-                &lt;?php if ( $color = get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) ) { ?&gt;
</del><ins>+                &lt;?php if ( $color = get_header_textcolor() ) { ?&gt;
</ins><span class="cx">                 pickColor('#&lt;?php echo $color; ?&gt;');
</span><span class="cx">                 &lt;?php } ?&gt;
</span><span class="cx"> 
</span><del>-                &lt;?php if ( 'blank' == get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ) || '' == get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) || ! $this-&gt;header_text() ) { ?&gt;
</del><ins>+                &lt;?php if ( 'blank' == $color || '' == $color || ! current_theme_supports( 'custom-header', 'header-text' ) ) { ?&gt;
</ins><span class="cx">                 toggle_text();
</span><span class="cx">                 &lt;?php } ?&gt;
</span><span class="cx">         });
</span><span class="lines">@@ -440,17 +430,8 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         jQuery(document).ready(function() {
</span><del>-                &lt;?php
-                $xinit = HEADER_IMAGE_WIDTH;
-                $yinit = HEADER_IMAGE_HEIGHT;
-                $header_support = get_theme_support( 'custom-header' );
-                if ( !empty( $header_support[ 0 ][ 'suggested-width' ] ) )
-                        $xinit = $header_support[ 0 ][ 'suggested-width' ];
-                if ( !empty( $header_support[ 0 ][ 'suggested-height' ] ) )
-                        $yinit = $header_support[ 0 ][ 'suggested-height' ];
-                ?&gt;
-                var xinit = &lt;?php echo absint( $xinit ); ?&gt;;
-                var yinit = &lt;?php echo absint( $yinit ); ?&gt;;
</del><ins>+                var xinit = &lt;?php echo absint( get_theme_support( 'custom-header', 'width' ) ); ?&gt;;
+                var yinit = &lt;?php echo absint( get_theme_support( 'custom-header', 'height' ) ); ?&gt;;
</ins><span class="cx">                 var ratio = xinit / yinit;
</span><span class="cx">                 var ximg = jQuery('img#upload').width();
</span><span class="cx">                 var yimg = jQuery('img#upload').height();
</span><span class="lines">@@ -481,12 +462,12 @@
</span><span class="cx">                         }
</span><span class="cx">                         if ( ! current_theme_supports( 'custom-header', 'flex-height' ) ) {
</span><span class="cx">                         ?&gt;
</span><del>-                        maxHeight: &lt;?php echo HEADER_IMAGE_HEIGHT; ?&gt;,
</del><ins>+                        maxHeight: &lt;?php echo get_theme_support( 'custom-header', 'height' ); ?&gt;,
</ins><span class="cx">                         &lt;?php
</span><span class="cx">                         }
</span><span class="cx">                         if ( ! current_theme_supports( 'custom-header', 'flex-width' ) ) {
</span><span class="cx">                         ?&gt;
</span><del>-                        maxWidth: &lt;?php echo HEADER_IMAGE_WIDTH; ?&gt;,
</del><ins>+                        maxWidth: &lt;?php echo get_theme_support( 'custom-header', 'width' ); ?&gt;,
</ins><span class="cx">                         &lt;?php
</span><span class="cx">                         }
</span><span class="cx">                         ?&gt;
</span><span class="lines">@@ -531,17 +512,18 @@
</span><span class="cx"> 
</span><span class="cx"> &lt;tr valign=&quot;top&quot;&gt;
</span><span class="cx"> &lt;th scope=&quot;row&quot;&gt;&lt;?php _e( 'Preview' ); ?&gt;&lt;/th&gt;
</span><del>-&lt;td &gt;
</del><ins>+&lt;td&gt;
</ins><span class="cx">         &lt;?php if ( $this-&gt;admin_image_div_callback ) {
</span><span class="cx">           call_user_func( $this-&gt;admin_image_div_callback );
</span><span class="cx">         } else {
</span><span class="cx">         ?&gt;
</span><del>-        &lt;div id=&quot;headimg&quot; style=&quot;background-image:url(&lt;?php esc_url ( header_image() ) ?&gt;);max-width:&lt;?php echo get_header_image_width(); ?&gt;px;height:&lt;?php echo get_header_image_height(); ?&gt;px;&quot;&gt;
</del><ins>+        &lt;div id=&quot;headimg&quot; style=&quot;background-image:url(&lt;?php esc_url ( header_image() ) ?&gt;);max-width:&lt;?php echo get_custom_header()-&gt;width; ?&gt;px;height:&lt;?php echo get_custom_header()-&gt;height; ?&gt;px;&quot;&gt;
</ins><span class="cx">                 &lt;?php
</span><del>-                if ( 'blank' == get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) || '' == get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) || ! $this-&gt;header_text() )
</del><ins>+                $color = get_header_textcolor();
+                if ( 'blank' == $color || '' == $color || ! current_theme_supports( 'custom-header', 'header-text' ) )
</ins><span class="cx">                         $style = ' style=&quot;display:none;&quot;';
</span><span class="cx">                 else
</span><del>-                        $style = ' style=&quot;color:#' . get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ) . ';&quot;';
</del><ins>+                        $style = ' style=&quot;color:#' . $color . ';&quot;';
</ins><span class="cx">                 ?&gt;
</span><span class="cx">                 &lt;h1&gt;&lt;a id=&quot;name&quot;&lt;?php echo $style; ?&gt; onclick=&quot;return false;&quot; href=&quot;&lt;?php bloginfo('url'); ?&gt;&quot;&gt;&lt;?php bloginfo( 'name' ); ?&gt;&lt;/a&gt;&lt;/h1&gt;
</span><span class="cx">                 &lt;div id=&quot;desc&quot;&lt;?php echo $style; ?&gt;&gt;&lt;?php bloginfo( 'description' ); ?&gt;&lt;/div&gt;
</span><span class="lines">@@ -549,27 +531,26 @@
</span><span class="cx">         &lt;?php } ?&gt;
</span><span class="cx"> &lt;/td&gt;
</span><span class="cx"> &lt;/tr&gt;
</span><del>-&lt;?php if ( current_theme_supports( 'custom-header-uploads' ) ) : ?&gt;
</del><ins>+&lt;?php if ( current_theme_supports( 'custom-header', 'uploads' ) ) : ?&gt;
</ins><span class="cx"> &lt;tr valign=&quot;top&quot;&gt;
</span><span class="cx"> &lt;th scope=&quot;row&quot;&gt;&lt;?php _e( 'Upload Image' ); ?&gt;&lt;/th&gt;
</span><span class="cx"> &lt;td&gt;
</span><span class="cx">         &lt;p&gt;&lt;?php _e( 'You can upload a custom header image to be shown at the top of your site instead of the default one. On the next screen you will be able to crop the image.' ); ?&gt;&lt;br /&gt;
</span><span class="cx">         &lt;?php
</span><span class="cx">         if ( ! current_theme_supports( 'custom-header', 'flex-height' ) &amp;&amp; ! current_theme_supports( 'custom-header', 'flex-width' ) ) {
</span><del>-                printf( __( 'Images of exactly &lt;strong&gt;%1$d &amp;times; %2$d pixels&lt;/strong&gt; will be used as-is.' ) . '&lt;br /&gt;', HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT );
</del><ins>+                printf( __( 'Images of exactly &lt;strong&gt;%1$d &amp;times; %2$d pixels&lt;/strong&gt; will be used as-is.' ) . '&lt;br /&gt;', get_theme_support( 'custom-header', 'width' ), get_theme_support( 'custom-header', 'height' ) );
</ins><span class="cx">         } elseif ( current_theme_supports( 'custom-header', 'flex-height' ) ) {
</span><span class="cx">                 if ( ! current_theme_supports( 'custom-header', 'flex-width' ) )
</span><del>-                        printf( __( 'Images should be at least &lt;strong&gt;%1$d pixels&lt;/strong&gt; wide.' ) . '&lt;br /&gt;', HEADER_IMAGE_WIDTH );
</del><ins>+                        printf( __( 'Images should be at least &lt;strong&gt;%1$d pixels&lt;/strong&gt; wide.' ) . ' ', get_theme_support( 'custom-header', 'width' ) );
</ins><span class="cx">         } elseif ( current_theme_supports( 'custom-header', 'flex-width' ) ) {
</span><span class="cx">                 if ( ! current_theme_supports( 'custom-header', 'flex-height' ) )
</span><del>-                        printf( __( 'Images should be at least &lt;strong&gt;%1$d pixels&lt;/strong&gt; tall.' ) . '&lt;br /&gt;', HEADER_IMAGE_HEIGHT );
</del><ins>+                        printf( __( 'Images should be at least &lt;strong&gt;%1$d pixels&lt;/strong&gt; tall.' ) . ' ', get_theme_support( 'custom-header', 'height' ) );
</ins><span class="cx">         }
</span><span class="cx">         if ( current_theme_supports( 'custom-header', 'flex-height' ) || current_theme_supports( 'custom-header', 'flex-width' ) ) {
</span><del>-                $header_support = get_theme_support( 'custom-header' );
-                if ( !empty( $header_support[ 0 ][ 'suggested-width' ] ) )
-                        printf( __( 'Suggested width is &lt;strong&gt;%1$d pixels&lt;/strong&gt;.' ) . '&lt;br /&gt;', absint( $header_support[ 0 ][ 'suggested-width' ] ) );
-                if ( !empty( $header_support[ 0 ][ 'suggested-height' ] ) )
-                        printf( __( 'Suggested height is &lt;strong&gt;%1$d pixels&lt;/strong&gt;.' ) . '&lt;br /&gt;', absint( $header_support[ 0 ][ 'suggested-height' ] ) );
</del><ins>+                if ( current_theme_supports( 'custom-header', 'width' ) )
+                        printf( __( 'Suggested width is &lt;strong&gt;%1$d pixels&lt;/strong&gt;.' ) . ' ', get_theme_support( 'custom-header', 'width' ) );
+                if ( current_theme_supports( 'custom-header', 'height' ) )
+                        printf( __( 'Suggested height is &lt;strong&gt;%1$d pixels&lt;/strong&gt;.' ) . ' ', get_theme_support( 'custom-header', 'height' ) );
</ins><span class="cx">         }
</span><span class="cx">         ?&gt;&lt;/p&gt;
</span><span class="cx">         &lt;form enctype=&quot;multipart/form-data&quot; id=&quot;upload-form&quot; method=&quot;post&quot; action=&quot;&lt;?php echo esc_attr( add_query_arg( 'step', 2 ) ) ?&gt;&quot;&gt;
</span><span class="lines">@@ -605,7 +586,7 @@
</span><span class="cx"> &lt;tr valign=&quot;top&quot;&gt;
</span><span class="cx"> &lt;th scope=&quot;row&quot;&gt;&lt;?php _e( 'Default Images' ); ?&gt;&lt;/th&gt;
</span><span class="cx"> &lt;td&gt;
</span><del>-&lt;?php if ( current_theme_supports( 'custom-header-uploads' ) ) : ?&gt;
</del><ins>+&lt;?php if ( current_theme_supports( 'custom-header', 'uploads' ) ) : ?&gt;
</ins><span class="cx">         &lt;p&gt;&lt;?php _e( 'If you don&amp;lsquo;t want to upload your own image, you can use one of these cool headers, or show a random one.' ) ?&gt;&lt;/p&gt;
</span><span class="cx"> &lt;?php else: ?&gt;
</span><span class="cx">         &lt;p&gt;&lt;?php _e( 'You can use one of these cool headers or show a random one on each page.' ) ?&gt;&lt;/p&gt;
</span><span class="lines">@@ -626,7 +607,7 @@
</span><span class="cx"> &lt;/tr&gt;
</span><span class="cx">         &lt;?php endif;
</span><span class="cx"> 
</span><del>-        if ( defined( 'HEADER_IMAGE' ) &amp;&amp; '' != HEADER_IMAGE ) : ?&gt;
</del><ins>+        if ( current_theme_supports( 'custom-header', 'default-image' ) ) : ?&gt;
</ins><span class="cx"> &lt;tr valign=&quot;top&quot;&gt;
</span><span class="cx"> &lt;th scope=&quot;row&quot;&gt;&lt;?php _e( 'Reset Image' ); ?&gt;&lt;/th&gt;
</span><span class="cx"> &lt;td&gt;
</span><span class="lines">@@ -637,16 +618,22 @@
</span><span class="cx">         &lt;?php endif; ?&gt;
</span><span class="cx"> &lt;/tbody&gt;
</span><span class="cx"> &lt;/table&gt;
</span><del>-        &lt;?php if ( $this-&gt;header_text() ) : ?&gt;
</del><ins>+        &lt;?php if ( current_theme_supports( 'custom-header', 'header-text' ) ) : ?&gt;
</ins><span class="cx"> &lt;table class=&quot;form-table&quot;&gt;
</span><span class="cx"> &lt;tbody&gt;
</span><span class="cx"> &lt;tr valign=&quot;top&quot; class=&quot;hide-if-no-js&quot;&gt;
</span><span class="cx"> &lt;th scope=&quot;row&quot;&gt;&lt;?php _e( 'Display Text' ); ?&gt;&lt;/th&gt;
</span><span class="cx"> &lt;td&gt;
</span><span class="cx">         &lt;p&gt;
</span><del>-        &lt;?php $hidetext = get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ); ?&gt;
-        &lt;label&gt;&lt;input type=&quot;radio&quot; value=&quot;1&quot; name=&quot;hidetext&quot; id=&quot;hidetext&quot;&lt;?php checked( ( 'blank' == $hidetext || empty( $hidetext ) )  ? true : false ); ?&gt; /&gt; &lt;?php _e( 'No' ); ?&gt;&lt;/label&gt;
-        &lt;label&gt;&lt;input type=&quot;radio&quot; value=&quot;0&quot; name=&quot;hidetext&quot; id=&quot;showtext&quot;&lt;?php checked( ( 'blank' == $hidetext || empty( $hidetext ) ) ? false : true ); ?&gt; /&gt; &lt;?php _e( 'Yes' ); ?&gt;&lt;/label&gt;
</del><ins>+        &lt;?php
+                $show_text = get_header_textcolor();
+                if ( 'blank' == $show_text )
+                        $show_text = false;
+                else
+                        $show_text = (bool) $show_text;
+        ?&gt;
+        &lt;label&gt;&lt;input type=&quot;radio&quot; value=&quot;1&quot; name=&quot;hidetext&quot; id=&quot;hidetext&quot;&lt;?php checked( ! $show_text ); ?&gt; /&gt; &lt;?php _e( 'No' ); ?&gt;&lt;/label&gt;
+        &lt;label&gt;&lt;input type=&quot;radio&quot; value=&quot;0&quot; name=&quot;hidetext&quot; id=&quot;showtext&quot;&lt;?php checked( $show_text ); ?&gt; /&gt; &lt;?php _e( 'Yes' ); ?&gt;&lt;/label&gt;
</ins><span class="cx">         &lt;/p&gt;
</span><span class="cx"> &lt;/td&gt;
</span><span class="cx"> &lt;/tr&gt;
</span><span class="lines">@@ -655,7 +642,7 @@
</span><span class="cx"> &lt;th scope=&quot;row&quot;&gt;&lt;?php _e( 'Text Color' ); ?&gt;&lt;/th&gt;
</span><span class="cx"> &lt;td&gt;
</span><span class="cx">         &lt;p&gt;
</span><del>-                &lt;input type=&quot;text&quot; name=&quot;text-color&quot; id=&quot;text-color&quot; value=&quot;#&lt;?php echo esc_attr( get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ) ); ?&gt;&quot; /&gt;
</del><ins>+                &lt;input type=&quot;text&quot; name=&quot;text-color&quot; id=&quot;text-color&quot; value=&quot;#&lt;?php echo esc_attr( get_header_textcolor() ); ?&gt;&quot; /&gt;
</ins><span class="cx">                 &lt;span class=&quot;description hide-if-js&quot;&gt;&lt;?php _e( 'If you want to hide header text, add &lt;strong&gt;#blank&lt;/strong&gt; as text color.' );?&gt;&lt;/span&gt;
</span><span class="cx">                 &lt;input type=&quot;button&quot; class=&quot;button hide-if-no-js&quot; value=&quot;&lt;?php esc_attr_e( 'Select a Color' ); ?&gt;&quot; id=&quot;pickcolor&quot; /&gt;
</span><span class="cx">         &lt;/p&gt;
</span><span class="lines">@@ -663,7 +650,7 @@
</span><span class="cx"> &lt;/td&gt;
</span><span class="cx"> &lt;/tr&gt;
</span><span class="cx"> 
</span><del>-        &lt;?php if ( defined('HEADER_TEXTCOLOR') &amp;&amp; get_theme_mod('header_textcolor') ) { ?&gt;
</del><ins>+        &lt;?php if ( current_theme_supports( 'custom-header', 'default-text-color' ) &amp;&amp; get_theme_mod( 'header_textcolor' ) ) { ?&gt;
</ins><span class="cx"> &lt;tr valign=&quot;top&quot;&gt;
</span><span class="cx"> &lt;th scope=&quot;row&quot;&gt;&lt;?php _e('Reset Text Color'); ?&gt;&lt;/th&gt;
</span><span class="cx"> &lt;td&gt;
</span><span class="lines">@@ -694,7 +681,7 @@
</span><span class="cx">          */
</span><span class="cx">         function step_2() {
</span><span class="cx">                 check_admin_referer('custom-header-upload', '_wpnonce-custom-header-upload');
</span><del>-                if ( ! current_theme_supports( 'custom-header-uploads' ) )
</del><ins>+                if ( ! current_theme_supports( 'custom-header', 'uploads' ) )
</ins><span class="cx">                         wp_die( __( 'Cheatin&amp;#8217; uh?' ) );
</span><span class="cx"> 
</span><span class="cx">                 $overrides = array('test_form' =&gt; false);
</span><span class="lines">@@ -722,19 +709,19 @@
</span><span class="cx"> 
</span><span class="cx">                 list($width, $height, $type, $attr) = getimagesize( $file );
</span><span class="cx"> 
</span><del>-                $header_support = get_theme_support( 'custom-header' );
</del><span class="cx">                 $max_width = 0;
</span><span class="cx">                 // For flex, limit size of image displayed to 1500px unless theme says otherwise
</span><span class="cx">                 if ( current_theme_supports( 'custom-header', 'flex-width' ) )
</span><span class="cx">                         $max_width = 1500;
</span><span class="cx"> 
</span><del>-                if ( !empty( $header_support[ 0 ][ 'max-width' ] ) )
-                        $max_width = max( $max_width, absint( $header_support[ 0 ][ 'max-width' ] ) );
</del><ins>+                if ( current_theme_supports( 'custom-header', 'max-width' ) )
+                        $max_width = max( $max_width, get_theme_support( 'custom-header', 'max-width' ) );
+                $max_width = max( $max_width, get_theme_support( 'custom-header', 'width' ) );
</ins><span class="cx"> 
</span><del>-                if ( defined( 'HEADER_IMAGE_WIDTH' ) )
-                        $max_width = max( $max_width, HEADER_IMAGE_WIDTH );
</del><span class="cx">                 // If flexible height isn't supported and the image is the exact right size
</span><del>-                if ( ! current_theme_supports( 'custom-header', 'flex-height' ) &amp;&amp; ! current_theme_supports( 'custom-header', 'flex-width' ) &amp;&amp; $width == HEADER_IMAGE_WIDTH &amp;&amp; $height == HEADER_IMAGE_HEIGHT ) {
</del><ins>+                if ( ! current_theme_supports( 'custom-header', 'flex-height' ) &amp;&amp; ! current_theme_supports( 'custom-header', 'flex-width' )
+                        &amp;&amp; $width == get_theme_support( 'custom-header', 'width' ) &amp;&amp; $height == get_theme_support( 'custom-header', 'height' ) )
+                {
</ins><span class="cx">                         // Add the meta-data
</span><span class="cx">                         wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
</span><span class="cx">                         update_post_meta( $id, '_wp_attachment_is_custom_header', get_option('stylesheet' ) );
</span><span class="lines">@@ -791,8 +778,9 @@
</span><span class="cx">          * @since 2.1.0
</span><span class="cx">          */
</span><span class="cx">         function step_3() {
</span><del>-                check_admin_referer('custom-header-crop-image');
-                if ( ! current_theme_supports( 'custom-header-uploads' ) )
</del><ins>+                check_admin_referer( 'custom-header-crop-image' );
+
+                if ( ! current_theme_supports( 'custom-header', 'uploads' ) )
</ins><span class="cx">                         wp_die( __( 'Cheatin&amp;#8217; uh?' ) );
</span><span class="cx"> 
</span><span class="cx">                 if ( $_POST['oitar'] &gt; 1 ) {
</span><span class="lines">@@ -805,31 +793,29 @@
</span><span class="cx">                 $attachment_id = absint( $_POST['attachment_id'] );
</span><span class="cx">                 $original = get_attached_file($attachment_id);
</span><span class="cx"> 
</span><del>-                $header_support = get_theme_support( 'custom-header' );
</del><ins>+
</ins><span class="cx">                 $max_width = 0;
</span><span class="cx">                 // For flex, limit size of image displayed to 1500px unless theme says otherwise
</span><span class="cx">                 if ( current_theme_supports( 'custom-header', 'flex-width' ) )
</span><span class="cx">                         $max_width = 1500;
</span><span class="cx"> 
</span><del>-                if ( !empty( $header_support[ 0 ][ 'max-width' ] ) )
-                        $max_width = max( $max_width, absint( $header_support[ 0 ][ 'max-width' ] ) );
</del><ins>+                if ( current_theme_supports( 'custom-header', 'max-width' ) )
+                        $max_width = max( $max_width, get_theme_support( 'custom-header', 'max-width' ) );
+                $max_width = max( $max_width, get_theme_support( 'custom-header', 'width' ) );
</ins><span class="cx"> 
</span><del>-                if ( defined( 'HEADER_IMAGE_WIDTH' ) )
-                        $max_width = max( $max_width, HEADER_IMAGE_WIDTH );
-
</del><span class="cx">                 if ( ( current_theme_supports( 'custom-header', 'flex-height' ) &amp;&amp; ! current_theme_supports( 'custom-header', 'flex-width' ) ) || $_POST['width'] &gt; $max_width )
</span><span class="cx">                         $dst_height = absint( $_POST['height'] * ( $max_width / $_POST['width'] ) );
</span><span class="cx">                 elseif ( current_theme_supports( 'custom-header', 'flex-height' ) &amp;&amp; current_theme_supports( 'custom-header', 'flex-width' ) )
</span><span class="cx">                         $dst_height = absint( $_POST['height'] );
</span><span class="cx">                 else
</span><del>-                        $dst_height = HEADER_IMAGE_HEIGHT;
</del><ins>+                        $dst_height = get_theme_support( 'custom-header', 'height' );
</ins><span class="cx"> 
</span><span class="cx">                 if ( ( current_theme_supports( 'custom-header', 'flex-width' ) &amp;&amp; ! current_theme_supports( 'custom-header', 'flex-height' ) ) || $_POST['width'] &gt; $max_width )
</span><span class="cx">                         $dst_width = absint( $_POST['width'] * ( $max_width / $_POST['width'] ) );
</span><span class="cx">                 elseif ( current_theme_supports( 'custom-header', 'flex-width' ) &amp;&amp; current_theme_supports( 'custom-header', 'flex-height' ) )
</span><span class="cx">                         $dst_width = absint( $_POST['width'] );
</span><span class="cx">                 else
</span><del>-                        $dst_width = HEADER_IMAGE_WIDTH;
</del><ins>+                        $dst_width = get_theme_support( 'custom-header', 'width' );
</ins><span class="cx"> 
</span><span class="cx">                 $cropped = wp_crop_image( $attachment_id, (int) $_POST['x1'], (int) $_POST['y1'], (int) $_POST['width'], (int) $_POST['height'], $dst_width, $dst_height );
</span><span class="cx">                 if ( is_wp_error( $cropped ) )
</span></span></pre></div>
<a id="trunkwpincludesclasswpcustomizephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/class-wp-customize.php (20211 => 20212)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/class-wp-customize.php        2012-03-19 14:45:29 UTC (rev 20211)
+++ trunk/wp-includes/class-wp-customize.php        2012-03-19 17:12:44 UTC (rev 20212)
</span><span class="lines">@@ -479,7 +479,7 @@
</span><span class="cx">                         'section'           =&gt; 'header',
</span><span class="cx">                         'sanitize_callback' =&gt; 'sanitize_hexcolor',
</span><span class="cx">                         'control'           =&gt; 'color',
</span><del>-                        'default'           =&gt; defined( 'HEADER_TEXTCOLOR' ) ? HEADER_TEXTCOLOR : ''
</del><ins>+                        'default'           =&gt; get_theme_support( 'custom-header', 'default-text-color' ),
</ins><span class="cx">                 ) );
</span><span class="cx"> 
</span><span class="cx">                 /*
</span><span class="lines">@@ -505,7 +505,7 @@
</span><span class="cx">                         'control' =&gt; 'checkbox',
</span><span class="cx">                          // @todo
</span><span class="cx">                          // not the default, it's the value.
</span><del>-                         // value is saved in get_theme_support( 'custom-header' )[0][ 'random-default' ]
</del><ins>+                         // value is saved in get_theme_support( 'custom-header', 'random-default' )
</ins><span class="cx">                         'default' =&gt; 'random-default-image'
</span><span class="cx">                 ) );
</span><span class="cx"> 
</span><span class="lines">@@ -522,7 +522,7 @@
</span><span class="cx">                         'label'             =&gt; 'Background Color',
</span><span class="cx">                         'section'           =&gt; 'background',
</span><span class="cx">                         'control'           =&gt; 'color',
</span><del>-                        'default'           =&gt; defined( 'BACKGROUND_COLOR' ) ? BACKGROUND_COLOR : '',
</del><ins>+                        'default'           =&gt; get_theme_support( 'custom-background', 'default-color' ),
</ins><span class="cx">                         'sanitize_callback' =&gt; 'sanitize_hexcolor',
</span><span class="cx">                 ) );
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpincludesthemephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/theme.php (20211 => 20212)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/theme.php        2012-03-19 14:45:29 UTC (rev 20211)
+++ trunk/wp-includes/theme.php        2012-03-19 17:12:44 UTC (rev 20212)
</span><span class="lines">@@ -901,14 +901,11 @@
</span><span class="cx">  * Retrieve text color for custom header.
</span><span class="cx">  *
</span><span class="cx">  * @since 2.1.0
</span><del>- * @uses HEADER_TEXTCOLOR
</del><span class="cx">  *
</span><span class="cx">  * @return string
</span><span class="cx">  */
</span><span class="cx"> function get_header_textcolor() {
</span><del>-        $default = defined('HEADER_TEXTCOLOR') ? HEADER_TEXTCOLOR : '';
-
-        return get_theme_mod('header_textcolor', $default);
</del><ins>+        return get_theme_mod('header_textcolor', get_theme_support( 'custom-header', 'default-text-color' ) );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -924,13 +921,11 @@
</span><span class="cx">  * Retrieve header image for custom header.
</span><span class="cx">  *
</span><span class="cx">  * @since 2.1.0
</span><del>- * @uses HEADER_IMAGE
</del><span class="cx">  *
</span><span class="cx">  * @return string
</span><span class="cx">  */
</span><span class="cx"> function get_header_image() {
</span><del>-        $default = defined( 'HEADER_IMAGE' ) ? HEADER_IMAGE : '';
-        $url = get_theme_mod( 'header_image', $default );
</del><ins>+        $url = get_theme_mod( 'header_image', get_theme_support( 'custom-header', 'default-image' ) );
</ins><span class="cx"> 
</span><span class="cx">         if ( 'remove-header' == $url )
</span><span class="cx">                 return false;
</span><span class="lines">@@ -970,8 +965,7 @@
</span><span class="cx">                         if ( 'random-default-image' == $header_image_mod ) {
</span><span class="cx">                                 $headers = $_wp_default_headers;
</span><span class="cx">                         } else {
</span><del>-                                $is_random = get_theme_support( 'custom-header' );
-                                if ( isset( $is_random[ 0 ] ) &amp;&amp; !empty( $is_random[ 0 ][ 'random-default' ] ) )
</del><ins>+                                if ( current_theme_supports( 'custom-header', 'random-default' ) )
</ins><span class="cx">                                         $headers = $_wp_default_headers;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="lines">@@ -1010,14 +1004,12 @@
</span><span class="cx">  * is chosen, and theme turns on random headers with add_theme_support().
</span><span class="cx">  *
</span><span class="cx">  * @since 3.2.0
</span><del>- * @uses HEADER_IMAGE
</del><span class="cx">  *
</span><span class="cx">  * @param string $type The random pool to use. any|default|uploaded
</span><span class="cx">  * @return boolean
</span><span class="cx">  */
</span><span class="cx"> function is_random_header_image( $type = 'any' ) {
</span><del>-        $default = defined( 'HEADER_IMAGE' ) ? HEADER_IMAGE : '';
-        $header_image_mod = get_theme_mod( 'header_image', $default );
</del><ins>+        $header_image_mod = get_theme_mod( 'header_image', get_theme_support( 'custom-header', 'default-image' ) );
</ins><span class="cx"> 
</span><span class="cx">         if ( 'any' == $type ) {
</span><span class="cx">                 if ( 'random-default-image' == $header_image_mod || 'random-uploaded-image' == $header_image_mod || ( '' != get_random_header_image() &amp;&amp; empty( $header_image_mod ) ) )
</span><span class="lines">@@ -1079,98 +1071,51 @@
</span><span class="cx">  *
</span><span class="cx">  * @return object
</span><span class="cx">  */
</span><del>-function get_current_header_data() {
</del><ins>+function get_custom_header() {
</ins><span class="cx">         $data = is_random_header_image()? _get_random_header_data() : get_theme_mod( 'header_image_data' );
</span><span class="cx">         $default = array(
</span><span class="cx">                 'url'           =&gt; '',
</span><span class="cx">                 'thumbnail_url' =&gt; '',
</span><del>-                'width'         =&gt; '',
-                'height'        =&gt; '',
</del><ins>+                'width'         =&gt; get_theme_suppport( 'custom-header', 'width' ),
+                'height'        =&gt; get_theme_suppport( 'custom-header', 'height' ),
</ins><span class="cx">         );
</span><span class="cx">         return (object) wp_parse_args( $data, $default );
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Get the header image width.
- *
- * @since 3.4.0
- *
- * @return int
- */
-function get_header_image_width() {
-        return empty( get_current_header_data()-&gt;width )? HEADER_IMAGE_WIDTH : get_current_header_data()-&gt;width;
-}
-
-/**
- * Get the header image height.
- *
- * @since 3.4.0
- *
- * @return int
- */
-function get_header_image_height() {
-        return empty( get_current_header_data()-&gt;height )? HEADER_IMAGE_HEIGHT : get_current_header_data()-&gt;height;
-}
-
-/**
</del><span class="cx">  * Add callbacks for image header display.
</span><span class="cx">  *
</span><del>- * The parameter $header_callback callback will be required to display the
- * content for the 'wp_head' action. The parameter $admin_header_callback
- * callback will be added to Custom_Image_Header class and that will be added
- * to the 'admin_menu' action.
- *
</del><span class="cx">  * @since 2.1.0
</span><del>- * @uses Custom_Image_Header Sets up for $admin_header_callback for administration panel display.
</del><ins>+ * @deprecated 3.4.0
+ * @deprecated Use add_theme_support('custom-header', $args)
+ * @see add_theme_support()
</ins><span class="cx">  *
</span><span class="cx">  * @param callback $header_callback Call on 'wp_head' action.
</span><span class="cx">  * @param callback $admin_header_callback Call on custom header administration screen.
</span><span class="cx">  * @param callback $admin_image_div_callback Output a custom header image div on the custom header administration screen. Optional.
</span><span class="cx">  */
</span><span class="cx"> function add_custom_image_header( $header_callback, $admin_header_callback, $admin_image_div_callback = '' ) {
</span><del>-        if ( ! empty( $header_callback ) )
-                add_action('wp_head', $header_callback);
-
-        $support = array( 'callback' =&gt; $header_callback );
-        $theme_support = get_theme_support( 'custom-header' );
-        if ( ! empty( $theme_support ) &amp;&amp; is_array( $theme_support[ 0 ] ) )
-                $support = array_merge( $theme_support[ 0 ], $support );
-        add_theme_support( 'custom-header',  $support );
-        add_theme_support( 'custom-header-uploads' );
-
-        if ( ! is_admin() )
-                return;
-
-        global $custom_image_header;
-
-        require_once( ABSPATH . 'wp-admin/custom-header.php' );
-        $custom_image_header = new Custom_Image_Header( $admin_header_callback, $admin_image_div_callback );
-        add_action( 'admin_menu', array( &amp;$custom_image_header, 'init' ) );
</del><ins>+        # _deprecated_function( __FUNCTION__, '3.4', 'add_theme_support(\'custom-header\', $args)' );
+        return add_theme_support( 'custom-header', array(
+                'callback' =&gt; $header_callback,
+                'admin-header-callback' =&gt; $admin_header_callback,
+                'admin-image-div-callback' =&gt; $admin_image_div_callback,
+        ) );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * Remove image header support.
</span><span class="cx">  *
</span><span class="cx">  * @since 3.1.0
</span><del>- * @see add_custom_image_header()
</del><ins>+ * @deprecated 3.4.0
+ * @deprecated Use remove_theme_support('custom-header')
+ * @see remove_theme_support()
</ins><span class="cx">  *
</span><span class="cx">  * @return bool Whether support was removed.
</span><span class="cx">  */
</span><span class="cx"> function remove_custom_image_header() {
</span><del>-        if ( ! current_theme_supports( 'custom-header' ) )
-                return false;
-
-        $callback = get_theme_support( 'custom-header' );
-        remove_action( 'wp_head', $callback[0]['callback'] );
-        _remove_theme_support( 'custom-header' );
-        remove_theme_support( 'custom-header-uploads' );
-
-        if ( is_admin() ) {
-                remove_action( 'admin_menu', array( &amp;$GLOBALS['custom_image_header'], 'init' ) );
-                unset( $GLOBALS['custom_image_header'] );
-        }
-
-        return true;
</del><ins>+        # _deprecated_function( __FUNCTION__, '3.4', 'remove_theme_support(\'custom-header\')' );
+        return remove_theme_support( 'custom-header' );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -1218,9 +1163,7 @@
</span><span class="cx">  * @return string
</span><span class="cx">  */
</span><span class="cx"> function get_background_image() {
</span><del>-        $default = defined('BACKGROUND_IMAGE') ? BACKGROUND_IMAGE : '';
-
-        return get_theme_mod('background_image', $default);
</del><ins>+        return get_theme_mod('background_image', get_theme_support( 'custom-background', 'default-image' ) );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -1236,14 +1179,11 @@
</span><span class="cx">  * Retrieve value for custom background color.
</span><span class="cx">  *
</span><span class="cx">  * @since 3.0.0
</span><del>- * @uses BACKGROUND_COLOR
</del><span class="cx">  *
</span><span class="cx">  * @return string
</span><span class="cx">  */
</span><span class="cx"> function get_background_color() {
</span><del>-        $default = defined('BACKGROUND_COLOR') ? BACKGROUND_COLOR : '';
-
-        return get_theme_mod('background_color', $default);
</del><ins>+        return get_theme_mod('background_color', get_theme_support( 'custom-background', 'default-color' ) );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -1271,21 +1211,12 @@
</span><span class="cx">  * @param callback $admin_image_div_callback Output a custom background image div on the custom background administration screen. Optional.
</span><span class="cx">  */
</span><span class="cx"> function add_custom_background( $header_callback = '', $admin_header_callback = '', $admin_image_div_callback = '' ) {
</span><del>-        if ( isset( $GLOBALS['custom_background'] ) )
-                return;
-
-        if ( empty( $header_callback ) )
-                $header_callback = '_custom_background_cb';
-
-        add_action( 'wp_head', $header_callback );
-
-        add_theme_support( 'custom-background', array( 'callback' =&gt; $header_callback ) );
-
-        if ( ! is_admin() )
-                return;
-        require_once( ABSPATH . 'wp-admin/custom-background.php' );
-        $GLOBALS['custom_background'] = new Custom_Background( $admin_header_callback, $admin_image_div_callback );
-        add_action( 'admin_menu', array( &amp;$GLOBALS['custom_background'], 'init' ) );
</del><ins>+        # _deprecated_function( __FUNCTION__, '3.4', 'add_theme_support(\'custom-background\', $args)' );
+        return add_theme_support( 'custom-background', array(
+                'callback' =&gt; $header_callback,
+                'admin-header-callback' =&gt; $admin_header_callback,
+                'admin-image-div-callback' =&gt; $admin_image_div_callback,
+        ) );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -1297,26 +1228,14 @@
</span><span class="cx">  * @return bool Whether support was removed.
</span><span class="cx">  */
</span><span class="cx"> function remove_custom_background() {
</span><del>-        if ( ! current_theme_supports( 'custom-background' ) )
-                return false;
-
-        $callback = get_theme_support( 'custom-background' );
-        remove_action( 'wp_head', $callback[0]['callback'] );
-        _remove_theme_support( 'custom-background' );
-
-        if ( is_admin() ) {
-                remove_action( 'admin_menu', array( &amp;$GLOBALS['custom_background'], 'init' ) );
-                unset( $GLOBALS['custom_background'] );
-        }
-
-        return true;
</del><ins>+        # _deprecated_function( __FUNCTION__, '3.4', 'remove_theme_support(\'custom-background\')' );
+        return remove_theme_support( 'custom-background' );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * Default custom background callback.
</span><span class="cx">  *
</span><span class="cx">  * @since 3.0.0
</span><del>- * @see add_custom_background()
</del><span class="cx">  * @access protected
</span><span class="cx">  */
</span><span class="cx"> function _custom_background_cb() {
</span><span class="lines">@@ -1422,15 +1341,172 @@
</span><span class="cx">         global $_wp_theme_features;
</span><span class="cx"> 
</span><span class="cx">         if ( func_num_args() == 1 )
</span><del>-                $_wp_theme_features[$feature] = true;
</del><ins>+                $args = true;
</ins><span class="cx">         else
</span><del>-                $_wp_theme_features[$feature] = array_slice( func_get_args(), 1 );
</del><ins>+                $args = array_slice( func_get_args(), 1 );
</ins><span class="cx"> 
</span><del>-        if ( $feature == 'post-formats' &amp;&amp; is_array( $_wp_theme_features[$feature][0] ) )
-                $_wp_theme_features[$feature][0] = array_intersect( $_wp_theme_features[$feature][0], array_keys( get_post_format_slugs() ) );
</del><ins>+        switch ( $feature ) {
+                case 'post-formats' :
+                        if ( is_array( $args[0] ) )
+                                $args[0] = array_intersect( $args[0], array_keys( get_post_format_slugs() ) );
+                        break;
+
+                case 'custom-header-uploads' :
+                        return add_theme_support( 'custom-header', array( 'uploads' =&gt; true ) );
+                        break;
+
+                case 'custom-header' :
+                        $defaults = array(
+                                'default-image' =&gt; '',
+                                'random-default' =&gt; false,
+                                'width' =&gt; 0,
+                                'height' =&gt; 0,
+                                'flex-height' =&gt; false,
+                                'flex-width' =&gt; false,
+                                'default-text-color' =&gt; '',
+                                'header-text' =&gt; true,
+                                'uploads' =&gt; true,
+                                'callback' =&gt; '',
+                                'admin-header-callback' =&gt; '',
+                                'admin-image-div-callback' =&gt; '',
+                        );
+
+                        $jit = isset( $args[0]['__jit'] );
+                        unset( $args[0]['__jit'] );
+
+                        // Merge in data from previous add_theme_support() calls.
+                        // The first value registered wins. (A child theme is set up first.)
+                        if ( isset( $_wp_theme_features['custom-header'] ) )
+                                $args[0] = wp_parse_args( $_wp_theme_features['custom-header'][0], $args[0] );
+
+                        // Load in the defaults at the end, as we need to insure first one wins.
+                        // This will cause all constants to be defined, as each arg will then be set to the default.
+                        if ( $jit )
+                                $args[0] = wp_parse_args( $args[0], $defaults );
+
+                        // If a constant was defined, use that value. Otherwise, define the constant to ensure
+                        // the constant is always accurate (and is not defined later,  overriding our value).
+                        // As stated above, the first value wins.
+                        // Once we get to wp_loaded (just-in-time), define any constants we haven't already.
+                        // Constants are lame. Don't reference them. This is just for backwards compatibility.
+
+                        if ( defined( 'NO_HEADER_TEXT' ) )
+                                $args[0]['header-text'] = ! NO_HEADER_TEXT;
+                        elseif ( isset( $args[0]['header-text'] ) )
+                                define( 'NO_HEADER_TEXT', empty( $args[0]['header-text'] ) );
+
+                        if ( defined( 'HEADER_IMAGE_WIDTH' ) )
+                                $args[0]['width'] = (int) HEADER_IMAGE_WIDTH;
+                        elseif ( isset( $args[0]['width'] ) )
+                                define( 'HEADER_IMAGE_WIDTH', (int) $args[0]['width'] );
+
+                        if ( defined( 'HEADER_IMAGE_HEIGHT' ) )
+                                $args[0]['height'] = (int) HEADER_IMAGE_HEIGHT;
+                        elseif ( ! isset( $args[0]['height'] ) )
+                                define( 'HEADER_IMAGE_HEIGHT', (int) $args[0]['height'] );
+
+                        if ( defined( 'HEADER_TEXTCOLOR' ) )
+                                $args[0]['default-text-color'] = HEADER_TEXTCOLOR;
+                        elseif ( isset( $args[0]['default-text-color'] ) )
+                                define( 'HEADER_TEXTCOLOR', $args[0]['default-text-color'] );
+
+                        if ( defined( 'HEADER_IMAGE' ) )
+                                $args[0]['default-image'] = HEADER_IMAGE;
+
+                        if ( $jit &amp;&amp; ! empty( $args[0]['default-image'] ) )
+                                $args[0]['random-default'] = false;
+
+                        if ( ! defined( 'HEADER_IMAGE' ) &amp;&amp; ( isset( $args[0]['default-image'] ) || isset( $args[0]['random-default'] ) ) )
+                                define( 'HEADER_IMAGE', $args[0]['default-image'] );
+
+                        // If headers are supported, and we still don't have a defined width or height,
+                        // we have implicit flex sizes.
+                        if ( $jit ) {
+                                if ( empty( $args[0]['width'] ) &amp;&amp; empty( $args[0]['flex-width'] ) )
+                                        $args[0]['flex-width'] = true;
+                                if ( empty( $args[0]['height'] ) &amp;&amp; empty( $args[0]['flex-height'] ) )
+                                        $args[0]['flex-height'] = true;
+                        }
+
+                        break;
+
+                case 'custom-background' :
+                        $defaults = array(
+                                'default-image' =&gt; '',
+                                'default-color' =&gt; '',
+                                'callback' =&gt; '',
+                                'admin-header-callback' =&gt; '',
+                                'admin-image-div-callback' =&gt; '',
+                        );
+
+                        $jit = isset( $args[0]['__jit'] );
+                        unset( $args[0]['__jit'] );
+
+                        // Merge in data from previous add_theme_support() calls. The first value registered wins.
+                        if ( isset( $_wp_theme_features['custom-background'] ) )
+                                $args[0] = wp_parse_args( $_wp_theme_features['custom-background'][0], $args[0] );
+
+                        if ( $jit )
+                                $args[0] = wp_parse_args( $args[0], $defaults );
+
+                        if ( defined( 'BACKGROUND_COLOR' ) )
+                                $args[0]['default-color'] = BACKGROUND_COLOR;
+                        elseif ( isset( $args[0]['default-color'] ) || $jit )
+                                define( 'BACKGROUND_COLOR', $args[0]['default-color'] );
+
+                        if ( defined( 'BACKGROUND_IMAGE' ) )
+                                $args[0]['default-image'] = BACKGROUND_IMAGE;
+                        elseif ( isset( $args[0]['default-image'] ) || $jit )
+                                define( 'BACKGROUND_IMAGE', $args[0]['default-image'] );
+
+                        if ( empty( $args[0]['callback'] ) )
+                                $args[0]['callback'] = '_custom_background_cb';
+
+                        break;
+        }
+
+        $_wp_theme_features[ $feature ] = $args;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><ins>+ * Registers the internal custom header and background routines.
+ *
+ * @since 3.4.0
+ * @access private
+ */
+function _custom_header_background_just_in_time() {
+        global $custom_image_header, $custom_background;
+
+        if ( current_theme_supports( 'custom-header' ) ) {
+                // In case any constants were defined after an add_custom_image_header() call, re-run.
+                add_theme_support( 'custom-header', array( '__jit' =&gt; true ) );
+
+                $args = get_theme_support( 'custom-header' );
+                if ( $args[0]['callback'] )
+                        add_action( 'wp_head', $args[0]['callback'] );
+
+                if ( is_admin() ) {
+                        require_once( ABSPATH . 'wp-admin/custom-header.php' );
+                        $custom_image_header = new Custom_Image_Header( $args[0]['admin-header-callback'], $args[0]['admin-image-div-callback'] );
+                }
+        }
+
+        if ( current_theme_supports( 'custom-background' ) ) {
+                // In case any constants were defined after an add_custom_background() call, re-run.
+                add_theme_support( 'custom-background', array( '__jit' =&gt; true ) );
+
+                $args = get_theme_support( 'custom-background' );
+                add_action( 'wp_head', $args[0]['callback'] );
+
+                if ( is_admin() ) {
+                        require_once( ABSPATH . 'wp-admin/custom-background.php' );
+                        $custom_background = new Custom_Background( $args[0]['admin-header-callback'], $args[0]['admin-image-div-callback'] );
+                }
+        }                
+}
+add_action( 'wp_loaded', '_custom_header_background_just_in_time' );
+
+/**
</ins><span class="cx">  * Gets the theme support arguments passed when registering that support
</span><span class="cx">  *
</span><span class="cx">  * @since 3.1
</span><span class="lines">@@ -1439,10 +1515,24 @@
</span><span class="cx">  */
</span><span class="cx"> function get_theme_support( $feature ) {
</span><span class="cx">         global $_wp_theme_features;
</span><del>-        if ( !isset( $_wp_theme_features[$feature] ) )
</del><ins>+        if ( ! isset( $_wp_theme_features[ $feature ] ) )
</ins><span class="cx">                 return false;
</span><del>-        else
-                return $_wp_theme_features[$feature];
</del><ins>+
+        if ( func_num_args() &lt;= 1 )
+                return $_wp_theme_features[ $feature ];
+
+        $args = array_slice( func_get_args(), 1 );
+        switch ( $feature ) {
+                case 'custom-header' :
+                case 'custom-background' :
+                        if ( isset( $_wp_theme_features[ $feature ][0][ $args[0] ] ) )
+                                return $_wp_theme_features[ $feature ][0][ $args[0] ];
+                        return false;
+                        break;
+                default :
+                        return $_wp_theme_features[ $feature ];
+                        break;
+        }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -1458,8 +1548,9 @@
</span><span class="cx">  */
</span><span class="cx"> function remove_theme_support( $feature ) {
</span><span class="cx">         // Blacklist: for internal registrations not used directly by themes.
</span><del>-        if ( in_array( $feature, array( 'custom-background', 'custom-header', 'editor-style', 'widgets', 'menus' ) ) )
</del><ins>+        if ( in_array( $feature, array( 'editor-style', 'widgets', 'menus' ) ) )
</ins><span class="cx">                 return false;
</span><ins>+
</ins><span class="cx">         return _remove_theme_support( $feature );
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1472,9 +1563,35 @@
</span><span class="cx"> function _remove_theme_support( $feature ) {
</span><span class="cx">         global $_wp_theme_features;
</span><span class="cx"> 
</span><del>-        if ( ! isset( $_wp_theme_features[$feature] ) )
</del><ins>+        switch ( $feature ) {
+                case 'custom-header-uploads' :
+                        if ( ! isset( $_wp_theme_features['custom-header'] ) )
+                                return false;
+                        add_theme_support( 'custom-header', array( 'uploads' =&gt; false ) );
+                        return; // Do not continue - custom-header-uploads no longer exists.
+        }
+
+        if ( ! isset( $_wp_theme_features[ $feature ] ) )
</ins><span class="cx">                 return false;
</span><del>-        unset( $_wp_theme_features[$feature] );
</del><ins>+
+        switch ( $feature ) {
+                case 'custom-header' :
+                        $support = get_theme_support( 'custom-header' );
+                        if ( $support[0]['callback'] )
+                                remove_action( 'wp_head', $support[0]['callback'] );
+                        remove_action( 'admin_menu', array( $GLOBALS['custom_image_header'], 'init' ) );
+                        unset( $GLOBALS['custom_image_header'] );
+                        break;
+
+                case 'custom-header' :
+                        $support = get_theme_support( 'custom-background' );
+                        remove_action( 'wp_head', $support[0]['callback'] );
+                        remove_action( 'admin_menu', array( $GLOBALS['custom_background'], 'init' ) );
+                        unset( $GLOBALS['custom_background'] );
+                        break;
+        }
+
+        unset( $_wp_theme_features[ $feature ] );
</ins><span class="cx">         return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1488,6 +1605,9 @@
</span><span class="cx"> function current_theme_supports( $feature ) {
</span><span class="cx">         global $_wp_theme_features;
</span><span class="cx"> 
</span><ins>+        if ( 'custom-header-uploads' == $feature )
+                return current_theme_supports( 'custom-header', 'uploads' );
+
</ins><span class="cx">         if ( !isset( $_wp_theme_features[$feature] ) )
</span><span class="cx">                 return false;
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>