PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.4.0
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.4.0
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 / CategoryGridThree.php

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

150 lines 4.7 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
5 use WPDeveloper\BetterDocs\Utils\Helper;
6 use WPDeveloper\BetterDocs\Core\Shortcode;
7
8 class CategoryGridThree extends Shortcode {
9 protected $layout_class = 'layout-3';
10
11 public function get_name() {
12 return 'betterdocs_category_grid_3';
13 }
14
15 public function get_style_depends() {
16 return [ 'betterdocs-category-grid' ];
17 }
18
19 public function get_script_depends() {
20 return [ 'betterdocs-category-grid' ];
21 }
22
23 /**
24 * Summary of default_attributes
25 * @return array
26 */
27 public function default_attributes() {
28 return [
29 'sidebar_list' => false,
30 'taxonomy' => 'doc_category',
31 'show_icon' => true,
32 'category_icon' => 'folder',
33 'masonry' => false,
34 'posts_per_page' => $this->settings->get( 'posts_number', 0 ),
35 'orderby' => $this->settings->get( 'alphabetically_order_post', 'betterdocs_order' ),
36 'order' => $this->settings->get( 'docs_order', 'ASC' ),
37 'show_count' => false,
38 'count_suffix' => '',
39 'count_suffix_singular' => '',
40 'column' => 4, //$this->settings->get( 'column_number' ),
41 'terms' => '',
42 'terms_orderby' => '',
43 'terms_order' => '',
44 'terms_include' => '',
45 'terms_exclude' => '',
46 'terms_offset' => '',
47 'kb_slug' => '',
48 'multiple_knowledge_base' => false,
49 'disable_customizer_style' => false,
50 'title_tag' => 'h2',
51 'category_title_link' => true,
52 'layout_type' => '',
53 'list_icon_url' => false,
54 ];
55 }
56
57 public function generate_attributes() {
58 $attributes = [
59 'class' => [
60 'betterdocs-category-grid-inner-wrapper',
61 $this->layout_class
62 ]
63 ];
64
65 if ( ! is_singular( 'docs' ) && ! is_tax( 'doc_category' ) && ! is_tax( 'doc_tag' ) ) {
66 $attributes['class'][] = 'layout-flex';
67
68 if ( $this->isset( 'column' ) ) {
69 $_column_val = $this->attributes['column'];
70 } else {
71 $_column_val = $this->settings->get( 'column_number' );
72 }
73
74 $attributes['class'][] = 'docs-col-' . $_column_val;
75 $attributes['data-column_desktop'] = esc_html( $_column_val );
76 $attributes['style'] = "--column: $_column_val;";
77 }
78
79 return $attributes;
80 }
81
82 public function header_layout_sequence( $sequence, $layout, $widget_type, $args ) {
83 return [ 'category_icon', 'category_title' ];
84 }
85
86 public function render( $atts, $content = null ) {
87 if ( (bool) $this->attributes['sidebar_list'] ) {
88 add_filter( 'betterdocs_header_layout_sequence', [ $this, 'header_layout_sequence' ], 10, 4 );
89 }
90
91 $this->views( 'layouts/base' );
92
93 if ( (bool) $this->attributes['sidebar_list'] ) {
94 remove_filter( 'betterdocs_header_layout_sequence', [ $this, 'header_layout_sequence' ], 10 );
95 }
96 }
97
98 public function view_params() {
99 $category_title_link = isset( $this->attributes['category_title_link'] ) ? $this->attributes['category_title_link'] : '';
100
101 $terms_query = $this->query->terms_query(
102 [
103 'taxonomy' => $this->attributes['taxonomy'],
104 'multiple_kb' => $this->attributes['multiple_knowledge_base'],
105 'kb_slug' => $this->attributes['kb_slug'],
106 'terms' => $this->attributes['terms'],
107 'order' => $this->attributes['terms_order'],
108 'orderby' => $this->attributes['terms_orderby']
109 ]
110 );
111
112 if ( $this->attributes['terms_include'] ) {
113 $terms_query['include'] = $this->attributes['terms_include'];
114 }
115
116 if ( $this->attributes['terms_exclude'] ) {
117 $terms_query['exclude'] = $this->attributes['terms_exclude'];
118 }
119
120 if ( $this->attributes['terms_offset'] ) {
121 $terms_query['offset'] = (int) $this->attributes['terms_offset'];
122 }
123
124 $inner_wrapper_attr = $this->generate_attributes();
125
126 $docs_query = [
127 'orderby' => $this->attributes['orderby'],
128 'order' => $this->attributes['order'],
129 'posts_per_page' => $this->attributes['posts_per_page']
130 ];
131
132 return [
133 'wrapper_attr' => [ 'class' => [ 'betterdocs-category-grid-three-wrapper' ] ],
134 'inner_wrapper_attr' => $inner_wrapper_attr,
135 'layout' => 'layout-3',
136 'widget_type' => 'category-grid',
137 'terms_query_args' => $terms_query,
138 'docs_query_args' => $docs_query,
139 'show_header' => true,
140 'show_list' => true,
141 'show_title' => true,
142 'show_button' => false,
143 'button_text' => '',
144 'category_title_link' => $category_title_link,
145 'layout_type' => $this->attributes['layout_type'],
146 'list_icon_url' => $this->attributes['list_icon_url'],
147 ];
148 }
149 }
150