| @@ -1,17 +1,52 @@ | ||
| 1 | 1 | <?php |
| 2 | -// If uninstall not called from WordPress exit | |
| 3 | -defined( 'WP_UNINSTALL_PLUGIN' ) or die( 'Cheatin’ uh?' ); | |
| 2 | +defined( 'WP_UNINSTALL_PLUGIN' ) || exit; | |
| 4 | 3 | |
| 5 | -// Delete Imagify options | |
| 4 | +require_once __DIR__ . '/classes/Tools/InternalStateList.php'; | |
| 5 | + | |
| 6 | +global $wpdb; | |
| 7 | + | |
| 8 | +// Delete Imagify options. | |
| 6 | 9 | delete_site_option( 'imagify_settings' ); |
| 10 | +delete_site_option( 'imagify_old_version' ); | |
| 11 | +delete_site_option( 'imagify_files_db_version' ); | |
| 12 | +delete_site_option( 'imagify_folders_db_version' ); | |
| 13 | +delete_option( 'imagify_data' ); | |
| 14 | +delete_option( 'ngg_imagify_data_db_version' ); | |
| 15 | +delete_option( $wpdb->prefix . 'ngg_imagify_data_db_version' ); | |
| 7 | 16 | |
| 8 | -// Delete all transients | |
| 17 | +// Delete all transients. | |
| 18 | +delete_site_transient( 'imagify_activation' ); | |
| 9 | 19 | delete_site_transient( 'imagify_check_licence_1' ); |
| 10 | -delete_site_transient( 'imagify_bulk_optimization_level' ); | |
| 11 | -delete_site_transient( 'imagify_large_library' ); | |
| 20 | +delete_site_transient( 'imagify_check_api_version' ); | |
| 21 | +delete_site_transient( 'imagify_user' ); | |
| 22 | +delete_site_transient( 'imagify_themes_plugins_to_sync' ); | |
| 23 | +delete_site_transient( 'do_imagify_rating_cron' ); | |
| 24 | +delete_site_transient( 'imagify_seen_rating_notice' ); | |
| 25 | +delete_site_transient( 'imagify_user_images_count' ); | |
| 26 | +delete_transient( 'imagify_activation' ); | |
| 27 | +delete_transient( 'imagify_large_library' ); | |
| 28 | +delete_transient( 'imagify_max_image_size' ); | |
| 29 | +delete_transient( 'imagify_user' ); | |
| 30 | +delete_transient( 'imagify_stat_without_next_gen' ); | |
| 31 | +delete_transient( 'imagify_attachments_number_modal' ); | |
| 32 | +delete_transient( 'imagify_user_cache' ); | |
| 33 | +foreach ( \Imagify\Tools\InternalStateList::get_bulk_transients() as $transient ) { | |
| 34 | + delete_transient( $transient ); | |
| 35 | +} | |
| 12 | 36 | |
| 13 | -global $wpdb; | |
| 14 | -$wpdb->query( 'DELETE from ' . $wpdb->options . ' WHERE option_name LIKE "_transient_imagify-async-in-progress-%"' ); | |
| 37 | +// Delete transients. | |
| 38 | +foreach ( \Imagify\Tools\InternalStateList::get_locked_transient_patterns() as $pattern ) { | |
| 39 | + $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s", $pattern ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders.LikeWildcardsInQuery | |
| 40 | +} | |
| 15 | 41 | |
| 16 | -// Delete all user meta related to Imagify | |
| 42 | +// Clear scheduled hooks. | |
| 43 | +wp_clear_scheduled_hook( 'imagify_rating_event' ); | |
| 44 | +wp_clear_scheduled_hook( 'imagify_update_library_size_calculations_event' ); | |
| 45 | + | |
| 46 | +// Delete all user meta related to Imagify. | |
| 17 | 47 | delete_metadata( 'user', '', '_imagify_ignore_notices', '', true ); |
| 48 | + | |
| 49 | +// Drop the tables. | |
| 50 | +$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->base_prefix . 'imagify_files' ); | |
| 51 | +$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->base_prefix . 'imagify_folders' ); | |
| 52 | +$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'ngg_imagify_data' ); | |