connection = $connection; } /** * Display connection settings. * * @since 3.7.0 */ public function display() { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.MaxExceeded, Generic.Metrics.NestingLevel.MaxExceeded $mailer = $this->connection->get_mailer_slug(); $connection_options = $this->connection->get_options(); $disabled_email = in_array( $mailer, [ 'zoho' ], true ) ? 'disabled' : ''; $disabled_name = in_array( $mailer, [ 'outlook' ], true ) ? 'disabled' : ''; if ( empty( $mailer ) || ! in_array( $mailer, Options::$mailers, true ) ) { $mailer = 'mail'; } $mailer_supported_settings = wp_mail_smtp()->get_providers()->get_options( $mailer )->get_supports(); ?>
is_const_defined( 'mail', 'from_email' ) || ! empty( $disabled_email ) ); ?> /> connection ); $gmail_aliases = $gmail_auth->is_clients_saved() ? $gmail_auth->get_user_possible_send_from_addresses() : []; ?>


get( 'mail', 'from_email_force' ) ); ?> is_const_defined( 'mail', 'from_email_force' ) || ! empty( $disabled_email ) ); ?> />

is_const_defined( 'mail', 'from_name' ) || ! empty( $disabled_name ) ); ?> />


get( 'mail', 'from_name_force' ) ); ?> is_const_defined( 'mail', 'from_name_force' ) || ! empty( $disabled_name ) ); ?> />

get( 'mail', 'return_path' ) ); ?> id="wp-mail-smtp-setting-return_path" is_const_defined( 'mail', 'return_path' ) ); ?> />


get_providers()->get_options_all( $this->connection ) as $provider ) : ?>
<?php echo esc_attr( $provider->get_title() ); ?>
is_disabled() ) : ?> get_slug(), $mailer ); ?> is_const_defined( 'mail', 'mailer' ) || $provider->is_disabled() ); ?> />

%2$s', esc_url( wp_mail_smtp()->get_utm_url( 'https://wpmailsmtp.com/suggest-a-mailer/', 'Suggest a Mailer' ) ), esc_html__( 'Suggest a Mailer', 'wp-mail-smtp' ) ); ?>

get_providers()->get_options_all( $this->connection ) as $provider ) : ?> get_description(); ?>
is_disabled() ) : ?>

get_title() ); ?>

get_notice( 'educational' ); $is_dismissed = (bool) get_user_meta( get_current_user_id(), "wp_mail_smtp_notice_educational_for_{$provider->get_slug()}_dismissed", true ); if ( ! empty( $provider_edu_notice ) && ! $is_dismissed ) : ?>

display_options(); ?>
connection->get_options(); // When checkbox is unchecked - it's not submitted at all, so we need to define its default false value. if ( ! isset( $data['mail']['from_email_force'] ) ) { $data['mail']['from_email_force'] = false; } if ( ! isset( $data['mail']['from_name_force'] ) ) { $data['mail']['from_name_force'] = false; } if ( ! isset( $data['mail']['return_path'] ) ) { $data['mail']['return_path'] = false; } if ( ! isset( $data['smtp']['autotls'] ) ) { $data['smtp']['autotls'] = false; } if ( ! isset( $data['smtp']['auth'] ) ) { $data['smtp']['auth'] = false; } // When switching mailers. if ( ! empty( $old_data['mail']['mailer'] ) && ! empty( $data['mail']['mailer'] ) && $old_data['mail']['mailer'] !== $data['mail']['mailer'] ) { // Remove all debug messages when switching mailers. Debug::clear(); // Save correct from email address if Zoho mailer is already configured. if ( in_array( $data['mail']['mailer'], [ 'zoho' ], true ) && ! empty( $old_data[ $data['mail']['mailer'] ]['user_details']['email'] ) ) { $data['mail']['from_email'] = $old_data[ $data['mail']['mailer'] ]['user_details']['email']; } } // Old and new Gmail client id/secret values are different - we need to invalidate tokens and scroll to Auth button. if ( $this->connection->get_mailer_slug() === 'gmail' && ! empty( $data['gmail']['client_id'] ) && ! empty( $data['gmail']['client_secret'] ) && ( $connection_options->get( 'gmail', 'client_id' ) !== $data['gmail']['client_id'] || $connection_options->get( 'gmail', 'client_secret' ) !== $data['gmail']['client_secret'] ) ) { unset( $old_data['gmail'] ); $this->scroll_to = '#wp-mail-smtp-setting-row-gmail-authorize'; } // Prevent redirect to setup wizard from settings page after successful auth. if ( ! empty( $data['mail']['mailer'] ) && in_array( $data['mail']['mailer'], [ 'gmail', 'outlook', 'zoho' ], true ) ) { $data[ $data['mail']['mailer'] ]['is_setup_wizard_auth'] = false; } return $data; } /** * Post process connection settings. Should be called after options save. * * @since 3.7.0 * * @param array $data Connection data. * @param array $old_data Old connection data. */ public function post_process( $data, $old_data ) { // When switching mailers. if ( ! empty( $old_data['mail']['mailer'] ) && ! empty( $data['mail']['mailer'] ) && $old_data['mail']['mailer'] !== $data['mail']['mailer'] ) { // Save correct from email address if Gmail mailer is already configured. if ( is_array( $data ) && in_array( $data['mail']['mailer'], [ 'gmail' ], true ) && ! empty( $data['gmail']['client_id'] ) && ! empty( $data['gmail']['client_secret'] ) ) { $gmail_auth = new Auth( $this->connection ); $gmail_aliases = $gmail_auth->is_clients_saved() ? $gmail_auth->get_user_possible_send_from_addresses() : []; if ( ! empty( $gmail_aliases ) && isset( $gmail_aliases[0] ) && is_email( $gmail_aliases[0] ) !== false && ( empty( $data['mail']['from_email'] ) || ! in_array( $data['mail']['from_email'], $gmail_aliases, true ) ) ) { $data['mail']['from_email'] = $gmail_aliases[0]; $this->connection->get_options()->set( $data, false, false ); } } } } /** * Get connection settings admin page URL. * * @since 3.7.0 * * @return string */ public function get_admin_page_url() { /** * Filters connection settings admin page URL. * * @since 3.7.0 * * @param string $admin_page_url Connection settings admin page URL. * @param ConnectionInterface $connection The Connection object. */ return apply_filters( 'wp_mail_smtp_admin_connection_settings_get_admin_page_url', wp_mail_smtp()->get_admin()->get_admin_page_url(), $this->connection ); } /** * Get after process scroll to anchor. Returns `false` if scroll is not needed. * * @since 3.7.0 */ public function get_scroll_to() { return $this->scroll_to; } }