PluginProbe
Email Log / 2.63
Email Log v2.63
2.63 2.4.8 2.4.9 2.6 2.61 2.62 trunk 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.8.1 0.9 0.9.1 0.9.2 1.1 1.5 1.5.1 1.5.2 1.5.3 1.5.4 All 61 releases
email-log / include / Core / UI / Setting / CoreSetting.php

CoreSetting.php in Email Log 2.63, at include/Core/UI/Setting/CoreSetting.php

657 lines 22.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php namespace EmailLog\Core\UI\Setting;
2
3 use \EmailLog\Core\UI\Page\SettingsPage;
4
5 defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
6
7 /**
8 * All Email Log Core settings.
9 *
10 * @since 2.1.0
11 */
12 class CoreSetting extends Setting {
13
14 protected function initialize() {
15 $this->section->id = 'email-log-core';
16 $this->section->title = __( 'Email Log Settings', 'email-log' );
17 $this->section->option_name = 'email-log-core';
18
19 $this->section->field_labels = array(
20 'allowed_user_roles' => __( 'Allowed User Roles', 'email-log' ),
21 'remove_on_uninstall' => __( 'Remove Data on Uninstall?', 'email-log' ),
22 'hide_dashboard_widget' => __( 'Disable Dashboard Widget', 'email-log' ),
23 'db_size_notification' => __( 'Database Size Notification', 'email-log' ),
24 'email_monitor_title' => '<h2>' . __( 'Email Monitor', 'email-log' ) . '</h2>',
25 'monitor_emails' => __( 'Alert Email <a title="This feature is available in the PRO version. Click for details." href="#" data-feature="email-monitor" class="open-upsell pro-label">PRO</a>', 'email-log' ),
26 'delete_log' => '<h2>' . __( 'Auto Delete Logs', 'email-log' ) . '</h2>',
27 'interval' => __( 'Interval <a title="This feature is available in the PRO version. Click for details." href="#" data-feature="autodelete-interval" class="open-upsell pro-label">PRO</a>', 'email-log' ),
28 'forward_email' => '<h2>' . __( 'Forward Emails Settings', 'email-log' ) . '</h2>',
29 'to' => __( 'To <a title="This feature is available in the PRO version. Click for details." href="#" data-feature="email-to" class="open-upsell pro-label">PRO</a>', 'email-log' ),
30 'cc' => __( 'CC <a title="This feature is available in the PRO version. Click for details." href="#" data-feature="email-cc" class="open-upsell pro-label">PRO</a>', 'email-log' ),
31 'bcc' => __( 'BCC <a title="This feature is available in the PRO version. Click for details." href="#" data-feature="email-bcc" class="open-upsell pro-label">PRO</a>', 'email-log' ),
32 );
33
34 $this->section->default_value = array(
35 'allowed_user_roles' => array(),
36 'remove_on_uninstall' => '',
37 'hide_dashboard_widget' => false,
38 'db_size_notification' => array(
39 'notify' => false,
40 'admin_email' => '',
41 'logs_threshold' => '',
42 'log_threshold_met' => false,
43 'threshold_email_last_sent' => false,
44 ),
45 'monitor_emails' => array(
46 'notify' => false,
47 'alert_email' => '',
48 ),
49 'delete_log' => false,
50 'interval' => 365,
51 'to' => '',
52 'cc' => '',
53 'bcc' => '',
54 );
55
56 $this->load();
57 }
58
59 /**
60 * Override `load` method so that the core settings are displayed first.
61 *
62 * @inheritdoc
63 */
64 public function load() {
65 add_filter( 'el_setting_sections', array( $this, 'register' ), 9 );
66
67 add_action( 'add_option_' . $this->section->option_name, array( $this, 'allowed_user_roles_added' ), 10, 2 );
68 add_action( 'update_option_' . $this->section->option_name, array( $this, 'allowed_user_roles_changed' ), 10, 2 );
69
70 add_action( 'el_email_log_inserted', array( $this, 'verify_email_log_threshold' ) );
71 add_action( 'el_trigger_notify_email_when_log_threshold_met', array( $this, 'trigger_threshold_met_notification_email' ) );
72 }
73
74 /**
75 * Renders the Auto Delete Section Title
76 *
77 * @param array $args
78 */
79 public function render_delete_log_settings() {
80 echo '';
81 }
82
83 /**
84 * Renders the Forward Email Section Title
85 *
86 * @param array $args
87 */
88 public function render_forward_email_settings() {
89 echo '';
90 }
91
92 /**
93 * Renders the Email Monitor Section Title
94 *
95 * @param array $args
96 */
97 public function render_email_monitor_title_settings() {
98 echo '';
99 }
100
101 /**
102 * Renders the Email Log `Allowed User Roles` settings.
103 *
104 * @param array $args Arguments.
105 */
106 public function render_allowed_user_roles_settings( $args ) {
107 $option = $this->get_value();
108 $selected_roles = $option[ $args['id'] ];
109
110 $field_name = $this->section->option_name . '[' . $args['id'] . '][]';
111
112 $available_roles = get_editable_roles();
113 unset( $available_roles['administrator'] );
114 ?>
115
116 <p>
117 <input type="checkbox" checked disabled><?php esc_html_e( 'Administrator', 'email-log' ); ?>
118 </p>
119
120 <?php foreach ( $available_roles as $role_id => $role ) : ?>
121 <p>
122 <input type="checkbox" name="<?php echo esc_attr( $field_name ); ?>" value="<?php echo esc_attr( $role_id ); ?>"
123 <?php \EmailLog\Util\checked_array( $selected_roles, $role_id ); ?>>
124
125 <?php echo esc_html($role['name']); ?>
126 </p>
127 <?php endforeach; ?>
128
129 <p>
130 <em>
131 <?php \EmailLog\Core\EmailLog::wp_kses_wf(__( '<strong>Note:</strong> Users with the above User Roles can view Email Logs.', 'email-log' )); ?>
132 <?php esc_html_e( 'Administrator role always has access and cannot be disabled.', 'email-log' ); ?>
133 </em>
134 </p>
135
136 <?php
137 }
138
139 /**
140 * Sanitize allowed user roles setting.
141 *
142 * @param array $roles User selected user roles.
143 *
144 * @return array Sanitized user roles.
145 */
146 public function sanitize_allowed_user_roles( $roles ) {
147 if ( ! is_array( $roles ) ) {
148 return array();
149 }
150
151 return array_map( 'sanitize_text_field', $roles );
152 }
153
154 /**
155 * Renders the Email Log `Remove Data on Uninstall?` settings.
156 *
157 * @param array $args
158 */
159 public function render_remove_on_uninstall_settings( $args ) {
160 $option = $this->get_value();
161 $remove_data = $option[ $args['id'] ];
162
163 $field_name = $this->section->option_name . '[' . $args['id'] . ']';
164 ?>
165
166 <input type="checkbox" name="<?php echo esc_attr( $field_name ); ?>" value="true" <?php checked( 'true', $remove_data ); ?>>
167 <?php esc_html_e( 'Check this box if you would like to completely remove all of its data when the plugin is deleted.', 'email-log' ) ?>
168 <?php
169 }
170
171 /**
172 * Sanitize Remove on uninstall value.
173 *
174 * @param string $value User entered value.
175 *
176 * @return string Sanitized value.
177 */
178 public function sanitize_remove_on_uninstall( $value ) {
179 return sanitize_text_field( $value );
180 }
181
182 /**
183 * Allowed user role list option is added.
184 *
185 * @param string $option Option name.
186 * @param array $value Option value.
187 */
188 public function allowed_user_roles_added( $option, $value ) {
189 $this->allowed_user_roles_changed( array(), $value );
190 }
191
192 /**
193 * Allowed user role list option was update.
194 *
195 * Change user role capabilities when the allowed user role list is changed.
196 *
197 * @param array $old_value Old Value.
198 * @param array $new_value New Value.
199 */
200 public function allowed_user_roles_changed( $old_value, $new_value ) {
201 $old_roles = $this->get_user_roles( $old_value );
202 $new_roles = $this->get_user_roles( $new_value );
203
204 /**
205 * The user roles who can manage email log list is changed.
206 *
207 * @since 2.1.0
208 *
209 * @param array $old_roles Old user roles.
210 * @param array $new_roles New user roles.
211 */
212 do_action( 'el-log-list-manage-user-roles-changed', $old_roles, $new_roles );
213 }
214
215 /**
216 * Get User roles from option value.
217 *
218 * @access protected
219 *
220 * @param array $option Option value
221 *
222 * @return array User roles.
223 */
224 protected function get_user_roles( $option ) {
225 if ( ! array_key_exists( 'allowed_user_roles', $option ) ) {
226 return array();
227 }
228
229 $user_roles = $option['allowed_user_roles'];
230 if ( ! is_array( $user_roles ) ) {
231 $user_roles = array( $user_roles );
232 }
233
234 return $user_roles;
235 }
236
237 /**
238 * Renders the Email Log `Remove Data on Uninstall?` settings.
239 *
240 * @param array $args
241 */
242 public function render_hide_dashboard_widget_settings( $args ) {
243 $option = $this->get_value();
244 $hide_dashboard_widget = $option[ $args['id'] ];
245
246 $field_name = $this->section->option_name . '[' . $args['id'] . ']';
247 ?>
248
249 <input type="checkbox" name="<?php echo esc_attr( $field_name ); ?>" value="true" <?php checked( 'true', $hide_dashboard_widget ); ?>>
250 <?php esc_html_e( 'Check this box if you would like to disable dashboard widget.', 'email-log' ) ?>
251
252 <p>
253 <em>
254 <?php \EmailLog\Core\EmailLog::wp_kses_wf(__( '<strong>Note:</strong> Each users can also disable dashboard widget using screen options', 'email-log' )); ?>
255 </em>
256 </p>
257
258 <?php
259 }
260
261 /**
262 * Renders the Email Log `Database Size Notification` settings.
263 *
264 * @since 2.3.0
265 *
266 * @param array $args
267 */
268 public function render_db_size_notification_settings( $args ) {
269 $option = $this->get_value();
270 $db_size_notification_data = $option[ $args['id'] ];
271
272 $field_name = $this->section->option_name . '[' . $args['id'] . ']';
273 // Since we store three different fields, give each field a unique name.
274 $db_size_notification_field_name = $field_name . '[notify]';
275 $admin_email_field_name = $field_name . '[admin_email]';
276 $logs_threshold_field_name = $field_name . '[logs_threshold]';
277
278 $email_log = email_log();
279 $logs_count = $email_log->table_manager->get_logs_count();
280
281 $admin_email_input_field = sprintf(
282 '<input type="email" name="%1$s" value="%2$s" size="35" />', esc_attr( $admin_email_field_name ), empty( $db_size_notification_data['admin_email'] ) ? get_option( 'admin_email', '' ) : esc_attr( $db_size_notification_data['admin_email'] ) );
283
284 $logs_threshold_input_field = sprintf( '<input type="number" name="%1$s" placeholder="5000" value="%2$s" min="0" max="99999999" />',
285 esc_attr( $logs_threshold_field_name ),
286 empty( $db_size_notification_data['logs_threshold'] ) ? '' : esc_attr( $db_size_notification_data['logs_threshold'] )
287 );
288 ?>
289
290 <input type="checkbox" name="<?php echo esc_attr( $db_size_notification_field_name ); ?>" value="true" <?php
291 checked( true, $db_size_notification_data['notify'] ?? false ); ?> />
292 <?php
293 // The values within each field are already escaped.
294 /* translators: %1$s is the admin email input field html, %2$s number of logs input field */
295 \EmailLog\Core\EmailLog::wp_kses_wf(sprintf( __( 'Notify %1$s if there are more than %2$s logs.', 'email-log' ),
296 $admin_email_input_field,
297 $logs_threshold_input_field
298 ));
299 ?>
300 <p>
301 <em>
302 <?php
303 /* translators: %1$s is the HTML bold "Note:", %2$s number of logs */
304 \EmailLog\Core\EmailLog::wp_kses_wf(sprintf(__( '%1$s There are %2$s email logs currently logged in the database.', 'email-log' ),
305 '<strong>Note:</strong>',
306 '<strong>' . esc_attr( $logs_count ) . '</strong>'
307 )); ?>
308 </em>
309 </p>
310 <?php if ( ! empty( $db_size_notification_data['threshold_email_last_sent'] ) ) : ?>
311 <p>
312 <?php
313 /* translators: %1$s is the last notification date, %2$s is the HTML Save in bold */
314 \EmailLog\Core\EmailLog::wp_kses_wf(sprintf(__( 'Last notification email was sent on %1$s. Click %2$s button to reset sending the notification.', 'email-log' ),
315 '<strong>' . get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $db_size_notification_data['threshold_email_last_sent'] ), \EmailLog\Util\get_user_defined_date_time_format() ) . '</strong>',
316 '<b>Save</b>'
317 )); ?>
318 </p>
319 <?php
320 endif;
321 /**
322 * After DB size notification setting in Settings page.
323 *
324 * @since 2.4.0
325 */
326 do_action( 'el_after_db_size_notification_setting' );
327 }
328
329 /**
330 * Removes any additional keys set other than the ones in db_size_notification array.
331 *
332 * @since 2.3.0
333 *
334 * @param array $arr `db_size_notification` option array.
335 *
336 * @return array `db_size_notification` option array with keys removed other than the allowed.
337 */
338 protected function restrict_array_to_db_size_notification_setting_keys( $arr ) {
339 $allowed_keys = array_keys( $this->section->default_value['db_size_notification'] );
340 $arr_keys = array_keys( $arr );
341
342 // Return the array when only the allowed keys exist.
343 $intersecting_keys = array_intersect( $allowed_keys, $arr_keys );
344 if ( count( $allowed_keys ) === count( $intersecting_keys ) ) {
345 return $arr;
346 }
347
348 // Otherwise remove keys that aren't expected.
349 $diff_keys = array_diff_key( $arr, $allowed_keys );
350 foreach ( $diff_keys as $key ) {
351 unset( $arr[ $key ] );
352 }
353
354 return $arr;
355 }
356
357 /**
358 * Sanitizes the db_size_notification option.
359 *
360 * @since 2.3.0
361 *
362 * @param array $db_size_notification_data
363 *
364 * @return array $db_size_notification_data
365 */
366 public function sanitize_db_size_notification( $db_size_notification_data ) {
367 $db_size_notification_data = $this->restrict_array_to_db_size_notification_setting_keys( $db_size_notification_data );
368
369 foreach ( $db_size_notification_data as $setting => $value ) {
370 if ( 'notify' === $setting ) {
371 $db_size_notification_data[ $setting ] = \filter_var( $value, FILTER_VALIDATE_BOOLEAN );
372 } elseif ( 'admin_email' === $setting ) {
373 $db_size_notification_data[ $setting ] = \sanitize_email( $value );
374 } elseif ( 'logs_threshold' === $setting ) {
375 $db_size_notification_data[ $setting ] = absint( \sanitize_text_field( $value ) );
376 }
377 }
378
379 // wp_parse_args won't merge nested array keys. So add the key here if it is not set.
380 if ( ! array_key_exists( 'notify', $db_size_notification_data ) ) {
381 $db_size_notification_data['notify'] = false;
382 }
383 if ( ! array_key_exists( 'log_threshold_met', $db_size_notification_data ) ) {
384 $db_size_notification_data['log_threshold_met'] = false;
385 }
386 if ( ! array_key_exists( 'threshold_email_last_sent', $db_size_notification_data ) ) {
387 $db_size_notification_data['threshold_email_last_sent'] = false;
388 }
389
390 return $db_size_notification_data;
391 }
392
393 /**
394 * Triggers the Cron to notify admin via email.
395 *
396 * Email is triggered only when the threshold setting is met.
397 *
398 * @since 2.3.0
399 */
400 public function verify_email_log_threshold() {
401 $cron_hook = 'el_trigger_notify_email_when_log_threshold_met';
402 if ( ! wp_next_scheduled( $cron_hook ) ) {
403 wp_schedule_event( time(), 'hourly', $cron_hook );
404 }
405 }
406
407 /**
408 * Utility method to verify all the given keys exist in the given array.
409 *
410 * This method helps reduce the Cyclomatic Complexity in its parent method.
411 *
412 * @since 2.3.0
413 *
414 * @param array $arr The array whose keys must be checked.
415 * @param array $keys All the required keys that the array must contain.
416 *
417 * @return bool
418 */
419 protected function has_array_contains_required_keys( $arr, $keys ) {
420 $has_keys = true;
421
422 if ( ! is_array( $arr ) || ! is_array( $keys ) ) {
423 return false;
424 }
425
426 foreach ( $arr as $key => $value ) {
427 $has_keys = $has_keys && in_array( $key, $keys, true );
428 }
429
430 return $has_keys;
431 }
432
433 /**
434 * Send the Threshold notification email to the admin.
435 *
436 * @since 2.3.0
437 */
438 public function trigger_threshold_met_notification_email() {
439 $email_log = email_log();
440 $logs_count = absint( $email_log->table_manager->get_logs_count() );
441
442 $setting_data = $this->get_value();
443
444 // Return early.
445 if ( ! array_key_exists( 'db_size_notification', $setting_data ) ) {
446 return;
447 }
448
449 $db_size_notification_key = 'db_size_notification';
450 $db_size_notification_data = $setting_data[ $db_size_notification_key ];
451
452 // Return early.
453 $keys = array_keys( $this->section->default_value['db_size_notification'] );
454 if ( ! $this->has_array_contains_required_keys( $db_size_notification_data, $keys ) ) {
455 return;
456 }
457
458 $is_notification_enabled = $db_size_notification_data['notify'];
459 $admin_email = $db_size_notification_data['admin_email'];
460 $logs_threshold = absint( $db_size_notification_data['logs_threshold'] );
461 $logs_threshold_met = $db_size_notification_data['log_threshold_met'];
462
463 // Ideally threshold cannot be 0. Also, skip sending email if it is already sent.
464 if ( 0 === $logs_threshold || true === $logs_threshold_met ) {
465 return;
466 }
467
468 if ( $logs_count < $logs_threshold ) {
469 return;
470 }
471
472 $this->register_threshold_met_admin_notice();
473
474 if ( $is_notification_enabled && is_email( $admin_email ) ) {
475 /* translators: %s is the number of log entries */
476 $subject = sprintf( __( 'Email Log Plugin: Your log threshold of %s has been met', 'email-log' ), $logs_threshold );
477 $message = '<p>This email is generated by the Email Log plugin.</p>';
478 $message .= '<p>Your log threshold of $logs_threshold has been met. You may manually delete the logs to keep your database table in size.</p>';
479 $message .= '<p>Also, consider using our <a href="https://wpemaillog.com/addons/auto-delete-logs/">Auto Delete Logs</a> plugin to delete the logs automatically.</p>';
480
481 $headers = array( 'Content-Type: text/html; charset=UTF-8' );
482
483 /**
484 * Filters Log threshold notification email subject.
485 *
486 * @since 2.3.0
487 *
488 * @param string $subject The email subject.
489 */
490 $subject = apply_filters( 'el_log_threshold_met_notification_email_subject', $subject );
491
492 /**
493 * Filters Log threshold notification email body.
494 *
495 * @since 2.3.0
496 *
497 * @param string $message The email body.
498 * @param int $logs_threshold The log threshold value set by the user.
499 */
500 $message = apply_filters( 'el_log_threshold_met_notification_email_body', $message, $logs_threshold );
501
502 wp_mail( $admin_email, $subject, $message, $headers );
503
504 $setting_data[ $db_size_notification_key ]['log_threshold_met'] = true;
505 $setting_data[ $db_size_notification_key ]['threshold_email_last_sent'] = time();
506 \update_option( $this->section->option_name, $setting_data );
507 }
508 }
509
510 /**
511 * Registers the Email Log threshold met admin notice.
512 *
513 * @since 2.3.0
514 */
515 public function register_threshold_met_admin_notice() {
516 add_action( 'admin_notices', array( $this, 'render_log_threshold_met_notice' ) );
517 }
518
519 /**
520 * Displays the Email Log threshold met admin notice.
521 *
522 * @since 2.3.0
523 */
524 public function render_log_threshold_met_notice() {
525 $email_log = email_log();
526 $logs_count = absint( $email_log->table_manager->get_logs_count() );
527 /* translators: %1$s is the number of log entries, %2$s admin settings link, %2$s wpemaillog.com website link */
528 $notice_message = sprintf( __( 'Currently there are %1$s logged, which is more than the threshold that is set in the %2$s screen. You can delete some logs or increase the threshold. You can also use our %3$s PRO version to automatically delete logs', 'email-log' ),
529 $logs_count . _n( ' email log', ' email logs', $logs_count, 'email-log' ),
530 '<a href="' . esc_url( admin_url( 'admin.php?page=' . SettingsPage::PAGE_SLUG ) ) . '">settings</a> screen',
531 '<a href="' . esc_url( 'https://wpemaillog.com/addons/auto-delete-logs/' ) . '">Auto Delete Logs</a>'
532 );
533 ?>
534 <div class="notice notice-warning is-dismissible">
535 <p><?php \EmailLog\Core\EmailLog::wp_kses_wf($notice_message); ?></p>
536 </div>
537 <?php
538 }
539
540 public function render_interval_settings( $args ) {
541 $option = $this->get_value();
542 ?>
543 <p><?php esc_html_e( 'Auto Delete Logs allows you to automatically delete logs that are older than specified interval (in days).', 'email-log' ); ?></p>
544 <p><?php esc_html_e( 'Specify the interval beyond which the logs are to be auto deleted.', 'email-log' ); ?></p>
545 <label>
546 <input class="open-pro-dialog" name="<?php echo esc_attr( $this->section->option_name . '[' . $args['id'] . ']' ); ?>"
547 size="40"
548 type="text" value="365" disabled>
549 </label>
550 <br>
551 <em> <?php esc_html_e( 'Specify the interval in days.', 'email-log' ); ?> </em>
552 <?php
553 /**
554 * After the Next Run setting is rendered in the Auto Delete Logs add-on.
555 *
556 * @since 1.1.1
557 */
558 do_action( 'el_auto_delete_logs_after_next_run_setting' );
559 ?>
560
561 <?php
562 }
563
564 public function render_monitor_emails_settings( $args ) {
565 $options = get_option( 'email-log-core' );
566 ?>
567 <p><?php esc_html_e( 'This service checks that your WordPress site is able to send emails reliably. Once enabled, the plugin will automatically send a daily "heartbeat" email to our monitoring server. If no heartbeat is received within 24 hours, an alert will be sent to the email address you provide below. This way you\'ll know right away if your site\'s emails stop working (for example, due to SMTP misconfiguration or server issues). You can also use the "Test email delivery" button at any time to confirm that emails are being delivered correctly.', 'email-log' ); ?></p>
568 <br />
569 <label>
570 <input data-feature="test-email" type="checkbox" class="open-upsell" name="<?php echo esc_attr( $this->section->option_name . '[' . $args['id'] . '][notify]' ); ?>" value="true" <?php
571 checked( true, false ); ?> /> Notify
572
573 <input name="<?php echo esc_attr( $this->section->option_name . '[' . $args['id'] . '][alerts_email]' ); ?>"
574 size="40"
575 type="email" class="open-upsell" data-feature="test-email" value="<?php echo esc_html(get_option('admin_email')); ?>" disabled>
576 </label>
577 <a class="button button-primary open-upsell" data-feature="test-email">Test email delivery now</a>
578 <br>
579
580 <p><em> <?php esc_html_e( 'Enter the email where you want to receive an alert if the monitor does not receive emails from your website.', 'email-log' ); ?> </em></p>
581 <?php
582 }
583
584 public function sanitize_interval( $value ) {
585 $value = absint( $value );
586
587 return 0 !== $value ? $value : 365;
588 }
589
590 /**
591 * Render To field.
592 *
593 * @since 2.0.2
594 *
595 * @param array $args Args.
596 */
597 public function render_to_settings( $args ) {
598 $this->render_email_field( $args );
599 }
600
601 /**
602 * Render CC field.
603 *
604 * @since 2.0.2
605 *
606 * @param array $args Args.
607 */
608 public function render_cc_settings( $args ) {
609 $this->render_email_field( $args );
610 }
611
612 /**
613 * Render BCC field.
614 *
615 * @since 2.0.2
616 *
617 * @param array $args Args.
618 */
619 public function render_bcc_settings( $args ) {
620 $this->render_email_field( $args );
621 }
622
623 /**
624 * Render email field.
625 *
626 * @since 2.0.2 Protected method.
627 *
628 * @param array $args Args.
629 */
630 protected function render_email_field( $args ) {
631 $option = $this->get_value();
632 ?>
633 <label>
634 <input class="open-pro-dialog" name="<?php echo esc_attr( $this->section->option_name . '[' . $args['id'] . ']' ); ?>" size="40"
635 type="text" value="" disabled>
636 </label>
637 <br>
638 <em> <?php esc_html_e( 'You can enter multiple email address by separating them with comma.', 'email-log' ); ?> </em>
639 <?php
640 }
641
642 public function sanitize( $values ) {
643 if ( ! is_array( $values ) ) {
644 return array();
645 }
646
647 foreach ( $values as $key => $value ) {
648 if(in_array($key, array('to', 'cc', 'bcc'))){
649 $values[ $key ] = \EmailLog\Util\sanitize_email( $value );
650 }
651 }
652
653 return $values;
654 }
655
656 }
657