Skip to content

Commit 1a9349d

Browse files
= 2.1.3 (2024-11-27): = (#195)
- Use password type for API Key field for hide it. Fix warning related co compact() method
1 parent c18452f commit 1a9349d

File tree

10 files changed

+70
-55
lines changed

10 files changed

+70
-55
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
Changelog
22
=========
33

4+
2.1.3 (2024-11-27)
5+
- Use password type for API Key field for hide it. Fix warning related co compact() method
6+
47
2.1.2 (2024-11-17)
58
- Fixed code. Removed line that try to connect not existing file. Fixed versions in the plugin
69

includes/admin.php

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ public function admin_menu(): void
118118
{
119119
if (current_user_can('manage_options')) {
120120
$this->hook_suffix = add_options_page(__('Mailgun', 'mailgun'), __('Mailgun', 'mailgun'),
121-
'manage_options', 'mailgun', array(&$this, 'options_page'));
121+
'manage_options', 'mailgun', [&$this, 'options_page']);
122122
add_options_page(__('Mailgun Lists', 'mailgun'), __('Mailgun Lists', 'mailgun'), 'manage_options',
123-
'mailgun-lists', array(&$this, 'lists_page'));
124-
add_action("admin_print_scripts-{$this->hook_suffix}", array(&$this, 'admin_js'));
125-
add_filter("plugin_action_links_{$this->plugin_basename}", array(&$this, 'filter_plugin_actions'));
126-
add_action("admin_footer-{$this->hook_suffix}", array(&$this, 'admin_footer_js'));
123+
'mailgun-lists', [&$this, 'lists_page']);
124+
add_action("admin_print_scripts-{$this->hook_suffix}", [&$this, 'admin_js']);
125+
add_filter("plugin_action_links_{$this->plugin_basename}", [&$this, 'filter_plugin_actions']);
126+
add_action("admin_footer-{$this->hook_suffix}", [&$this, 'admin_footer_js']);
127127
}
128128
}
129129

