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 +26 -5 4.5.0 → 4.9.3 View file →
@@ -1,6 +1,11 @@
1 1 <?php
2 - use WPDeveloper\BetterDocs\Utils\Helper;
2 +// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- view template receives variables via extract(); prefixing is impractical.
3 +
4 +if ( ! defined( 'ABSPATH' ) ) {
5 + exit;
6 +}
7 +use WPDeveloper\BetterDocs\Utils\Helper;
3 8
4 9 $attributes = [
5 10 'data-id' => isset( $term->term_id ) ? $term->term_id : 0,
6 11 'class' => [ 'betterdocs-single-category-wrapper category-grid' ]
@@ -5,11 +10,15 @@
5 10 'data-id' => isset( $term->term_id ) ? $term->term_id : 0,
6 11 'class' => [ 'betterdocs-single-category-wrapper category-grid' ]
7 12 ];
8 13
14 + $is_active = false;
9 15 if ( is_single() && ( $term->term_id === $current_queried_object_id || ( (bool) $nested_subcategory && in_array( $term->term_id, $ancestors ) ) ) ) {
10 - $attributes['class'][] = 'active';
16 + $is_active = true;
11 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 ) {
12 21 $attributes['class'][] = 'active';
13 22 }
14 23
15 24 if ( isset( $wrapper_class ) && is_array( $wrapper_class ) && ! empty( $wrapper_class ) ) {
@@ -18,8 +27,10 @@
18 27
19 28 $attributes = betterdocs()->template_helper->get_html_attributes( $attributes );
20 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
21 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;
22 33 ?>
23 34
24 35 <article
25 36 <?php echo $attributes; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
@@ -29,11 +40,21 @@
29 40 $view_object->get( 'layout-parts/header' );
30 41 }
31 42
32 43 if ( $show_list ) {
33 - echo '<div class="betterdocs-body">';
34 - $view_object->get( 'template-parts/category-list' );
35 - 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 + }
36 57 }
37 58
38 59 if( $posts_per_page < $current_term_posts_count ) {
39 60 $view_object->get( 'layout-parts/footer' );