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_5_amelia / server / index.php
ameliabooking / extensions / divi_5_amelia / server Last commit date
AmeliaBookingButtonRendererTrait.php 3 months ago AmeliaBookingModule.php 2 days ago AmeliaCatalogBookingModule.php 2 days ago AmeliaCatalogModule.php 2 days ago AmeliaCatalogShortcodeHelper.php 2 days ago AmeliaCustomerPanelModule.php 2 days ago AmeliaEmployeePanelModule.php 2 days ago AmeliaEventsCalendarModule.php 2 days ago AmeliaEventsListBookingButtonModule.php 2 days ago AmeliaEventsListModule.php 2 days ago AmeliaEventsModule.php 2 days ago AmeliaSearchModule.php 2 days ago AmeliaStepBookingButtonModule.php 2 days ago AmeliaStepBookingModule.php 2 days ago ModuleMetadata.php 2 months ago SharedShortcodeModule.php 2 months ago index.php 2 days ago
index.php
235 lines
1 <?php
2
3 /**
4 * Divi 5 Amelia Modules Bootstrap
5 *
6 * This file loads and registers all Divi 5 Amelia modules.
7 * phpcs:disable PSR1.Files.SideEffects
8 */
9
10 namespace Divi5Amelia;
11
12 use AmeliaBooking\Infrastructure\Licence\Licence;
13
14 if (!defined('ABSPATH')) {
15 die('Direct access forbidden.');
16 }
17
18 // Check if Divi 5 is active before loading modules
19 function is_divi_5_active()
20 {
21 $theme = wp_get_theme();
22 $is_divi_theme = 'Divi' === $theme->name || 'Divi' === $theme->parent_theme;
23
24 return $is_divi_theme;
25 }
26
27 /**
28 * Custom value expansion function for converting comma-separated strings to arrays
29 * Used during Divi 4 to Divi 5 conversion for multi-select fields
30 */
31 function ameliaConvertParams($value, $context = [])
32 {
33 if (is_string($value) && $value !== '') {
34 $items = array_map('trim', explode(',', $value));
35 return array_filter($items, function ($item) {
36 return $item !== '';
37 });
38 }
39
40 if (is_array($value)) {
41 return $value;
42 }
43
44 return [];
45 }
46
47 /**
48 * Convert Divi 4 yes_no_button values to Divi 5 toggle string values
49 * Keep as 'on'/'off' strings since that's what Divi Toggle component expects
50 */
51 function ameliaConvertToggle($value, $context = [])
52 {
53 // Handle empty/null/undefined - default to 'on' (Divi 4 defaults were 'on')
54 if ($value === null || $value === '') {
55 return 'on';
56 }
57
58 // Already correct string format
59 if ($value === 'on' || $value === '1' || $value === 1 || $value === true || $value === 'true') {
60 return 'on';
61 }
62
63 if ($value === 'off' || $value === '0' || $value === 0 || $value === false || $value === 'false') {
64 return 'off';
65 }
66
67 // Default to 'on' for Customer Panel (matches D4 behavior)
68 return 'on';
69 }
70
71 /**
72 * Convert catalog items (categories/services/packages) and automatically set catalog_view
73 *
74 * @param mixed $value The value to convert (comma-separated string or array)
75 * @param array $context Context information including field name and attributes
76 * @return array Converted array of items
77 */
78 function ameliaConvertCatalogItems($value, $context = [])
79 {
80 $result = ameliaConvertParams($value, $context);
81
82 // If items were selected, also update the catalog_view based on field name
83 if (!empty($result) && isset($context['attrs']) && isset($context['fieldName'])) {
84 // Determine catalog view type from field name
85 $catalogViewMap = [
86 'categories' => 'category',
87 'services' => 'service',
88 'packages' => 'package',
89 ];
90
91 $fieldName = $context['fieldName'];
92 if (isset($catalogViewMap[$fieldName])) {
93 if (!isset($context['attrs']['catalog_view'])) {
94 $context['attrs']['catalog_view'] = [];
95 }
96 $context['attrs']['catalog_view']['innerContent'] = [
97 'desktop' => ['value' => $catalogViewMap[$fieldName]]
98 ];
99 }
100 }
101
102 return $result;
103 }
104
105 /**
106 * Register custom value expansion functions for Divi conversion system
107 */
108 add_filter('divi.moduleLibrary.conversion.valueExpansionFunctionMap', function ($functionMap) {
109 $functionMap['ameliaConvertParams'] = 'Divi5Amelia\ameliaConvertParams';
110 $functionMap['ameliaConvertToggle'] = 'Divi5Amelia\ameliaConvertToggle';
111 $functionMap['ameliaConvertCatalogItems'] = 'Divi5Amelia\ameliaConvertCatalogItems';
112
113 return $functionMap;
114 });
115
116 if (is_divi_5_active()) {
117 // Load Divi dependency interface before loading modules
118 $divi_dependency_interface = get_template_directory() . '/includes/builder-5/server/Framework/DependencyManagement/Interfaces/DependencyInterface.php';
119
120 if (!file_exists($divi_dependency_interface)) {
121 return;
122 }
123
124 require_once $divi_dependency_interface;
125
126 // Shared helpers used by booking button modules.
127 require_once __DIR__ . '/AmeliaBookingButtonRendererTrait.php';
128 require_once __DIR__ . '/AmeliaCatalogShortcodeHelper.php';
129
130 require_once __DIR__ . '/ModuleMetadata.php';
131 require_once __DIR__ . '/SharedShortcodeModule.php';
132 require_once __DIR__ . '/AmeliaStepBookingModule.php';
133 require_once __DIR__ . '/AmeliaStepBookingButtonModule.php';
134 require_once __DIR__ . '/AmeliaBookingModule.php';
135 require_once __DIR__ . '/AmeliaCatalogBookingModule.php';
136 require_once __DIR__ . '/AmeliaCatalogModule.php';
137 require_once __DIR__ . '/AmeliaEventsListModule.php';
138 require_once __DIR__ . '/AmeliaEventsListBookingButtonModule.php';
139 require_once __DIR__ . '/AmeliaEventsModule.php';
140 require_once __DIR__ . '/AmeliaSearchModule.php';
141
142 if (Licence::$premium) {
143 require_once __DIR__ . '/AmeliaEventsCalendarModule.php';
144 require_once __DIR__ . '/AmeliaCustomerPanelModule.php';
145 require_once __DIR__ . '/AmeliaEmployeePanelModule.php';
146 }
147
148 add_action(
149 'divi_module_library_modules_dependency_tree',
150 function ($dependency_tree) {
151 $dependency_tree->add_dependency(new AmeliaStepBookingModule());
152 }
153 );
154
155 add_action(
156 'divi_module_library_modules_dependency_tree',
157 function ($dependency_tree) {
158 $dependency_tree->add_dependency(new AmeliaStepBookingButtonModule());
159 }
160 );
161
162 add_action(
163 'divi_module_library_modules_dependency_tree',
164 function ($dependency_tree) {
165 $dependency_tree->add_dependency(new AmeliaBookingModule());
166 }
167 );
168
169 add_action(
170 'divi_module_library_modules_dependency_tree',
171 function ($dependency_tree) {
172 $dependency_tree->add_dependency(new AmeliaCatalogBookingModule());
173 }
174 );
175
176 add_action(
177 'divi_module_library_modules_dependency_tree',
178 function ($dependency_tree) {
179 $dependency_tree->add_dependency(new AmeliaCatalogModule());
180 }
181 );
182
183 add_action(
184 'divi_module_library_modules_dependency_tree',
185 function ($dependency_tree) {
186 $dependency_tree->add_dependency(new AmeliaEventsListModule());
187 }
188 );
189
190 add_action(
191 'divi_module_library_modules_dependency_tree',
192 function ($dependency_tree) {
193 $dependency_tree->add_dependency(new AmeliaEventsListBookingButtonModule());
194 }
195 );
196
197 add_action(
198 'divi_module_library_modules_dependency_tree',
199 function ($dependency_tree) {
200 $dependency_tree->add_dependency(new AmeliaEventsModule());
201 }
202 );
203
204 add_action(
205 'divi_module_library_modules_dependency_tree',
206 function ($dependency_tree) {
207 $dependency_tree->add_dependency(new AmeliaSearchModule());
208 }
209 );
210
211 // Register premium modules only if license is premium
212 if (Licence::$premium) {
213 add_action(
214 'divi_module_library_modules_dependency_tree',
215 function ($dependency_tree) {
216 $dependency_tree->add_dependency(new AmeliaEventsCalendarModule());
217 }
218 );
219
220 add_action(
221 'divi_module_library_modules_dependency_tree',
222 function ($dependency_tree) {
223 $dependency_tree->add_dependency(new AmeliaCustomerPanelModule());
224 }
225 );
226
227 add_action(
228 'divi_module_library_modules_dependency_tree',
229 function ($dependency_tree) {
230 $dependency_tree->add_dependency(new AmeliaEmployeePanelModule());
231 }
232 );
233 }
234 }
235