TemplateApiController.php
5 months ago
TemplatesController.php
1 year ago
WooEmailTemplate.php
2 months ago
WooEmailTemplate.php
86 lines
| 1 | <?php declare(strict_types = 1); |
| 2 | |
| 3 | namespace Automattic\WooCommerce\Internal\EmailEditor\EmailTemplates; |
| 4 | |
| 5 | /** |
| 6 | * Basic template for WooCommerce transactional emails used in the email editor. |
| 7 | */ |
| 8 | class WooEmailTemplate { |
| 9 | /** |
| 10 | * The template slug. |
| 11 | */ |
| 12 | public const TEMPLATE_SLUG = 'wooemailtemplate'; |
| 13 | |
| 14 | /** |
| 15 | * Get the template slug. |
| 16 | * |
| 17 | * @return string Template identifier. |
| 18 | */ |
| 19 | public function get_slug(): string { |
| 20 | return self::TEMPLATE_SLUG; |
| 21 | } |
| 22 | |
| 23 | /** |
| 24 | * Get the template title. |
| 25 | * |
| 26 | * @return string Localized template title. |
| 27 | */ |
| 28 | public function get_title(): string { |
| 29 | return __( 'Woo Email Template', 'woocommerce' ); |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Get the template description. |
| 34 | * |
| 35 | * @return string Localized template description. |
| 36 | */ |
| 37 | public function get_description(): string { |
| 38 | return __( 'Basic template for WooCommerce transactional emails used in the email editor', 'woocommerce' ); |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Get the template content. |
| 43 | * |
| 44 | * @return string HTML content for the template. |
| 45 | */ |
| 46 | public function get_content(): string { |
| 47 | return ' |
| 48 | <!-- wp:group {"style":{"spacing":{"padding":{"top":"var:preset|spacing|10","bottom":"var:preset|spacing|10","left":"var:preset|spacing|20","right":"var:preset|spacing|20"}}},"layout":{"type":"constrained"}} --> |
| 49 | <div class="wp-block-group" style="padding-top:var(--wp--preset--spacing--10);padding-right:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--10);padding-left:var(--wp--preset--spacing--20)"> |
| 50 | ' . $this->get_site_logo_or_title() . ' |
| 51 | |
| 52 | <!-- wp:group {"layout":{"type":"constrained"}} --> |
| 53 | <div class="wp-block-group"> |
| 54 | <!-- wp:post-content {"lock":{"move":true,"remove":true},"layout":{"type":"default"}} /--> |
| 55 | </div> |
| 56 | <!-- /wp:group --> |
| 57 | |
| 58 | <!-- wp:group {"style":{"spacing":{"padding":{"right":"0","left":"0","top":"var:preset|spacing|10","bottom":"var:preset|spacing|10"}}}} --> |
| 59 | <div class="wp-block-group" style="padding-top:var(--wp--preset--spacing--10);padding-right:0;padding-bottom:var(--wp--preset--spacing--10);padding-left:0"><!-- wp:paragraph {"align":"center","style":{"border":{"top":{"color":"var:preset|color|cyan-bluish-gray","width":"1px","style":"solid"},"right":[],"bottom":[],"left":[]},"spacing":{"padding":{"top":"var:preset|spacing|20","bottom":"var:preset|spacing|20"}},"color":{"text":"#787c82"},"elements":{"link":{"color":{"text":"#787c82"}}}},"fontSize":"small"} --> |
| 60 | <p class="has-text-align-center has-text-color has-link-color has-small-font-size" style="border-top-color:var(--wp--preset--color--cyan-bluish-gray);border-top-style:solid;border-top-width:1px;color:#787c82;padding-top:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--20)">© <!--[woocommerce/store-name]-->. ' . esc_html__( 'All Rights Reserved.', 'woocommerce' ) . '<br><!--[woocommerce/store-address]--> </p> |
| 61 | <!-- /wp:paragraph --></div> |
| 62 | <!-- /wp:group --> |
| 63 | </div> |
| 64 | <!-- /wp:group --> |
| 65 | '; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Get the site logo or title. |
| 70 | * |
| 71 | * This is used to display the site logo or title in the email template. |
| 72 | * |
| 73 | * @return string HTML content for the site logo or title. |
| 74 | */ |
| 75 | private function get_site_logo_or_title(): string { |
| 76 | $custom_logo = get_custom_logo(); |
| 77 | |
| 78 | if ( ! empty( $custom_logo ) ) { |
| 79 | // Use Site logo if available. |
| 80 | return '<!-- wp:site-logo {"width":130,"isLink":false,"align":"center","style":{"spacing":{"padding":{"top":"var:preset|spacing|10","bottom":"var:preset|spacing|10"}}}} /-->'; |
| 81 | } |
| 82 | |
| 83 | return '<!-- wp:site-title {"level":2,"style":{"spacing":{"padding":{"top":"var:preset|spacing|10","bottom":"var:preset|spacing|10"}}}} /-->'; |
| 84 | } |
| 85 | } |
| 86 |