PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.9.5
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.9.5
4.9.5 4.9.4 4.9.3 4.9.2 4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 All 203 releases
← All changes | includes/Core/Migration.php +42 -0 4.9.4 → 4.9.5 View file →
@@ -37,8 +37,9 @@
37 37
38 38 $this->search_migration();
39 39 $this->fix_search_table_collation();
40 40 $this->backfill_search_keyword_hash();
41 + $this->reset_formerly_locked_analytics_settings();
41 42
42 43 /**
43 44 * Settings Migration
44 45 */
@@ -205,6 +206,47 @@
205 206
206 207 if ( 0 === $remaining ) {
207 208 $this->database->save( 'betterdocs_search_keyword_hash_filled', '1.0.3' );
208 209 }
210 + }
211 +
212 + /**
213 + * Clear the placeholder values the old Pro lock saved for the analytics
214 + * collection settings.
215 + *
216 + * Until these settings were unlocked in Free (WP.org guideline 5), the
217 + * settings screen merged Settings::pro_settings_default_values() into its
218 + * form whenever Pro was inactive, so any save stored `analytics_from`,
219 + * `unique_visitor_count`, `exclude_bot_analytics` and
220 + * `child_category_exclude` as boolean false. Free ignored those keys then,
221 + * so the tracker counted everyone, excluded bots and skipped unique visits.
222 + *
223 + * Free now reads the stored values, so a leftover `exclude_bot_analytics =
224 + * false` would suddenly start counting bot traffic. A boolean false in
225 + * `analytics_from` is the marker of that merge: no UI ever saves it (Free's
226 + * select saves a string; Pro's Analytics → Settings never writes the key).
227 + * When it is present, restore the behaviour those sites actually had.
228 + * `unique_visitor_count` is left as stored — false there matches the old
229 + * behaviour — and `child_category_exclude` false is already the default.
230 + *
231 + * @return void
232 + */
233 + public function reset_formerly_locked_analytics_settings() {
234 + if ( $this->database->get( 'betterdocs_unlocked_analytics_settings_migrated', false ) ) {
235 + return;
236 + }
237 +
238 + $settings = $this->database->get( 'betterdocs_settings', [] );
239 +
240 + if ( is_array( $settings ) && array_key_exists( 'analytics_from', $settings ) && false === $settings['analytics_from'] ) {
241 + $settings['analytics_from'] = 'everyone';
242 +
243 + if ( array_key_exists( 'exclude_bot_analytics', $settings ) && ! $settings['exclude_bot_analytics'] ) {
244 + $settings['exclude_bot_analytics'] = true;
245 + }
246 +
247 + $this->database->save( 'betterdocs_settings', $settings );
248 + }
249 +
250 + $this->database->save( 'betterdocs_unlocked_analytics_settings_migrated', '1' );
209 251 }
210 252 }