Make WordPress Core

Ticket #37443: 37443.patch

File 37443.patch, 2.3 KB (added by paulschreiber, 9 years ago)
  • wp-includes/template.php

     
    510510 * @param bool         $require_once   Whether to require_once or require. Default true. Has no effect if $load is false.
    511511 * @return string The template filename if one is located.
    512512 */
    513 function locate_template($template_names, $load = false, $require_once = true ) {
     513function locate_template( $template_names, $load = false, $require_once = true ) {
    514514        $located = '';
    515515        foreach ( (array) $template_names as $template_name ) {
    516                 if ( !$template_name )
     516                if ( ! $template_name ) {
    517517                        continue;
    518                 if ( file_exists(STYLESHEETPATH . '/' . $template_name)) {
    519                         $located = STYLESHEETPATH . '/' . $template_name;
     518                }
     519
     520                /**
     521                 * Filters the path to the stylesheet directory used by load_template.
     522                 *
     523                 * Allows user to override STYLESHEETPATH. Useful in contexts where this
     524                 * context is not defined, such as oEmbed or Public API.
     525                 *
     526                 * @since 4.7.0
     527                 *
     528                 * @param string $template path to the stylesheet directory
     529                 */
     530                $stylesheet_path = apply_filters( 'stylesheet_path', STYLESHEETPATH );
     531
     532                /**
     533                 * Filters the path to the template directory used by load_template.
     534                 *
     535                 * Allows user to override TEMPLATEPATH. Useful in contexts where this
     536                 * context is not defined, such as oEmbed or Public API.
     537                 *
     538                 * @since 4.7.0
     539                 *
     540                 * @param string $template path to the template directory
     541                 */
     542                $template_path = apply_filters( 'template_path', TEMPLATEPATH );
     543
     544                if ( file_exists( $stylesheet_path . '/' . $template_name ) ) {
     545                        $located = $stylesheet_path . '/' . $template_name;
    520546                        break;
    521                 } elseif ( file_exists(TEMPLATEPATH . '/' . $template_name) ) {
    522                         $located = TEMPLATEPATH . '/' . $template_name;
     547                } elseif ( file_exists( $template_path . '/' . $template_name ) ) {
     548                        $located = $template_path . '/' . $template_name;
    523549                        break;
    524550                } elseif ( file_exists( ABSPATH . WPINC . '/theme-compat/' . $template_name ) ) {
    525551                        $located = ABSPATH . WPINC . '/theme-compat/' . $template_name;
     
    527553                }
    528554        }
    529555
    530         if ( $load && '' != $located )
     556        if ( $load && '' !== $located ) {
    531557                load_template( $located, $require_once );
     558        }
    532559
    533560        return $located;
    534561}