WordPress.org

Make WordPress Core

Ticket #13239: 13239.c2c.2.diff

File 13239.c2c.2.diff, 1.9 KB (added by coffee2code, 8 years ago)

Amended version of my previous patch w/ extra hook added

  • wp-includes/theme.php

     
    10351035 * inherit from a parent theme can just overload one file.
    10361036 *
    10371037 * @since 2.7.0
     1038 * @uses apply_filters() Calls 'locate_template' filter on array of template names.
     1039 * @uses apply_filters() Calls "locate_template-$template_name" filter on template name.
     1040 * @uses apply_filters() Calls "locate_template_path-$template_name" filter on empty string, to be used to explicit define a template path.
     1041 * @uses apply_filters() Calls 'locate_template_located' filter on located template.
    10381042 *
    10391043 * @param array $template_names Array of template files to search for in priority order.
    10401044 * @param bool $load If true the template file will be loaded if it is found.
     
    10451049        if ( !is_array($template_names) )
    10461050                return '';
    10471051
     1052        $template_names = apply_filters( 'locate_template', $template_names, $load, $require_once );
     1053
    10481054        $located = '';
    10491055        foreach ( $template_names as $template_name ) {
     1056                $template_name = apply_filters( "locate_template-$template_name", $template_name, $load, $require_once );
    10501057                if ( !$template_name )
    10511058                        continue;
    1052                 if ( file_exists(STYLESHEETPATH . '/' . $template_name)) {
     1059                $template_path = apply_filters( "locate_template_path-$template_name", '', $template_name, $load, $require_once );
     1060                if ( !empty( $template_path ) && file_exists( $template_path ) ) {
     1061                        $located = $template_path;
     1062                        break;
     1063                } else if ( file_exists(STYLESHEETPATH . '/' . $template_name)) {
    10531064                        $located = STYLESHEETPATH . '/' . $template_name;
    10541065                        break;
    10551066                } else if ( file_exists(TEMPLATEPATH . '/' . $template_name) ) {
     
    10581069                }
    10591070        }
    10601071
     1072        $located = apply_filters( 'locate_template_located', $located, $template_names, $load, $require_once );
     1073
    10611074        if ( $load && '' != $located )
    10621075                load_template( $located, $require_once );
    10631076