Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Changelog
=========

2.1.9 (2025-06-24)
- Added fallback option. Merge PR for widget

2.1.8 (2025-05-11)
- Just keep update WP version. And tested compatibility with it

Expand Down
37 changes: 37 additions & 0 deletions includes/options-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@
$trackOpens = ( defined('MAILGUN_TRACK_OPENS') ? MAILGUN_TRACK_OPENS : null );

$suppressClicks = $this->get_option('suppress_clicks') ?: 'no';
$emailFallback = $this->get_option('email_fallback') ?: 'no';

$settings = [];
try {
$settings = $mailgun->getTrackingSettings();
} catch (Throwable $e) {

Check failure on line 68 in includes/options-page.php

View workflow job for this annotation

GitHub Actions / WPCS

Empty CATCH statement must have a comment to explain why the exception is not handled
}

?>
<div class="wrap">
Expand Down Expand Up @@ -116,6 +123,24 @@
<?php settings_fields('mailgun'); ?>

<table class="form-table">
<?php if ($settings) : ?>
<tr>
<th><?php _e('Domain tracking settings from account', 'mailgun'); ?></th>
<td>
<ul>
<li>
<b>Click tracking</b> &mdash; <?php echo $settings['tracking']['open']['active'] == 1 ? 'Yes' : 'No'?>

Check failure on line 132 in includes/options-page.php

View workflow job for this annotation

GitHub Actions / WPCS

Expected 1 space before closing PHP tag; 0 found

Check failure on line 132 in includes/options-page.php

View workflow job for this annotation

GitHub Actions / WPCS

Inline PHP statement must end with a semicolon
</li>
<li>
<b>Open tracking</b> &mdash; <?php echo $settings['tracking']['click']['active'] == 1 ? 'Yes' : 'No'?>

Check failure on line 135 in includes/options-page.php

View workflow job for this annotation

GitHub Actions / WPCS

Expected 1 space before closing PHP tag; 0 found

Check failure on line 135 in includes/options-page.php

View workflow job for this annotation

GitHub Actions / WPCS

Inline PHP statement must end with a semicolon
</li>
<li>
<b>Unsubscribes</b> &mdash; <?php echo $settings['tracking']['unsubscribe']['active'] == 1 ? 'Yes' : 'No'?>

Check failure on line 138 in includes/options-page.php

View workflow job for this annotation

GitHub Actions / WPCS

Expected 1 space before closing PHP tag; 0 found

Check failure on line 138 in includes/options-page.php

View workflow job for this annotation

GitHub Actions / WPCS

Inline PHP statement must end with a semicolon
</li>
</ul>
</td>
</tr>
<?php endif; ?>
<tr valign="top">
<th scope="row">
<?php _e('Select Your Region', 'mailgun'); ?>
Expand Down Expand Up @@ -431,6 +456,18 @@
</p>
</td>
</tr>
<tr valign="top">
<th scope="row">
<?php _e('Email fallback', 'mailgun'); ?> <br>
</th>
<td>
<select
name="mailgun[email_fallback]">
<option value="yes"<?php selected('yes', $emailFallback); ?>><?php _e('Yes', 'mailgun'); ?></option>
<option value="no"<?php selected('no', $emailFallback); ?>><?php _e('No', 'mailgun'); ?></option>
</select>
</td>
</tr>
</table>
<h3><?php _e('Lists', 'mailgun'); ?></h3>
<table class="form-table">
Expand Down
4 changes: 2 additions & 2 deletions includes/wp-mail-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,8 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array()
}

// Email Fallback

if ($isFallbackNeeded) {
$isFallbackEnabled = get_option('email_fallback') ?: 'no';
if ($isFallbackNeeded && $isFallbackEnabled === 'yes') {
global $phpmailer;

// (Re)create it, if it's gone missing.
Expand Down
38 changes: 31 additions & 7 deletions mailgun.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Mailgun
* Plugin URI: http://wordpress.org/extend/plugins/mailgun/
* Description: Mailgun integration for WordPress
* Version: 2.1.8
* Version: 2.1.9
* Requires PHP: 7.4
* Requires at least: 4.4
* Author: Mailgun
Expand Down Expand Up @@ -294,6 +294,21 @@
return $results;
}

/**
* @return array
* @throws JsonException
*/
public function getTrackingSettings(): array
{

Check failure on line 302 in mailgun.php

View workflow job for this annotation

GitHub Actions / WPCS

Opening brace should be on the same line as the declaration
$domain = ( defined( 'MAILGUN_DOMAIN' ) && MAILGUN_DOMAIN ) ? MAILGUN_DOMAIN : $this->get_option( 'domain' );
if (!$domain) {

Check failure on line 304 in mailgun.php

View workflow job for this annotation

GitHub Actions / WPCS

Expected 1 space after &quot;!&quot;; 0 found

Check failure on line 304 in mailgun.php

View workflow job for this annotation

GitHub Actions / WPCS

Expected 1 space before &quot;!&quot;; 0 found
return [];
}
$settings = $this->api_call(sprintf("domains/%s/tracking", $domain), [], 'GET' );

return json_decode( $settings, true, 512, JSON_THROW_ON_ERROR );
}

/**
* Handle add list ajax post.
*
Expand Down Expand Up @@ -384,17 +399,18 @@
<?php endif; ?>
<?php if ( isset( $args['collect_name'] ) && (int) $args['collect_name'] === 1 ) : ?>
<p class="mailgun-list-widget-name">
<strong>Name:</strong>
<input type="text" name="name"/>
<label><strong>Name:</strong></label>
<input type="text" name="name" placeholder="Name"/>
</p>
<?php endif; ?>
<p class="mailgun-list-widget-email">
<strong>Email:</strong>
<input type="text" name="email"/>
<label><strong>Email:</strong></label>
<input type="text" name="email" placeholder="Email"/>
</p>
</div>

<?php if ( count( $list_addresses ) > '1' ) : ?>
<div class="mailgun-list-widget-lists">
<?php if ( count( $list_addresses ) > '1' ) : ?>
<ul class="mailgun-lists" style="list-style: none;">
<?php
foreach ( $all_list_addresses as $la ) :
Expand All @@ -414,7 +430,7 @@

<input class="mailgun-list-submit-button" data-form-id="<?php echo esc_attr( $form_class_id ); ?>" type="button"
value="Subscribe"/>
<input type="hidden" name="mailgun-submission" value="1"/>
<input type="hidden" name="mailgun-submission" value="1"/></div>

</form>
<div class="widget-list-panel result-panel" style="display:none;">
Expand Down Expand Up @@ -444,6 +460,14 @@
return
}

// Email validation regex pattern
var emailPattern = /.+@.+\..{2,}/;

if (!emailPattern.test(jQuery('.' + form_id + ' .mailgun-list-widget-email input').val())) {
alert('Please enter a valid email address.')
return
}

jQuery.ajax({
url: '<?php echo admin_url( 'admin-ajax.php?action=add_list' ); ?>',
action: 'add_list',
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.8.1
Stable tag: 2.1.8
Stable tag: 2.1.9
Requires PHP: 7.4
License: GPLv2 or later

Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.8.1
Stable tag: 2.1.8
Stable tag: 2.1.9
Requires PHP: 7.4
License: GPLv2 or later

Expand Down Expand Up @@ -129,6 +129,9 @@ MAILGUN_TRACK_OPENS Type: string Choices: 'yes' or 'no'

== Changelog ==

= 2.1.9 (2025-06-24): =
- Added fallback option. Merge PR for widget

= 2.1.8 (2025-05-11): =
- Just keep update WP version. And tested compatibility with it

Expand Down