AmeliaBookingButtonRendererTrait.php
2 months ago
AmeliaBookingModule.php
7 months ago
AmeliaCatalogBookingModule.php
1 month ago
AmeliaCatalogModule.php
7 months ago
AmeliaCustomerPanelModule.php
7 months ago
AmeliaEmployeePanelModule.php
7 months ago
AmeliaEventsCalendarModule.php
1 month ago
AmeliaEventsListBookingButtonModule.php
2 months ago
AmeliaEventsListModule.php
1 month ago
AmeliaEventsModule.php
7 months ago
AmeliaSearchModule.php
7 months ago
AmeliaStepBookingButtonModule.php
2 months ago
AmeliaStepBookingModule.php
1 month ago
ModuleMetadata.php
1 month ago
SharedShortcodeModule.php
1 month ago
index.php
1 month ago
AmeliaStepBookingModule.php
87 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Divi5Amelia; |
| 4 | |
| 5 | use ET\Builder\Packages\ModuleLibrary\ModuleRegistration; |
| 6 | |
| 7 | /** |
| 8 | * Class that handle "Amelia Step Booking" module output in frontend. |
| 9 | */ |
| 10 | class AmeliaStepBookingModule extends SharedShortcodeModule |
| 11 | { |
| 12 | /** |
| 13 | * Register module. |
| 14 | * DependencyInterface interface ensures class method name `load()` is executed for initialization. |
| 15 | */ |
| 16 | public function load() |
| 17 | { |
| 18 | // Register module. |
| 19 | add_action('init', [AmeliaStepBookingModule::class, 'registerModule']); |
| 20 | } |
| 21 | |
| 22 | public static function registerModule() |
| 23 | { |
| 24 | // Path to module metadata that is shared between Frontend and Visual Builder. |
| 25 | $module_json_folder_path = dirname(__DIR__, 1) . '/visual-builder/src/modules/StepBooking'; |
| 26 | |
| 27 | ModuleRegistration::register_module( |
| 28 | $module_json_folder_path, |
| 29 | ModuleMetadata::getRegistrationArgs( |
| 30 | $module_json_folder_path, |
| 31 | [ |
| 32 | 'render_callback' => [AmeliaStepBookingModule::class, 'renderCallback'], |
| 33 | ] |
| 34 | ) |
| 35 | ); |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Render module HTML output. |
| 40 | */ |
| 41 | public static function renderCallback($attrs, $content, $block, $elements) |
| 42 | { |
| 43 | $shortcode = '[ameliastepbooking'; |
| 44 | |
| 45 | $show_all = $attrs['type']['innerContent']['desktop']['value'] ?? null; |
| 46 | if ($show_all !== null && $show_all !== '0') { |
| 47 | $shortcode .= ' show=' . $show_all; |
| 48 | } |
| 49 | |
| 50 | // Layout |
| 51 | $layout = $attrs['layout']['innerContent']['desktop']['value'] ?? null; |
| 52 | if ($layout !== null && $layout !== '') { |
| 53 | $shortcode .= ' layout=' . $layout; |
| 54 | } |
| 55 | |
| 56 | $shortcode .= self::getSharedShortcodeString($attrs); |
| 57 | |
| 58 | $preselect = $attrs['parameters']['innerContent']['desktop']['value'] ?? false; |
| 59 | if ($preselect === 'on') { |
| 60 | $category = $attrs['categories']['innerContent']['desktop']['value'] ?? []; |
| 61 | $service = $attrs['services']['innerContent']['desktop']['value'] ?? []; |
| 62 | $employee = $attrs['employees']['innerContent']['desktop']['value'] ?? []; |
| 63 | $location = $attrs['locations']['innerContent']['desktop']['value'] ?? []; |
| 64 | $package = $attrs['packages']['innerContent']['desktop']['value'] ?? []; |
| 65 | |
| 66 | if ($service && count($service) > 0) { |
| 67 | $shortcode .= ' service=' . implode(',', $service); |
| 68 | } elseif ($category && count($category) > 0) { |
| 69 | $shortcode .= ' category=' . implode(',', $category); |
| 70 | } |
| 71 | if ($employee && count($employee) > 0) { |
| 72 | $shortcode .= ' employee=' . implode(',', $employee); |
| 73 | } |
| 74 | if ($location && count($location) > 0) { |
| 75 | $shortcode .= ' location=' . implode(',', $location); |
| 76 | } |
| 77 | if ($package && count($package) > 0) { |
| 78 | $shortcode .= ' package=' . implode(',', $package); |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | $shortcode .= ']'; |
| 83 | |
| 84 | return do_shortcode($shortcode); |
| 85 | } |
| 86 | } |
| 87 |