Make WordPress Core

Ticket #11242: ticket_11242-patch.diff

File ticket_11242-patch.diff, 5.6 KB (added by ptahdunbar, 15 years ago)

Minor updates based off hakre's 11242.patch

  • wp-includes/template-loader.php

     
    11<?php
    22/**
    3  * Loads the correct template based on the visitor's url
     3 * Loads the correct template based on the url requested.
     4 *
    45 * @package WordPress
    56 */
    6 if ( defined('WP_USE_THEMES') && constant('WP_USE_THEMES') ) {
    7         do_action('template_redirect');
    8         if ( is_robots() ) {
    9                 do_action('do_robots');
    10                 return;
    11         } else if ( is_feed() ) {
    12                 do_feed();
    13                 return;
    14         } else if ( is_trackback() ) {
    15                 include(ABSPATH . 'wp-trackback.php');
    16                 return;
    17         } else if ( is_404() && $template = get_404_template() ) {
    18                 include($template);
    19                 return;
    20         } else if ( is_search() && $template = get_search_template() ) {
    21                 include($template);
    22                 return;
    23         } else if ( is_tax() && $template = get_taxonomy_template()) {
    24                 include($template);
    25                 return;
    26         } else if ( is_home() && $template = get_home_template() ) {
    27                 include($template);
    28                 return;
    29         } else if ( is_attachment() && $template = get_attachment_template() ) {
    30                 remove_filter('the_content', 'prepend_attachment');
    31                 include($template);
    32                 return;
    33         } else if ( is_single() && $template = get_single_template() ) {
    34                 include($template);
    35                 return;
    36         } else if ( is_page() && $template = get_page_template() ) {
    37                 include($template);
    38                 return;
    39         } else if ( is_category() && $template = get_category_template()) {
    40                 include($template);
    41                 return;
    42         } else if ( is_tag() && $template = get_tag_template()) {
    43                 include($template);
    44                 return;
    45         } else if ( is_author() && $template = get_author_template() ) {
    46                 include($template);
    47                 return;
    48         } else if ( is_date() && $template = get_date_template() ) {
    49                 include($template);
    50                 return;
    51         } else if ( is_archive() && $template = get_archive_template() ) {
    52                 include($template);
    53                 return;
    54         } else if ( is_comments_popup() && $template = get_comments_popup_template() ) {
    55                 include($template);
    56                 return;
    57         } else if ( is_paged() && $template = get_paged_template() ) {
    58                 include($template);
    59                 return;
    60         } else if ( file_exists(TEMPLATEPATH . "/index.php") ) {
    61                 include(TEMPLATEPATH . "/index.php");
    62                 return;
     7
     8$template = '';
     9
     10if ( $flag_themes = ( defined( 'WP_USE_THEMES' ) && constant( 'WP_USE_THEMES' ) ) )
     11        do_action( 'template_redirect' );
     12
     13/* Default actions regardless of wether themes are used or not */
     14if ( is_robots() ) {
     15        do_action( 'do_robots' );
     16        return;
     17} else if ( is_feed() ) {
     18        do_feed();
     19        return;
     20} else if ( is_trackback() ) {
     21        $template = ABSPATH . 'wp-trackback.php';
     22}
     23
     24/* Load the template if themes are used */
     25if ( $flag_themes && $template == '') {
     26       
     27        $themes_template_config = array(
     28                '404'            => array(),
     29                'search'         => array(),
     30                'tax'                => array(),
     31                'home'               => array(),
     32                'attachment'     => array( 'remove_filter' => array( 'the_content', 'prepend_attachment' ) ),
     33                'single'         => array(),
     34                'page'           => array(),
     35                'category'       => array(),
     36                'tag'            => array(),
     37                'author'         => array(),
     38                'date'           => array(),
     39                'archive'        => array(),
     40                'comments_popup' => array(),
     41                'paged'          => array(),
     42        );
     43       
     44        $themes_template_config = apply_filters( 'template_include_config', $themes_template_config );
     45       
     46        foreach( $themes_template_config as $name => $config ) {
     47                $is_query     = sprintf( 'is_%s',                       $name );
     48                $get_template = sprintf( 'get_%s_template', $name );
     49                if ( $wp_query->$is_query && $template = $get_template() ) {
     50                        if ( isset( $config['remove_filter'] ) )
     51                                remove_filter( $config['remove_filter'][0], $config['remove_filter'][1] );
     52                        break;
     53                }
    6354        }
    64 } else {
    65         // Process feeds and trackbacks even if not using themes.
    66         if ( is_robots() ) {
    67                 do_action('do_robots');
    68                 return;
    69         } else if ( is_feed() ) {
    70                 do_feed();
    71                 return;
    72         } else if ( is_trackback() ) {
    73                 include(ABSPATH . 'wp-trackback.php');
    74                 return;
    75         }
     55       
     56        unset( $themes_template_config, $is_query, $get_template );
     57               
     58        if ( '' == $template && file_exists(TEMPLATEPATH . '/index.php') )
     59                $template = TEMPLATEPATH . '/index.php';
    7660}
    7761
     62unset( $flag_themes );
     63
     64if ( $template = apply_filters('template_include', $template) ) {
     65        include( $template );
     66        do_action( 'template_included', $template );
     67}
     68
    7869?>
     70 No newline at end of file
  • wp-includes/theme.php

     
    975975 *
    976976 * @param array $template_names Array of template files to search for in priority order.
    977977 * @param bool $load If true the template file will be loaded if it is found.
    978  * @return string The template filename if one is located.
     978 * @return string The template filename if one is located, empty string if none is located
    979979 */
    980980function locate_template($template_names, $load = false) {
    981981        if ( !is_array($template_names) )
     
    10091009 *
    10101010 * @param string $_template_file Path to template file.
    10111011 */
    1012 function load_template($_template_file) {
     1012function load_template( $_template_file ) {
    10131013        global $posts, $post, $wp_did_header, $wp_did_template_redirect, $wp_query, $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID;
    10141014
    10151015        if ( is_array($wp_query->query_vars) )
    10161016                extract($wp_query->query_vars, EXTR_SKIP);
    10171017
    1018         require_once($_template_file);
     1018        if ( $_template_file = apply_filters( 'template_load', $_template_file ) ) {
     1019                require_once( $_template_file );
     1020                do_action( 'template_loaded', $_template_file );
     1021        }
    10191022}
    10201023
    10211024/**