class-template.php
1 year ago
class-templates-registry.php
1 year ago
class-templates.php
2 months ago
email-general.html
5 months ago
single-email-post-template.php
1 year ago
class-template.php
143 lines
| 1 | <?php |
| 2 | /** |
| 3 | * This file is part of the WooCommerce Email Editor package. |
| 4 | * |
| 5 | * @package Automattic\WooCommerce\EmailEditor |
| 6 | */ |
| 7 | |
| 8 | declare(strict_types = 1); |
| 9 | |
| 10 | namespace Automattic\WooCommerce\EmailEditor\Engine\Templates; |
| 11 | |
| 12 | /** |
| 13 | * The class represents a template |
| 14 | */ |
| 15 | class Template { |
| 16 | /** |
| 17 | * Plugin uri used in the template name. |
| 18 | * |
| 19 | * @var string $plugin_uri |
| 20 | */ |
| 21 | private string $plugin_uri; |
| 22 | /** |
| 23 | * The template slug used in the template name. |
| 24 | * |
| 25 | * @var string $slug |
| 26 | */ |
| 27 | private string $slug; |
| 28 | /** |
| 29 | * The template name used for block template registration. |
| 30 | * |
| 31 | * @var string $name |
| 32 | */ |
| 33 | private string $name; |
| 34 | /** |
| 35 | * The template title. |
| 36 | * |
| 37 | * @var string $title |
| 38 | */ |
| 39 | private string $title; |
| 40 | /** |
| 41 | * The template description. |
| 42 | * |
| 43 | * @var string $description |
| 44 | */ |
| 45 | private string $description; |
| 46 | /** |
| 47 | * The template content. |
| 48 | * |
| 49 | * @var string $content |
| 50 | */ |
| 51 | private string $content; |
| 52 | /** |
| 53 | * The list of supoorted post types. |
| 54 | * |
| 55 | * @var string[] |
| 56 | */ |
| 57 | private array $post_types; |
| 58 | |
| 59 | /** |
| 60 | * Constructor of the class. |
| 61 | * |
| 62 | * @param string $plugin_uri The plugin uri. |
| 63 | * @param string $slug The template slug. |
| 64 | * @param string $title The template title. |
| 65 | * @param string $description The template description. |
| 66 | * @param string $content The template content. |
| 67 | * @param string[] $post_types The list of post types supported by the template. |
| 68 | */ |
| 69 | public function __construct( |
| 70 | string $plugin_uri, |
| 71 | string $slug, |
| 72 | string $title, |
| 73 | string $description, |
| 74 | string $content, |
| 75 | array $post_types = array() |
| 76 | ) { |
| 77 | $this->plugin_uri = $plugin_uri; |
| 78 | $this->slug = $slug; |
| 79 | $this->name = "{$plugin_uri}//{$slug}"; // The template name is composed from the namespace and the slug. |
| 80 | $this->title = $title; |
| 81 | $this->description = $description; |
| 82 | $this->content = $content; |
| 83 | $this->post_types = $post_types; |
| 84 | } |
| 85 | /** |
| 86 | * Get the plugin uri. |
| 87 | * |
| 88 | * @return string |
| 89 | */ |
| 90 | public function get_pluginuri(): string { |
| 91 | return $this->plugin_uri; |
| 92 | } |
| 93 | /** |
| 94 | * Get the template slug. |
| 95 | * |
| 96 | * @return string |
| 97 | */ |
| 98 | public function get_slug(): string { |
| 99 | return $this->slug; |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Get the template name composed from the plugin_uri and the slug. |
| 104 | * |
| 105 | * @return string |
| 106 | */ |
| 107 | public function get_name(): string { |
| 108 | return $this->name; |
| 109 | } |
| 110 | /** |
| 111 | * Get the template title. |
| 112 | * |
| 113 | * @return string |
| 114 | */ |
| 115 | public function get_title(): string { |
| 116 | return $this->title; |
| 117 | } |
| 118 | /** |
| 119 | * Get the template description. |
| 120 | * |
| 121 | * @return string |
| 122 | */ |
| 123 | public function get_description(): string { |
| 124 | return $this->description; |
| 125 | } |
| 126 | /** |
| 127 | * Get the template content. |
| 128 | * |
| 129 | * @return string |
| 130 | */ |
| 131 | public function get_content(): string { |
| 132 | return $this->content; |
| 133 | } |
| 134 | /** |
| 135 | * Get the list of supported post types. |
| 136 | * |
| 137 | * @return string[] |
| 138 | */ |
| 139 | public function get_post_types(): array { |
| 140 | return $this->post_types; |
| 141 | } |
| 142 | } |
| 143 |