plugin updates

This commit is contained in:
Tony Volpe
2024-11-15 13:53:04 -05:00
parent 1293d604ca
commit 0238f0c4ca
2009 changed files with 163492 additions and 89543 deletions

View File

@@ -28,7 +28,7 @@ class Options {
* @var array Map of all the default options of the plugin.
*/
private static $map = [
'mail' => [
'mail' => [
'from_name',
'from_email',
'mailer',
@@ -36,7 +36,7 @@ class Options {
'from_name_force',
'from_email_force',
],
'smtp' => [
'smtp' => [
'host',
'port',
'encryption',
@@ -45,60 +45,64 @@ class Options {
'user',
'pass',
],
'gmail' => [
'gmail' => [
'one_click_setup_enabled',
'client_id',
'client_secret',
],
'outlook' => [
'outlook' => [
'client_id',
'client_secret',
],
'zoho' => [
'zoho' => [
'domain',
'client_id',
'client_secret',
],
'amazonses' => [
'amazonses' => [
'client_id',
'client_secret',
'region',
],
'mailgun' => [
'mailgun' => [
'api_key',
'domain',
'region',
],
'sendgrid' => [
'mailjet' => [
'api_key',
'secret_key',
],
'sendgrid' => [
'api_key',
'domain',
],
'sparkpost' => [
'sparkpost' => [
'api_key',
'region',
],
'postmark' => [
'postmark' => [
'server_api_token',
'message_stream',
],
'smtpcom' => [
'smtpcom' => [
'api_key',
'channel',
],
'sendinblue' => [
'sendinblue' => [
'api_key',
'domain',
],
'sendlayer' => [
'sendlayer' => [
'api_key',
],
'smtp2go' => [
'smtp2go' => [
'api_key',
],
'pepipostapi' => [
'pepipostapi' => [
'api_key',
],
'pepipost' => [
'pepipost' => [
'host',
'port',
'encryption',
@@ -106,26 +110,30 @@ class Options {
'user',
'pass',
],
'license' => [
'license' => [
'key',
],
'alert_email' => [
'alert_email' => [
'enabled',
'connections',
],
'alert_slack_webhook' => [
'alert_slack_webhook' => [
'enabled',
'connections',
],
'alert_twilio_sms' => [
'alert_discord_webhook' => [
'enabled',
'connections',
],
'alert_custom_webhook' => [
'alert_twilio_sms' => [
'enabled',
'connections',
],
'alert_events' => [
'alert_custom_webhook' => [
'enabled',
'connections',
],
'alert_events' => [
'email_hard_bounced',
],
];
@@ -144,6 +152,7 @@ class Options {
'amazonses',
'gmail',
'mailgun',
'mailjet',
'outlook',
'postmark',
'sendgrid',
@@ -319,7 +328,7 @@ class Options {
* Get the values saved in DB.
* If plugin is configured with constants right from the start - this will not have all the values.
*/
$options = isset( $this->options[ $group ] ) ? $this->options[ $group ] : array();
$options = isset( $this->options[ $group ] ) ? $this->options[ $group ] : [];
// We need to process certain constants-aware options through actual constants.
if ( isset( self::$map[ $group ] ) ) {
@@ -439,7 +448,7 @@ class Options {
break;
case 'encryption':
$value = in_array( $group, array( 'smtp', 'pepipost' ), true ) ? 'none' : $value;
$value = in_array( $group, [ 'smtp', 'pepipost' ], true ) ? 'none' : $value;
break;
case 'region':
@@ -448,7 +457,7 @@ class Options {
case 'auth':
case 'autotls':
$value = in_array( $group, array( 'smtp', 'pepipost' ), true ) ? false : true;
$value = in_array( $group, [ 'smtp', 'pepipost' ], true ) ? false : true;
break;
case 'pass':
@@ -479,7 +488,7 @@ class Options {
*
* @param string $group
* @param string $key
* @param mixed $value
* @param mixed $value
*
* @return mixed
*/
@@ -648,6 +657,20 @@ class Options {
break;
case 'mailjet':
switch ( $key ) {
case 'api_key':
/** @noinspection PhpUndefinedConstantInspection */
$return = $this->is_const_defined( $group, $key ) ? WPMS_MAILJET_API_KEY : $value;
break;
case 'secret_key':
/** @noinspection PhpUndefinedConstantInspection */
$return = $this->is_const_defined( $group, $key ) ? WPMS_MAILJET_SECRET_KEY : $value;
break;
}
break;
case 'sendgrid':
switch ( $key ) {
case 'api_key':
@@ -754,6 +777,15 @@ class Options {
break;
case 'alert_discord_webhook':
switch ( $key ) {
case 'connections':
$return = $this->is_const_defined( $group, $key ) ? [ [ 'webhook_url' => WPMS_ALERT_DISCORD_WEBHOOK_URL ] ] : $value;
break;
}
break;
case 'alert_teams_webhook':
switch ( $key ) {
case 'connections':
@@ -1016,6 +1048,18 @@ class Options {
break;
case 'mailjet':
switch ( $key ) {
case 'api_key':
$return = defined( 'WPMS_MAILJET_API_KEY' ) && WPMS_MAILJET_API_KEY;
break;
case 'secret_key':
$return = defined( 'WPMS_MAILJET_SECRET_KEY' ) && WPMS_MAILJET_SECRET_KEY;
break;
}
break;
case 'sendgrid':
switch ( $key ) {
case 'api_key':
@@ -1112,6 +1156,15 @@ class Options {
break;
case 'alert_discord_webhook':
switch ( $key ) {
case 'connections':
$return = defined( 'WPMS_ALERT_DISCORD_WEBHOOK_URL' ) && WPMS_ALERT_DISCORD_WEBHOOK_URL;
break;
}
break;
case 'alert_teams_webhook':
switch ( $key ) {
case 'connections':
@@ -1125,9 +1178,9 @@ class Options {
switch ( $key ) {
case 'connections':
$return = defined( 'WPMS_ALERT_TWILIO_SMS_ACCOUNT_SID' ) && WPMS_ALERT_TWILIO_SMS_ACCOUNT_SID &&
defined( 'WPMS_ALERT_TWILIO_SMS_AUTH_TOKEN' ) && WPMS_ALERT_TWILIO_SMS_AUTH_TOKEN &&
defined( 'WPMS_ALERT_TWILIO_SMS_FROM_PHONE_NUMBER' ) && WPMS_ALERT_TWILIO_SMS_FROM_PHONE_NUMBER &&
defined( 'WPMS_ALERT_TWILIO_SMS_TO_PHONE_NUMBER' ) && WPMS_ALERT_TWILIO_SMS_TO_PHONE_NUMBER;
defined( 'WPMS_ALERT_TWILIO_SMS_AUTH_TOKEN' ) && WPMS_ALERT_TWILIO_SMS_AUTH_TOKEN &&
defined( 'WPMS_ALERT_TWILIO_SMS_FROM_PHONE_NUMBER' ) && WPMS_ALERT_TWILIO_SMS_FROM_PHONE_NUMBER &&
defined( 'WPMS_ALERT_TWILIO_SMS_TO_PHONE_NUMBER' ) && WPMS_ALERT_TWILIO_SMS_TO_PHONE_NUMBER;
break;
}
@@ -1356,11 +1409,13 @@ class Options {
if ( $mailer === 'smtp' && ! $this->is_const_defined( 'smtp', 'pass' ) ) {
try {
$options[ $mailer ][ $option_name ] = Crypto::encrypt( $option_value );
} catch ( \Exception $e ) {} // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch, Squiz.Commenting.EmptyCatchComment.Missing, Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace
} catch ( \Exception $e ) {
} // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch, Squiz.Commenting.EmptyCatchComment.Missing, Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace
}
break;
case 'api_key': // mailgun/sendgrid/sendinblue/pepipostapi/smtpcom/sparkpost/sendlayer/smtp2go.
case 'api_key': // mailgun/sendgrid/sendinblue/pepipostapi/smtpcom/sparkpost/sendlayer/smtp2go/mailjet.
case 'secret_key': // mailjet.
case 'domain': // mailgun/zoho/sendgrid/sendinblue.
case 'client_id': // gmail/outlook/amazonses/zoho.
case 'client_secret': // gmail/outlook/amazonses/zoho.
@@ -1396,16 +1451,16 @@ class Options {
$arrays = func_get_args();
if ( count( $arrays ) < 2 ) {
return isset( $arrays[0] ) ? $arrays[0] : array();
return isset( $arrays[0] ) ? $arrays[0] : [];
}
$merged = array();
$merged = [];
while ( $arrays ) {
$array = array_shift( $arrays );
if ( ! is_array( $array ) ) {
return array();
return [];
}
if ( empty( $array ) ) {
@@ -1435,11 +1490,11 @@ class Options {
/**
* Check whether the site is using Pepipost SMTP or not.
*
* @deprecated 2.4.0
*
* @since 1.0.0
* @since 1.0.0
*
* @return bool
* @deprecated 2.4.0
*
*/
public function is_pepipost_active() {
@@ -1479,7 +1534,7 @@ class Options {
* @return bool
*/
public function is_mailer_smtp() {
return apply_filters( 'wp_mail_smtp_options_is_mailer_smtp', in_array( $this->get( 'mail', 'mailer' ), array( 'pepipost', 'smtp' ), true ) );
return apply_filters( 'wp_mail_smtp_options_is_mailer_smtp', in_array( $this->get( 'mail', 'mailer' ), [ 'pepipost', 'smtp' ], true ) );
}
/**