403Webshell
Server IP : 172.67.158.161  /  Your IP : 3.142.134.23
Web Server : LiteSpeed
System : Linux business53.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : giankuin ( 1871)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/giankuin/khowordpress.com/wp-content/plugins/wp-mail-smtp/src/Admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/giankuin/khowordpress.com/wp-content/plugins/wp-mail-smtp/src/Admin/SetupWizard.php
<?php

namespace WPMailSMTP\Admin;

use Plugin_Upgrader;
use WPMailSMTP\Admin\Pages\TestTab;
use WPMailSMTP\Connect;
use WPMailSMTP\Helpers\Helpers;
use WPMailSMTP\Helpers\PluginImportDataRetriever;
use WPMailSMTP\Options;
use WPMailSMTP\UsageTracking\UsageTracking;
use WPMailSMTP\WP;
use WPMailSMTP\Reports\Emails\Summary as SummaryReportEmail;
use WPMailSMTP\Tasks\Reports\SummaryEmailTask as SummaryReportEmailTask;

/**
 * Class for the plugin's Setup Wizard.
 *
 * @since 2.6.0
 */
class SetupWizard {

	/**
	 * The WP Option key for storing setup wizard stats.
	 *
	 * @since 3.1.0
	 */
	const STATS_OPTION_KEY = 'wp_mail_smtp_setup_wizard_stats';

	/**
	 * Run all the hooks needed for the Setup Wizard.
	 *
	 * @since 2.6.0
	 */
	public function hooks() {

		add_action( 'admin_init', [ $this, 'maybe_load_wizard' ] );
		add_action( 'admin_init', [ $this, 'maybe_redirect_after_activation' ], 9999 );
		add_action( 'admin_menu', [ $this, 'add_dashboard_page' ], 20 );
		add_filter( 'removable_query_args', [ $this, 'maybe_disable_automatic_query_args_removal' ] );

		// API AJAX callbacks.
		add_action( 'wp_ajax_wp_mail_smtp_vue_wizard_steps_started', [ $this, 'wizard_steps_started' ] );
		add_action( 'wp_ajax_wp_mail_smtp_vue_get_settings', [ $this, 'get_settings' ] );
		add_action( 'wp_ajax_wp_mail_smtp_vue_update_settings', [ $this, 'update_settings' ] );
		add_action( 'wp_ajax_wp_mail_smtp_vue_import_settings', [ $this, 'import_settings' ] );
		add_action( 'wp_ajax_wp_mail_smtp_vue_get_oauth_url', [ $this, 'get_oauth_url' ] );
		add_action( 'wp_ajax_wp_mail_smtp_vue_remove_oauth_connection', [ $this, 'remove_oauth_connection' ] );
		add_action( 'wp_ajax_wp_mail_smtp_vue_get_connected_data', [ $this, 'get_connected_data' ] );
		add_action( 'wp_ajax_wp_mail_smtp_vue_install_plugin', [ $this, 'install_plugin' ] );
		add_action( 'wp_ajax_wp_mail_smtp_vue_get_partner_plugins_info', [ $this, 'get_partner_plugins_info' ] );
		add_action( 'wp_ajax_wp_mail_smtp_vue_subscribe_to_newsletter', [ $this, 'subscribe_to_newsletter' ] );
		add_action( 'wp_ajax_wp_mail_smtp_vue_upgrade_plugin', [ $this, 'upgrade_plugin' ] );
		add_action( 'wp_ajax_wp_mail_smtp_vue_check_mailer_configuration', [ $this, 'check_mailer_configuration' ] );
		add_action( 'wp_ajax_wp_mail_smtp_vue_send_feedback', [ $this, 'send_feedback' ] );
	}

	/**
	 * Get the URL of the Setup Wizard page.
	 *
	 * @since 2.6.0
	 *
	 * @return string
	 */
	public static function get_site_url() {

		return wp_mail_smtp()->get_admin()->get_admin_page_url() . '-setup-wizard';
	}

	/**
	 * Checks if the Wizard should be loaded in current context.
	 *
	 * @since 2.6.0
	 */
	public function maybe_load_wizard() {

		// Check for wizard-specific parameter
		// Allow plugins to disable the setup wizard
		// Check if current user is allowed to save settings.
		if (
			! (
				isset( $_GET['page'] ) && // phpcs:ignore WordPress.Security.NonceVerification.Recommended
				Area::SLUG . '-setup-wizard' === $_GET['page'] && // phpcs:ignore WordPress.Security.NonceVerification.Recommended
				$this->should_setup_wizard_load() &&
				current_user_can( wp_mail_smtp()->get_capability_manage_options() )
			)
		) {
			return;
		}

		// Don't load the interface if doing an ajax call.
		if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
			return;
		}

		set_current_screen();

		// Remove an action in the Gutenberg plugin ( not core Gutenberg ) which throws an error.
		remove_action( 'admin_print_styles', 'gutenberg_block_editor_admin_print_styles' );

		// Remove hooks for deprecated functions in WordPress 6.4.0.
		remove_action( 'admin_print_styles', 'print_emoji_styles' );
		remove_action( 'admin_head', 'wp_admin_bar_header' );

