MailPoet\EmailEditor\Engine\Templates

Templates_Registry::register()publicWC 1.0

Register a template instance in the registry.

Method of the class: Templates_Registry{}

No Hooks.

Return

null. Nothing (null).

Usage

$Templates_Registry = new Templates_Registry();
$Templates_Registry->register( $template ): void;
$template(Template) (required)
The template to register.

Templates_Registry::register() code WC 9.8.2

public function register( Template $template ): void {
	// The function was added in WordPress 6.7. We can remove this check after we drop support for WordPress 6.6.
	if ( ! function_exists( 'register_block_template' ) ) {
		return;
	}

	if ( ! \WP_Block_Templates_Registry::get_instance()->is_registered( $template->get_name() ) ) {
		// skip registration if the template was already registered.
		register_block_template(
			$template->get_name(),
			array(
				'title'       => $template->get_title(),
				'description' => $template->get_description(),
				'content'     => $template->get_content(),
				'post_types'  => $template->get_post_types(),
			)
		);
		$this->templates[ $template->get_name() ] = $template;
	}
}