v2.0.0
This commit is contained in:
parent
5638b8e13b
commit
a29b2d82ad
19 changed files with 3792 additions and 231 deletions
64
uninstall.php
Normal file
64
uninstall.php
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @package ROBOTSTXT_SMTP_Newsletter
|
||||
*/
|
||||
|
||||
// Exit if not called by WordPress uninstaller.
|
||||
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' );
|
||||
Loading…
Reference in a new issue