get_label(); } /** * Display the content of the tab. * * @since 1.0.0 */ public function display() { if ( $this->result === self::FAILED_DOMAIN_CHECK ) { $this->display_domain_check_details(); return; } if ( $this->result === self::SUCCESS ) { $this->display_success_banner(); } $this->display_form(); } /** * Process the email-test form submission. * * @since 1.0.0 * * @param array $data Submitted POST data. * * @inheritdoc */ public function process_post( $data ) { $connection = wp_mail_smtp()->get_connections_manager()->get_primary_connection(); /** * Filters test email connection object. * * @since 3.7.0 * * @param ConnectionInterface $connection The Connection object. * @param array $data Post data. */ $this->connection = apply_filters( 'wp_mail_smtp_admin_pages_test_tab_process_post_connection', $connection, $data ); if ( ! empty( $data['test']['email'] ) ) { $data['test']['email'] = wp_unslash( $data['test']['email'] ); $data['test']['email'] = filter_var( $data['test']['email'], FILTER_VALIDATE_EMAIL ); } if ( empty( $data['test']['email'] ) ) { WP::add_admin_notice( esc_html__( 'Test failed. Please use a valid email address and try to resend the test email.', 'wp-mail-smtp' ), WP::ADMIN_NOTICE_WARNING ); return; } $is_html = ! empty( $data['test']['html'] ); $test_email = ( new TestEmail() ) ->with_connection( $this->connection ) ->with_context( TestEmail::CONTEXT_ADMIN_TEST ) ->as_html( $is_html ) ->with_domain_check( true ); $test_email->send( $data['test']['email'] ); $this->result = $test_email->get_result(); $this->domain_checker = $test_email->get_domain_checker(); // Persist the form values so the next visit prefills with what the // user last entered (matches ESMTP's TestTab behavior). $test_email_options = get_option( self::TEST_EMAIL_OPTION_KEY, [] ); $test_email_options['to'] = $data['test']['email']; $test_email_options['html'] = $is_html; update_option( self::TEST_EMAIL_OPTION_KEY, $test_email_options, false ); } /** * Display test email title section. * * @since 3.0.0 */ private function display_title_section() { ?>

'', 'html' => true, ], get_option( self::TEST_EMAIL_OPTION_KEY, [] ) ); if ( empty( $test_email_options['to'] ) ) { $test_email_options['to'] = wp_get_current_user()->user_email; } ?>
wp_nonce_field(); ?> display_title_section(); ?>

'wp-mail-smtp[test][html]', 'id' => 'wp-mail-smtp-setting-test_email_html', 'checked' => (bool) $test_email_options['html'], ] ); ?>

get_providers()->get_mailer( Options::init()->get( 'mail', 'mailer' ), wp_mail_smtp()->get_processor()->get_phpmailer() ); if ( ! $mailer || ! $mailer->is_mailer_complete() ) { $btn = 'wp-mail-smtp-btn-red'; $disabled = 'disabled'; $help_text = '' . esc_html__( 'You cannot send an email. Mailer is not properly configured. Please check your settings.', 'wp-mail-smtp' ) . ''; } ?>

post_form_hidden_field(); ?>
is_mailer_complete() && isset( $_GET['auto-start'] ) ) : // phpcs:ignore ?> domain_checker ) || $this->domain_checker->no_issues() ) { return; } $this->display_title_section(); ?> domain_checker->is_supported_mailer() ) : ?>

