PluginProbe ʕ •ᴥ•ʔ
WP Mail SMTP by WPForms – The Most Popular SMTP and Email Log Plugin / 3.4.0
WP Mail SMTP by WPForms – The Most Popular SMTP and Email Log Plugin v3.4.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 4 years ago libs 4 years ago src 4 years ago vendor 4 years ago vendor_prefixed 4 years ago readme.txt 4 years ago uninstall.php 4 years ago wp-mail-smtp.php 4 years ago wp_mail_smtp.php 4 years ago
uninstall.php
242 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 if ( is_multisite() ) {
68 $main_site_settings = get_blog_option( get_main_site_id(), 'wp_mail_smtp', [] );
69 $network_wide = ! empty( $main_site_settings['general']['network_wide'] );
70 $network_uninstall = ! empty( $main_site_settings['general']['uninstall'] );
71
72 $sites = get_sites();
73
74 foreach ( $sites as $site ) {
75 $settings = get_blog_option( $site->blog_id, 'wp_mail_smtp', [] );
76
77 // Confirm network site admin has decided to remove all data, otherwise skip.
78 if (
79 ( $network_wide && ! $network_uninstall ) ||
80 ( ! $network_wide && empty( $settings['general']['uninstall'] ) )
81 ) {
82 continue;
83 }
84
85 /*
86 * Delete network site plugin options.
87 */
88 foreach ( $options as $option ) {
89 delete_blog_option( $site->blog_id, $option );
90 }
91
92 // Switch to the current network site.
93 switch_to_blog( $site->blog_id );
94
95 // Delete plugin settings.
96 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wp\_mail\_smtp%'" ); // phpcs:ignore WordPress.DB
97
98 // Delete plugin user meta.
99 $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE 'wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
100
101 // Remove any transients we've left behind.
102 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_transient\_wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
103 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_site\_transient\_wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
104 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_transient\_timeout\_wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
105 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_site\_transient\_timeout\_wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
106
107 // Delete debug events table.
108 $debug_events_table = \WPMailSMTP\Admin\DebugEvents\DebugEvents::get_table_name();
109 $wpdb->query( "DROP TABLE IF EXISTS $debug_events_table;" ); // phpcs:ignore WordPress.DB
110
111 /*
112 * Delete network site product announcements.
113 */
114 $announcements = get_posts( $am_announcement_params );
115
116 if ( ! empty( $announcements ) ) {
117 foreach ( $announcements as $announcement ) {
118 wp_delete_post( $announcement, true );
119 }
120 }
121
122 /*
123 * Cleanup network site data for Pro plugin only.
124 */
125 if (
126 function_exists( 'wp_mail_smtp' ) &&
127 is_readable( wp_mail_smtp()->plugin_path . '/src/Pro/Pro.php' )
128 ) {
129
130 // Delete logs table.
131 $table = \WPMailSMTP\Pro\Emails\Logs\Logs::get_table_name();
132 $wpdb->query( "DROP TABLE IF EXISTS $table;" ); // phpcs:ignore WordPress.DB
133
134 // Delete attachments tables.
135 $attachment_files_table = \WPMailSMTP\Pro\Emails\Logs\Attachments\Attachments::get_attachment_files_table_name();
136 $wpdb->query( "DROP TABLE IF EXISTS $attachment_files_table;" ); // phpcs:ignore WordPress.DB
137
138 $email_attachments_table = \WPMailSMTP\Pro\Emails\Logs\Attachments\Attachments::get_email_attachments_table_name();
139 $wpdb->query( "DROP TABLE IF EXISTS $email_attachments_table;" ); // phpcs:ignore WordPress.DB
140
141 // Delete all attachments if any.
142 ( new \WPMailSMTP\Pro\Emails\Logs\Attachments\Attachments() )->delete_all_attachments();
143
144 // Delete tracking tables.
145 $tracking_events_table = \WPMailSMTP\Pro\Emails\Logs\Tracking\Tracking::get_events_table_name();
146 $wpdb->query( "DROP TABLE IF EXISTS $tracking_events_table;" ); // phpcs:ignore WordPress.DB
147
148 $tracking_links_table = \WPMailSMTP\Pro\Emails\Logs\Tracking\Tracking::get_links_table_name();
149 $wpdb->query( "DROP TABLE IF EXISTS $tracking_links_table;" ); // phpcs:ignore WordPress.DB
150 }
151
152 /*
153 * Drop all Action Scheduler data and unschedule all plugin ActionScheduler actions.
154 */
155 ( new \WPMailSMTP\Tasks\Tasks() )->cancel_all();
156
157 $meta_table = \WPMailSMTP\Tasks\Meta::get_table_name();
158 $wpdb->query( "DROP TABLE IF EXISTS $meta_table;" ); // phpcs:ignore WordPress.DB
159
160 // Restore the current network site back to the original one.
161 restore_current_blog();
162 }
163 } else { // Non WP MS uninstall process (for normal WP installs).
164
165 // Confirm user has decided to remove all data, otherwise stop.
166 $settings = get_option( 'wp_mail_smtp', [] );
167 if ( empty( $settings['general']['uninstall'] ) ) {
168 return;
169 }
170
171 /*
172 * Delete plugin options.
173 */
174 foreach ( $options as $option ) {
175 delete_option( $option );
176 }
177
178 // Delete plugin settings.
179 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wp\_mail\_smtp%'" ); // phpcs:ignore WordPress.DB
180
181 // Delete plugin user meta.
182 $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE 'wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
183
184 // Remove any transients we've left behind.
185 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_transient\_wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
186 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_site\_transient\_wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
187 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_transient\_timeout\_wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
188 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_site\_transient\_timeout\_wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
189
190 // Delete debug events table.
191 $debug_events_table = \WPMailSMTP\Admin\DebugEvents\DebugEvents::get_table_name();
192 $wpdb->query( "DROP TABLE IF EXISTS $debug_events_table;" ); // phpcs:ignore WordPress.DB
193
194 /*
195 * Remove product announcements.
196 */
197 $announcements = get_posts( $am_announcement_params );
198 if ( ! empty( $announcements ) ) {
199 foreach ( $announcements as $announcement ) {
200 wp_delete_post( $announcement, true );
201 }
202 }
203
204 /*
205 * Cleanup data for Pro plugin only.
206 */
207 if (
208 function_exists( 'wp_mail_smtp' ) &&
209 is_readable( wp_mail_smtp()->plugin_path . '/src/Pro/Pro.php' )
210 ) {
211
212 // Delete logs table.
213 $table = \WPMailSMTP\Pro\Emails\Logs\Logs::get_table_name();
214 $wpdb->query( "DROP TABLE IF EXISTS $table;" ); // phpcs:ignore WordPress.DB
215
216 // Delete attachments tables.
217 $attachment_files_table = \WPMailSMTP\Pro\Emails\Logs\Attachments\Attachments::get_attachment_files_table_name();
218 $wpdb->query( "DROP TABLE IF EXISTS $attachment_files_table;" ); // phpcs:ignore WordPress.DB
219
220 $email_attachments_table = \WPMailSMTP\Pro\Emails\Logs\Attachments\Attachments::get_email_attachments_table_name();
221 $wpdb->query( "DROP TABLE IF EXISTS $email_attachments_table;" ); // phpcs:ignore WordPress.DB
222
223 // Delete all attachments if any.
224 ( new \WPMailSMTP\Pro\Emails\Logs\Attachments\Attachments() )->delete_all_attachments();
225
226 // Delete tracking tables.
227 $tracking_events_table = \WPMailSMTP\Pro\Emails\Logs\Tracking\Tracking::get_events_table_name();
228 $wpdb->query( "DROP TABLE IF EXISTS $tracking_events_table;" ); // phpcs:ignore WordPress.DB
229
230 $tracking_links_table = \WPMailSMTP\Pro\Emails\Logs\Tracking\Tracking::get_links_table_name();
231 $wpdb->query( "DROP TABLE IF EXISTS $tracking_links_table;" ); // phpcs:ignore WordPress.DB
232 }
233
234 /*
235 * Drop all Action Scheduler data and unschedule all plugin ActionScheduler actions.
236 */
237 ( new \WPMailSMTP\Tasks\Tasks() )->cancel_all();
238
239 $meta_table = \WPMailSMTP\Tasks\Meta::get_table_name();
240 $wpdb->query( "DROP TABLE IF EXISTS $meta_table;" ); // phpcs:ignore WordPress.DB
241 }
242