| 1 |
<?php |
| 2 |
namespace WPDeveloper\BetterDocs\Editors\Elementor\Widget; |
| 3 |
|
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; // Exit if accessed directly |
| 6 |
} |
| 7 |
|
| 8 |
use WPDeveloper\BetterDocs\Editors\Elementor\BaseWidget; |
| 9 |
use Elementor\Controls_Manager; |
| 10 |
use Elementor\Group_Control_Typography; |
| 11 |
use Elementor\Plugin; |
| 12 |
|
| 13 |
class Feedback extends BaseWidget { |
| 14 |
|
| 15 |
public function get_name() { |
| 16 |
return 'betterdocs-feedback'; |
| 17 |
} |
| 18 |
|
| 19 |
public function get_title() { |
| 20 |
return __( 'Doc Feedback', 'betterdocs' ); |
| 21 |
} |
| 22 |
|
| 23 |
public function get_icon() { |
| 24 |
return 'betterdocs-icon-feedback'; |
| 25 |
} |
| 26 |
|
| 27 |
public function get_categories() { |
| 28 |
return [ 'betterdocs-elements-single' ]; |
| 29 |
} |
| 30 |
|
| 31 |
public function get_keywords() { |
| 32 |
return [ 'betterdocs-elements', 'feedback', 'betterdocs', 'docs' ]; |
| 33 |
} |
| 34 |
|
| 35 |
public function get_style_depends() { |
| 36 |
return [ 'betterdocs-feedback-form' ]; |
| 37 |
} |
| 38 |
|
| 39 |
public function get_custom_help_url() { |
| 40 |
return 'https://betterdocs.co/docs/single-doc-in-elementor'; |
| 41 |
} |
| 42 |
|
| 43 |
protected function register_controls() { |
| 44 |
|
| 45 |
/** |
| 46 |
* ---------------------------------------------------------- |
| 47 |
* Section: Layout Options |
| 48 |
* ---------------------------------------------------------- |
| 49 |
*/ |
| 50 |
$this->start_controls_section( |
| 51 |
'section_layout_options', |
| 52 |
[ |
| 53 |
'label' => __( 'General ', 'betterdocs' ) |
| 54 |
] |
| 55 |
); |
| 56 |
|
| 57 |
|
| 58 |
$this->add_control( |
| 59 |
'feedback_form_name_label_text', |
| 60 |
[ |
| 61 |
'label' => __( 'Label Name Text', 'betterdocs' ), |
| 62 |
'type' => Controls_Manager::TEXT, |
| 63 |
'default' => esc_html__( 'Name:', 'betterdocs' ) |
| 64 |
] |
| 65 |
); |
| 66 |
|
| 67 |
|
| 68 |
$this->add_control( |
| 69 |
'feedback_form_email_label_text', |
| 70 |
[ |
| 71 |
'label' => __( 'Label Email Text', 'betterdocs' ), |
| 72 |
'type' => Controls_Manager::TEXT, |
| 73 |
'default' => esc_html__( 'Email:', 'betterdocs' ) |
| 74 |
] |
| 75 |
); |
| 76 |
|
| 77 |
$this->add_control( |
| 78 |
'feedback_form_message_label_text', |
| 79 |
[ |
| 80 |
'label' => __( 'Label Message Text', 'betterdocs' ), |
| 81 |
'type' => Controls_Manager::TEXT, |
| 82 |
'default' => esc_html__( 'Message:', 'betterdocs' ) |
| 83 |
] |
| 84 |
); |
| 85 |
|
| 86 |
$this->add_control( |
| 87 |
'feedback_link_title', |
| 88 |
[ |
| 89 |
'label' => __( 'Content', 'betterdocs' ), |
| 90 |
'type' => Controls_Manager::TEXT, |
| 91 |
'default' => esc_html__( 'Still stuck? How can we help?', 'betterdocs' ) |
| 92 |
] |
| 93 |
); |
| 94 |
$this->add_control( |
| 95 |
'feedback_form_title', |
| 96 |
[ |
| 97 |
'label' => __( 'Feedback Form Title', 'betterdocs' ), |
| 98 |
'type' => Controls_Manager::TEXT, |
| 99 |
'default' => esc_html__( 'How can we help?', 'betterdocs' ) |
| 100 |
] |
| 101 |
); |
| 102 |
|
| 103 |
$this->add_control( |
| 104 |
'feedback_form_button_text', |
| 105 |
[ |
| 106 |
'label' => __( 'Button Text', 'betterdocs' ), |
| 107 |
'type' => Controls_Manager::TEXT, |
| 108 |
'default' => 'Send', |
| 109 |
'placeholder' => __( 'Enter button text', 'betterdocs' ), |
| 110 |
'title' => __( 'Enter button text here', 'betterdocs' ) |
| 111 |
] |
| 112 |
); |
| 113 |
|
| 114 |
$this->add_control( |
| 115 |
'feedback_form_icon_image', |
| 116 |
[ |
| 117 |
'label' => esc_html__( 'Choose Feedback Icon Image', 'betterdocs' ), |
| 118 |
'type' => Controls_Manager::MEDIA, |
| 119 |
'default' => [ |
| 120 |
'url' => '', |
| 121 |
], |
| 122 |
] |
| 123 |
); |
| 124 |
|
| 125 |
$this->end_controls_section(); |
| 126 |
|
| 127 |
$this->start_controls_section( |
| 128 |
'section_card_settings_text', |
| 129 |
[ |
| 130 |
'label' => __( 'Text', 'betterdocs' ), |
| 131 |
'tab' => Controls_Manager::TAB_STYLE |
| 132 |
] |
| 133 |
); |
| 134 |
|
| 135 |
$this->add_control( |
| 136 |
'feedback_text_color', |
| 137 |
[ |
| 138 |
'label' => esc_html__( 'Color', 'betterdocs' ), |
| 139 |
'type' => Controls_Manager::COLOR, |
| 140 |
'selectors' => [ |
| 141 |
'{{WRAPPER}} .feedback-form-link' => 'color: {{VALUE}};' |
| 142 |
] |
| 143 |
] |
| 144 |
); |
| 145 |
|
| 146 |
$this->add_group_control( |
| 147 |
Group_Control_Typography::get_type(), |
| 148 |
[ |
| 149 |
'name' => 'feedback_text_typography', |
| 150 |
'selector' => '{{WRAPPER}} .feedback-form-link' |
| 151 |
] |
| 152 |
); |
| 153 |
|
| 154 |
$this->end_controls_section(); |
| 155 |
|
| 156 |
$this->icon_section(); |
| 157 |
|
| 158 |
$this->feedback_form(); |
| 159 |
} |
| 160 |
|
| 161 |
public function icon_section() { |
| 162 |
$this->start_controls_section( |
| 163 |
'section_icon_options', |
| 164 |
[ |
| 165 |
'label' => __( 'Icon ', 'betterdocs' ), |
| 166 |
'tab' => Controls_Manager::TAB_STYLE |
| 167 |
] |
| 168 |
); |
| 169 |
|
| 170 |
$this->add_control( |
| 171 |
'feedback_icon_color', |
| 172 |
[ |
| 173 |
'label' => esc_html__( 'Color', 'betterdocs' ), |
| 174 |
'type' => Controls_Manager::COLOR |
| 175 |
] |
| 176 |
); |
| 177 |
|
| 178 |
$this->add_control( |
| 179 |
'feedback_text_icon_size', |
| 180 |
[ |
| 181 |
'label' => __( 'Size', 'betterdocs' ), |
| 182 |
'type' => Controls_Manager::SLIDER, |
| 183 |
'size_units' => [ 'px' ], |
| 184 |
'range' => [ |
| 185 |
'px' => [ |
| 186 |
'max' => 1000, |
| 187 |
'step' => 1 |
| 188 |
] |
| 189 |
], |
| 190 |
'selectors' => [ |
| 191 |
'{{WRAPPER}} .feedback-form-icon svg' => 'width: {{SIZE}}px;height: {{SIZE}}px;', |
| 192 |
'{{WRAPPER}} .feedback-form-icon img' => 'width: {{SIZE}}px;height: {{SIZE}}px;' |
| 193 |
] |
| 194 |
] |
| 195 |
); |
| 196 |
|
| 197 |
$this->end_controls_section(); |
| 198 |
} |
| 199 |
|
| 200 |
public function feedback_form() { |
| 201 |
/** |
| 202 |
* ---------------------------------------------------------- |
| 203 |
* Section: Box Styles |
| 204 |
* ---------------------------------------------------------- |
| 205 |
*/ |
| 206 |
$this->start_controls_section( |
| 207 |
'section_card_settings', |
| 208 |
[ |
| 209 |
'label' => __( 'FeedBack Form', 'betterdocs' ), |
| 210 |
'tab' => Controls_Manager::TAB_STYLE |
| 211 |
] |
| 212 |
); |
| 213 |
|
| 214 |
$this->add_control( |
| 215 |
'feedback_form_width', |
| 216 |
[ |
| 217 |
'label' => __( 'Width', 'betterdocs' ), |
| 218 |
'type' => Controls_Manager::SLIDER, |
| 219 |
'size_units' => [ 'px' ], |
| 220 |
'range' => [ |
| 221 |
'px' => [ |
| 222 |
'max' => 1000, |
| 223 |
'step' => 1 |
| 224 |
] |
| 225 |
], |
| 226 |
'selectors' => [ |
| 227 |
'{{WRAPPER}} .betterdocs-modalwindow .modal-content' => 'width: {{SIZE}}px;' |
| 228 |
] |
| 229 |
] |
| 230 |
); |
| 231 |
|
| 232 |
$this->add_control( |
| 233 |
'feedback_form_height', |
| 234 |
[ |
| 235 |
'label' => __( 'Height', 'betterdocs' ), |
| 236 |
'type' => Controls_Manager::SLIDER, |
| 237 |
'size_units' => [ 'px' ], |
| 238 |
'range' => [ |
| 239 |
'px' => [ |
| 240 |
'max' => 1000, |
| 241 |
'step' => 1 |
| 242 |
] |
| 243 |
], |
| 244 |
'selectors' => [ |
| 245 |
'{{WRAPPER}} .betterdocs-modalwindow .modal-content' => 'height: {{SIZE}}px;' |
| 246 |
] |
| 247 |
] |
| 248 |
); |
| 249 |
|
| 250 |
$this->add_control( |
| 251 |
'feedback_form_heading', |
| 252 |
[ |
| 253 |
'label' => esc_html__( 'Heading', 'betterdocs' ), |
| 254 |
'type' => Controls_Manager::HEADING |
| 255 |
] |
| 256 |
); |
| 257 |
|
| 258 |
$this->add_control( |
| 259 |
'feedback_form_heading_color', |
| 260 |
[ |
| 261 |
'label' => esc_html__( 'Color', 'betterdocs' ), |
| 262 |
'type' => Controls_Manager::COLOR, |
| 263 |
'selectors' => [ |
| 264 |
'{{WRAPPER}} #betterdocs-form-modal .modal-inner .modal-content .feedback-form-title' => 'color: {{VALUE}};' |
| 265 |
] |
| 266 |
] |
| 267 |
); |
| 268 |
|
| 269 |
$this->add_group_control( |
| 270 |
Group_Control_Typography::get_type(), |
| 271 |
[ |
| 272 |
'name' => 'feedback_form_heading_typography', |
| 273 |
'selector' => '{{WRAPPER}} #betterdocs-form-modal .modal-inner .modal-content .feedback-form-title' |
| 274 |
] |
| 275 |
); |
| 276 |
|
| 277 |
$this->add_responsive_control( |
| 278 |
'align', |
| 279 |
[ |
| 280 |
'label' => __( 'Alignment', 'betterdocs' ), |
| 281 |
'type' => Controls_Manager::CHOOSE, |
| 282 |
'options' => [ |
| 283 |
'left' => [ |
| 284 |
'title' => __( 'Left', 'betterdocs' ), |
| 285 |
'icon' => 'eicon-text-align-left' |
| 286 |
], |
| 287 |
'center' => [ |
| 288 |
'title' => __( 'Center', 'betterdocs' ), |
| 289 |
'icon' => 'eicon-text-align-center' |
| 290 |
], |
| 291 |
'right' => [ |
| 292 |
'title' => __( 'Right', 'betterdocs' ), |
| 293 |
'icon' => 'eicon-text-align-right' |
| 294 |
], |
| 295 |
'justify' => [ |
| 296 |
'title' => __( 'Justified', 'betterdocs' ), |
| 297 |
'icon' => 'eicon-text-align-justify' |
| 298 |
] |
| 299 |
], |
| 300 |
'default' => '', |
| 301 |
'selectors' => [ |
| 302 |
'{{WRAPPER}} #betterdocs-form-modal .modal-inner .modal-content .feedback-form-title' => 'text-align: {{VALUE}};' |
| 303 |
] |
| 304 |
] |
| 305 |
); |
| 306 |
|
| 307 |
$this->add_control( |
| 308 |
'feedback_form_label', |
| 309 |
[ |
| 310 |
'label' => esc_html__( 'Lable', 'betterdocs' ), |
| 311 |
'type' => Controls_Manager::HEADING |
| 312 |
] |
| 313 |
); |
| 314 |
|
| 315 |
$this->add_control( |
| 316 |
'feedback_form_label_color', |
| 317 |
[ |
| 318 |
'label' => esc_html__( 'Color', 'betterdocs' ), |
| 319 |
'type' => Controls_Manager::COLOR, |
| 320 |
'selectors' => [ |
| 321 |
'{{WRAPPER}} .betterdocs-modalwindow .betterdocs-feedback-form label' => 'color: {{VALUE}};' |
| 322 |
] |
| 323 |
] |
| 324 |
); |
| 325 |
|
| 326 |
$this->add_group_control( |
| 327 |
Group_Control_Typography::get_type(), |
| 328 |
[ |
| 329 |
'name' => 'feedback_form_label_typography', |
| 330 |
'selector' => '{{WRAPPER}} .betterdocs-modalwindow .betterdocs-feedback-form label' |
| 331 |
] |
| 332 |
); |
| 333 |
|
| 334 |
$this->add_control( |
| 335 |
'feedback_form_label_space', |
| 336 |
[ |
| 337 |
'label' => __( 'Space', 'betterdocs' ), |
| 338 |
'type' => Controls_Manager::SLIDER, |
| 339 |
'size_units' => [ 'px' ], |
| 340 |
'range' => [ |
| 341 |
'px' => [ |
| 342 |
'max' => 500, |
| 343 |
'step' => 1 |
| 344 |
] |
| 345 |
], |
| 346 |
'selectors' => [ |
| 347 |
'{{WRAPPER}} .betterdocs-modalwindow .betterdocs-feedback-form label input,{{WRAPPER}} .betterdocs-modalwindow .betterdocs-feedback-form label textarea' => 'margin-top: {{SIZE}}{{UNIT}};' |
| 348 |
] |
| 349 |
] |
| 350 |
); |
| 351 |
|
| 352 |
$this->add_control( |
| 353 |
'feedback_form_button', |
| 354 |
[ |
| 355 |
'label' => esc_html__( 'Button', 'betterdocs' ), |
| 356 |
'type' => Controls_Manager::HEADING |
| 357 |
] |
| 358 |
); |
| 359 |
|
| 360 |
$this->add_control( |
| 361 |
'feedback_form_button_background', |
| 362 |
[ |
| 363 |
'label' => esc_html__( 'Background', 'betterdocs' ), |
| 364 |
'type' => Controls_Manager::COLOR, |
| 365 |
'selectors' => [ |
| 366 |
'{{WRAPPER}} .betterdocs-feedback-form #feedback_form_submit_btn' => 'background-color: {{VALUE}};' |
| 367 |
] |
| 368 |
] |
| 369 |
); |
| 370 |
|
| 371 |
$this->add_control( |
| 372 |
'feedback_form_button_color', |
| 373 |
[ |
| 374 |
'label' => esc_html__( 'Text Color', 'betterdocs' ), |
| 375 |
'type' => Controls_Manager::COLOR, |
| 376 |
'selectors' => [ |
| 377 |
'{{WRAPPER}} .betterdocs-feedback-form #feedback_form_submit_btn' => 'color: {{VALUE}};' |
| 378 |
] |
| 379 |
] |
| 380 |
); |
| 381 |
|
| 382 |
$this->add_group_control( |
| 383 |
Group_Control_Typography::get_type(), |
| 384 |
[ |
| 385 |
'name' => 'feedback_form_button_typography', |
| 386 |
'selector' => '{{WRAPPER}} .betterdocs-feedback-form #feedback_form_submit_btn' |
| 387 |
] |
| 388 |
); |
| 389 |
|
| 390 |
$this->add_responsive_control( |
| 391 |
'feedback_form_button_width', |
| 392 |
[ |
| 393 |
'label' => esc_html__( 'Width', 'betterdocs' ), |
| 394 |
'type' => Controls_Manager::SLIDER, |
| 395 |
'size_units' => [ 'px', '%' ], |
| 396 |
'range' => [ |
| 397 |
'px' => [ |
| 398 |
'min' => 0, |
| 399 |
'max' => 500, |
| 400 |
'step' => 1 |
| 401 |
], |
| 402 |
'%' => [ |
| 403 |
'min' => 0, |
| 404 |
'max' => 100 |
| 405 |
] |
| 406 |
], |
| 407 |
'selectors' => [ |
| 408 |
'{{WRAPPER}} .betterdocs-feedback-form #feedback_form_submit_btn' => 'width: {{SIZE}}{{UNIT}};' |
| 409 |
] |
| 410 |
] |
| 411 |
); |
| 412 |
|
| 413 |
$this->add_control( |
| 414 |
'feedback_form_button_padding', |
| 415 |
[ |
| 416 |
'label' => __( 'Padding', 'betterdocs' ), |
| 417 |
'type' => Controls_Manager::DIMENSIONS, |
| 418 |
'size_units' => [ 'px', 'em', '%' ], |
| 419 |
'selectors' => [ |
| 420 |
'{{WRAPPER}} .betterdocs-feedback-form #feedback_form_submit_btn' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' |
| 421 |
] |
| 422 |
] |
| 423 |
); |
| 424 |
|
| 425 |
$this->add_responsive_control( |
| 426 |
'feedback_form_button_align', |
| 427 |
[ |
| 428 |
'label' => __( 'Alignment', 'betterdocs' ), |
| 429 |
'type' => Controls_Manager::CHOOSE, |
| 430 |
'options' => [ |
| 431 |
'left' => [ |
| 432 |
'title' => __( 'Left', 'betterdocs' ), |
| 433 |
'icon' => 'eicon-text-align-left' |
| 434 |
], |
| 435 |
'center' => [ |
| 436 |
'title' => __( 'Center', 'betterdocs' ), |
| 437 |
'icon' => 'eicon-text-align-center' |
| 438 |
], |
| 439 |
'right' => [ |
| 440 |
'title' => __( 'Right', 'betterdocs' ), |
| 441 |
'icon' => 'eicon-text-align-right' |
| 442 |
], |
| 443 |
'justify' => [ |
| 444 |
'title' => __( 'Justified', 'betterdocs' ), |
| 445 |
'icon' => 'eicon-text-align-justify' |
| 446 |
] |
| 447 |
], |
| 448 |
'default' => '', |
| 449 |
'selectors' => [ |
| 450 |
'{{WRAPPER}} .betterdocs-feedback-form .feedback-from-button' => 'text-align: {{VALUE}};' |
| 451 |
] |
| 452 |
] |
| 453 |
); |
| 454 |
|
| 455 |
$this->end_controls_section(); |
| 456 |
} |
| 457 |
|
| 458 |
protected function render_callback() { |
| 459 |
$settings = $this->get_settings_for_display(); |
| 460 |
|
| 461 |
betterdocs()->views->get( |
| 462 |
'templates/feedback-parts/form', |
| 463 |
[ |
| 464 |
'widget' => $this, |
| 465 |
'settings' => $settings |
| 466 |
] |
| 467 |
); |
| 468 |
|
| 469 |
if ( Plugin::instance()->editor->is_edit_mode() ) { |
| 470 |
$this->render_editor_script(); |
| 471 |
} |
| 472 |
} |
| 473 |
|
| 474 |
public function render_editor_script() { |
| 475 |
betterdocs()->views->get( 'templates/feedback-parts/editor' ); |
| 476 |
} |
| 477 |
} |
| 478 |
|