| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPDeveloper\BetterDocs\Editors\Elementor\Widget; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
exit; // Exit if accessed directly |
| 7 |
} |
| 8 |
|
| 9 |
use Elementor\Controls_Manager; |
| 10 |
use Elementor\Group_Control_Background; |
| 11 |
use Elementor\Group_Control_Typography; |
| 12 |
use WPDeveloper\BetterDocs\Editors\Elementor\BaseWidget; |
| 13 |
use Elementor\Group_Control_Border as Group_Control_Border; |
| 14 |
use Elementor\Group_Control_Box_Shadow as Group_Control_Box_Shadow; |
| 15 |
|
| 16 |
class Reactions extends BaseWidget { |
| 17 |
public $view_wrapper = 'betterdocs-article-reactions'; |
| 18 |
|
| 19 |
public function get_name() { |
| 20 |
return 'betterdocs-reactions'; |
| 21 |
} |
| 22 |
|
| 23 |
public function get_title() { |
| 24 |
return __( 'Doc Reactions', 'betterdocs' ); |
| 25 |
} |
| 26 |
|
| 27 |
public function get_icon() { |
| 28 |
return 'betterdocs-icon-Reactions'; |
| 29 |
} |
| 30 |
|
| 31 |
public function get_categories() { |
| 32 |
return ['betterdocs-elements-single']; |
| 33 |
} |
| 34 |
|
| 35 |
public function get_keywords() { |
| 36 |
return ['betterdocs-elements', 'reaction', 'betterdocs', 'heading', 'docs']; |
| 37 |
} |
| 38 |
|
| 39 |
public function get_style_depends() { |
| 40 |
return ['betterdocs-reactions']; |
| 41 |
} |
| 42 |
|
| 43 |
public function get_script_depends() { |
| 44 |
return ['betterdocs-reactions']; |
| 45 |
} |
| 46 |
|
| 47 |
public function get_custom_help_url() { |
| 48 |
return 'https://betterdocs.co/docs/single-doc-in-elementor'; |
| 49 |
} |
| 50 |
|
| 51 |
protected function register_controls() { |
| 52 |
|
| 53 |
$this->start_controls_section( |
| 54 |
'section_column_settings', |
| 55 |
[ |
| 56 |
'label' => __( 'Box Style', 'betterdocs' ), |
| 57 |
'tab' => Controls_Manager::TAB_STYLE |
| 58 |
] |
| 59 |
); |
| 60 |
|
| 61 |
$this->add_control( |
| 62 |
'reaction_box_width', |
| 63 |
[ |
| 64 |
'label' => __( 'Width', 'betterdocs' ), |
| 65 |
'type' => Controls_Manager::SLIDER, |
| 66 |
'size_units' => ['px'], |
| 67 |
'range' => [ |
| 68 |
'px' => [ |
| 69 |
'max' => 2500, |
| 70 |
'step' => 1 |
| 71 |
] |
| 72 |
], |
| 73 |
'selectors' => [ |
| 74 |
'{{WRAPPER}} .betterdocs-article-reactions' => 'width: {{SIZE}}px;' |
| 75 |
] |
| 76 |
] |
| 77 |
); |
| 78 |
|
| 79 |
$this->add_control( |
| 80 |
'reaction_box_height', |
| 81 |
[ |
| 82 |
'label' => __( 'Height', 'betterdocs' ), |
| 83 |
'type' => Controls_Manager::SLIDER, |
| 84 |
'size_units' => ['px'], |
| 85 |
'range' => [ |
| 86 |
'px' => [ |
| 87 |
'max' => 500, |
| 88 |
'step' => 1 |
| 89 |
] |
| 90 |
], |
| 91 |
'selectors' => [ |
| 92 |
'{{WRAPPER}} .betterdocs-article-reactions' => 'height: {{SIZE}}px;' |
| 93 |
] |
| 94 |
] |
| 95 |
); |
| 96 |
|
| 97 |
$this->add_group_control( |
| 98 |
Group_Control_Background::get_type(), |
| 99 |
[ |
| 100 |
'name' => 'reaction_box_background', |
| 101 |
'types' => ['classic', 'gradient'], |
| 102 |
'selector' => '{{WRAPPER}} .betterdocs-article-reactions' |
| 103 |
] |
| 104 |
); |
| 105 |
|
| 106 |
$this->add_responsive_control( |
| 107 |
'reaction_box_space', // Legacy control id but new control |
| 108 |
[ |
| 109 |
'label' => __( 'Box Spacing', 'betterdocs' ), |
| 110 |
'type' => Controls_Manager::DIMENSIONS, |
| 111 |
'size_units' => ['px', '%', 'em'], |
| 112 |
'selectors' => [ |
| 113 |
'{{WRAPPER}} .betterdocs-article-reactions' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 114 |
] |
| 115 |
] |
| 116 |
); |
| 117 |
|
| 118 |
$this->add_responsive_control( |
| 119 |
'reaction_box_padding', |
| 120 |
[ |
| 121 |
'label' => __( 'Box Padding', 'betterdocs' ), |
| 122 |
'type' => Controls_Manager::DIMENSIONS, |
| 123 |
'size_units' => ['px', 'em', '%'], |
| 124 |
'selectors' => [ |
| 125 |
'{{WRAPPER}} .betterdocs-article-reactions' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 126 |
] |
| 127 |
] |
| 128 |
); |
| 129 |
|
| 130 |
$this->add_group_control( |
| 131 |
Group_Control_Border::get_type(), |
| 132 |
[ |
| 133 |
'name' => 'reaction_box_border_normal', |
| 134 |
'label' => esc_html__( 'Border', 'betterdocs' ), |
| 135 |
'selector' => '{{WRAPPER}} .betterdocs-article-reactions' |
| 136 |
] |
| 137 |
); |
| 138 |
|
| 139 |
$this->add_responsive_control( |
| 140 |
'reaction_box_radius_normal', |
| 141 |
[ |
| 142 |
'label' => esc_html__( 'Border Radius', 'betterdocs' ), |
| 143 |
'type' => Controls_Manager::DIMENSIONS, |
| 144 |
'size_units' => ['px', 'em', '%'], |
| 145 |
'selectors' => [ |
| 146 |
'{{WRAPPER}} .betterdocs-article-reactions' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 147 |
] |
| 148 |
] |
| 149 |
); |
| 150 |
|
| 151 |
$this->add_group_control( |
| 152 |
Group_Control_Box_Shadow::get_type(), |
| 153 |
[ |
| 154 |
'name' => 'reaction_box_shadow_normal', |
| 155 |
'selector' => '{{WRAPPER}} .betterdocs-article-reactions' |
| 156 |
] |
| 157 |
); |
| 158 |
|
| 159 |
$this->end_controls_section(); |
| 160 |
|
| 161 |
$this->start_controls_section( |
| 162 |
'section_title_settings', |
| 163 |
[ |
| 164 |
'label' => __( 'Title', 'betterdocs' ), |
| 165 |
'tab' => Controls_Manager::TAB_STYLE |
| 166 |
] |
| 167 |
); |
| 168 |
|
| 169 |
$this->add_control( |
| 170 |
'reaction_text', |
| 171 |
[ |
| 172 |
'label' => __( 'Text', 'betterdocs' ), |
| 173 |
'type' => Controls_Manager::TEXT, |
| 174 |
'default' => esc_html__( 'What are your feelings', 'betterdocs-pro' ) |
| 175 |
] |
| 176 |
); |
| 177 |
|
| 178 |
$this->add_control( |
| 179 |
'reaction_box_title_color', |
| 180 |
[ |
| 181 |
'label' => esc_html__( 'Color', 'betterdocs' ), |
| 182 |
'type' => Controls_Manager::COLOR, |
| 183 |
'selectors' => [ |
| 184 |
'{{WRAPPER}} .betterdocs-article-reactions-heading h5' => 'color: {{VALUE}};' |
| 185 |
] |
| 186 |
] |
| 187 |
); |
| 188 |
|
| 189 |
$this->add_group_control( |
| 190 |
Group_Control_Typography::get_type(), |
| 191 |
[ |
| 192 |
'name' => 'reaction_box_title_typography', |
| 193 |
'selector' => '{{WRAPPER}} .betterdocs-article-reactions-heading h5' |
| 194 |
] |
| 195 |
); |
| 196 |
|
| 197 |
$this->end_controls_section(); |
| 198 |
|
| 199 |
$this->start_controls_section( |
| 200 |
'section_icon_settings', |
| 201 |
[ |
| 202 |
'label' => __( 'Icon', 'betterdocs' ), |
| 203 |
'tab' => Controls_Manager::TAB_STYLE |
| 204 |
] |
| 205 |
); |
| 206 |
|
| 207 |
$this->add_control( |
| 208 |
'reaction_box_icon_area', |
| 209 |
[ |
| 210 |
'label' => __( 'Area', 'betterdocs' ), |
| 211 |
'type' => Controls_Manager::SLIDER, |
| 212 |
'size_units' => ['px'], |
| 213 |
'range' => [ |
| 214 |
'px' => [ |
| 215 |
'max' => 500, |
| 216 |
'step' => 1 |
| 217 |
] |
| 218 |
], |
| 219 |
'selectors' => [ |
| 220 |
'{{WRAPPER}} .betterdocs-article-reaction-links li a' => 'height: {{SIZE}}px;width: {{SIZE}}px;' |
| 221 |
] |
| 222 |
] |
| 223 |
); |
| 224 |
|
| 225 |
$this->add_control( |
| 226 |
'reaction_box_icon_size', |
| 227 |
[ |
| 228 |
'label' => __( 'Icon Size', 'betterdocs' ), |
| 229 |
'type' => Controls_Manager::SLIDER, |
| 230 |
'size_units' => ['px'], |
| 231 |
'range' => [ |
| 232 |
'px' => [ |
| 233 |
'max' => 500, |
| 234 |
'step' => 1 |
| 235 |
] |
| 236 |
], |
| 237 |
'selectors' => [ |
| 238 |
'{{WRAPPER}} .betterdocs-article-reaction-links li a svg' => 'height: {{SIZE}}px;width: {{SIZE}}px;' |
| 239 |
] |
| 240 |
] |
| 241 |
); |
| 242 |
|
| 243 |
$this->add_control( |
| 244 |
'reaction_box_icon_background', |
| 245 |
[ |
| 246 |
'label' => esc_html__( 'Background Color', 'betterdocs' ), |
| 247 |
'type' => Controls_Manager::COLOR, |
| 248 |
'selectors' => [ |
| 249 |
'{{WRAPPER}} .betterdocs-article-reaction-links li a' => 'background-color: {{VALUE}};' |
| 250 |
] |
| 251 |
] |
| 252 |
); |
| 253 |
|
| 254 |
$this->add_control( |
| 255 |
'reaction_box_icon_hover_background', |
| 256 |
[ |
| 257 |
'label' => esc_html__( 'Hover Background Color', 'betterdocs' ), |
| 258 |
'type' => Controls_Manager::COLOR, |
| 259 |
'selectors' => [ |
| 260 |
'{{WRAPPER}} .betterdocs-article-reaction-links li a:hover' => 'background-color: {{VALUE}};' |
| 261 |
] |
| 262 |
] |
| 263 |
); |
| 264 |
|
| 265 |
$this->add_control( |
| 266 |
'reaction_box_icon_color', |
| 267 |
[ |
| 268 |
'label' => esc_html__( 'Color', 'betterdocs' ), |
| 269 |
'type' => Controls_Manager::COLOR, |
| 270 |
'selectors' => [ |
| 271 |
'{{WRAPPER}} .betterdocs-article-reaction-links li a svg path' => 'fill: {{VALUE}};' |
| 272 |
] |
| 273 |
] |
| 274 |
); |
| 275 |
|
| 276 |
$this->add_control( |
| 277 |
'reaction_box_icon_hover_color', |
| 278 |
[ |
| 279 |
'label' => esc_html__( 'Hover Color', 'betterdocs' ), |
| 280 |
'type' => Controls_Manager::COLOR, |
| 281 |
'selectors' => [ |
| 282 |
'{{WRAPPER}} .betterdocs-article-reaction-links li a:hover svg path' => 'fill: {{VALUE}};' |
| 283 |
] |
| 284 |
] |
| 285 |
); |
| 286 |
|
| 287 |
$this->end_controls_section(); |
| 288 |
} |
| 289 |
|
| 290 |
protected function render_callback() { |
| 291 |
$this->views( 'widgets/reactions' ); |
| 292 |
} |
| 293 |
|
| 294 |
public function view_params(){ |
| 295 |
return [ |
| 296 |
'reactions_text' => $this->attributes['reaction_text'] |
| 297 |
]; |
| 298 |
} |
| 299 |
} |
| 300 |
|