<!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>[14075] trunk/wp-includes: Don't use require_once for get_template_part().</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/14075">14075</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-04-11 17:26:03 +0000 (Sun, 11 Apr 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Don't use require_once for get_template_part(). fixes <a href="http://trac.wordpress.org/ticket/12958">#12958</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludesgeneraltemplatephp">trunk/wp-includes/general-template.php</a></li>
<li><a href="#trunkwpincludesthemephp">trunk/wp-includes/theme.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludesgeneraltemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/general-template.php (14074 => 14075)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/general-template.php        2010-04-11 17:07:20 UTC (rev 14074)
+++ trunk/wp-includes/general-template.php        2010-04-11 17:26:03 UTC (rev 14075)
</span><span class="lines">@@ -103,6 +103,9 @@
</span><span class="cx">  * specialised part will be included. If the theme contains no {slug}.php file
</span><span class="cx">  * then no template will be included.
</span><span class="cx">  *
</span><ins>+ * The template is included using require, not require_once, so you may include the
+ * same template part multiple times.
+ *
</ins><span class="cx">  * For the parameter, if the file is called &quot;{slug}-special.php&quot; then specify
</span><span class="cx">  * &quot;special&quot;.
</span><span class="cx">  *
</span><span class="lines">@@ -122,7 +125,7 @@
</span><span class="cx"> 
</span><span class="cx">         $templates[] = &quot;{$slug}.php&quot;;
</span><span class="cx"> 
</span><del>-        locate_template($templates, true);
</del><ins>+        locate_template($templates, true, false);
</ins><span class="cx"> }
</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 (14074 => 14075)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/theme.php        2010-04-11 17:07:20 UTC (rev 14074)
+++ trunk/wp-includes/theme.php        2010-04-11 17:26:03 UTC (rev 14075)
</span><span class="lines">@@ -986,9 +986,10 @@
</span><span class="cx">  *
</span><span class="cx">  * @param array $template_names Array of template files to search for in priority order.
</span><span class="cx">  * @param bool $load If true the template file will be loaded if it is found.
</span><ins>+ * @param bool $require_once Whether to require_once or require. Default true. Has no effect if $load is false.
</ins><span class="cx">  * @return string The template filename if one is located.
</span><span class="cx">  */
</span><del>-function locate_template($template_names, $load = false) {
</del><ins>+function locate_template($template_names, $load = false, $require_once = true ) {
</ins><span class="cx">         if ( !is_array($template_names) )
</span><span class="cx">                 return '';
</span><span class="cx"> 
</span><span class="lines">@@ -1004,13 +1005,13 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if ( $load &amp;&amp; '' != $located )
</span><del>-                load_template($located);
</del><ins>+                load_template( $located, $require_once );
</ins><span class="cx"> 
</span><span class="cx">         return $located;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Require once the template file with WordPress environment.
</del><ins>+ * Require the template file with WordPress environment.
</ins><span class="cx">  *
</span><span class="cx">  * The globals are set up for the template file to ensure that the WordPress
</span><span class="cx">  * environment is available from within the function. The query variables are
</span><span class="lines">@@ -1019,14 +1020,18 @@
</span><span class="cx">  * @since 1.5.0
</span><span class="cx">  *
</span><span class="cx">  * @param string $_template_file Path to template file.
</span><ins>+ * @param bool $require_once Whether to require_once or require. Default true.
</ins><span class="cx">  */
</span><del>-function load_template($_template_file) {
</del><ins>+function load_template( $_template_file, $require_once = true ) {
</ins><span class="cx">         global $posts, $post, $wp_did_header, $wp_did_template_redirect, $wp_query, $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID;
</span><span class="cx"> 
</span><del>-        if ( is_array($wp_query-&gt;query_vars) )
-                extract($wp_query-&gt;query_vars, EXTR_SKIP);
</del><ins>+        if ( is_array( $wp_query-&gt;query_vars ) )
+                extract( $wp_query-&gt;query_vars, EXTR_SKIP );
</ins><span class="cx"> 
</span><del>-        require_once($_template_file);
</del><ins>+        if ( $require_once )
+                require_once( $_template_file );
+        else
+                require( $_template_file );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span></span></pre>
</div>
</div>

</body>
</html>