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 / AmeliaCustomerPanelModule.php
ameliabooking / extensions / divi_5_amelia / server Last commit date
AmeliaBookingButtonRendererTrait.php 3 months ago AmeliaBookingModule.php 1 day ago AmeliaCatalogBookingModule.php 1 day ago AmeliaCatalogModule.php 1 day ago AmeliaCatalogShortcodeHelper.php 1 day ago AmeliaCustomerPanelModule.php 1 day ago AmeliaEmployeePanelModule.php 1 day ago AmeliaEventsCalendarModule.php 1 day ago AmeliaEventsListBookingButtonModule.php 1 day ago AmeliaEventsListModule.php 1 day ago AmeliaEventsModule.php 1 day ago AmeliaSearchModule.php 1 day ago AmeliaStepBookingButtonModule.php 1 day ago AmeliaStepBookingModule.php 1 day ago ModuleMetadata.php 2 months ago SharedShortcodeModule.php 2 months ago index.php 1 day ago
AmeliaCustomerPanelModule.php
70 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 Customer Panel" module output in frontend.
11 */
12 class AmeliaCustomerPanelModule 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', [AmeliaCustomerPanelModule::class, 'registerModule']);
22 }
23
24 /**
25 * Register module.
26 */
27 public static function registerModule()
28 {
29 // Path to module metadata that is shared between Frontend and Visual Builder.
30 $module_json_folder_path = dirname(__DIR__, 1) . '/visual-builder/src/modules/CustomerPanel';
31
32 ModuleRegistration::register_module(
33 $module_json_folder_path,
34 [
35 'render_callback' => [AmeliaCustomerPanelModule::class, 'renderCallback'],
36 ]
37 );
38 }
39
40 /**
41 * Render callback for the module
42 *
43 * @param array $attrs Module attributes from Visual Builder
44 * @return string Rendered HTML output
45 */
46 public static function renderCallback(array $attrs): string
47 {
48 $shortcode = '[' . ShortcodeAliasService::activeShortcodeTag('customer_panel', 'ameliacustomerpanel') . ' version=2';
49
50 $trigger = $attrs['trigger']['innerContent']['desktop']['value'] ?? '';
51 if ($trigger) {
52 $shortcode .= ' trigger=' . esc_attr($trigger);
53 }
54
55 $appointments = $attrs['appointments']['innerContent']['desktop']['value'] ?? true;
56 if ($appointments === true || $appointments === 'true' || $appointments === 'on' || $appointments === 1 || $appointments === '1') {
57 $shortcode .= ' appointments=1';
58 }
59
60 $events = $attrs['events']['innerContent']['desktop']['value'] ?? true;
61 if ($events === true || $events === 'true' || $events === 'on' || $events === 1 || $events === '1') {
62 $shortcode .= ' events=1';
63 }
64
65 $shortcode .= ']';
66
67 return do_shortcode($shortcode);
68 }
69 }
70