Fix coming soon page fatal error with non-FSE theme (#46570)
* Fix fatal error with non-fse theme * Update conditional inclusion of header and footer templates in coming-soon-store-only.php * Update conditional inclusion of header and footer templates in ComingSoonRequestHandler.php * Remove add_theme_support( block-template-parts ); * Add changefile(s) from automation for the following project(s): woocommerce --------- Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
parent
fcfec4000e
commit
9a288fb4c2
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
|
||||
Fix coming soon page fatal error with non-FSE theme
|
|
@ -9,7 +9,12 @@
|
|||
|
||||
?>
|
||||
|
||||
<!-- wp:template-part {"slug":"header","tagName":"header"} /-->
|
||||
<?php
|
||||
if ( wc_current_theme_is_fse_theme() ) {
|
||||
echo '<!-- wp:template-part {"slug":"header","tagName":"header"} /-->';
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- wp:group {"layout":{"type":"constrained"}} -->
|
||||
<div class="wp-block-group"><!-- wp:spacer -->
|
||||
<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
|
||||
|
@ -31,5 +36,10 @@
|
|||
<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
|
||||
<!-- /wp:spacer --></div>
|
||||
<!-- /wp:group -->
|
||||
<!-- wp:template-part {"slug":"footer","tagName":"footer"} /-->
|
||||
|
||||
|
||||
<?php
|
||||
if ( wc_current_theme_is_fse_theme() ) {
|
||||
echo '<!-- wp:template-part {"slug":"footer","tagName":"footer"} /-->';
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -3,6 +3,7 @@ namespace Automattic\WooCommerce\Blocks;
|
|||
|
||||
use Automattic\WooCommerce\Blocks\Templates\ProductCatalogTemplate;
|
||||
use Automattic\WooCommerce\Blocks\Utils\BlockTemplateUtils;
|
||||
use Automattic\WooCommerce\Blocks\Templates\ComingSoonTemplate;
|
||||
|
||||
/**
|
||||
* BlockTypesController class.
|
||||
|
@ -331,12 +332,13 @@ class BlockTemplatesController {
|
|||
* @return array
|
||||
*/
|
||||
public function add_block_templates( $query_result, $query, $template_type ) {
|
||||
if ( ! BlockTemplateUtils::supports_block_templates( $template_type ) ) {
|
||||
$slugs = isset( $query['slug__in'] ) ? $query['slug__in'] : array();
|
||||
|
||||
if ( ! BlockTemplateUtils::supports_block_templates( $template_type ) && ! in_array( ComingSoonTemplate::SLUG, $slugs, true ) ) {
|
||||
return $query_result;
|
||||
}
|
||||
|
||||
$post_type = isset( $query['post_type'] ) ? $query['post_type'] : '';
|
||||
$slugs = isset( $query['slug__in'] ) ? $query['slug__in'] : array();
|
||||
$template_files = $this->get_block_templates( $slugs, $template_type );
|
||||
$theme_slug = wp_get_theme()->get_stylesheet();
|
||||
|
||||
|
|
|
@ -53,7 +53,9 @@ class BlockTemplatesRegistry {
|
|||
SingleProductTemplate::SLUG => new SingleProductTemplate(),
|
||||
);
|
||||
} else {
|
||||
$templates = array();
|
||||
$templates = array(
|
||||
ComingSoonTemplate::SLUG => new ComingSoonTemplate(),
|
||||
);
|
||||
}
|
||||
if ( BlockTemplateUtils::supports_block_templates( 'wp_template_part' ) ) {
|
||||
$template_parts = array(
|
||||
|
|
|
@ -66,10 +66,20 @@ class ComingSoonRequestHandler {
|
|||
|
||||
// A coming soon page needs to be displayed. Don't cache this response.
|
||||
nocache_headers();
|
||||
add_theme_support( 'block-templates' );
|
||||
|
||||
$template = get_query_template( 'coming-soon' );
|
||||
|
||||
if ( ! wc_current_theme_is_fse_theme() && $this->coming_soon_helper->is_store_coming_soon() ) {
|
||||
get_header();
|
||||
}
|
||||
|
||||
include $template;
|
||||
|
||||
if ( ! wc_current_theme_is_fse_theme() && $this->coming_soon_helper->is_store_coming_soon() ) {
|
||||
get_footer();
|
||||
}
|
||||
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue