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/layouts/category-grid/default.php +20 -4 4.5.5 → 4.9.3 View file →
@@ -10,11 +10,15 @@
10 10 'data-id' => isset( $term->term_id ) ? $term->term_id : 0,
11 11 'class' => [ 'betterdocs-single-category-wrapper category-grid' ]
12 12 ];
13 13
14 + $is_active = false;
14 15 if ( is_single() && ( $term->term_id === $current_queried_object_id || ( (bool) $nested_subcategory && in_array( $term->term_id, $ancestors ) ) ) ) {
15 - $attributes['class'][] = 'active';
16 + $is_active = true;
16 17 } elseif ( Helper::get_tax() == 'doc_category' && $term->term_id === $current_queried_object_id || ( (bool) $nested_subcategory && Helper::get_tax() == 'doc_category' && Helper::get_the_top_most_parent( $current_queried_object_id ) == $term->term_id ) ) {
18 + $is_active = true;
19 + }
20 + if ( $is_active ) {
17 21 $attributes['class'][] = 'active';
18 22 }
19 23
20 24 if ( isset( $wrapper_class ) && is_array( $wrapper_class ) && ! empty( $wrapper_class ) ) {
@@ -23,8 +27,10 @@
23 27
24 28 $attributes = betterdocs()->template_helper->get_html_attributes( $attributes );
25 29 $posts_per_page = isset( $docs_query_args['posts_per_page'] ) ? $docs_query_args['posts_per_page'] : ( isset( $post_per_tab ) ? $post_per_tab : ( isset($post_per_page) ? $post_per_page : 0 ) ); // for category grid, mkb, tab
26 30 $current_term_posts_count = isset( $counts ) && ! is_array( $counts ) ? $counts : ( isset( $counts ) && is_array( $counts ) ? $counts['counts'] : 0 );
31 +
32 + $is_lazy_body = ! empty( $lazy_load ) && ! $is_active;
27 33 ?>
28 34
29 35 <article
30 36 <?php echo $attributes; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
@@ -34,11 +40,21 @@
34 40 $view_object->get( 'layout-parts/header' );
35 41 }
36 42
37 43 if ( $show_list ) {
38 - echo '<div class="betterdocs-body">';
39 - $view_object->get( 'template-parts/category-list' );
40 - echo '</div>';
44 + if ( $is_lazy_body ) {
45 + // Empty placeholder. JS injects the skeleton on click and swaps
46 + // in real docs once the AJAX completes (with a 1s minimum
47 + // display so the loading state is perceptible).
48 + printf(
49 + '<div class="betterdocs-body" data-bd-lazy="1" data-bd-term-id="%d" style="display:none;"></div>',
50 + (int) $term->term_id
51 + );
52 + } else {
53 + echo '<div class="betterdocs-body">';
54 + $view_object->get( 'template-parts/category-list' );
55 + echo '</div>';
56 + }
41 57 }
42 58
43 59 if( $posts_per_page < $current_term_posts_count ) {
44 60 $view_object->get( 'layout-parts/footer' );