This commit is contained in:
Javier Casares 2026-11-03 17:39:56 +00:00
commit 7cfb57a530
9 changed files with 324 additions and 143 deletions

View file

@ -1,5 +1,48 @@
== Changelog == == Changelog ==
= 2.1.0 =
_Release date: 2026-09-18_
**Highlights**
* Known issues resolved: WooCommerce context values are no longer lost, and plugin data is now preserved on uninstall unless you opt in to removal.
**Added**
* "Delete plugin data on uninstall" opt-in setting (Default tab). Your Reply-To settings are preserved by default and only removed when you explicitly check this box. On Multisite, each site's own opt-in decides its own data.
* WP_MAIL_REPLYTO_VERSION constant for cache-busting and version checks.
**Changed**
* WooCommerce context values now survive settings saves made while WooCommerce is deactivated (previously they were silently dropped; the tab reappears with its values when WooCommerce is reactivated).
* Settings page now terminates with wp_die() instead of a silent blank page when accessed without manage_options.
* "Save Settings" button no longer double-escaped.
* Active tab query parameter ($_GET['tab']) now unslashed before sanitization (Plugin Check hardening).
* Development tooling updated via composer update (PHPStan 2.2.8 → 2.2.14, wp-compat 1.5.0 → 2.0.1, wordpress-stubs 6.9.4 → 7.1.0, phpstan-wordpress 2.0.3 → 2.0.4, php-parser 5.8.0 → 5.9.0, wp-hooks/wordpress-core 1.12.0 → 1.13.0).
* Documented wp-compat 2.x false positive for apply_filters() extra args (formalized in the 6.0 signature, functional since WP 0.71) with a targeted phpstan.neon ignore.
* bin/preflight.sh runs PHPStan with --memory-limit=1G (updated dev deps exceed the default 512M worker limit).
**Fixed**
* Uninstall no longer deletes plugin options unconditionally (previous documented behavior since 1.1.0); removal now requires the explicit opt-in introduced in this version.
* Uninstall no longer processes the main site twice on Multisite.
**Compatibility**
* WordPress: 4.7 - 7.1 (7.2 not yet released — expected December 2026 — so Tested up to stays at 7.1)
* PHP: 5.6 - 8.5
**Tests**
* PHP Coding Standards: 3.13.6
* WordPress Coding Standards: 3.4.1
* PHPStan: 2.2.14 (level 9)
* PHPUnit: 9.6.36
* PHPUnit suite expanded from 78 to 86 tests (95.84% line coverage): uninstall opt-in behaviour, WooCommerce context preservation, admin opt-in rendering.
* Plugin Check (PCP): run against the release package — 0 errors (3 accepted warnings documented in docs/known-issues.md).
* Smoke-tested on WordPress 7.1-alpha staging (single-site): settings page renders, wp_mail filter injects the configured Reply-To header.
= 2.0.3 = = 2.0.3 =
_Release date: 2026-08-18_ _Release date: 2026-08-18_

Binary file not shown.

View file

@ -3,10 +3,10 @@
# This file is distributed under the GPL-3.0-or-later. # This file is distributed under the GPL-3.0-or-later.
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Reply-To for WP_Mail 2.0.3\n" "Project-Id-Version: Reply-To for WP_Mail 2.1.0\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/replyto\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/replyto\n"
"POT-Creation-Date: 2026-08-18T11:23:15+00:00\n" "POT-Creation-Date: 2026-09-18T14:58:16+00:00\n"
"PO-Revision-Date: 2026-06-05 12:00+0100\n" "PO-Revision-Date: 2026-09-18 17:00+0100\n"
"Last-Translator: Javier Casares <javier@robotstxt.es>\n" "Last-Translator: Javier Casares <javier@robotstxt.es>\n"
"Language-Team: Catalan <ca@li.org>\n" "Language-Team: Catalan <ca@li.org>\n"
"Language: ca\n" "Language: ca\n"
@ -104,6 +104,10 @@ msgstr "El nom del context %s s'ha truncat a 255 caràcters."
msgid "Reply-To configuration updated successfully." msgid "Reply-To configuration updated successfully."
msgstr "La configuració de Respon-A s'ha actualitzat correctament." msgstr "La configuració de Respon-A s'ha actualitzat correctament."
#: replyto.php:744
msgid "You do not have sufficient permissions to access this page."
msgstr "No teniu permisos suficients per a accedir a aquesta pàgina."
#: replyto.php:710 #: replyto.php:710
msgid "" msgid ""
"Default Reply-To used for all emails that do not match a specific context. " "Default Reply-To used for all emails that do not match a specific context. "
@ -272,6 +276,18 @@ msgstr ""
"El context predeterminat sempre està actiu i actua com a reserva per a tots " "El context predeterminat sempre està actiu i actua com a reserva per a tots "
"els correus." "els correus."
#: replyto.php:898 #: replyto.php:935
msgid "Delete plugin data on uninstall"
msgstr "Suprimeix les dades del complement en desinstal·lar-lo"
#: replyto.php:938
msgid ""
"Your Reply-To settings are preserved by default. Check this box to remove "
"all plugin data when the plugin is uninstalled."
msgstr ""
"Per defecte, els ajustaments de Respon-A es conserven. Marqueu aquesta "
"casella per a suprimir totes les dades del complement quan es desinstal·li."
#: replyto.php:967
msgid "Save Settings" msgid "Save Settings"
msgstr "Desa la configuració" msgstr "Desa la configuració"

