PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.6
Booking for Appointments and Events Calendar – Amelia v2.4.6
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 / AmeliaCatalogModule.php
ameliabooking / extensions / divi_5_amelia / server Last commit date
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
AmeliaCatalogModule.php
84 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 Catalog" (legacy) module output in frontend.
10 */
11 class AmeliaCatalogModule 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', [AmeliaCatalogModule::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/Catalog';
27
28 ModuleRegistration::register_module(
29 $module_json_folder_path,
30 [
31 'render_callback' => [AmeliaCatalogModule::class, 'renderCallback'],
32 ]
33 );
34 }
35
36 /**
37 * Render module HTML output.
38 * This converts old divi_catalog to ameliacatalogbooking shortcode.
39 */
40 public static function renderCallback($attrs, $content, $block, $elements)
41 {
42 $shortcode = '[ameliacatalogbooking';
43
44 $catalogView = $attrs['catalog_view']['innerContent']['desktop']['value'] ?? '0';
45
46 // Handle catalog view
47 if ($catalogView && $catalogView !== '0') {
48 // Map the categories/services/packages based on view
49 if ($catalogView === 'category') {
50 $categories = $attrs['categories_catalog']['innerContent']['desktop']['value'] ?? [];
51 if ($categories && count($categories) > 0) {
52 $shortcode .= ' category=' . implode(',', $categories);
53 }
54 } elseif ($catalogView === 'service') {
55 $services = $attrs['services_catalog']['innerContent']['desktop']['value'] ?? [];
56 if ($services && count($services) > 0) {
57 $shortcode .= ' service=' . implode(',', $services);
58 }
59 } elseif ($catalogView === 'package') {
60 $packages = $attrs['packages_catalog']['innerContent']['desktop']['value'] ?? [];
61 if ($packages && count($packages) > 0) {
62 $shortcode .= ' package=' . implode(',', $packages);
63 }
64 }
65 }
66
67 // Type
68 $type = $attrs['type']['innerContent']['desktop']['value'] ?? null;
69 if ($type !== null && $type !== '0') {
70 $shortcode .= ' show=' . $type;
71 }
72
73 // Trigger
74 $trigger = $attrs['trigger']['innerContent']['desktop']['value'] ?? null;
75 if ($trigger !== null && $trigger !== '') {
76 $shortcode .= ' trigger=' . esc_attr($trigger);
77 }
78
79 $shortcode .= ']';
80
81 return do_shortcode($shortcode);
82 }
83 }
84