PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 3.5.3
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v3.5.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 3.5.1 All 200 releases
← All changes | includes/Shortcodes/CategoryBox.php +93 -98 4.9.23.5.3 View file →
@@ -1,126 +1,121 @@
1 1 <?php
2 -// phpcs:disable WordPress.DB.SlowDBQuery.slow_db_query_meta_key -- ordering by user-assigned meta is required UX.
2 +
3 3 namespace WPDeveloper\BetterDocs\Shortcodes;
4 4
5 -if ( ! defined( 'ABSPATH' ) ) {
6 - exit;
7 -}
8 -
9 -
10 5 use WPDeveloper\BetterDocs\Core\Shortcode;
11 6
12 7 class CategoryBox extends Shortcode {
13 - protected $layout_class = 'layout-1';
14 - protected $deprecated_attributes = [
15 - 'category' => 'taxonomy',
16 - 'icon' => 'show_icon'
17 - ];
8 + protected $layout_class = 'layout-1';
9 + protected $deprecated_attributes = [
10 + 'category' => 'taxonomy',
11 + 'icon' => 'show_icon'
12 + ];
18 13
19 - public function get_name() {
20 - return 'betterdocs_category_box';
21 - }
14 + public function get_name() {
15 + return 'betterdocs_category_box';
16 + }
22 17
23 - public function get_style_depends() {
24 - return [ 'betterdocs-category-box' ];
25 - }
18 + public function get_style_depends(){
19 + return [ 'betterdocs-category-box' ];
20 + }
26 21
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 - }
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 + }
48 43
49 - public function header_sequence( $_layout_sequence, $layout, $widget_type, $_defined_vars ) {
50 - return [ 'category_icon', 'category_title', 'category_description', 'category_counts' ];
51 - }
44 + public function header_sequence( $_layout_sequence, $layout, $widget_type, $_defined_vars ) {
45 + return ['category_icon', 'category_title', 'category_description', 'category_counts'];
46 + }
52 47
53 - public function render( $atts, $content = null ) {
54 - add_filter( 'betterdocs_header_layout_sequence', [ $this, 'header_sequence' ], 10, 4 );
48 + public function render( $atts, $content = null ) {
49 + add_filter( 'betterdocs_header_layout_sequence', [$this, 'header_sequence'], 10, 4 );
55 50
56 - $this->views( 'layouts/base' );
51 + $this->views( 'layouts/base' );
57 52
58 - remove_filter( 'betterdocs_header_layout_sequence', [ $this, 'header_sequence' ], 10 );
59 - }
53 + remove_filter( 'betterdocs_header_layout_sequence', [$this, 'header_sequence'], 10 );
54 + }
60 55
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 = '';
56 + public function view_params() {
57 + $classes = [ 'betterdocs-category-box-inner-wrapper ash-bg layout-flex', $this->layout_class ];
58 + $styles = '';
64 59
65 - if ( $this->isset( 'column' ) ) {
66 - $_c = intval( $this->attributes['column'] );
67 - $classes[] = 'docs-col-' . $_c;
68 - $styles .= "--column: $_c;";
69 - }
60 + if ( $this->isset( 'column' ) ) {
61 + $_c = intval( $this->attributes['column'] );
62 + $classes[] = 'docs-col-' . $_c;
63 + $styles .= "--column: $_c;";
64 + }
70 65
71 - if ( $this->isset( 'border_bottom', true ) ) {
72 - $classes[] = 'border-bottom';
73 - }
66 + if ( $this->isset( 'border_bottom', true ) ) {
67 + $classes[] = 'border-bottom';
68 + }
74 69
75 - if ( $this->isset( 'disable_customizer_style', false ) ) {
76 - $classes[] = 'single-kb';
77 - }
70 + if ( $this->isset( 'disable_customizer_style', false ) ) {
71 + $classes[] = 'single-kb';
72 + }
78 73
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 - ];
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 + ];
87 82
88 - if ( $this->isset( 'taxonomy' ) ) {
89 - $_query_args['taxonomy'] = $this->attributes['taxonomy'];
90 - }
83 + if ( $this->isset( 'taxonomy' ) ) {
84 + $_query_args['taxonomy'] = $this->attributes['taxonomy'];
85 + }
91 86
92 - // if ( $this->isset( 'parent', 0 ) ) {
93 - // $_query_args['parent'] = $this->attributes['parent'];
94 - // }
87 + // if ( $this->isset( 'parent', 0 ) ) {
88 + // $_query_args['parent'] = $this->attributes['parent'];
89 + // }
95 90
96 - if ( $this->isset( 'meta_key' ) ) {
97 - $_query_args['meta_key'] = $this->attributes['meta_key'];
98 - }
91 + if ( $this->isset( 'meta_key' ) ) {
92 + $_query_args['meta_key'] = $this->attributes['meta_key'];
93 + }
99 94
100 - $terms_query = $this->query->terms_query( $_query_args );
95 + $terms_query = $this->query->terms_query( $_query_args );
101 96
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' );
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' ) );
105 100
106 - $inner_wrapper_attr = [
107 - 'class' => $classes,
108 - 'style' => $styles,
109 - ];
101 + $inner_wrapper_attr = [
102 + 'class' => $classes,
103 + 'style' => $styles,
104 + ];
105 +
110 106
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',
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',
116 112
117 - 'terms_query_args' => $terms_query,
113 + 'terms_query_args' => $terms_query,
118 114
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 - }
115 + 'show_title' => true,
116 + 'show_count' => $show_count,
117 + 'count_suffix_singular' => $singular_text,
118 + 'count_suffix' => $plural_text
119 + ];
120 + }
126 121 }