Fix: Display the correct title for templates from theme (https://github.com/woocommerce/woocommerce-blocks/pull/6452)
This commit is contained in:
parent
138df96762
commit
aadb94c012
|
@ -184,6 +184,28 @@ class BlockTemplatesController {
|
|||
// We need to remove theme (i.e. filesystem) templates that have the same slug as a customised one.
|
||||
// This only affects saved templates that were saved BEFORE a theme template with the same slug was added.
|
||||
$query_result = BlockTemplateUtils::remove_theme_templates_with_custom_alternative( $query_result );
|
||||
|
||||
/**
|
||||
* WC templates from theme aren't included in `$this->get_block_templates()` but are handled by Gutenberg.
|
||||
* We need to do additional search through all templates file to update title and description for WC
|
||||
* templates that aren't listed in theme.json.
|
||||
*/
|
||||
$query_result = array_map(
|
||||
function( $template ) {
|
||||
if ( 'theme' === $template->origin ) {
|
||||
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;
|
||||
},
|
||||
$query_result
|
||||
);
|
||||
|
||||
return $query_result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue