| 1 |
<?php |
| 2 |
/** |
| 3 |
* Uninstall Module Control for Jetpack |
| 4 |
* |
| 5 |
* @package JMC |
| 6 |
*/ |
| 7 |
|
| 8 |
// Exit if uninstall not called from WordPress. |
| 9 |
defined( 'WP_UNINSTALL_PLUGIN' ) || exit(); |
| 10 |
|
| 11 |
$default_options = array( |
| 12 |
'jetpack_mc_manual_control', |
| 13 |
'jetpack_mc_development_mode', |
| 14 |
'jetpack_mc_blacklist', |
| 15 |
); |
| 16 |
|
| 17 |
if ( is_multisite() ) { |
| 18 |
// Get sites in the network. |
| 19 |
$args = array( |
| 20 |
'fields' => 'ids', |
| 21 |
'number' => 1000, // Limit to 1000 sites. |
| 22 |
'update_site_meta_cache' => false, |
| 23 |
); |
| 24 |
$blogs = get_sites( $args ); |
| 25 |
|
| 26 |
foreach ( $blogs as $_id ) { |
| 27 |
switch_to_blog( $_id ); |
| 28 |
// Remove site options. |
| 29 |
foreach ( $default_options as $option ) { |
| 30 |
delete_option( $option ); |
| 31 |
} |
| 32 |
restore_current_blog(); |
| 33 |
} |
| 34 |
|
| 35 |
// Remove network options. |
| 36 |
foreach ( $default_options as $option ) { |
| 37 |
delete_site_option( $option ); |
| 38 |
} |
| 39 |
delete_site_option( 'jetpack_mc_subsite_override' ); |
| 40 |
} else { |
| 41 |
// Remove site options. |
| 42 |
foreach ( $default_options as $option ) { |
| 43 |
delete_option( $option ); |
| 44 |
} |
| 45 |
} |
| 46 |
|