Automattic\WooCommerce\Blocks

BlockTemplatesController::dont_load_templates_for_suggestionspublicWC 1.0

When creating a template from the WP suggestion, don't load the templates with the WooCommerce slug. Otherwise they take precedence and the new template can't be created.

Method of the class: BlockTemplatesController{}

No Hooks.

Returns

null. Nothing (null).

Usage

$BlockTemplatesController = new BlockTemplatesController();
$BlockTemplatesController->dont_load_templates_for_suggestions( $prepared_post );
$prepared_post(stdClass) (required)
An object representing a single post prepared for inserting or updating the database.

BlockTemplatesController::dont_load_templates_for_suggestions() code WC 10.3.6

public function dont_load_templates_for_suggestions( $prepared_post ) {
	if ( isset( $prepared_post->meta_input['is_wp_suggestion'] ) ) {
		remove_filter( 'get_block_templates', array( $this, 'add_db_templates_with_woo_slug' ), 10, 3 );
	}
	return $prepared_post;
}