| 1 |
<?php |
| 2 |
// If uninstall not called from WordPress, then exit |
| 3 |
if (!defined('WP_UNINSTALL_PLUGIN')) { |
| 4 |
exit(); |
| 5 |
} |
| 6 |
|
| 7 |
/** |
| 8 |
* Uninstall operations |
| 9 |
*/ |
| 10 |
function single_uninstall() { |
| 11 |
// delete subscribers table |
| 12 |
$GLOBALS['wpdb']->query("DROP TABLE IF EXISTS {$GLOBALS['wpdb']->prefix}uji_counter"); |
| 13 |
$GLOBALS['wpdb']->query("DROP TABLE IF EXISTS {$GLOBALS['wpdb']->prefix}uji_subscriptions"); |
| 14 |
|
| 15 |
// delete options |
| 16 |
delete_option('ujic_set'); |
| 17 |
} |
| 18 |
|
| 19 |
$_set = get_option('ujic_set'); |
| 20 |
$delete_set = (isset( $_set['ujic_remove'] ) && !empty( $_set['ujic_remove'] ) ) ? $_set['ujic_remove'] : false; |
| 21 |
|
| 22 |
if( $delete_set == "true" ): |
| 23 |
// Let's do it! |
| 24 |
if (is_multisite()) { |
| 25 |
single_uninstall(); |
| 26 |
|
| 27 |
// delete data foreach blog |
| 28 |
$blogs_list = $GLOBALS['wpdb']->get_results("SELECT blog_id FROM {$GLOBALS['wpdb']->blogs}", ARRAY_A); |
| 29 |
if (!empty($blogs_list)) { |
| 30 |
foreach ($blogs_list as $blog) { |
| 31 |
switch_to_blog($blog['blog_id']); |
| 32 |
single_uninstall(); |
| 33 |
restore_current_blog(); |
| 34 |
} |
| 35 |
} |
| 36 |
} else { |
| 37 |
single_uninstall(); |
| 38 |
} |
| 39 |
|
| 40 |
endif; |