diff --git a/admin/settings/class-admin-apple-settings-section-developer-tools.php b/admin/settings/class-admin-apple-settings-section-developer-tools.php
index 77db19a5..7e372794 100644
--- a/admin/settings/class-admin-apple-settings-section-developer-tools.php
+++ b/admin/settings/class-admin-apple-settings-section-developer-tools.php
@@ -41,10 +41,11 @@ public function __construct( $page ) {
'type' => [ 'no', 'yes' ],
],
'apple_news_admin_email' => [
- 'label' => __( 'Administrator Email', 'apple-news' ),
+ 'label' => __( 'Email(s)', 'apple-news' ),
'required' => false,
- 'type' => 'string',
+ 'type' => 'email',
'size' => 40,
+ 'multiple' => true,
],
];
@@ -70,7 +71,7 @@ public function __construct( $page ) {
*/
public function get_section_info() {
return __(
- 'If debugging is enabled, emails will be sent to an administrator for every publish, update or delete action with a detailed API response.',
+ 'If debugging is enabled (and valid emails are provided), emails will be sent for every publish, update or delete action with a detailed API response.',
'apple-news'
);
}
diff --git a/admin/settings/class-admin-apple-settings-section.php b/admin/settings/class-admin-apple-settings-section.php
index 9f6c540d..a96aab80 100644
--- a/admin/settings/class-admin-apple-settings-section.php
+++ b/admin/settings/class-admin-apple-settings-section.php
@@ -126,6 +126,7 @@ class Admin_Apple_Settings_Section extends Apple_News {
'max' => [],
'step' => [],
'type' => [],
+ 'multiple' => [],
'required' => [],
'size' => [],
'id' => [],
@@ -324,6 +325,14 @@ public function render_field( $args ) {
$field = '';
} elseif ( 'number' === $type ) {
$field = '';
+ } elseif ( 'email' === $type ) {
+ $field = 'is_multiple( $name ) ) {
+ $field .= ' multiple %s>';
+ } else {
+ $field .= ' %s>';
+ }
} else {
// If nothing else matches, it's a string.
$field = '';
@@ -403,9 +412,9 @@ public function render_field( $args ) {
protected function get_type_for( $name ) {
if ( $this->hidden ) {
return 'hidden';
- } else {
- return empty( $this->settings[ $name ]['type'] ) ? 'string' : $this->settings[ $name ]['type'];
}
+
+ return empty( $this->settings[ $name ]['type'] ) ? 'string' : $this->settings[ $name ]['type'];
}
/**
diff --git a/includes/apple-push-api/request/class-request.php b/includes/apple-push-api/request/class-request.php
index 844904cb..ee44a57d 100644
--- a/includes/apple-push-api/request/class-request.php
+++ b/includes/apple-push-api/request/class-request.php
@@ -171,10 +171,17 @@ private function parse_response( $response, $json = true, $type = 'post', $meta
&& 'yes' === $settings['apple_news_enable_debugging']
&& 'get' !== $type ) {
- // Get the admin email.
- $admin_email = filter_var( $settings['apple_news_admin_email'], FILTER_VALIDATE_EMAIL );
+ $emails = $settings['apple_news_admin_email'] ?? '';
- if ( empty( $admin_email ) ) {
+ if ( str_contains( $emails, ',' ) ) {
+ $emails = array_map( 'trim', explode( ',', $emails ) );
+ } else {
+ $emails = [ $emails ];
+ }
+
+ $to = array_filter( $emails, 'is_email' );
+
+ if ( empty( $to ) ) {
return; // TODO Fix inconsistent return value.
}
@@ -218,7 +225,7 @@ private function parse_response( $response, $json = true, $type = 'post', $meta
// Send the email.
if ( ! empty( $body ) ) {
wp_mail( // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.wp_mail_wp_mail
- $admin_email,
+ $to,
esc_html__( 'Apple News Notification', 'apple-news' ),
$body,
$headers