wp/wp-includes/template-loader.php
author ymh <ymh.work@gmail.com>
Tue, 22 Oct 2019 16:11:46 +0200
changeset 15 3d4e9c994f10
parent 9 177826044cd9
child 16 a86126ab1dd4
permissions -rw-r--r--
Upgrade jquery-ui in in-motion theme version from 1.8.14 to 1.8.22 to avoid 'a.curCSS is not a function' errors in console that caused problems with circles and navigation.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * Loads the correct template based on the visitor's url
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     4
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     7
if ( wp_using_themes() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
	 * Fires before determining which template to load.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    11
	 * @since 1.5.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
	do_action( 'template_redirect' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    14
}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    17
 * Filters whether to allow 'HEAD' requests to generate content.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
 * Provides a significant performance bump by exiting before the page
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
 * content loads for 'HEAD' requests. See #14348.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
 * @since 3.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
 * @param bool $exit Whether to exit without generating any content for 'HEAD' requests. Default true.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    26
if ( 'HEAD' === $_SERVER['REQUEST_METHOD'] && apply_filters( 'exit_on_http_head', true ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
	exit();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    28
}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
// Process feeds and trackbacks even if not using themes.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
if ( is_robots() ) :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
	 * Fired when the template loader determines a robots.txt request.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
	 * @since 2.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
	do_action( 'do_robots' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
	return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
elseif ( is_feed() ) :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
	do_feed();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
	return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
elseif ( is_trackback() ) :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
	include( ABSPATH . 'wp-trackback.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
	return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
endif;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    47
if ( wp_using_themes() ) :
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
	$template = false;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    49
	if ( is_embed() && $template = get_embed_template() ) :
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    50
	elseif ( is_404() && $template = get_404_template() ) :
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    51
	elseif ( is_search() && $template = get_search_template() ) :
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    52
	elseif ( is_front_page() && $template = get_front_page_template() ) :
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    53
	elseif ( is_home() && $template = get_home_template() ) :
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    54
	elseif ( is_privacy_policy() && $template = get_privacy_policy_template() ) :
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
	elseif ( is_post_type_archive() && $template = get_post_type_archive_template() ) :
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    56
	elseif ( is_tax() && $template = get_taxonomy_template() ) :
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    57
	elseif ( is_attachment() && $template = get_attachment_template() ) :
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    58
		remove_filter( 'the_content', 'prepend_attachment' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    59
	elseif ( is_single() && $template = get_single_template() ) :
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    60
	elseif ( is_page() && $template = get_page_template() ) :
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    61
	elseif ( is_singular() && $template = get_singular_template() ) :
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    62
	elseif ( is_category() && $template = get_category_template() ) :
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    63
	elseif ( is_tag() && $template = get_tag_template() ) :
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    64
	elseif ( is_author() && $template = get_author_template() ) :
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    65
	elseif ( is_date() && $template = get_date_template() ) :
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    66
	elseif ( is_archive() && $template = get_archive_template() ) :
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
	else :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
		$template = get_index_template();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
	endif;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    71
	 * Filters the path of the current template before including it.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
	 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
	 * @param string $template The path of the template to include.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    77
	if ( $template = apply_filters( 'template_include', $template ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
		include( $template );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    79
	} elseif ( current_user_can( 'switch_themes' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    80
		$theme = wp_get_theme();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    81
		if ( $theme->errors() ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    82
			wp_die( $theme->errors() );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    83
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    84
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
	return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
endif;