PluginProbe ʕ •ᴥ•ʔ
WP Mail SMTP by WPForms – The Most Popular SMTP and Email Log Plugin / 3.3.0
WP Mail SMTP by WPForms – The Most Popular SMTP and Email Log Plugin v3.3.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
237 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 // Load plugin file.
14 require_once 'wp_mail_smtp.php';
15 require_once dirname( __FILE__ ) . '/vendor/woocommerce/action-scheduler/action-scheduler.php';
16
17 global $wpdb;
18
19 /*
20 * Remove Legacy options.
21 */
22 $options = [
23 '_amn_smtp_last_checked',
24 'pepipost_ssl',
25 'pepipost_port',
26 'pepipost_pass',
27 'pepipost_user',
28 'smtp_pass',
29 'smtp_user',
30 'smtp_auth',
31 'smtp_ssl',
32 'smtp_port',
33 'smtp_host',
34 'mail_set_return_path',
35 'mailer',
36 'mail_from_name',
37 'mail_from',
38 ];
39
40 /**
41 * Remove AM announcement posts.
42 */
43 $am_announcement_params = [
44 'post_type' => [ 'amn_smtp' ],
45 'post_status' => 'any',
46 'numberposts' => - 1,
47 'fields' => 'ids',
48 ];
49
50 /**
51 * Disable Action Schedule Queue Runner, to prevent a fatal error on the shutdown WP hook.
52 */
53 if ( class_exists( 'ActionScheduler_QueueRunner' ) ) {
54 $as_queue_runner = \ActionScheduler_QueueRunner::instance();
55
56 if ( method_exists( $as_queue_runner, 'unhook_dispatch_async_request' ) ) {
57 $as_queue_runner->unhook_dispatch_async_request();
58 }
59 }
60
61 // WP MS uninstall process.
62 if ( is_multisite() ) {
63 $main_site_settings = get_blog_option( get_main_site_id(), 'wp_mail_smtp', [] );
64 $network_wide = ! empty( $main_site_settings['general']['network_wide'] );
65 $network_uninstall = ! empty( $main_site_settings['general']['uninstall'] );
66
67 $sites = get_sites();
68
69 foreach ( $sites as $site ) {
70 $settings = get_blog_option( $site->blog_id, 'wp_mail_smtp', [] );
71
72 // Confirm network site admin has decided to remove all data, otherwise skip.
73 if (
74 ( $network_wide && ! $network_uninstall ) ||
75 ( ! $network_wide && empty( $settings['general']['uninstall'] ) )
76 ) {
77 continue;
78 }
79
80 /*
81 * Delete network site plugin options.
82 */
83 foreach ( $options as $option ) {
84 delete_blog_option( $site->blog_id, $option );
85 }
86
87 // Switch to the current network site.
88 switch_to_blog( $site->blog_id );
89
90 // Delete plugin settings.
91 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wp\_mail\_smtp%'" ); // phpcs:ignore WordPress.DB
92
93 // Delete plugin user meta.
94 $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE 'wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
95
96 // Remove any transients we've left behind.
97 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_transient\_wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
98 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_site\_transient\_wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
99 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_transient\_timeout\_wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
100 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_site\_transient\_timeout\_wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
101
102 // Delete debug events table.
103 $debug_events_table = \WPMailSMTP\Admin\DebugEvents\DebugEvents::get_table_name();
104 $wpdb->query( "DROP TABLE IF EXISTS $debug_events_table;" ); // phpcs:ignore WordPress.DB
105
106 /*
107 * Delete network site product announcements.
108 */
109 $announcements = get_posts( $am_announcement_params );
110
111 if ( ! empty( $announcements ) ) {
112 foreach ( $announcements as $announcement ) {
113 wp_delete_post( $announcement, true );
114 }
115 }
116
117 /*
118 * Cleanup network site data for Pro plugin only.
119 */
120 if (
121 function_exists( 'wp_mail_smtp' ) &&
122 is_readable( wp_mail_smtp()->plugin_path . '/src/Pro/Pro.php' )
123 ) {
124
125 // Delete logs table.
126 $table = \WPMailSMTP\Pro\Emails\Logs\Logs::get_table_name();
127 $wpdb->query( "DROP TABLE IF EXISTS $table;" ); // phpcs:ignore WordPress.DB
128
129 // Delete attachments tables.
130 $attachment_files_table = \WPMailSMTP\Pro\Emails\Logs\Attachments\Attachments::get_attachment_files_table_name();
131 $wpdb->query( "DROP TABLE IF EXISTS $attachment_files_table;" ); // phpcs:ignore WordPress.DB
132
133 $email_attachments_table = \WPMailSMTP\Pro\Emails\Logs\Attachments\Attachments::get_email_attachments_table_name();
134 $wpdb->query( "DROP TABLE IF EXISTS $email_attachments_table;" ); // phpcs:ignore WordPress.DB
135
136 // Delete all attachments if any.
137 ( new \WPMailSMTP\Pro\Emails\Logs\Attachments\Attachments() )->delete_all_attachments();
138
139 // Delete tracking tables.
140 $tracking_events_table = \WPMailSMTP\Pro\Emails\Logs\Tracking\Tracking::get_events_table_name();
141 $wpdb->query( "DROP TABLE IF EXISTS $tracking_events_table;" ); // phpcs:ignore WordPress.DB
142
143 $tracking_links_table = \WPMailSMTP\Pro\Emails\Logs\Tracking\Tracking::get_links_table_name();
144 $wpdb->query( "DROP TABLE IF EXISTS $tracking_links_table;" ); // phpcs:ignore WordPress.DB
145 }
146
147 /*
148 * Drop all Action Scheduler data and unschedule all plugin ActionScheduler actions.
149 */
150 ( new \WPMailSMTP\Tasks\Tasks() )->cancel_all();
151
152 $meta_table = \WPMailSMTP\Tasks\Meta::get_table_name();
153 $wpdb->query( "DROP TABLE IF EXISTS $meta_table;" ); // phpcs:ignore WordPress.DB
154
155 // Restore the current network site back to the original one.
156 restore_current_blog();
157 }
158 } else { // Non WP MS uninstall process (for normal WP installs).
159
160 // Confirm user has decided to remove all data, otherwise stop.
161 $settings = get_option( 'wp_mail_smtp', [] );
162 if ( empty( $settings['general']['uninstall'] ) ) {
163 return;
164 }
165
166 /*
167 * Delete plugin options.
168 */
169 foreach ( $options as $option ) {
170 delete_option( $option );
171 }
172
173 // Delete plugin settings.
174 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wp\_mail\_smtp%'" ); // phpcs:ignore WordPress.DB
175
176 // Delete plugin user meta.
177 $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE 'wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
178
179 // Remove any transients we've left behind.
180 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_transient\_wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
181 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_site\_transient\_wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
182 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_transient\_timeout\_wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
183 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_site\_transient\_timeout\_wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
184
185 // Delete debug events table.
186 $debug_events_table = \WPMailSMTP\Admin\DebugEvents\DebugEvents::get_table_name();
187 $wpdb->query( "DROP TABLE IF EXISTS $debug_events_table;" ); // phpcs:ignore WordPress.DB
188
189 /*
190 * Remove product announcements.
191 */
192 $announcements = get_posts( $am_announcement_params );
193 if ( ! empty( $announcements ) ) {
194 foreach ( $announcements as $announcement ) {
195 wp_delete_post( $announcement, true );
196 }
197 }
198
199 /*
200 * Cleanup data for Pro plugin only.
201 */
202 if (
203 function_exists( 'wp_mail_smtp' ) &&
204 is_readable( wp_mail_smtp()->plugin_path . '/src/Pro/Pro.php' )
205 ) {
206
207 // Delete logs table.
208 $table = \WPMailSMTP\Pro\Emails\Logs\Logs::get_table_name();
209 $wpdb->query( "DROP TABLE IF EXISTS $table;" ); // phpcs:ignore WordPress.DB
210
211 // Delete attachments tables.
212 $attachment_files_table = \WPMailSMTP\Pro\Emails\Logs\Attachments\Attachments::get_attachment_files_table_name();
213 $wpdb->query( "DROP TABLE IF EXISTS $attachment_files_table;" ); // phpcs:ignore WordPress.DB
214
215 $email_attachments_table = \WPMailSMTP\Pro\Emails\Logs\Attachments\Attachments::get_email_attachments_table_name();
216 $wpdb->query( "DROP TABLE IF EXISTS $email_attachments_table;" ); // phpcs:ignore WordPress.DB
217
218 // Delete all attachments if any.
219 ( new \WPMailSMTP\Pro\Emails\Logs\Attachments\Attachments() )->delete_all_attachments();
220
221 // Delete tracking tables.
222 $tracking_events_table = \WPMailSMTP\Pro\Emails\Logs\Tracking\Tracking::get_events_table_name();
223 $wpdb->query( "DROP TABLE IF EXISTS $tracking_events_table;" ); // phpcs:ignore WordPress.DB
224
225 $tracking_links_table = \WPMailSMTP\Pro\Emails\Logs\Tracking\Tracking::get_links_table_name();
226 $wpdb->query( "DROP TABLE IF EXISTS $tracking_links_table;" ); // phpcs:ignore WordPress.DB
227 }
228
229 /*
230 * Drop all Action Scheduler data and unschedule all plugin ActionScheduler actions.
231 */
232 ( new \WPMailSMTP\Tasks\Tasks() )->cancel_all();
233
234 $meta_table = \WPMailSMTP\Tasks\Meta::get_table_name();
235 $wpdb->query( "DROP TABLE IF EXISTS $meta_table;" ); // phpcs:ignore WordPress.DB
236 }
237