PluginProbe
ElasticPress / 5.3.5
ElasticPress v5.3.5
5.3.5 5.3.4 3.6.5 3.6.6 4.0.0 4.0.1 4.1.0 4.2.0 4.2.1 4.2.2 4.3.0 4.3.1 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.6.0 4.6.1 4.7.0 4.7.1 4.7.2 5.0.0 5.0.1 5.0.2 All 108 releases
← All changes | uninstall.php +58 -25 4.5.05.3.5 View file →
@@ -9,8 +9,12 @@
9 9 */
10 10
11 11 use ElasticPress\Utils;
12 12
13 +defined( 'ABSPATH' ) || exit;
14 +
15 +require_once __DIR__ . '/includes/utils.php';
16 +
13 17 /**
14 18 * Class EP_Uninstaller
15 19 */
16 20 class EP_Uninstaller {
@@ -23,8 +27,9 @@
23 27 protected $options = [
24 28 'ep_host',
25 29 'ep_index_meta',
26 30 'ep_feature_settings',
31 + 'ep_feature_settings_draft',
27 32 'ep_version',
28 33 'ep_intro_shown',
29 34 'ep_last_sync',
30 35 'ep_need_upgrade_sync',
@@ -36,10 +41,12 @@
36 41 'ep_credentials',
37 42 'ep_prefix',
38 43 'ep_language',
39 44 'ep_bulk_setting',
40 - 'ep_last_index',
45 + 'ep_sync_history',
41 46
47 + 'elasticpress_weighting',
48 +
42 49 // Admin notices options
43 50 'ep_hide_host_error_notice',
44 51 'ep_hide_es_below_compat_notice',
45 52 'ep_hide_es_above_compat_notice',
@@ -48,9 +55,8 @@
48 55 'ep_hide_upgrade_sync_notice',
49 56 'ep_hide_auto_activate_sync_notice',
50 57 'ep_hide_using_autosuggest_defaults_notice',
51 58 'ep_hide_yellow_health_notice',
52 - 'ep_hide_users_migration_notice',
53 59 ];
54 60
55 61 /**
56 62 * List of transient keys that need to be deleted when uninstalling the plugin.
@@ -76,14 +82,18 @@
76 82 *
77 83 * @since 1.7
78 84 */
79 85 public function __construct() {
80 -
81 86 // Exit if accessed directly.
82 87 if ( ! defined( 'ABSPATH' ) ) {
83 88 $this->exit_uninstaller();
84 89 }
85 90
91 + // If testing, do not do anything automatically
92 + if ( defined( 'EP_UNIT_TESTS' ) && EP_UNIT_TESTS ) {
93 + return;
94 + }
95 +
86 96 // EP_MANUAL_SETTINGS_RESET is used by the `settings-reset` WP-CLI command.
87 97 if ( ! defined( 'EP_MANUAL_SETTINGS_RESET' ) || ! EP_MANUAL_SETTINGS_RESET ) {
88 98 // Not uninstalling.
89 99 if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) || ! WP_UNINSTALL_PLUGIN ) {
@@ -97,8 +107,9 @@
97 107 }
98 108
99 109 // Uninstall ElasticPress.
100 110 $this->clean_options_and_transients();
111 + $this->clean_site_meta();
101 112 $this->remove_elasticpress_capability();
102 113 }
103 114
104 115 /**
@@ -119,35 +130,43 @@
119 130 }
120 131 }
121 132
122 133 /**
123 - * Delete all transients of the Related Posts feature.
134 + * Delete remaining transients by their option names.
135 + *
136 + * @since 4.7.0
124 137 */
125 - protected function delete_related_posts_transients() {
138 + protected function delete_transients_by_option_name() {
126 139 global $wpdb;
127 140
128 - $related_posts_transients = $wpdb->get_col( "SELECT option_name FROM {$wpdb->prefix}options WHERE option_name LIKE '_transient_ep_related_posts_%'" );
141 + $transients = $wpdb->get_col( // phpcs:ignore WordPress.DB.DirectDatabaseQuery
142 + "SELECT option_name
143 + FROM {$wpdb->prefix}options
144 + WHERE
145 + option_name LIKE '_transient_ep_index_settings_%'
146 + OR option_name LIKE '_transient_ep_related_posts_%'
147 + "
148 + );
129 149
130 - foreach ( $related_posts_transients as $related_posts_transient ) {
131 - $related_posts_transient = str_replace( '_transient_', '', $related_posts_transient );
132 - delete_site_transient( $related_posts_transient );
133 - delete_transient( $related_posts_transient );
150 + foreach ( $transients as $transient ) {
151 + $transient_name = str_replace( '_transient_', '', $transient );
152 + delete_site_transient( $transient_name );
153 + delete_transient( $transient_name );
134 154 }
135 155 }
136 156
137 157 /**
138 - * Delete all transients of the total fields limit.
158 + * DEPRECATED. Delete all transients of the Related Posts feature.
139 159 */
160 + protected function delete_related_posts_transients() {
161 + _deprecated_function( __METHOD__, '4.7.0', '\EP_Uninstaller::delete_transients_by_name()' );
162 + }
163 +
164 + /**
165 + * DEPRECATED. Delete all transients of the total fields limit.
166 + */
140 167 protected function delete_total_fields_limit_transients() {
141 - global $wpdb;
142 -
143 - $related_posts_transients = $wpdb->get_col( "SELECT option_name FROM {$wpdb->prefix}options WHERE option_name LIKE '_transient_ep_total_fields_limit_%'" );
144 -
145 - foreach ( $related_posts_transients as $related_posts_transient ) {
146 - $related_posts_transient = str_replace( '_transient_', '', $related_posts_transient );
147 - delete_site_transient( $related_posts_transient );
148 - delete_transient( $related_posts_transient );
149 - }
168 + _deprecated_function( __METHOD__, '4.7.0', '\EP_Uninstaller::delete_transients_by_name()' );
150 169 }
151 170
152 171 /**
153 172 * Cleanup options and transients
@@ -164,9 +183,9 @@
164 183 foreach ( $this->transients as $transient ) {
165 184 delete_site_transient( $transient );
166 185 }
167 186
168 - $sites = get_sites();
187 + $sites = \get_sites();
169 188
170 189 foreach ( $sites as $site ) {
171 190 switch_to_blog( $site->blog_id );
172 191
@@ -171,10 +190,9 @@
171 190 switch_to_blog( $site->blog_id );
172 191
173 192 $this->delete_options();
174 193 $this->delete_transients();
175 - $this->delete_related_posts_transients();
176 - $this->delete_total_fields_limit_transients();
194 + $this->delete_transients_by_option_name();
177 195
178 196 restore_current_blog();
179 197 }
180 198 } else {
@@ -179,10 +197,25 @@
179 197 }
180 198 } else {
181 199 $this->delete_options();
182 200 $this->delete_transients();
183 - $this->delete_related_posts_transients();
184 - $this->delete_total_fields_limit_transients();
201 + $this->delete_transients_by_option_name();
202 + }
203 + }
204 +
205 + /**
206 + * Delete all site meta
207 + *
208 + * @since 4.7.0
209 + */
210 + protected function clean_site_meta() {
211 + if ( ! is_multisite() ) {
212 + return;
213 + }
214 +
215 + $sites = Utils\get_sites();
216 + foreach ( $sites as $site ) {
217 + delete_site_meta( $site['blog_id'], 'ep_indexable' );
185 218 }
186 219 }
187 220
188 221 /**