'POST', 'body' => [ 'client_id' => $client_id, 'client_secret' => $client_secret, 'code' => $code, 'redirect_uri' => $redirect_uri, 'grant_type' => 'authorization_code' ] ]; if ($state === 'google') { $token_url = 'https://oauth2.googleapis.com/token'; } elseif ($state === 'microsoft') { $token_url = 'https://login.microsoftonline.com/common/oauth2/v2.0/token'; } if (empty($token_url)) return; $response = wp_remote_post($token_url, $args); if ( !is_wp_error($response) ) { $body = json_decode(wp_remote_retrieve_body($response), true); if ( isset($body['refresh_token']) ) { $settings['optOAuthRefreshToken_' . $state] = AIO_Crypto::encrypt($body['refresh_token']); update_option('aio_options', $settings); // Redirect to clean URL wp_redirect($redirect_uri); exit; } } } public function w2wSmtpCheckHandler(){ check_ajax_referer( 'aio-smtp-check-nonce', 'security' ); if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( __( 'You do not have sufficient permissions to access this page.', 'aio' ) ); } $recipient = sanitize_email($_POST['your_email']); if ( ! is_email( $recipient ) ) { wp_send_json_error( __( 'Invalid email address.', 'aio' ) ); } $subject = __('AIO Tool: SMTP Test Connection', 'aio' ); $headers = array('Content-Type: text/html; charset=UTF-8'); $message = '
'; // Inject PHPMailer debug interceptor add_action( 'phpmailer_init', function( $phpmailer ) { $phpmailer->SMTPDebug = 2; // Enable verbose debug output $phpmailer->Debugoutput = 'html'; }); ob_start(); try { $result = wp_mail($recipient, $subject, $message, $headers); $debug_log = ob_get_clean(); $debug_log = strip_tags(str_replace("