MailPoet\EmailEditor\Engine\Templates

Templates_Registry::get_by_slug()publicWC 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.

Return

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 9.8.1

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