diff --git a/includes/admin.php b/includes/admin.php
index af87214..5c67c99 100755
--- a/includes/admin.php
+++ b/includes/admin.php
@@ -61,17 +61,16 @@ public function __construct()
add_action('wp_ajax_mailgun-test', [&$this, 'ajax_send_test']);
}
- /**
- * Adds the default options during plugin activation.
- *
- * @return void
- *
- */
- public function activation() {
- if (!$this->options) {
- $this->options = $this->defaults;
- add_option('mailgun', $this->options);
- }
+ /**
+ * Adds the default options during plugin activation.
+ * @return void
+ */
+ public function activation(): void
+ {
+ if (!$this->options) {
+ $this->options = $this->defaults;
+ add_option('mailgun', $this->options);
+ }
}
@@ -81,7 +80,7 @@ public function activation() {
* @return void
*
*/
- public function init()
+ public function init(): void
{
$sitename = sanitize_text_field(strtolower($_SERVER['SERVER_NAME']));
if (substr($sitename, 0, 4) === 'www.') {
@@ -338,26 +337,25 @@ public function admin_notices(): void
$apiKeyUndefined = (!$this->get_option('apiKey') && (!defined('MAILGUN_APIKEY') || !MAILGUN_APIKEY));
$apiActiveNotConfigured = ($this->get_option('useAPI') === '1' && ($apiRegionUndefined || $apiKeyUndefined));
- if ($apiActiveNotConfigured || $smtpActiveNotConfigured):
- ?>
+ if ($_SESSION['settings_turned_of'] === false && ($apiActiveNotConfigured || $smtpActiveNotConfigured) ) { ?>
here',
+ __('Use HTTP API is turned off or you do not have SMTP credentials. You can configure your Mailgun settings in your wp-config.php file or here',
'mailgun'),
menu_page_url('mailgun', false)
);
?>
-
+
+ get_option('override-from') === '1' &&
(!$this->get_option('from-name') || !$this->get_option('from-address'))
- ):
- ?>
+ ) { ?>
@@ -372,8 +370,7 @@ public function admin_notices(): void
?>
- ' . __('Settings', 'mailgun') . '';
array_unshift($links, $settings_link);
@@ -462,9 +459,6 @@ public function ajax_send_test()
//Log purpose
}
-
-
-
if ($useAPI) {
if (!function_exists('mg_api_last_error')) {
if (!include __DIR__ . '/wp-mail-api.php') {
diff --git a/includes/lists-page.php b/includes/lists-page.php
index 1719f79..de3025d 100644
--- a/includes/lists-page.php
+++ b/includes/lists-page.php
@@ -26,8 +26,8 @@
$api_key = (defined('MAILGUN_APIKEY') && MAILGUN_APIKEY) ? MAILGUN_APIKEY : $this->get_option('apiKey');
$mailgun_domain = (defined('MAILGUN_DOMAIN') && MAILGUN_DOMAIN) ? MAILGUN_DOMAIN : $this->get_option('domain');
-if ($api_key != '') {
- if ($mailgun_domain == '') {
+if ($api_key !== '') {
+ if ($mailgun_domain === '') {
$missing_error = 'Missing or invalid Mailgun Domain. ';
}
} else {
diff --git a/includes/mg-filter.php b/includes/mg-filter.php
index 7ea936d..1e31c93 100755
--- a/includes/mg-filter.php
+++ b/includes/mg-filter.php
@@ -80,21 +80,19 @@ function mg_detect_from_name($from_name_header = null)
$from_name = $from_name_header;
} elseif (defined('MAILGUN_FROM_NAME') && MAILGUN_FROM_NAME) {
$from_name = MAILGUN_FROM_NAME;
- } else {
- if (empty($mg_from_name)) {
- if (function_exists('get_current_site')) {
- $from_name = get_current_site()->site_name;
- } else {
- $from_name = 'WordPress';
- }
+ } else if (empty($mg_from_name)) {
+ if (function_exists('get_current_site')) {
+ $from_name = get_current_site()->site_name;
} else {
- $from_name = $mg_from_name;
+ $from_name = 'WordPress';
}
+ } else {
+ $from_name = $mg_from_name;
}
$filter_from_name = null;
- if ((!isset($mg_override_from) || $mg_override_from == '0') && has_filter('wp_mail_from_name')) {
+ if ((!isset($mg_override_from) || $mg_override_from === '0') && has_filter('wp_mail_from_name')) {
$filter_from_name = apply_filters(
'wp_mail_from_name',
$from_name
@@ -148,25 +146,23 @@ function mg_detect_from_address($from_addr_header = null): string
$from_addr = $from_addr_header;
} elseif (defined('MAILGUN_FROM_ADDRESS') && MAILGUN_FROM_ADDRESS) {
$from_addr = MAILGUN_FROM_ADDRESS;
- } else {
- if (empty($mg_from_addr)) {
- if (function_exists('get_current_site')) {
- $sitedomain = get_current_site()->domain;
- } else {
- $sitedomain = strtolower(sanitize_text_field($_SERVER['SERVER_NAME']));
- if (substr($sitedomain, 0, 4) === 'www.') {
- $sitedomain = substr($sitedomain, 4);
- }
- }
-
- $from_addr = 'wordpress@' . $sitedomain;
+ } else if (empty($mg_from_addr)) {
+ if (function_exists('get_current_site')) {
+ $sitedomain = get_current_site()->domain;
} else {
- $from_addr = $mg_from_addr;
+ $sitedomain = strtolower(sanitize_text_field($_SERVER['SERVER_NAME']));
+ if (substr($sitedomain, 0, 4) === 'www.') {
+ $sitedomain = substr($sitedomain, 4);
+ }
}
+
+ $from_addr = 'wordpress@' . $sitedomain;
+ } else {
+ $from_addr = $mg_from_addr;
}
$filter_from_addr = null;
- if ((!isset($mg_override_from) || $mg_override_from == '0') && has_filter('wp_mail_from')) {
+ if ((!isset($mg_override_from) || $mg_override_from === '0') && has_filter('wp_mail_from')) {
$filter_from_addr = apply_filters(
'wp_mail_from',
$from_addr
@@ -214,7 +210,7 @@ function mg_parse_headers($headers = []): array
$tmp = $headers;
}
- $new_headers = array();
+ $new_headers = [];
if (!empty($tmp)) {
$name = null;
$value = null;
@@ -242,14 +238,14 @@ function mg_parse_headers($headers = []): array
$value = trim($value);
if (!isset($new_headers[$name])) {
- $new_headers[$name] = array();
+ $new_headers[$name] = [];
}
- $new_headers[$name][] = array(
+ $new_headers[$name][] = [
'value' => $value,
'boundary' => $boundary,
'parts' => $parts,
- );
+ ];
}
}
@@ -268,7 +264,7 @@ function mg_parse_headers($headers = []): array
*/
function mg_dump_headers($headers = null): string
{
- if (is_null($headers) || !is_array($headers)) {
+ if (!is_array($headers)) {
return '';
}
diff --git a/includes/options-page.php b/includes/options-page.php
index a7bc211..9061da2 100755
--- a/includes/options-page.php
+++ b/includes/options-page.php
@@ -56,10 +56,10 @@
-
-
-
-
+
+
+
+
diff --git a/includes/wp-mail-api.php b/includes/wp-mail-api.php
index 302b62c..b7d8434 100644
--- a/includes/wp-mail-api.php
+++ b/includes/wp-mail-api.php
@@ -58,9 +58,11 @@ function mg_api_last_error(string $error = null): ?string
* @since 1.5.7
*/
add_filter('mg_mutate_to_rcpt_vars', 'mg_mutate_to_rcpt_vars_cb');
+
/**
* @param $to_addrs
* @return array
+ * @throws JsonException
*/
function mg_mutate_to_rcpt_vars_cb($to_addrs): array
{
diff --git a/mailgun.php b/mailgun.php
index c39d7c3..dec06d4 100755
--- a/mailgun.php
+++ b/mailgun.php
@@ -3,7 +3,7 @@
* Plugin Name: Mailgun
* Plugin URI: http://wordpress.org/extend/plugins/mailgun/
* Description: Mailgun integration for WordPress
- * Version: 1.9.7
+ * Version: 1.9.8
* Requires PHP: 7.4
* Requires at least: 4.4
* Author: Mailgun
diff --git a/readme.md b/readme.md
index 166f901..27be26e 100755
--- a/readme.md
+++ b/readme.md
@@ -4,7 +4,7 @@ Mailgun for WordPress
Contributors: mailgun, sivel, lookahead.io, m35dev, alanfuller
Tags: mailgun, smtp, http, api, mail, email
Tested up to: 6.4
-Stable tag: 1.9.7
+Stable tag: 1.9.8
License: GPLv2 or later
Easily send email from your WordPress site through Mailgun using the HTTP API or SMTP.
@@ -130,6 +130,10 @@ MAILGUN_TRACK_OPENS Type: string Choices: 'yes' or 'no'
== Changelog ==
+= 1.9.8 (2024-02-25): =
+ - Improve admin notices about not fully configured plugin
+ - Small code cleaning
+
= 1.9.7 (2024-01-03): =
- Ensure defaults are always set to remove warnings in PHP 8.1+
diff --git a/readme.txt b/readme.txt
index 95cbf0a..b271348 100755
--- a/readme.txt
+++ b/readme.txt
@@ -4,7 +4,7 @@ Mailgun for WordPress
Contributors: mailgun, sivel, lookahead.io, m35dev, alanfuller
Tags: mailgun, smtp, http, api, mail, email
Tested up to: 6.4
-Stable tag: 1.9.7
+Stable tag: 1.9.8
License: GPLv2 or later
Easily send email from your WordPress site through Mailgun using the HTTP API or SMTP.
@@ -128,6 +128,10 @@ MAILGUN_TRACK_OPENS Type: string Choices: 'yes' or 'no'
== Changelog ==
+= 1.9.8 (2024-02-25): =
+ - Improve admin notices about not fully configured plugin
+ - Small code cleaning
+
= 1.9.7 (2024-01-03): =
- Ensure defaults are always set to remove warnings in PHP 8.1+