PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 3.8.9
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v3.8.9
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/Shortcodes/CategoryGrid.php +169 -151 3.5.03.8.9 View file →
@@ -5,181 +5,199 @@
5 5 use WPDeveloper\BetterDocs\Utils\Helper;
6 6 use WPDeveloper\BetterDocs\Core\Shortcode;
7 7
8 8 class CategoryGrid extends Shortcode {
9 - protected $layout_class = 'layout-1';
9 + protected $layout_class = 'layout-1';
10 10
11 - /**
12 - * A list of deprecated attributes.
13 - * @var array<string, string>
14 - */
15 - protected $deprecated_attributes = [
16 - 'category' => 'taxonomy',
17 - 'posts_per_grid' => 'posts_per_page',
18 - 'icon' => 'show_icon',
19 - 'post_counter' => 'show_count'
20 - ];
11 + /**
12 + * A list of deprecated attributes.
13 + * @var array<string, string>
14 + */
15 + protected $deprecated_attributes = [
16 + 'category' => 'taxonomy',
17 + 'posts_per_grid' => 'posts_per_page',
18 + 'icon' => 'show_icon',
19 + 'post_counter' => 'show_count'
20 + ];
21 21
22 - public function get_name() {
23 - return 'betterdocs_category_grid';
24 - }
22 + public function get_name() {
23 + return 'betterdocs_category_grid';
24 + }
25 25
26 - public function get_style_depends() {
27 - return ['betterdocs-category-grid'];
28 - }
26 + public function get_style_depends() {
27 + return [ 'betterdocs-category-grid' ];
28 + }
29 29
30 - public function get_script_depends() {
31 - return ['betterdocs-category-grid'];
32 - }
30 + public function get_script_depends() {
31 + return [ 'betterdocs-category-grid' ];
32 + }
33 33
34 - /**
35 - * Summary of default_attributes
36 - * @return array
37 - */
38 - public function default_attributes() {
39 - return [
40 - 'sidebar_list' => false,
41 - 'taxonomy' => 'doc_category',
42 - 'show_icon' => true,
43 - 'masonry' => false,
44 - 'posts_per_page' => $this->settings->get( 'posts_number', 0 ),
45 - 'orderby' => $this->settings->get( 'alphabetically_order_post', 'betterdocs_order' ),
46 - 'order' => $this->settings->get( 'docs_order', 'ASC' ),
47 - 'show_count' => $this->settings->get( 'post_count' ),
48 - 'column' => $this->settings->get( 'column_number' ),
49 - 'nested_subcategory' => $this->settings->get( 'nested_subcategory' ),
50 - 'terms' => '',
51 - 'terms_orderby' => '',
52 - 'terms_order' => '',
53 - 'terms_include' => '',
54 - 'terms_exclude' => '',
55 - 'terms_offset' => '',
56 - 'kb_slug' => '',
57 - 'multiple_knowledge_base' => false,
58 - 'disable_customizer_style' => false,
59 - 'title_tag' => 'h2',
60 - 'category_title_link' => false
61 - ];
62 - }
34 + /**
35 + * Summary of default_attributes
36 + * @return array
37 + */
38 + public function default_attributes() {
39 + return [
40 + 'sidebar_list' => false,
41 + 'taxonomy' => 'doc_category',
42 + 'show_icon' => true,
43 + 'category_icon' => '',
44 + 'masonry' => false,
45 + 'posts_per_page' => $this->settings->get( 'posts_number', 0 ),
46 + 'orderby' => $this->settings->get( 'alphabetically_order_post', 'betterdocs_order' ),
47 + 'order' => $this->settings->get( 'docs_order', 'ASC' ),
48 + 'show_count' => $this->settings->get( 'post_count' ),
49 + 'count_suffix' => '',
50 + 'count_suffix_singular' => '',
51 + 'column' => $this->settings->get( 'column_number' ),
52 + 'nested_subcategory' => $this->settings->get( 'nested_subcategory' ),
53 + 'terms' => '',
54 + 'terms_orderby' => '',
55 + 'terms_order' => '',
56 + 'terms_include' => '',
57 + 'terms_exclude' => '',
58 + 'terms_offset' => '',
59 + 'kb_slug' => '',
60 + 'multiple_knowledge_base' => false,
61 + 'disable_customizer_style' => false,
62 + 'title_tag' => 'h2',
63 + 'category_title_link' => false,
64 + 'layout_type' => '',
65 + 'list_icon_url' => '',
66 + 'list_icon_name' => 'list',
67 + 'sidebar_layout' => ''
68 + ];
69 + }
63 70
64 - public function generate_attributes() {
65 - $attributes = [
66 - 'class' => [
67 - 'betterdocs-category-grid-inner-wrapper',
68 - $this->layout_class
69 - ]
70 - ];
71 + public function generate_attributes() {
72 + $attributes = [
73 + 'class' => [
74 + 'betterdocs-category-grid-inner-wrapper',
75 + $this->layout_class
76 + ]
77 + ];
71 78
72 - $masonry = (bool) $this->settings->get( 'masonry_layout', false );
73 - if ( $this->has( 'masonry' ) ) {
74 - $masonry = (bool) $this->attributes['masonry'];
75 - }
79 + $masonry = (bool) $this->settings->get( 'masonry_layout', false );
80 + if ( $this->has( 'masonry' ) ) {
81 + $masonry = (bool) $this->attributes['masonry'];
82 + }
76 83
77 - if ( ! is_singular( 'docs' ) && ! is_tax( 'doc_category' ) && ! is_tax( 'doc_tag' ) ) {
78 - if ( $this->attributes['sidebar_list'] == true ) {
79 - $attributes['class'][] = 'layout-flex';
80 - } elseif ( $masonry == true ) {
81 - wp_enqueue_script( 'masonry' );
82 - $attributes['class'][] = 'masonry';
83 - } else {
84 - $attributes['class'][] = 'layout-flex';
85 - }
86 - if ( $this->attributes['sidebar_list'] == true ) {
87 - $_column_val = 1;
88 - } elseif ( $this->isset( 'column' ) ) {
89 - $_column_val = $this->attributes['column'];
90 - } else {
91 - $_column_val = $this->settings->get( 'column_number' );
92 - }
84 + if ( ! is_singular( 'docs' ) && ! is_tax( 'doc_category' ) && ! is_tax( 'doc_tag' ) ) {
85 + if ( $this->attributes['sidebar_list'] == true ) {
86 + $attributes['class'][] = 'layout-flex';
87 + } elseif ( $masonry == true ) {
88 + wp_enqueue_script( 'masonry' );
89 + $attributes['class'][] = 'masonry';
90 + } else {
91 + $attributes['class'][] = 'layout-flex';
92 + }
93 + if ( $this->attributes['sidebar_list'] == true ) {
94 + $_column_val = 1;
95 + } elseif ( $this->isset( 'column' ) ) {
96 + $_column_val = $this->attributes['column'];
97 + } else {
98 + $_column_val = $this->settings->get( 'column_number' );
99 + }
93 100
94 - $attributes['class'][] = 'docs-col-' . $_column_val;
95 - $attributes['data-column_desktop'] = esc_html( $_column_val );
96 - $attributes['style'] = "--column: $_column_val;";
101 + $attributes['class'][] = 'docs-col-' . $_column_val;
102 + $attributes['data-column_desktop'] = esc_html( $_column_val );
103 + $attributes['style'] = "--column: $_column_val;";
97 104
98 - if ( $this->isset( 'disable_customizer_style', false ) ) {
99 - $attributes['class'][] = 'single-kb';
100 - }
101 - }
105 + if ( $this->isset( 'disable_customizer_style', false ) ) {
106 + $attributes['class'][] = 'single-kb';
107 + }
108 + }
102 109
103 - return $attributes;
104 - }
110 + return $attributes;
111 + }
105 112
106 - public function header_layout_sequence( $sequence, $layout, $widget_type, $args ) {
107 - return ['category_icon', 'category_title', 'category_counts', 'collapse_icon'];
108 - }
113 + public function header_layout_sequence( $sequence, $layout, $widget_type, $args ) {
114 + return [ 'category_icon', 'category_title', 'category_counts', 'collapse_icon' ];
115 + }
109 116
110 - public function render( $atts, $content = null ) {
111 - if ( (bool) $this->attributes['sidebar_list'] ) {
112 - add_filter( 'betterdocs_header_layout_sequence', [$this, 'header_layout_sequence'], 10, 4 );
113 - }
117 + public function render( $atts, $content = null ) {
118 + if ( (bool) $this->attributes['sidebar_list'] ) {
119 + add_filter( 'betterdocs_header_layout_sequence', [ $this, 'header_layout_sequence' ], 10, 4 );
120 + }
114 121
115 - $this->views( 'layouts/base' );
122 + $this->views( 'layouts/base' );
116 123
117 - if ( (bool) $this->attributes['sidebar_list'] ) {
118 - remove_filter( 'betterdocs_header_layout_sequence', [$this, 'header_layout_sequence'], 10 );
119 - }
120 - }
124 + if ( (bool) $this->attributes['sidebar_list'] ) {
125 + remove_filter( 'betterdocs_header_layout_sequence', [ $this, 'header_layout_sequence' ], 10 );
126 + }
127 + }
121 128
122 - public function view_params() {
123 - $exploremore_btn = $this->settings->get( 'exploremore_btn' );
124 - $button_text = $this->settings->get( 'exploremore_btn_txt' );
125 - $category_title_link = isset( $this->attributes['category_title_link'] ) ? $this->attributes['category_title_link'] : '';
129 + public function view_params() {
130 + $exploremore_btn = $this->settings->get( 'exploremore_btn' );
131 + $button_text = $this->settings->get( 'exploremore_btn_txt' );
132 + $category_title_link = isset( $this->attributes['category_title_link'] ) ? $this->attributes['category_title_link'] : '';
126 133
127 - $show_button = false;
128 - if ( $this->attributes['posts_per_page'] == -1 ) {
129 - $show_button = false;
130 - } elseif ( $exploremore_btn && ! is_singular( 'docs' ) && Helper::get_tax() != 'doc_category' && ! is_tax( 'doc_tag' ) ) {
131 - $show_button = true;
132 - }
134 + $show_button = false;
135 + if ( $this->attributes['posts_per_page'] == -1 ) {
136 + $show_button = false;
137 + } elseif ( $exploremore_btn && ! is_singular( 'docs' ) && Helper::get_tax() != 'doc_category' && ! is_tax( 'doc_tag' ) ) {
138 + $show_button = true;
139 + }
133 140
134 - $terms_query = $this->query->terms_query( [
135 - 'taxonomy' => $this->attributes['taxonomy'],
136 - 'multiple_kb' => $this->attributes['multiple_knowledge_base'],
137 - 'kb_slug' => $this->attributes['kb_slug'],
138 - 'terms' => $this->attributes['terms'],
139 - 'order' => $this->attributes['terms_order'],
140 - 'orderby' => $this->attributes['terms_orderby'],
141 - 'nested_subcategory' => $this->attributes['nested_subcategory']
142 - ] );
141 + $terms_query = $this->query->terms_query(
142 + [
143 + 'taxonomy' => $this->attributes['taxonomy'],
144 + 'multiple_kb' => $this->attributes['multiple_knowledge_base'],
145 + 'kb_slug' => $this->attributes['kb_slug'],
146 + 'terms' => $this->attributes['terms'],
147 + 'order' => $this->attributes['terms_order'],
148 + 'orderby' => $this->attributes['terms_orderby'],
149 + 'nested_subcategory' => $this->attributes['nested_subcategory']
150 + ]
151 + );
143 152
144 - if ( $this->attributes['terms_include'] ) {
145 - $terms_query['include'] = $this->attributes['terms_include'];
146 - }
153 + if ( $this->attributes['terms_include'] ) {
154 + $terms_query['include'] = $this->attributes['terms_include'];
155 + }
147 156
148 - if ( $this->attributes['terms_exclude'] ) {
149 - $terms_query['exclude'] = $this->attributes['terms_exclude'];
150 - }
157 + if ( $this->attributes['terms_exclude'] ) {
158 + $terms_query['exclude'] = $this->attributes['terms_exclude'];
159 + }
151 160
152 - if ( $this->attributes['terms_offset'] ) {
153 - $terms_query['offset'] = (int) $this->attributes['terms_offset'];
154 - }
161 + if ( $this->attributes['terms_offset'] ) {
162 + $terms_query['offset'] = (int) $this->attributes['terms_offset'];
163 + }
155 164
156 - $inner_wrapper_attr = $this->generate_attributes();
165 + $inner_wrapper_attr = $this->generate_attributes();
157 166
158 - $docs_query = [
159 - 'orderby' => $this->attributes['orderby'],
160 - 'order' => $this->attributes['order'],
161 - 'posts_per_page' => $this->attributes['posts_per_page']
162 - ];
167 + $docs_query = [
168 + 'orderby' => $this->attributes['orderby'],
169 + 'order' => $this->attributes['order'],
170 + 'posts_per_page' => $this->attributes['posts_per_page']
171 + ];
163 172
164 - return [
165 - 'wrapper_attr' => ['class' => ['betterdocs-category-grid-wrapper']],
166 - 'inner_wrapper_attr' => $inner_wrapper_attr,
167 - 'layout' => 'default',
168 - 'widget_type' => 'category-grid',
173 + /**
174 + * Add This Attribute When Using Outside Betterdocs Templates Only
175 + */
176 + if ( $this->attributes['multiple_knowledge_base'] && ( ! empty( $this->attributes['kb_slug'] ) ) && ( ! betterdocs()->helper->is_templates() ) ) {
177 + $inner_wrapper_attr['data-mkb-slug'] = $this->attributes['kb_slug'];
178 + }
169 179
170 - 'terms_query_args' => $terms_query,
171 - 'docs_query_args' => $docs_query,
172 - 'nested_docs_query_args' => $docs_query,
173 -
174 - 'show_header' => true,
175 - 'show_list' => true,
176 - 'show_title' => true,
177 - 'show_button' => $show_button,
178 - 'button_text' => $button_text,
179 - 'show_button_icon' => true,
180 - 'button_icon_position' => true,
181 - 'button_icon' => true,
182 - 'category_title_link' => $category_title_link
183 - ];
184 - }
180 + return [
181 + 'wrapper_attr' => [ 'class' => [ 'betterdocs-category-grid-wrapper' ] ],
182 + 'inner_wrapper_attr' => $inner_wrapper_attr,
183 + 'layout' => 'default',
184 + 'widget_type' => 'category-grid',
185 + 'terms_query_args' => $terms_query,
186 + 'docs_query_args' => $docs_query,
187 + 'nested_docs_query_args' => $docs_query,
188 + 'list_icon_name' => $this->attributes['list_icon_name'] == 'list' ? 'list' : [ 'value' => $this->attributes['list_icon_name'] ],
189 + 'show_header' => true,
190 + 'show_list' => true,
191 + 'show_title' => true,
192 + 'show_button' => $show_button,
193 + 'button_text' => $button_text,
194 + 'show_button_icon' => true,
195 + 'button_icon_position' => true,
196 + 'button_icon' => true,
197 + 'category_title_link' => $category_title_link,
198 + 'layout_type' => $this->attributes['layout_type'],
199 + 'list_icon_url' => $this->attributes['list_icon_url'],
200 + 'sidebar_layout' => $this->attributes['sidebar_layout']
201 + ];
202 + }
185 203 }