updated plugin WP Mail SMTP version 2.3.1

This commit is contained in:
2020-08-24 15:45:02 +00:00
committed by Gitium
parent be08bbbabd
commit fd5eaaad6c
66 changed files with 3703 additions and 1342 deletions

View File

@ -22,33 +22,41 @@ class Options extends OptionsAbstract {
* Gmail Options constructor.
*
* @since 1.0.0
* @since 2.3.0 Added supports parameter.
*/
public function __construct() {
parent::__construct(
array(
[
'logo_url' => wp_mail_smtp()->assets_url . '/images/providers/google.svg',
'slug' => self::SLUG,
'title' => esc_html__( 'Gmail', 'wp-mail-smtp' ),
'description' => sprintf(
wp_kses( /* translators: %s - URL to our Gmail doc. */
__( 'Send emails using your Gmail or G Suite (formerly Google Apps) account, all while keeping your login credentials safe. Other Google SMTP methods require enabling less secure apps in your account and entering your password. However, this integration uses the Google API to improve email delivery issues while keeping your site secure.<br><br>Read our <a href="%s" target="_blank" rel="noopener noreferrer">Gmail documentation</a> to learn how to configure Gmail or G Suite.', 'wp-mail-smtp' ),
array(
'br' => array(),
'a' => array(
'href' => array(),
'rel' => array(),
'target' => array(),
),
)
[
'br' => [],
'a' => [
'href' => [],
'rel' => [],
'target' => [],
],
]
),
'https://wpmailsmtp.com/docs/how-to-set-up-the-gmail-mailer-in-wp-mail-smtp/'
),
'notices' => array(
'notices' => [
'educational' => esc_html__( 'The Gmail mailer works well for sites that send low numbers of emails. However, Gmail\'s API has rate limitations and a number of additional restrictions that can lead to challenges during setup. If you expect to send a high volume of emails, or if you find that your web host is not compatible with the Gmail API restrictions, then we recommend considering a different mailer option.', 'wp-mail-smtp' ),
),
],
'php' => '5.5',
)
'supports' => [
'from_email' => true,
'from_name' => true,
'return_path' => false,
'from_email_force' => true,
'from_name_force' => true,
],
]
);
}
@ -109,7 +117,7 @@ class Options extends OptionsAbstract {
<label for="wp-mail-smtp-setting-<?php echo esc_attr( $this->get_slug() ); ?>-client_redirect"><?php esc_html_e( 'Authorized redirect URI', 'wp-mail-smtp' ); ?></label>
</div>
<div class="wp-mail-smtp-setting-field">
<input type="text" readonly="readonly"
<input type="text" readonly="readonly" onfocus="this.select();"
value="<?php echo esc_attr( Auth::get_plugin_auth_url() ); ?>"
id="wp-mail-smtp-setting-<?php echo esc_attr( $this->get_slug() ); ?>-client_redirect"
/>

View File

@ -32,6 +32,7 @@ class Loader {
'amazonses' => 'WPMailSMTP\Providers\AmazonSES\\',
'gmail' => 'WPMailSMTP\Providers\Gmail\\',
'outlook' => 'WPMailSMTP\Providers\Outlook\\',
'zoho' => 'WPMailSMTP\Providers\Zoho\\',
'smtp' => 'WPMailSMTP\Providers\SMTP\\',
'pepipost' => 'WPMailSMTP\Providers\Pepipost\\',
);
@ -56,6 +57,10 @@ class Loader {
unset( $this->providers['pepipost'] );
}
if ( ! Options::init()->is_mailer_active( 'pepipostapi' ) ) {
unset( $this->providers['pepipostapi'] );
}
return apply_filters( 'wp_mail_smtp_providers_loader_get_providers', $this->providers );
}
@ -200,4 +205,35 @@ class Loader {
return apply_filters( 'wp_mail_smtp_providers_loader_get_entity', $entity, $provider, $request );
}
/**
* Get supports options for all mailers.
*
* @since 2.3.0
*
* @return array
*/
public function get_supports_all() {
$supports = [];
foreach ( $this->get_providers() as $provider => $path ) {
$option = $this->get_options( $provider );
if ( ! $option instanceof OptionsAbstract ) {
continue;
}
$mailer_slug = $option->get_slug();
$mailer_supports = $option->get_supports();
if ( empty( $mailer_slug ) || empty( $mailer_supports ) ) {
continue;
}
$supports[ $mailer_slug ] = $mailer_supports;
}
return apply_filters( 'wp_mail_smtp_providers_loader_get_supports_all', $supports );
}
}

