diff --git a/lib/full-site-editing/page-templates.php b/lib/full-site-editing/page-templates.php new file mode 100644 index 00000000000000..89ce31dba143f0 --- /dev/null +++ b/lib/full-site-editing/page-templates.php @@ -0,0 +1,42 @@ + $page_template ) { + if ( ( ! isset( $page_template['postTypes'] ) && 'page' === $post->post_type ) || + ( isset( $page_template['postTypes'] ) && in_array( $post->post_type, $page_template['postTypes'], true ) ) + ) { + $page_templates[ $key ] = $page_template['title']; + } + } + } + + return $page_templates; +} +add_filter( 'theme_post_templates', 'gutenberg_load_block_page_templates', 10, 3 ); +add_filter( 'theme_page_templates', 'gutenberg_load_block_page_templates', 10, 3 ); diff --git a/lib/load.php b/lib/load.php index 11cd0edfe53769..02b54459609dd6 100644 --- a/lib/load.php +++ b/lib/load.php @@ -79,6 +79,7 @@ function gutenberg_is_experiment_enabled( $name ) { require __DIR__ . '/full-site-editing.php'; require __DIR__ . '/full-site-editing/default-template-types.php'; require __DIR__ . '/full-site-editing/templates-utils.php'; +require __DIR__ . '/full-site-editing/page-templates.php'; require __DIR__ . '/templates-sync.php'; require __DIR__ . '/templates.php'; require __DIR__ . '/template-parts.php'; diff --git a/lib/template-loader.php b/lib/template-loader.php index b886a9f5ab58b6..5dc55ec88cb8f1 100644 --- a/lib/template-loader.php +++ b/lib/template-loader.php @@ -63,7 +63,6 @@ function get_template_hierarchy( $template_type ) { */ function gutenberg_override_query_template( $template, $type, array $templates = array() ) { global $_wp_current_template_content; - $current_template = gutenberg_resolve_template( $type, $templates ); if ( $current_template ) { @@ -215,7 +214,7 @@ function gutenberg_viewport_meta_tag() { * @return string Template file name without extension. */ function gutenberg_strip_php_suffix( $template_file ) { - return preg_replace( '/\.php$/', '', $template_file ); + return preg_replace( '/\.(php|html)$/', '', $template_file ); } /**