Make WordPress Core

Ticket #13239: 13239.2.diff

File 13239.2.diff, 1.6 KB (added by DrewAPicture, 11 years ago)
  • wp-includes/template.php

     
    359359 * inherit from a parent theme can just overload one file.
    360360 *
    361361 * @since 2.7.0
     362 * @uses apply_filters() Calls 'locate_template' filter on array of template names.
    362363 *
    363364 * @param string|array $template_names Template file(s) to search for, in order.
    364365 * @param bool $load If true the template file will be loaded if it is found.
     
    366367 * @return string The template filename if one is located.
    367368 */
    368369function locate_template($template_names, $load = false, $require_once = true ) {
     370        $template_names = apply_filters( 'locate_template', $template_names, $load, $require_once );
     371
    369372        $located = '';
    370373        foreach ( (array) $template_names as $template_name ) {
    371374                if ( !$template_name )
    372375                        continue;
    373                 if ( file_exists(STYLESHEETPATH . '/' . $template_name)) {
    374                         $located = STYLESHEETPATH . '/' . $template_name;
     376                if ( path_is_absolute( $template_name ) && file_exists( $template_name ) ) {
     377                        $located = $template_name;
    375378                        break;
    376                 } else if ( file_exists(TEMPLATEPATH . '/' . $template_name) ) {
    377                         $located = TEMPLATEPATH . '/' . $template_name;
     379                } else if ( file_exists( get_stylesheet_directory() . '/' . $template_name)) {
     380                        $located = get_stylesheet_directory() . '/' . $template_name;
    378381                        break;
     382                } else if ( file_exists( get_template_directory() . '/' . $template_name) ) {
     383                        $located = get_template_directory() . '/' . $template_name;
     384                        break;
    379385                }
    380386        }
    381387