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.5 4.9.4 4.9.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 All 203 releases
betterdocs / includes / Editors / Elementor / Widget / ArchiveList.php

ArchiveList.php in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 3.5.3, at includes/Editors/Elementor/Widget/ArchiveList.php

501 lines 17.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace WPDeveloper\BetterDocs\Editors\Elementor\Widget;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit; // Exit if accessed directly
6 }
7
8 use Elementor\Controls_Manager;
9 use Elementor\Group_Control_Typography;
10 use ElementorPro\Base\Base_Widget_Trait;
11 use WPDeveloper\BetterDocs\Editors\Elementor\BaseWidget;
12
13 class ArchiveList extends BaseWidget {
14
15 use Base_Widget_Trait;
16
17 public function get_name() {
18 return 'betterdocs-category-archive-list';
19 }
20
21 public function get_title() {
22 return __( 'Doc Category Archive List', 'betterdocs' );
23 }
24
25 public function get_icon() {
26 return 'eicon-post-list betterdocs-eicon-post-list';
27 }
28
29 public function get_categories() {
30 return ['betterdocs-elements', 'docs-archive'];
31 }
32
33 public function get_style_depends() {
34 return ['betterdocs-el-articles-list'];
35 }
36
37 public function get_keywords() {
38 return ['betterdocs-elements', 'title', 'heading', 'betterdocs', 'docs', 'doc-category', 'doc-category-archive'];
39 }
40
41 public function get_custom_help_url() {
42 return 'https://betterdocs.co/docs/docs-archive-in-elementor/';
43 }
44
45 protected function register_controls() {
46 $this->section_content();
47 $this->list_settings();
48 $this->subcat_list_settings();
49 }
50
51 public function section_content() {
52 $this->start_controls_section(
53 'section_title',
54 [
55 'label' => __( 'Controls', 'betterdocs' )
56 ]
57 );
58
59 $this->add_control(
60 'alphabetic_order',
61 [
62 'label' => __( 'Order By', 'betterdocs' ),
63 'type' => Controls_Manager::SELECT,
64 'options' => [
65 'none' => __( 'No order', 'betterdocs' ),
66 'name' => __( 'Name', 'betterdocs' ),
67 'slug' => __( 'Slug', 'betterdocs' ),
68 'term_group' => __( 'Term Group', 'betterdocs' ),
69 'term_id' => __( 'Term ID', 'betterdocs' ),
70 'id' => __( 'ID', 'betterdocs' ),
71 'description' => __( 'Description', 'betterdocs' ),
72 'parent' => __( 'Parent', 'betterdocs' ),
73 'betterdocs_order' => __( 'BetterDocs Order', 'betterdocs' )
74 ],
75 'default' => 'name'
76 ]
77 );
78
79 $this->add_control(
80 'order',
81 [
82 'label' => __( 'Order', 'betterdocs' ),
83 'type' => Controls_Manager::SELECT,
84 'options' => [
85 'asc' => 'Ascending',
86 'desc' => 'Descending'
87 ],
88 'default' => 'asc'
89
90 ]
91 );
92
93 $this->add_control(
94 'nested_subcategory',
95 [
96 'label' => __( 'Nested Subcategory', 'betterdocs' ),
97 'type' => Controls_Manager::SWITCHER,
98 'label_on' => __( 'Show', 'betterdocs' ),
99 'label_off' => __( 'Hide', 'betterdocs' ),
100 'return_value' => '1',
101 'default' => '1'
102 ]
103 );
104
105 $this->add_control(
106 'important_note',
107 [
108 'type' => Controls_Manager::RAW_HTML,
109 'raw' => __( 'Note: This is the preview only for Elementor Editor. You will see the real view in the archive page itself.', 'betterdocs' ),
110 'content_classes' => 'betterdocs-elementor-note elementor-panel-alert elementor-panel-alert-info'
111 ]
112 );
113
114 $this->end_controls_section();
115 }
116
117 public function list_settings() {
118 /**
119 * ----------------------------------------------------------
120 * Section: List Settinggs
121 * ----------------------------------------------------------
122 */
123 $this->start_controls_section(
124 'section_article_settings',
125 [
126 'label' => __( 'Category List', 'betterdocs' ),
127 'tab' => Controls_Manager::TAB_STYLE
128 ]
129 );
130
131 $this->add_group_control(
132 Group_Control_Typography::get_type(),
133 [
134 'name' => 'list_item_typography',
135 'selector' => '{{WRAPPER}} .betterdocs-articles-list li a'
136 ]
137 );
138
139 $this->add_control(
140 'list_word_wrap',
141 [
142 'label' => __( 'Word Wrap', 'betterdocs' ),
143 'type' => Controls_Manager::SELECT2,
144 'multiple' => false,
145 'options' => [
146 'normal' => 'normal',
147 'break-word' => 'break-word',
148 'initial' => 'initial',
149 'inherit' => 'inherit'
150 ],
151 'default' => 'normal',
152 'selectors' => [
153 '{{WRAPPER}} .betterdocs-articles-list li a' => 'word-wrap: {{VALUE}};'
154 ]
155 ]
156 );
157
158 $this->add_control(
159 'list_color',
160 [
161 'label' => esc_html__( 'Color', 'betterdocs' ),
162 'type' => Controls_Manager::COLOR,
163 'selectors' => [
164 '{{WRAPPER}} .betterdocs-articles-list li a' => 'color: {{VALUE}};'
165 ]
166 ]
167 );
168
169 $this->add_control(
170 'list_hover_color',
171 [
172 'label' => esc_html__( 'Hover Color', 'betterdocs' ),
173 'type' => Controls_Manager::COLOR,
174 'selectors' => [
175 '{{WRAPPER}} .betterdocs-articles-list li a:hover' => 'color: {{VALUE}};'
176 ]
177 ]
178 );
179
180 $this->add_responsive_control(
181 'list_margin',
182 [
183 'label' => esc_html__( 'List Item Spacing', 'betterdocs' ),
184 'type' => Controls_Manager::DIMENSIONS,
185 'size_units' => ['px', 'em', '%'],
186 'selectors' => [
187 '{{WRAPPER}} .betterdocs-articles-list li' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
188 ]
189 ]
190 );
191
192 $this->add_control(
193 'icon_settings_heading',
194 [
195 'label' => esc_html__( 'List Icon', 'betterdocs' ),
196 'type' => Controls_Manager::HEADING,
197 'separator' => 'before'
198 ]
199 );
200
201 $this->add_control(
202 'list_icon_color',
203 [
204 'label' => esc_html__( 'Color', 'betterdocs' ),
205 'type' => Controls_Manager::COLOR,
206 'selectors' => [
207 '{{WRAPPER}} .betterdocs-articles-list li svg' => 'fill: {{VALUE}};'
208 ]
209 ]
210 );
211
212 $this->add_responsive_control(
213 'list_icon_size',
214 [
215 'label' => __( 'Size', 'betterdocs' ),
216 'type' => Controls_Manager::SLIDER,
217 'size_units' => ['px', '%', 'em'],
218 'range' => [
219 '%' => [
220 'max' => 100,
221 'step' => 1
222 ]
223 ],
224 'selectors' => [
225 '{{WRAPPER}} .betterdocs-articles-list li svg' => 'width: {{SIZE}}{{UNIT}};',
226 '{{WRAPPER}} .betterdocs-articles-list .betterdocs-nested-category-title svg' => 'font-size: {{SIZE}}{{UNIT}};'
227 ]
228 ]
229 );
230
231 $this->add_responsive_control(
232 'list_icon_spacing',
233 [
234 'label' => esc_html__( 'Spacing', 'betterdocs' ),
235 'type' => Controls_Manager::DIMENSIONS,
236 'size_units' => ['px', 'em', '%'],
237 'selectors' => [
238 '{{WRAPPER}} .betterdocs-articles-list li svg' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
239 ]
240 ]
241 );
242
243 $this->end_controls_section(); # end of 'Column Settings'
244 }
245
246 public function subcat_list_settings() {
247 /**
248 * ----------------------------------------------------------
249 * Section: List Settinggs
250 * ----------------------------------------------------------
251 */
252 $this->start_controls_section(
253 'section_sub_category_settings',
254 [
255 'label' => __( 'Sub Category', 'betterdocs' ),
256 'tab' => Controls_Manager::TAB_STYLE
257 ]
258 );
259
260 $this->add_control(
261 'subcat_color',
262 [
263 'label' => esc_html__( 'Color', 'betterdocs' ),
264 'type' => Controls_Manager::COLOR,
265 'default' => '#3f5876',
266 'selectors' => [
267 '{{WRAPPER}} .betterdocs-articles-list li .betterdocs-nested-category-title > a' => 'color: {{VALUE}};'
268 ]
269 ]
270 );
271
272 $this->add_control(
273 'subcat_hover_color',
274 [
275 'label' => esc_html__( 'Hover Color', 'betterdocs' ),
276 'type' => Controls_Manager::COLOR,
277 'default' => '#3f5876',
278 'selectors' => [
279 '{{WRAPPER}} .betterdocs-articles-list li .betterdocs-nested-category-title > a:hover' => 'color: {{VALUE}};'
280 ]
281 ]
282 );
283
284 $this->add_responsive_control(
285 'subcat_font_size',
286 [
287 'label' => __( 'Font Size', 'betterdocs' ),
288 'type' => Controls_Manager::SLIDER,
289 'size_units' => ['px', '%', 'em'],
290 'range' => [
291 '%' => [
292 'max' => 100,
293 'step' => 1
294 ]
295 ],
296 'selectors' => [
297 '{{WRAPPER}} .betterdocs-articles-list li .betterdocs-nested-category-title > a' => 'font-size: {{SIZE}}{{UNIT}};'
298 ]
299 ]
300 );
301
302 $this->add_control(
303 'subcat_icon_color',
304 [
305 'label' => esc_html__( 'Icon Color', 'betterdocs' ),
306 'type' => Controls_Manager::COLOR,
307 'default' => '#3f5876',
308 'selectors' => [
309 '{{WRAPPER}} .betterdocs-articles-list li .betterdocs-nested-category-title > svg.toggle-arrow' => 'fill: {{VALUE}};'
310 ]
311 ]
312 );
313
314 $this->add_responsive_control(
315 'subcat_icon_size',
316 [
317 'label' => __( 'Icon Size', 'betterdocs' ),
318 'type' => Controls_Manager::SLIDER,
319 'size_units' => ['px', '%', 'em'],
320 'range' => [
321 '%' => [
322 'max' => 100,
323 'step' => 1
324 ]
325 ],
326 'selectors' => [
327 '{{WRAPPER}} .betterdocs-articles-list li .betterdocs-nested-category-title > svg.toggle-arrow' => 'font-size: {{SIZE}}{{UNIT}}; width: auto;'
328 ]
329 ]
330 );
331
332 $this->add_control(
333 'subcategory_list_heading',
334 [
335 'label' => esc_html__( 'Subcategory List', 'betterdocs' ),
336 'type' => Controls_Manager::HEADING,
337 'separator' => 'before'
338 ]
339 );
340
341 $this->add_group_control(
342 Group_Control_Typography::get_type(),
343 [
344 'name' => 'subcat_list_item_typography',
345 'selector' => '{{WRAPPER}} .betterdocs-articles-list .betterdocs-nested-category-list li:not(.betterdocs-nested-category-wrapper) a'
346 ]
347 );
348
349 $this->add_control(
350 'subcat_list_word_wrap',
351 [
352 'label' => __( 'Word Wrap', 'betterdocs' ),
353 'type' => Controls_Manager::SELECT2,
354 'multiple' => false,
355 'options' => [
356 'normal' => 'normal',
357 'break-word' => 'break-word',
358 'initial' => 'initial',
359 'inherit' => 'inherit'
360 ],
361 'default' => 'normal',
362 'selectors' => [
363 '{{WRAPPER}} .betterdocs-articles-list .betterdocs-nested-category-list li:not(.betterdocs-nested-category-wrapper) a' => 'word-wrap: {{VALUE}};'
364 ]
365 ]
366 );
367
368 $this->add_control(
369 'subcat_list_color',
370 [
371 'label' => esc_html__( 'Color', 'betterdocs' ),
372 'type' => Controls_Manager::COLOR,
373 'selectors' => [
374 '{{WRAPPER}} .betterdocs-articles-list .betterdocs-nested-category-list li:not(.betterdocs-nested-category-wrapper) a' => 'color: {{VALUE}};'
375 ]
376 ]
377 );
378
379 $this->add_control(
380 'subcat_list_hover_color',
381 [
382 'label' => esc_html__( 'Hover Color', 'betterdocs' ),
383 'type' => Controls_Manager::COLOR,
384 'selectors' => [
385 '{{WRAPPER}} .betterdocs-articles-list li:not(.betterdocs-nested-category-wrapper) a:hover' => 'color: {{VALUE}};'
386 ]
387 ]
388 );
389
390 $this->add_responsive_control(
391 'subcat_list_margin',
392 [
393 'label' => esc_html__( 'List Item Spacing', 'betterdocs' ),
394 'type' => Controls_Manager::DIMENSIONS,
395 'size_units' => ['px', 'em', '%'],
396 'selectors' => [
397 '{{WRAPPER}} .betterdocs-articles-list .betterdocs-nested-category-list li:not(.betterdocs-nested-category-wrapper)' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
398 ]
399 ]
400 );
401
402 $this->add_control(
403 'subcat_icon_settings_heading',
404 [
405 'label' => esc_html__( 'List Icon', 'betterdocs' ),
406 'type' => Controls_Manager::HEADING,
407 'separator' => 'before'
408 ]
409 );
410
411 $this->add_control(
412 'subcat_list_icon_color',
413 [
414 'label' => esc_html__( 'Color', 'betterdocs' ),
415 'type' => Controls_Manager::COLOR,
416 'selectors' => [
417 '{{WRAPPER}} .betterdocs-articles-list .betterdocs-nested-category-list li svg:not(.toggle-arrow)' => 'fill: {{VALUE}};'
418 ]
419 ]
420 );
421
422 $this->add_responsive_control(
423 'subcat_list_icon_size',
424 [
425 'label' => __( 'Size', 'betterdocs' ),
426 'type' => Controls_Manager::SLIDER,
427 'size_units' => ['px', '%', 'em'],
428 'range' => [
429 '%' => [
430 'max' => 100,
431 'step' => 1
432 ]
433 ],
434 'selectors' => [
435 '{{WRAPPER}} .betterdocs-articles-list .betterdocs-nested-category-list li svg:not(.toggle-arrow)' => 'width: {{SIZE}}{{UNIT}};'
436 ]
437 ]
438 );
439
440 $this->add_responsive_control(
441 'subcat_list_icon_spacing',
442 [
443 'label' => esc_html__( 'Spacing', 'betterdocs' ),
444 'type' => Controls_Manager::DIMENSIONS,
445 'size_units' => ['px', 'em', '%'],
446 'selectors' => [
447 '{{WRAPPER}} .betterdocs-articles-list .betterdocs-nested-category-list li svg:not(.toggle-arrow)' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
448 ]
449 ]
450 );
451
452 $this->end_controls_section(); # end of 'Column Settings'
453 }
454
455 public function reset_attributes(){
456 $this->attributes['orderby'] = $this->attributes['alphabetic_order'];
457 $this->attributes['post_orderby'] = $this->attributes['alphabetic_order'];
458 $this->attributes['post_order'] = $this->attributes['order'];
459 }
460
461 protected function render_callback() {
462 $this->views( 'widgets/archive-list' );
463 }
464
465 public function view_params() {
466 global $wp_query;
467
468 $_term_slug = '';
469 if ( isset( $wp_query->query ) && array_key_exists( 'doc_category', $wp_query->query ) ) {
470 $_term_slug = $wp_query->query['doc_category'];
471 }
472
473 $term = get_term_by( 'slug', $_term_slug, 'doc_category' );
474
475 $_docs_query = [
476 'term_id' => isset( $term->term_id ) ? $term->term_id : 0,
477 'orderby' => $this->attributes['alphabetic_order'],
478 'order' => $this->attributes['order'],
479 'kb_slug' => '',
480 'posts_per_page' => $term == false ? 5 : -1,
481 'term_slug' => isset( $term->slug ) ? $term->slug : ''
482 ];
483
484 return [
485 'term' => $term,
486 'nested_subcategory' => (bool) $this->attributes['nested_subcategory'],
487 'query_args' => betterdocs()->query->docs_query_args( $_docs_query ),
488 'nested_docs_query_args' => [
489 'orderby' => $this->attributes['alphabetic_order'],
490 'order' => $this->attributes['order']
491 ],
492 'nested_terms_query' => [
493 'orderby' => $this->attributes['alphabetic_order'],
494 'order' => $this->attributes['order']
495 ]
496 ];
497 }
498
499 public function render_plain_content() {}
500 }
501