PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / trunk
Booking for Appointments and Events Calendar – Amelia vtrunk
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 / AmeliaEventsCalendarModule.php
ameliabooking / extensions / divi_5_amelia / server Last commit date
AmeliaBookingButtonRendererTrait.php 3 months ago AmeliaBookingModule.php 5 days ago AmeliaCatalogBookingModule.php 5 days ago AmeliaCatalogModule.php 5 days ago AmeliaCatalogShortcodeHelper.php 5 days ago AmeliaCustomerPanelModule.php 5 days ago AmeliaEmployeePanelModule.php 5 days ago AmeliaEventsCalendarModule.php 5 days ago AmeliaEventsListBookingButtonModule.php 5 days ago AmeliaEventsListModule.php 5 days ago AmeliaEventsModule.php 5 days ago AmeliaSearchModule.php 5 days ago AmeliaStepBookingButtonModule.php 5 days ago AmeliaStepBookingModule.php 5 days ago ModuleMetadata.php 2 months ago SharedShortcodeModule.php 2 months ago index.php 5 days ago
AmeliaEventsCalendarModule.php
75 lines
1 <?php
2
3 namespace Divi5Amelia;
4
5 use AmeliaBooking\Infrastructure\WP\ShortcodeService\ShortcodeAliasService;
6 use ET\Builder\Packages\ModuleLibrary\ModuleRegistration;
7
8 /**
9 * Class that handle "Amelia Events Calendar" module output in frontend.
10 */
11 class AmeliaEventsCalendarModule extends SharedShortcodeModule
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', [AmeliaEventsCalendarModule::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/EventsCalendar';
27
28 ModuleRegistration::register_module(
29 $module_json_folder_path,
30 [
31 'render_callback' => [AmeliaEventsCalendarModule::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 = '[' . ShortcodeAliasService::activeShortcodeTag('eventscalendarbooking', 'ameliaeventscalendarbooking');
42
43 $shortcode .= self::getSharedShortcodeString($attrs);
44
45 $booking_params = $attrs['booking_params']['innerContent']['desktop']['value'] ?? false;
46 if ($booking_params === 'on') {
47 $event = $attrs['events']['innerContent']['desktop']['value'] ?? [];
48 if ($event && count($event) > 0) {
49 $shortcode .= ' event=' . implode(',', $event);
50 }
51
52 $tag = $attrs['tags']['innerContent']['desktop']['value'] ?? [];
53 if ($tag && count($tag) > 0) {
54 $shortcode .= ' tag="' . implode(',', array_map(function ($t) {
55 return '{' . $t . '}';
56 }, $tag)) . '"';
57 }
58
59 $recurring = $attrs['recurring']['innerContent']['desktop']['value'] ?? false;
60 if ($recurring === 'on') {
61 $shortcode .= ' recurring=1';
62 }
63
64 $locations = $attrs['locations']['innerContent']['desktop']['value'] ?? [];
65 if ($locations && count($locations) > 0) {
66 $shortcode .= ' location=' . implode(',', $locations);
67 }
68 }
69
70 $shortcode .= ']';
71
72 return do_shortcode($shortcode);
73 }
74 }
75