wp/wp-includes/template-loader.php
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
    10 	 * @since 1.5.0
    10 	 * @since 1.5.0
    11 	 */
    11 	 */
    12 	do_action( 'template_redirect' );
    12 	do_action( 'template_redirect' );
    13 
    13 
    14 /**
    14 /**
    15  * Filter whether to allow 'HEAD' requests to generate content.
    15  * Filters whether to allow 'HEAD' requests to generate content.
    16  *
    16  *
    17  * Provides a significant performance bump by exiting before the page
    17  * Provides a significant performance bump by exiting before the page
    18  * content loads for 'HEAD' requests. See #14348.
    18  * content loads for 'HEAD' requests. See #14348.
    19  *
    19  *
    20  * @since 3.5.0
    20  * @since 3.5.0
    41 	return;
    41 	return;
    42 endif;
    42 endif;
    43 
    43 
    44 if ( defined('WP_USE_THEMES') && WP_USE_THEMES ) :
    44 if ( defined('WP_USE_THEMES') && WP_USE_THEMES ) :
    45 	$template = false;
    45 	$template = false;
    46 	if     ( is_404()            && $template = get_404_template()            ) :
    46 	if     ( is_embed()          && $template = get_embed_template()          ) :
       
    47 	elseif ( is_404()            && $template = get_404_template()            ) :
    47 	elseif ( is_search()         && $template = get_search_template()         ) :
    48 	elseif ( is_search()         && $template = get_search_template()         ) :
    48 	elseif ( is_front_page()     && $template = get_front_page_template()     ) :
    49 	elseif ( is_front_page()     && $template = get_front_page_template()     ) :
    49 	elseif ( is_home()           && $template = get_home_template()           ) :
    50 	elseif ( is_home()           && $template = get_home_template()           ) :
    50 	elseif ( is_post_type_archive() && $template = get_post_type_archive_template() ) :
    51 	elseif ( is_post_type_archive() && $template = get_post_type_archive_template() ) :
    51 	elseif ( is_tax()            && $template = get_taxonomy_template()       ) :
    52 	elseif ( is_tax()            && $template = get_taxonomy_template()       ) :
    52 	elseif ( is_attachment()     && $template = get_attachment_template()     ) :
    53 	elseif ( is_attachment()     && $template = get_attachment_template()     ) :
    53 		remove_filter('the_content', 'prepend_attachment');
    54 		remove_filter('the_content', 'prepend_attachment');
    54 	elseif ( is_single()         && $template = get_single_template()         ) :
    55 	elseif ( is_single()         && $template = get_single_template()         ) :
    55 	elseif ( is_page()           && $template = get_page_template()           ) :
    56 	elseif ( is_page()           && $template = get_page_template()           ) :
       
    57 	elseif ( is_singular()       && $template = get_singular_template()       ) :
    56 	elseif ( is_category()       && $template = get_category_template()       ) :
    58 	elseif ( is_category()       && $template = get_category_template()       ) :
    57 	elseif ( is_tag()            && $template = get_tag_template()            ) :
    59 	elseif ( is_tag()            && $template = get_tag_template()            ) :
    58 	elseif ( is_author()         && $template = get_author_template()         ) :
    60 	elseif ( is_author()         && $template = get_author_template()         ) :
    59 	elseif ( is_date()           && $template = get_date_template()           ) :
    61 	elseif ( is_date()           && $template = get_date_template()           ) :
    60 	elseif ( is_archive()        && $template = get_archive_template()        ) :
    62 	elseif ( is_archive()        && $template = get_archive_template()        ) :
    61 	elseif ( is_comments_popup() && $template = get_comments_popup_template() ) :
       
    62 	elseif ( is_paged()          && $template = get_paged_template()          ) :
       
    63 	else :
    63 	else :
    64 		$template = get_index_template();
    64 		$template = get_index_template();
    65 	endif;
    65 	endif;
    66 	/**
    66 	/**
    67 	 * Filter the path of the current template before including it.
    67 	 * Filters the path of the current template before including it.
    68 	 *
    68 	 *
    69 	 * @since 3.0.0
    69 	 * @since 3.0.0
    70 	 *
    70 	 *
    71 	 * @param string $template The path of the template to include.
    71 	 * @param string $template The path of the template to include.
    72 	 */
    72 	 */
    73 	if ( $template = apply_filters( 'template_include', $template ) )
    73 	if ( $template = apply_filters( 'template_include', $template ) ) {
    74 		include( $template );
    74 		include( $template );
       
    75 	} elseif ( current_user_can( 'switch_themes' ) ) {
       
    76 		$theme = wp_get_theme();
       
    77 		if ( $theme->errors() ) {
       
    78 			wp_die( $theme->errors() );
       
    79 		}
       
    80 	}
    75 	return;
    81 	return;
    76 endif;
    82 endif;