Changeset 15641
- Timestamp:
- 09/21/2010 07:41:35 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/theme.php
r15613 r15641 467 467 * @since 2.9.0 468 468 * 469 * @return array Theme roots469 * @return array|string An arry of theme roots keyed by template/stylesheet or a single theme root if all themes have the same root. 470 470 */ 471 471 function get_theme_roots() { 472 global $wp_theme_directories; 473 474 if ( count($wp_theme_directories <= 1) ) 475 return '/themes'; 476 472 477 $theme_roots = get_site_transient( 'theme_roots' ); 473 478 if ( false === $theme_roots ) { … … 652 657 */ 653 658 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]; 659 if ( $stylesheet_or_template ) { 660 if ( $theme_root = get_raw_theme_root($stylesheet_or_template) ) 661 $theme_root = WP_CONTENT_DIR . $theme_root; 659 662 else 660 663 $theme_root = WP_CONTENT_DIR . '/themes'; … … 677 680 */ 678 681 function get_theme_root_uri( $stylesheet_or_template = false ) { 679 $theme_roots = get_theme_roots(); 680 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 682 if ( $stylesheet_or_template ) { 683 if ( $theme_root = get_raw_theme_root($stylesheet_or_template) ) 684 $theme_root_uri = content_url( $theme_root ); 685 else 686 $theme_root_uri = content_url( 'themes' ); 687 } else { 684 688 $theme_root_uri = content_url( 'themes' ); 689 } 685 690 686 691 return apply_filters( 'theme_root_uri', $theme_root_uri, get_option('siteurl'), $stylesheet_or_template ); 692 } 693 694 /** 695 * Get the raw theme root relative to the content directory with no filters applied. 696 * 697 * @since 3.1.0 698 * 699 * @param string $stylesheet_or_template The stylesheet or template name of the theme 700 * @return string Theme root 701 */ 702 function get_raw_theme_root( $stylesheet_or_template ) { 703 global $wp_theme_directories; 704 705 if ( count($wp_theme_directories <= 1) ) 706 return '/themes'; 707 708 $theme_root = false; 709 710 // If requesting the root for the current theme, consult options to avoid calling get_theme_roots() 711 if ( get_option('stylesheet') == $stylesheet_or_template ) 712 $theme_root = get_option('stylesheet_root'); 713 elseif ( get_option('template') == $stylesheet_or_template ) 714 $theme_root = get_option('template_root'); 715 716 if ( empty($theme_root) ) { 717 $theme_roots = get_theme_roots(); 718 if ( !empty($theme_roots[$stylesheet_or_template]) ) 719 $theme_root = $theme_roots[$stylesheet_or_template]; 720 } 721 722 return $theme_root; 687 723 } 688 724 … … 1214 1250 */ 1215 1251 function switch_theme($template, $stylesheet) { 1252 global $wp_theme_directories; 1253 1216 1254 update_option('template', $template); 1217 1255 update_option('stylesheet', $stylesheet); 1256 if ( count($wp_theme_directories) > 1 ) { 1257 update_option('template_root', get_raw_theme_root($template)); 1258 update_option('stylesheet_root', get_raw_theme_root($stylesheet)); 1259 } 1218 1260 delete_option('current_theme'); 1219 1261 $theme = get_current_theme();
Note: See TracChangeset
for help on using the changeset viewer.