Ticket #13239: template.diff
File template.diff, 3.1 KB (added by , 7 years ago) |
---|
-
wp-includes/template.php
40 40 */ 41 41 $templates = apply_filters( "{$type}_template_hierarchy", $templates ); 42 42 43 $template = locate_template( $templates );43 $template = locate_template( $templates, null, null, $type ); 44 44 45 45 /** 46 46 * Filters the path of the queried template by type. … … 613 613 return get_query_template( 'attachment', $templates ); 614 614 } 615 615 616 617 616 618 /** 617 619 * Retrieve the name of the highest priority template file that exists. 618 620 * … … 626 628 * @param bool $require_once Whether to require_once or require. Default true. Has no effect if $load is false. 627 629 * @return string The template filename if one is located. 628 630 */ 629 function locate_template($template_names, $load = false, $require_once = true ) { 630 $located = ''; 631 function locate_template($template_names, $load = false, $require_once = true, $type = null ) { 632 633 $located = ''; 634 635 /** 636 * Filters the path to the template files that are searched for when retrieving a template to use. 637 * 638 * If the filter is not triggered, the templates are expected to be in their default 639 * location (the theme root). 640 * 641 * If the filter is triggered and a directory name is returned, then WordPress will 642 * look in that directory (relative ancestor to the theme root) for the files. 643 * 644 * This filter also moves the location of all template parts such as header.php, footer.php ect ect 645 * @since 4.7.0 646 * 647 * @param string $path A Directory name which contains all the template files, relative to the theme root. 648 */ 649 $path = apply_filters("templates_path", ''); 650 $path = isset($path) ? trailingslashit($path) : $path; 651 652 /** 653 * Filters the path to the template files, based on type, that are searched 654 * for when retrieving a template to use. 655 * 656 * 657 * Possible values for `$type` include: 'index', '404', 'archive', 'author', 'category', 'tag', 'taxonomy', 'date', 658 * 'embed', 'home', 'frontpage', 'page', 'paged', 'search', 'single', 'singular', and 'attachment'. 659 * 660 * @param string $path A Directory name which contains all the template files, relative to the theme root. 661 */ 662 $path = apply_filters("{$type}_templates_path", $path); 663 $path = isset($path) ? trailingslashit($path) : $path; 664 665 631 666 foreach ( (array) $template_names as $template_name ) { 632 667 if ( !$template_name ) 633 668 continue; 634 if ( file_exists(STYLESHEETPATH . '/' . $ template_name)) {635 $located = STYLESHEETPATH . '/' . $ template_name;669 if ( file_exists(STYLESHEETPATH . '/' . $path . $template_name)) { 670 $located = STYLESHEETPATH . '/' . $path . $template_name; 636 671 break; 637 } elseif ( file_exists(TEMPLATEPATH . '/' . $ template_name) ) {638 $located = TEMPLATEPATH . '/' . $ template_name;672 } elseif ( file_exists(TEMPLATEPATH . '/' . $path . $template_name) ) { 673 $located = TEMPLATEPATH . '/' . $path . $template_name; 639 674 break; 640 675 } elseif ( file_exists( ABSPATH . WPINC . '/theme-compat/' . $template_name ) ) { 641 676 $located = ABSPATH . WPINC . '/theme-compat/' . $template_name;