author | ymh <ymh.work@gmail.com> |
Mon, 14 Oct 2019 18:28:13 +0200 | |
changeset 9 | 177826044cd9 |
parent 7 | cf61fcea0001 |
child 16 | a86126ab1dd4 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* Loads the correct template based on the visitor's url |
|
9 | 4 |
* |
0 | 5 |
* @package WordPress |
6 |
*/ |
|
9 | 7 |
if ( wp_using_themes() ) { |
0 | 8 |
/** |
9 |
* Fires before determining which template to load. |
|
10 |
* |
|
5 | 11 |
* @since 1.5.0 |
0 | 12 |
*/ |
13 |
do_action( 'template_redirect' ); |
|
9 | 14 |
} |
0 | 15 |
|
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 | 18 |
* |
19 |
* Provides a significant performance bump by exiting before the page |
|
20 |
* content loads for 'HEAD' requests. See #14348. |
|
21 |
* |
|
22 |
* @since 3.5.0 |
|
23 |
* |
|
24 |
* @param bool $exit Whether to exit without generating any content for 'HEAD' requests. Default true. |
|
25 |
*/ |
|
9 | 26 |
if ( 'HEAD' === $_SERVER['REQUEST_METHOD'] && apply_filters( 'exit_on_http_head', true ) ) { |
0 | 27 |
exit(); |
9 | 28 |
} |
0 | 29 |
|
30 |
// Process feeds and trackbacks even if not using themes. |
|
31 |
if ( is_robots() ) : |
|
32 |
/** |
|
33 |
* Fired when the template loader determines a robots.txt request. |
|
34 |
* |
|
35 |
* @since 2.1.0 |
|
36 |
*/ |
|
37 |
do_action( 'do_robots' ); |
|
38 |
return; |
|
39 |
elseif ( is_feed() ) : |
|
40 |
do_feed(); |
|
41 |
return; |
|
42 |
elseif ( is_trackback() ) : |
|
43 |
include( ABSPATH . 'wp-trackback.php' ); |
|
44 |
return; |
|
45 |
endif; |
|
46 |
||
9 | 47 |
if ( wp_using_themes() ) : |
0 | 48 |
$template = false; |
9 | 49 |
if ( is_embed() && $template = get_embed_template() ) : |
50 |
elseif ( is_404() && $template = get_404_template() ) : |
|
51 |
elseif ( is_search() && $template = get_search_template() ) : |
|
52 |
elseif ( is_front_page() && $template = get_front_page_template() ) : |
|
53 |
elseif ( is_home() && $template = get_home_template() ) : |
|
54 |
elseif ( is_privacy_policy() && $template = get_privacy_policy_template() ) : |
|
0 | 55 |
elseif ( is_post_type_archive() && $template = get_post_type_archive_template() ) : |
9 | 56 |
elseif ( is_tax() && $template = get_taxonomy_template() ) : |
57 |
elseif ( is_attachment() && $template = get_attachment_template() ) : |
|
58 |
remove_filter( 'the_content', 'prepend_attachment' ); |
|
59 |
elseif ( is_single() && $template = get_single_template() ) : |
|
60 |
elseif ( is_page() && $template = get_page_template() ) : |
|
61 |
elseif ( is_singular() && $template = get_singular_template() ) : |
|
62 |
elseif ( is_category() && $template = get_category_template() ) : |
|
63 |
elseif ( is_tag() && $template = get_tag_template() ) : |
|
64 |
elseif ( is_author() && $template = get_author_template() ) : |
|
65 |
elseif ( is_date() && $template = get_date_template() ) : |
|
66 |
elseif ( is_archive() && $template = get_archive_template() ) : |
|
0 | 67 |
else : |
68 |
$template = get_index_template(); |
|
69 |
endif; |
|
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 | 72 |
* |
73 |
* @since 3.0.0 |
|
74 |
* |
|
75 |
* @param string $template The path of the template to include. |
|
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 | 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 | 85 |
return; |
86 |
endif; |