PluginProbe
AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI / 6.0.0
AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI v6.0.0
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 / advanced-custom-fields / includes / functions.php

functions.php in AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI 6.0.0, at integrations/advanced-custom-fields/includes/functions.php

97 lines 2.0 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\Advance_Custom_Fields\Functions
6 * @since 1.0.0
7 */
8 // Exit if accessed directly
9 if( !defined( 'ABSPATH' ) ) exit;
10
11 /**
12 * Get acf fields related to posts
13 *
14 * @since 1.0.0
15 *
16 * @return array
17 */
18 function automatorwp_advanced_custom_fields_options_cb_fields_posts( ) {
19
20 $options = array(
21 'any' => __( 'any field', 'automatorwp-advanced-custom-fields' ),
22 );
23
24 // Get all post types
25 $all_post_types = automatorwp_advanced_custom_fields_get_post_types_field_groups( 'post' );
26
27 foreach( $all_post_types as $group ) {
28
29 // Get fields from group
30 $all_acf_fields = acf_get_fields( $group['ID'] );
31
32 foreach ( $all_acf_fields as $acf_fields ){
33
34 $options[$acf_fields['name']] = $acf_fields['label'];
35 }
36
37 }
38
39 return $options;
40
41 }
42
43 /**
44 * Get all post field groups
45 *
46 * @return array
47 */
48 function automatorwp_advanced_custom_fields_get_post_types_field_groups( $post_type ) {
49
50 if ( ! function_exists( 'acf_get_field_groups' ) ) {
51 return array();
52 }
53
54 $groups_post = array();
55
56 switch ( $post_type ){
57 case 'post':
58 $groups_types = array(
59 'post_type',
60 'post_template',
61 'post_status',
62 'post_format',
63 'post_category',
64 'post_taxonomy',
65 'post',
66 );
67 break;
68 }
69
70 $groups = acf_get_field_groups();
71
72 foreach ( $groups as $group ) {
73
74 if ( ! empty( $group['location'] ) ) {
75
76 foreach ( $group['location'] as $locations ) {
77
78 foreach ( $locations as $location ) {
79
80 if ( ! in_array( $location['param'], $groups_types )) {
81 continue;
82
83 } else {
84 $groups_post[] = $group;
85 }
86
87 }
88
89 }
90
91 }
92
93 }
94
95 return $groups_post;
96
97 }