PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.9.3
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.9.3
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 3.4.2 3.5.0 All 201 releases
← All changes | views/template-parts/nested-categories.php +15 -3 4.8.0 → 4.9.3 View file →
@@ -64,9 +64,12 @@
64 64 // the wrong .active branch.
65 65 $bd_queried = (int) get_queried_object_id();
66 66 $bd_is_single = is_singular( 'docs' ) ? 1 : 0;
67 67 $bd_version = betterdocs()->database->get_cache_version( 'betterdocs_term_counts' );
68 - $bd_cache_key = 'bd_nested_frag_' . md5( "v{$bd_version}_term{$term_id}_m{$bd_multi_kb}_k{$bd_kb_slug}_p{$bd_can_priv}_i{$bd_cat_icon}_q{$bd_queried}_s{$bd_is_single}" );
68 + $bd_icon_disc = md5( wp_json_encode( isset( $list_icon_name ) ? $list_icon_name : "" ) );
69 + $bd_show_icon = ( isset( $show_list_icon ) && $show_list_icon === false ) ? 0 : 1;
70 + $bd_order_disc = md5( wp_json_encode( array( isset( $nested_terms_query ) ? $nested_terms_query : array(), isset( $nested_docs_query_args ) ? $nested_docs_query_args : array() ) ) );
71 + $bd_cache_key = 'bd_nested_frag_' . md5( "v{$bd_version}_term{$term_id}_m{$bd_multi_kb}_k{$bd_kb_slug}_p{$bd_can_priv}_i{$bd_cat_icon}_q{$bd_queried}_s{$bd_is_single}_ic{$bd_icon_disc}_si{$bd_show_icon}_o{$bd_order_disc}" );
69 72
70 73 $bd_cached = get_transient( $bd_cache_key );
71 74 if ( false !== $bd_cached ) {
72 75 echo $bd_cached; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
@@ -202,9 +205,10 @@
202 205 echo wp_sprintf(
203 206 '<li>%s<a %s>%s</a></li>',
204 207 $_icon, //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
205 208 $_link_attributes, //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
206 - betterdocs()->template_helper->kses( get_the_title() ) //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
209 + // Same per-item filter as category-list.php (API method badges etc.).
210 + apply_filters( 'betterdocs_docs_list_item_title', betterdocs()->template_helper->kses( get_the_title() ), get_the_ID() ) //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
207 211 );
208 212 endwhile;
209 213 }
210 214
@@ -230,7 +234,15 @@
230 234 $bd_nested_depth--;
231 235
232 236 if ( $bd_is_outermost ) {
233 237 $bd_html = ob_get_clean();
234 - set_transient( $bd_cache_key, $bd_html, HOUR_IN_SECONDS * 6 );
238 + // Never cache an empty render. An empty buffer means every child term was
239 + // skipped ( $_counts <= 0 ), which is usually a transient data state — stale
240 + // counts mid-import, docs not yet published. The read guard treats '' as a hit
241 + // ( '' !== false ), so caching it would pin a blank nested block for 6 hours
242 + // after the data is already correct. Re-rendering once per request while empty
243 + // is what lets it self-heal. (#165)
244 + if ( '' !== $bd_html ) {
245 + set_transient( $bd_cache_key, $bd_html, HOUR_IN_SECONDS * 6 );
246 + }
235 247 echo $bd_html; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
236 248 }