PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.8
Booking for Appointments and Events Calendar – Amelia v2.4.8
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 / extensions / divi_amelia / includes / modules / Booking / Booking.php
ameliabooking / extensions / divi_amelia / includes / modules / Booking Last commit date
Booking.php 1 day ago style.css 5 years ago
Booking.php
196 lines
1 <?php
2
3 use AmeliaBooking\Infrastructure\WP\GutenbergBlock\GutenbergBlock;
4 use AmeliaBooking\Infrastructure\WP\Translations\BackendStrings;
5
6 class DIVI_Booking extends ET_Builder_Module
7 {
8 public $slug = 'divi_booking';
9 public $vb_support = 'on';
10
11 private $categories = array();
12 private $services = array();
13 private $employees = array();
14 private $locations = array();
15 private $showPackages = true;
16
17 public $type = array();
18
19
20 protected $module_credits = array(
21 'module_uri' => '',
22 'author' => '',
23 'author_uri' => '',
24 );
25
26 public function init()
27 {
28 $this->name = esc_html__(DIVI_AmeliaWhiteLabelHelper::label(BackendStrings::get('booking_divi')), 'divi-divi_amelia');
29
30 $this->type['0'] = BackendStrings::get('show_all');
31 $this->type['services'] = BackendStrings::get('services');
32 $this->type['packages'] = BackendStrings::get('packages');
33
34 if (!is_admin()) {
35 return;
36 }
37
38 $data = GutenbergBlock::getEntitiesData()['data'];
39 $this->showPackages = !empty($data['packages']);
40
41 $this->categories['0'] = BackendStrings::get('show_all_categories');
42 foreach ($data['categories'] as $category) {
43 $this->categories[$category['id']] = $category['name'] . ' (id: ' . $category['id'] . ')';
44 }
45 $this->services['0'] = BackendStrings::get('show_all_services');
46 foreach ($data['servicesList'] as $service) {
47 if ($service) {
48 $this->services[$service['id']] = $service['name'] . ' (id: ' . $service['id'] . ')';
49 }
50 }
51 $this->employees['0'] = BackendStrings::get('show_all_employees');
52 foreach ($data['employees'] as $employee) {
53 $this->employees[$employee['id']] = $employee['firstName'] . ' ' . $employee['lastName'] . ' (id: ' . $employee['id'] . ')';
54 }
55 $this->locations['0'] = BackendStrings::get('show_all_locations');
56 foreach ($data['locations'] as $location) {
57 $this->locations[$location['id']] = $location['name'] . ' (id: ' . $location['id'] . ')';
58 }
59 }
60
61 /**
62 * Advanced Fields Config
63 *
64 * @return array
65 */
66 public function get_advanced_fields_config()
67 {
68 return array(
69 'button' => false,
70 'link_options' => false
71 );
72 }
73
74 public function get_fields()
75 {
76 $array = array(
77 'booking_params' => array(
78 'label' => esc_html__(BackendStrings::get('filter'), 'divi-divi_amelia'),
79 'type' => 'yes_no_button',
80 'options' => array(
81 'on' => esc_html__(BackendStrings::get('yes'), 'divi-divi_amelia'),
82 'off' => esc_html__(BackendStrings::get('no'), 'divi-divi_amelia'),
83 ),
84 'toggle_slug' => 'main_content',
85 'option_category' => 'basic_option',
86 ),
87 'categories' => array(
88 'label' => esc_html__(BackendStrings::get('select_category'), 'divi-divi_amelia'),
89 'type' => 'select',
90 'options' => $this->categories,
91 'toggle_slug' => 'main_content',
92 'option_category' => 'basic_option',
93 'show_if' => array(
94 'booking_params' => 'on',
95 ),
96 ),
97 'services' => array(
98 'label' => esc_html__(BackendStrings::get('select_service'), 'divi-divi_amelia'),
99 'type' => 'select',
100 'toggle_slug' => 'main_content',
101 'options' => $this->services,
102 'option_category' => 'basic_option',
103 'show_if' => array(
104 'booking_params' => 'on',
105 ),
106 ),
107 'employees' => array(
108 'label' => esc_html__(BackendStrings::get('select_employee'), 'divi-divi_amelia'),
109 'type' => 'select',
110 'options' => $this->employees,
111 'toggle_slug' => 'main_content',
112 'option_category' => 'basic_option',
113 'show_if' => array(
114 'booking_params' => 'on',
115 ),
116 ),
117 'locations' => array(
118 'label' => esc_html__(BackendStrings::get('select_location'), 'divi-divi_amelia'),
119 'type' => 'select',
120 'options' => $this->locations,
121 'toggle_slug' => 'main_content',
122 'option_category' => 'basic_option',
123 'show_if' => array(
124 'booking_params' => 'on',
125 ),
126 ),
127 );
128
129 if ($this->showPackages) {
130 $array['type'] = array(
131 'label' => esc_html__(BackendStrings::get('show_all'), 'divi-divi_amelia'),
132 'type' => 'select',
133 'options' => $this->type,
134 'toggle_slug' => 'main_content',
135 'option_category' => 'basic_option',
136 'show_if' => array(
137 'booking_params' => 'on'
138 ));
139 }
140
141 $array['trigger'] = array(
142 'label' => esc_html__(BackendStrings::get('manually_loading'), 'divi-divi_amelia'),
143 'type' => 'text',
144 'toggle_slug' => 'main_content',
145 'option_category' => 'basic_option',
146 'description' => BackendStrings::get('manually_loading_description'),
147 );
148
149 return $array;
150 }
151
152 public function checkValues($val)
153 {
154 if ($val !== null) {
155 return !is_numeric($val) ? (strpos($val, 'id:') ? substr(explode('id: ', $val)[1], 0, -1) : '0') : $val;
156 }
157 return '0';
158 }
159
160 public function render($attrs, $content = null, $render_slug = null)
161 {
162 $preselect = $this->props['booking_params'];
163 $shortcode = '[' . DIVI_AmeliaWhiteLabelHelper::shortcodeTag('booking', 'ameliabooking');
164 $showAll = isset($this->props['type']) ? $this->props['type'] : null;
165 $trigger = $this->props['trigger'];
166 if ($showAll !== null && $showAll !== '' && $showAll !== '0') {
167 $shortcode .= ' show=' . $showAll;
168 }
169 if ($trigger !== null && $trigger !== '') {
170 $shortcode .= ' trigger=' . $trigger;
171 }
172 if ($preselect === 'on') {
173 $category = $this->checkValues($this->props['categories']);
174 $service = $this->checkValues($this->props['services']);
175 $employee = $this->checkValues($this->props['employees']);
176 $location = $this->checkValues($this->props['locations']);
177
178 if ($service !== '0') {
179 $shortcode .= ' service=' . $service;
180 } elseif ($category !== '0') {
181 $shortcode .= ' category=' . $category;
182 }
183 if ($employee !== '0') {
184 $shortcode .= ' employee=' . $employee;
185 }
186 if ($location !== '0') {
187 $shortcode .= ' location=' . $location;
188 }
189 }
190 $shortcode .= ']';
191 return do_shortcode($shortcode);
192 }
193 }
194
195 new DIVI_Booking();
196