wp-maintenance-mode
Last commit date
assets
3 years ago
includes
3 years ago
languages
5 years ago
vendor
3 years ago
views
3 years ago
CHANGELOG.md
3 years ago
README.md
3 years ago
index.php
9 years ago
readme.txt
3 years ago
uninstall.php
5 years ago
wp-maintenance-mode.php
3 years ago
uninstall.php
63 lines
| 1 | <?php |
| 2 | |
| 3 | // If uninstall not called from WordPress, then exit |
| 4 | if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
| 5 | exit(); |
| 6 | } |
| 7 | |
| 8 | /** |
| 9 | * Uninstall operations |
| 10 | */ |
| 11 | function single_uninstall() { |
| 12 | // delete subscribers table |
| 13 | $GLOBALS['wpdb']->query( "DROP TABLE IF EXISTS {$GLOBALS['wpdb']->prefix}wpmm_subscribers" ); |
| 14 | |
| 15 | // delete options |
| 16 | $options_to_delete = array( |
| 17 | 'wpmm_settings', |
| 18 | 'wpmm_notice', |
| 19 | 'wpmm_version', |
| 20 | ); |
| 21 | |
| 22 | foreach ( $options_to_delete as $option ) { |
| 23 | delete_option( $option ); |
| 24 | } |
| 25 | |
| 26 | // delete dismissed notices meta key |
| 27 | $users_with_dismissed_notices = (array) get_users( |
| 28 | array( |
| 29 | 'fields' => 'ids', |
| 30 | 'meta_key' => 'wpmm_dismissed_notices', |
| 31 | ) |
| 32 | ); |
| 33 | |
| 34 | foreach ( $users_with_dismissed_notices as $user_id ) { |
| 35 | delete_user_meta( $user_id, 'wpmm_dismissed_notices' ); |
| 36 | } |
| 37 | |
| 38 | // delete bot settings file (data.js) |
| 39 | $upload_dir = wp_upload_dir(); |
| 40 | $bot_settings_file = ! empty( $upload_dir['basedir'] ) ? trailingslashit( $upload_dir['basedir'] ) . 'data.js' : false; |
| 41 | |
| 42 | if ( $bot_settings_file !== false && file_exists( $bot_settings_file ) ) { |
| 43 | wp_delete_file( $bot_settings_file ); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | // Let's do it! |
| 48 | if ( is_multisite() ) { |
| 49 | single_uninstall(); |
| 50 | |
| 51 | // delete data foreach blog |
| 52 | $blogs_list = $GLOBALS['wpdb']->get_results( "SELECT blog_id FROM {$GLOBALS['wpdb']->blogs}", ARRAY_A ); |
| 53 | if ( ! empty( $blogs_list ) ) { |
| 54 | foreach ( $blogs_list as $blog ) { |
| 55 | switch_to_blog( $blog['blog_id'] ); |
| 56 | single_uninstall(); |
| 57 | restore_current_blog(); |
| 58 | } |
| 59 | } |
| 60 | } else { |
| 61 | single_uninstall(); |
| 62 | } |
| 63 |