PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.8
Booking for Appointments and Events Calendar – Amelia v2.4.8
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 / src / Infrastructure / WP / Elementor / ElementorBlock.php
ameliabooking / src / Infrastructure / WP / Elementor Last commit date
AmeliaBookingElementorWidget.php 1 week ago AmeliaCatalogBookingElementorWidget.php 1 week ago AmeliaCatalogElementorWidget.php 1 week ago AmeliaElementorWhiteLabelHelper.php 1 week ago AmeliaEventsCalendarBookingElementorWidget.php 1 week ago AmeliaEventsElementorWidget.php 1 week ago AmeliaEventsListBookingButtonElementorWidget.php 1 week ago AmeliaEventsListBookingElementorWidget.php 1 week ago AmeliaStepBookingButtonElementorWidget.php 1 week ago AmeliaStepBookingElementorWidget.php 1 week ago ElementorBlock.php 1 week ago ElementorSharedShortcodeWidget.php 2 months ago
ElementorBlock.php
161 lines
1 <?php
2
3 /**
4 * @copyright © Melograno Ventures. All rights reserved.
5 * @licence See LICENCE.md for license details.
6 */
7
8 namespace AmeliaBooking\Infrastructure\WP\Elementor;
9
10 use AmeliaBooking\Domain\Services\Settings\SettingsService;
11 use AmeliaBooking\Infrastructure\WP\SettingsService\SettingsStorage;
12 use AmeliaBooking\Infrastructure\WP\ShortcodeService\ShortcodeAliasService;
13 use Elementor\AmeliaBookingElementorWidget;
14 use Elementor\AmeliaStepBookingElementorWidget;
15 use Elementor\AmeliaStepBookingButtonElementorWidget;
16 use Elementor\AmeliaCatalogBookingElementorWidget;
17 use Elementor\AmeliaCatalogElementorWidget;
18 use Elementor\AmeliaEventsElementorWidget;
19 use Elementor\AmeliaEventsListBookingElementorWidget;
20 use Elementor\AmeliaEventsListBookingButtonElementorWidget;
21 use Elementor\Plugin;
22
23 /**
24 * Class ElementorBlock
25 *
26 * @package AmeliaBooking\Infrastructure\WP\Elementor
27 */
28 class ElementorBlock
29 {
30 protected static $instance;
31
32 public static function get_instance()
33 {
34 if (!isset(static::$instance)) {
35 static::$instance = new static();
36 }
37
38 return static::$instance;
39 }
40
41 protected function __construct()
42 {
43 add_action('elementor/editor/before_enqueue_scripts', [$this, 'widget_styles']);
44 add_action('elementor/editor/after_enqueue_styles', [$this, 'widget_styles']);
45 add_action('elementor/widgets/register', [$this, 'register_widgets']);
46 add_action('elementor/frontend/after_enqueue_styles', [$this, 'widget_styles']);
47 add_action('elementor/elements/categories_registered', [$this, 'register_widget_categories']);
48 add_filter('admin_body_class', [$this, 'addWhiteLabelBodyClass']);
49 }
50
51 public function includes()
52 {
53 require_once(AMELIA_PATH . '/src/Infrastructure/WP/Elementor/AmeliaElementorWhiteLabelHelper.php');
54 require_once(AMELIA_PATH . '/src/Infrastructure/WP/Elementor/ElementorSharedShortcodeWidget.php');
55 require_once(AMELIA_PATH . '/src/Infrastructure/WP/Elementor/AmeliaStepBookingElementorWidget.php');
56 require_once(AMELIA_PATH . '/src/Infrastructure/WP/Elementor/AmeliaStepBookingButtonElementorWidget.php');
57 require_once(AMELIA_PATH . '/src/Infrastructure/WP/Elementor/AmeliaCatalogBookingElementorWidget.php');
58 require_once(AMELIA_PATH . '/src/Infrastructure/WP/Elementor/AmeliaBookingElementorWidget.php');
59 require_once(AMELIA_PATH . '/src/Infrastructure/WP/Elementor/AmeliaCatalogElementorWidget.php');
60 require_once(AMELIA_PATH . '/src/Infrastructure/WP/Elementor/AmeliaEventsElementorWidget.php');
61 require_once(AMELIA_PATH . '/src/Infrastructure/WP/Elementor/AmeliaEventsListBookingElementorWidget.php');
62 require_once(AMELIA_PATH . '/src/Infrastructure/WP/Elementor/AmeliaEventsListBookingButtonElementorWidget.php');
63 }
64
65 public function register_widgets()
66 {
67 $this->includes();
68 Plugin::instance()->widgets_manager->register(new AmeliaStepBookingElementorWidget());
69 Plugin::instance()->widgets_manager->register(new AmeliaStepBookingButtonElementorWidget());
70 Plugin::instance()->widgets_manager->register(new AmeliaCatalogBookingElementorWidget());
71 Plugin::instance()->widgets_manager->register(new AmeliaBookingElementorWidget());
72 Plugin::instance()->widgets_manager->register(new AmeliaCatalogElementorWidget());
73 Plugin::instance()->widgets_manager->register(new AmeliaEventsElementorWidget());
74 Plugin::instance()->widgets_manager->register(new AmeliaEventsListBookingElementorWidget());
75 Plugin::instance()->widgets_manager->register(new AmeliaEventsListBookingButtonElementorWidget());
76 }
77
78 public function widget_styles()
79 {
80 wp_register_style('amelia-elementor-widget-font', AMELIA_URL . 'public/css/frontend/elementor.css', array(), AMELIA_VERSION);
81 wp_enqueue_style('amelia-elementor-widget-font');
82
83 $settingsService = new SettingsService(new SettingsStorage());
84 $useNeutral = ShortcodeAliasService::shouldUseNeutralShortcodes($settingsService);
85
86 // Elementor editor does not use admin_body_class; inject the flag on html/body instead.
87 if ($useNeutral) {
88 wp_register_script('amelia-elementor-white-label', false, [], AMELIA_VERSION, false);
89 wp_enqueue_script('amelia-elementor-white-label');
90 wp_add_inline_script(
91 'amelia-elementor-white-label',
92 '(function(){var c="amelia-white-label-active";document.documentElement.classList.add(c);'
93 . 'function a(){if(document.body){document.body.classList.add(c)}}'
94 . 'document.body?a():document.addEventListener("DOMContentLoaded",a);})();'
95 );
96
97 // Custom image uploaded: replace Amelia logo on Elementor widget icons.
98 // White-label without image: keep Amelia logo from elementor.css (same as Divi).
99 $pluginImage = ShortcodeAliasService::getWhiteLabelPluginImage($settingsService);
100 if ($pluginImage !== '') {
101 wp_register_style('amelia-white-label-builders', false, ['amelia-elementor-widget-font'], AMELIA_VERSION);
102 wp_enqueue_style('amelia-white-label-builders');
103
104 $iconSelectors = [
105 '.elementor-element .icon .amelia-logo:before',
106 '.elementor-element .icon i.amelia-logo:before',
107 '.elementor-element .icon .amelia-logo-beta:before',
108 '.elementor-element .icon i.amelia-logo-beta:before',
109 '.elementor-element .icon .amelia-logo-outdated:before',
110 '.elementor-element .icon i.amelia-logo-outdated:before',
111 '.amelia-elementor-content::before',
112 '.amelia-elementor-content-beta::before',
113 '.amelia-elementor-content-outdated::before',
114 ];
115 $selectors = [];
116 foreach ($iconSelectors as $iconSelector) {
117 $selectors[] = 'html.amelia-white-label-active ' . $iconSelector;
118 $selectors[] = 'body.amelia-white-label-active ' . $iconSelector;
119 }
120 $css = implode(', ', $selectors) . '{'
121 . 'content:""!important;'
122 . 'display:block!important;'
123 . 'background-image:url(' . esc_url_raw($pluginImage) . ')!important;'
124 . 'background-repeat:no-repeat!important;'
125 . 'background-position:center center!important;'
126 . 'background-size:contain!important;'
127 . '}';
128 wp_add_inline_style('amelia-white-label-builders', $css);
129 }
130 }
131 }
132
133 /**
134 * @param string $classes
135 *
136 * @return string
137 */
138 public function addWhiteLabelBodyClass($classes)
139 {
140 if (ShortcodeAliasService::shouldUseNeutralShortcodes()) {
141 $classes .= ' amelia-white-label-active';
142 }
143
144 return $classes;
145 }
146
147 public function register_widget_categories($elements_manager)
148 {
149 require_once(AMELIA_PATH . '/src/Infrastructure/WP/Elementor/AmeliaElementorWhiteLabelHelper.php');
150
151 $elements_manager->add_category(
152 'amelia-elementor',
153 [
154 'title' => \Elementor\AmeliaElementorWhiteLabelHelper::categoryTitle(),
155 'icon' => \Elementor\AmeliaElementorWhiteLabelHelper::icon(),
156 ],
157 1
158 );
159 }
160 }
161