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.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 / Editors / BlockEditor / Blocks / FAQ.php

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

124 lines 4.5 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\Editors\BlockEditor\Blocks;
4
5 use WPDeveloper\BetterDocs\Editors\BlockEditor\Block;
6
7 class FAQ extends Block {
8 protected $editor_scripts = [
9 'betterdocs-faq',
10 'betterdocs-blocks-editor'
11 ];
12
13 protected $editor_styles = [
14 'betterdocs-faq',
15 'betterdocs-blocks-editor'
16 ];
17
18 protected $frontend_styles = [
19 'betterdocs-faq'
20 ];
21
22 protected $frontend_scripts = [
23 'betterdocs-faq'
24 ];
25
26 /**
27 * unique name of block
28 * @return string
29 */
30 public function get_name() {
31 return 'faq';
32 }
33
34 public function get_default_attributes() {
35 return [
36 'blockId' => '',
37 'resOption' => 'Desktop',
38 'blockRoot' => 'better_docs',
39 'blockMeta' => null,
40 'faqLayout' => 'layout-1',
41 'faqSectionText' => 'Frequently Asked Questions',
42 'faqSectionTitleColor' => null,
43 'includeFaqGroup' => '',
44 'excludeFaqGroup' => '',
45 'faqGroupTitleColor' => null,
46 'faqGroupTitleHoverColor' => null,
47 'faqListColor' => null,
48 'faqContentColor' => null,
49 'faqIconColor' => null,
50 'faqGroupTitleTypography' => null,
51 'faqPerPage' => 9,
52
53 'showButtonIcon' => true,
54 'buttonColor' => '#528ffe'
55 ];
56 }
57
58 public function render( $attributes, $content ) {
59
60 add_filter( 'betterdocs_header_layout_sequence', [$this, 'header_sequence'], 10, 4 );
61 $this->views( 'layouts/faq' );
62 remove_filter( 'betterdocs_header_layout_sequence', [$this, 'header_sequence'], 10 );
63 }
64
65 public function get_groups_ids( $json ) {
66 $data = json_decode( $json, true );
67 $ids = '';
68 if ( $data !== null ) {
69 $ids = implode( ',', array_column( $data, 'value' ) );
70 }
71
72 return $ids;
73 }
74
75 public function view_params() {
76 $attributes = &$this->attributes;
77 $exclude = $this->get_groups_ids( $attributes['excludeFaqGroup'] );
78 $include = $this->get_groups_ids( $attributes['includeFaqGroup'] );
79
80 $terms_query = betterdocs()->query->faq_terms_query_args( $include, $exclude );
81
82 return wp_parse_args( [
83 'enable' => true,
84 'have_posts' => true,
85 'widget' => $this,
86 'layout' => $attributes['faqLayout'],
87 'terms_query_args' => $terms_query,
88 'shortcode_attr' => [
89 'group_exclude' => $exclude,
90 'class' => 'betterdocs-faq-' . $attributes['faqLayout'] . ' ' . $attributes['blockId'],
91 'groups' => $include,
92 'is_gutenberg' => true,
93 'faq_heading' => $attributes['faqSectionText'],
94 'faq_section_title_color' => $attributes['faqSectionTitleColor'],
95 'include_faq_group' => $attributes['includeFaqGroup'],
96 'exclude_faq_group' => $attributes['excludeFaqGroup'],
97 'faq_group_title_color' => $attributes['faqGroupTitleColor'],
98 'faq_group_title_hover_color' => $attributes['faqGroupTitleHoverColor'],
99 'faq_list_color' => $attributes['faqListColor'],
100 'faq_content_color' => $attributes['faqContentColor'],
101 'faq_icon_color' => $attributes['faqIconColor'],
102 'faq_group_title_typography' => $attributes['faqGroupTitleTypography'],
103 'faq_per_page' => $attributes['faqPerPage'],
104 'show_button_icon' => $attributes['showButtonIcon'],
105 'button_icon_position' => $attributes['faqLayout'] == 'layout-1' ? 'after' : 'before',
106 'button_color' => $attributes['buttonColor']
107 ]
108
109 ] );
110 }
111
112 public function header_sequence( $_layout_sequence, $layout, $widget_type, $_defined_vars ) {
113 $_new_layout_sequence = [
114 [
115 'class' => 'betterdocs-category-title-counts',
116 'sequence' => ['category_title', 'category_counts']
117 ],
118 'category_description'
119 ];
120
121 return $_new_layout_sequence;
122 }
123 }
124