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