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;
}
?>
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' => [] ] ]
);
?>
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' => [] ] ]
);
?>
-
' . esc_html( $product['name'] ) . '',
'',
''
),
[
'strong' => [ 'class' => [] ],
'a' => [
'href' => [],
'class' => [],
],
]
);
?>
>
*/
protected function get_cross_sell_recommendations( $limit = 3 ) {
$assets_url = wp_mail_smtp()->assets_url;
// Copy and imagery for the banner; identity and install state come
// from the plugin catalog.
$copy = [
'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',
'settings_page_url' => admin_url( 'admin.php?page=activelayer-settings' ),
'framed_icon' => true,
],
'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',
'settings_page_url' => admin_url( 'admin.php?page=wpconsent-cookies' ),
'framed_icon' => true,
],
'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',
'settings_page_url' => admin_url( 'admin.php?page=duplicator-settings' ),
'framed_icon' => false,
],
];
$catalog = new Catalog();
$candidates = [];
foreach ( $copy as $slug => $product ) {
$plugin = $catalog->get( $slug );
if ( $plugin === null ) {
continue;
}
// Skip a plugin the site already has, and one whose need a
// competitor already covers: recommending Duplicator to an
// UpdraftPlus user is wasted screen space.
if ( $plugin->is_installed() || $plugin->is_pro_installed() || $plugin->is_competitor_installed() ) {
continue;
}
$candidates[] = $product + [
'name' => $plugin->get_name(),
'plugin' => $plugin->get_basename(),
'install' => $plugin->get_wporg_slug(),
'install_url' => $plugin->get_download_url(),
];
}
return array_slice( $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' );
}
}