| 1 |
<?php |
| 2 |
if (!defined('WP_UNINSTALL_PLUGIN')) //if uninstall not called from WordPress exit |
| 3 |
exit(); |
| 4 |
|
| 5 |
if (get_option('wpsi_delete_data_on_uninstall') === '1') { |
| 6 |
global $wpdb; |
| 7 |
// Delete created table when plugin uninstall |
| 8 |
$tables_to_drop = array( 'files', 'posts', 'imports' ); |
| 9 |
foreach ( $tables_to_drop as $table_name ) { |
| 10 |
// Construct the table name with prefix |
| 11 |
$table_name_with_prefix = $wpdb->prefix . 'wpsi_' . $table_name; |
| 12 |
|
| 13 |
// Execute the query |
| 14 |
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange |
| 15 |
$wpdb->query( "DROP TABLE IF EXISTS `$table_name_with_prefix`" ); |
| 16 |
} |
| 17 |
|
| 18 |
// Delete options when plugin uninstall |
| 19 |
delete_option('wp-smart-import-settings'); |
| 20 |
delete_option('wp-smart-import-session'); |
| 21 |
delete_option('wpsi_delete_data_on_uninstall'); |
| 22 |
delete_option('wpsi_import_batch_size'); |
| 23 |
delete_option('wpsi_batch_delay'); |
| 24 |
delete_option('wpsi_image_timeout'); |
| 25 |
delete_option('wpsi_file_pruning'); |
| 26 |
delete_option('wpsi_custom_php_code'); |
| 27 |
delete_option('wpsi_cron_batch_size'); |
| 28 |
} |