Automattic\WooCommerce\Internal\Admin\BlockTemplateRegistry

TemplateTransformer::transform()publicWC 1.0

Transform the WooCommerceBlockTemplate to a WP_Block_Template.
*

  • @param object $block_template The product template.

Метод класса: TemplateTransformer{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$TemplateTransformer = new TemplateTransformer();
$TemplateTransformer->transform( $block_template ): \WP_Block_Template;
$block_template(BlockTemplateInterface) (обязательный)
-

Код TemplateTransformer::transform() WC 8.1.1

public function transform( BlockTemplateInterface $block_template ): \WP_Block_Template {
	$template                 = new \WP_Block_Template();
	$template->id             = $block_template->get_id();
	$template->theme          = 'woocommerce/woocommerce';
	$template->content        = $block_template->get_formatted_template();
	$template->source         = 'plugin';
	$template->slug           = $block_template->get_id();
	$template->type           = 'wp_template';
	$template->title          = $block_template->get_title();
	$template->description    = $block_template->get_description();
	$template->status         = 'publish';
	$template->has_theme_file = true;
	$template->origin         = 'plugin';
	$template->is_custom      = false; // Templates loaded from the filesystem aren't custom, ones that have been edited and loaded from the DB are.
	$template->post_types     = array(); // Don't appear in any Edit Post template selector dropdown.
	$template->area           = $block_template->get_area();

	return $template;
}