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
← All changes | integrations/fluentcommunity/includes/functions.php +189 -0 5.7.7 → 6.0.3 View file →
@@ -1,0 +1,189 @@
1 +<?php
2 +/**
3 + * Functions
4 + *
5 + * @package AutomatorWP\FluentCommunity\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 spaces
13 + *
14 + * @since 1.0.0
15 + *
16 + * @param stdClass $field
17 + *
18 + * @return array
19 + */
20 +function automatorwp_fluentcommunity_options_cb_space( $field ) {
21 +
22 + // Setup vars
23 + $value = $field->escaped_value;
24 + $none_value = 'any';
25 + $none_label = __( 'any space', '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 $space_id ) {
34 +
35 + // Skip option none
36 + if( $space_id === $none_value ) {
37 + continue;
38 + }
39 +
40 + $options[$space_id] = automatorwp_fluentcommunity_get_space_title( $space_id );
41 + }
42 + }
43 +
44 + return $options;
45 +
46 +}
47 +
48 +/**
49 + * Get spaces
50 + *
51 + * @since 1.0.0
52 + *
53 + * @return array|false
54 + */
55 +function automatorwp_fluentcommunity_get_spaces() {
56 +
57 + $spaces = array();
58 +
59 + // Return Collection of Space objects
60 + $all_spaces = \FluentCommunity\App\Functions\Utility::getSpaces( );
61 +
62 + foreach ( $all_spaces as $space ){
63 +
64 + $spaces[] = array(
65 + 'id' => $space['id'],
66 + 'title' => $space['title'],
67 + );
68 +
69 + }
70 +
71 + return $spaces;
72 +
73 +}
74 +
75 +/**
76 + * Get the space title
77 + *
78 + * @since 1.0.0
79 + *
80 + * @param int $space_id
81 + *
82 + * @return string|null
83 + */
84 +function automatorwp_fluentcommunity_get_space_title( $space_id ) {
85 +
86 + // Empty title if no ID provided
87 + if( absint( $space_id ) === 0 ) {
88 + return '';
89 + }
90 +
91 + $spaces = \FluentCommunity\App\Functions\Utility::getSpaces();
92 +
93 + foreach ( $spaces as $space ) {
94 + if ( absint( $space['id'] ) === absint( $space_id ) ) {
95 + return $space['title'];
96 + }
97 + }
98 +
99 +}
100 +
101 +/**
102 + * Options callback for select2 fields assigned to courses
103 + *
104 + * @since 1.0.0
105 + *
106 + * @param stdClass $field
107 + *
108 + * @return array
109 + */
110 +function automatorwp_fluentcommunity_options_cb_course( $field ) {
111 +
112 + // Setup vars
113 + $value = $field->escaped_value;
114 + $none_value = 'any';
115 + $none_label = __( 'any course', 'automatorwp' );
116 + $options = automatorwp_options_cb_none_option( $field, $none_value, $none_label );
117 +
118 + if( ! empty( $value ) ) {
119 + if( ! is_array( $value ) ) {
120 + $value = array( $value );
121 + }
122 +
123 + foreach( $value as $course_id ) {
124 +
125 + // Skip option none
126 + if( $course_id === $none_value ) {
127 + continue;
128 + }
129 +
130 + $options[$course_id] = automatorwp_fluentcommunity_get_course_title( $course_id );
131 + }
132 + }
133 +
134 + return $options;
135 +
136 +}
137 +
138 +/**
139 + * Get courses
140 + *
141 + * @since 1.0.0
142 + *
143 + * @return array|false
144 + */
145 +function automatorwp_fluentcommunity_get_courses() {
146 +
147 + $courses = array();
148 +
149 + // Return Collection of Course objects
150 + $all_courses = \FluentCommunity\App\Functions\Utility::getCourses();
151 +
152 + foreach ( $all_courses as $course ){
153 +
154 + $courses[] = array(
155 + 'id' => $course['id'],
156 + 'title' => $course['title'],
157 + );
158 +
159 + }
160 +
161 + return $courses;
162 +
163 +}
164 +
165 +/**
166 + * Get the course title
167 + *
168 + * @since 1.0.0
169 + *
170 + * @param int $course_id
171 + *
172 + * @return string|null
173 + */
174 +function automatorwp_fluentcommunity_get_course_title( $course_id ) {
175 +
176 + // Empty title if no ID provided
177 + if( absint( $course_id ) === 0 ) {
178 + return '';
179 + }
180 +
181 + $courses = \FluentCommunity\App\Functions\Utility::getCourses();
182 +
183 + foreach ( $courses as $course ) {
184 + if ( absint( $course['id'] ) === absint( $course_id ) ) {
185 + return $course['title'];
186 + }
187 + }
188 +
189 +}