Make WordPress Core

Ticket #13239: 13239.c2c.3.diff

File 13239.c2c.3.diff, 1.3 KB (added by coffee2code, 14 years ago)

Only one filter added, but can do everything, including templates outside theme's directory

  • wp-includes/theme.php

     
    10671067 * inherit from a parent theme can just overload one file.
    10681068 *
    10691069 * @since 2.7.0
     1070 * @uses apply_filters() Calls 'locate_template' filter on array of template names.
    10701071 *
    10711072 * @param string|array $template_names Template file(s) to search for, in order.
    10721073 * @param bool $load If true the template file will be loaded if it is found.
     
    10741075 * @return string The template filename if one is located.
    10751076 */
    10761077function locate_template($template_names, $load = false, $require_once = true ) {
     1078        $template_names = apply_filters( 'locate_template', $template_names, $load, $require_once );
     1079
    10771080        $located = '';
    10781081        foreach ( (array) $template_names as $template_name ) {
    10791082                if ( !$template_name )
    10801083                        continue;
    1081                 if ( file_exists(STYLESHEETPATH . '/' . $template_name)) {
     1084                if ( $template_name{0} == '/' && file_exists( $template_name ) ) {
     1085                        $located = $template_name;
     1086                        break;
     1087                } else if ( file_exists(STYLESHEETPATH . '/' . $template_name)) {
    10821088                        $located = STYLESHEETPATH . '/' . $template_name;
    10831089                        break;
    10841090                } else if ( file_exists(TEMPLATEPATH . '/' . $template_name) ) {