| 1 |
<?php |
| 2 |
/* |
| 3 |
* Uninstall plugin |
| 4 |
*/ |
| 5 |
if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) |
| 6 |
exit (); |
| 7 |
|
| 8 |
$option_names = array( |
| 9 |
'email_smtp' |
| 10 |
, 'email_contenttype' |
| 11 |
, 'email_mailer' |
| 12 |
, 'email_template_subject' |
| 13 |
, 'email_template_body' |
| 14 |
, 'email_template_bodyalt' |
| 15 |
, 'email_template_sentsuccess' |
| 16 |
, 'email_template_sentfailed' |
| 17 |
, 'email_template_error' |
| 18 |
, 'email_interval' |
| 19 |
, 'email_snippet' |
| 20 |
, 'email_multiple' |
| 21 |
, 'email_imageverify' |
| 22 |
, 'email_options' |
| 23 |
, 'email_fields' |
| 24 |
, 'email_template_title' |
| 25 |
, 'email_template_subtitle' |
| 26 |
, 'widget_email_most_emailed' |
| 27 |
); |
| 28 |
|
| 29 |
if ( is_multisite() ) { |
| 30 |
$ms_sites = wp_get_sites(); |
| 31 |
|
| 32 |
if( 0 < sizeof( $ms_sites ) ) { |
| 33 |
foreach ( $ms_sites as $ms_site ) { |
| 34 |
switch_to_blog( $ms_site['blog_id'] ); |
| 35 |
if( sizeof( $option_names ) > 0 ) { |
| 36 |
foreach( $option_names as $option_name ) { |
| 37 |
delete_option( $option_name ); |
| 38 |
plugin_uninstalled(); |
| 39 |
} |
| 40 |
} |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
restore_current_blog(); |
| 45 |
} else { |
| 46 |
if( sizeof( $option_names ) > 0 ) { |
| 47 |
foreach( $option_names as $option_name ) { |
| 48 |
delete_option( $option_name ); |
| 49 |
plugin_uninstalled(); |
| 50 |
} |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* Delete plugin table when uninstalled |
| 56 |
* |
| 57 |
* @access public |
| 58 |
* @return void |
| 59 |
*/ |
| 60 |
function plugin_uninstalled() { |
| 61 |
global $wpdb; |
| 62 |
|
| 63 |
$email_table = $wpdb->prefix . 'email'; |
| 64 |
$wpdb->query( "DROP TABLE IF EXISTS $email_table" ); |
| 65 |
} |