| 1 |
<?php |
| 2 |
|
| 3 |
use Elementor\Controls_Manager; |
| 4 |
use Elementor\Group_Control_Typography; |
| 5 |
use Elementor\Widget_Base; |
| 6 |
|
| 7 |
if (!defined('ABSPATH')) { |
| 8 |
exit; // Exit if accessed directly |
| 9 |
} |
| 10 |
|
| 11 |
class BetterDocs_Elementor_Feedback extends Widget_Base { |
| 12 |
|
| 13 |
public function get_name () { |
| 14 |
return 'betterdocs-feedback'; |
| 15 |
} |
| 16 |
|
| 17 |
public function get_title () { |
| 18 |
return __('Doc Feedback', 'betterdocs'); |
| 19 |
} |
| 20 |
|
| 21 |
public function get_icon () { |
| 22 |
return 'betterdocs-icon-feedback'; |
| 23 |
} |
| 24 |
|
| 25 |
public function get_categories () { |
| 26 |
return ['betterdocs-elements']; |
| 27 |
} |
| 28 |
|
| 29 |
public function get_keywords () { |
| 30 |
return ['betterdocs-elements', 'feedback', 'betterdocs', 'docs']; |
| 31 |
} |
| 32 |
|
| 33 |
public function get_custom_help_url() { |
| 34 |
return 'https://betterdocs.co/docs/single-doc-in-elementor'; |
| 35 |
} |
| 36 |
|
| 37 |
protected function _register_controls () { |
| 38 |
|
| 39 |
/** |
| 40 |
* ---------------------------------------------------------- |
| 41 |
* Section: Layout Options |
| 42 |
* ---------------------------------------------------------- |
| 43 |
*/ |
| 44 |
$this->start_controls_section( |
| 45 |
'section_layout_options', |
| 46 |
[ |
| 47 |
'label' => __('General ', 'betterdocs') |
| 48 |
] |
| 49 |
); |
| 50 |
|
| 51 |
$this->add_control( |
| 52 |
'feedback_link_title', |
| 53 |
[ |
| 54 |
'label' => __('Content', 'betterdocs'), |
| 55 |
'type' => Controls_Manager::TEXT, |
| 56 |
'default' => esc_html__('Still stuck? How can we help?', 'betterdocs') |
| 57 |
] |
| 58 |
); |
| 59 |
$this->add_control( |
| 60 |
'feedback_form_title', |
| 61 |
[ |
| 62 |
'label' => __('Feedback Form Title', 'betterdocs'), |
| 63 |
'type' => Controls_Manager::TEXT, |
| 64 |
'default' => esc_html__('How can we help?', 'betterdocs') |
| 65 |
] |
| 66 |
); |
| 67 |
|
| 68 |
$this->add_control( |
| 69 |
'feedback_form_button_text', |
| 70 |
[ |
| 71 |
'label' => __('Button Text', 'betterdocs'), |
| 72 |
'type' => Controls_Manager::TEXT, |
| 73 |
'default' => 'Send', |
| 74 |
'placeholder' => __('Enter button text', 'betterdocs'), |
| 75 |
'title' => __('Enter button text here', 'betterdocs'), |
| 76 |
] |
| 77 |
); |
| 78 |
|
| 79 |
$this->end_controls_section(); |
| 80 |
|
| 81 |
$this->start_controls_section( |
| 82 |
'section_card_settings_text', |
| 83 |
[ |
| 84 |
'label' => __('Text', 'betterdocs'), |
| 85 |
'tab' => Controls_Manager::TAB_STYLE, |
| 86 |
] |
| 87 |
); |
| 88 |
|
| 89 |
$this->add_control( |
| 90 |
'feedback_text_color', |
| 91 |
[ |
| 92 |
'label' => esc_html__('Color', 'betterdocs'), |
| 93 |
'type' => Controls_Manager::COLOR, |
| 94 |
'selectors' => [ |
| 95 |
'{{WRAPPER}} .feedback-form-link' => 'color: {{VALUE}};', |
| 96 |
] |
| 97 |
] |
| 98 |
); |
| 99 |
|
| 100 |
$this->add_group_control( |
| 101 |
Group_Control_Typography::get_type(), |
| 102 |
[ |
| 103 |
'name' => 'feedback_text_typography', |
| 104 |
'selector' => '{{WRAPPER}} .feedback-form-link' |
| 105 |
] |
| 106 |
); |
| 107 |
|
| 108 |
$this->end_controls_section(); |
| 109 |
|
| 110 |
$this->icon_section(); |
| 111 |
|
| 112 |
$this->feedback_form(); |
| 113 |
|
| 114 |
} |
| 115 |
|
| 116 |
public function icon_section () { |
| 117 |
$this->start_controls_section( |
| 118 |
'section_icon_options', |
| 119 |
[ |
| 120 |
'label' => __('Icon ', 'betterdocs'), |
| 121 |
'tab' => Controls_Manager::TAB_STYLE, |
| 122 |
] |
| 123 |
); |
| 124 |
|
| 125 |
$this->add_control( |
| 126 |
'feedback_icon_color', |
| 127 |
[ |
| 128 |
'label' => esc_html__('Color', 'betterdocs'), |
| 129 |
'type' => Controls_Manager::COLOR |
| 130 |
] |
| 131 |
); |
| 132 |
|
| 133 |
$this->add_control( |
| 134 |
'feedback_text_icon_size', |
| 135 |
[ |
| 136 |
'label' => __('Size', 'betterdocs'), |
| 137 |
'type' => Controls_Manager::SLIDER, |
| 138 |
'size_units' => ['px'], |
| 139 |
'range' => [ |
| 140 |
'px' => [ |
| 141 |
'max' => 1000, |
| 142 |
'step' => 1, |
| 143 |
], |
| 144 |
], |
| 145 |
'selectors' => [ |
| 146 |
'{{WRAPPER}} .feedback-form-icon svg' => 'width: {{SIZE}}px;height: {{SIZE}}px;' |
| 147 |
] |
| 148 |
] |
| 149 |
); |
| 150 |
|
| 151 |
$this->end_controls_section(); |
| 152 |
} |
| 153 |
|
| 154 |
public function feedback_form () { |
| 155 |
/** |
| 156 |
* ---------------------------------------------------------- |
| 157 |
* Section: Box Styles |
| 158 |
* ---------------------------------------------------------- |
| 159 |
*/ |
| 160 |
$this->start_controls_section( |
| 161 |
'section_card_settings', |
| 162 |
[ |
| 163 |
'label' => __('FeedBack Form', 'betterdocs'), |
| 164 |
'tab' => Controls_Manager::TAB_STYLE, |
| 165 |
] |
| 166 |
); |
| 167 |
|
| 168 |
$this->add_control( |
| 169 |
'feedback_form_width', |
| 170 |
[ |
| 171 |
'label' => __('Width', 'betterdocs'), |
| 172 |
'type' => Controls_Manager::SLIDER, |
| 173 |
'size_units' => ['px'], |
| 174 |
'range' => [ |
| 175 |
'px' => [ |
| 176 |
'max' => 1000, |
| 177 |
'step' => 1, |
| 178 |
], |
| 179 |
], |
| 180 |
'selectors' => [ |
| 181 |
'{{WRAPPER}} .betterdocs-modalwindow .modal-content' => 'width: {{SIZE}}px;' |
| 182 |
], |
| 183 |
] |
| 184 |
); |
| 185 |
|
| 186 |
$this->add_control( |
| 187 |
'feedback_form_height', |
| 188 |
[ |
| 189 |
'label' => __('Height', 'betterdocs'), |
| 190 |
'type' => Controls_Manager::SLIDER, |
| 191 |
'size_units' => ['px'], |
| 192 |
'range' => [ |
| 193 |
'px' => [ |
| 194 |
'max' => 1000, |
| 195 |
'step' => 1, |
| 196 |
], |
| 197 |
], |
| 198 |
'selectors' => [ |
| 199 |
'{{WRAPPER}} .betterdocs-modalwindow .modal-content' => 'height: {{SIZE}}px;' |
| 200 |
], |
| 201 |
] |
| 202 |
); |
| 203 |
|
| 204 |
$this->add_control( |
| 205 |
'feedback_form_heading', |
| 206 |
[ |
| 207 |
'label' => esc_html__('Heading', 'betterdocs'), |
| 208 |
'type' => Controls_Manager::HEADING |
| 209 |
] |
| 210 |
); |
| 211 |
|
| 212 |
$this->add_control( |
| 213 |
'feedback_form_heading_color', |
| 214 |
[ |
| 215 |
'label' => esc_html__('Color', 'betterdocs'), |
| 216 |
'type' => Controls_Manager::COLOR, |
| 217 |
'selectors' => [ |
| 218 |
'{{WRAPPER}} .betterdocs-modalwindow .modal-content .feedback-form-title' => 'color: {{VALUE}};', |
| 219 |
] |
| 220 |
] |
| 221 |
); |
| 222 |
|
| 223 |
$this->add_group_control( |
| 224 |
Group_Control_Typography::get_type(), |
| 225 |
[ |
| 226 |
'name' => 'feedback_form_heading_typography', |
| 227 |
'selector' => '{{WRAPPER}} .betterdocs-modalwindow .modal-content .feedback-form-title' |
| 228 |
] |
| 229 |
); |
| 230 |
|
| 231 |
$this->add_responsive_control( |
| 232 |
'align', |
| 233 |
[ |
| 234 |
'label' => __('Alignment', 'betterdocs'), |
| 235 |
'type' => Controls_Manager::CHOOSE, |
| 236 |
'options' => [ |
| 237 |
'left' => [ |
| 238 |
'title' => __('Left', 'betterdocs'), |
| 239 |
'icon' => 'eicon-text-align-left', |
| 240 |
], |
| 241 |
'center' => [ |
| 242 |
'title' => __('Center', 'betterdocs'), |
| 243 |
'icon' => 'eicon-text-align-center', |
| 244 |
], |
| 245 |
'right' => [ |
| 246 |
'title' => __('Right', 'betterdocs'), |
| 247 |
'icon' => 'eicon-text-align-right', |
| 248 |
], |
| 249 |
'justify' => [ |
| 250 |
'title' => __('Justified', 'betterdocs'), |
| 251 |
'icon' => 'eicon-text-align-justify', |
| 252 |
], |
| 253 |
], |
| 254 |
'default' => '', |
| 255 |
'selectors' => [ |
| 256 |
'{{WRAPPER}} .betterdocs-modalwindow .modal-content .feedback-form-title' => 'text-align: {{VALUE}};', |
| 257 |
], |
| 258 |
] |
| 259 |
); |
| 260 |
|
| 261 |
$this->add_control( |
| 262 |
'feedback_form_label', |
| 263 |
[ |
| 264 |
'label' => esc_html__('Lable', 'betterdocs'), |
| 265 |
'type' => Controls_Manager::HEADING |
| 266 |
] |
| 267 |
); |
| 268 |
|
| 269 |
$this->add_control( |
| 270 |
'feedback_form_label_color', |
| 271 |
[ |
| 272 |
'label' => esc_html__('Color', 'betterdocs'), |
| 273 |
'type' => Controls_Manager::COLOR, |
| 274 |
'selectors' => [ |
| 275 |
'{{WRAPPER}} .betterdocs-modalwindow .betterdocs-feedback-form label' => 'color: {{VALUE}};', |
| 276 |
] |
| 277 |
] |
| 278 |
); |
| 279 |
|
| 280 |
$this->add_group_control( |
| 281 |
Group_Control_Typography::get_type(), |
| 282 |
[ |
| 283 |
'name' => 'feedback_form_label_typography', |
| 284 |
'selector' => '{{WRAPPER}} .betterdocs-modalwindow .betterdocs-feedback-form label' |
| 285 |
] |
| 286 |
); |
| 287 |
|
| 288 |
$this->add_control( |
| 289 |
'feedback_form_label_space', |
| 290 |
[ |
| 291 |
'label' => __('Space', 'betterdocs'), |
| 292 |
'type' => Controls_Manager::SLIDER, |
| 293 |
'size_units' => ['px'], |
| 294 |
'range' => [ |
| 295 |
'px' => [ |
| 296 |
'max' => 500, |
| 297 |
'step' => 1, |
| 298 |
], |
| 299 |
], |
| 300 |
'selectors' => [ |
| 301 |
'{{WRAPPER}} .betterdocs-modalwindow .betterdocs-feedback-form label input,{{WRAPPER}} .betterdocs-modalwindow .betterdocs-feedback-form label textarea' => 'margin-top: {{SIZE}}{{UNIT}};', |
| 302 |
], |
| 303 |
] |
| 304 |
); |
| 305 |
|
| 306 |
$this->add_control( |
| 307 |
'feedback_form_button', |
| 308 |
[ |
| 309 |
'label' => esc_html__('Button', 'betterdocs'), |
| 310 |
'type' => Controls_Manager::HEADING |
| 311 |
] |
| 312 |
); |
| 313 |
|
| 314 |
$this->add_control( |
| 315 |
'feedback_form_button_background', |
| 316 |
[ |
| 317 |
'label' => esc_html__('Background', 'betterdocs'), |
| 318 |
'type' => Controls_Manager::COLOR, |
| 319 |
'selectors' => [ |
| 320 |
'{{WRAPPER}} .betterdocs-modalwindow .betterdocs-feedback-form #feedback_form_submit_btn' => 'color: {{VALUE}};', |
| 321 |
] |
| 322 |
] |
| 323 |
); |
| 324 |
|
| 325 |
$this->add_control( |
| 326 |
'feedback_form_button_color', |
| 327 |
[ |
| 328 |
'label' => esc_html__('Text Color', 'betterdocs'), |
| 329 |
'type' => Controls_Manager::COLOR, |
| 330 |
'selectors' => [ |
| 331 |
'{{WRAPPER}} .betterdocs-modalwindow .betterdocs-feedback-form #feedback_form_submit_btn' => 'color: {{VALUE}};', |
| 332 |
] |
| 333 |
] |
| 334 |
); |
| 335 |
|
| 336 |
$this->add_group_control( |
| 337 |
Group_Control_Typography::get_type(), |
| 338 |
[ |
| 339 |
'name' => 'feedback_form_button_typography', |
| 340 |
'selector' => '{{WRAPPER}} .betterdocs-modalwindow .betterdocs-feedback-form #feedback_form_submit_btn' |
| 341 |
] |
| 342 |
); |
| 343 |
|
| 344 |
$this->add_responsive_control( |
| 345 |
'feedback_form_button_width', |
| 346 |
[ |
| 347 |
'label' => esc_html__('Width', 'betterdocs'), |
| 348 |
'type' => Controls_Manager::SLIDER, |
| 349 |
'size_units' => ['px', '%'], |
| 350 |
'range' => [ |
| 351 |
'px' => [ |
| 352 |
'min' => 0, |
| 353 |
'max' => 500, |
| 354 |
'step' => 1, |
| 355 |
], |
| 356 |
'%' => [ |
| 357 |
'min' => 0, |
| 358 |
'max' => 100, |
| 359 |
], |
| 360 |
], |
| 361 |
'selectors' => [ |
| 362 |
'{{WRAPPER}} .betterdocs-modalwindow .betterdocs-feedback-form #feedback_form_submit_btn' => 'width: {{SIZE}}{{UNIT}};', |
| 363 |
], |
| 364 |
] |
| 365 |
); |
| 366 |
|
| 367 |
$this->add_control( |
| 368 |
'feedback_form_button_padding', |
| 369 |
[ |
| 370 |
'label' => __('Padding', 'betterdocs'), |
| 371 |
'type' => Controls_Manager::DIMENSIONS, |
| 372 |
'size_units' => ['px', 'em', '%'], |
| 373 |
'selectors' => [ |
| 374 |
'{{WRAPPER}} .betterdocs-modalwindow .betterdocs-feedback-form #feedback_form_submit_btn' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 375 |
], |
| 376 |
] |
| 377 |
); |
| 378 |
|
| 379 |
$this->add_responsive_control( |
| 380 |
'feedback_form_button_align', |
| 381 |
[ |
| 382 |
'label' => __('Alignment', 'betterdocs'), |
| 383 |
'type' => Controls_Manager::CHOOSE, |
| 384 |
'options' => [ |
| 385 |
'left' => [ |
| 386 |
'title' => __('Left', 'betterdocs'), |
| 387 |
'icon' => 'eicon-text-align-left', |
| 388 |
], |
| 389 |
'center' => [ |
| 390 |
'title' => __('Center', 'betterdocs'), |
| 391 |
'icon' => 'eicon-text-align-center', |
| 392 |
], |
| 393 |
'right' => [ |
| 394 |
'title' => __('Right', 'betterdocs'), |
| 395 |
'icon' => 'eicon-text-align-right', |
| 396 |
], |
| 397 |
'justify' => [ |
| 398 |
'title' => __('Justified', 'betterdocs'), |
| 399 |
'icon' => 'eicon-text-align-justify', |
| 400 |
], |
| 401 |
], |
| 402 |
'default' => '', |
| 403 |
'selectors' => [ |
| 404 |
'{{WRAPPER}} .betterdocs-modalwindow .betterdocs-feedback-form .feedback-from-button' => 'text-align: {{VALUE}};', |
| 405 |
], |
| 406 |
] |
| 407 |
); |
| 408 |
|
| 409 |
$this->end_controls_section(); |
| 410 |
} |
| 411 |
|
| 412 |
protected function render () { |
| 413 |
$settings = $this->get_settings_for_display(); |
| 414 |
$email_feedback = BetterDocs_DB::get_settings('email_feedback'); |
| 415 |
if ($email_feedback == 1) { |
| 416 |
|
| 417 |
?> |
| 418 |
<div class="feedback-form"> |
| 419 |
<a class="feedback-form-link" href="#betterdocs-form-modal" name="betterdocs-form-modal"> |
| 420 |
<span class="feedback-form-icon"> |
| 421 |
<?php $this->feedback_icon(); ?> |
| 422 |
</span> |
| 423 |
<?php echo $settings['feedback_link_title']; ?></a> |
| 424 |
<div id="betterdocs-form-modal" class="betterdocs-modalwindow"> |
| 425 |
<div class="modal-inner"> |
| 426 |
<div class="modal-content"> |
| 427 |
<a href="#" class="close"> |
| 428 |
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" |
| 429 |
width="16px" viewBox="0 0 50 50" version="1.1"> |
| 430 |
<g id="surface1"> |
| 431 |
<path style=" " |
| 432 |
d="M 9.15625 6.3125 L 6.3125 9.15625 L 22.15625 25 L 6.21875 40.96875 L 9.03125 43.78125 L 25 27.84375 L 40.9375 43.78125 L 43.78125 40.9375 L 27.84375 25 L 43.6875 9.15625 L 40.84375 6.3125 L 25 22.15625 Z "></path> |
| 433 |
</g> |
| 434 |
</svg> |
| 435 |
</a> |
| 436 |
<h2><?php echo $settings['feedback_form_title']; ?></h2> |
| 437 |
<div class="modal-content-inner"> |
| 438 |
<?php echo do_shortcode("[betterdocs_feedback_form button_text='{$settings['feedback_form_button_text']}']"); ?> |
| 439 |
</div> |
| 440 |
</div> |
| 441 |
</div> |
| 442 |
</div> |
| 443 |
</div> |
| 444 |
<?php |
| 445 |
} |
| 446 |
} |
| 447 |
|
| 448 |
public function feedback_icon () { |
| 449 |
$settings = $this->get_settings_for_display(); |
| 450 |
// $color = $settings['feedback_icon_color']; |
| 451 |
$color = ''; |
| 452 |
?> |
| 453 |
<svg xmlns="http://www.w3.org/2000/svg" width="32px" |
| 454 |
viewBox="0 0 64 64"> |
| 455 |
<linearGradient |
| 456 |
id="zWPy7gPuySZ8fg4Y3QF24a" x1="26" x2="26" y1="630.833" y2="619.332" |
| 457 |
gradientTransform="matrix(1 0 0 -1 0 654)" gradientUnits="userSpaceOnUse" |
| 458 |
spreadMethod="reflect"> |
| 459 |
<stop offset="0" stop-color="#6dc7ff"></stop> |
| 460 |
<stop offset="1" |
| 461 |
stop-color="#e6abff"></stop> |
| 462 |
</linearGradient> |
| 463 |
<path |
| 464 |
fill="<?php echo !empty($color)?$color:'url(#zWPy7gPuySZ8fg4Y3QF24a)' ?>" |
| 465 |
d="M15.082,25.762l9.625,8.141c0.746,0.633,1.84,0.633,2.59,0l9.621-8.141 C37.629,25.16,37.203,24,36.27,24H15.73C14.797,24,14.371,25.16,15.082,25.762z"></path> |
| 466 |
<linearGradient |
| 467 |
id="zWPy7gPuySZ8fg4Y3QF24b" x1="26" x2="26" y1="647.5" y2="596.439" |
| 468 |
gradientTransform="matrix(1 0 0 -1 0 654)" gradientUnits="userSpaceOnUse" |
| 469 |
spreadMethod="reflect"> |
| 470 |
<stop offset="0" stop-color="#1a6dff"></stop> |
| 471 |
<stop offset="1" |
| 472 |
stop-color="#c822ff"></stop> |
| 473 |
</linearGradient> |
| 474 |
<path |
| 475 |
fill="<?php echo !empty($color)?$color:'url(#zWPy7gPuySZ8fg4Y3QF24b)' ?>" d="M18,49h16v2H18V49z"></path> |
| 476 |
<linearGradient |
| 477 |
id="zWPy7gPuySZ8fg4Y3QF24c" x1="32" x2="32" y1="8.915" y2="55.387" |
| 478 |
gradientUnits="userSpaceOnUse" spreadMethod="reflect"> |
| 479 |
<stop offset="0" |
| 480 |
stop-color="#1a6dff"></stop> |
| 481 |
<stop |
| 482 |
offset="1" stop-color="#c822ff"></stop> |
| 483 |
</linearGradient> |
| 484 |
<path |
| 485 |
fill="<?php echo !empty($color)?$color:'url(#zWPy7gPuySZ8fg4Y3QF24c)' ?>" |
| 486 |
d="M48,9c-6.134,0-11.277,4.276-12.637,10H8c-2.758,0-5,2.242-5,5v26c0,2.758,2.242,5,5,5h36 c2.758,0,5-2.242,5-5V35h2v-2h-3c-6.066,0-11-4.934-11-11s4.934-11,11-11s11,4.934,11,11v3c0,1.102-0.898,2-2,2s-2-0.898-2-2v-3 c0-3.859-3.141-7-7-7s-7,3.141-7,7s3.141,7,7,7c2.125,0,4.027-0.953,5.312-2.453C53.918,27.984,55.344,29,57,29c2.207,0,4-1.793,4-4 v-3C61,14.832,55.168,9,48,9z M5,24.109L17.086,34L5,43.891V24.109z M47,50c0,1.652-1.348,3-3,3H8c-1.652,0-3-1.348-3-3v-3.527 l13.668-11.18l4.168,3.41c0.914,0.75,2.039,1.125,3.164,1.125s2.25-0.375,3.164-1.125l4.172-3.41L47,46.473V50z M47,34.949v8.941 L34.914,34l3.618-3.12C40.691,33.18,43.668,34.694,47,34.949z M37.264,29.317l-9.365,7.835c-1.102,0.902-2.699,0.902-3.801,0 L5.699,22.098C6.25,21.434,7.07,21,8,21h27.051C35.025,21.331,35,21.662,35,22C35,24.712,35.837,27.231,37.264,29.317z M48,27 c-2.758,0-5-2.242-5-5s2.242-5,5-5s5,2.242,5,5S50.758,27,48,27z"></path> |
| 487 |
</svg> |
| 488 |
<?php |
| 489 |
} |
| 490 |
} |
| 491 |
|