PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 3.2.2
Pods – Custom Content Types and Fields v3.2.2
trunk 1.14.8 2.7.31.3 2.8.23.3 2.9.19.3 3.0.10.3 3.1.4.1 3.2.0 3.2.1 3.2.1.1 3.2.2 3.2.4 3.2.5 3.2.6 3.2.7 3.2.7.1 3.2.8 3.2.8.1 3.2.8.2 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9
pods / includes / compatibility / acf.php
pods / includes / compatibility Last commit date
acf.php 6 years ago
acf.php
415 lines
1 <?php
2 /**
3 * Compatibility functions for integration with other plugins.
4 *
5 * @package Pods
6 */
7
8 /**
9 * Enable backwards compatibility with ACF functions.
10 *
11 * @param bool $acf_backwards_compatibility Whether to enable backwards compatibility for ACF functions.
12 *
13 * @since 2.7.17
14 */
15 $acf_backwards_compatibility = apply_filters( 'pods_acf_backwards_compatibility', true );
16
17 if ( $acf_backwards_compatibility ) {
18 if ( ! function_exists( 'the_field' ) ) {
19 /**
20 * Backwards compatibility function for the_field() from ACF.
21 *
22 * @param string|array $field The field name, or an associative array of parameters.
23 * @param mixed|false $id The ID or slug to load a single item, array of $params to run find.
24 *
25 * @since 2.7.17
26 */
27 function the_field( $field, $id = false ) {
28 // @codingStandardsIgnoreLine
29 echo pods_field_display( null, $id, $field, true );
30 }
31 }
32
33 if ( ! function_exists( 'get_field' ) ) {
34 /**
35 * Backwards compatibility function for get_field() from ACF.
36 *
37 * @param string|array $field The field name, or an associative array of parameters.
38 * @param mixed|false $id The ID or slug to load a single item, array of $params to run find.
39 *
40 * @return mixed Field value.
41 *
42 * @since 2.7.17
43 */
44 function get_field( $field, $id = false ) {
45 return pods_field( null, $id, $field, true );
46 }
47 }
48
49 if ( ! function_exists( 'update_field' ) ) {
50 /**
51 * Backwards compatibility function for update_field() from ACF.
52 *
53 * @param string|array $field The field name, or an associative array of parameters.
54 * @param mixed $value The value to save.
55 * @param mixed|false $id The ID or slug to load a single item, array of $params to run find.
56 *
57 * @return int|false The item ID or false if not saved.
58 *
59 * @since 2.7.17
60 */
61 function update_field( $field, $value, $id = false ) {
62 return pods_field_update( null, $id, $field, $value );
63 }
64 }
65
66 if ( ! function_exists( 'delete_field' ) ) {
67 /**
68 * Backwards compatibility function for delete_field() from ACF.
69 *
70 * @param string|array $field The field name, or an associative array of parameters.
71 * @param mixed|false $id The ID or slug to load a single item, array of $params to run find.
72 *
73 * @return int|false The item ID or false if not saved.
74 *
75 * @since 2.7.17
76 */
77 function delete_field( $field, $id = false ) {
78 return pods_field_update( null, $id, $field, null );
79 }
80 }
81
82 if ( ! shortcode_exists( 'acf' ) ) {
83 /**
84 * Backwards compatibility function for [acf] shortcode from ACF.
85 *
86 * @param array $tags An associative array of shortcode properties.
87 * @param string $content A string that represents a template override.
88 *
89 * @return string
90 *
91 * @since 2.7.17
92 */
93 function pods_acf_shortcode( $tags, $content ) {
94
95 $post_id = null;
96
97 if ( ! empty( $tags['post_id'] ) ) {
98 $post_id = $tags['post_id'];
99 }
100
101 $tags = array(
102 'field' => $tags['field'],
103 'id' => $post_id,
104 );
105
106 return pods_shortcode( $tags, $content );
107 }
108
109 add_shortcode( 'acf', 'pods_acf_shortcode' );
110 }//end if
111
112 /**
113 * These functions below will do nothing for now. We might add some sort of further compatibility later.
114 */
115
116 if ( ! function_exists( 'get_field_object' ) ) {
117 /**
118 * Backwards compatibility function for get_field_object() from ACF.
119 *
120 * @return array
121 *
122 * @since 2.7.17
123 */
124 function get_field_object() {
125 return array();
126 }
127 }
128
129 if ( ! function_exists( 'get_fields' ) ) {
130 /**
131 * Backwards compatibility function for get_fields() from ACF.
132 *
133 * @return array
134 *
135 * @since 2.7.17
136 */
137 function get_fields() {
138 return array();
139 }
140 }
141
142 if ( ! function_exists( 'get_field_objects' ) ) {
143 /**
144 * Backwards compatibility function for get_field_objects() from ACF.
145 *
146 * @return array
147 *
148 * @since 2.7.17
149 */
150 function get_field_objects() {
151 return array();
152 }
153 }
154
155 if ( ! function_exists( 'have_rows' ) ) {
156 /**
157 * Backwards compatibility function for have_rows() from ACF.
158 *
159 * @return false
160 *
161 * @since 2.7.17
162 */
163 function have_rows() {
164 return false;
165 }
166 }
167
168 if ( ! function_exists( 'get_sub_field' ) ) {
169 /**
170 * Backwards compatibility function for get_sub_field() from ACF.
171 *
172 * @return false
173 *
174 * @since 2.7.17
175 */
176 function get_sub_field() {
177 return false;
178 }
179 }
180
181 if ( ! function_exists( 'the_sub_field' ) ) {
182 /**
183 * Backwards compatibility function for the_sub_field() from ACF.
184 *
185 * @return null
186 *
187 * @since 2.7.17
188 */
189 function the_sub_field() {
190 return null;
191 }
192 }
193
194 if ( ! function_exists( 'get_sub_field_object' ) ) {
195 /**
196 * Backwards compatibility function for get_sub_field_object() from ACF.
197 *
198 * @return array
199 *
200 * @since 2.7.17
201 */
202 function get_sub_field_object() {
203 return array();
204 }
205 }
206
207 if ( ! function_exists( 'get_row' ) ) {
208 /**
209 * Backwards compatibility function for get_row() from ACF.
210 *
211 * @return array
212 *
213 * @since 2.7.17
214 */
215 function get_row() {
216 return array();
217 }
218 }
219
220 if ( ! function_exists( 'get_row_index' ) ) {
221 /**
222 * Backwards compatibility function for get_row_index() from ACF.
223 *
224 * @return int
225 *
226 * @since 2.7.17
227 */
228 function get_row_index() {
229 return 0;
230 }
231 }
232
233 if ( ! function_exists( 'get_row_layout' ) ) {
234 /**
235 * Backwards compatibility function for get_row_layout() from ACF.
236 *
237 * @return null
238 *
239 * @since 2.7.17
240 */
241 function get_row_layout() {
242 return null;
243 }
244 }
245
246 if ( ! function_exists( 'delete_sub_field' ) ) {
247 /**
248 * Backwards compatibility function for delete_sub_field() from ACF.
249 *
250 * @return null
251 *
252 * @since 2.7.17
253 */
254 function delete_sub_field() {
255 return null;
256 }
257 }
258
259 if ( ! function_exists( 'update_sub_field' ) ) {
260 /**
261 * Backwards compatibility function for update_sub_field() from ACF.
262 *
263 * @return null
264 *
265 * @since 2.7.17
266 */
267 function update_sub_field() {
268 return null;
269 }
270 }
271
272 if ( ! function_exists( 'add_row' ) ) {
273 /**
274 * Backwards compatibility function for add_row() from ACF.
275 *
276 * @return null
277 *
278 * @since 2.7.17
279 */
280 function add_row() {
281 return null;
282 }
283 }
284
285 if ( ! function_exists( 'update_row' ) ) {
286 /**
287 * Backwards compatibility function for update_row() from ACF.
288 *
289 * @return null
290 *
291 * @since 2.7.17
292 */
293 function update_row() {
294 return null;
295 }
296 }
297
298 if ( ! function_exists( 'delete_row' ) ) {
299 /**
300 * Backwards compatibility function for delete_row() from ACF.
301 *
302 * @return null
303 *
304 * @since 2.7.17
305 */
306 function delete_row() {
307 return null;
308 }
309 }
310
311 if ( ! function_exists( 'add_sub_row' ) ) {
312 /**
313 * Backwards compatibility function for add_sub_row() from ACF.
314 *
315 * @return null
316 *
317 * @since 2.7.17
318 */
319 function add_sub_row() {
320 return null;
321 }
322 }
323
324 if ( ! function_exists( 'update_sub_row' ) ) {
325 /**
326 * Backwards compatibility function for update_sub_row() from ACF.
327 *
328 * @return null
329 *
330 * @since 2.7.17
331 */
332 function update_sub_row() {
333 return null;
334 }
335 }
336
337 if ( ! function_exists( 'delete_sub_row' ) ) {
338 /**
339 * Backwards compatibility function for delete_sub_row() from ACF.
340 *
341 * @return null
342 *
343 * @since 2.7.17
344 */
345 function delete_sub_row() {
346 return null;
347 }
348 }
349
350 if ( ! function_exists( 'acf_add_options_page' ) ) {
351 /**
352 * Backwards compatibility function for acf_add_options_page() from ACF.
353 *
354 * @return null
355 *
356 * @since 2.7.17
357 */
358 function acf_add_options_page() {
359 return null;
360 }
361 }
362
363 if ( ! function_exists( 'acf_add_options_sub_page' ) ) {
364 /**
365 * Backwards compatibility function for acf_add_options_sub_page() from ACF.
366 *
367 * @return null
368 *
369 * @since 2.7.17
370 */
371 function acf_add_options_sub_page() {
372 return null;
373 }
374 }
375
376 if ( ! function_exists( 'acf_form_head' ) ) {
377 /**
378 * Backwards compatibility function for acf_form_head() from ACF.
379 *
380 * @return null
381 *
382 * @since 2.7.17
383 */
384 function acf_form_head() {
385 return null;
386 }
387 }
388
389 if ( ! function_exists( 'acf_form' ) ) {
390 /**
391 * Backwards compatibility function for acf_form() from ACF.
392 *
393 * @return null
394 *
395 * @since 2.7.17
396 */
397 function acf_form() {
398 return null;
399 }
400 }
401
402 if ( ! function_exists( 'acf_register_form' ) ) {
403 /**
404 * Backwards compatibility function for acf_register_form() from ACF.
405 *
406 * @return null
407 *
408 * @since 2.7.17
409 */
410 function acf_register_form() {
411 return null;
412 }
413 }
414 }//end if
415