DB
2 months ago
Request
2 months ago
UI
2 months ago
Auth.php
2 months ago
Check_Email_Admin_Capability_Giver.php
2 months ago
Check_Email_Export_Log.php
2 months ago
Check_Email_From_Handler.php
2 months ago
Check_Email_Log.php
2 months ago
Check_Email_Logger.php
2 months ago
Check_Email_Multisite.php
2 months ago
Check_Email_Review.php
2 months ago
Loadie.php
2 months ago
Check_Email_Multisite.php
433 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'] ) && strpos(sanitize_text_field( wp_unslash($_GET['state'])), 'check-email-nonce_') !== false ) { |
| 26 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form |
| 27 | $state = str_replace("check-email-nonce_", "", sanitize_text_field( wp_unslash($_GET['state']) ) ); |
| 28 | $nonce = $state; |
| 29 | $smtp_options = get_site_option('check-email-log-global-smtp'); |
| 30 | if (isset($smtp_options['enable_global']) && ! empty($smtp_options['enable_global']) && is_multisite()) { |
| 31 | $redirect_url = network_admin_url('admin.php?page=check-mail-global-settings&tab=smtp' ); |
| 32 | }else{ |
| 33 | $redirect_url = admin_url('admin.php?page=check-email-settings&tab=smtp' ); |
| 34 | } |
| 35 | |
| 36 | if ( ! wp_verify_nonce( $nonce, 'ck_mail_outlook_check_nonce' ) ) { |
| 37 | $url = add_query_arg( 'error', 'Microsoft invalid nonce', $redirect_url ); |
| 38 | wp_safe_redirect( $url ); |
| 39 | exit; |
| 40 | } |
| 41 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form |
| 42 | $auth = new Auth( 'outlook' ); |
| 43 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form |
| 44 | $auth->update_auth_code( sanitize_text_field( wp_unslash( $_GET['code'] ) ) ); |
| 45 | wp_safe_redirect( $redirect_url ); |
| 46 | exit; |
| 47 | } |
| 48 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form |
| 49 | if ( isset( $_GET['error_description'] ) ) { |
| 50 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form |
| 51 | $error_message = sanitize_text_field( wp_unslash( $_GET['error_description'] ) ); |
| 52 | if (isset($smtp_options['enable_global']) && ! empty($smtp_options['enable_global']) && is_multisite()) { |
| 53 | $redirect_url = network_admin_url('admin.php?page=check-mail-global-settings&tab=smtp' ); |
| 54 | }else{ |
| 55 | $redirect_url = admin_url('admin.php?page=check-email-settings&tab=smtp' ); |
| 56 | } |
| 57 | $url = add_query_arg( 'error', $error_message, $redirect_url ); |
| 58 | wp_safe_redirect( $url ); |
| 59 | exit; |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | public function ck_mail_network_settings_menu() { |
| 64 | add_menu_page( |
| 65 | esc_html__('Check & Log Email', 'check-email'), |
| 66 | esc_html__('Check & Log Email', 'check-email'), |
| 67 | 'manage_check_email', |
| 68 | 'check-mail-global-settings', |
| 69 | [$this, 'render_page'], |
| 70 | 'dashicons-email-alt', |
| 71 | 26 |
| 72 | ); |
| 73 | } |
| 74 | |
| 75 | function render_page() { |
| 76 | $check_email = wpchill_check_email(); |
| 77 | $plugin_dir_url = plugin_dir_url( $check_email->get_plugin_file() ); |
| 78 | $smtp_options = []; |
| 79 | $outlook_smtp = []; |
| 80 | $enable_smtp = ""; |
| 81 | $enable_global = ""; |
| 82 | $mailer = "smtp"; |
| 83 | $auth = new Auth( 'outlook' ); |
| 84 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form |
| 85 | $tab = isset( $_GET['tab']) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : 'general'; |
| 86 | if (! empty(get_site_option( 'check-email-log-global-smtp') ) ) { |
| 87 | $smtp_options = get_site_option( 'check-email-log-global-smtp'); |
| 88 | $enable_smtp = isset($smtp_options['enable_smtp'])? $smtp_options['enable_smtp'] : ''; |
| 89 | $enable_global = isset($smtp_options['enable_global'])? $smtp_options['enable_global'] : ''; |
| 90 | $mailer = isset($smtp_options['mailer'])?$smtp_options['mailer']:'smtp'; |
| 91 | if ( $mailer == 'outlook' ) { |
| 92 | $outlook_smtp = $auth->get_mailer_option(); |
| 93 | } |
| 94 | }?> |
| 95 | |
| 96 | <div class="wrap"> |
| 97 | <nav class="nav-tab-wrapper"> |
| 98 | <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> |
| 99 | <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> |
| 100 | </nav> |
| 101 | <div class="tab-content"> |
| 102 | <?php |
| 103 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form |
| 104 | if (isset( $_GET['error_description'] ) ) { |
| 105 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form |
| 106 | $error_message = sanitize_text_field( wp_unslash( $_GET['error_description'] ) ); |
| 107 | ?> <div class="notice notice-error is-dismissible"> |
| 108 | <h3><?php esc_html_e( 'Its an error to linking with microsoft 365 / outlook', 'check-email' ); ?></h3> |
| 109 | <p><?php echo esc_html( $error_message ); ?></p> |
| 110 | </div> |
| 111 | <?php |
| 112 | } |
| 113 | ?> |
| 114 | <form method="post" id="my-network-settings-form"> |
| 115 | <?php wp_nonce_field('update_network_settings', 'ck_mail_ajax_check_nonce'); ?> |
| 116 | <table class="form-table"> |
| 117 | <thead> |
| 118 | <tr valign="top"> |
| 119 | <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> |
| 120 | <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> |
| 121 | </tr> |
| 122 | </thead> |
| 123 | <?php if( 'general' == $tab ) : ?> |
| 124 | |
| 125 | <tbody id="check-email-global-smtp-form" style="<?php echo $enable_global != 'on' ? "display: none" : ''; ?>"> |
| 126 | |
| 127 | <tr> |
| 128 | |
| 129 | <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> |
| 130 | |
| 131 | <td> |
| 132 | |
| 133 | <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" : ''; ?> /> |
| 134 | |
| 135 | <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> |
| 136 | |
| 137 | </td> |
| 138 | |
| 139 | </tr> |
| 140 | |
| 141 | <tr class="cm_global_override"> |
| 142 | |
| 143 | <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> |
| 144 | |
| 145 | <td> |
| 146 | |
| 147 | <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"> |
| 148 | |
| 149 | </td> |
| 150 | |
| 151 | </tr> |
| 152 | |
| 153 | <tr class="cm_global_override"> |
| 154 | |
| 155 | <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> |
| 156 | |
| 157 | <td> |
| 158 | |
| 159 | <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"> |
| 160 | |
| 161 | </td> |
| 162 | |
| 163 | </tr> |
| 164 | |
| 165 | <tr> |
| 166 | |
| 167 | <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> |
| 168 | |
| 169 | <td> |
| 170 | |
| 171 | <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> |
| 172 | |
| 173 | </td> |
| 174 | |
| 175 | </tr> |
| 176 | |
| 177 | <tr class="cm_global_forward"> |
| 178 | |
| 179 | <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> |
| 180 | |
| 181 | <td> |
| 182 | |
| 183 | <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"> |
| 184 | |
| 185 | </td> |
| 186 | |
| 187 | </tr> |
| 188 | |
| 189 | <tr class="cm_global_forward"> |
| 190 | |
| 191 | <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> |
| 192 | |
| 193 | <td> |
| 194 | |
| 195 | <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"> |
| 196 | |
| 197 | </td> |
| 198 | |
| 199 | </tr> |
| 200 | |
| 201 | <tr class="cm_global_forward"> |
| 202 | |
| 203 | <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> |
| 204 | |
| 205 | <td> |
| 206 | |
| 207 | <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"> |
| 208 | |
| 209 | </td> |
| 210 | |
| 211 | </tr> |
| 212 | |
| 213 | </tbody> |
| 214 | |
| 215 | <?php endif; ?> |
| 216 | |
| 217 | <?php if( 'smtp' == $tab ) : ?> |
| 218 | <tbody id="check-email-global-smtp-form" style="<?php echo $enable_global != 'on' ? "display: none" : ''; ?>"> |
| 219 | <tr class="check_email_mailer"> |
| 220 | <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> |
| 221 | <td> |
| 222 | <div class="ce_radio-container"> |
| 223 | <label class="ce_radio-label <?php echo $mailer == 'smtp' ? "ck_radio_selected" : ''; ?>"> |
| 224 | <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"> |
| 225 | <?php // phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage ?> |
| 226 | <img src="<?php echo esc_attr($plugin_dir_url . 'assets/images/smtp.svg') ?>" alt="SMTP Icon"> |
| 227 | <div class="ce_radio-title"><?php esc_html_e('General SMTP','check-email'); ?></div> |
| 228 | </label> |
| 229 | |
| 230 | <label class="ce_radio-label <?php echo $mailer == 'outlook' ? "ck_radio_selected" : ''; ?>" > |
| 231 | <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"> |
| 232 | <?php // phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage ?> |
| 233 | <img src="<?php echo esc_attr($plugin_dir_url . 'assets/images/microsoft.svg') ?>" alt="Outlook Icon"> |
| 234 | <div class="ce_radio-title"><?php esc_html_e('365 / Outlook','check-email'); ?></div> |
| 235 | </label> |
| 236 | |
| 237 | <label class="ce_radio-label <?php echo $mailer == 'gmail' ? "ck_radio_selected" : ''; ?>" > |
| 238 | <input class="check_email_mailer_type_multi" type="radio" name="check-email-smtp-options[mailer]" value="gmail" <?php echo $mailer == 'gmail' ? "checked" : ''; ?>> |
| 239 | <?php // phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage ?> |
| 240 | <img src="<?php echo esc_attr($plugin_dir_url . 'assets/images/gmail.png') ?>" alt="Gmail Icon"> |
| 241 | <div class="ce_radio-title"><?php esc_html_e('Gmail','check-email'); ?></div> |
| 242 | </label> |
| 243 | </div> |
| 244 | </td> |
| 245 | </tr> |
| 246 | <tr class="check_email_smtp_class" style="padding-left: 10px;"> |
| 247 | <th scope="row" style="padding-left: 10px;"><?php esc_html_e('From', 'check-email'); ?></th> |
| 248 | <td> |
| 249 | <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"> |
| 250 | </td> |
| 251 | </tr> |
| 252 | <tr class="check_email_smtp_class"> |
| 253 | <th scope="row" style="padding-left: 10px;"><?php esc_html_e('From Name', 'check-email'); ?></th> |
| 254 | <td> |
| 255 | <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']) : "" ?>"> |
| 256 | </td> |
| 257 | </tr> |
| 258 | <tr class="check_email_smtp_class"> |
| 259 | <th scope="row" style="padding-left: 10px;"><?php esc_html_e('SMTP Host', 'check-email'); ?></th> |
| 260 | <td> |
| 261 | <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"> |
| 262 | </td> |
| 263 | </tr> |
| 264 | <tr class="check_email_smtp_class"> |
| 265 | <th scope="row" style="padding-left: 10px;"><?php esc_html_e('SMTP Secure', 'check-email'); ?></th> |
| 266 | <td> |
| 267 | <?php |
| 268 | $secure_array = array('None' => '', 'SSL' => 'ssl', 'TLS' => 'tls'); |
| 269 | $field_value = isset($smtp_options['smtp_secure']) ? $smtp_options['smtp_secure'] : ""; |
| 270 | foreach ($secure_array as $sa_key => $sa_value) { |
| 271 | $checked = ''; |
| 272 | $id = 'check-email-smtp-secure'; |
| 273 | if ($sa_value == 'ssl') { |
| 274 | $id = 'check-email-smtp-secure-ssl'; |
| 275 | } else if ($sa_value == 'tls') { |
| 276 | $id = 'check-email-smtp-secure-tls'; |
| 277 | } |
| 278 | if ($field_value == $sa_value) { |
| 279 | $checked = 'checked'; |
| 280 | } |
| 281 | |
| 282 | ?> |
| 283 | <label for="<?php echo esc_attr($id); ?>" class="check-mail-smtp-secure-label"> |
| 284 | <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> |
| 285 | <?php |
| 286 | } |
| 287 | ?> |
| 288 | </td> |
| 289 | </tr> |
| 290 | <tr class="check_email_smtp_class"> |
| 291 | <?php $smtp_port = isset($smtp_options['smtp_port']) ? $smtp_options['smtp_port'] : ""; ?> |
| 292 | <th scope="row" style="padding-left: 10px;"><?php esc_html_e('SMTP Port', 'check-email'); ?></th> |
| 293 | <td> |
| 294 | <input id="check-email-smtp-port" type="text" name="check-email-log-global[smtp_port]" value="<?php echo esc_attr($smtp_port) ?>" size="35"> |
| 295 | </td> |
| 296 | </tr> |
| 297 | <tr class="check_email_smtp_class"> |
| 298 | <th scope="row" style="padding-left: 10px;"><?php esc_html_e('SMTP Authentication', 'check-email'); ?></th> |
| 299 | <td> |
| 300 | <?php |
| 301 | $secure_array = array('No' => 'no', 'Yes' => 'yes'); |
| 302 | $field_value = isset($smtp_options['smtp_auth']) ? $smtp_options['smtp_auth'] : "yes"; |
| 303 | |
| 304 | foreach ($secure_array as $sa_key => $sa_value) { |
| 305 | $checked = ''; |
| 306 | $id = 'check-email-smtp-secure-yes'; |
| 307 | if ($sa_value == 'no') { |
| 308 | $id = 'check-email-smtp-secure-no'; |
| 309 | } |
| 310 | if ($field_value == $sa_value) { |
| 311 | $checked = 'checked'; |
| 312 | } |
| 313 | ?> |
| 314 | <label for="<?php echo esc_attr($id); ?>" class="check-mail-smtp-secure-label"> |
| 315 | <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> |
| 316 | <?php |
| 317 | } |
| 318 | ?> |
| 319 | </td> |
| 320 | </tr> |
| 321 | <tr class="check_email_smtp_class"> |
| 322 | <th scope="row" style="padding-left: 10px;"><?php esc_html_e('Username', 'check-email'); ?></th> |
| 323 | <?php $smtp_username = isset($smtp_options['smtp_username']) ? base64_decode($smtp_options['smtp_username']) : ''; ?> |
| 324 | <td> |
| 325 | <input id="check-email-smtp-username" type="text" name="check-email-log-global[smtp_username]" value="<?php echo esc_attr($smtp_username); ?>" size="35"> |
| 326 | </td> |
| 327 | </tr> |
| 328 | <tr class="check_email_smtp_class"> |
| 329 | <th scope="row" style="padding-left: 10px;"><?php esc_html_e('Password', 'check-email'); ?></th> |
| 330 | <?php $smtp_password = isset($smtp_options['smtp_password']) ? base64_decode($smtp_options['smtp_password']) : ''; ?> |
| 331 | <td> |
| 332 | <input id="check-email-smtp-password" type="password" name="check-email-log-global[smtp_password]" value="<?php echo esc_attr($smtp_password); ?>" size="35"> |
| 333 | </td> |
| 334 | </tr> |
| 335 | </tbody> |
| 336 | |
| 337 | <tbody id="check-email-outllook" style="<?php echo $enable_global != 'on' || $mailer != 'outlook' ? "display: none" : ''; ?>"> |
| 338 | <tr class="check_email_smtp_from"> |
| 339 | <th scope="row" style="padding-left: 10px;"><?php esc_html_e('Application ID', 'check-email'); ?></th> |
| 340 | <td> |
| 341 | <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'])):"" ?>" > |
| 342 | </td> |
| 343 | </tr> |
| 344 | <tr class=""> |
| 345 | <th scope="row" style="padding-left: 10px;"><?php esc_html_e('Client Secret', 'check-email'); ?></th> |
| 346 | <td> |
| 347 | <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'])):"" ?>"> |
| 348 | </td> |
| 349 | </tr> |
| 350 | <tr class=""> |
| 351 | <th scope="row" style="padding-left: 10px;"><?php esc_html_e('Redirect URI', 'check-email'); ?></th> |
| 352 | <td> |
| 353 | |
| 354 | <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> |
| 355 | <p><?php esc_html_e('This is the page on your site that you will be redirected to after you have authenticated with Microsoft. |
| 356 | 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> |
| 357 | </td> |
| 358 | </tr> |
| 359 | <tr class=""> |
| 360 | <td colspan="2"> |
| 361 | <?php |
| 362 | |
| 363 | if ( $auth->is_clients_saved() ) : |
| 364 | if ( $auth->is_auth_required() ) : ?> |
| 365 | <a href="<?php echo esc_url( $auth->get_auth_url() ); ?>" class="button button-secondary"> |
| 366 | <?php esc_html_e( 'Allow plugin to send emails using your Microsoft account', 'check-email' ); ?> |
| 367 | </a> |
| 368 | |
| 369 | <?php else : ?> |
| 370 | |
| 371 | <button class="button" id="check_email_remove_outlook"> |
| 372 | <?php esc_html_e( 'Remove OAuth Connection', 'check-email' ); ?> |
| 373 | </button> |
| 374 | <span class=""> |
| 375 | <?php |
| 376 | $user = (isset( $outlook_smtp['user_details'] )) ? $outlook_smtp['user_details'] : []; |
| 377 | |
| 378 | if ( isset( $user['email'] ) && isset( $user['display_name'] ) && ! empty( $user['email'] ) && ! empty( $user['display_name'] ) ) { |
| 379 | printf( |
| 380 | /* translators: %s - Display name and email, as received from oAuth provider. */ |
| 381 | esc_html__( 'Connected as %s', 'check-email' ), |
| 382 | '<code>' . esc_html( $user['display_name'] . ' <' . $user['email'] . '>' ) . '</code>' |
| 383 | ); |
| 384 | } |
| 385 | ?> |
| 386 | </span> |
| 387 | <p class="desc"> |
| 388 | <?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' ); ?> |
| 389 | </p> |
| 390 | |
| 391 | <?php endif; ?> |
| 392 | <?php |
| 393 | endif; |
| 394 | ?> |
| 395 | </td> |
| 396 | </tr> |
| 397 | </tbody> |
| 398 | |
| 399 | |
| 400 | <?php endif; ?> |
| 401 | </table> |
| 402 | <?php submit_button(); ?> |
| 403 | </form> |
| 404 | </div> |
| 405 | </div> |
| 406 | <?php |
| 407 | } |
| 408 | |
| 409 | |
| 410 | |
| 411 | |
| 412 | |
| 413 | public function ck_mail_network_enqueue_scripts() { |
| 414 | $check_email = wpchill_check_email(); |
| 415 | $plugin_dir_url = plugin_dir_url($check_email->get_plugin_file()); |
| 416 | $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
| 417 | wp_register_script( |
| 418 | 'ck-network-admin-js', |
| 419 | $plugin_dir_url . 'assets/js/network-admin'. $suffix .'.js', |
| 420 | array(), |
| 421 | $check_email->get_version(), |
| 422 | true |
| 423 | ); |
| 424 | |
| 425 | wp_localize_script('ck-network-admin-js', 'network_admin_setting', array( |
| 426 | // 'ajaxUrl' => network_admin_url( 'admin-ajax.php' ), |
| 427 | 'ajaxUrl' => admin_url('admin-ajax.php'), |
| 428 | 'nonce' => wp_create_nonce('ck_mail_ajax_check_nonce'), |
| 429 | )); |
| 430 | wp_enqueue_script( 'ck-network-admin-js' ); |
| 431 | } |
| 432 | } |
| 433 |