View File

@ -54,12 +54,22 @@ abstract class OptionsAbstract implements OptionsInterface {
*/
protected $options;
/**
* An array with mailer supported setting fields.
*
* @since 2.3.0
*
* @var array
*/
protected $supports;
/**
* ProviderAbstract constructor.
*
* @since 1.0.0
* @since 2.3.0 Added supports parameter.
*
* @param array $params
* @param array $params The mailer options parameters.
*/
public function __construct( $params ) {
@ -120,6 +130,8 @@ abstract class OptionsAbstract implements OptionsInterface {
$this->logo_url = esc_url_raw( $params['logo_url'] );
}
$this->supports = ( ! empty( $params['supports'] ) ) ? $params['supports'] : $this->get_supports_defaults();
$this->options = new Options();
}
@ -474,4 +486,33 @@ abstract class OptionsAbstract implements OptionsInterface {
<?php
}
/**
* Return the defaults for the mailer supported settings.
*
* @since 2.3.0
*
* @return array
*/
public function get_supports_defaults() {
return [
'from_email' => true,
'from_name' => true,
'return_path' => true,
'from_email_force' => true,
'from_name_force' => true,
];
}
/**
* Get the mailer supported settings.
*
* @since 2.3.0
*
* @return array
*/
public function get_supports() {
return apply_filters( 'wp_mail_smtp_providers_provider_get_supports', $this->supports, $this );
}
}

View File

@ -1,64 +1,71 @@
<?php
namespace WPMailSMTP\Providers;
/**
* Interface ProviderInterface, shared between all current and future providers.
* Defines required methods across all providers.
*
* @since 1.0.0
*/
interface OptionsInterface {
/**
* Get the mailer provider slug.
*
* @since 1.0.0
*
* @return string
*/
public function get_slug();
/**
* Get the mailer provider title (or name).
*
* @since 1.0.0
*
* @return string
*/
public function get_title();
/**
* Get the mailer provider description.
*
* @since 1.0.0
*
* @return string
*/
public function get_description();
/**
* Get the mailer provider minimum PHP version.
*
* @since 1.0.0
*
* @return string
*/
public function get_php_version();
/**
* Get the mailer provider logo URL.
*
* @since 1.0.0
*
* @return string
*/
public function get_logo_url();
/**
* Output the mailer provider options.
*
* @since 1.0.0
*/
public function display_options();
}
<?php
namespace WPMailSMTP\Providers;
/**
* Interface ProviderInterface, shared between all current and future providers.
* Defines required methods across all providers.
*
* @since 1.0.0
*/
interface OptionsInterface {
/**
* Get the mailer provider slug.
*
* @since 1.0.0
*
* @return string
*/
public function get_slug();
/**
* Get the mailer provider title (or name).
*
* @since 1.0.0
*
* @return string
*/
public function get_title();
/**
* Get the mailer provider description.
*
* @since 1.0.0
*
* @return string
*/
public function get_description();
/**
* Get the mailer provider minimum PHP version.
*
* @since 1.0.0
*
* @return string
*/
public function get_php_version();
/**
* Get the mailer provider logo URL.
*
* @since 1.0.0
*
* @return string
*/
public function get_logo_url();
/**
* Output the mailer provider options.
*
* @since 1.0.0
*/
public function display_options();
/**
* Get the mailer supported settings.
*
* @since 2.3.0
*/
public function get_supports();
}

View File

