diff --git a/lib/full-site-editing/template-loader.php b/lib/compat/wordpress-5.9/block-template.php similarity index 95% rename from lib/full-site-editing/template-loader.php rename to lib/compat/wordpress-5.9/block-template.php index 5077d024724915..4a57ece0d8c1f6 100644 --- a/lib/full-site-editing/template-loader.php +++ b/lib/compat/wordpress-5.9/block-template.php @@ -17,7 +17,7 @@ function gutenberg_add_template_loader_filters() { if ( 'embed' === $template_type ) { // Skip 'embed' for now because it is not a regular template type. continue; } - add_filter( str_replace( '-', '', $template_type ) . '_template', 'gutenberg_override_query_template', 20, 3 ); + add_filter( str_replace( '-', '', $template_type ) . '_template', 'gutenberg_locate_block_template', 20, 3 ); } // Request to resolve a template. @@ -38,7 +38,7 @@ function gutenberg_add_template_loader_filters() { * @param array $templates A list of template candidates, in descending order of priority. * @return string The path to the Full Site Editing template canvas file. */ -function gutenberg_override_query_template( $template, $type, array $templates ) { +function gutenberg_locate_block_template( $template, $type, array $templates ) { global $_wp_current_template_content; if ( $template ) { @@ -97,11 +97,12 @@ function gutenberg_override_query_template( $template, $type, array $templates ) // Render title tag with content, regardless of whether theme has title-tag support. remove_action( 'wp_head', '_wp_render_title_tag', 1 ); // Remove conditional title tag rendering... + // Override WP 5.8 title-tag support. remove_action( 'wp_head', '_block_template_render_title_tag', 1 ); add_action( 'wp_head', 'gutenberg_render_title_tag', 1 ); // ...and make it unconditional. // This file will be included instead of the theme's template file. - return gutenberg_dir_path() . 'lib/template-canvas.php'; + return gutenberg_dir_path() . 'lib/compat/wordpress-5.9/template-canvas.php'; } /** @@ -126,7 +127,7 @@ function gutenberg_resolve_template( $template_type, $template_hierarchy, $fallb } $slugs = array_map( - 'gutenberg_strip_php_suffix', + 'gutenberg_strip_template_file_suffix', $template_hierarchy ); @@ -223,13 +224,6 @@ function gutenberg_get_the_template_html() { return '