Engine
2 days ago
Integrations
2 days ago
Validator
11 months ago
class-bootstrap.php
3 months ago
class-container.php
9 months ago
class-email-css-inliner.php
9 months ago
class-email-editor-container.php
5 months ago
class-package.php
11 months ago
exceptions.php
11 months ago
index.php
11 months ago
class-bootstrap.php
62 lines
| 1 | <?php |
| 2 | declare( strict_types = 1 ); |
| 3 | namespace Automattic\WooCommerce\EmailEditor; |
| 4 | if (!defined('ABSPATH')) exit; |
| 5 | use Automattic\WooCommerce\EmailEditor\Engine\Email_Editor; |
| 6 | use Automattic\WooCommerce\EmailEditor\Integrations\Core\Initializer as CoreEmailEditorIntegration; |
| 7 | use Automattic\WooCommerce\EmailEditor\Integrations\WooCommerce\Coupon_Code_Generator; |
| 8 | use Automattic\WooCommerce\EmailEditor\Integrations\WooCommerce\Initializer as WooCommerceEmailEditorIntegration; |
| 9 | class Bootstrap { |
| 10 | private $email_editor; |
| 11 | private $core_email_editor_integration; |
| 12 | private $woocommerce_email_editor_integration; |
| 13 | public function __construct( |
| 14 | Email_Editor $email_editor, |
| 15 | CoreEmailEditorIntegration $core_email_editor_integration, |
| 16 | WooCommerceEmailEditorIntegration $woocommerce_email_editor_integration |
| 17 | ) { |
| 18 | $this->email_editor = $email_editor; |
| 19 | $this->core_email_editor_integration = $core_email_editor_integration; |
| 20 | $this->woocommerce_email_editor_integration = $woocommerce_email_editor_integration; |
| 21 | } |
| 22 | public function init(): void { |
| 23 | add_action( |
| 24 | 'init', |
| 25 | array( |
| 26 | $this, |
| 27 | 'initialize', |
| 28 | ) |
| 29 | ); |
| 30 | add_filter( |
| 31 | 'woocommerce_email_editor_initialized', |
| 32 | array( |
| 33 | $this, |
| 34 | 'setup_email_editor_integrations', |
| 35 | ) |
| 36 | ); |
| 37 | add_filter( |
| 38 | 'block_type_metadata_settings', |
| 39 | array( $this->core_email_editor_integration, 'update_block_settings' ), |
| 40 | 10, |
| 41 | 1 |
| 42 | ); |
| 43 | if ( class_exists( 'WooCommerce' ) ) { |
| 44 | add_filter( |
| 45 | 'block_type_metadata_settings', |
| 46 | array( $this->woocommerce_email_editor_integration, 'update_block_settings' ), |
| 47 | 10, |
| 48 | 1 |
| 49 | ); |
| 50 | $coupon_generator = new Coupon_Code_Generator(); |
| 51 | $coupon_generator->init(); |
| 52 | } |
| 53 | } |
| 54 | public function initialize(): void { |
| 55 | $this->email_editor->initialize(); |
| 56 | } |
| 57 | public function setup_email_editor_integrations(): bool { |
| 58 | $this->core_email_editor_integration->initialize(); |
| 59 | return true; // PHPStan expect returning a value from the filter. |
| 60 | } |
| 61 | } |
| 62 |