Merged in feature/from-pantheon (pull request #16)
code from pantheon * code from pantheon
This commit is contained in:
164
wp/wp-content/plugins/wp-mail-smtp/src/Admin/AdminBarMenu.php
Normal file
164
wp/wp-content/plugins/wp-mail-smtp/src/Admin/AdminBarMenu.php
Normal file
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin;
|
||||
|
||||
use WPMailSMTP\Debug;
|
||||
use WPMailSMTP\Options;
|
||||
|
||||
/**
|
||||
* WP Mail SMTP admin bar menu.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
class AdminBarMenu {
|
||||
|
||||
/**
|
||||
* Initialize class.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public function init() {
|
||||
|
||||
$this->hooks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register hooks.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public function hooks() {
|
||||
|
||||
add_action( 'wp_enqueue_scripts', [ $this, 'enqueues' ] );
|
||||
add_action( 'admin_enqueue_scripts', [ $this, 'enqueues' ] );
|
||||
add_action( 'admin_bar_menu', [ $this, 'register' ], 999 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if current user has access to see admin bar menu.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has_access() {
|
||||
|
||||
$access = false;
|
||||
|
||||
if (
|
||||
is_user_logged_in() &&
|
||||
current_user_can( wp_mail_smtp()->get_capability_manage_options() )
|
||||
) {
|
||||
$access = true;
|
||||
}
|
||||
|
||||
return apply_filters( 'wp_mail_smtp_admin_adminbarmenu_has_access', $access );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if new notifications are available.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has_notifications() {
|
||||
|
||||
return wp_mail_smtp()->get_notifications()->get_count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue styles.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public function enqueues() {
|
||||
|
||||
if ( ! is_admin_bar_showing() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! $this->has_access() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
wp_enqueue_style(
|
||||
'wp-mail-smtp-admin-bar',
|
||||
wp_mail_smtp()->assets_url . '/css/admin-bar.min.css',
|
||||
[],
|
||||
WPMS_PLUGIN_VER
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register and render admin menu bar.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*
|
||||
* @param \WP_Admin_Bar $wp_admin_bar WordPress Admin Bar object.
|
||||
*/
|
||||
public function register( \WP_Admin_Bar $wp_admin_bar ) {
|
||||
|
||||
if (
|
||||
! $this->has_access() ||
|
||||
(
|
||||
(
|
||||
empty( Debug::get_last() ) ||
|
||||
(bool) Options::init()->get( 'general', 'email_delivery_errors_hidden' )
|
||||
) &&
|
||||
empty( $this->has_notifications() )
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
$items = apply_filters(
|
||||
'wp_mail_smtp_admin_adminbarmenu_register',
|
||||
[
|
||||
'main_menu',
|
||||
],
|
||||
$wp_admin_bar
|
||||
);
|
||||
|
||||
foreach ( $items as $item ) {
|
||||
$this->{ $item }( $wp_admin_bar );
|
||||
|
||||
do_action( "wp_mail_smtp_admin_adminbarmenu_register_{$item}_after", $wp_admin_bar );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render primary top-level admin menu bar item.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*
|
||||
* @param \WP_Admin_Bar $wp_admin_bar WordPress Admin Bar object.
|
||||
*/
|
||||
public function main_menu( \WP_Admin_Bar $wp_admin_bar ) {
|
||||
|
||||
if (
|
||||
! empty( Debug::get_last() ) &&
|
||||
! (bool) Options::init()->get( 'general', 'email_delivery_errors_hidden' )
|
||||
) {
|
||||
$indicator = ' <span class="wp-mail-smtp-admin-bar-menu-error">!</span>';
|
||||
} elseif ( ! empty( $this->has_notifications() ) ) {
|
||||
$count = $this->has_notifications() < 10 ? $this->has_notifications() : '!';
|
||||
$indicator = ' <div class="wp-mail-smtp-admin-bar-menu-notification-counter"><span>' . $count . '</span></div>';
|
||||
}
|
||||
|
||||
if ( ! isset( $indicator ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$wp_admin_bar->add_menu(
|
||||
[
|
||||
'id' => 'wp-mail-smtp-menu',
|
||||
'title' => 'WP Mail SMTP' . $indicator,
|
||||
'href' => apply_filters(
|
||||
'wp_mail_smtp_admin_adminbarmenu_main_menu_href',
|
||||
wp_mail_smtp()->get_admin()->get_admin_page_url()
|
||||
),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
1547
wp/wp-content/plugins/wp-mail-smtp/src/Admin/Area.php
Normal file
1547
wp/wp-content/plugins/wp-mail-smtp/src/Admin/Area.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,437 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin;
|
||||
|
||||
use WPMailSMTP\ConnectionInterface;
|
||||
use WPMailSMTP\Debug;
|
||||
use WPMailSMTP\Helpers\UI;
|
||||
use WPMailSMTP\Options;
|
||||
|
||||
/**
|
||||
* Class ConnectionSettings.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
class ConnectionSettings {
|
||||
|
||||
/**
|
||||
* The Connection object.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*
|
||||
* @var ConnectionInterface
|
||||
*/
|
||||
private $connection;
|
||||
|
||||
/**
|
||||
* After process scroll to anchor.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*
|
||||
* @var false|string
|
||||
*/
|
||||
private $scroll_to = false;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*
|
||||
* @param ConnectionInterface $connection The Connection object.
|
||||
*/
|
||||
public function __construct( $connection ) {
|
||||
|
||||
$this->connection = $connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display connection settings.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
public function display() { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.MaxExceeded, Generic.Metrics.NestingLevel.MaxExceeded
|
||||
|
||||
$mailer = $this->connection->get_mailer_slug();
|
||||
$connection_options = $this->connection->get_options();
|
||||
|
||||
$disabled_email = in_array( $mailer, [ 'zoho' ], true ) ? 'disabled' : '';
|
||||
$disabled_name = in_array( $mailer, [ 'outlook' ], true ) ? 'disabled' : '';
|
||||
|
||||
if ( empty( $mailer ) || ! in_array( $mailer, Options::$mailers, true ) ) {
|
||||
$mailer = 'mail';
|
||||
}
|
||||
|
||||
$mailer_supported_settings = wp_mail_smtp()->get_providers()->get_options( $mailer )->get_supports();
|
||||
?>
|
||||
<!-- From Email -->
|
||||
<div class="wp-mail-smtp-setting-group js-wp-mail-smtp-setting-from_email" style="display: <?php echo empty( $mailer_supported_settings['from_email'] ) ? 'none' : 'block'; ?>;">
|
||||
<div id="wp-mail-smtp-setting-row-from_email" class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-email wp-mail-smtp-clear">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label for="wp-mail-smtp-setting-from_email"><?php esc_html_e( 'From Email', 'wp-mail-smtp' ); ?></label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<input name="wp-mail-smtp[mail][from_email]" type="email"
|
||||
value="<?php echo esc_attr( $connection_options->get( 'mail', 'from_email' ) ); ?>"
|
||||
id="wp-mail-smtp-setting-from_email" spellcheck="false"
|
||||
placeholder="<?php echo esc_attr( wp_mail_smtp()->get_processor()->get_default_email() ); ?>"
|
||||
<?php disabled( $connection_options->is_const_defined( 'mail', 'from_email' ) || ! empty( $disabled_email ) ); ?>
|
||||
/>
|
||||
|
||||
<?php if ( ! in_array( $mailer, [ 'zoho' ], true ) ) : ?>
|
||||
<p class="desc">
|
||||
<?php esc_html_e( 'The email address that emails are sent from.', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
<p class="desc">
|
||||
<?php esc_html_e( 'If you\'re using an email provider (Yahoo, Outlook.com, etc) this should be your email address for that account.', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
<p class="desc">
|
||||
<?php esc_html_e( 'Please note that other plugins can change this, to prevent this use the setting below.', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div id="wp-mail-smtp-setting-row-from_email_force" class="wp-mail-smtp-setting-row wp-mail-smtp-clear js-wp-mail-smtp-setting-from_email_force" style="display: <?php echo empty( $mailer_supported_settings['from_email_force'] ) ? 'none' : 'block'; ?>;">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label for="wp-mail-smtp-setting-from_email_force"><?php esc_html_e( 'Force From Email', 'wp-mail-smtp' ); ?></label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<?php
|
||||
UI::toggle(
|
||||
[
|
||||
'name' => 'wp-mail-smtp[mail][from_email_force]',
|
||||
'id' => 'wp-mail-smtp-setting-from_email_force',
|
||||
'value' => 'true',
|
||||
'checked' => (bool) $connection_options->get( 'mail', 'from_email_force' ),
|
||||
'disabled' => $connection_options->is_const_defined( 'mail', 'from_email_force' ) || ! empty( $disabled_email ),
|
||||
]
|
||||
);
|
||||
?>
|
||||
|
||||
<?php if ( ! empty( $disabled_email ) ) : ?>
|
||||
<p class="desc">
|
||||
<?php esc_html_e( 'Current provider will automatically force From Email to be the email address that you use to set up the OAuth connection below.', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
<?php else : ?>
|
||||
<p class="desc">
|
||||
<?php esc_html_e( 'If checked, the From Email setting above will be used for all emails, ignoring values set by other plugins.', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- From Name -->
|
||||
<div class="wp-mail-smtp-setting-group js-wp-mail-smtp-setting-from_name" style="display: <?php echo empty( $mailer_supported_settings['from_name'] ) ? 'none' : 'block'; ?>;">
|
||||
<div id="wp-mail-smtp-setting-row-from_name" 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-from_name"><?php esc_html_e( 'From Name', 'wp-mail-smtp' ); ?></label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<input name="wp-mail-smtp[mail][from_name]" type="text"
|
||||
value="<?php echo esc_attr( $connection_options->get( 'mail', 'from_name' ) ); ?>"
|
||||
id="wp-mail-smtp-setting-from_name" spellcheck="false"
|
||||
placeholder="<?php echo esc_attr( wp_mail_smtp()->get_processor()->get_default_name() ); ?>"
|
||||
<?php disabled( $connection_options->is_const_defined( 'mail', 'from_name' ) || ! empty( $disabled_name ) ); ?>
|
||||
/>
|
||||
|
||||
<?php if ( empty( $disabled_name ) ) : ?>
|
||||
<p class="desc">
|
||||
<?php esc_html_e( 'The name that emails are sent from.', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div id="wp-mail-smtp-setting-row-from_name_force" class="wp-mail-smtp-setting-row wp-mail-smtp-clear js-wp-mail-smtp-setting-from_name_force" style="display: <?php echo empty( $mailer_supported_settings['from_name_force'] ) ? 'none' : 'block'; ?>;">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label for="wp-mail-smtp-setting-from_name_force"><?php esc_html_e( 'Force From Name', 'wp-mail-smtp' ); ?></label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<?php
|
||||
UI::toggle(
|
||||
[
|
||||
'name' => 'wp-mail-smtp[mail][from_name_force]',
|
||||
'id' => 'wp-mail-smtp-setting-from_name_force',
|
||||
'value' => 'true',
|
||||
'checked' => (bool) $connection_options->get( 'mail', 'from_name_force' ),
|
||||
'disabled' => $connection_options->is_const_defined( 'mail', 'from_name_force' ) || ! empty( $disabled_name ),
|
||||
]
|
||||
);
|
||||
?>
|
||||
|
||||
<?php if ( ! empty( $disabled_name ) ) : ?>
|
||||
<p class="desc">
|
||||
<?php esc_html_e( 'Current provider doesn\'t support setting and forcing From Name. Emails will be sent on behalf of the account name used to setup the OAuth connection below.', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
<?php else : ?>
|
||||
<p class="desc">
|
||||
<?php esc_html_e( 'If checked, the From Name setting above will be used for all emails, ignoring values set by other plugins.', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Return Path -->
|
||||
<div id="wp-mail-smtp-setting-row-return_path" class="wp-mail-smtp-setting-row wp-mail-smtp-clear js-wp-mail-smtp-setting-return_path" style="display: <?php echo empty( $mailer_supported_settings['return_path'] ) ? 'none' : 'block'; ?>;">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label for="wp-mail-smtp-setting-return_path"><?php esc_html_e( 'Return Path', 'wp-mail-smtp' ); ?></label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<?php
|
||||
UI::toggle(
|
||||
[
|
||||
'name' => 'wp-mail-smtp[mail][return_path]',
|
||||
'id' => 'wp-mail-smtp-setting-return_path',
|
||||
'value' => 'true',
|
||||
'checked' => (bool) $connection_options->get( 'mail', 'return_path' ),
|
||||
'disabled' => $connection_options->is_const_defined( 'mail', 'return_path' ),
|
||||
]
|
||||
);
|
||||
?>
|
||||
|
||||
<p class="desc">
|
||||
<?php esc_html_e( 'Return Path indicates where non-delivery receipts - or bounce messages - are to be sent.', 'wp-mail-smtp' ); ?><br/>
|
||||
<?php esc_html_e( 'If unchecked, bounce messages may be lost.', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Mailer -->
|
||||
<div id="wp-mail-smtp-setting-row-mailer" class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-mailer wp-mail-smtp-clear">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label for="wp-mail-smtp-setting-mailer"><?php esc_html_e( 'Mailer', 'wp-mail-smtp' ); ?></label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<div class="wp-mail-smtp-mailers">
|
||||
|
||||
<?php foreach ( wp_mail_smtp()->get_providers()->get_options_all( $this->connection ) as $provider ) : ?>
|
||||
|
||||
<div class="wp-mail-smtp-mailer wp-mail-smtp-mailer-<?php echo esc_attr( $provider->get_slug() ); ?> <?php echo $mailer === $provider->get_slug() ? 'active' : ''; ?>">
|
||||
|
||||
<div class="wp-mail-smtp-mailer-image <?php echo $provider->is_recommended() ? 'is-recommended' : ''; ?>">
|
||||
<img src="<?php echo esc_url( $provider->get_logo_url() ); ?>"
|
||||
alt="<?php echo esc_attr( $provider->get_title() ); ?>">
|
||||
</div>
|
||||
|
||||
<div class="wp-mail-smtp-mailer-text">
|
||||
<?php if ( $provider->is_disabled() ) : ?>
|
||||
<input type="radio" name="wp-mail-smtp[mail][mailer]" disabled
|
||||
data-title="<?php echo esc_attr( $provider->get_title() ); ?>"
|
||||
class="js-wp-mail-smtp-setting-mailer-radio-input educate"
|
||||
id="wp-mail-smtp-setting-mailer-<?php echo esc_attr( $provider->get_slug() ); ?>"
|
||||
value="<?php echo esc_attr( $provider->get_slug() ); ?>"
|
||||
/>
|
||||
<?php else : ?>
|
||||
<input id="wp-mail-smtp-setting-mailer-<?php echo esc_attr( $provider->get_slug() ); ?>"
|
||||
data-title="<?php echo esc_attr( $provider->get_title() ); ?>"
|
||||
type="radio" name="wp-mail-smtp[mail][mailer]"
|
||||
value="<?php echo esc_attr( $provider->get_slug() ); ?>"
|
||||
class="js-wp-mail-smtp-setting-mailer-radio-input<?php echo $provider->is_disabled() ? ' educate' : ''; ?>"
|
||||
<?php checked( $provider->get_slug(), $mailer ); ?>
|
||||
<?php disabled( $connection_options->is_const_defined( 'mail', 'mailer' ) || $provider->is_disabled() ); ?>
|
||||
/>
|
||||
<?php endif; ?>
|
||||
<label for="wp-mail-smtp-setting-mailer-<?php echo esc_attr( $provider->get_slug() ); ?>">
|
||||
<?php echo esc_html( $provider->get_title() ); ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<!-- Suggest a mailer -->
|
||||
<div class="wp-mail-smtp-suggest-new-mailer">
|
||||
<p class="desc">
|
||||
<?php esc_html_e( 'Don\'t see what you\'re looking for?', 'wp-mail-smtp' ); ?>
|
||||
<?php
|
||||
printf(
|
||||
'<a href="%1$s" target="_blank" rel="noopener noreferrer">%2$s</a>',
|
||||
esc_url( wp_mail_smtp()->get_utm_url( 'https://wpmailsmtp.com/suggest-a-mailer/', 'Suggest a Mailer' ) ),
|
||||
esc_html__( 'Suggest a Mailer', 'wp-mail-smtp' )
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Mailer Options -->
|
||||
<div class="wp-mail-smtp-setting-group wp-mail-smtp-mailer-options">
|
||||
<?php foreach ( wp_mail_smtp()->get_providers()->get_options_all( $this->connection ) as $provider ) : ?>
|
||||
<?php $provider_desc = $provider->get_description(); ?>
|
||||
<div class="wp-mail-smtp-mailer-option wp-mail-smtp-mailer-option-<?php echo esc_attr( $provider->get_slug() ); ?> <?php echo $mailer === $provider->get_slug() ? 'active' : 'hidden'; ?>">
|
||||
|
||||
<?php if ( ! $provider->is_disabled() ) : ?>
|
||||
<!-- Mailer Title/Notice/Description -->
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-content wp-mail-smtp-clear section-heading <?php echo empty( $provider_desc ) ? 'no-desc' : ''; ?>">
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<h2><?php echo esc_html( $provider->get_title() ); ?></h2>
|
||||
<?php
|
||||
$provider_edu_notice = $provider->get_notice( 'educational' );
|
||||
$is_dismissed = (bool) get_user_meta( get_current_user_id(), "wp_mail_smtp_notice_educational_for_{$provider->get_slug()}_dismissed", true );
|
||||
|
||||
if ( ! empty( $provider_edu_notice ) && ! $is_dismissed ) :
|
||||
?>
|
||||
<p class="inline-notice inline-edu-notice"
|
||||
data-notice="educational"
|
||||
data-mailer="<?php echo esc_attr( $provider->get_slug() ); ?>">
|
||||
<a href="#" title="<?php esc_attr_e( 'Dismiss this notice', 'wp-mail-smtp' ); ?>"
|
||||
class="wp-mail-smtp-mailer-notice-dismiss js-wp-mail-smtp-mailer-notice-dismiss">
|
||||
<span class="dashicons dashicons-dismiss"></span>
|
||||
</a>
|
||||
|
||||
<?php echo wp_kses_post( $provider_edu_notice ); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( ! empty( $provider_desc ) ) : ?>
|
||||
<p class="desc"><?php echo wp_kses_post( $provider_desc ); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php $provider->display_options(); ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Process connection settings. Should be called before options save.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*
|
||||
* @param array $data Connection data.
|
||||
* @param array $old_data Old connection data.
|
||||
*/
|
||||
public function process( $data, $old_data ) { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.MaxExceeded, Generic.Metrics.CyclomaticComplexity.TooHigh
|
||||
|
||||
// When checkbox is unchecked - it's not submitted at all, so we need to define its default false value.
|
||||
if ( ! isset( $data['mail']['from_email_force'] ) ) {
|
||||
$data['mail']['from_email_force'] = false;
|
||||
}
|
||||
if ( ! isset( $data['mail']['from_name_force'] ) ) {
|
||||
$data['mail']['from_name_force'] = false;
|
||||
}
|
||||
if ( ! isset( $data['mail']['return_path'] ) ) {
|
||||
$data['mail']['return_path'] = false;
|
||||
}
|
||||
if ( ! isset( $data['smtp']['autotls'] ) ) {
|
||||
$data['smtp']['autotls'] = false;
|
||||
}
|
||||
if ( ! isset( $data['smtp']['auth'] ) ) {
|
||||
$data['smtp']['auth'] = false;
|
||||
}
|
||||
|
||||
// When switching mailers.
|
||||
if (
|
||||
! empty( $old_data['mail']['mailer'] ) &&
|
||||
! empty( $data['mail']['mailer'] ) &&
|
||||
$old_data['mail']['mailer'] !== $data['mail']['mailer']
|
||||
) {
|
||||
// Remove all debug messages when switching mailers.
|
||||
Debug::clear();
|
||||
|
||||
// Save correct from email address if Zoho mailer is already configured.
|
||||
if (
|
||||
in_array( $data['mail']['mailer'], [ 'zoho' ], true ) &&
|
||||
! empty( $old_data[ $data['mail']['mailer'] ]['user_details']['email'] )
|
||||
) {
|
||||
$data['mail']['from_email'] = $old_data[ $data['mail']['mailer'] ]['user_details']['email'];
|
||||
}
|
||||
}
|
||||
|
||||
// Prevent redirect to setup wizard from settings page after successful auth.
|
||||
if (
|
||||
! empty( $data['mail']['mailer'] ) &&
|
||||
in_array( $data['mail']['mailer'], [ 'gmail', 'outlook', 'zoho' ], true )
|
||||
) {
|
||||
$data[ $data['mail']['mailer'] ]['is_setup_wizard_auth'] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters connection data.
|
||||
*
|
||||
* @since 3.11.0
|
||||
*
|
||||
* @param array $data Connection data.
|
||||
* @param array $old_data Old connection data.
|
||||
*/
|
||||
return apply_filters( 'wp_mail_smtp_admin_connection_settings_process_data', $data, $old_data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Post process connection settings. Should be called after options save.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*
|
||||
* @param array $data Connection data.
|
||||
* @param array $old_data Old connection data.
|
||||
*/
|
||||
public function post_process( $data, $old_data ) {
|
||||
|
||||
// When switching mailers.
|
||||
if (
|
||||
! empty( $old_data['mail']['mailer'] ) &&
|
||||
! empty( $data['mail']['mailer'] ) &&
|
||||
$old_data['mail']['mailer'] !== $data['mail']['mailer']
|
||||
) {
|
||||
|
||||
// Save correct from email address if Gmail mailer is already configured.
|
||||
if ( $data['mail']['mailer'] === 'gmail' ) {
|
||||
$gmail_auth = wp_mail_smtp()->get_providers()->get_auth( 'gmail', $this->connection );
|
||||
$user_info = ! $gmail_auth->is_auth_required() ? $gmail_auth->get_user_info() : false;
|
||||
|
||||
if (
|
||||
! empty( $user_info['email'] ) &&
|
||||
is_email( $user_info['email'] ) !== false &&
|
||||
(
|
||||
empty( $data['mail']['from_email'] ) ||
|
||||
$data['mail']['from_email'] !== $user_info['email']
|
||||
)
|
||||
) {
|
||||
$data['mail']['from_email'] = $user_info['email'];
|
||||
|
||||
$this->connection->get_options()->set( $data, false, false );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get connection settings admin page URL.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_admin_page_url() {
|
||||
|
||||
/**
|
||||
* Filters connection settings admin page URL.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*
|
||||
* @param string $admin_page_url Connection settings admin page URL.
|
||||
* @param ConnectionInterface $connection The Connection object.
|
||||
*/
|
||||
return apply_filters(
|
||||
'wp_mail_smtp_admin_connection_settings_get_admin_page_url',
|
||||
wp_mail_smtp()->get_admin()->get_admin_page_url(),
|
||||
$this->connection
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get after process scroll to anchor. Returns `false` if scroll is not needed.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
public function get_scroll_to() {
|
||||
|
||||
return $this->scroll_to;
|
||||
}
|
||||
}
|
||||
759
wp/wp-content/plugins/wp-mail-smtp/src/Admin/DashboardWidget.php
Normal file
759
wp/wp-content/plugins/wp-mail-smtp/src/Admin/DashboardWidget.php
Normal file
@@ -0,0 +1,759 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin;
|
||||
|
||||
use WPMailSMTP\Admin\DebugEvents\DebugEvents;
|
||||
use WPMailSMTP\Helpers\Helpers;
|
||||
use WPMailSMTP\Options;
|
||||
use WPMailSMTP\WP;
|
||||
use WPMailSMTP\Reports\Reports;
|
||||
use WPMailSMTP\Reports\Emails\Summary as SummaryReportEmail;
|
||||
|
||||
/**
|
||||
* Dashboard Widget shows the number of sent emails in WP Dashboard.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*/
|
||||
class DashboardWidget {
|
||||
|
||||
/**
|
||||
* Instance slug.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @const string
|
||||
*/
|
||||
const SLUG = 'dash_widget_lite';
|
||||
|
||||
/**
|
||||
* The WP option key for storing the total number of sent emails.
|
||||
*
|
||||
* @since 2.9.0
|
||||
* @since 3.0.0 Constant moved to Reports class.
|
||||
*
|
||||
* @const string
|
||||
*/
|
||||
const SENT_EMAILS_COUNTER_OPTION_KEY = Reports::SENT_EMAILS_COUNTER_OPTION_KEY;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
// Prevent the class initialization, if the dashboard widget hidden setting is enabled.
|
||||
if ( Options::init()->get( 'general', 'dashboard_widget_hidden' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
add_action( 'admin_init', [ $this, 'init' ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Init class.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*/
|
||||
public function init() {
|
||||
|
||||
// This widget should be displayed for certain high-level users only.
|
||||
if ( ! current_user_can( wp_mail_smtp()->get_capability_manage_options() ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters whether the initialization of the dashboard widget should be allowed.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param bool $var If the dashboard widget should be initialized.
|
||||
*/
|
||||
if ( ! apply_filters( 'wp_mail_smtp_admin_dashboard_widget', '__return_true' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->hooks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Widget hooks.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*/
|
||||
public function hooks() {
|
||||
|
||||
add_action( 'admin_enqueue_scripts', [ $this, 'widget_scripts' ] );
|
||||
add_action( 'wp_dashboard_setup', [ $this, 'widget_register' ] );
|
||||
|
||||
add_action( 'wp_ajax_wp_mail_smtp_' . static::SLUG . '_save_widget_meta', [ $this, 'save_widget_meta_ajax' ] );
|
||||
add_action(
|
||||
'wp_ajax_wp_mail_smtp_' . static::SLUG . '_enable_summary_report_email',
|
||||
[
|
||||
$this,
|
||||
'enable_summary_report_email_ajax',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load widget-specific scripts.
|
||||
* Load them only on the admin dashboard page.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*/
|
||||
public function widget_scripts() {
|
||||
|
||||
$screen = get_current_screen();
|
||||
|
||||
if ( ! isset( $screen->id ) || 'dashboard' !== $screen->id ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$min = WP::asset_min();
|
||||
|
||||
wp_enqueue_style(
|
||||
'wp-mail-smtp-dashboard-widget',
|
||||
wp_mail_smtp()->assets_url . '/css/dashboard-widget.min.css',
|
||||
[],
|
||||
WPMS_PLUGIN_VER
|
||||
);
|
||||
|
||||
wp_enqueue_script(
|
||||
'wp-mail-smtp-chart',
|
||||
wp_mail_smtp()->assets_url . '/js/vendor/chart.min.js',
|
||||
[ 'moment' ],
|
||||
'2.9.4.1',
|
||||
true
|
||||
);
|
||||
|
||||
wp_enqueue_script(
|
||||
'wp-mail-smtp-dashboard-widget',
|
||||
wp_mail_smtp()->assets_url . "/js/smtp-dashboard-widget{$min}.js",
|
||||
[ 'jquery', 'wp-mail-smtp-chart' ],
|
||||
WPMS_PLUGIN_VER,
|
||||
true
|
||||
);
|
||||
|
||||
wp_localize_script(
|
||||
'wp-mail-smtp-dashboard-widget',
|
||||
'wp_mail_smtp_dashboard_widget',
|
||||
[
|
||||
'slug' => static::SLUG,
|
||||
'nonce' => wp_create_nonce( 'wp_mail_smtp_' . static::SLUG . '_nonce' ),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the widget.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*/
|
||||
public function widget_register() {
|
||||
|
||||
global $wp_meta_boxes;
|
||||
|
||||
$widget_key = 'wp_mail_smtp_reports_widget_lite';
|
||||
|
||||
wp_add_dashboard_widget(
|
||||
$widget_key,
|
||||
esc_html__( 'WP Mail SMTP', 'wp-mail-smtp' ),
|
||||
[ $this, 'widget_content' ]
|
||||
);
|
||||
|
||||
// Attempt to place the widget at the top.
|
||||
$normal_dashboard = $wp_meta_boxes['dashboard']['normal']['core'];
|
||||
$widget_instance = [ $widget_key => $normal_dashboard[ $widget_key ] ];
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a widget meta for a current user using AJAX.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*/
|
||||
public function save_widget_meta_ajax() {
|
||||
|
||||
check_admin_referer( 'wp_mail_smtp_' . static::SLUG . '_nonce' );
|
||||
|
||||
if ( ! current_user_can( wp_mail_smtp()->get_capability_manage_options() ) ) {
|
||||
wp_send_json_error();
|
||||
}
|
||||
|
||||
$meta = ! empty( $_POST['meta'] ) ? sanitize_key( $_POST['meta'] ) : '';
|
||||
$value = ! empty( $_POST['value'] ) ? sanitize_key( $_POST['value'] ) : 0;
|
||||
|
||||
$this->widget_meta( 'set', $meta, $value );
|
||||
|
||||
wp_send_json_success();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable summary report email using AJAX.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function enable_summary_report_email_ajax() {
|
||||
|
||||
check_admin_referer( 'wp_mail_smtp_' . static::SLUG . '_nonce' );
|
||||
|
||||
if ( ! current_user_can( wp_mail_smtp()->get_capability_manage_options() ) ) {
|
||||
wp_send_json_error();
|
||||
}
|
||||
|
||||
$options = Options::init();
|
||||
|
||||
$data = [
|
||||
'general' => [
|
||||
SummaryReportEmail::SETTINGS_SLUG => false,
|
||||
],
|
||||
];
|
||||
|
||||
$options->set( $data, false, false );
|
||||
|
||||
wp_send_json_success();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load widget content.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*/
|
||||
public function widget_content() {
|
||||
|
||||
echo '<div class="wp-mail-smtp-dash-widget wp-mail-smtp-dash-widget--lite">';
|
||||
|
||||
$this->widget_content_html();
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the number of total emails sent by 1.
|
||||
*
|
||||
* @deprecated 3.0.0
|
||||
*
|
||||
* @since 2.9.0
|
||||
*/
|
||||
public function increment_sent_email_counter() {
|
||||
|
||||
_deprecated_function( __METHOD__, '3.0.0' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Widget content HTML.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*/
|
||||
private function widget_content_html() {
|
||||
|
||||
$hide_graph = (bool) $this->widget_meta( 'get', 'hide_graph' );
|
||||
?>
|
||||
|
||||
<?php if ( ! $hide_graph ) : ?>
|
||||
<div class="wp-mail-smtp-dash-widget-chart-block-container">
|
||||
<div class="wp-mail-smtp-dash-widget-block wp-mail-smtp-dash-widget-chart-block">
|
||||
<canvas id="wp-mail-smtp-dash-widget-chart" width="554" height="291"></canvas>
|
||||
<div class="wp-mail-smtp-dash-widget-chart-upgrade">
|
||||
<div class="wp-mail-smtp-dash-widget-modal">
|
||||
<a href="#" class="wp-mail-smtp-dash-widget-dismiss-chart-upgrade">
|
||||
<span class="dashicons dashicons-no-alt"></span>
|
||||
</a>
|
||||
<h2><?php esc_html_e( 'View Detailed Email Stats', 'wp-mail-smtp' ); ?></h2>
|
||||
<p><?php esc_html_e( 'Automatically keep track of every email sent from your WordPress site and view valuable statistics right here in your dashboard.', 'wp-mail-smtp' ); ?></p>
|
||||
<p>
|
||||
<a href="<?php echo esc_url( wp_mail_smtp()->get_upgrade_link( [ 'medium' => 'dashboard-widget', 'content' => 'upgrade-to-wp-mail-smtp-pro' ] ) ); // phpcs:ignore WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound ?>" target="_blank" rel="noopener noreferrer" class="button button-primary button-hero">
|
||||
<?php esc_html_e( 'Upgrade to WP Mail SMTP Pro', 'wp-mail-smtp' ); ?>
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-dash-widget-overlay"></div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="wp-mail-smtp-dash-widget-block wp-mail-smtp-dash-widget-block-settings">
|
||||
<div>
|
||||
<?php $this->email_types_select_html(); ?>
|
||||
</div>
|
||||
<div>
|
||||
<?php
|
||||
$this->timespan_select_html();
|
||||
$this->widget_settings_html();
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wp-mail-smtp-dash-widget-email-stats-block" class="wp-mail-smtp-dash-widget-block wp-mail-smtp-dash-widget-email-stats-block">
|
||||
<?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
|
||||
$error_title = sprintf(
|
||||
/* translators: %d - number of failed emails. */
|
||||
_n(
|
||||
'We detected %d failed email in the last 30 days.',
|
||||
'We detected %d failed emails in the last 30 days.',
|
||||
$error_count,
|
||||
'wp-mail-smtp'
|
||||
),
|
||||
$error_count
|
||||
);
|
||||
|
||||
$error_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(
|
||||
$error_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>
|
||||
</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
|
||||
printf(
|
||||
wp_kses( /* translators: %s - URL to WPMailSMTP.com. */
|
||||
__( '<a href="%s" target="_blank" rel="noopener noreferrer">Upgrade to Pro</a> for detailed stats, email logs, and more!', 'wp-mail-smtp' ),
|
||||
[
|
||||
'a' => [
|
||||
'href' => [],
|
||||
'rel' => [],
|
||||
'target' => [],
|
||||
],
|
||||
]
|
||||
),
|
||||
// phpcs:ignore WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
|
||||
esc_url( wp_mail_smtp()->get_upgrade_link( [ 'medium' => 'dashboard-widget', 'content' => 'upgrade-to-pro' ] ) )
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Timespan select HTML.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*/
|
||||
private function timespan_select_html() {
|
||||
|
||||
?>
|
||||
<select id="wp-mail-smtp-dash-widget-timespan" class="wp-mail-smtp-dash-widget-select-timespan" title="<?php esc_attr_e( 'Select timespan', 'wp-mail-smtp' ); ?>">
|
||||
<option value="all">
|
||||
<?php esc_html_e( 'All Time', 'wp-mail-smtp' ); ?>
|
||||
</option>
|
||||
<?php foreach ( [ 7, 14, 30 ] as $option ) : ?>
|
||||
<option value="<?php echo absint( $option ); ?>" disabled>
|
||||
<?php /* translators: %d - Number of days. */ ?>
|
||||
<?php echo esc_html( sprintf( _n( 'Last %d day', 'Last %d days', absint( $option ), 'wp-mail-smtp' ), absint( $option ) ) ); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Email types select HTML.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*/
|
||||
private function email_types_select_html() {
|
||||
|
||||
$options = [
|
||||
'delivered' => esc_html__( 'Confirmed Emails', 'wp-mail-smtp' ),
|
||||
'sent' => esc_html__( 'Unconfirmed Emails', 'wp-mail-smtp' ),
|
||||
'unsent' => esc_html__( 'Failed Emails', 'wp-mail-smtp' ),
|
||||
];
|
||||
|
||||
if ( Helpers::mailer_without_send_confirmation() ) {
|
||||
unset( $options['sent'] );
|
||||
$options['delivered'] = esc_html__( 'Sent Emails', 'wp-mail-smtp' );
|
||||
}
|
||||
|
||||
?>
|
||||
<select id="wp-mail-smtp-dash-widget-email-type" class="wp-mail-smtp-dash-widget-select-email-type" title="<?php esc_attr_e( 'Select email type', 'wp-mail-smtp' ); ?>">
|
||||
<option value="all">
|
||||
<?php esc_html_e( 'All Emails', 'wp-mail-smtp' ); ?>
|
||||
</option>
|
||||
<?php foreach ( $options as $key => $title ) : ?>
|
||||
<option value="<?php echo sanitize_key( $key ); ?>" disabled>
|
||||
<?php echo esc_html( $title ); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Widget settings HTML.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*/
|
||||
private function widget_settings_html() {
|
||||
|
||||
?>
|
||||
<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>
|
||||
</button>
|
||||
<div class="wp-mail-smtp-dash-widget-settings-menu">
|
||||
<div class="wp-mail-smtp-dash-widget-settings-menu--style">
|
||||
<h4><?php esc_html_e( 'Graph Style', 'wp-mail-smtp' ); ?></h4>
|
||||
<div>
|
||||
<div class="wp-mail-smtp-dash-widget-settings-menu-item">
|
||||
<input type="radio" id="wp-mail-smtp-dash-widget-settings-style-bar" name="style" value="bar" disabled>
|
||||
<label for="wp-mail-smtp-dash-widget-settings-style-bar"><?php esc_html_e( 'Bar', 'wp-mail-smtp' ); ?></label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-dash-widget-settings-menu-item">
|
||||
<input type="radio" id="wp-mail-smtp-dash-widget-settings-style-line" name="style" value="line" checked disabled>
|
||||
<label for="wp-mail-smtp-dash-widget-settings-style-line"><?php esc_html_e( 'Line', 'wp-mail-smtp' ); ?></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-dash-widget-settings-menu--color">
|
||||
<h4><?php esc_html_e( 'Color Scheme', 'wp-mail-smtp' ); ?></h4>
|
||||
<div>
|
||||
<div class="wp-mail-smtp-dash-widget-settings-menu-item">
|
||||
<input type="radio" id="wp-mail-smtp-dash-widget-settings-color-smtp" name="color" value="smtp" disabled>
|
||||
<label for="wp-mail-smtp-dash-widget-settings-color-smtp"><?php esc_html_e( 'WP Mail SMTP', 'wp-mail-smtp' ); ?></label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-dash-widget-settings-menu-item">
|
||||
<input type="radio" id="wp-mail-smtp-dash-widget-settings-color-wp" name="color" value="wp" checked disabled>
|
||||
<label for="wp-mail-smtp-dash-widget-settings-color-wp"><?php esc_html_e( 'WordPress', 'wp-mail-smtp' ); ?></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="button wp-mail-smtp-dash-widget-settings-menu-save" disabled><?php esc_html_e( 'Save Changes', 'wp-mail-smtp' ); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Email statistics block.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*/
|
||||
private function email_stats_block() {
|
||||
|
||||
$output_data = $this->get_email_stats_data();
|
||||
?>
|
||||
|
||||
<table id="wp-mail-smtp-dash-widget-email-stats-table" cellspacing="0">
|
||||
<tr>
|
||||
<?php
|
||||
$count = 0;
|
||||
$per_row = 2;
|
||||
|
||||
foreach ( array_values( $output_data ) as $stats ) :
|
||||
if ( ! is_array( $stats ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ! isset( $stats['icon'], $stats['title'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Make some exceptions for mailers without send confirmation functionality.
|
||||
if ( Helpers::mailer_without_send_confirmation() ) {
|
||||
$per_row = 3;
|
||||
}
|
||||
|
||||
// Create new row after every $per_row cells.
|
||||
if ( $count !== 0 && $count % $per_row === 0 ) {
|
||||
echo '</tr><tr>';
|
||||
}
|
||||
|
||||
$count++;
|
||||
?>
|
||||
<td class="wp-mail-smtp-dash-widget-email-stats-table-cell wp-mail-smtp-dash-widget-email-stats-table-cell--<?php echo esc_attr( $stats['type'] ); ?> wp-mail-smtp-dash-widget-email-stats-table-cell--3">
|
||||
<div class="wp-mail-smtp-dash-widget-email-stats-table-cell-container">
|
||||
<img src="<?php echo esc_url( $stats['icon'] ); ?>" alt="<?php esc_attr_e( 'Table cell icon', 'wp-mail-smtp' ); ?>">
|
||||
<span>
|
||||
<?php echo esc_html( $stats['title'] ); ?>
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the email stats data.
|
||||
* The text and counts of the email stats.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @return array[]
|
||||
*/
|
||||
private function get_email_stats_data() {
|
||||
|
||||
$reports = new Reports();
|
||||
$total_sent = $reports->get_total_emails_sent();
|
||||
|
||||
$output_data = [
|
||||
'all' => [
|
||||
'type' => 'all',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/dash-widget/wp/total.svg',
|
||||
/* translators: %d number of total emails sent. */
|
||||
'title' => esc_html( sprintf( esc_html__( '%d total', 'wp-mail-smtp' ), $total_sent ) ),
|
||||
],
|
||||
'delivered' => [
|
||||
'type' => 'delivered',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/dash-widget/wp/delivered.svg',
|
||||
/* translators: %s fixed string of 'N/A'. */
|
||||
'title' => esc_html( sprintf( esc_html__( 'Confirmed %s', 'wp-mail-smtp' ), 'N/A' ) ),
|
||||
],
|
||||
'sent' => [
|
||||
'type' => 'sent',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/dash-widget/wp/sent.svg',
|
||||
/* translators: %s fixed string of 'N/A'. */
|
||||
'title' => esc_html( sprintf( esc_html__( 'Unconfirmed %s', 'wp-mail-smtp' ), 'N/A' ) ),
|
||||
],
|
||||
'unsent' => [
|
||||
'type' => 'unsent',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/dash-widget/wp/unsent.svg',
|
||||
/* translators: %s fixed string of 'N/A'. */
|
||||
'title' => esc_html( sprintf( esc_html__( 'Failed %s', 'wp-mail-smtp' ), 'N/A' ) ),
|
||||
],
|
||||
];
|
||||
|
||||
if ( Helpers::mailer_without_send_confirmation() ) {
|
||||
|
||||
// Skip the 'unconfirmed sent' section.
|
||||
unset( $output_data['sent'] );
|
||||
|
||||
// Change the 'confirmed sent' section into a general 'sent' section.
|
||||
$output_data['delivered']['title'] = esc_html( /* translators: %s fixed string of 'N/A'. */
|
||||
sprintf( esc_html__( 'Sent %s', 'wp-mail-smtp' ), 'N/A' )
|
||||
);
|
||||
}
|
||||
|
||||
return $output_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get/set a widget meta.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param string $action Possible value: 'get' or 'set'.
|
||||
* @param string $meta Meta name.
|
||||
* @param int $value Value to set.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function widget_meta( $action, $meta, $value = 0 ) {
|
||||
|
||||
$allowed_actions = [ 'get', 'set' ];
|
||||
|
||||
if ( ! in_array( $action, $allowed_actions, true ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $action === 'get' ) {
|
||||
return $this->get_widget_meta( $meta );
|
||||
}
|
||||
|
||||
$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 );
|
||||
}
|
||||
|
||||
if ( 'set' === $action && empty( $value ) ) {
|
||||
return delete_user_meta( get_current_user_id(), $meta_key );
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,422 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin\DebugEvents;
|
||||
|
||||
use WP_Error;
|
||||
use WPMailSMTP\Admin\Area;
|
||||
use WPMailSMTP\Options;
|
||||
use WPMailSMTP\Tasks\DebugEventsCleanupTask;
|
||||
use WPMailSMTP\WP;
|
||||
|
||||
/**
|
||||
* Debug Events class.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function hooks() {
|
||||
|
||||
// Process AJAX requests.
|
||||
add_action( 'wp_ajax_wp_mail_smtp_debug_event_preview', [ $this, 'process_ajax_debug_event_preview' ] );
|
||||
add_action( 'wp_ajax_wp_mail_smtp_delete_all_debug_events', [ $this, 'process_ajax_delete_all_debug_events' ] );
|
||||
|
||||
// Initialize screen options for the Debug Events page.
|
||||
add_action( 'load-wp-mail-smtp_page_wp-mail-smtp-tools', [ $this, 'screen_options' ] );
|
||||
add_filter( 'set-screen-option', [ $this, 'set_screen_options' ], 10, 3 );
|
||||
add_filter( 'set_screen_option_wp_mail_smtp_debug_events_per_page', [ $this, 'set_screen_options' ], 10, 3 );
|
||||
|
||||
// Cancel previous debug events cleanup task if retention period option was changed.
|
||||
add_filter( 'wp_mail_smtp_options_set', [ $this, 'maybe_cancel_debug_events_cleanup_task' ] );
|
||||
|
||||
// Detect debug events log retention period constant change.
|
||||
if ( Options::init()->is_const_defined( 'debug_events', 'retention_period' ) ) {
|
||||
add_action( 'admin_init', [ $this, 'detect_debug_events_retention_period_constant_change' ] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect debug events retention period constant change.
|
||||
*
|
||||
* @since 3.6.0
|
||||
*/
|
||||
public function detect_debug_events_retention_period_constant_change() {
|
||||
|
||||
if ( ! WP::in_wp_admin() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( Options::init()->is_const_changed( 'debug_events', 'retention_period' ) ) {
|
||||
( new DebugEventsCleanupTask() )->cancel();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel previous debug events cleanup task if retention period option was changed.
|
||||
*
|
||||
* @since 3.6.0
|
||||
*
|
||||
* @param array $options Currently processed options passed to a filter hook.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function maybe_cancel_debug_events_cleanup_task( $options ) {
|
||||
|
||||
if ( isset( $options['debug_events']['retention_period'] ) ) {
|
||||
// If this option has changed, cancel the recurring cleanup task and init again.
|
||||
if ( Options::init()->is_option_changed( $options['debug_events']['retention_period'], 'debug_events', 'retention_period' ) ) {
|
||||
( new DebugEventsCleanupTask() )->cancel();
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process AJAX request for deleting all debug event entries.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function process_ajax_delete_all_debug_events() {
|
||||
|
||||
if (
|
||||
empty( $_POST['nonce'] ) ||
|
||||
! wp_verify_nonce( sanitize_key( $_POST['nonce'] ), 'wp_mail_smtp_debug_events' )
|
||||
) {
|
||||
wp_send_json_error( esc_html__( 'Access rejected.', 'wp-mail-smtp' ) );
|
||||
}
|
||||
|
||||
if ( ! current_user_can( wp_mail_smtp()->get_capability_manage_options() ) ) {
|
||||
wp_send_json_error( esc_html__( 'You don\'t have the capability to perform this action.', 'wp-mail-smtp' ) );
|
||||
}
|
||||
|
||||
global $wpdb;
|
||||
|
||||
$table = self::get_table_name();
|
||||
|
||||
$sql = "TRUNCATE TABLE `$table`;";
|
||||
|
||||
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
||||
$result = $wpdb->query( $sql );
|
||||
|
||||
if ( $result !== false ) {
|
||||
wp_send_json_success( esc_html__( 'All debug event entries were deleted successfully.', 'wp-mail-smtp' ) );
|
||||
}
|
||||
|
||||
wp_send_json_error(
|
||||
sprintf( /* translators: %s - WPDB error message. */
|
||||
esc_html__( 'There was an issue while trying to delete all debug event entries. Error message: %s', 'wp-mail-smtp' ),
|
||||
$wpdb->last_error
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process AJAX request for debug event preview.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function process_ajax_debug_event_preview() {
|
||||
|
||||
if (
|
||||
empty( $_POST['nonce'] ) ||
|
||||
! wp_verify_nonce( sanitize_key( $_POST['nonce'] ), 'wp_mail_smtp_debug_events' )
|
||||
) {
|
||||
wp_send_json_error( esc_html__( 'Access rejected.', 'wp-mail-smtp' ) );
|
||||
}
|
||||
|
||||
if ( ! current_user_can( wp_mail_smtp()->get_capability_manage_options() ) ) {
|
||||
wp_send_json_error( esc_html__( 'You don\'t have the capability to perform this action.', 'wp-mail-smtp' ) );
|
||||
}
|
||||
|
||||
$event_id = isset( $_POST['id'] ) ? intval( $_POST['id'] ) : false;
|
||||
|
||||
if ( empty( $event_id ) ) {
|
||||
wp_send_json_error( esc_html__( 'No Debug Event ID provided!', 'wp-mail-smtp' ) );
|
||||
}
|
||||
|
||||
$event = new Event( $event_id );
|
||||
|
||||
wp_send_json_success(
|
||||
[
|
||||
'title' => $event->get_title(),
|
||||
'content' => $event->get_details_html(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the debug event to the DB.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param string $message The event's message.
|
||||
* @param int $type The event's type.
|
||||
*
|
||||
* @return bool|int
|
||||
*/
|
||||
public static function add( $message = '', $type = 0 ) {
|
||||
|
||||
if ( ! in_array( $type, array_keys( Event::get_types() ), true ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $type === Event::TYPE_DEBUG && ! self::is_debug_enabled() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$event = new Event();
|
||||
$event->set_type( $type );
|
||||
$event->set_content( $message );
|
||||
$event->set_initiator();
|
||||
|
||||
return $event->save()->get_id();
|
||||
} catch ( \Exception $exception ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the debug message.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @since 3.5.0 Returns Event ID.
|
||||
*
|
||||
* @param string $message The debug message.
|
||||
*
|
||||
* @return bool|int
|
||||
*/
|
||||
public static function add_debug( $message = '' ) {
|
||||
|
||||
return self::add( $message, Event::TYPE_DEBUG );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the debug message from the provided debug event IDs.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param array|string|int $ids A single or a list of debug event IDs.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_debug_messages( $ids ) {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
if ( empty( $ids ) ) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if ( ! self::is_valid_db() ) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Convert to a string.
|
||||
if ( is_array( $ids ) ) {
|
||||
$ids = implode( ',', $ids );
|
||||
}
|
||||
|
||||
$ids = explode( ',', (string) $ids );
|
||||
$ids = array_map( 'intval', $ids );
|
||||
$placeholders = implode( ', ', array_fill( 0, count( $ids ), '%d' ) );
|
||||
|
||||
$table = self::get_table_name();
|
||||
|
||||
// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
|
||||
$events_data = $wpdb->get_results(
|
||||
$wpdb->prepare( "SELECT id, content, initiator, event_type, created_at FROM {$table} WHERE id IN ( {$placeholders} )", $ids )
|
||||
);
|
||||
// phpcs:enable
|
||||
|
||||
if ( empty( $events_data ) ) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return array_map(
|
||||
function ( $event_item ) {
|
||||
$event = new Event( $event_item );
|
||||
|
||||
return $event->get_short_details();
|
||||
},
|
||||
$events_data
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function screen_options() {
|
||||
|
||||
$screen = get_current_screen();
|
||||
|
||||
if (
|
||||
! is_object( $screen ) ||
|
||||
strpos( $screen->id, 'wp-mail-smtp_page_wp-mail-smtp-tools' ) === false ||
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
! isset( $_GET['tab'] ) || $_GET['tab'] !== 'debug-events'
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
add_screen_option(
|
||||
'per_page',
|
||||
[
|
||||
'label' => esc_html__( 'Number of events per page:', 'wp-mail-smtp' ),
|
||||
'option' => 'wp_mail_smtp_debug_events_per_page',
|
||||
'default' => EventsCollection::PER_PAGE,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the screen options for the debug events page.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param bool $keep Whether to save or skip saving the screen option value.
|
||||
* @param string $option The option name.
|
||||
* @param int $value The number of items to use.
|
||||
*
|
||||
* @return bool|int
|
||||
*/
|
||||
public function set_screen_options( $keep, $option, $value ) {
|
||||
|
||||
if ( 'wp_mail_smtp_debug_events_per_page' === $option ) {
|
||||
return (int) $value;
|
||||
}
|
||||
|
||||
return $keep;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the email debug for debug events is enabled or not.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_debug_enabled() {
|
||||
|
||||
return (bool) Options::init()->get( 'debug_events', 'email_debug' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the debug events page URL.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_page_url() {
|
||||
|
||||
return add_query_arg(
|
||||
[
|
||||
'tab' => 'debug-events',
|
||||
],
|
||||
wp_mail_smtp()->get_admin()->get_admin_page_url( Area::SLUG . '-tools' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the DB table name.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return string Table name, prefixed.
|
||||
*/
|
||||
public static function get_table_name() {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
return $wpdb->prefix . 'wpmailsmtp_debug_events';
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the DB table exists.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_valid_db() {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
static $is_valid = null;
|
||||
|
||||
// Return cached value only if table already exists.
|
||||
if ( $is_valid === true ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$table = self::get_table_name();
|
||||
|
||||
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||
$is_valid = (bool) $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s;', $table ) );
|
||||
|
||||
return $is_valid;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,597 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin\DebugEvents;
|
||||
|
||||
use WPMailSMTP\WP;
|
||||
|
||||
/**
|
||||
* Debug Event class.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
class Event {
|
||||
|
||||
/**
|
||||
* This is an error event.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
const TYPE_ERROR = 0;
|
||||
|
||||
/**
|
||||
* This is a debug event.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
const TYPE_DEBUG = 1;
|
||||
|
||||
/**
|
||||
* The event's ID.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $id = 0;
|
||||
|
||||
/**
|
||||
* The event's content.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $content = '';
|
||||
|
||||
/**
|
||||
* The event's initiator - who called the `wp_mail` function?
|
||||
* JSON encoded string.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $initiator = '';
|
||||
|
||||
/**
|
||||
* The event's type.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $event_type = 0;
|
||||
|
||||
/**
|
||||
* The date and time when this event was created.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @var \DateTime
|
||||
*/
|
||||
protected $created_at;
|
||||
|
||||
/**
|
||||
* Retrieve a particular event when constructing the object.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param int|object $id_or_row The event ID or object with event attributes.
|
||||
*/
|
||||
public function __construct( $id_or_row = null ) {
|
||||
|
||||
$this->populate_event( $id_or_row );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get and prepare the event data.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param int|object $id_or_row The event ID or object with event attributes.
|
||||
*/
|
||||
private function populate_event( $id_or_row ) {
|
||||
|
||||
$event = null;
|
||||
|
||||
if ( is_numeric( $id_or_row ) ) {
|
||||
// Get by ID.
|
||||
$collection = new EventsCollection( [ 'id' => (int) $id_or_row ] );
|
||||
$events = $collection->get();
|
||||
|
||||
if ( $events->valid() ) {
|
||||
$event = $events->current();
|
||||
}
|
||||
} elseif (
|
||||
is_object( $id_or_row ) &&
|
||||
isset(
|
||||
$id_or_row->id,
|
||||
$id_or_row->content,
|
||||
$id_or_row->initiator,
|
||||
$id_or_row->event_type,
|
||||
$id_or_row->created_at
|
||||
)
|
||||
) {
|
||||
$event = $id_or_row;
|
||||
}
|
||||
|
||||
if ( $event !== null ) {
|
||||
foreach ( get_object_vars( $event ) as $key => $value ) {
|
||||
$this->{$key} = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event ID as per our DB table.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_id() {
|
||||
|
||||
return (int) $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the event title.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_title() {
|
||||
|
||||
/* translators: %d the event ID. */
|
||||
return sprintf( esc_html__( 'Event #%d', 'wp-mail-smtp' ), $this->get_id() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the content of the event.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_content() {
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the event's type.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_type() {
|
||||
|
||||
return (int) $this->event_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of all event types.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_types() {
|
||||
|
||||
return [
|
||||
self::TYPE_ERROR => esc_html__( 'Error', 'wp-mail-smtp' ),
|
||||
self::TYPE_DEBUG => esc_html__( 'Debug', 'wp-mail-smtp' ),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get human readable type name.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_type_name() {
|
||||
|
||||
$types = self::get_types();
|
||||
|
||||
return isset( $types[ $this->get_type() ] ) ? $types[ $this->get_type() ] : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the date/time when this event was created.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @throws \Exception Emits exception on incorrect date.
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function get_created_at() {
|
||||
|
||||
$timezone = new \DateTimeZone( 'UTC' );
|
||||
$date = false;
|
||||
|
||||
if ( ! empty( $this->created_at ) ) {
|
||||
$date = \DateTime::createFromFormat( WP::datetime_mysql_format(), $this->created_at, $timezone );
|
||||
}
|
||||
|
||||
if ( $date === false ) {
|
||||
$date = new \DateTime( 'now', $timezone );
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the date/time when this event was created in a nicely formatted string.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_created_at_formatted() {
|
||||
|
||||
try {
|
||||
$date = $this->get_created_at();
|
||||
} catch ( \Exception $e ) {
|
||||
$date = null;
|
||||
}
|
||||
|
||||
if ( empty( $date ) ) {
|
||||
return esc_html__( 'N/A', 'wp-mail-smtp' );
|
||||
}
|
||||
|
||||
return esc_html(
|
||||
date_i18n(
|
||||
WP::datetime_format(),
|
||||
strtotime( get_date_from_gmt( $date->format( WP::datetime_mysql_format() ) ) )
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the event's initiator raw data.
|
||||
* Who called the `wp_mail` function?
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_initiator_raw() {
|
||||
|
||||
return json_decode( $this->initiator, true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the event's initiator name.
|
||||
* Which plugin/theme (or WP core) called the `wp_mail` function?
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_initiator() {
|
||||
|
||||
$initiator = (array) $this->get_initiator_raw();
|
||||
|
||||
if ( empty( $initiator['file'] ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return WP::get_initiator_name( $initiator['file'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the event's initiator file path.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_initiator_file_path() {
|
||||
|
||||
$initiator = (array) $this->get_initiator_raw();
|
||||
|
||||
if ( empty( $initiator['file'] ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $initiator['file'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the event's initiator file line.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_initiator_file_line() {
|
||||
|
||||
$initiator = (array) $this->get_initiator_raw();
|
||||
|
||||
if ( empty( $initiator['line'] ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $initiator['line'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the event's initiator backtrace.
|
||||
*
|
||||
* @since 3.6.0
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function get_initiator_backtrace() {
|
||||
|
||||
$initiator = (array) $this->get_initiator_raw();
|
||||
|
||||
if ( empty( $initiator['backtrace'] ) ) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $initiator['backtrace'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the event preview HTML.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_details_html() {
|
||||
|
||||
$initiator = $this->get_initiator();
|
||||
$initiator_backtrace = $this->get_initiator_backtrace();
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<div class="wp-mail-smtp-debug-event-preview">
|
||||
<div class="wp-mail-smtp-debug-event-preview-subtitle">
|
||||
<span><?php esc_html_e( 'Debug Event Details', 'wp-mail-smtp' ); ?></span>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-debug-event-row wp-mail-smtp-debug-event-preview-type">
|
||||
<span class="debug-event-label"><?php esc_html_e( 'Type', 'wp-mail-smtp' ); ?></span>
|
||||
<span class="debug-event-value"><?php echo esc_html( $this->get_type_name() ); ?></span>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-debug-event-row wp-mail-smtp-debug-event-preview-date">
|
||||
<span class="debug-event-label"><?php esc_html_e( 'Date', 'wp-mail-smtp' ); ?></span>
|
||||
<span class="debug-event-value"><?php echo esc_html( $this->get_created_at_formatted() ); ?></span>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-debug-event-row wp-mail-smtp-debug-event-preview-content">
|
||||
<span class="debug-event-label"><?php esc_html_e( 'Content', 'wp-mail-smtp' ); ?></span>
|
||||
<div class="debug-event-value">
|
||||
<?php echo wp_kses( str_replace( [ "\r\n", "\r", "\n" ], '<br>', $this->get_content() ), [ 'br' => [] ] ); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ( ! empty( $initiator ) ) : ?>
|
||||
<div class="wp-mail-smtp-debug-event-row wp-mail-smtp-debug-event-preview-caller">
|
||||
<span class="debug-event-label"><?php esc_html_e( 'Source', 'wp-mail-smtp' ); ?></span>
|
||||
<div class="debug-event-value">
|
||||
<span class="debug-event-initiator"><?php echo esc_html( $initiator ); ?></span>
|
||||
<p class="debug-event-code">
|
||||
<?php
|
||||
printf( /* Translators: %1$s the path of a file, %2$s the line number in the file. */
|
||||
esc_html__( '%1$s (line: %2$s)', 'wp-mail-smtp' ),
|
||||
esc_html( $this->get_initiator_file_path() ),
|
||||
esc_html( $this->get_initiator_file_line() )
|
||||
);
|
||||
?>
|
||||
|
||||
<?php if ( ! empty( $initiator_backtrace ) ) : ?>
|
||||
<br><br>
|
||||
<b><?php esc_html_e( 'Backtrace:', 'wp-mail-smtp' ); ?></b>
|
||||
<br>
|
||||
<?php
|
||||
foreach ( $initiator_backtrace as $i => $item ) {
|
||||
printf(
|
||||
/* translators: %1$d - index number; %2$s - function name; %3$s - file path; %4$s - line number. */
|
||||
esc_html__( '[%1$d] %2$s called at [%3$s:%4$s]', 'wp-mail-smtp' ),
|
||||
$i,
|
||||
isset( $item['class'] ) ? esc_html( $item['class'] . $item['type'] . $item['function'] ) : esc_html( $item['function'] ),
|
||||
isset( $item['file'] ) ? esc_html( $item['file'] ) : '', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
isset( $item['line'] ) ? esc_html( $item['line'] ) : '' // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
);
|
||||
echo '<br>';
|
||||
}
|
||||
?>
|
||||
<?php endif; ?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the short details about this event (event content and the initiator's name).
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_short_details() {
|
||||
|
||||
$result = [];
|
||||
|
||||
if ( ! empty( $this->get_initiator() ) ) {
|
||||
$result[] = sprintf(
|
||||
/* Translators: %s - Email initiator/source name. */
|
||||
esc_html__( 'Email Source: %s', 'wp-mail-smtp' ),
|
||||
esc_html( $this->get_initiator() )
|
||||
);
|
||||
}
|
||||
|
||||
$result[] = esc_html( $this->get_content() );
|
||||
|
||||
return implode( WP::EOL, $result );
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a new or modified event in DB.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @throws \Exception When event init fails.
|
||||
*
|
||||
* @return Event New or updated event class instance.
|
||||
*/
|
||||
public function save() {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
$table = DebugEvents::get_table_name();
|
||||
|
||||
if ( (bool) $this->get_id() ) {
|
||||
// Update the existing DB table record.
|
||||
$wpdb->update( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||
$table,
|
||||
[
|
||||
'content' => $this->content,
|
||||
'initiator' => $this->initiator,
|
||||
'event_type' => $this->event_type,
|
||||
'created_at' => $this->get_created_at()->format( WP::datetime_mysql_format() ),
|
||||
],
|
||||
[
|
||||
'id' => $this->get_id(),
|
||||
],
|
||||
[
|
||||
'%s', // content.
|
||||
'%s', // initiator.
|
||||
'%s', // type.
|
||||
'%s', // created_at.
|
||||
],
|
||||
[
|
||||
'%d',
|
||||
]
|
||||
);
|
||||
|
||||
$event_id = $this->get_id();
|
||||
} else {
|
||||
// Create a new DB table record.
|
||||
$wpdb->insert(
|
||||
$table,
|
||||
[
|
||||
'content' => $this->content,
|
||||
'initiator' => $this->initiator,
|
||||
'event_type' => $this->event_type,
|
||||
'created_at' => $this->get_created_at()->format( WP::datetime_mysql_format() ),
|
||||
],
|
||||
[
|
||||
'%s', // content.
|
||||
'%s', // initiator.
|
||||
'%s', // type.
|
||||
'%s', // created_at.
|
||||
]
|
||||
);
|
||||
|
||||
$event_id = $wpdb->insert_id;
|
||||
}
|
||||
|
||||
try {
|
||||
$event = new Event( $event_id );
|
||||
} catch ( \Exception $e ) {
|
||||
$event = new Event();
|
||||
}
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the content of this event.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param string|array $content The event's content.
|
||||
*/
|
||||
public function set_content( $content ) {
|
||||
|
||||
if ( ! is_string( $content ) ) {
|
||||
$this->content = wp_json_encode( $content );
|
||||
} else {
|
||||
$this->content = wp_strip_all_tags( str_replace( '<br>', "\r\n", $content ), false );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the initiator by checking the backtrace for the wp_mail function call.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function set_initiator() {
|
||||
|
||||
$initiator = wp_mail_smtp()->get_wp_mail_initiator();
|
||||
|
||||
if ( empty( $initiator->get_file() ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$data['file'] = $initiator->get_file();
|
||||
|
||||
if ( ! empty( $initiator->get_line() ) ) {
|
||||
$data['line'] = $initiator->get_line();
|
||||
}
|
||||
|
||||
if ( DebugEvents::is_debug_enabled() ) {
|
||||
$data['backtrace'] = $initiator->get_backtrace();
|
||||
}
|
||||
|
||||
$this->initiator = wp_json_encode( $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the type of this event.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param int $type The event's type.
|
||||
*/
|
||||
public function set_type( $type ) {
|
||||
|
||||
$this->event_type = (int) $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the event instance is a valid entity to work with.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function is_valid() {
|
||||
|
||||
return ! ( empty( $this->id ) || empty( $this->created_at ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this is an error event.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_error() {
|
||||
|
||||
return self::TYPE_ERROR === $this->get_type();
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this is a debug event.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_debug() {
|
||||
|
||||
return self::TYPE_DEBUG === $this->get_type();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,421 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin\DebugEvents;
|
||||
|
||||
use WPMailSMTP\WP;
|
||||
|
||||
/**
|
||||
* Debug Events Collection.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
class EventsCollection implements \Countable, \Iterator {
|
||||
|
||||
/**
|
||||
* Default number of log entries per page.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const PER_PAGE = 10;
|
||||
|
||||
/**
|
||||
* Number of log entries per page.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public static $per_page;
|
||||
|
||||
/**
|
||||
* List of all Event instances.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $list = [];
|
||||
|
||||
/**
|
||||
* List of current collection instance parameters.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $params;
|
||||
|
||||
/**
|
||||
* Used for \Iterator when iterating through Queue in loops.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $iterator_position = 0;
|
||||
|
||||
/**
|
||||
* Collection constructor.
|
||||
* $events = new EventsCollection( [ 'type' => 0 ] );
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param array $params The events collection parameters.
|
||||
*/
|
||||
public function __construct( array $params = [] ) {
|
||||
|
||||
$this->set_per_page();
|
||||
$this->params = $this->process_params( $params );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the per page attribute to the screen options value.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
protected function set_per_page() {
|
||||
|
||||
$per_page = (int) get_user_meta(
|
||||
get_current_user_id(),
|
||||
'wp_mail_smtp_debug_events_per_page',
|
||||
true
|
||||
);
|
||||
|
||||
if ( $per_page < 1 ) {
|
||||
$per_page = self::PER_PAGE;
|
||||
}
|
||||
|
||||
self::$per_page = $per_page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify, sanitize, and populate with default values
|
||||
* all the passed parameters, which participate in DB queries.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param array $params The events collection parameters.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function process_params( $params ) { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.MaxExceeded
|
||||
|
||||
$params = (array) $params;
|
||||
$processed = [];
|
||||
|
||||
/*
|
||||
* WHERE.
|
||||
*/
|
||||
// Single ID.
|
||||
if ( ! empty( $params['id'] ) ) {
|
||||
$processed['id'] = (int) $params['id'];
|
||||
}
|
||||
|
||||
// Multiple IDs.
|
||||
if (
|
||||
! empty( $params['ids'] ) &&
|
||||
is_array( $params['ids'] )
|
||||
) {
|
||||
$processed['ids'] = array_unique( array_filter( array_map( 'intval', array_values( $params['ids'] ) ) ) );
|
||||
}
|
||||
|
||||
// Type.
|
||||
if (
|
||||
isset( $params['type'] ) &&
|
||||
in_array( $params['type'], array_keys( Event::get_types() ), true )
|
||||
) {
|
||||
$processed['type'] = (int) $params['type'];
|
||||
}
|
||||
|
||||
// Search.
|
||||
if ( ! empty( $params['search'] ) ) {
|
||||
$processed['search'] = sanitize_text_field( $params['search'] );
|
||||
}
|
||||
|
||||
/*
|
||||
* LIMIT.
|
||||
*/
|
||||
if ( ! empty( $params['offset'] ) ) {
|
||||
$processed['offset'] = (int) $params['offset'];
|
||||
}
|
||||
|
||||
if ( ! empty( $params['per_page'] ) ) {
|
||||
$processed['per_page'] = (int) $params['per_page'];
|
||||
}
|
||||
|
||||
/*
|
||||
* Sent date.
|
||||
*/
|
||||
if ( ! empty( $params['date'] ) ) {
|
||||
if ( is_string( $params['date'] ) ) {
|
||||
$params['date'] = array_fill( 0, 2, $params['date'] );
|
||||
} elseif ( is_array( $params['date'] ) && count( $params['date'] ) === 1 ) {
|
||||
$params['date'] = array_fill( 0, 2, $params['date'][0] );
|
||||
}
|
||||
|
||||
// We pass array and treat it as a range from:to.
|
||||
if ( is_array( $params['date'] ) && count( $params['date'] ) === 2 ) {
|
||||
$date_start = WP::get_day_period_date( 'start_of_day', strtotime( $params['date'][0] ), 'Y-m-d H:i:s', true );
|
||||
$date_end = WP::get_day_period_date( 'end_of_day', strtotime( $params['date'][1] ), 'Y-m-d H:i:s', true );
|
||||
|
||||
if ( ! empty( $date_start ) && ! empty( $date_end ) ) {
|
||||
$processed['date'] = [ $date_start, $date_end ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Merge missing values with defaults.
|
||||
return wp_parse_args(
|
||||
$processed,
|
||||
$this->get_default_params()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of default params for a usual query.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_default_params() {
|
||||
|
||||
return [
|
||||
'offset' => 0,
|
||||
'per_page' => self::$per_page,
|
||||
'order' => 'DESC',
|
||||
'orderby' => 'id',
|
||||
'search' => '',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the SQL-ready string of WHERE part for a query.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function build_where() { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh
|
||||
|
||||
global $wpdb;
|
||||
|
||||
$where = [ '1=1' ];
|
||||
|
||||
// Shortcut single ID or multiple IDs.
|
||||
if ( ! empty( $this->params['id'] ) || ! empty( $this->params['ids'] ) ) {
|
||||
if ( ! empty( $this->params['id'] ) ) {
|
||||
$where[] = $wpdb->prepare( 'id = %d', $this->params['id'] );
|
||||
} elseif ( ! empty( $this->params['ids'] ) ) {
|
||||
$where[] = 'id IN (' . implode( ',', $this->params['ids'] ) . ')';
|
||||
}
|
||||
|
||||
// When some ID(s) defined - we should ignore all other possible filtering options.
|
||||
return implode( ' AND ', $where );
|
||||
}
|
||||
|
||||
// Type.
|
||||
if ( isset( $this->params['type'] ) ) {
|
||||
$where[] = $wpdb->prepare( 'event_type = %d', $this->params['type'] );
|
||||
}
|
||||
|
||||
// Search.
|
||||
if ( ! empty( $this->params['search'] ) ) {
|
||||
$where[] = '(' .
|
||||
$wpdb->prepare(
|
||||
'content LIKE %s',
|
||||
'%' . $wpdb->esc_like( $this->params['search'] ) . '%'
|
||||
)
|
||||
. ' OR ' .
|
||||
$wpdb->prepare(
|
||||
'initiator LIKE %s',
|
||||
'%' . $wpdb->esc_like( $this->params['search'] ) . '%'
|
||||
)
|
||||
. ')';
|
||||
}
|
||||
|
||||
// Sent date.
|
||||
if (
|
||||
! empty( $this->params['date'] ) &&
|
||||
is_array( $this->params['date'] ) &&
|
||||
count( $this->params['date'] ) === 2
|
||||
) {
|
||||
$where[] = $wpdb->prepare(
|
||||
'( created_at >= %s AND created_at <= %s )',
|
||||
$this->params['date'][0],
|
||||
$this->params['date'][1]
|
||||
);
|
||||
}
|
||||
|
||||
return implode( ' AND ', $where );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the SQL-ready string of ORDER part for a query.
|
||||
* Order is always in the params, as per our defaults.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function build_order() {
|
||||
|
||||
return 'ORDER BY ' . $this->params['orderby'] . ' ' . $this->params['order'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the SQL-ready string of LIMIT part for a query.
|
||||
* Limit is always in the params, as per our defaults.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function build_limit() {
|
||||
|
||||
return 'LIMIT ' . $this->params['offset'] . ', ' . $this->params['per_page'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the number of DB records according to filters.
|
||||
* Do not retrieve actual records.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_count() {
|
||||
|
||||
$table = DebugEvents::get_table_name();
|
||||
|
||||
$where = $this->build_where();
|
||||
|
||||
// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||
return (int) WP::wpdb()->get_var(
|
||||
"SELECT COUNT(id) FROM $table
|
||||
WHERE {$where}"
|
||||
);
|
||||
// phpcs:enable
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of DB records.
|
||||
* You can either use array returned there OR iterate over the whole object,
|
||||
* as it implements Iterator interface.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return EventsCollection
|
||||
*/
|
||||
public function get() {
|
||||
|
||||
$table = DebugEvents::get_table_name();
|
||||
|
||||
$where = $this->build_where();
|
||||
$limit = $this->build_limit();
|
||||
$order = $this->build_order();
|
||||
|
||||
// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||
$data = WP::wpdb()->get_results(
|
||||
"SELECT * FROM $table
|
||||
WHERE {$where}
|
||||
{$order}
|
||||
{$limit}"
|
||||
);
|
||||
// phpcs:enable
|
||||
|
||||
if ( ! empty( $data ) ) {
|
||||
// As we got raw data we need to convert each row to Event.
|
||||
foreach ( $data as $row ) {
|
||||
$this->list[] = new Event( $row );
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/*********************************************************************************************
|
||||
* ****************************** \Counter interface method. *********************************
|
||||
*********************************************************************************************/
|
||||
|
||||
/**
|
||||
* Count number of Record in a Queue.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function count() {
|
||||
|
||||
return count( $this->list );
|
||||
}
|
||||
|
||||
/*********************************************************************************************
|
||||
* ****************************** \Iterator interface methods. *******************************
|
||||
*********************************************************************************************/
|
||||
|
||||
/**
|
||||
* Rewind the Iterator to the first element.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function rewind() {
|
||||
|
||||
$this->iterator_position = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current element.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return Event|null Return null when no items in collection.
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current() {
|
||||
|
||||
return $this->valid() ? $this->list[ $this->iterator_position ] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the key of the current element.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key() {
|
||||
|
||||
return $this->iterator_position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move forward to next element.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function next() {
|
||||
|
||||
++ $this->iterator_position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if current position is valid.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function valid() {
|
||||
|
||||
return isset( $this->list[ $this->iterator_position ] );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin\DebugEvents;
|
||||
|
||||
use WPMailSMTP\MigrationAbstract;
|
||||
|
||||
/**
|
||||
* Debug Events Migration Class
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
class Migration extends MigrationAbstract {
|
||||
|
||||
/**
|
||||
* Version of the debug events database table.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
const DB_VERSION = 1;
|
||||
|
||||
/**
|
||||
* Option key where we save the current debug events DB version.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
const OPTION_NAME = 'wp_mail_smtp_debug_events_db_version';
|
||||
|
||||
/**
|
||||
* Option key where we save any errors while creating the debug events DB table.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
const ERROR_OPTION_NAME = 'wp_mail_smtp_debug_events_db_error';
|
||||
|
||||
/**
|
||||
* Create the debug events DB table structure.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
protected function migrate_to_1() {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
$table = DebugEvents::get_table_name();
|
||||
$charset_collate = $wpdb->get_charset_collate();
|
||||
|
||||
$sql = "CREATE TABLE IF NOT EXISTS `$table` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`content` TEXT DEFAULT NULL,
|
||||
`initiator` TEXT DEFAULT NULL,
|
||||
`event_type` TINYINT UNSIGNED NOT NULL DEFAULT '0',
|
||||
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (id)
|
||||
)
|
||||
ENGINE='InnoDB'
|
||||
{$charset_collate};";
|
||||
|
||||
$result = $wpdb->query( $sql ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
|
||||
|
||||
if ( ! empty( $wpdb->last_error ) ) {
|
||||
update_option( self::ERROR_OPTION_NAME, $wpdb->last_error, false );
|
||||
}
|
||||
|
||||
// Save the current version to DB.
|
||||
if ( $result !== false ) {
|
||||
$this->update_db_ver( 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,582 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin\DebugEvents;
|
||||
|
||||
use WPMailSMTP\Helpers\Helpers;
|
||||
|
||||
if ( ! class_exists( 'WP_List_Table', false ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Class Table that displays the list of debug events.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
class Table extends \WP_List_Table {
|
||||
|
||||
/**
|
||||
* Number of debug events by different types.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $counts;
|
||||
|
||||
/**
|
||||
* Set up a constructor that references the parent constructor.
|
||||
* Using the parent reference to set some default configs.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
// Set parent defaults.
|
||||
parent::__construct(
|
||||
[
|
||||
'singular' => 'event',
|
||||
'plural' => 'events',
|
||||
'ajax' => false,
|
||||
]
|
||||
);
|
||||
|
||||
// Include polyfill if mbstring PHP extension is not enabled.
|
||||
if ( ! function_exists( 'mb_substr' ) || ! function_exists( 'mb_strlen' ) ) {
|
||||
Helpers::include_mbstring_polyfill();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the debug event types for filtering purpose.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return array Associative array of debug event types StatusCode=>Name.
|
||||
*/
|
||||
public function get_types() {
|
||||
|
||||
return Event::get_types();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the items counts for various types of debug logs.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function get_counts() {
|
||||
|
||||
$this->counts = [];
|
||||
|
||||
// Base params with applied filters.
|
||||
$base_params = $this->get_filters_query_params();
|
||||
|
||||
$total_params = $base_params;
|
||||
unset( $total_params['type'] );
|
||||
$this->counts['total'] = ( new EventsCollection( $total_params ) )->get_count();
|
||||
|
||||
foreach ( $this->get_types() as $type => $name ) {
|
||||
$collection = new EventsCollection( array_merge( $base_params, [ 'type' => $type ] ) );
|
||||
|
||||
$this->counts[ 'type_' . $type ] = $collection->get_count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters items counts by various types of debug events.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param array $counts {
|
||||
* Items counts by types.
|
||||
*
|
||||
* @type integer $total Total items count.
|
||||
* @type integer $status_{$type_key} Items count by type.
|
||||
* }
|
||||
*/
|
||||
$this->counts = apply_filters( 'wp_mail_smtp_admin_debug_events_table_get_counts', $this->counts );
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the view types.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function get_views() {
|
||||
|
||||
$base_url = $this->get_filters_base_url();
|
||||
$current_type = $this->get_filtered_types();
|
||||
|
||||
$views = [];
|
||||
|
||||
$views['all'] = sprintf(
|
||||
'<a href="%1$s" %2$s>%3$s <span class="count">(%4$d)</span></a>',
|
||||
esc_url( remove_query_arg( 'type', $base_url ) ),
|
||||
$current_type === false ? 'class="current"' : '',
|
||||
esc_html__( 'All', 'wp-mail-smtp' ),
|
||||
intval( $this->counts['total'] )
|
||||
);
|
||||
|
||||
foreach ( $this->get_types() as $type => $type_label ) {
|
||||
|
||||
$count = intval( $this->counts[ 'type_' . $type ] );
|
||||
|
||||
// Skipping types with no events.
|
||||
if ( $count === 0 && $current_type !== $type ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$views[ $type ] = sprintf(
|
||||
'<a href="%1$s" %2$s>%3$s <span class="count">(%4$d)</span></a>',
|
||||
esc_url( add_query_arg( 'type', $type, $base_url ) ),
|
||||
$current_type === $type ? 'class="current"' : '',
|
||||
esc_html( $type_label ),
|
||||
$count
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters debug event item views.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param array $views {
|
||||
* Debug event items views by types.
|
||||
*
|
||||
* @type string $all Total items view.
|
||||
* @type integer $status_key Items views by type.
|
||||
* }
|
||||
* @param array $counts {
|
||||
* Items counts by types.
|
||||
*
|
||||
* @type integer $total Total items count.
|
||||
* @type integer $status_{$status_key} Items count by types.
|
||||
* }
|
||||
*/
|
||||
return apply_filters( 'wp_mail_smtp_admin_debug_events_table_get_views', $views, $this->counts );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the table columns.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return array Associative array of slug=>Name columns data.
|
||||
*/
|
||||
public function get_columns() {
|
||||
|
||||
return [
|
||||
'event' => esc_html__( 'Event', 'wp-mail-smtp' ),
|
||||
'type' => esc_html__( 'Type', 'wp-mail-smtp' ),
|
||||
'content' => esc_html__( 'Content', 'wp-mail-smtp' ),
|
||||
'initiator' => esc_html__( 'Source', 'wp-mail-smtp' ),
|
||||
'created_at' => esc_html__( 'Date', 'wp-mail-smtp' ),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the main event title with a link to open event details.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param Event $item Event object.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function column_event( $item ) {
|
||||
|
||||
return '<strong>' .
|
||||
'<a href="#" data-event-id="' . esc_attr( $item->get_id() ) . '"' .
|
||||
' class="js-wp-mail-smtp-debug-event-preview row-title event-preview" title="' . esc_attr( $item->get_title() ) . '">' .
|
||||
esc_html( $item->get_title() ) .
|
||||
'</a>' .
|
||||
'</strong>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Display event's type.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param Event $item Event object.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function column_type( $item ) {
|
||||
|
||||
return esc_html( $item->get_type_name() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Display event's content.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param Event $item Event object.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function column_content( $item ) {
|
||||
|
||||
$content = $item->get_content();
|
||||
|
||||
if ( mb_strlen( $content ) > 100 ) {
|
||||
$content = mb_substr( $content, 0, 100 ) . '...';
|
||||
}
|
||||
|
||||
return wp_kses_post( $content );
|
||||
}
|
||||
|
||||
/**
|
||||
* Display event's wp_mail initiator.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param Event $item Event object.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function column_initiator( $item ) {
|
||||
|
||||
return esc_html( $item->get_initiator() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Display event's created date.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param Event $item Event object.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function column_created_at( $item ) {
|
||||
|
||||
return $item->get_created_at_formatted();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return type filter value or FALSE.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return bool|integer
|
||||
*/
|
||||
public function get_filtered_types() {
|
||||
|
||||
if ( ! isset( $_REQUEST['type'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
return false;
|
||||
}
|
||||
|
||||
return intval( $_REQUEST['type'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
}
|
||||
|
||||
/**
|
||||
* Return date filter value or FALSE.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return bool|array
|
||||
*/
|
||||
public function get_filtered_dates() {
|
||||
|
||||
if ( empty( $_REQUEST['date'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
return false;
|
||||
}
|
||||
|
||||
$dates = (array) explode( ' - ', sanitize_text_field( wp_unslash( $_REQUEST['date'] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
|
||||
return array_map( 'sanitize_text_field', $dates );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return search filter values or FALSE.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return bool|array
|
||||
*/
|
||||
public function get_filtered_search() {
|
||||
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
if ( empty( $_REQUEST['search'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
return sanitize_text_field( wp_unslash( $_REQUEST['search'] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the event log is filtered or not.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_filtered() {
|
||||
|
||||
$is_filtered = false;
|
||||
|
||||
if (
|
||||
$this->get_filtered_search() !== false ||
|
||||
$this->get_filtered_dates() !== false ||
|
||||
$this->get_filtered_types() !== false
|
||||
) {
|
||||
$is_filtered = true;
|
||||
}
|
||||
|
||||
return $is_filtered;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current filters query parameters.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_filters_query_params() {
|
||||
|
||||
$params = [
|
||||
'search' => $this->get_filtered_search(),
|
||||
'type' => $this->get_filtered_types(),
|
||||
'date' => $this->get_filtered_dates(),
|
||||
];
|
||||
|
||||
return array_filter(
|
||||
$params,
|
||||
function ( $v ) {
|
||||
return $v !== false;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current filters base url.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_filters_base_url() {
|
||||
|
||||
$base_url = DebugEvents::get_page_url();
|
||||
$filters_params = $this->get_filters_query_params();
|
||||
|
||||
if ( isset( $filters_params['search'] ) ) {
|
||||
$base_url = add_query_arg( 'search', $filters_params['search'], $base_url );
|
||||
}
|
||||
|
||||
if ( isset( $filters_params['type'] ) ) {
|
||||
$base_url = add_query_arg( 'type', $filters_params['type'], $base_url );
|
||||
}
|
||||
|
||||
if ( isset( $filters_params['date'] ) ) {
|
||||
$base_url = add_query_arg( 'date', implode( ' - ', $filters_params['date'] ), $base_url );
|
||||
}
|
||||
|
||||
return $base_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data, prepare pagination, process bulk actions.
|
||||
* Prepare columns for display.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function prepare_items() {
|
||||
|
||||
// Retrieve count.
|
||||
$this->get_counts();
|
||||
|
||||
// Prepare all the params to pass to our Collection. All sanitization is done in that class.
|
||||
$params = $this->get_filters_query_params();
|
||||
|
||||
// Total amount for pagination with WHERE clause - super quick count DB request.
|
||||
$total_items = ( new EventsCollection( $params ) )->get_count();
|
||||
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
if ( ! empty( $_REQUEST['orderby'] ) && in_array( $_REQUEST['orderby'], [ 'event', 'type', 'content', 'initiator', 'created_at' ], true ) ) {
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
$params['orderby'] = sanitize_key( $_REQUEST['orderby'] );
|
||||
}
|
||||
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
if ( ! empty( $_REQUEST['order'] ) ) {
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
$params['order'] = strtoupper( sanitize_text_field( wp_unslash( $_REQUEST['order'] ) ) ) === 'DESC' ? 'DESC' : 'ASC';
|
||||
}
|
||||
|
||||
$params['offset'] = ( $this->get_pagenum() - 1 ) * EventsCollection::$per_page;
|
||||
|
||||
// Get the data from the DB using parameters defined above.
|
||||
$collection = new EventsCollection( $params );
|
||||
$this->items = $collection->get();
|
||||
|
||||
/*
|
||||
* Register our pagination options & calculations.
|
||||
*/
|
||||
$this->set_pagination_args(
|
||||
[
|
||||
'total_items' => $total_items,
|
||||
'per_page' => EventsCollection::$per_page,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the search box.
|
||||
*
|
||||
* @since 1.7.0
|
||||
*
|
||||
* @param string $text The 'submit' button label.
|
||||
* @param string $input_id ID attribute value for the search input field.
|
||||
*/
|
||||
public function search_box( $text, $input_id ) {
|
||||
|
||||
if ( ! $this->is_filtered() && ! $this->has_items() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
$search = ! empty( $_REQUEST['search'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['search'] ) ) : '';
|
||||
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
if ( ! empty( $_REQUEST['orderby'] ) && in_array( $_REQUEST['orderby'], [ 'event', 'type', 'content', 'initiator', 'created_at' ], true ) ) {
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
$order_by = sanitize_text_field( wp_unslash( $_REQUEST['orderby'] ) );
|
||||
echo '<input type="hidden" name="orderby" value="' . esc_attr( $order_by ) . '" />';
|
||||
}
|
||||
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
if ( ! empty( $_REQUEST['order'] ) ) {
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
$order = strtoupper( sanitize_text_field( wp_unslash( $_REQUEST['order'] ) ) ) === 'DESC' ? 'DESC' : 'ASC';
|
||||
echo '<input type="hidden" name="order" value="' . esc_attr( $order ) . '" />';
|
||||
}
|
||||
?>
|
||||
|
||||
<p class="search-box">
|
||||
<label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"><?php echo esc_html( $text ); ?>:</label>
|
||||
<input type="search" id="<?php echo esc_attr( $input_id ); ?>" name="search" value="<?php echo esc_attr( $search ); ?>" />
|
||||
<?php submit_button( $text, '', '', false, [ 'id' => 'search-submit' ] ); ?>
|
||||
</p>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the table has items to display or not.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has_items() {
|
||||
|
||||
return count( $this->items ) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Message to be displayed when there are no items.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function no_items() {
|
||||
|
||||
if ( $this->is_filtered() ) {
|
||||
esc_html_e( 'No events found.', 'wp-mail-smtp' );
|
||||
} else {
|
||||
esc_html_e( 'No events have been logged for now.', 'wp-mail-smtp' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the table.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function display() {
|
||||
|
||||
$this->_column_headers = [ $this->get_columns(), [], [] ];
|
||||
|
||||
parent::display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide the tablenav if there are no items in the table.
|
||||
* And remove the bulk action nonce and code.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param string $which Which tablenav: top or bottom.
|
||||
*/
|
||||
protected function display_tablenav( $which ) {
|
||||
|
||||
if ( ! $this->has_items() ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="tablenav <?php echo esc_attr( $which ); ?>">
|
||||
|
||||
<?php
|
||||
$this->extra_tablenav( $which );
|
||||
$this->pagination( $which );
|
||||
?>
|
||||
|
||||
<br class="clear" />
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Extra controls to be displayed between bulk actions and pagination.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param string $which Which tablenav: top or bottom.
|
||||
*/
|
||||
protected function extra_tablenav( $which ) {
|
||||
|
||||
if ( $which !== 'top' || ! $this->has_items() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$date = $this->get_filtered_dates() !== false ? implode( ' - ', $this->get_filtered_dates() ) : '';
|
||||
?>
|
||||
<div class="alignleft actions wp-mail-smtp-filter-date">
|
||||
|
||||
<input type="text" name="date" class="regular-text wp-mail-smtp-filter-date-selector wp-mail-smtp-filter-date__control"
|
||||
placeholder="<?php esc_attr_e( 'Select a date range', 'wp-mail-smtp' ); ?>"
|
||||
value="<?php echo esc_attr( $date ); ?>">
|
||||
|
||||
<button type="submit" name="action" value="filter_date" class="button wp-mail-smtp-filter-date__btn">
|
||||
<?php esc_html_e( 'Filter', 'wp-mail-smtp' ); ?>
|
||||
</button>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
if ( current_user_can( wp_mail_smtp()->get_capability_manage_options() ) ) {
|
||||
wp_nonce_field( 'wp_mail_smtp_debug_events', 'wp-mail-smtp-debug-events-nonce', false );
|
||||
printf(
|
||||
'<button id="wp-mail-smtp-delete-all-debug-events-button" type="button" class="button">%s</button>',
|
||||
esc_html__( 'Delete All Events', 'wp-mail-smtp' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the primary column.
|
||||
* Important for the mobile view.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return string The name of the primary column.
|
||||
*/
|
||||
protected function get_primary_column_name() {
|
||||
|
||||
return 'event';
|
||||
}
|
||||
}
|
||||
203
wp/wp-content/plugins/wp-mail-smtp/src/Admin/DomainChecker.php
Normal file
203
wp/wp-content/plugins/wp-mail-smtp/src/Admin/DomainChecker.php
Normal file
@@ -0,0 +1,203 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin;
|
||||
|
||||
use WPMailSMTP\Helpers\Helpers;
|
||||
|
||||
/**
|
||||
* Class for interacting with the Domain Checker API.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*/
|
||||
class DomainChecker {
|
||||
|
||||
/**
|
||||
* The domain checker API endpoint.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*/
|
||||
const ENDPOINT = 'https://connect.wpmailsmtp.com/domain-check/';
|
||||
|
||||
/**
|
||||
* The API results.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $results;
|
||||
|
||||
/**
|
||||
* The plugin mailer slug.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $mailer;
|
||||
|
||||
/**
|
||||
* Verify the domain for the provided mailer and email address and save the API results.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*
|
||||
* @param string $mailer The plugin mailer.
|
||||
* @param string $email The email address from which the domain will be extracted.
|
||||
* @param string $sending_domain The optional sending domain to check the domain records for.
|
||||
*/
|
||||
public function __construct( $mailer, $email, $sending_domain = '' ) {
|
||||
|
||||
$this->mailer = $mailer;
|
||||
|
||||
$params = [
|
||||
'mailer' => $mailer,
|
||||
'email' => base64_encode( $email ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
|
||||
'domain' => $sending_domain,
|
||||
];
|
||||
|
||||
$response = wp_remote_get(
|
||||
add_query_arg( $params, self::ENDPOINT ),
|
||||
[
|
||||
'user-agent' => Helpers::get_default_user_agent(),
|
||||
]
|
||||
);
|
||||
|
||||
if ( is_wp_error( $response ) ) {
|
||||
$this->results = [
|
||||
'success' => false,
|
||||
'message' => method_exists( $response, 'get_error_message' ) ?
|
||||
$response->get_error_message() :
|
||||
esc_html__( 'Something went wrong. Please try again later.', 'wp-mail-smtp' ),
|
||||
'checks' => [],
|
||||
];
|
||||
} else {
|
||||
$this->results = json_decode( wp_remote_retrieve_body( $response ), true );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple getter for the API results.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_results() {
|
||||
return $this->results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the domain checker has found any errors.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has_errors() {
|
||||
|
||||
if ( empty( $this->results['success'] ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( empty( $this->results['checks'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$has_error = false;
|
||||
|
||||
foreach ( $this->results['checks'] as $check ) {
|
||||
if ( $check['state'] === 'error' ) {
|
||||
$has_error = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $has_error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the domain checker has not found any errors or warnings.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function no_issues() {
|
||||
|
||||
if ( empty( $this->results['success'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$no_issues = true;
|
||||
|
||||
foreach ( $this->results['checks'] as $check ) {
|
||||
if ( in_array( $check['state'], [ 'error', 'warning' ], true ) ) {
|
||||
$no_issues = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $no_issues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the domain checker support mailer.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_supported_mailer() {
|
||||
|
||||
return ! in_array( $this->mailer, [ 'mail', 'pepipostapi' ], true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the domain checker results html.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_results_html() {
|
||||
|
||||
$results = $this->get_results();
|
||||
$allowed_html = [
|
||||
'b' => [],
|
||||
'i' => [],
|
||||
'a' => [
|
||||
'href' => [],
|
||||
'target' => [],
|
||||
'rel' => [],
|
||||
],
|
||||
];
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<div id="wp-mail-smtp-domain-check-details">
|
||||
<h2><?php esc_html_e( 'Domain Check Results', 'wp-mail-smtp' ); ?></h2>
|
||||
|
||||
<?php if ( empty( $results['success'] ) ) : ?>
|
||||
<div class="notice-inline <?php echo $this->is_supported_mailer() ? 'notice-error' : 'notice-warning'; ?>">
|
||||
<p><?php echo wp_kses( $results['message'], $allowed_html ); ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( ! empty( $results['checks'] ) ) : ?>
|
||||
<div class="wp-mail-smtp-domain-check-details-check-list">
|
||||
<?php foreach ( $results['checks'] as $check ) : ?>
|
||||
<div class="wp-mail-smtp-domain-check-details-check-list-item">
|
||||
<img src="<?php echo esc_url( wp_mail_smtp()->assets_url . '/images/icons/' . esc_attr( $check['state'] ) . '.svg' ); ?>" class="wp-mail-smtp-domain-check-details-check-list-item-icon" alt="<?php printf( /* translators: %s - item state name. */ esc_attr__( '%s icon', 'wp-mail-smtp' ), esc_attr( $check['state'] ) ); ?>">
|
||||
<div class="wp-mail-smtp-domain-check-details-check-list-item-content">
|
||||
<h3><?php echo esc_html( $check['type'] ); ?></h3>
|
||||
<p><?php echo wp_kses( $check['message'], $allowed_html ); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
}
|
||||
102
wp/wp-content/plugins/wp-mail-smtp/src/Admin/Education.php
Normal file
102
wp/wp-content/plugins/wp-mail-smtp/src/Admin/Education.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin;
|
||||
|
||||
/**
|
||||
* WP Mail SMTP enhancements to admin pages to educate Lite users on what is available in WP Mail SMTP Pro.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
class Education {
|
||||
|
||||
/**
|
||||
* The dismissed notice bar user meta key.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
const DISMISS_NOTICE_BAR_KEY = 'wp_mail_smtp_edu_notice_bar_dismissed';
|
||||
|
||||
/**
|
||||
* Hooks.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public function hooks() {
|
||||
|
||||
if ( apply_filters( 'wp_mail_smtp_admin_education_notice_bar', true ) ) {
|
||||
add_action( 'admin_init', [ $this, 'notice_bar_init' ] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notice bar init.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public function notice_bar_init() {
|
||||
|
||||
add_action( 'wp_mail_smtp_admin_header_before', [ $this, 'notice_bar_display' ] );
|
||||
add_action( 'wp_ajax_wp_mail_smtp_notice_bar_dismiss', [ $this, 'notice_bar_ajax_dismiss' ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Notice bar display message.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public function notice_bar_display() {
|
||||
|
||||
// Bail if we're not on a plugin admin page.
|
||||
if ( ! wp_mail_smtp()->get_admin()->is_admin_page() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$dismissed = get_user_meta( get_current_user_id(), self::DISMISS_NOTICE_BAR_KEY, true );
|
||||
|
||||
if ( ! empty( $dismissed ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
printf(
|
||||
'<div id="wp-mail-smtp-notice-bar">
|
||||
<div class="wp-mail-smtp-notice-bar-container">
|
||||
<span class="wp-mail-smtp-notice-bar-message">%s</span>
|
||||
<button type="button" class="dismiss" title="%s" />
|
||||
</div>
|
||||
</div>',
|
||||
wp_kses(
|
||||
sprintf( /* translators: %s - WPMailSMTP.com Upgrade page URL. */
|
||||
__( 'You’re using WP Mail SMTP Lite. To unlock more features, consider <a href="%s" target="_blank" rel="noopener noreferrer">upgrading to Pro</a>.', 'wp-mail-smtp' ),
|
||||
wp_mail_smtp()->get_upgrade_link( [ 'medium' => 'notice-bar' ] )
|
||||
),
|
||||
[
|
||||
'a' => [
|
||||
'href' => [],
|
||||
'rel' => [],
|
||||
'target' => [],
|
||||
],
|
||||
]
|
||||
),
|
||||
esc_attr__( 'Dismiss this message.', 'wp-mail-smtp' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for dismissing notices.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public function notice_bar_ajax_dismiss() {
|
||||
|
||||
// Run a security check.
|
||||
check_ajax_referer( 'wp-mail-smtp-admin', 'nonce' );
|
||||
|
||||
// Check for permissions.
|
||||
if ( ! current_user_can( wp_mail_smtp()->get_capability_manage_options() ) ) {
|
||||
wp_send_json_error();
|
||||
}
|
||||
|
||||
update_user_meta( get_current_user_id(), self::DISMISS_NOTICE_BAR_KEY, time() );
|
||||
wp_send_json_success();
|
||||
}
|
||||
}
|
||||
146
wp/wp-content/plugins/wp-mail-smtp/src/Admin/FlyoutMenu.php
Normal file
146
wp/wp-content/plugins/wp-mail-smtp/src/Admin/FlyoutMenu.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin;
|
||||
|
||||
/**
|
||||
* Admin Flyout Menu.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
class FlyoutMenu {
|
||||
|
||||
/**
|
||||
* Hooks.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function hooks() {
|
||||
|
||||
/**
|
||||
* Filter for enabling/disabling the quick links (flyout menu).
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param bool $enabled Whether quick links are enabled.
|
||||
*/
|
||||
if ( apply_filters( 'wp_mail_smtp_admin_flyout_menu', true ) ) {
|
||||
add_action( 'admin_footer', [ $this, 'output' ] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Output menu.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function output() {
|
||||
|
||||
// Bail if we're not on a plugin admin page.
|
||||
if ( ! wp_mail_smtp()->get_admin()->is_admin_page() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
printf(
|
||||
'<div id="wp-mail-smtp-flyout">
|
||||
<div id="wp-mail-smtp-flyout-items">%1$s</div>
|
||||
<a href="#" class="wp-mail-smtp-flyout-button wp-mail-smtp-flyout-head">
|
||||
<div class="wp-mail-smtp-flyout-label">%2$s</div>
|
||||
<figure><img src="%3$s" alt="%2$s"/></figure>
|
||||
</a>
|
||||
</div>',
|
||||
$this->get_items_html(), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
esc_html__( 'See Quick Links', 'wp-mail-smtp' ),
|
||||
esc_url( wp_mail_smtp()->assets_url . '/images/flyout-menu/mascot.svg' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate menu items HTML.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return string Menu items HTML.
|
||||
*/
|
||||
private function get_items_html() {
|
||||
|
||||
$items = array_reverse( $this->menu_items() );
|
||||
$items_html = '';
|
||||
|
||||
foreach ( $items as $item_key => $item ) {
|
||||
$items_html .= sprintf(
|
||||
'<a href="%1$s" target="_blank" rel="noopener noreferrer" class="wp-mail-smtp-flyout-button wp-mail-smtp-flyout-item wp-mail-smtp-flyout-item-%2$d"%5$s%6$s>
|
||||
<div class="wp-mail-smtp-flyout-label">%3$s</div>
|
||||
<img src="%4$s" alt="%3$s">
|
||||
</a>',
|
||||
esc_url( $item['url'] ),
|
||||
(int) $item_key,
|
||||
esc_html( $item['title'] ),
|
||||
esc_url( $item['icon'] ),
|
||||
! empty( $item['bgcolor'] ) ? ' style="background-color: ' . esc_attr( $item['bgcolor'] ) . '"' : '',
|
||||
! empty( $item['hover_bgcolor'] ) ? ' onMouseOver="this.style.backgroundColor=\'' . esc_attr( $item['hover_bgcolor'] ) . '\'" onMouseOut="this.style.backgroundColor=\'' . esc_attr( $item['bgcolor'] ) . '\'"' : ''
|
||||
);
|
||||
}
|
||||
|
||||
return $items_html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu items data.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return array Menu items data.
|
||||
*/
|
||||
private function menu_items() {
|
||||
|
||||
$icons_url = wp_mail_smtp()->assets_url . '/images/flyout-menu';
|
||||
|
||||
$items = [
|
||||
[
|
||||
'title' => esc_html__( 'Upgrade to WP Mail SMTP Pro', 'wp-mail-smtp' ),
|
||||
'url' => wp_mail_smtp()->get_upgrade_link( [ 'medium' => 'quick-link-menu' ] ),
|
||||
'icon' => $icons_url . '/star.svg',
|
||||
'bgcolor' => '#E27730',
|
||||
'hover_bgcolor' => '#B85A1B',
|
||||
],
|
||||
[
|
||||
'title' => esc_html__( 'Support & Docs', 'wp-mail-smtp' ),
|
||||
// phpcs:ignore WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
|
||||
'url' => esc_url( wp_mail_smtp()->get_utm_url( 'https://wpmailsmtp.com/docs/', [ 'medium' => 'quick-link-menu', 'content' => 'Support' ] ) ),
|
||||
'icon' => $icons_url . '/life-ring.svg',
|
||||
],
|
||||
[
|
||||
'title' => esc_html__( 'Follow on Facebook', 'wp-mail-smtp' ),
|
||||
'url' => 'https://www.facebook.com/wpmailsmtp',
|
||||
'icon' => $icons_url . '/facebook.svg',
|
||||
],
|
||||
[
|
||||
'title' => esc_html__( 'Suggest a Feature', 'wp-mail-smtp' ),
|
||||
// phpcs:ignore WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
|
||||
'url' => esc_url( wp_mail_smtp()->get_utm_url( 'https://wpmailsmtp.com/suggest-a-feature/', [ 'medium' => 'quick-link-menu', 'content' => 'Feature' ] ) ),
|
||||
'icon' => $icons_url . '/lightbulb.svg',
|
||||
],
|
||||
];
|
||||
|
||||
if ( wp_mail_smtp()->is_pro() ) {
|
||||
array_shift( $items );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters quick links items.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param array $items {
|
||||
* Quick links items.
|
||||
*
|
||||
* @type string $title Item title.
|
||||
* @type string $url Item link.
|
||||
* @type string $icon Item icon url.
|
||||
* @type string $bgcolor Item background color (optional).
|
||||
* @type string $hover_bgcolor Item background color on hover (optional).
|
||||
* }
|
||||
*/
|
||||
return apply_filters( 'wp_mail_smtp_admin_flyout_menu_menu_items', $items );
|
||||
}
|
||||
}
|
||||
540
wp/wp-content/plugins/wp-mail-smtp/src/Admin/Notifications.php
Normal file
540
wp/wp-content/plugins/wp-mail-smtp/src/Admin/Notifications.php
Normal file
@@ -0,0 +1,540 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin;
|
||||
|
||||
use WPMailSMTP\Helpers\Helpers;
|
||||
use WPMailSMTP\Options;
|
||||
use WPMailSMTP\Tasks\Tasks;
|
||||
use WPMailSMTP\WP;
|
||||
|
||||
/**
|
||||
* Notifications.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
class Notifications {
|
||||
|
||||
/**
|
||||
* Source of notifications content.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const SOURCE_URL = 'https://plugin.wpmailsmtp.com/wp-content/notifications.json';
|
||||
|
||||
/**
|
||||
* The WP option key for storing the notification options.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const OPTION_KEY = 'wp_mail_smtp_notifications';
|
||||
|
||||
/**
|
||||
* Option value.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*
|
||||
* @var bool|array
|
||||
*/
|
||||
public $option = false;
|
||||
|
||||
/**
|
||||
* Initialize class.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public function init() {
|
||||
|
||||
$this->hooks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register hooks.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public function hooks() {
|
||||
|
||||
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_assets' ] );
|
||||
add_action( 'wp_mail_smtp_admin_pages_before_content', [ $this, 'output' ] );
|
||||
add_action( 'wp_mail_smtp_admin_notifications_update', [ $this, 'update' ] );
|
||||
add_action( 'wp_ajax_wp_mail_smtp_notification_dismiss', [ $this, 'dismiss' ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user has access and is enabled.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has_access() {
|
||||
|
||||
$access = false;
|
||||
|
||||
if (
|
||||
current_user_can( wp_mail_smtp()->get_capability_manage_options() ) &&
|
||||
! Options::init()->get( 'general', 'am_notifications_hidden' )
|
||||
) {
|
||||
$access = true;
|
||||
}
|
||||
|
||||
return apply_filters( 'wp_mail_smtp_admin_notifications_has_access', $access );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get option value.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*
|
||||
* @param bool $cache Reference property cache if available.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_option( $cache = true ) {
|
||||
|
||||
if ( $this->option && $cache ) {
|
||||
return $this->option;
|
||||
}
|
||||
|
||||
$option = get_option( self::OPTION_KEY, [] );
|
||||
|
||||
$this->option = [
|
||||
'update' => ! empty( $option['update'] ) ? $option['update'] : 0,
|
||||
'events' => ! empty( $option['events'] ) ? $option['events'] : [],
|
||||
'feed' => ! empty( $option['feed'] ) ? $option['feed'] : [],
|
||||
'dismissed' => ! empty( $option['dismissed'] ) ? $option['dismissed'] : [],
|
||||
];
|
||||
|
||||
return $this->option;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch notifications from feed.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function fetch_feed() {
|
||||
|
||||
$response = wp_remote_get(
|
||||
self::SOURCE_URL,
|
||||
[
|
||||
'user-agent' => Helpers::get_default_user_agent(),
|
||||
]
|
||||
);
|
||||
|
||||
if ( is_wp_error( $response ) ) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$body = wp_remote_retrieve_body( $response );
|
||||
|
||||
if ( empty( $body ) ) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $this->verify( json_decode( $body, true ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify notification data before it is saved.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*
|
||||
* @param array $notifications Array of notification items to verify.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function verify( $notifications ) { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh
|
||||
|
||||
$data = [];
|
||||
|
||||
if ( ! is_array( $notifications ) || empty( $notifications ) ) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
$option = $this->get_option();
|
||||
|
||||
foreach ( $notifications as $notification ) {
|
||||
|
||||
// The message and license should never be empty, if they are, ignore.
|
||||
if ( empty( $notification['content'] ) || empty( $notification['type'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ignore if license type does not match.
|
||||
if ( ! in_array( wp_mail_smtp()->get_license_type(), $notification['type'], true ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ignore if expired.
|
||||
if ( ! empty( $notification['end'] ) && time() > strtotime( $notification['end'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ignore if notification has already been dismissed.
|
||||
if ( ! empty( $option['dismissed'] ) && in_array( $notification['id'], $option['dismissed'] ) ) { // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ignore if notification existed before installing WPForms.
|
||||
// Prevents bombarding the user with notifications after activation.
|
||||
$activated = get_option( 'wp_mail_smtp_activated_time' );
|
||||
|
||||
if (
|
||||
! empty( $activated ) &&
|
||||
! empty( $notification['start'] ) &&
|
||||
$activated > strtotime( $notification['start'] )
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$data[] = $notification;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify saved notification data for active notifications.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*
|
||||
* @param array $notifications Array of notification items to verify.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function verify_active( $notifications ) {
|
||||
|
||||
if ( ! is_array( $notifications ) || empty( $notifications ) ) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Remove notifications that are not active.
|
||||
foreach ( $notifications as $key => $notification ) {
|
||||
if (
|
||||
( ! empty( $notification['start'] ) && time() < strtotime( $notification['start'] ) ) ||
|
||||
( ! empty( $notification['end'] ) && time() > strtotime( $notification['end'] ) )
|
||||
) {
|
||||
unset( $notifications[ $key ] );
|
||||
}
|
||||
}
|
||||
|
||||
return $notifications;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get notification data.
|
||||
*
|
||||
* @since 2.3.0
|
||||
* @since 3.9.0 Make the AS a recurring task.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get() {
|
||||
|
||||
if ( ! $this->has_access() ) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$option = $this->get_option();
|
||||
|
||||
// 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' )
|
||||
->recurring(
|
||||
strtotime( '+1 minute' ),
|
||||
$this->get_notification_update_task_interval()
|
||||
)
|
||||
->params()
|
||||
->register();
|
||||
}
|
||||
|
||||
$events = ! empty( $option['events'] ) ? $this->verify_active( $option['events'] ) : [];
|
||||
$feed = ! empty( $option['feed'] ) ? $this->verify_active( $option['feed'] ) : [];
|
||||
|
||||
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.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_count() {
|
||||
|
||||
return count( $this->get() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a manual notification event.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*
|
||||
* @param array $notification Notification data.
|
||||
*/
|
||||
public function add( $notification ) {
|
||||
|
||||
if ( empty( $notification['id'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$option = $this->get_option();
|
||||
|
||||
if ( in_array( $notification['id'], $option['dismissed'] ) ) { // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ( $option['events'] as $item ) {
|
||||
if ( $item['id'] === $notification['id'] ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$notification = $this->verify( [ $notification ] );
|
||||
|
||||
update_option(
|
||||
self::OPTION_KEY,
|
||||
[
|
||||
'update' => $option['update'],
|
||||
'feed' => $option['feed'],
|
||||
'events' => array_merge( $notification, $option['events'] ),
|
||||
'dismissed' => $option['dismissed'],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update notification data from feed.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public function update() {
|
||||
|
||||
$feed = $this->fetch_feed();
|
||||
$option = $this->get_option();
|
||||
|
||||
update_option(
|
||||
self::OPTION_KEY,
|
||||
[
|
||||
'update' => time(),
|
||||
'feed' => $feed,
|
||||
'events' => $option['events'],
|
||||
'dismissed' => $option['dismissed'],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin area assets.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*
|
||||
* @param string $hook Hook suffix for the current admin page.
|
||||
*/
|
||||
public function enqueue_assets( $hook ) {
|
||||
|
||||
if ( strpos( $hook, Area::SLUG ) === false ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! $this->has_access() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$notifications = $this->get();
|
||||
|
||||
if ( empty( $notifications ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
wp_enqueue_style(
|
||||
'wp-mail-smtp-admin-notifications',
|
||||
wp_mail_smtp()->assets_url . '/css/admin-notifications.min.css',
|
||||
[],
|
||||
WPMS_PLUGIN_VER
|
||||
);
|
||||
|
||||
wp_enqueue_script(
|
||||
'wp-mail-smtp-admin-notifications',
|
||||
wp_mail_smtp()->assets_url . '/js/smtp-notifications' . WP::asset_min() . '.js',
|
||||
[ 'jquery' ],
|
||||
WPMS_PLUGIN_VER,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Output notifications.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public function output() { // phpcs:ignore Generic.Metrics.NestingLevel.MaxExceeded
|
||||
|
||||
$notifications = $this->get();
|
||||
|
||||
if ( empty( $notifications ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$notifications_html = '';
|
||||
$current_class = ' current';
|
||||
$content_allowed_tags = [
|
||||
'em' => [],
|
||||
'i' => [],
|
||||
'strong' => [],
|
||||
'span' => [
|
||||
'style' => [],
|
||||
],
|
||||
'a' => [
|
||||
'href' => [],
|
||||
'target' => [],
|
||||
'rel' => [],
|
||||
],
|
||||
'br' => [],
|
||||
'p' => [
|
||||
'id' => [],
|
||||
'class' => [],
|
||||
],
|
||||
];
|
||||
|
||||
foreach ( $notifications as $notification ) {
|
||||
|
||||
// Buttons HTML.
|
||||
$buttons_html = '';
|
||||
if ( ! empty( $notification['btns'] ) && is_array( $notification['btns'] ) ) {
|
||||
foreach ( $notification['btns'] as $btn_type => $btn ) {
|
||||
if ( empty( $btn['text'] ) ) {
|
||||
continue;
|
||||
}
|
||||
$buttons_html .= sprintf(
|
||||
'<a href="%1$s" class="button button-%2$s"%3$s>%4$s</a>',
|
||||
! empty( $btn['url'] ) ? esc_url( $btn['url'] ) : '',
|
||||
$btn_type === 'main' ? 'primary' : 'secondary',
|
||||
! empty( $btn['target'] ) && $btn['target'] === '_blank' ? ' target="_blank" rel="noopener noreferrer"' : '',
|
||||
sanitize_text_field( $btn['text'] )
|
||||
);
|
||||
}
|
||||
$buttons_html = ! empty( $buttons_html ) ? '<div class="wp-mail-smtp-notifications-buttons">' . $buttons_html . '</div>' : '';
|
||||
}
|
||||
|
||||
// Notification HTML.
|
||||
$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>
|
||||
<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( wpautop( $notification['content'] ), $content_allowed_tags ) : '',
|
||||
$buttons_html,
|
||||
! empty( $notification['id'] ) ? esc_attr( sanitize_text_field( $notification['id'] ) ) : 0,
|
||||
$current_class
|
||||
);
|
||||
|
||||
// Only first notification is current.
|
||||
$current_class = '';
|
||||
}
|
||||
?>
|
||||
|
||||
<div id="wp-mail-smtp-notifications">
|
||||
|
||||
<div class="wp-mail-smtp-notifications-header">
|
||||
<div class="wp-mail-smtp-notifications-bell">
|
||||
<svg width="16" height="20" viewBox="0 0 16 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.8173 8.92686C12.4476 9.01261 12.0624 9.05794 11.6666 9.05794C8.86542 9.05794 6.59455 6.78729 6.59419 3.98616C4.22974 4.54931 2.51043 6.64293 2.51043 9.23824C2.51043 12.4695 1.48985 13.6147 0.849845 14.3328C0.796894 14.3922 0.746548 14.4487 0.699601 14.5032C0.505584 14.707 0.408575 14.9787 0.440912 15.2165C0.440912 15.7939 0.828946 16.3034 1.47567 16.3034H13.8604C14.5071 16.3034 14.8952 15.7939 14.9275 15.2165C14.9275 14.9787 14.8305 14.707 14.6365 14.5032C14.5895 14.4487 14.5392 14.3922 14.4862 14.3328C13.8462 13.6147 12.8257 12.4695 12.8257 9.23824C12.8257 9.13361 12.8229 9.02979 12.8173 8.92686ZM9.72139 17.3904C9.72139 18.6132 8.81598 19.5643 7.68421 19.5643C6.52011 19.5643 5.6147 18.6132 5.6147 17.3904H9.72139Z" fill="#777777"/>
|
||||
<path d="M11.6666 7.60868C13.6677 7.60868 15.2898 5.98653 15.2898 3.9855C15.2898 1.98447 13.6677 0.36232 11.6666 0.36232C9.66561 0.36232 8.04346 1.98447 8.04346 3.9855C8.04346 5.98653 9.66561 7.60868 11.6666 7.60868Z" fill="#d63638"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-notifications-title"><?php esc_html_e( 'Notifications', 'wp-mail-smtp' ); ?></div>
|
||||
</div>
|
||||
|
||||
<div class="wp-mail-smtp-notifications-body">
|
||||
<a class="dismiss" title="<?php echo esc_attr__( 'Dismiss this message', 'wp-mail-smtp' ); ?>"><i class="dashicons dashicons-dismiss" aria-hidden="true"></i></a>
|
||||
|
||||
<?php if ( count( $notifications ) > 1 ) : ?>
|
||||
<div class="navigation">
|
||||
<a class="prev">
|
||||
<span class="screen-reader-text"><?php esc_attr_e( 'Previous message', 'wp-mail-smtp' ); ?></span>
|
||||
<span aria-hidden="true">‹</span>
|
||||
</a>
|
||||
<a class="next">
|
||||
<span class="screen-reader-text"><?php esc_attr_e( 'Next message', 'wp-mail-smtp' ); ?>"></span>
|
||||
<span aria-hidden="true">›</span>
|
||||
</a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="wp-mail-smtp-notifications-messages">
|
||||
<?php echo $notifications_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Dismiss notification via AJAX.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public function dismiss() {
|
||||
|
||||
// Run a security check.
|
||||
check_ajax_referer( 'wp-mail-smtp-admin', 'nonce' );
|
||||
|
||||
// Check for access and required param.
|
||||
if ( ! current_user_can( wp_mail_smtp()->get_capability_manage_options() ) || empty( $_POST['id'] ) ) {
|
||||
wp_send_json_error();
|
||||
}
|
||||
|
||||
$id = sanitize_text_field( wp_unslash( $_POST['id'] ) );
|
||||
$option = $this->get_option();
|
||||
$type = is_numeric( $id ) ? 'feed' : 'events';
|
||||
|
||||
$option['dismissed'][] = $id;
|
||||
$option['dismissed'] = array_unique( $option['dismissed'] );
|
||||
|
||||
// Remove notification.
|
||||
if ( is_array( $option[ $type ] ) && ! empty( $option[ $type ] ) ) {
|
||||
foreach ( $option[ $type ] as $key => $notification ) {
|
||||
if ( $notification['id'] == $id ) { // phpcs:ignore WordPress.PHP.StrictComparisons
|
||||
unset( $option[ $type ][ $key ] );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
update_option( self::OPTION_KEY, $option );
|
||||
|
||||
wp_send_json_success();
|
||||
}
|
||||
}
|
||||
208
wp/wp-content/plugins/wp-mail-smtp/src/Admin/PageAbstract.php
Normal file
208
wp/wp-content/plugins/wp-mail-smtp/src/Admin/PageAbstract.php
Normal file
@@ -0,0 +1,208 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin;
|
||||
|
||||
use WPMailSMTP\WP;
|
||||
|
||||
/**
|
||||
* Class PageAbstract.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
abstract class PageAbstract implements PageInterface {
|
||||
|
||||
/**
|
||||
* @var string Slug of a tab.
|
||||
*/
|
||||
protected $slug;
|
||||
|
||||
/**
|
||||
* Tab priority.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $priority = 999;
|
||||
|
||||
/**
|
||||
* Tab parent page.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @var ParentPageAbstract
|
||||
*/
|
||||
protected $parent_page = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @param ParentPageAbstract $parent_page Tab parent page.
|
||||
*/
|
||||
public function __construct( $parent_page = null ) {
|
||||
|
||||
$this->parent_page = $parent_page;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_link() {
|
||||
|
||||
$page = Area::SLUG;
|
||||
|
||||
if ( $this->parent_page !== null ) {
|
||||
$page .= '-' . $this->parent_page->get_slug();
|
||||
}
|
||||
|
||||
return add_query_arg(
|
||||
'tab',
|
||||
$this->slug,
|
||||
WP::admin_url( 'admin.php?page=' . $page )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Title of a tab.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_title() {
|
||||
|
||||
return $this->get_label();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tab slug.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_slug() {
|
||||
|
||||
return $this->slug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tab priority.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_priority() {
|
||||
|
||||
return $this->priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent page.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @return ParentPageAbstract
|
||||
*/
|
||||
public function get_parent_page() {
|
||||
|
||||
return $this->parent_page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent page slug.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_parent_slug() {
|
||||
|
||||
if ( is_null( $this->parent_page ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->parent_page->get_slug();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register tab related hooks.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public function hooks() {}
|
||||
|
||||
/**
|
||||
* Register tab related ajax hooks.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function ajax() {}
|
||||
|
||||
/**
|
||||
* Process tab form submission ($_POST ).
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @param array $data $_POST data specific for the plugin.
|
||||
*/
|
||||
public function process_post( $data ) {}
|
||||
|
||||
/**
|
||||
* Process tab & mailer specific Auth actions.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function process_auth() {}
|
||||
|
||||
/**
|
||||
* Print the nonce field for a specific tab.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function wp_nonce_field() {
|
||||
|
||||
wp_nonce_field( Area::SLUG . '-' . $this->slug );
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure that a user was referred from plugin admin page.
|
||||
* To avoid security problems.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function check_admin_referer() {
|
||||
|
||||
check_admin_referer( Area::SLUG . '-' . $this->slug );
|
||||
}
|
||||
|
||||
/**
|
||||
* Save button to be reused on other tabs.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public function display_save_btn() {
|
||||
|
||||
?>
|
||||
<p class="wp-mail-smtp-submit">
|
||||
<button type="submit" class="wp-mail-smtp-btn wp-mail-smtp-btn-md wp-mail-smtp-btn-orange">
|
||||
<?php esc_html_e( 'Save Settings', 'wp-mail-smtp' ); ?>
|
||||
</button>
|
||||
</p>
|
||||
<?php
|
||||
$this->post_form_hidden_field();
|
||||
}
|
||||
|
||||
/**
|
||||
* Form hidden field for identifying plugin POST requests.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*/
|
||||
public function post_form_hidden_field() {
|
||||
|
||||
echo '<input type="hidden" name="wp-mail-smtp-post" value="1">';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin;
|
||||
|
||||
/**
|
||||
* Class PageInterface defines what should be in each page class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
interface PageInterface {
|
||||
|
||||
/**
|
||||
* URL to a tab.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_link();
|
||||
|
||||
/**
|
||||
* Title of a tab.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_title();
|
||||
|
||||
/**
|
||||
* Link label of a tab.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_label();
|
||||
|
||||
/**
|
||||
* Tab content.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function display();
|
||||
}
|
||||
92
wp/wp-content/plugins/wp-mail-smtp/src/Admin/Pages/About.php
Normal file
92
wp/wp-content/plugins/wp-mail-smtp/src/Admin/Pages/About.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin\Pages;
|
||||
|
||||
use WPMailSMTP\Admin\ParentPageAbstract;
|
||||
|
||||
/**
|
||||
* About parent page.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @since 2.9.0 changed parent class from PageAbstract to ParentPageAbstract.
|
||||
*/
|
||||
class About extends ParentPageAbstract {
|
||||
|
||||
/**
|
||||
* Slug of a page.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @var string Slug of a page.
|
||||
*/
|
||||
protected $slug = 'about';
|
||||
|
||||
/**
|
||||
* Page default tab slug.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $default_tab = 'about';
|
||||
|
||||
/**
|
||||
* Get label for a tab.
|
||||
* Process only those that exists.
|
||||
* Defaults to "About Us".
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @param string $tab Tab to get label for.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_label( $tab = '' ) {
|
||||
|
||||
if ( ! empty( $tab ) ) {
|
||||
return $this->get_tab_label( $tab );
|
||||
}
|
||||
|
||||
return esc_html__( 'About Us', 'wp-mail-smtp' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Title of a page.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_title() {
|
||||
|
||||
return $this->get_label();
|
||||
}
|
||||
|
||||
/**
|
||||
* Active the given plugin.
|
||||
*
|
||||
* @deprecated 2.9.0
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static function ajax_plugin_activate() {
|
||||
|
||||
_deprecated_function( __METHOD__, '2.9.0', '\WPMailSMTP\Admin\Pages\AboutTab::ajax_plugin_activate' );
|
||||
|
||||
AboutTab::ajax_plugin_activate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Install & activate the given plugin.
|
||||
*
|
||||
* @deprecated 2.9.0
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static function ajax_plugin_install() {
|
||||
|
||||
_deprecated_function( __METHOD__, '2.9.0', '\WPMailSMTP\Admin\Pages\AboutTab::ajax_plugin_install' );
|
||||
|
||||
AboutTab::ajax_plugin_install();
|
||||
}
|
||||
}
|
||||
672
wp/wp-content/plugins/wp-mail-smtp/src/Admin/Pages/AboutTab.php
Normal file
672
wp/wp-content/plugins/wp-mail-smtp/src/Admin/Pages/AboutTab.php
Normal file
@@ -0,0 +1,672 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin\Pages;
|
||||
|
||||
use Plugin_Upgrader;
|
||||
use WPMailSMTP\Admin\PageAbstract;
|
||||
use WPMailSMTP\Admin\PluginsInstallSkin;
|
||||
use WPMailSMTP\Helpers\Helpers;
|
||||
|
||||
/**
|
||||
* About tab.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*/
|
||||
class AboutTab extends PageAbstract {
|
||||
|
||||
/**
|
||||
* Part of the slug of a tab.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $slug = 'about';
|
||||
|
||||
/**
|
||||
* Tab priority.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $priority = 20;
|
||||
|
||||
/**
|
||||
* Link label of a tab.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_label() {
|
||||
|
||||
return esc_html__( 'About Us', 'wp-mail-smtp' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Title of a tab.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_title() {
|
||||
|
||||
return $this->get_label();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tab content.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*/
|
||||
public function display() {
|
||||
|
||||
?>
|
||||
<div class="wp-mail-smtp-admin-about-section wp-mail-smtp-admin-columns">
|
||||
|
||||
<div class="wp-mail-smtp-admin-column-60">
|
||||
<h3>
|
||||
<?php esc_html_e( 'Hello and welcome to WP Mail SMTP, the easiest and most popular WordPress SMTP plugin. We build software that helps your site reliably deliver emails every time.', 'wp-mail-smtp' ); ?>
|
||||
</h3>
|
||||
|
||||
<p>
|
||||
<?php esc_html_e( 'Email deliverability has been a well-documented problem for all WordPress websites. However as WPForms grew, we became more aware of this painful issue that affects our users and the larger WordPress community. So we decided to solve this problem and make a solution that\'s beginner friendly.', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
<p>
|
||||
<?php esc_html_e( 'Our goal is to make reliable email deliverability easy for WordPress.', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
<p>
|
||||
<?php
|
||||
printf(
|
||||
wp_kses(
|
||||
/* translators: %1$s - WPForms URL, %2$s - WPBeginner URL, %3$s - OptinMonster URL, %4$s - MonsterInsights URL, %5$s - Awesome Motive URL */
|
||||
__( 'WP Mail SMTP is brought to you by the same team that\'s behind the most user friendly WordPress forms, <a href="%1$s" target="_blank" rel="noopener noreferrer">WPForms</a>, the largest WordPress resource site, <a href="%2$s" target="_blank" rel="noopener noreferrer">WPBeginner</a>, the most popular lead-generation software, <a href="%3$s" target="_blank" rel="noopener noreferrer">OptinMonster</a>, the best WordPress analytics plugin, <a href="%4$s" target="_blank" rel="noopener noreferrer">MonsterInsights</a>, and <a href="%5$s" target="_blank" rel="noopener noreferrer">more</a>.', 'wp-mail-smtp' ),
|
||||
[
|
||||
'a' => [
|
||||
'href' => [],
|
||||
'rel' => [],
|
||||
'target' => [],
|
||||
],
|
||||
]
|
||||
),
|
||||
'https://wpforms.com/?utm_source=wpmailsmtpplugin&utm_medium=pluginaboutpage&utm_campaign=aboutwpmailsmtp',
|
||||
'https://www.wpbeginner.com/?utm_source=wpmailsmtpplugin&utm_medium=pluginaboutpage&utm_campaign=aboutwpmailsmtp',
|
||||
'https://optinmonster.com/?utm_source=wpmailsmtpplugin&utm_medium=pluginaboutpage&utm_campaign=aboutwpmailsmtp',
|
||||
'https://www.monsterinsights.com/?utm_source=wpmailsmtpplugin&utm_medium=pluginaboutpage&utm_campaign=aboutwpmailsmtp',
|
||||
// phpcs:ignore WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
|
||||
esc_url( wp_mail_smtp()->get_utm_url( 'https://awesomemotive.com/', [ 'medium' => 'pluginaboutpage', 'content' => 'aboutwpmailsmtp' ] ) )
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
<p>
|
||||
<?php esc_html_e( 'Yup, we know a thing or two about building awesome products that customers love.', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="wp-mail-smtp-admin-column-40 wp-mail-smtp-admin-column-last">
|
||||
<figure>
|
||||
<img src="<?php echo esc_url( wp_mail_smtp()->assets_url . '/images/about/team.jpg' ); ?>" alt="<?php esc_attr_e( 'The WPForms Team photo', 'wp-mail-smtp' ); ?>">
|
||||
<figcaption>
|
||||
<?php esc_html_e( 'The WPForms Team', 'wp-mail-smtp' ); ?>
|
||||
</figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
// Do not display the plugin section if the user can't install or activate them.
|
||||
if ( ! current_user_can( 'install_plugins' ) && ! current_user_can( 'activate_plugins' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->display_plugins();
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the plugins section.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*/
|
||||
protected function display_plugins() {
|
||||
|
||||
?>
|
||||
<div class="wp-mail-smtp-admin-about-plugins">
|
||||
<div class="plugins-container">
|
||||
<?php
|
||||
foreach ( self::get_am_plugins() as $key => $plugin ) :
|
||||
$is_url_external = false;
|
||||
|
||||
$data = $this->get_about_plugins_data( $plugin );
|
||||
|
||||
if ( isset( $plugin['pro'] ) && array_key_exists( $plugin['pro']['path'], get_plugins() ) ) {
|
||||
$is_url_external = true;
|
||||
$plugin = $plugin['pro'];
|
||||
|
||||
$data = array_merge( $data, $this->get_about_plugins_data( $plugin, true ) );
|
||||
}
|
||||
|
||||
// Do not display a plugin which has to be installed and the user can't install it.
|
||||
if ( ! current_user_can( 'install_plugins' ) && $data['status_class'] === 'status-download' ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="plugin-container">
|
||||
<div class="plugin-item">
|
||||
<div class="details wp-mail-smtp-clear">
|
||||
<img src="<?php echo esc_url( $plugin['icon'] ); ?>" alt="<?php esc_attr_e( 'Plugin icon', 'wp-mail-smtp' ); ?>">
|
||||
<h5 class="plugin-name">
|
||||
<?php echo esc_html( $plugin['name'] ); ?>
|
||||
</h5>
|
||||
<p class="plugin-desc">
|
||||
<?php echo esc_html( $plugin['desc'] ); ?>
|
||||
</p>
|
||||
</div>
|
||||
<div class="actions wp-mail-smtp-clear">
|
||||
<div class="status">
|
||||
<strong>
|
||||
<?php
|
||||
printf(
|
||||
/* translators: %s - status HTML text. */
|
||||
esc_html__( 'Status: %s', 'wp-mail-smtp' ),
|
||||
'<span class="status-label ' . esc_attr( $data['status_class'] ) . '">' . esc_html( $data['status_text'] ) . '</span>'
|
||||
);
|
||||
?>
|
||||
</strong>
|
||||
</div>
|
||||
<div class="action-button">
|
||||
<?php
|
||||
$go_to_class = '';
|
||||
if ( $is_url_external && $data['status_class'] === 'status-download' ) {
|
||||
$go_to_class = ' go_to';
|
||||
}
|
||||
?>
|
||||
<a href="<?php echo esc_url( $plugin['url'] ); ?>"
|
||||
class="<?php echo esc_attr( $data['action_class'] . $go_to_class ); ?>"
|
||||
data-plugin="<?php echo esc_attr( $data['plugin_src'] ); ?>">
|
||||
<?php echo esc_html( $data['action_text'] ); ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate all the required CSS classed and labels to be used in rendering.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param array $plugin Plugin slug.
|
||||
* @param bool $is_pro License type.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function get_about_plugins_data( $plugin, $is_pro = false ) {
|
||||
|
||||
$data = [];
|
||||
|
||||
if ( array_key_exists( $plugin['path'], get_plugins() ) ) {
|
||||
if ( is_plugin_active( $plugin['path'] ) ) {
|
||||
// Status text/status.
|
||||
$data['status_class'] = 'status-active';
|
||||
$data['status_text'] = esc_html__( 'Active', 'wp-mail-smtp' );
|
||||
// Button text/status.
|
||||
$data['action_class'] = $data['status_class'] . ' button button-secondary disabled';
|
||||
$data['action_text'] = esc_html__( 'Activated', 'wp-mail-smtp' );
|
||||
$data['plugin_src'] = esc_attr( $plugin['path'] );
|
||||
} else {
|
||||
// Status text/status.
|
||||
$data['status_class'] = 'status-inactive';
|
||||
$data['status_text'] = esc_html__( 'Inactive', 'wp-mail-smtp' );
|
||||
// Button text/status.
|
||||
$data['action_class'] = $data['status_class'] . ' button button-secondary';
|
||||
$data['action_text'] = esc_html__( 'Activate', 'wp-mail-smtp' );
|
||||
$data['plugin_src'] = esc_attr( $plugin['path'] );
|
||||
}
|
||||
} else {
|
||||
if ( ! $is_pro ) {
|
||||
// Doesn't exist, install.
|
||||
// Status text/status.
|
||||
$data['status_class'] = 'status-download';
|
||||
$data['status_text'] = esc_html__( 'Not Installed', 'wp-mail-smtp' );
|
||||
// Button text/status.
|
||||
$data['action_class'] = $data['status_class'] . ' button button-primary';
|
||||
$data['action_text'] = esc_html__( 'Install Plugin', 'wp-mail-smtp' );
|
||||
$data['plugin_src'] = esc_url( $plugin['url'] );
|
||||
|
||||
// If plugin URL is not a zip file, open a new tab with site URL.
|
||||
if ( preg_match( '/.*\.zip$/', $plugin['url'] ) === 0 ) {
|
||||
$data['status_class'] = 'status-open';
|
||||
$data['action_class'] = $data['status_class'] . ' button button-primary';
|
||||
$data['action_text'] = esc_html__( 'Visit Site', 'wp-mail-smtp' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* List of AM plugins that we propose to install.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private static function get_am_plugins() {
|
||||
|
||||
$data = [
|
||||
'om' => [
|
||||
'path' => 'optinmonster/optin-monster-wp-api.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/plugin-om.png',
|
||||
'name' => esc_html__( 'OptinMonster', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'Instantly get more subscribers, leads, and sales with the #1 conversion optimization toolkit. Create high converting popups, announcement bars, spin a wheel, and more with smart targeting and personalization.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://downloads.wordpress.org/plugin/optinmonster.zip',
|
||||
],
|
||||
'wpforms' => [
|
||||
'path' => 'wpforms-lite/wpforms.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/plugin-wpf.png',
|
||||
'name' => esc_html__( 'WPForms', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'The best drag & drop WordPress form builder. Easily create beautiful contact forms, surveys, payment forms, and more with our 600+ form templates. Trusted by over 5 million websites as the best forms plugin.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://downloads.wordpress.org/plugin/wpforms-lite.zip',
|
||||
'pro' => [
|
||||
'path' => 'wpforms/wpforms.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/plugin-wpf.png',
|
||||
'name' => esc_html__( 'WPForms Pro', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'The best drag & drop WordPress form builder. Easily create beautiful contact forms, surveys, payment forms, and more with our 600+ form templates. Trusted by over 5 million websites as the best forms plugin.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://wpforms.com/?utm_source=WordPress&utm_medium=about&utm_campaign=smtp',
|
||||
],
|
||||
],
|
||||
'mi' => [
|
||||
'path' => 'google-analytics-for-wordpress/googleanalytics.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/plugin-mi.png',
|
||||
'name' => esc_html__( 'MonsterInsights', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'The leading WordPress analytics plugin that shows you how people find and use your website, so you can make data driven decisions to grow your business. Properly set up Google Analytics without writing code.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://downloads.wordpress.org/plugin/google-analytics-for-wordpress.zip',
|
||||
'pro' => [
|
||||
'path' => 'google-analytics-premium/googleanalytics-premium.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/plugin-mi.png',
|
||||
'name' => esc_html__( 'MonsterInsights Pro', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'The leading WordPress analytics plugin that shows you how people find and use your website, so you can make data driven decisions to grow your business. Properly set up Google Analytics without writing code.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://www.monsterinsights.com/?utm_source=WordPress&utm_medium=about&utm_campaign=smtp',
|
||||
],
|
||||
],
|
||||
'aioseo' => [
|
||||
'path' => 'all-in-one-seo-pack/all_in_one_seo_pack.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/plugin-aioseo.png',
|
||||
'name' => esc_html__( 'AIOSEO', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'The original WordPress SEO plugin and toolkit that improves your website’s search rankings. Comes with all the SEO features like Local SEO, WooCommerce SEO, sitemaps, SEO optimizer, schema, and more.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://downloads.wordpress.org/plugin/all-in-one-seo-pack.zip',
|
||||
'pro' => [
|
||||
'path' => 'all-in-one-seo-pack-pro/all_in_one_seo_pack.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/plugin-aioseo.png',
|
||||
'name' => esc_html__( 'AIOSEO', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'The original WordPress SEO plugin and toolkit that improves your website’s search rankings. Comes with all the SEO features like Local SEO, WooCommerce SEO, sitemaps, SEO optimizer, schema, and more.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://aioseo.com/?utm_source=WordPress&utm_medium=about&utm_campaign=smtp',
|
||||
],
|
||||
],
|
||||
'seedprod' => [
|
||||
'path' => 'coming-soon/coming-soon.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/plugin-seedprod.png',
|
||||
'name' => esc_html__( 'SeedProd', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'The fastest drag & drop landing page builder for WordPress. Create custom landing pages without writing code, connect them with your CRM, collect subscribers, and grow your audience. Trusted by 1 million sites.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://downloads.wordpress.org/plugin/coming-soon.zip',
|
||||
'pro' => [
|
||||
'path' => 'seedprod-coming-soon-pro-5/seedprod-coming-soon-pro-5.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/plugin-seedprod.png',
|
||||
'name' => esc_html__( 'SeedProd', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'The fastest drag & drop landing page builder for WordPress. Create custom landing pages without writing code, connect them with your CRM, collect subscribers, and grow your audience. Trusted by 1 million sites.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://www.seedprod.com/?utm_source=WordPress&utm_medium=about&utm_campaign=smtp',
|
||||
],
|
||||
],
|
||||
'rafflepress' => [
|
||||
'path' => 'rafflepress/rafflepress.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/plugin-rp.png',
|
||||
'name' => esc_html__( 'RafflePress', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'Turn your website visitors into brand ambassadors! Easily grow your email list, website traffic, and social media followers with the most powerful giveaways & contests plugin for WordPress.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://downloads.wordpress.org/plugin/rafflepress.zip',
|
||||
'pro' => [
|
||||
'path' => 'rafflepress-pro/rafflepress-pro.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/plugin-rp.png',
|
||||
'name' => esc_html__( 'RafflePress Pro', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'Turn your website visitors into brand ambassadors! Easily grow your email list, website traffic, and social media followers with the most powerful giveaways & contests plugin for WordPress.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://rafflepress.com/pricing/?utm_source=WordPress&utm_medium=about&utm_campaign=smtp',
|
||||
],
|
||||
],
|
||||
'pushengage' => [
|
||||
'path' => 'pushengage/main.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/plugin-pushengage.png',
|
||||
'name' => esc_html__( 'PushEngage', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'Connect with your visitors after they leave your website with the leading web push notification software. Over 10,000+ businesses worldwide use PushEngage to send 15 billion notifications each month.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://downloads.wordpress.org/plugin/pushengage.zip',
|
||||
],
|
||||
'smash-balloon-instagram-feeds' => [
|
||||
'path' => 'instagram-feed/instagram-feed.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/plugin-smash-balloon-instagram-feeds.png',
|
||||
'name' => esc_html__( 'Smash Balloon Instagram Feeds', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'Easily display Instagram content on your WordPress site without writing any code. Comes with multiple templates, ability to show content from multiple accounts, hashtags, and more. Trusted by 1 million websites.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://downloads.wordpress.org/plugin/instagram-feed.zip',
|
||||
'pro' => [
|
||||
'path' => 'instagram-feed-pro/instagram-feed.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/plugin-smash-balloon-instagram-feeds.png',
|
||||
'name' => esc_html__( 'Smash Balloon Instagram Feeds', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'Easily display Instagram content on your WordPress site without writing any code. Comes with multiple templates, ability to show content from multiple accounts, hashtags, and more. Trusted by 1 million websites.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://smashballoon.com/instagram-feed/?utm_source=WordPress&utm_medium=about&utm_campaign=smtp',
|
||||
],
|
||||
],
|
||||
'smash-balloon-facebook-feeds' => [
|
||||
'path' => 'custom-facebook-feed/custom-facebook-feed.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/plugin-smash-balloon-facebook-feeds.png',
|
||||
'name' => esc_html__( 'Smash Balloon Facebook Feeds', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'Easily display Facebook content on your WordPress site without writing any code. Comes with multiple templates, ability to embed albums, group content, reviews, live videos, comments, and reactions.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://downloads.wordpress.org/plugin/custom-facebook-feed.zip',
|
||||
'pro' => [
|
||||
'path' => 'custom-facebook-feed-pro/custom-facebook-feed.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/plugin-smash-balloon-facebook-feeds.png',
|
||||
'name' => esc_html__( 'Smash Balloon Facebook Feeds', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'Easily display Facebook content on your WordPress site without writing any code. Comes with multiple templates, ability to embed albums, group content, reviews, live videos, comments, and reactions.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://smashballoon.com/custom-facebook-feed/?utm_source=WordPress&utm_medium=about&utm_campaign=smtp',
|
||||
],
|
||||
],
|
||||
'smash-balloon-youtube-feeds' => [
|
||||
'path' => 'feeds-for-youtube/youtube-feed.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/plugin-smash-balloon-youtube-feeds.png',
|
||||
'name' => esc_html__( 'Smash Balloon YouTube Feeds', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'Easily display YouTube videos on your WordPress site without writing any code. Comes with multiple layouts, ability to embed live streams, video filtering, ability to combine multiple channel videos, and more.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://downloads.wordpress.org/plugin/feeds-for-youtube.zip',
|
||||
'pro' => [
|
||||
'path' => 'youtube-feed-pro/youtube-feed.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/plugin-smash-balloon-youtube-feeds.png',
|
||||
'name' => esc_html__( 'Smash Balloon YouTube Feeds', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'Easily display YouTube videos on your WordPress site without writing any code. Comes with multiple layouts, ability to embed live streams, video filtering, ability to combine multiple channel videos, and more.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://smashballoon.com/youtube-feed/?utm_source=WordPress&utm_medium=about&utm_campaign=smtp',
|
||||
],
|
||||
],
|
||||
'smash-balloon-twitter-feeds' => [
|
||||
'path' => 'custom-twitter-feeds/custom-twitter-feed.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/plugin-smash-balloon-twitter-feeds.png',
|
||||
'name' => esc_html__( 'Smash Balloon Twitter Feeds', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'Easily display Twitter content in WordPress without writing any code. Comes with multiple layouts, ability to combine multiple Twitter feeds, Twitter card support, tweet moderation, and more.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://downloads.wordpress.org/plugin/custom-twitter-feeds.zip',
|
||||
'pro' => [
|
||||
'path' => 'custom-twitter-feeds-pro/custom-twitter-feed.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/plugin-smash-balloon-twitter-feeds.png',
|
||||
'name' => esc_html__( 'Smash Balloon Twitter Feeds', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'Easily display Twitter content in WordPress without writing any code. Comes with multiple layouts, ability to combine multiple Twitter feeds, Twitter card support, tweet moderation, and more.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://smashballoon.com/custom-twitter-feeds/?utm_source=WordPress&utm_medium=about&utm_campaign=smtp',
|
||||
],
|
||||
],
|
||||
'trustpulse' => [
|
||||
'path' => 'trustpulse-api/trustpulse.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/plugin-trustpulse.png',
|
||||
'name' => esc_html__( 'TrustPulse', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'Boost your sales and conversions by up to 15% with real-time social proof notifications. TrustPulse helps you show live user activity and purchases to help convince other users to purchase.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://downloads.wordpress.org/plugin/trustpulse-api.zip',
|
||||
],
|
||||
'searchwp' => [
|
||||
'path' => '',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/searchwp.png',
|
||||
'name' => esc_html__( 'SearchWP', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'The most advanced WordPress search plugin. Customize your WordPress search algorithm, reorder search results, track search metrics, and everything you need to leverage search to grow your business.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://searchwp.com/?utm_source=WordPress&utm_medium=about&utm_campaign=smtp',
|
||||
'pro' => [
|
||||
'path' => 'searchwp/index.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/searchwp.png',
|
||||
'name' => esc_html__( 'SearchWP', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'The most advanced WordPress search plugin. Customize your WordPress search algorithm, reorder search results, track search metrics, and everything you need to leverage search to grow your business.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://searchwp.com/?utm_source=WordPress&utm_medium=about&utm_campaign=smtp',
|
||||
],
|
||||
],
|
||||
'affiliatewp' => [
|
||||
'path' => '',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/affiliatewp.png',
|
||||
'name' => esc_html__( 'AffiliateWP', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'The #1 affiliate management plugin for WordPress. Easily create an affiliate program for your eCommerce store or membership site within minutes and start growing your sales with the power of referral marketing.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://affiliatewp.com/?utm_source=WordPress&utm_medium=about&utm_campaign=smtp',
|
||||
'pro' => [
|
||||
'path' => 'affiliate-wp/affiliate-wp.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/affiliatewp.png',
|
||||
'name' => esc_html__( 'AffiliateWP', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'The #1 affiliate management plugin for WordPress. Easily create an affiliate program for your eCommerce store or membership site within minutes and start growing your sales with the power of referral marketing.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://affiliatewp.com/?utm_source=WordPress&utm_medium=about&utm_campaign=smtp',
|
||||
],
|
||||
],
|
||||
'wp-simple-pay' => [
|
||||
'path' => 'stripe/stripe-checkout.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/wp-simple-pay.png',
|
||||
'name' => esc_html__( 'WP Simple Pay', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'The #1 Stripe payments plugin for WordPress. Start accepting one-time and recurring payments on your WordPress site without setting up a shopping cart. No code required.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://downloads.wordpress.org/plugin/stripe.zip',
|
||||
'pro' => [
|
||||
'path' => 'wp-simple-pay-pro-3/simple-pay.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/wp-simple-pay.png',
|
||||
'name' => esc_html__( 'WP Simple Pay Pro', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'The #1 Stripe payments plugin for WordPress. Start accepting one-time and recurring payments on your WordPress site without setting up a shopping cart. No code required.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://wpsimplepay.com/?utm_source=WordPress&utm_medium=about&utm_campaign=smtp',
|
||||
],
|
||||
],
|
||||
'easy-digital-downloads' => [
|
||||
'path' => 'easy-digital-downloads/easy-digital-downloads.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/edd.png',
|
||||
'name' => esc_html__( 'Easy Digital Downloads', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'The best WordPress eCommerce plugin for selling digital downloads. Start selling eBooks, software, music, digital art, and more within minutes. Accept payments, manage subscriptions, advanced access control, and more.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://downloads.wordpress.org/plugin/easy-digital-downloads.zip',
|
||||
],
|
||||
'sugar-calendar' => [
|
||||
'path' => 'sugar-calendar-lite/sugar-calendar-lite.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/sugar-calendar.png',
|
||||
'name' => esc_html__( 'Sugar Calendar Lite', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'A simple & powerful event calendar plugin for WordPress that comes with all the event management features including payments, scheduling, timezones, ticketing, recurring events, and more.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://downloads.wordpress.org/plugin/sugar-calendar-lite.zip',
|
||||
'pro' => [
|
||||
'path' => 'sugar-calendar/sugar-calendar.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/sugar-calendar.png',
|
||||
'name' => esc_html__( 'Sugar Calendar', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'A simple & powerful event calendar plugin for WordPress that comes with all the event management features including payments, scheduling, timezones, ticketing, recurring events, and more.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://sugarcalendar.com/?utm_source=WordPress&utm_medium=about&utm_campaign=smtp',
|
||||
],
|
||||
],
|
||||
'wp-charitable' => [
|
||||
'path' => 'charitable/charitable.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/plugin-charitable.png',
|
||||
'name' => esc_html__( 'WP Charitable', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'Top-rated WordPress donation and fundraising plugin. Over 10,000+ non-profit organizations and website owners use Charitable to create fundraising campaigns and raise more money online.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://downloads.wordpress.org/plugin/charitable.zip',
|
||||
],
|
||||
'wpcode' => [
|
||||
'path' => 'insert-headers-and-footers/ihaf.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/plugin-wpcode.png',
|
||||
'name' => esc_html__( 'WPCode Lite', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'Future proof your WordPress customizations with the most popular code snippet management plugin for WordPress. Trusted by over 1,500,000+ websites for easily adding code to WordPress right from the admin area.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://downloads.wordpress.org/plugin/insert-headers-and-footers.zip',
|
||||
'pro' => [
|
||||
'path' => 'wpcode-premium/wpcode.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/plugin-wpcode.png',
|
||||
'name' => esc_html__( 'WPCode Pro', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'Future proof your WordPress customizations with the most popular code snippet management plugin for WordPress. Trusted by over 1,500,000+ websites for easily adding code to WordPress right from the admin area.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://wpcode.com/?utm_source=WordPress&utm_medium=about&utm_campaign=smtp',
|
||||
],
|
||||
],
|
||||
'duplicator' => [
|
||||
'path' => 'duplicator/duplicator.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/duplicator-icon-large.png',
|
||||
'name' => esc_html__( 'Duplicator', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'Leading WordPress backup & site migration plugin. Over 1,500,000+ smart website owners use Duplicator to make reliable and secure WordPress backups to protect their websites. It also makes website migration really easy.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://downloads.wordpress.org/plugin/duplicator.zip',
|
||||
'pro' => [
|
||||
'path' => 'duplicator-pro/duplicator-pro.php',
|
||||
'icon' => wp_mail_smtp()->assets_url . '/images/about/duplicator-icon-large.png',
|
||||
'name' => esc_html__( 'Duplicator Pro', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'Leading WordPress backup & site migration plugin. Over 1,500,000+ smart website owners use Duplicator to make reliable and secure WordPress backups to protect their websites. It also makes website migration really easy.', 'wp-mail-smtp' ),
|
||||
'url' => 'https://duplicator.com/?utm_source=WordPress&utm_medium=about&utm_campaign=smtp',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Active the given plugin.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*/
|
||||
public static function ajax_plugin_activate() {
|
||||
|
||||
// Run a security check.
|
||||
check_ajax_referer( 'wp-mail-smtp-about', 'nonce' );
|
||||
|
||||
$error = esc_html__( 'Could not activate the plugin. Please activate it from the Plugins page.', 'wp-mail-smtp' );
|
||||
|
||||
// Check for permissions.
|
||||
if ( ! current_user_can( 'activate_plugins' ) ) {
|
||||
wp_send_json_error( $error );
|
||||
}
|
||||
|
||||
if ( empty( $_POST['plugin'] ) ) {
|
||||
wp_send_json_error( $error );
|
||||
}
|
||||
|
||||
$plugin_slug = sanitize_text_field( wp_unslash( $_POST['plugin'] ) );
|
||||
|
||||
$whitelisted_plugins = [];
|
||||
|
||||
foreach ( self::get_am_plugins() as $item ) {
|
||||
if ( ! empty( $item['path'] ) ) {
|
||||
$whitelisted_plugins[] = $item['path'];
|
||||
}
|
||||
|
||||
if ( ! empty( $item['pro']['path'] ) ) {
|
||||
$whitelisted_plugins[] = $item['pro']['path'];
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! in_array( $plugin_slug, $whitelisted_plugins, true ) ) {
|
||||
wp_send_json_error( esc_html__( 'Could not activate the plugin. Plugin is not whitelisted.', 'wp-mail-smtp' ) );
|
||||
}
|
||||
|
||||
$activate = activate_plugins( $plugin_slug );
|
||||
|
||||
if ( ! is_wp_error( $activate ) ) {
|
||||
wp_send_json_success( esc_html__( 'Plugin activated.', 'wp-mail-smtp' ) );
|
||||
}
|
||||
|
||||
wp_send_json_error( $error );
|
||||
}
|
||||
|
||||
/**
|
||||
* Install & activate the given plugin.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*/
|
||||
public static function ajax_plugin_install() { // phpcs:ignore:Generic.Metrics.CyclomaticComplexity.TooHigh
|
||||
|
||||
// Run a security check.
|
||||
check_ajax_referer( 'wp-mail-smtp-about', 'nonce' );
|
||||
|
||||
$error = esc_html__( 'Could not install the plugin.', 'wp-mail-smtp' );
|
||||
|
||||
// Check for permissions.
|
||||
if ( ! current_user_can( 'install_plugins' ) ) {
|
||||
wp_send_json_error( $error );
|
||||
}
|
||||
|
||||
if ( empty( $_POST['plugin'] ) ) {
|
||||
wp_send_json_error();
|
||||
}
|
||||
|
||||
$plugin_url = esc_url_raw( wp_unslash( $_POST['plugin'] ) );
|
||||
|
||||
if ( ! in_array( $plugin_url, wp_list_pluck( array_values( self::get_am_plugins() ), 'url' ) , true ) ) {
|
||||
wp_send_json_error( esc_html__( 'Could not install the plugin. Plugin is not whitelisted.', 'wp-mail-smtp' ) );
|
||||
}
|
||||
|
||||
// Set the current screen to avoid undefined notices.
|
||||
set_current_screen( 'wp-mail-smtp_page_wp-mail-smtp-about' );
|
||||
|
||||
// Prepare variables.
|
||||
$url = esc_url_raw(
|
||||
add_query_arg(
|
||||
[
|
||||
'page' => 'wp-mail-smtp-about',
|
||||
],
|
||||
admin_url( 'admin.php' )
|
||||
)
|
||||
);
|
||||
|
||||
/*
|
||||
* The `request_filesystem_credentials` function will output a credentials form in case of failure.
|
||||
* We don't want that, since it will break AJAX response. So just hide output with a buffer.
|
||||
*/
|
||||
ob_start();
|
||||
// phpcs:ignore WPForms.Formatting.EmptyLineAfterAssigmentVariables.AddEmptyLine
|
||||
$creds = request_filesystem_credentials( $url, '', false, false, null );
|
||||
ob_end_clean();
|
||||
|
||||
// Check for file system permissions.
|
||||
if ( false === $creds ) {
|
||||
wp_send_json_error( $error );
|
||||
}
|
||||
|
||||
if ( ! WP_Filesystem( $creds ) ) {
|
||||
wp_send_json_error( $error );
|
||||
}
|
||||
|
||||
// Do not allow WordPress to search/download translations, as this will break JS output.
|
||||
remove_action( 'upgrader_process_complete', [ 'Language_Pack_Upgrader', 'async_upgrade' ], 20 );
|
||||
|
||||
// Import the plugin upgrader.
|
||||
Helpers::include_plugin_upgrader();
|
||||
|
||||
// Create the plugin upgrader with our custom skin.
|
||||
$installer = new Plugin_Upgrader( new PluginsInstallSkin() );
|
||||
|
||||
// Error check.
|
||||
if ( ! method_exists( $installer, 'install' ) ) {
|
||||
wp_send_json_error( $error );
|
||||
}
|
||||
|
||||
$installer->install( $plugin_url );
|
||||
|
||||
// Flush the cache and return the newly installed plugin basename.
|
||||
wp_cache_flush();
|
||||
|
||||
if ( $installer->plugin_info() ) {
|
||||
|
||||
$plugin_basename = $installer->plugin_info();
|
||||
|
||||
// Activate the plugin silently.
|
||||
$activated = activate_plugin( $plugin_basename );
|
||||
|
||||
if ( ! is_wp_error( $activated ) ) {
|
||||
wp_send_json_success(
|
||||
[
|
||||
'msg' => esc_html__( 'Plugin installed & activated.', 'wp-mail-smtp' ),
|
||||
'is_activated' => true,
|
||||
'basename' => $plugin_basename,
|
||||
]
|
||||
);
|
||||
} else {
|
||||
wp_send_json_success(
|
||||
[
|
||||
'msg' => esc_html__( 'Plugin installed.', 'wp-mail-smtp' ),
|
||||
'is_activated' => false,
|
||||
'basename' => $plugin_basename,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
wp_send_json_error( $error );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin\Pages;
|
||||
|
||||
use WPMailSMTP\Admin\PageAbstract;
|
||||
|
||||
/**
|
||||
* Class ActionScheduler.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*/
|
||||
class ActionSchedulerTab extends PageAbstract {
|
||||
|
||||
/**
|
||||
* Part of the slug of a tab.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $slug = 'action-scheduler';
|
||||
|
||||
/**
|
||||
* Tab priority.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $priority = 30;
|
||||
|
||||
/**
|
||||
* Link label of a tab.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_label() {
|
||||
|
||||
return esc_html__( 'Scheduled Actions', 'wp-mail-smtp' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Title of a tab.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_title() {
|
||||
|
||||
return $this->get_label();
|
||||
}
|
||||
|
||||
/**
|
||||
* URL to a tab.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_link() {
|
||||
|
||||
return add_query_arg( [ 's' => 'wp_mail_smtp' ], parent::get_link() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register hooks.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*/
|
||||
public function hooks() {
|
||||
|
||||
add_action( 'current_screen', [ $this, 'init' ], 20 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Init.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*/
|
||||
public function init() {
|
||||
|
||||
if ( $this->is_applicable() ) {
|
||||
\ActionScheduler_AdminView::instance()->process_admin_ui();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display scheduled actions table.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*/
|
||||
public function display() {
|
||||
|
||||
if ( ! $this->is_applicable() ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<h1><?php echo esc_html__( 'Scheduled Actions', 'wp-mail-smtp' ); ?></h1>
|
||||
|
||||
<p>
|
||||
<?php
|
||||
echo sprintf(
|
||||
wp_kses( /* translators: %s - Action Scheduler website URL. */
|
||||
__( 'WP Mail SMTP is using the <a href="%s" target="_blank" rel="noopener noreferrer">Action Scheduler</a> library, which allows it to queue and process bigger tasks in the background without making your site slower for your visitors. Below you can see the list of all tasks and their status. This table can be very useful when debugging certain issues.', 'wp-mail-smtp' ),
|
||||
[
|
||||
'a' => [
|
||||
'href' => [],
|
||||
'rel' => [],
|
||||
'target' => [],
|
||||
],
|
||||
]
|
||||
),
|
||||
'https://actionscheduler.org/'
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<?php echo esc_html__( 'Action Scheduler library is also used by other plugins, like WPForms and WooCommerce, so you might see tasks that are not related to our plugin in the table below.', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
|
||||
<?php if ( isset( $_GET['s'] ) ) : // phpcs:ignore WordPress.Security.NonceVerification.Recommended ?>
|
||||
<div id="wp-mail-smtp-reset-filter">
|
||||
<?php
|
||||
echo wp_kses(
|
||||
sprintf( /* translators: %s - search term. */
|
||||
__( 'Search results for <strong>%s</strong>', 'wp-mail-smtp' ),
|
||||
sanitize_text_field( wp_unslash( $_GET['s'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
),
|
||||
[ 'strong' => [] ]
|
||||
);
|
||||
?>
|
||||
<a href="<?php echo esc_url( remove_query_arg( 's' ) ); ?>">
|
||||
<i class="reset dashicons dashicons-dismiss"></i>
|
||||
</a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
\ActionScheduler_AdminView::instance()->render_admin_ui();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if ActionScheduler_AdminView class exists.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function is_applicable() {
|
||||
|
||||
return class_exists( 'ActionScheduler_AdminView' );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin\Pages;
|
||||
|
||||
use WPMailSMTP\Admin\PageAbstract;
|
||||
|
||||
/**
|
||||
* Class AdditionalConnectionsTab is a placeholder for Pro additional connections feature.
|
||||
* Displays product education.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
class AdditionalConnectionsTab extends PageAbstract {
|
||||
|
||||
/**
|
||||
* Part of the slug of a tab.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $slug = 'connections';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*
|
||||
* @param PageAbstract $parent_page Parent page object.
|
||||
*/
|
||||
public function __construct( $parent_page = null ) {
|
||||
|
||||
parent::__construct( $parent_page );
|
||||
|
||||
if ( wp_mail_smtp()->get_admin()->get_current_tab() === $this->slug && ! wp_mail_smtp()->is_pro() ) {
|
||||
$this->hooks();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Link label of a tab.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_label() {
|
||||
|
||||
return esc_html__( 'Additional Connections', 'wp-mail-smtp' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register hooks.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
public function hooks() {
|
||||
|
||||
add_action( 'wp_mail_smtp_admin_area_enqueue_assets', [ $this, 'enqueue_assets' ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue required JS and CSS.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
public function enqueue_assets() {
|
||||
|
||||
wp_enqueue_style(
|
||||
'wp-mail-smtp-admin-lity',
|
||||
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 . '/js/vendor/lity.min.js',
|
||||
[],
|
||||
'2.4.1'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Output HTML of additional connections' education.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
public function display() {
|
||||
|
||||
$top_upgrade_button_url = wp_mail_smtp()->get_upgrade_link(
|
||||
[
|
||||
'medium' => 'Additional Connections Settings',
|
||||
'content' => 'Upgrade to WP Mail SMTP Pro Button Top',
|
||||
]
|
||||
);
|
||||
$bottom_upgrade_button_url = wp_mail_smtp()->get_upgrade_link(
|
||||
[
|
||||
'medium' => 'Additional Connections Settings',
|
||||
'content' => 'Upgrade to WP Mail SMTP Pro Button',
|
||||
]
|
||||
);
|
||||
?>
|
||||
<div id="wp-mail-additional-connections-product-education" class="wp-mail-smtp-product-education">
|
||||
<div class="wp-mail-smtp-product-education__row">
|
||||
<h4 class="wp-mail-smtp-product-education__heading">
|
||||
<?php esc_html_e( 'Additional Connections', 'wp-mail-smtp' ); ?>
|
||||
</h4>
|
||||
<p class="wp-mail-smtp-product-education__description">
|
||||
<?php
|
||||
esc_html_e( 'Create additional connections to set a backup for your Primary Connection or to configure Smart Routing.', 'wp-mail-smtp' );
|
||||
?>
|
||||
</p>
|
||||
|
||||
<a href="<?php echo esc_url( $top_upgrade_button_url ); ?>" target="_blank" rel="noopener noreferrer" class="wp-mail-smtp-product-education__upgrade-btn wp-mail-smtp-product-education__upgrade-btn--top wp-mail-smtp-btn wp-mail-smtp-btn-upgrade wp-mail-smtp-btn-orange">
|
||||
<?php esc_html_e( 'Upgrade to WP Mail SMTP Pro', 'wp-mail-smtp' ); ?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$this->display_education_screenshots();
|
||||
$this->display_education_features_list();
|
||||
?>
|
||||
|
||||
<a href="<?php echo esc_url( $bottom_upgrade_button_url ); ?>" target="_blank" rel="noopener noreferrer" class="wp-mail-smtp-product-education__upgrade-btn wp-mail-smtp-product-education__upgrade-btn--bottom wp-mail-smtp-btn wp-mail-smtp-btn-upgrade wp-mail-smtp-btn-orange">
|
||||
<?php esc_html_e( 'Upgrade to WP Mail SMTP Pro', 'wp-mail-smtp' ); ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Output HTML of additional connections' education screenshots.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
protected function display_education_screenshots() {
|
||||
|
||||
$assets_url = wp_mail_smtp()->assets_url . '/images/additional-connections/';
|
||||
$screenshots = [
|
||||
[
|
||||
'url' => $assets_url . 'screenshot-01.png',
|
||||
'url_thumbnail' => $assets_url . 'thumbnail-01.png',
|
||||
'title' => __( 'Backup Connection', 'wp-mail-smtp' ),
|
||||
],
|
||||
[
|
||||
'url' => $assets_url . 'screenshot-02.png',
|
||||
'url_thumbnail' => $assets_url . 'thumbnail-02.png',
|
||||
'title' => __( 'Smart Routing', 'wp-mail-smtp' ),
|
||||
],
|
||||
];
|
||||
?>
|
||||
<div class="wp-mail-smtp-product-education__row wp-mail-smtp-product-education__row--full-width">
|
||||
<div class="wp-mail-smtp-product-education__screenshots wp-mail-smtp-product-education__screenshots--two">
|
||||
<?php foreach ( $screenshots as $screenshot ) : ?>
|
||||
<div>
|
||||
<a href="<?php echo esc_url( $screenshot['url'] ); ?>" data-lity data-lity-desc="<?php echo esc_attr( $screenshot['title'] ); ?>">
|
||||
<img src="<?php echo esc_url( $screenshot['url_thumbnail'] ); ?>" alt="<?php esc_attr( $screenshot['title'] ); ?>">
|
||||
</a>
|
||||
<span><?php echo esc_html( $screenshot['title'] ); ?></span>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Output HTML of additional connections' education features list.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
protected function display_education_features_list() {
|
||||
|
||||
?>
|
||||
<div class="wp-mail-smtp-product-education__row wp-mail-smtp-product-education__row--full-width">
|
||||
<div class="wp-mail-smtp-product-education__list">
|
||||
<h4><?php esc_html_e( 'With additional connections you can...', 'wp-mail-smtp' ); ?></h4>
|
||||
<div>
|
||||
<ul>
|
||||
<li><?php esc_html_e( 'Set a Backup Connection', 'wp-mail-smtp' ); ?></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><?php esc_html_e( 'Use mailers for different purposes', 'wp-mail-smtp' ); ?></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><?php esc_html_e( 'Create advanced routing rules', 'wp-mail-smtp' ); ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
273
wp/wp-content/plugins/wp-mail-smtp/src/Admin/Pages/AlertsTab.php
Normal file
273
wp/wp-content/plugins/wp-mail-smtp/src/Admin/Pages/AlertsTab.php
Normal file
@@ -0,0 +1,273 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin\Pages;
|
||||
|
||||
use WPMailSMTP\Admin\PageAbstract;
|
||||
use WPMailSMTP\Helpers\UI;
|
||||
|
||||
/**
|
||||
* Class AlertsTab is a placeholder for Pro alerts feature.
|
||||
* Displays product education.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*/
|
||||
class AlertsTab extends PageAbstract {
|
||||
|
||||
/**
|
||||
* Part of the slug of a tab.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $slug = 'alerts';
|
||||
|
||||
/**
|
||||
* Tab priority.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $priority = 20;
|
||||
|
||||
/**
|
||||
* Link label of a tab.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_label() {
|
||||
|
||||
return esc_html__( 'Alerts', 'wp-mail-smtp' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Title of a tab.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_title() {
|
||||
|
||||
return $this->get_label();
|
||||
}
|
||||
|
||||
/**
|
||||
* Output HTML of the alerts settings preview.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*/
|
||||
public function display() {
|
||||
|
||||
$top_upgrade_button_url = wp_mail_smtp()->get_upgrade_link(
|
||||
[
|
||||
'medium' => 'Alerts Settings',
|
||||
'content' => 'Upgrade to WP Mail SMTP Pro Button Top',
|
||||
]
|
||||
);
|
||||
$bottom_upgrade_button_url = wp_mail_smtp()->get_upgrade_link(
|
||||
[
|
||||
'medium' => 'Alerts Settings',
|
||||
'content' => 'Upgrade to WP Mail SMTP Pro Button',
|
||||
]
|
||||
);
|
||||
?>
|
||||
<div class="wp-mail-smtp-product-education">
|
||||
<div class="wp-mail-smtp-product-education__row">
|
||||
<h4 class="wp-mail-smtp-product-education__heading">
|
||||
<?php esc_html_e( 'Alerts', 'wp-mail-smtp' ); ?>
|
||||
</h4>
|
||||
<p class="wp-mail-smtp-product-education__description">
|
||||
<?php
|
||||
esc_html_e( 'Configure at least one of these integrations to receive notifications when email fails to send from your site. Alert notifications will contain the following important data: email subject, email Send To address, the error message, and helpful links to help you fix the issue.', 'wp-mail-smtp' );
|
||||
?>
|
||||
</p>
|
||||
|
||||
<a href="<?php echo esc_url( $top_upgrade_button_url ); ?>" target="_blank" rel="noopener noreferrer" class="wp-mail-smtp-product-education__upgrade-btn wp-mail-smtp-product-education__upgrade-btn--top wp-mail-smtp-btn wp-mail-smtp-btn-upgrade wp-mail-smtp-btn-orange">
|
||||
<?php esc_html_e( 'Upgrade to WP Mail SMTP Pro', 'wp-mail-smtp' ); ?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="wp-mail-smtp-product-education__row wp-mail-smtp-product-education__row--inactive">
|
||||
<div id="wp-mail-smtp-setting-row-alert_event_types" class="wp-mail-smtp-setting-row wp-mail-smtp-clear">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label for="wp-mail-smtp-setting-debug_event_types">
|
||||
<?php esc_html_e( 'Notify when', 'wp-mail-smtp' ); ?>
|
||||
</label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<?php
|
||||
UI::toggle(
|
||||
[
|
||||
'label' => esc_html__( 'The initial email sending request fails', 'wp-mail-smtp' ),
|
||||
'checked' => true,
|
||||
'disabled' => true,
|
||||
]
|
||||
);
|
||||
?>
|
||||
<p class="desc">
|
||||
<?php esc_html_e( 'This option is always enabled and will notify you about instant email sending failures.', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
<hr class="wp-mail-smtp-setting-mid-row-sep">
|
||||
|
||||
<?php
|
||||
UI::toggle(
|
||||
[
|
||||
'label' => esc_html__( 'The deliverability verification process detects a hard bounce', 'wp-mail-smtp' ),
|
||||
'disabled' => true,
|
||||
]
|
||||
);
|
||||
?>
|
||||
<p class="desc">
|
||||
<?php esc_html_e( 'Get notified about emails that were successfully sent, but have hard bounced on delivery attempt. A hard bounce is an email that has failed to deliver for permanent reasons, such as the recipient\'s email address being invalid.', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wp-mail-smtp-product-education__row wp-mail-smtp-product-education__row--inactive">
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-alert">
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-content section-heading">
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<h3><?php esc_html_e( 'Email', 'wp-mail-smtp' ); ?></h3>
|
||||
<p class="desc"><?php esc_html_e( 'Enter the email addresses (3 max) you’d like to use to receive alerts when email sending fails. Read our documentation on setting up email alerts.', 'wp-mail-smtp' ); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-checkbox-toggle">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label><?php esc_html_e( 'Email Alerts', 'wp-mail-smtp' ); ?></label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<?php
|
||||
UI::toggle();
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-alert-options">
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-alert-connection-options">
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-text">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label><?php esc_html_e( 'Send To', 'wp-mail-smtp' ); ?></label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field"><input type="text"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-alert">
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-content section-heading">
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<h3><?php esc_html_e( 'Slack', 'wp-mail-smtp' ); ?></h3>
|
||||
<p class="desc"><?php esc_html_e( 'Paste in the Slack webhook URL you’d like to use to receive alerts when email sending fails. Read our documentation on setting up Slack alerts.', 'wp-mail-smtp' ); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-checkbox-toggle">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label><?php esc_html_e( 'Slack Alerts', 'wp-mail-smtp' ); ?></label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<?php
|
||||
UI::toggle();
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-alert-options">
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-alert-connection-options">
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-text">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label><?php esc_html_e( 'Webhook URL', 'wp-mail-smtp' ); ?></label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field"><input type="text"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-alert">
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-content section-heading">
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<h3><?php esc_html_e( 'SMS via Twilio', 'wp-mail-smtp' ); ?></h3>
|
||||
<p class="desc"><?php esc_html_e( 'To receive SMS alerts, you’ll need a Twilio account. Read our documentation to learn how to set up Twilio SMS, then enter your connection details below.', 'wp-mail-smtp' ); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-checkbox-toggle">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label><?php esc_html_e( 'SMS via Twilio Alerts', 'wp-mail-smtp' ); ?></label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<?php
|
||||
UI::toggle();
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-alert-options">
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-alert-connection-options">
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-text">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label><?php esc_html_e( 'Twilio Account ID', 'wp-mail-smtp' ); ?></label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field"><input type="text"></div>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-text">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label><?php esc_html_e( 'Twilio Auth Token', 'wp-mail-smtp' ); ?></label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field"><input type="text"></div>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-text">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label><?php esc_html_e( 'From Phone Number', 'wp-mail-smtp' ); ?></label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field"><input type="text"></div>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-text">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label><?php esc_html_e( 'To Phone Number', 'wp-mail-smtp' ); ?></label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field"><input type="text"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-alert">
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-content section-heading">
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<h3><?php esc_html_e( 'Webhook', 'wp-mail-smtp' ); ?></h3>
|
||||
<p class="desc"><?php esc_html_e( 'Paste in the webhook URL you’d like to use to receive alerts when email sending fails. Read our documentation on setting up webhook alerts.', 'wp-mail-smtp' ); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-checkbox-toggle">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label><?php esc_html_e( 'Webhook Alerts', 'wp-mail-smtp' ); ?></label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<?php
|
||||
UI::toggle();
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-alert-options">
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-alert-connection-options">
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-text">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label><?php esc_html_e( 'Webhook URL', 'wp-mail-smtp' ); ?></label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field"><input type="text"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a href="<?php echo esc_url( $bottom_upgrade_button_url ); ?>" target="_blank" rel="noopener noreferrer" class="wp-mail-smtp-product-education__upgrade-btn wp-mail-smtp-product-education__upgrade-btn--bottom wp-mail-smtp-btn wp-mail-smtp-btn-upgrade wp-mail-smtp-btn-orange">
|
||||
<?php esc_html_e( 'Upgrade to WP Mail SMTP Pro', 'wp-mail-smtp' ); ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin\Pages;
|
||||
|
||||
use WPMailSMTP\ConnectionInterface;
|
||||
use WPMailSMTP\Providers\AuthAbstract;
|
||||
|
||||
/**
|
||||
* Class AuthTab.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class AuthTab {
|
||||
|
||||
/**
|
||||
* @var string Slug of a tab.
|
||||
*/
|
||||
protected $slug = 'auth';
|
||||
|
||||
/**
|
||||
* Launch mailer specific Auth logic.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function process_auth() {
|
||||
|
||||
$connection = wp_mail_smtp()->get_connections_manager()->get_primary_connection();
|
||||
|
||||
/**
|
||||
* Filters auth connection object.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*
|
||||
* @param ConnectionInterface $connection The Connection object.
|
||||
*/
|
||||
$connection = apply_filters( 'wp_mail_smtp_admin_pages_auth_tab_process_auth_connection', $connection );
|
||||
|
||||
$auth = wp_mail_smtp()->get_providers()->get_auth( $connection->get_mailer_slug(), $connection );
|
||||
|
||||
if (
|
||||
$auth &&
|
||||
$auth instanceof AuthAbstract &&
|
||||
method_exists( $auth, 'process' )
|
||||
) {
|
||||
$auth->process();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return nothing, as we don't need this functionality.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function get_label() {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return nothing, as we don't need this functionality.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function get_title() {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Do nothing, as we don't need this functionality.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function display() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,327 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin\Pages;
|
||||
|
||||
use WPMailSMTP\Admin\PageAbstract;
|
||||
use WPMailSMTP\Helpers\UI;
|
||||
use WPMailSMTP\WP;
|
||||
|
||||
/**
|
||||
* Class ControlTab is a placeholder for Pro Email Control tab settings.
|
||||
* Displays an upsell.
|
||||
*
|
||||
* @since 1.6.0
|
||||
*/
|
||||
class ControlTab extends PageAbstract {
|
||||
|
||||
/**
|
||||
* Slug of a tab.
|
||||
*
|
||||
* @since 1.6.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $slug = 'control';
|
||||
|
||||
/**
|
||||
* Link label of a tab.
|
||||
*
|
||||
* @since 1.6.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_label() {
|
||||
|
||||
return esc_html__( 'Email Controls', 'wp-mail-smtp' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Title of a tab.
|
||||
*
|
||||
* @since 1.6.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_title() {
|
||||
|
||||
return $this->get_label();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of all available emails that we can manage.
|
||||
*
|
||||
* @see https://github.com/johnbillion/wp_mail Apr 12th 2019.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_controls() {
|
||||
|
||||
return [
|
||||
'comments' => [
|
||||
'title' => esc_html__( 'Comments', 'wp-mail-smtp' ),
|
||||
'emails' => [
|
||||
'dis_comments_awaiting_moderation' => [
|
||||
'label' => esc_html__( 'Awaiting Moderation', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'Comment is awaiting moderation. Sent to the site admin and post author if they can edit comments.', 'wp-mail-smtp' ),
|
||||
],
|
||||
'dis_comments_published' => [
|
||||
'label' => esc_html__( 'Published', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'Comment has been published. Sent to the post author.', 'wp-mail-smtp' ),
|
||||
],
|
||||
],
|
||||
],
|
||||
'admin_email' => [
|
||||
'title' => esc_html__( 'Change of Admin Email', 'wp-mail-smtp' ),
|
||||
'emails' => [
|
||||
'dis_admin_email_attempt' => [
|
||||
'label' => esc_html__( 'Site Admin Email Change Attempt', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'Change of site admin email address was attempted. Sent to the proposed new email address.', 'wp-mail-smtp' ),
|
||||
],
|
||||
'dis_admin_email_changed' => [
|
||||
'label' => esc_html__( 'Site Admin Email Changed', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'Site admin email address was changed. Sent to the old site admin email address.', 'wp-mail-smtp' ),
|
||||
],
|
||||
'dis_admin_email_network_attempt' => [
|
||||
'label' => esc_html__( 'Network Admin Email Change Attempt', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'Change of network admin email address was attempted. Sent to the proposed new email address.', 'wp-mail-smtp' ),
|
||||
],
|
||||
'dis_admin_email_network_changed' => [
|
||||
'label' => esc_html__( 'Network Admin Email Changed', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'Network admin email address was changed. Sent to the old network admin email address.', 'wp-mail-smtp' ),
|
||||
],
|
||||
],
|
||||
],
|
||||
'user_details' => [
|
||||
'title' => esc_html__( 'Change of User Email or Password', 'wp-mail-smtp' ),
|
||||
'emails' => [
|
||||
'dis_user_details_password_reset_request' => [
|
||||
'label' => esc_html__( 'Reset Password Request', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'User requested a password reset via "Lost your password?". Sent to the user.', 'wp-mail-smtp' ),
|
||||
],
|
||||
'dis_user_details_password_reset' => [
|
||||
'label' => esc_html__( 'Password Reset Successfully', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'User reset their password from the password reset link. Sent to the site admin.', 'wp-mail-smtp' ),
|
||||
],
|
||||
'dis_user_details_password_changed' => [
|
||||
'label' => esc_html__( 'Password Changed', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'User changed their password. Sent to the user.', 'wp-mail-smtp' ),
|
||||
],
|
||||
'dis_user_details_email_change_attempt' => [
|
||||
'label' => esc_html__( 'Email Change Attempt', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'User attempted to change their email address. Sent to the proposed new email address.', 'wp-mail-smtp' ),
|
||||
],
|
||||
'dis_user_details_email_changed' => [
|
||||
'label' => esc_html__( 'Email Changed', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'User changed their email address. Sent to the user.', 'wp-mail-smtp' ),
|
||||
],
|
||||
],
|
||||
],
|
||||
'personal_data' => [
|
||||
'title' => esc_html__( 'Personal Data Requests', 'wp-mail-smtp' ),
|
||||
'emails' => [
|
||||
'dis_personal_data_user_confirmed' => [
|
||||
'label' => esc_html__( 'User Confirmed Export / Erasure Request', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'User clicked a confirmation link in personal data export or erasure request email. Sent to the site or network admin.', 'wp-mail-smtp' ),
|
||||
],
|
||||
'dis_personal_data_erased_data' => [
|
||||
'label' => esc_html__( 'Admin Erased Data', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'Site admin clicked "Erase Personal Data" button next to a confirmed data erasure request. Sent to the requester email address.', 'wp-mail-smtp' ),
|
||||
],
|
||||
'dis_personal_data_sent_export_link' => [
|
||||
'label' => esc_html__( 'Admin Sent Link to Export Data', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'Site admin clicked "Email Data" button next to a confirmed data export request. Sent to the requester email address.', 'wp-mail-smtp' ) . '<br>' .
|
||||
'<strong>' . esc_html__( 'Disabling this option will block users from being able to export their personal data, as they will not receive an email with a link.', 'wp-mail-smtp' ) . '</strong>',
|
||||
],
|
||||
],
|
||||
],
|
||||
'auto_updates' => [
|
||||
'title' => esc_html__( 'Automatic Updates', 'wp-mail-smtp' ),
|
||||
'emails' => [
|
||||
'dis_auto_updates_plugin_status' => [
|
||||
'label' => esc_html__( 'Plugin Status', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'Completion or failure of a background automatic plugin update. Sent to the site or network admin.', 'wp-mail-smtp' ),
|
||||
],
|
||||
'dis_auto_updates_theme_status' => [
|
||||
'label' => esc_html__( 'Theme Status', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'Completion or failure of a background automatic theme update. Sent to the site or network admin.', 'wp-mail-smtp' ),
|
||||
],
|
||||
'dis_auto_updates_status' => [
|
||||
'label' => esc_html__( 'WP Core Status', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'Completion or failure of a background automatic core update. Sent to the site or network admin.', 'wp-mail-smtp' ),
|
||||
],
|
||||
'dis_auto_updates_full_log' => [
|
||||
'label' => esc_html__( 'Full Log', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'Full log of background update results which includes information about WordPress core, plugins, themes, and translations updates. Only sent when you are using a development version of WordPress. Sent to the site or network admin.', 'wp-mail-smtp' ),
|
||||
],
|
||||
],
|
||||
],
|
||||
'new_user' => [
|
||||
'title' => esc_html__( 'New User', 'wp-mail-smtp' ),
|
||||
'emails' => [
|
||||
'dis_new_user_created_to_admin' => [
|
||||
'label' => esc_html__( 'Created (Admin)', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'A new user was created. Sent to the site admin.', 'wp-mail-smtp' ),
|
||||
],
|
||||
'dis_new_user_created_to_user' => [
|
||||
'label' => esc_html__( 'Created (User)', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'A new user was created. Sent to the new user.', 'wp-mail-smtp' ),
|
||||
],
|
||||
'dis_new_user_invited_to_site_network' => [
|
||||
'label' => esc_html__( 'Invited To Site', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'A new user was invited to a site from Users -> Add New -> Add New User. Sent to the invited user.', 'wp-mail-smtp' ),
|
||||
],
|
||||
'dis_new_user_created_network' => [
|
||||
'label' => esc_html__( 'Created On Site', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'A new user account was created. Sent to Network Admin.', 'wp-mail-smtp' ),
|
||||
],
|
||||
'dis_new_user_added_activated_network' => [
|
||||
'label' => esc_html__( 'Added / Activated on Site', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'A user has been added, or their account activation has been successful. Sent to the user, that has been added/activated.', 'wp-mail-smtp' ),
|
||||
],
|
||||
],
|
||||
],
|
||||
'network_new_site' => [
|
||||
'title' => esc_html__( 'New Site', 'wp-mail-smtp' ),
|
||||
'emails' => [
|
||||
'dis_new_site_user_registered_site_network' => [
|
||||
'label' => esc_html__( 'User Created Site', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'User registered for a new site. Sent to the site admin.', 'wp-mail-smtp' ),
|
||||
],
|
||||
'dis_new_site_user_added_activated_site_in_network_to_admin' => [
|
||||
'label' => esc_html__( 'Network Admin: User Activated / Added Site', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'User activated their new site, or site was added from Network Admin -> Sites -> Add New. Sent to Network Admin.', 'wp-mail-smtp' ),
|
||||
],
|
||||
'dis_new_site_user_added_activated_site_in_network_to_site' => [
|
||||
'label' => esc_html__( 'Site Admin: Activated / Added Site', 'wp-mail-smtp' ),
|
||||
'desc' => esc_html__( 'User activated their new site, or site was added from Network Admin -> Sites -> Add New. Sent to Site Admin.', 'wp-mail-smtp' ),
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Output HTML of the email controls settings preview.
|
||||
*
|
||||
* @since 1.6.0
|
||||
* @since 2.1.0 Replaced images with SVGs.
|
||||
* @since 3.1.0 Updated layout to inactive settings preview.
|
||||
*/
|
||||
public function display() { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh
|
||||
|
||||
$top_upgrade_button_url = add_query_arg(
|
||||
[ 'discount' => 'LITEUPGRADE' ],
|
||||
wp_mail_smtp()->get_upgrade_link(
|
||||
[
|
||||
'medium' => 'Email Controls',
|
||||
'content' => 'Upgrade to WP Mail SMTP Pro Button Top',
|
||||
]
|
||||
)
|
||||
);
|
||||
$bottom_upgrade_button_url = add_query_arg(
|
||||
[ 'discount' => 'LITEUPGRADE' ],
|
||||
wp_mail_smtp()->get_upgrade_link(
|
||||
[
|
||||
'medium' => 'Email Controls',
|
||||
'content' => 'Upgrade to WP Mail SMTP Pro Button',
|
||||
]
|
||||
)
|
||||
);
|
||||
?>
|
||||
|
||||
<div id="wp-mail-smtp-email-controls-product-education" class="wp-mail-smtp-product-education">
|
||||
<div class="wp-mail-smtp-product-education__row">
|
||||
<h4 class="wp-mail-smtp-product-education__heading">
|
||||
<?php esc_html_e( 'Email Controls', 'wp-mail-smtp' ); ?>
|
||||
</h4>
|
||||
<p class="wp-mail-smtp-product-education__description">
|
||||
<?php
|
||||
esc_html_e( 'Email controls allow you to manage the automatic notifications you receive from your WordPress website. With the flick of a switch, you can reduce inbox clutter and focus on the alerts that matter the most. It\'s easy to disable emails about comments, email or password changes, WordPress updates, user registrations, and personal data requests.', 'wp-mail-smtp' );
|
||||
?>
|
||||
</p>
|
||||
|
||||
<a href="<?php echo esc_url( $top_upgrade_button_url ); ?>" target="_blank" rel="noopener noreferrer" class="wp-mail-smtp-product-education__upgrade-btn wp-mail-smtp-product-education__upgrade-btn--top wp-mail-smtp-btn wp-mail-smtp-btn-upgrade wp-mail-smtp-btn-orange">
|
||||
<?php esc_html_e( 'Upgrade to WP Mail SMTP Pro', 'wp-mail-smtp' ); ?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="wp-mail-smtp-product-education__row wp-mail-smtp-product-education__row--inactive">
|
||||
<?php
|
||||
foreach ( static::get_controls() as $section_id => $section ) :
|
||||
if ( empty( $section['emails'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( $this->is_it_for_multisite( sanitize_key( $section_id ) ) && ! WP::use_global_plugin_settings() ) {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-content wp-mail-smtp-clear section-heading no-desc">
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<h5><?php echo esc_html( $section['title'] ); ?></h5>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
foreach ( $section['emails'] as $email_id => $email ) :
|
||||
$email_id = sanitize_key( $email_id );
|
||||
|
||||
if ( empty( $email_id ) || empty( $email['label'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( $this->is_it_for_multisite( sanitize_key( $email_id ) ) && ! WP::use_global_plugin_settings() ) {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-checkbox-toggle wp-mail-smtp-clear">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label><?php echo esc_html( $email['label'] ); ?></label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<?php
|
||||
UI::toggle( [ 'checked' => true ] );
|
||||
?>
|
||||
<?php if ( ! empty( $email['desc'] ) ) : ?>
|
||||
<p class="desc">
|
||||
<?php echo $email['desc']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<a href="<?php echo esc_url( $bottom_upgrade_button_url ); ?>" target="_blank" rel="noopener noreferrer" class="wp-mail-smtp-product-education__upgrade-btn wp-mail-smtp-product-education__upgrade-btn--bottom wp-mail-smtp-btn wp-mail-smtp-btn-upgrade wp-mail-smtp-btn-orange">
|
||||
<?php esc_html_e( 'Upgrade to WP Mail SMTP Pro', 'wp-mail-smtp' ); ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this key dedicated to MultiSite environment.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @param string $key Email unique key.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function is_it_for_multisite( $key ) {
|
||||
|
||||
return strpos( $key, 'network' ) !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Not used as we display an upsell.
|
||||
*
|
||||
* @since 1.6.0
|
||||
*
|
||||
* @param array $data Post data specific for the plugin.
|
||||
*/
|
||||
public function process_post( $data ) { }
|
||||
}
|
||||
@@ -0,0 +1,561 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin\Pages;
|
||||
|
||||
use WPMailSMTP\Admin\Area;
|
||||
use WPMailSMTP\Admin\DebugEvents\DebugEvents;
|
||||
use WPMailSMTP\Admin\DebugEvents\Migration;
|
||||
use WPMailSMTP\Admin\DebugEvents\Table;
|
||||
use WPMailSMTP\Admin\PageAbstract;
|
||||
use WPMailSMTP\Admin\ParentPageAbstract;
|
||||
use WPMailSMTP\Helpers\UI;
|
||||
use WPMailSMTP\Options;
|
||||
use WPMailSMTP\WP;
|
||||
|
||||
/**
|
||||
* Debug Events settings page.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
class DebugEventsTab extends PageAbstract {
|
||||
|
||||
/**
|
||||
* Part of the slug of a tab.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $slug = 'debug-events';
|
||||
|
||||
/**
|
||||
* Tab priority.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $priority = 40;
|
||||
|
||||
/**
|
||||
* Debug events list table.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @var Table
|
||||
*/
|
||||
protected $table = null;
|
||||
|
||||
/**
|
||||
* Plugin options.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @var Options
|
||||
*/
|
||||
protected $options;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param ParentPageAbstract $parent_page Tab parent page.
|
||||
*/
|
||||
public function __construct( $parent_page = null ) {
|
||||
|
||||
$this->options = Options::init();
|
||||
|
||||
parent::__construct( $parent_page );
|
||||
|
||||
// Remove unnecessary $_GET parameters and prevent url duplications in _wp_http_referer input.
|
||||
$this->remove_get_parameters();
|
||||
}
|
||||
|
||||
/**
|
||||
* Link label of a tab.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_label() {
|
||||
|
||||
return esc_html__( 'Debug Events', 'wp-mail-smtp' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Title of a tab.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_title() {
|
||||
|
||||
return $this->get_label();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register hooks.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function hooks() {
|
||||
|
||||
add_action( 'wp_mail_smtp_admin_area_enqueue_assets', [ $this, 'enqueue_assets' ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue required JS and CSS.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function enqueue_assets() {
|
||||
|
||||
$min = WP::asset_min();
|
||||
|
||||
wp_enqueue_style(
|
||||
'wp-mail-smtp-flatpickr',
|
||||
wp_mail_smtp()->assets_url . '/css/vendor/flatpickr.min.css',
|
||||
[],
|
||||
'4.6.9'
|
||||
);
|
||||
wp_enqueue_script(
|
||||
'wp-mail-smtp-flatpickr',
|
||||
wp_mail_smtp()->assets_url . '/js/vendor/flatpickr.min.js',
|
||||
[ 'jquery' ],
|
||||
'4.6.9',
|
||||
true
|
||||
);
|
||||
|
||||
wp_enqueue_script(
|
||||
'wp-mail-smtp-tools-debug-events',
|
||||
wp_mail_smtp()->assets_url . "/js/smtp-tools-debug-events{$min}.js",
|
||||
[ 'jquery', 'wp-mail-smtp-flatpickr' ],
|
||||
WPMS_PLUGIN_VER,
|
||||
true
|
||||
);
|
||||
|
||||
wp_localize_script(
|
||||
'wp-mail-smtp-tools-debug-events',
|
||||
'wp_mail_smtp_tools_debug_events',
|
||||
[
|
||||
'lang_code' => sanitize_key( WP::get_language_code() ),
|
||||
'plugin_url' => wp_mail_smtp()->plugin_url,
|
||||
'loader' => wp_mail_smtp()->prepare_loader( 'blue' ),
|
||||
'texts' => [
|
||||
'delete_all_notice' => esc_html__( 'Are you sure you want to permanently delete all debug events?', 'wp-mail-smtp' ),
|
||||
'cancel' => esc_html__( 'Cancel', 'wp-mail-smtp' ),
|
||||
'close' => esc_html__( 'Close', 'wp-mail-smtp' ),
|
||||
'yes' => esc_html__( 'Yes', 'wp-mail-smtp' ),
|
||||
'ok' => esc_html__( 'OK', 'wp-mail-smtp' ),
|
||||
'notice_title' => esc_html__( 'Heads up!', 'wp-mail-smtp' ),
|
||||
'error_occurred' => esc_html__( 'An error occurred!', 'wp-mail-smtp' ),
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email logs list table.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return Table
|
||||
*/
|
||||
public function get_table() {
|
||||
|
||||
if ( $this->table === null ) {
|
||||
$this->table = new Table();
|
||||
}
|
||||
|
||||
return $this->table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display scheduled actions table.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function display() {
|
||||
|
||||
?>
|
||||
<?php if( WP::use_global_plugin_settings() && ! current_user_can( 'manage_network_options' ) ) : ?>
|
||||
<!-- Debug Events Section Title -->
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-content wp-mail-smtp-clear section-heading" id="wp-mail-smtp-setting-row-email-heading">
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<h2><?php esc_html_e( 'Debug Events', 'wp-mail-smtp' ); ?></h2>
|
||||
</div>
|
||||
<p>
|
||||
<?php esc_html_e( 'On this page, you can view different plugin debugging events and email sending errors.', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<form method="POST" action="<?php echo esc_url( $this->get_link() ); ?>">
|
||||
<?php $this->wp_nonce_field(); ?>
|
||||
|
||||
<!-- Debug Events Section Title -->
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-content wp-mail-smtp-clear section-heading wp-mail-smtp-section-heading--has-divider">
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<h2><?php esc_html_e( 'Debug Events', 'wp-mail-smtp' ); ?></h2>
|
||||
</div>
|
||||
<p>
|
||||
<?php esc_html_e( 'On this page, you can view and configure different plugin debugging events. View email sending errors and enable debugging events, allowing you to detect email sending issues.', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- Debug Events -->
|
||||
<div id="wp-mail-smtp-setting-row-debug_event_types" class="wp-mail-smtp-setting-row wp-mail-smtp-clear">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label for="wp-mail-smtp-setting-debug_event_types">
|
||||
<?php esc_html_e( 'Event Types', 'wp-mail-smtp' ); ?>
|
||||
</label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<?php
|
||||
UI::toggle(
|
||||
[
|
||||
'name' => 'wp-mail-smtp[debug_events][email_errors]',
|
||||
'id' => 'wp-mail-smtp-setting-debug_events_email_errors',
|
||||
'value' => 'true',
|
||||
'checked' => true,
|
||||
'disabled' => true,
|
||||
]
|
||||
);
|
||||
?>
|
||||
<p class="desc">
|
||||
<?php esc_html_e( 'Email Sending Errors', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
<p class="desc">
|
||||
<?php esc_html_e( 'This debug event is always enabled and will record any email sending errors in the table below.', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
<hr class="wp-mail-smtp-setting-mid-row-sep">
|
||||
<?php
|
||||
UI::toggle(
|
||||
[
|
||||
'name' => 'wp-mail-smtp[debug_events][email_debug]',
|
||||
'id' => 'wp-mail-smtp-setting-debug_events_email_debug',
|
||||
'value' => 'true',
|
||||
'checked' => (bool) $this->options->get( 'debug_events', 'email_debug' ),
|
||||
]
|
||||
);
|
||||
?>
|
||||
<p class="desc">
|
||||
<?php esc_html_e( 'Debug Email Sending', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
<p class="desc">
|
||||
<?php esc_html_e( 'Check this if you would like to debug the email sending process. Once enabled, all debug events will be logged in the table below. This setting should only be enabled for shorter debugging periods and disabled afterwards.', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wp-mail-smtp-setting-row-debug_events_retention_period" class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-select wp-mail-smtp-clear">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label for="wp-mail-smtp-setting-debug_events_retention_period">
|
||||
<?php esc_html_e( 'Events Retention Period', 'wp-mail-smtp' ); ?>
|
||||
</label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<select name="wp-mail-smtp[debug_events][retention_period]" id="wp-mail-smtp-setting-debug_events_retention_period"
|
||||
<?php disabled( $this->options->is_const_defined( 'debug_events', 'retention_period' ) ); ?>>
|
||||
<option value=""><?php esc_html_e( 'Forever', 'wp-mail-smtp' ); ?></option>
|
||||
<?php foreach ( $this->get_debug_events_retention_period_options() as $value => $label ) : ?>
|
||||
<option value="<?php echo esc_attr( $value ); ?>" <?php selected( $this->options->get( 'debug_events', 'retention_period' ), $value ); ?>>
|
||||
<?php echo esc_html( $label ); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<p class="desc">
|
||||
<?php
|
||||
esc_html_e( 'Debug events older than the selected period will be permanently deleted from the database.', 'wp-mail-smtp' );
|
||||
|
||||
if ( $this->options->is_const_defined( 'debug_events', 'retention_period' ) ) {
|
||||
//phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo '<br>' . $this->options->get_const_set_message( 'WPMS_DEBUG_EVENTS_RETENTION_PERIOD' );
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php $this->display_save_btn(); ?>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
|
||||
if ( ! DebugEvents::is_valid_db() ) {
|
||||
$this->display_debug_events_not_installed();
|
||||
} else {
|
||||
$table = $this->get_table();
|
||||
$table->prepare_items();
|
||||
|
||||
?>
|
||||
<form action="<?php echo esc_url( $this->get_link() ); ?>" method="get">
|
||||
<input type="hidden" name="page" value="<?php echo esc_attr( Area::SLUG . '-tools' ); ?>" />
|
||||
<input type="hidden" name="tab" value="<?php echo esc_attr( $this->get_slug() ); ?>" />
|
||||
<?php
|
||||
|
||||
// State of status filter for submission with other filters.
|
||||
if ( $table->get_filtered_types() !== false ) {
|
||||
printf( '<input type="hidden" name="type" value="%s">', esc_attr( $table->get_filtered_types() ) );
|
||||
}
|
||||
|
||||
if ( $this->get_filters_html() ) {
|
||||
?>
|
||||
<div id="wp-mail-smtp-reset-filter">
|
||||
<?php
|
||||
$type = $table->get_filtered_types();
|
||||
|
||||
echo wp_kses(
|
||||
sprintf( /* translators: %1$s - number of debug events found; %2$s - filtered type. */
|
||||
_n(
|
||||
'Found <strong>%1$s %2$s event</strong>',
|
||||
'Found <strong>%1$s %2$s events</strong>',
|
||||
absint( $table->get_pagination_arg( 'total_items' ) ),
|
||||
'wp-mail-smtp'
|
||||
),
|
||||
absint( $table->get_pagination_arg( 'total_items' ) ),
|
||||
$type !== false && isset( $table->get_types()[ $type ] ) ? $table->get_types()[ $type ] : ''
|
||||
),
|
||||
[
|
||||
'strong' => [],
|
||||
]
|
||||
);
|
||||
?>
|
||||
|
||||
<?php foreach ( $this->get_filters_html() as $id => $html ) : ?>
|
||||
<?php
|
||||
echo wp_kses(
|
||||
$html,
|
||||
[ 'em' => [] ]
|
||||
);
|
||||
?>
|
||||
<i class="reset dashicons dashicons-dismiss" data-scope="<?php echo esc_attr( $id ); ?>"></i>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
$table->search_box(
|
||||
esc_html__( 'Search Events', 'wp-mail-smtp' ),
|
||||
Area::SLUG . '-debug-events-search-input'
|
||||
);
|
||||
|
||||
$table->views();
|
||||
$table->display();
|
||||
?>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process tab form submission ($_POST ).
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param array $data Post data specific for the plugin.
|
||||
*/
|
||||
public function process_post( $data ) {
|
||||
|
||||
$this->check_admin_referer();
|
||||
|
||||
if ( WP::use_global_plugin_settings() && ! current_user_can( 'manage_network_options' ) ) {
|
||||
wp_die( esc_html__( 'You don\'t have the capability to perform this action.', 'wp-mail-smtp' ) );
|
||||
}
|
||||
|
||||
// Unchecked checkboxes doesn't exist in $_POST, so we need to ensure we actually have them in data to save.
|
||||
if ( empty( $data['debug_events']['email_debug'] ) ) {
|
||||
$data['debug_events']['email_debug'] = false;
|
||||
}
|
||||
|
||||
// All the sanitization is done there.
|
||||
$this->options->set( $data, false, false );
|
||||
|
||||
WP::add_admin_notice(
|
||||
esc_html__( 'Settings were successfully saved.', 'wp-mail-smtp' ),
|
||||
WP::ADMIN_NOTICE_SUCCESS
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array with information (HTML and id) for each filter for this current view.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function get_filters_html() {
|
||||
|
||||
$filters = [
|
||||
'.search-box' => $this->get_filter_search_html(),
|
||||
'.wp-mail-smtp-filter-date' => $this->get_filter_date_html(),
|
||||
];
|
||||
|
||||
return array_filter( $filters );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return HTML with information about the search filter.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function get_filter_search_html() {
|
||||
|
||||
$table = $this->get_table();
|
||||
$term = $table->get_filtered_search();
|
||||
|
||||
if ( $term === false ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return sprintf( /* translators: %s The searched term. */
|
||||
__( 'where event contains "%s"', 'wp-mail-smtp' ),
|
||||
'<em>' . esc_html( $term ) . '</em>'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return HTML with information about the date filter.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function get_filter_date_html() {
|
||||
|
||||
$table = $this->get_table();
|
||||
$dates = $table->get_filtered_dates();
|
||||
|
||||
if ( $dates === false ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$dates = array_map(
|
||||
function ( $date ) {
|
||||
return date_i18n( 'M j, Y', strtotime( $date ) );
|
||||
},
|
||||
$dates
|
||||
);
|
||||
|
||||
$html = '';
|
||||
|
||||
switch ( count( $dates ) ) {
|
||||
case 1:
|
||||
$html = sprintf( /* translators: %s - Date. */
|
||||
esc_html__( 'on %s', 'wp-mail-smtp' ),
|
||||
'<em>' . $dates[0] . '</em>'
|
||||
);
|
||||
break;
|
||||
case 2:
|
||||
$html = sprintf( /* translators: %1$s - Date. %2$s - Date. */
|
||||
esc_html__( 'between %1$s and %2$s', 'wp-mail-smtp' ),
|
||||
'<em>' . $dates[0] . '</em>',
|
||||
'<em>' . $dates[1] . '</em>'
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a message when debug events DB table is missing.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
private function display_debug_events_not_installed() {
|
||||
|
||||
$error_message = get_option( Migration::ERROR_OPTION_NAME );
|
||||
?>
|
||||
|
||||
<div class="notice-inline notice-error">
|
||||
<h3><?php esc_html_e( 'Debug Events are Not Installed Correctly', 'wp-mail-smtp' ); ?></h3>
|
||||
|
||||
<p>
|
||||
<?php
|
||||
if ( ! empty( $error_message ) ) {
|
||||
esc_html_e( 'The database table was not installed correctly. Please contact plugin support to diagnose and fix the issue. Provide them the error message below:', 'wp-mail-smtp' );
|
||||
echo '<br><br>';
|
||||
echo '<code>' . esc_html( $error_message ) . '</code>';
|
||||
} else {
|
||||
esc_html_e( 'For some reason the database table was not installed correctly. Please contact plugin support team to diagnose and fix the issue.', 'wp-mail-smtp' );
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove unnecessary $_GET parameters for shorter URL.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
protected function remove_get_parameters() {
|
||||
|
||||
if ( isset( $_SERVER['REQUEST_URI'] ) ) {
|
||||
$_SERVER['REQUEST_URI'] = remove_query_arg(
|
||||
[
|
||||
'_wp_http_referer',
|
||||
'_wpnonce',
|
||||
'wp-mail-smtp-debug-events-nonce',
|
||||
],
|
||||
$_SERVER['REQUEST_URI'] // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get debug events retention period options.
|
||||
*
|
||||
* @since 3.6.0
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_debug_events_retention_period_options() {
|
||||
|
||||
$options = [
|
||||
604800 => esc_html__( '1 Week', 'wp-mail-smtp' ),
|
||||
2628000 => esc_html__( '1 Month', 'wp-mail-smtp' ),
|
||||
7885000 => esc_html__( '3 Months', 'wp-mail-smtp' ),
|
||||
15770000 => esc_html__( '6 Months', 'wp-mail-smtp' ),
|
||||
31540000 => esc_html__( '1 Year', 'wp-mail-smtp' ),
|
||||
];
|
||||
|
||||
$debug_event_retention_period = $this->options->get( 'debug_events', 'retention_period' );
|
||||
|
||||
// Check if defined value already in list and add it if not.
|
||||
if (
|
||||
! empty( $debug_event_retention_period ) &&
|
||||
! isset( $options[ $debug_event_retention_period ] )
|
||||
) {
|
||||
$debug_event_retention_period_days = floor( $debug_event_retention_period / DAY_IN_SECONDS );
|
||||
|
||||
$options[ $debug_event_retention_period ] = sprintf(
|
||||
/* translators: %d - days count. */
|
||||
_n( '%d Day', '%d Days', $debug_event_retention_period_days, 'wp-mail-smtp' ),
|
||||
$debug_event_retention_period_days
|
||||
);
|
||||
|
||||
ksort( $options );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter debug events retention period options.
|
||||
*
|
||||
* @since 3.6.0
|
||||
*
|
||||
* @param array $options Debug Events retention period options.
|
||||
* Option key in seconds.
|
||||
*/
|
||||
return apply_filters(
|
||||
'wp_mail_smtp_admin_pages_debug_events_tab_get_debug_events_retention_period_options',
|
||||
$options
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin\Pages;
|
||||
|
||||
use WPMailSMTP\Admin\ParentPageAbstract;
|
||||
|
||||
/**
|
||||
* Class EmailReports.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
class EmailReports extends ParentPageAbstract {
|
||||
|
||||
/**
|
||||
* Page default tab slug.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $default_tab = 'reports';
|
||||
|
||||
/**
|
||||
* Slug of a page.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $slug = 'reports';
|
||||
|
||||
/**
|
||||
* Link label of a page.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_label() {
|
||||
|
||||
return esc_html__( 'Email Reports', 'wp-mail-smtp' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Title of a page.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_title() {
|
||||
|
||||
return $this->get_label();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin\Pages;
|
||||
|
||||
use WPMailSMTP\Admin\PageAbstract;
|
||||
|
||||
/**
|
||||
* Class EmailTrackingReportsTab is a placeholder for Pro email tracking reports.
|
||||
* Displays product education.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
class EmailReportsTab extends PageAbstract {
|
||||
|
||||
/**
|
||||
* Part of the slug of a tab.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $slug = 'reports';
|
||||
|
||||
/**
|
||||
* Tab priority.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $priority = 10;
|
||||
|
||||
/**
|
||||
* Link label of a tab.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_label() {
|
||||
|
||||
return esc_html__( 'Email Reports', 'wp-mail-smtp' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Title of a tab.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_title() {
|
||||
|
||||
return $this->get_label();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register hooks.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function hooks() {
|
||||
|
||||
add_action( 'wp_mail_smtp_admin_area_enqueue_assets', [ $this, 'enqueue_assets' ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue required JS and CSS.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function enqueue_assets() {
|
||||
|
||||
wp_enqueue_style(
|
||||
'wp-mail-smtp-admin-lity',
|
||||
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 . '/js/vendor/lity.min.js',
|
||||
[],
|
||||
'2.4.1',
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Output HTML of the email reports education.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function display() {
|
||||
|
||||
$top_upgrade_button_url = wp_mail_smtp()->get_upgrade_link(
|
||||
[
|
||||
'medium' => 'email-reports',
|
||||
'content' => 'upgrade-to-wp-mail-smtp-pro-button-link-top',
|
||||
]
|
||||
);
|
||||
$bottom_upgrade_button_url = wp_mail_smtp()->get_upgrade_link(
|
||||
[
|
||||
'medium' => 'email-reports',
|
||||
'content' => 'upgrade-to-wp-mail-smtp-pro-button-link',
|
||||
]
|
||||
);
|
||||
|
||||
$assets_url = wp_mail_smtp()->assets_url . '/images/email-reports/';
|
||||
$screenshots = [
|
||||
[
|
||||
'url' => $assets_url . 'screenshot-01.png',
|
||||
'url_thumbnail' => $assets_url . 'thumbnail-01.png',
|
||||
'title' => __( 'Stats at a Glance', 'wp-mail-smtp' ),
|
||||
],
|
||||
[
|
||||
'url' => $assets_url . 'screenshot-02.png',
|
||||
'url_thumbnail' => $assets_url . 'thumbnail-02.png',
|
||||
'title' => __( 'Detailed Stats by Subject Line', 'wp-mail-smtp' ),
|
||||
],
|
||||
[
|
||||
'url' => $assets_url . 'screenshot-03.png',
|
||||
'url_thumbnail' => $assets_url . 'thumbnail-03.png',
|
||||
'title' => __( 'Weekly Email Report', 'wp-mail-smtp' ),
|
||||
],
|
||||
];
|
||||
?>
|
||||
<div id="wp-mail-smtp-email-reports-product-education" class="wp-mail-smtp-product-education">
|
||||
<div class="wp-mail-smtp-product-education__row">
|
||||
<p class="wp-mail-smtp-product-education__description">
|
||||
<?php
|
||||
esc_html_e( 'Email reports make it easy to track deliverability and engagement at-a-glance. Your open and click-through rates are grouped by subject line, making it easy to review the performance of campaigns or notifications. The report also displays Sent and Failed emails each week so you spot any issues quickly. When you upgrade, we\'ll also add an email report chart right in your WordPress dashboard.', 'wp-mail-smtp' );
|
||||
?>
|
||||
</p>
|
||||
|
||||
<a href="<?php echo esc_url( $top_upgrade_button_url ); ?>" target="_blank" rel="noopener noreferrer" class="wp-mail-smtp-product-education__upgrade-btn wp-mail-smtp-product-education__upgrade-btn--top wp-mail-smtp-btn wp-mail-smtp-btn-upgrade wp-mail-smtp-btn-orange">
|
||||
<?php esc_html_e( 'Upgrade to WP Mail SMTP Pro', 'wp-mail-smtp' ); ?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="wp-mail-smtp-product-education__row">
|
||||
<div class="wp-mail-smtp-product-education__screenshots wp-mail-smtp-product-education__screenshots--three">
|
||||
<?php foreach ( $screenshots as $screenshot ) : ?>
|
||||
<div>
|
||||
<a href="<?php echo esc_url( $screenshot['url'] ); ?>" data-lity data-lity-desc="<?php echo esc_attr( $screenshot['title'] ); ?>">
|
||||
<img src="<?php echo esc_url( $screenshot['url_thumbnail'] ); ?>" alt="<?php esc_attr( $screenshot['title'] ); ?>">
|
||||
</a>
|
||||
<span><?php echo esc_html( $screenshot['title'] ); ?></span>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wp-mail-smtp-product-education__row">
|
||||
<div class="wp-mail-smtp-product-education__list">
|
||||
<h4><?php esc_html_e( 'Unlock these awesome reporting features:', 'wp-mail-smtp' ); ?></h4>
|
||||
<div>
|
||||
<ul>
|
||||
<li><?php esc_html_e( 'Get weekly deliverability reports', 'wp-mail-smtp' ); ?></li>
|
||||
<li><?php esc_html_e( 'View stats grouped by subject line', 'wp-mail-smtp' ); ?></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><?php esc_html_e( 'Track total emails sent each week', 'wp-mail-smtp' ); ?></li>
|
||||
<li><?php esc_html_e( 'Measure open rate and click through rates', 'wp-mail-smtp' ); ?></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><?php esc_html_e( 'Spot failed emails quickly', 'wp-mail-smtp' ); ?></li>
|
||||
<li><?php esc_html_e( 'See email report graphs in WordPress', 'wp-mail-smtp' ); ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a href="<?php echo esc_url( $bottom_upgrade_button_url ); ?>" target="_blank" rel="noopener noreferrer" class="wp-mail-smtp-product-education__upgrade-btn wp-mail-smtp-product-education__upgrade-btn--bottom wp-mail-smtp-btn wp-mail-smtp-btn-upgrade wp-mail-smtp-btn-orange">
|
||||
<?php esc_html_e( 'Upgrade to WP Mail SMTP Pro', 'wp-mail-smtp' ); ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
151
wp/wp-content/plugins/wp-mail-smtp/src/Admin/Pages/ExportTab.php
Normal file
151
wp/wp-content/plugins/wp-mail-smtp/src/Admin/Pages/ExportTab.php
Normal file
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin\Pages;
|
||||
|
||||
use WPMailSMTP\Admin\PageAbstract;
|
||||
|
||||
/**
|
||||
* Class ExportTab is a placeholder for Pro email logs export.
|
||||
* Displays product education.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*/
|
||||
class ExportTab extends PageAbstract {
|
||||
|
||||
/**
|
||||
* Part of the slug of a tab.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $slug = 'export';
|
||||
|
||||
/**
|
||||
* Tab priority.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $priority = 20;
|
||||
|
||||
/**
|
||||
* Link label of a tab.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_label() {
|
||||
|
||||
return esc_html__( 'Export', 'wp-mail-smtp' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Title of a tab.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_title() {
|
||||
|
||||
return $this->get_label();
|
||||
}
|
||||
|
||||
/**
|
||||
* Output HTML of the email logs export form preview.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*/
|
||||
public function display() {
|
||||
|
||||
$top_upgrade_button_url = wp_mail_smtp()->get_upgrade_link(
|
||||
[
|
||||
'medium' => 'tools-export',
|
||||
'content' => 'upgrade-to-wp-mail-smtp-pro-button-top',
|
||||
]
|
||||
);
|
||||
$bottom_upgrade_button_url = wp_mail_smtp()->get_upgrade_link(
|
||||
[
|
||||
'medium' => 'tools-export',
|
||||
'content' => 'upgrade-to-wp-mail-smtp-pro-button',
|
||||
]
|
||||
);
|
||||
?>
|
||||
<div id="wp-mail-smtp-tools-export-email-logs-product-education" class="wp-mail-smtp-product-education">
|
||||
<div class="wp-mail-smtp-product-education__row">
|
||||
<h4 class="wp-mail-smtp-product-education__heading">
|
||||
<?php esc_html_e( 'Export Email Logs', 'wp-mail-smtp' ); ?>
|
||||
</h4>
|
||||
<p class="wp-mail-smtp-product-education__description">
|
||||
<?php
|
||||
esc_html_e( 'Easily export your logs to CSV or Excel. Filter the logs before you export and only download the data you need. This feature lets you easily create your own deliverability reports. You can also use the data in 3rd party dashboards to track deliverability along with your other website statistics.', 'wp-mail-smtp' );
|
||||
?>
|
||||
</p>
|
||||
|
||||
<a href="<?php echo esc_url( $top_upgrade_button_url ); ?>" target="_blank" rel="noopener noreferrer" class="wp-mail-smtp-product-education__upgrade-btn wp-mail-smtp-product-education__upgrade-btn--top wp-mail-smtp-btn wp-mail-smtp-btn-upgrade wp-mail-smtp-btn-orange">
|
||||
<?php esc_html_e( 'Upgrade to WP Mail SMTP Pro', 'wp-mail-smtp' ); ?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="wp-mail-smtp-product-education__row wp-mail-smtp-product-education__row--inactive">
|
||||
<section class="wp-clearfix">
|
||||
<h5><?php esc_html_e( 'Export Type', 'wp-mail-smtp' ); ?></h5>
|
||||
<label>
|
||||
<input type="radio" checked><?php esc_html_e( 'Export in CSV (.csv)', 'wp-mail-smtp' ); ?>
|
||||
</label>
|
||||
<label>
|
||||
<input type="radio"><?php esc_html_e( 'Export in Microsoft Excel (.xlsx)', 'wp-mail-smtp' ); ?>
|
||||
</label>
|
||||
<label>
|
||||
<input type="radio"><?php esc_html_e( 'Export in EML (.eml)', 'wp-mail-smtp' ); ?>
|
||||
</label>
|
||||
</section>
|
||||
|
||||
<section class="wp-clearfix">
|
||||
<h5><?php esc_html_e( 'Common Information', 'wp-mail-smtp' ); ?></h5>
|
||||
<label><input type="checkbox" checked><?php esc_html_e( 'To Address', 'wp-mail-smtp' ); ?></label>
|
||||
<label><input type="checkbox" checked><?php esc_html_e( 'From Address', 'wp-mail-smtp' ); ?></label>
|
||||
<label><input type="checkbox" checked><?php esc_html_e( 'From Name', 'wp-mail-smtp' ); ?></label>
|
||||
<label><input type="checkbox" checked><?php esc_html_e( 'Subject', 'wp-mail-smtp' ); ?></label>
|
||||
<label><input type="checkbox" checked><?php esc_html_e( 'Body', 'wp-mail-smtp' ); ?></label>
|
||||
<label><input type="checkbox" checked><?php esc_html_e( 'Created Date', 'wp-mail-smtp' ); ?></label>
|
||||
<label><input type="checkbox" checked><?php esc_html_e( 'Number of Attachments', 'wp-mail-smtp' ); ?></label>
|
||||
<label><input type="checkbox" checked><?php esc_html_e( 'Attachments', 'wp-mail-smtp' ); ?></label>
|
||||
</section>
|
||||
|
||||
<section class="wp-clearfix">
|
||||
<h5><?php esc_html_e( 'Additional Information', 'wp-mail-smtp' ); ?></h5>
|
||||
<label><input type="checkbox"><?php esc_html_e( 'Status', 'wp-mail-smtp' ); ?></label>
|
||||
<label><input type="checkbox"><?php esc_html_e( 'Carbon Copy (CC)', 'wp-mail-smtp' ); ?></label>
|
||||
<label><input type="checkbox"><?php esc_html_e( 'Blind Carbon Copy (BCC)', 'wp-mail-smtp' ); ?></label>
|
||||
<label><input type="checkbox"><?php esc_html_e( 'Headers', 'wp-mail-smtp' ); ?></label>
|
||||
<label><input type="checkbox"><?php esc_html_e( 'Mailer', 'wp-mail-smtp' ); ?></label>
|
||||
<label><input type="checkbox"><?php esc_html_e( 'Error Details', 'wp-mail-smtp' ); ?></label>
|
||||
<label><input type="checkbox"><?php esc_html_e( 'Email log ID', 'wp-mail-smtp' ); ?></label>
|
||||
<label><input type="checkbox"><?php esc_html_e( 'Source', 'wp-mail-smtp' ); ?></label>
|
||||
</section>
|
||||
|
||||
<section class="wp-clearfix">
|
||||
<h5><?php esc_html_e( 'Custom Date Range', 'wp-mail-smtp' ); ?></h5>
|
||||
<input type="text" class="wp-mail-smtp-date-selector" placeholder="<?php esc_html_e( 'Select a date range', 'wp-mail-smtp' ); ?>">
|
||||
</section>
|
||||
|
||||
<section class="wp-clearfix">
|
||||
<h5><?php esc_html_e( 'Search', 'wp-mail-smtp' ); ?></h5>
|
||||
<select class="wp-mail-smtp-search-box-field">
|
||||
<option><?php esc_html_e( 'Email Addresses', 'wp-mail-smtp' ); ?></option>
|
||||
</select>
|
||||
<input type="text" class="wp-mail-smtp-search-box-term">
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<a href="<?php echo esc_url( $bottom_upgrade_button_url ); ?>" target="_blank" rel="noopener noreferrer" class="wp-mail-smtp-product-education__upgrade-btn wp-mail-smtp-product-education__upgrade-btn--bottom wp-mail-smtp-btn wp-mail-smtp-btn-upgrade wp-mail-smtp-btn-orange">
|
||||
<?php esc_html_e( 'Upgrade to WP Mail SMTP Pro', 'wp-mail-smtp' ); ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
68
wp/wp-content/plugins/wp-mail-smtp/src/Admin/Pages/Logs.php
Normal file
68
wp/wp-content/plugins/wp-mail-smtp/src/Admin/Pages/Logs.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin\Pages;
|
||||
|
||||
use WPMailSMTP\Admin\Area;
|
||||
use WPMailSMTP\Admin\PageAbstract;
|
||||
use WPMailSMTP\WP;
|
||||
|
||||
/**
|
||||
* Class Logs
|
||||
*/
|
||||
class Logs extends PageAbstract {
|
||||
|
||||
/**
|
||||
* Slug of a page.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $slug = 'logs';
|
||||
|
||||
/**
|
||||
* Get the page/tab link.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @since 2.1.0 Changed the URL to point to the email log settings tab.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_link() {
|
||||
|
||||
return add_query_arg(
|
||||
'tab',
|
||||
$this->slug,
|
||||
WP::admin_url( 'admin.php?page=' . Area::SLUG )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Link label of a tab.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_label() {
|
||||
return esc_html__( 'Email Log', 'wp-mail-smtp' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Title of a tab.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_title() {
|
||||
return $this->get_label();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tab content.
|
||||
*
|
||||
* @since 2.1.0 Moved the display content to the email log settings tab.
|
||||
*/
|
||||
public function display() {}
|
||||
}
|
||||
204
wp/wp-content/plugins/wp-mail-smtp/src/Admin/Pages/LogsTab.php
Normal file
204
wp/wp-content/plugins/wp-mail-smtp/src/Admin/Pages/LogsTab.php
Normal file
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin\Pages;
|
||||
|
||||
use WPMailSMTP\Admin\PageAbstract;
|
||||
use WPMailSMTP\Admin\ParentPageAbstract;
|
||||
|
||||
/**
|
||||
* Class LogsTab is a placeholder for Lite users and redirects them to Email Log page.
|
||||
*
|
||||
* @since 1.6.0
|
||||
*/
|
||||
class LogsTab extends PageAbstract {
|
||||
|
||||
/**
|
||||
* Part of the slug of a tab.
|
||||
*
|
||||
* @since 1.6.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $slug = 'logs';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param ParentPageAbstract $parent_page Tab parent page.
|
||||
*/
|
||||
public function __construct( $parent_page = null ) {
|
||||
|
||||
parent::__construct( $parent_page );
|
||||
|
||||
$current_tab = isset( $_GET['tab'] ) ? sanitize_key( $_GET['tab'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
|
||||
if ( wp_mail_smtp()->get_admin()->is_admin_page() && $current_tab === 'logs' ) {
|
||||
$this->hooks();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Link label of a tab.
|
||||
*
|
||||
* @since 1.6.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_label() {
|
||||
|
||||
return esc_html__( 'Email Log', 'wp-mail-smtp' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Title of a tab.
|
||||
*
|
||||
* @since 1.6.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_title() {
|
||||
|
||||
return $this->get_label();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register hooks.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function hooks() {
|
||||
|
||||
add_action( 'wp_mail_smtp_admin_area_enqueue_assets', [ $this, 'enqueue_assets' ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue required JS and CSS.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function enqueue_assets() {
|
||||
|
||||
wp_enqueue_style(
|
||||
'wp-mail-smtp-admin-lity',
|
||||
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 . '/js/vendor/lity.min.js',
|
||||
[],
|
||||
'2.4.1',
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the upsell content for the Email Log feature.
|
||||
*
|
||||
* @since 1.6.0
|
||||
* @since 2.1.0 Moved the display content from the email log page (WP admin menu "Email Log" page).
|
||||
*/
|
||||
public function display() {
|
||||
|
||||
$top_upgrade_button_url = add_query_arg(
|
||||
[ 'discount' => 'LITEUPGRADE' ],
|
||||
wp_mail_smtp()->get_upgrade_link(
|
||||
[
|
||||
'medium' => 'logs',
|
||||
'content' => 'Upgrade to Pro Button Top',
|
||||
]
|
||||
)
|
||||
);
|
||||
$bottom_upgrade_button_url = add_query_arg(
|
||||
[ 'discount' => 'LITEUPGRADE' ],
|
||||
wp_mail_smtp()->get_upgrade_link(
|
||||
[
|
||||
'medium' => 'logs',
|
||||
'content' => 'Upgrade to Pro Button',
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
$assets_url = wp_mail_smtp()->assets_url . '/images/logs/';
|
||||
$screenshots = [
|
||||
[
|
||||
'url' => $assets_url . 'archive.png',
|
||||
'url_thumbnail' => $assets_url . 'archive-thumbnail.png',
|
||||
'title' => __( 'Email Log Index', 'wp-mail-smtp' ),
|
||||
],
|
||||
[
|
||||
'url' => $assets_url . 'single.png',
|
||||
'url_thumbnail' => $assets_url . 'single-thumbnail.png',
|
||||
'title' => __( 'Individual Email Log', 'wp-mail-smtp' ),
|
||||
],
|
||||
];
|
||||
?>
|
||||
|
||||
<div id="wp-mail-smtp-email-logs-product-education" class="wp-mail-smtp-product-education">
|
||||
<div class="wp-mail-smtp-product-education__row">
|
||||
<h4 class="wp-mail-smtp-product-education__heading">
|
||||
<?php esc_html_e( 'Email Log', 'wp-mail-smtp' ); ?>
|
||||
</h4>
|
||||
<p class="wp-mail-smtp-product-education__description">
|
||||
<?php
|
||||
esc_html_e( 'Email logging makes it easy to save details about all of the emails sent from your WordPress site. You can search and filter the email log to find specific messages and check the color-coded delivery status. Email logging also allows you to resend emails, save attachments, and export your logs in different formats.', 'wp-mail-smtp' );
|
||||
?>
|
||||
</p>
|
||||
|
||||
<a href="<?php echo esc_url( $top_upgrade_button_url ); ?>" target="_blank" rel="noopener noreferrer" class="wp-mail-smtp-product-education__upgrade-btn wp-mail-smtp-product-education__upgrade-btn--top wp-mail-smtp-btn wp-mail-smtp-btn-upgrade wp-mail-smtp-btn-orange">
|
||||
<?php esc_html_e( 'Upgrade to WP Mail SMTP Pro', 'wp-mail-smtp' ); ?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="wp-mail-smtp-product-education__row">
|
||||
<div class="wp-mail-smtp-product-education__screenshots wp-mail-smtp-product-education__screenshots--two">
|
||||
<?php foreach ( $screenshots as $screenshot ) : ?>
|
||||
<div>
|
||||
<a href="<?php echo esc_url( $screenshot['url'] ); ?>" data-lity data-lity-desc="<?php echo esc_attr( $screenshot['title'] ); ?>">
|
||||
<img src="<?php echo esc_url( $screenshot['url_thumbnail'] ); ?>" alt="<?php esc_attr( $screenshot['title'] ); ?>">
|
||||
</a>
|
||||
<span><?php echo esc_html( $screenshot['title'] ); ?></span>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wp-mail-smtp-product-education__row">
|
||||
<div class="wp-mail-smtp-product-education__list">
|
||||
<h4><?php esc_html_e( 'Unlock these awesome logging features:', 'wp-mail-smtp' ); ?></h4>
|
||||
<div>
|
||||
<ul>
|
||||
<li><?php esc_html_e( 'Save detailed email headers', 'wp-mail-smtp' ); ?></li>
|
||||
<li><?php esc_html_e( 'See sent and failed emails', 'wp-mail-smtp' ); ?></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><?php esc_html_e( 'Resend emails and attachments', 'wp-mail-smtp' ); ?></li>
|
||||
<li><?php esc_html_e( 'Track email opens and clicks', 'wp-mail-smtp' ); ?></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><?php esc_html_e( 'Print email logs or save as PDF', 'wp-mail-smtp' ); ?></li>
|
||||
<li><?php esc_html_e( 'Export logs to CSV, XLSX, or EML', 'wp-mail-smtp' ); ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a href="<?php echo esc_url( $bottom_upgrade_button_url ); ?>" target="_blank" rel="noopener noreferrer" class="wp-mail-smtp-product-education__upgrade-btn wp-mail-smtp-product-education__upgrade-btn--bottom wp-mail-smtp-btn wp-mail-smtp-btn-upgrade wp-mail-smtp-btn-orange">
|
||||
<?php esc_html_e( 'Upgrade to WP Mail SMTP Pro', 'wp-mail-smtp' ); ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Not used as we are simply redirecting users.
|
||||
*
|
||||
* @since 1.6.0
|
||||
*
|
||||
* @param array $data Post data specific for the plugin.
|
||||
*/
|
||||
public function process_post( $data ) { }
|
||||
}
|
||||
402
wp/wp-content/plugins/wp-mail-smtp/src/Admin/Pages/MiscTab.php
Normal file
402
wp/wp-content/plugins/wp-mail-smtp/src/Admin/Pages/MiscTab.php
Normal file
@@ -0,0 +1,402 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin\Pages;
|
||||
|
||||
use WPMailSMTP\Admin\Area;
|
||||
use WPMailSMTP\Admin\PageAbstract;
|
||||
use WPMailSMTP\Helpers\UI;
|
||||
use WPMailSMTP\Options;
|
||||
use WPMailSMTP\UsageTracking\UsageTracking;
|
||||
use WPMailSMTP\Reports\Emails\Summary as SummaryReportEmail;
|
||||
use WPMailSMTP\Tasks\Reports\SummaryEmailTask as SummaryReportEmailTask;
|
||||
use WPMailSMTP\WP;
|
||||
|
||||
/**
|
||||
* Class MiscTab is part of Area, displays different plugin-related settings of the plugin (not related to emails).
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class MiscTab extends PageAbstract {
|
||||
|
||||
/**
|
||||
* Slug of a tab.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $slug = 'misc';
|
||||
|
||||
/**
|
||||
* Link label of a tab.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_label() {
|
||||
return esc_html__( 'Misc', 'wp-mail-smtp' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Title of a tab.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_title() {
|
||||
|
||||
return esc_html__( 'Miscellaneous', 'wp-mail-smtp' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Output HTML of the misc settings.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function display() {
|
||||
|
||||
$options = Options::init();
|
||||
?>
|
||||
|
||||
<form method="POST" action="">
|
||||
<?php $this->wp_nonce_field(); ?>
|
||||
|
||||
<!-- Section Title -->
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-content wp-mail-smtp-clear section-heading wp-mail-smtp-section-heading--has-divider no-desc">
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<h2><?php echo $this->get_title(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></h2>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Do not send -->
|
||||
<div id="wp-mail-smtp-setting-row-do_not_send" class="wp-mail-smtp-setting-row wp-mail-smtp-clear">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label for="wp-mail-smtp-setting-do_not_send">
|
||||
<?php esc_html_e( 'Do Not Send', 'wp-mail-smtp' ); ?>
|
||||
</label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<?php
|
||||
UI::toggle(
|
||||
[
|
||||
'name' => 'wp-mail-smtp[general][do_not_send]',
|
||||
'id' => 'wp-mail-smtp-setting-do_not_send',
|
||||
'value' => 'true',
|
||||
'checked' => (bool) $options->get( 'general', 'do_not_send' ),
|
||||
'disabled' => $options->is_const_defined( 'general', 'do_not_send' ),
|
||||
]
|
||||
);
|
||||
?>
|
||||
<p class="desc">
|
||||
<?php esc_html_e( 'Stop sending all emails', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
<p class="desc">
|
||||
<?php
|
||||
printf(
|
||||
wp_kses(
|
||||
__( 'Some plugins, like BuddyPress and Events Manager, are using their own email delivery solutions. By default, this option does not block their emails, as those plugins do not use default <code>wp_mail()</code> function to send emails.', 'wp-mail-smtp' ),
|
||||
[
|
||||
'code' => [],
|
||||
]
|
||||
)
|
||||
);
|
||||
?>
|
||||
<br>
|
||||
<?php esc_html_e( 'You will need to consult with their documentation to switch them to use default WordPress email delivery.', 'wp-mail-smtp' ); ?>
|
||||
<br>
|
||||
<?php esc_html_e( 'Test emails are allowed to be sent, regardless of this option.', 'wp-mail-smtp' ); ?>
|
||||
<br>
|
||||
<?php
|
||||
if ( $options->is_const_defined( 'general', 'do_not_send' ) ) {
|
||||
echo $options->get_const_set_message( 'WPMS_DO_NOT_SEND' ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
} else {
|
||||
printf(
|
||||
wp_kses( /* translators: %s - The URL to the constants support article. */
|
||||
__( 'Please read this <a href="%s" target="_blank" rel="noopener noreferrer">support article</a> if you want to enable this option using constants.', 'wp-mail-smtp' ),
|
||||
[
|
||||
'a' => [
|
||||
'href' => [],
|
||||
'target' => [],
|
||||
'rel' => [],
|
||||
],
|
||||
]
|
||||
),
|
||||
// phpcs:ignore WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
|
||||
esc_url( wp_mail_smtp()->get_utm_url( 'https://wpmailsmtp.com/docs/how-to-secure-smtp-settings-by-using-constants/', [ 'medium' => 'misc-settings', 'content' => 'Do not send setting description - support article' ] ) )
|
||||
);
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Hide Announcements -->
|
||||
<div id="wp-mail-smtp-setting-row-am_notifications_hidden" class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-checkbox-toggle wp-mail-smtp-clear">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label for="wp-mail-smtp-setting-am_notifications_hidden">
|
||||
<?php esc_html_e( 'Hide Announcements', 'wp-mail-smtp' ); ?>
|
||||
</label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<?php
|
||||
UI::toggle(
|
||||
[
|
||||
'name' => 'wp-mail-smtp[general][am_notifications_hidden]',
|
||||
'id' => 'wp-mail-smtp-setting-am_notifications_hidden',
|
||||
'value' => 'true',
|
||||
'checked' => (bool) $options->get( 'general', 'am_notifications_hidden' ),
|
||||
]
|
||||
);
|
||||
?>
|
||||
<p class="desc">
|
||||
<?php esc_html_e( 'Hide plugin announcements and update details.', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Hide Email Delivery Errors -->
|
||||
<div id="wp-mail-smtp-setting-row-email_delivery_errors_hidden"
|
||||
class="wp-mail-smtp-setting-row wp-mail-smtp-clear">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label for="wp-mail-smtp-setting-email_delivery_errors_hidden">
|
||||
<?php esc_html_e( 'Hide Email Delivery Errors', 'wp-mail-smtp' ); ?>
|
||||
</label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<?php
|
||||
$is_hard_disabled = has_filter( 'wp_mail_smtp_admin_is_error_delivery_notice_enabled' ) && ! wp_mail_smtp()->get_admin()->is_error_delivery_notice_enabled();
|
||||
?>
|
||||
<?php
|
||||
UI::toggle(
|
||||
[
|
||||
'name' => 'wp-mail-smtp[general][email_delivery_errors_hidden]',
|
||||
'id' => 'wp-mail-smtp-setting-email_delivery_errors_hidden',
|
||||
'value' => 'true',
|
||||
'checked' => $is_hard_disabled || (bool) $options->get( 'general', 'email_delivery_errors_hidden' ),
|
||||
'disabled' => $is_hard_disabled,
|
||||
]
|
||||
);
|
||||
?>
|
||||
<p class="desc">
|
||||
<?php esc_html_e( 'Hide warnings alerting of email delivery errors.', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
<?php if ( $is_hard_disabled ) : ?>
|
||||
<p class="desc">
|
||||
<?php
|
||||
printf( /* translators: %s - filter that was used to disabled. */
|
||||
esc_html__( 'Email Delivery Errors were disabled using a %s filter.', 'wp-mail-smtp' ),
|
||||
'<code>wp_mail_smtp_admin_is_error_delivery_notice_enabled</code>'
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
<?php else : ?>
|
||||
<p class="desc">
|
||||
<?php
|
||||
echo wp_kses(
|
||||
__( '<strong>This is not recommended</strong> and should only be done for staging or development sites.', 'wp-mail-smtp' ),
|
||||
[
|
||||
'strong' => [],
|
||||
]
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Hide Dashboard Widget -->
|
||||
<div id="wp-mail-smtp-setting-row-dashboard_widget_hidden" class="wp-mail-smtp-setting-row wp-mail-smtp-clear">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label for="wp-mail-smtp-setting-dashboard_widget_hidden">
|
||||
<?php esc_html_e( 'Hide Dashboard Widget', 'wp-mail-smtp' ); ?>
|
||||
</label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<?php
|
||||
UI::toggle(
|
||||
[
|
||||
'name' => 'wp-mail-smtp[general][dashboard_widget_hidden]',
|
||||
'id' => 'wp-mail-smtp-setting-dashboard_widget_hidden',
|
||||
'value' => 'true',
|
||||
'checked' => (bool) $options->get( 'general', 'dashboard_widget_hidden' ),
|
||||
]
|
||||
);
|
||||
?>
|
||||
<p class="desc">
|
||||
<?php esc_html_e( 'Hide the WP Mail SMTP Dashboard Widget.', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ( apply_filters( 'wp_mail_smtp_admin_pages_misc_tab_show_usage_tracking_setting', true ) ) : ?>
|
||||
<!-- Usage Tracking -->
|
||||
<div id="wp-mail-smtp-setting-row-usage-tracking" class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-checkbox-toggle wp-mail-smtp-clear">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label for="wp-mail-smtp-setting-usage-tracking">
|
||||
<?php esc_html_e( 'Allow Usage Tracking', 'wp-mail-smtp' ); ?>
|
||||
</label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<?php
|
||||
UI::toggle(
|
||||
[
|
||||
'name' => 'wp-mail-smtp[general][' . UsageTracking::SETTINGS_SLUG . ']',
|
||||
'id' => 'wp-mail-smtp-setting-usage-tracking',
|
||||
'value' => 'true',
|
||||
'checked' => (bool) $options->get( 'general', UsageTracking::SETTINGS_SLUG ),
|
||||
]
|
||||
);
|
||||
?>
|
||||
<p class="desc">
|
||||
<?php esc_html_e( 'By allowing us to track usage data we can better help you because we know with which WordPress configurations, themes and plugins we should test.', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Summary Report Email -->
|
||||
<div id="wp-mail-smtp-setting-row-summary-report-email" class="wp-mail-smtp-setting-row wp-mail-smtp-clear">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label for="wp-mail-smtp-setting-summary-report-email">
|
||||
<?php esc_html_e( 'Disable Email Summaries', 'wp-mail-smtp' ); ?>
|
||||
</label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<?php
|
||||
UI::toggle(
|
||||
[
|
||||
'name' => 'wp-mail-smtp[general][' . SummaryReportEmail::SETTINGS_SLUG . ']',
|
||||
'id' => 'wp-mail-smtp-setting-summary-report-email',
|
||||
'value' => 'true',
|
||||
'checked' => (bool) SummaryReportEmail::is_disabled(),
|
||||
'disabled' => (
|
||||
$options->is_const_defined( 'general', SummaryReportEmail::SETTINGS_SLUG ) ||
|
||||
( wp_mail_smtp()->is_pro() && empty( Options::init()->get( 'logs', 'enabled' ) ) )
|
||||
),
|
||||
]
|
||||
);
|
||||
?>
|
||||
<p class="desc">
|
||||
<?php esc_html_e( 'Disable Email Summaries weekly delivery.', 'wp-mail-smtp' ); ?>
|
||||
<?php
|
||||
if ( wp_mail_smtp()->is_pro() && empty( Options::init()->get( 'logs', 'enabled' ) ) ) {
|
||||
echo wp_kses(
|
||||
sprintf( /* translators: %s - Email Log settings url. */
|
||||
__( 'Please enable <a href="%s">Email Logging</a> first, before this setting can be configured.', 'wp-mail-smtp' ),
|
||||
esc_url( wp_mail_smtp()->get_admin()->get_admin_page_url( Area::SLUG . '&tab=logs' ) )
|
||||
),
|
||||
[
|
||||
'a' => [
|
||||
'href' => [],
|
||||
],
|
||||
]
|
||||
);
|
||||
} else {
|
||||
printf(
|
||||
'<a href="%1$s" target="_blank">%2$s</a>',
|
||||
esc_url( SummaryReportEmail::get_preview_link() ),
|
||||
esc_html__( 'View Email Summary Example', 'wp-mail-smtp' )
|
||||
);
|
||||
}
|
||||
|
||||
if ( $options->is_const_defined( 'general', SummaryReportEmail::SETTINGS_SLUG ) ) {
|
||||
echo '<br>' . $options->get_const_set_message( 'WPMS_SUMMARY_REPORT_EMAIL_DISABLED' ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Uninstall -->
|
||||
<div id="wp-mail-smtp-setting-row-uninstall" class="wp-mail-smtp-setting-row wp-mail-smtp-clear">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label for="wp-mail-smtp-setting-uninstall">
|
||||
<?php esc_html_e( 'Uninstall WP Mail SMTP', 'wp-mail-smtp' ); ?>
|
||||
</label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<?php
|
||||
UI::toggle(
|
||||
[
|
||||
'name' => 'wp-mail-smtp[general][uninstall]',
|
||||
'id' => 'wp-mail-smtp-setting-uninstall',
|
||||
'value' => 'true',
|
||||
'checked' => (bool) $options->get( 'general', 'uninstall' ),
|
||||
]
|
||||
);
|
||||
?>
|
||||
<p class="desc">
|
||||
<?php esc_html_e( 'Remove ALL WP Mail SMTP data upon plugin deletion.', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
<p class="desc wp-mail-smtp-danger">
|
||||
<?php esc_html_e( 'All settings will be unrecoverable.', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php $this->display_save_btn(); ?>
|
||||
|
||||
</form>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Process tab form submission ($_POST).
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.2.0 Fixed checkbox saving and use the correct merge to prevent breaking other 'general' checkboxes.
|
||||
*
|
||||
* @param array $data Tab data specific for the plugin ($_POST).
|
||||
*/
|
||||
public function process_post( $data ) { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh
|
||||
|
||||
$this->check_admin_referer();
|
||||
|
||||
$options = Options::init();
|
||||
|
||||
// Unchecked checkboxes doesn't exist in $_POST, so we need to ensure we actually have them in data to save.
|
||||
if ( empty( $data['general']['do_not_send'] ) ) {
|
||||
$data['general']['do_not_send'] = false;
|
||||
}
|
||||
if ( empty( $data['general']['am_notifications_hidden'] ) ) {
|
||||
$data['general']['am_notifications_hidden'] = false;
|
||||
}
|
||||
if ( empty( $data['general']['email_delivery_errors_hidden'] ) ) {
|
||||
$data['general']['email_delivery_errors_hidden'] = false;
|
||||
}
|
||||
if ( empty( $data['general']['dashboard_widget_hidden'] ) ) {
|
||||
$data['general']['dashboard_widget_hidden'] = false;
|
||||
}
|
||||
if ( empty( $data['general']['uninstall'] ) ) {
|
||||
$data['general']['uninstall'] = false;
|
||||
}
|
||||
if ( empty( $data['general'][ UsageTracking::SETTINGS_SLUG ] ) ) {
|
||||
$data['general'][ UsageTracking::SETTINGS_SLUG ] = false;
|
||||
}
|
||||
if ( empty( $data['general'][ SummaryReportEmail::SETTINGS_SLUG ] ) ) {
|
||||
$data['general'][ SummaryReportEmail::SETTINGS_SLUG ] = false;
|
||||
}
|
||||
|
||||
$is_summary_report_email_opt_changed = $options->is_option_changed(
|
||||
$options->parse_boolean( $data['general'][ SummaryReportEmail::SETTINGS_SLUG ] ),
|
||||
'general',
|
||||
SummaryReportEmail::SETTINGS_SLUG
|
||||
);
|
||||
|
||||
// If this option was changed, cancel summary report email task.
|
||||
if ( $is_summary_report_email_opt_changed ) {
|
||||
( new SummaryReportEmailTask() )->cancel();
|
||||
}
|
||||
|
||||
// All the sanitization is done there.
|
||||
$options->set( $data, false, false );
|
||||
|
||||
WP::add_admin_notice(
|
||||
esc_html__( 'Settings were successfully saved.', 'wp-mail-smtp' ),
|
||||
WP::ADMIN_NOTICE_SUCCESS
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,444 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin\Pages;
|
||||
|
||||
use WPMailSMTP\Admin\ConnectionSettings;
|
||||
use WPMailSMTP\Admin\PageAbstract;
|
||||
use WPMailSMTP\Admin\SetupWizard;
|
||||
use WPMailSMTP\Options;
|
||||
use WPMailSMTP\WP;
|
||||
|
||||
/**
|
||||
* Class SettingsTab is part of Area, displays general settings of the plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class SettingsTab extends PageAbstract {
|
||||
|
||||
/**
|
||||
* Settings constructor.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
|
||||
add_action( 'wp_mail_smtp_admin_pages_settings_license_key', array( __CLASS__, 'display_license_key_field_content' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @var string Slug of a tab.
|
||||
*/
|
||||
protected $slug = 'settings';
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_label() {
|
||||
return esc_html__( 'General', 'wp-mail-smtp' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_title() {
|
||||
return $this->get_label();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function display() {
|
||||
|
||||
$options = Options::init();
|
||||
?>
|
||||
|
||||
<form method="POST" action="" autocomplete="off" class="wp-mail-smtp-connection-settings-form">
|
||||
<?php $this->wp_nonce_field(); ?>
|
||||
|
||||
<?php ob_start(); ?>
|
||||
|
||||
<!-- License Section Title -->
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-content wp-mail-smtp-clear section-heading" id="wp-mail-smtp-setting-row-license-heading">
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<h2><?php esc_html_e( 'License', 'wp-mail-smtp' ); ?></h2>
|
||||
|
||||
<p class="desc">
|
||||
<?php esc_html_e( 'Your license key provides access to updates and support.', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- License Key -->
|
||||
<div id="wp-mail-smtp-setting-row-license_key" class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-license_key wp-mail-smtp-clear">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label for="wp-mail-smtp-setting-license_key"><?php esc_html_e( 'License Key', 'wp-mail-smtp' ); ?></label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<?php do_action( 'wp_mail_smtp_admin_pages_settings_license_key', $options ); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Mail Section Title -->
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-content wp-mail-smtp-clear section-heading no-desc">
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<h2><?php esc_html_e( 'Primary Connection', 'wp-mail-smtp' ); ?></h2>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ( ! is_network_admin() ) : ?>
|
||||
<!-- Setup Wizard button -->
|
||||
<div id="wp-mail-smtp-setting-row-setup-wizard-button" class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-email wp-mail-smtp-clear">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label for="wp-mail-smtp-setting-from_email"><?php esc_html_e( 'Setup Wizard', 'wp-mail-smtp' ); ?></label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<a href="<?php echo esc_url( SetupWizard::get_site_url() ); ?>" class="wp-mail-smtp-btn wp-mail-smtp-btn-md wp-mail-smtp-btn-blueish">
|
||||
<?php esc_html_e( 'Launch Setup Wizard', 'wp-mail-smtp' ); ?>
|
||||
</a>
|
||||
|
||||
<p class="desc">
|
||||
<?php esc_html_e( 'We\'ll guide you through each step needed to get WP Mail SMTP fully set up on your site.', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
$connection = wp_mail_smtp()->get_connections_manager()->get_primary_connection();
|
||||
$connection_settings = new ConnectionSettings( $connection );
|
||||
|
||||
// Display connection settings.
|
||||
$connection_settings->display();
|
||||
?>
|
||||
|
||||
<?php $this->display_backup_connection_education(); ?>
|
||||
|
||||
<?php
|
||||
$settings_content = apply_filters( 'wp_mail_smtp_admin_settings_tab_display', ob_get_clean() );
|
||||
echo $settings_content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
?>
|
||||
|
||||
<?php $this->display_save_btn(); ?>
|
||||
|
||||
</form>
|
||||
|
||||
<?php
|
||||
$this->display_wpforms();
|
||||
$this->display_pro_banner();
|
||||
}
|
||||
|
||||
/**
|
||||
* License key text for a Lite version of the plugin.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @param Options $options
|
||||
*/
|
||||
public static function display_license_key_field_content( $options ) {
|
||||
?>
|
||||
|
||||
<p><?php esc_html_e( 'You\'re using WP Mail SMTP Lite - no license needed. Enjoy!', 'wp-mail-smtp' ); ?> 🙂</p>
|
||||
|
||||
<p>
|
||||
<?php
|
||||
printf(
|
||||
wp_kses( /* translators: %s - WPMailSMTP.com upgrade URL. */
|
||||
__( 'To unlock more features, consider <strong><a href="%s" target="_blank" rel="noopener noreferrer" class="wp-mail-smtp-upgrade-modal">upgrading to PRO</a></strong>.', 'wp-mail-smtp' ),
|
||||
array(
|
||||
'a' => array(
|
||||
'href' => array(),
|
||||
'class' => array(),
|
||||
'target' => array(),
|
||||
'rel' => array(),
|
||||
),
|
||||
'strong' => array(),
|
||||
)
|
||||
),
|
||||
esc_url( wp_mail_smtp()->get_upgrade_link( 'general-license-key' ) )
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
|
||||
<p class="desc">
|
||||
<?php
|
||||
printf(
|
||||
wp_kses( /* Translators: %s - discount value $50 */
|
||||
__( 'As a valued WP Mail SMTP Lite user you receive <strong>%s off</strong>, automatically applied at checkout!', 'wp-mail-smtp' ),
|
||||
array(
|
||||
'strong' => array(),
|
||||
'br' => array(),
|
||||
)
|
||||
),
|
||||
'$50'
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<p>
|
||||
<?php esc_html_e( 'Already purchased? Simply enter your license key below to connect with WP Mail SMTP Pro!', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<input type="password" id="wp-mail-smtp-setting-upgrade-license-key" class="wp-mail-smtp-not-form-input" placeholder="<?php esc_attr_e( 'Paste license key here', 'wp-mail-smtp' ); ?>" value="" />
|
||||
<button type="button" class="wp-mail-smtp-btn wp-mail-smtp-btn-md wp-mail-smtp-btn-orange" id="wp-mail-smtp-setting-upgrade-license-button">
|
||||
<?php esc_attr_e( 'Connect', 'wp-mail-smtp' ); ?>
|
||||
</button>
|
||||
</p>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a WPForms related message.
|
||||
*
|
||||
* @since 1.3.0
|
||||
* @since 1.4.0 Display only to site admins.
|
||||
* @since 1.5.0 Do nothing.
|
||||
*/
|
||||
protected function display_wpforms() {
|
||||
/*
|
||||
* Used to have this check:
|
||||
*
|
||||
* $is_dismissed = get_user_meta( get_current_user_id(), 'wp_mail_smtp_wpforms_dismissed', true );
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Display WP Mail SMTP Pro upgrade banner.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
protected function display_pro_banner() {
|
||||
|
||||
// Display only to site admins. Only site admins can install plugins.
|
||||
if ( ! is_super_admin() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Do not display if WP Mail SMTP Pro already installed.
|
||||
if ( wp_mail_smtp()->is_pro() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$is_dismissed = get_user_meta( get_current_user_id(), 'wp_mail_smtp_pro_banner_dismissed', true );
|
||||
|
||||
// Do not display if user dismissed.
|
||||
if ( (bool) $is_dismissed === true ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
|
||||
<div id="wp-mail-smtp-pro-banner">
|
||||
|
||||
<span class="wp-mail-smtp-pro-banner-dismiss">
|
||||
<button id="wp-mail-smtp-pro-banner-dismiss">
|
||||
<span class="dashicons dashicons-dismiss"></span>
|
||||
</button>
|
||||
</span>
|
||||
|
||||
<h2>
|
||||
<?php esc_html_e( 'Get WP Mail SMTP Pro and Unlock all the Powerful Features', 'wp-mail-smtp' ); ?>
|
||||
</h2>
|
||||
|
||||
<p>
|
||||
<?php esc_html_e( 'Thanks for being a loyal WP Mail SMTP user. Upgrade to WP Mail SMTP Pro to unlock more awesome features and experience why WP Mail SMTP is the most popular SMTP plugin.', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<?php esc_html_e( 'We know that you will truly love WP Mail SMTP. It\'s used by over 3,000,000 websites.', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
|
||||
<p><strong><?php esc_html_e( 'Pro Features:', 'wp-mail-smtp' ); ?></strong></p>
|
||||
|
||||
<div class="benefits">
|
||||
<ul>
|
||||
<li><?php esc_html_e( 'Email Logging - keep track of every email sent from your site', 'wp-mail-smtp' ); ?></li>
|
||||
<li><?php esc_html_e( 'Alerts - get notified when your emails fail (via email, slack or SMS)', 'wp-mail-smtp' ); ?></li>
|
||||
<li><?php esc_html_e( 'Backup Connection - send emails even if your primary connection fails', 'wp-mail-smtp' ); ?></li>
|
||||
<li><?php esc_html_e( 'Smart Routing - define conditions for your email sending', 'wp-mail-smtp' ); ?></li>
|
||||
<li><?php esc_html_e( 'Amazon SES - harness the power of AWS', 'wp-mail-smtp' ); ?></li>
|
||||
<li><?php esc_html_e( 'Outlook - send emails using your Outlook or Microsoft 365 account', 'wp-mail-smtp' ); ?></li>
|
||||
<li><?php esc_html_e( 'Zoho Mail - use your Zoho Mail account to send emails', 'wp-mail-smtp' ); ?></li>
|
||||
<li><?php esc_html_e( 'Multisite Support - network settings for easy management', 'wp-mail-smtp' ); ?></li>
|
||||
<li><?php esc_html_e( 'Manage Notifications - control which emails your site sends', 'wp-mail-smtp' ); ?></li>
|
||||
<li><?php esc_html_e( 'Access to our world class support team', 'wp-mail-smtp' ); ?></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><?php esc_html_e( 'White Glove Setup - sit back and relax while we handle everything for you', 'wp-mail-smtp' ); ?></li>
|
||||
<li class="arrow-right"><?php esc_html_e( 'Install & Setup WP Mail SMTP Pro plugin', 'wp-mail-smtp' ); ?></li>
|
||||
<li class="arrow-right"><?php esc_html_e( 'Configure SendLayer, SMTP.com or Brevo service', 'wp-mail-smtp' ); ?></li>
|
||||
<li class="arrow-right"><?php esc_html_e( 'Set up domain name verification (DNS)', 'wp-mail-smtp' ); ?></li>
|
||||
<li class="arrow-right"><?php esc_html_e( 'Test and verify email delivery', 'wp-mail-smtp' ); ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<?php
|
||||
printf(
|
||||
wp_kses( /* translators: %s - WPMailSMTP.com URL. */
|
||||
__( '<a href="%s" target="_blank" rel="noopener noreferrer">Get WP Mail SMTP Pro Today and Unlock all the Powerful Features »</a>', 'wp-mail-smtp' ),
|
||||
array(
|
||||
'a' => array(
|
||||
'href' => array(),
|
||||
'target' => array(),
|
||||
'rel' => array(),
|
||||
),
|
||||
'strong' => array(),
|
||||
)
|
||||
),
|
||||
esc_url( wp_mail_smtp()->get_upgrade_link( 'general-cta' ) )
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<?php
|
||||
printf(
|
||||
wp_kses( /* Translators: %s - discount value $50. */
|
||||
__( '<strong>Bonus:</strong> WP Mail SMTP users get <span class="price-off">%s off regular price</span>, automatically applied at checkout.', 'wp-mail-smtp' ),
|
||||
array(
|
||||
'strong' => array(),
|
||||
'span' => array(
|
||||
'class' => array(),
|
||||
),
|
||||
)
|
||||
),
|
||||
'$50'
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Display backup connection education section.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
private function display_backup_connection_education() {
|
||||
|
||||
if ( wp_mail_smtp()->is_pro() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$upgrade_link_url = wp_mail_smtp()->get_upgrade_link(
|
||||
[
|
||||
'medium' => 'Backup Connection Settings',
|
||||
'content' => 'Upgrade to WP Mail SMTP Pro Link',
|
||||
]
|
||||
);
|
||||
?>
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-content wp-mail-smtp-clear section-heading">
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<h4 class="wp-mail-smtp-product-education__heading">
|
||||
<?php esc_html_e( 'Backup Connection', 'wp-mail-smtp' ); ?>
|
||||
</h4>
|
||||
<p class="wp-mail-smtp-product-education__description">
|
||||
<?php
|
||||
echo wp_kses(
|
||||
sprintf( /* translators: %s - WPMailSMTP.com Upgrade page URL. */
|
||||
__( 'Don’t worry about losing emails. Add an additional connection, then set it as your Backup Connection. Emails that fail to send with the Primary Connection will be sent via the selected Backup Connection. <a href="%s" target="_blank" rel="noopener noreferrer">Upgrade to WP Mail SMTP Pro!</a>', 'wp-mail-smtp' ),
|
||||
esc_url( $upgrade_link_url )
|
||||
),
|
||||
[
|
||||
'a' => [
|
||||
'href' => [],
|
||||
'rel' => [],
|
||||
'target' => [],
|
||||
],
|
||||
]
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-clear">
|
||||
<div class="wp-mail-smtp-setting-label">
|
||||
<label>
|
||||
<?php esc_html_e( 'Backup Connection', 'wp-mail-smtp' ); ?>
|
||||
</label>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-field">
|
||||
<div class="wp-mail-smtp-connection-selector">
|
||||
<label>
|
||||
<input type="radio" checked/>
|
||||
<span><?php esc_attr_e( 'None', 'wp-mail-smtp' ); ?></span>
|
||||
</label>
|
||||
</div>
|
||||
<p class="desc">
|
||||
<?php
|
||||
echo wp_kses(
|
||||
sprintf( /* translators: %s - Smart routing settings page url. */
|
||||
__( 'Once you add an <a href="%s">additional connection</a>, you can select it here.', 'wp-mail-smtp' ),
|
||||
add_query_arg(
|
||||
[
|
||||
'tab' => 'connections',
|
||||
],
|
||||
wp_mail_smtp()->get_admin()->get_admin_page_url()
|
||||
)
|
||||
),
|
||||
[
|
||||
'a' => [
|
||||
'href' => [],
|
||||
'target' => [],
|
||||
'rel' => [],
|
||||
],
|
||||
]
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Process tab form submission ($_POST ).
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @param array $data Post data specific for the plugin.
|
||||
*/
|
||||
public function process_post( $data ) {
|
||||
|
||||
$this->check_admin_referer();
|
||||
|
||||
$connection = wp_mail_smtp()->get_connections_manager()->get_primary_connection();
|
||||
$connection_settings = new ConnectionSettings( $connection );
|
||||
|
||||
$old_data = $connection->get_options()->get_all();
|
||||
|
||||
$data = $connection_settings->process( $data, $old_data );
|
||||
|
||||
/**
|
||||
* Filters mail settings before save.
|
||||
*
|
||||
* @since 2.2.1
|
||||
*
|
||||
* @param array $data Settings data.
|
||||
*/
|
||||
$data = apply_filters( 'wp_mail_smtp_settings_tab_process_post', $data );
|
||||
|
||||
// All the sanitization is done in Options class.
|
||||
Options::init()->set( $data, false, false );
|
||||
|
||||
$connection_settings->post_process( $data, $old_data );
|
||||
|
||||
if ( $connection_settings->get_scroll_to() !== false ) {
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
|
||||
wp_safe_redirect( sanitize_text_field( wp_unslash( $_POST['_wp_http_referer'] ) ) . $connection_settings->get_scroll_to() );
|
||||
exit;
|
||||
}
|
||||
|
||||
WP::add_admin_notice(
|
||||
esc_html__( 'Settings were successfully saved.', 'wp-mail-smtp' ),
|
||||
WP::ADMIN_NOTICE_SUCCESS
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,313 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin\Pages;
|
||||
|
||||
use WPMailSMTP\Admin\PageAbstract;
|
||||
use WPMailSMTP\Helpers\UI;
|
||||
use WPMailSMTP\WP;
|
||||
|
||||
/**
|
||||
* Class SmartRoutingTab is a placeholder for Pro smart routing feature.
|
||||
* Displays product education.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
class SmartRoutingTab extends PageAbstract {
|
||||
|
||||
/**
|
||||
* Part of the slug of a tab.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $slug = 'routing';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*
|
||||
* @param PageAbstract $parent_page Parent page object.
|
||||
*/
|
||||
public function __construct( $parent_page = null ) {
|
||||
|
||||
parent::__construct( $parent_page );
|
||||
|
||||
if ( wp_mail_smtp()->get_admin()->get_current_tab() === $this->slug && ! wp_mail_smtp()->is_pro() ) {
|
||||
$this->hooks();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Link label of a tab.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_label() {
|
||||
|
||||
return esc_html__( 'Smart Routing', 'wp-mail-smtp' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register hooks.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
public function hooks() {
|
||||
|
||||
add_action( 'wp_mail_smtp_admin_area_enqueue_assets', [ $this, 'enqueue_assets' ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue required JS and CSS.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
public function enqueue_assets() {
|
||||
|
||||
wp_enqueue_style(
|
||||
'wp-mail-smtp-smart-routing',
|
||||
wp_mail_smtp()->plugin_url . '/assets/css/smtp-smart-routing.min.css',
|
||||
[],
|
||||
WPMS_PLUGIN_VER
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Output HTML of smart routing education.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
public function display() {
|
||||
|
||||
$top_upgrade_button_url = wp_mail_smtp()->get_upgrade_link(
|
||||
[
|
||||
'medium' => 'Smart Routing Settings',
|
||||
'content' => 'Upgrade to WP Mail SMTP Pro Button Top',
|
||||
]
|
||||
);
|
||||
$bottom_upgrade_button_url = wp_mail_smtp()->get_upgrade_link(
|
||||
[
|
||||
'medium' => 'Smart Routing Settings',
|
||||
'content' => 'Upgrade to WP Mail SMTP Pro Button',
|
||||
]
|
||||
);
|
||||
?>
|
||||
<div id="wp-mail-smtp-smart-routing-product-education" class="wp-mail-smtp-product-education">
|
||||
<div class="wp-mail-smtp-product-education__row wp-mail-smtp-product-education__row--no-border">
|
||||
<h4 class="wp-mail-smtp-product-education__heading">
|
||||
<?php esc_html_e( 'Smart Routing', 'wp-mail-smtp' ); ?>
|
||||
</h4>
|
||||
<p class="wp-mail-smtp-product-education__description">
|
||||
<?php
|
||||
esc_html_e( 'Send emails from different additional connections based on your configured conditions. Emails that do not match any of the conditions below will be sent via your Primary Connection.', 'wp-mail-smtp' );
|
||||
?>
|
||||
</p>
|
||||
|
||||
<a href="<?php echo esc_url( $top_upgrade_button_url ); ?>" target="_blank" rel="noopener noreferrer" class="wp-mail-smtp-product-education__upgrade-btn wp-mail-smtp-product-education__upgrade-btn--top wp-mail-smtp-btn wp-mail-smtp-btn-upgrade wp-mail-smtp-btn-orange">
|
||||
<?php esc_html_e( 'Upgrade to WP Mail SMTP Pro', 'wp-mail-smtp' ); ?>
|
||||
</a>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-product-education__row wp-mail-smtp-product-education__row--inactive wp-mail-smtp-product-education__row--no-border wp-mail-smtp-product-education__row--no-padding wp-mail-smtp-product-education__row--full-width">
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-no-border">
|
||||
<?php
|
||||
UI::toggle(
|
||||
[
|
||||
'label' => esc_html__( 'Enable Smart Routing', 'wp-mail-smtp' ),
|
||||
'class' => 'wp-mail-smtp-smart-routing-toggle',
|
||||
'checked' => true,
|
||||
]
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-no-border wp-mail-smtp-setting-row-no-padding">
|
||||
<div class="wp-mail-smtp-smart-routing-routes">
|
||||
<div class="wp-mail-smtp-smart-routing-route">
|
||||
<div class="wp-mail-smtp-smart-routing-route__header">
|
||||
<span><?php esc_html_e( 'Send with', 'wp-mail-smtp' ); ?></span>
|
||||
<select class="wp-mail-smtp-smart-routing-route__connection">
|
||||
<option><?php esc_html_e( 'WooCommerce Emails (SendLayer)', 'wp-mail-smtp' ); ?></option>
|
||||
</select>
|
||||
<span><?php esc_html_e( 'if the following conditions are met...', 'wp-mail-smtp' ); ?></span>
|
||||
<div class="wp-mail-smtp-smart-routing-route__actions">
|
||||
<div class="wp-mail-smtp-smart-routing-route__order">
|
||||
<button class="wp-mail-smtp-smart-routing-route__order-btn wp-mail-smtp-smart-routing-route__order-btn--up">
|
||||
<img src="<?php echo esc_url( wp_mail_smtp()->assets_url . '/images/icons/arrow-up.svg' ); ?>" alt="<?php esc_attr_e( 'Arrow Up', 'wp-mail-smtp' ); ?>">
|
||||
</button>
|
||||
<button class="wp-mail-smtp-smart-routing-route__order-btn wp-mail-smtp-smart-routing-route__order-btn--down">
|
||||
<img src="<?php echo esc_url( wp_mail_smtp()->assets_url . '/images/icons/arrow-up.svg' ); ?>" alt="<?php esc_attr_e( 'Arrow Down', 'wp-mail-smtp' ); ?>">
|
||||
</button>
|
||||
</div>
|
||||
<button class="wp-mail-smtp-smart-routing-route__delete">
|
||||
<i class="dashicons dashicons-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-smart-routing-route__main">
|
||||
<div class="wp-mail-smtp-conditional">
|
||||
<div class="wp-mail-smtp-conditional__group">
|
||||
<table>
|
||||
<tbody>
|
||||
<tr class="wp-mail-smtp-conditional__row">
|
||||
<td class="wp-mail-smtp-conditional__property-col">
|
||||
<select>
|
||||
<option><?php esc_html_e( 'Subject', 'wp-mail-smtp' ); ?></option>
|
||||
</select>
|
||||
</td>
|
||||
<td class="wp-mail-smtp-conditional__operator-col">
|
||||
<select class="wp-mail-smtp-conditional__operator">
|
||||
<option><?php esc_html_e( 'Contains', 'wp-mail-smtp' ); ?></option>
|
||||
</select>
|
||||
</td>
|
||||
<td class="wp-mail-smtp-conditional__value-col">
|
||||
<input type="text" value="<?php esc_html_e( 'Order', 'wp-mail-smtp' ); ?>" class="wp-mail-smtp-conditional__value">
|
||||
</td>
|
||||
<td class="wp-mail-smtp-conditional__actions">
|
||||
<button class="wp-mail-smtp-conditional__add-rule wp-mail-smtp-btn wp-mail-smtp-btn-md wp-mail-smtp-btn-grey">
|
||||
<?php esc_html_e( 'And', 'wp-mail-smtp' ); ?>
|
||||
</button>
|
||||
<button class="wp-mail-smtp-conditional__delete-rule">
|
||||
<i class="dashicons dashicons-trash" aria-hidden="true"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="wp-mail-smtp-conditional__row">
|
||||
<td class="wp-mail-smtp-conditional__property-col">
|
||||
<select class="wp-mail-smtp-conditional__property">
|
||||
<option><?php esc_html_e( 'From Email', 'wp-mail-smtp' ); ?></option>
|
||||
</select>
|
||||
</td>
|
||||
<td class="wp-mail-smtp-conditional__operator-col">
|
||||
<select class="wp-mail-smtp-conditional__operator">
|
||||
<option><?php esc_html_e( 'Is', 'wp-mail-smtp' ); ?></option>
|
||||
</select>
|
||||
</td>
|
||||
<td class="wp-mail-smtp-conditional__value-col">
|
||||
<input type="text" value="shop@wpmailsmtp.com" class="wp-mail-smtp-conditional__value">
|
||||
</td>
|
||||
<td class="wp-mail-smtp-conditional__actions">
|
||||
<button class="wp-mail-smtp-conditional__add-rule wp-mail-smtp-btn wp-mail-smtp-btn-md wp-mail-smtp-btn-grey">
|
||||
<?php esc_html_e( 'And', 'wp-mail-smtp' ); ?>
|
||||
</button>
|
||||
<button class="wp-mail-smtp-conditional__delete-rule">
|
||||
<i class="dashicons dashicons-trash" aria-hidden="true"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="wp-mail-smtp-conditional__group-delimiter"><?php esc_html_e( 'or', 'wp-mail-smtp' ); ?></div>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-conditional__group">
|
||||
<table>
|
||||
<tbody>
|
||||
<tr class="wp-mail-smtp-conditional__row">
|
||||
<td class="wp-mail-smtp-conditional__property-col">
|
||||
<select class="wp-mail-smtp-conditional__property">
|
||||
<option><?php esc_html_e( 'From Email', 'wp-mail-smtp' ); ?></option>
|
||||
</select>
|
||||
</td>
|
||||
<td class="wp-mail-smtp-conditional__operator-col">
|
||||
<select class="wp-mail-smtp-conditional__operator">
|
||||
<option><?php esc_html_e( 'Is', 'wp-mail-smtp' ); ?></option>
|
||||
</select>
|
||||
</td>
|
||||
<td class="wp-mail-smtp-conditional__value-col">
|
||||
<input type="text" value="returns@wpmailsmtp.com" class="wp-mail-smtp-conditional__value">
|
||||
</td>
|
||||
<td class="wp-mail-smtp-conditional__actions">
|
||||
<button class="wp-mail-smtp-conditional__add-rule wp-mail-smtp-btn wp-mail-smtp-btn-md wp-mail-smtp-btn-grey">
|
||||
<?php esc_html_e( 'And', 'wp-mail-smtp' ); ?>
|
||||
</button>
|
||||
<button class="wp-mail-smtp-conditional__delete-rule">
|
||||
<i class="dashicons dashicons-trash" aria-hidden="true"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="wp-mail-smtp-conditional__group-delimiter"><?php esc_html_e( 'or', 'wp-mail-smtp' ); ?></div>
|
||||
</div>
|
||||
<button class="wp-mail-smtp-conditional__add-group wp-mail-smtp-btn wp-mail-smtp-btn-md wp-mail-smtp-btn-grey">
|
||||
<?php esc_html_e( 'Add New Group', 'wp-mail-smtp' ); ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-smart-routing-route">
|
||||
<div class="wp-mail-smtp-smart-routing-route__header">
|
||||
<span><?php esc_html_e( 'Send with', 'wp-mail-smtp' ); ?></span>
|
||||
<select class="wp-mail-smtp-smart-routing-route__connection">
|
||||
<option><?php esc_html_e( 'Contact Emails (SMTP.com)', 'wp-mail-smtp' ); ?></option>
|
||||
</select>
|
||||
<span><?php esc_html_e( 'if the following conditions are met...', 'wp-mail-smtp' ); ?></span>
|
||||
<div class="wp-mail-smtp-smart-routing-route__actions">
|
||||
<div class="wp-mail-smtp-smart-routing-route__order">
|
||||
<button class="wp-mail-smtp-smart-routing-route__order-btn wp-mail-smtp-smart-routing-route__order-btn--up">
|
||||
<img src="<?php echo esc_url( wp_mail_smtp()->assets_url . '/images/icons/arrow-up.svg' ); ?>" alt="<?php esc_attr_e( 'Arrow Up', 'wp-mail-smtp' ); ?>">
|
||||
</button>
|
||||
<button class="wp-mail-smtp-smart-routing-route__order-btn wp-mail-smtp-smart-routing-route__order-btn--down">
|
||||
<img src="<?php echo esc_url( wp_mail_smtp()->assets_url . '/images/icons/arrow-up.svg' ); ?>" alt="<?php esc_attr_e( 'Arrow Down', 'wp-mail-smtp' ); ?>">
|
||||
</button>
|
||||
</div>
|
||||
<button class="wp-mail-smtp-smart-routing-route__delete">
|
||||
<i class="dashicons dashicons-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-smart-routing-route__main">
|
||||
<div class="wp-mail-smtp-conditional">
|
||||
<div class="wp-mail-smtp-conditional__group">
|
||||
<table>
|
||||
<tbody>
|
||||
<tr class="wp-mail-smtp-conditional__row">
|
||||
<td class="wp-mail-smtp-conditional__property-col">
|
||||
<select>
|
||||
<option><?php esc_html_e( 'Initiator', 'wp-mail-smtp' ); ?></option>
|
||||
</select>
|
||||
</td>
|
||||
<td class="wp-mail-smtp-conditional__operator-col">
|
||||
<select class="wp-mail-smtp-conditional__operator">
|
||||
<option><?php esc_html_e( 'Is', 'wp-mail-smtp' ); ?></option>
|
||||
</select>
|
||||
</td>
|
||||
<td class="wp-mail-smtp-conditional__value-col">
|
||||
<input type="text" value="<?php esc_html_e( 'WPForms', 'wp-mail-smtp' ); ?>" class="wp-mail-smtp-conditional__value">
|
||||
</td>
|
||||
<td class="wp-mail-smtp-conditional__actions">
|
||||
<button class="wp-mail-smtp-conditional__add-rule wp-mail-smtp-btn wp-mail-smtp-btn-md wp-mail-smtp-btn-grey">
|
||||
<?php esc_html_e( 'And', 'wp-mail-smtp' ); ?>
|
||||
</button>
|
||||
<button class="wp-mail-smtp-conditional__delete-rule">
|
||||
<i class="dashicons dashicons-trash" aria-hidden="true"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="wp-mail-smtp-conditional__group-delimiter"><?php esc_html_e( 'or', 'wp-mail-smtp' ); ?></div>
|
||||
</div>
|
||||
<button class="wp-mail-smtp-conditional__add-group wp-mail-smtp-btn wp-mail-smtp-btn-md wp-mail-smtp-btn-grey">
|
||||
<?php esc_html_e( 'Add New Group', 'wp-mail-smtp' ); ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-smart-routing-routes-note">
|
||||
<img src="<?php echo esc_url( wp_mail_smtp()->assets_url . '/images/icons/lightbulb.svg' ); ?>" alt="<?php esc_attr_e( 'Light bulb icon', 'wp-mail-smtp' ); ?>">
|
||||
<?php esc_html_e( 'Friendly reminder, your Primary Connection will be used for all emails that do not match the conditions above.', 'wp-mail-smtp' ); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a href="<?php echo esc_url( $bottom_upgrade_button_url ); ?>" target="_blank" rel="noopener noreferrer" class="wp-mail-smtp-product-education__upgrade-btn wp-mail-smtp-product-education__upgrade-btn--bottom wp-mail-smtp-btn wp-mail-smtp-btn-upgrade wp-mail-smtp-btn-orange">
|
||||
<?php esc_html_e( 'Upgrade to WP Mail SMTP Pro', 'wp-mail-smtp' ); ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
1606
wp/wp-content/plugins/wp-mail-smtp/src/Admin/Pages/TestTab.php
Normal file
1606
wp/wp-content/plugins/wp-mail-smtp/src/Admin/Pages/TestTab.php
Normal file
File diff suppressed because it is too large
Load Diff
55
wp/wp-content/plugins/wp-mail-smtp/src/Admin/Pages/Tools.php
Normal file
55
wp/wp-content/plugins/wp-mail-smtp/src/Admin/Pages/Tools.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin\Pages;
|
||||
|
||||
use WPMailSMTP\Admin\ParentPageAbstract;
|
||||
|
||||
/**
|
||||
* Class Tools.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
class Tools extends ParentPageAbstract {
|
||||
|
||||
/**
|
||||
* Slug of a page.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $slug = 'tools';
|
||||
|
||||
/**
|
||||
* Page default tab slug.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $default_tab = 'test';
|
||||
|
||||
/**
|
||||
* Link label of a page.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_label() {
|
||||
|
||||
return esc_html__( 'Tools', 'wp-mail-smtp' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Title of a page.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_title() {
|
||||
|
||||
return $this->get_label();
|
||||
}
|
||||
}
|
||||
281
wp/wp-content/plugins/wp-mail-smtp/src/Admin/Pages/VersusTab.php
Normal file
281
wp/wp-content/plugins/wp-mail-smtp/src/Admin/Pages/VersusTab.php
Normal file
@@ -0,0 +1,281 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin\Pages;
|
||||
|
||||
use WPMailSMTP\Admin\PageAbstract;
|
||||
|
||||
/**
|
||||
* Versus tab.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*/
|
||||
class VersusTab extends PageAbstract {
|
||||
|
||||
/**
|
||||
* Part of the slug of a tab.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $slug = 'versus';
|
||||
|
||||
/**
|
||||
* Tab priority.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $priority = 40;
|
||||
|
||||
/**
|
||||
* Link label of a tab.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_label() {
|
||||
|
||||
return esc_html__( 'Lite vs Pro', 'wp-mail-smtp' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Title of a tab.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_title() {
|
||||
|
||||
return $this->get_label();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tab content.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*/
|
||||
public function display() {
|
||||
|
||||
$license = wp_mail_smtp()->get_license_type();
|
||||
?>
|
||||
|
||||
<div class="wp-mail-smtp-admin-about-section wp-mail-smtp-admin-about-section-squashed">
|
||||
<h1 class="centered">
|
||||
<strong>
|
||||
<?php
|
||||
printf(
|
||||
/* translators: %s - plugin current license type. */
|
||||
esc_html__( '%s vs Pro', 'wp-mail-smtp' ),
|
||||
esc_html( ucfirst( $license ) )
|
||||
);
|
||||
?>
|
||||
</strong>
|
||||
</h1>
|
||||
|
||||
<p class="centered <?php echo( $license === 'pro' ? 'hidden' : '' ); ?>">
|
||||
<?php esc_html_e( 'Get the most out of WP Mail SMTP by upgrading to Pro and unlocking all of the powerful features.', 'wp-mail-smtp' ); ?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="wp-mail-smtp-admin-about-section wp-mail-smtp-admin-about-section-squashed wp-mail-smtp-admin-about-section-hero wp-mail-smtp-admin-about-section-table">
|
||||
|
||||
<div class="wp-mail-smtp-admin-about-section-hero-main wp-mail-smtp-admin-columns">
|
||||
<div class="wp-mail-smtp-admin-column-33">
|
||||
<h3 class="no-margin">
|
||||
<?php esc_html_e( 'Feature', 'wp-mail-smtp' ); ?>
|
||||
</h3>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-admin-column-33">
|
||||
<h3 class="no-margin">
|
||||
<?php echo esc_html( ucfirst( $license ) ); ?>
|
||||
</h3>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-admin-column-33">
|
||||
<h3 class="no-margin">
|
||||
<?php esc_html_e( 'Pro', 'wp-mail-smtp' ); ?>
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-admin-about-section-hero-extra no-padding wp-mail-smtp-admin-columns">
|
||||
|
||||
<table>
|
||||
<?php
|
||||
foreach ( $this->get_license_features() as $slug => $name ) {
|
||||
$current = $this->get_license_data( $slug, $license );
|
||||
$pro = $this->get_license_data( $slug, 'pro' );
|
||||
?>
|
||||
<tr class="wp-mail-smtp-admin-columns">
|
||||
<td class="wp-mail-smtp-admin-column-33">
|
||||
<p><?php echo esc_html( $name ); ?></p>
|
||||
</td>
|
||||
<td class="wp-mail-smtp-admin-column-33">
|
||||
<p class="features-<?php echo esc_attr( $current['status'] ); ?>">
|
||||
<?php echo implode( '<br>', $current['text'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</p>
|
||||
</td>
|
||||
<td class="wp-mail-smtp-admin-column-33">
|
||||
<p class="features-full">
|
||||
<?php echo implode( '<br>', $pro['text'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php if ( 'lite' === $license ) : ?>
|
||||
<div class="wp-mail-smtp-admin-about-section wp-mail-smtp-admin-about-section-hero">
|
||||
<div class="wp-mail-smtp-admin-about-section-hero-main no-border">
|
||||
<h3 class="call-to-action centered">
|
||||
<a href="<?php echo esc_url( wp_mail_smtp()->get_upgrade_link( 'lite-vs-pro' ) ); ?>" target="_blank" rel="noopener noreferrer">
|
||||
<?php esc_html_e( 'Get WP Mail SMTP Pro Today and Unlock all of these Powerful Features', 'wp-mail-smtp' ); ?>
|
||||
</a>
|
||||
</h3>
|
||||
|
||||
<p class="centered">
|
||||
<?php
|
||||
printf(
|
||||
wp_kses( /* Translators: %s - discount value $50. */
|
||||
__( 'Bonus: WP Mail SMTP Lite users get <span class="price-off">%s off regular price</span>, automatically applied at checkout.', 'wp-mail-smtp' ),
|
||||
[
|
||||
'span' => [
|
||||
'class' => [],
|
||||
],
|
||||
]
|
||||
),
|
||||
'$50'
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of features for all licenses.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function get_license_features() {
|
||||
|
||||
return [
|
||||
'log' => esc_html__( 'Email Log', 'wp-mail-smtp' ),
|
||||
'control' => esc_html__( 'Email Controls', 'wp-mail-smtp' ),
|
||||
'mailers' => esc_html__( 'Mailer Options', 'wp-mail-smtp' ),
|
||||
'multisite' => esc_html__( 'WordPress Multisite', 'wp-mail-smtp' ),
|
||||
'support' => esc_html__( 'Customer Support', 'wp-mail-smtp' ),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array of data that compared the license data.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param string $feature Feature name.
|
||||
* @param string $license License type to get data for.
|
||||
*
|
||||
* @return array|false
|
||||
*/
|
||||
private function get_license_data( $feature, $license ) {
|
||||
|
||||
$data = [
|
||||
'log' => [
|
||||
'lite' => [
|
||||
'status' => 'none',
|
||||
'text' => [
|
||||
'<strong>' . esc_html__( 'Emails are not logged', 'wp-mail-smtp' ) . '</strong>',
|
||||
],
|
||||
],
|
||||
'pro' => [
|
||||
'status' => 'full',
|
||||
'text' => [
|
||||
'<strong>' . esc_html__( 'Access to all Email Logging options right inside WordPress', 'wp-mail-smtp' ) . '</strong>',
|
||||
],
|
||||
],
|
||||
],
|
||||
'control' => [
|
||||
'lite' => [
|
||||
'status' => 'none',
|
||||
'text' => [
|
||||
'<strong>' . esc_html__( 'No controls over whether default WordPress emails are sent', 'wp-mail-smtp' ) . '</strong>',
|
||||
],
|
||||
],
|
||||
'pro' => [
|
||||
'status' => 'full',
|
||||
'text' => [
|
||||
'<strong>' . esc_html__( 'Complete Email Controls management for most default WordPress emails', 'wp-mail-smtp' ) . '</strong>',
|
||||
],
|
||||
],
|
||||
],
|
||||
'mailers' => [
|
||||
'lite' => [
|
||||
'status' => 'none',
|
||||
'text' => [
|
||||
'<strong>' . esc_html__( 'Limited Mailers', 'wp-mail-smtp' ) . '</strong><br>' . esc_html__( 'Access is limited to standard mailer options only', 'wp-mail-smtp' ),
|
||||
],
|
||||
],
|
||||
'pro' => [
|
||||
'status' => 'full',
|
||||
'text' => [
|
||||
'<strong>' . esc_html__( 'Additional Mailer Options', 'wp-mail-smtp' ) . '</strong><br>' . esc_html__( 'Microsoft Outlook (with Office365 support), Amazon SES and Zoho Mail', 'wp-mail-smtp' ),
|
||||
],
|
||||
],
|
||||
],
|
||||
'multisite' => [
|
||||
'lite' => [
|
||||
'status' => 'none',
|
||||
'text' => [
|
||||
'<strong>' . esc_html__( 'No Global Network Settings', 'wp-mail-smtp' ) . '</strong>',
|
||||
],
|
||||
],
|
||||
'pro' => [
|
||||
'status' => 'full',
|
||||
'text' => [
|
||||
'<strong>' . esc_html__( 'All Global Network Settings', 'wp-mail-smtp' ) . '</strong><br>' . esc_html__( 'Optionally configure settings at the network level or manage separately for each subsite', 'wp-mail-smtp' ),
|
||||
],
|
||||
],
|
||||
],
|
||||
'support' => [
|
||||
'lite' => [
|
||||
'status' => 'none',
|
||||
'text' => [
|
||||
'<strong>' . esc_html__( 'Limited Support', 'wp-mail-smtp' ) . '</strong>',
|
||||
],
|
||||
],
|
||||
'pro' => [
|
||||
'status' => 'full',
|
||||
'text' => [
|
||||
'<strong>' . esc_html__( 'Priority Support', 'wp-mail-smtp' ) . '</strong>',
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// Wrong feature?
|
||||
if ( ! isset( $data[ $feature ] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Wrong license type?
|
||||
if ( ! isset( $data[ $feature ][ $license ] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $data[ $feature ][ $license ];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,381 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin;
|
||||
|
||||
use WPMailSMTP\WP;
|
||||
|
||||
/**
|
||||
* Class ParentPageAbstract.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
abstract class ParentPageAbstract implements PageInterface {
|
||||
|
||||
/**
|
||||
* Slug of a page.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $slug;
|
||||
|
||||
/**
|
||||
* Page tabs.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @var PageAbstract[]
|
||||
*/
|
||||
protected $tabs = [];
|
||||
|
||||
/**
|
||||
* Page default tab slug.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $default_tab = '';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @param array $tabs Page tabs.
|
||||
*/
|
||||
public function __construct( $tabs = [] ) {
|
||||
|
||||
/**
|
||||
* Filters parent page tabs.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @param string[] $tabs Parent page tabs.
|
||||
*/
|
||||
$tabs = apply_filters( 'wp_mail_smtp_admin_page_' . $this->slug . '_tabs', $tabs );
|
||||
|
||||
if ( wp_mail_smtp()->get_admin()->is_admin_page( $this->slug ) ) {
|
||||
$this->init_tabs( $tabs );
|
||||
$this->hooks();
|
||||
}
|
||||
|
||||
if ( WP::is_doing_self_ajax() ) {
|
||||
$this->init_ajax( $tabs );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hooks.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
protected function hooks() {
|
||||
|
||||
add_action( 'admin_init', [ $this, 'process_actions' ] );
|
||||
|
||||
// Register tab related hooks.
|
||||
if ( isset( $this->tabs[ $this->get_current_tab() ] ) ) {
|
||||
$this->tabs[ $this->get_current_tab() ]->hooks();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize ajax actions.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param array $tabs Page tabs.
|
||||
*/
|
||||
private function init_ajax( $tabs ) {
|
||||
|
||||
foreach ( $tabs as $tab ) {
|
||||
if ( $this->is_valid_tab( $tab ) ) {
|
||||
( new $tab( $this ) )->ajax();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the page slug.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_slug() {
|
||||
|
||||
return $this->slug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the page tabs.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @return PageAbstract[]
|
||||
*/
|
||||
public function get_tabs() {
|
||||
|
||||
return $this->tabs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the page tabs slugs.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function get_tabs_slugs() {
|
||||
|
||||
return array_map(
|
||||
function ( $tab ) {
|
||||
return $tab->get_slug();
|
||||
},
|
||||
$this->tabs
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the page/tab link.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @param string $tab Tab to generate a link to.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_link( $tab = '' ) {
|
||||
|
||||
return add_query_arg(
|
||||
'tab',
|
||||
$this->get_defined_tab( $tab ),
|
||||
WP::admin_url( 'admin.php?page=' . Area::SLUG . '-' . $this->slug )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current tab.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_current_tab() {
|
||||
|
||||
$tab = isset( $_GET['tab'] ) ? sanitize_key( $_GET['tab'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
|
||||
return $this->get_defined_tab( $tab );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tab label.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param string $tab Tab key.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_tab_label( $tab ) {
|
||||
|
||||
$tabs = $this->get_tabs();
|
||||
|
||||
return isset( $tabs[ $tab ] ) ? $tabs[ $tab ]->get_label() : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tab title.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param string $tab Tab key.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_tab_title( $tab ) {
|
||||
|
||||
$tabs = $this->get_tabs();
|
||||
|
||||
return isset( $tabs[ $tab ] ) ? $tabs[ $tab ]->get_title() : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the defined or default tab.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @param string $tab Tab to check.
|
||||
*
|
||||
* @return string Defined tab. Fallback to default one if it doesn't exist.
|
||||
*/
|
||||
protected function get_defined_tab( $tab ) {
|
||||
|
||||
$tab = sanitize_key( $tab );
|
||||
|
||||
return in_array( $tab, $this->get_tabs_slugs(), true ) ? $tab : $this->default_tab;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize tabs.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @param array $tabs Page tabs.
|
||||
*/
|
||||
public function init_tabs( $tabs ) {
|
||||
|
||||
foreach ( $tabs as $key => $tab ) {
|
||||
if ( ! $this->is_valid_tab( $tab ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->tabs[ $key ] = new $tab( $this );
|
||||
}
|
||||
|
||||
// Sort tabs by priority.
|
||||
$this->sort_tabs();
|
||||
}
|
||||
|
||||
/**
|
||||
* All possible plugin forms manipulation and hooks registration will be done here.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public function process_actions() {
|
||||
|
||||
$tabs = $this->get_tabs_slugs();
|
||||
|
||||
// Allow to process only own tabs.
|
||||
if ( ! array_key_exists( $this->get_current_tab(), $tabs ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Process POST only if it exists.
|
||||
// phpcs:disable WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
|
||||
if ( ! empty( $_POST ) && isset( $_POST['wp-mail-smtp-post'] ) ) {
|
||||
if ( ! empty( $_POST['wp-mail-smtp'] ) ) {
|
||||
$post = $_POST['wp-mail-smtp'];
|
||||
} else {
|
||||
$post = [];
|
||||
}
|
||||
|
||||
$this->tabs[ $this->get_current_tab() ]->process_post( $post );
|
||||
}
|
||||
// phpcs:enable
|
||||
|
||||
// This won't do anything for most pages.
|
||||
// Works for plugin page only, when GET params are allowed.
|
||||
$this->tabs[ $this->get_current_tab() ]->process_auth();
|
||||
}
|
||||
|
||||
/**
|
||||
* Display page content based on the current tab.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public function display() {
|
||||
|
||||
$current_tab = $this->get_current_tab();
|
||||
$page_slug = $this->slug;
|
||||
?>
|
||||
<div class="wp-mail-smtp-page-title">
|
||||
<?php if ( count( $this->tabs ) > 1 ) : ?>
|
||||
<?php foreach ( $this->tabs as $tab ) : ?>
|
||||
<a href="<?php echo esc_url( $tab->get_link() ); ?>"
|
||||
class="tab <?php echo $current_tab === $tab->get_slug() ? 'active' : ''; ?>">
|
||||
<?php echo esc_html( $tab->get_label() ); ?>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
<?php else : ?>
|
||||
<span class="page-title"><?php echo esc_html( array_values( $this->tabs )[0]->get_title() ); ?></span>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
/**
|
||||
* Fires after page title.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param ParentPageAbstract $page Current page.
|
||||
*/
|
||||
do_action( "wp_mail_smtp_admin_page_{$page_slug}_{$current_tab}_display_header", $this );
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="wp-mail-smtp-page-content">
|
||||
<?php
|
||||
foreach ( $this->tabs as $tab ) {
|
||||
if ( $tab->get_slug() === $current_tab ) {
|
||||
|
||||
printf( '<h1 class="screen-reader-text">%s</h1>', esc_html( $tab->get_title() ) );
|
||||
|
||||
/**
|
||||
* Fires before tab content.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @param PageAbstract $tab Current tab.
|
||||
*/
|
||||
do_action( 'wp_mail_smtp_admin_pages_before_content', $tab );
|
||||
|
||||
/**
|
||||
* Fires before tab content.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param PageAbstract $tab Current tab.
|
||||
*/
|
||||
do_action( "wp_mail_smtp_admin_page_{$page_slug}_{$current_tab}_display_before", $tab );
|
||||
|
||||
$tab->display();
|
||||
|
||||
/**
|
||||
* Fires after tab content.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @param PageAbstract $tab Current tab.
|
||||
*/
|
||||
do_action( "wp_mail_smtp_admin_page_{$page_slug}_{$current_tab}_display_after", $tab );
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort tabs by priority.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
protected function sort_tabs() {
|
||||
|
||||
uasort(
|
||||
$this->tabs,
|
||||
function ( $a, $b ) {
|
||||
|
||||
return ( $a->get_priority() < $b->get_priority() ) ? - 1 : 1;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether tab is valid.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param array $tab Page tab.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function is_valid_tab( $tab ) {
|
||||
|
||||
return is_subclass_of( $tab, '\WPMailSMTP\Admin\PageAbstract' );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin;
|
||||
|
||||
use Automatic_Upgrader_Skin;
|
||||
|
||||
/**
|
||||
* WordPress class extended for on-the-fly plugin installations.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @since 1.7.1 Removed feedback() method override to be compatible with PHP5.3+ and WP5.3.
|
||||
* @since 3.11.0 Updated to extend Automatic_Upgrader_Skin.
|
||||
*/
|
||||
class PluginsInstallSkin extends Automatic_Upgrader_Skin {
|
||||
|
||||
/**
|
||||
* Empty out the header of its HTML content and only check to see if it has
|
||||
* been performed or not.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public function header() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty out the footer of its HTML contents.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public function footer() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instead of outputting HTML for errors, json_encode the errors and send them
|
||||
* back to the Ajax script for processing.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @param array $errors Array of errors with the install process.
|
||||
*/
|
||||
public function error( $errors ) {
|
||||
|
||||
if ( ! empty( $errors ) ) {
|
||||
wp_send_json_error( $errors );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty out JavaScript output that calls function to decrement the update counts.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @param string $type Type of update count to decrement.
|
||||
*/
|
||||
public function decrement_update_count( $type ) {
|
||||
}
|
||||
}
|
||||
|
||||
227
wp/wp-content/plugins/wp-mail-smtp/src/Admin/Review.php
Normal file
227
wp/wp-content/plugins/wp-mail-smtp/src/Admin/Review.php
Normal file
@@ -0,0 +1,227 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Admin;
|
||||
|
||||
use WPMailSMTP\Options;
|
||||
|
||||
/**
|
||||
* Class for admin notice requesting plugin review.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
class Review {
|
||||
|
||||
/**
|
||||
* The name of the WP option for the review notice data.
|
||||
*
|
||||
* Data attributes:
|
||||
* - time
|
||||
* - dismissed
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
const NOTICE_OPTION = 'wp_mail_smtp_review_notice';
|
||||
|
||||
/**
|
||||
* Days the plugin waits before displaying a review request.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
const WAIT_PERIOD = 14;
|
||||
|
||||
/**
|
||||
* Initialize hooks.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public function hooks() {
|
||||
|
||||
add_action( 'admin_init', [ $this, 'admin_notices' ] );
|
||||
add_action( 'wp_ajax_wp_mail_smtp_review_dismiss', array( $this, 'review_dismiss' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Display notices only in Network Admin if in Multisite.
|
||||
* Otherwise, display in Admin Dashboard.
|
||||
*
|
||||
* @since 3.8.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function admin_notices() { // phpcs:ignore WPForms.PHP.HooksMethod.InvalidPlaceForAddingHooks
|
||||
|
||||
if ( is_multisite() ) {
|
||||
add_action( 'network_admin_notices', [ $this, 'review_request' ] );
|
||||
} else {
|
||||
add_action( 'admin_notices', [ $this, 'review_request' ] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add admin notices as needed for reviews.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public function review_request() {
|
||||
|
||||
// Only consider showing the review request to admin users.
|
||||
if ( ! is_super_admin() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Verify that we can do a check for reviews.
|
||||
$review = get_option( self::NOTICE_OPTION );
|
||||
$time = time();
|
||||
$load = false;
|
||||
|
||||
if ( empty( $review ) ) {
|
||||
$review = [
|
||||
'time' => $time,
|
||||
'dismissed' => false,
|
||||
];
|
||||
update_option( self::NOTICE_OPTION, $review );
|
||||
} else {
|
||||
// Check if it has been dismissed or not.
|
||||
if ( isset( $review['dismissed'] ) && ! $review['dismissed'] ) {
|
||||
$load = true;
|
||||
}
|
||||
}
|
||||
|
||||
// If we cannot load, return early.
|
||||
if ( ! $load ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->review();
|
||||
}
|
||||
|
||||
/**
|
||||
* Maybe show review request.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
private function review() {
|
||||
|
||||
// Get the currently selected mailer.
|
||||
$mailer = Options::init()->get( 'mail', 'mailer' );
|
||||
|
||||
// Skip if no or the default mailer is selected.
|
||||
if ( empty( $mailer ) || $mailer === 'mail' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Fetch when plugin was initially activated.
|
||||
$activated = get_option( 'wp_mail_smtp_activated_time' );
|
||||
|
||||
// Skip if the plugin activated time is not set.
|
||||
if ( empty( $activated ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$mailer_object = wp_mail_smtp()
|
||||
->get_providers()
|
||||
->get_mailer( $mailer, wp_mail_smtp()->get_processor()->get_phpmailer() );
|
||||
|
||||
// Check if mailer setup is complete.
|
||||
$mailer_setup_complete = ! empty( $mailer_object ) ? $mailer_object->is_mailer_complete() : false;
|
||||
|
||||
// Skip if the mailer is not set or the plugin is active for less then a defined number of days.
|
||||
if ( ! $mailer_setup_complete || ( $activated + ( DAY_IN_SECONDS * self::WAIT_PERIOD ) ) > time() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We have a candidate! Output a review message.
|
||||
?>
|
||||
<div class="notice notice-info is-dismissible wp-mail-smtp-review-notice">
|
||||
<div class="wp-mail-smtp-review-step wp-mail-smtp-review-step-1">
|
||||
<p><?php esc_html_e( 'Are you enjoying WP Mail SMTP?', 'wp-mail-smtp' ); ?></p>
|
||||
<p>
|
||||
<a href="#" class="wp-mail-smtp-review-switch-step" data-step="3"><?php esc_html_e( 'Yes', 'wp-mail-smtp' ); ?></a><br />
|
||||
<a href="#" class="wp-mail-smtp-review-switch-step" data-step="2"><?php esc_html_e( 'Not Really', 'wp-mail-smtp' ); ?></a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-review-step wp-mail-smtp-review-step-2" style="display: none">
|
||||
<p><?php esc_html_e( 'We\'re sorry to hear you aren\'t enjoying WP Mail SMTP. We would love a chance to improve. Could you take a minute and let us know what we can do better?', 'wp-mail-smtp' ); ?></p>
|
||||
<p>
|
||||
<?php
|
||||
printf(
|
||||
'<a href="%1$s" class="wp-mail-smtp-dismiss-review-notice wp-mail-smtp-review-out" target="_blank" rel="noopener noreferrer">%2$s</a>',
|
||||
// phpcs:ignore WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
|
||||
esc_url( wp_mail_smtp()->get_utm_url( 'https://wpmailsmtp.com/plugin-feedback/', [ 'medium' => 'review-notice', 'content' => 'Give Feedback' ] ) ),
|
||||
esc_html__( 'Give Feedback', 'wp-mail-smtp' )
|
||||
);
|
||||
?>
|
||||
<br>
|
||||
<a href="#" class="wp-mail-smtp-dismiss-review-notice" target="_blank" rel="noopener noreferrer">
|
||||
<?php esc_html_e( 'No thanks', 'wp-mail-smtp' ); ?>
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="wp-mail-smtp-review-step wp-mail-smtp-review-step-3" style="display: none">
|
||||
<p><?php esc_html_e( 'That’s awesome! Could you please do me a BIG favor and give it a 5-star rating on WordPress to help us spread the word and boost our motivation?', 'wp-mail-smtp' ); ?></p>
|
||||
<p><strong><?php echo wp_kses( __( '~ Jared Atchison<br>Co-Founder, WP Mail SMTP', 'wp-mail-smtp' ), [ 'br' => [] ] ); ?></strong></p>
|
||||
<p>
|
||||
<a href="https://wordpress.org/support/plugin/wp-mail-smtp/reviews/?filter=5#new-post" class="wp-mail-smtp-dismiss-review-notice wp-mail-smtp-review-out" target="_blank" rel="noopener noreferrer">
|
||||
<?php esc_html_e( 'Ok, you deserve it', 'wp-mail-smtp' ); ?>
|
||||
</a><br>
|
||||
<a href="#" class="wp-mail-smtp-dismiss-review-notice" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Nope, maybe later', 'wp-mail-smtp' ); ?></a><br>
|
||||
<a href="#" class="wp-mail-smtp-dismiss-review-notice" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'I already did', 'wp-mail-smtp' ); ?></a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
jQuery( document ).ready( function ( $ ) {
|
||||
$( document ).on( 'click', '.wp-mail-smtp-dismiss-review-notice, .wp-mail-smtp-review-notice button', function( e ) {
|
||||
if ( ! $( this ).hasClass( 'wp-mail-smtp-review-out' ) ) {
|
||||
e.preventDefault();
|
||||
}
|
||||
$.post( ajaxurl, { action: 'wp_mail_smtp_review_dismiss' } );
|
||||
$( '.wp-mail-smtp-review-notice' ).remove();
|
||||
} );
|
||||
|
||||
$( document ).on( 'click', '.wp-mail-smtp-review-switch-step', function( e ) {
|
||||
e.preventDefault();
|
||||
var target = parseInt( $( this ).attr( 'data-step' ), 10 );
|
||||
|
||||
if ( target ) {
|
||||
var $notice = $( this ).closest( '.wp-mail-smtp-review-notice' );
|
||||
var $review_step = $notice.find( '.wp-mail-smtp-review-step-' + target );
|
||||
|
||||
if ( $review_step.length > 0 ) {
|
||||
$notice.find( '.wp-mail-smtp-review-step:visible' ).fadeOut( function() {
|
||||
$review_step.fadeIn();
|
||||
} );
|
||||
}
|
||||
}
|
||||
} );
|
||||
} );
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Dismiss the review admin notice.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public function review_dismiss() {
|
||||
|
||||
$review = get_option( self::NOTICE_OPTION, [] );
|
||||
$review['time'] = time();
|
||||
$review['dismissed'] = true;
|
||||
update_option( self::NOTICE_OPTION, $review );
|
||||
|
||||
if ( is_super_admin() && is_multisite() ) {
|
||||
$site_list = get_sites();
|
||||
foreach ( (array) $site_list as $site ) {
|
||||
switch_to_blog( $site->blog_id );
|
||||
|
||||
update_option( self::NOTICE_OPTION, $review );
|
||||
|
||||
restore_current_blog();
|
||||
}
|
||||
}
|
||||
|
||||
wp_send_json_success();
|
||||
}
|
||||
}
|
||||
1469
wp/wp-content/plugins/wp-mail-smtp/src/Admin/SetupWizard.php
Normal file
1469
wp/wp-content/plugins/wp-mail-smtp/src/Admin/SetupWizard.php
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user