@@ -145,7 +145,7 @@ public function admin_js(): void
145145
public function admin_footer_js(): void
146146
{
147147
?>
148-
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css" >
148+
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css">
149149
<script src="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>
150150
<script type="text/javascript">
151151

@@ -260,7 +260,7 @@ public function admin_init(): void
260260
*/
261261
public function register_settings(): void
262262
{
263-
register_setting('mailgun', 'mailgun', array(&$this, 'validation'));
263+
register_setting('mailgun', 'mailgun', [&$this, 'validation']);
264264
}
265265

266266
/**
@@ -337,7 +337,7 @@ public function admin_notices(): void
337337
$apiKeyUndefined = (!$this->get_option('apiKey') && (!defined('MAILGUN_APIKEY') || !MAILGUN_APIKEY));
338338
$apiActiveNotConfigured = ($this->get_option('useAPI') === '1' && ($apiRegionUndefined || $apiKeyUndefined));
339339

340-
if (isset($_SESSION) && (!isset($_SESSION['settings_turned_of']) || $_SESSION['settings_turned_of'] === false) && ($apiActiveNotConfigured || $smtpActiveNotConfigured) ) { ?>
340+
if (isset($_SESSION) && (!isset($_SESSION['settings_turned_of']) || $_SESSION['settings_turned_of'] === false) && ($apiActiveNotConfigured || $smtpActiveNotConfigured)) { ?>
341341
<div id='mailgun-warning' class='notice notice-warning is-dismissible'>
342342
<p>
343343
<?php
@@ -349,7 +349,7 @@ public function admin_notices(): void
349349
?>
350350
</p>
351351
</div>
352-
<?php $_SESSION['settings_turned_of'] = true; ?>
352+
<?php $_SESSION['settings_turned_of'] = true; ?>
353353
<?php } ?>
354354

355355
<?php
@@ -403,11 +403,11 @@ public function ajax_send_test()
403403

404404
if (!current_user_can('manage_options') || !wp_verify_nonce(sanitize_text_field($_GET['_wpnonce']))) {
405405
die(
406-
json_encode(array(
407-
'message' => __('Unauthorized', 'mailgun'),
408-
'method' => null,
409-
'error' => __('Unauthorized', 'mailgun'),
410-
), JSON_THROW_ON_ERROR)
406+
json_encode([
407+
'message' => __('Unauthorized', 'mailgun'),
408+
'method' => null,
409+
'error' => __('Unauthorized', 'mailgun'),
410+
], JSON_THROW_ON_ERROR)
411411
);
412412
}
413413

@@ -440,11 +440,11 @@ public function ajax_send_test()
440440
$admin_email = get_option('admin_email');
441441
if (!$admin_email) {
442442
die(
443-
json_encode(array(
444-
'message' => __('Admin Email is empty', 'mailgun'),
445-
'method' => $method,
446-
'error' => __('Admin Email is empty', 'mailgun'),
447-
), JSON_THROW_ON_ERROR)
443+
json_encode([
444+
'message' => __('Admin Email is empty', 'mailgun'),
445+
'method' => $method,
446+
'error' => __('Admin Email is empty', 'mailgun'),
447+
], JSON_THROW_ON_ERROR)
448448
);
449449
}
450450

@@ -482,7 +482,7 @@ public function ajax_send_test()
482482
}
483483

484484
// Admin Email is used as 'to' parameter, but in case of 'Test Configuration' this message is not clear for the user, so replaced with more appropriate one
485-
if (false !== strpos($error_msg, "'to'") && false !== strpos($error_msg, 'is not a valid')) {
485+
if (str_contains($error_msg, "'to'") && str_contains($error_msg, 'is not a valid')) {
486486
$error_msg = sprintf(
487487
"Administration Email Address (%s) is not valid and can't be used for test, you can change it at General Setting page",
488488
$admin_email
@@ -491,22 +491,22 @@ public function ajax_send_test()
491491

492492
if ($result) {
493493
die(
494-
json_encode(array(
495-
'message' => __('Success', 'mailgun'),
496-
'method' => $method,
497-
'error' => __('Success', 'mailgun'),
498-
), JSON_THROW_ON_ERROR)
494+
json_encode([
495+
'message' => __('Success', 'mailgun'),
496+
'method' => $method,
497+
'error' => __('Success', 'mailgun'),
498+
], JSON_THROW_ON_ERROR)
499499
);
500500
}
501501

502502
// Error message will always be returned in case of failure, if not - connection wasn't successful
503503
$error_msg = $error_msg ?: "Can't connect to Mailgun";
504504
die(
505-
json_encode(array(
506-
'message' => __('Failure', 'mailgun'),
507-
'method' => $method,
508-
'error' => $error_msg,
509-
), JSON_THROW_ON_ERROR)
505+
json_encode([
506+
'message' => __('Failure', 'mailgun'),
507+
'method' => $method,
508+
'error' => $error_msg,
509+
], JSON_THROW_ON_ERROR)
510510
);
511511
}
512512
}

includes/mg-filter.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,6 @@ function mg_detect_from_address($from_addr_header = null): string
138138
$mg_override_from = $mg_opts['override-from'] ?? null;
139139
$mg_from_addr = $mg_opts['from-address'] ?? null;
140140

141-
$from_addr = null;
142-
143141
if ($mg_override_from && !is_null($mg_from_addr)) {
144142
$from_addr = $mg_from_addr;
145143
} elseif (!is_null($from_addr_header)) {
@@ -223,7 +221,7 @@ function mg_parse_headers($headers = []): array
223221
// Does this header have a boundary?
224222
if (false !== stripos($header, 'boundary=')) {
225223
$parts = preg_split('/boundary=/i', trim($header));
226-
$boundary = trim(str_replace(array('"', '\''), '', $parts[1]));
224+
$boundary = trim(str_replace(['"', '\''], '', $parts[1]));
227225
}
228226
$value .= $header;
229227

@@ -271,7 +269,7 @@ function mg_dump_headers($headers = null): string
271269
$header_string = '';
272270
foreach ($headers as $name => $values) {
273271
$header_string .= sprintf("%s: ", $name);
274-
$header_values = array();
272+
$header_values = [];
275273

276274
foreach ($values as $content) {
277275
// XXX - Is it actually okay to discard `parts` and `boundary`?

includes/options-page.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@
7676
$link = sprintf(
7777
wp_kses(
7878
__('A <a href="%1$s" target="%2$s">Mailgun</a> account is required to use this plugin and the Mailgun service.', 'mailgun'),
79-
array('a' => array(
80-
'href' => array(),
81-
'target' => array()
82-
)
83-
)
79+
['a' => [
80+
'href' => [],
81+
'target' => []
82+
]
83+
]
8484
), esc_url($url), '_blank'
8585
);
8686
echo wp_kses_data($link);
@@ -93,11 +93,11 @@
9393
$link = sprintf(
9494
wp_kses(
9595
__('If you need to register for an account, you can do so at <a href="%1$s" target="%2$s">Mailgun.com</a>.', 'mailgun'),
96-
array('a' => array(
97-
'href' => array(),
98-
'target' => array()
99-
)
100-
)
96+
['a' => [
97+
'href' => [],
98+
'target' => []
99+
]
100+
]
101101
), esc_url($url), '_blank'
102102
);
103103
echo wp_kses_data($link);
@@ -172,7 +172,7 @@
172172
<?php _e('API Key', 'mailgun'); ?>
173173
</th>
174174
<td>
175-
<input type="text" class="regular-text" name="mailgun[apiKey]"
175+
<input type="password" class="regular-text" name="mailgun[apiKey]"
176176
value="<?php esc_attr_e($mailgun_api_key); ?>"
177177
placeholder="key-3ax6xnjp29jd6fds4gc373sgvjxteol0"
178178
<?php echo $mailgun_api_key_const ? 'readonly="readonly"' : '' ?>
@@ -451,10 +451,10 @@ class="regular-text"
451451
$link = sprintf(
452452
wp_kses(
453453
__('<a href="%1$s" target="%2$s">View available lists</a>.', 'mailgun'),
454-
array('a' => array(
455-
'href' => array(),
456-
)
457-
)
454+
['a' => [
455+
'href' => [],
456+
]
457+
]
458458
), esc_url($url)
459459
);
460460
echo wp_kses_data($link);

includes/widget.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function __construct()
2929
// Widget name will appear in UI
3030
__('Mailgun List Widget', 'wpb_widget_domain'),
3131
// Widget description
32-
array('description' => __('Mailgun list widget', 'wpb_widget_domain'))
32+
['description' => __('Mailgun list widget', 'wpb_widget_domain')]
3333
);
3434
}
3535

includes/wp-mail-api.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ function mg_mutate_to_rcpt_vars_cb($to_addrs): array
112112
*
113113
*/
114114
if (!function_exists('wp_mail')) {
115+
/**
116+
* @throws \PHPMailer\PHPMailer\Exception
117+
*/
115118
function wp_mail($to, $subject, $message, $headers = '', $attachments = [])
116119
{
117120
$mailgun = get_option('mailgun');
@@ -160,6 +163,9 @@ function wp_mail($to, $subject, $message, $headers = '', $attachments = [])
160163
$attachments = explode("\n", str_replace("\r\n", "\n", $attachments));
161164
}
162165

166+
$cc = [];
167+
$bcc = [];
168+
163169
// Headers
164170
if (empty($headers)) {
165171
$headers = [];

includes/wp-mail-smtp.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function mg_smtp_mail_filter(array $args)
103103

104104
// $headers and $attachments are optional - make sure they exist
105105
$headers = (!isset($headers)) ? '' : $headers;
106-
$attachments = (!isset($attachments)) ? array() : $attachments;
106+
$attachments = (!isset($attachments)) ? [] : $attachments;
107107

108108
$mg_opts = get_option('mailgun');
109109
$mg_headers = mg_parse_headers($headers);
@@ -142,7 +142,7 @@ function mg_smtp_mail_filter(array $args)
142142
$from_addr = mg_detect_from_address($from_addr);
143143

144144
$from_header['value'] = sprintf('%s <%s>', $from_name, $from_addr);
145-
$mg_headers['From'] = array($from_header);
145+
$mg_headers['From'] = [$from_header];
146146

147147
// Header compaction
148148
$headers = mg_dump_headers($mg_headers);

mailgun.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: Mailgun
44
* Plugin URI: http://wordpress.org/extend/plugins/mailgun/
55
* Description: Mailgun integration for WordPress
6-
* Version: 2.1.2
6+
* Version: 2.1.3
77
* Requires PHP: 7.4
88
* Requires at least: 4.4
99
* Author: Mailgun

readme.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ Mailgun for WordPress
44
Contributors: mailgun, sivel, lookahead.io, m35dev, alanfuller
55
Tags: mailgun, smtp, http, api, mail, email
66
Tested up to: 6.7
7-
Stable tag: 2.1.2
7+
Stable tag: 2.1.3
8+
Requires PHP: 7.4
89
License: GPLv2 or later
910

1011
Easily send email from your WordPress site through Mailgun using the HTTP API or SMTP.
@@ -132,6 +133,9 @@ MAILGUN_REPLY_TO_ADDRESS Type: string
132133

133134
== Changelog ==
134135

136+
= 2.1.3 (2024-11-27): =
137+
- Use password type for API Key field for hide it. Fix warning related co compact() method
138+
135139
= 2.1.2 (2024-11-17): =
136140
- Fixed code. Removed line that try to connect not existing file. Fixed versions in the plugin
137141

readme.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ Mailgun for WordPress
44
Contributors: mailgun, sivel, lookahead.io, m35dev, alanfuller
55
Tags: mailgun, smtp, http, api, mail, email
66
Tested up to: 6.7
7-
Stable tag: 2.1.2
7+
Stable tag: 2.1.3
8+
Requires PHP: 7.4
89
License: GPLv2 or later
910

1011
Easily send email from your WordPress site through Mailgun using the HTTP API or SMTP.
@@ -128,6 +129,9 @@ MAILGUN_TRACK_OPENS Type: string Choices: 'yes' or 'no'
128129

129130
== Changelog ==
130131

132+
= 2.1.3 (2024-11-27): =
133+
- Use password type for API Key field for hide it. Fix warning related co compact() method
134+
131135
= 2.1.2 (2024-11-17): =
132136
- Fixed code. Removed line that try to connect not existing file. Fixed versions in the plugin
133137

0 commit comments

Comments
 (0)