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 / AmeliaBookingModule.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
AmeliaBookingModule.php
101 lines
1 <?php
2
3 namespace Divi5Amelia;
4
5 use AmeliaBooking\Infrastructure\WP\ShortcodeService\ShortcodeAliasService;
6 use ET\Builder\Framework\DependencyManagement\Interfaces\DependencyInterface;
7 use ET\Builder\Packages\ModuleLibrary\ModuleRegistration;
8
9 /**
10 * Class that handle "Amelia Booking" module output in frontend.
11 */
12 class AmeliaBookingModule implements DependencyInterface
13 {
14 /**
15 * Register module.
16 * DependencyInterface interface ensures class method name `load()` is executed for initialization.
17 */
18 public function load()
19 {
20 // Register module.
21 add_action('init', [AmeliaBookingModule::class, 'registerModule']);
22 }
23
24 public static function registerModule()
25 {
26 // Path to module metadata that is shared between Frontend and Visual Builder.
27 $module_json_folder_path = dirname(__DIR__, 1) . '/visual-builder/src/modules/Booking';
28
29 ModuleRegistration::register_module(
30 $module_json_folder_path,
31 [
32 'render_callback' => [AmeliaBookingModule::class, 'renderCallback'],
33 ]
34 );
35 }
36
37 /**
38 * Render module HTML output.
39 */
40 public static function renderCallback($attrs, $content, $block, $elements)
41 {
42 $shortcode = '[' . ShortcodeAliasService::activeShortcodeTag('stepbooking', 'ameliastepbooking');
43
44 $show_all = $attrs['type']['innerContent']['desktop']['value'] ?? null;
45 if ($show_all !== null && $show_all !== '0') {
46 $shortcode .= ' show=' . $show_all;
47 }
48
49 $trigger = $attrs['trigger']['innerContent']['desktop']['value'] ?? null;
50 if ($trigger !== null && $trigger !== '') {
51 $shortcode .= ' trigger=' . esc_attr($trigger);
52 }
53
54 // Layout
55 $layout = $attrs['layout']['innerContent']['desktop']['value'] ?? null;
56 if ($layout !== null && $layout !== '') {
57 $shortcode .= ' layout=' . $layout;
58 }
59
60 // Trigger Type
61 $trigger_type = $attrs['trigger_type']['innerContent']['desktop']['value'] ?? null;
62 if ($trigger && $trigger_type !== null && $trigger_type !== '') {
63 $shortcode .= ' trigger_type=' . $trigger_type;
64 }
65
66 // In Dialog
67 $in_dialog = $attrs['in_dialog']['innerContent']['desktop']['value'] ?? false;
68 if ($in_dialog === 'on') {
69 $shortcode .= ' in_dialog=1';
70 }
71
72 $preselect = $attrs['parameters']['innerContent']['desktop']['value'] ?? false;
73 if ($preselect === 'on') {
74 $category = $attrs['categories']['innerContent']['desktop']['value'] ?? [];
75 $service = $attrs['services']['innerContent']['desktop']['value'] ?? [];
76 $employee = $attrs['employees']['innerContent']['desktop']['value'] ?? [];
77 $location = $attrs['locations']['innerContent']['desktop']['value'] ?? [];
78 $package = $attrs['packages']['innerContent']['desktop']['value'] ?? [];
79
80 if ($service && count($service) > 0) {
81 $shortcode .= ' service=' . implode(',', $service);
82 } elseif ($category && count($category) > 0) {
83 $shortcode .= ' category=' . implode(',', $category);
84 }
85 if ($employee && count($employee) > 0) {
86 $shortcode .= ' employee=' . implode(',', $employee);
87 }
88 if ($location && count($location) > 0) {
89 $shortcode .= ' location=' . implode(',', $location);
90 }
91 if ($package && count($package) > 0) {
92 $shortcode .= ' package=' . implode(',', $package);
93 }
94 }
95
96 $shortcode .= ']';
97
98 return do_shortcode($shortcode);
99 }
100 }
101