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