PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 3.8.1
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v3.8.1
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 3.5.2 All 199 releases
betterdocs / includes / Shortcodes / CategoryBoxThree.php

CategoryBoxThree.php in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 3.8.1, at includes/Shortcodes/CategoryBoxThree.php

109 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPDeveloper\BetterDocs\Shortcodes;
4 use WPDeveloper\BetterDocs\Shortcodes\CategoryBox;
5
6 class CategoryBoxThree extends CategoryBox {
7 protected $layout_class = 'layout-4';
8
9 /**
10 * Summary of get_id
11 * @return string
12 */
13 public function get_name() {
14 return 'betterdocs_category_box_3';
15 }
16
17 /**
18 * Summary of default_attributes
19 * @return array
20 */
21 public function default_attributes() {
22 return [
23 'taxonomy' => 'doc_category',
24 'column' => $this->settings->get( 'column_number', 4 ),
25 'nested_subcategory' => $this->settings->get( 'nested_subcategory', false ),
26 'terms' => '',
27 'terms_order' => $this->settings->get( 'terms_order', 'ASC' ),
28 'terms_orderby' => $this->settings->get( 'terms_orderby', 'betterdocs_order' ),
29 'kb_slug' => '',
30 'multiple_knowledge_base' => false,
31 'disable_customizer_style' => false,
32 'title_tag' => 'h2',
33 'show_description' => false,
34 'show_icon' => true,
35 'category_icon' => 'folder',
36 'last_update' => '',
37 ];
38 }
39
40 public function header_sequence( $_layout_sequence, $layout, $widget_type, $_defined_vars ) {
41 $_new_layout_sequence = ['category_icon', [
42 'class' => 'betterdocs-category-title-counts',
43 'sequence' => ['category_title', 'category_description', 'sub_category_counts', 'last_update']
44 ]];
45
46 return $_new_layout_sequence;
47 }
48
49 /**
50 * Summary of render
51 *
52 * @param mixed $atts
53 * @param mixed $content
54 * @return mixed
55 */
56 public function render( $atts, $content = null ) {
57 parent::render( $atts, $content );
58 }
59
60 public function view_params() {
61 $parent_params = parent::view_params();
62 $query_arg = $parent_params['terms_query_args'];
63
64 $term_count = count( get_terms( $query_arg ) );
65 $styles = '';
66
67 if ( $this->isset( 'column' ) ) {
68 $_c = intval( $this->attributes['column'] );
69 } else {
70 $_c = 4;
71 }
72
73 if ( is_tax( 'doc_category' ) && ! $this->isset( 'column' ) ) {
74 $_c = 3;
75 }
76
77 $styles .= "--column: $_c;";
78 $styles .= "--count: $term_count;";
79 $reminder = $term_count % $_c;
80 $styles .= "--reminder: $reminder;";
81
82 $classes = [ 'betterdocs-categories-folder', $this->layout_class ];
83
84 if ( $this->isset( 'border_bottom', true ) ) {
85 $classes[] = 'border-bottom';
86 }
87
88 if ( $this->isset( 'disable_customizer_style', false ) ) {
89 $classes[] = 'single-kb';
90 }
91
92 $inner_wrapper_attr = [
93 'class' => $classes,
94 'style' => $styles,
95 ];
96
97 $_view_params = [
98 'layout' => 'layout-4',
99 'reminder' => $reminder,
100 'column' => $_c,
101 'total_terms' => $term_count,
102 'inner_wrapper_attr' => $inner_wrapper_attr,
103 'show_icon' => $this->attributes['show_icon']
104 ];
105
106 return $this->merge( $parent_params, $_view_params );
107 }
108 }
109