Skip to content

Commit 901da7e

Browse files
authored
Add experimental emails settings API to V4 (#61849)
1 parent 327c6ef commit 901da7e

14 files changed

+1772
-6
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Significance: patch
2+
Type: add
3+
Comment: Add experimental V4 settings/emails API
4+
5+

plugins/woocommerce/includes/emails/class-wc-email-cancelled-order.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,9 @@ public function init_form_fields() {
236236
$this->form_fields['cc'] = $this->get_cc_field();
237237
$this->form_fields['bcc'] = $this->get_bcc_field();
238238
}
239+
if ( $this->block_email_editor_enabled ) {
240+
$this->form_fields['preheader'] = $this->get_preheader_field();
241+
}
239242
}
240243
}
241244

plugins/woocommerce/includes/emails/class-wc-email-customer-cancelled-order.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ public function init_form_fields() {
226226
$this->form_fields['cc'] = $this->get_cc_field();
227227
$this->form_fields['bcc'] = $this->get_bcc_field();
228228
}
229+
if ( $this->block_email_editor_enabled ) {
230+
$this->form_fields['preheader'] = $this->get_preheader_field();
231+
}
229232
}
230233
}
231234

plugins/woocommerce/includes/emails/class-wc-email-customer-invoice.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@ public function init_form_fields() {
260260
$this->form_fields['cc'] = $this->get_cc_field();
261261
$this->form_fields['bcc'] = $this->get_bcc_field();
262262
}
263+
if ( $this->block_email_editor_enabled ) {
264+
$this->form_fields['preheader'] = $this->get_preheader_field();
265+
}
263266
}
264267
}
265268

plugins/woocommerce/includes/emails/class-wc-email-customer-pos-refunded-order.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,9 @@ public function init_form_fields() {
376376
$this->form_fields['cc'] = $this->get_cc_field();
377377
$this->form_fields['bcc'] = $this->get_bcc_field();
378378
}
379+
if ( $this->block_email_editor_enabled ) {
380+
$this->form_fields['preheader'] = $this->get_preheader_field();
381+
}
379382
}
380383

381384
/**

plugins/woocommerce/includes/emails/class-wc-email-customer-refunded-order.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,9 @@ public function init_form_fields() {
357357
$this->form_fields['cc'] = $this->get_cc_field();
358358
$this->form_fields['bcc'] = $this->get_bcc_field();
359359
}
360+
if ( $this->block_email_editor_enabled ) {
361+
$this->form_fields['preheader'] = $this->get_preheader_field();
362+
}
360363
}
361364
}
362365

plugins/woocommerce/includes/emails/class-wc-email-failed-order.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,9 @@ public function init_form_fields() {
236236
$this->form_fields['cc'] = $this->get_cc_field();
237237
$this->form_fields['bcc'] = $this->get_bcc_field();
238238
}
239+
if ( $this->block_email_editor_enabled ) {
240+
$this->form_fields['preheader'] = $this->get_preheader_field();
241+
}
239242
}
240243
}
241244

plugins/woocommerce/includes/emails/class-wc-email-new-order.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,9 @@ public function init_form_fields() {
264264
$this->form_fields['cc'] = $this->get_cc_field();
265265
$this->form_fields['bcc'] = $this->get_bcc_field();
266266
}
267+
if ( $this->block_email_editor_enabled ) {
268+
$this->form_fields['preheader'] = $this->get_preheader_field();
269+
}
267270
}
268271

269272

plugins/woocommerce/includes/emails/class-wc-email.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,9 @@ public function init_form_fields() {
11901190
$this->form_fields['cc'] = $this->get_cc_field();
11911191
$this->form_fields['bcc'] = $this->get_bcc_field();
11921192
}
1193+
if ( $this->block_email_editor_enabled ) {
1194+
$this->form_fields['preheader'] = $this->get_preheader_field();
1195+
}
11931196
}
11941197

11951198
/**
@@ -1226,6 +1229,22 @@ protected function get_bcc_field() {
12261229
);
12271230
}
12281231

1232+
/**
1233+
* Get the preheader field definition.
1234+
*
1235+
* @return array
1236+
*/
1237+
protected function get_preheader_field() {
1238+
return array(
1239+
'title' => __( 'Preheader', 'woocommerce' ),
1240+
'description' => __( 'Shown as a preview in the Inbox, next to the subject line. (Max 150 characters).', 'woocommerce' ),
1241+
'placeholder' => '',
1242+
'type' => 'text',
1243+
'default' => '',
1244+
'desc_tip' => true,
1245+
);
1246+
}
1247+
12291248
/**
12301249
* Email type options.
12311250
*

plugins/woocommerce/includes/rest-api/Server.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Automattic\WooCommerce\Internal\RestApi\Routes\V4\Customers\Controller as CustomersController;
2525
use Automattic\WooCommerce\Internal\RestApi\Routes\V4\Settings\General\Controller as GeneralSettingsController;
2626
use Automattic\WooCommerce\Internal\RestApi\Routes\V4\Settings\Email\Controller as EmailSettingsController;
27+
use Automattic\WooCommerce\Internal\RestApi\Routes\V4\Settings\Emails\Controller as EmailsSettingsController;
2728
use Automattic\WooCommerce\Internal\RestApi\Routes\V4\Fulfillments\Controller as FulfillmentsController;
2829

2930
/**
@@ -241,6 +242,7 @@ protected function get_v4_controllers() {
241242
'offline-payment-methods' => OfflinePaymentMethodsController::class,
242243
'settings-general' => GeneralSettingsController::class,
243244
'settings-email' => EmailSettingsController::class,
245+
'settings-emails' => EmailsSettingsController::class,
244246
'settings-products' => SettingsProductsController::class,
245247
'settings-payment-gateways' => PaymentGatewaysController::class,
246248
// This is a wrapper that redirects V4 settings requests to the V3 settings controller.

0 commit comments

Comments
 (0)