Automattic\WooCommerce\Blocks

BlockTemplatesController::add_plugin_templates_parts_support()publicWC 1.0

By default, the Template Part Block only supports template parts that are in the current theme directory. This render_callback wrapper allows us to add support for plugin-housed template parts.

Method of the class: BlockTemplatesController{}

No Hooks.

Return

null. Nothing (null).

Usage

$BlockTemplatesController = new BlockTemplatesController();
$BlockTemplatesController->add_plugin_templates_parts_support( $settings, $metadata );
$settings(array) (required)
Array of determined settings for registering a block type.
$metadata(array) (required)
Metadata provided for registering a block type.

BlockTemplatesController::add_plugin_templates_parts_support() code WC 9.4.2

public function add_plugin_templates_parts_support( $settings, $metadata ) {
	if (
		isset( $metadata['name'], $settings['render_callback'] ) &&
		'core/template-part' === $metadata['name'] &&
		in_array( $settings['render_callback'], array( 'render_block_core_template_part', 'gutenberg_render_block_core_template_part' ), true )
	) {
		$settings['render_callback'] = array( $this, 'render_woocommerce_template_part' );
	}
	return $settings;
}