<!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>[20983] trunk/wp-content/themes: Back compat for bundled themes.</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/20983">20983</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2012-06-04 14:43:19 +0000 (Mon, 04 Jun 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Back compat for bundled themes. Props nacin, SergeyBiryukov, kobenland. fixes <a href="http://core.trac.wordpress.org/ticket/20768">#20768</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpcontentthemestwentyelevenfunctionsphp">trunk/wp-content/themes/twentyeleven/functions.php</a></li>
<li><a href="#trunkwpcontentthemestwentyelevenheaderphp">trunk/wp-content/themes/twentyeleven/header.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 (20982 => 20983)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyeleven/functions.php        2012-06-04 14:37:57 UTC (rev 20982)
+++ trunk/wp-content/themes/twentyeleven/functions.php        2012-06-04 14:43:19 UTC (rev 20983)
</span><span class="lines">@@ -114,7 +114,7 @@
</span><span class="cx">         add_theme_support( 'post-thumbnails' );
</span><span class="cx"> 
</span><span class="cx">         // Add support for custom headers.
</span><del>-        add_theme_support( 'custom-header', array(
</del><ins>+        $custom_header_support = array(
</ins><span class="cx">                 // The default header text color.
</span><span class="cx">                 'default-text-color' =&gt; '000',
</span><span class="cx">                 // The height and width of our custom header.
</span><span class="lines">@@ -130,16 +130,28 @@
</span><span class="cx">                 'admin-head-callback' =&gt; 'twentyeleven_admin_header_style',
</span><span class="cx">                 // Callback used to display the header preview in the admin.
</span><span class="cx">                 'admin-preview-callback' =&gt; 'twentyeleven_admin_header_image',
</span><del>-        ) );
</del><ins>+        );
+        
+        add_theme_support( 'custom-header', $custom_header_support );
</ins><span class="cx"> 
</span><ins>+        if ( ! function_exists( 'get_custom_header' ) ) {
+                // This is all for compatibility with versions of WordPress prior to 3.4.
+                define( 'HEADER_TEXTCOLOR', $custom_header_support['default-text-color'] );
+                define( 'HEADER_IMAGE', '' );
+                define( 'HEADER_IMAGE_WIDTH', $custom_header_support['width'] );
+                define( 'HEADER_IMAGE_HEIGHT', $custom_header_support['height'] );
+                add_custom_image_header( $custom_header_support['wp-head-callback'], $custom_header_support['admin-head-callback'], $custom_header_support['admin-preview-callback'] );
+                add_custom_background();
+        }
+
</ins><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 the size of the header image that we just defined
</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( get_theme_support( 'custom-header', 'width' ), get_theme_support( 'custom-header', 'height' ), true );
</del><ins>+        set_post_thumbnail_size( $custom_header_support['width'], $custom_header_support['height'], true );
</ins><span class="cx"> 
</span><span class="cx">         // Add Twenty Eleven's custom image sizes.
</span><span class="cx">         // Used for large feature (header) images.
</span><del>-        add_image_size( 'large-feature', get_theme_support( 'custom-header', 'width' ), get_theme_support( 'custom-header', 'height' ), true );
</del><ins>+        add_image_size( 'large-feature', $custom_header_support['width'], $custom_header_support['height'], true );
</ins><span class="cx">         // Used for featured posts if a large-feature doesn't exist.
</span><span class="cx">         add_image_size( 'small-feature', 500, 300 );
</span><span class="cx"> 
</span><span class="lines">@@ -207,8 +219,9 @@
</span><span class="cx">         $text_color = get_header_textcolor();
</span><span class="cx"> 
</span><span class="cx">         // If no custom options for text are set, let's bail.
</span><del>-        if ( $text_color == get_theme_support( 'custom-header', 'default-text-color' ) )
</del><ins>+        if ( $text_color == HEADER_TEXTCOLOR )
</ins><span class="cx">                 return;
</span><ins>+                
</ins><span class="cx">         // If we get this far, we have custom styles. Let's do this.
</span><span class="cx">         ?&gt;
</span><span class="cx">         &lt;style type=&quot;text/css&quot;&gt;
</span><span class="lines">@@ -269,7 +282,7 @@
</span><span class="cx">         }
</span><span class="cx">         &lt;?php
</span><span class="cx">                 // If the user has set a custom color for the text use that
</span><del>-                if ( get_header_textcolor() != get_theme_support( 'custom-header', 'default-text-color' ) ) :
</del><ins>+                if ( get_header_textcolor() != HEADER_TEXTCOLOR ) :
</ins><span class="cx">         ?&gt;
</span><span class="cx">                 #site-title a,
</span><span class="cx">                 #site-description {
</span></span></pre></div>
<a id="trunkwpcontentthemestwentyelevenheaderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/themes/twentyeleven/header.php (20982 => 20983)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyeleven/header.php        2012-06-04 14:37:57 UTC (rev 20982)
+++ trunk/wp-content/themes/twentyeleven/header.php        2012-06-04 14:43:19 UTC (rev 20983)
</span><span class="lines">@@ -79,8 +79,15 @@
</span><span class="cx">                                 // Check to see if the header image has been removed
</span><span class="cx">                                 $header_image = get_header_image();
</span><span class="cx">                                 if ( $header_image ) :
</span><del>-                                        $header_image_width  = get_custom_header()-&gt;width;
-                        ?&gt;
</del><ins>+                                        // Compatibility with versions of WordPress prior to 3.4.
+                                        if ( function_exists( 'get_custom_header' ) ) {
+                                                // We need to figure out what the minimum width should be for our featured image.
+                                                // This result would be the suggested width if the theme were to implement flexible widths.
+                                                $header_image_width = get_theme_support( 'custom-header', 'width' );
+                                        } else {
+                                                $header_image_width = HEADER_IMAGE_WIDTH;
+                                        }
+                                        ?&gt;
</ins><span class="cx">                         &lt;a href=&quot;&lt;?php echo esc_url( home_url( '/' ) ); ?&gt;&quot;&gt;
</span><span class="cx">                                 &lt;?php
</span><span class="cx">                                         // The header image
</span><span class="lines">@@ -90,8 +97,17 @@
</span><span class="cx">                                                         $image[1] &gt;= $header_image_width ) :
</span><span class="cx">                                                 // Houston, we have a new header image!
</span><span class="cx">                                                 echo get_the_post_thumbnail( $post-&gt;ID, 'post-thumbnail' );
</span><del>-                                        else : ?&gt;
-                                        &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 get_custom_header()-&gt;height; ?&gt;&quot; alt=&quot;&quot; /&gt;
</del><ins>+                                        else :
+                                                // Compatibility with versions of WordPress prior to 3.4.
+                                                if ( function_exists( 'get_custom_header' ) ) {
+                                                        $header_image_width  = get_custom_header()-&gt;width;
+                                                        $header_image_height = get_custom_header()-&gt;height;
+                                                } else {
+                                                        $header_image_width  = HEADER_IMAGE_WIDTH;
+                                                        $header_image_height = HEADER_IMAGE_HEIGHT;
+                                                }
+                                                ?&gt;
+                                        &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;
</ins><span class="cx">                                 &lt;?php endif; // end check for featured image or standard header ?&gt;
</span><span class="cx">                         &lt;/a&gt;
</span><span class="cx">                         &lt;?php endif; // end check for removed header image ?&gt;
</span></span></pre></div>
<a id="trunkwpcontentthemestwentyelevenshowcasephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/themes/twentyeleven/showcase.php (20982 => 20983)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyeleven/showcase.php        2012-06-04 14:37:57 UTC (rev 20982)
+++ trunk/wp-content/themes/twentyeleven/showcase.php        2012-06-04 14:43:19 UTC (rev 20983)
</span><span class="lines">@@ -66,8 +66,12 @@
</span><span class="cx">                                          */
</span><span class="cx">                                         $counter_slider = 0;
</span><span class="cx"> 
</span><del>-                                        $header_image_width  = get_theme_support( 'custom-header', 'width' );
-                                        ?&gt;
</del><ins>+                                        // Compatibility with versions of WordPress prior to 3.4.
+                                        if ( function_exists( 'get_custom_header' ) )
+                                                $header_image_width = get_theme_support( 'custom-header', 'width' );
+                                        else
+                                                $header_image_width = HEADER_IMAGE_WIDTH;
+                                ?&gt;
</ins><span class="cx"> 
</span><span class="cx">                                 &lt;div class=&quot;featured-posts&quot;&gt;
</span><span class="cx">                                         &lt;h1 class=&quot;showcase-heading&quot;&gt;&lt;?php _e( 'Featured Post', 'twentyeleven' ); ?&gt;&lt;/h1&gt;
</span></span></pre></div>
<a id="trunkwpcontentthemestwentytenfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/themes/twentyten/functions.php (20982 => 20983)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyten/functions.php        2012-06-04 14:37:57 UTC (rev 20982)
+++ trunk/wp-content/themes/twentyten/functions.php        2012-06-04 14:43:19 UTC (rev 20983)
</span><span class="lines">@@ -101,7 +101,7 @@
</span><span class="cx"> 
</span><span class="cx">         // The custom header business starts here.
</span><span class="cx"> 
</span><del>-        add_theme_support( 'custom-header', array(
</del><ins>+        $custom_header_support = array(
</ins><span class="cx">                 // The default image to use.
</span><span class="cx">                 // The %s is a placeholder for the theme template directory URI.
</span><span class="cx">                 'default-image' =&gt; '%s/images/headers/path.jpg',
</span><span class="lines">@@ -114,12 +114,25 @@
</span><span class="cx">                 'header-text' =&gt; false,
</span><span class="cx">                 // Callback for styling the header preview in the admin.
</span><span class="cx">                 'admin-head-callback' =&gt; 'twentyten_admin_header_style',
</span><del>-        ) );
</del><ins>+        );
+        
+        add_theme_support( 'custom-header', $custom_header_support );
+        
+        if ( ! function_exists( 'get_custom_header' ) ) {
+                // This is all for compatibility with versions of WordPress prior to 3.4.
+                define( 'HEADER_TEXTCOLOR', '' );
+                define( 'NO_HEADER_TEXT', true );
+                define( 'HEADER_IMAGE', $custom_header_support['default-image'] );
+                define( 'HEADER_IMAGE_WIDTH', $custom_header_support['width'] );
+                define( 'HEADER_IMAGE_HEIGHT', $custom_header_support['height'] );
+                add_custom_image_header( '', $custom_header_support['admin-head-callback'] );
+                add_custom_background();
+        }
</ins><span class="cx"> 
</span><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( get_theme_support( 'custom-header', 'width' ), get_theme_support( 'custom-header', 'height' ), true );
</del><ins>+        set_post_thumbnail_size( $custom_header_support['width'], $custom_header_support['height'], true );
</ins><span class="cx"> 
</span><span class="cx">         // ... and thus ends the custom header business.
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpcontentthemestwentytenheaderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/themes/twentyten/header.php (20982 => 20983)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyten/header.php        2012-06-04 14:37:57 UTC (rev 20982)
+++ trunk/wp-content/themes/twentyten/header.php        2012-06-04 14:43:19 UTC (rev 20983)
</span><span class="lines">@@ -66,22 +66,33 @@
</span><span class="cx">                                 &lt;div id=&quot;site-description&quot;&gt;&lt;?php bloginfo( 'description' ); ?&gt;&lt;/div&gt;
</span><span class="cx"> 
</span><span class="cx">                                 &lt;?php
</span><ins>+                                        // Compatibility with versions of WordPress prior to 3.4.
+                                        if ( function_exists( 'get_custom_header' ) ) {
+                                                // We need to figure out what the minimum width should be for our featured image.
+                                                // This result would be the suggested width if the theme were to implement flexible widths.
+                                                $header_image_width = get_theme_support( 'custom-header', 'width' );
+                                        } else {
+                                                $header_image_width = HEADER_IMAGE_WIDTH;
+                                        }
+
</ins><span class="cx">                                         // Check if this is a post or page, if it has a thumbnail, and if it's a big one
</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;= get_theme_support( 'custom-header', 'width' ) ) :
</del><ins>+                                                        $image[1] &gt;= $header_image_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><del>-                                        elseif ( get_header_image() ) :        
</del><ins>+                                        elseif ( get_header_image() ) :
+                                                // Compatibility with versions of WordPress prior to 3.4.
</ins><span class="cx">                                                 if ( function_exists( 'get_custom_header' ) ) {
</span><del>-                                                        $header_width  = get_custom_header()-&gt;width;
-                                                        $header_height = get_custom_header()-&gt;height;
</del><ins>+                                                        $header_image_width  = get_custom_header()-&gt;width;
+                                                        $header_image_height = get_custom_header()-&gt;height;
</ins><span class="cx">                                                 } else {
</span><del>-                                                        $header_height = $header_width = '';
</del><ins>+                                                        $header_image_width  = HEADER_IMAGE_WIDTH;
+                                                        $header_image_height = HEADER_IMAGE_HEIGHT;
</ins><span class="cx">                                                 }
</span><del>-                                                ?&gt;
-                                                &lt;img src=&quot;&lt;?php header_image(); ?&gt;&quot; width=&quot;&lt;?php echo $header_width; ?&gt;&quot; height=&quot;&lt;?php echo $header_height; ?&gt;&quot; alt=&quot;&quot; /&gt;
</del><ins>+                                        ?&gt;
+                                                &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;
</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>