v2.2.0
This commit is contained in:
parent
0a42e00299
commit
0ece5f3a6d
16 changed files with 2342 additions and 785 deletions
|
|
@ -2,13 +2,7 @@
|
|||
/**
|
||||
* Uninstall script for Newsletter - SMTP (by ROBOTSTXT).
|
||||
*
|
||||
* This add-on does not perform any cleanup on uninstall. All data cleanup
|
||||
* (including Newsletter plugin options) is handled by the core SMTP plugin
|
||||
* when it is uninstalled.
|
||||
*
|
||||
* This ensures that:
|
||||
* - If only the Newsletter add-on is removed, the configuration remains intact
|
||||
* - If the core SMTP plugin is removed, all data (including add-on data) is cleaned up
|
||||
* Removes plugin data and database tables on uninstall.
|
||||
*
|
||||
* @package ROBOTSTXT_SMTP_Newsletter
|
||||
*/
|
||||
|
|
@ -18,4 +12,59 @@ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
|||
exit;
|
||||
}
|
||||
|
||||
// No cleanup needed - handled by core SMTP plugin uninstall.
|
||||
// Check if should delete data.
|
||||
$should_delete = false;
|
||||
|
||||
if ( function_exists( 'is_multisite' ) && is_multisite() ) {
|
||||
// Check network-level setting if available.
|
||||
$network_options = get_site_option( 'robotstxt_smtp_network_options', array() );
|
||||
$should_delete = ! empty( $network_options['delete_data_on_uninstall'] );
|
||||
} else {
|
||||
// Check site-level setting.
|
||||
$options = get_option( 'robotstxt_smtp_options', array() );
|
||||
$should_delete = ! empty( $options['delete_data_on_uninstall'] );
|
||||
}
|
||||
|
||||
if ( ! $should_delete ) {
|
||||
// User wants to preserve data.
|
||||
return;
|
||||
}
|
||||
|
||||
// Drop tables for all sites if multisite.
|
||||
if ( function_exists( 'is_multisite' ) && is_multisite() ) {
|
||||
$sites = get_sites( array( 'fields' => 'ids' ) );
|
||||
|
||||
foreach ( $sites as $site_id ) {
|
||||
switch_to_blog( $site_id );
|
||||
robotstxt_smtp_newsletter_drop_tables();
|
||||
restore_current_blog();
|
||||
}
|
||||
} else {
|
||||
robotstxt_smtp_newsletter_drop_tables();
|
||||
}
|
||||
|
||||
// Delete plugin options.
|
||||
delete_option( 'robotstxt_smtp_newsletter_options' );
|
||||
|
||||
/**
|
||||
* Drop queue and statistics tables.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function robotstxt_smtp_newsletter_drop_tables() {
|
||||
global $wpdb;
|
||||
|
||||
$queue_table = $wpdb->prefix . 'robotstxt_smtp_newsletter_queue';
|
||||
$stats_table = $wpdb->prefix . 'robotstxt_smtp_newsletter_stats';
|
||||
|
||||
// Drop both tables.
|
||||
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.DirectDatabaseQuery.SchemaChange,WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||
$wpdb->query( "DROP TABLE IF EXISTS {$queue_table}" );
|
||||
|
||||
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.DirectDatabaseQuery.SchemaChange,WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||
$wpdb->query( "DROP TABLE IF EXISTS {$stats_table}" );
|
||||
|
||||
// Delete version options.
|
||||
delete_option( 'robotstxt_smtp_newsletter_queue_db_version' );
|
||||
delete_option( 'robotstxt_smtp_newsletter_stats_db_version' );
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue