PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 2.6.3
Kubio AI Page Builder v2.6.3
2.8.4 2.8.3 2.8.2 2.8.1 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.9.0 2.0.0 2.1.1 2.1.2 2.1.3 2.2.0 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.5 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.6.2 2.6.3 2.6.5 2.6.6 2.6.7 2.7.0 2.7.1 2.7.2 2.7.3 2.8.0
kubio / lib / recommendations / fluent-booking.php
kubio / lib / recommendations Last commit date
contact-forms 1 year ago bubble-chat.php 1 year ago contact-forms.php 1 year ago fluent-booking.php 1 year ago index.php 1 year ago newsletters.php 1 year ago recommendation-page-post-type.php 1 year ago recommendations-trait.php 1 year ago
fluent-booking.php
98 lines
1 <?php
2 use Kubio\Core\LodashBasic;
3
4
5 function kubio_is_fluent_booking_plugin_active() {
6 if ( ! class_exists( '\Kubio\PluginsManager' ) ) {
7 return false;
8 }
9 $manager = \Kubio\PluginsManager::getInstance();
10
11 return $manager->isPluginActive( 'fluent-booking' );
12 }
13
14 function kubio_get_fluent_booking_events() {
15 if ( ! kubio_is_fluent_booking_plugin_active() ) {
16 return array();
17 }
18 if ( ! class_exists( '\FluentBooking\App\Models\CalendarSlot' ) ||
19 ! class_exists( '\FluentBooking\App\Models\Calendar' ) ||
20 ! method_exists( '\FluentBooking\App\Models\CalendarSlot', 'getTable' ) ||
21 ! method_exists( '\FluentBooking\App\Models\Calendar', 'getTable' )
22 ) {
23 return array();
24 }
25
26 global $wpdb;
27 $calendar_slot_model = new \FluentBooking\App\Models\CalendarSlot();
28 $calendar_model = new \FluentBooking\App\Models\Calendar();
29 $calendar_slot_table = $wpdb->prefix . $calendar_slot_model->getTable();
30 $calendar_table = $wpdb->prefix . $calendar_model->getTable();
31
32 $calendars = $wpdb->get_results( "SELECT * FROM $calendar_table WHERE user_id = 1", ARRAY_A );
33
34 if ( $calendars === false || ! is_array( $calendars ) || $wpdb->last_error ) {
35 return array();
36 }
37
38 $calendar_id = LodashBasic::get( $calendars, '0.id' );
39
40 if ( empty( $calendar_id ) ) {
41 return array();
42 }
43
44 $events = $wpdb->get_results( "SELECT * FROM $calendar_slot_table WHERE calendar_id = $calendar_id", ARRAY_A );
45
46 if ( $events === false || ! is_array( $events ) || $wpdb->last_error ) {
47 return array();
48 }
49
50 $slots = array_map(
51 function ( $event ) {
52 return array(
53 'label' => LodashBasic::get( $event, 'title' ),
54 'value' => intval( LodashBasic::get( $event, 'id' ) ),
55 );
56 },
57 $events
58 );
59
60 //We make sure we have the data we require
61 $slots = array_filter(
62 $slots,
63 function ( $item ) {
64 return LodashBasic::get( $item, 'value' ) !== null && LodashBasic::get( $item, 'label' ) !== null;
65 }
66 );
67 return $slots;
68 }
69
70 function kubio_get_fluent_booking_calendar_id() {
71 if ( ! kubio_is_fluent_booking_plugin_active() ) {
72 return null;
73 }
74
75 if ( ! class_exists( '\FluentBooking\App\Models\Calendar' ) ) {
76 return null;
77 }
78
79 ob_start();
80 global $wpdb;
81 $calendar_model = new \FluentBooking\App\Models\Calendar();
82 $calendar_table = $wpdb->prefix . $calendar_model->getTable();
83
84 $calendars = $wpdb->get_results( "SELECT * FROM $calendar_table WHERE user_id = 1", OBJECT );
85
86 $calendar_id = 1;
87 if ( count( $calendars ) > 0 ) {
88 $calendar_id = $calendars[0]->id;
89 }
90
91 $errors = ob_get_clean();
92 if ( ! empty( $errors ) ) {
93 error_log( $errors );
94 }
95
96 return $calendar_id;
97 }
98