<!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>[12129] trunk/wp-includes/theme.php: get_themes() and theme root fixes.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/12129">12129</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2009-10-30 00:18:15 +0000 (Fri, 30 Oct 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>get_themes() and theme root fixes. see <a href="http://trac.wordpress.org/ticket/10467">#10467</a></pre>

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

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludesthemephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/theme.php (12128 => 12129)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/theme.php        2009-10-29 21:53:57 UTC (rev 12128)
+++ trunk/wp-includes/theme.php        2009-10-30 00:18:15 UTC (rev 12129)
</span><span class="lines">@@ -263,6 +263,8 @@
</span><span class="cx"> 
</span><span class="cx">         asort( $theme_files );
</span><span class="cx"> 
</span><ins>+        $wp_themes = array();
+
</ins><span class="cx">         foreach ( (array) $theme_files as $theme_file ) {
</span><span class="cx">                 $theme_root = $theme_file['theme_root'];
</span><span class="cx">                 $theme_file = $theme_file['theme_file'];
</span><span class="lines">@@ -308,7 +310,7 @@
</span><span class="cx">                         $parent_dir = dirname(dirname($theme_file));
</span><span class="cx">                         if ( file_exists(&quot;$theme_root/$parent_dir/$template/index.php&quot;) ) {
</span><span class="cx">                                 $template = &quot;$parent_dir/$template&quot;;
</span><del>-                                $template_directory = &quot;$theme_root/$parent_dir/$template&quot;;
</del><ins>+                                $template_directory = &quot;$theme_root/$template&quot;;
</ins><span class="cx">                         } else {
</span><span class="cx">                                 /**
</span><span class="cx">                                  * The parent theme doesn't exist in the current theme's folder or sub folder
</span><span class="lines">@@ -316,7 +318,7 @@
</span><span class="cx">                                  */
</span><span class="cx">                                 $parent_theme_root = $theme_files[$template]['theme_root'];
</span><span class="cx">                                 if ( file_exists( &quot;$parent_theme_root/$template/index.php&quot; ) ) {
</span><del>-                                        $template = &quot;$parent_theme_root/$template&quot;;
</del><ins>+                                        $template_directory = &quot;$parent_theme_root/$template&quot;;
</ins><span class="cx">                                 } else {
</span><span class="cx">                                         $wp_broken_themes[$name] = array('Name' =&gt; $name, 'Title' =&gt; $title, 'Description' =&gt; __('Template is missing.'));
</span><span class="cx">                                         continue;
</span><span class="lines">@@ -376,46 +378,46 @@
</span><span class="cx">                 // a new theme directory and the theme header is not updated.  Whichever
</span><span class="cx">                 // theme is first keeps the name.  Subsequent themes get a suffix applied.
</span><span class="cx">                 // The Default and Classic themes always trump their pretenders.
</span><del>-                if ( isset($themes[$name]) ) {
</del><ins>+                if ( isset($wp_themes[$name]) ) {
</ins><span class="cx">                         if ( ('WordPress Default' == $name || 'WordPress Classic' == $name) &amp;&amp;
</span><span class="cx">                                          ('default' == $stylesheet || 'classic' == $stylesheet) ) {
</span><span class="cx">                                 // If another theme has claimed to be one of our default themes, move
</span><span class="cx">                                 // them aside.
</span><del>-                                $suffix = $themes[$name]['Stylesheet'];
</del><ins>+                                $suffix = $wp_themes[$name]['Stylesheet'];
</ins><span class="cx">                                 $new_name = &quot;$name/$suffix&quot;;
</span><del>-                                $themes[$new_name] = $themes[$name];
-                                $themes[$new_name]['Name'] = $new_name;
</del><ins>+                                $wp_themes[$new_name] = $wp_themes[$name];
+                                $wp_themes[$new_name]['Name'] = $new_name;
</ins><span class="cx">                         } else {
</span><span class="cx">                                 $name = &quot;$name/$stylesheet&quot;;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 $theme_roots[$stylesheet] = str_replace( WP_CONTENT_DIR, '', $theme_root );
</span><del>-                $themes[$name] = array( 'Name' =&gt; $name, 'Title' =&gt; $title, 'Description' =&gt; $description, 'Author' =&gt; $author, 'Version' =&gt; $version, 'Template' =&gt; $template, 'Stylesheet' =&gt; $stylesheet, 'Template Files' =&gt; $template_files, 'Stylesheet Files' =&gt; $stylesheet_files, 'Template Dir' =&gt; $template_dir, 'Stylesheet Dir' =&gt; $stylesheet_dir, 'Status' =&gt; $theme_data['Status'], 'Screenshot' =&gt; $screenshot, 'Tags' =&gt; $theme_data['Tags'], 'Theme Root' =&gt; $theme_root, 'Theme Root URI' =&gt; str_replace( WP_CONTENT_DIR, content_url(), $theme_root ) );
</del><ins>+                $wp_themes[$name] = array( 'Name' =&gt; $name, 'Title' =&gt; $title, 'Description' =&gt; $description, 'Author' =&gt; $author, 'Version' =&gt; $version, 'Template' =&gt; $template, 'Stylesheet' =&gt; $stylesheet, 'Template Files' =&gt; $template_files, 'Stylesheet Files' =&gt; $stylesheet_files, 'Template Dir' =&gt; $template_dir, 'Stylesheet Dir' =&gt; $stylesheet_dir, 'Status' =&gt; $theme_data['Status'], 'Screenshot' =&gt; $screenshot, 'Tags' =&gt; $theme_data['Tags'], 'Theme Root' =&gt; $theme_root, 'Theme Root URI' =&gt; str_replace( WP_CONTENT_DIR, content_url(), $theme_root ) );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        /* Resolve theme dependencies. */
-        $theme_names = array_keys( $themes );
</del><ins>+        unset($theme_files);
</ins><span class="cx"> 
</span><span class="cx">         /* Store theme roots in the DB */
</span><span class="cx">         if ( get_site_transient( 'theme_roots' ) != $theme_roots )
</span><span class="cx">                 set_site_transient( 'theme_roots', $theme_roots, 7200 ); // cache for two hours
</span><ins>+        unset($theme_roots);
</ins><span class="cx"> 
</span><ins>+        /* Resolve theme dependencies. */
+        $theme_names = array_keys( $wp_themes );
</ins><span class="cx">         foreach ( (array) $theme_names as $theme_name ) {
</span><del>-                $themes[$theme_name]['Parent Theme'] = '';
-                if ( $themes[$theme_name]['Stylesheet'] != $themes[$theme_name]['Template'] ) {
</del><ins>+                $wp_themes[$theme_name]['Parent Theme'] = '';
+                if ( $wp_themes[$theme_name]['Stylesheet'] != $wp_themes[$theme_name]['Template'] ) {
</ins><span class="cx">                         foreach ( (array) $theme_names as $parent_theme_name ) {
</span><del>-                                if ( ($themes[$parent_theme_name]['Stylesheet'] == $themes[$parent_theme_name]['Template']) &amp;&amp; ($themes[$parent_theme_name]['Template'] == $themes[$theme_name]['Template']) ) {
-                                        $themes[$theme_name]['Parent Theme'] = $themes[$parent_theme_name]['Name'];
</del><ins>+                                if ( ($wp_themes[$parent_theme_name]['Stylesheet'] == $wp_themes[$parent_theme_name]['Template']) &amp;&amp; ($wp_themes[$parent_theme_name]['Template'] == $wp_themes[$theme_name]['Template']) ) {
+                                        $wp_themes[$theme_name]['Parent Theme'] = $wp_themes[$parent_theme_name]['Name'];
</ins><span class="cx">                                         break;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        $wp_themes = $themes;
-
-        return $themes;
</del><ins>+        return $wp_themes;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span></span></pre>
</div>
</div>

</body>
</html>