v2.1.0
This commit is contained in:
parent
7929462680
commit
a6b592a27d
6 changed files with 384 additions and 9 deletions
|
|
@ -1,3 +1,12 @@
|
||||||
|
= 2.1.0 =
|
||||||
|
|
||||||
|
* Added data management option to control whether plugin data is deleted on uninstall (disabled by default for data preservation).
|
||||||
|
* Added reset plugin data functionality with site-level and network-level support.
|
||||||
|
* Added unified uninstall cleanup system that handles all add-on data (Amazon SES, Newsletter).
|
||||||
|
* Added automatic password clearing when both host and username fields are empty to prevent orphaned credentials.
|
||||||
|
* Changed uninstall behavior to respect user preference: data is preserved by default unless explicitly enabled.
|
||||||
|
* Changed add-on plugins (Amazon SES, Newsletter) to no longer perform cleanup on uninstall - all cleanup is centralized in the core plugin.
|
||||||
|
|
||||||
= 2.0.1 =
|
= 2.0.1 =
|
||||||
|
|
||||||
* Fixed automatic password clearing when both host and username fields are empty to prevent orphaned credentials.
|
* Fixed automatic password clearing when both host and username fields are empty to prevent orphaned credentials.
|
||||||
|
|
|
||||||
|
|
@ -299,8 +299,12 @@ class Settings_Page {
|
||||||
add_action( 'admin_post_robotstxt_smtp_test_email', array( $this, 'handle_test_email' ) );
|
add_action( 'admin_post_robotstxt_smtp_test_email', array( $this, 'handle_test_email' ) );
|
||||||
add_action( 'admin_post_robotstxt_smtp_clear_logs', array( $this, 'handle_clear_logs' ) );
|
add_action( 'admin_post_robotstxt_smtp_clear_logs', array( $this, 'handle_clear_logs' ) );
|
||||||
add_action( 'admin_post_robotstxt_smtp_save_network_settings', array( $this, 'handle_save_network_settings' ) );
|
add_action( 'admin_post_robotstxt_smtp_save_network_settings', array( $this, 'handle_save_network_settings' ) );
|
||||||
|
add_action( 'admin_post_robotstxt_smtp_reset_data', array( $this, 'handle_reset_data' ) );
|
||||||
|
add_action( 'admin_post_robotstxt_smtp_reset_data_network', array( $this, 'handle_reset_data_network' ) );
|
||||||
add_action( 'admin_notices', array( $this, 'display_test_email_notice' ) );
|
add_action( 'admin_notices', array( $this, 'display_test_email_notice' ) );
|
||||||
add_action( 'network_admin_notices', array( $this, 'display_test_email_notice' ) );
|
add_action( 'network_admin_notices', array( $this, 'display_test_email_notice' ) );
|
||||||
|
add_action( 'admin_notices', array( $this, 'display_reset_data_notice' ) );
|
||||||
|
add_action( 'network_admin_notices', array( $this, 'display_reset_data_notice' ) );
|
||||||
add_action( 'shutdown', array( $this, 'maybe_send_pending_site_test' ) );
|
add_action( 'shutdown', array( $this, 'maybe_send_pending_site_test' ) );
|
||||||
add_action( 'updated_option', array( $this, 'handle_settings_option_updated' ), 10, 3 );
|
add_action( 'updated_option', array( $this, 'handle_settings_option_updated' ), 10, 3 );
|
||||||
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) );
|
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) );
|
||||||
|
|
@ -1075,6 +1079,7 @@ class Settings_Page {
|
||||||
public function render_site_settings_page(): void {
|
public function render_site_settings_page(): void {
|
||||||
$this->ensure_capability( self::SCOPE_SITE );
|
$this->ensure_capability( self::SCOPE_SITE );
|
||||||
$this->set_scope( self::SCOPE_SITE );
|
$this->set_scope( self::SCOPE_SITE );
|
||||||
|
$settings = $this->get_settings();
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
|
|
@ -1085,6 +1090,36 @@ class Settings_Page {
|
||||||
do_settings_sections( self::PAGE_SLUG );
|
do_settings_sections( self::PAGE_SLUG );
|
||||||
submit_button( esc_html__( 'Save Changes', 'robotstxt-smtp' ) );
|
submit_button( esc_html__( 'Save Changes', 'robotstxt-smtp' ) );
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
<hr style="margin: 30px 0;">
|
||||||
|
<h2><?php esc_html_e( 'Data Management', 'robotstxt-smtp' ); ?></h2>
|
||||||
|
<table class="form-table" role="presentation">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th scope="row"><?php esc_html_e( 'Delete data on uninstall', 'robotstxt-smtp' ); ?></th>
|
||||||
|
<td>
|
||||||
|
<fieldset>
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" name="<?php echo esc_attr( self::OPTION_NAME ); ?>[delete_data_on_uninstall]" value="1" <?php checked( ! empty( $settings['delete_data_on_uninstall'] ) ); ?> />
|
||||||
|
<?php esc_html_e( 'Remove all plugin data when uninstalling', 'robotstxt-smtp' ); ?>
|
||||||
|
</label>
|
||||||
|
<p class="description">
|
||||||
|
<?php esc_html_e( 'When enabled, all settings, logs, statistics, and data from add-ons (Amazon SES, Newsletter) will be permanently deleted when you uninstall this plugin. When disabled (default), all data will be preserved.', 'robotstxt-smtp' ); ?>
|
||||||
|
</p>
|
||||||
|
</fieldset>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<hr style="margin: 30px 0;">
|
||||||
|
<h2><?php esc_html_e( 'Reset Plugin Data', 'robotstxt-smtp' ); ?></h2>
|
||||||
|
<p><?php esc_html_e( 'This will permanently delete all plugin settings, logs, statistics, and reset the plugin to its default state. This action cannot be undone.', 'robotstxt-smtp' ); ?></p>
|
||||||
|
<form action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" method="post" onsubmit="return confirm('<?php echo esc_js( __( 'Are you sure you want to reset all plugin data? This action cannot be undone.', 'robotstxt-smtp' ) ); ?>');">
|
||||||
|
<?php wp_nonce_field( 'robotstxt_smtp_reset_data' ); ?>
|
||||||
|
<input type="hidden" name="action" value="robotstxt_smtp_reset_data" />
|
||||||
|
<?php submit_button( esc_html__( 'Reset All Plugin Data', 'robotstxt-smtp' ), 'delete', 'submit', false ); ?>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
|
|
@ -1187,6 +1222,36 @@ class Settings_Page {
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<?php submit_button( esc_html__( 'Save Changes', 'robotstxt-smtp' ) ); ?>
|
<?php submit_button( esc_html__( 'Save Changes', 'robotstxt-smtp' ) ); ?>
|
||||||
|
|
||||||
|
<hr style="margin: 30px 0;">
|
||||||
|
<h2><?php esc_html_e( 'Data Management', 'robotstxt-smtp' ); ?></h2>
|
||||||
|
<table class="form-table" role="presentation">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th scope="row"><?php esc_html_e( 'Delete data on uninstall', 'robotstxt-smtp' ); ?></th>
|
||||||
|
<td>
|
||||||
|
<fieldset>
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" name="robotstxt_smtp_options[delete_data_on_uninstall]" value="1" <?php checked( ! empty( $this->get_settings()['delete_data_on_uninstall'] ) ); ?> />
|
||||||
|
<?php esc_html_e( 'Remove all plugin data when uninstalling', 'robotstxt-smtp' ); ?>
|
||||||
|
</label>
|
||||||
|
<p class="description">
|
||||||
|
<?php esc_html_e( 'When enabled, all settings, logs, statistics, and data from add-ons (Amazon SES, Newsletter) will be permanently deleted when you uninstall this plugin. When disabled (default), all data will be preserved.', 'robotstxt-smtp' ); ?>
|
||||||
|
</p>
|
||||||
|
</fieldset>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<hr style="margin: 30px 0;">
|
||||||
|
<h2><?php esc_html_e( 'Reset Plugin Data', 'robotstxt-smtp' ); ?></h2>
|
||||||
|
<p><?php esc_html_e( 'This will permanently delete all network-wide and site-specific plugin settings, logs, statistics, and reset the plugin to its default state across all sites. This action cannot be undone.', 'robotstxt-smtp' ); ?></p>
|
||||||
|
<form action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" method="post" onsubmit="return confirm('<?php echo esc_js( __( 'Are you sure you want to reset all plugin data across the entire network? This action cannot be undone.', 'robotstxt-smtp' ) ); ?>');">
|
||||||
|
<?php wp_nonce_field( 'robotstxt_smtp_reset_data_network' ); ?>
|
||||||
|
<input type="hidden" name="action" value="robotstxt_smtp_reset_data_network" />
|
||||||
|
<?php submit_button( esc_html__( 'Reset All Plugin Data (Network-wide)', 'robotstxt-smtp' ), 'delete', 'submit', false ); ?>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
|
|
@ -3422,6 +3487,169 @@ class Settings_Page {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the reset plugin data request.
|
||||||
|
*
|
||||||
|
* @since 2.0.1
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle_reset_data(): void {
|
||||||
|
$nonce_value = filter_input( INPUT_POST, '_wpnonce', FILTER_UNSAFE_RAW );
|
||||||
|
|
||||||
|
// Block reset unless the nonce matches the action button submission.
|
||||||
|
if ( ! is_string( $nonce_value ) || ! wp_verify_nonce( wp_unslash( $nonce_value ), 'robotstxt_smtp_reset_data' ) ) {
|
||||||
|
wp_die( esc_html__( 'The link you followed has expired.', 'robotstxt-smtp' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->ensure_capability( self::SCOPE_SITE );
|
||||||
|
|
||||||
|
// Delete all plugin data for current site.
|
||||||
|
delete_option( self::OPTION_NAME );
|
||||||
|
delete_option( 'robotstxt_smtp_newsletter_options' );
|
||||||
|
|
||||||
|
// Delete logs.
|
||||||
|
Plugin::get_instance()->clear_all_logs();
|
||||||
|
|
||||||
|
// Clear transients.
|
||||||
|
$this->delete_transient_prefix( 'robotstxt_smtp_tool_' );
|
||||||
|
$this->delete_transient_prefix( 'robotstxt_smtp_test_result_' );
|
||||||
|
$this->delete_transient_prefix( 'robotstxt_smtp_amazonses_quota_' );
|
||||||
|
|
||||||
|
// Clear cron hooks.
|
||||||
|
wp_clear_scheduled_hook( 'robotstxt_smtp_cleanup_logs' );
|
||||||
|
wp_clear_scheduled_hook( 'robotstxt_smtp_cleanup_stats' );
|
||||||
|
wp_clear_scheduled_hook( 'robotstxt_smtp_amazonses_update_quota' );
|
||||||
|
|
||||||
|
// Redirect with success message.
|
||||||
|
$redirect = add_query_arg(
|
||||||
|
array(
|
||||||
|
'page' => self::PAGE_SLUG,
|
||||||
|
'robotstxt_smtp_reset' => 1,
|
||||||
|
),
|
||||||
|
admin_url( 'options-general.php' )
|
||||||
|
);
|
||||||
|
|
||||||
|
wp_safe_redirect( $redirect );
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the reset plugin data request for network admin.
|
||||||
|
*
|
||||||
|
* @since 2.0.1
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle_reset_data_network(): void {
|
||||||
|
$nonce_value = filter_input( INPUT_POST, '_wpnonce', FILTER_UNSAFE_RAW );
|
||||||
|
|
||||||
|
// Block reset unless the nonce matches the action button submission.
|
||||||
|
if ( ! is_string( $nonce_value ) || ! wp_verify_nonce( wp_unslash( $nonce_value ), 'robotstxt_smtp_reset_data_network' ) ) {
|
||||||
|
wp_die( esc_html__( 'The link you followed has expired.', 'robotstxt-smtp' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! ROBOTSTXT_SMTP_IS_MULTISITE ) {
|
||||||
|
wp_die( esc_html__( 'Network reset is only available on multisite installations.', 'robotstxt-smtp' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->ensure_capability( self::SCOPE_NETWORK );
|
||||||
|
|
||||||
|
// Delete network-wide data.
|
||||||
|
delete_site_option( self::NETWORK_OPTION_NAME );
|
||||||
|
delete_site_option( 'robotstxt_smtp_configuration_scope' );
|
||||||
|
|
||||||
|
// Delete statistics table.
|
||||||
|
global $wpdb;
|
||||||
|
$table_name = $wpdb->base_prefix . 'robotstxt_smtp_stats';
|
||||||
|
$wpdb->query( "DROP TABLE IF EXISTS {$table_name}" );
|
||||||
|
delete_site_option( 'robotstxt_smtp_stats_db_version' );
|
||||||
|
|
||||||
|
// Reset all sites in the network.
|
||||||
|
$sites = get_sites( array( 'fields' => 'ids' ) );
|
||||||
|
foreach ( $sites as $site_id ) {
|
||||||
|
switch_to_blog( (int) $site_id );
|
||||||
|
|
||||||
|
// Delete site options.
|
||||||
|
delete_option( self::OPTION_NAME );
|
||||||
|
delete_option( 'robotstxt_smtp_newsletter_options' );
|
||||||
|
|
||||||
|
// Clear logs.
|
||||||
|
Plugin::get_instance()->clear_all_logs();
|
||||||
|
|
||||||
|
// Clear transients.
|
||||||
|
$this->delete_transient_prefix( 'robotstxt_smtp_tool_' );
|
||||||
|
$this->delete_transient_prefix( 'robotstxt_smtp_test_result_' );
|
||||||
|
$this->delete_transient_prefix( 'robotstxt_smtp_amazonses_quota_' );
|
||||||
|
|
||||||
|
// Clear cron hooks.
|
||||||
|
wp_clear_scheduled_hook( 'robotstxt_smtp_cleanup_logs' );
|
||||||
|
wp_clear_scheduled_hook( 'robotstxt_smtp_cleanup_stats' );
|
||||||
|
wp_clear_scheduled_hook( 'robotstxt_smtp_amazonses_update_quota' );
|
||||||
|
|
||||||
|
restore_current_blog();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Redirect with success message.
|
||||||
|
$redirect = add_query_arg(
|
||||||
|
array(
|
||||||
|
'page' => self::NETWORK_PAGE_SLUG,
|
||||||
|
'robotstxt_smtp_reset' => 1,
|
||||||
|
),
|
||||||
|
network_admin_url( 'settings.php' )
|
||||||
|
);
|
||||||
|
|
||||||
|
wp_safe_redirect( $redirect );
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes transients with a specific prefix.
|
||||||
|
*
|
||||||
|
* @since 2.0.1
|
||||||
|
*
|
||||||
|
* @param string $prefix Transient prefix without internal storage prefix.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function delete_transient_prefix( string $prefix ): void {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$stored_prefix = '_transient_' . $prefix;
|
||||||
|
$timeout_prefix = '_transient_timeout_' . $prefix;
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||||
|
$matches = $wpdb->get_col(
|
||||||
|
$wpdb->prepare(
|
||||||
|
"SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE %s OR option_name LIKE %s",
|
||||||
|
$wpdb->esc_like( $stored_prefix ) . '%',
|
||||||
|
$wpdb->esc_like( $timeout_prefix ) . '%'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if ( empty( $matches ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ( $matches as $option_name ) {
|
||||||
|
if ( ! is_string( $option_name ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( str_starts_with( $option_name, '_transient_timeout_' ) ) {
|
||||||
|
$transient_key = substr( $option_name, strlen( '_transient_timeout_' ) );
|
||||||
|
} else {
|
||||||
|
$transient_key = substr( $option_name, strlen( '_transient_' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( '' === $transient_key ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete_transient( $transient_key );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders the host field.
|
* Renders the host field.
|
||||||
*
|
*
|
||||||
|
|
@ -3990,6 +4218,9 @@ class Settings_Page {
|
||||||
$clean['rate_limit_per_day'] = absint( $options['rate_limit_per_day'] );
|
$clean['rate_limit_per_day'] = absint( $options['rate_limit_per_day'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sanitize delete on uninstall option.
|
||||||
|
$clean['delete_data_on_uninstall'] = ! empty( $options['delete_data_on_uninstall'] );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the sanitized SMTP options before they are persisted.
|
* Filters the sanitized SMTP options before they are persisted.
|
||||||
*
|
*
|
||||||
|
|
@ -5243,6 +5474,7 @@ class Settings_Page {
|
||||||
'rate_limit_per_second' => 0,
|
'rate_limit_per_second' => 0,
|
||||||
'rate_limit_per_hour' => 0,
|
'rate_limit_per_hour' => 0,
|
||||||
'rate_limit_per_day' => 0,
|
'rate_limit_per_day' => 0,
|
||||||
|
'delete_data_on_uninstall' => false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5630,6 +5862,49 @@ class Settings_Page {
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays the reset data success notice.
|
||||||
|
*
|
||||||
|
* @since 2.0.1
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function display_reset_data_notice(): void {
|
||||||
|
if ( ! is_admin() ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$page = filter_input( INPUT_GET, 'page', FILTER_UNSAFE_RAW );
|
||||||
|
|
||||||
|
if ( null === $page ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$page = sanitize_key( $page );
|
||||||
|
|
||||||
|
if ( '' === $page || ! in_array( $page, array( self::PAGE_SLUG, self::NETWORK_PAGE_SLUG ), true ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$reset = filter_input( INPUT_GET, 'robotstxt_smtp_reset', FILTER_UNSAFE_RAW );
|
||||||
|
|
||||||
|
if ( null === $reset ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$reset = absint( $reset );
|
||||||
|
|
||||||
|
if ( 1 !== $reset ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<div class="notice notice-success is-dismissible">
|
||||||
|
<p><strong><?php esc_html_e( 'All plugin data has been reset successfully.', 'robotstxt-smtp' ); ?></strong></p>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders the test email form.
|
* Renders the test email form.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@ Contributors: javiercasares
|
||||||
Tags: smtp, email, mail
|
Tags: smtp, email, mail
|
||||||
Requires at least: 6.5
|
Requires at least: 6.5
|
||||||
Tested up to: 6.9
|
Tested up to: 6.9
|
||||||
Stable tag: 2.0.1
|
Stable tag: 2.1.0
|
||||||
Requires PHP: 8.2
|
Requires PHP: 8.2
|
||||||
Version: 2.0.1
|
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.html
|
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
* Plugin Name: SMTP (by ROBOTSTXT)
|
* Plugin Name: SMTP (by ROBOTSTXT)
|
||||||
* Plugin URI: https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp
|
* Plugin URI: https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp
|
||||||
* Description: Configure WordPress to send emails through SMTP with detailed controls.
|
* Description: Configure WordPress to send emails through SMTP with detailed controls.
|
||||||
* Version: 2.0.1
|
* Version: 2.1.0
|
||||||
* Requires at least: 6.5
|
* Requires at least: 6.5
|
||||||
* Requires PHP: 8.2
|
* Requires PHP: 8.2
|
||||||
* Network: true
|
* Network: true
|
||||||
|
|
@ -25,7 +25,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! defined( 'ROBOTSTXT_SMTP_VERSION' ) ) {
|
if ( ! defined( 'ROBOTSTXT_SMTP_VERSION' ) ) {
|
||||||
define( 'ROBOTSTXT_SMTP_VERSION', '2.0.1' );
|
define( 'ROBOTSTXT_SMTP_VERSION', '2.1.0' );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! defined( 'ROBOTSTXT_SMTP_FILE' ) ) {
|
if ( ! defined( 'ROBOTSTXT_SMTP_FILE' ) ) {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,30 @@ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if user wants to delete data on uninstall.
|
||||||
|
$should_delete_data = false;
|
||||||
|
|
||||||
|
if ( function_exists( 'is_multisite' ) && is_multisite() ) {
|
||||||
|
// Check network option first, fallback to first site option.
|
||||||
|
$network_options = get_site_option( 'robotstxt_smtp_network_options', array() );
|
||||||
|
if ( is_array( $network_options ) && ! empty( $network_options['delete_data_on_uninstall'] ) ) {
|
||||||
|
$should_delete_data = true;
|
||||||
|
} else {
|
||||||
|
$sites = get_sites( array( 'number' => 1, 'fields' => 'ids' ) );
|
||||||
|
$first_site_id = ! empty( $sites ) ? $sites[0] : 1;
|
||||||
|
$site_options = get_blog_option( $first_site_id, 'robotstxt_smtp_options', array() );
|
||||||
|
$should_delete_data = is_array( $site_options ) && ! empty( $site_options['delete_data_on_uninstall'] );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$options = get_option( 'robotstxt_smtp_options', array() );
|
||||||
|
$should_delete_data = is_array( $options ) && ! empty( $options['delete_data_on_uninstall'] );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exit early if user doesn't want to delete data.
|
||||||
|
if ( ! $should_delete_data ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! function_exists( 'robotstxt_smtp_uninstall_cleanup_site' ) ) {
|
if ( ! function_exists( 'robotstxt_smtp_uninstall_cleanup_site' ) ) {
|
||||||
/**
|
/**
|
||||||
* Removes all plugin data for the current site.
|
* Removes all plugin data for the current site.
|
||||||
|
|
@ -18,12 +42,36 @@ if ( ! function_exists( 'robotstxt_smtp_uninstall_cleanup_site' ) ) {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function robotstxt_smtp_uninstall_cleanup_site(): void {
|
function robotstxt_smtp_uninstall_cleanup_site(): void {
|
||||||
|
// Delete core SMTP plugin options.
|
||||||
delete_option( 'robotstxt_smtp_options' );
|
delete_option( 'robotstxt_smtp_options' );
|
||||||
|
|
||||||
|
// Delete Newsletter add-on options.
|
||||||
|
delete_option( 'robotstxt_smtp_newsletter_options' );
|
||||||
|
|
||||||
|
// Delete logs (shared by core and add-ons).
|
||||||
robotstxt_smtp_uninstall_delete_logs();
|
robotstxt_smtp_uninstall_delete_logs();
|
||||||
|
|
||||||
|
// Delete core SMTP transients.
|
||||||
robotstxt_smtp_uninstall_delete_transient_prefix( 'robotstxt_smtp_tool_', false );
|
robotstxt_smtp_uninstall_delete_transient_prefix( 'robotstxt_smtp_tool_', false );
|
||||||
robotstxt_smtp_uninstall_delete_transient_prefix( 'robotstxt_smtp_test_result_', false );
|
robotstxt_smtp_uninstall_delete_transient_prefix( 'robotstxt_smtp_test_result_', false );
|
||||||
|
|
||||||
|
// Delete Amazon SES transients.
|
||||||
|
robotstxt_smtp_uninstall_delete_transient_prefix( 'robotstxt_smtp_amazonses_quota_', false );
|
||||||
|
|
||||||
|
// Delete updater cache transients for all plugins.
|
||||||
|
$plugin_basenames = array(
|
||||||
|
'robotstxt-smtp/robotstxt-smtp.php',
|
||||||
|
'robotstxt-smtp-amazonses/robotstxt-smtp-amazonses.php',
|
||||||
|
'robotstxt-smtp-newsletter/robotstxt-smtp-newsletter.php',
|
||||||
|
);
|
||||||
|
foreach ( $plugin_basenames as $basename ) {
|
||||||
|
delete_transient( 'robotstxt_updater_' . md5( $basename ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear scheduled cron hooks.
|
||||||
wp_clear_scheduled_hook( 'robotstxt_smtp_cleanup_logs' );
|
wp_clear_scheduled_hook( 'robotstxt_smtp_cleanup_logs' );
|
||||||
|
wp_clear_scheduled_hook( 'robotstxt_smtp_cleanup_stats' );
|
||||||
|
wp_clear_scheduled_hook( 'robotstxt_smtp_amazonses_update_quota' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -36,11 +84,29 @@ if ( ! function_exists( 'robotstxt_smtp_uninstall_cleanup_network' ) ) {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function robotstxt_smtp_uninstall_cleanup_network(): void {
|
function robotstxt_smtp_uninstall_cleanup_network(): void {
|
||||||
|
// Delete core SMTP network options.
|
||||||
delete_site_option( 'robotstxt_smtp_network_options' );
|
delete_site_option( 'robotstxt_smtp_network_options' );
|
||||||
delete_site_option( 'robotstxt_smtp_configuration_scope' );
|
delete_site_option( 'robotstxt_smtp_configuration_scope' );
|
||||||
|
|
||||||
|
// Delete core SMTP site transients.
|
||||||
robotstxt_smtp_uninstall_delete_transient_prefix( 'robotstxt_smtp_tool_', true );
|
robotstxt_smtp_uninstall_delete_transient_prefix( 'robotstxt_smtp_tool_', true );
|
||||||
robotstxt_smtp_uninstall_delete_transient_prefix( 'robotstxt_smtp_test_result_', true );
|
robotstxt_smtp_uninstall_delete_transient_prefix( 'robotstxt_smtp_test_result_', true );
|
||||||
|
|
||||||
|
// Delete Amazon SES site transients.
|
||||||
|
robotstxt_smtp_uninstall_delete_transient_prefix( 'robotstxt_smtp_amazonses_quota_', true );
|
||||||
|
|
||||||
|
// Delete updater cache site transients for all plugins.
|
||||||
|
$plugin_basenames = array(
|
||||||
|
'robotstxt-smtp/robotstxt-smtp.php',
|
||||||
|
'robotstxt-smtp-amazonses/robotstxt-smtp-amazonses.php',
|
||||||
|
'robotstxt-smtp-newsletter/robotstxt-smtp-newsletter.php',
|
||||||
|
);
|
||||||
|
foreach ( $plugin_basenames as $basename ) {
|
||||||
|
delete_site_transient( 'robotstxt_updater_' . md5( $basename ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear WordPress update cache.
|
||||||
|
delete_site_transient( 'update_plugins' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -140,8 +206,30 @@ if ( ! function_exists( 'robotstxt_smtp_uninstall_delete_logs' ) ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( ! function_exists( 'robotstxt_smtp_uninstall_delete_statistics_table' ) ) {
|
||||||
|
/**
|
||||||
|
* Drops the statistics table from the database.
|
||||||
|
*
|
||||||
|
* @since 2.0.1
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function robotstxt_smtp_uninstall_delete_statistics_table(): void {
|
||||||
|
global $wpdb;
|
||||||
|
$table_name = $wpdb->base_prefix . 'robotstxt_smtp_stats';
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange
|
||||||
|
$wpdb->query( "DROP TABLE IF EXISTS {$table_name}" );
|
||||||
|
|
||||||
|
// Delete the database version option.
|
||||||
|
delete_site_option( 'robotstxt_smtp_stats_db_version' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clean up network-wide data.
|
||||||
robotstxt_smtp_uninstall_cleanup_network();
|
robotstxt_smtp_uninstall_cleanup_network();
|
||||||
|
|
||||||
|
// Clean up site-specific data.
|
||||||
if ( function_exists( 'is_multisite' ) && is_multisite() ) {
|
if ( function_exists( 'is_multisite' ) && is_multisite() ) {
|
||||||
$robotstxt_smtp_sites = get_sites( array( 'fields' => 'ids' ) );
|
$robotstxt_smtp_sites = get_sites( array( 'fields' => 'ids' ) );
|
||||||
|
|
||||||
|
|
@ -153,3 +241,6 @@ if ( function_exists( 'is_multisite' ) && is_multisite() ) {
|
||||||
} else {
|
} else {
|
||||||
robotstxt_smtp_uninstall_cleanup_site();
|
robotstxt_smtp_uninstall_cleanup_site();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Drop the statistics table (global, only once).
|
||||||
|
robotstxt_smtp_uninstall_delete_statistics_table();
|
||||||
|
|
|
||||||
10
update.json
10
update.json
|
|
@ -1,20 +1,20 @@
|
||||||
{
|
{
|
||||||
"name": "SMTP (by ROBOTSTXT)",
|
"name": "SMTP (by ROBOTSTXT)",
|
||||||
"slug": "robotstxt-smtp",
|
"slug": "robotstxt-smtp",
|
||||||
"version": "2.0.0",
|
"version": "2.1.0",
|
||||||
"download_url": "https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp/releases/download/2.0.0/robotstxt-smtp-2.0.0.zip",
|
"download_url": "https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp/releases/download/2.1.0/robotstxt-smtp-2.1.0.zip",
|
||||||
"requires": "6.5",
|
"requires": "6.5",
|
||||||
"requires_php": "8.2",
|
"requires_php": "8.2",
|
||||||
"tested": "6.9",
|
"tested": "6.9",
|
||||||
"last_updated": "2026-01-29",
|
"last_updated": "2026-02-09",
|
||||||
"author": "ROBOTSTXT",
|
"author": "ROBOTSTXT",
|
||||||
"author_profile": "https://www.robotstxt.es/",
|
"author_profile": "https://www.robotstxt.es/",
|
||||||
"homepage": "https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp",
|
"homepage": "https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp",
|
||||||
"description": "Configure WordPress to send emails through SMTP with detailed controls. Supports multiple SMTP providers, logging, diagnostics, and network/site-level configuration.",
|
"description": "Configure WordPress to send emails through SMTP with detailed controls. Supports multiple SMTP providers, logging, diagnostics, and network/site-level configuration.",
|
||||||
"changelog": "<h3>2.0.0 - 2026-01-29</h3><ul><li><strong>Security:</strong> Comprehensive security audit and hardening</li><li><strong>Security:</strong> Enhanced nonce validation across all forms and actions</li><li><strong>Security:</strong> Improved input sanitization and validation</li><li><strong>Security:</strong> Enhanced password encryption and migration</li><li><strong>Security:</strong> Secure handling of superglobals and transients</li><li><strong>Security:</strong> Strengthened regex patterns and port number validation</li><li><strong>Added:</strong> Reply-To header support for Amazon SES</li><li><strong>Fixed:</strong> Access control and form handling improvements</li><li><strong>Fixed:</strong> WordPress Multisite rate limiting enhancements</li><li><strong>Fixed:</strong> Empty password field handling</li><li><strong>Improved:</strong> Code quality and PHPDoc documentation</li></ul><h3>1.2.0 - 2026-01-27</h3><ul><li>Enhanced DNS blacklist checking with error handling</li><li>Added rate limiting for DNSBL queries</li><li>Improved caching mechanism for DNS results</li><li>Fixed warnings in SMTP diagnostics</li><li>Security improvements and code optimization</li></ul>",
|
"changelog": "<h3>2.1.0 - 2026-02-09</h3><ul><li><strong>Added:</strong> Data management option to control whether plugin data is deleted on uninstall (disabled by default for data preservation)</li><li><strong>Added:</strong> Reset plugin data functionality with site-level and network-level support</li><li><strong>Added:</strong> Unified uninstall cleanup system that handles all add-on data (Amazon SES, Newsletter)</li><li><strong>Added:</strong> Automatic password clearing when both host and username fields are empty to prevent orphaned credentials</li><li><strong>Changed:</strong> Uninstall behavior now respects user preference: data is preserved by default unless explicitly enabled</li><li><strong>Changed:</strong> Add-on plugins (Amazon SES, Newsletter) no longer perform cleanup on uninstall - all cleanup is centralized in the core plugin</li><li><strong>Technical:</strong> Centralized data cleanup logic in core plugin for better maintainability</li><li><strong>Technical:</strong> Enhanced uninstall.php to check delete_data_on_uninstall option before performing cleanup</li></ul><h3>2.0.0 - 2026-01-29</h3><ul><li><strong>Security:</strong> Comprehensive security audit and hardening</li><li><strong>Security:</strong> Enhanced nonce validation across all forms and actions</li><li><strong>Security:</strong> Improved input sanitization and validation</li><li><strong>Security:</strong> Enhanced password encryption and migration</li><li><strong>Security:</strong> Secure handling of superglobals and transients</li><li><strong>Security:</strong> Strengthened regex patterns and port number validation</li><li><strong>Added:</strong> Reply-To header support for Amazon SES</li><li><strong>Fixed:</strong> Access control and form handling improvements</li><li><strong>Fixed:</strong> WordPress Multisite rate limiting enhancements</li><li><strong>Fixed:</strong> Empty password field handling</li><li><strong>Improved:</strong> Code quality and PHPDoc documentation</li></ul>",
|
||||||
"sections": {
|
"sections": {
|
||||||
"description": "Configure WordPress to send emails through SMTP with detailed controls. Supports multiple SMTP providers, logging, diagnostics, and network/site-level configuration.",
|
"description": "Configure WordPress to send emails through SMTP with detailed controls. Supports multiple SMTP providers, logging, diagnostics, and network/site-level configuration.",
|
||||||
"changelog": "<h3>2.0.0 - 2026-01-29</h3><ul><li><strong>Security:</strong> Comprehensive security audit and hardening</li><li><strong>Security:</strong> Enhanced nonce validation across all forms and actions</li><li><strong>Security:</strong> Improved input sanitization and validation</li><li><strong>Security:</strong> Enhanced password encryption and migration</li><li><strong>Security:</strong> Secure handling of superglobals and transients</li><li><strong>Security:</strong> Strengthened regex patterns and port number validation</li><li><strong>Added:</strong> Reply-To header support for Amazon SES</li><li><strong>Fixed:</strong> Access control and form handling improvements</li><li><strong>Fixed:</strong> WordPress Multisite rate limiting enhancements</li><li><strong>Fixed:</strong> Empty password field handling</li><li><strong>Improved:</strong> Code quality and PHPDoc documentation</li></ul><h3>1.2.0 - 2026-01-27</h3><ul><li>Enhanced DNS blacklist checking with error handling</li><li>Added rate limiting for DNSBL queries</li><li>Improved caching mechanism for DNS results</li><li>Fixed warnings in SMTP diagnostics</li><li>Security improvements and code optimization</li></ul>"
|
"changelog": "<h3>2.1.0 - 2026-02-09</h3><ul><li><strong>Added:</strong> Data management option to control whether plugin data is deleted on uninstall (disabled by default for data preservation)</li><li><strong>Added:</strong> Reset plugin data functionality with site-level and network-level support</li><li><strong>Added:</strong> Unified uninstall cleanup system that handles all add-on data (Amazon SES, Newsletter)</li><li><strong>Added:</strong> Automatic password clearing when both host and username fields are empty to prevent orphaned credentials</li><li><strong>Changed:</strong> Uninstall behavior now respects user preference: data is preserved by default unless explicitly enabled</li><li><strong>Changed:</strong> Add-on plugins (Amazon SES, Newsletter) no longer perform cleanup on uninstall - all cleanup is centralized in the core plugin</li><li><strong>Technical:</strong> Centralized data cleanup logic in core plugin for better maintainability</li><li><strong>Technical:</strong> Enhanced uninstall.php to check delete_data_on_uninstall option before performing cleanup</li></ul><h3>2.0.0 - 2026-01-29</h3><ul><li><strong>Security:</strong> Comprehensive security audit and hardening</li><li><strong>Security:</strong> Enhanced nonce validation across all forms and actions</li><li><strong>Security:</strong> Improved input sanitization and validation</li><li><strong>Security:</strong> Enhanced password encryption and migration</li><li><strong>Security:</strong> Secure handling of superglobals and transients</li><li><strong>Security:</strong> Strengthened regex patterns and port number validation</li><li><strong>Added:</strong> Reply-To header support for Amazon SES</li><li><strong>Fixed:</strong> Access control and form handling improvements</li><li><strong>Fixed:</strong> WordPress Multisite rate limiting enhancements</li><li><strong>Fixed:</strong> Empty password field handling</li><li><strong>Improved:</strong> Code quality and PHPDoc documentation</li></ul>"
|
||||||
},
|
},
|
||||||
"banners": {
|
"banners": {
|
||||||
"low": "",
|
"low": "",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue