PluginProbe ʕ •ᴥ•ʔ
WP Mail SMTP by WPForms – The Most Popular SMTP and Email Log Plugin / 2.8.0
WP Mail SMTP by WPForms – The Most Popular SMTP and Email Log Plugin v2.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 5 years ago src 5 years ago vendor 5 years ago vendor_prefixed 5 years ago readme.txt 5 years ago uninstall.php 5 years ago wp-mail-smtp.php 5 years ago wp_mail_smtp.php 5 years ago
uninstall.php
191 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 /*
103 * Delete network site product announcements.
104 */
105 $announcements = get_posts( $am_announcement_params );
106
107 if ( ! empty( $announcements ) ) {
108 foreach ( $announcements as $announcement ) {
109 wp_delete_post( $announcement, true );
110 }
111 }
112
113 /*
114 * Delete network site Logs for Pro plugin only.
115 */
116 if (
117 function_exists( 'wp_mail_smtp' ) &&
118 is_readable( wp_mail_smtp()->plugin_path . '/src/Pro/Pro.php' )
119 ) {
120 $table = \WPMailSMTP\Pro\Emails\Logs\Logs::get_table_name();
121 $wpdb->query( "DROP TABLE IF EXISTS $table;" ); // phpcs:ignore WordPress.DB
122 }
123
124 /*
125 * Drop all Action Scheduler data and unschedule all plugin ActionScheduler actions.
126 */
127 ( new \WPMailSMTP\Tasks\Tasks() )->cancel_all();
128
129 $meta_table = \WPMailSMTP\Tasks\Meta::get_table_name();
130 $wpdb->query( "DROP TABLE IF EXISTS $meta_table;" ); // phpcs:ignore WordPress.DB
131
132 // Restore the current network site back to the original one.
133 restore_current_blog();
134 }
135 } else { // Non WP MS uninstall process (for normal WP installs).
136
137 // Confirm user has decided to remove all data, otherwise stop.
138 $settings = get_option( 'wp_mail_smtp', [] );
139 if ( empty( $settings['general']['uninstall'] ) ) {
140 return;
141 }
142
143 /*
144 * Delete plugin options.
145 */
146 foreach ( $options as $option ) {
147 delete_option( $option );
148 }
149
150 // Delete plugin settings.
151 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wp\_mail\_smtp%'" ); // phpcs:ignore WordPress.DB
152
153 // Delete plugin user meta.
154 $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE 'wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
155
156 // Remove any transients we've left behind.
157 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_transient\_wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
158 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_site\_transient\_wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
159 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_transient\_timeout\_wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
160 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_site\_transient\_timeout\_wp\_mail\_smtp\_%'" ); // phpcs:ignore WordPress.DB
161
162 /*
163 * Remove product announcements.
164 */
165 $announcements = get_posts( $am_announcement_params );
166 if ( ! empty( $announcements ) ) {
167 foreach ( $announcements as $announcement ) {
168 wp_delete_post( $announcement, true );
169 }
170 }
171
172 /*
173 * Logs for Pro plugin only.
174 */
175 if (
176 function_exists( 'wp_mail_smtp' ) &&
177 is_readable( wp_mail_smtp()->plugin_path . '/src/Pro/Pro.php' )
178 ) {
179 $table = \WPMailSMTP\Pro\Emails\Logs\Logs::get_table_name();
180 $wpdb->query( "DROP TABLE IF EXISTS $table;" ); // phpcs:ignore WordPress.DB
181 }
182
183 /*
184 * Drop all Action Scheduler data and unschedule all plugin ActionScheduler actions.
185 */
186 ( new \WPMailSMTP\Tasks\Tasks() )->cancel_all();
187
188 $meta_table = \WPMailSMTP\Tasks\Meta::get_table_name();
189 $wpdb->query( "DROP TABLE IF EXISTS $meta_table;" ); // phpcs:ignore WordPress.DB
190 }
191