Binary file not shown.

View file

@ -3,10 +3,10 @@
# This file is distributed under the GPL-3.0-or-later. # This file is distributed under the GPL-3.0-or-later.
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Reply-To for WP_Mail 2.0.3\n" "Project-Id-Version: Reply-To for WP_Mail 2.1.0\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/replyto\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/replyto\n"
"POT-Creation-Date: 2026-08-18T11:23:15+00:00\n" "POT-Creation-Date: 2026-09-18T14:58:16+00:00\n"
"PO-Revision-Date: 2026-06-05 12:00+0100\n" "PO-Revision-Date: 2026-09-18 17:00+0100\n"
"Last-Translator: Javier Casares <javier@robotstxt.es>\n" "Last-Translator: Javier Casares <javier@robotstxt.es>\n"
"Language-Team: Spanish (Spain) <es@li.org>\n" "Language-Team: Spanish (Spain) <es@li.org>\n"
"Language: es_ES\n" "Language: es_ES\n"
@ -104,6 +104,10 @@ msgstr "El nombre del contexto %s se ha truncado a 255 caracteres."
msgid "Reply-To configuration updated successfully." msgid "Reply-To configuration updated successfully."
msgstr "La configuración de Responder a se ha actualizado correctamente." msgstr "La configuración de Responder a se ha actualizado correctamente."
#: replyto.php:744
msgid "You do not have sufficient permissions to access this page."
msgstr "No tienes permisos suficientes para acceder a esta página."
#: replyto.php:710 #: replyto.php:710
msgid "" msgid ""
"Default Reply-To used for all emails that do not match a specific context. " "Default Reply-To used for all emails that do not match a specific context. "
@ -274,6 +278,18 @@ msgstr ""
"El contexto predeterminado siempre está activo y actúa como alternativa para " "El contexto predeterminado siempre está activo y actúa como alternativa para "
"todos los correos." "todos los correos."
#: replyto.php:898 #: replyto.php:935
msgid "Delete plugin data on uninstall"
msgstr "Borrar los datos del plugin al desinstalarlo"
#: replyto.php:938
msgid ""
"Your Reply-To settings are preserved by default. Check this box to remove "
"all plugin data when the plugin is uninstalled."
msgstr ""
"Por defecto, tus ajustes de Responder a se conservan. Marca esta casilla "
"para eliminar todos los datos del plugin cuando se desinstale."
#: replyto.php:967
msgid "Save Settings" msgid "Save Settings"
msgstr "Guardar ajustes" msgstr "Guardar ajustes"

View file

