PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.4
Booking for Appointments and Events Calendar – Amelia v2.4.4
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / src / Infrastructure / WP / Elementor / AmeliaEventsElementorWidget.php
ameliabooking / src / Infrastructure / WP / Elementor Last commit date
AmeliaBookingElementorWidget.php 6 months ago AmeliaCatalogBookingElementorWidget.php 2 weeks ago AmeliaCatalogElementorWidget.php 6 months ago AmeliaEventsCalendarBookingElementorWidget.php 2 weeks ago AmeliaEventsElementorWidget.php 2 weeks ago AmeliaEventsListBookingButtonElementorWidget.php 2 weeks ago AmeliaEventsListBookingElementorWidget.php 2 weeks ago AmeliaStepBookingButtonElementorWidget.php 1 month ago AmeliaStepBookingElementorWidget.php 2 weeks ago ElementorBlock.php 2 weeks ago ElementorSharedShortcodeWidget.php 2 weeks ago
AmeliaEventsElementorWidget.php
171 lines
1 <?php
2
3 /**
4 * @copyright © Melograno Ventures. All rights reserved.
5 * @licence See LICENCE.md for license details.
6 */
7
8 namespace Elementor;
9
10 use AmeliaBooking\Infrastructure\WP\GutenbergBlock\GutenbergBlock;
11 use AmeliaBooking\Infrastructure\WP\Translations\BackendStrings;
12 use AmeliaBooking\Infrastructure\Licence;
13
14 /**
15 * Class AmeliaEventsElementorWidget
16 *
17 * @package AmeliaBooking\Infrastructure\WP\Elementor
18 */
19 class AmeliaEventsElementorWidget extends Widget_Base
20 {
21 public function get_name()
22 {
23 return 'ameliaevents';
24 }
25
26 protected function register_controls()
27 {
28 $isLite = !Licence\Licence::isPremium();
29
30 $this->start_controls_section(
31 'amelia_events_section',
32 [
33 'label' => '<div class="amelia-elementor-content-outdated"><p class="amelia-elementor-content-title">'
34 . BackendStrings::get('events_gutenberg_block')['title']
35 . '</p><br><p class="amelia-elementor-content-p">'
36 . BackendStrings::get('events_gutenberg_block')['description']
37 . '</p><br><p class="amelia-elementor-content-p amelia-elementor-content-p-outdated">'
38 . BackendStrings::get('outdated_booking_gutenberg_block')
39 . '</p>',
40 ]
41 );
42
43 if (!$isLite) {
44 $this->add_control(
45 'selected_type',
46 [
47 'label' => BackendStrings::get('show_event_view_type'),
48 'type' => Controls_Manager::SELECT,
49 'options' => [
50 'list' => BackendStrings::get('show_event_view_list'),
51 'calendar' => BackendStrings::get('show_event_view_calendar')
52 ],
53 'default' => 'list',
54 ]
55 );
56 }
57
58 $this->add_control(
59 'preselect',
60 [
61 'label' => BackendStrings::get('filter'),
62 'type' => Controls_Manager::SWITCHER,
63 'default' => false,
64 'label_on' => BackendStrings::get('yes'),
65 'label_off' => BackendStrings::get('no'),
66 ]
67 );
68
69 $this->add_control(
70 'select_event',
71 [
72 'label' => BackendStrings::get('select_event'),
73 'type' => Controls_Manager::SELECT,
74 'options' => self::amelia_elementor_get_events(),
75 'condition' => ['preselect' => 'yes'],
76 'default' => '0',
77 ]
78 );
79
80 $this->add_control(
81 'select_tag',
82 [
83 'label' => BackendStrings::get('select_tag'),
84 'type' => Controls_Manager::SELECT,
85 'options' => self::amelia_elementor_get_tags(),
86 'condition' => ['preselect' => 'yes'],
87 'default' => '',
88 ]
89 );
90
91 $this->add_control(
92 'show_recurring',
93 [
94 'label' => __('Show recurring events:'),
95 'type' => Controls_Manager::SWITCHER,
96 'condition' => ['preselect' => 'yes'],
97 'default' => false,
98 'label_on' => BackendStrings::get('yes'),
99 'label_off' => BackendStrings::get('no'),
100 ]
101 );
102
103 $this->add_control(
104 'load_manually',
105 [
106 'label' => BackendStrings::get('manually_loading'),
107 'label_block' => true,
108 'type' => Controls_Manager::TEXT,
109 'condition' => ['preselect' => 'yes'],
110 'placeholder' => '',
111 'description' => BackendStrings::get('manually_loading_description'),
112 ]
113 );
114
115 $this->end_controls_section();
116 }
117
118 protected function render()
119 {
120
121 $settings = $this->get_settings_for_display();
122
123 $selected_type = $settings['selected_type'] ? ' type="' . esc_attr($settings['selected_type']) . '"' : '';
124
125 if ($settings['preselect']) {
126 $trigger = $settings['load_manually'] !== '' ? ' trigger="' . esc_attr($settings['load_manually']) . '"' : '';
127
128 $selected_event = $settings['select_event'] === '0' ? '' : ' event="' . esc_attr($settings['select_event']) . '"';
129
130 $show_recurring = $settings['show_recurring'] ? ' recurring=1' : '';
131
132 $selected_tag = $settings['select_tag'] ? ' tag="' . esc_attr($settings['select_tag']) . '"' : '';
133
134 echo wp_kses_post('[ameliaevents' . $selected_type . $trigger . $selected_event . $selected_tag . $show_recurring . ']');
135 } else {
136 $selected_type = $settings['selected_type'] ? ' type="' . esc_attr($settings['selected_type']) . '"' : '';
137 echo wp_kses_post('[ameliaevents' . $selected_type . ']');
138 }
139 }
140
141
142 public static function amelia_elementor_get_events()
143 {
144 $events = GutenbergBlock::getEntitiesData()['data']['events'];
145
146 $returnEvents = [];
147
148 $returnEvents['0'] = BackendStrings::get('show_all_events');
149 foreach ($events as $event) {
150 $returnEvents[$event['id']] = $event['name'] . ' (id: ' . $event['id'] . ') - ' . $event['formattedPeriodStart'];
151 }
152
153 return $returnEvents;
154 }
155
156 public static function amelia_elementor_get_tags()
157 {
158 $tags = GutenbergBlock::getEntitiesData()['data']['tags'];
159
160 $returnTags = [];
161
162 $returnTags[''] = BackendStrings::get('show_all_tags');
163
164 foreach ($tags as $index => $tag) {
165 $returnTags[$tag['name']] = $tag['name'];
166 }
167
168 return $returnTags;
169 }
170 }
171