PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.8
Booking for Appointments and Events Calendar – Amelia v2.4.8
2.4.9 2.4.8 2.4.7 2.4.6 2.4.5 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 1 week ago AmeliaCatalogBookingElementorWidget.php 1 week ago AmeliaCatalogElementorWidget.php 1 week ago AmeliaElementorWhiteLabelHelper.php 1 week ago AmeliaEventsCalendarBookingElementorWidget.php 1 week ago AmeliaEventsElementorWidget.php 1 week ago AmeliaEventsListBookingButtonElementorWidget.php 1 week ago AmeliaEventsListBookingElementorWidget.php 1 week ago AmeliaStepBookingButtonElementorWidget.php 1 week ago AmeliaStepBookingElementorWidget.php 1 week ago ElementorBlock.php 1 week ago ElementorSharedShortcodeWidget.php 2 months ago
AmeliaEventsElementorWidget.php
174 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 . AmeliaElementorWhiteLabelHelper::label(BackendStrings::get('events_gutenberg_block')['title'])
35 . '</p><br><p class="amelia-elementor-content-p">'
36 . AmeliaElementorWhiteLabelHelper::label(BackendStrings::get('events_gutenberg_block')['description'])
37 . '</p><br><p class="amelia-elementor-content-p amelia-elementor-content-p-outdated">'
38 . AmeliaElementorWhiteLabelHelper::label(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 = !empty($settings['selected_type'])
124 ? ' type="' . esc_attr($settings['selected_type']) . '"'
125 : '';
126
127 if ($settings['preselect']) {
128 $trigger = $settings['load_manually'] !== '' ? ' trigger="' . esc_attr($settings['load_manually']) . '"' : '';
129
130 $selected_event = $settings['select_event'] === '0' ? '' : ' event="' . esc_attr($settings['select_event']) . '"';
131
132 $show_recurring = $settings['show_recurring'] ? ' recurring=1' : '';
133
134 $selected_tag = $settings['select_tag'] ? ' tag="' . esc_attr($settings['select_tag']) . '"' : '';
135
136 echo esc_html('[' . AmeliaElementorWhiteLabelHelper::shortcodeTag('events', 'ameliaevents') .
137 $selected_type . $trigger . $selected_event . $selected_tag . $show_recurring . ']');
138 } else {
139 echo esc_html('[' . AmeliaElementorWhiteLabelHelper::shortcodeTag('events', 'ameliaevents') .
140 $selected_type . ']');
141 }
142 }
143
144
145 public static function amelia_elementor_get_events()
146 {
147 $events = GutenbergBlock::getEntitiesData()['data']['events'];
148
149 $returnEvents = [];
150
151 $returnEvents['0'] = BackendStrings::get('show_all_events');
152 foreach ($events as $event) {
153 $returnEvents[$event['id']] = $event['name'] . ' (id: ' . $event['id'] . ') - ' . $event['formattedPeriodStart'];
154 }
155
156 return $returnEvents;
157 }
158
159 public static function amelia_elementor_get_tags()
160 {
161 $tags = GutenbergBlock::getEntitiesData()['data']['tags'];
162
163 $returnTags = [];
164
165 $returnTags[''] = BackendStrings::get('show_all_tags');
166
167 foreach ($tags as $index => $tag) {
168 $returnTags[$tag['name']] = $tag['name'];
169 }
170
171 return $returnTags;
172 }
173 }
174