| 1 |
<?php |
| 2 |
/** |
| 3 |
* Uninstall Atomic Edge Security |
| 4 |
* |
| 5 |
* Removes all plugin data when the plugin is deleted. |
| 6 |
* |
| 7 |
* @package AtomicEdge |
| 8 |
*/ |
| 9 |
|
| 10 |
// If uninstall not called from WordPress, exit. |
| 11 |
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
| 12 |
exit; |
| 13 |
} |
| 14 |
|
| 15 |
// Delete all plugin options. |
| 16 |
$atomicedge_options_to_delete = array( |
| 17 |
'atomicedge_api_key', |
| 18 |
'atomicedge_api_url', |
| 19 |
'atomicedge_connected', |
| 20 |
'atomicedge_site_data', |
| 21 |
'atomicedge_last_scan', |
| 22 |
'atomicedge_scan_results', |
| 23 |
); |
| 24 |
|
| 25 |
foreach ( $atomicedge_options_to_delete as $atomicedge_option ) { |
| 26 |
delete_option( $atomicedge_option ); |
| 27 |
} |
| 28 |
|
| 29 |
// Delete all transients. |
| 30 |
global $wpdb; |
| 31 |
|
| 32 |
// Drop scanner queue table. |
| 33 |
$atomicedge_table_name = $wpdb->prefix . 'atomicedge_scan_queue'; |
| 34 |
if ( preg_match( '/^[A-Za-z0-9_]+$/', $atomicedge_table_name ) ) { |
| 35 |
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.PreparedSQL.NotPrepared,PluginCheck.Security.DirectDB.UnescapedDBParameter |
| 36 |
$wpdb->query( 'DROP TABLE IF EXISTS `' . $atomicedge_table_name . '`' ); |
| 37 |
} |
| 38 |
|
| 39 |
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching |
| 40 |
if ( preg_match( '/^[A-Za-z0-9_]+$/', $wpdb->options ) ) { |
| 41 |
$wpdb->query( |
| 42 |
$wpdb->prepare( |
| 43 |
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,PluginCheck.Security.DirectDB.UnescapedDBParameter |
| 44 |
'DELETE FROM `' . $wpdb->options . '` WHERE option_name LIKE %s OR option_name LIKE %s', |
| 45 |
'_transient_atomicedge_%', |
| 46 |
'_transient_timeout_atomicedge_%' |
| 47 |
) |
| 48 |
); |
| 49 |
} |
| 50 |
|
| 51 |
// Clear any scheduled cron events. |
| 52 |
wp_clear_scheduled_hook( 'atomicedge_daily_scan' ); |
| 53 |
wp_clear_scheduled_hook( 'atomicedge_sync_settings' ); |
| 54 |
|