Ticket #13239: 22355.2.patch
File 22355.2.patch, 1.8 KB (added by , 8 years ago) |
---|
-
template.php
539 539 */ 540 540 function locate_template($template_names, $load = false, $require_once = true ) { 541 541 $located = ''; 542 $locations = array( 543 'stylesheet' => get_stylesheet_directory(), 544 'template' => get_template_directory(), 545 'theme-compat' => ABSPATH . WPINC . '/theme-compat' 546 ); 547 548 /** 549 * Filter the possible template locations. 550 * 551 * @param array $locations Possible template locations. 552 */ 553 $locations = (array)apply_filters( 'template_locations', $locations ); 554 542 555 foreach ( (array) $template_names as $template_name ) { 543 if ( !$template_name ) 556 if ( !$template_name ) { 544 557 continue; 545 if ( file_exists(STYLESHEETPATH . '/' . $template_name)) {546 $located = STYLESHEETPATH . '/' . $template_name;547 break;548 } elseif ( file_exists(TEMPLATEPATH . '/' . $template_name) ) {549 $located = TEMPLATEPATH . '/' . $template_name;550 break;551 } elseif ( file_exists( ABSPATH . WPINC . '/theme-compat/' . $template_name ) ) {552 $located = ABSPATH . WPINC . '/theme-compat/' . $template_name;553 break;554 558 } 559 560 foreach ( $locations as $k=>$location ) { 561 $template = trailingslashit( $location ) . $template_name; 562 if ( file_exists( $template ) { 563 $located = $template; 564 break; 565 } 566 } 555 567 } 556 568 557 if ( $load && '' != $located ) 569 /** 570 * Filter the set template location 571 * 572 * @param string $located Generated template location. 573 * @param array $templates_names Possible template names. 574 */ 575 $located = apply_filters( 'locate_template', $located, $template_names ); 576 577 if ( $load && '' != $located ) { 558 578 load_template( $located, $require_once ); 579 } 559 580 560 581 return $located; 561 582 }