PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 3.8.1
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v3.8.1
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 / Shortcodes / Reactions.php

Reactions.php in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 3.8.1, at includes/Shortcodes/Reactions.php

86 lines 2.3 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\Shortcodes;
4 use WPDeveloper\BetterDocs\Core\Shortcode;
5
6 class Reactions extends Shortcode {
7 public $view_wrapper = 'betterdocs-article-reactions';
8
9 public function get_name() {
10 return 'betterdocs_article_reactions';
11 }
12
13 public function get_style_depends() {
14 return ['betterdocs-reactions'];
15 }
16
17 public function get_script_depends() {
18 return ['betterdocs-reactions'];
19 }
20
21 /**
22 * Summary of default_attributes
23 * @return array
24 */
25 public function default_attributes() {
26 return [
27 'text' => '',
28 'layout' => 'layout-1',
29 'happy' => true,
30 'happy_icon' => '',
31 'normal' => true,
32 'normal_icon' => '',
33 'sad' => true,
34 'sad_icon' => '',
35 ];
36 }
37
38 public function generate_attributes() {
39 $attributes = [
40 'class' => [
41 $this->attributes['layout']
42 ]
43 ];
44
45 return $attributes;
46 }
47
48 /**
49 * Summary of render
50 *
51 * @param mixed $atts
52 * @param mixed $content
53 * @return mixed
54 */
55 public function render( $atts, $content = null ) {
56 $args = [
57 'happy' => $atts['happy'],
58 'happy_icon' => $atts['happy_icon'],
59 'normal' => $atts['normal'],
60 'normal_icon' => $atts['normal_icon'],
61 'sad' => $atts['sad'],
62 'sad_icon' => $atts['sad_icon']
63 ];
64
65 if ( isset( $atts['layout'] ) && $atts['layout'] == 'layout-2' ) {
66 $this->views( 'widgets/reactions-2', $args );
67 } else if ( isset( $atts['layout'] ) && $atts['layout'] == 'layout-3' ) {
68 $this->views( 'widgets/reactions-3', $args );
69 } else {
70 $this->views( 'widgets/reactions' );
71 }
72 }
73
74 public function view_params() {
75 $wrapper_attr = $this->generate_attributes();
76 $reactions_text = ! empty( $this->attributes['text'] ) ? $this->attributes['text'] : $this->customizer->get(
77 'betterdocs_post_reactions_text', __( 'What are your Feelings', 'betterdocs' )
78 );
79
80 return [
81 'wrapper_attr' => $wrapper_attr,
82 'reactions_text' => $reactions_text
83 ];
84 }
85 }
86