PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.2.0
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.2.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 / Editors / BlockEditor / Blocks / FAQ.php

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

130 lines 4.2 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 'faqSectionTitleTag' => 'h2',
43 'faqGroupTitleTag' => 'h3',
44 'faqSectionTitleColor' => null,
45 'includeFaqGroup' => '',
46 'excludeFaqGroup' => '',
47 'faqGroupTitleColor' => null,
48 'faqGroupTitleHoverColor' => null,
49 'faqListColor' => null,
50 'faqContentColor' => null,
51 'faqIconColor' => null,
52 'faqGroupTitleTypography' => null,
53 'faqPerPage' => 9,
54
55 'showButtonIcon' => true,
56 'buttonColor' => '#528ffe'
57 ];
58 }
59
60 public function render( $attributes, $content ) {
61
62 add_filter( 'betterdocs_header_layout_sequence', [ $this, 'header_sequence' ], 10, 4 );
63 $this->views( 'layouts/faq' );
64 remove_filter( 'betterdocs_header_layout_sequence', [ $this, 'header_sequence' ], 10 );
65 }
66
67 public function get_groups_ids( $json ) {
68 $data = json_decode( $json, true );
69 $ids = '';
70 if ( $data !== null ) {
71 $ids = implode( ',', array_column( $data, 'value' ) );
72 }
73
74 return $ids;
75 }
76
77 public function view_params() {
78 $attributes = &$this->attributes;
79 $exclude = $this->get_groups_ids( $attributes['excludeFaqGroup'] );
80 $include = $this->get_groups_ids( $attributes['includeFaqGroup'] );
81
82 $terms_query = betterdocs()->query->faq_terms_query_args( $include, $exclude );
83
84 return wp_parse_args(
85 [
86 'enable' => true,
87 'have_posts' => true,
88 'widget' => $this,
89 'layout' => $attributes['faqLayout'],
90 'terms_query_args' => $terms_query,
91 'shortcode_attr' => [
92 'group_exclude' => $exclude,
93 'class' => 'betterdocs-faq-' . $attributes['faqLayout'] . ' ' . $attributes['blockId'],
94 'groups' => $include,
95 'is_gutenberg' => true,
96 'faq_heading' => $attributes['faqSectionText'],
97 'faq_section_title_tag' => $attributes['faqSectionTitleTag'],
98 'faq_group_title_tag' => $attributes['faqGroupTitleTag'],
99 'faq_section_title_color' => $attributes['faqSectionTitleColor'],
100 'include_faq_group' => $this->string_to_array( $attributes['includeFaqGroup'] ),
101 'exclude_faq_group' => $this->string_to_array( $attributes['excludeFaqGroup'] ),
102 'faq_group_title_color' => $attributes['faqGroupTitleColor'],
103 'faq_group_title_hover_color' => $attributes['faqGroupTitleHoverColor'],
104 'faq_list_color' => $attributes['faqListColor'],
105 'faq_content_color' => $attributes['faqContentColor'],
106 'faq_icon_color' => $attributes['faqIconColor'],
107 'faq_group_title_typography' => $attributes['faqGroupTitleTypography'],
108 'faq_per_page' => $attributes['faqPerPage'],
109 'show_button_icon' => $attributes['showButtonIcon'],
110 'button_icon_position' => $attributes['faqLayout'] == 'layout-1' || $attributes['faqLayout'] == 'layout-3' || $attributes['faqLayout'] == 'layout-4' ? 'after' : 'before',
111 'button_color' => $attributes['buttonColor']
112 ]
113
114 ]
115 );
116 }
117
118 public function header_sequence( $_layout_sequence, $layout, $widget_type, $_defined_vars ) {
119 $_new_layout_sequence = [
120 [
121 'class' => 'betterdocs-category-title-counts',
122 'sequence' => [ 'category_title', 'category_counts' ]
123 ],
124 'category_description'
125 ];
126
127 return $_new_layout_sequence;
128 }
129 }
130