Skip to content

Commit

Permalink
Adding suppress function for tracking clicks in the Reset Password em…
Browse files Browse the repository at this point in the history
…ails. It will lead to long domain in the list. Experimental (#185)
  • Loading branch information
oleksandr-mykhailenko authored Jul 27, 2024
1 parent e8ca032 commit c1d21fd
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 1 deletion.
17 changes: 17 additions & 0 deletions includes/options-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
$mailgun_use_api = !is_null($mailgun_use_api_const) ? ((string)(1 * $mailgun_use_api_const)) : $this->get_option('useAPI');
$icon = $mailgun->getAssetsPath() . 'icon-128x128.png';

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

?>
<div class="wrap">
<div id="icon-options-general" class="icon32"><br/></div>
Expand Down Expand Up @@ -400,6 +402,21 @@ class="regular-text"
</p>
</td>
</tr>
<tr valign="top">
<th scope="row">
<?php _e('Suppress Click Track for password reset email', 'mailgun'); ?> <br>
</th>
<td>
<select
name="mailgun[suppress_clicks]">
<option value="yes"<?php selected('yes', $suppressClicks); ?>><?php _e('Yes', 'mailgun'); ?></option>
<option value="no"<?php selected('no', $suppressClicks); ?>><?php _e('No', 'mailgun'); ?></option>
</select>
<p class="description">
<span><?php _e('Experimental function', 'mailgun'); ?></span>
</p>
</td>
</tr>
</table>
<h3><?php _e('Lists', 'mailgun'); ?></h3>
<table class="form-table">
Expand Down
9 changes: 8 additions & 1 deletion includes/wp-mail-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ function wp_mail($to, $subject, $message, $headers = '', $attachments = [])
'subject' => $subject,
];


$rcpt_data = apply_filters('mg_mutate_to_rcpt_vars', $to);
if (!is_null($rcpt_data['rcpt_vars'])) {
$body['recipient-variables'] = $rcpt_data['rcpt_vars'];
Expand All @@ -273,6 +272,14 @@ function wp_mail($to, $subject, $message, $headers = '', $attachments = [])
} else {
$trackOpens = empty($mailgun['track-opens']) ? 'no' : 'yes';
}

if (isset($mailgun['suppress_clicks']) && $mailgun['suppress_clicks'] === 'yes') {
$passwordResetSubject = __('Password Reset Request', 'mailgun') ?: __( 'Password Reset Request', 'woocommerce' );
if (!empty($passwordResetSubject) && stripos($subject, $passwordResetSubject) !== false) {
$trackClicks = 'no';
}
}

$body['o:tracking-clicks'] = $trackClicks;
$body['o:tracking-opens'] = $trackOpens;

Expand Down
3 changes: 3 additions & 0 deletions languages/mailgun-de_DE.po
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,6 @@ msgstr "Änderungen speichern"

msgid "Reply-to address"
msgstr "Antwortadresse"

msgid "Suppress Click Track for password reset email"
msgstr "Klick-Tracking für Passwort-Reset-Email unterdrücken"
3 changes: 3 additions & 0 deletions languages/mailgun-es_ES.po
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,6 @@ msgstr "Guardar cambios"

msgid "Reply-to address"
msgstr "dirección de respuesta"

msgid "Suppress Click Track for password reset email"
msgstr "Suprimir seguimiento de clics para el email de restablecimiento de contraseña"
3 changes: 3 additions & 0 deletions languages/mailgun-pt_BR.po
Original file line number Diff line number Diff line change
Expand Up @@ -366,3 +366,6 @@ msgstr ""

msgid "Reply-to address"
msgstr ""

msgid "Suppress Click Track for password reset email"
msgstr ""

0 comments on commit c1d21fd

Please sign in to comment.