Make WordPress Core

Ticket #13239: 22355.1.patch

File 22355.1.patch, 1.7 KB (added by tifosi, 8 years ago)

Wrong file extn

  • template.php

     
    539539 */
    540540function locate_template($template_names, $load = false, $require_once = true ) {
    541541        $located = '';
     542    $locations = array( 
     543        get_stylesheet_directory(), 
     544                get_template_directory() 
     545        ); 
     546
     547        /** 
     548         * Filter the possible template locations. 
     549         * 
     550         * @param array $locations Possible template locations. 
     551         */ 
     552        $locations = apply_filters( 'template_locations', $locations ); 
     553 
    542554        foreach ( (array) $template_names as $template_name ) {
    543                 if ( !$template_name )
     555                if ( !$template_name ) {
    544556                        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;
    554557                }
     558
     559                foreach ( (array) $locations as $location ) { 
     560                        $template = trailingslashit( $location ) . $template_name; 
     561                        if ( file_exists( $template ) { 
     562                                $located = $template; 
     563                                break; 
     564                        } 
     565                }
    555566        }
    556567
    557         if ( $load && '' != $located )
     568        /** 
     569         * Filter the set template location 
     570         * 
     571         * @param       string  $located Generated template location. 
     572         * @param       array   $templates_names Possible template names. 
     573         */ 
     574        $located = apply_filters( 'locate_template', $located, $template_names );
     575
     576        if ( $load && '' != $located ) {
    558577                load_template( $located, $require_once );
     578        }
    559579
    560580        return $located;
    561581}