WCEmailPostsCleanup.php
2 weeks ago
WCEmailScratchpadRefresher.php
2 weeks ago
WCEmailTemplateAutoApplier.php
2 months ago
WCEmailTemplateChangeSummary.php
2 months ago
WCEmailTemplateDivergenceDetector.php
2 months ago
WCEmailTemplateSelectiveApplier.php
2 months ago
WCEmailTemplateSyncBackfill.php
2 months ago
WCEmailTemplateSyncRegistry.php
4 months ago
WCEmailTemplateSyncTracker.php
2 months ago
WCTransactionalEmailPostsGenerator.php
2 weeks ago
WCTransactionalEmailPostsManager.php
2 weeks ago
WCTransactionalEmails.php
2 weeks ago
WCTransactionalEmails.php
105 lines
| 1 | <?php |
| 2 | declare(strict_types=1); |
| 3 | |
| 4 | namespace Automattic\WooCommerce\Internal\EmailEditor\WCTransactionalEmails; |
| 5 | |
| 6 | use Automattic\WooCommerce\Utilities\FeaturesUtil; |
| 7 | |
| 8 | /** |
| 9 | * Class WCTransactionalEmails |
| 10 | * |
| 11 | * Handles the initialization and management of WooCommerce transactional emails. |
| 12 | * |
| 13 | * @package Automattic\WooCommerce\Internal\EmailEditor\WCTransactionalEmails |
| 14 | */ |
| 15 | class WCTransactionalEmails { |
| 16 | |
| 17 | /** |
| 18 | * Array of core transactional email types. |
| 19 | * |
| 20 | * @var array |
| 21 | */ |
| 22 | public static $core_transactional_emails = array( |
| 23 | 'admin_payment_gateway_enabled', |
| 24 | 'cancelled_order', |
| 25 | 'customer_cancelled_order', |
| 26 | 'customer_completed_order', |
| 27 | 'customer_failed_order', |
| 28 | 'customer_invoice', |
| 29 | 'customer_new_account', |
| 30 | 'customer_note', |
| 31 | 'customer_on_hold_order', |
| 32 | 'customer_pos_completed_order', |
| 33 | 'customer_pos_refunded_order', |
| 34 | 'customer_processing_order', |
| 35 | 'customer_refunded_order', |
| 36 | 'customer_partially_refunded_order', |
| 37 | 'customer_reset_password', |
| 38 | 'customer_review_request', |
| 39 | 'customer_verify_email', |
| 40 | 'failed_order', |
| 41 | 'new_order', |
| 42 | ); |
| 43 | |
| 44 | /** |
| 45 | * Initialize the class. |
| 46 | * |
| 47 | * Email posts are no longer generated on initialization. They are created |
| 48 | * lazily (as drafts) when a user opens the email editor for a specific |
| 49 | * email type, following the WordPress Site Editor pattern where file |
| 50 | * templates are the source of truth until the user edits and saves. |
| 51 | * |
| 52 | * @internal |
| 53 | */ |
| 54 | final public function init() { |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Get the core transactional emails. |
| 59 | * |
| 60 | * @return array |
| 61 | */ |
| 62 | public static function get_core_transactional_emails() { |
| 63 | $emails = self::$core_transactional_emails; |
| 64 | |
| 65 | if ( FeaturesUtil::feature_is_enabled( 'fulfillments' ) ) { |
| 66 | $fulfillment_emails = array( |
| 67 | 'customer_fulfillment_created', |
| 68 | 'customer_fulfillment_updated', |
| 69 | 'customer_fulfillment_deleted', |
| 70 | ); |
| 71 | $emails = array_merge( $emails, $fulfillment_emails ); |
| 72 | } |
| 73 | |
| 74 | return $emails; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Get the Core WooCommerce transactional emails for the block editor. |
| 79 | * |
| 80 | * @return array |
| 81 | */ |
| 82 | public static function get_transactional_emails() { |
| 83 | $emails = self::get_core_transactional_emails(); |
| 84 | |
| 85 | /** |
| 86 | * Filter the transactional emails for the block editor. |
| 87 | * |
| 88 | * @param array $transactional_emails The transactional emails. |
| 89 | * @return array |
| 90 | * @since 9.9.0 |
| 91 | */ |
| 92 | return apply_filters( 'woocommerce_transactional_emails_for_block_editor', $emails ); |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Initialize email templates on WooCommerce admin pages. |
| 97 | * |
| 98 | * @deprecated 11.1.0 Email posts are no longer generated on admin page loads; they are created lazily when the user opens the editor. No-op, will be removed in a future version. |
| 99 | * @return void |
| 100 | */ |
| 101 | public function init_email_templates() { |
| 102 | wc_deprecated_function( __METHOD__, '11.1.0' ); |
| 103 | } |
| 104 | } |
| 105 |