rebase on oct-10-2023
This commit is contained in:
@@ -95,6 +95,9 @@ class Area {
|
||||
// Display notice instructing the user to complete plugin setup.
|
||||
add_action( 'admin_init', [ $this, 'display_setup_notice' ] );
|
||||
|
||||
// Display notice explaining removal of "Email Test" tab.
|
||||
add_action( 'admin_init', [ $this, 'display_email_test_tab_removal_notice' ] );
|
||||
|
||||
// Outputs the plugin admin header.
|
||||
add_action( 'in_admin_header', [ $this, 'display_admin_header' ], 100 );
|
||||
|
||||
@@ -104,9 +107,6 @@ class Area {
|
||||
// Process all AJAX requests.
|
||||
add_action( 'wp_ajax_wp_mail_smtp_ajax', [ $this, 'process_ajax' ] );
|
||||
|
||||
// Maybe redirect to "Tools -> Email Test" page if old direct URL to "Settings -> Email Test" is accessed.
|
||||
add_action( 'admin_init', [ $this, 'maybe_redirect_test_tab' ] );
|
||||
|
||||
// Init parent admin pages.
|
||||
if ( WP::in_wp_admin() || WP::is_doing_self_ajax() ) {
|
||||
add_action( 'init', [ $this, 'get_parent_pages' ] );
|
||||
@@ -221,6 +221,36 @@ class Area {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display notice explaining removal of "Email Test" tab.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*/
|
||||
public function display_email_test_tab_removal_notice() {
|
||||
|
||||
// Bail if we aren't on a "Settings" page.
|
||||
if ( ! $this->is_admin_page( self::SLUG ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Bail if the notice has been dismissed.
|
||||
if ( metadata_exists( 'user', get_current_user_id(), 'wp_mail_smtp_email_test_tab_removal_notice_dismissed' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
WP::add_admin_notice(
|
||||
sprintf(
|
||||
wp_kses(
|
||||
/* translators: %s: Tools page URL. */
|
||||
__( 'The Email Test tab was moved to <a href="%s">WP Mail SMTP > Tools</a>.', 'wp-mail-smtp' ),
|
||||
[ 'a' => [ 'href' => [] ] ]
|
||||
),
|
||||
$this->get_admin_page_url( self::SLUG . '-tools' )
|
||||
),
|
||||
implode( ' ', [ WP::ADMIN_NOTICE_INFO, 'email_test_tab_removal_notice' ] )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get menu item position.
|
||||
*
|
||||
@@ -526,13 +556,13 @@ class Area {
|
||||
*/
|
||||
wp_enqueue_style(
|
||||
'wp-mail-smtp-admin-jconfirm',
|
||||
wp_mail_smtp()->assets_url . '/libs/jquery-confirm.min.css',
|
||||
wp_mail_smtp()->assets_url . '/css/vendor/jquery-confirm.min.css',
|
||||
[ 'wp-mail-smtp-admin' ],
|
||||
'3.3.4'
|
||||
);
|
||||
wp_enqueue_script(
|
||||
'wp-mail-smtp-admin-jconfirm',
|
||||
wp_mail_smtp()->assets_url . '/libs/jquery-confirm.min.js',
|
||||
wp_mail_smtp()->assets_url . '/js/vendor/jquery-confirm.min.js',
|
||||
[ 'wp-mail-smtp-admin' ],
|
||||
'3.3.4',
|
||||
false
|
||||
@@ -920,7 +950,6 @@ class Area {
|
||||
if ( empty( $this->pages ) ) {
|
||||
$this->pages = [
|
||||
'settings' => new Pages\SettingsTab(),
|
||||
'test' => new Pages\TestTab( new Pages\Tools() ),
|
||||
'logs' => new Pages\LogsTab(),
|
||||
'alerts' => new Pages\AlertsTab(),
|
||||
'connections' => new Pages\AdditionalConnectionsTab(),
|
||||
@@ -1131,6 +1160,14 @@ class Area {
|
||||
$data['message'] = $dismissal_response;
|
||||
break;
|
||||
|
||||
case 'email_test_tab_removal_notice_dismiss':
|
||||
if ( ! check_ajax_referer( 'wp-mail-smtp-admin', 'nonce', false ) ) {
|
||||
break;
|
||||
}
|
||||
|
||||
update_user_meta( get_current_user_id(), 'wp_mail_smtp_email_test_tab_removal_notice_dismissed', true );
|
||||
break;
|
||||
|
||||
default:
|
||||
// Allow custom tasks data processing being added here.
|
||||
$data = apply_filters( 'wp_mail_smtp_admin_process_ajax_' . $task . '_data', $data );
|
||||
@@ -1189,7 +1226,7 @@ class Area {
|
||||
return $links;
|
||||
}
|
||||
|
||||
$custom['pro'] = sprintf(
|
||||
$custom['wp-mail-smtp-pro'] = sprintf(
|
||||
'<a href="%1$s" aria-label="%2$s" target="_blank" rel="noopener noreferrer"
|
||||
style="color: #00a32a; font-weight: 700;"
|
||||
onmouseover="this.style.color=\'#008a20\';"
|
||||
@@ -1201,14 +1238,14 @@ class Area {
|
||||
esc_html__( 'Get WP Mail SMTP Pro', 'wp-mail-smtp' )
|
||||
);
|
||||
|
||||
$custom['settings'] = sprintf(
|
||||
$custom['wp-mail-smtp-settings'] = sprintf(
|
||||
'<a href="%s" aria-label="%s">%s</a>',
|
||||
esc_url( $this->get_admin_page_url() ),
|
||||
esc_attr__( 'Go to WP Mail SMTP Settings page', 'wp-mail-smtp' ),
|
||||
esc_html__( 'Settings', 'wp-mail-smtp' )
|
||||
);
|
||||
|
||||
$custom['docs'] = sprintf(
|
||||
$custom['wp-mail-smtp-docs'] = sprintf(
|
||||
'<a href="%1$s" target="_blank" aria-label="%2$s" rel="noopener noreferrer">%3$s</a>',
|
||||
// phpcs:ignore WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
|
||||
esc_url( wp_mail_smtp()->get_utm_url( 'https://wpmailsmtp.com/docs/', [ 'medium' => 'all-plugins', 'content' => 'Documentation' ] ) ),
|
||||
@@ -1300,10 +1337,14 @@ class Area {
|
||||
/**
|
||||
* Maybe redirect to "Tools -> Email Test" page if old direct URL to "Settings -> Email Test" is accessed.
|
||||
*
|
||||
* @deprecated 3.9.0
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public function maybe_redirect_test_tab() {
|
||||
|
||||
_deprecated_function( __METHOD__, '3.9.0' );
|
||||
|
||||
if ( $this->is_admin_page( 'general' ) && $this->get_current_tab() === 'test' ) {
|
||||
wp_safe_redirect( add_query_arg( 'tab', 'test', $this->get_admin_page_url( self::SLUG . '-tools' ) ) );
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace WPMailSMTP\Admin;
|
||||
|
||||
use WPMailSMTP\Admin\DebugEvents\DebugEvents;
|
||||
use WPMailSMTP\Helpers\Helpers;
|
||||
use WPMailSMTP\Options;
|
||||
use WPMailSMTP\WP;
|
||||
@@ -175,7 +176,8 @@ class DashboardWidget {
|
||||
unset( $normal_dashboard[ $widget_key ] );
|
||||
$sorted_dashboard = array_merge( $widget_instance, $normal_dashboard );
|
||||
|
||||
$wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard; //phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
|
||||
//phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
|
||||
$wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -258,8 +260,7 @@ class DashboardWidget {
|
||||
*/
|
||||
private function widget_content_html() {
|
||||
|
||||
$hide_graph = (bool) $this->widget_meta( 'get', 'hide_graph' );
|
||||
$hide_summary_report_email_block = (bool) $this->widget_meta( 'get', 'hide_summary_report_email_block' );
|
||||
$hide_graph = (bool) $this->widget_meta( 'get', 'hide_graph' );
|
||||
?>
|
||||
|
||||
<?php if ( ! $hide_graph ) : ?>
|
||||
@@ -301,37 +302,155 @@ class DashboardWidget {
|
||||
<?php $this->email_stats_block(); ?>
|
||||
</div>
|
||||
|
||||
<?php if ( SummaryReportEmail::is_disabled() && ! $hide_summary_report_email_block ) : ?>
|
||||
<div id="wp-mail-smtp-dash-widget-summary-report-email-block" class="wp-mail-smtp-dash-widget-block wp-mail-smtp-dash-widget-summary-report-email-block">
|
||||
<div>
|
||||
<div class="wp-mail-smtp-dash-widget-summary-report-email-block-setting">
|
||||
<label for="wp-mail-smtp-dash-widget-summary-report-email-enable">
|
||||
<input type="checkbox" id="wp-mail-smtp-dash-widget-summary-report-email-enable">
|
||||
<i class="wp-mail-smtp-dash-widget-loader"></i>
|
||||
<span>
|
||||
<?php
|
||||
echo wp_kses(
|
||||
__( '<b>NEW!</b> Enable Weekly Email Summaries', 'wp-mail-smtp' ),
|
||||
[
|
||||
'b' => [],
|
||||
]
|
||||
);
|
||||
?>
|
||||
</span>
|
||||
</label>
|
||||
<a href="<?php echo esc_url( SummaryReportEmail::get_preview_link() ); ?>" target="_blank">
|
||||
<?php esc_html_e( 'View Example', 'wp-mail-smtp' ); ?>
|
||||
</a>
|
||||
<i class="dashicons dashicons-dismiss wp-mail-smtp-dash-widget-summary-report-email-dismiss"></i>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-dash-widget-summary-report-email-block-applied hidden">
|
||||
<i class="wp-mail-smtp-dashicons-yes-alt-green"></i>
|
||||
<span><?php esc_attr_e( 'Weekly Email Summaries have been enabled', 'wp-mail-smtp' ); ?></span>
|
||||
</div>
|
||||
<?php
|
||||
$this->display_after_email_stats_block_content();
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the content after the email stats block.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function display_after_email_stats_block_content() {
|
||||
|
||||
if ( empty( $this->widget_meta( 'get', 'hide_email_alerts_banner' ) ) ) {
|
||||
// Check if we have error debug events.
|
||||
$error_debug_events_count = DebugEvents::get_error_debug_events_count();
|
||||
|
||||
if ( ! is_wp_error( $error_debug_events_count ) && ! empty( $error_debug_events_count ) ) {
|
||||
$this->show_email_alerts_banner( $error_debug_events_count );
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$hide_summary_report_email_block = (bool) $this->widget_meta( 'get', 'hide_summary_report_email_block' );
|
||||
|
||||
if ( SummaryReportEmail::is_disabled() && ! $hide_summary_report_email_block ) {
|
||||
$this->show_summary_report_email_block();
|
||||
}
|
||||
|
||||
$this->show_upgrade_footer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the email alerts banner.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @param int $error_count The number of debug events error.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function show_email_alerts_banner( $error_count ) {
|
||||
|
||||
?>
|
||||
<div id="wp-mail-smtp-dash-widget-email-alerts-education" class="wp-mail-smtp-dash-widget-block wp-mail-smtp-dash-widget-email-alerts-education">
|
||||
<div class="wp-mail-smtp-dash-widget-email-alerts-education-error-icon">
|
||||
<?php
|
||||
printf(
|
||||
'<img src="%s" alt="%s"/>',
|
||||
esc_url( wp_mail_smtp()->assets_url . '/images/dash-widget/error-icon.svg' ),
|
||||
esc_attr__( 'Error icon', 'wp-mail-smtp' )
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-dash-widget-email-alerts-education-content">
|
||||
<?php
|
||||
if ( $error_count === 1 ) {
|
||||
$error_title = __( 'We detected a failed email in the last 30 days.', 'wp-mail-smtp' );
|
||||
} else {
|
||||
$error_title = sprintf(
|
||||
/* translators: %d - number of failed emails. */
|
||||
__( 'We detected %d failed emails in the last 30 days.', 'wp-mail-smtp' ),
|
||||
$error_count
|
||||
);
|
||||
}
|
||||
|
||||
$content = sprintf(
|
||||
/* translators: %s - URL to WPMailSMTP.com. */
|
||||
__( '<a href="%s" target="_blank" rel="noopener noreferrer">Upgrade to Pro</a> and get instant alert notifications when they fail.', 'wp-mail-smtp' ),
|
||||
esc_url( wp_mail_smtp()->get_upgrade_link( [ 'medium' => 'dashboard-widget', 'content' => 'alerts-promo-upgrade-to-pro' ] ) ) // phpcs:ignore WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
|
||||
);
|
||||
?>
|
||||
<p>
|
||||
<strong><?php echo esc_html( $error_title ); ?></strong><br />
|
||||
<?php
|
||||
echo wp_kses(
|
||||
$content,
|
||||
[
|
||||
'a' => [
|
||||
'href' => [],
|
||||
'target' => [],
|
||||
'rel' => [],
|
||||
],
|
||||
]
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<button type="button" id="wp-mail-smtp-dash-widget-dismiss-email-alert-block" class="wp-mail-smtp-dash-widget-dismiss-email-alert-block" title="<?php esc_attr_e( 'Dismiss email alert block', 'wp-mail-smtp' ); ?>">
|
||||
<span class="dashicons dashicons-no-alt"></span>
|
||||
</button>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the summary report email block.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function show_summary_report_email_block() {
|
||||
|
||||
?>
|
||||
<div id="wp-mail-smtp-dash-widget-summary-report-email-block" class="wp-mail-smtp-dash-widget-block wp-mail-smtp-dash-widget-summary-report-email-block">
|
||||
<div>
|
||||
<div class="wp-mail-smtp-dash-widget-summary-report-email-block-setting">
|
||||
<label for="wp-mail-smtp-dash-widget-summary-report-email-enable">
|
||||
<input type="checkbox" id="wp-mail-smtp-dash-widget-summary-report-email-enable">
|
||||
<i class="wp-mail-smtp-dash-widget-loader"></i>
|
||||
<span>
|
||||
<?php
|
||||
echo wp_kses(
|
||||
__( '<b>NEW!</b> Enable Weekly Email Summaries', 'wp-mail-smtp' ),
|
||||
[
|
||||
'b' => [],
|
||||
]
|
||||
);
|
||||
?>
|
||||
</span>
|
||||
</label>
|
||||
<a href="<?php echo esc_url( SummaryReportEmail::get_preview_link() ); ?>" target="_blank">
|
||||
<?php esc_html_e( 'View Example', 'wp-mail-smtp' ); ?>
|
||||
</a>
|
||||
<i class="dashicons dashicons-dismiss wp-mail-smtp-dash-widget-summary-report-email-dismiss"></i>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-dash-widget-summary-report-email-block-applied hidden">
|
||||
<i class="wp-mail-smtp-dashicons-yes-alt-green"></i>
|
||||
<span><?php esc_attr_e( 'Weekly Email Summaries have been enabled', 'wp-mail-smtp' ); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the upgrade footer.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function show_upgrade_footer() {
|
||||
|
||||
$hide_graph = (bool) $this->widget_meta( 'get', 'hide_graph' );
|
||||
?>
|
||||
<div id="wp-mail-smtp-dash-widget-upgrade-footer" class="wp-mail-smtp-dash-widget-block wp-mail-smtp-dash-widget-upgrade-footer wp-mail-smtp-dash-widget-upgrade-footer--<?php echo ! $hide_graph ? 'hide' : 'show'; ?>">
|
||||
<p>
|
||||
<?php
|
||||
@@ -346,7 +465,8 @@ class DashboardWidget {
|
||||
],
|
||||
]
|
||||
),
|
||||
esc_url( wp_mail_smtp()->get_upgrade_link( [ 'medium' => 'dashboard-widget', 'content' => 'upgrade-to-pro' ] ) ) // phpcs:ignore WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
|
||||
// phpcs:ignore WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
|
||||
esc_url( wp_mail_smtp()->get_upgrade_link( [ 'medium' => 'dashboard-widget', 'content' => 'upgrade-to-pro' ] ) )
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
@@ -420,7 +540,9 @@ class DashboardWidget {
|
||||
?>
|
||||
<div class="wp-mail-smtp-dash-widget-settings-container">
|
||||
<button id="wp-mail-smtp-dash-widget-settings-button" class="wp-mail-smtp-dash-widget-settings-button button" type="button">
|
||||
<span class="dashicons dashicons-admin-generic"></span>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 19 19">
|
||||
<path d="M18,11l-2.18,0c-0.17,0.7 -0.44,1.35 -0.81,1.93l1.54,1.54l-2.1,2.1l-1.54,-1.54c-0.58,0.36 -1.23,0.63 -1.91,0.79l0,2.18l-3,0l0,-2.18c-0.68,-0.16 -1.33,-0.43 -1.91,-0.79l-1.54,1.54l-2.12,-2.12l1.54,-1.54c-0.36,-0.58 -0.63,-1.23 -0.79,-1.91l-2.18,0l0,-2.97l2.17,0c0.16,-0.7 0.44,-1.35 0.8,-1.94l-1.54,-1.54l2.1,-2.1l1.54,1.54c0.58,-0.37 1.24,-0.64 1.93,-0.81l0,-2.18l3,0l0,2.18c0.68,0.16 1.33,0.43 1.91,0.79l1.54,-1.54l2.12,2.12l-1.54,1.54c0.36,0.59 0.64,1.24 0.8,1.94l2.17,0l0,2.97Zm-8.5,1.5c1.66,0 3,-1.34 3,-3c0,-1.66 -1.34,-3 -3,-3c-1.66,0 -3,1.34 -3,3c0,1.66 1.34,3 3,3Z"></path>
|
||||
</svg>
|
||||
</button>
|
||||
<div class="wp-mail-smtp-dash-widget-settings-menu">
|
||||
<div class="wp-mail-smtp-dash-widget-settings-menu--style">
|
||||
@@ -580,24 +702,12 @@ class DashboardWidget {
|
||||
return false;
|
||||
}
|
||||
|
||||
$defaults = [
|
||||
'hide_graph' => 0,
|
||||
'hide_summary_report_email_block' => 0,
|
||||
];
|
||||
|
||||
if ( ! array_key_exists( $meta, $defaults ) ) {
|
||||
return false;
|
||||
if ( $action === 'get' ) {
|
||||
return $this->get_widget_meta( $meta );
|
||||
}
|
||||
|
||||
$meta_key = 'wp_mail_smtp_' . static::SLUG . '_' . $meta;
|
||||
|
||||
if ( 'get' === $action ) {
|
||||
$meta_value = get_user_meta( get_current_user_id(), $meta_key, true );
|
||||
|
||||
return empty( $meta_value ) ? $defaults[ $meta ] : $meta_value;
|
||||
}
|
||||
|
||||
$value = sanitize_key( $value );
|
||||
$meta_key = $this->get_widget_meta_key( $meta );
|
||||
$value = sanitize_key( $value );
|
||||
|
||||
if ( 'set' === $action && ! empty( $value ) ) {
|
||||
return update_user_meta( get_current_user_id(), $meta_key, $value );
|
||||
@@ -609,4 +719,48 @@ class DashboardWidget {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the widget meta value.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @param string $meta Meta name.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private function get_widget_meta( $meta ) {
|
||||
|
||||
$defaults = [
|
||||
'hide_graph' => 0,
|
||||
'hide_summary_report_email_block' => 0,
|
||||
'hide_email_alerts_banner' => 0,
|
||||
];
|
||||
|
||||
$meta_value = get_user_meta( get_current_user_id(), $this->get_widget_meta_key( $meta ), true );
|
||||
|
||||
if ( ! empty( $meta_value ) ) {
|
||||
return $meta_value;
|
||||
}
|
||||
|
||||
if ( isset( $defaults[ $meta ] ) ) {
|
||||
return $defaults[ $meta ];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the meta key.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @param string $meta Meta name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function get_widget_meta_key( $meta ) {
|
||||
|
||||
return 'wp_mail_smtp_' . static::SLUG . '_' . $meta;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace WPMailSMTP\Admin\DebugEvents;
|
||||
|
||||
use WP_Error;
|
||||
use WPMailSMTP\Admin\Area;
|
||||
use WPMailSMTP\Options;
|
||||
use WPMailSMTP\Tasks\DebugEventsCleanupTask;
|
||||
@@ -14,6 +15,15 @@ use WPMailSMTP\WP;
|
||||
*/
|
||||
class DebugEvents {
|
||||
|
||||
/**
|
||||
* Transient name for the error debug events.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const ERROR_DEBUG_EVENTS_TRANSIENT = 'wp_mail_smtp_error_debug_events_transient';
|
||||
|
||||
/**
|
||||
* Register hooks.
|
||||
*
|
||||
@@ -248,6 +258,51 @@ class DebugEvents {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of error debug events in a given time span.
|
||||
*
|
||||
* By default it returns the number of error debug events in the last 30 days.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @param string $span_of_time The time span to count the events for. Default '-30 days'.
|
||||
*
|
||||
* @return int|WP_Error The number of error debug events or WP_Error on failure.
|
||||
*/
|
||||
public static function get_error_debug_events_count( $span_of_time = '-30 days' ) {
|
||||
|
||||
$timestamp = strtotime( $span_of_time );
|
||||
|
||||
if ( ! $timestamp || $timestamp > time() ) {
|
||||
return new WP_Error( 'wp_mail_smtp_admin_debug_events_get_error_debug_events_count_invalid_time', 'Invalid time span.' );
|
||||
}
|
||||
|
||||
$transient_key = self::ERROR_DEBUG_EVENTS_TRANSIENT . '_' . sanitize_title_with_dashes( $span_of_time );
|
||||
$cached_error_events_count = get_transient( $transient_key );
|
||||
|
||||
if ( $cached_error_events_count !== false ) {
|
||||
return (int) $cached_error_events_count;
|
||||
}
|
||||
|
||||
global $wpdb;
|
||||
|
||||
// phpcs:disable WordPress.DB.PreparedSQLPlaceholders.UnquotedComplexPlaceholder
|
||||
$sql = $wpdb->prepare(
|
||||
'SELECT COUNT(*) FROM `%1$s` WHERE event_type = %2$d AND created_at >= "%3$s"',
|
||||
self::get_table_name(),
|
||||
Event::TYPE_ERROR,
|
||||
gmdate( WP::datetime_mysql_format(), $timestamp )
|
||||
);
|
||||
// phpcs:enable WordPress.DB.PreparedSQLPlaceholders.UnquotedComplexPlaceholder
|
||||
|
||||
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
|
||||
$error_events_count = (int) $wpdb->get_var( $sql );
|
||||
|
||||
set_transient( $transient_key, $error_events_count, HOUR_IN_SECONDS );
|
||||
|
||||
return $error_events_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the screen options for the debug events page.
|
||||
*
|
||||
@@ -359,7 +414,8 @@ class DebugEvents {
|
||||
|
||||
$table = self::get_table_name();
|
||||
|
||||
$is_valid = (bool) $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s;', $table ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||
$is_valid = (bool) $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s;', $table ) );
|
||||
|
||||
return $is_valid;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace WPMailSMTP\Admin;
|
||||
|
||||
use WPMailSMTP\Helpers\Helpers;
|
||||
|
||||
/**
|
||||
* Class for interacting with the Domain Checker API.
|
||||
*
|
||||
@@ -53,7 +55,12 @@ class DomainChecker {
|
||||
'domain' => $sending_domain,
|
||||
];
|
||||
|
||||
$response = wp_remote_get( add_query_arg( $params, self::ENDPOINT ) );
|
||||
$response = wp_remote_get(
|
||||
add_query_arg( $params, self::ENDPOINT ),
|
||||
[
|
||||
'user-agent' => Helpers::get_default_user_agent(),
|
||||
]
|
||||
);
|
||||
|
||||
if ( is_wp_error( $response ) ) {
|
||||
$this->results = [
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace WPMailSMTP\Admin;
|
||||
|
||||
use WPMailSMTP\Helpers\Helpers;
|
||||
use WPMailSMTP\Options;
|
||||
use WPMailSMTP\Tasks\Tasks;
|
||||
use WPMailSMTP\WP;
|
||||
@@ -120,7 +121,12 @@ class Notifications {
|
||||
*/
|
||||
protected function fetch_feed() {
|
||||
|
||||
$response = wp_remote_get( self::SOURCE_URL );
|
||||
$response = wp_remote_get(
|
||||
self::SOURCE_URL,
|
||||
[
|
||||
'user-agent' => Helpers::get_default_user_agent(),
|
||||
]
|
||||
);
|
||||
|
||||
if ( is_wp_error( $response ) ) {
|
||||
return [];
|
||||
@@ -226,6 +232,7 @@ class Notifications {
|
||||
* Get notification data.
|
||||
*
|
||||
* @since 2.3.0
|
||||
* @since 3.9.0 Make the AS a recurring task.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -237,16 +244,17 @@ class Notifications {
|
||||
|
||||
$option = $this->get_option();
|
||||
|
||||
// Update notifications using async task.
|
||||
if ( empty( $option['update'] ) || time() > $option['update'] + DAY_IN_SECONDS ) {
|
||||
if ( empty( Tasks::is_scheduled( 'wp_mail_smtp_admin_notifications_update' ) ) ) {
|
||||
// Update notifications a recurring task.
|
||||
if ( Tasks::is_scheduled( 'wp_mail_smtp_admin_notifications_update' ) === false ) {
|
||||
|
||||
wp_mail_smtp()->get_tasks()
|
||||
->create( 'wp_mail_smtp_admin_notifications_update' )
|
||||
->async()
|
||||
->params()
|
||||
->register();
|
||||
}
|
||||
wp_mail_smtp()->get_tasks()
|
||||
->create( 'wp_mail_smtp_admin_notifications_update' )
|
||||
->recurring(
|
||||
strtotime( '+1 minute' ),
|
||||
$this->get_notification_update_task_interval()
|
||||
)
|
||||
->params()
|
||||
->register();
|
||||
}
|
||||
|
||||
$events = ! empty( $option['events'] ) ? $this->verify_active( $option['events'] ) : [];
|
||||
@@ -255,6 +263,25 @@ class Notifications {
|
||||
return array_merge( $events, $feed );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the update notifications interval.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function get_notification_update_task_interval() {
|
||||
|
||||
/**
|
||||
* Filters the interval for the notifications update task.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @param int $interval The interval in seconds. Default to a day (in seconds).
|
||||
*/
|
||||
return (int) apply_filters( 'wp_mail_smtp_admin_notifications_get_notification_update_task_interval', DAY_IN_SECONDS );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get notification count.
|
||||
*
|
||||
@@ -392,6 +419,11 @@ class Notifications {
|
||||
'target' => [],
|
||||
'rel' => [],
|
||||
],
|
||||
'br' => [],
|
||||
'p' => [
|
||||
'id' => [],
|
||||
'class' => [],
|
||||
],
|
||||
];
|
||||
|
||||
foreach ( $notifications as $notification ) {
|
||||
@@ -418,11 +450,11 @@ class Notifications {
|
||||
$notifications_html .= sprintf(
|
||||
'<div class="wp-mail-smtp-notifications-message%5$s" data-message-id="%4$s">
|
||||
<h3 class="wp-mail-smtp-notifications-title">%1$s</h3>
|
||||
<p class="wp-mail-smtp-notifications-content">%2$s</p>
|
||||
<div class="wp-mail-smtp-notifications-content">%2$s</div>
|
||||
%3$s
|
||||
</div>',
|
||||
! empty( $notification['title'] ) ? sanitize_text_field( $notification['title'] ) : '',
|
||||
! empty( $notification['content'] ) ? wp_kses( $notification['content'], $content_allowed_tags ) : '',
|
||||
! empty( $notification['content'] ) ? wp_kses( wpautop( $notification['content'] ), $content_allowed_tags ) : '',
|
||||
$buttons_html,
|
||||
! empty( $notification['id'] ) ? esc_attr( sanitize_text_field( $notification['id'] ) ) : 0,
|
||||
$current_class
|
||||
|
||||
@@ -68,13 +68,13 @@ class AdditionalConnectionsTab extends PageAbstract {
|
||||
|
||||
wp_enqueue_style(
|
||||
'wp-mail-smtp-admin-lity',
|
||||
wp_mail_smtp()->assets_url . '/libs/lity/lity.min.css',
|
||||
wp_mail_smtp()->assets_url . '/css/vendor/lity.min.css',
|
||||
[],
|
||||
'2.4.1'
|
||||
);
|
||||
wp_enqueue_script(
|
||||
'wp-mail-smtp-admin-lity',
|
||||
wp_mail_smtp()->assets_url . '/libs/lity/lity.min.js',
|
||||
wp_mail_smtp()->assets_url . '/js/vendor/lity.min.js',
|
||||
[],
|
||||
'2.4.1'
|
||||
);
|
||||
|
||||
@@ -73,13 +73,13 @@ class EmailReportsTab extends PageAbstract {
|
||||
|
||||
wp_enqueue_style(
|
||||
'wp-mail-smtp-admin-lity',
|
||||
wp_mail_smtp()->assets_url . '/libs/lity/lity.min.css',
|
||||
wp_mail_smtp()->assets_url . '/css/vendor/lity.min.css',
|
||||
[],
|
||||
'2.4.1'
|
||||
);
|
||||
wp_enqueue_script(
|
||||
'wp-mail-smtp-admin-lity',
|
||||
wp_mail_smtp()->assets_url . '/libs/lity/lity.min.js',
|
||||
wp_mail_smtp()->assets_url . '/js/vendor/lity.min.js',
|
||||
[],
|
||||
'2.4.1',
|
||||
false
|
||||
|
||||
@@ -82,13 +82,13 @@ class LogsTab extends PageAbstract {
|
||||
|
||||
wp_enqueue_style(
|
||||
'wp-mail-smtp-admin-lity',
|
||||
wp_mail_smtp()->assets_url . '/libs/lity/lity.min.css',
|
||||
wp_mail_smtp()->assets_url . '/css/vendor/lity.min.css',
|
||||
[],
|
||||
'2.4.1'
|
||||
);
|
||||
wp_enqueue_script(
|
||||
'wp-mail-smtp-admin-lity',
|
||||
wp_mail_smtp()->assets_url . '/libs/lity/lity.min.js',
|
||||
wp_mail_smtp()->assets_url . '/js/vendor/lity.min.js',
|
||||
[],
|
||||
'2.4.1',
|
||||
false
|
||||
|
||||
@@ -67,11 +67,9 @@ class SmartRoutingTab extends PageAbstract {
|
||||
*/
|
||||
public function enqueue_assets() {
|
||||
|
||||
$min = WP::asset_min();
|
||||
|
||||
wp_enqueue_style(
|
||||
'wp-mail-smtp-smart-routing',
|
||||
wp_mail_smtp()->plugin_url . "/assets/css/smtp-smart-routing{$min}.css",
|
||||
wp_mail_smtp()->plugin_url . '/assets/css/smtp-smart-routing.min.css',
|
||||
[],
|
||||
WPMS_PLUGIN_VER
|
||||
);
|
||||
|
||||
@@ -326,12 +326,14 @@ class TestTab extends PageAbstract {
|
||||
|
||||
/* translators: %s - email address a test email will be sent to. */
|
||||
$subject = 'WP Mail SMTP: ' . sprintf( esc_html__( 'Test email to %s', 'wp-mail-smtp' ), $data['test']['email'] );
|
||||
$headers = [ 'X-Mailer-Type:WPMailSMTP/Admin/Test' ];
|
||||
|
||||
if ( $is_html ) {
|
||||
add_filter( 'wp_mail_content_type', array( __CLASS__, 'set_test_html_content_type' ) );
|
||||
|
||||
/* translators: %s - email address a test email will be sent to. */
|
||||
$subject = 'WP Mail SMTP: HTML ' . sprintf( esc_html__( 'Test email to %s', 'wp-mail-smtp' ), $data['test']['email'] );
|
||||
$subject = 'WP Mail SMTP: HTML ' . sprintf( esc_html__( 'Test email to %s', 'wp-mail-smtp' ), $data['test']['email'] );
|
||||
$headers[] = 'Content-Type: text/html';
|
||||
}
|
||||
|
||||
// Clear debug before send test email.
|
||||
@@ -345,9 +347,7 @@ class TestTab extends PageAbstract {
|
||||
$data['test']['email'],
|
||||
$subject,
|
||||
$this->get_email_message( $is_html ),
|
||||
array(
|
||||
'X-Mailer-Type:WPMailSMTP/Admin/Test',
|
||||
)
|
||||
$headers
|
||||
);
|
||||
|
||||
$smtp_debug = ob_get_clean();
|
||||
@@ -814,7 +814,7 @@ Co-Founder, WP Mail SMTP';
|
||||
esc_html__( 'Typically this error is returned when you are sending too many e-mails or e-mails that have been identified as spam.', 'wp-mail-smtp' ),
|
||||
],
|
||||
'steps' => [
|
||||
esc_html__( 'Check the emails that are sending are sending individually. Example: email is not sending to 30 recipients. You can install any WordPress e-mail logging plugin to do that.', 'wp-mail-smtp' ),
|
||||
esc_html__( 'Make sure you are not sending emails with too many recipients. Example: single email should not have 10+ recipients. You can install any WordPress e-mail logging plugin to check your recipients (TO, CC and BCC).', 'wp-mail-smtp' ),
|
||||
esc_html__( 'Contact your SMTP host to ask about sending/rate limits.', 'wp-mail-smtp' ),
|
||||
esc_html__( 'Verify with them your SMTP account is in good standing and your account has not been flagged.', 'wp-mail-smtp' ),
|
||||
],
|
||||
@@ -938,12 +938,12 @@ Co-Founder, WP Mail SMTP';
|
||||
],
|
||||
'title' => esc_html__( 'Mailgun failed.', 'wp-mail-smtp' ),
|
||||
'description' => [
|
||||
esc_html__( 'Typically this error occurs because there is an issue with your Mailgun settings, in many cases Private API Key, Domain Name, or Region is incorrect.', 'wp-mail-smtp' ),
|
||||
esc_html__( 'Typically this error occurs because there is an issue with your Mailgun settings, in many cases Mailgun API Key, Domain Name, or Region is incorrect.', 'wp-mail-smtp' ),
|
||||
],
|
||||
'steps' => [
|
||||
sprintf(
|
||||
wp_kses( /* translators: %1$s - Mailgun API Key area URL. */
|
||||
__( 'Go to your Mailgun account and verify that your <a href="%1$s" target="_blank" rel="noopener noreferrer">Private API Key</a> is correct.', 'wp-mail-smtp' ),
|
||||
__( 'Go to your Mailgun account and verify that your <a href="%1$s" target="_blank" rel="noopener noreferrer">Mailgun API Key</a> is correct.', 'wp-mail-smtp' ),
|
||||
[
|
||||
'a' => [
|
||||
'href' => [],
|
||||
@@ -952,7 +952,7 @@ Co-Founder, WP Mail SMTP';
|
||||
],
|
||||
]
|
||||
),
|
||||
'https://app.mailgun.com/app/account/security/api_keys'
|
||||
'https://app.mailgun.com/settings/api_security'
|
||||
),
|
||||
sprintf(
|
||||
wp_kses( /* translators: %1$s - Mailgun domains area URL. */
|
||||
@@ -1033,7 +1033,7 @@ Co-Founder, WP Mail SMTP';
|
||||
. '<li>' .
|
||||
sprintf(
|
||||
wp_kses( /* translators: %s - Google support article URL. */
|
||||
__( 'if you are using G Suite, please <a href="%s" target="_blank" rel="noopener noreferrer">read this article</a> to proceed.', 'wp-mail-smtp' ),
|
||||
__( 'if you are using Google Workspace, please <a href="%s" target="_blank" rel="noopener noreferrer">read this article</a> to proceed.', 'wp-mail-smtp' ),
|
||||
[
|
||||
'a' => [
|
||||
'href' => [],
|
||||
@@ -1124,8 +1124,8 @@ Co-Founder, WP Mail SMTP';
|
||||
],
|
||||
'steps' => [
|
||||
sprintf(
|
||||
wp_kses( /* translators: %s - Google G Suite Admin area URL. */
|
||||
__( 'Make sure that your G Suite trial period has not expired. You can check the status <a href="%s" target="_blank" rel="noopener noreferrer">here</a>.', 'wp-mail-smtp' ),
|
||||
wp_kses( /* translators: %s - Google Workspace Admin area URL. */
|
||||
__( 'Make sure that your Google Workspace trial period has not expired. You can check the status <a href="%s" target="_blank" rel="noopener noreferrer">here</a>.', 'wp-mail-smtp' ),
|
||||
[
|
||||
'a' => [
|
||||
'href' => [],
|
||||
@@ -1137,8 +1137,8 @@ Co-Founder, WP Mail SMTP';
|
||||
'https://admin.google.com'
|
||||
),
|
||||
sprintf(
|
||||
wp_kses( /* translators: %s - Google G Suite Admin area URL. */
|
||||
__( 'Make sure that Gmail app in your G Suite is actually enabled. You can check that in Apps list in <a href="%s" target="_blank" rel="noopener noreferrer">G Suite Admin</a> area.', 'wp-mail-smtp' ),
|
||||
wp_kses( /* translators: %s - Google Workspace Admin area URL. */
|
||||
__( 'Make sure that Gmail app in your Google Workspace is actually enabled. You can check that in Apps list in <a href="%s" target="_blank" rel="noopener noreferrer">Google Workspace Admin</a> area.', 'wp-mail-smtp' ),
|
||||
[
|
||||
'a' => [
|
||||
'href' => [],
|
||||
@@ -1357,7 +1357,7 @@ Co-Founder, WP Mail SMTP';
|
||||
. '</ul>',
|
||||
],
|
||||
'steps' => [
|
||||
esc_html__( 'Triple check the plugin settings, consider reconfiguring to make sure everything is correct (eg bad copy and paste).', 'wp-mail-smtp' ),
|
||||
esc_html__( 'Triple-check the plugin settings and consider reconfiguring to make sure everything is correct. Maybe there was an issue with copy&pasting.', 'wp-mail-smtp' ),
|
||||
wp_kses(
|
||||
__( 'Contact your web hosting provider and ask them to verify your server can make outside connections. Additionally, ask them if a firewall or security policy may be preventing the connection - many shared hosts block certain ports.<br><strong>Note: this is the most common cause of this issue.</strong>', 'wp-mail-smtp' ),
|
||||
[
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace WPMailSMTP\Admin;
|
||||
|
||||
use WPMailSMTP\Admin\Pages\TestTab;
|
||||
use WPMailSMTP\Connect;
|
||||
use WPMailSMTP\Helpers\Helpers;
|
||||
use WPMailSMTP\Helpers\PluginImportDataRetriever;
|
||||
use WPMailSMTP\Options;
|
||||
use WPMailSMTP\UsageTracking\UsageTracking;
|
||||
@@ -974,6 +975,7 @@ class SetupWizard {
|
||||
* AJAX callback for getting all partner's plugin information.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @since 3.9.0 Check if a SEO toolkit plugin is installed.
|
||||
*/
|
||||
public function get_partner_plugins_info() {
|
||||
|
||||
@@ -982,6 +984,7 @@ class SetupWizard {
|
||||
$plugins = $this->get_partner_plugins();
|
||||
|
||||
$contact_form_plugin_already_installed = false;
|
||||
$seo_toolkit_plugin_already_installed = false;
|
||||
|
||||
$contact_form_basenames = [
|
||||
'wpforms-lite/wpforms.php',
|
||||
@@ -992,12 +995,22 @@ class SetupWizard {
|
||||
'ninja-forms/ninja-forms.php',
|
||||
];
|
||||
|
||||
$seo_toolkit_basenames = [
|
||||
'all-in-one-seo-pack/all_in_one_seo_pack.php',
|
||||
'all-in-one-seo-pack-pro/all_in_one_seo_pack.php',
|
||||
'seo-by-rank-math/rank-math.php',
|
||||
'seo-by-rank-math-pro/rank-math-pro.php',
|
||||
'wordpress-seo/wp-seo.php',
|
||||
'wordpress-seo-premium/wp-seo-premium.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;
|
||||
} elseif ( in_array( $basename, $seo_toolkit_basenames, true ) ) {
|
||||
$seo_toolkit_plugin_already_installed = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1009,6 +1022,7 @@ class SetupWizard {
|
||||
$data = [
|
||||
'plugins' => $plugins,
|
||||
'contact_form_plugin_already_installed' => $contact_form_plugin_already_installed,
|
||||
'seo_toolkit_plugin_already_installed' => $seo_toolkit_plugin_already_installed,
|
||||
];
|
||||
|
||||
wp_send_json_success( $data );
|
||||
@@ -1032,6 +1046,12 @@ class SetupWizard {
|
||||
'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' ),
|
||||
@@ -1039,10 +1059,10 @@ class SetupWizard {
|
||||
'is_installed' => array_key_exists( 'google-analytics-for-wordpress/googleanalytics.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' => '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',
|
||||
@@ -1086,23 +1106,20 @@ class SetupWizard {
|
||||
wp_send_json_error();
|
||||
}
|
||||
|
||||
if ( function_exists( 'wpforms' ) && ( wpforms()->pro ) ) {
|
||||
$wpforms_version_type = 'pro';
|
||||
} elseif ( function_exists( 'wpforms' ) && ( ! wpforms()->pro ) ) {
|
||||
$wpforms_version_type = 'lite';
|
||||
}
|
||||
|
||||
$body = [
|
||||
'email' => base64_encode( $email ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
|
||||
];
|
||||
|
||||
if ( isset( $wpforms_version_type ) ) {
|
||||
$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,
|
||||
]
|
||||
);
|
||||
@@ -1110,6 +1127,28 @@ class SetupWizard {
|
||||
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.
|
||||
*
|
||||
@@ -1133,10 +1172,9 @@ class SetupWizard {
|
||||
wp_send_json_error( esc_html__( 'Please enter a valid license key!', 'wp-mail-smtp' ) );
|
||||
}
|
||||
|
||||
$oth = hash( 'sha512', wp_rand() );
|
||||
$url = Connect::generate_url(
|
||||
$license_key,
|
||||
$oth,
|
||||
'',
|
||||
add_query_arg( 'upgrade-redirect', '1', self::get_site_url() ) . '#/step/license'
|
||||
);
|
||||
|
||||
@@ -1220,6 +1258,7 @@ class SetupWizard {
|
||||
wp_remote_post(
|
||||
'https://wpmailsmtp.com/wizard-feedback/',
|
||||
[
|
||||
'user-agent' => Helpers::get_default_user_agent(),
|
||||
'body' => [
|
||||
'wpforms' => [
|
||||
'id' => 87892,
|
||||
|
||||
@@ -66,18 +66,21 @@ class Connect {
|
||||
*
|
||||
* @since 2.6.0
|
||||
*
|
||||
* @param string $key The license key.
|
||||
* @param string $oth The One-time hash.
|
||||
* @param string $redirect The redirect URL.
|
||||
* @param string $key The license key.
|
||||
* @param string $oth The One-time hash.
|
||||
* @param string $redirect The redirect URL.
|
||||
*
|
||||
* @return bool|string
|
||||
*/
|
||||
public static function generate_url( $key, $oth, $redirect = '' ) {
|
||||
public static function generate_url( $key, $oth = '', $redirect = '' ) {
|
||||
|
||||
if ( empty( $key ) || wp_mail_smtp()->is_pro() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$oth = ! empty( $oth ) ? $oth : hash( 'sha512', wp_rand() );
|
||||
$hashed_oth = hash_hmac( 'sha512', $oth, wp_salt() );
|
||||
|
||||
$redirect = ! empty( $redirect ) ? $redirect : wp_mail_smtp()->get_admin()->get_admin_page_url();
|
||||
|
||||
update_option( 'wp_mail_smtp_connect_token', $oth );
|
||||
@@ -86,7 +89,7 @@ class Connect {
|
||||
return add_query_arg(
|
||||
[
|
||||
'key' => $key,
|
||||
'oth' => $oth,
|
||||
'oth' => $hashed_oth,
|
||||
'endpoint' => admin_url( 'admin-ajax.php' ),
|
||||
'version' => WPMS_PLUGIN_VER,
|
||||
'siteurl' => admin_url(),
|
||||
@@ -151,8 +154,7 @@ class Connect {
|
||||
);
|
||||
}
|
||||
|
||||
$oth = hash( 'sha512', wp_rand() );
|
||||
$url = self::generate_url( $key, $oth );
|
||||
$url = self::generate_url( $key );
|
||||
|
||||
if ( empty( $url ) ) {
|
||||
wp_send_json_error(
|
||||
@@ -162,18 +164,7 @@ class Connect {
|
||||
);
|
||||
}
|
||||
|
||||
wp_send_json_success(
|
||||
[
|
||||
'url' => $url,
|
||||
'back_url' => add_query_arg(
|
||||
[
|
||||
'action' => 'wp_mail_smtp_connect',
|
||||
'oth' => $oth,
|
||||
],
|
||||
admin_url( 'admin-ajax.php' )
|
||||
),
|
||||
]
|
||||
);
|
||||
wp_send_json_success( [ 'url' => $url ] );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -196,7 +187,11 @@ class Connect {
|
||||
// Verify oth.
|
||||
$oth = get_option( 'wp_mail_smtp_connect_token' );
|
||||
|
||||
if ( empty( $oth ) || ! hash_equals( $oth, $post_oth ) ) {
|
||||
if ( empty( $oth ) ) {
|
||||
wp_send_json_error( $error );
|
||||
}
|
||||
|
||||
if ( hash_hmac( 'sha512', $oth, wp_salt() ) !== $post_oth ) {
|
||||
wp_send_json_error( $error );
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ use WPMailSMTP\Admin\AdminBarMenu;
|
||||
use WPMailSMTP\Admin\DashboardWidget;
|
||||
use WPMailSMTP\Admin\DebugEvents\DebugEvents;
|
||||
use WPMailSMTP\Admin\Notifications;
|
||||
use WPMailSMTP\Helpers\Helpers;
|
||||
use WPMailSMTP\Tasks\Meta;
|
||||
use WPMailSMTP\UsageTracking\UsageTracking;
|
||||
use WPMailSMTP\Compatibility\Compatibility;
|
||||
@@ -687,6 +688,8 @@ class Core {
|
||||
update_option( 'wp_mail_smtp_activated', $activated );
|
||||
}
|
||||
|
||||
set_transient( 'wp_mail_smtp_just_activated', true, 60 );
|
||||
|
||||
// Add transient to trigger redirect to the Setup Wizard.
|
||||
set_transient( 'wp_mail_smtp_activation_redirect', true, 30 );
|
||||
}
|
||||
@@ -751,11 +754,7 @@ class Core {
|
||||
*/
|
||||
public function get_upgrade_link( $utm ) {
|
||||
|
||||
$url = add_query_arg(
|
||||
'utm_locale',
|
||||
sanitize_key( get_locale() ),
|
||||
$this->get_utm_url( 'https://wpmailsmtp.com/lite-upgrade/', $utm )
|
||||
);
|
||||
$url = $this->get_utm_url( 'https://wpmailsmtp.com/lite-upgrade/', $utm );
|
||||
|
||||
/**
|
||||
* Filters upgrade link.
|
||||
@@ -784,6 +783,7 @@ class Core {
|
||||
$medium = 'plugin-settings';
|
||||
$campaign = $this->is_pro() ? 'plugin' : 'liteplugin';
|
||||
$content = 'general';
|
||||
$locale = get_user_locale();
|
||||
|
||||
if ( is_array( $utm ) ) {
|
||||
if ( isset( $utm['source'] ) ) {
|
||||
@@ -798,6 +798,9 @@ class Core {
|
||||
if ( isset( $utm['content'] ) ) {
|
||||
$content = $utm['content'];
|
||||
}
|
||||
if ( isset( $utm['locale'] ) ) {
|
||||
$locale = $utm['locale'];
|
||||
}
|
||||
} elseif ( is_string( $utm ) ) {
|
||||
$content = $utm;
|
||||
}
|
||||
@@ -806,6 +809,7 @@ class Core {
|
||||
'utm_source' => esc_attr( rawurlencode( $source ) ),
|
||||
'utm_medium' => esc_attr( rawurlencode( $medium ) ),
|
||||
'utm_campaign' => esc_attr( rawurlencode( $campaign ) ),
|
||||
'utm_locale' => esc_attr( sanitize_key( $locale ) ),
|
||||
];
|
||||
|
||||
if ( ! empty( $content ) ) {
|
||||
|
||||
@@ -141,7 +141,7 @@ class DBRepair {
|
||||
|
||||
return sprintf(
|
||||
wp_kses( /* translators: %1$s - missing table name; %2$s - error message. */
|
||||
__( '<strong>Table</strong> %1$s: <strong>Reason</strong> %2$s', 'wp-mail-smtp' ),
|
||||
__( '<strong>Table:</strong> %1$s. <strong>Reason:</strong> %2$s', 'wp-mail-smtp' ),
|
||||
[
|
||||
'strong' => [],
|
||||
]
|
||||
@@ -197,6 +197,16 @@ class DBRepair {
|
||||
_n( 'Table is', 'Tables are', count( $missing_tables ), 'wp-mail-smtp' ),
|
||||
implode( '<br/>', $reasons )
|
||||
);
|
||||
|
||||
$msg = sprintf(
|
||||
wp_kses(
|
||||
_n( 'The following DB table is still missing.', 'The following DB tables are still missing.', count( $missing_tables ), 'wp-mail-smtp' ) . '<br />%s',
|
||||
[
|
||||
'br' => [],
|
||||
]
|
||||
),
|
||||
implode( '<br/>', $reasons )
|
||||
);
|
||||
} else {
|
||||
$msg = esc_html__( 'Some DB Tables are still missing.', 'wp-mail-smtp' );
|
||||
}
|
||||
|
||||
@@ -139,4 +139,18 @@ class Helpers {
|
||||
|
||||
return $error_text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default user agent.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_default_user_agent() {
|
||||
|
||||
$license_type = wp_mail_smtp()->get_license_type();
|
||||
|
||||
return 'WordPress/' . get_bloginfo( 'version' ) . '; ' . get_bloginfo( 'url' ) . '; WPMailSMTP/' . $license_type . '-' . WPMS_PLUGIN_VER;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ class Options extends OptionsAbstract {
|
||||
<!-- API Key -->
|
||||
<div id="wp-mail-smtp-setting-row-<?php echo esc_attr( $this->get_slug() ); ?>-api_key" class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-text wp-mail-smtp-clear">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label for="wp-mail-smtp-setting-<?php echo esc_attr( $this->get_slug() ); ?>-api_key"><?php esc_html_e( 'Private API Key', 'wp-mail-smtp' ); ?></label>
|
||||
<label for="wp-mail-smtp-setting-<?php echo esc_attr( $this->get_slug() ); ?>-api_key"><?php esc_html_e( 'Mailgun API Key', 'wp-mail-smtp' ); ?></label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<?php if ( $this->connection_options->is_const_defined( $this->get_slug(), 'api_key' ) ) : ?>
|
||||
@@ -73,12 +73,18 @@ class Options extends OptionsAbstract {
|
||||
<?php endif; ?>
|
||||
<p class="desc">
|
||||
<?php
|
||||
printf(
|
||||
/* translators: %s - API key link. */
|
||||
esc_html__( 'Follow this link to get a Private API Key from Mailgun: %s.', 'wp-mail-smtp' ),
|
||||
'<a href="https://app.mailgun.com/app/account/security/api_keys" target="_blank" rel="noopener noreferrer">' .
|
||||
esc_html__( 'Get a Private API Key', 'wp-mail-smtp' ) .
|
||||
'</a>'
|
||||
echo wp_kses(
|
||||
sprintf( /* translators: %s - API key URL. */
|
||||
__( 'Follow this link to <a href="%s" target="_blank" rel="noopener noreferrer">get a Mailgun API Key</a>. Generate a key in the "Mailgun API Keys" section.', 'wp-mail-smtp' ),
|
||||
'https://app.mailgun.com/settings/api_security'
|
||||
),
|
||||
[
|
||||
'a' => [
|
||||
'href' => [],
|
||||
'rel' => [],
|
||||
'target' => [],
|
||||
],
|
||||
]
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
@@ -101,7 +107,7 @@ class Options extends OptionsAbstract {
|
||||
printf(
|
||||
/* translators: %s - Domain Name link. */
|
||||
esc_html__( 'Follow this link to get a Domain Name from Mailgun: %s.', 'wp-mail-smtp' ),
|
||||
'<a href="https://app.mailgun.com/app/domains" target="_blank" rel="noopener noreferrer">' .
|
||||
'<a href="https://app.mailgun.com/app/sending/domains" target="_blank" rel="noopener noreferrer">' .
|
||||
esc_html__( 'Get a Domain Name', 'wp-mail-smtp' ) .
|
||||
'</a>'
|
||||
);
|
||||
|
||||
@@ -3,10 +3,6 @@
|
||||
namespace WPMailSMTP\Providers\Sendinblue;
|
||||
|
||||
use WPMailSMTP\ConnectionInterface;
|
||||
use WPMailSMTP\Vendor\SendinBlue\Client\Api\AccountApi;
|
||||
use WPMailSMTP\Vendor\SendinBlue\Client\Api\SendersApi;
|
||||
use WPMailSMTP\Vendor\SendinBlue\Client\Api\TransactionalEmailsApi;
|
||||
use WPMailSMTP\Vendor\SendinBlue\Client\Configuration;
|
||||
|
||||
/**
|
||||
* Class Api is a wrapper for Sendinblue library with handy methods.
|
||||
@@ -55,51 +51,54 @@ class Api {
|
||||
* Configure API key authorization: api-key.
|
||||
*
|
||||
* @since 1.6.0
|
||||
* @deprecated 3.9.0 We are no longer using the Sendinblue SDK.
|
||||
*
|
||||
* @return Configuration
|
||||
* @return null
|
||||
*/
|
||||
protected function get_api_config() {
|
||||
|
||||
return Configuration::getDefaultConfiguration()->setApiKey( 'api-key', isset( $this->options['api_key'] ) ? $this->options['api_key'] : '' );
|
||||
_deprecated_function( __METHOD__, '3.9.0' );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mailer client instance for Account API.
|
||||
*
|
||||
* @since 1.6.0
|
||||
* @deprecated 3.9.0 We are no longer using the Sendinblue SDK.
|
||||
*/
|
||||
public function get_account_client() {
|
||||
|
||||
// Include the library.
|
||||
require_once wp_mail_smtp()->plugin_path . '/vendor/autoload.php';
|
||||
_deprecated_function( __METHOD__, '3.9.0' );
|
||||
|
||||
return new AccountApi( null, $this->get_api_config() );
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mailer client instance for Sender API.
|
||||
*
|
||||
* @since 1.6.0
|
||||
* @deprecated 3.9.0 We are no longer using the Sendinblue SDK.
|
||||
*/
|
||||
public function get_sender_client() {
|
||||
|
||||
// Include the library.
|
||||
require_once wp_mail_smtp()->plugin_path . '/vendor/autoload.php';
|
||||
_deprecated_function( __METHOD__, '3.9.0' );
|
||||
|
||||
return new SendersApi( null, $this->get_api_config() );
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mailer client instance for SMTP API.
|
||||
*
|
||||
* @since 1.6.0
|
||||
* @deprecated 3.9.0 We are no longer using the Sendinblue SDK.
|
||||
*/
|
||||
public function get_smtp_client() {
|
||||
|
||||
// Include the library.
|
||||
require_once wp_mail_smtp()->plugin_path . '/vendor/autoload.php';
|
||||
_deprecated_function( __METHOD__, '3.9.0' );
|
||||
|
||||
return new TransactionalEmailsApi( null, $this->get_api_config() );
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,13 +2,10 @@
|
||||
|
||||
namespace WPMailSMTP\Providers\Sendinblue;
|
||||
|
||||
use WPMailSMTP\Admin\DebugEvents\DebugEvents;
|
||||
use WPMailSMTP\ConnectionInterface;
|
||||
use WPMailSMTP\Helpers\Helpers;
|
||||
use WPMailSMTP\MailCatcherInterface;
|
||||
use WPMailSMTP\Providers\MailerAbstract;
|
||||
use WPMailSMTP\Vendor\SendinBlue\Client\ApiException;
|
||||
use WPMailSMTP\Vendor\SendinBlue\Client\Model\CreateSmtpEmail;
|
||||
use WPMailSMTP\Vendor\SendinBlue\Client\Model\SendSmtpEmail;
|
||||
use WPMailSMTP\WP;
|
||||
|
||||
/**
|
||||
@@ -27,15 +24,41 @@ class Mailer extends MailerAbstract {
|
||||
*/
|
||||
protected $email_sent_code = 201;
|
||||
|
||||
/**
|
||||
* Response code for scheduled email.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $email_scheduled_code = 202;
|
||||
|
||||
/**
|
||||
* URL to make an API request to.
|
||||
* Not actually used, because we use a lib to make requests.
|
||||
*
|
||||
* @since 1.6.0
|
||||
* @since 3.9.0 Update to use Brevo API.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $url = 'https://api.sendinblue.com/v3';
|
||||
protected $url = 'https://api.brevo.com/v3/smtp/email';
|
||||
|
||||
/**
|
||||
* Mailer constructor.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @param MailCatcherInterface $phpmailer The MailCatcher object.
|
||||
* @param ConnectionInterface $connection The Connection object.
|
||||
*/
|
||||
public function __construct( $phpmailer, $connection = null ) {
|
||||
|
||||
parent::__construct( $phpmailer, $connection );
|
||||
|
||||
$this->set_header( 'api-key', $this->connection_options->get( $this->mailer, 'api_key' ) );
|
||||
$this->set_header( 'Accept', 'application/json' );
|
||||
$this->set_header( 'content-type', 'application/json' );
|
||||
}
|
||||
|
||||
/**
|
||||
* The list of allowed attachment files extensions.
|
||||
@@ -51,15 +74,49 @@ class Mailer extends MailerAbstract {
|
||||
// @formatter:on
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* Redefine the way custom headers are processed for this mailer - they should be in body.
|
||||
*
|
||||
* @since 1.6.0
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @param array $headers List of key=>value pairs.
|
||||
*/
|
||||
public function set_header( $name, $value ) {
|
||||
public function set_headers( $headers ) {
|
||||
|
||||
foreach ( $headers as $header ) {
|
||||
$name = isset( $header[0] ) ? $header[0] : false;
|
||||
$value = isset( $header[1] ) ? $header[1] : false;
|
||||
|
||||
$this->set_body_header( $name, $value );
|
||||
}
|
||||
|
||||
// Add custom PHPMailer-specific header.
|
||||
$this->set_body_header( 'X-Mailer', 'WPMailSMTP/Mailer/' . $this->mailer . ' ' . WPMS_PLUGIN_VER );
|
||||
}
|
||||
|
||||
/**
|
||||
* This mailer supports email-related custom headers inside a body of the message.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @param string $name Key.
|
||||
* @param string $value Value.
|
||||
*/
|
||||
public function set_body_header( $name, $value ) {
|
||||
|
||||
$name = sanitize_text_field( $name );
|
||||
|
||||
$this->body['headers'][ $name ] = WP::sanitize_value( $value );
|
||||
if ( empty( $name ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$headers = isset( $this->body['headers'] ) ? (array) $this->body['headers'] : [];
|
||||
$headers[ $name ] = WP::sanitize_value( $value );
|
||||
|
||||
$this->set_body_param(
|
||||
[
|
||||
'headers' => $headers,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -263,8 +320,9 @@ class Mailer extends MailerAbstract {
|
||||
* Get the email body.
|
||||
*
|
||||
* @since 1.6.0
|
||||
* @since 3.9.0 Returns email body array instead of `SendSmtpEmail` object.
|
||||
*
|
||||
* @return SendSmtpEmail
|
||||
* @return array
|
||||
*/
|
||||
public function get_body() {
|
||||
|
||||
@@ -275,82 +333,110 @@ class Mailer extends MailerAbstract {
|
||||
*
|
||||
* @param array $body Email body.
|
||||
*/
|
||||
$body = apply_filters( 'wp_mail_smtp_providers_sendinblue_mailer_get_body', $this->body );
|
||||
|
||||
return new SendSmtpEmail( $body );
|
||||
return apply_filters( 'wp_mail_smtp_providers_sendinblue_mailer_get_body', $this->body );
|
||||
}
|
||||
|
||||
/**
|
||||
* Use a library to send emails.
|
||||
* Send email.
|
||||
*
|
||||
* @since 1.6.0
|
||||
* @since 3.9.0 Use API instead of SDK to send email.
|
||||
*/
|
||||
public function send() {
|
||||
|
||||
try {
|
||||
$api = new Api( $this->connection );
|
||||
$response = wp_safe_remote_post(
|
||||
$this->url,
|
||||
[
|
||||
'headers' => $this->get_headers(),
|
||||
'body' => wp_json_encode( $this->get_body() ),
|
||||
]
|
||||
);
|
||||
|
||||
$response = $api->get_smtp_client()->sendTransacEmail( $this->get_body() );
|
||||
$this->process_response( $response );
|
||||
}
|
||||
|
||||
DebugEvents::add_debug(
|
||||
esc_html__( 'An email request was sent to the Sendinblue API.', 'wp-mail-smtp' )
|
||||
);
|
||||
/**
|
||||
* We might need to do something after the email was sent to the API.
|
||||
* In this method we preprocess the response from the API.
|
||||
*
|
||||
* @since 1.6.0
|
||||
* @since 3.9.0 Expect a generic class object instead of `CreateSmtpEmail`.
|
||||
*
|
||||
* @param mixed $response Response from the API.
|
||||
*/
|
||||
protected function process_response( $response ) {
|
||||
|
||||
$this->process_response( $response );
|
||||
} catch ( ApiException $e ) {
|
||||
$error = json_decode( $e->getResponseBody() );
|
||||
parent::process_response( $response );
|
||||
|
||||
if ( json_last_error() === JSON_ERROR_NONE && ! empty( $error ) ) {
|
||||
$message = Helpers::format_error_message( $error->message, $error->code );
|
||||
} else {
|
||||
$message = $e->getMessage();
|
||||
}
|
||||
|
||||
$this->error_message = $message;
|
||||
} catch ( \Exception $e ) {
|
||||
$this->error_message = $e->getMessage();
|
||||
if ( $this->has_message_id() ) {
|
||||
$this->phpmailer->MessageID = $this->response['body']->messageId;
|
||||
$this->verify_sent_status = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save response from the API to use it later.
|
||||
* All the actually response processing is done in send() method,
|
||||
* because SendinBlue throws exception if any error occurs.
|
||||
* Get a Sendinblue-specific response with a helpful error.
|
||||
*
|
||||
* @since 1.6.0
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @param CreateSmtpEmail $response The Sendinblue Email object.
|
||||
* @return string
|
||||
*/
|
||||
protected function process_response( $response ) {
|
||||
public function get_response_error() {
|
||||
|
||||
$this->response = $response;
|
||||
$error_text = [];
|
||||
|
||||
if ( ! empty( $this->error_message ) ) {
|
||||
$error_text[] = $this->error_message;
|
||||
}
|
||||
|
||||
if ( ! empty( $this->response ) ) {
|
||||
$body = wp_remote_retrieve_body( $this->response );
|
||||
|
||||
if ( ! empty( $body->message ) ) {
|
||||
$error_text[] = Helpers::format_error_message( $body->message, ! empty( $body->code ) ? $body->code : '' );
|
||||
} else {
|
||||
$error_text[] = WP::wp_remote_get_response_error_message( $this->response );
|
||||
}
|
||||
}
|
||||
|
||||
return implode( WP::EOL, array_map( 'esc_textarea', array_filter( $error_text ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the response has `messageId` property.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function has_message_id() {
|
||||
|
||||
if (
|
||||
is_a( $response, 'WPMailSMTP\Vendor\SendinBlue\Client\Model\CreateSmtpEmail' ) &&
|
||||
method_exists( $response, 'getMessageId' )
|
||||
! in_array(
|
||||
wp_remote_retrieve_response_code( $this->response ),
|
||||
[ $this->email_sent_code, $this->email_scheduled_code ],
|
||||
true
|
||||
) ||
|
||||
empty( $this->response['body']->messageId )
|
||||
) {
|
||||
$this->phpmailer->MessageID = $response->getMessageId();
|
||||
$this->verify_sent_status = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the email was sent.
|
||||
*
|
||||
* @since 1.6.0
|
||||
* @since 3.9.0 Check if `$this->response` has `messageId` property to check if the email was sent.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_email_sent() {
|
||||
|
||||
$is_sent = false;
|
||||
|
||||
if ( $this->response instanceof CreateSmtpEmail ) {
|
||||
$is_sent = $this->response->valid();
|
||||
}
|
||||
|
||||
/** This filter is documented in src/Providers/MailerAbstract.php. */
|
||||
return apply_filters( 'wp_mail_smtp_providers_mailer_is_email_sent', $is_sent, $this->mailer );
|
||||
return apply_filters( 'wp_mail_smtp_providers_mailer_is_email_sent', $this->has_message_id(), $this->mailer ); // phpcs:ignore WPForms.PHP.ValidateHooks.InvalidHookName
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,11 +34,11 @@ class Options extends OptionsAbstract {
|
||||
}
|
||||
|
||||
$description = sprintf(
|
||||
wp_kses( /* translators: %1$s - URL to sendinblue.com site. */
|
||||
__( '<strong><a href="%1$s" target="_blank" rel="noopener noreferrer">Sendinblue</a> is one of our recommended mailers.</strong> It\'s a transactional email provider with scalable price plans, so it\'s suitable for any size of business.<br><br>If you\'re just starting out, you can use Sendinblue\'s free plan to send up to 300 emails a day. You don\'t need to use a credit card to try it out. When you\'re ready, you can upgrade to a higher plan to increase your sending limits.', 'wp-mail-smtp' ) .
|
||||
wp_kses( /* translators: %1$s - URL to brevo.com site. */
|
||||
__( '<strong><a href="%1$s" target="_blank" rel="noopener noreferrer">Brevo</a> (formerly Sendinblue) is one of our recommended mailers.</strong> It\'s a transactional email provider with scalable price plans, so it\'s suitable for any size of business.<br><br>If you\'re just starting out, you can use Brevo\'s free plan to send up to 300 emails a day. You don\'t need to use a credit card to try it out. When you\'re ready, you can upgrade to a higher plan to increase your sending limits.', 'wp-mail-smtp' ) .
|
||||
'<br><br>' .
|
||||
/* translators: %2$s - URL to wpmailsmtp.com doc. */
|
||||
__( 'To get started, read our <a href="%2$s" target="_blank" rel="noopener noreferrer">Sendinblue documentation</a>.', 'wp-mail-smtp' ),
|
||||
__( 'To get started, read our <a href="%2$s" target="_blank" rel="noopener noreferrer">Brevo documentation</a>.', 'wp-mail-smtp' ),
|
||||
[
|
||||
'strong' => true,
|
||||
'br' => true,
|
||||
@@ -50,7 +50,7 @@ class Options extends OptionsAbstract {
|
||||
]
|
||||
),
|
||||
'https://wpmailsmtp.com/go/sendinblue/',
|
||||
esc_url( wp_mail_smtp()->get_utm_url( 'https://wpmailsmtp.com/docs/how-to-set-up-the-sendinblue-mailer-in-wp-mail-smtp/', 'Sendinblue documentation' ) )
|
||||
esc_url( wp_mail_smtp()->get_utm_url( 'https://wpmailsmtp.com/docs/how-to-set-up-the-sendinblue-mailer-in-wp-mail-smtp/', 'Brevo documentation' ) )
|
||||
);
|
||||
|
||||
$api_key = $connection->get_options()->get( self::SLUG, 'api_key' );
|
||||
@@ -59,21 +59,21 @@ class Options extends OptionsAbstract {
|
||||
$description .= sprintf(
|
||||
'</p><p class="buttonned"><a href="%1$s" target="_blank" rel="noopener noreferrer" class="wp-mail-smtp-btn wp-mail-smtp-btn-md wp-mail-smtp-btn-blueish">%2$s</a></p>',
|
||||
'https://wpmailsmtp.com/go/sendinblue/',
|
||||
esc_html__( 'Get Sendinblue Now (Free)', 'wp-mail-smtp' )
|
||||
esc_html__( 'Get Brevo Now (Free)', 'wp-mail-smtp' )
|
||||
);
|
||||
}
|
||||
|
||||
$description .= '<p class="wp-mail-smtp-tooltip">' .
|
||||
esc_html__( 'Transparency and Disclosure', 'wp-mail-smtp' ) .
|
||||
'<span class="wp-mail-smtp-tooltip-text">' .
|
||||
esc_html__( 'We believe in full transparency. The Sendinblue links above are tracking links as part of our partnership with Sendinblue. We can recommend just about any SMTP service, but we only recommend products that we believe will add value to our users.', 'wp-mail-smtp' ) .
|
||||
esc_html__( 'We believe in full transparency. The Brevo (formerly Sendinblue) links above are tracking links as part of our partnership with Brevo. We can recommend just about any SMTP service, but we only recommend products that we believe will add value to our users.', 'wp-mail-smtp' ) .
|
||||
'</span></p>';
|
||||
|
||||
parent::__construct(
|
||||
[
|
||||
'logo_url' => wp_mail_smtp()->assets_url . '/images/providers/sendinblue.svg',
|
||||
'logo_url' => wp_mail_smtp()->assets_url . '/images/providers/brevo.svg',
|
||||
'slug' => self::SLUG,
|
||||
'title' => esc_html__( 'Sendinblue', 'wp-mail-smtp' ),
|
||||
'title' => esc_html__( 'Brevo', 'wp-mail-smtp' ),
|
||||
'php' => '5.6',
|
||||
'description' => $description,
|
||||
'supports' => [
|
||||
@@ -128,7 +128,7 @@ class Options extends OptionsAbstract {
|
||||
<?php
|
||||
printf( /* translators: %s - link to get an API Key. */
|
||||
esc_html__( 'Follow this link to get an API Key: %s.', 'wp-mail-smtp' ),
|
||||
'<a href="https://account.sendinblue.com/advanced/api" target="_blank" rel="noopener noreferrer">' .
|
||||
'<a href="https://app.brevo.com/settings/keys/api" target="_blank" rel="noopener noreferrer">' .
|
||||
esc_html__( 'Get v3 API Key', 'wp-mail-smtp' ) .
|
||||
'</a>'
|
||||
);
|
||||
@@ -153,7 +153,7 @@ class Options extends OptionsAbstract {
|
||||
printf(
|
||||
wp_kses(
|
||||
/* translators: %s - URL to Sendinblue documentation on wpmailsmtp.com */
|
||||
__( 'Please input the sending domain/subdomain you configured in your Sendinblue dashboard. More information can be found in our <a href="%s" target="_blank" rel="noopener noreferrer">Sendinblue documentation</a>.', 'wp-mail-smtp' ),
|
||||
__( 'Please input the sending domain/subdomain you configured in your Brevo (formerly Sendinblue) dashboard. More information can be found in our <a href="%s" target="_blank" rel="noopener noreferrer">Brevo documentation</a>.', 'wp-mail-smtp' ),
|
||||
[
|
||||
'br' => [],
|
||||
'a' => [
|
||||
@@ -163,7 +163,7 @@ class Options extends OptionsAbstract {
|
||||
],
|
||||
]
|
||||
),
|
||||
esc_url( wp_mail_smtp()->get_utm_url( 'https://wpmailsmtp.com/docs/how-to-set-up-the-sendinblue-mailer-in-wp-mail-smtp/#setup-smtp', 'Sendinblue documentation' ) )
|
||||
esc_url( wp_mail_smtp()->get_utm_url( 'https://wpmailsmtp.com/docs/how-to-set-up-the-sendinblue-mailer-in-wp-mail-smtp/#setup-smtp', 'Brevo documentation' ) )
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
|
||||
@@ -6,6 +6,7 @@ use WPMailSMTP\Admin\DomainChecker;
|
||||
use WPMailSMTP\Admin\SetupWizard;
|
||||
use WPMailSMTP\Conflicts;
|
||||
use WPMailSMTP\Debug;
|
||||
use WPMailSMTP\Helpers\Helpers;
|
||||
use WPMailSMTP\Options;
|
||||
use WPMailSMTP\WP;
|
||||
|
||||
@@ -91,7 +92,7 @@ class UsageTracking {
|
||||
*/
|
||||
public function get_user_agent() {
|
||||
|
||||
return 'WPMailSMTP/' . WPMS_PLUGIN_VER . '; ' . get_bloginfo( 'url' );
|
||||
return Helpers::get_default_user_agent();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user