| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
/* Quit */ |
| 5 |
defined('ABSPATH') OR exit; |
| 6 |
|
| 7 |
|
| 8 |
/** |
| 9 |
* Statify_Uninstall |
| 10 |
* |
| 11 |
* @since 0.1 |
| 12 |
*/ |
| 13 |
|
| 14 |
class Statify_Uninstall |
| 15 |
{ |
| 16 |
|
| 17 |
|
| 18 |
/** |
| 19 |
* Uninstallation auch für MU-Blog |
| 20 |
* |
| 21 |
* @since 0.1.0 |
| 22 |
* @change 0.1.0 |
| 23 |
* |
| 24 |
* @param integer ID des Blogs |
| 25 |
*/ |
| 26 |
|
| 27 |
public static function init($id) |
| 28 |
{ |
| 29 |
/* Global */ |
| 30 |
global $wpdb; |
| 31 |
|
| 32 |
/* Neuer MU-Blog */ |
| 33 |
if ( ! empty($id) ) { |
| 34 |
/* Im Netzwerk? */ |
| 35 |
if ( ! is_plugin_active_for_network(STATIFY_BASE) ) { |
| 36 |
return; |
| 37 |
} |
| 38 |
|
| 39 |
/* Wechsel */ |
| 40 |
switch_to_blog( (int)$id ); |
| 41 |
|
| 42 |
/* Installieren */ |
| 43 |
self::_apply(); |
| 44 |
|
| 45 |
/* Wechsel zurück */ |
| 46 |
restore_current_blog(); |
| 47 |
|
| 48 |
/* Raus */ |
| 49 |
return; |
| 50 |
} |
| 51 |
|
| 52 |
/* Multisite & Network */ |
| 53 |
if ( is_multisite() && ! empty($_GET['networkwide']) ) { |
| 54 |
/* Alter Blog */ |
| 55 |
$old = $wpdb->blogid; |
| 56 |
|
| 57 |
/* Blog-IDs */ |
| 58 |
$ids = $wpdb->get_col("SELECT blog_id FROM `$wpdb->blogs`"); |
| 59 |
|
| 60 |
/* Loopen */ |
| 61 |
foreach ($ids as $id) { |
| 62 |
switch_to_blog($id); |
| 63 |
self::_apply(); |
| 64 |
} |
| 65 |
|
| 66 |
/* Wechsel zurück */ |
| 67 |
switch_to_blog($old); |
| 68 |
|
| 69 |
/* Raus */ |
| 70 |
return; |
| 71 |
} |
| 72 |
|
| 73 |
/* Single-Blog */ |
| 74 |
self::_apply(); |
| 75 |
} |
| 76 |
|
| 77 |
|
| 78 |
/** |
| 79 |
* Löschung der Daten |
| 80 |
* |
| 81 |
* @since 0.1.0 |
| 82 |
* @change 1.4.0 |
| 83 |
*/ |
| 84 |
|
| 85 |
private static function _apply() |
| 86 |
{ |
| 87 |
/* Delete options */ |
| 88 |
delete_option('statify'); |
| 89 |
|
| 90 |
/* Init table */ |
| 91 |
Statify_Table::init(); |
| 92 |
|
| 93 |
/* Delete table */ |
| 94 |
Statify_Table::drop(); |
| 95 |
} |
| 96 |
} |