BlockTemplateUtils::create_new_block_template_object()public staticWC 1.0

Build a new template object so that we can make Woo Blocks default templates available in the current theme should they not have any.

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

Хуков нет.


Объект. Block template object.


$result = BlockTemplateUtils::create_new_block_template_object( $template_file, $template_type, $template_slug, $template_is_from_theme );
$template_file(строка) (обязательный)
Block template file path.
$template_type(строка) (обязательный)
wp_template or wp_template_part.
$template_slug(строка) (обязательный)
Block template slug e.g. single-product.
If the block template file is being loaded from the current theme instead of Woo Blocks.
По умолчанию: false

Код BlockTemplateUtils::create_new_block_template_object() WC 7.1.0

public static function create_new_block_template_object( $template_file, $template_type, $template_slug, $template_is_from_theme = false ) {
	$theme_name = wp_get_theme()->get( 'TextDomain' );

	$new_template_item = array(
		'slug'        => $template_slug,
		'id'          => $template_is_from_theme ? $theme_name . '//' . $template_slug : self::PLUGIN_SLUG . '//' . $template_slug,
		'path'        => $template_file,
		'type'        => $template_type,
		'theme'       => $template_is_from_theme ? $theme_name : self::PLUGIN_SLUG,
		// Plugin was agreed as a valid source value despite existing inline docs at the time of creating:
		'source'      => $template_is_from_theme ? 'theme' : 'plugin',
		'title'       => self::get_block_template_title( $template_slug ),
		'description' => self::get_block_template_description( $template_slug ),
		'post_types'  => array(), // Don't appear in any Edit Post template selector dropdown.

	return (object) $new_template_item;