check-email
Last commit date
assets
2 years ago
include
2 years ago
languages
2 years ago
changelog.txt
2 years ago
check-email.php
2 years ago
readme.txt
2 years ago
uninstall.php
2 years ago
uninstall.php
53 lines
| 1 | <?php |
| 2 | |
| 3 | // exit if WordPress is not uninstalling the plugin. |
| 4 | if ( ! defined( 'ABSPATH' ) && ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
| 5 | exit(); |
| 6 | } |
| 7 | |
| 8 | if ( is_multisite() ) { |
| 9 | $sites = get_sites(); |
| 10 | |
| 11 | foreach ( $sites as $site ) { |
| 12 | switch_to_blog( $site->blog_id ); |
| 13 | check_email_delete_db_data(); |
| 14 | restore_current_blog(); |
| 15 | } |
| 16 | } else { |
| 17 | check_email_delete_db_data(); |
| 18 | } |
| 19 | |
| 20 | function check_email_delete_db_data() { |
| 21 | global $wpdb; |
| 22 | |
| 23 | $remove_data_on_uninstall = false; |
| 24 | |
| 25 | $option = get_option( 'check-email-log-core' ); |
| 26 | if ( is_array( $option ) && array_key_exists( 'remove_on_uninstall', $option ) && |
| 27 | 'true' === strtolower( $option['remove_on_uninstall'] ) ) { |
| 28 | |
| 29 | $remove_data_on_uninstall = true; |
| 30 | } |
| 31 | |
| 32 | // This is hardcoded on purpose, since the entire plugin is not loaded during uninstall. |
| 33 | $table_name = $wpdb->prefix . 'check_email_log'; |
| 34 | |
| 35 | if ( $remove_data_on_uninstall ) { |
| 36 | if ( $wpdb->get_var( "SHOW TABLES LIKE '{$table_name}'" ) == $table_name ) { |
| 37 | $wpdb->query( "DROP TABLE $table_name" ); |
| 38 | } |
| 39 | |
| 40 | delete_option( 'check-email-log-db' ); |
| 41 | delete_option( 'check-email-log-core' ); |
| 42 | |
| 43 | $roles = get_editable_roles(); |
| 44 | foreach ( $roles as $role_name => $role_obj ) { |
| 45 | $role = get_role( $role_name ); |
| 46 | |
| 47 | if ( ! is_null( $role ) ) { |
| 48 | $role->remove_cap( 'manage_check_email' ); |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 |