Make WordPress Core

Ticket #11242: ticket_11242_patch2.diff

File ticket_11242_patch2.diff, 1.2 KB (added by ptahdunbar, 15 years ago)

adds a template_loaded action to load_template()

  • 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                include( $_template_file );
     1020                do_action( 'template_loaded', $_template_file );
     1021        }
    10191022}
    10201023
    10211024/**