v2.1.0
This commit is contained in:
parent
e12ae9784f
commit
0a42e00299
5 changed files with 34 additions and 58 deletions
|
|
@ -2,8 +2,13 @@
|
|||
/**
|
||||
* Uninstall script for Newsletter - SMTP (by ROBOTSTXT).
|
||||
*
|
||||
* This file is called when the plugin is deleted via WordPress admin.
|
||||
* It removes all plugin data from the database.
|
||||
* 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
|
||||
*
|
||||
* @package ROBOTSTXT_SMTP_Newsletter
|
||||
*/
|
||||
|
|
@ -13,52 +18,4 @@ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
|||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete plugin options and transients.
|
||||
*
|
||||
* @param int $site_id Site ID (for multisite).
|
||||
* @return void
|
||||
*/
|
||||
function robotstxt_smtp_newsletter_delete_site_data( $site_id = null ) {
|
||||
// Switch to site if multisite.
|
||||
if ( is_multisite() && $site_id ) {
|
||||
switch_to_blog( $site_id );
|
||||
}
|
||||
|
||||
// Delete plugin options.
|
||||
delete_option( 'robotstxt_smtp_newsletter_options' );
|
||||
|
||||
// Delete updater cache transients.
|
||||
$plugin_basename = 'robotstxt-smtp-newsletter/robotstxt-smtp-newsletter.php';
|
||||
$cache_key = 'robotstxt_updater_' . md5( $plugin_basename );
|
||||
delete_site_transient( $cache_key );
|
||||
|
||||
// Restore current blog if multisite.
|
||||
if ( is_multisite() && $site_id ) {
|
||||
restore_current_blog();
|
||||
}
|
||||
}
|
||||
|
||||
// Single site installation.
|
||||
if ( ! is_multisite() ) {
|
||||
robotstxt_smtp_newsletter_delete_site_data();
|
||||
} else {
|
||||
// Multisite installation.
|
||||
global $wpdb;
|
||||
|
||||
// Get all blog IDs.
|
||||
$blog_ids = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->blogs}" );
|
||||
|
||||
// Delete data for each site.
|
||||
foreach ( $blog_ids as $blog_id ) {
|
||||
robotstxt_smtp_newsletter_delete_site_data( $blog_id );
|
||||
}
|
||||
|
||||
// Delete network-wide updater cache.
|
||||
$plugin_basename = 'robotstxt-smtp-newsletter/robotstxt-smtp-newsletter.php';
|
||||
$cache_key = 'robotstxt_updater_' . md5( $plugin_basename );
|
||||
delete_site_transient( $cache_key );
|
||||
}
|
||||
|
||||
// Clear WordPress update cache to remove our plugin from the list.
|
||||
delete_site_transient( 'update_plugins' );
|
||||
// No cleanup needed - handled by core SMTP plugin uninstall.
|
||||
|
|
|
|||
Loading…
Reference in a new issue