rebase code on oct-10-2023
This commit is contained in:
@@ -95,9 +95,6 @@ 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 );
|
||||
|
||||
@@ -107,6 +104,9 @@ 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,36 +221,6 @@ 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.
|
||||
*
|
||||
@@ -556,13 +526,13 @@ class Area {
|
||||
*/
|
||||
wp_enqueue_style(
|
||||
'wp-mail-smtp-admin-jconfirm',
|
||||
wp_mail_smtp()->assets_url . '/css/vendor/jquery-confirm.min.css',
|
||||
wp_mail_smtp()->assets_url . '/libs/jquery-confirm.min.css',
|
||||
[ 'wp-mail-smtp-admin' ],
|
||||
'3.3.4'
|
||||
);
|
||||
wp_enqueue_script(
|
||||
'wp-mail-smtp-admin-jconfirm',
|
||||
wp_mail_smtp()->assets_url . '/js/vendor/jquery-confirm.min.js',
|
||||
wp_mail_smtp()->assets_url . '/libs/jquery-confirm.min.js',
|
||||
[ 'wp-mail-smtp-admin' ],
|
||||
'3.3.4',
|
||||
false
|
||||
@@ -950,6 +920,7 @@ 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(),
|
||||
@@ -1160,14 +1131,6 @@ 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 );
|
||||
@@ -1226,7 +1189,7 @@ class Area {
|
||||
return $links;
|
||||
}
|
||||
|
||||
$custom['wp-mail-smtp-pro'] = sprintf(
|
||||
$custom['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\';"
|
||||
@@ -1238,14 +1201,14 @@ class Area {
|
||||
esc_html__( 'Get WP Mail SMTP Pro', 'wp-mail-smtp' )
|
||||
);
|
||||
|
||||
$custom['wp-mail-smtp-settings'] = sprintf(
|
||||
$custom['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['wp-mail-smtp-docs'] = sprintf(
|
||||
$custom['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' ] ) ),
|
||||
@@ -1337,14 +1300,10 @@ 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,7 +2,6 @@
|
||||
|
||||
namespace WPMailSMTP\Admin;
|
||||
|
||||
use WPMailSMTP\Admin\DebugEvents\DebugEvents;
|
||||
use WPMailSMTP\Helpers\Helpers;
|
||||
use WPMailSMTP\Options;
|
||||
use WPMailSMTP\WP;
|
||||
@@ -176,8 +175,7 @@ class DashboardWidget {
|
||||
unset( $normal_dashboard[ $widget_key ] );
|
||||
$sorted_dashboard = array_merge( $widget_instance, $normal_dashboard );
|
||||
|
||||
//phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
|
||||
$wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard;
|
||||
$wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard; //phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -260,7 +258,8 @@ class DashboardWidget {
|
||||
*/
|
||||
private function widget_content_html() {
|
||||
|
||||
$hide_graph = (bool) $this->widget_meta( 'get', 'hide_graph' );
|
||||
$hide_graph = (bool) $this->widget_meta( 'get', 'hide_graph' );
|
||||
$hide_summary_report_email_block = (bool) $this->widget_meta( 'get', 'hide_summary_report_email_block' );
|
||||
?>
|
||||
|
||||
<?php if ( ! $hide_graph ) : ?>
|
||||
@@ -302,155 +301,37 @@ class DashboardWidget {
|
||||
<?php $this->email_stats_block(); ?>
|
||||
</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>
|
||||
<?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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
<?php endif; ?>
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -465,8 +346,7 @@ class DashboardWidget {
|
||||
],
|
||||
]
|
||||
),
|
||||
// phpcs:ignore WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
|
||||
esc_url( wp_mail_smtp()->get_upgrade_link( [ 'medium' => 'dashboard-widget', 'content' => 'upgrade-to-pro' ] ) )
|
||||
esc_url( wp_mail_smtp()->get_upgrade_link( [ 'medium' => 'dashboard-widget', 'content' => 'upgrade-to-pro' ] ) ) // phpcs:ignore WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
@@ -540,9 +420,7 @@ 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">
|
||||
<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>
|
||||
<span class="dashicons dashicons-admin-generic"></span>
|
||||
</button>
|
||||
<div class="wp-mail-smtp-dash-widget-settings-menu">
|
||||
<div class="wp-mail-smtp-dash-widget-settings-menu--style">
|
||||
@@ -702,12 +580,24 @@ class DashboardWidget {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $action === 'get' ) {
|
||||
return $this->get_widget_meta( $meta );
|
||||
$defaults = [
|
||||
'hide_graph' => 0,
|
||||
'hide_summary_report_email_block' => 0,
|
||||
];
|
||||
|
||||
if ( ! array_key_exists( $meta, $defaults ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$meta_key = $this->get_widget_meta_key( $meta );
|
||||
$value = sanitize_key( $value );
|
||||
$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 );
|
||||
|
||||
if ( 'set' === $action && ! empty( $value ) ) {
|
||||
return update_user_meta( get_current_user_id(), $meta_key, $value );
|
||||
@@ -719,48 +609,4 @@ 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,7 +2,6 @@
|
||||
|
||||
namespace WPMailSMTP\Admin\DebugEvents;
|
||||
|
||||
use WP_Error;
|
||||
use WPMailSMTP\Admin\Area;
|
||||
use WPMailSMTP\Options;
|
||||
use WPMailSMTP\Tasks\DebugEventsCleanupTask;
|
||||
@@ -15,15 +14,6 @@ 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.
|
||||
*
|
||||
@@ -258,51 +248,6 @@ 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.
|
||||
*
|
||||
@@ -414,8 +359,7 @@ class DebugEvents {
|
||||
|
||||
$table = self::get_table_name();
|
||||
|
||||
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||
$is_valid = (bool) $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s;', $table ) );
|
||||
$is_valid = (bool) $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s;', $table ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||
|
||||
return $is_valid;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace WPMailSMTP\Admin;
|
||||
|
||||
use WPMailSMTP\Helpers\Helpers;
|
||||
|
||||
/**
|
||||
* Class for interacting with the Domain Checker API.
|
||||
*
|
||||
@@ -55,12 +53,7 @@ class DomainChecker {
|
||||
'domain' => $sending_domain,
|
||||
];
|
||||
|
||||
$response = wp_remote_get(
|
||||
add_query_arg( $params, self::ENDPOINT ),
|
||||
[
|
||||
'user-agent' => Helpers::get_default_user_agent(),
|
||||
]
|
||||
);
|
||||
$response = wp_remote_get( add_query_arg( $params, self::ENDPOINT ) );
|
||||
|
||||
if ( is_wp_error( $response ) ) {
|
||||
$this->results = [
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace WPMailSMTP\Admin;
|
||||
|
||||
use WPMailSMTP\Helpers\Helpers;
|
||||
use WPMailSMTP\Options;
|
||||
use WPMailSMTP\Tasks\Tasks;
|
||||
use WPMailSMTP\WP;
|
||||
@@ -121,12 +120,7 @@ class Notifications {
|
||||
*/
|
||||
protected function fetch_feed() {
|
||||
|
||||
$response = wp_remote_get(
|
||||
self::SOURCE_URL,
|
||||
[
|
||||
'user-agent' => Helpers::get_default_user_agent(),
|
||||
]
|
||||
);
|
||||
$response = wp_remote_get( self::SOURCE_URL );
|
||||
|
||||
if ( is_wp_error( $response ) ) {
|
||||
return [];
|
||||
@@ -232,7 +226,6 @@ class Notifications {
|
||||
* Get notification data.
|
||||
*
|
||||
* @since 2.3.0
|
||||
* @since 3.9.0 Make the AS a recurring task.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -244,17 +237,16 @@ class Notifications {
|
||||
|
||||
$option = $this->get_option();
|
||||
|
||||
// Update notifications a recurring task.
|
||||
if ( Tasks::is_scheduled( 'wp_mail_smtp_admin_notifications_update' ) === false ) {
|
||||
// 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' ) ) ) {
|
||||
|
||||
wp_mail_smtp()->get_tasks()
|
||||
->create( 'wp_mail_smtp_admin_notifications_update' )
|
||||
->recurring(
|
||||
strtotime( '+1 minute' ),
|
||||
$this->get_notification_update_task_interval()
|
||||
)
|
||||
->params()
|
||||
->register();
|
||||
wp_mail_smtp()->get_tasks()
|
||||
->create( 'wp_mail_smtp_admin_notifications_update' )
|
||||
->async()
|
||||
->params()
|
||||
->register();
|
||||
}
|
||||
}
|
||||
|
||||
$events = ! empty( $option['events'] ) ? $this->verify_active( $option['events'] ) : [];
|
||||
@@ -263,25 +255,6 @@ 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.
|
||||
*
|
||||
|
||||
@@ -68,13 +68,13 @@ class AdditionalConnectionsTab extends PageAbstract {
|
||||
|
||||
wp_enqueue_style(
|
||||
'wp-mail-smtp-admin-lity',
|
||||
wp_mail_smtp()->assets_url . '/css/vendor/lity.min.css',
|
||||
wp_mail_smtp()->assets_url . '/libs/lity/lity.min.css',
|
||||
[],
|
||||
'2.4.1'
|
||||
);
|
||||
wp_enqueue_script(
|
||||
'wp-mail-smtp-admin-lity',
|
||||
wp_mail_smtp()->assets_url . '/js/vendor/lity.min.js',
|
||||
wp_mail_smtp()->assets_url . '/libs/lity/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 . '/css/vendor/lity.min.css',
|
||||
wp_mail_smtp()->assets_url . '/libs/lity/lity.min.css',
|
||||
[],
|
||||
'2.4.1'
|
||||
);
|
||||
wp_enqueue_script(
|
||||
'wp-mail-smtp-admin-lity',
|
||||
wp_mail_smtp()->assets_url . '/js/vendor/lity.min.js',
|
||||
wp_mail_smtp()->assets_url . '/libs/lity/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 . '/css/vendor/lity.min.css',
|
||||
wp_mail_smtp()->assets_url . '/libs/lity/lity.min.css',
|
||||
[],
|
||||
'2.4.1'
|
||||
);
|
||||
wp_enqueue_script(
|
||||
'wp-mail-smtp-admin-lity',
|
||||
wp_mail_smtp()->assets_url . '/js/vendor/lity.min.js',
|
||||
wp_mail_smtp()->assets_url . '/libs/lity/lity.min.js',
|
||||
[],
|
||||
'2.4.1',
|
||||
false
|
||||
|
||||
@@ -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__( '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__( '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__( '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 Mailgun 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 Private 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">Mailgun 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">Private API Key</a> is correct.', 'wp-mail-smtp' ),
|
||||
[
|
||||
'a' => [
|
||||
'href' => [],
|
||||
@@ -952,7 +952,7 @@ Co-Founder, WP Mail SMTP';
|
||||
],
|
||||
]
|
||||
),
|
||||
'https://app.mailgun.com/settings/api_security'
|
||||
'https://app.mailgun.com/app/account/security/api_keys'
|
||||
),
|
||||
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 Google Workspace, please <a href="%s" target="_blank" rel="noopener noreferrer">read this article</a> to proceed.', 'wp-mail-smtp' ),
|
||||
__( 'if you are using G Suite, 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 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' ),
|
||||
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' ),
|
||||
[
|
||||
'a' => [
|
||||
'href' => [],
|
||||
@@ -1137,8 +1137,8 @@ Co-Founder, WP Mail SMTP';
|
||||
'https://admin.google.com'
|
||||
),
|
||||
sprintf(
|
||||
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' ),
|
||||
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' ),
|
||||
[
|
||||
'a' => [
|
||||
'href' => [],
|
||||
@@ -1357,7 +1357,7 @@ Co-Founder, WP Mail SMTP';
|
||||
. '</ul>',
|
||||
],
|
||||
'steps' => [
|
||||
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' ),
|
||||
esc_html__( 'Triple check the plugin settings, consider reconfiguring to make sure everything is correct (eg bad copy and paste).', '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,7 +4,6 @@ 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;
|
||||
@@ -975,7 +974,6 @@ 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() {
|
||||
|
||||
@@ -984,7 +982,6 @@ 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',
|
||||
@@ -995,22 +992,12 @@ 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;
|
||||
} elseif ( in_array( $basename, $seo_toolkit_basenames, true ) ) {
|
||||
$seo_toolkit_plugin_already_installed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1022,7 +1009,6 @@ 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 );
|
||||
@@ -1046,12 +1032,6 @@ 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' ),
|
||||
@@ -1059,10 +1039,10 @@ class SetupWizard {
|
||||
'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' => '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' => 'rafflepress',
|
||||
@@ -1119,7 +1099,6 @@ class SetupWizard {
|
||||
wp_remote_post(
|
||||
'https://connect.wpmailsmtp.com/subscribe/drip/',
|
||||
[
|
||||
'user-agent' => Helpers::get_default_user_agent(),
|
||||
'body' => $body,
|
||||
]
|
||||
);
|
||||
@@ -1130,7 +1109,7 @@ class SetupWizard {
|
||||
/**
|
||||
* Get the WPForms version type if it's installed.
|
||||
*
|
||||
* @since 3.9.0
|
||||
* @since {VERSION}
|
||||
*
|
||||
* @return false|string Return `false` if WPForms is not installed, otherwise return either `lite` or `pro`.
|
||||
*/
|
||||
@@ -1258,7 +1237,6 @@ class SetupWizard {
|
||||
wp_remote_post(
|
||||
'https://wpmailsmtp.com/wizard-feedback/',
|
||||
[
|
||||
'user-agent' => Helpers::get_default_user_agent(),
|
||||
'body' => [
|
||||
'wpforms' => [
|
||||
'id' => 87892,
|
||||
|
||||
Reference in New Issue
Block a user