elementor_widget_book_button.php
1 year ago
elementor_widget_book_form.php
1 year ago
elementor_widget_calendar.php
1 year ago
elementor_widget_customer_dashboard.php
1 year ago
elementor_widget_customer_login.php
1 year ago
elementor_widget_list_of_resources.php
1 year ago
elementor_widget_book_button.php
541 lines
| 1 | <?php |
| 2 | |
| 3 | class Latepoint_Elementor_Widget_Book_Button extends \Elementor\Widget_Base { |
| 4 | |
| 5 | protected $widget_data; |
| 6 | /** |
| 7 | * Widget base constructor |
| 8 | */ |
| 9 | public function __construct( $data = [], $args = null ) { |
| 10 | $this->widget_data = $args; |
| 11 | parent::__construct( $data, $args ); |
| 12 | |
| 13 | wp_register_script( |
| 14 | 'elementor_widget_book_button_script', |
| 15 | LATEPOINT_PLUGIN_URL . 'blocks/assets/javascripts/elementor-widget-book-button.js', |
| 16 | ['jquery'], |
| 17 | LATEPOINT_VERSION |
| 18 | ); |
| 19 | } |
| 20 | |
| 21 | |
| 22 | /** |
| 23 | * Get widget name |
| 24 | */ |
| 25 | public function get_name(): string { |
| 26 | return 'latepoint_book_button'; |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Get widget title |
| 31 | */ |
| 32 | public function get_title(): string { |
| 33 | return esc_html__( 'Booking Button', 'latepoint' ); |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Get widget icon |
| 38 | */ |
| 39 | public function get_icon(): string { |
| 40 | return 'eicon-dual-button'; |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Get widget categories |
| 45 | */ |
| 46 | public function get_categories(): array { |
| 47 | return [ OsElementorHelper::$category ]; |
| 48 | } |
| 49 | |
| 50 | public function get_script_depends() { |
| 51 | if (\Elementor\Plugin::$instance->editor->is_edit_mode() || \Elementor\Plugin::$instance->preview->is_preview_mode()) { |
| 52 | return ['elementor_widget_book_button_script']; |
| 53 | } |
| 54 | return []; |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Register widget controls |
| 59 | */ |
| 60 | protected function register_controls(): void { |
| 61 | |
| 62 | # Booking Form Settings Section |
| 63 | $this->start_controls_section( |
| 64 | 'content_section_booking_form_settings', |
| 65 | [ |
| 66 | 'label' => esc_html__( 'Booking Form Settings', 'latepoint' ), |
| 67 | 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, |
| 68 | ] |
| 69 | ); |
| 70 | |
| 71 | $this->add_control( |
| 72 | 'caption', |
| 73 | [ |
| 74 | 'label' => esc_html__( 'Button Caption', 'latepoint' ), |
| 75 | 'type' => \Elementor\Controls_Manager::TEXT, |
| 76 | 'default' => esc_html__( 'Book Appointment', 'latepoint' ), |
| 77 | ] |
| 78 | ); |
| 79 | |
| 80 | $this->add_control( |
| 81 | 'hide_summary', |
| 82 | [ |
| 83 | 'label' => esc_html__( 'Hide Summary Panel', 'latepoint' ), |
| 84 | 'type' => \Elementor\Controls_Manager::SWITCHER, |
| 85 | 'label_on' => esc_html__( 'Yes', 'latepoint' ), |
| 86 | 'label_off' => esc_html__( 'No', 'latepoint' ), |
| 87 | 'return_value' => 'yes', |
| 88 | 'default' => 'no', |
| 89 | ] |
| 90 | ); |
| 91 | |
| 92 | $this->add_control( |
| 93 | 'hide_side_panel', |
| 94 | [ |
| 95 | 'label' => esc_html__( 'Hide Side Panel', 'latepoint' ), |
| 96 | 'type' => \Elementor\Controls_Manager::SWITCHER, |
| 97 | 'label_on' => esc_html__( 'Yes', 'latepoint' ), |
| 98 | 'label_off' => esc_html__( 'No', 'latepoint' ), |
| 99 | 'return_value' => 'yes', |
| 100 | 'default' => 'no', |
| 101 | ] |
| 102 | ); |
| 103 | |
| 104 | $this->end_controls_section(); |
| 105 | |
| 106 | |
| 107 | # Step Settings Section |
| 108 | $this->start_controls_section( |
| 109 | 'content_section_step_settings', |
| 110 | [ |
| 111 | 'label' => esc_html__( 'Step Settings', 'latepoint' ), |
| 112 | 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, |
| 113 | ] |
| 114 | ); |
| 115 | |
| 116 | $this->add_control( |
| 117 | 'selected_agent', |
| 118 | [ |
| 119 | 'label' => esc_html__('Preselected Agent', 'latepoint'), |
| 120 | 'type' => \Elementor\Controls_Manager::SELECT, |
| 121 | 'default' => '', |
| 122 | 'options' => $this->widget_data['selected_agents_options'], |
| 123 | ] |
| 124 | ); |
| 125 | |
| 126 | $this->add_control( |
| 127 | 'selected_service', |
| 128 | [ |
| 129 | 'label' => esc_html__('Preselected Service', 'latepoint'), |
| 130 | 'type' => \Elementor\Controls_Manager::SELECT, |
| 131 | 'default' => '', |
| 132 | 'options' => $this->widget_data['selected_services_options'], |
| 133 | ] |
| 134 | ); |
| 135 | $this->add_control( |
| 136 | 'selected_service_category', |
| 137 | [ |
| 138 | 'label' => esc_html__('Preselected Service Category', 'latepoint'), |
| 139 | 'type' => \Elementor\Controls_Manager::SELECT, |
| 140 | 'default' => '', |
| 141 | 'options' => $this->widget_data['selected_service_categories_options'], |
| 142 | ] |
| 143 | ); |
| 144 | |
| 145 | $this->add_control( |
| 146 | 'selected_bundle', |
| 147 | [ |
| 148 | 'label' => esc_html__('Preselected Bundle', 'latepoint'), |
| 149 | 'type' => \Elementor\Controls_Manager::SELECT, |
| 150 | 'default' => '', |
| 151 | 'options' => $this->widget_data['selected_bundles_options'], |
| 152 | ] |
| 153 | ); |
| 154 | |
| 155 | $this->add_control( |
| 156 | 'selected_location', |
| 157 | [ |
| 158 | 'label' => esc_html__('Preselected Location', 'latepoint'), |
| 159 | 'type' => \Elementor\Controls_Manager::SELECT, |
| 160 | 'default' => '', |
| 161 | 'options' => $this->widget_data['selected_locations_options'], |
| 162 | ] |
| 163 | ); |
| 164 | $this->add_control( |
| 165 | 'selected_start_date', |
| 166 | [ |
| 167 | 'label' => esc_html__( 'Preselected Booking Start Date', 'latepoint' ), |
| 168 | 'type' => \Elementor\Controls_Manager::DATE_TIME, |
| 169 | 'picker_options' => ['enableTime' => false], |
| 170 | 'label_block' => false, |
| 171 | 'default' => '' |
| 172 | ] |
| 173 | ); |
| 174 | $this->add_control( |
| 175 | 'selected_start_time', |
| 176 | [ |
| 177 | 'label' => esc_html__( 'Preselected Booking Start Time', 'latepoint' ), |
| 178 | 'type' => \Elementor\Controls_Manager::TEXT, |
| 179 | 'input_type' => 'time', |
| 180 | 'placeholder' => esc_html__( 'HH:MM', 'latepoint' ), |
| 181 | 'description' => esc_html__( 'Choose a time (format HH:MM)', 'latepoint' ), |
| 182 | 'default' => '' |
| 183 | ] |
| 184 | ); |
| 185 | $this->add_control( |
| 186 | 'selected_duration', |
| 187 | [ |
| 188 | 'label' => esc_html__( 'Preselected Duration', 'latepoint' ), |
| 189 | 'type' => \Elementor\Controls_Manager::NUMBER, |
| 190 | 'min' => 0, |
| 191 | 'step' => 1, |
| 192 | 'default' => "", |
| 193 | 'description' => esc_html__( 'Minutes', 'latepoint' ), |
| 194 | ] |
| 195 | ); |
| 196 | $this->add_control( |
| 197 | 'selected_total_attendees', |
| 198 | [ |
| 199 | 'label' => esc_html__( 'Preselected Total Attendees', 'latepoint' ), |
| 200 | 'type' => \Elementor\Controls_Manager::NUMBER, |
| 201 | 'min' => 0, |
| 202 | 'step' => 1, |
| 203 | 'default' => "", |
| 204 | ] |
| 205 | ); |
| 206 | |
| 207 | |
| 208 | $this->end_controls_section(); |
| 209 | |
| 210 | |
| 211 | # Button Appearance Section |
| 212 | $this->start_controls_section( |
| 213 | 'content_section_button_appearance', |
| 214 | [ |
| 215 | 'label' => esc_html__( 'Button Appearance', 'latepoint' ), |
| 216 | 'tab' => \Elementor\Controls_Manager::TAB_STYLE, |
| 217 | ] |
| 218 | ); |
| 219 | |
| 220 | # Position |
| 221 | $this->add_responsive_control( |
| 222 | 'btn_align', |
| 223 | [ |
| 224 | 'label' => esc_html__( 'Position', 'latepoint' ), |
| 225 | 'type' => \Elementor\Controls_Manager::CHOOSE, |
| 226 | 'options' => [ |
| 227 | 'left' => [ |
| 228 | 'title' => esc_html__( 'Left', 'latepoint' ), |
| 229 | 'icon' => 'eicon-h-align-left', |
| 230 | ], |
| 231 | 'center' => [ |
| 232 | 'title' => esc_html__( 'Center', 'latepoint' ), |
| 233 | 'icon' => 'eicon-h-align-center', |
| 234 | ], |
| 235 | 'right' => [ |
| 236 | 'title' => esc_html__( 'Right', 'latepoint' ), |
| 237 | 'icon' => 'eicon-h-align-right', |
| 238 | ], |
| 239 | 'justify' => [ |
| 240 | 'title' => esc_html__( 'Stretch', 'latepoint' ), |
| 241 | 'icon' => 'eicon-h-align-stretch', |
| 242 | ], |
| 243 | ], |
| 244 | 'prefix_class' => 'elementor%s-align-', |
| 245 | 'default' => '', |
| 246 | 'toggle' => true |
| 247 | ] |
| 248 | ); |
| 249 | |
| 250 | $this->add_control( |
| 251 | 'is_inherit', |
| 252 | [ |
| 253 | 'label' => esc_html__( 'Inherit From Theme', 'latepoint' ), |
| 254 | 'type' => \Elementor\Controls_Manager::SWITCHER, |
| 255 | 'label_on' => esc_html__( 'Yes', 'latepoint' ), |
| 256 | 'label_off' => esc_html__( 'No', 'latepoint' ), |
| 257 | 'return_value' => 'yes', |
| 258 | 'default' => 'no', |
| 259 | ] |
| 260 | ); |
| 261 | |
| 262 | # Divider |
| 263 | $this->add_control( 'hr3', [ |
| 264 | 'type' => \Elementor\Controls_Manager::DIVIDER, |
| 265 | 'condition' => ['is_inherit!' => 'yes'], |
| 266 | ]); |
| 267 | |
| 268 | |
| 269 | # Typography |
| 270 | $this->add_group_control( |
| 271 | \Elementor\Group_Control_Typography::get_type(), |
| 272 | [ |
| 273 | 'name' => 'button_typography', |
| 274 | 'selector' => '{{WRAPPER}} .latepoint-book-button', |
| 275 | 'condition' => ['is_inherit!' => 'yes'], |
| 276 | ] |
| 277 | ); |
| 278 | |
| 279 | #Text Shadow |
| 280 | $this->add_group_control( |
| 281 | \Elementor\Group_Control_Text_Shadow::get_type(), |
| 282 | [ |
| 283 | 'name' => 'text_shadow', |
| 284 | 'selector' => '{{WRAPPER}} .latepoint-book-button', |
| 285 | 'condition' => ['is_inherit!' => 'yes'], |
| 286 | ] |
| 287 | ); |
| 288 | |
| 289 | |
| 290 | #Tabs |
| 291 | |
| 292 | $this->start_controls_tabs('style_tabs', [ |
| 293 | 'condition' => ['is_inherit!' => 'yes'], |
| 294 | ]); |
| 295 | |
| 296 | $this->start_controls_tab( 'style_normal_tab', [ |
| 297 | 'label' => esc_html__( 'Normal', 'latepoint' ), |
| 298 | ] |
| 299 | ); |
| 300 | |
| 301 | $this->add_control( |
| 302 | 'bg_color', |
| 303 | [ |
| 304 | 'label' => esc_html__( 'Background', 'latepoint' ), |
| 305 | 'type' => \Elementor\Controls_Manager::COLOR, |
| 306 | 'selectors' => [ |
| 307 | '{{WRAPPER}} .latepoint-book-button' => 'background-color: {{VALUE}}', |
| 308 | ], |
| 309 | 'default' => '' |
| 310 | ] |
| 311 | ); |
| 312 | |
| 313 | $this->add_control( |
| 314 | 'text_color', |
| 315 | [ |
| 316 | 'label' => esc_html__( 'Text Color', 'latepoint' ), |
| 317 | 'type' => \Elementor\Controls_Manager::COLOR, |
| 318 | 'selectors' => [ |
| 319 | '{{WRAPPER}} .latepoint-book-button' => 'color: {{VALUE}}', |
| 320 | ], |
| 321 | 'default' => '' |
| 322 | ] |
| 323 | ); |
| 324 | |
| 325 | $this->end_controls_tab(); |
| 326 | |
| 327 | |
| 328 | $this->start_controls_tab( 'style_hover_tab', [ |
| 329 | 'label' => esc_html__( 'Hover', 'latepoint' ), |
| 330 | ] |
| 331 | ); |
| 332 | $this->add_control( |
| 333 | 'bg_color_hover', |
| 334 | [ |
| 335 | 'label' => esc_html__( 'Background', 'latepoint' ), |
| 336 | 'type' => \Elementor\Controls_Manager::COLOR, |
| 337 | 'selectors' => [ |
| 338 | '{{WRAPPER}} .latepoint-book-button:hover' => 'background-color: {{VALUE}}', |
| 339 | ], |
| 340 | 'default' => '' |
| 341 | ] |
| 342 | ); |
| 343 | $this->add_control( |
| 344 | 'text_color_hover', |
| 345 | [ |
| 346 | 'label' => esc_html__( 'Text Color', 'latepoint' ), |
| 347 | 'type' => \Elementor\Controls_Manager::COLOR, |
| 348 | 'default' => '', |
| 349 | 'selectors' => [ |
| 350 | '{{WRAPPER}} .latepoint-book-button:hover' => 'color: {{VALUE}}', |
| 351 | ], |
| 352 | ] |
| 353 | ); |
| 354 | $this->end_controls_tab(); |
| 355 | |
| 356 | $this->end_controls_tabs(); |
| 357 | |
| 358 | # Divider |
| 359 | $this->add_control( 'hr2', [ |
| 360 | 'type' => \Elementor\Controls_Manager::DIVIDER, |
| 361 | 'condition' => ['is_inherit!' => 'yes'], |
| 362 | ]); |
| 363 | |
| 364 | # Border Controls |
| 365 | $this->add_group_control( |
| 366 | \Elementor\Group_Control_Border::get_type(), |
| 367 | [ |
| 368 | 'name' => 'border', |
| 369 | 'label' => esc_html__( 'Button Border', 'latepoint' ), |
| 370 | 'selector' => '{{WRAPPER}} .latepoint-book-button', |
| 371 | 'condition' => ['is_inherit!' => 'yes'], |
| 372 | 'default' => '' |
| 373 | ] |
| 374 | ); |
| 375 | |
| 376 | # Border Radius |
| 377 | $this->add_responsive_control( |
| 378 | 'border_radius', |
| 379 | [ |
| 380 | 'label' => esc_html__( 'Border Radius', 'latepoint' ), |
| 381 | 'type' => \Elementor\Controls_Manager::DIMENSIONS, |
| 382 | 'size_units' => [ 'px', '%', 'em', 'rem' ], |
| 383 | 'selectors' => [ |
| 384 | '{{WRAPPER}} .latepoint-book-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 385 | ], |
| 386 | 'condition' => ['is_inherit!' => 'yes'], |
| 387 | ] |
| 388 | ); |
| 389 | |
| 390 | $this->add_group_control( |
| 391 | \Elementor\Group_Control_Box_Shadow::get_type(), |
| 392 | [ |
| 393 | 'name' => 'box_shadow', |
| 394 | 'selector' => '{{WRAPPER}} .latepoint-book-button', |
| 395 | 'condition' => ['is_inherit!' => 'yes'], |
| 396 | 'default' => '' |
| 397 | ] |
| 398 | ); |
| 399 | |
| 400 | |
| 401 | # Divider |
| 402 | $this->add_control( 'hr1', [ |
| 403 | 'type' => \Elementor\Controls_Manager::DIVIDER, |
| 404 | 'condition' => ['is_inherit!' => 'yes'], |
| 405 | ]); |
| 406 | |
| 407 | |
| 408 | # Padding Controls |
| 409 | $this->add_responsive_control( |
| 410 | 'padding', |
| 411 | [ |
| 412 | 'label' => esc_html__( 'Padding', 'latepoint' ), |
| 413 | 'type' => \Elementor\Controls_Manager::DIMENSIONS, |
| 414 | 'size_units' => [ 'px', '%', 'em', 'rem' ], |
| 415 | 'selectors' => [ |
| 416 | '{{WRAPPER}} .latepoint-book-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 417 | ], |
| 418 | 'condition' => ['is_inherit!' => 'yes'], |
| 419 | ] |
| 420 | ); |
| 421 | |
| 422 | $this->end_controls_section(); |
| 423 | |
| 424 | |
| 425 | # Other Settings Section |
| 426 | $this->start_controls_section( |
| 427 | 'content_section_other_settings', |
| 428 | [ |
| 429 | 'label' => esc_html__( 'Other Settings', 'latepoint' ), |
| 430 | 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, |
| 431 | ] |
| 432 | ); |
| 433 | |
| 434 | $this->add_control( |
| 435 | 'source_id', |
| 436 | [ |
| 437 | 'label' => esc_html__( 'Source ID', 'latepoint' ), |
| 438 | 'type' => \Elementor\Controls_Manager::NUMBER, |
| 439 | 'min' => 0, |
| 440 | 'step' => 1, |
| 441 | 'default' => '', |
| 442 | ] |
| 443 | ); |
| 444 | |
| 445 | $this->add_control( |
| 446 | 'calendar_start_date', |
| 447 | [ |
| 448 | 'label' => esc_html__( 'Calendar Start Date', 'latepoint' ), |
| 449 | 'type' => \Elementor\Controls_Manager::DATE_TIME, |
| 450 | 'picker_options' => ['enableTime' => false], |
| 451 | 'label_block' => false, |
| 452 | 'default' => '' |
| 453 | ] |
| 454 | ); |
| 455 | |
| 456 | $this->add_control( |
| 457 | 'show_services', |
| 458 | [ |
| 459 | 'label' => esc_html__('Show Services', 'latepoint'), |
| 460 | 'type' => \Elementor\Controls_Manager::SELECT2, |
| 461 | 'default' => '', |
| 462 | 'options' => $this->widget_data['services'], |
| 463 | 'multiple' => true |
| 464 | ] |
| 465 | ); |
| 466 | |
| 467 | $this->add_control( |
| 468 | 'show_service_categories', |
| 469 | [ |
| 470 | 'label' => esc_html__( 'Show Service Categories', 'latepoint' ), |
| 471 | 'type' => \Elementor\Controls_Manager::SELECT2, |
| 472 | 'default' => '', |
| 473 | 'multiple' => true, |
| 474 | 'options' => $this->widget_data['service_categories'], |
| 475 | ] |
| 476 | ); |
| 477 | |
| 478 | $this->add_control( |
| 479 | 'show_agents', |
| 480 | [ |
| 481 | 'label' => esc_html__( 'Show Agents', 'latepoint' ), |
| 482 | 'type' => \Elementor\Controls_Manager::SELECT2, |
| 483 | 'default' => '', |
| 484 | 'multiple' => true, |
| 485 | 'options' => $this->widget_data['agents'], |
| 486 | ] |
| 487 | ); |
| 488 | |
| 489 | $this->add_control( |
| 490 | 'show_locations', |
| 491 | [ |
| 492 | 'label' => esc_html__( 'Show Locations', 'latepoint' ), |
| 493 | 'type' => \Elementor\Controls_Manager::SELECT2, |
| 494 | 'default' => '', |
| 495 | 'multiple' => true, |
| 496 | 'options' => $this->widget_data['locations'], |
| 497 | ] |
| 498 | ); |
| 499 | |
| 500 | |
| 501 | $this->end_controls_section(); |
| 502 | } |
| 503 | |
| 504 | |
| 505 | /** |
| 506 | * Render widget output on the frontend |
| 507 | */ |
| 508 | protected function render(): void { |
| 509 | $settings = $this->get_settings_for_display(); |
| 510 | |
| 511 | $allowed_params = [ |
| 512 | 'caption', |
| 513 | 'hide_summary', |
| 514 | 'hide_side_panel', |
| 515 | 'selected_agent', |
| 516 | 'selected_service', |
| 517 | 'selected_bundle', |
| 518 | 'selected_service_category', |
| 519 | 'selected_location', |
| 520 | 'selected_start_date', |
| 521 | 'selected_start_time', |
| 522 | 'selected_duration', |
| 523 | 'selected_total_attendees', |
| 524 | 'source_id', |
| 525 | 'calendar_start_date', |
| 526 | 'show_services', |
| 527 | 'show_service_categories', |
| 528 | 'show_agents', |
| 529 | 'show_locations', |
| 530 | 'btn_wrapper_classes', |
| 531 | 'btn_classes' |
| 532 | ]; |
| 533 | $settings['btn_wrapper_classes'] = 'elementor-button-wrapper'; |
| 534 | $settings['btn_classes'] = 'elementor-button elementor-button-link elementor-size-sm'; |
| 535 | |
| 536 | $params = OsBlockHelper::attributes_to_data_params($settings, $allowed_params); |
| 537 | |
| 538 | echo do_shortcode('[latepoint_book_button ' . $params . ']'); |
| 539 | } |
| 540 | |
| 541 | } |