<!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>[20225] trunk/wp-content/themes: Move Twenty Ten and the rest of Twenty Eleven to add_theme_support() for headers and 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/20225">20225</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2012-03-20 21:32:42 +0000 (Tue, 20 Mar 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Move Twenty Ten and the rest of Twenty Eleven to add_theme_support() for headers and backgrounds. props sabreuse for initial patch. fixes <a href="http://core.trac.wordpress.org/ticket/20265">#20265</a>. see <a href="http://core.trac.wordpress.org/ticket/20249">#20249</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpcontentthemestwentyelevenfunctionsphp">trunk/wp-content/themes/twentyeleven/functions.php</a></li>
<li><a href="#trunkwpcontentthemestwentyelevenshowcasephp">trunk/wp-content/themes/twentyeleven/showcase.php</a></li>
<li><a href="#trunkwpcontentthemestwentytenfunctionsphp">trunk/wp-content/themes/twentyten/functions.php</a></li>
<li><a href="#trunkwpcontentthemestwentytenheaderphp">trunk/wp-content/themes/twentyten/header.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpcontentthemestwentyelevenfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/themes/twentyeleven/functions.php (20224 => 20225)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyeleven/functions.php        2012-03-20 21:17:55 UTC (rev 20224)
+++ trunk/wp-content/themes/twentyeleven/functions.php        2012-03-20 21:32:42 UTC (rev 20225)
</span><span class="lines">@@ -62,10 +62,9 @@
</span><span class="cx">  *
</span><span class="cx">  * @uses load_theme_textdomain() For translation/localization support.
</span><span class="cx">  * @uses add_editor_style() To style the visual editor.
</span><del>- * @uses add_theme_support() To add support for post thumbnails, automatic feed links, and Post Formats.
</del><ins>+ * @uses add_theme_support() To add support for post thumbnails, automatic feed links, custom headers
+ *         and backgrounds, and post formats.
</ins><span class="cx">  * @uses register_nav_menus() To add support for navigation menus.
</span><del>- * @uses add_custom_background() To add support for a custom background.
- * @uses add_custom_image_header() To add support for a custom header.
</del><span class="cx">  * @uses register_default_headers() To register the default custom header images provided with the theme.
</span><span class="cx">  * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
</span><span class="cx">  *
</span><span class="lines">@@ -234,7 +233,7 @@
</span><span class="cx"> /**
</span><span class="cx">  * Styles the header image displayed on the Appearance &gt; Header admin panel.
</span><span class="cx">  *
</span><del>- * Referenced via add_custom_image_header() in twentyeleven_setup().
</del><ins>+ * Referenced via add_theme_support('custom-header') in twentyeleven_setup().
</ins><span class="cx">  *
</span><span class="cx">  * @since Twenty Eleven 1.0
</span><span class="cx">  */
</span><span class="lines">@@ -284,7 +283,7 @@
</span><span class="cx"> /**
</span><span class="cx">  * Custom header image markup displayed on the Appearance &gt; Header admin panel.
</span><span class="cx">  *
</span><del>- * Referenced via add_custom_image_header() in twentyeleven_setup().
</del><ins>+ * Referenced via add_theme_support('custom-header') in twentyeleven_setup().
</ins><span class="cx">  *
</span><span class="cx">  * @since Twenty Eleven 1.0
</span><span class="cx">  */
</span></span></pre></div>
<a id="trunkwpcontentthemestwentyelevenshowcasephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/themes/twentyeleven/showcase.php (20224 => 20225)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyeleven/showcase.php        2012-03-20 21:17:55 UTC (rev 20224)
+++ trunk/wp-content/themes/twentyeleven/showcase.php        2012-03-20 21:32:42 UTC (rev 20225)
</span><span class="lines">@@ -66,6 +66,8 @@
</span><span class="cx">                                          */
</span><span class="cx">                                         $counter_slider = 0;
</span><span class="cx"> 
</span><ins>+                                        $header_image_width  = get_theme_support( 'custom-header', 'width' );
+                                        $header_image_height = get_theme_support( 'custom-header', 'height' );
</ins><span class="cx">                                         ?&gt;
</span><span class="cx"> 
</span><span class="cx">                                 &lt;div class=&quot;featured-posts&quot;&gt;
</span><span class="lines">@@ -89,10 +91,10 @@
</span><span class="cx">                                                 $feature_class = 'feature-image small';
</span><span class="cx"> 
</span><span class="cx">                                                 // Hang on. Let's check this here image out.
</span><del>-                                                $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post-&gt;ID ), array( HEADER_IMAGE_WIDTH, HEADER_IMAGE_WIDTH ) );
</del><ins>+                                                $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post-&gt;ID ), array( $header_image_width, $header_image_width ) );
</ins><span class="cx"> 
</span><span class="cx">                                                 // Is it bigger than or equal to our header?
</span><del>-                                                if ( $image[1] &gt;= HEADER_IMAGE_WIDTH ) {
</del><ins>+                                                if ( $image[1] &gt;= $header_image_width ) {
</ins><span class="cx">                                                         // If bigger, let's add a BIGGER class. It's EXTRA classy now.
</span><span class="cx">                                                         $feature_class = 'feature-image large';
</span><span class="cx">                                                 }
</span><span class="lines">@@ -107,7 +109,7 @@
</span><span class="cx">                                                          * make it a large featured post, otherwise render it small
</span><span class="cx">                                                          */
</span><span class="cx">                                                         if ( has_post_thumbnail() ) {
</span><del>-                                                                if ( $image[1] &gt;= HEADER_IMAGE_WIDTH )
</del><ins>+                                                                if ( $image[1] &gt;= $header_image_width )
</ins><span class="cx">                                                                         $thumbnail_size = 'large-feature';
</span><span class="cx">                                                                 else
</span><span class="cx">                                                                         $thumbnail_size = 'small-feature';
</span></span></pre></div>
<a id="trunkwpcontentthemestwentytenfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/themes/twentyten/functions.php (20224 => 20225)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyten/functions.php        2012-03-20 21:17:55 UTC (rev 20224)
+++ trunk/wp-content/themes/twentyten/functions.php        2012-03-20 21:32:42 UTC (rev 20225)
</span><span class="lines">@@ -61,12 +61,10 @@
</span><span class="cx">  * To override twentyten_setup() in a child theme, add your own twentyten_setup to your child theme's
</span><span class="cx">  * functions.php file.
</span><span class="cx">  *
</span><del>- * @uses add_theme_support() To add support for post thumbnails and automatic feed links.
</del><ins>+ * @uses add_theme_support() To add support for post thumbnails, custom headers and backgrounds, and automatic feed links.
</ins><span class="cx">  * @uses register_nav_menus() To add support for navigation menus.
</span><del>- * @uses add_custom_background() To add support for a custom background.
</del><span class="cx">  * @uses add_editor_style() To style the visual editor.
</span><span class="cx">  * @uses load_theme_textdomain() For translation/localization support.
</span><del>- * @uses add_custom_image_header() To add support for a custom header.
</del><span class="cx">  * @uses register_default_headers() To register the default custom header images provided with the theme.
</span><span class="cx">  * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
</span><span class="cx">  *
</span><span class="lines">@@ -100,37 +98,31 @@
</span><span class="cx">                 'primary' =&gt; __( 'Primary Navigation', 'twentyten' ),
</span><span class="cx">         ) );
</span><span class="cx"> 
</span><del>-        // This theme allows users to set a custom background
-        add_custom_background();
</del><ins>+        // This theme allows users to set a custom background.
+        add_theme_support( 'custom-background' );
</ins><span class="cx"> 
</span><del>-        // Your changeable header business starts here
-        if ( ! defined( 'HEADER_TEXTCOLOR' ) )
-                define( 'HEADER_TEXTCOLOR', '' );
</del><ins>+        // The custom header business starts here.
</ins><span class="cx"> 
</span><del>-        // No CSS, just IMG call. The %s is a placeholder for the theme template directory URI.
-        if ( ! defined( 'HEADER_IMAGE' ) )
-                define( 'HEADER_IMAGE', '%s/images/headers/path.jpg' );
</del><ins>+        add_theme_support( 'custom-header', array(
+                // The default image to use.
+                // The %s is a placeholder for the theme template directory URI.
+                'default-image' =&gt; '%s/images/headers/path.jpg',
+                // The height and width of our custom header.
+                'width' =&gt; apply_filters( 'twentyten_header_image_width', 940 ),
+                'height' =&gt; apply_filters( 'twentyten_header_image_height', 198 ),
+                // Don't support text inside the header image.
+                'header-text' =&gt; false,
+                // Callback for styling the header preview in the admin.
+                'admin-header-callback' =&gt; 'twentyten_admin_header_style',
+        ) );
</ins><span class="cx"> 
</span><del>-        // The height and width of your custom header. You can hook into the theme's own filters to change these values.
-        // Add a filter to twentyten_header_image_width and twentyten_header_image_height to change these values.
-        define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 940 ) );
-        define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 198 ) );
-
</del><span class="cx">         // We'll be using post thumbnails for custom header images on posts and pages.
</span><span class="cx">         // We want them to be 940 pixels wide by 198 pixels tall.
</span><span class="cx">         // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
</span><del>-        set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
</del><ins>+        set_post_thumbnail_size( get_theme_support( 'custom-header', 'width' ), get_theme_support( 'custom-header', 'height' ), true );
</ins><span class="cx"> 
</span><del>-        // Don't support text inside the header image.
-        if ( ! defined( 'NO_HEADER_TEXT' ) )
-                define( 'NO_HEADER_TEXT', true );
</del><ins>+        // ... and thus ends the custom header business.
</ins><span class="cx"> 
</span><del>-        // Add a way for the custom header to be styled in the admin panel that controls
-        // custom headers. See twentyten_admin_header_style(), below.
-        add_custom_image_header( '', 'twentyten_admin_header_style' );
-
-        // ... and thus ends the changeable header business.
-
</del><span class="cx">         // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
</span><span class="cx">         register_default_headers( array(
</span><span class="cx">                 'berries' =&gt; array(
</span><span class="lines">@@ -201,7 +193,7 @@
</span><span class="cx">         border-bottom: 1px solid #000;
</span><span class="cx">         border-top: 4px solid #000;
</span><span class="cx"> }
</span><del>-/* If NO_HEADER_TEXT is false, you would style the text with these selectors:
</del><ins>+/* If header-text was supported, you would style the text with these selectors:
</ins><span class="cx">         #headimg #name { }
</span><span class="cx">         #headimg #desc { }
</span><span class="cx"> */
</span></span></pre></div>
<a id="trunkwpcontentthemestwentytenheaderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/themes/twentyten/header.php (20224 => 20225)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyten/header.php        2012-03-20 21:17:55 UTC (rev 20224)
+++ trunk/wp-content/themes/twentyten/header.php        2012-03-20 21:32:42 UTC (rev 20225)
</span><span class="lines">@@ -70,11 +70,11 @@
</span><span class="cx">                                         if ( is_singular() &amp;&amp; current_theme_supports( 'post-thumbnails' ) &amp;&amp;
</span><span class="cx">                                                         has_post_thumbnail( $post-&gt;ID ) &amp;&amp;
</span><span class="cx">                                                         ( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post-&gt;ID ), 'post-thumbnail' ) ) &amp;&amp;
</span><del>-                                                        $image[1] &gt;= HEADER_IMAGE_WIDTH ) :
</del><ins>+                                                        $image[1] &gt;= get_theme_support( 'custom-header', 'width' ) ) :
</ins><span class="cx">                                                 // Houston, we have a new header image!
</span><span class="cx">                                                 echo get_the_post_thumbnail( $post-&gt;ID );
</span><span class="cx">                                         elseif ( get_header_image() ) : ?&gt;
</span><del>-                                                &lt;img src=&quot;&lt;?php header_image(); ?&gt;&quot; width=&quot;&lt;?php echo HEADER_IMAGE_WIDTH; ?&gt;&quot; height=&quot;&lt;?php echo HEADER_IMAGE_HEIGHT; ?&gt;&quot; alt=&quot;&quot; /&gt;
</del><ins>+                                                &lt;img src=&quot;&lt;?php header_image(); ?&gt;&quot; width=&quot;&lt;?php echo get_theme_support( 'custom-header', 'width' ); ?&gt;&quot; height=&quot;&lt;?php echo get_theme_support( 'custom-header', 'height' ); ?&gt;&quot; alt=&quot;&quot; /&gt;
</ins><span class="cx">                                         &lt;?php endif; ?&gt;
</span><span class="cx">                         &lt;/div&gt;&lt;!-- #branding --&gt;
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>