PluginProbe ʕ •ᴥ•ʔ
WP Mail SMTP by WPForms – The Most Popular SMTP and Email Log Plugin / 4.8.0
WP Mail SMTP by WPForms – The Most Popular SMTP and Email Log Plugin v4.8.0
0.9.6 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.6.0 1.6.2 1.7.0 1.7.1 1.8.0 1.8.1 1.9.0 2.0.0 2.0.1 2.1.1 2.2.1 2.3.1 2.4.0 2.5.0 2.5.1 2.6.0 2.7.0 2.8.0 2.9.0 3.0.1 3.0.2 3.0.3 3.1.0 3.10.0 3.11.0 3.11.1 3.2.0 3.2.1 3.3.0 3.4.0 3.5.0 3.5.1 3.5.2 3.6.1 3.7.0 3.8.0 3.8.2 3.9.0 4.0.1 4.1.0 4.1.1 4.2.0 4.3.0 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.8.0 trunk 0.10.0 0.10.1 0.11.1 0.11.2 0.3.1 0.3.2 0.4 0.4.1 0.4.2 0.5.0 0.5.1 0.5.2 0.6 0.7 0.8 0.8.2 0.8.3 0.8.4 0.8.5 0.8.6 0.8.7 0.9.0 0.9.1 0.9.2 0.9.3 0.9.4 0.9.5
wp-mail-smtp / uninstall.php
wp-mail-smtp Last commit date
assets 1 month ago src 1 month ago vendor 1 month ago vendor_prefixed 1 month ago readme.txt 1 month ago uninstall.php 1 month ago wp-mail-smtp.php 1 month ago wp_mail_smtp.php 1 month ago
uninstall.php
264 lines
1 <?php
2 /**
3 * Uninstall all WP Mail SMTP data.
4 *
5 * @since 1.3.0
6 */
7
8 // Exit if accessed directly.
9 if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
10 exit;
11 }
12
13 // Prevent data removal if Pro plugin is active.
14 if ( is_plugin_active( 'wp-mail-smtp-pro/wp_mail_smtp.php' ) ) {
15 return;
16 }
17
18 // Load plugin file.
19 require_once 'wp_mail_smtp.php';
20 require_once dirname( __FILE__ ) . '/vendor/woocommerce/action-scheduler/action-scheduler.php';
21
22 global $wpdb;
23
24 /*
25 * Remove Legacy options.
26 */
27 $options = [
28 '_amn_smtp_last_checked',
29 'pepipost_ssl',
30 'pepipost_port',
31 'pepipost_pass',
32 'pepipost_user',
33 'smtp_pass',
34 'smtp_user',
35 'smtp_auth',
36 'smtp_ssl',
37 'smtp_port',
38 'smtp_host',
39 'mail_set_return_path',
40 'mailer',
41 'mail_from_name',
42 'mail_from',
43 ];
44
45 /**
46 * Remove AM announcement posts.
47 */
48 $am_announcement_params = [
49 'post_type' => [ 'amn_smtp' ],
50 'post_status' => 'any',
51 'numberposts' => - 1,
52 'fields' => 'ids',
53 ];
54
55 /**
56 * Disable Action Schedule Queue Runner, to prevent a fatal error on the shutdown WP hook.
57 */
58 if ( class_exists( 'ActionScheduler_QueueRunner' ) ) {
59 $as_queue_runner = \ActionScheduler_QueueRunner::instance();
60
61 if ( method_exists( $as_queue_runner, 'unhook_dispatch_async_request' ) ) {
62 $as_queue_runner->unhook_dispatch_async_request();
63 }
64 }
65
66 // WP MS uninstall process.
67 //phpcs:disable WPForms.Formatting.EmptyLineAfterAssigmentVariables.AddEmptyLine, WPForms.PHP.BackSlash.UseShortSyntax
68 if ( is_multisite() ) {
69 $main_site_settings = get_blog_option( get_main_site_id(), 'wp_mail_smtp', [] );
70 $network_wide = ! empty( $main_site_settings['general']['network_wide'] );
71 $network_uninstall = ! empty( $main_site_settings['general']['uninstall'] );
72
73 $sites = get_sites();
74
75 foreach ( $sites as $site ) {
76 $settings = get_blog_option( $site->blog_id, 'wp_mail_smtp', [] );
77
78 // Confirm network site admin has decided to remove all data, otherwise skip.
79 if (
80 ( $network_wide && ! $network_uninstall ) ||
81 ( ! $network_wide && empty( $settings['general']['uninstall'] ) )
82 ) {
83 continue;
84 }
85
86 /*
87 * Delete network site plugin options.
88 */
89 foreach ( $options as $option ) {
90 delete_blog_option( $site->blog_id, $option );
91 }
92
93 // Switch to the current network site.
94 switch_to_blog( $site->blog_id );
95
96 // Delete plugin settings.
97 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wp\_mail\_smtp%'" ); // phpcs:ignore WordPress.DB
98
99 // Delete plugin user meta.
100 $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE 'wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
101
102 // Remove any transients we've left behind.
103 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_transient\_wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
104 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_site\_transient\_wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
105 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_transient\_timeout\_wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
106 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_site\_transient\_timeout\_wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
107
108 // Delete debug events table.
109 $debug_events_table = \WPMailSMTP\Admin\DebugEvents\DebugEvents::get_table_name();
110 $wpdb->query( "DROP TABLE IF EXISTS $debug_events_table;" ); // phpcs:ignore WordPress.DB
111
112 /*
113 * Delete network site product announcements.
114 */
115 $announcements = get_posts( $am_announcement_params );
116
117 if ( ! empty( $announcements ) ) {
118 foreach ( $announcements as $announcement ) {
119 wp_delete_post( $announcement, true );
120 }
121 }
122
123 // Delete queue table.
124 $queue_table = \WPMailSMTP\Queue\Queue::get_table_name();
125 $wpdb->query( "DROP TABLE IF EXISTS $queue_table;" ); // phpcs:ignore WordPress.DB
126
127 // Delete all queue attachments.
128 ( new \WPMailSMTP\Queue\Attachments() )->delete_attachments();
129
130 /*
131 * Cleanup network site data for Pro plugin only.
132 */
133 if (
134 function_exists( 'wp_mail_smtp' ) &&
135 is_readable( wp_mail_smtp()->plugin_path . '/src/Pro/Pro.php' )
136 ) {
137
138 // Delete logs table.
139 $table = \WPMailSMTP\Pro\Emails\Logs\Logs::get_table_name();
140 $wpdb->query( "DROP TABLE IF EXISTS $table;" ); // phpcs:ignore WordPress.DB
141
142 // Delete attachments tables.
143 $attachment_files_table = \WPMailSMTP\Pro\Emails\Logs\Attachments\Attachments::get_attachment_files_table_name();
144 $wpdb->query( "DROP TABLE IF EXISTS $attachment_files_table;" ); // phpcs:ignore WordPress.DB
145
146 $email_attachments_table = \WPMailSMTP\Pro\Emails\Logs\Attachments\Attachments::get_email_attachments_table_name();
147 $wpdb->query( "DROP TABLE IF EXISTS $email_attachments_table;" ); // phpcs:ignore WordPress.DB
148
149 // Delete all attachments if any.
150 ( new \WPMailSMTP\Pro\Emails\Logs\Attachments\Attachments() )->delete_all_attachments();
151
152 // Delete tracking tables.
153 $tracking_events_table = \WPMailSMTP\Pro\Emails\Logs\Tracking\Tracking::get_events_table_name();
154 $wpdb->query( "DROP TABLE IF EXISTS $tracking_events_table;" ); // phpcs:ignore WordPress.DB
155
156 $tracking_links_table = \WPMailSMTP\Pro\Emails\Logs\Tracking\Tracking::get_links_table_name();
157 $wpdb->query( "DROP TABLE IF EXISTS $tracking_links_table;" ); // phpcs:ignore WordPress.DB
158 }
159
160 /*
161 * Drop all Action Scheduler data and unschedule all plugin ActionScheduler actions.
162 */
163 ( new \WPMailSMTP\Tasks\Tasks() )->remove_all();
164
165 $meta_table = \WPMailSMTP\Tasks\Meta::get_table_name();
166 $wpdb->query( "DROP TABLE IF EXISTS $meta_table;" ); // phpcs:ignore WordPress.DB
167
168 // Delete current sub-site wp-mail-smtp uploads folder.
169 \WPMailSMTP\Uploads::delete_upload_dir();
170
171 // Restore the current network site back to the original one.
172 restore_current_blog();
173 }
174 } else { // Non WP MS uninstall process (for normal WP installs).
175
176 // Confirm user has decided to remove all data, otherwise stop.
177 $settings = get_option( 'wp_mail_smtp', [] );
178 if ( empty( $settings['general']['uninstall'] ) ) {
179 return;
180 }
181
182 /*
183 * Delete plugin options.
184 */
185 foreach ( $options as $option ) {
186 delete_option( $option );
187 }
188
189 // Delete plugin settings.
190 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wp\_mail\_smtp%'" ); // phpcs:ignore WordPress.DB
191
192 // Delete plugin user meta.
193 $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE 'wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
194
195 // Remove any transients we've left behind.
196 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_transient\_wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
197 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_site\_transient\_wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
198 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_transient\_timeout\_wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
199 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_site\_transient\_timeout\_wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
200
201 // Delete debug events table.
202 $debug_events_table = \WPMailSMTP\Admin\DebugEvents\DebugEvents::get_table_name();
203 $wpdb->query( "DROP TABLE IF EXISTS $debug_events_table;" ); // phpcs:ignore WordPress.DB
204
205 /*
206 * Remove product announcements.
207 */
208 $announcements = get_posts( $am_announcement_params );
209 if ( ! empty( $announcements ) ) {
210 foreach ( $announcements as $announcement ) {
211 wp_delete_post( $announcement, true );
212 }
213 }
214
215 // Delete queue table.
216 $queue_table = \WPMailSMTP\Queue\Queue::get_table_name();
217 $wpdb->query( "DROP TABLE IF EXISTS $queue_table;" ); // phpcs:ignore WordPress.DB
218
219 // Delete all queue attachments.
220 ( new \WPMailSMTP\Queue\Attachments() )->delete_attachments();
221
222 /*
223 * Cleanup data for Pro plugin only.
224 */
225 if (
226 function_exists( 'wp_mail_smtp' ) &&
227 is_readable( wp_mail_smtp()->plugin_path . '/src/Pro/Pro.php' )
228 ) {
229
230 // Delete logs table.
231 $table = \WPMailSMTP\Pro\Emails\Logs\Logs::get_table_name();
232 $wpdb->query( "DROP TABLE IF EXISTS $table;" ); // phpcs:ignore WordPress.DB
233
234 // Delete attachments tables.
235 $attachment_files_table = \WPMailSMTP\Pro\Emails\Logs\Attachments\Attachments::get_attachment_files_table_name();
236 $wpdb->query( "DROP TABLE IF EXISTS $attachment_files_table;" ); // phpcs:ignore WordPress.DB
237
238 $email_attachments_table = \WPMailSMTP\Pro\Emails\Logs\Attachments\Attachments::get_email_attachments_table_name();
239 $wpdb->query( "DROP TABLE IF EXISTS $email_attachments_table;" ); // phpcs:ignore WordPress.DB
240
241 // Delete all attachments if any.
242 ( new \WPMailSMTP\Pro\Emails\Logs\Attachments\Attachments() )->delete_all_attachments();
243
244 // Delete tracking tables.
245 $tracking_events_table = \WPMailSMTP\Pro\Emails\Logs\Tracking\Tracking::get_events_table_name();
246 $wpdb->query( "DROP TABLE IF EXISTS $tracking_events_table;" ); // phpcs:ignore WordPress.DB
247
248 $tracking_links_table = \WPMailSMTP\Pro\Emails\Logs\Tracking\Tracking::get_links_table_name();
249 $wpdb->query( "DROP TABLE IF EXISTS $tracking_links_table;" ); // phpcs:ignore WordPress.DB
250 }
251
252 /*
253 * Drop all Action Scheduler data and unschedule all plugin ActionScheduler actions.
254 */
255 ( new \WPMailSMTP\Tasks\Tasks() )->remove_all();
256
257 $meta_table = \WPMailSMTP\Tasks\Meta::get_table_name();
258 $wpdb->query( "DROP TABLE IF EXISTS $meta_table;" ); // phpcs:ignore WordPress.DB
259
260 // Delete wp-mail-smtp uploads folder.
261 \WPMailSMTP\Uploads::delete_upload_dir();
262 }
263 //phpcs:enable WPForms.Formatting.EmptyLineAfterAssigmentVariables.AddEmptyLine, WPForms.PHP.BackSlash.UseShortSyntax
264