PluginProbe ʕ •ᴥ•ʔ
Smush – Image Optimization, Compression, Lazy Load, WebP & CDN / 3.23.3
Smush – Image Optimization, Compression, Lazy Load, WebP & CDN v3.23.3
4.1.0 4.0.3 4.0.2 2.8.1 2.9.1 3.0.0 3.0.1 3.0.2 3.1.1 3.10.1 3.10.2 3.10.3 3.11.1 3.12.3 3.12.4 3.12.5 3.12.6 3.13.0 3.13.1 3.13.2 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.15.2 3.15.3 3.15.4 3.15.5 3.16.2 3.16.4 3.16.5 3.16.6 3.17.0 3.17.1 3.18.0 3.18.1 3.2.0.1 3.2.1 3.2.2.1 3.2.4 3.20.0 3.21.1 3.22.1 3.22.3 3.23.0 3.23.1 3.23.2 3.23.3 3.23.4 3.24.0 3.24.0-beta.2 3.3.0 3.3.1 3.3.2 3.4.1 3.4.2 3.6.1 3.6.3 3.7.0 3.7.1 3.7.2 3.7.3 3.8.2 3.8.3 3.8.4 3.8.5 3.8.7 3.8.8 3.9.0 3.9.1 3.9.11 3.9.2 3.9.4 3.9.5 3.9.8 3.9.9 trunk 1.0.0 1.0.1 1.0.2 1.1 1.1.1 1.1.2 1.1.3 1.2 1.2.1 1.2.10 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.5.1 1.6.5.2 1.6.5.3 1.6.5.4 1.7 1.7.1 1.7.1.1 2.0 2.0.1 2.0.3 2.0.4 2.0.5 2.0.6 2.0.6.2 2.0.6.3 2.0.6.5 2.0.7 2.0.7.1 2.1 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2 2.2.1 2.2.2 2.3 2.3.1 2.4 2.4.2 2.4.3 2.4.4 2.4.5 2.5.2 2.5.3 2.6.1 2.6.2 2.6.3 2.7 2.7.1 2.7.4 2.7.4.1 2.7.5 2.7.6 2.7.8 2.7.8.1 2.7.9.1 2.8.0 2.8.0.1
wp-smushit / uninstall.php
wp-smushit Last commit date
_src 4 months ago app 4 months ago core 4 months ago languages 4 months ago vendor_prefixed 4 months ago readme.txt 3 months ago uninstall.php 4 months ago wp-smush.php 4 months ago
uninstall.php
222 lines
1 <?php
2 /**
3 * Remove plugin settings data.
4 *
5 * @since 1.7
6 * @package Smush
7 */
8
9 use Smush\Core\LCP\LCP_Helper;
10 use Smush\Core\Settings;
11
12 // If uninstall not called from WordPress exit.
13 if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
14 exit();
15 }
16
17 if ( ! class_exists( '\\Smush\\Core\\Settings' ) ) {
18 /* @noinspection PhpIncludeInspection */
19 include_once plugin_dir_path( __FILE__ ) . '/core/class-settings.php';
20 }
21 $keep_data = Settings::get_instance()->get( 'keep_data' );
22
23 // Check if someone want to keep the stats and settings.
24 if ( ( defined( 'WP_SMUSH_PRESERVE_STATS' ) && WP_SMUSH_PRESERVE_STATS ) || true === $keep_data ) {
25 return;
26 }
27
28 global $wpdb;
29
30 $smushit_keys = array(
31 'wp-smush-resmush-list',
32 'wp-smush-nextgen-resmush-list',
33 'wp-smush-resize_sizes',
34 'wp-smush-transparent_png',
35 'wp-smush-image_sizes',
36 'wp-smush-super_smushed',
37 'wp-smush-super_smushed_nextgen',
38 'wp-smush-settings_updated',
39 'wp-smush-hide_update_info',
40 'wp-smush-install-type',
41 'wp-smush-version',
42 'wp-smush-scan',
43 'wp-smush-settings',
44 'wp-smush-cdn-advanced-settings',
45 'wp-smush-cdn_status',
46 'wp-smush-lazy_load',
47 'wp-smush-last_run_sync',
48 'wp-smush-networkwide',
49 'wp-smush-cron_update_running',
50 'wp-smush-dismissed-notices',
51 'wp-smush-show_upgrade_modal',
52 'wp-smush-preset_configs',
53 'wp-smush-webp_hide_wizard',
54 'wp-smush-hide-tutorials',
55 'wp-smush-hide_tutorials_from_bulk_smush', // Possible leftover from 3.8.4.
56 'wp-smush-png2jpg-rewrite-rules-flushed',
57 'wp-smush-optimization-global-stats',
58 'wp-smush-resize-global-stats',
59 'wp-smush-png2jpg-global-stats',
60 'wp_smush_skip_image_sizes_recheck',
61 'wp_smush_image_sizes_state',
62 'wp_smush_global_stats',
63 'wp-smush-optimize-list',
64 'wp-smush-reoptimize-list',
65 'wp-smush-error-items-list',
66 'wp-smush-plugin-activated',
67 'wp_smush_run_optimize_on_scan_completed',
68 'wp-smush-nextgen-reoptimize-list',
69 'wp-smush-nextgen-super-smushed-list',
70 'wp-smush-webp-global-stats',
71 'wp-smush-avif-global-stats',
72 'wp_smush_scan_slice_size',
73 'wp_smush_media_library_last_process',
74 'wp_smush_expected_public_nonces',
75 'wp_smush_expected_nonces',
76 'wp_smush_background_pre_flight',
77 'wp_smush_background_scan_process_status',
78 'wp_smush_bulk_smush_background_process_status',
79 'wp_smush_event_times',
80 'wp-smush-show-new-feature-hotspot',
81 );
82
83 $db_keys = array(
84 'skip-smush-setup',
85 'smush_global_stats',
86 'wp_smush_stats_nextgen',
87 );
88
89 // Cache Keys.
90 $cache_smush_group = array(
91 'exceeding_items',
92 'wp-smush-resize_count',
93 'wp-smush-resize_savings',
94 'wp-smush-pngjpg_savings',
95 'wp-smush-smushed_ids',
96 'media_attachments',
97 'skipped_images',
98 'images_with_backups',
99 'wp-smush-dir_total_stats',
100 );
101
102 $cache_nextgen_group = array(
103 'wp_smush_images',
104 'wp_smush_images_smushed',
105 'wp_smush_images_unsmushed',
106 'wp_smush_stats_nextgen',
107 );
108
109 if ( ! class_exists( '\Smush\Core\LCP\LCP_Helper' ) ) {
110 /* @noinspection PhpIncludeInspection */
111 include_once plugin_dir_path( __FILE__ ) . '/core/lcp/class-lcp-helper.php';
112 }
113
114 if ( ! is_multisite() ) {
115 // Delete Options.
116 foreach ( $smushit_keys as $key ) {
117 delete_option( $key );
118 delete_site_option( $key );
119 }
120
121 foreach ( $db_keys as $key ) {
122 delete_option( $key );
123 delete_site_option( $key );
124 }
125
126 // Delete Cache data.
127 foreach ( $cache_smush_group as $s_key ) {
128 wp_cache_delete( $s_key, 'wp-smush' );
129 }
130
131 foreach ( $cache_nextgen_group as $n_key ) {
132 wp_cache_delete( $n_key, 'nextgen' );
133 }
134
135 wp_cache_delete( 'get_image_sizes', 'smush_image_sizes' );
136
137 delete_transient( 'wp-smush-conflict_check' );
138
139 LCP_Helper::delete_all_lcp_data();
140 }
141
142 // Delete Directory Smush stats.
143 delete_option( 'dir_smush_stats' );
144 delete_option( 'wp_smush_scan' );
145 delete_option( 'wp_smush_api_auth' );
146 delete_site_option( 'wp_smush_api_auth' );
147
148 // Delete Post meta.
149 $meta_type = 'post';
150 $meta_key = 'wp-smpro-smush-data';
151 $meta_value = '';
152 $delete_all = true;
153
154 if ( is_multisite() ) {
155 $offset = 0;
156 $limit = 100;
157 while ( $blogs = $wpdb->get_results( "SELECT blog_id FROM {$wpdb->blogs} LIMIT $offset, $limit", ARRAY_A ) ) {
158 if ( $blogs ) {
159 foreach ( $blogs as $blog ) {
160 switch_to_blog( $blog['blog_id'] );
161 delete_metadata( $meta_type, null, $meta_key, $meta_value, $delete_all );
162 delete_metadata( $meta_type, null, 'wp-smush-lossy', '', $delete_all );
163 delete_metadata( $meta_type, null, 'wp-smush-resize_savings', '', $delete_all );
164 delete_metadata( $meta_type, null, 'wp-smush-original_file', '', $delete_all );
165 delete_metadata( $meta_type, null, 'wp-smush-pngjpg_savings', '', $delete_all );
166
167 foreach ( $smushit_keys as $key ) {
168 delete_option( $key );
169 delete_site_option( $key );
170 }
171
172 foreach ( $db_keys as $key ) {
173 delete_option( $key );
174 delete_site_option( $key );
175 }
176
177 // Delete Cache data.
178 foreach ( $cache_smush_group as $s_key ) {
179 wp_cache_delete( $s_key, 'wp-smush' );
180 }
181
182 foreach ( $cache_nextgen_group as $n_key ) {
183 wp_cache_delete( $n_key, 'nextgen' );
184 }
185
186 wp_cache_delete( 'get_image_sizes', 'smush_image_sizes' );
187 LCP_Helper::delete_all_lcp_data();
188 }
189 restore_current_blog();
190 }
191 $offset += $limit;
192 }
193 } else {
194 delete_metadata( $meta_type, null, $meta_key, $meta_value, $delete_all );
195 delete_metadata( $meta_type, null, 'wp-smush-lossy', '', $delete_all );
196 delete_metadata( $meta_type, null, 'wp-smush-resize_savings', '', $delete_all );
197 delete_metadata( $meta_type, null, 'wp-smush-original_file', '', $delete_all );
198 delete_metadata( $meta_type, null, 'wp-smush-pngjpg_savings', '', $delete_all );
199 }
200 // Delete Directory smush table.
201 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->base_prefix}smush_dir_images" );
202
203 // Delete directory scan data.
204 delete_option( 'wp-smush-scan-step' );
205
206 // Delete all WebP images.
207 global $wp_filesystem;
208 if ( is_null( $wp_filesystem ) ) {
209 WP_Filesystem();
210 }
211
212 $upload_dir = wp_get_upload_dir();
213 $webp_dir = dirname( $upload_dir['basedir'] ) . '/smush-webp';
214 $wp_filesystem->delete( $webp_dir, true );
215
216 // Delete WebP test image.
217 $webp_img = $upload_dir['basedir'] . '/smush-webp-test.png';
218 $wp_filesystem->delete( $webp_img );
219
220 // TODO: Add procedure to delete backup files
221 // TODO: Update NextGen Metadata to remove Smush stats on plugin deletion.
222