WordPress.org

Make WordPress Core

Ticket #20027: 20027.diff

File 20027.diff, 3.2 KB (added by nacin, 6 years ago)
  • wp-includes/theme.php

     
    1414 * @return bool true if a child theme is in use, false otherwise.
    1515 **/
    1616function is_child_theme() {
    17         return ( TEMPLATEPATH !== STYLESHEETPATH );
     17        return ( get_stylesheet() !== get_template() );
    1818}
    1919
    2020/**
     
    2323 * The theme name that the administrator has currently set the front end theme
    2424 * as.
    2525 *
    26  * For all extensive purposes, the template name and the stylesheet name are
    27  * going to be the same for most cases.
     26 * The template name and stylesheet name differ when a child theme is in use.
    2827 *
    2928 * @since 1.5.0
    3029 * @uses apply_filters() Calls 'stylesheet' filter on stylesheet name.
     
    3231 * @return string Stylesheet name.
    3332 */
    3433function get_stylesheet() {
    35         return apply_filters('stylesheet', get_option('stylesheet'));
     34        return get_option( 'stylesheet' );
    3635}
    3736
    3837/**
     
    125124 * @return string Template name.
    126125 */
    127126function get_template() {
    128         return apply_filters('template', get_option('template'));
     127        return get_option( 'template' );
    129128}
    130129
    131130/**
     131 * Applies the 'stylesheet' and 'template' filters to option calls.
     132 *
     133 * @since 3.4.0
     134 * @access private
     135 */
     136function _stylesheet_template_option_filter( $value ) {
     137        if ( 'stylesheet' == current_filter() )
     138                return apply_filters( 'stylesheet', $value );
     139        return apply_filters( 'template', $value );
     140}
     141add_action( 'option_stylesheet', '_stylesheet_template_option_filter', 100 );
     142add_action( 'option_stylesheet', '_stylesheet_template_option_filter', 100 );
     143
     144/**
    132145 * Retrieve current theme directory.
    133146 *
    134147 * @since 1.5.0
     
    10631076/**
    10641077 * Retrieve the name of the highest priority template file that exists.
    10651078 *
    1066  * Searches in the STYLESHEETPATH before TEMPLATEPATH so that themes which
     1079 * Searches in the stylesheet path before template path so that themes which
    10671080 * inherit from a parent theme can just overload one file.
    10681081 *
    10691082 * @since 2.7.0
     
    10781091        foreach ( (array) $template_names as $template_name ) {
    10791092                if ( !$template_name )
    10801093                        continue;
    1081                 if ( file_exists(STYLESHEETPATH . '/' . $template_name)) {
    1082                         $located = STYLESHEETPATH . '/' . $template_name;
     1094                if ( file_exists( get_stylesheet() . '/' . $template_name)) {
     1095                        $located = get_stylesheet() . '/' . $template_name;
    10831096                        break;
    1084                 } else if ( file_exists(TEMPLATEPATH . '/' . $template_name) ) {
    1085                         $located = TEMPLATEPATH . '/' . $template_name;
     1097                } else if ( file_exists( get_template() . '/' . $template_name) ) {
     1098                        $located = get_template() . '/' . $template_name;
    10861099                        break;
    10871100                }
    10881101        }
     
    11531166        if ( validate_file($_GET['template']) )
    11541167                return;
    11551168
    1156         add_filter( 'template', '_preview_theme_template_filter' );
     1169        add_filter( 'option_template', '_preview_theme_template_filter' );
    11571170
    11581171        if ( isset($_GET['stylesheet']) ) {
    11591172                $_GET['stylesheet'] = preg_replace('|[^a-z0-9_./-]|i', '', $_GET['stylesheet']);
    11601173                if ( validate_file($_GET['stylesheet']) )
    11611174                        return;
    1162                 add_filter( 'stylesheet', '_preview_theme_stylesheet_filter' );
     1175                add_filter( 'option_stylesheet', '_preview_theme_stylesheet_filter' );
    11631176        }
    11641177
    11651178        // Prevent theme mods to current theme being used on theme being previewed