WordPress.org

Make WordPress Core

Ticket #13239: 13239.diff

File 13239.diff, 921 bytes (added by chrisbliss18, 4 years ago)

Add filters to locate_template

  • wp-includes/theme.php

    diff --git a/wp-includes/theme.php b/wp-includes/theme.php
    index 00db024..f985490 100644
    a b function locate_template($template_names, $load = false, $require_once = true ) 
    10171017        if ( !is_array($template_names) ) 
    10181018                return ''; 
    10191019 
     1020        $template_names = apply_filters( 'locate_template', $template_names ); 
     1021 
    10201022        $located = ''; 
    10211023        foreach ( $template_names as $template_name ) { 
    10221024                if ( !$template_name ) 
    10231025                        continue; 
    1024                 if ( file_exists(STYLESHEETPATH . '/' . $template_name)) { 
     1026 
     1027                $template_name = apply_filters( "locate_template-$template_name", $template_name ); 
     1028 
     1029                if ( file_exists($template_name) ) { 
     1030                        $located = $template_name; 
     1031                        break; 
     1032                } else if ( file_exists(STYLESHEETPATH . '/' . $template_name) ) { 
    10251033                        $located = STYLESHEETPATH . '/' . $template_name; 
    10261034                        break; 
    10271035                } else if ( file_exists(TEMPLATEPATH . '/' . $template_name) ) {