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_calendar.php
136 lines
| 1 | <?php |
| 2 | |
| 3 | class Latepoint_Elementor_Widget_Calendar 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 | |
| 14 | |
| 15 | /** |
| 16 | * Get widget name |
| 17 | */ |
| 18 | public function get_name(): string { |
| 19 | return 'latepoint_calendar'; |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * Get widget title |
| 24 | */ |
| 25 | public function get_title(): string { |
| 26 | return esc_html__( 'Latepoint Calendar', 'latepoint' ); |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Get widget icon |
| 31 | */ |
| 32 | public function get_icon(): string { |
| 33 | return 'eicon-calendar'; |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Get widget categories |
| 38 | */ |
| 39 | public function get_categories(): array { |
| 40 | return [ OsElementorHelper::$category ]; |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Register widget controls |
| 45 | */ |
| 46 | protected function register_controls(): void { |
| 47 | |
| 48 | # Form Settings Section |
| 49 | $this->start_controls_section( |
| 50 | 'content_section_form_settings', |
| 51 | [ |
| 52 | 'label' => esc_html__( 'Latepoint Calendar Settings', 'latepoint' ), |
| 53 | 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, |
| 54 | ] |
| 55 | ); |
| 56 | |
| 57 | $this->add_control( |
| 58 | 'date', |
| 59 | [ |
| 60 | 'label' => esc_html__( 'Date', 'latepoint' ), |
| 61 | 'type' => \Elementor\Controls_Manager::DATE_TIME, |
| 62 | 'picker_options' => ['enableTime' => false], |
| 63 | 'label_block' => false |
| 64 | ] |
| 65 | ); |
| 66 | |
| 67 | $this->add_control( |
| 68 | 'show_agents', |
| 69 | [ |
| 70 | 'label' => esc_html__( 'Show Agents', 'latepoint' ), |
| 71 | 'type' => \Elementor\Controls_Manager::SELECT2, |
| 72 | 'default' => '', |
| 73 | 'multiple' => true, |
| 74 | 'options' => $this->widget_data['agents'], |
| 75 | ] |
| 76 | ); |
| 77 | |
| 78 | $this->add_control( |
| 79 | 'show_services', |
| 80 | [ |
| 81 | 'label' => esc_html__('Show Services', 'latepoint'), |
| 82 | 'type' => \Elementor\Controls_Manager::SELECT2, |
| 83 | 'default' => '', |
| 84 | 'options' => $this->widget_data['services'], |
| 85 | 'multiple' => true |
| 86 | ] |
| 87 | ); |
| 88 | |
| 89 | |
| 90 | $this->add_control( |
| 91 | 'show_locations', |
| 92 | [ |
| 93 | 'label' => esc_html__( 'Show Locations', 'latepoint' ), |
| 94 | 'type' => \Elementor\Controls_Manager::SELECT2, |
| 95 | 'default' => '', |
| 96 | 'multiple' => true, |
| 97 | 'options' => $this->widget_data['locations'], |
| 98 | ] |
| 99 | ); |
| 100 | |
| 101 | $this->add_control( |
| 102 | 'view', |
| 103 | [ |
| 104 | 'label' => esc_html__( 'View', 'latepoint' ), |
| 105 | 'type' => \Elementor\Controls_Manager::SELECT, |
| 106 | 'default' => 'month', |
| 107 | 'options' => [ |
| 108 | 'month' => esc_html__( 'Month', 'latepoint' ), |
| 109 | 'week' => esc_html__( 'Week', 'latepoint' ), |
| 110 | ], |
| 111 | ] |
| 112 | ); |
| 113 | |
| 114 | $this->end_controls_section(); |
| 115 | } |
| 116 | |
| 117 | |
| 118 | /** |
| 119 | * Render widget output on the frontend |
| 120 | */ |
| 121 | protected function render(): void { |
| 122 | $settings = $this->get_settings_for_display(); |
| 123 | |
| 124 | $allowed_params = [ |
| 125 | 'date', |
| 126 | 'show_services', |
| 127 | 'show_agents', |
| 128 | 'show_locations', |
| 129 | 'view' |
| 130 | ]; |
| 131 | |
| 132 | $params = OsBlockHelper::attributes_to_data_params($settings, $allowed_params); |
| 133 | echo do_shortcode('[latepoint_calendar ' . $params . ']'); |
| 134 | } |
| 135 | |
| 136 | } |