Skip to content
Browse files

Register the default theme dir in wp-settings.php so that it is regis…

…tered even when get_themes() doesn't run. Fix counting of theme dirs. Add option to get_raw_theme_root() to disregard the current theme root cache. see #14911

git-svn-id: http://svn.automattic.com/wordpress/trunk@16424 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information...
1 parent a0e5b38 commit a6cdc2dea419a9102700e8513a16370859a5825d ryan committed Nov 17, 2010
Showing with 14 additions and 12 deletions.
  1. +11 −12 wp-includes/theme.php
  2. +3 −0 wp-settings.php
View
23 wp-includes/theme.php
@@ -267,9 +267,6 @@ function get_themes() {
if ( isset($wp_themes) )
return $wp_themes;
- /* Register the default root as a theme directory */
- register_theme_directory( get_theme_root() );
-
if ( !$theme_files = search_theme_directories() )
return false;
@@ -475,7 +472,7 @@ function get_themes() {
function get_theme_roots() {
global $wp_theme_directories;
- if ( count($wp_theme_directories <= 1) )
+ if ( count($wp_theme_directories) <= 1 )
return '/themes';
$theme_roots = get_site_transient( 'theme_roots' );
@@ -703,19 +700,21 @@ function get_theme_root_uri( $stylesheet_or_template = false ) {
* @param string $stylesheet_or_template The stylesheet or template name of the theme
* @return string Theme root
*/
-function get_raw_theme_root( $stylesheet_or_template ) {
+function get_raw_theme_root( $stylesheet_or_template, $no_cache = false ) {
global $wp_theme_directories;
- if ( count($wp_theme_directories <= 1) )
+ if ( count($wp_theme_directories) <= 1 )
return '/themes';
$theme_root = false;
// If requesting the root for the current theme, consult options to avoid calling get_theme_roots()
- if ( get_option('stylesheet') == $stylesheet_or_template )
- $theme_root = get_option('stylesheet_root');
- elseif ( get_option('template') == $stylesheet_or_template )
- $theme_root = get_option('template_root');
+ if ( !$no_cache ) {
+ if ( get_option('stylesheet') == $stylesheet_or_template )
+ $theme_root = get_option('stylesheet_root');
+ elseif ( get_option('template') == $stylesheet_or_template )
+ $theme_root = get_option('template_root');
+ }
if ( empty($theme_root) ) {
$theme_roots = get_theme_roots();
@@ -1248,8 +1247,8 @@ function switch_theme($template, $stylesheet) {
update_option('template', $template);
update_option('stylesheet', $stylesheet);
if ( count($wp_theme_directories) > 1 ) {
- update_option('template_root', get_raw_theme_root($template));
- update_option('stylesheet_root', get_raw_theme_root($stylesheet));
+ update_option('template_root', get_raw_theme_root($template, true));
+ update_option('stylesheet_root', get_raw_theme_root($stylesheet, true));
}
delete_option('current_theme');
$theme = get_current_theme();
View
3 wp-settings.php
@@ -174,6 +174,9 @@
create_initial_taxonomies();
create_initial_post_types();
+// Register the default theme directory root
+register_theme_directory( get_theme_root() );
+
// Load active plugins.
foreach ( wp_get_active_and_valid_plugins() as $plugin )
include_once( $plugin );

0 comments on commit a6cdc2d

Please sign in to comment.
Something went wrong with that request. Please try again.