		$this->load_setup_wizard();
	}

	/**
	 * Maybe redirect to the setup wizard after plugin activation on a new install.
	 *
	 * @since 2.6.0
	 */
	public function maybe_redirect_after_activation() { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh

		if ( wp_doing_ajax() || wp_doing_cron() ) {
			return;
		}

		// Check if we should consider redirection.
		if ( ! get_transient( 'wp_mail_smtp_activation_redirect' ) ) {
			return;
		}

		delete_transient( 'wp_mail_smtp_activation_redirect' );

		// Check option to disable setup wizard redirect.
		if ( get_option( 'wp_mail_smtp_activation_prevent_redirect' ) ) {
			return;
		}

		// Only do this for single site installs if Network Wide setting is not enabled.
		if ( isset( $_GET['activate-multi'] ) || is_network_admin() || WP::use_global_plugin_settings() ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
			return;
		}

		// Don't redirect if the Setup Wizard is disabled.
		if ( ! $this->should_setup_wizard_load() ) {
			return;
		}

		// Initial install.
		if ( get_option( 'wp_mail_smtp_initial_version' ) === WPMS_PLUGIN_VER ) {
			update_option( 'wp_mail_smtp_activation_prevent_redirect', true );
			wp_safe_redirect( self::get_site_url() );
			exit;
		}
	}

	/**
	 * Register page through WordPress's hooks.
	 *
	 * Create a dummy admin page, where the Setup Wizard app can be displayed,
	 * but it's not visible in the admin dashboard menu.
	 *
	 * @since 2.6.0
	 */
	public function add_dashboard_page() {

		if ( ! $this->should_setup_wizard_load() ) {
			return;
		}

		add_submenu_page( '', '', '', wp_mail_smtp()->get_capability_manage_options(), Area::SLUG . '-setup-wizard', '' );
	}

	/**
	 * Load the Setup Wizard template.
	 *
	 * @since 2.6.0
	 */
	private function load_setup_wizard() {

		/**
		 * Before setup wizard load.
		 *
		 * @since 2.8.0
		 *
		 * @param \WPMailSMTP\Admin\SetupWizard  $setup_wizard SetupWizard instance.
		 */
		do_action( 'wp_mail_smtp_admin_setup_wizard_load_setup_wizard_before', $this );

		$this->enqueue_scripts();

		$this->setup_wizard_header();
		$this->setup_wizard_content();
		$this->setup_wizard_footer();

		/**
		 * After setup wizard load.
		 *
		 * @since 2.8.0
		 *
		 * @param \WPMailSMTP\Admin\SetupWizard  $setup_wizard SetupWizard instance.
		 */
		do_action( 'wp_mail_smtp_admin_setup_wizard_load_setup_wizard_after', $this );

		exit;
	}

	/**
	 * Load the scripts needed for the Setup Wizard.
	 *
	 * @since 2.6.0
	 */
	public function enqueue_scripts() {

		if ( ! defined( 'WPMS_VUE_LOCAL_DEV' ) || ! WPMS_VUE_LOCAL_DEV ) {
			$rtl = is_rtl() ? '.rtl' : '';
			wp_enqueue_style( 'wp-mail-smtp-vue-style', wp_mail_smtp()->assets_url . '/vue/css/wizard' . $rtl . '.min.css', [], WPMS_PLUGIN_VER );
		}

		wp_enqueue_script( 'wp-mail-smtp-vue-vendors', wp_mail_smtp()->assets_url . '/vue/js/chunk-vendors.min.js', [], WPMS_PLUGIN_VER, true );
		wp_enqueue_script( 'wp-mail-smtp-vue-script', wp_mail_smtp()->assets_url . '/vue/js/wizard.min.js', [ 'wp-mail-smtp-vue-vendors' ], WPMS_PLUGIN_VER, true );

		wp_localize_script(
			'wp-mail-smtp-vue-script',
			'wp_mail_smtp_vue',
			[
				'ajax_url'           => admin_url( 'admin-ajax.php' ),
				'nonce'              => wp_create_nonce( 'wpms-admin-nonce' ),
				'is_multisite'       => is_multisite(),
				'translations'       => WP::get_jed_locale_data( 'wp-mail-smtp' ),
				'exit_url'           => wp_mail_smtp()->get_admin()->get_admin_page_url(),
				'email_test_tab_url' => add_query_arg( 'tab', 'test', wp_mail_smtp()->get_admin()->get_admin_page_url( Area::SLUG . '-tools' ) ),
				'is_pro'             => wp_mail_smtp()->is_pro(),
				'is_ssl'             => is_ssl(),
				'license_exists'     => apply_filters( 'wp_mail_smtp_admin_setup_wizard_license_exists', false ),
				'plugin_version'     => WPMS_PLUGIN_VER,
				'other_smtp_plugins' => $this->detect_other_smtp_plugins(),
				'mailer_options'     => $this->prepare_mailer_options(),
				'defined_constants'  => $this->prepare_defined_constants(),
				'upgrade_link'       => wp_mail_smtp()->get_upgrade_link( 'setup-wizard' ),
				'versions'           => $this->prepare_versions_data(),
				'public_url'         => wp_mail_smtp()->assets_url . '/vue/',
				'current_user_email' => wp_get_current_user()->user_email,
				'completed_time'     => self::get_stats()['completed_time'],
				'education'          => [
					'upgrade_text'   => esc_html__( 'We\'re sorry, the %mailer% mailer is not available on your plan. Please upgrade to the PRO plan to unlock all these awesome features.', 'wp-mail-smtp' ),
					'upgrade_button' => esc_html__( 'Upgrade to Pro', 'wp-mail-smtp' ),
					'upgrade_url'    => add_query_arg( 'discount', 'SMTPLITEUPGRADE', wp_mail_smtp()->get_upgrade_link( '' ) ),
					'upgrade_bonus'  => sprintf(
						wp_kses( /* Translators: %s - discount value $50 */
							__( '<strong>Bonus:</strong> WP Mail SMTP users get <span class="highlight">%s off</span> regular price,<br>applied at checkout.', 'wp-mail-smtp' ),
							[
								'strong' => [],
								'span'   => [
									'class' => [],
								],
								'br'     => [],
							]
						),
						'$50'
					),
					'upgrade_doc'       => sprintf(
						'<a href="%1$s" target="_blank" rel="noopener noreferrer" class="already-purchased">%2$s</a>',
						// phpcs:ignore WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
						esc_url( wp_mail_smtp()->get_utm_url( 'https://wpmailsmtp.com/docs/how-to-upgrade-wp-mail-smtp-to-pro-version/', [ 'medium' => 'setup-wizard', 'content' => 'Wizard Pro Mailer Popup - Already purchased' ] ) ),
						esc_html__( 'Already purchased?', 'wp-mail-smtp' )
					)
				],
			]
		);
	}

	/**
	 * Outputs the simplified header used for the Setup Wizard.
	 *
	 * @since 2.6.0
	 */
	public function setup_wizard_header() {
		?>
		<!DOCTYPE html>
		<html <?php language_attributes(); ?>>
		<head>
			<meta name="viewport" content="width=device-width"/>
			<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
			<title><?php esc_html_e( 'WP Mail SMTP &rsaquo; Setup Wizard', 'wp-mail-smtp' ); ?></title>
			<?php do_action( 'admin_print_styles' ); ?>
			<?php do_action( 'admin_print_scripts' ); ?>
			<?php do_action( 'admin_head' ); ?>
		</head>
		<body class="wp-mail-smtp-setup-wizard">
		<?php
	}

	/**
	 * Outputs the content of the current step.
	 *
	 * @since 2.6.0
	 */
	public function setup_wizard_content() {
		$admin_url = is_network_admin() ? network_admin_url() : admin_url();

		$this->settings_error_page( 'wp-mail-smtp-vue-setup-wizard', '<a href="' . $admin_url . '">' . esc_html__( 'Go back to the Dashboard', 'wp-mail-smtp' ) . '</a>' );
		$this->settings_inline_js();
	}

	/**
	 * Outputs the simplified footer used for the Setup Wizard.
	 *
	 * @since 2.6.0
	 */
	public function setup_wizard_footer() {
		?>
		<?php wp_print_scripts( 'wp-mail-smtp-vue-script' ); ?>
		</body>
		</html>
		<?php
	}

	/**
	 * Error page HTML
	 *
	 * @since 2.6.0
	 *
	 * @param string $id     The HTML ID attribute of the main container div.
	 * @param string $footer The centered footer content.
	 */
	private function settings_error_page( $id = 'wp-mail-smtp-vue-site-settings', $footer = '' ) {

		$inline_logo_image = 'data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMSIgZGF0YS1uYW1lPSJMYXllciAxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNDIgNjAiPjxkZWZzPjxzdHlsZT4uY2xzLTExLC5jbHMtMTJ7ZmlsbC1ydWxlOmV2ZW5vZGR9LmNscy00e2ZpbGw6bm9uZX0uY2xzLTExe2ZpbGw6Izg2YTE5Nn0uY2xzLTEye2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MjloMS4xMnYtMS44NWgxLjQ3djEuODVoMS4zN3YxLjI5aC0xLjM3djMuNTVjMCAuNDYuMjIuOC42NC44YTEgMSAwIDAwLjY2LS4yNGwuMzUgMS4xYTEuOTEgMS45MSAwIDAxLTEuMzkuNDQgMS41NiAxLjU2IDAgMDEtMS43My0xLjc0em0tMTExLjcxLjg0YTIuODcgMi44NyAwIDAxLTIuMTkuOSAyLjI1IDIuMjUgMCAwMS0yLjM1LTIuMjQgMi4xOCAyLjE4IDAgMDEyLjM0LTIuMiAyLjggMi44IDAgMDEyLjE5Ljg2di0xYzAtLjc5LS42NC0xLjI2LTEuNTgtMS4yNmEyLjc5IDIuNzkgMCAwMC0yIC44NWwtLjYtMWE0LjA1IDQuMDUgMCAwMTIuODUtMS4wOWMxLjQ5IDAgMi44MS42MyAyLjgxIDIuNDV2NC40OEg2Mi4yem0wLTEuODNhMiAyIDAgMDAtMS42MS0uNyAxLjIzIDEuMjMgMCAxMDAgMi40MiAyIDIgMCAwMDEuNjEtLjd6IiBmaWxsPSIjOTk5Ii8+PC9zdmc+';

		if ( ! wp_mail_smtp()->is_pro() ) {
			$contact_url = 'https://wordpress.org/support/plugin/wp-mail-smtp/';
		} else {
			// phpcs:ignore WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
			$contact_url = esc_url( wp_mail_smtp()->get_utm_url( 'https://wpmailsmtp.com/contact/', [ 'medium' => 'setup-wizard', 'content' => 'Contact Us' ] ) );
		}

		?>
		<style type="text/css">
			#wp-mail-smtp-settings-area {
				visibility: hidden;
				animation: loadWpMailSMTPSettingsNoJSView 0s 2s forwards;
			}

			@keyframes loadWpMailSMTPSettingsNoJSView{
				to { visibility: visible; }
			}

			body {
				background: #F1F1F1;
				font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
				margin: 0;
			}

			#wp-mail-smtp-settings-area .wp-mail-smtp-setup-wizard-header {
				text-align: center;
				border-top: 4px solid #E27730;
			}

			#wp-mail-smtp-settings-area .wp-mail-smtp-setup-wizard-header h1 {
				margin: 0;
			}

			#wp-mail-smtp-settings-area .wp-mail-smtp-logo {
				display: inline-block;
				width: 320px;
				margin-top: 10px;
				padding: 0 10px;
			}

			#wp-mail-smtp-settings-area .wp-mail-smtp-logo img {
				width: 100%;
				height: 100%;
			}

			#wp-mail-smtp-settings-error-loading-area {
				box-sizing: border-box;
				max-width: 90%;
				width: auto;
				margin: 0 auto;
				background: #fff;
				border: 1px solid #DDDDDD;
				border-radius: 6px;
				-webkit-box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.05);
				box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.05);
				padding: 20px 30px;
			}

			#wp-mail-smtp-settings-area .wp-mail-smtp-error-footer {
				text-align: center;
				margin-top: 20px;
				font-size: 14px;
			}

			#wp-mail-smtp-settings-area .wp-mail-smtp-error-footer a {
				color: #999999;
			}

			#wp-mail-smtp-error-js h3 {
				font-size: 24px;
				font-weight: 500;
				line-height: 23px;
				margin: 0 0 15px;
				color: #444444;
			}

			#wp-mail-smtp-error-js p.info,
			#wp-mail-smtp-error-js ul.info {
				color: #777777;
				font-size: 16px;
				line-height: 23px;
				margin: 0 0 10px;
			}

			#wp-mail-smtp-error-js ul.info {
				margin: -10px 0 20px;
			}

			#wp-mail-smtp-error-js a.button {
				display: inline-block;
				background-color: #E27730;
				color: #ffffff;
				line-height: 22px;
				font-size: 16px;
				padding: 14px 30px;
				font-weight: 500;
				border-radius: 3px;
				border: none;
				cursor: pointer;
				text-decoration: none;
				margin-top: 7px;
			}

			#wp-mail-smtp-error-js a.button:hover {
				background-color: #c45e1b;
			}

			#wp-mail-smtp-error-js .medium-bold {
				font-weight: 500;
			}

			#wp-mail-smtp-nojs-error-message > div {
				border: 1px solid #DDDDDD;
				border-left: 4px solid #DC3232;
				color: #777777;
				font-size: 14px;
				padding: 18px 18px 18px 21px;
				font-weight: 300;
				text-align: left;
			}

			@media (min-width: 782px) {
				#wp-mail-smtp-settings-area .wp-mail-smtp-logo {
					margin-top: 50px;
					padding: 0;
				}

				#wp-mail-smtp-settings-error-loading-area {
					width: 650px;
					margin-top: 40px;
					padding: 52px 67px 49px;
				}

				#wp-mail-smtp-settings-area .wp-mail-smtp-error-footer {
					margin-top: 50px;
				}

				#wp-mail-smtp-error-js p.info {
					margin: 0 0 20px;
				}
			}
		</style>
		<!--[if IE]>
		<style>
			#wp-mail-smtp-settings-area{
				visibility: visible !important;
			}
		</style>
		<![endif]-->
		<div id="<?php echo esc_attr( $id ); ?>">
			<div id="wp-mail-smtp-settings-area" class="wp-mail-smtp-settings-area wpms-container">
				<header class="wp-mail-smtp-setup-wizard-header">
					<h1 class="wp-mail-smtp-setup-wizard-logo">
						<div class="wp-mail-smtp-logo">
							<img src="<?php echo esc_attr( $inline_logo_image ); ?>" alt="<?php esc_attr_e( 'WP Mail SMTP logo', 'wp-mail-smtp' ); ?>" class="wp-mail-smtp-logo-img">
						</div>
					</h1>
				</header>
				<div id="wp-mail-smtp-settings-error-loading-area-container">
					<div id="wp-mail-smtp-settings-error-loading-area">
						<div>
							<div id="wp-mail-smtp-error-js">
								<h3><?php esc_html_e( 'Whoops, something\'s not working.', 'wp-mail-smtp' ); ?></h3>
								<p class="info"><?php esc_html_e( 'It looks like something is preventing JavaScript from loading on your website. WP Mail SMTP requires JavaScript in order to give you the best possible experience.', 'wp-mail-smtp' ); ?></p>
								<p class="info">
									<?php esc_html_e( 'In order to fix this issue, please check each of the items below:', 'wp-mail-smtp' ); ?>
								</p>
								<ul class="info">
									<li><?php esc_html_e( 'If you are using an ad blocker, please disable it or whitelist the current page.', 'wp-mail-smtp' ); ?></li>
									<li><?php esc_html_e( 'If you aren\'t already using Chrome, Firefox, Safari, or Edge, then please try switching to one of these popular browsers.', 'wp-mail-smtp' ); ?></li>
									<li><?php esc_html_e( 'Confirm that your browser is updated to the latest version.', 'wp-mail-smtp' ); ?></li>
								</ul>
								<p class="info">
									<?php esc_html_e( 'If you\'ve checked each of these details and are still running into issues, then please get in touch with our support team. We’d be happy to help!', 'wp-mail-smtp' ); ?>
								</p>
								<div style="display: none;" id="wp-mail-smtp-nojs-error-message">
									<div>
										<strong style="font-weight: 500;" id="wp-mail-smtp-alert-message"></strong>
									</div>
									<p style="font-size: 14px;color: #777777;padding-bottom: 15px;"><?php esc_html_e( 'Copy the error message above and paste it in a message to the WP Mail SMTP support team.', 'wp-mail-smtp' ); ?></p>
								</div>
								<a href="<?php echo esc_url( $contact_url ); ?>" target="_blank" class="button" rel="noopener noreferrer">
									<?php esc_html_e( 'Contact Us', 'wp-mail-smtp' ); ?>
								</a>
							</div>
						</div>
					</div>
					<div class="wp-mail-smtp-error-footer">
						<?php echo wp_kses_post( $footer ); ?>
					</div>
				</div>
			</div>
		</div>
		<?php
	}

	/**
	 * Attempt to catch the js error preventing the Vue app from loading and displaying that message for better support.
	 *
	 * @since 2.6.0
	 */
	private function settings_inline_js() {
		?>
		<script type="text/javascript">
			window.onerror = function myErrorHandler( errorMsg, url, lineNumber ) {
				/* Don't try to put error in container that no longer exists post-vue loading */
				var message_container = document.getElementById( 'wp-mail-smtp-nojs-error-message' );
				if ( ! message_container ) {
					return false;
				}
				var message = document.getElementById( 'wp-mail-smtp-alert-message' );
				message.innerHTML = errorMsg;
				message_container.style.display = 'block';
				return false;
			}
		</script>
		<?php
	}

	/**
	 * Ajax handler for retrieving the plugin settings.
	 *
	 * @since 2.6.0
	 */
	public function get_settings() {

		check_ajax_referer( 'wpms-admin-nonce', 'nonce' );

		if ( ! current_user_can( wp_mail_smtp()->get_capability_manage_options() ) ) {
			wp_send_json_error( esc_html__( 'You don\'t have permission to change options for this WP site!', 'wp-mail-smtp' ) );
		}

		$options = Options::init();

		wp_send_json_success( $options->get_all() );
	}

	/**
	 * Ajax handler for starting the Setup Wizard steps.
	 *
	 * @since 3.1.0
	 */
	public function wizard_steps_started() {

		check_ajax_referer( 'wpms-admin-nonce', 'nonce' );

		if ( ! current_user_can( wp_mail_smtp()->get_capability_manage_options() ) ) {
			wp_send_json_error( esc_html__( 'You don\'t have permission to change options for this WP site!', 'wp-mail-smtp' ) );
		}

		self::update_stats(
			[
				'launched_time' => time(),
			]
		);

		wp_send_json_success();
	}

	/**
	 * Ajax handler for updating the settings.
	 *
	 * @since 2.6.0
	 */
	public function update_settings() {

		check_ajax_referer( 'wpms-admin-nonce', 'nonce' );

		if ( ! current_user_can( wp_mail_smtp()->get_capability_manage_options() ) ) {
			wp_send_json_error();
		}

		$options   = Options::init();
		$overwrite = ! empty( $_POST['overwrite'] );

		// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
		$value = isset( $_POST['value'] ) ? wp_slash( json_decode( wp_unslash( $_POST['value'] ), true ) ) : [];

		// Cancel summary report email task if summary report email was disabled.
		if (
			! SummaryReportEmail::is_disabled() &&
			isset( $value['general'][ SummaryReportEmail::SETTINGS_SLUG ] ) &&
			$value['general'][ SummaryReportEmail::SETTINGS_SLUG ] === true
		) {
			( new SummaryReportEmailTask() )->cancel();
		}

		/**
		 * Before updating settings in Setup Wizard.
		 *
		 * @since 3.3.0
		 *
		 * @param array $post POST data.
		 */
		do_action( 'wp_mail_smtp_admin_setup_wizard_update_settings', $value );

		$options->set( $value, false, $overwrite );

		wp_send_json_success();
	}

	/**
	 * Ajax handler for importing settings from other SMTP plugins.
	 *
	 * @since 2.6.0
	 */
	public function import_settings() {

		check_ajax_referer( 'wpms-admin-nonce', 'nonce' );

		if ( ! current_user_can( wp_mail_smtp()->get_capability_manage_options() ) ) {
			wp_send_json_error( esc_html__( 'You don\'t have permission to change options for this WP site!', 'wp-mail-smtp' ) );
		}

		$other_plugin = ! empty( $_POST['value'] ) ? sanitize_text_field( wp_unslash( $_POST['value'] ) ) : '';

		if ( empty( $other_plugin ) ) {
			wp_send_json_error();
		}

		$other_plugin_settings = ( new PluginImportDataRetriever( $other_plugin ) )->get();

		if ( empty( $other_plugin_settings ) ) {
			wp_send_json_error();
		}

		$options = Options::init();

		$options->set( $other_plugin_settings, false, false );

		wp_send_json_success();
	}

	/**
	 * Detect if any other SMTP plugin options are defined.
	 * Other SMTP plugins:
	 * - Easy WP SMTP
	 * - Post SMTP Mailer
	 * - SMTP Mailer
	 * - WP SMTP
	 * - FluentSMTP
	 *
	 * @since 2.6.0
	 * @since 3.2.0 Added FluentSMTP.
	 *
	 * @return array
	 */
	private function detect_other_smtp_plugins() {

		$data = [];

		$plugins = [
			'easy-smtp'        => 'swpsmtp_options',
			'post-smtp-mailer' => 'postman_options',
			'smtp-mailer'      => 'smtp_mailer_options',
			'wp-smtp'          => 'wp_smtp_options',
			'fluent-smtp'      => 'fluentmail-settings',
		];

		foreach ( $plugins as $plugin_slug => $plugin_options ) {
			$options = get_option( $plugin_options );

			if ( ! empty( $options ) ) {
				$data[] = $plugin_slug;
			}
		}

		return $data;
	}

	/**
	 * Prepare mailer options for all mailers.
	 *
	 * @since 2.6.0
	 * @since 3.10.0 Supply WPMS_AMAZONSES_DISPLAY_IDENTITIES constant value to control display of Amazon SES identity list.
	 * @since 3.11.0 Removed WPMS_AMAZONSES_DISPLAY_IDENTITIES constant handling.
	 *
	 * @return array
	 */
	private function prepare_mailer_options() {

		$data = [];

		foreach ( wp_mail_smtp()->get_providers()->get_options_all() as $provider ) {
			$data[ $provider->get_slug() ] = [
				'slug'        => $provider->get_slug(),
				'title'       => $provider->get_title(),
				'description' => $provider->get_description(),
				'edu_notice'  => $provider->get_notice( 'educational' ),
				'min_php'     => $provider->get_php_version(),
				'disabled'    => $provider->is_disabled(),
			];

			if ( $provider->get_slug() === 'gmail' ) {
				$data['gmail']['redirect_uri'] = \WPMailSMTP\Providers\Gmail\Auth::get_oauth_redirect_url();
			}
		}

		return apply_filters( 'wp_mail_smtp_admin_setup_wizard_prepare_mailer_options', $data );
	}

	/**
	 * AJAX callback for getting the oAuth authorization URL.
	 *
	 * @since 2.6.0
	 */
	public function get_oauth_url() { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh

		check_ajax_referer( 'wpms-admin-nonce', 'nonce' );

		if ( ! current_user_can( wp_mail_smtp()->get_capability_manage_options() ) ) {
			wp_send_json_error();
		}

		$data   = [];
		$mailer = ! empty( $_POST['mailer'] ) ? sanitize_text_field( wp_unslash( $_POST['mailer'] ) ) : '';

		// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
		$settings = isset( $_POST['settings'] ) ? wp_slash( json_decode( wp_unslash( $_POST['settings'] ), true ) ) : [];

		if ( empty( $mailer ) ) {
			wp_send_json_error();
		}

		$settings = array_merge( $settings, [ 'is_setup_wizard_auth' => true ] );

		$options = Options::init();
		$options->set( [ $mailer => $settings ], false, false );

		switch ( $mailer ) {
			case 'gmail':
				$auth = wp_mail_smtp()->get_providers()->get_auth( 'gmail' );

				if ( $auth->is_clients_saved() && $auth->is_auth_required() ) {
					$data['oauth_url'] = $auth->get_auth_url();
				}
				break;
		}

		$data = apply_filters( 'wp_mail_smtp_admin_setup_wizard_get_oauth_url', $data, $mailer );

		wp_send_json_success( array_merge( [ 'mailer' => $mailer ], $data ) );
	}

	/**
	 * AJAX callback for getting the oAuth connected data.
	 *
	 * @since 2.6.0
	 */
	public function get_connected_data() { // phpcs:ignore Generic.Metrics.NestingLevel.MaxExceeded

		check_ajax_referer( 'wpms-admin-nonce', 'nonce' );

		if ( ! current_user_can( wp_mail_smtp()->get_capability_manage_options() ) ) {
			wp_send_json_error();
		}

		$data   = [];
		$mailer = ! empty( $_POST['mailer'] ) ? sanitize_text_field( wp_unslash( $_POST['mailer'] ) ) : '';

		if ( empty( $mailer ) ) {
			wp_send_json_error();
		}

		switch ( $mailer ) {
			case 'gmail':
				$auth = wp_mail_smtp()->get_providers()->get_auth( 'gmail' );

				if ( $auth->is_clients_saved() && ! $auth->is_auth_required() ) {
					$user_info               = $auth->get_user_info();
					$data['connected_email'] = $user_info['email'];
				}
				break;
		}

		wp_send_json_success( array_merge( [ 'mailer' => $mailer ], $data ) );
	}

	/**
	 * AJAX callback for removing the oAuth authorization connection.
	 *
	 * @since 2.6.0
	 */
	public function remove_oauth_connection() { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh

		check_ajax_referer( 'wpms-admin-nonce', 'nonce' );

		if ( ! current_user_can( wp_mail_smtp()->get_capability_manage_options() ) ) {
			wp_send_json_error();
		}

		$mailer = ! empty( $_POST['mailer'] ) ? sanitize_text_field( wp_unslash( $_POST['mailer'] ) ) : '';

		if ( empty( $mailer ) ) {
			wp_send_json_error();
		}

		$options = Options::init();
		$old_opt = $options->get_all_raw();

		/*
		 * Since Gmail mailer uses the same settings array for both the custom app and One-Click Setup,
		 * we need to make sure we don't remove the wrong settings.
		 */
		if ( $mailer === 'gmail' ) {
			unset( $old_opt[ $mailer ]['access_token'] );
			unset( $old_opt[ $mailer ]['refresh_token'] );
			unset( $old_opt[ $mailer ]['user_details'] );
			unset( $old_opt[ $mailer ]['auth_code'] );
		} else {
			foreach ( $old_opt[ $mailer ] as $key => $value ) {
				// Unset everything except Client ID, Client Secret and Domain (for Zoho).
				if ( ! in_array( $key, [ 'domain', 'client_id', 'client_secret' ], true ) ) {
					unset( $old_opt[ $mailer ][ $key ] );
				}
			}
		}

		$options->set( $old_opt );

		wp_send_json_success();
	}

	/**
	 * AJAX callback for installing a plugin.
	 * Has to contain the `slug` POST parameter.
	 *
	 * @since 2.6.0
	 */
	public function install_plugin() { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.MaxExceeded

		check_ajax_referer( 'wpms-admin-nonce', 'nonce' );

		// Check for permissions.
		if ( ! current_user_can( 'install_plugins' ) ) {
			wp_send_json_error( esc_html__( 'Could not install the plugin. You don\'t have permission to install plugins.', 'wp-mail-smtp' ) );
		}

		if ( ! current_user_can( 'activate_plugins' ) ) {
			wp_send_json_error( esc_html__( 'Could not install the plugin. You don\'t have permission to activate plugins.', 'wp-mail-smtp' ) );
		}

		$slug = ! empty( $_POST['slug'] ) ? sanitize_text_field( wp_unslash( $_POST['slug'] ) ) : '';

		if ( empty( $slug ) ) {
			wp_send_json_error( esc_html__( 'Could not install the plugin. Plugin slug is missing.', 'wp-mail-smtp' ) );
		}

		if ( ! in_array( $slug, wp_list_pluck( $this->get_partner_plugins(), 'slug' ), true ) ) {
			wp_send_json_error( esc_html__( 'Could not install the plugin. Plugin is not whitelisted.', 'wp-mail-smtp' ) );
		}

		$url = esc_url_raw( WP::admin_url( 'admin.php?page=' . Area::SLUG . '-setup-wizard' ) );

		/*
		 * The `request_filesystem_credentials` function will output a credentials form in case of failure.
		 * We don't want that, since it will break AJAX response. So just hide output with a buffer.
		 */
		ob_start();
		// phpcs:ignore WPForms.Formatting.EmptyLineAfterAssigmentVariables.AddEmptyLine
		$creds = request_filesystem_credentials( $url, '', false, false, null );
		ob_end_clean();

		// Check for file system permissions.
		if ( false === $creds ) {
			wp_send_json_error( esc_html__( 'Could not install the plugin. Don\'t have file permission.', 'wp-mail-smtp' ) );
		}

		if ( ! WP_Filesystem( $creds ) ) {
			wp_send_json_error( esc_html__( 'Could not install the plugin. Don\'t have file permission.', 'wp-mail-smtp' ) );
		}

		// Do not allow WordPress to search/download translations, as this will break JS output.
		remove_action( 'upgrader_process_complete', [ 'Language_Pack_Upgrader', 'async_upgrade' ], 20 );

		// Import the plugin upgrader.
		Helpers::include_plugin_upgrader();

		// Create the plugin upgrader with our custom skin.
		$installer = new Plugin_Upgrader( new PluginsInstallSkin() );

		// Error check.
		if ( ! method_exists( $installer, 'install' ) || empty( $slug ) ) {
			wp_send_json_error( esc_html__( 'Could not install the plugin. WP Plugin installer initialization failed.', 'wp-mail-smtp' ) );
		}

		include_once ABSPATH . 'wp-admin/includes/plugin-install.php';

		$api = plugins_api(
			'plugin_information',
			[
				'slug'   => $slug,
				'fields' => [
					'short_description' => false,
					'sections'          => false,
					'requires'          => false,
					'rating'            => false,
					'ratings'           => false,
					'downloaded'        => false,
					'last_updated'      => false,
					'added'             => false,
					'tags'              => false,
					'compatibility'     => false,
					'homepage'          => false,
					'donate_link'       => false,
				],
			]
		);

		if ( is_wp_error( $api ) ) {
			wp_send_json_error( $api->get_error_message() );
		}

		$installer->install( $api->download_link );

		// Flush the cache and return the newly installed plugin basename.
		wp_cache_flush();

		if ( $installer->plugin_info() ) {
			$plugin_basename = $installer->plugin_info();

			// Disable the WPForms redirect after plugin activation.
			if ( $slug === 'wpforms-lite' ) {
				update_option( 'wpforms_activation_redirect', true );
				add_option( 'wpforms_installation_source', 'wp-mail-smtp-setup-wizard' );
			}

			// Disable the AIOSEO redirect after plugin activation.
			if ( $slug === 'all-in-one-seo-pack' ) {
				update_option( 'aioseo_activation_redirect', true );
			}

			// Activate the plugin silently.
			$activated = activate_plugin( $plugin_basename );

			// Disable the RafflePress redirect after plugin activation.
			if ( $slug === 'rafflepress' ) {
				delete_transient( '_rafflepress_welcome_screen_activation_redirect' );
			}

			// Disable the MonsterInsights redirect after plugin activation.
			if ( $slug === 'google-analytics-for-wordpress' ) {
				delete_transient( '_monsterinsights_activation_redirect' );
			}

			// Disable the SeedProd redirect after the plugin activation.
			if ( $slug === 'coming-soon' ) {
				delete_transient( '_seedprod_welcome_screen_activation_redirect' );
			}

			if ( ! is_wp_error( $activated ) ) {
				wp_send_json_success(
					[
						'slug'         => $slug,
						'is_installed' => true,
						'is_activated' => true,
					]
				);
			} else {
				wp_send_json_success(
					[
						'slug'         => $slug,
						'is_installed' => true,
						'is_activated' => false,
					]
				);
			}
		}

		wp_send_json_error( esc_html__( 'Could not install the plugin. WP Plugin installer could not retrieve plugin information.', 'wp-mail-smtp' ) );
	}

	/**
	 * AJAX callback for getting all partner's plugin information.
	 *
	 * @since 2.6.0
	 */
	public function get_partner_plugins_info() {

		check_ajax_referer( 'wpms-admin-nonce', 'nonce' );

		$plugins = $this->get_partner_plugins();

		$contact_form_plugin_already_installed = false;

		$contact_form_basenames = [
			'wpforms-lite/wpforms.php',
			'wpforms/wpforms.php',
			'formidable/formidable.php',
			'formidable/formidable-pro.php',
			'gravityforms/gravityforms.php',
			'ninja-forms/ninja-forms.php',
		];

		$installed_plugins = get_plugins();

		foreach ( $installed_plugins as $basename => $plugin_info ) {
			if ( in_array( $basename, $contact_form_basenames, true ) ) {
				$contact_form_plugin_already_installed = true;
				break;
			}
		}

		// Final check if maybe WPForms is already install and active as a MU plugin.
		if ( class_exists( '\WPForms\WPForms' ) ) {
			$contact_form_plugin_already_installed = true;
		}

		$data = [
			'plugins'                               => $plugins,
			'contact_form_plugin_already_installed' => $contact_form_plugin_already_installed,
		];

		wp_send_json_success( $data );
	}

	/**
	 * Get the partner plugins data.
	 *
	 * @since 3.3.0
	 *
	 * @return array[]
	 */
	private function get_partner_plugins() {

		$installed_plugins = get_plugins();

		return [
			[
				'slug'         => 'wpforms-lite',
				'name'         => esc_html__( 'Contact Forms by WPForms', 'wp-mail-smtp' ),
				'is_activated' => function_exists( 'wpforms' ),
				'is_installed' => array_key_exists( 'wpforms-lite/wpforms.php', $installed_plugins ),
			],
			[
				'slug'         => 'all-in-one-seo-pack',
				'name'         => esc_html__( 'All in One SEO', 'wp-mail-smtp' ),
				'is_activated' => class_exists( 'AIOSEOP_Core' ),
				'is_installed' => array_key_exists( 'all-in-one-seo-pack/all_in_one_seo_pack.php', $installed_plugins ),
			],
			[
				'slug'         => 'google-analytics-for-wordpress',
				'name'         => esc_html__( 'Google Analytics by MonsterInsights', 'wp-mail-smtp' ),
				'is_activated' => function_exists( 'MonsterInsights' ),
				'is_installed' => array_key_exists( 'google-analytics-for-wordpress/googleanalytics.php', $installed_plugins ),
			],
			[
				'slug'         => 'insert-headers-and-footers',
				'name'         => esc_html__( 'Code Snippets by WPCode', 'wp-mail-smtp' ),
				'is_activated' => class_exists( 'InsertHeadersAndFooters' ),
				'is_installed' => array_key_exists( 'insert-headers-and-footers/ihaf.php', $installed_plugins ),
			],
			[
				'slug'         => 'rafflepress',
				'name'         => esc_html__( 'Giveaways by RafflePress', 'wp-mail-smtp' ),
				'is_activated' => defined( 'RAFFLEPRESS_BUILD' ),
				'is_installed' => array_key_exists( 'rafflepress/rafflepress.php', $installed_plugins ),
			],
			[
				'slug'         => 'instagram-feed',
				'name'         => esc_html__( 'Smash Balloon Social Photo Feed', 'wp-mail-smtp' ),
				'is_activated' => function_exists( 'sb_instagram_feed_init' ),
				'is_installed' => array_key_exists( 'instagram-feed/instagram-feed.php', $installed_plugins ),
			],
			[
				'slug'         => 'coming-soon',
				'name'         => esc_html__( 'SeedProd Landing Page Builder', 'wp-mail-smtp' ),
				'is_activated' => defined( 'SEEDPROD_BUILD' ),
				'is_installed' => array_key_exists( 'coming-soon/coming-soon.php', $installed_plugins ),
			],
			[
				'slug'         => 'wp-call-button',
				'name'         => esc_html__( 'WP Call Button', 'wp-mail-smtp' ),
				'is_activated' => defined( 'WP_CALL_BUTTON_VERSION' ),
				'is_installed' => array_key_exists( 'wp-call-button/wp-call-button.php', $installed_plugins ),
			],
		];
	}

	/**
	 * AJAX callback for subscribing an email address to the WP Mail SMTP Drip newsletter.
	 *
	 * @since 2.6.0
	 */
	public function subscribe_to_newsletter() {

		check_ajax_referer( 'wpms-admin-nonce', 'nonce' );

		$email = ! empty( $_POST['email'] ) ? filter_var( wp_unslash( $_POST['email'] ), FILTER_VALIDATE_EMAIL ) : '';

		if ( empty( $email ) ) {
			wp_send_json_error();
		}

		$body = [
			'email' => base64_encode( $email ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
		];

		$wpforms_version_type = $this->get_wpforms_version_type();

		if ( ! empty( $wpforms_version_type ) ) {
			$body['wpforms_version_type'] = $wpforms_version_type;
		}

		wp_remote_post(
			'https://connect.wpmailsmtp.com/subscribe/drip/',
			[
				'user-agent' => Helpers::get_default_user_agent(),
				'body' => $body,
			]
		);

		wp_send_json_success();
	}

	/**
	 * Get the WPForms version type if it's installed.
	 *
	 * @since 3.9.0
	 *
	 * @return false|string Return `false` if WPForms is not installed, otherwise return either `lite` or `pro`.
	 */
	private function get_wpforms_version_type() {

		if ( ! function_exists( 'wpforms' ) ) {
			return false;
		}

		if ( method_exists( wpforms(), 'is_pro' ) ) {
			$is_wpforms_pro = wpforms()->is_pro();
		} else {
			$is_wpforms_pro = wpforms()->pro;
		}

		return $is_wpforms_pro ? 'pro' : 'lite';
	}

	/**
	 * AJAX callback for plugin upgrade, from lite to pro.
	 *
	 * @since 2.6.0
	 */
	public function upgrade_plugin() {

		check_ajax_referer( 'wpms-admin-nonce', 'nonce' );

		if ( wp_mail_smtp()->is_pro() ) {
			wp_send_json_success( esc_html__( 'You are already using the WP Mail SMTP PRO version. Please refresh this page and verify your license key.', 'wp-mail-smtp' ) );
		}

		if ( ! current_user_can( 'install_plugins' ) ) {
			wp_send_json_error( esc_html__( 'You don\'t have the permission to perform this action.', 'wp-mail-smtp' ) );
		}

		$license_key = ! empty( $_POST['license_key'] ) ? sanitize_key( $_POST['license_key'] ) : '';

		if ( empty( $license_key ) ) {
			wp_send_json_error( esc_html__( 'Please enter a valid license key!', 'wp-mail-smtp' ) );
		}

		$url = Connect::generate_url(
			$license_key,
			'',
			add_query_arg( 'upgrade-redirect', '1', self::get_site_url() ) . '#/step/license'
		);

		if ( empty( $url ) ) {
			wp_send_json_error( esc_html__( 'Upgrade functionality not available!', 'wp-mail-smtp' ) );
		}

		wp_send_json_success( [ 'redirect_url' => $url ] );
	}

	/**
	 * AJAX callback for checking the mailer configuration.
	 * - Send a test email
	 * - Check the domain setup with the Domain Checker API.
	 *
	 * @since 2.6.0
	 */
	public function check_mailer_configuration() {

		check_ajax_referer( 'wpms-admin-nonce', 'nonce' );

		$options = Options::init();
		$mailer  = $options->get( 'mail', 'mailer' );
		$email   = $options->get( 'mail', 'from_email' );
		$domain  = '';

		// Send the test mail.
		$result = wp_mail(
			$email,
			'WP Mail SMTP Automatic Email Test',
			TestTab::get_email_message_text(),
			array(
				'X-Mailer-Type:WPMailSMTP/Admin/SetupWizard/Test',
			)
		);

		if ( ! $result ) {
			$this->update_completed_stat( false );

			( new UsageTracking() )->send_failed_setup_wizard_usage_tracking_data();

			wp_send_json_error();
		}

		// Add the optional sending domain parameter.
		if ( in_array( $mailer, [ 'mailgun', 'sendinblue', 'sendgrid' ], true ) ) {
			$domain = $options->get( $mailer, 'domain' );
		}

		// Perform the domain checker API test.
		$domain_checker = new DomainChecker( $mailer, $email, $domain );

		if ( $domain_checker->has_errors() ) {
			$this->update_completed_stat( false );

			( new UsageTracking() )->send_failed_setup_wizard_usage_tracking_data( $domain_checker );

			wp_send_json_error();
		}

		$this->update_completed_stat( true );

		wp_send_json_success();
	}

	/**
	 * AJAX callback for sending feedback.
	 *
	 * @since 2.6.0
	 */
	public function send_feedback() {

		check_ajax_referer( 'wpms-admin-nonce', 'nonce' );

		// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
		$data = ! empty( $_POST['data'] ) ? json_decode( wp_unslash( $_POST['data'] ), true ) : [];

		$feedback   = ! empty( $data['feedback'] ) ? sanitize_textarea_field( $data['feedback'] ) : '';
		$permission = ! empty( $data['permission'] );

		wp_remote_post(
			'https://wpmailsmtp.com/wizard-feedback/',
			[
				'user-agent' => Helpers::get_default_user_agent(),
				'body' => [
					'wpforms' => [
						'id'     => 87892,
						'fields' => [
							'1' => $feedback,
							'2' => $permission ? wp_get_current_user()->user_email : '',
							'3' => wp_mail_smtp()->get_license_type(),
							'4' => WPMS_PLUGIN_VER,
						],
					],
				],
			]
		);

		wp_send_json_success();
	}

	/**
	 * Data used for the Vue scripts to display old PHP and WP versions warnings.
	 *
	 * @since 2.6.0
	 */
	private function prepare_versions_data() {

		global $wp_version;

		return array(
			'php_version'          => phpversion(),
			'php_version_below_55' => apply_filters( 'wp_mail_smtp_temporarily_hide_php_under_55_upgrade_warnings', version_compare( phpversion(), '5.5', '<' ) ),
			'php_version_below_56' => apply_filters( 'wp_mail_smtp_temporarily_hide_php_56_upgrade_warnings', version_compare( phpversion(), '5.6', '<' ) ),
			'wp_version'           => $wp_version,
			'wp_version_below_49'  => version_compare( $wp_version, '4.9', '<' ),
		);
	}

	/**
	 * Remove 'error' from the automatic clearing list of query arguments after page loads.
	 * This will fix the issue with missing oAuth 'error' argument for the Setup Wizard.
	 *
	 * @since 2.6.0
	 *
	 * @param array $defaults Array of query arguments to be cleared after page load.
	 *
	 * @return array
	 */
	public function maybe_disable_automatic_query_args_removal( $defaults ) {

		if (
			( isset( $_GET['page'] ) && $_GET['page'] === 'wp-mail-smtp-setup-wizard' ) && // phpcs:ignore WordPress.Security.NonceVerification.Recommended
			( ! empty( $_GET['error'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
		) {
			$defaults = array_values( array_diff( $defaults, [ 'error' ] ) );
		}

		return $defaults;
	}

	/**
	 * Check if the Setup Wizard should load.
	 *
	 * @since 2.6.0
	 *
	 * @return bool
	 */
	public function should_setup_wizard_load() {

		return (bool) apply_filters( 'wp_mail_smtp_admin_setup_wizard_load_wizard', true );
	}

	/**
	 * Get the Setup Wizard stats.
	 * - launched_time  -> when the Setup Wizard was last launched.
	 * - completed_time -> when the Setup Wizard was last completed.
	 * - was_successful -> if the Setup Wizard was completed successfully.
	 *
	 * @since 3.1.0
	 *
	 * @return array
	 */
	public static function get_stats() {

		$defaults = [
			'launched_time'  => 0,
			'completed_time' => 0,
			'was_successful' => false,
		];

		return get_option( self::STATS_OPTION_KEY, $defaults );
	}

	/**
	 * Update the Setup Wizard stats.
	 *
	 * @since 3.1.0
	 *
	 * @param array $options Take a look at SetupWizard::get_stats method for the possible array keys.
	 */
	public static function update_stats( $options ) {

		update_option( self::STATS_OPTION_KEY, array_merge( self::get_stats(), $options ) , false );
	}

	/**
	 * Update the completed Setup Wizard stats.
	 *
	 * @since 3.1.0
	 *
	 * @param bool $was_successful If the Setup Wizard was completed successfully.
	 */
	private function update_completed_stat( $was_successful ) {

		self::update_stats(
			[
				'completed_time' => time(),
				'was_successful' => $was_successful,
			]
		);
	}

	/**
	 * Prepare an array of WP Mail SMTP PHP constants in use.
	 * Those that are used in the setup wizard.
	 *
	 * @since 3.2.0
	 *
	 * @return array
	 */
	private function prepare_defined_constants() {

		$options = Options::init();

		if ( ! $options->is_const_enabled() ) {
			return [];
		}

		$constants = [
			'WPMS_MAIL_FROM'                     => [ 'mail', 'from_email' ],
			'WPMS_MAIL_FROM_FORCE'               => [ 'mail', 'from_email_force' ],
			'WPMS_MAIL_FROM_NAME'                => [ 'mail', 'from_name' ],
			'WPMS_MAIL_FROM_NAME_FORCE'          => [ 'mail', 'from_name_force' ],
			'WPMS_MAILER'                        => [ 'mail', 'mailer' ],
			'WPMS_SMTPCOM_API_KEY'               => [ 'smtpcom', 'api_key' ],
			'WPMS_SMTPCOM_CHANNEL'               => [ 'smtpcom', 'channel' ],
			'WPMS_SENDINBLUE_API_KEY'            => [ 'sendinblue', 'api_key' ],
			'WPMS_SENDINBLUE_DOMAIN'             => [ 'sendinblue', 'domain' ],
			'WPMS_AMAZONSES_CLIENT_ID'           => [ 'amazonses', 'client_id' ],
			'WPMS_AMAZONSES_CLIENT_SECRET'       => [ 'amazonses', 'client_secret' ],
			'WPMS_AMAZONSES_REGION'              => [ 'amazonses', 'region' ],
			'WPMS_GMAIL_CLIENT_ID'               => [ 'gmail', 'client_id' ],
			'WPMS_GMAIL_CLIENT_SECRET'           => [ 'gmail', 'client_secret' ],
			'WPMS_MAILGUN_API_KEY'               => [ 'mailgun', 'api_key' ],
			'WPMS_MAILGUN_DOMAIN'                => [ 'mailgun', 'domain' ],
			'WPMS_MAILGUN_REGION'                => [ 'mailgun', 'region' ],
			'WPMS_OUTLOOK_CLIENT_ID'             => [ 'outlook', 'client_id' ],
			'WPMS_OUTLOOK_CLIENT_SECRET'         => [ 'outlook', 'client_secret' ],
			'WPMS_POSTMARK_SERVER_API_TOKEN'     => [ 'postmark', 'server_api_token' ],
			'WPMS_POSTMARK_MESSAGE_STREAM'       => [ 'postmark', 'message_stream' ],
			'WPMS_SENDGRID_API_KEY'              => [ 'sendgrid', 'api_key' ],
			'WPMS_SENDGRID_DOMAIN'               => [ 'sendgrid', 'domain' ],
			'WPMS_SPARKPOST_API_KEY'             => [ 'sparkpost', 'api_key' ],
			'WPMS_SPARKPOST_REGION'              => [ 'sparkpost', 'region' ],
			'WPMS_ZOHO_DOMAIN'                   => [ 'zoho', 'domain' ],
			'WPMS_ZOHO_CLIENT_ID'                => [ 'zoho', 'client_id' ],
			'WPMS_ZOHO_CLIENT_SECRET'            => [ 'zoho', 'client_secret' ],
			'WPMS_SMTP_HOST'                     => [ 'smtp', 'host' ],
			'WPMS_SMTP_PORT'                     => [ 'smtp', 'port' ],
			'WPMS_SSL'                           => [ 'smtp', 'encryption' ],
			'WPMS_SMTP_AUTH'                     => [ 'smtp', 'auth' ],
			'WPMS_SMTP_AUTOTLS'                  => [ 'smtp', 'autotls' ],
			'WPMS_SMTP_USER'                     => [ 'smtp', 'user' ],
			'WPMS_SMTP_PASS'                     => [ 'smtp', 'pass' ],
			'WPMS_LOGS_ENABLED'                  => [ 'logs', 'enabled' ],
			'WPMS_SUMMARY_REPORT_EMAIL_DISABLED' => [ 'general', SummaryReportEmail::SETTINGS_SLUG ],
		];

		$defined = [];

		foreach ( $constants as $constant => $group_and_key ) {
			if ( $options->is_const_defined( $group_and_key[0], $group_and_key[1] ) ) {
				$defined[] = $constant;
			}
		}

		return $defined;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit