PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.9.3
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.9.3
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 3.4.2 3.5.0 All 201 releases
← All changes | includes/Editors/BlockEditor/Blocks/Reactions.php +83 -29 3.4.2 → 4.9.3 View file →
@@ -3,42 +3,96 @@
3 3 namespace WPDeveloper\BetterDocs\Editors\BlockEditor\Blocks;
4 4
5 5 use WPDeveloper\BetterDocs\Editors\BlockEditor\Block;
6 6
7 +use function cli\err;
8 +
7 9 class Reactions extends Block {
8 - public $view_wrapper = 'betterdocs-article-reactions';
9 10
10 - protected $editor_scripts = [
11 - 'betterdocs-reactions'
12 - ];
11 + protected $editor_scripts = [
12 + 'betterdocs-reactions'
13 + ];
13 14
14 - protected $editor_styles = [
15 - 'betterdocs-reactions'
16 - ];
15 + protected $editor_styles = [
16 + 'betterdocs-reactions'
17 + ];
17 18
18 - protected $frontend_scripts = [
19 - 'betterdocs-reactions'
20 - ];
21 - protected $frontend_styles = [
22 - 'betterdocs-reactions'
23 - ];
19 + protected $frontend_scripts = [
20 + 'betterdocs-reactions'
21 + ];
22 + protected $frontend_styles = [
23 + 'betterdocs-reactions'
24 + ];
24 25
25 - public function get_name() {
26 - return 'reactions';
27 - }
26 + public function get_name() {
27 + return 'reactions';
28 + }
28 29
29 - public function get_default_attributes() {
30 - return [
31 - 'reaction_text' => __( 'What are your feelings', 'betterdocs' )
32 - ];
33 - }
30 + public function get_default_attributes() {
31 + return [
32 + 'blockId' => 'layout-1',
33 + 'reaction_text' => __( 'What are your feelings', 'betterdocs' ),
34 + 'reaction_text_tag' => 'h4',
35 + 'layout' => 'layout-1',
36 + 'show_happy_icon' => true,
37 + 'happy_icon_url' => '',
38 + 'show_neutral_icon' => true,
39 + 'neutral_icon_url' => '',
40 + 'show_sad_icon' => true,
41 + 'sad_icon_url' => ''
42 + ];
43 + }
34 44
35 - public function render( $attributes, $content ) {
36 - $this->views( 'widgets/reactions' );
37 - }
45 + public function render( $attributes, $content ) {
46 + $layout = $attributes['layout'];
47 + if ( $layout == 'layout-1' ) {
48 + $this->views( 'widgets/reactions' );
49 + } elseif ( $layout == 'layout-2' ) {
50 + $this->views( 'widgets/reactions-2' );
51 + } else {
52 + $this->views( 'widgets/reactions-3' );
53 + }
54 + }
38 55
39 - public function view_params() {
40 - return [
41 - 'reactions_text' => $this->attributes['reaction_text']
42 - ];
43 - }
56 + public function view_params() {
57 + $wrapper_class = [
58 + 'class' => []
59 + ];
60 +
61 + $default_params = [
62 + 'reactions_text' => $this->attributes['reaction_text'],
63 + 'text_tag' => $this->attributes['reaction_text_tag'],
64 + 'wrapper_attr' => &$wrapper_class
65 + ];
66 +
67 + if ( $this->attributes['layout'] == 'layout-1' ) {
68 + $wrapper_class['class'][] = 'betterdocs-article-reactions';
69 + $default_params['happy'] = $this->attributes['show_happy_icon'];
70 + $default_params['happy_icon'] = $this->attributes['happy_icon_url'];
71 + $default_params['normal'] = $this->attributes['show_neutral_icon'];
72 + $default_params['normal_icon'] = $this->attributes['neutral_icon_url'];
73 + $default_params['sad'] = $this->attributes['show_sad_icon'];
74 + $default_params['sad_icon'] = $this->attributes['sad_icon_url'];
75 + }
76 +
77 + if ( $this->attributes['layout'] == 'layout-2' ) {
78 + $default_params['happy'] = $this->attributes['show_happy_icon'];
79 + $default_params['happy_icon'] = $this->attributes['happy_icon_url'];
80 + $default_params['normal'] = $this->attributes['show_neutral_icon'];
81 + $default_params['normal_icon'] = $this->attributes['neutral_icon_url'];
82 + $default_params['sad'] = $this->attributes['show_sad_icon'];
83 + $default_params['sad_icon'] = $this->attributes['sad_icon_url'];
84 + }
85 +
86 + if ( $this->attributes['layout'] == 'layout-3' ) {
87 + $default_params['happy'] = $this->attributes['show_happy_icon'];
88 + $default_params['happy_icon'] = $this->attributes['happy_icon_url'];
89 + $default_params['normal'] = $this->attributes['show_neutral_icon'];
90 + $default_params['normal_icon'] = $this->attributes['neutral_icon_url'];
91 + $default_params['sad'] = $this->attributes['show_sad_icon'];
92 + $default_params['sad_icon'] = $this->attributes['sad_icon_url'];
93 + $wrapper_class['class'][] = 'betterdocs-article-reactions-blocks';
94 + }
95 +
96 + return $default_params;
97 + }
44 98 }