@ -2,14 +2,14 @@
# This file is distributed under the GPL-3.0-or-later. # This file is distributed under the GPL-3.0-or-later.
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Reply-To for WP_Mail 2.0.3\n" "Project-Id-Version: Reply-To for WP_Mail 2.1.0\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/replyto\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/replyto\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2026-08-18T11:23:15+00:00\n" "POT-Creation-Date: 2026-09-18T14:58:16+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.12.0\n" "X-Generator: WP-CLI 2.12.0\n"
"X-Domain: replyto\n" "X-Domain: replyto\n"
@ -39,179 +39,191 @@ msgstr ""
msgid "https://www.robotstxt.software/" msgid "https://www.robotstxt.software/"
msgstr "" msgstr ""
#: replyto.php:394 #: replyto.php:401
msgid "WP Mail Reply-To Settings" msgid "WP Mail Reply-To Settings"
msgstr "" msgstr ""
#: replyto.php:395 #: replyto.php:402
msgid "Reply-To" msgid "Reply-To"
msgstr "" msgstr ""
#: replyto.php:495 #: replyto.php:535
#: replyto.php:709 #: replyto.php:762
msgid "Default" msgid "Default"
msgstr "" msgstr ""
#: replyto.php:496 #: replyto.php:536
msgid "Authentication" msgid "Authentication"
msgstr "" msgstr ""
#: replyto.php:497 #: replyto.php:537
msgid "Comments" msgid "Comments"
msgstr "" msgstr ""
#: replyto.php:498 #: replyto.php:538
msgid "Users" msgid "Users"
msgstr "" msgstr ""
#: replyto.php:499 #: replyto.php:539
msgid "System" msgid "System"
msgstr "" msgstr ""
#: replyto.php:504 #: replyto.php:540
#: replyto.php:738 #: replyto.php:791
msgid "WooCommerce" msgid "WooCommerce"
msgstr "" msgstr ""
#. translators: %s: context name #. translators: %s: context name
#: replyto.php:529 #: replyto.php:580
#, php-format #, php-format
msgid "Invalid email address for %s context." msgid "Invalid email address for %s context."
msgstr "" msgstr ""
#. translators: %s: context name #. translators: %s: context name
#: replyto.php:545 #: replyto.php:596
#, php-format #, php-format
msgid "Warning: The email domain for %s context does not appear to have valid DNS records." msgid "Warning: The email domain for %s context does not appear to have valid DNS records."
msgstr "" msgstr ""
#. translators: %s: context name #. translators: %s: context name
#: replyto.php:560 #: replyto.php:611
#: replyto.php:570 #: replyto.php:621
#, php-format #, php-format
msgid "Name for %s context was truncated to 255 characters." msgid "Name for %s context was truncated to 255 characters."
msgstr "" msgstr ""
#: replyto.php:611 #: replyto.php:661
msgid "Reply-To configuration updated successfully." msgid "Reply-To configuration updated successfully."
msgstr "" msgstr ""
#: replyto.php:710 #: replyto.php:744
msgid "You do not have sufficient permissions to access this page."
msgstr ""
#: replyto.php:763
msgid "Default Reply-To used for all emails that do not match a specific context. This is the fallback when other contexts are not configured." msgid "Default Reply-To used for all emails that do not match a specific context. This is the fallback when other contexts are not configured."
msgstr "" msgstr ""
#: replyto.php:711 #: replyto.php:764
msgid "Newsletter confirmations, general notifications, and any emails not covered by other contexts." msgid "Newsletter confirmations, general notifications, and any emails not covered by other contexts."
msgstr "" msgstr ""
#: replyto.php:714 #: replyto.php:767
msgid "Authentication & Security" msgid "Authentication & Security"
msgstr "" msgstr ""
#: replyto.php:715 #: replyto.php:768
msgid "Reply-To for password resets, password changes, and email address changes." msgid "Reply-To for password resets, password changes, and email address changes."
msgstr "" msgstr ""
#: replyto.php:716 #: replyto.php:769
msgid "Password reset requests, password change confirmations, email address verifications." msgid "Password reset requests, password change confirmations, email address verifications."
msgstr "" msgstr ""
#: replyto.php:719 #: replyto.php:772
msgid "Comments & Moderation" msgid "Comments & Moderation"
msgstr "" msgstr ""
#: replyto.php:720 #: replyto.php:773
msgid "Reply-To for comment notifications and moderation alerts." msgid "Reply-To for comment notifications and moderation alerts."
msgstr "" msgstr ""
#: replyto.php:721 #: replyto.php:774
msgid "New comment notifications, comment moderation alerts, comment replies." msgid "New comment notifications, comment moderation alerts, comment replies."
msgstr "" msgstr ""
#: replyto.php:724 #: replyto.php:777
msgid "Users & Registration" msgid "Users & Registration"
msgstr "" msgstr ""
#: replyto.php:725 #: replyto.php:778
msgid "Reply-To for new user registrations, role changes, and user management emails." msgid "Reply-To for new user registrations, role changes, and user management emails."
msgstr "" msgstr ""
#: replyto.php:726 #: replyto.php:779
msgid "New user welcome emails, user role changes, account activations." msgid "New user welcome emails, user role changes, account activations."
msgstr "" msgstr ""
#: replyto.php:729 #: replyto.php:782
msgid "System & Updates" msgid "System & Updates"
msgstr "" msgstr ""
#: replyto.php:730 #: replyto.php:783
msgid "Reply-To for automatic updates, system alerts, and critical site health notifications." msgid "Reply-To for automatic updates, system alerts, and critical site health notifications."
msgstr "" msgstr ""
#: replyto.php:731 #: replyto.php:784
msgid "WordPress core updates, plugin updates, theme updates, recovery mode, fatal error notifications." msgid "WordPress core updates, plugin updates, theme updates, recovery mode, fatal error notifications."
msgstr "" msgstr ""
#: replyto.php:739 #: replyto.php:792
msgid "Reply-To for WooCommerce order notifications, invoices, and customer communications." msgid "Reply-To for WooCommerce order notifications, invoices, and customer communications."
msgstr "" msgstr ""
#: replyto.php:740 #: replyto.php:793
msgid "Order confirmations, shipping notifications, invoices, customer notes." msgid "Order confirmations, shipping notifications, invoices, customer notes."
msgstr "" msgstr ""
#: replyto.php:754 #: replyto.php:807
msgid "Configure different Reply-To addresses based on the type of email being sent. Each context can have its own email address and display name." msgid "Configure different Reply-To addresses based on the type of email being sent. Each context can have its own email address and display name."
msgstr "" msgstr ""
#: replyto.php:792 #: replyto.php:845
msgid "Active with email configured" msgid "Active with email configured"
msgstr "" msgstr ""
#: replyto.php:793 #: replyto.php:846
msgid "Inactive or no email configured" msgid "Inactive or no email configured"
msgstr "" msgstr ""
#: replyto.php:809 #: replyto.php:862
msgid "What this context covers:" msgid "What this context covers:"
msgstr "" msgstr ""
#: replyto.php:811 #: replyto.php:864
msgid "Examples:" msgid "Examples:"
msgstr "" msgstr ""
#: replyto.php:822 #: replyto.php:875
msgid "Enable this context" msgid "Enable this context"
msgstr "" msgstr ""
#: replyto.php:825 #: replyto.php:878
msgid "When disabled, emails in this context will use the Default Reply-To address." msgid "When disabled, emails in this context will use the Default Reply-To address."
msgstr "" msgstr ""
#: replyto.php:835 #: replyto.php:888
msgid "Reply-To Email Address" msgid "Reply-To Email Address"
msgstr "" msgstr ""
#: replyto.php:845 #: replyto.php:898
msgid "Enter the email address where replies should be sent." msgid "Enter the email address where replies should be sent."
msgstr "" msgstr ""
#: replyto.php:852 #: replyto.php:905
msgid "Reply-To Display Name (Optional)" msgid "Reply-To Display Name (Optional)"
msgstr "" msgstr ""
#: replyto.php:862 #: replyto.php:915
msgid "Optional: Enter a name to display with the email (e.g., \"Support Team\")." msgid "Optional: Enter a name to display with the email (e.g., \"Support Team\")."
msgstr "" msgstr ""
#: replyto.php:871 #: replyto.php:924
msgid "Note:" msgid "Note:"
msgstr "" msgstr ""
#: replyto.php:872 #: replyto.php:925
msgid "The Default context is always active and acts as a fallback for all emails." msgid "The Default context is always active and acts as a fallback for all emails."
msgstr "" msgstr ""
#: replyto.php:898 #: replyto.php:935
msgid "Delete plugin data on uninstall"
msgstr ""
#: replyto.php:938
msgid "Your Reply-To settings are preserved by default. Check this box to remove all plugin data when the plugin is uninstalled."
msgstr ""
#: replyto.php:967
msgid "Save Settings" msgid "Save Settings"
msgstr "" msgstr ""

