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/Shortcodes/CategoryBox.php +98 -93 3.5.14.9.2 View file →
@@ -1,121 +1,126 @@
1 1 <?php
2 +// phpcs:disable WordPress.DB.SlowDBQuery.slow_db_query_meta_key -- ordering by user-assigned meta is required UX.
3 +namespace WPDeveloper\BetterDocs\Shortcodes;
2 4
3 -namespace WPDeveloper\BetterDocs\Shortcodes;
5 +if ( ! defined( 'ABSPATH' ) ) {
6 + exit;
7 +}
4 8
9 +
5 10 use WPDeveloper\BetterDocs\Core\Shortcode;
6 11
7 12 class CategoryBox extends Shortcode {
8 - protected $layout_class = 'layout-1';
9 - protected $deprecated_attributes = [
10 - 'category' => 'taxonomy',
11 - 'icon' => 'show_icon'
12 - ];
13 + protected $layout_class = 'layout-1';
14 + protected $deprecated_attributes = [
15 + 'category' => 'taxonomy',
16 + 'icon' => 'show_icon'
17 + ];
13 18
14 - public function get_name() {
15 - return 'betterdocs_category_box';
16 - }
19 + public function get_name() {
20 + return 'betterdocs_category_box';
21 + }
17 22
18 - public function get_style_depends(){
19 - return [ 'betterdocs-category-box' ];
20 - }
23 + public function get_style_depends() {
24 + return [ 'betterdocs-category-box' ];
25 + }
21 26
22 - public function default_attributes() {
23 - return [
24 - 'taxonomy' => 'doc_category',
25 - 'parent' => 0,
26 - 'meta_key' => '',
27 - 'layout' => '',
28 - 'column' => $this->settings->get( 'column_number', 3 ),
29 - 'orderby' => $this->settings->get( 'alphabetically_order_post', 'title' ),
30 - 'nested_subcategory' => (bool) $this->settings->get( 'nested_subcategory', false ),
31 - 'terms' => '',
32 - 'terms_order' => $this->settings->get( 'terms_order', 'ASC' ),
33 - 'terms_orderby' => $this->settings->get( 'terms_orderby', 'betterdocs_order' ),
34 - 'show_icon' => true,
35 - 'kb_slug' => '',
36 - 'title_tag' => 'h2',
37 - 'multiple_knowledge_base' => false,
38 - 'disable_customizer_style' => false,
39 - 'border_bottom' => false,
40 - 'show_description' => (bool) $this->customizer->get( 'betterdocs_doc_page_cat_desc', false )
41 - ];
42 - }
27 + public function default_attributes() {
28 + return [
29 + 'taxonomy' => 'doc_category',
30 + 'parent' => 0,
31 + 'meta_key' => '',
32 + 'layout' => '',
33 + 'column' => $this->settings->get( 'column_number', 3 ),
34 + 'orderby' => $this->settings->get( 'alphabetically_order_post', 'title' ),
35 + 'nested_subcategory' => (bool) $this->settings->get( 'nested_subcategory', false ),
36 + 'terms' => '',
37 + 'terms_order' => $this->settings->get( 'terms_order', 'ASC' ),
38 + 'terms_orderby' => $this->settings->get( 'terms_orderby', 'betterdocs_order' ),
39 + 'show_icon' => true,
40 + 'kb_slug' => '',
41 + 'title_tag' => 'h2',
42 + 'multiple_knowledge_base' => false,
43 + 'disable_customizer_style' => false,
44 + 'border_bottom' => false,
45 + 'show_description' => (bool) $this->customizer->get( 'betterdocs_doc_page_cat_desc', false )
46 + ];
47 + }
43 48
44 - public function header_sequence( $_layout_sequence, $layout, $widget_type, $_defined_vars ) {
45 - return ['category_icon', 'category_title', 'category_description', 'category_counts'];
46 - }
49 + public function header_sequence( $_layout_sequence, $layout, $widget_type, $_defined_vars ) {
50 + return [ 'category_icon', 'category_title', 'category_description', 'category_counts' ];
51 + }
47 52
48 - public function render( $atts, $content = null ) {
49 - add_filter( 'betterdocs_header_layout_sequence', [$this, 'header_sequence'], 10, 4 );
53 + public function render( $atts, $content = null ) {
54 + add_filter( 'betterdocs_header_layout_sequence', [ $this, 'header_sequence' ], 10, 4 );
50 55
51 - $this->views( 'layouts/base' );
56 + $this->views( 'layouts/base' );
52 57
53 - remove_filter( 'betterdocs_header_layout_sequence', [$this, 'header_sequence'], 10 );
54 - }
58 + remove_filter( 'betterdocs_header_layout_sequence', [ $this, 'header_sequence' ], 10 );
59 + }
55 60
56 - public function view_params() {
57 - $classes = [ 'betterdocs-category-box-inner-wrapper ash-bg layout-flex', $this->layout_class ];
58 - $styles = '';
61 + public function view_params() {
62 + $classes = [ 'betterdocs-category-box-inner-wrapper', $this->layout_class, ( $this->layout_class != 'layout-4' ? 'layout-flex ash-bg' : '' ) ];
63 + $styles = '';
59 64
60 - if ( $this->isset( 'column' ) ) {
61 - $_c = intval( $this->attributes['column'] );
62 - $classes[] = 'docs-col-' . $_c;
63 - $styles .= "--column: $_c;";
64 - }
65 + if ( $this->isset( 'column' ) ) {
66 + $_c = intval( $this->attributes['column'] );
67 + $classes[] = 'docs-col-' . $_c;
68 + $styles .= "--column: $_c;";
69 + }
65 70
66 - if ( $this->isset( 'border_bottom', true ) ) {
67 - $classes[] = 'border-bottom';
68 - }
71 + if ( $this->isset( 'border_bottom', true ) ) {
72 + $classes[] = 'border-bottom';
73 + }
69 74
70 - if ( $this->isset( 'disable_customizer_style', false ) ) {
71 - $classes[] = 'single-kb';
72 - }
75 + if ( $this->isset( 'disable_customizer_style', false ) ) {
76 + $classes[] = 'single-kb';
77 + }
73 78
74 - $_query_args = [
75 - 'terms' => $this->attributes['terms'],
76 - 'order' => $this->attributes['terms_order'],
77 - 'orderby' => $this->attributes['terms_orderby'],
78 - 'multiple_kb' => $this->attributes['multiple_knowledge_base'],
79 - 'kb_slug' => $this->attributes['kb_slug'],
80 - 'nested_subcategory' => (bool) $this->attributes['nested_subcategory']
81 - ];
79 + $_query_args = [
80 + 'terms' => $this->attributes['terms'],
81 + 'order' => $this->attributes['terms_order'],
82 + 'orderby' => $this->attributes['terms_orderby'],
83 + 'multiple_kb' => ( $this->attributes['multiple_knowledge_base'] && ! empty( $this->attributes['kb_slug'] ) ) ? true : false,
84 + 'kb_slug' => $this->attributes['kb_slug'],
85 + 'nested_subcategory' => (bool) $this->attributes['nested_subcategory']
86 + ];
82 87
83 - if ( $this->isset( 'taxonomy' ) ) {
84 - $_query_args['taxonomy'] = $this->attributes['taxonomy'];
85 - }
88 + if ( $this->isset( 'taxonomy' ) ) {
89 + $_query_args['taxonomy'] = $this->attributes['taxonomy'];
90 + }
86 91
87 - // if ( $this->isset( 'parent', 0 ) ) {
88 - // $_query_args['parent'] = $this->attributes['parent'];
89 - // }
92 + // if ( $this->isset( 'parent', 0 ) ) {
93 + // $_query_args['parent'] = $this->attributes['parent'];
94 + // }
90 95
91 - if ( $this->isset( 'meta_key' ) ) {
92 - $_query_args['meta_key'] = $this->attributes['meta_key'];
93 - }
96 + if ( $this->isset( 'meta_key' ) ) {
97 + $_query_args['meta_key'] = $this->attributes['meta_key'];
98 + }
94 99
95 - $terms_query = $this->query->terms_query( $_query_args );
100 + $terms_query = $this->query->terms_query( $_query_args );
96 101
97 - $show_count = (bool) $this->settings->get( 'post_count', false );
98 - $singular_text = $this->settings->get( 'count_text_singular', __( 'article', 'betterdocs' ) );
99 - $plural_text = $this->settings->get( 'count_text', __( 'articles', 'betterdocs' ) );
102 + $show_count = (bool) $this->settings->get( 'post_count', false );
103 + $singular_text = $this->settings->get( 'count_text_singular' );
104 + $plural_text = $this->settings->get( 'count_text' );
100 105
101 - $inner_wrapper_attr = [
102 - 'class' => $classes,
103 - 'style' => $styles,
104 - ];
105 -
106 + $inner_wrapper_attr = [
107 + 'class' => $classes,
108 + 'style' => $styles,
109 + ];
106 110
107 - return [
108 - 'wrapper_attr' => ['class' => ['betterdocs-category-box-wrapper']],
109 - 'inner_wrapper_attr' => $inner_wrapper_attr,
110 - 'layout' => 'default',
111 - 'widget_type' => 'category-box',
111 + return [
112 + 'wrapper_attr' => [ 'class' => [ 'betterdocs-category-box-wrapper' ] ],
113 + 'inner_wrapper_attr' => $inner_wrapper_attr,
114 + 'layout' => 'default',
115 + 'widget_type' => 'category-box',
112 116
113 - 'terms_query_args' => $terms_query,
117 + 'terms_query_args' => $terms_query,
114 118
115 - 'show_title' => true,
116 - 'show_count' => $show_count,
117 - 'count_suffix_singular' => $singular_text,
118 - 'count_suffix' => $plural_text
119 - ];
120 - }
119 + 'show_title' => true,
120 + 'show_count' => $show_count,
121 + 'count_suffix_singular' => $singular_text,
122 + 'count_suffix' => $plural_text,
123 + 'title_tag' => $this->attributes['title_tag']
124 + ];
125 + }
121 126 }