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 +53 -28 4.6.15.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,39 +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( // phpcs:ignore WordPress.DB.DirectDatabaseQuery
133 - "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 + "
134 148 );
135 149
136 - foreach ( $related_posts_transients as $related_posts_transient ) {
137 - $related_posts_transient = str_replace( '_transient_', '', $related_posts_transient );
138 - delete_site_transient( $related_posts_transient );
139 - 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 );
140 154 }
141 155 }
142 156
143 157 /**
144 - * Delete all transients of the total fields limit.
158 + * DEPRECATED. Delete all transients of the Related Posts feature.
145 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 + */
146 167 protected function delete_total_fields_limit_transients() {
147 - global $wpdb;
148 -
149 - $related_posts_transients = $wpdb->get_col( // phpcs:ignore WordPress.DB.DirectDatabaseQuery
150 - "SELECT option_name FROM {$wpdb->prefix}options WHERE option_name LIKE '_transient_ep_total_fields_limit_%'"
151 - );
152 -
153 - foreach ( $related_posts_transients as $related_posts_transient ) {
154 - $related_posts_transient = str_replace( '_transient_', '', $related_posts_transient );
155 - delete_site_transient( $related_posts_transient );
156 - delete_transient( $related_posts_transient );
157 - }
168 + _deprecated_function( __METHOD__, '4.7.0', '\EP_Uninstaller::delete_transients_by_name()' );
158 169 }
159 170
160 171 /**
161 172 * Cleanup options and transients
@@ -172,9 +183,9 @@
172 183 foreach ( $this->transients as $transient ) {
173 184 delete_site_transient( $transient );
174 185 }
175 186
176 - $sites = get_sites();
187 + $sites = \get_sites();
177 188
178 189 foreach ( $sites as $site ) {
179 190 switch_to_blog( $site->blog_id );
180 191
@@ -179,10 +190,9 @@
179 190 switch_to_blog( $site->blog_id );
180 191
181 192 $this->delete_options();
182 193 $this->delete_transients();
183 - $this->delete_related_posts_transients();
184 - $this->delete_total_fields_limit_transients();
194 + $this->delete_transients_by_option_name();
185 195
186 196 restore_current_blog();
187 197 }
188 198 } else {
@@ -187,10 +197,25 @@
187 197 }
188 198 } else {
189 199 $this->delete_options();
190 200 $this->delete_transients();
191 - $this->delete_related_posts_transients();
192 - $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' );
193 218 }
194 219 }
195 220
196 221 /**