Ticket #14911: 14911.diff
File 14911.diff, 2.7 KB (added by , 14 years ago) |
---|
-
wp-includes/theme.php
651 651 * @return string Theme path. 652 652 */ 653 653 function get_theme_root( $stylesheet_or_template = false ) { 654 if ($stylesheet_or_template) { 655 $theme_roots = get_theme_roots(); 656 657 if ( ! empty( $theme_roots[$stylesheet_or_template] ) ) 658 $theme_root = WP_CONTENT_DIR . $theme_roots[$stylesheet_or_template]; 654 if ( $stylesheet_or_template ) { 655 if ( $theme_root = get_raw_theme_root($stylesheet_or_template) ) 656 $theme_root = WP_CONTENT_DIR . $theme_root; 659 657 else 660 658 $theme_root = WP_CONTENT_DIR . '/themes'; 661 659 } else { … … 676 674 * @return string Themes URI. 677 675 */ 678 676 function get_theme_root_uri( $stylesheet_or_template = false ) { 679 $theme_roots = get_theme_roots();680 677 681 if ( isset( $theme_roots[$stylesheet_or_template] ) && $theme_roots[$stylesheet_or_template] ) 682 $theme_root_uri = content_url( $theme_roots[$stylesheet_or_template] ); 683 else 678 if ($stylesheet_or_template) { 679 if ( $theme_root = get_raw_theme_root($stylesheet_or_template) ) 680 $theme_root_uri = content_url( $theme_root ); 681 else 682 $theme_root_uri = content_url( 'themes' ); 683 } else { 684 684 $theme_root_uri = content_url( 'themes' ); 685 } 685 686 686 687 return apply_filters( 'theme_root_uri', $theme_root_uri, get_option('siteurl'), $stylesheet_or_template ); 687 688 } 688 689 689 690 /** 691 * Get the raw theme root relative to the content directory with no filters applied. 692 * 693 * @since 3.1.0 694 * 695 * @param string $stylesheet_or_template The stylesheet or template name of the theme 696 * @return string Theme root 697 */ 698 function get_raw_theme_root( $stylesheet_or_template ) { 699 $theme_root = false; 700 701 // If requesting the root for the current theme, consult options to avoid calling get_theme_roots() 702 if ( get_option('stylesheet') == $stylesheet_or_template ) 703 $theme_root = get_option('stylesheet_root'); 704 elseif ( get_option('template') == $stylesheet_or_template ) 705 $theme_root = get_option('template_root'); 706 707 if ( empty($theme_root) ) { 708 $theme_roots = get_theme_roots(); 709 if ( !empty($theme_roots[$stylesheet_or_template]) ) 710 $theme_root = $theme_roots[$stylesheet_or_template]; 711 } 712 713 return $theme_root; 714 } 715 716 /** 690 717 * Retrieve path to a template 691 718 * 692 719 * Used to quickly retrieve the path of a template without including the file … … 1215 1242 function switch_theme($template, $stylesheet) { 1216 1243 update_option('template', $template); 1217 1244 update_option('stylesheet', $stylesheet); 1245 update_option('template_root', get_raw_theme_root($template)); 1246 update_option('stylesheet_root', get_raw_theme_root($stylesheet)); 1218 1247 delete_option('current_theme'); 1219 1248 $theme = get_current_theme(); 1220 1249 do_action('switch_theme', $theme);