Changeset 57685 for trunk/src/wp-includes/template.php
- Timestamp:
- 02/21/2024 07:24:12 PM (10 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/template.php
r57223 r57685 681 681 682 682 /** 683 * Set up the globals used for template loading. 684 * 685 * @since 6.5.0 686 * 687 * @global string $wp_stylesheet_path Path to current theme's stylesheet directory. 688 * @global string $wp_template_path Path to current theme's template directory. 689 */ 690 function wp_set_template_globals() { 691 global $wp_stylesheet_path, $wp_template_path; 692 693 $wp_stylesheet_path = get_stylesheet_directory(); 694 $wp_template_path = get_template_directory(); 695 } 696 697 /** 683 698 * Retrieves the name of the highest priority template file that exists. 684 699 * … … 689 704 * @since 2.7.0 690 705 * @since 5.5.0 The `$args` parameter was added. 706 * 707 * @global string $wp_stylesheet_path Path to current theme's stylesheet directory. 708 * @global string $wp_template_path Path to current theme's template directory. 691 709 * 692 710 * @param string|array $template_names Template file(s) to search for, in order. … … 699 717 */ 700 718 function locate_template( $template_names, $load = false, $load_once = true, $args = array() ) { 701 $stylesheet_path = get_stylesheet_directory(); 702 $template_path = get_template_directory(); 703 $is_child_theme = $stylesheet_path !== $template_path; 719 global $wp_stylesheet_path, $wp_template_path; 720 721 if ( ! isset( $wp_stylesheet_path ) || ! isset( $wp_template_path ) ) { 722 wp_set_template_globals(); 723 } 724 725 $is_child_theme = is_child_theme(); 704 726 705 727 $located = ''; … … 708 730 continue; 709 731 } 710 if ( file_exists( $ stylesheet_path . '/' . $template_name ) ) {711 $located = $ stylesheet_path . '/' . $template_name;732 if ( file_exists( $wp_stylesheet_path . '/' . $template_name ) ) { 733 $located = $wp_stylesheet_path . '/' . $template_name; 712 734 break; 713 } elseif ( $is_child_theme && file_exists( $ template_path . '/' . $template_name ) ) {714 $located = $ template_path . '/' . $template_name;735 } elseif ( $is_child_theme && file_exists( $wp_template_path . '/' . $template_name ) ) { 736 $located = $wp_template_path . '/' . $template_name; 715 737 break; 716 738 } elseif ( file_exists( ABSPATH . WPINC . '/theme-compat/' . $template_name ) ) {
Note: See TracChangeset
for help on using the changeset viewer.