PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 2.8.4
Kubio AI Page Builder v2.8.4
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 contact-forms.php 1 year ago fluent-booking.php 9 months ago index.php 1 month ago newsletters.php 1 year ago recommendation-page-post-type.php 1 year ago recommendations-trait.php 3 months ago siteleads.php 3 months ago
fluent-booking.php
97 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 // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
33 $calendars = $wpdb->get_results( "SELECT * FROM $calendar_table WHERE user_id = 1", ARRAY_A );
34
35 if ( $calendars === false || ! is_array( $calendars ) || $wpdb->last_error ) {
36 return array();
37 }
38
39 $calendar_id = LodashBasic::get( $calendars, '0.id' );
40
41 if ( empty( $calendar_id ) ) {
42 return array();
43 }
44 // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
45 $events = $wpdb->get_results( "SELECT * FROM $calendar_slot_table WHERE calendar_id = $calendar_id", ARRAY_A );
46
47 if ( $events === false || ! is_array( $events ) || $wpdb->last_error ) {
48 return array();
49 }
50
51 $slots = array_map(
52 function ( $event ) {
53 return array(
54 'label' => LodashBasic::get( $event, 'title' ),
55 'value' => intval( LodashBasic::get( $event, 'id' ) ),
56 );
57 },
58 $events
59 );
60
61 //We make sure we have the data we require
62 $slots = array_filter(
63 $slots,
64 function ( $item ) {
65 return LodashBasic::get( $item, 'value' ) !== null && LodashBasic::get( $item, 'label' ) !== null;
66 }
67 );
68 return $slots;
69 }
70
71 function kubio_get_fluent_booking_calendar_id() {
72 if ( ! kubio_is_fluent_booking_plugin_active() ) {
73 return null;
74 }
75
76 if ( ! class_exists( '\FluentBooking\App\Models\Calendar' ) ) {
77 return null;
78 }
79
80 ob_start();
81 global $wpdb;
82 $calendar_model = new \FluentBooking\App\Models\Calendar();
83 $calendar_table = $wpdb->prefix . $calendar_model->getTable();
84
85 // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
86 $calendars = $wpdb->get_results( "SELECT * FROM $calendar_table WHERE user_id = 1", OBJECT );
87
88 $calendar_id = 1;
89 if ( count( $calendars ) > 0 ) {
90 $calendar_id = $calendars[0]->id;
91 }
92
93 $errors = ob_get_clean();
94
95 return $calendar_id;
96 }
97