wp/wp-includes/template-loader.php
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 16 a86126ab1dd4
equal deleted inserted replaced
8:c7c34916027a 9:177826044cd9
     1 <?php
     1 <?php
     2 /**
     2 /**
     3  * Loads the correct template based on the visitor's url
     3  * Loads the correct template based on the visitor's url
       
     4  *
     4  * @package WordPress
     5  * @package WordPress
     5  */
     6  */
     6 if ( defined('WP_USE_THEMES') && WP_USE_THEMES )
     7 if ( wp_using_themes() ) {
     7 	/**
     8 	/**
     8 	 * Fires before determining which template to load.
     9 	 * Fires before determining which template to load.
     9 	 *
    10 	 *
    10 	 * @since 1.5.0
    11 	 * @since 1.5.0
    11 	 */
    12 	 */
    12 	do_action( 'template_redirect' );
    13 	do_action( 'template_redirect' );
       
    14 }
    13 
    15 
    14 /**
    16 /**
    15  * Filters whether to allow 'HEAD' requests to generate content.
    17  * Filters whether to allow 'HEAD' requests to generate content.
    16  *
    18  *
    17  * Provides a significant performance bump by exiting before the page
    19  * Provides a significant performance bump by exiting before the page
    19  *
    21  *
    20  * @since 3.5.0
    22  * @since 3.5.0
    21  *
    23  *
    22  * @param bool $exit Whether to exit without generating any content for 'HEAD' requests. Default true.
    24  * @param bool $exit Whether to exit without generating any content for 'HEAD' requests. Default true.
    23  */
    25  */
    24 if ( 'HEAD' === $_SERVER['REQUEST_METHOD'] && apply_filters( 'exit_on_http_head', true ) )
    26 if ( 'HEAD' === $_SERVER['REQUEST_METHOD'] && apply_filters( 'exit_on_http_head', true ) ) {
    25 	exit();
    27 	exit();
       
    28 }
    26 
    29 
    27 // Process feeds and trackbacks even if not using themes.
    30 // Process feeds and trackbacks even if not using themes.
    28 if ( is_robots() ) :
    31 if ( is_robots() ) :
    29 	/**
    32 	/**
    30 	 * Fired when the template loader determines a robots.txt request.
    33 	 * Fired when the template loader determines a robots.txt request.
    39 elseif ( is_trackback() ) :
    42 elseif ( is_trackback() ) :
    40 	include( ABSPATH . 'wp-trackback.php' );
    43 	include( ABSPATH . 'wp-trackback.php' );
    41 	return;
    44 	return;
    42 endif;
    45 endif;
    43 
    46 
    44 if ( defined('WP_USE_THEMES') && WP_USE_THEMES ) :
    47 if ( wp_using_themes() ) :
    45 	$template = false;
    48 	$template = false;
    46 	if     ( is_embed()          && $template = get_embed_template()          ) :
    49 	if ( is_embed() && $template = get_embed_template() ) :
    47 	elseif ( is_404()            && $template = get_404_template()            ) :
    50 	elseif ( is_404() && $template = get_404_template() ) :
    48 	elseif ( is_search()         && $template = get_search_template()         ) :
    51 	elseif ( is_search() && $template = get_search_template() ) :
    49 	elseif ( is_front_page()     && $template = get_front_page_template()     ) :
    52 	elseif ( is_front_page() && $template = get_front_page_template() ) :
    50 	elseif ( is_home()           && $template = get_home_template()           ) :
    53 	elseif ( is_home() && $template = get_home_template() ) :
       
    54 	elseif ( is_privacy_policy() && $template = get_privacy_policy_template() ) :
    51 	elseif ( is_post_type_archive() && $template = get_post_type_archive_template() ) :
    55 	elseif ( is_post_type_archive() && $template = get_post_type_archive_template() ) :
    52 	elseif ( is_tax()            && $template = get_taxonomy_template()       ) :
    56 	elseif ( is_tax() && $template = get_taxonomy_template() ) :
    53 	elseif ( is_attachment()     && $template = get_attachment_template()     ) :
    57 	elseif ( is_attachment() && $template = get_attachment_template() ) :
    54 		remove_filter('the_content', 'prepend_attachment');
    58 		remove_filter( 'the_content', 'prepend_attachment' );
    55 	elseif ( is_single()         && $template = get_single_template()         ) :
    59 	elseif ( is_single() && $template = get_single_template() ) :
    56 	elseif ( is_page()           && $template = get_page_template()           ) :
    60 	elseif ( is_page() && $template = get_page_template() ) :
    57 	elseif ( is_singular()       && $template = get_singular_template()       ) :
    61 	elseif ( is_singular() && $template = get_singular_template() ) :
    58 	elseif ( is_category()       && $template = get_category_template()       ) :
    62 	elseif ( is_category() && $template = get_category_template() ) :
    59 	elseif ( is_tag()            && $template = get_tag_template()            ) :
    63 	elseif ( is_tag() && $template = get_tag_template() ) :
    60 	elseif ( is_author()         && $template = get_author_template()         ) :
    64 	elseif ( is_author() && $template = get_author_template() ) :
    61 	elseif ( is_date()           && $template = get_date_template()           ) :
    65 	elseif ( is_date() && $template = get_date_template() ) :
    62 	elseif ( is_archive()        && $template = get_archive_template()        ) :
    66 	elseif ( is_archive() && $template = get_archive_template() ) :
    63 	else :
    67 	else :
    64 		$template = get_index_template();
    68 		$template = get_index_template();
    65 	endif;
    69 	endif;
    66 	/**
    70 	/**
    67 	 * Filters the path of the current template before including it.
    71 	 * Filters the path of the current template before including it.