Single Product Template: fix Compatibility Layer when the template implements the Single Product Template (https://github.com/woocommerce/woocommerce-blocks/pull/9723)
This commit is contained in:
parent
b8fdeb4b68
commit
eddaf34918
|
@ -313,16 +313,6 @@ class BlockTemplatesController {
|
||||||
*/
|
*/
|
||||||
$query_result = array_map(
|
$query_result = array_map(
|
||||||
function( $template ) {
|
function( $template ) {
|
||||||
if ( 'theme' === $template->origin && BlockTemplateUtils::template_has_title( $template ) ) {
|
|
||||||
return $template;
|
|
||||||
}
|
|
||||||
if ( $template->title === $template->slug ) {
|
|
||||||
$template->title = BlockTemplateUtils::get_block_template_title( $template->slug );
|
|
||||||
}
|
|
||||||
if ( ! $template->description ) {
|
|
||||||
$template->description = BlockTemplateUtils::get_block_template_description( $template->slug );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( str_contains( $template->slug, 'single-product' ) ) {
|
if ( str_contains( $template->slug, 'single-product' ) ) {
|
||||||
// We don't want to add the compatibility layer on the Editor Side.
|
// We don't want to add the compatibility layer on the Editor Side.
|
||||||
// The second condition is necessary to not apply the compatibility layer on the REST API. Gutenberg uses the REST API to clone the template.
|
// The second condition is necessary to not apply the compatibility layer on the REST API. Gutenberg uses the REST API to clone the template.
|
||||||
|
@ -339,8 +329,17 @@ class BlockTemplatesController {
|
||||||
$new_content = SingleProductTemplateCompatibility::add_compatibility_layer( $template->content );
|
$new_content = SingleProductTemplateCompatibility::add_compatibility_layer( $template->content );
|
||||||
$template->content = $new_content;
|
$template->content = $new_content;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( 'theme' === $template->origin && BlockTemplateUtils::template_has_title( $template ) ) {
|
||||||
return $template;
|
return $template;
|
||||||
}
|
}
|
||||||
|
if ( $template->title === $template->slug ) {
|
||||||
|
$template->title = BlockTemplateUtils::get_block_template_title( $template->slug );
|
||||||
|
}
|
||||||
|
if ( ! $template->description ) {
|
||||||
|
$template->description = BlockTemplateUtils::get_block_template_description( $template->slug );
|
||||||
|
}
|
||||||
|
|
||||||
return $template;
|
return $template;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue