PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / trunk
Booking for Appointments and Events Calendar – Amelia vtrunk
2.4.9 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 / AmeliaEmployeePanelModule.php
ameliabooking / extensions / divi_5_amelia / server Last commit date
AmeliaBookingButtonRendererTrait.php 3 months ago AmeliaBookingModule.php 1 week ago AmeliaCatalogBookingModule.php 1 week ago AmeliaCatalogModule.php 1 week ago AmeliaCatalogShortcodeHelper.php 1 week ago AmeliaCustomerPanelModule.php 1 week ago AmeliaEmployeePanelModule.php 1 week ago AmeliaEventsCalendarModule.php 1 week ago AmeliaEventsListBookingButtonModule.php 1 week ago AmeliaEventsListModule.php 1 week ago AmeliaEventsModule.php 1 week ago AmeliaSearchModule.php 1 week ago AmeliaStepBookingButtonModule.php 1 week ago AmeliaStepBookingModule.php 1 week ago ModuleMetadata.php 2 months ago SharedShortcodeModule.php 2 months ago index.php 1 week ago
AmeliaEmployeePanelModule.php
84 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 Employee Panel" module output in frontend.
11 */
12 class AmeliaEmployeePanelModule 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', [AmeliaEmployeePanelModule::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/EmployeePanel';
31
32 ModuleRegistration::register_module(
33 $module_json_folder_path,
34 [
35 'render_callback' => [AmeliaEmployeePanelModule::class, 'renderCallback'],
36 ]
37 );
38 }
39
40 /**
41 * @param mixed $value
42 * @return bool
43 */
44 private static function checkValue($value): bool
45 {
46 return isset($value) && $value !== '';
47 }
48
49 /**
50 * Render callback for the module
51 *
52 * @param array $attrs Module attributes from Visual Builder
53 * @return string Rendered HTML output
54 */
55 public static function renderCallback(array $attrs): string
56 {
57 $shortcode = '[' . ShortcodeAliasService::activeShortcodeTag('employee_panel', 'ameliaemployeepanel') . ' version=2';
58
59 $trigger = $attrs['trigger']['innerContent']['desktop']['value'] ?? '';
60 if (self::checkValue($trigger)) {
61 $shortcode .= ' trigger=' . esc_attr($trigger);
62 }
63
64 $appointments = $attrs['appointments']['innerContent']['desktop']['value'] ?? true;
65 if ($appointments === true || $appointments === 'true' || $appointments === 'on' || $appointments === 1 || $appointments === '1') {
66 $shortcode .= ' appointments=1';
67 }
68
69 $events = $attrs['events']['innerContent']['desktop']['value'] ?? true;
70 if ($events === true || $events === 'true' || $events === 'on' || $events === 1 || $events === '1') {
71 $shortcode .= ' events=1';
72 }
73
74 $profile = $attrs['profile']['innerContent']['desktop']['value'] ?? false;
75 if ($profile === true || $profile === 'true' || $profile === 'on' || $profile === 1 || $profile === '1') {
76 $shortcode .= ' profile-hidden=1';
77 }
78
79 $shortcode .= ']';
80
81 return do_shortcode($shortcode);
82 }
83 }
84