@ -23,19 +23,19 @@ class Options extends OptionsAbstract {
* Options constructor.
*
* @since 1.8.0
* @since 2.3.0 Added 'supports' parameter.
*/
public function __construct() {
$description = sprintf(
wp_kses( /* translators: %1$s - URL to pepipost.com site. */
__( '<strong><a href="%1$s" target="_blank" rel="noopener noreferrer">Pepipost</a> is a recommended transactional email service.</strong> Every month Pepipost delivers over 8 billion emails from 20,000+ customers. Their mission is to reliably send emails in the most efficient way and at the most disruptive pricing ever. Pepipost provides users 30,000 free emails the first 30 days.', 'wp-mail-smtp' ) .
__( '<a href="%1$s" target="_blank" rel="noopener noreferrer">Pepipost</a> is a transactional email service. Every month Pepipost delivers over 8 billion emails from 20,000+ customers. Their mission is to reliably send emails in the most efficient way and at the most disruptive pricing ever. Pepipost provides users 30,000 free emails the first 30 days.', 'wp-mail-smtp' ) .
'<br><br>' .
/* translators: %1$s - URL to wpmailsmtp.com doc. */
__( 'Read our <a href="%2$s" target="_blank" rel="noopener noreferrer">Pepipost documentation</a> to learn how to configure Pepipost and improve your email deliverability.', 'wp-mail-smtp' ),
array(
'br' => true,
'strong' => true,
'a' => array(
'br' => true,
'a' => array(
'href' => true,
'rel' => true,
'target' => true,
@ -55,14 +55,20 @@ class Options extends OptionsAbstract {
}
parent::__construct(
array(
[
'logo_url' => wp_mail_smtp()->assets_url . '/images/providers/pepipost.png',
'slug' => self::SLUG,
'title' => esc_html__( 'Pepipost', 'wp-mail-smtp' ),
'description' => $description,
'recommended' => true,
'php' => '5.3',
)
'supports' => [
'from_email' => true,
'from_name' => true,
'return_path' => false,
'from_email_force' => true,
'from_name_force' => true,
],
]
);
}

View File

@ -23,6 +23,7 @@ class Options extends OptionsAbstract {
* Options constructor.
*
* @since 2.0.0
* @since 2.3.0 Added supports parameter.
*/
public function __construct() {
@ -61,13 +62,20 @@ class Options extends OptionsAbstract {
}
parent::__construct(
array(
[
'logo_url' => wp_mail_smtp()->assets_url . '/images/providers/smtp-com.svg',
'slug' => self::SLUG,
'title' => esc_html__( 'SMTP.com', 'wp-mail-smtp' ),
'description' => $description,
'recommended' => true,
)
'supports' => [
'from_email' => true,
'from_name' => true,
'return_path' => false,
'from_email_force' => true,
'from_name_force' => true,
],
]
);
}

View File

@ -1,96 +1,104 @@
<?php
namespace WPMailSMTP\Providers\Sendgrid;
use WPMailSMTP\Providers\OptionsAbstract;
/**
* Class Option.
*
* @since 1.0.0
*/
class Options extends OptionsAbstract {
/**
* Options constructor.
*
* @since 1.0.0
*/
public function __construct() {
parent::__construct(
array(
'logo_url' => wp_mail_smtp()->assets_url . '/images/providers/sendgrid.svg',
'slug' => 'sendgrid',
'title' => esc_html__( 'SendGrid', 'wp-mail-smtp' ),
'description' => sprintf(
wp_kses(
/* translators: %1$s - opening link tag; %2$s - closing link tag; %3$s - opening link tag; %4$s - closing link tag. */
__( '%1$sSendGrid%2$s is one of the leading transactional email services, sending over 35 billion emails every month. They provide users 100 free emails per day.<br><br>Read our %3$sSendGrid documentation%4$s to learn how to set up SendGrid and improve your email deliverability.', 'wp-mail-smtp' ),
array(
'br' => array(),
'a' => array(
'href' => array(),
'rel' => array(),
'target' => array(),
),
)
),
'<a href="https://sendgrid.com" target="_blank" rel="noopener noreferrer">',
'</a>',
'<a href="https://wpmailsmtp.com/docs/how-to-set-up-the-sendgrid-mailer-in-wp-mail-smtp/" target="_blank" rel="noopener noreferrer">',
'</a>'
),
)
);
}
/**
* @inheritdoc
*/
public function display_options() {
?>
<!-- API Key -->
<div id="wp-mail-smtp-setting-row-<?php echo esc_attr( $this->get_slug() ); ?>-api_key" class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-text wp-mail-smtp-clear">
<div class="wp-mail-smtp-setting-label">
<label for="wp-mail-smtp-setting-<?php echo esc_attr( $this->get_slug() ); ?>-api_key"><?php esc_html_e( 'API Key', 'wp-mail-smtp' ); ?></label>
</div>
<div class="wp-mail-smtp-setting-field">
<?php if ( $this->options->is_const_defined( $this->get_slug(), 'api_key' ) ) : ?>
<input type="text" disabled value="****************************************"
id="wp-mail-smtp-setting-<?php echo esc_attr( $this->get_slug() ); ?>-api_key"
/>
<?php $this->display_const_set_message( 'WPMS_SENDGRID_API_KEY' ); ?>
<?php else : ?>
<input type="password" spellcheck="false"
name="wp-mail-smtp[<?php echo esc_attr( $this->get_slug() ); ?>][api_key]"
value="<?php echo esc_attr( $this->options->get( $this->get_slug(), 'api_key' ) ); ?>"
id="wp-mail-smtp-setting-<?php echo esc_attr( $this->get_slug() ); ?>-api_key"
/>
<?php endif; ?>
<p class="desc">
<?php
printf(
/* translators: %s - API key link. */
esc_html__( 'Follow this link to get an API Key from SendGrid: %s.', 'wp-mail-smtp' ),
'<a href="https://app.sendgrid.com/settings/api_keys" target="_blank" rel="noopener noreferrer">' .
esc_html__( 'Create API Key', 'wp-mail-smtp' ) .
'</a>'
);
?>
<br/>
<?php
printf(
/* translators: %s - SendGrid access level. */
esc_html__( 'To send emails you will need only a %s access level for this API key.', 'wp-mail-smtp' ),
'<code>Mail Send</code>'
);
?>
</p>
</div>
</div>
<?php
}
}
<?php
namespace WPMailSMTP\Providers\Sendgrid;
use WPMailSMTP\Providers\OptionsAbstract;
/**
* Class Option.
*
* @since 1.0.0
*/
class Options extends OptionsAbstract {
/**
* Options constructor.
*
* @since 1.0.0
* @since 2.3.0 Added supports parameter.
*/
public function __construct() {
parent::__construct(
[
'logo_url' => wp_mail_smtp()->assets_url . '/images/providers/sendgrid.svg',
'slug' => 'sendgrid',
'title' => esc_html__( 'SendGrid', 'wp-mail-smtp' ),
'description' => sprintf(
wp_kses(
/* translators: %1$s - opening link tag; %2$s - closing link tag; %3$s - opening link tag; %4$s - closing link tag. */
__( '%1$sSendGrid%2$s is one of the leading transactional email services, sending over 35 billion emails every month. They provide users 100 free emails per day.<br><br>Read our %3$sSendGrid documentation%4$s to learn how to set up SendGrid and improve your email deliverability.', 'wp-mail-smtp' ),
[
'br' => [],
'a' => [
'href' => [],
'rel' => [],
'target' => [],
],
]
),
'<a href="https://sendgrid.com" target="_blank" rel="noopener noreferrer">',
'</a>',
'<a href="https://wpmailsmtp.com/docs/how-to-set-up-the-sendgrid-mailer-in-wp-mail-smtp/" target="_blank" rel="noopener noreferrer">',
'</a>'
),
'supports' => [
'from_email' => true,
'from_name' => true,
'return_path' => false,
'from_email_force' => true,
'from_name_force' => true,
],
]
);
}
/**
* @inheritdoc
*/
public function display_options() {
?>
<!-- API Key -->
<div id="wp-mail-smtp-setting-row-<?php echo esc_attr( $this->get_slug() ); ?>-api_key" class="wp-mail-smtp-setting-row wp-mail-smtp-setting-row-text wp-mail-smtp-clear">
<div class="wp-mail-smtp-setting-label">
<label for="wp-mail-smtp-setting-<?php echo esc_attr( $this->get_slug() ); ?>-api_key"><?php esc_html_e( 'API Key', 'wp-mail-smtp' ); ?></label>
</div>
<div class="wp-mail-smtp-setting-field">
<?php if ( $this->options->is_const_defined( $this->get_slug(), 'api_key' ) ) : ?>
<input type="text" disabled value="****************************************"
id="wp-mail-smtp-setting-<?php echo esc_attr( $this->get_slug() ); ?>-api_key"
/>
<?php $this->display_const_set_message( 'WPMS_SENDGRID_API_KEY' ); ?>
<?php else : ?>
<input type="password" spellcheck="false"
name="wp-mail-smtp[<?php echo esc_attr( $this->get_slug() ); ?>][api_key]"
value="<?php echo esc_attr( $this->options->get( $this->get_slug(), 'api_key' ) ); ?>"
id="wp-mail-smtp-setting-<?php echo esc_attr( $this->get_slug() ); ?>-api_key"
/>
<?php endif; ?>
<p class="desc">
<?php
printf(
/* translators: %s - API key link. */
esc_html__( 'Follow this link to get an API Key from SendGrid: %s.', 'wp-mail-smtp' ),
'<a href="https://app.sendgrid.com/settings/api_keys" target="_blank" rel="noopener noreferrer">' .
esc_html__( 'Create API Key', 'wp-mail-smtp' ) .
'</a>'
);
?>
<br/>
<?php
printf(
/* translators: %s - SendGrid access level. */
esc_html__( 'To send emails you will need only a %s access level for this API key.', 'wp-mail-smtp' ),
'<code>Mail Send</code>'
);
?>
</p>
</div>
</div>
<?php
}
}

View File

@ -23,11 +23,12 @@ class Options extends OptionsAbstract {
* Options constructor.
*
* @since 1.6.0
* @since 2.3.0 Added supports parameter.
*/
public function __construct() {
parent::__construct(
array(
[
'logo_url' => wp_mail_smtp()->assets_url . '/images/providers/sendinblue.svg',
'slug' => self::SLUG,
'title' => esc_html__( 'Sendinblue', 'wp-mail-smtp' ),
@ -38,19 +39,26 @@ class Options extends OptionsAbstract {
'<br><br>' .
/* translators: %2$s - URL to wpmailsmtp.com doc. */
__( 'Read our <a href="%2$s" target="_blank" rel="noopener noreferrer">Sendinblue documentation</a> to learn how to configure Sendinblue and improve your email deliverability.', 'wp-mail-smtp' ),
array(
[
'br' => true,
'a' => array(
'a' => [
'href' => true,
'rel' => true,
'target' => true,
),
)
],
]
),
'https://wpmailsmtp.com/go/sendinblue/',
'https://wpmailsmtp.com/docs/how-to-set-up-the-sendinblue-mailer-in-wp-mail-smtp'
),
)
'supports' => [
'from_email' => true,
'from_name' => true,
'return_path' => false,
'from_email_force' => true,
'from_name_force' => true,
],
]
);
}

View File

@ -0,0 +1,46 @@
<?php
namespace WPMailSMTP\Providers\Zoho;
use WPMailSMTP\Providers\OptionsAbstract;
/**
* Class Options.
*
* @since 2.3.0
*/
class Options extends OptionsAbstract {
/**
* Zoho Options constructor.
*
* @since 2.3.0
*/
public function __construct() {
parent::__construct(
array(
'logo_url' => wp_mail_smtp()->assets_url . '/images/providers/zoho.svg',
'slug' => 'zoho',
'title' => esc_html__( 'Zoho Mail', 'wp-mail-smtp' ),
'disabled' => true,
)
);
}
/**
* {@inheritdoc}
*
* @since 2.3.0
*/
public function display_options() {
?>
<p>
<?php esc_html_e( 'We\'re sorry, the Zoho Mail mailer is not available on your plan. Please upgrade to the PRO plan to unlock all these awesome features.', 'wp-mail-smtp' ); ?>
</p>
<?php
}
}