PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.9.2
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.9.2
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 3.4.2 3.5.0 3.5.1 All 200 releases
← All changes | includes/Core/Install.php +46 -40 4.8.24.9.2 View file →
@@ -152,13 +152,20 @@
152 152 global $wpdb;
153 153
154 154 $charset_collate = $wpdb->get_charset_collate();
155 155
156 + // keyword_hash exists purely to make the lookup indexable: `keyword` is
157 + // TEXT and is matched with BINARY (for collation safety), which no index
158 + // can serve — so every front-end search used to full-scan this table.
159 + // The hash narrows to a single row via the index; the BINARY comparison
160 + // still decides the match, so behaviour is unchanged.
156 161 $search_keyword_table = $wpdb->prefix . 'betterdocs_search_keyword';
157 162 $search_keyword = "CREATE TABLE $search_keyword_table (
158 163 id bigint NOT NULL AUTO_INCREMENT,
159 164 keyword text NOT NULL,
160 - PRIMARY KEY (id)
165 + keyword_hash char(32) NOT NULL DEFAULT '',
166 + PRIMARY KEY (id),
167 + KEY keyword_hash (keyword_hash)
161 168 ) {$charset_collate};";
162 169
163 170 $search_log_table = $wpdb->prefix . 'betterdocs_search_log';
164 171 $search_log = "CREATE TABLE $search_log_table (
@@ -204,11 +211,46 @@
204 211 update_option( 'betterdocs_db_version', $_db_code_version );
205 212 }
206 213
207 214 public function migrate_customizer() {
208 - $search_layout = get_theme_mod( 'betterdocs_search_layout_select' );
209 - if ( empty( $search_layout ) ) {
210 - set_theme_mod( 'betterdocs_search_layout_select', 'layout-1' );
215 + /**
216 + * Seed the layout Customizer settings for installs that never explicitly
217 + * picked a layout. Some consumers read the raw theme_mod without a fallback
218 + * (e.g. FrontEnd::article_reactions()), so an unseeded mod can render
219 + * differently from the layout the front-end otherwise defaults to.
220 + *
221 + * Two rules keep this safe and correct:
222 + * 1. Only seed a mod that has never been set ( get_theme_mod() === false ).
223 + * An explicit choice — including an explicit 'layout-1' — is never
224 + * overwritten, so existing sites cannot change layout on update.
225 + * 2. Pull the value from Customizer\Defaults (the single source of truth
226 + * the front-end already renders from) instead of a hardcoded string, so
227 + * it can never drift from the real default again. Pro defaults are merged
228 + * in automatically when BetterDocs Pro is active.
229 + */
230 + $defaults = betterdocs()->customizer->defaults->defaults();
231 + $layout_mods = [
232 + 'betterdocs_search_layout_select',
233 + 'betterdocs_docs_layout_select',
234 + 'betterdocs_single_layout_select',
235 + 'betterdocs_archive_layout_select',
236 + 'betterdocs_select_faq_template',
237 + 'betterdocs_multikb_layout_select', // BetterDocs Pro.
238 + 'betterdocs_select_faq_template_mkb', // BetterDocs Pro.
239 + ];
240 +
241 + foreach ( $layout_mods as $mod ) {
242 + // Respect an explicit user choice (including an explicit 'layout-1').
243 + if ( get_theme_mod( $mod, false ) !== false ) {
244 + continue;
245 + }
246 +
247 + // Only seed when a real default is registered (skips inactive add-ons).
248 + if ( empty( $defaults[ $mod ] ) ) {
249 + continue;
250 + }
251 +
252 + set_theme_mod( $mod, $defaults[ $mod ] );
211 253 }
212 254
213 255 $search_heading = get_theme_mod( 'betterdocs_live_search_heading_switch' );
214 256 if ( empty( $search_heading ) ) {
@@ -214,45 +256,9 @@
214 256 if ( empty( $search_heading ) ) {
215 257 set_theme_mod( 'betterdocs_live_search_heading_switch', false );
216 258 }
217 259
218 - $docs_layout = get_theme_mod( 'betterdocs_docs_layout_select' );
219 - if ( empty( $docs_layout ) ) {
220 - set_theme_mod( 'betterdocs_docs_layout_select', 'layout-1' );
221 - }
222 -
223 - $single_layout = get_theme_mod( 'betterdocs_single_layout_select' );
224 - if ( empty( $single_layout ) ) {
225 - set_theme_mod( 'betterdocs_single_layout_select', 'layout-1' );
226 - }
227 -
228 - $category_archive_layout = get_theme_mod( 'betterdocs_archive_layout_select' );
229 - if ( empty( $category_archive_layout ) ) {
230 - set_theme_mod( 'betterdocs_archive_layout_select', 'layout-1' );
231 - }
232 -
233 - $search_layout_select = get_theme_mod( 'betterdocs_search_layout_select' );
234 - if ( empty( $search_layout_select ) ) {
235 - set_theme_mod( 'betterdocs_search_layout_select', 'layout-1' );
236 - }
237 -
238 - $docs_faq = get_theme_mod( 'betterdocs_select_faq_template' );
239 - if ( empty( $docs_faq ) ) {
240 - set_theme_mod( 'betterdocs_select_faq_template', 'layout-1' );
241 - }
242 -
243 260 if ( get_option( 'betterdocs_settings' ) && betterdocs()->settings->get( 'enable_estimated_reading_time' ) == false ) {
244 261 betterdocs()->settings->save( 'enable_estimated_reading_time', false );
245 - }
246 -
247 - if ( function_exists( 'betterdocs_pro' ) ) {
248 - $mkb_layout = get_theme_mod( 'betterdocs_multikb_layout_select' );
249 - if ( empty( $mkb_layout ) ) {
250 - set_theme_mod( 'betterdocs_multikb_layout_select', 'layout-1' );
251 - }
252 - $mkb_faq = get_theme_mod( 'betterdocs_select_faq_template_mkb' );
253 - if ( empty( $mkb_faq ) ) {
254 - set_theme_mod( 'betterdocs_select_faq_template_mkb', 'layout-1' );
255 - }
256 262 }
257 263 }
258 264 }