ExportWCCoreProfilerOptions.php
1 year ago
ExportWCPaymentGateways.php
1 year ago
ExportWCSettings.php
11 months ago
ExportWCSettingsAccount.php
1 year ago
ExportWCSettingsAdvanced.php
1 year ago
ExportWCSettingsEmails.php
1 year ago
ExportWCSettingsGeneral.php
1 year ago
ExportWCSettingsIntegrations.php
1 year ago
ExportWCSettingsProducts.php
1 year ago
ExportWCSettingsShipping.php
1 year ago
ExportWCSettingsSiteVisibility.php
1 year ago
ExportWCSettingsTax.php
11 months ago
ExportWCTaskOptions.php
1 year ago
ExportWCSettingsEmails.php
79 lines
| 1 | <?php |
| 2 | |
| 3 | declare( strict_types = 1); |
| 4 | |
| 5 | namespace Automattic\WooCommerce\Admin\Features\Blueprint\Exporters; |
| 6 | |
| 7 | use Automattic\WooCommerce\Admin\Features\Blueprint\SettingOptions; |
| 8 | use Automattic\WooCommerce\Blueprint\UseWPFunctions; |
| 9 | use Automattic\WooCommerce\Blueprint\Steps\SetSiteOptions; |
| 10 | |
| 11 | /** |
| 12 | * Class ExportWCSettingsEmails |
| 13 | * |
| 14 | * This class exports WooCommerce settings on the Emails page. |
| 15 | * |
| 16 | * @package Automattic\WooCommerce\Admin\Features\Blueprint\Exporters |
| 17 | */ |
| 18 | class ExportWCSettingsEmails extends ExportWCSettings { |
| 19 | use UseWPFunctions; |
| 20 | |
| 21 | /** |
| 22 | * Get the alias for this exporter. |
| 23 | * |
| 24 | * @return string |
| 25 | */ |
| 26 | public function get_alias() { |
| 27 | return 'setWCSettingsEmails'; |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * Export WooCommerce settings. |
| 32 | * |
| 33 | * @return SetSiteOptions |
| 34 | */ |
| 35 | public function export() { |
| 36 | $emails = \WC_Emails::instance(); |
| 37 | $setting_options = new SettingOptions(); |
| 38 | |
| 39 | $email_settings = $setting_options->get_page_options( $this->get_page_id() ); |
| 40 | |
| 41 | // Get sub-settings for each email. |
| 42 | foreach ( $emails->get_emails() as $email ) { |
| 43 | $email_settings = array_merge( |
| 44 | $email_settings, |
| 45 | $setting_options->get_page_options( 'email_' . $email->id ) |
| 46 | ); |
| 47 | } |
| 48 | |
| 49 | return new SetSiteOptions( $email_settings ); |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Return label used in the frontend. |
| 54 | * |
| 55 | * @return string |
| 56 | */ |
| 57 | public function get_label() { |
| 58 | return __( 'Emails', 'woocommerce' ); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Return description used in the frontend. |
| 63 | * |
| 64 | * @return string |
| 65 | */ |
| 66 | public function get_description() { |
| 67 | return __( 'Includes all settings in WooCommerce | Settings | Emails.', 'woocommerce' ); |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Get the page ID for the settings page. |
| 72 | * |
| 73 | * @return string |
| 74 | */ |
| 75 | protected function get_page_id(): string { |
| 76 | return 'email'; |
| 77 | } |
| 78 | } |
| 79 |