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 / autonami / includes / functions.php

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

191 lines 3.5 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\Autonami\Functions
6 * @since 1.0.0
7 */
8 // Exit if accessed directly
9 if( !defined( 'ABSPATH' ) ) exit;
10
11 /**
12 * Get the tags
13 *
14 * @since 1.0.0
15 *
16 * @return array
17 */
18 function automatorwp_autonami_get_tags( ){
19
20 $tags = array();
21
22 $all_tags = BWFCRM_Tag::get_tags();
23
24 foreach ( $all_tags as $tag ) {
25 $tags[] = array(
26 'id' => $tag['ID'],
27 'name' => $tag['name'],
28 );
29 }
30
31 return $tags;
32
33 }
34
35 /**
36 * Options callback for select2 fields assigned to tags
37 *
38 * @since 1.0.0
39 *
40 * @param stdClass $field
41 *
42 * @return array
43 */
44 function automatorwp_autonami_options_cb_tag( $field ) {
45
46 // Setup vars
47 $value = $field->escaped_value;
48 $none_value = 'any';
49 $none_label = __( 'any tag', 'automatorwp' );
50 $options = automatorwp_options_cb_none_option( $field, $none_value, $none_label );
51
52 if( ! empty( $value ) ) {
53 if( ! is_array( $value ) ) {
54 $value = array( $value );
55 }
56
57 foreach( $value as $tag_id ) {
58
59 // Skip option none
60 if( $tag_id === $none_value ) {
61 continue;
62 }
63
64 $options[$tag_id] = automatorwp_autonami_get_tag_title( $tag_id );
65 }
66 }
67
68 return $options;
69
70 }
71
72 /**
73 * Get the tag title
74 *
75 * @since 1.0.0
76 *
77 * @param int $tag_id
78 *
79 * @return string|null
80 */
81 function automatorwp_autonami_get_tag_title( $tag_id ) {
82
83 // Empty title if no ID provided
84 if( absint( $tag_id ) === 0 ) {
85 return '';
86 }
87
88 $all_tags = BWFCRM_Tag::get_tags();
89
90 foreach ( $all_tags as $tag ) {
91
92 if ( absint( $tag_id ) === absint( $tag['ID'] ) ){
93 $tag_name = $tag['name'];
94 }
95
96 }
97
98 return $tag_name;
99
100 }
101
102 /**
103 * Get the lists
104 *
105 * @since 1.0.0
106 *
107 * @return array
108 */
109 function automatorwp_autonami_get_lists( ){
110
111 $lists = array();
112
113 $all_lists = BWFCRM_Lists::get_lists();
114
115 foreach ( $all_lists as $list ) {
116 $lists[] = array(
117 'id' => $list['ID'],
118 'name' => $list['name'],
119 );
120 }
121
122 return $lists;
123
124 }
125
126 /**
127 * Options callback for select2 fields assigned to lists
128 *
129 * @since 1.0.0
130 *
131 * @param stdClass $field
132 *
133 * @return array
134 */
135 function automatorwp_autonami_options_cb_list( $field ) {
136
137 // Setup vars
138 $value = $field->escaped_value;
139 $none_value = 'any';
140 $none_label = __( 'any list', 'automatorwp' );
141 $options = automatorwp_options_cb_none_option( $field, $none_value, $none_label );
142
143 if( ! empty( $value ) ) {
144 if( ! is_array( $value ) ) {
145 $value = array( $value );
146 }
147
148 foreach( $value as $list_id ) {
149
150 // Skip option none
151 if( $list_id === $none_value ) {
152 continue;
153 }
154
155 $options[$list_id] = automatorwp_autonami_get_list_title( $list_id );
156 }
157 }
158
159 return $options;
160
161 }
162
163 /**
164 * Get the list title
165 *
166 * @since 1.0.0
167 *
168 * @param int $list_id
169 *
170 * @return string|null
171 */
172 function automatorwp_autonami_get_list_title( $list_id ) {
173
174 // Empty title if no ID provided
175 if( absint( $list_id ) === 0 ) {
176 return '';
177 }
178
179 $all_lists = BWFCRM_Lists::get_lists();
180
181 foreach ( $all_lists as $list ) {
182
183 if ( absint( $list_id ) === absint( $list['ID'] ) ){
184 $list_name = $list['name'];
185 }
186
187 }
188
189 return $list_name;
190
191 }