View file

@ -3,9 +3,9 @@ Contributors: robotstxt, javiercasares
Tags: email, reply-to, mail, smtp Tags: email, reply-to, mail, smtp
Requires at least: 4.7 Requires at least: 4.7
Tested up to: 7.1 Tested up to: 7.1
Stable tag: 2.0.3 Stable tag: 2.1.0
Requires PHP: 5.6 Requires PHP: 5.6
Version: 2.0.3 Version: 2.1.0
License: GPL-3.0-or-later License: GPL-3.0-or-later
License URI: https://www.gnu.org/licenses/gpl-3.0.txt License URI: https://www.gnu.org/licenses/gpl-3.0.txt
@ -46,9 +46,13 @@ Disabled contexts fall back to the Default Reply-To. If no Default is configured
Yes. When WooCommerce is active, a dedicated WooCommerce tab appears so you can route order emails to a separate reply address. Yes. When WooCommerce is active, a dedicated WooCommerce tab appears so you can route order emails to a separate reply address.
= Will my settings be deleted when I uninstall the plugin? =
No. By default all plugin data is preserved on uninstall. If you want everything removed, check "Delete plugin data on uninstall" on the Default tab before uninstalling. On Multisite, each site's own setting decides for that site's data.
= Does this plugin work on WordPress Multisite? = = Does this plugin work on WordPress Multisite? =
Yes. Each site in a Multisite network maintains its own configuration. On uninstall, data is removed from all sites. Yes. Each site in a Multisite network maintains its own configuration. On uninstall, each site's data is removed only if that site opted in to data deletion; by default all data is preserved.
== Compatibility == == Compatibility ==
@ -57,6 +61,42 @@ Yes. Each site in a Multisite network maintains its own configuration. On uninst
== Changelog == == Changelog ==
= 2.1.0 =
_Release date: 2026-09-18_
**Highlights**
* Known issues resolved: WooCommerce context values are no longer lost, and plugin data is now preserved on uninstall unless you opt in to removal.
**Added**
* "Delete plugin data on uninstall" opt-in setting (Default tab). Your Reply-To settings are preserved by default and only removed when you explicitly check this box.
* WP_MAIL_REPLYTO_VERSION constant for cache-busting and version checks.
**Changed**
* WooCommerce context values now survive settings saves made while WooCommerce is deactivated (previously they were silently dropped; the tab reappears with its values when WooCommerce is reactivated).
* Settings page now terminates with wp_die() instead of a silent blank page when accessed without manage_options.
* "Save Settings" button no longer double-escaped.
* Active tab query parameter ($_GET['tab']) now unslashed before sanitization (Plugin Check hardening).
* Development tooling updated via composer update (PHPStan 2.2.8 → 2.2.14, wp-compat 1.5.0 → 2.0.1, wordpress-stubs 6.9.4 → 7.1.0, phpstan-wordpress 2.0.3 → 2.0.4, php-parser 5.8.0 → 5.9.0, wp-hooks/wordpress-core 1.12.0 → 1.13.0).
* Documented wp-compat 2.x false positive for apply_filters() extra args (formalized in the 6.0 signature, functional since WP 0.71) with a targeted phpstan.neon ignore.
* bin/preflight.sh runs PHPStan with --memory-limit=1G (updated dev deps exceed the default 512M worker limit).
**Compatibility**
* WordPress: 4.7 - 7.1 (7.2 not yet released — expected December 2026 — so Tested up to stays at 7.1)
* PHP: 5.6 - 8.5
**Tests**
* PHP Coding Standards: 3.13.6
* WordPress Coding Standards: 3.4.1
* PHPStan: 2.2.14 (level 9)
* PHPUnit: 9.6.36
* Plugin Check (PCP): 0 errors on the release package.
= 2.0.3 = = 2.0.3 =
_Release date: 2026-08-18_ _Release date: 2026-08-18_
@ -121,57 +161,21 @@ _Release date: 2026-06-05_
* PHPStan: 2.2.2 (level 9) * PHPStan: 2.2.2 (level 9)
* PHPUnit: 9.6.34 * PHPUnit: 9.6.34
= 2.0.1 =
_Release date: 2026-06-05_
**Highlights**
* Major bugfix release addressing three critical issues found during pre-deploy audit.
**Fixed**
* Context cache not resetting between emails in the same PHP process.
* Duplicate Reply-To header injected when an existing Reply-To was present.
* Migration hook only running on admin_init — missed WP-CLI activations.
* RFC 5322 display name quoting now applied only when the name contains special characters.
**Added**
* Developer filters: wp_mail_replyto_context and wp_mail_replyto_header.
* load_plugin_textdomain() for translation support on WordPress < 4.6.
**Security**
* sanitize_callback added to legacy option registrations.
**Compatibility**
* WordPress: 4.1 - 6.9
* PHP: 5.6 - 8.5
**Tests**
* PHP Coding Standards: 3.13.5
* WordPress Coding Standards: 3.3.0
* PHPStan: 2.2.2 (level 9)
* PHPUnit: 9.6.34
= Previous versions = = Previous versions =
If you want to see the full changelog, visit the [changelog](https://www.robotstxt.software/plugins/replyto/changelog/) page. If you want to see the full changelog, visit the [changelog](https://www.robotstxt.software/plugins/replyto/changelog/) page.
== Upgrade Notice == == Upgrade Notice ==
= 2.1.0 =
WooCommerce context values are preserved and plugin data is kept on uninstall unless you opt in. Recommended for all users.
= 2.0.3 = = 2.0.3 =
Housekeeping release: branding URLs moved to robotstxt.software. Minimum WordPress version is now 4.7. Housekeeping release: branding URLs moved to robotstxt.software. Minimum WordPress version is now 4.7.
= 2.0.2 = = 2.0.2 =
Translations added for Spanish (Spain) and Catalan. WordPress minimum corrected to 3.6. Upgrade recommended. Translations added for Spanish (Spain) and Catalan. WordPress minimum corrected to 3.6. Upgrade recommended.
= 2.0.1 =
Bugfix release. Fixes context isolation between emails, duplicate Reply-To headers, and migration on WP-CLI. Upgrade recommended.
== Compliance == == Compliance ==
This plugin adheres to the following security measures and review protocols for each version: This plugin adheres to the following security measures and review protocols for each version:

View file

@ -5,7 +5,7 @@
* Plugin URI: https://www.robotstxt.software/plugins/replyto/ * Plugin URI: https://www.robotstxt.software/plugins/replyto/
* Requires at least: 4.7 * Requires at least: 4.7
* Requires PHP: 5.6 * Requires PHP: 5.6
* Version: 2.0.3 * Version: 2.1.0
* Author: ROBOTSTXT * Author: ROBOTSTXT
* Author URI: https://www.robotstxt.software/ * Author URI: https://www.robotstxt.software/
* License: GPL-3.0-or-later * License: GPL-3.0-or-later
@ -15,11 +15,20 @@
* *
* @package replyto * @package replyto
* *
* @version 2.0.3 * @version 2.1.0
*/ */
defined( 'ABSPATH' ) || die( 'No script kiddies please!' ); defined( 'ABSPATH' ) || die( 'No script kiddies please!' );
/**
* Current plugin version, used for cache busting and version checks.
*
* @since 2.1.0
*/
if ( ! defined( 'WP_MAIL_REPLYTO_VERSION' ) ) {
define( 'WP_MAIL_REPLYTO_VERSION', '2.1.0' );
}
register_activation_hook( __FILE__, 'wp_mail_replyto_migrate_to_v200' ); register_activation_hook( __FILE__, 'wp_mail_replyto_migrate_to_v200' );
/** /**
@ -472,10 +481,36 @@ function wp_mail_replyto_register_settings() {
'default' => '', 'default' => '',
) )
); );
// Uninstall behaviour opt-in: data is preserved unless the user checks this.
register_setting(
'wp_mail_replyto_settings_group',
'wp_mail_replyto_delete_on_uninstall',
array(
'type' => 'boolean',
'sanitize_callback' => 'wp_mail_replyto_sanitize_delete_on_uninstall',
'default' => false,
)
);
} }
add_action( 'admin_init', 'wp_mail_replyto_register_settings' ); add_action( 'admin_init', 'wp_mail_replyto_register_settings' );
/**
* Sanitizes the uninstall data-removal opt-in.
*
* Accepts the hidden/checkbox form values ('0'/'1') and booleans from
* programmatic update_option() calls. Anything else is treated as false.
*
* @since 2.1.0
*
* @param mixed $value Raw input value.
* @return bool True when data removal was explicitly requested.
*/
function wp_mail_replyto_sanitize_delete_on_uninstall( $value ) {
return ( '1' === $value || true === $value );
}
/** /**
* Sanitizes and validates the contexts configuration. * Sanitizes and validates the contexts configuration.
* *
@ -490,23 +525,41 @@ add_action( 'admin_init', 'wp_mail_replyto_register_settings' );
function wp_mail_replyto_sanitize_contexts( $input ) { function wp_mail_replyto_sanitize_contexts( $input ) {
$sanitized = array(); $sanitized = array();
// Define available contexts. // Previously stored configuration, used to preserve contexts whose tab
// was not rendered (WooCommerce while inactive) and for change logging.
$old_contexts_raw = get_option( 'wp_mail_replyto_contexts', array() );
$old_contexts = is_array( $old_contexts_raw ) ? $old_contexts_raw : array();
// Define available contexts. WooCommerce is always part of the sanitize
// set so its stored values survive saves made while WooCommerce is
// inactive; the tab itself is only rendered when WooCommerce is active.
$available_contexts = array( $available_contexts = array(
'default' => __( 'Default', 'replyto' ), 'default' => __( 'Default', 'replyto' ),
'authentication' => __( 'Authentication', 'replyto' ), 'authentication' => __( 'Authentication', 'replyto' ),
'comments' => __( 'Comments', 'replyto' ), 'comments' => __( 'Comments', 'replyto' ),
'users' => __( 'Users', 'replyto' ), 'users' => __( 'Users', 'replyto' ),
'system' => __( 'System', 'replyto' ), 'system' => __( 'System', 'replyto' ),
'woocommerce' => __( 'WooCommerce', 'replyto' ),
); );
// Add WooCommerce context only if WooCommerce is active. foreach ( $available_contexts as $context_key => $context_label ) {
if ( class_exists( 'WooCommerce' ) ) { // Context absent from the input means its tab was not rendered:
$available_contexts['woocommerce'] = __( 'WooCommerce', 'replyto' ); // preserve the stored entry (normalized) instead of wiping it.
if ( ! isset( $input[ $context_key ] ) ) {
$stored = isset( $old_contexts[ $context_key ] ) && is_array( $old_contexts[ $context_key ] )
? $old_contexts[ $context_key ]
: array();
$sanitized[ $context_key ] = array(
'email' => isset( $stored['email'] ) && is_string( $stored['email'] ) ? $stored['email'] : '',
'name' => isset( $stored['name'] ) && is_string( $stored['name'] ) ? $stored['name'] : '',
'enabled' => ! empty( $stored['enabled'] ),
);
continue;
} }
foreach ( $available_contexts as $context_key => $context_label ) {
// Get input for this context. // Get input for this context.
$ctx_input = isset( $input[ $context_key ] ) && is_array( $input[ $context_key ] ) ? $input[ $context_key ] : array(); $ctx_input = is_array( $input[ $context_key ] ) ? $input[ $context_key ] : array();
$email = isset( $ctx_input['email'] ) && is_string( $ctx_input['email'] ) ? sanitize_email( $ctx_input['email'] ) : ''; $email = isset( $ctx_input['email'] ) && is_string( $ctx_input['email'] ) ? sanitize_email( $ctx_input['email'] ) : '';
$name = isset( $ctx_input['name'] ) && is_string( $ctx_input['name'] ) ? sanitize_text_field( $ctx_input['name'] ) : ''; $name = isset( $ctx_input['name'] ) && is_string( $ctx_input['name'] ) ? sanitize_text_field( $ctx_input['name'] ) : '';
$enabled_raw = isset( $ctx_input['enabled'] ) ? $ctx_input['enabled'] : ''; $enabled_raw = isset( $ctx_input['enabled'] ) ? $ctx_input['enabled'] : '';
@ -586,8 +639,7 @@ function wp_mail_replyto_sanitize_contexts( $input ) {
} }
// Log changes if in debug mode. // Log changes if in debug mode.
$old_value = get_option( 'wp_mail_replyto_contexts', array() ); if ( $old_contexts !== $sanitized ) {
if ( $old_value !== $sanitized ) {
$user = wp_get_current_user(); $user = wp_get_current_user();
$remote_addr = isset( $_SERVER['REMOTE_ADDR'] ) && is_string( $_SERVER['REMOTE_ADDR'] ) $remote_addr = isset( $_SERVER['REMOTE_ADDR'] ) && is_string( $_SERVER['REMOTE_ADDR'] )
? sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ) ? sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) )
@ -629,7 +681,7 @@ function wp_mail_replyto_admin_styles( $hook ) {
return; return;
} }
wp_register_style( 'replyto-admin', false, array(), '2.0.3' ); wp_register_style( 'replyto-admin', false, array(), WP_MAIL_REPLYTO_VERSION );
wp_enqueue_style( 'replyto-admin' ); wp_enqueue_style( 'replyto-admin' );
wp_add_inline_style( wp_add_inline_style(
'replyto-admin', 'replyto-admin',
@ -691,17 +743,23 @@ add_action( 'admin_enqueue_scripts', 'wp_mail_replyto_admin_styles' );
function wp_mail_replyto_render_settings_page() { function wp_mail_replyto_render_settings_page() {
// Check if the current user has the required capability. // Check if the current user has the required capability.
if ( ! current_user_can( 'manage_options' ) ) { if ( ! current_user_can( 'manage_options' ) ) {
return; wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'replyto' ) );
} }
// Get current contexts configuration. // Get current contexts configuration.
$contexts_raw = get_option( 'wp_mail_replyto_contexts', array() ); $contexts_raw = get_option( 'wp_mail_replyto_contexts', array() );
$contexts = is_array( $contexts_raw ) ? $contexts_raw : array(); $contexts = is_array( $contexts_raw ) ? $contexts_raw : array();
// Uninstall behaviour opt-in (data is preserved by default).
$delete_on_uninstall = wp_mail_replyto_sanitize_delete_on_uninstall( get_option( 'wp_mail_replyto_delete_on_uninstall', false ) );
// Get active tab from URL, default to 'default'. // Get active tab from URL, default to 'default'.
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Tab parameter is for display only, not data modification. // phpcs:disable WordPress.Security.NonceVerification.Recommended -- Tab parameter is for display only, not data modification.
$active_tab_raw = isset( $_GET['tab'] ) && is_string( $_GET['tab'] ) ? $_GET['tab'] : 'default'; $active_tab = 'default';
$active_tab = sanitize_key( $active_tab_raw ); if ( isset( $_GET['tab'] ) && is_string( $_GET['tab'] ) ) {
$active_tab = sanitize_key( wp_unslash( $_GET['tab'] ) );
}
// phpcs:enable
// Define contexts with descriptions. // Define contexts with descriptions.
$context_config = array( $context_config = array(
@ -871,6 +929,22 @@ function wp_mail_replyto_render_settings_page() {
<strong><?php esc_html_e( 'Note:', 'replyto' ); ?></strong> <strong><?php esc_html_e( 'Note:', 'replyto' ); ?></strong>
<?php esc_html_e( 'The Default context is always active and acts as a fallback for all emails.', 'replyto' ); ?> <?php esc_html_e( 'The Default context is always active and acts as a fallback for all emails.', 'replyto' ); ?>
</p> </p>
<div class="replyto-toggle-wrapper">
<label>
<input type="hidden" name="wp_mail_replyto_delete_on_uninstall" value="0" />
<input type="checkbox"
name="wp_mail_replyto_delete_on_uninstall"
value="1"
<?php checked( $delete_on_uninstall ); ?> />
<strong><?php esc_html_e( 'Delete plugin data on uninstall', 'replyto' ); ?></strong>
</label>
<p class="description">
<?php esc_html_e( 'Your Reply-To settings are preserved by default. Check this box to remove all plugin data when the plugin is uninstalled.', 'replyto' ); ?>
</p>
</div>
<?php else : ?>
<input type="hidden" name="wp_mail_replyto_delete_on_uninstall" value="<?php echo esc_attr( $delete_on_uninstall ? '1' : '0' ); ?>" />
<?php endif; ?> <?php endif; ?>
<?php <?php
@ -895,7 +969,7 @@ function wp_mail_replyto_render_settings_page() {
?> ?>
</div> </div>
<?php submit_button( esc_html__( 'Save Settings', 'replyto' ) ); ?> <?php submit_button( __( 'Save Settings', 'replyto' ) ); ?>
</form> </form>
</div> </div>
<?php <?php

View file

@ -3,11 +3,12 @@
* Uninstall script for Reply-To for WP_Mail * Uninstall script for Reply-To for WP_Mail
* *
* This file is executed when the plugin is uninstalled via the WordPress admin. * This file is executed when the plugin is uninstalled via the WordPress admin.
* It removes all plugin data from the database to ensure clean uninstallation. * Since 2.1.0 plugin data is preserved by default; it is only removed when the
* user opted in via the "Delete plugin data on uninstall" setting.
* *
* @package replyto * @package replyto
* @since 1.1.0 * @since 1.1.0
* @version 2.0.0 - Added cleanup for contexts configuration. * @version 2.1.0 - Data removal is now opt-in; cleanup honours the per-site setting.
*/ */
// If uninstall not called from WordPress, exit. // If uninstall not called from WordPress, exit.
@ -15,9 +16,25 @@ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit; exit;
} }
if ( ! function_exists( 'wp_mail_replyto_uninstall_cleanup' ) ) {
/** /**
* Delete plugin options from single site or main site. * Deletes this site's plugin options when the user opted in to removal.
*
* The opt-in flag itself is only removed together with the rest of the
* data; when data is preserved the flag is preserved too, so a later
* deactivate/reactivate/uninstall cycle keeps honouring the choice.
*
* @since 2.1.0
*
* @return void
*/ */
function wp_mail_replyto_uninstall_cleanup() {
// Inlined opt-in check (uninstall.php runs without the main plugin file).
$delete_data = get_option( 'wp_mail_replyto_delete_on_uninstall', false );
if ( '1' !== $delete_data && true !== $delete_data ) {
return;
}
// Legacy options (v1.0.0 - v1.0.3). // Legacy options (v1.0.0 - v1.0.3).
delete_option( 'wp_mail_replyto_email' ); delete_option( 'wp_mail_replyto_email' );
delete_option( 'wp_mail_replyto_name' ); delete_option( 'wp_mail_replyto_name' );
@ -26,25 +43,24 @@ delete_option( 'wp_mail_replyto_name' );
delete_option( 'wp_mail_replyto_contexts' ); delete_option( 'wp_mail_replyto_contexts' );
delete_option( 'wp_mail_replyto_migration_v200' ); delete_option( 'wp_mail_replyto_migration_v200' );
/** // The opt-in flag itself (v2.1.0+).
* For multisite installations, delete the options from all sites. delete_option( 'wp_mail_replyto_delete_on_uninstall' );
*/ }
}
if ( is_multisite() ) { if ( is_multisite() ) {
global $wpdb; // Delete options from every site; each site's own opt-in decides its data.
// Get all blog IDs.
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- $blog_ids is a temporary local variable used only within this uninstall script, not a global variable that persists across the plugin. It's scoped to this file and iteration loop only.
$blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
foreach ( $blog_ids as $blog_id ) { foreach ( get_sites(
switch_to_blog( $blog_id ); array(
// Legacy options. 'fields' => 'ids',
delete_option( 'wp_mail_replyto_email' ); 'number' => 0,
delete_option( 'wp_mail_replyto_name' ); )
// v2.0.0+ options. ) as $site_id ) {
delete_option( 'wp_mail_replyto_contexts' ); switch_to_blog( (int) $site_id );
delete_option( 'wp_mail_replyto_migration_v200' ); wp_mail_replyto_uninstall_cleanup();
restore_current_blog(); restore_current_blog();
} }
} else {
wp_mail_replyto_uninstall_cleanup();
} }