domain_checker->get_results_html(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
assets_url; $illustration = $assets_url . '/images/test-success/illustration-lite.svg'; $upgrade_url = wp_mail_smtp()->get_upgrade_link( [ 'medium' => 'lite-test-email-success', 'content' => 'Upgrade Button', ] ); $bullets = [ esc_html__( 'Log, track, and resend any email your site sends', 'wp-mail-smtp' ), esc_html__( 'Get instant failure alerts via Email, Slack, SMS, Discord, etc', 'wp-mail-smtp' ), esc_html__( 'Never miss an email with an automatic backup mailer', 'wp-mail-smtp' ), ]; ?>
display_success_banner_dismiss(); ?>

' . esc_html__( 'Pro', 'wp-mail-smtp' ) . '' ), [ 'strong' => [ 'class' => [] ] ] ); ?>

<?php esc_attr_e( 'A person celebrating after sending an email.', 'wp-mail-smtp' ); ?>
display_success_pro_tip_strip(); ?>
get_cross_sell_recommendations( 1 ); if ( empty( $recommendations ) ) { return; } $product = $recommendations[0]; $install_url = $this->get_install_plugin_url( $product['install'] ); ?>
, e.g. WPConsent. */ __( '%1$s with our sister plugin %2$s', 'wp-mail-smtp' ), esc_html( $product['pro_tip'] ), '' . esc_html( $product['name'] ) . '' ), [ 'strong' => [ 'class' => [] ] ] ); ?> -
> */ protected function get_cross_sell_recommendations( $limit = 3 ) { // phpcs:ignore Generic.Metrics.NestingLevel.MaxExceeded -- Inner foreach over per-product competitor list is intentional; flattening would obscure the catalog structure. if ( ! current_user_can( 'install_plugins' ) ) { return []; } $assets_url = wp_mail_smtp()->assets_url; $catalog = [ [ 'name' => 'ActiveLayer', 'title' => esc_html__( 'Smarter Spam Protection for WordPress', 'wp-mail-smtp' ), 'desc' => esc_html__( 'Catch spam in milliseconds with AI, invisible to your real visitors.', 'wp-mail-smtp' ), 'pro_tip' => esc_html__( 'Stop spam at the door', 'wp-mail-smtp' ), 'icon' => $assets_url . '/images/about/icon-activelayer.svg', 'plugin' => 'activelayer-anti-spam-spam-protection-for-forms-comments/activelayer-anti-spam-spam-protection-for-forms-comments.php', 'install' => 'activelayer-anti-spam-spam-protection-for-forms-comments', 'install_url' => 'https://downloads.wordpress.org/plugin/activelayer-anti-spam-spam-protection-for-forms-comments.zip', 'settings_page_url' => admin_url( 'admin.php?page=activelayer-settings' ), 'framed_icon' => true, 'competitors' => [ 'akismet/akismet.php', 'antispam-bee/antispam_bee.php', 'honeypot/wp-armour.php', 'wp-armour-extended/wp-armour-extended.php', 'cleantalk-spam-protect/cleantalk.php', 'wp-cerber/wp-cerber.php', 'anti-spam/anti-spam.php', ], ], [ 'name' => 'WPConsent', 'title' => esc_html__( 'Stay GDPR & Privacy Compliant', 'wp-mail-smtp' ), 'desc' => esc_html__( 'Add a cookie consent banner to your site and meet privacy laws in minutes.', 'wp-mail-smtp' ), 'pro_tip' => esc_html__( 'Stay GDPR & Privacy compliant', 'wp-mail-smtp' ), 'icon' => $assets_url . '/images/about/icon-wpconsent.svg', 'plugin' => 'wpconsent-cookies-banner-privacy-suite/wpconsent.php', 'install' => 'wpconsent-cookies-banner-privacy-suite', 'install_url' => 'https://downloads.wordpress.org/plugin/wpconsent-cookies-banner-privacy-suite.zip', 'settings_page_url' => admin_url( 'admin.php?page=wpconsent-cookies' ), 'framed_icon' => true, 'competitors' => [ 'cookie-law-info/cookie-law-info.php', 'complianz-gdpr/complianz-gpdr.php', 'complianz-gdpr-premium/complianz-gpdr-premium.php', 'cookie-notice/cookie-notice.php', 'gdpr-cookie-compliance/moove-gdpr.php', 'iubenda-cookie-law-solution/iubenda_cookie_solution.php', 'real-cookie-banner/index.php', 'cookiebot/cookiebot.php', 'uk-cookie-consent/uk-cookie-consent.php', 'borlabs-cookie/borlabs-cookie.php', ], ], [ 'name' => 'Duplicator', 'title' => esc_html__( 'Add Secure WordPress Backups', 'wp-mail-smtp' ), 'desc' => esc_html__( 'Automated, encrypted backups with 1-click restore to keep your site safe.', 'wp-mail-smtp' ), 'pro_tip' => esc_html__( 'Protect your site with automated backups', 'wp-mail-smtp' ), 'icon' => $assets_url . '/images/about/icon-duplicator.svg', 'plugin' => 'duplicator/duplicator.php', 'plugin_pro' => 'duplicator-pro/duplicator-pro.php', 'install' => 'duplicator', 'install_url' => 'https://downloads.wordpress.org/plugin/duplicator.zip', 'settings_page_url' => admin_url( 'admin.php?page=duplicator-settings' ), 'framed_icon' => false, 'competitors' => [ 'all-in-one-wp-migration/all-in-one-wp-migration.php', 'all-in-one-wp-migration-unlimited-extension/all-in-one-wp-migration-unlimited-extension.php', 'updraftplus/updraftplus.php', 'wpvivid-backuprestore/wpvivid-backuprestore.php', 'wpvivid-backup-pro/wpvivid-backup-pro.php', 'backwpup/backwpup.php', 'backwpup-pro/backwpup.php', 'migrate-guru/migrateguru.php', 'wp-migrate-db/wp-migrate-db.php', 'wp-migrate-db-pro/wp-migrate-db-pro.php', 'wp-staging/wp-staging.php', 'wp-staging-pro/wp-staging-pro.php', 'backupbuddy/backupbuddy.php', ], ], ]; if ( ! function_exists( 'get_plugins' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $installed = get_plugins(); $candidates = array_filter( $catalog, function ( $product ) use ( $installed ) { if ( array_key_exists( $product['plugin'], $installed ) ) { return false; } // Pro variant present too — treat as "already provided" so we // don't push the Lite when the Pro version is installed. if ( ! empty( $product['plugin_pro'] ) && array_key_exists( $product['plugin_pro'], $installed ) ) { return false; } // Drop the entry when a competitor that covers the same need // is installed (e.g., recommending Duplicator to an // UpdraftPlus user is wasted screen space). if ( ! empty( $product['competitors'] ) ) { foreach ( $product['competitors'] as $competitor ) { if ( array_key_exists( $competitor, $installed ) ) { return false; } } } return true; } ); return array_slice( array_values( $candidates ), 0, $limit ); } /** * Build a nonce-protected install-plugin URL for the WP-Admin updater. * Users without the install_plugins capability get the public wp.org * page so the link still makes sense. * * @since 4.9.0 * * @param string $slug WP.org plugin slug. * * @return string */ private function get_install_plugin_url( $slug ) { if ( ! current_user_can( 'install_plugins' ) ) { return 'https://wordpress.org/plugins/' . $slug . '/'; } return wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $slug ), 'install-plugin_' . $slug ); } /** * Get the plain text prepared message for test email. * * Use {@see TestEmail::get_email_message_text()} instead. * * @since 1.4.0 * @since 1.5.0 Display an upsell to WP Mail SMTP Pro if free version installed. * @since 2.6.0 Change visibility, so it can be used elsewhere. * @deprecated {VERSION} * * @return string */ public static function get_email_message_text() { return TestEmail::get_email_message_text(); } /** * Returns debug information for detection, processing, and display. * * @since 1.3.0 * @deprecated {VERSION} * * @return array */ protected function get_debug_details() { _deprecated_function( __METHOD__, '4.9.0', '\WPMailSMTP\Admin\EmailSendingErrors\EmailSendingErrors::get_local_failure_info' ); return []; } /** * Displays all the various error and debug details. * * @since 1.3.0 * @deprecated {VERSION} */ protected function display_debug_details() { _deprecated_function( __METHOD__, '4.9.0', '\WPMailSMTP\Admin\EmailSendingErrors\EmailSendingErrors::print_banner_body' ); } }