WooEmailContentPattern.php
92 lines
| 1 | <?php declare(strict_types = 1); |
| 2 | |
| 3 | namespace Automattic\WooCommerce\Internal\EmailEditor\EmailPatterns; |
| 4 | |
| 5 | use Automattic\WooCommerce\EmailEditor\Engine\Patterns\Abstract_Pattern; |
| 6 | use Automattic\WooCommerce\Internal\EmailEditor\Integration; |
| 7 | |
| 8 | /** |
| 9 | * Pattern class for WooCommerce email content. |
| 10 | * |
| 11 | * Provides a default content pattern that can be used in WooCommerce email templates. |
| 12 | */ |
| 13 | class WooEmailContentPattern extends Abstract_Pattern { |
| 14 | /** |
| 15 | * Pattern name identifier. |
| 16 | * |
| 17 | * @var string |
| 18 | */ |
| 19 | public $name = 'woo-email-content-pattern'; |
| 20 | |
| 21 | /** |
| 22 | * Allowed block types for this pattern. |
| 23 | * |
| 24 | * @var array |
| 25 | */ |
| 26 | public $block_types = array(); |
| 27 | |
| 28 | /** |
| 29 | * Template types where this pattern can be used. |
| 30 | * |
| 31 | * @var array |
| 32 | */ |
| 33 | public $template_types = array( 'email-template' ); // Required. |
| 34 | |
| 35 | /** |
| 36 | * Categories this pattern belongs to. |
| 37 | * |
| 38 | * @var array |
| 39 | */ |
| 40 | public $categories = array( 'email-contents' ); // Optional. |
| 41 | |
| 42 | /** |
| 43 | * Pattern namespace. |
| 44 | * |
| 45 | * @var string |
| 46 | */ |
| 47 | public $namespace = 'woocommerce'; // Required. |
| 48 | |
| 49 | /** |
| 50 | * List of supported post types. |
| 51 | * |
| 52 | * @var string[] |
| 53 | */ |
| 54 | protected $post_types = array( Integration::EMAIL_POST_TYPE ); |
| 55 | /** |
| 56 | * Get the pattern content. |
| 57 | * |
| 58 | * @return string HTML content for the pattern. |
| 59 | */ |
| 60 | public function get_content(): string { |
| 61 | return '<!-- wp:group {"style":{"spacing":{"padding":{"right":"var:preset|spacing|20","left":"var:preset|spacing|20"}}},"layout":{"type":"constrained"}} --> |
| 62 | <div class="wp-block-group" style="padding-right:var(--wp--preset--spacing--20);padding-left:var(--wp--preset--spacing--20)"><!-- wp:heading --> |
| 63 | <h2 class="wp-block-heading">Woo Email Content</h2> |
| 64 | <!-- /wp:heading --> |
| 65 | |
| 66 | <!-- wp:paragraph --> |
| 67 | <p>Here comes content composed of supported core blocks and Woo transactional email block(s).</p> |
| 68 | <!-- /wp:paragraph --> |
| 69 | |
| 70 | <!-- wp:woocommerce/email-content {"lock":{"move":false,"remove":true}} --> |
| 71 | <div class="wp-block-woocommerce-email-content">##WOO_CONTENT##</div> |
| 72 | <!-- /wp:woocommerce/email-content --> |
| 73 | |
| 74 | <!-- wp:buttons {"layout":{"justifyContent":"center"}} --> |
| 75 | <div class="wp-block-buttons"><!-- wp:button {"style":{"color":{"background":"#873eff"}}} --> |
| 76 | <div class="wp-block-button"><a class="wp-block-button__link has-background wp-element-button" style="background-color:#873eff">Shop now</a></div> |
| 77 | <!-- /wp:button --></div> |
| 78 | <!-- /wp:buttons --></div> |
| 79 | <!-- /wp:group -->'; |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Get the pattern title. |
| 84 | * |
| 85 | * @return string Localized pattern title. |
| 86 | */ |
| 87 | public function get_title(): string { |
| 88 | /* translators: Name of a content pattern used as starting content of an email */ |
| 89 | return __( 'Woo Email Content Pattern', 'woocommerce' ); |
| 90 | } |
| 91 | } |
| 92 |