<!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" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { 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 #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#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>
<title>[12134] trunk: Introduce require_if_theme_supports(),
  move post thumbnails functions to there own include and only included them if the theme supports them
 .</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/12134">12134</a></dd>
<dt>Author</dt> <dd>westi</dd>
<dt>Date</dt> <dd>2009-11-01 10:10:06 +0000 (Sun, 01 Nov 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>Introduce require_if_theme_supports(), move post thumbnails functions to there own include and only included them if the theme supports them. See <a href="http://trac.wordpress.org/ticket/10928">#10928</a> and <a href="http://trac.wordpress.org/changeset/12132">[12132]</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludesposttemplatephp">trunk/wp-includes/post-template.php</a></li>
<li><a href="#trunkwpincludesthemephp">trunk/wp-includes/theme.php</a></li>
<li><a href="#trunkwpsettingsphp">trunk/wp-settings.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkwpincludespostimagetemplatephp">trunk/wp-includes/post-image-template.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludespostimagetemplatephp"></a>
<div class="addfile"><h4>Added: trunk/wp-includes/post-image-template.php (0 => 12134)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/post-image-template.php                                (rev 0)
+++ trunk/wp-includes/post-image-template.php        2009-11-01 10:10:06 UTC (rev 12134)
</span><span class="lines">@@ -0,0 +1,43 @@
</span><ins>+&lt;?php
+/**
+ * WordPress Post Image Template Functions.
+ *
+ * Support for post thumbnails
+ * Themes function.php must call add_theme_support( 'post-thumbnails' ) to use these.
+ *
+ * @package WordPress
+ * @subpackage Template
+ */
+
+function has_post_image( $post_id = NULL ) {
+        global $id;
+        $post_id = ( NULL === $post_id ) ? $id : $post_id;
+        return !! get_post_image_id( $post_id );
+}
+
+function get_post_image_id( $post_id = NULL ) {
+        global $id;
+        $post_id = ( NULL === $post_id ) ? $id : $post_id;
+        return get_post_meta( $post_id, '_thumbnail_id', true );
+}
+
+function the_post_image( $size = 'thumbnail', $attr = '' ) {
+        echo get_the_post_image( NULL, $size, $attr );
+}
+
+function get_the_post_image( $post_id = NULL, $size = 'thumbnail', $attr = '' ) {
+        global $id;
+        $post_id = ( NULL === $post_id ) ? $id : $post_id;
+        $post_image_id = get_post_image_id( $post_id );
+        $size = apply_filters( 'post_image_size', $size );
+        if ( $post_image_id ) {
+                do_action( 'begin_fetch_post_image_html', $post_id, $post_image_id, $size ); // for &quot;Just In Time&quot; filtering of all of wp_get_attachment_image()'s filters
+                $html = wp_get_attachment_image( $post_image_id, $size, false, $attr );
+                do_action( 'end_fetch_post_image_html', $post_id, $post_image_id, $size );
+        } else {
+                $html = '';
+        }
+        return apply_filters( 'post_image_html', $html, $post_id, $post_image_id );
+}
+
+?&gt;
</ins><span class="cx">\ No newline at end of file
</span><span class="cx">Property changes on: trunk/wp-includes/post-image-template.php
</span><span class="cx">___________________________________________________________________
</span><span class="cx">Name: svn:eol-style
</span><span class="cx">   + native
</span></span></pre></div>
<a id="trunkwpincludesposttemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/post-template.php (12133 => 12134)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/post-template.php        2009-11-01 08:12:21 UTC (rev 12133)
+++ trunk/wp-includes/post-template.php        2009-11-01 10:10:06 UTC (rev 12134)
</span><span class="lines">@@ -881,41 +881,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> //
</span><del>-// Post images
-//
-
-function has_post_image( $post_id = NULL ) {
-        global $id;
-        $post_id = ( NULL === $post_id ) ? $id : $post_id;
-        return !! get_post_image_id( $post_id );
-}
-
-function get_post_image_id( $post_id = NULL ) {
-        global $id;
-        $post_id = ( NULL === $post_id ) ? $id : $post_id;
-        return get_post_meta( $post_id, '_thumbnail_id', true );
-}
-
-function the_post_image( $size = 'thumbnail', $attr = '' ) {
-        echo get_the_post_image( NULL, $size, $attr );
-}
-
-function get_the_post_image( $post_id = NULL, $size = 'thumbnail', $attr = '' ) {
-        global $id;
-        $post_id = ( NULL === $post_id ) ? $id : $post_id;
-        $post_image_id = get_post_image_id( $post_id );
-        $size = apply_filters( 'post_image_size', $size );
-        if ( $post_image_id ) {
-                do_action( 'begin_fetch_post_image_html', $post_id, $post_image_id, $size ); // for &quot;Just In Time&quot; filtering of all of wp_get_attachment_image()'s filters
-                $html = wp_get_attachment_image( $post_image_id, $size, false, $attr );
-                do_action( 'end_fetch_post_image_html', $post_id, $post_image_id, $size );
-        } else {
-                $html = '';
-        }
-        return apply_filters( 'post_image_html', $html, $post_id, $post_image_id );
-}
-
-//
</del><span class="cx"> // Attachments
</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 (12133 => 12134)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/theme.php        2009-11-01 08:12:21 UTC (rev 12133)
+++ trunk/wp-includes/theme.php        2009-11-01 10:10:06 UTC (rev 12134)
</span><span class="lines">@@ -1305,6 +1305,8 @@
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * Allows a theme to register its support of a certain feature
</span><ins>+ * 
+ * Must be called in the themes functions.php file to work.
</ins><span class="cx">  *
</span><span class="cx">  * @author Mark Jaquith
</span><span class="cx">  * @since 2.9
</span><span class="lines">@@ -1329,4 +1331,17 @@
</span><span class="cx">         return ( isset( $_wp_theme_features[$feature] ) &amp;&amp; $_wp_theme_features[$feature] );
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/**
+ * Checks a theme's support for a given feature before loading the functions which implement it.
+ *
+ * @author Peter Westwood
+ * @since 2.9
+ * @param string $feature the feature being checked
+ * @param string $include the file containing the functions that implement the feature
+ */
+function require_if_theme_supports( $feature, $include) {
+        if ( current_theme_supports( $feature ) )
+                require ( $include );
+}
+
</ins><span class="cx"> ?&gt;
</span></span></pre></div>
<a id="trunkwpsettingsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-settings.php (12133 => 12134)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-settings.php        2009-11-01 08:12:21 UTC (rev 12133)
+++ trunk/wp-settings.php        2009-11-01 10:10:06 UTC (rev 12134)
</span><span class="lines">@@ -687,6 +687,9 @@
</span><span class="cx"> if ( file_exists(TEMPLATEPATH . '/functions.php') )
</span><span class="cx">         include(TEMPLATEPATH . '/functions.php');
</span><span class="cx"> 
</span><ins>+// Load in support for template functions which the theme supports
+require_if_theme_supports( 'post-thumbnails', ABSPATH . WPINC . '/post-image-template.php' );
+
</ins><span class="cx"> /**
</span><span class="cx">  * Runs just before PHP shuts down execution.
</span><span class="cx">  *
</span></span></pre>
</div>
</div>

</body>
</html>