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 +54 -25 4.5.25.3.5 View file →
@@ -27,8 +27,9 @@
27 27 protected $options = [
28 28 'ep_host',
29 29 'ep_index_meta',
30 30 'ep_feature_settings',
31 + 'ep_feature_settings_draft',
31 32 'ep_version',
32 33 'ep_intro_shown',
33 34 'ep_last_sync',
34 35 'ep_need_upgrade_sync',
@@ -40,10 +41,12 @@
40 41 'ep_credentials',
41 42 'ep_prefix',
42 43 'ep_language',
43 44 'ep_bulk_setting',
44 - 'ep_last_index',
45 + 'ep_sync_history',
45 46
47 + 'elasticpress_weighting',
48 +
46 49 // Admin notices options
47 50 'ep_hide_host_error_notice',
48 51 'ep_hide_es_below_compat_notice',
49 52 'ep_hide_es_above_compat_notice',
@@ -52,9 +55,8 @@
52 55 'ep_hide_upgrade_sync_notice',
53 56 'ep_hide_auto_activate_sync_notice',
54 57 'ep_hide_using_autosuggest_defaults_notice',
55 58 'ep_hide_yellow_health_notice',
56 - 'ep_hide_users_migration_notice',
57 59 ];
58 60
59 61 /**
60 62 * List of transient keys that need to be deleted when uninstalling the plugin.
@@ -80,14 +82,18 @@
80 82 *
81 83 * @since 1.7
82 84 */
83 85 public function __construct() {
84 -
85 86 // Exit if accessed directly.
86 87 if ( ! defined( 'ABSPATH' ) ) {
87 88 $this->exit_uninstaller();
88 89 }
89 90
91 + // If testing, do not do anything automatically
92 + if ( defined( 'EP_UNIT_TESTS' ) && EP_UNIT_TESTS ) {
93 + return;
94 + }
95 +
90 96 // EP_MANUAL_SETTINGS_RESET is used by the `settings-reset` WP-CLI command.
91 97 if ( ! defined( 'EP_MANUAL_SETTINGS_RESET' ) || ! EP_MANUAL_SETTINGS_RESET ) {
92 98 // Not uninstalling.
93 99 if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) || ! WP_UNINSTALL_PLUGIN ) {
@@ -101,8 +107,9 @@
101 107 }
102 108
103 109 // Uninstall ElasticPress.
104 110 $this->clean_options_and_transients();
111 + $this->clean_site_meta();
105 112 $this->remove_elasticpress_capability();
106 113 }
107 114
108 115 /**
@@ -123,35 +130,43 @@
123 130 }
124 131 }
125 132
126 133 /**
127 - * Delete all transients of the Related Posts feature.
134 + * Delete remaining transients by their option names.
135 + *
136 + * @since 4.7.0
128 137 */
129 - protected function delete_related_posts_transients() {
138 + protected function delete_transients_by_option_name() {
130 139 global $wpdb;
131 140
132 - $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 + );
133 149
134 - foreach ( $related_posts_transients as $related_posts_transient ) {
135 - $related_posts_transient = str_replace( '_transient_', '', $related_posts_transient );
136 - delete_site_transient( $related_posts_transient );
137 - 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 );
138 154 }
139 155 }
140 156
141 157 /**
142 - * Delete all transients of the total fields limit.
158 + * DEPRECATED. Delete all transients of the Related Posts feature.
143 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 + */
144 167 protected function delete_total_fields_limit_transients() {
145 - global $wpdb;
146 -
147 - $related_posts_transients = $wpdb->get_col( "SELECT option_name FROM {$wpdb->prefix}options WHERE option_name LIKE '_transient_ep_total_fields_limit_%'" );
148 -
149 - foreach ( $related_posts_transients as $related_posts_transient ) {
150 - $related_posts_transient = str_replace( '_transient_', '', $related_posts_transient );
151 - delete_site_transient( $related_posts_transient );
152 - delete_transient( $related_posts_transient );
153 - }
168 + _deprecated_function( __METHOD__, '4.7.0', '\EP_Uninstaller::delete_transients_by_name()' );
154 169 }
155 170
156 171 /**
157 172 * Cleanup options and transients
@@ -168,9 +183,9 @@
168 183 foreach ( $this->transients as $transient ) {
169 184 delete_site_transient( $transient );
170 185 }
171 186
172 - $sites = get_sites();
187 + $sites = \get_sites();
173 188
174 189 foreach ( $sites as $site ) {
175 190 switch_to_blog( $site->blog_id );
176 191
@@ -175,10 +190,9 @@
175 190 switch_to_blog( $site->blog_id );
176 191
177 192 $this->delete_options();
178 193 $this->delete_transients();
179 - $this->delete_related_posts_transients();
180 - $this->delete_total_fields_limit_transients();
194 + $this->delete_transients_by_option_name();
181 195
182 196 restore_current_blog();
183 197 }
184 198 } else {
@@ -183,10 +197,25 @@
183 197 }
184 198 } else {
185 199 $this->delete_options();
186 200 $this->delete_transients();
187 - $this->delete_related_posts_transients();
188 - $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' );
189 218 }
190 219 }
191 220
192 221 /**