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
AmeliaSearchModule.php
62 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Divi5Amelia; |
| 4 | |
| 5 | use ET\Builder\Framework\DependencyManagement\Interfaces\DependencyInterface; |
| 6 | use ET\Builder\Packages\ModuleLibrary\ModuleRegistration; |
| 7 | |
| 8 | /** |
| 9 | * Class that handle "Amelia Search" module output in frontend. |
| 10 | */ |
| 11 | class AmeliaSearchModule implements DependencyInterface |
| 12 | { |
| 13 | /** |
| 14 | * Register module. |
| 15 | * DependencyInterface interface ensures class method name `load()` is executed for initialization. |
| 16 | */ |
| 17 | public function load() |
| 18 | { |
| 19 | // Register module. |
| 20 | add_action('init', [AmeliaSearchModule::class, 'registerModule']); |
| 21 | } |
| 22 | |
| 23 | public static function registerModule() |
| 24 | { |
| 25 | // Path to module metadata that is shared between Frontend and Visual Builder. |
| 26 | $module_json_folder_path = dirname(__DIR__, 1) . '/visual-builder/src/modules/Search'; |
| 27 | |
| 28 | ModuleRegistration::register_module( |
| 29 | $module_json_folder_path, |
| 30 | [ |
| 31 | 'render_callback' => [AmeliaSearchModule::class, 'renderCallback'], |
| 32 | ] |
| 33 | ); |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Render module HTML output. |
| 38 | */ |
| 39 | public static function renderCallback($attrs, $content, $block, $elements) |
| 40 | { |
| 41 | $shortcode = '[ameliasearch'; |
| 42 | |
| 43 | $trigger = $attrs['trigger']['innerContent']['desktop']['value'] ?? null; |
| 44 | if ($trigger !== null && $trigger !== '') { |
| 45 | $shortcode .= ' trigger=' . esc_attr($trigger); |
| 46 | } |
| 47 | |
| 48 | $bookingParams = $attrs['booking_params']['innerContent']['desktop']['value'] ?? 'off'; |
| 49 | if ($bookingParams === 'on') { |
| 50 | $showAll = $attrs['type']['innerContent']['desktop']['value'] ?? '0'; |
| 51 | if ($showAll !== null && $showAll !== '' && $showAll !== '0') { |
| 52 | $shortcode .= ' show=' . $showAll; |
| 53 | } |
| 54 | $shortcode .= ' today=1'; |
| 55 | } |
| 56 | |
| 57 | $shortcode .= ']'; |
| 58 | |
| 59 | return do_shortcode($shortcode); |
| 60 | } |
| 61 | } |
| 62 |