@@ -61,12 +61,12 @@ public function __construct() {
6161 $ this ->form_id = isset ( $ _GET ['form_id ' ] ) ? intval ( $ _GET ['form_id ' ] ) : 0 ;
6262 }
6363
64- add_action ( 'pre_get_posts ' , [ $ this , 'pre_get_posts ' ] );
65- add_filter ( 'template_include ' , [ $ this , 'template_include ' ] );
66-
67- add_filter ( 'the_title ' , [ $ this , 'the_title ' ] );
68- add_filter ( 'the_content ' , [ $ this , 'the_content ' ] );
69- add_filter ( 'get_the_excerpt ' , [ $ this , 'the_content ' ] );
64+ add_action ( 'pre_get_posts ' , array ( $ this , 'pre_get_posts ' ) );
65+ add_filter ( 'the_title ' , array ( $ this , 'the_title ' ) );
66+ add_filter ( ' the_content ' , array ( $ this , ' the_content ' ) );
67+ add_filter ( 'get_the_excerpt ' , array ( $ this , 'the_content ' ) );
68+ add_filter ( 'home_template_hierarchy ' , array ( $ this , 'use_page_template_hierarchy ' ) );
69+ add_filter ( 'frontpage_template_hierarchy ' , array ( $ this , 'use_page_template_hierarchy ' ) );
7070 add_filter ( 'post_thumbnail_html ' , '__return_empty_string ' );
7171 }
7272
@@ -129,12 +129,31 @@ public function pre_get_posts( $query ) {
129129 }
130130 }
131131
132+
133+ /**
134+ * Use page template types.
135+ *
136+ * Instead of just locating one page template with the highest priority,
137+ * we are going to look for any page template that matches 'page.php', 'single.php' or 'index.php'.
138+ * This resolves issues with Block Based themes that do not have a index.php.
139+ *
140+ * @since 1.6.12
141+ * @param array $templates The list of templates in descending order of priority from WordPress.
142+ *
143+ * @return array
144+ */
145+ public function use_page_template_hierarchy ( $ templates ) {
146+
147+ return array ( 'page.php ' , 'single.php ' , 'index.php ' );
148+ }
132149 /**
133150 * Limit the page templates to singular pages only
134151 *
152+ * @deprecated 1.6.11
135153 * @return string
136154 */
137- public function template_include () {
138- return locate_template ( [ 'page.php ' , 'single.php ' , 'index.php ' ] );
155+ public function template_include ( ) {
156+ _deprecated_function ( __METHOD__ , 'WeForms 1.6.11 ' );
157+ return locate_template ( array ( 'page.php ' , 'single.php ' , 'index.php ' ) );
139158 }
140159}
0 commit comments