PluginProbe
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution / 2.5.0
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution v2.5.0
2.5.0 2.4.0 2.3.0 2.2.5 2.2.0 2.1.2 2.1.1 trunk 1.10.0 1.10.01 1.10.02 1.5.0 1.5.01 1.5.02 1.5.1 1.5.10 1.5.20 1.5.21 1.5.22 1.5.23 1.5.24 1.5.25 1.6.0 1.7.0 1.7.1 All 34 releases
← All changes | app/Hooks/Handlers/BlockEditorHandler.php +27 -35 2.2.0 → 2.5.0 View file →
@@ -2,12 +2,14 @@
2 2
3 3 namespace FluentBooking\App\Hooks\Handlers;
4 4
5 5 use FluentBooking\App\App;
6 +use FluentBooking\App\Vite;
6 7 use FluentBooking\App\Models\Calendar;
7 8 use FluentBooking\App\Models\CalendarSlot;
8 9 use FluentBooking\App\Services\CalendarEventService;
9 10 use FluentBooking\App\Services\Helper;
11 +use FluentBooking\App\Services\LocationService;
10 12 use FluentBooking\Framework\Support\Arr;
11 13
12 14 class BlockEditorHandler
13 15 {
@@ -13,48 +15,25 @@
13 15 {
14 16 public function init()
15 17 {
16 18 add_action('enqueue_block_editor_assets', function () {
17 - $app = App::getInstance();
18 - $assets = $app['url.assets'];
19 + $blockDeps = array('wp-blocks', 'wp-components', 'wp-block-editor', 'wp-element');
19 20
20 - wp_enqueue_script(
21 - 'fluent-booking/calendar',
22 - $assets . 'admin/fluent-booking-index.js',
23 - array('wp-blocks', 'wp-components', 'wp-block-editor', 'wp-element'),
24 - FLUENT_BOOKING_ASSETS_VERSION,
25 - true
26 - );
21 + $assetsVersion = Vite::isDev() ? time() : FLUENT_BOOKING_ASSETS_VERSION;
27 22
23 + Vite::enqueueScript('fluent-booking/calendar', 'fb_index', $blockDeps, $assetsVersion);
24 +
28 25 wp_localize_script('fluent-booking/calendar', 'fluentCalendarGutenbergVars', [
29 26 'ajaxurl' => admin_url('admin-ajax.php'),
30 27 ]);
31 28
32 - wp_enqueue_script(
33 - 'fluent-booking/team-management',
34 - $assets . 'admin/fluent-booking-team-management-index.js',
35 - array('wp-blocks', 'wp-components', 'wp-block-editor', 'wp-element'),
36 - FLUENT_BOOKING_ASSETS_VERSION,
37 - true
38 - );
29 + Vite::enqueueScript('fluent-booking/team-management', 'fb_team', $blockDeps, $assetsVersion);
39 30
40 - wp_enqueue_script(
41 - 'fluent-booking/calendar-management',
42 - $assets . 'admin/fluent-booking-calendar-management-index.js',
43 - array('wp-blocks', 'wp-components', 'wp-block-editor', 'wp-element'),
44 - FLUENT_BOOKING_ASSETS_VERSION,
45 - true
46 - );
31 + Vite::enqueueScript('fluent-booking/calendar-management', 'fb_calendar', $blockDeps, $assetsVersion);
47 32
48 - wp_enqueue_script(
49 - 'fluent-booking/booking-management',
50 - $assets . 'admin/fluent-booking-booking-management-index.js',
51 - array('wp-blocks', 'wp-components', 'wp-block-editor', 'wp-element'),
52 - FLUENT_BOOKING_ASSETS_VERSION,
53 - true
54 - );
33 + Vite::enqueueScript('fluent-booking/booking-management', 'fb_booking', $blockDeps, $assetsVersion);
55 34
56 - $calendars = Calendar::with(['events' => function ($query) {
35 + $calendars = Calendar::with(['metas', 'events' => function ($query) {
57 36 $query->where('status', 'active');
58 37 }])->where('status', 'active')->get();
59 38
60 39 $formattedCalendars = [];
@@ -72,9 +51,9 @@
72 51 'color_schema' => $event->color_schema,
73 52 'durations' => $event->getAvailableDurations(),
74 53 'locations' => $event->defaultLocationHtml(),
75 54 'payment_html' => $event->getPaymentHtml(),
76 - 'loc_settings' => $event->location_settings,
55 + 'loc_settings' => LocationService::sanitizePublicLocationSettings($event->location_settings),
77 56 'description' => $event->short_description
78 57 ];
79 58 }
80 59
@@ -81,9 +60,9 @@
81 60 $formattedCalendars[$calendar->id] = [
82 61 'id' => (string)$calendar->id,
83 62 'title' => $calendar->title,
84 63 'description' => wpautop(Helper::excerpt($calendar->description, 200)),
85 - 'author' => $calendar->getAuthorProfile(),
64 + 'author' => Arr::only($calendar->getAuthorProfile(), ['name', 'avatar']),
86 65 'event_order' => $calendar->getMeta('event_order'),
87 66 'events' => $formattedEvents
88 67 ];
89 68 }
@@ -88,13 +67,26 @@
88 67 ];
89 68 }
90 69
91 70 wp_localize_script('fluent-booking/calendar', 'fluent_booking_block', [
92 - 'assets_url' => $assets,
71 + 'assets_url' => App::getInstance()['url.assets'] ?? '',
93 72 'hosts' => $formattedCalendars
94 73 ]);
95 74 });
96 75
76 + add_action('enqueue_block_assets', function () {
77 + if (!is_admin()) {
78 + return;
79 + }
80 +
81 + $assetsVersion = Vite::isDev() ? time() : FLUENT_BOOKING_ASSETS_VERSION;
82 +
83 + Vite::enqueueStyle('fluent-booking/calendar-style', 'fb_index_css', [], $assetsVersion);
84 + Vite::enqueueStyle('fluent-booking/team-management-style', 'fb_team_css', [], $assetsVersion);
85 + Vite::enqueueStyle('fluent-booking/calendar-management-style', 'fb_calendar_css', [], $assetsVersion);
86 + Vite::enqueueStyle('fluent-booking/booking-management-style', 'fb_booking_css', [], $assetsVersion);
87 + });
88 +
97 89 register_block_type('fluent-booking/calendar', array(
98 90 'editor_script' => 'fluent-booking/calendar',
99 91 'render_callback' => array($this, 'fcalRenderBlock'),
100 92 'attributes' => [
@@ -239,9 +231,9 @@
239 231
240 232 $hostItems = [];
241 233
242 234 foreach ($hosts as $config) {
243 - $calendar = Calendar::find($config['id']);
235 + $calendar = Calendar::with('metas')->find($config['id']);
244 236 if (!$calendar) {
245 237 continue;
246 238 }
247 239