PluginProbe
AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI / 6.0.3
AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI v6.0.3
6.0.3 6.0.2 6.0.1 6.0.0 5.8.6 5.8.5 5.8.4 5.8.3 5.8.2 5.8.1 5.8.0 5.7.9.2 5.7.9.1 5.7.8 5.7.9 5.7.6 5.7.7 5.7.5 5.7.4 5.7.3 5.7.2 5.7.1 trunk 5.6.0 5.6.1 All 34 releases
automatorwp / integrations / fluentbooking / includes / functions.php

functions.php in AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI 6.0.3, at integrations/fluentbooking/includes/functions.php

191 lines 3.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Functions
4 *
5 * @package AutomatorWP\FluentBooking\Functions
6 * @since 1.0.0
7 */
8 // Exit if accessed directly
9 if( !defined( 'ABSPATH' ) ) exit;
10
11 /**
12 * Options callback for select2 fields assigned to events
13 *
14 * @since 1.0.0
15 *
16 * @param stdClass $field
17 *
18 * @return array
19 */
20 function automatorwp_fluentbooking_options_cb_single_event( $field ) {
21
22 // Setup vars
23 $value = $field->escaped_value;
24 $none_value = 'any';
25 $none_label = __( 'any event', 'automatorwp' );
26 $options = automatorwp_options_cb_none_option( $field, $none_value, $none_label );
27
28 if( ! empty( $value ) ) {
29 if( ! is_array( $value ) ) {
30 $value = array( $value );
31 }
32
33 foreach( $value as $event_id ) {
34
35 // Skip option none
36 if( $event_id === $none_value ) {
37 continue;
38 }
39
40 $options[$event_id] = automatorwp_fluentbooking_get_single_event_title( $event_id );
41 }
42 }
43
44 return $options;
45
46 }
47
48 /**
49 * Get one-to-one events
50 *
51 * @since 1.0.0
52 *
53 * @return array|false
54 */
55 function automatorwp_fluentbooking_get_single_events() {
56
57 $calendars = array( );
58
59 $results = FluentBooking\App\Models\CalendarSlot::where( 'event_type', 'single' )->get();
60
61 foreach ( $results as $calendar ){
62
63 $calendars[] = array(
64 'id' => $calendar->id,
65 'name' => $calendar->title,
66 );
67
68 }
69
70 return $calendars;
71
72 }
73
74 /**
75 * Get the form title
76 *
77 * @since 1.0.0
78 *
79 * @param int $event_id
80 *
81 * @return string|null
82 */
83 function automatorwp_fluentbooking_get_single_event_title( $event_id ) {
84
85
86 // Empty title if no ID provided
87 if( absint( $event_id ) === 0 ) {
88 return '';
89 }
90
91 $result = FluentBooking\App\Models\CalendarSlot::where( 'id', $event_id )->get();
92
93 foreach ( $result as $event ){
94 $event_title = $event->title;
95 }
96
97 return $event_title;
98
99 }
100
101
102 /**
103 * Options callback for select2 fields assigned to team events
104 *
105 * @since 1.0.0
106 *
107 * @param stdClass $field
108 *
109 * @return array
110 */
111 function automatorwp_fluentbooking_options_cb_team_event( $field ) {
112
113 // Setup vars
114 $value = $field->escaped_value;
115 $none_value = 'any';
116 $none_label = __( 'any meeting', 'automatorwp' );
117 $options = automatorwp_options_cb_none_option( $field, $none_value, $none_label );
118
119 if( ! empty( $value ) ) {
120 if( ! is_array( $value ) ) {
121 $value = array( $value );
122 }
123
124 foreach( $value as $event_id ) {
125
126 // Skip option none
127 if( $event_id === $none_value ) {
128 continue;
129 }
130
131 $options[$event_id] = automatorwp_fluentbooking_get_team_event_title( $event_id );
132 }
133 }
134
135 return $options;
136
137 }
138
139 /**
140 * Get team events
141 *
142 * @since 1.0.0
143 *
144 * @return array|false
145 */
146 function automatorwp_fluentbooking_get_team_events() {
147
148 $calendars = array( );
149
150 $results = FluentBooking\App\Models\CalendarSlot::whereIn( 'event_type', ['collective', 'round_robin'] )->get();
151
152 foreach ( $results as $calendar ){
153
154 $calendars[] = array(
155 'id' => $calendar->id,
156 'name' => $calendar->title,
157 );
158
159 }
160
161 return $calendars;
162
163 }
164
165 /**
166 * Get the team event title
167 *
168 * @since 1.0.0
169 *
170 * @param int $event_id
171 *
172 * @return string|null
173 */
174 function automatorwp_fluentbooking_get_team_event_title( $event_id ) {
175
176
177 // Empty title if no ID provided
178 if( absint( $event_id ) === 0 ) {
179 return '';
180 }
181
182 $result = FluentBooking\App\Models\CalendarSlot::where( 'id', $event_id )->get();
183
184 foreach ( $result as $event ){
185 $event_title = $event->title;
186 }
187
188 return $event_title;
189
190 }
191