PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 1.2.20
Booking for Appointments and Events Calendar – Amelia v1.2.20
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 / AmeliaBookingElementorWidget.php
ameliabooking / src / Infrastructure / WP / Elementor Last commit date
AmeliaBookingElementorWidget.php 2 years ago AmeliaCatalogBookingElementorWidget.php 1 year ago AmeliaCatalogElementorWidget.php 2 years ago AmeliaEventsCalendarBookingElementorWidget.php 1 year ago AmeliaEventsElementorWidget.php 2 years ago AmeliaEventsListBookingElementorWidget.php 2 years ago AmeliaStepBookingElementorWidget.php 2 years ago ElementorBlock.php 2 years ago
AmeliaBookingElementorWidget.php
202 lines
1 <?php
2 /**
3 * @copyright © TMS-Plugins. All rights reserved.
4 * @licence See LICENCE.md for license details.
5 */
6
7 namespace Elementor;
8
9 use AmeliaBooking\Infrastructure\WP\GutenbergBlock\GutenbergBlock;
10 use AmeliaBooking\Infrastructure\WP\Translations\BackendStrings;
11
12 /**
13 * Class AmeliaBookingElementorWidget
14 *
15 * @package AmeliaBooking\Infrastructure\WP\Elementor
16 */
17 class AmeliaBookingElementorWidget extends Widget_Base
18 {
19 protected $controls_data;
20
21 public function get_name() {
22 return 'ameliabooking';
23 }
24
25 public function get_title() {
26 return BackendStrings::getWordPressStrings()['booking_gutenberg_block']['title'];
27 }
28
29 public function get_icon() {
30 return 'amelia-logo-outdated';
31 }
32
33 public function get_categories() {
34 return [ 'amelia-elementor' ];
35 }
36
37 protected function register_controls() {
38
39 $controls_data = self::amelia_elementor_get_data();
40
41 $this->start_controls_section(
42 'amelia_booking_section',
43 [
44 'label' => '<div class="amelia-elementor-content-outdated"><p class="amelia-elementor-content-title">'
45 . BackendStrings::getWordPressStrings()['booking_gutenberg_block']['title']
46 . '</p><br><p class="amelia-elementor-content-p">'
47 . BackendStrings::getWordPressStrings()['booking_gutenberg_block']['description']
48 . '</p><br><p class="amelia-elementor-content-p amelia-elementor-content-p-outdated">'
49 . BackendStrings::getWordPressStrings()['outdated_booking_gutenberg_block']
50 . '</p>',
51 ]
52 );
53
54 $this->add_control(
55 'preselect',
56 [
57 'label' => BackendStrings::getWordPressStrings()['filter'],
58 'type' => Controls_Manager::SWITCHER,
59 'default' => false,
60 'label_on' => BackendStrings::getCommonStrings()['yes'],
61 'label_off' => BackendStrings::getCommonStrings()['no'],
62 ]
63 );
64
65 $this->add_control(
66 'select_category',
67 [
68 'label' => BackendStrings::getWordPressStrings()['select_category'],
69 'type' => Controls_Manager::SELECT,
70 'options' => $controls_data['categories'],
71 'condition' => ['preselect' => 'yes'],
72 'default' => '0',
73 ]
74 );
75
76 $this->add_control(
77 'select_service',
78 [
79 'label' => BackendStrings::getWordPressStrings()['select_service'],
80 'type' => Controls_Manager::SELECT,
81 'options' => $controls_data['services'],
82 'condition' => ['preselect' => 'yes'],
83 'default' => '0',
84 ]
85 );
86
87 $this->add_control(
88 'select_employee',
89 [
90 'label' => BackendStrings::getWordPressStrings()['select_employee'],
91 'type' => Controls_Manager::SELECT,
92 'options' => $controls_data['employees'],
93 'condition' => ['preselect' => 'yes'],
94 'default' => '0',
95 ]
96 );
97
98 $this->add_control(
99 'select_location',
100 [
101 'label' => BackendStrings::getWordPressStrings()['select_location'],
102 'type' => Controls_Manager::SELECT,
103 'options' => $controls_data['locations'],
104 'condition' => ['preselect' => 'yes'],
105 'default' => '0',
106 ]
107 );
108
109 if ($controls_data['show']) {
110 $this->add_control(
111 'select_show',
112 [
113 'label' => BackendStrings::getWordPressStrings()['show_all'],
114 'type' => Controls_Manager::SELECT,
115 'options' => $controls_data['show'],
116 'condition' => ['preselect' => 'yes'],
117 'default' => '',
118 ]
119 );
120 }
121
122 $this->add_control(
123 'load_manually',
124 [
125 'label' => BackendStrings::getWordPressStrings()['manually_loading'],
126 'label_block' => true,
127 'type' => Controls_Manager::TEXT,
128 'condition' => ['preselect' => 'yes'],
129 'placeholder' => '',
130 'description' => BackendStrings::getWordPressStrings()['manually_loading_description'],
131 ]
132 );
133
134 $this->end_controls_section();
135 }
136 protected function render() {
137 $settings = $this->get_settings_for_display();
138
139 $trigger = $settings['load_manually'] !== '' ? ' trigger=' . $settings['load_manually'] : '';
140
141 $category = $settings['select_category'] === '0' ? '' : ' category=' . $settings['select_category'];
142 $service = $settings['select_service'] === '0' ? '' : ' service=' . $settings['select_service'];
143 $category_service = $settings['select_service'] === '0' ? $category : $service;
144
145 $employee = $settings['select_employee'] === '0' ? '' : ' employee=' . $settings['select_employee'];
146 $location = $settings['select_location'] === '0' ? '' : ' location=' . $settings['select_location'];
147 $employee_location = $settings['select_employee'] === '0' ? $location : $employee;
148
149 $show = empty($settings['select_show']) ? '' : ' show=' . $settings['select_show'];
150
151 if ($settings['preselect']) {
152 echo esc_html('[ameliabooking' . $show . $trigger . $category_service . $employee_location . ']');
153 } else {
154 echo '[ameliabooking]';
155 }
156 }
157
158
159 public static function amelia_elementor_get_data() {
160 $data = GutenbergBlock::getEntitiesData()['data'];
161 $elementorData = [];
162
163 $elementorData['categories'] = [];
164 $elementorData['categories'][0] = BackendStrings::getWordPressStrings()['show_all_categories'];
165
166 foreach ($data['categories'] as $category) {
167 $elementorData['categories'][$category['id']] = $category['name'] . ' (id: ' . $category['id'] . ')';
168 }
169
170 $elementorData['services'] = [];
171 $elementorData['services'][0] = BackendStrings::getWordPressStrings()['show_all_services'];
172
173 foreach ($data['servicesList'] as $service) {
174 if ($service) {
175 $elementorData['services'][$service['id']] = $service['name'] . ' (id: ' . $service['id'] . ')';
176 }
177 }
178
179 $elementorData['employees'] = [];
180 $elementorData['employees'][0] = BackendStrings::getWordPressStrings()['show_all_employees'];
181
182 foreach ($data['employees'] as $provider) {
183 $elementorData['employees'][$provider['id']] = $provider['firstName'] . $provider['lastName'] . ' (id: ' . $provider['id'] . ')';
184 }
185
186 $elementorData['locations'] = [];
187 $elementorData['locations'][0] = BackendStrings::getWordPressStrings()['show_all_locations'];
188
189 foreach ($data['locations'] as $location) {
190 $elementorData['locations'][$location['id']] = $location['name'] . ' (id: ' . $location['id'] . ')';
191 }
192
193 $elementorData['show'] = $data['packages'] ? [
194 '' => BackendStrings::getWordPressStrings()['show_all'],
195 'services' => BackendStrings::getCommonStrings()['services'],
196 'packages' => BackendStrings::getCommonStrings()['packages']
197 ] : [];
198
199 return $elementorData;
200 }
201 }
202