Automattic\WooCommerce\Blocks\Utils
BlockTemplateUtils::update_template_data
Updates the title, description and area of a template to the correct values and to make them more user-friendly. For example, instead of:
- Title: Tag (product_tag)
- Description: Displays taxonomy: Tag. we display:
- Title: Products by Tag
- Description: Displays products filtered by a tag..
Method of the class: BlockTemplateUtils{}
No Hooks.
Returns
WP_Block_Template
.
Usage
$result = BlockTemplateUtils::update_template_data( $template, $template_type );
- $template(WP_Block_Template) (required)
- The template object.
- $template_type(string) (required)
- wp_template or wp_template_part.
BlockTemplateUtils::update_template_data() BlockTemplateUtils::update template data code WC 9.9.5
public static function update_template_data( $template, $template_type ) { if ( ! $template ) { return $template; } if ( empty( $template->title ) || $template->title === $template->slug ) { $template->title = self::get_block_template_title( $template->slug ); } if ( empty( $template->description ) ) { $template->description = self::get_block_template_description( $template->slug ); } if ( empty( $template->area ) || 'uncategorized' === $template->area ) { $template->area = self::get_block_template_area( $template->slug, $template_type ); } return $template; }