Ticket #6801: 6801.3.diff

File 6801.3.diff, 2.4 KB (added by Denis-de-Bernardy, 3 years ago)
Line 
1Index: wp-includes/template-loader.php
2===================================================================
3--- wp-includes/template-loader.php     (revision 13536)
4+++ wp-includes/template-loader.php     (working copy)
5@@ -23,6 +23,7 @@
6        if     ( is_404()            && $template = get_404_template()            ) :
7        elseif ( is_search()         && $template = get_search_template()         ) :
8        elseif ( is_tax()            && $template = get_taxonomy_template()       ) :
9+       elseif ( is_front_page()     && $template = get_front_page_template()     ) :
10        elseif ( is_home()           && $template = get_home_template()           ) :
11        elseif ( is_attachment()     && $template = get_attachment_template()     ) :
12                remove_filter('the_content', 'prepend_attachment');
13@@ -43,4 +44,4 @@
14        return;
15 endif;
16 
17-?>
18\ No newline at end of file
19+?>
20Index: wp-includes/theme.php
21===================================================================
22--- wp-includes/theme.php       (revision 13536)
23+++ wp-includes/theme.php       (working copy)
24@@ -847,6 +847,36 @@
25 }
26 
27 /**
28+ * Retrieve path of front-page template in current or parent template.
29+ *
30+ * First attempt is to look for a page specific template either based on
31+ * the '_wp_page_template' page meta, the page slug and the page id.
32+ * The second attempt is to look for 'front-page.php' before falling back
33+ * to 'page.php' and ultimately falling back to 'index.php' if none of
34+ * these exist.
35+ *
36+ * @since 3.0.0
37+ * @uses apply_filters() Calls 'front_page_template' on file path of template.
38+ *
39+ * @return string
40+ */
41+function get_front_page_template() {
42+       global $wp_query;
43+
44+       $templates = array();
45+       $templates[] = "front-page.php";
46+
47+       // If we are showing a page on the front give priority to the page specific templates.
48+       if ( 'page' == get_option('show_on_front') ) {
49+               $templates[] = basename(get_page_template());
50+       } else if ( 'posts' == get_option('show_on_front') ) {
51+               $templates[] = basename(get_home_template());
52+       }
53+
54+       return apply_filters('front_page_template', locate_template($templates));
55+}
56+
57+/**
58  * Retrieve path of page template in current or parent template.
59  *
60  * Will first look for the specifically assigned page template
61@@ -983,6 +1013,8 @@
62 
63        $located = '';
64        foreach ( $template_names as $template_name ) {
65+               if ( !$template_name )
66+                       continue;
67                if ( file_exists(STYLESHEETPATH . '/' . $template_name)) {
68                        $located = STYLESHEETPATH . '/' . $template_name;
69                        break;