Automattic\WooCommerce\EmailEditor\Engine\Templates

Templates_Registry::get_by_slugpublicWC 1.0

Retrieve a template by its slug. Example: get_by_slug( 'email-general' ) will return the instance of Template with identical slug.

Method of the class: Templates_Registry{}

No Hooks.

Returns

Template|null. The template object or null if not found.

Usage

$Templates_Registry = new Templates_Registry();
$Templates_Registry->get_by_slug( $slug ): ?Template;
$slug(string) (required)
The slug of the template.

Templates_Registry::get_by_slug() code WC 10.6.2

public function get_by_slug( string $slug ): ?Template {
	foreach ( $this->templates as $template ) {
		if ( $template->get_slug() === $slug ) {
			return $template;
		}
	}
	return null;
}