PluginProbe ʕ •ᴥ•ʔ
Check & Log Email – Easy Email Testing & Mail logging / 2.0.2
Check & Log Email – Easy Email Testing & Mail logging v2.0.2
2.0.15 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 2.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.13.1 2.0.13.2 2.0.14 2.0.2 2.0.3 2.0.4 2.0.5 2.0.5.1 2.0.6 2.0.7 2.0.8 2.0.9 trunk 0.5.7 0.6.0 0.6.1 0.6.2 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.12.1 1.0.13 1.0.13.1 1.0.2 1.0.3
check-email / include / Core / Check_Email_Multisite.php
check-email / include / Core Last commit date
DB 1 year ago Request 1 year ago UI 1 year ago Auth.php 1 year ago Check_Email_Admin_Capability_Giver.php 1 year ago Check_Email_Export_Log.php 1 year ago Check_Email_From_Handler.php 1 year ago Check_Email_Log.php 1 year ago Check_Email_Logger.php 1 year ago Check_Email_Multisite.php 1 year ago Check_Email_Review.php 1 year ago Loadie.php 1 year ago
Check_Email_Multisite.php
415 lines
1 <?php
2
3 namespace CheckEmail\Core;
4 use CheckEmail\Core\Auth;
5
6 defined('ABSPATH') || exit; // Exit if accessed directly.
7
8 class Check_Email_Multisite {
9
10 public function __construct() {
11 add_action('init', [$this, 'check_mail_handle_outlook_callback']);
12 add_action('init', [$this, 'init']);
13 }
14
15 public function init() {
16 if (! is_multisite()) {
17 return;
18 }
19
20 add_action('network_admin_menu', [$this, 'ck_mail_network_settings_menu']);
21 add_action('admin_enqueue_scripts', [$this, 'ck_mail_network_enqueue_scripts']);
22 }
23 public function check_mail_handle_outlook_callback() {
24 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form
25 if ( isset( $_GET['code'] ) && !empty( $_GET['code'] ) && isset( $_GET['state'] ) && !empty( $_GET['state'] )) {
26 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form
27 $auth = new Auth( 'outlook' );
28 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form
29 $auth->update_auth_code( sanitize_text_field( wp_unslash( $_GET['code'] ) ) );
30 $smtp_options = get_site_option('check-email-log-global-smtp');
31 if (isset($smtp_options['enable_global']) && ! empty($smtp_options['enable_global']) && is_multisite()) {
32 $url = network_admin_url('admin.php?page=check-mail-global-settings&tab=smtp' );
33 }else{
34 $url = admin_url('admin.php?page=check-email-settings&tab=smtp' );
35 }
36 wp_safe_redirect( $url );
37 exit;
38 }
39 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form
40 if ( isset( $_GET['error_description'] ) ) {
41 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form
42 $error_message = sanitize_text_field( wp_unslash( $_GET['error_description'] ) );
43 if (isset($smtp_options['enable_global']) && ! empty($smtp_options['enable_global']) && is_multisite()) {
44 $redirect_url = network_admin_url('admin.php?page=check-mail-global-settings&tab=smtp' );
45 }else{
46 $redirect_url = admin_url('admin.php?page=check-email-settings&tab=smtp' );
47 }
48 $url = add_query_arg( 'error', $error_message, $redirect_url );
49 wp_safe_redirect( $url );
50 exit;
51 }
52 }
53
54 public function ck_mail_network_settings_menu() {
55 add_menu_page(
56 esc_html__('Check & Log Email', 'check-email'),
57 esc_html__('Check & Log Email', 'check-email'),
58 'manage_check_email',
59 'check-mail-global-settings',
60 [$this, 'render_page'],
61 'dashicons-email-alt',
62 26
63 );
64 }
65
66 function render_page() {
67 $check_email = wpchill_check_email();
68 $plugin_dir_url = plugin_dir_url( $check_email->get_plugin_file() );
69 $smtp_options = [];
70 $outlook_smtp = [];
71 $enable_smtp = "";
72 $enable_global = "";
73 $mailer = "smtp";
74 $auth = new Auth( 'outlook' );
75 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form
76 $tab = isset( $_GET['tab']) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : 'general';
77 if (! empty(get_site_option( 'check-email-log-global-smtp') ) ) {
78 $smtp_options = get_site_option( 'check-email-log-global-smtp');
79 $enable_smtp = isset($smtp_options['enable_smtp'])? $smtp_options['enable_smtp'] : '';
80 $enable_global = isset($smtp_options['enable_global'])? $smtp_options['enable_global'] : '';
81 $mailer = isset($smtp_options['mailer'])?$smtp_options['mailer']:'smtp';
82 if ( $mailer == 'outlook' ) {
83 $outlook_smtp = $auth->get_mailer_option();
84 }
85 }?>
86
87 <div class="wrap">
88 <nav class="nav-tab-wrapper">
89 <a href="?page=check-mail-global-settings" class="nav-tab <?php if( 'general' == $tab ):?>nav-tab-active<?php endif; ?>"><?php esc_html_e( 'General', 'check-email' ); ?></a>
90 <a href="?page=check-mail-global-settings&tab=smtp" class="nav-tab <?php if( 'smtp' == $tab ):?>nav-tab-active<?php endif; ?>"><?php esc_html_e( 'SMTP', 'check-email' ); ?></a>
91 </nav>
92 <div class="tab-content">
93 <?php
94 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form
95 if (isset( $_GET['error_description'] ) ) {
96 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form
97 $error_message = sanitize_text_field( wp_unslash( $_GET['error_description'] ) );
98 ?> <div class="notice notice-error is-dismissible">
99 <h3><?php esc_html_e( 'Its an error to linking with microsoft 365 / outlook' ); ?></h3>
100 <p><?php echo esc_html( $error_message ); ?></p>
101 </div>
102 <?php
103 }
104 ?>
105 <form method="post" id="my-network-settings-form">
106 <?php wp_nonce_field('update_network_settings', 'ck_mail_ajax_check_nonce'); ?>
107 <table class="form-table">
108 <thead>
109 <tr valign="top">
110 <th scope="row"><label for="check-email-log-global-enable_global" class="check-email-opt-labels"><?php esc_html_e('Setting Control', 'check-email'); ?></label></th>
111 <td><input type="checkbox" id="check-email-log-global-enable_global" name="check-email-log-global[enable_global]" <?php echo $enable_global == 'on' ? "checked" : ''; ?> class="regular-text" /><label for="check-email-log-global-enable_global" class="check-email-opt-labels"><?php esc_html_e('Make the plugin settings global network-wide', 'check-email'); ?></label></td>
112 </tr>
113 </thead>
114 <?php if( 'general' == $tab ) : ?>
115
116 <tbody id="check-email-global-smtp-form" style="<?php echo $enable_global != 'on' ? "display: none" : ''; ?>">
117
118 <tr>
119
120 <th scope="row"><label for="check-email-global-override_emails_from" class="check-email-opt-labels" ><?php esc_html_e('Override Emails From', 'check-email'); ?></label></th>
121
122 <td>
123
124 <input id="check-email-global-override_emails_from" type="checkbox" name="check-email-log-global[override_emails_from]" value="true" <?php echo (isset($smtp_options['override_emails_from'])) && $smtp_options['override_emails_from'] == true ? "checked" : ''; ?> />
125
126 <label for="check-email-global-override_emails_from" class="check-email-opt-labels" ><?php esc_html_e( 'Check this box if you would like override wordpress default from email and name.', 'check-email' ) ?> </label>
127
128 </td>
129
130 </tr>
131
132 <tr class="cm_global_override">
133
134 <th scope="row"> <label for="check-email-log-global-email_from_name" style="padding-left:10px;" class="check-email-opt-labels"><?php esc_html_e('Change the "from" name', 'check-email'); ?> </label></th>
135
136 <td>
137
138 <input id="check-email-log-global-email_from_name" placeholder="<?php esc_html_e('Change the "from" name', 'check-email'); ?>" type="text" name="check-email-log-global[email_from_name]" value="<?php echo (isset($smtp_options['email_from_name'])) ? esc_html( $smtp_options['email_from_name'] ) : ''; ?>" class="regular-text">
139
140 </td>
141
142 </tr>
143
144 <tr class="cm_global_override">
145
146 <th scope="row"> <label for="check-email-log-global-email_from_email" class="check-email-opt-labels" style="padding-left:10px;"><?php esc_html_e('Change the "from" email', 'check-email'); ?></th>
147
148 <td>
149
150 <input id="check-email-log-global-email_from_email" placeholder="<?php esc_html_e('Change the "from" email', 'check-email'); ?>" type="text" name="check-email-log-global[email_from_email]" value="<?php echo (isset($smtp_options['email_from_email'])) ? esc_html( $smtp_options['email_from_email'] ) : ''; ?>" class="regular-text">
151
152 </td>
153
154 </tr>
155
156 <tr>
157
158 <th scope="row"><label for="check-email-global-forward_email" class="check-email-opt-labels"><?php esc_html_e('Forward Email', 'check-email'); ?></label></th>
159
160 <td>
161
162 <input id="check-email-global-forward_email" type="checkbox" name="check-email-log-global[forward_email]" value="true" <?php echo (isset($smtp_options['forward_email'])) && $smtp_options['forward_email'] == true ? "checked" : ''; ?> /> <label for="check-email-global-forward_email" class="check-email-opt-labels"><?php esc_html_e( 'Automatically forward a copy of all emails sent by WordPress to other email addresses ', 'check-email' ) ?> </label><a href=" https://check-email.tech/docs/knowledge-base/forward-email-option-in-the-check-log-email-plugin/"><?php esc_html_e( 'Learn More', 'check-email' ) ?></a>
163
164 </td>
165
166 </tr>
167
168 <tr class="cm_global_forward">
169
170 <th scope="row"> <label for="check-email-log-global-forward_to" class="check-email-opt-labels" style="padding-left:10px;"><?php esc_html_e('Forward To', 'check-email'); ?> </label></th>
171
172 <td>
173
174 <input id="check-email-log-global-forward_to" placeholder="<?php esc_html_e('Forward To Email', 'check-email'); ?>" type="text" name="check-email-log-global[forward_to]" value="<?php echo (isset($smtp_options['forward_to'])) ? esc_html( $smtp_options['forward_to'] ) : ''; ?>" class="regular-text">
175
176 </td>
177
178 </tr>
179
180 <tr class="cm_global_forward">
181
182 <th scope="row"> <label for="check-email-log-global-forward_cc" class="check-email-opt-labels" style="padding-left:10px;"><?php esc_html_e('Forward Cc', 'check-email'); ?></th>
183
184 <td>
185
186 <input id="check-email-log-global-forward_cc" placeholder="<?php esc_html_e('Forward Cc Email', 'check-email'); ?>" type="text" name="check-email-log-global[forward_cc]" value="<?php echo (isset($smtp_options['forward_cc'])) ? esc_html( $smtp_options['forward_cc'] ) : ''; ?>" class="regular-text">
187
188 </td>
189
190 </tr>
191
192 <tr class="cm_global_forward">
193
194 <th scope="row"> <label for="check-email-log-global-forward_bcc" class="check-email-opt-labels" style="padding-left:10px;"><?php esc_html_e('Forward Bcc', 'check-email'); ?></th>
195
196 <td>
197
198 <input id="check-email-log-global-forward_bcc" placeholder="<?php esc_html_e('Forward Bcc Email', 'check-email'); ?>" type="text" name="check-email-log-global[forward_bcc]" value="<?php echo (isset($smtp_options['forward_bcc'])) ? esc_html( $smtp_options['forward_bcc'] ) : ''; ?>" class="regular-text">
199
200 </td>
201
202 </tr>
203
204 </tbody>
205
206 <?php endif; ?>
207
208 <?php if( 'smtp' == $tab ) : ?>
209 <tbody id="check-email-global-smtp-form" style="<?php echo $enable_global != 'on' ? "display: none" : ''; ?>">
210 <tr class="check_email_mailer">
211 <th scope="row" style="padding-left: 10px;"><label for="check-email-mailer" class="check-email-opt-labels"><?php esc_html_e( 'Mailer', 'check-email' ); ?></label></th>
212 <td>
213 <div class="ce_radio-container">
214 <label class="ce_radio-label <?php echo $mailer == 'smtp' ? "ck_radio_selected" : ''; ?>">
215 <input class="check_email_mailer_type_multi" type="radio" name="check-email-log-global[mailer]" value="smtp" <?php echo $mailer == 'smtp' ? "checked" : ''; ?> id="check-email-mailer-general-smtp">
216 <img src="<?php echo esc_attr($plugin_dir_url . 'assets/images/smtp.svg') ?>" alt="SMTP Icon">
217 <div class="ce_radio-title"><?php esc_html_e('General SMTP','check-email'); ?></div>
218 </label>
219
220 <label class="ce_radio-label <?php echo $mailer == 'outlook' ? "ck_radio_selected" : ''; ?>" >
221 <input class="check_email_mailer_type_multi" type="radio" name="check-email-log-global[mailer]" value="outlook" <?php echo $mailer == 'outlook' ? "checked" : ''; ?> id="check-email-mailer-outlook">
222 <img src="<?php echo esc_attr($plugin_dir_url . 'assets/images/microsoft.svg') ?>" alt="Outlook Icon">
223 <div class="ce_radio-title"><?php esc_html_e('365 / Outlook','check-email'); ?></div>
224 </label>
225 </div>
226 </td>
227 </tr>
228 <tr class="check_email_smtp_class" style="padding-left: 10px;">
229 <th scope="row" style="padding-left: 10px;"><?php esc_html_e('From', 'check-email'); ?></th>
230 <td>
231 <input id="check-email-smtp-from" type="text" name="check-email-log-global[smtp_from]" value="<?php echo isset($smtp_options['smtp_from']) ? esc_attr($smtp_options['smtp_from']) : "" ?>" size="35">
232 </td>
233 </tr>
234 <tr class="check_email_smtp_class">
235 <th scope="row" style="padding-left: 10px;"><?php esc_html_e('From Name', 'check-email'); ?></th>
236 <td>
237 <input id="check-email-smtp-from-name" type="text" name="check-email-log-global[smtp_from_name]" size="35" value="<?php echo isset($smtp_options['smtp_from_name']) ? esc_attr($smtp_options['smtp_from_name']) : "" ?>">
238 </td>
239 </tr>
240 <tr class="check_email_smtp_class">
241 <th scope="row" style="padding-left: 10px;"><?php esc_html_e('SMTP Host', 'check-email'); ?></th>
242 <td>
243 <input id="check-email-smtp-host" type="text" name="check-email-log-global[smtp_host]" value="<?php echo isset($smtp_options['smtp_host']) ? esc_attr($smtp_options['smtp_host']) : "" ?>" size="35">
244 </td>
245 </tr>
246 <tr class="check_email_smtp_class">
247 <th scope="row" style="padding-left: 10px;"><?php esc_html_e('SMTP Secure', 'check-email'); ?></th>
248 <td>
249 <?php
250 $secure_array = array('None' => '', 'SSL' => 'ssl', 'TLS' => 'tls');
251 $field_value = isset($smtp_options['smtp_secure']) ? $smtp_options['smtp_secure'] : "";
252 foreach ($secure_array as $sa_key => $sa_value) {
253 $checked = '';
254 $id = 'check-email-smtp-secure';
255 if ($sa_value == 'ssl') {
256 $id = 'check-email-smtp-secure-ssl';
257 } else if ($sa_value == 'tls') {
258 $id = 'check-email-smtp-secure-tls';
259 }
260 if ($field_value == $sa_value) {
261 $checked = 'checked';
262 }
263
264 ?>
265 <label for="<?php echo esc_attr($id); ?>" class="check-mail-smtp-secure-label">
266 <input id="<?php echo esc_attr($id); ?>" type="radio" name="check-email-log-global[smtp_secure]" value="<?php echo esc_attr($sa_value); ?>" <?php echo esc_attr($checked); ?>> <?php echo esc_html($sa_key); ?> </label>
267 <?php
268 }
269 ?>
270 </td>
271 </tr>
272 <tr class="check_email_smtp_class">
273 <?php $smtp_port = isset($smtp_options['smtp_port']) ? $smtp_options['smtp_port'] : ""; ?>
274 <th scope="row" style="padding-left: 10px;"><?php esc_html_e('SMTP Port', 'check-email'); ?></th>
275 <td>
276 <input id="check-email-smtp-port" type="text" name="check-email-log-global[smtp_port]" value="<?php echo esc_attr($smtp_port) ?>" size="35">
277 </td>
278 </tr>
279 <tr class="check_email_smtp_class">
280 <th scope="row" style="padding-left: 10px;"><?php esc_html_e('SMTP Authentication', 'check-email'); ?></th>
281 <td>
282 <?php
283 $secure_array = array('No' => 'no', 'Yes' => 'yes');
284 $field_value = isset($smtp_options['smtp_auth']) ? $smtp_options['smtp_auth'] : "yes";
285
286 foreach ($secure_array as $sa_key => $sa_value) {
287 $checked = '';
288 $id = 'check-email-smtp-secure-yes';
289 if ($sa_value == 'no') {
290 $id = 'check-email-smtp-secure-no';
291 }
292 if ($field_value == $sa_value) {
293 $checked = 'checked';
294 }
295 ?>
296 <label for="<?php echo esc_attr($id); ?>" class="check-mail-smtp-secure-label">
297 <input id="<?php echo esc_attr($id); ?>" type="radio" name="check-email-log-global[smtp_auth]" value="<?php echo esc_attr($sa_value); ?>" <?php echo esc_attr($checked); ?>> <?php echo esc_html($sa_key); ?> </label>
298 <?php
299 }
300 ?>
301 </td>
302 </tr>
303 <tr class="check_email_smtp_class">
304 <th scope="row" style="padding-left: 10px;"><?php esc_html_e('Username', 'check-email'); ?></th>
305 <?php $smtp_username = isset($smtp_options['smtp_username']) ? base64_decode($smtp_options['smtp_username']) : ''; ?>
306 <td>
307 <input id="check-email-smtp-username" type="text" name="check-email-log-global[smtp_username]" value="<?php echo esc_attr($smtp_username); ?>" size="35">
308 </td>
309 </tr>
310 <tr class="check_email_smtp_class">
311 <th scope="row" style="padding-left: 10px;"><?php esc_html_e('Password', 'check-email'); ?></th>
312 <?php $smtp_password = isset($smtp_options['smtp_password']) ? base64_decode($smtp_options['smtp_password']) : ''; ?>
313 <td>
314 <input id="check-email-smtp-password" type="password" name="check-email-log-global[smtp_password]" value="<?php echo esc_attr($smtp_password); ?>" size="35">
315 </td>
316 </tr>
317 </tbody>
318
319 <tbody id="check-email-outllook" style="<?php echo $enable_global != 'on' || $mailer != 'outlook' ? "display: none" : ''; ?>">
320 <tr class="check_email_smtp_from">
321 <th scope="row" style="padding-left: 10px;"><?php esc_html_e('Application ID', 'check-email'); ?></th>
322 <td>
323 <input class="regular-text" type="text" name="check-email-outlook-options[client_id]" value="<?php echo isset($outlook_smtp['client_id'])?esc_attr(base64_decode($outlook_smtp['client_id'])):"" ?>" >
324 </td>
325 </tr>
326 <tr class="">
327 <th scope="row" style="padding-left: 10px;"><?php esc_html_e('Client Secret', 'check-email'); ?></th>
328 <td>
329 <input class="regular-text" type="password" name="check-email-outlook-options[client_secret]" value="<?php echo isset($outlook_smtp['client_secret'])?esc_attr(base64_decode($outlook_smtp['client_secret'])):"" ?>">
330 </td>
331 </tr>
332 <tr class="">
333 <th scope="row" style="padding-left: 10px;"><?php esc_html_e('Redirect URI', 'check-email'); ?></th>
334 <td>
335
336 <input class="regular-text" type="text" readonly id="check_mail_request_uri" value="<?php echo (is_network_admin()) ? esc_url(network_admin_url()):esc_url(admin_url()) ?>" ><small id="check_mail_copy_text"></small>
337 <p><?php esc_html_e('This is the page on your site that you will be redirected to after you have authenticated with Microsoft.
338 You need to copy this URL into "Authentication > Redirect URIs" web field for your application on Microsoft Azure site for your project there.','check-email'); ?></p>
339 </td>
340 </tr>
341 <tr class="">
342 <td colspan="2">
343 <?php
344
345 if ( $auth->is_clients_saved() ) :
346 if ( $auth->is_auth_required() ) : ?>
347 <a href="<?php echo esc_url( $auth->get_auth_url() ); ?>" class="button button-secondary">
348 <?php esc_html_e( 'Allow plugin to send emails using your Microsoft account', 'check-email' ); ?>
349 </a>
350
351 <?php else : ?>
352
353 <button class="button" id="check_email_remove_outlook">
354 <?php esc_html_e( 'Remove OAuth Connection', 'check-email' ); ?>
355 </button>
356 <span class="">
357 <?php
358 $user = (isset( $outlook_smtp['user_details'] )) ? $outlook_smtp['user_details'] : [];
359
360 if ( isset( $user['email'] ) && isset( $user['display_name'] ) && ! empty( $user['email'] ) && ! empty( $user['display_name'] ) ) {
361 printf(
362 /* translators: %s - Display name and email, as received from oAuth provider. */
363 esc_html__( 'Connected as %s', 'check-email' ),
364 '<code>' . esc_html( $user['display_name'] . ' <' . $user['email'] . '>' ) . '</code>'
365 );
366 }
367 ?>
368 </span>
369 <p class="desc">
370 <?php esc_html_e( 'Removing the OAuth connection will give you an ability to redo the OAuth connection or link to another Microsoft account.', 'check-email' ); ?>
371 </p>
372
373 <?php endif; ?>
374 <?php
375 endif;
376 ?>
377 </td>
378 </tr>
379 </tbody>
380
381
382 <?php endif; ?>
383 </table>
384 <?php submit_button(); ?>
385 </form>
386 </div>
387 </div>
388 <?php
389 }
390
391
392
393
394
395 public function ck_mail_network_enqueue_scripts() {
396 $check_email = wpchill_check_email();
397 $plugin_dir_url = plugin_dir_url($check_email->get_plugin_file());
398 $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
399 wp_register_script(
400 'ck-network-admin-js',
401 $plugin_dir_url . 'assets/js/network-admin'. $suffix .'.js',
402 array(),
403 $check_email->get_version(),
404 true
405 );
406
407 wp_localize_script('ck-network-admin-js', 'network_admin_setting', array(
408 // 'ajaxUrl' => network_admin_url( 'admin-ajax.php' ),
409 'ajaxUrl' => admin_url('admin-ajax.php'),
410 'nonce' => wp_create_nonce('ck_mail_ajax_check_nonce'),
411 ));
412 wp_enqueue_script( 'ck-network-admin-js' );
413 }
414 }
415