siteguard
Last commit date
admin
1 week ago
classes
1 week ago
css
2 months ago
images
2 months ago
languages
1 week ago
really-simple-captcha
1 week ago
changelog.txt
2 months ago
license.txt
11 years ago
readme.txt
1 week ago
siteguard.php
1 week ago
uninstall.php
1 week ago
uninstall.php
48 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
| 4 | exit(); |
| 5 | } |
| 6 | |
| 7 | function remove_directory( $dir ) { |
| 8 | if ( ! is_dir( $dir ) ) { |
| 9 | return true; |
| 10 | } |
| 11 | $entries = @scandir( $dir ); |
| 12 | if ( ! is_array( $entries ) ) { |
| 13 | return false; |
| 14 | } |
| 15 | $files = array_diff( $entries, array( '.', '..' ) ); |
| 16 | foreach ( $files as $file ) { |
| 17 | if ( is_dir( "$dir/$file" ) ) { |
| 18 | remove_directory( "$dir/$file" ); |
| 19 | } else { |
| 20 | @unlink( "$dir/$file" ); |
| 21 | } |
| 22 | } |
| 23 | return @rmdir( $dir ); |
| 24 | } |
| 25 | |
| 26 | function delete_siteguard_plugin() { |
| 27 | global $wpdb; |
| 28 | |
| 29 | delete_option( 'siteguard_config' ); |
| 30 | |
| 31 | // Deleting the plugin deactivates it first, which already clears this event, |
| 32 | // but an uninstall that reaches this point with the event still scheduled |
| 33 | // would leave it in the cron table with no handler and no settings behind it. |
| 34 | // The name is duplicated from SiteGuard_UpdatesNotify::CRON_NAME because the |
| 35 | // plugin classes are not loaded during uninstall. |
| 36 | wp_clear_scheduled_hook( 'siteguard_update_check' ); |
| 37 | |
| 38 | $table_name = $wpdb->prefix . 'siteguard_login'; |
| 39 | $wpdb->query( "DROP TABLE IF EXISTS $table_name;" ); |
| 40 | |
| 41 | $table_name = $wpdb->prefix . 'siteguard_history'; |
| 42 | $wpdb->query( "DROP TABLE IF EXISTS $table_name;" ); |
| 43 | |
| 44 | remove_directory( WP_CONTENT_DIR . '/siteguard' ); |
| 45 | } |
| 46 | |
| 47 | delete_siteguard_plugin(); |
| 48 |