Advanced Custom Fields: Extended - Version 0.5

Version Description

  • Initial release

=

Download this release

Release Info

Developer hwk-fr
Plugin Icon 128x128 Advanced Custom Fields: Extended
Version 0.5
Comparing to
See all releases

Version 0.5

acf-extended.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin Name: Advanced Custom Fields: Extended
4
+ * Description: Enhancement Suite which improves Advanced Custom Fields administration
5
+ * Version: 0.5
6
+ * Author: hwk-fr
7
+ * Author URI: https://hwk.fr
8
+ * Text Domain: acfe
9
+ */
10
+
11
+ if(!defined('ABSPATH'))
12
+ exit;
13
+
14
+ /**
15
+ * ACFE: Constants
16
+ */
17
+ if(!defined('ACFE_FILE')) define('ACFE_FILE', __FILE__);
18
+ if(!defined('ACFE_PATH')) define('ACFE_PATH', plugin_dir_path(__FILE__));
19
+ if(!defined('ACFE_URL')) define('ACFE_URL', plugin_dir_url(__FILE__));
20
+ if(!defined('ACFE_BASENAME')) define('ACFE_BASENAME', plugin_basename(__FILE__));
21
+ if(!defined('ACFE_THEME_PATH')) define('ACFE_THEME_PATH', get_stylesheet_directory());
22
+ if(!defined('ACFE_THEME_URL')) define('ACFE_THEME_URL', get_stylesheet_directory_uri());
23
+
24
+ /**
25
+ * ACFE: Activate
26
+ */
27
+ register_activation_hook(ACFE_FILE, 'acfe_activate');
28
+ function acfe_activate(){
29
+ if(class_exists('ACF') && defined('ACF_PRO') && ACF_PRO === true && version_compare(ACF_VERSION, '5.7.10', '>='))
30
+ return;
31
+
32
+ deactivate_plugins(ACFE_BASENAME);
33
+ wp_die(__('ACF Extended requires at least ACF Pro version 5.7.10'));
34
+ }
35
+
36
+ /**
37
+ * ACFE: Init
38
+ */
39
+ add_action('acf/include_fields', 'acfe_init');
40
+ function acfe_init(){
41
+
42
+ /**
43
+ * Settings
44
+ */
45
+ acf_update_setting('acfe_php', true);
46
+ acf_update_setting('acfe_php_save', ACFE_THEME_PATH . '/acfe-php');
47
+ acf_update_setting('acfe_php_load', array(ACFE_THEME_PATH . '/acfe-php'));
48
+ acf_update_setting('acfe_php_found', false);
49
+
50
+ /**
51
+ * Core
52
+ */
53
+ require_once(ACFE_PATH . 'includes/core/enqueue.php');
54
+ require_once(ACFE_PATH . 'includes/core/helpers.php');
55
+
56
+ /**
57
+ * Settings
58
+ */
59
+ require_once(ACFE_PATH . 'includes/admin/settings.php');
60
+
61
+ /**
62
+ * Fields
63
+ */
64
+ require_once(ACFE_PATH . 'includes/fields/field-dynamic-message.php');
65
+ require_once(ACFE_PATH . 'includes/fields/settings-data.php');
66
+ require_once(ACFE_PATH . 'includes/fields/settings-permissions.php');
67
+ require_once(ACFE_PATH . 'includes/fields/settings-update.php');
68
+ require_once(ACFE_PATH . 'includes/fields/settings-validation.php');
69
+
70
+ /**
71
+ * Field Groups
72
+ */
73
+ require_once(ACFE_PATH . 'includes/field-groups/field-group.php');
74
+ require_once(ACFE_PATH . 'includes/field-groups/field-group-category.php');
75
+ require_once(ACFE_PATH . 'includes/field-groups/field-groups.php');
76
+
77
+ /**
78
+ * Modules
79
+ */
80
+ require_once(ACFE_PATH . 'includes/modules/autosync.php');
81
+
82
+ }
assets/admin.css ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .acf-field .acf-label label{
2
+ font-weight:600 !important;
3
+ }
4
+
5
+ .acf-field-setting-acfe_permissions > .acf-input > .acf-fields,
6
+ .acf-field-setting-acfe_validate > .acf-input > .acf-fields,
7
+ .acf-field-setting-acfe_update > .acf-input > .acf-fields,
8
+
9
+ .acf-field-setting-acfe_validate > .acf-input > .acf-fields > .acf-field.acf-field-acfe-validate-rules-or,
10
+ .acf-field-setting-acfe_update > .acf-input > .acf-fields > .acf-field.acf-field-acfe-update-functions{
11
+ border:0;
12
+ }
13
+
14
+ .acf-field-setting-acfe_permissions > .acf-input > .acf-fields > .acf-field,
15
+ .acf-field-setting-acfe_validate > .acf-input > .acf-fields > .acf-field,
16
+ .acf-field-setting-acfe_update > .acf-input > .acf-fields > .acf-field{
17
+ padding:0;
18
+ }
19
+
20
+ .acf-field-setting-acfe_validate > .acf-input > .acf-fields > .acf-field.acf-field-acfe-validate-activate > .acf-label,
21
+ .acf-field-setting-acfe_update > .acf-input > .acf-fields > .acf-field.acf-field-acfe-update-activate > .acf-label{
22
+ display:none;
23
+ }
24
+
25
+ .acf-field-setting-acfe_update > .acf-input .acf-repeater.-empty.-table > table,
26
+ .acf-field-setting-acfe_validate > .acf-input .acf-repeater.-empty.-table > table,
27
+ .acf-field-acfe-meta > .acf-input .acf-repeater.-empty.-table > table{
28
+ border:0;
29
+ display:none;
30
+ }
31
+
32
+ .acf-field-setting-acfe_update > .acf-input .acf-repeater.-empty.-table > table > thead,
33
+ .acf-field-setting-acfe_validate > .acf-input .acf-repeater.-empty.-table > table > thead,
34
+ .acf-field-acfe-meta > .acf-input .acf-repeater.-empty.-table > table > thead{
35
+ display:none;
36
+ }
37
+
38
+ .acf-field-setting-acfe_update > .acf-input > .acf-repeater .acf-actions,
39
+ .acf-field-setting-acfe_validate > .acf-input > .acf-repeater .acf-actions,
40
+ .acf-field-acfe-meta > .acf-input > .acf-repeater .acf-actions{
41
+ text-align:left;
42
+ }
43
+
44
+ .acf-field-setting-acfe_update > .acf-input > .acf-repeater .acf-actions .acf-button.button-primary,
45
+ .acf-field-setting-acfe_validate > .acf-input > .acf-repeater .acf-actions .acf-button.button-primary,
46
+ .acf-field-acfe-meta > .acf-input > .acf-repeater .acf-actions .acf-button.button-primary{
47
+ color: #555;
48
+ border-color: #ccc;
49
+ background: #f7f7f7;
50
+ box-shadow: 0 1px 0 #ccc;
51
+ text-shadow:none;
52
+ }
53
+
54
+ pre {
55
+ display: block;
56
+ padding: 9.5px;
57
+ margin: 0;
58
+ font-size: 13px;
59
+ line-height: 1.42857143;
60
+ color: #333;
61
+ word-break: break-all;
62
+ word-wrap: break-word;
63
+ background-color: #f5f5f5;
64
+ border: 1px solid #ccc;
65
+ border-radius: 4px;
66
+ white-space: pre-wrap;
67
+ overflow: auto;
68
+ }
69
+ code, kbd, pre, samp {
70
+ font-family: Menlo,Monaco,Consolas,"Courier New",monospace;
71
+ }
72
+ code, kbd, pre, samp {
73
+ font-family: monospace,monospace;
74
+ font-size: 1em;
75
+ }
76
+
77
+ .acfe_modal{
78
+ min-width:500px;
79
+ max-width:800px;
80
+ max-height:500px;
81
+ }
82
+
83
+ .column-acf-field-group-category{
84
+ width:125px;
85
+ }
86
+
87
+ td.acf-field-group-category a{
88
+ word-wrap: break-word;
89
+ padding: 2px 5px;
90
+ margin: 0 1px;
91
+ border-radius:2px;
92
+ background: rgba(0,0,0,.05);
93
+ color:#333;
94
+ }
95
+
96
+ .column-acfe-locations{
97
+ width:100px;
98
+ }
99
+
100
+ #acf-field-group-wrap .wp-list-table .column-acf-fg-status{
101
+ width:70px;
102
+ }
103
+
104
+ #acf-field-group-wrap .wp-list-table .column-acf-fg-count{
105
+ width:70px;
106
+ }
107
+
108
+ .column-acfe-local{
109
+ width:50px;
110
+ }
111
+
112
+ .column-acfe-autosync-php,
113
+ .column-acfe-autosync-json{
114
+ width:65px;
115
+ text-align:center;
116
+ }
assets/admin.js ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function($){
2
+
3
+ $('.acfe_modal').dialog({
4
+ title: 'Data',
5
+ dialogClass: 'wp-dialog',
6
+ autoOpen: false,
7
+ draggable: false,
8
+ width: 'auto',
9
+ modal: true,
10
+ resizable: false,
11
+ closeOnEscape: true,
12
+ position: {
13
+ my: "center",
14
+ at: "center",
15
+ of: window
16
+ },
17
+ open: function(){
18
+ $('.ui-widget-overlay').bind('click', function(){
19
+ $('.acfe_modal').dialog('close');
20
+ })
21
+ },
22
+ create: function(){
23
+ $('.ui-dialog-titlebar-close').addClass('ui-button');
24
+ },
25
+ });
26
+
27
+ $('.button.edit-field').each(function(k, v){
28
+ var tbody = $(this).closest('tbody');
29
+ $(tbody).find('.acfe_modal_open:first').insertAfter($(this));
30
+ $(tbody).find('tr.acf-field-setting-acfe_field_data:first').remove();
31
+ });
32
+
33
+ $('.acfe_modal_open').click(function(e){
34
+ e.preventDefault();
35
+
36
+ var key = $(this).attr('data-modal-key');
37
+ console.log(key);
38
+ $('.acfe_modal[data-modal-key=' + key + ']').dialog('open');
39
+
40
+ });
41
+
42
+ });
includes/admin/settings.php ADDED
@@ -0,0 +1,278 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ABSPATH'))
4
+ exit;
5
+
6
+ add_action('admin_menu', 'acfe_admin_settings_menu');
7
+ function acfe_admin_settings_menu(){
8
+ if(!acf_get_setting('show_admin'))
9
+ return;
10
+
11
+ $submenu_page = add_submenu_page('edit.php?post_type=acf-field-group', __('Settings'), __('Settings'), acf_get_setting('capability'), 'acfe-settings', 'acfe_admin_settings_html');
12
+
13
+ add_action('admin_print_scripts-' . $submenu_page, function(){
14
+ wp_enqueue_style('acf-input');
15
+ wp_enqueue_script('acf-input');
16
+ });
17
+ }
18
+
19
+ add_action('admin_menu', 'acfe_admin_settings_submenu_swap', 999);
20
+ function acfe_admin_settings_submenu_swap(){
21
+ global $submenu;
22
+
23
+ if(!isset($submenu['edit.php?post_type=acf-field-group']) || empty($submenu['edit.php?post_type=acf-field-group']))
24
+ return;
25
+
26
+ foreach($submenu['edit.php?post_type=acf-field-group'] as $ikey => $item){
27
+
28
+ // ACFE: Field Group Category
29
+ if($item[2] == 'edit-tags.php?taxonomy=acf-field-group-category'){
30
+ $temp_category = $submenu['edit.php?post_type=acf-field-group'][$ikey];
31
+ $temp_category_key = $ikey;
32
+ }
33
+
34
+ // ACFE: Settings
35
+ elseif($item[2] == 'acfe-settings'){
36
+ $temp_settings = $submenu['edit.php?post_type=acf-field-group'][$ikey];
37
+ $temp_settings_key = $ikey;
38
+ }
39
+
40
+ // Tools
41
+ elseif($item[2] == 'acf-tools'){
42
+ $temp_tools = $submenu['edit.php?post_type=acf-field-group'][$ikey];
43
+ $temp_tools_key = $ikey;
44
+ }
45
+
46
+ // Infos
47
+ elseif($item[2] == 'acf-settings-info'){
48
+ $temp_infos = $submenu['edit.php?post_type=acf-field-group'][$ikey];
49
+ $temp_infos_key = $ikey;
50
+ }
51
+
52
+ }
53
+
54
+ // Swapping
55
+ $submenu['edit.php?post_type=acf-field-group'][$temp_tools_key] = $temp_category;
56
+ $submenu['edit.php?post_type=acf-field-group'][$temp_infos_key] = $temp_settings;
57
+ $submenu['edit.php?post_type=acf-field-group'][$temp_category_key] = $temp_tools;
58
+ $submenu['edit.php?post_type=acf-field-group'][$temp_settings_key] = $temp_infos;
59
+ }
60
+
61
+ function acfe_admin_settings_html(){
62
+ ?>
63
+ <div class="wrap" id="acfe-admin-settings">
64
+
65
+ <h1><?php _e('Settings'); ?></h1>
66
+
67
+ <div id="poststuff">
68
+ <?php
69
+
70
+ $load_json = acf_get_setting('load_json');
71
+ $load_json_text = '';
72
+ if(!empty($load_json))
73
+ $load_json_text = implode("<br />", $load_json);
74
+
75
+ $settings = array(
76
+ array(
77
+ 'name' => 'path',
78
+ 'label' => 'Path',
79
+ 'value' => '<code>' . acf_get_setting('path') . '</code>',
80
+ 'description' => 'Absolute path to ACF plugin folder including trailing slash.<br />Defaults to plugin_dir_path'
81
+ ),
82
+ array(
83
+ 'name' => 'dir',
84
+ 'label' => 'Directory',
85
+ 'value' => '<code>' . acf_get_setting('dir') . '</code>',
86
+ 'description' => 'URL to ACF plugin folder including trailing slash. Defaults to plugin_dir_url'
87
+ ),
88
+ array(
89
+ 'name' => 'show_admin',
90
+ 'label' => 'Show menu',
91
+ 'value' => '<code>' . (acf_get_setting('show_admin') ? __('True'): __('False')) . '</code>',
92
+ 'description' => 'Show/hide ACF menu item. Defaults to true'
93
+ ),
94
+ array(
95
+ 'name' => 'stripslashes',
96
+ 'label' => 'Strip slashes',
97
+ 'value' => '<code>' . (acf_get_setting('stripslashes') ? __('True'): __('False')) . '</code>',
98
+ 'description' => 'Runs the function stripslashes on all $_POST data. Some servers / WP instals may require this extra functioanlity. Defaults to false'
99
+ ),
100
+ array(
101
+ 'name' => 'local',
102
+ 'label' => 'PHP/Json',
103
+ 'value' => '<code>' . (acf_get_setting('local') ? __('True'): __('False')) . '</code>',
104
+ 'description' => 'Enable/Disable local (PHP/json) fields. Defaults to true'
105
+ ),
106
+ array(
107
+ 'name' => 'json',
108
+ 'label' => 'Json',
109
+ 'value' => '<code>' . (acf_get_setting('json') ? __('True'): __('False')) . '</code>',
110
+ 'description' => 'Enable/Disable json fields. Defaults to true'
111
+ ),
112
+ array(
113
+ 'name' => 'save_json',
114
+ 'label' => 'Json folder (save)',
115
+ 'value' => '<code>' . acf_get_setting('dir') . '</code>',
116
+ 'description' => 'Absolute path to folder where json files will be created when field groups are saved.<br />Defaults to ‘acf-json’ folder within current theme'
117
+ ),
118
+ array(
119
+ 'name' => 'load_json',
120
+ 'label' => 'Json folder (load)',
121
+ 'value' => '<code>' . $load_json_text . '</code>',
122
+ 'description' => 'Array of absolutes paths to folders where field group json files can be read.<br />Defaults to an array containing at index 0, the ‘acf-json’ folder within current theme'
123
+ ),
124
+ array(
125
+ 'name' => 'default_language',
126
+ 'label' => 'Default language',
127
+ 'value' => '<code>' . acf_get_setting('default_language') . '</code>',
128
+ 'description' => 'Language code of the default language. Defaults to ”.<br />If WPML is active, ACF will default this to the WPML default language setting'
129
+ ),
130
+ array(
131
+ 'name' => 'current_language',
132
+ 'label' => 'Current language',
133
+ 'value' => '<code>' . acf_get_setting('current_language') . '</code>',
134
+ 'description' => 'Language code of the current post’s language. Defaults to ”.<br />If WPML is active, ACF will default this to the WPML current language'
135
+ ),
136
+ array(
137
+ 'name' => 'capability',
138
+ 'label' => 'Capability',
139
+ 'value' => '<code>' . acf_get_setting('capability') . '</code>',
140
+ 'description' => 'Capability used for ACF post types and if the current user can see the ACF menu item.<br />Defaults to ‘manage_options’.'
141
+ ),
142
+ array(
143
+ 'name' => 'show_updates',
144
+ 'label' => 'Show updates',
145
+ 'value' => '<code>' . (acf_get_setting('show_updates') ? __('True'): __('False')) . '</code>',
146
+ 'description' => 'Enable/Disable updates to appear in plugin list and show/hide the ACF updates admin page.<br />Defaults to true.'
147
+ ),
148
+ array(
149
+ 'name' => 'export_textdomain',
150
+ 'label' => 'Export textdomain',
151
+ 'value' => '<code>' . (acf_get_setting('export_textdomain') ? __('True'): __('False')) . '</code>',
152
+ 'description' => 'Array of keys used during the ‘Export to PHP’ feature to wrap strings within the __() function.<br />Defaults to array(’title’, ’label’, ’instructions’). Depreciated in v5.3.4 – please see l10n_field and l10n_field_group'
153
+ ),
154
+ array(
155
+ 'name' => 'export_translate',
156
+ 'label' => 'Export translate',
157
+ 'value' => '<code>' . print_r(acf_get_setting('export_translate'), true) . '</code>',
158
+ 'description' => 'Used during the ‘Export to PHP’ feature to wrap strings within the __() function.<br />Depreciated in v5.4.4 – please see l10n_textdomain'
159
+ ),
160
+ array(
161
+ 'name' => 'autoload',
162
+ 'label' => 'Auto load',
163
+ 'value' => '<code>' . (acf_get_setting('autoload') ? __('True'): __('False')) . '</code>',
164
+ 'description' => 'Sets the text domain used when translating field and field group settings.<br />Defaults to ”. Strings will not be translated if this setting is empty'
165
+ ),
166
+ array(
167
+ 'name' => 'l10n',
168
+ 'label' => 'l10n',
169
+ 'value' => '<code>' . (acf_get_setting('l10n') ? __('True'): __('False')) . '</code>',
170
+ 'description' => 'Allows ACF to translate field and field group settings using the __() function.<br />Defaults to true. Useful to override translation without modifying the textdomain'
171
+ ),
172
+ array(
173
+ 'name' => 'l10n_textdomain',
174
+ 'label' => 'l10n Textdomain',
175
+ 'value' => '<code>' . (acf_get_setting('l10n') ? __('True'): __('False')) . '</code>',
176
+ 'description' => 'Sets the text domain used when translating field and field group settings.<br />Defaults to ”. Strings will not be translated if this setting is empty'
177
+ ),
178
+ array(
179
+ 'name' => 'l10n_field',
180
+ 'label' => 'l10n Field',
181
+ 'value' => '<code>' . print_r(acf_get_setting('l10n_field'), true) . '</code>',
182
+ 'description' => 'An array of settings to translate when loading and exporting a field.<br />Defaults to array(’label’, ’instructions’). Depreciated in v5.3.6 – please see acf/translate_field filter'
183
+ ),
184
+ array(
185
+ 'name' => 'l10n_field_group',
186
+ 'label' => 'l10n Field group',
187
+ 'value' => '<code>' . print_r(acf_get_setting('l10n_field_group'), true) . '</code>',
188
+ 'description' => 'An array of settings to translate when loading and exporting a field group.<br />Defaults to array(’title’). Depreciated in v5.3.6 – please see acf/translate_field_group filter'
189
+ ),
190
+ array(
191
+ 'name' => 'google_api_key',
192
+ 'label' => 'Google API Key',
193
+ 'value' => '<code>' . acf_get_setting('google_api_key') . '</code>',
194
+ 'description' => 'Specify a Google Maps API authentication key to prevent usage limits.<br />Defaults to ”'
195
+ ),
196
+ array(
197
+ 'name' => 'google_api_client',
198
+ 'label' => 'Google API Key',
199
+ 'value' => '<code>' . acf_get_setting('google_api_client') . '</code>',
200
+ 'description' => 'Specify a Google Maps API Client ID to prevent usage limits.<br />Not needed if using google_api_key. Defaults to ”'
201
+ ),
202
+ array(
203
+ 'name' => 'enqueue_google_maps',
204
+ 'label' => 'Enqueue Google Maps',
205
+ 'value' => '<code>' . (acf_get_setting('enqueue_google_maps') ? __('True'): __('False')) . '</code>',
206
+ 'description' => 'Allows ACF to enqueue and load the Google Maps API JS library.<br />Defaults to true'
207
+ ),
208
+ array(
209
+ 'name' => 'enqueue_select2',
210
+ 'label' => 'Enqueue Select2',
211
+ 'value' => '<code>' . (acf_get_setting('enqueue_select2') ? __('True'): __('False')) . '</code>',
212
+ 'description' => 'Allows ACF to enqueue and load the Select2 JS/CSS library.<br />Defaults to true'
213
+ ),
214
+ array(
215
+ 'name' => 'select2_version',
216
+ 'label' => 'Select2 version',
217
+ 'value' => '<code>' . acf_get_setting('select2_version') . '</code>',
218
+ 'description' => 'Defines which version of Select2 library to enqueue. Either 3 or 4.<br />Defaults to 4 since ACF 5.6.0'
219
+ ),
220
+ array(
221
+ 'name' => 'enqueue_datepicker',
222
+ 'label' => 'Enqueue Datepicker',
223
+ 'value' => '<code>' . (acf_get_setting('enqueue_datepicker') ? __('True'): __('False')) . '</code>',
224
+ 'description' => 'Allows ACF to enqueue and load the WP datepicker JS/CSS library.<br />Defaults to true'
225
+ ),
226
+ array(
227
+ 'name' => 'enqueue_datetimepicker',
228
+ 'label' => 'Enqueue Datepiker/time',
229
+ 'value' => '<code>' . (acf_get_setting('enqueue_datetimepicker') ? __('True'): __('False')) . '</code>',
230
+ 'description' => 'Allows ACF to enqueue and load the datetimepicker JS/CSS library.<br />Defaults to true'
231
+ ),
232
+ array(
233
+ 'name' => 'row_index_offset',
234
+ 'label' => 'Row index offset',
235
+ 'value' => '<code>' . acf_get_setting('row_index_offset') . '</code>',
236
+ 'description' => 'Defines the starting index used in all ‘loop’ and ‘row’ functions.<br />Defaults to 1 (1 is the first row), can be changed to 0 (0 is the first row)'
237
+ ),
238
+ array(
239
+ 'name' => 'remove_wp_meta_box',
240
+ 'label' => 'Remove WP meta box',
241
+ 'value' => '<code>' . (acf_get_setting('remove_wp_meta_box') ? __('True'): __('False')) . '</code>',
242
+ 'description' => 'Allows ACF to remove the default WP custom fields metabox. Defaults to true'
243
+ ),
244
+ );
245
+
246
+ ?>
247
+ <div class="postbox acf-postbox">
248
+ <h2 class="hndle ui-sortable-handle"><span><?php _e('ACF Settings'); ?></span></h2>
249
+ <div class="inside acf-fields -left">
250
+
251
+ <?php foreach($settings as $setting){ ?>
252
+ <div class="acf-field">
253
+ <div class="acf-label">
254
+ <label><span class="acf-js-tooltip dashicons dashicons-info" style="float:right; font-size:16px; color:#ccc;" title="<?php echo $setting['description']; ?>"></span><?php echo $setting['label']; ?></label>
255
+ </div>
256
+ <div class="acf-input">
257
+ <?php echo $setting['value']; ?>
258
+ </div>
259
+ </div>
260
+ <?php } ?>
261
+
262
+ <script type="text/javascript">
263
+ if( typeof acf !== 'undefined' ) {
264
+
265
+ acf.newPostbox({
266
+ 'id': 'acfe-settings',
267
+ 'label': 'left'
268
+ });
269
+
270
+ }
271
+ </script>
272
+ </div>
273
+ </div>
274
+ </div>
275
+
276
+ </div>
277
+ <?php
278
+ }
includes/core/enqueue.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ABSPATH'))
4
+ exit;
5
+
6
+ /**
7
+ * Enqueue
8
+ */
9
+ add_action('admin_enqueue_scripts', 'acfe_enqueue_admin');
10
+ function acfe_enqueue_admin(){
11
+ if(!acf_is_screen(array('edit-acf-field-group', 'acf-field-group')))
12
+ return;
13
+
14
+ // CSS
15
+ wp_enqueue_style('acf-input');
16
+ wp_enqueue_style('wp-jquery-ui-dialog');
17
+ wp_enqueue_style('acfe-css', plugins_url('assets/admin.css', ACFE_FILE), false, null);
18
+
19
+ // JS
20
+ wp_enqueue_script('acf-input');
21
+ wp_enqueue_script('jquery-ui-core');
22
+ wp_enqueue_script('jquery-ui-dialog');
23
+ wp_enqueue_script('acfe-js', plugins_url('assets/admin.js', ACFE_FILE), array('jquery'), null);
24
+ }
includes/core/helpers.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ABSPATH'))
4
+ exit;
5
+
6
+ /**
7
+ * Print_r
8
+ */
9
+ if(!function_exists('_print_r')){
10
+ function _print_r($data, $args = false){
11
+ $args = wp_parse_args($args, array(
12
+ 'title' => false,
13
+ 'return' => false,
14
+ 'dump' => false,
15
+ 'pre' => true,
16
+ ));
17
+
18
+ $code = print_r($data, true);
19
+ if($args['dump']){
20
+ ob_start();
21
+ var_dump($data);
22
+ $code = ob_get_clean();
23
+ }
24
+
25
+ $title = false;
26
+ if($args['title'])
27
+ $title = '<h5><strong>' . $args['title'] . '</strong></h5><hr>';
28
+
29
+ $pre_start = $pre_end = false;
30
+ if($args['pre']){
31
+ $pre_start = "<pre style='position:relative; z-index:1000000;'>";
32
+ $pre_end = "</pre>";
33
+ }
34
+
35
+ $return = $pre_start . $title . $code . $pre_end;
36
+
37
+ if($args['return'])
38
+ return $return;
39
+
40
+ echo $return;
41
+ }
42
+ }
includes/field-groups/field-group-category.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ABSPATH'))
4
+ exit;
5
+
6
+ add_action('init', 'acfe_field_group_category_register');
7
+ function acfe_field_group_category_register(){
8
+ register_taxonomy('acf-field-group-category', array('acf-field-group'), array(
9
+ 'hierarchical' => true,
10
+ 'public' => false,
11
+ 'show_ui' => true,
12
+ 'show_admin_column' => true,
13
+ 'show_in_menu' => true,
14
+ 'show_in_nav_menus' => true,
15
+ 'show_tagcloud' => false,
16
+ 'labels' => array(
17
+ 'name' => _x('Categories', 'Category'),
18
+ 'singular_name' => _x('Categories', 'Category'),
19
+ 'search_items' => __('Search categories', 'acfe'),
20
+ 'all_items' => __('All categories', 'acfe'),
21
+ 'parent_item' => __('Parent category', 'acfe'),
22
+ 'parent_item_colon' => __('Parent category:', 'acfe'),
23
+ 'edit_item' => __('Edit category', 'acfe'),
24
+ 'update_item' => __('Update category', 'acfe'),
25
+ 'add_new_item' => __('Add New category', 'acfe'),
26
+ 'new_item_name' => __('New category name', 'acfe'),
27
+ 'menu_name' => __('category', 'acfe'),
28
+ ),
29
+ ));
30
+ }
31
+
32
+ add_action('admin_menu', 'acfe_field_group_category_submenu');
33
+ function acfe_field_group_category_submenu(){
34
+ if(!acf_get_setting('show_admin'))
35
+ return;
36
+
37
+ add_submenu_page('edit.php?post_type=acf-field-group', __('Categories'), __('Categories'), acf_get_setting('capability'), 'edit-tags.php?taxonomy=acf-field-group-category');
38
+ }
39
+
40
+ add_filter('parent_file', 'acfe_field_group_category_submenu_highlight');
41
+ function acfe_field_group_category_submenu_highlight($parent_file){
42
+ global $submenu_file, $current_screen, $pagenow;
43
+ if($current_screen->taxonomy == 'acf-field-group-category' && ($pagenow == 'edit-tags.php' || $pagenow == 'term.php'))
44
+ $parent_file = 'edit.php?post_type=acf-field-group';
45
+
46
+ return $parent_file;
47
+ }
48
+
49
+ add_filter('manage_edit-acf-field-group_columns', 'acfe_field_group_category_column', 11);
50
+ function acfe_field_group_category_column($columns){
51
+ $new_columns = array();
52
+ foreach($columns as $key => $value) {
53
+ if($key == 'title')
54
+ $new_columns['acf-field-group-category'] = __('Categories');
55
+
56
+ $new_columns[$key] = $value;
57
+ }
58
+
59
+ return $new_columns;
60
+ }
61
+
62
+ add_action('manage_acf-field-group_posts_custom_column' , 'acfe_field_group_category_column_html', 10, 2);
63
+ function acfe_field_group_category_column_html($column, $post_id){
64
+ if($column == 'acf-field-group-category'){
65
+ if(!$terms = get_the_terms($post_id, 'acf-field-group-category'))
66
+ return;
67
+
68
+ $categories = array();
69
+ foreach($terms as $term){
70
+ $categories[] = '<a href="' . admin_url('edit.php?acf-field-group-category='.$term->slug.'&post_type=acf-field-group') . '">' . $term->name . '</a>';
71
+ }
72
+
73
+ echo implode(' ', $categories);
74
+ }
75
+ }
76
+
77
+ add_filter('views_edit-acf-field-group', 'acfe_field_group_category_views', 9);
78
+ function acfe_field_group_category_views($views){
79
+ if(!$terms = get_terms('acf-field-group-category', array('hide_empty' => false)))
80
+ return $views;
81
+
82
+ foreach($terms as $term){
83
+
84
+ $groups = get_posts( array(
85
+ 'post_type' => 'acf-field-group',
86
+ 'posts_per_page' => -1,
87
+ 'suppress_filters' => false,
88
+ 'post_status' => array('publish', 'acf-disabled'),
89
+ 'taxonomy' => 'acf-field-group-category',
90
+ 'term' => $term->slug,
91
+ 'fields' => 'ids'
92
+ ));
93
+
94
+ $count = count($groups);
95
+
96
+ $html = '';
97
+ if($count > 0)
98
+ $html = ' <span class="count">(' . $count . ')</span>';
99
+
100
+ global $wp_query;
101
+ $class = '';
102
+ if(isset($wp_query->query_vars['acf-field-group-category']) && $wp_query->query_vars['acf-field-group-category'] == $term->slug)
103
+ $class = ' class="current"';
104
+
105
+ $views['category-' . $term->slug] = '<a href="' . admin_url('edit.php?acf-field-group-category=' . $term->slug . '&post_type=acf-field-group') . '"' . $class . '>' . $term->name . $html . '</a>';
106
+ }
107
+ return $views;
108
+ }
includes/field-groups/field-group.php ADDED
@@ -0,0 +1,373 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ABSPATH'))
4
+ exit;
5
+
6
+ /**
7
+ * Field Group Options: Native Note
8
+ */
9
+ add_action('acf/render_field_group_settings', 'acfe_render_field_group_options');
10
+ function acfe_render_field_group_options($field_group){
11
+ acf_render_field_wrap(array(
12
+ 'label' => __('Note'),
13
+ 'name' => 'acfe_note',
14
+ 'prefix' => 'acf_field_group',
15
+ 'type' => 'textarea',
16
+ 'instructions' => __('Personal note. Only visible to administrators'),
17
+ 'value' => (isset($field_group['acfe_note'])) ? $field_group['acfe_note'] : '',
18
+ 'required' => false,
19
+ ));
20
+ }
21
+
22
+ /**
23
+ * Field Group Options: Data
24
+ */
25
+ add_action('acf/field_group/admin_head', 'acfe_render_field_group_settings');
26
+ function acfe_render_field_group_settings(){
27
+ add_meta_box('acf-field-group-acfe', __('Data', 'acfe'), function(){
28
+
29
+ global $field_group;
30
+
31
+ acf_render_field_wrap(array(
32
+ 'label' => __('Custom meta data'),
33
+ 'name' => 'acfe_meta',
34
+ 'key' => 'acfe_meta',
35
+ 'instructions' => '',
36
+ 'prefix' => 'acf_field_group',
37
+ 'type' => 'repeater',
38
+ 'button_label' => __('+ Add row'),
39
+ 'required' => false,
40
+ 'layout' => 'table',
41
+ 'value' => (isset($field_group['acfe_meta'])) ? $field_group['acfe_meta'] : array(),
42
+ 'sub_fields' => array(
43
+ array(
44
+ 'label' => __('Key'),
45
+ 'name' => 'acfe_meta_key',
46
+ 'key' => 'acfe_meta_key',
47
+ 'prefix' => '',
48
+ '_name' => '',
49
+ '_prepare' => '',
50
+ 'type' => 'text',
51
+ 'instructions' => false,
52
+ 'required' => false,
53
+ 'wrapper' => array(
54
+ 'width' => '',
55
+ 'class' => '',
56
+ 'id' => '',
57
+ ),
58
+ ),
59
+ array(
60
+ 'label' => __('Value'),
61
+ 'name' => 'acfe_meta_value',
62
+ 'key' => 'acfe_meta_value',
63
+ 'prefix' => '',
64
+ '_name' => '',
65
+ '_prepare' => '',
66
+ 'type' => 'text',
67
+ 'instructions' => false,
68
+ 'required' => false,
69
+ 'wrapper' => array(
70
+ 'width' => '',
71
+ 'class' => '',
72
+ 'id' => '',
73
+ ),
74
+ ),
75
+ )
76
+ ));
77
+
78
+ acf_render_field_wrap(array(
79
+ 'label' => __('Field group data'),
80
+ 'instructions' => __('View raw data'),
81
+ 'type' => 'acfe_dynamic_message',
82
+ 'name' => 'acfe_data',
83
+ 'prefix' => 'acf_field_group',
84
+ 'value' => $field_group['key'],
85
+ ));
86
+
87
+ ?>
88
+ <script type="text/javascript">
89
+ if(typeof acf !== 'undefined'){
90
+ acf.postbox.render({
91
+ 'id': 'acf-field-group-acfe',
92
+ 'label': 'left'
93
+ });
94
+ }
95
+
96
+ jQuery(document).ready(function($){
97
+ $('#post_name').on('keyup', function(){
98
+ var val = $(this).val();
99
+ if(!val.startsWith('group_')){
100
+ var val = 'group_' + val;
101
+ $(this).val(val);
102
+ }
103
+
104
+ $('[name="acf_field_group[key]"]').val(val);
105
+ $('.misc-pub-acfe-field-group-key code').html(val);
106
+ });
107
+ });
108
+ </script>
109
+ <?php
110
+ }, 'acf-field-group', 'normal', 'high');
111
+ }
112
+
113
+ /**
114
+ * Field Group Options: Sidebar - Submit Div
115
+ */
116
+ add_action('post_submitbox_misc_actions', 'acfe_render_field_group_submitbox');
117
+ function acfe_render_field_group_submitbox(){
118
+ if(get_post_type(get_the_ID()) !== 'acf-field-group')
119
+ return;
120
+
121
+ $field_group = acf_get_field_group(get_the_ID());
122
+ ?>
123
+ <div class="misc-pub-section misc-pub-acfe-field-group-key">
124
+ <span style="font-size:16px;color: #82878c;" class="dashicons dashicons-tag"></span> <code style="font-size: 12px;"><?php echo $field_group['key']; ?></code>
125
+ </div>
126
+ <script type="text/javascript">
127
+ (function($) {
128
+ $('.misc-pub-acfe-field-group-key').insertBefore('.misc-pub-post-status');
129
+ })(jQuery);
130
+ </script>
131
+ <?php
132
+ }
133
+
134
+ /**
135
+ * Field Group Options: Sidebar
136
+ */
137
+ add_action('acf/field_group/admin_head', 'acfe_render_field_group_settings_side');
138
+ function acfe_render_field_group_settings_side(){
139
+ add_meta_box('acf-field-group-acfe-side', __('Advanced Settings', 'acfe'), function(){
140
+
141
+ global $field_group;
142
+
143
+ acf_render_field_wrap(array(
144
+ 'label' => __('Display title', 'acfe'),
145
+ 'instructions' => __('Render this title on edit post screen', 'acfe'),
146
+ 'type' => 'text',
147
+ 'name' => 'acfe_display_title',
148
+ 'prefix' => 'acf_field_group',
149
+ 'value' => (isset($field_group['acfe_display_title'])) ? $field_group['acfe_display_title'] : '',
150
+ 'placeholder' => '',
151
+ 'prepend' => '',
152
+ 'append' => ''
153
+ ));
154
+
155
+ if(acfe_is_field_group_json_desync($field_group)){
156
+ acf_render_field_wrap(array(
157
+ 'label' => __('Json Desync'),
158
+ 'instructions' => __('Local json file is different from this version. If you manually synchronize it, you will lose your current field group settings'),
159
+ 'type' => 'acfe_dynamic_message',
160
+ 'name' => 'acfe_sync_available',
161
+ 'prefix' => 'acf_field_group',
162
+ 'value' => $field_group['key'],
163
+ ));
164
+ }
165
+
166
+ acf_render_field_wrap(array(
167
+ 'label' => __('Auto Sync'),
168
+ 'instructions' => __('Synchronize field group upon update'),
169
+ 'type' => 'checkbox',
170
+ 'name' => 'acfe_autosync',
171
+ 'prefix' => 'acf_field_group',
172
+ 'value' => (isset($field_group['acfe_autosync']) && !empty($field_group['acfe_autosync'])) ? $field_group['acfe_autosync'] : array(),
173
+ 'choices' => array(
174
+ 'php' => 'PHP',
175
+ 'json' => 'Json',
176
+ )
177
+ ));
178
+
179
+ acf_render_field_wrap(array(
180
+ 'label' => __('Permissions'),
181
+ 'name' => 'acfe_permissions',
182
+ 'prefix' => 'acf_field_group',
183
+ 'type' => 'checkbox',
184
+ 'instructions' => __('Select user roles that are allowed to view and edit this field group in post edition'),
185
+ 'required' => false,
186
+ 'default_value' => false,
187
+ 'choices' => acfe_get_roles(),
188
+ 'value' => (isset($field_group['acfe_permissions'])) ? $field_group['acfe_permissions'] : array(),
189
+ 'layout' => 'vertical'
190
+ ));
191
+
192
+ ?>
193
+ <script type="text/javascript">
194
+ if(typeof acf !== 'undefined'){
195
+ acf.postbox.render({
196
+ 'id': 'acf-field-group-acfe-side',
197
+ 'label': 'top'
198
+ });
199
+ }
200
+
201
+ (function($){
202
+ if($('[data-name=acfe_sync_available]').length){
203
+
204
+ if($('[data-name=acfe_sync_available]').find('[data-acfe-autosync-json-active]').attr('data-acfe-autosync-json-active') == '0'){
205
+ $('#acf_field_group-acfe_autosync-json').change(function(e){
206
+ if($(this).prop('checked')){
207
+ if(!confirm('Local json file was found and is different from this version.' + "\n" + 'Enabling json auto sync will erase the local file with the current field group settings')){
208
+ $(this).prop('checked', false);
209
+ return false;
210
+ }
211
+ }
212
+ });
213
+ }
214
+
215
+ else{
216
+
217
+ $('#publish').click(function(e){
218
+ if(!confirm('Local json file was found and is different from this version.' + "\n" + 'Proceed to erase the local file with the current field group settings'))
219
+ e.preventDefault();
220
+ });
221
+
222
+ }
223
+ }
224
+ })(jQuery);
225
+ </script>
226
+ <?php
227
+ }, 'acf-field-group', 'side');
228
+ }
229
+
230
+ /**
231
+ * Render: Sync Available
232
+ */
233
+ add_action('acf/render_field/name=acfe_sync_available', 'acfe_render_field_sync_available');
234
+ function acfe_render_field_sync_available($field){
235
+ $field_group = acf_get_field_group($field['value']);
236
+
237
+ $acfe_autosync_active = 0;
238
+ if(isset($field_group['acfe_autosync']) && is_array($field_group['acfe_autosync']) && in_array('json', $field_group['acfe_autosync']))
239
+ $acfe_autosync_active = 1;
240
+
241
+ $nonce = wp_create_nonce('bulk-posts');
242
+ echo '<a data-acfe-autosync-json-active="'.$acfe_autosync_active.'" class="button" href="'.admin_url('edit.php?post_type=acf-field-group&post_status=sync&acfsync=' . $field['value'] . '&_wpnonce=' . $nonce).'">Synchronize</a>';
243
+ }
244
+
245
+ /**
246
+ * Render: Sync Warnings
247
+ */
248
+ add_action('acf/render_field/name=acfe_autosync', 'acfe_render_field_acfe_sync_warnings');
249
+ function acfe_render_field_acfe_sync_warnings($field){
250
+ global $field_group;
251
+
252
+ // PHP
253
+
254
+ // Fix to load local fiel groups
255
+ acf_enable_filters();
256
+
257
+ if(acfe_has_field_group_autosync($field_group, 'php') && !acf_get_setting('acfe_php_found')){
258
+ echo '<p class="description"><span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="dashicons dashicons-warning"></span> Folder <code style="font-size:11px;">/acfe-php</code> was not found in your theme. You must create it to activate PHP Sync</p>';
259
+ }
260
+
261
+ elseif(!acfe_has_field_group_autosync($field_group, 'php') && acfe_has_field_group_autosync_file($field_group, 'php')){
262
+ echo '<p class="description"><span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="dashicons dashicons-warning"></span> This field group is registered via a third-party PHP code</p>';
263
+ }
264
+
265
+ elseif(acfe_has_field_group_autosync($field_group, 'php') && !acfe_has_field_group_autosync_file($field_group, 'php')){
266
+ echo '<p class="description"><span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="dashicons dashicons-warning"></span> This field group is not registered locally. Update it to resync PHP</p>';
267
+ }
268
+
269
+ // Re-disable filters, as natively
270
+ acf_disable_filters();
271
+
272
+ // Json
273
+
274
+ if(!acfe_has_field_group_autosync($field_group, 'json') && acfe_has_field_group_autosync_file($field_group, 'json')){
275
+ echo '<p class="description"><span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="dashicons dashicons-warning"></span> <code style="font-size:11px;">' . $field_group['key'] . '.json</code> was found. Activate Json sync to keep it updated</p>';
276
+ }
277
+
278
+ elseif(acfe_has_field_group_autosync($field_group, 'json') && !acfe_has_field_group_autosync_file($field_group, 'json')){
279
+ echo '<p class="description"><span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="dashicons dashicons-warning"></span> <code style="font-size:11px;">' . $field_group['key'] . '.json</code> was not found. Update this field group to regenerate it</p>';
280
+ }
281
+
282
+
283
+ }
284
+
285
+ /**
286
+ * Render: Data button
287
+ */
288
+ add_action('acf/render_field/name=acfe_data', 'acfe_render_field_group_data');
289
+ function acfe_render_field_group_data($field){
290
+ $field_group = acf_get_field_group($field['value']);
291
+ if(!$field_group){
292
+ echo '<a href="#" class="button disabled" disabled>' . __('Data') . '</a>';
293
+ return;
294
+ }
295
+
296
+ echo '<a href="#" class="button acfe_modal_open" data-modal-key="' . $field_group['key'] . '">' . __('Data') . '</a>';
297
+ echo '<div class="acfe_modal acfe_modal_data hidden" data-modal-key="' . $field_group['key'] . '"><pre>' . print_r($field_group, true) . '</pre></div>';
298
+ }
299
+
300
+ /**
301
+ * Default: Label placement - Left
302
+ */
303
+ add_filter('acf/validate_field_group', 'acfc_field_group_options');
304
+ function acfc_field_group_options($field_group){
305
+ $field_group['label_placement'] = 'left';
306
+ return $field_group;
307
+ }
308
+
309
+ /**
310
+ * Field Group Title (post edit)
311
+ */
312
+ add_filter('acf/get_field_groups', 'acfe_render_field_groups', 999);
313
+ function acfe_render_field_groups($field_groups){
314
+ $check_current_screen = acf_is_screen(array(
315
+ 'edit-acf-field-group',
316
+ 'acf-field-group',
317
+ 'acf_page_acf-tools'
318
+ ));
319
+
320
+ if($check_current_screen)
321
+ return $field_groups;
322
+
323
+ foreach($field_groups as &$field_group){
324
+ if(!isset($field_group['acfe_display_title']) || empty($field_group['acfe_display_title']))
325
+ continue;
326
+
327
+ $field_group['title'] = $field_group['acfe_display_title'];
328
+ }
329
+
330
+ return $field_groups;
331
+ }
332
+
333
+ /**
334
+ * Field Group Permissions (post edit)
335
+ */
336
+ add_filter('acf/get_field_groups', 'acfe_permissions_field_groups', 999);
337
+ function acfe_permissions_field_groups($field_groups){
338
+ $check_current_screen = acf_is_screen(array(
339
+ 'edit-acf-field-group',
340
+ 'acf-field-group',
341
+ 'acf_page_acf-tools'
342
+ ));
343
+
344
+ if($check_current_screen)
345
+ return $field_groups;
346
+
347
+ $current_user_roles = acfe_get_current_user_roles();
348
+
349
+ foreach($field_groups as $key => $field_group){
350
+ if(!isset($field_group['acfe_permissions']) || empty($field_group['acfe_permissions']))
351
+ continue;
352
+
353
+ $render_field_group = false;
354
+
355
+ foreach($current_user_roles as $current_user_role){
356
+ foreach($field_group['acfe_permissions'] as $field_group_role){
357
+ if($current_user_role !== $field_group_role)
358
+ continue;
359
+
360
+ $render_field_group = true;
361
+ break;
362
+ }
363
+
364
+ if($render_field_group)
365
+ break;
366
+ }
367
+
368
+ if(!$render_field_group)
369
+ unset($field_groups[$key]);
370
+ }
371
+
372
+ return $field_groups;
373
+ }
includes/field-groups/field-groups.php ADDED
@@ -0,0 +1,322 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ABSPATH'))
4
+ exit;
5
+
6
+ /**
7
+ * Display Title (post states)
8
+ */
9
+ add_filter('display_post_states', 'acfe_field_groups_states', 10, 2);
10
+ function acfe_field_groups_states($states, $post){
11
+ if(!acf_is_screen('edit-acf-field-group'))
12
+ return $states;
13
+
14
+ if(get_post_type($post->ID) != 'acf-field-group')
15
+ return $states;
16
+
17
+ $field_group = acf_get_field_group($post->ID);
18
+
19
+ if(!$field_group || !isset($field_group['acfe_display_title']) || empty($field_group['acfe_display_title']))
20
+ return $states;
21
+
22
+ $states[] = $field_group['acfe_display_title'];
23
+ return $states;
24
+ }
25
+
26
+ /**
27
+ * Table Columns
28
+ */
29
+ add_filter('manage_edit-acf-field-group_columns', 'acfe_field_groups_column', 999);
30
+ function acfe_field_groups_column($columns){
31
+
32
+ // Fix 'Sync' screen columns
33
+ if(acf_maybe_get_GET('post_status') === 'sync'){
34
+ unset($columns['acf-field-group-type']);
35
+ return $columns;
36
+ }
37
+
38
+ // Locations
39
+ $columns['acfe-locations'] = __('Locations');
40
+
41
+ // Load
42
+ $columns['acfe-local'] = __('Load');
43
+
44
+ // PHP sync
45
+ if(acf_get_setting('acfe_php'))
46
+ $columns['acfe-autosync-php'] = __('PHP sync');
47
+
48
+ // Json sync
49
+ if(acf_get_setting('json'))
50
+ $columns['acfe-autosync-json'] = __('Json sync');
51
+
52
+ return $columns;
53
+ }
54
+
55
+ /**
56
+ * Table Columns HTML
57
+ */
58
+ add_action('manage_acf-field-group_posts_custom_column', 'acfe_field_groups_column_html', 10, 2);
59
+ function acfe_field_groups_column_html($column, $post_id){
60
+
61
+ /**
62
+ * Locations
63
+ */
64
+ if($column == 'acfe-locations'){
65
+ $field_group = acf_get_field_group($post_id);
66
+ $choices = acf_get_location_rule_types();
67
+
68
+ if(!isset($field_group['location']) || empty($field_group['location']) ||empty($choices))
69
+ return;
70
+
71
+ $final = array();
72
+
73
+ $icon_default = 'admin-generic';
74
+
75
+ $icons = array(
76
+ 'edit' => array(
77
+ 'post_type',
78
+ 'post_template',
79
+ 'post_status',
80
+ 'post_format',
81
+ 'post',
82
+ ),
83
+ 'media-default' => array(
84
+ 'page_template',
85
+ 'page_type',
86
+ 'page_parent',
87
+ 'page',
88
+ ),
89
+ 'admin-users' => array(
90
+ 'current_user',
91
+ 'user_form',
92
+ ),
93
+ 'welcome-widgets-menus' => array(
94
+ 'widget',
95
+ 'nav_menu',
96
+ 'nav_menu_item',
97
+ ),
98
+ 'category' => array(
99
+ 'taxonomy',
100
+ 'post_category',
101
+ 'post_taxonomy',
102
+ ),
103
+ 'admin-comments' => array(
104
+ 'comment',
105
+ ),
106
+ 'paperclip' => array(
107
+ 'attachment',
108
+ ),
109
+ 'admin-settings' => array(
110
+ 'options_page',
111
+ ),
112
+ 'businessman' => array(
113
+ 'current_user_role',
114
+ 'user_role',
115
+ ),
116
+ );
117
+
118
+ foreach($choices as $key => $sub_choices){
119
+ foreach($sub_choices as $choice_slug => $choice_name){
120
+
121
+ $final_icon = $icon_default;
122
+ foreach($icons as $icon => $icon_slugs){
123
+ foreach($icon_slugs as $icon_slug){
124
+ if($choice_slug != $icon_slug)
125
+ continue;
126
+
127
+ $final_icon = $icon;
128
+ break(2);
129
+ }
130
+ }
131
+
132
+ $final[$choice_slug] = array(
133
+ 'name' => $choice_name,
134
+ 'icon' => $final_icon
135
+ );
136
+ }
137
+ }
138
+
139
+
140
+
141
+ $html = array();
142
+ foreach($field_group['location'] as $or){
143
+ foreach($or as $and){
144
+ if(!isset($final[$and['param']]))
145
+ continue;
146
+
147
+ $final_name = $and['value'];
148
+ $values = acf_get_location_rule_values($and);
149
+
150
+ if(!empty($values) && is_array($values)){
151
+ foreach($values as $value_slug => $value_name){
152
+ if($and['value'] != $value_slug)
153
+ continue;
154
+
155
+ $final_name = $value_name;
156
+ break;
157
+ }
158
+ }
159
+
160
+ $name = '<span class="acf-js-tooltip dashicons dashicons-' . $final[$and['param']]['icon'] . '" title="' . $final[$and['param']]['name'] . ' = ' . $final_name . '"></span>';
161
+ if($and['operator'] == '!=')
162
+ $name = '<span class="acf-js-tooltip dashicons dashicons-' . $final[$and['param']]['icon'] . '" title="' . $final[$and['param']]['name'] . ' != ' . $final_name . '" style="color:#ccc;"></span>';
163
+
164
+ $html[] = $name;
165
+ }
166
+ }
167
+
168
+ echo implode(' ', $html);
169
+ }
170
+
171
+ /**
172
+ * Load
173
+ */
174
+ elseif($column == 'acfe-local'){
175
+
176
+ if(!$field_group = acf_get_field_group($post_id))
177
+ return;
178
+
179
+ $local_field_group = acf_get_local_field_group($field_group['key']);
180
+ $local_field_group_type = acf_maybe_get($local_field_group, 'local', false);
181
+
182
+ if($local_field_group_type != 'php'){
183
+ echo __('DB');
184
+ return;
185
+ }
186
+
187
+ echo '<span class="acf-js-tooltip" title="' . $field_group['key'] . ' is registered locally">php</span>';
188
+
189
+ }
190
+
191
+ /**
192
+ * PHP sync
193
+ */
194
+ elseif($column == 'acfe-autosync-php'){
195
+
196
+ if(!$field_group = acf_get_field_group($post_id))
197
+ return;
198
+
199
+ if(!acfe_has_field_group_autosync($field_group, 'php')){
200
+ echo '<span style="color:#ccc" class="dashicons dashicons-no-alt"></span>';
201
+
202
+ if(acfe_has_field_group_autosync_file($field_group, 'php')){
203
+ echo '<span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="acf-js-tooltip dashicons dashicons-warning" title="Field group: ' . $field_group['key'] . ' is registered via a third-party PHP code"></span>';
204
+ }
205
+
206
+ return;
207
+ }
208
+
209
+ if(!acf_get_setting('acfe_php_found')){
210
+ echo '<span style="color:#ccc" class="dashicons dashicons-yes"></span>';
211
+
212
+ echo '<span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="acf-js-tooltip dashicons dashicons-warning" title="Folder \'/acfe-php\' was not found in your theme.<br />You must create it to activate this setting"></span>';
213
+ }
214
+
215
+ elseif(!acfe_has_field_group_autosync_file($field_group, 'php')){
216
+ echo '<span class="dashicons dashicons-yes"></span>';
217
+
218
+ echo '<span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="acf-js-tooltip dashicons dashicons-warning" title="Field group: ' . $field_group['key'] . ' is not registered locally.<br />Update the field group to resync PHP"></span>';
219
+ }
220
+
221
+ else{
222
+
223
+ echo '<span class="dashicons dashicons-yes"></span>';
224
+
225
+ }
226
+
227
+ }
228
+
229
+ /**
230
+ * Json sync
231
+ */
232
+ elseif($column == 'acfe-autosync-json'){
233
+
234
+ if(!$field_group = acf_get_field_group($post_id))
235
+ return;
236
+
237
+ if(!acfe_has_field_group_autosync($field_group, 'json')){
238
+ echo '<span style="color:#ccc" class="dashicons dashicons-no-alt"></span>';
239
+ if(acfe_has_field_group_autosync_file($field_group, 'json'))
240
+ echo '<span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="acf-js-tooltip dashicons dashicons-warning" title="Local file: ' . $field_group['key'] . '.json was found.<br />Activate Json sync in the field group settings to keep it updated"></span>';
241
+
242
+ return;
243
+ }
244
+
245
+ echo '<span class="dashicons dashicons-yes"></span>';
246
+ if(!acfe_has_field_group_autosync_file($field_group, 'json'))
247
+ echo '<span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="acf-js-tooltip dashicons dashicons-warning" title="Local file: ' . $field_group['key'] . '.json was not found.<br />Update the field group to regenerate it"></span>';
248
+
249
+ }
250
+ }
251
+ /**
252
+ * Table Row Actions
253
+ */
254
+ add_filter('page_row_actions', 'hwk_post_type_exemple_row_actions', 10, 2);
255
+ function hwk_post_type_exemple_row_actions($actions, $post){
256
+ if(!isset($post->post_type) || $post->post_type != 'acf-field-group')
257
+ return $actions;
258
+
259
+ $field_group = acf_get_field_group($post->ID);
260
+
261
+ $actions['acfe-export-php'] = '<a href="' . admin_url('edit.php?post_type=acf-field-group&page=acf-tools&tool=export&keys=' . $field_group['key']) . '">PHP</a>';
262
+ $actions['acfe-export-json'] = '<span class="acfe-form" data-action="'.admin_url('edit.php?post_type=acf-field-group&page=acf-tools&tool=export').'"><input type="hidden" name="_acf_nonce" value="' . wp_create_nonce('export') . '" /><input type="hidden" name="action" value="download" /><input type="hidden" name="keys" value="' . $field_group['key'] . '" /><a href="#">Json</a></span>';
263
+ //$actions['acfe-id'] = '<span style="color:#555;">ID: ' . $field_group['ID'] . '</span>';
264
+ $actions['acfe-key'] = '<span style="color:#555;"><code style="-webkit-user-select: all;-moz-user-select: all;-ms-user-select: all;user-select: all;font-size: 12px;">' . $field_group['key'] . '</code></span>';
265
+ return $actions;
266
+ }
267
+
268
+ //add_filter('acf/validate_field_group', 'acfe_test_local_fg', 999);
269
+ function acfe_test_local_fg($field_group){
270
+
271
+ error_log(print_r($field_group, true));
272
+ //_print_r($field_group);
273
+
274
+ return $field_group;
275
+ }
276
+
277
+ /**
278
+ * Sidebar
279
+ */
280
+ add_action('current_screen',function(){
281
+ if(!acf_is_screen('edit-acf-field-group'))
282
+ return;
283
+
284
+ add_action('admin_footer', function(){
285
+ ?>
286
+
287
+ <!-- ACFE: Label -->
288
+ <script type="text/html" id="tmpl-acfe-label">
289
+ <span style="word-wrap: break-word;padding: 2px 6px;margin-left:1px;border-radius:2px;background:#ca4a1f;color: #fff; font-size: 14px;vertical-align: text-bottom;font-style: italic;">Extended</span>
290
+ </script>
291
+
292
+ <!-- ACFE: Debug -->
293
+ <script type="text/html" id="tmpl-acfe-debug">
294
+ <div class="acf-box">
295
+ <?php _print_r(acf_get_local_field_groups()); ?>
296
+ </div>
297
+ </script>
298
+
299
+ <script type="text/javascript">
300
+ (function($){
301
+
302
+ // ACFE: Label
303
+ $('.acf-column-2 > .acf-box > .inner > h2').append($('#tmpl-acfe-label').html());
304
+
305
+ // ACFE: Debug
306
+ //$('#posts-filter').append($('#tmpl-acfe-debug').html());
307
+
308
+ // ACFE: Table Row Actions - Export Wrap Form
309
+ $('.acfe-export-json .acfe-form').each(function(k, v){
310
+ $(this).wrapAll('<form action="' + $(this).attr('data-action') + '" method="post" style="display:inline;"></form>');
311
+ });
312
+
313
+ // ACFE: Table Row Actions - Export Submit Form
314
+ $('.acfe-export-json a').click(function(e){
315
+ e.preventDefault();
316
+ $(this).closest('form').submit();
317
+ });
318
+ })(jQuery);
319
+ </script>
320
+ <?php
321
+ });
322
+ });
includes/fields/field-dynamic-message.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ABSPATH'))
4
+ exit;
5
+
6
+ add_action('acf/include_field_types', function(){
7
+
8
+ class acfe_field_dynamic_message extends acf_field{
9
+
10
+ function __construct(){
11
+ $this->name = 'acfe_dynamic_message';
12
+ $this->label = __('Dynamic Message', 'acfe');
13
+ $this->category = 'layout';
14
+
15
+ // do not delete!
16
+ parent::__construct();
17
+ }
18
+
19
+ }
20
+
21
+ // create field
22
+ new acfe_field_dynamic_message();
23
+
24
+ });
includes/fields/settings-data.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ABSPATH'))
4
+ exit;
5
+
6
+ /**
7
+ * Setting: Field Data
8
+ */
9
+ add_action('acf/render_field_settings', 'acfe_settings_field_data', 992);
10
+ function acfe_settings_field_data($field){
11
+
12
+ if($field['ID'] == 'acfcloneindex')
13
+ return;
14
+
15
+ $acfe_field_data_id = false;
16
+ if($field['ID'] != 'acfcloneindex')
17
+ $acfe_field_data_id = $field['ID'];
18
+
19
+ acf_render_field_setting($field, array(
20
+ 'label' => false,
21
+ 'instructions' => '',
22
+ 'type' => 'acfe_dynamic_message',
23
+ 'required' => false,
24
+ 'name' => 'acfe_field_data',
25
+ 'key' => 'acfe_field_data',
26
+ 'value' => $acfe_field_data_id,
27
+ ), true);
28
+
29
+ }
30
+
31
+ /**
32
+ * Render: Field Data
33
+ */
34
+ add_filter('acf/render_field/name=acfe_field_data', 'acfe_render_field_data');
35
+ function acfe_render_field_data($field){
36
+
37
+ $acfe_field_data_id = $field['value'];
38
+
39
+ $get_field = acf_get_field($acfe_field_data_id);
40
+ $get_field_debug = '<pre style="margin-bottom:15px;">' . print_r($get_field, true) . '</pre>';
41
+
42
+ if(!$get_field)
43
+ $get_field_debug = '<pre>Field data unavailable</pre>';
44
+
45
+ $get_post = get_post($acfe_field_data_id);
46
+ $get_post_debug = '<pre>' . print_r($get_post, true) . '</pre>';
47
+
48
+ if(!$get_post || $get_post->post_type !== 'acf-field'){
49
+ $get_post_debug = '<pre>Post object unavailable</pre>';
50
+ }
51
+
52
+ $button = '<a href="#" class="button acfe_modal_open" style="margin-left:5px;" data-modal-key="' . $acfe_field_data_id . '">' . __('Data') . '</a>';
53
+ if(!$get_field && !$get_post)
54
+ $button = '<a href="#" class="button disabled" disabled>' . __('Data') . '</a>';
55
+
56
+ echo $button . '<div class="acfe_modal acfe_modal_dev_debug hidden" data-modal-key="' . $acfe_field_data_id . '">' . $get_field_debug . $get_post_debug . '</div>';
57
+
58
+ }
includes/fields/settings-permissions.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ABSPATH'))
4
+ exit;
5
+
6
+ add_action('acf/render_field_settings', 'acfe_permissions_settings', 999);
7
+ function acfe_permissions_settings($field){
8
+
9
+ // Settings
10
+ acf_render_field_setting($field, array(
11
+ 'label' => __('Permissions'),
12
+ 'name' => 'acfe_permissions',
13
+ 'key' => 'acfe_permissions',
14
+ 'instructions' => __('Select user roles that are allowed to view and edit this field. If nothing is selected, then this field will be available to everyone.'),
15
+ 'type' => 'checkbox',
16
+ 'required' => false,
17
+ 'default_value' => false,
18
+ 'choices' => acfe_get_roles(),
19
+ 'layout' => 'horizontal'
20
+ ), true);
21
+
22
+ }
23
+
24
+ add_filter('acf/prepare_field', 'acfe_roles_prepare_field');
25
+ function acfe_roles_prepare_field($field){
26
+ if(!isset($field['acfe_permissions']) || empty($field['acfe_permissions']))
27
+ return $field;
28
+
29
+ $current_user_roles = acfe_get_current_user_roles();
30
+ $render_field = false;
31
+
32
+ foreach($current_user_roles as $current_user_role){
33
+ foreach($field['acfe_permissions'] as $field_role){
34
+ if($current_user_role !== $field_role)
35
+ continue;
36
+
37
+ $render_field = true;
38
+ break;
39
+ }
40
+
41
+ if($render_field)
42
+ break;
43
+ }
44
+
45
+ if(!$render_field)
46
+ return false;
47
+
48
+ return $field;
49
+ }
50
+
51
+ function acfe_get_roles(){
52
+ global $wp_roles;
53
+ $choices = array();
54
+
55
+ if(is_multisite())
56
+ $choices['super_admin'] = __('Super Admin');
57
+
58
+ foreach($wp_roles->roles as $role => $settings){
59
+ $choices[$role] = $settings['name'];
60
+ }
61
+
62
+ return $choices;
63
+ }
64
+
65
+ function acfe_get_current_user_roles(){
66
+ global $current_user;
67
+
68
+ if(!is_object($current_user) || !isset($current_user->roles))
69
+ return false;
70
+
71
+ $roles = $current_user->roles;
72
+ if(is_multisite() && current_user_can('setup_network'))
73
+ $roles[] = 'super_admin';
74
+
75
+ return $roles;
76
+ }
includes/fields/settings-update.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ABSPATH'))
4
+ exit;
5
+
6
+ add_filter('acfe/update/functions', 'acfe_update_functions', 0);
7
+ function acfe_update_functions($choices){
8
+ return array(
9
+ 'Sanitize' => array(
10
+ 'sanitize_email' => 'Sanitize email (sanitize_email)',
11
+ 'sanitize_file_name' => 'Sanitize file name (sanitize_file_name)',
12
+ 'sanitize_html_class' => 'Sanitize html class (sanitize_html_class)',
13
+ 'sanitize_key' => 'Sanitize key (sanitize_key)',
14
+ 'sanitize_meta' => 'Sanitize meta (sanitize_meta)',
15
+ 'sanitize_mime_type' => 'Sanitize mime type (sanitize_mime_type)',
16
+ 'sanitize_option' => 'Sanitize option (sanitize_option)',
17
+ 'sanitize_text_field' => 'Sanitize text field (sanitize_text_field)',
18
+ 'sanitize_title' => 'Sanitize title (sanitize_title)',
19
+ 'sanitize_user' => 'Sanitize user (sanitize_user)',
20
+ ),
21
+ );
22
+ }
23
+
24
+ add_action('acf/render_field_settings', 'acfe_update_settings', 991);
25
+ function acfe_update_settings($field){
26
+
27
+ $exclude = false;
28
+ $exclude = apply_filters('acfe/update/exclude/key=' . $field['key'], $exclude, $field);
29
+ $exclude = apply_filters('acfe/update/exclude/name=' . $field['name'], $exclude, $field);
30
+ $exclude = apply_filters('acfe/update/exclude/type=' . $field['type'], $exclude, $field);
31
+
32
+ if($exclude)
33
+ return;
34
+
35
+ $choices = apply_filters('acfe/update/functions', array(), $field);
36
+ if(empty($choices))
37
+ return;
38
+
39
+ // Settings
40
+ acf_render_field_setting($field, array(
41
+ 'label' => __('Filters'),
42
+ 'name' => 'acfe_update',
43
+ 'key' => 'acfe_update',
44
+ 'instructions' => __('Filter value right before saving'),
45
+ 'type' => 'repeater',
46
+ 'button_label' => __('Add filter'),
47
+ 'required' => false,
48
+ 'sub_fields' => array(
49
+ array(
50
+ 'label' => 'Function',
51
+ 'name' => 'acfe_update_function',
52
+ 'key' => 'acfe_update_function',
53
+ 'prefix' => '',
54
+ '_name' => '',
55
+ '_prepare' => '',
56
+ 'type' => 'select',
57
+ 'choices' => $choices,
58
+ 'instructions' => false,
59
+ 'required' => false,
60
+ 'wrapper' => array(
61
+ 'width' => '',
62
+ 'class' => '',
63
+ 'id' => '',
64
+ ),
65
+ ),
66
+ )
67
+ ), true);
68
+
69
+ }
70
+
71
+ add_filter('acf/update_value', 'acfe_update_value', 99, 3);
72
+ function acfe_update_value($value, $post_id, $field){
73
+
74
+ if(!isset($field['acfe_update']) || empty($field['acfe_update']))
75
+ return $value;
76
+
77
+ $exclude = false;
78
+ $exclude = apply_filters('acfe/update/exclude/key=' . $field['key'], $exclude, $field);
79
+ $exclude = apply_filters('acfe/update/exclude/name=' . $field['name'], $exclude, $field);
80
+ $exclude = apply_filters('acfe/update/exclude/type=' . $field['type'], $exclude, $field);
81
+
82
+ if($exclude)
83
+ return $value;
84
+
85
+ foreach($field['acfe_update'] as $vkey => $function){
86
+
87
+ // Check filters
88
+ $filters = array(
89
+ 'acfe/update/function/' . $rule['acfe_update_function'] . '/key=' . $field['key'],
90
+ 'acfe/update/function/' . $rule['acfe_update_function'] . '/name=' . $field['name'],
91
+ 'acfe/update/function/' . $rule['acfe_update_function'] . '/type=' . $field['type'],
92
+ 'acfe/update/function/' . $rule['acfe_update_function'],
93
+ );
94
+
95
+ $filter_call = false;
96
+ foreach($filters as $filter){
97
+ if(has_filter($filter))
98
+ $filter_call = $filter;
99
+ }
100
+
101
+ if(!$filter_call && !is_callable($function['acfe_update_function']))
102
+ continue;
103
+
104
+ // Apply Filter
105
+ if($filter_call)
106
+ $value = apply_filters($filter_call, $value, $post_id, $field);
107
+
108
+ // [or] Call Function
109
+ else
110
+ $value = call_user_func($function['acfe_update_function'], $value);
111
+
112
+ }
113
+
114
+ return $value;
115
+ }
includes/fields/settings-validation.php ADDED
@@ -0,0 +1,274 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ABSPATH'))
4
+ exit;
5
+
6
+ add_filter('acfe/validate/function/acfe_get_user_by_id', 'acfe_get_user_by_id', 10, 3);
7
+ function acfe_get_user_by_id($result, $value, $field){
8
+ return get_user_by('id', $value);
9
+ }
10
+
11
+ add_filter('acfe/validate/function/acfe_get_user_by_slug', 'acfe_get_user_by_slug', 10, 3);
12
+ function acfe_get_user_by_slug($result, $value, $field){
13
+ return get_user_by('slug', $value);
14
+ }
15
+
16
+ add_filter('acfe/validate/function/acfe_get_user_by_email', 'acfe_get_user_by_email', 10, 3);
17
+ function acfe_get_user_by_email($result, $value, $field){
18
+ return get_user_by('email', $value);
19
+ }
20
+
21
+ add_filter('acfe/validate/function/acfe_get_user_by_login', 'acfe_get_user_by_login', 10, 3);
22
+ function acfe_get_user_by_login($result, $value, $field){
23
+ return get_user_by('login', $value);
24
+ }
25
+
26
+ add_filter('acfe/validate/function/acfe_value', 'acfe_value', 10, 3);
27
+ function acfe_value($result, $value, $field){
28
+ return $value;
29
+ }
30
+
31
+ add_filter('acfe/validate/functions', 'acfe_validate_functions', 0);
32
+ function acfe_validate_functions($choices){
33
+ return array(
34
+ 'Global' => array(
35
+ 'acfe_value' => 'Value (acfe_value)',
36
+ ),
37
+
38
+ 'Exists' => array(
39
+ 'email_exists' => 'Email exists (email_exists)',
40
+ 'post_type_exists' => 'Post type exists (post_type_exists)',
41
+ 'taxonomy_exists' => 'Taxonomy exists (taxonomy_exists)',
42
+ 'term_exists' => 'Term exists (term_exists)',
43
+ 'username_exists' => 'Username exists (username_exists)',
44
+ ),
45
+
46
+ 'Is' => array(
47
+ 'is_email' => 'Is email (is_email)',
48
+ ),
49
+
50
+ 'Sanitize' => array(
51
+ 'sanitize_email' => 'Sanitize email (sanitize_email)',
52
+ 'sanitize_file_name' => 'Sanitize file name (sanitize_file_name)',
53
+ 'sanitize_html_class' => 'Sanitize html class (sanitize_html_class)',
54
+ 'sanitize_key' => 'Sanitize key (sanitize_key)',
55
+ 'sanitize_meta' => 'Sanitize meta (sanitize_meta)',
56
+ 'sanitize_mime_type' => 'Sanitize mime type (sanitize_mime_type)',
57
+ 'sanitize_option' => 'Sanitize option (sanitize_option)',
58
+ 'sanitize_text_field' => 'Sanitize text field (sanitize_text_field)',
59
+ 'sanitize_title' => 'Sanitize title (sanitize_title)',
60
+ 'sanitize_user' => 'Sanitize user (sanitize_user)',
61
+ ),
62
+
63
+ 'User' => array(
64
+ 'acfe_get_user_by_id' => 'Get user by id (acfe_get_user_by_id)',
65
+ 'acfe_get_user_by_slug' => 'Get user by slug (acfe_get_user_by_slug)',
66
+ 'acfe_get_user_by_email' => 'Get user by email (acfe_get_user_by_email)',
67
+ 'acfe_get_user_by_login' => 'Get user by login (acfe_get_user_by_login)',
68
+ 'is_user_logged_in' => 'Is user logged in (is_user_logged_in)',
69
+ )
70
+ );
71
+ }
72
+
73
+ add_action('acf/render_field_settings', 'acfe_validation_settings', 990);
74
+ function acfe_validation_settings($field){
75
+
76
+ $exclude = false;
77
+ $exclude = apply_filters('acfe/validate/exclude/key=' . $field['key'], $exclude, $field);
78
+ $exclude = apply_filters('acfe/validate/exclude/name=' . $field['name'], $exclude, $field);
79
+ $exclude = apply_filters('acfe/validate/exclude/type=' . $field['type'], $exclude, $field);
80
+
81
+ if($exclude)
82
+ return;
83
+
84
+ $choices = apply_filters('acfe/validate/functions', array(), $field);
85
+ if(empty($choices))
86
+ return;
87
+
88
+ // Settings
89
+ acf_render_field_setting($field, array(
90
+ 'label' => __('Validation'),
91
+ 'name' => 'acfe_validate',
92
+ 'key' => 'acfe_validate',
93
+ 'instructions' => __('Validate value against rules'),
94
+ 'type' => 'repeater',
95
+ 'button_label' => __('Add rule'),
96
+ 'required' => false,
97
+ 'layout' => 'row',
98
+ 'sub_fields' => array(
99
+ array(
100
+ 'label' => __('Rules'),
101
+ 'name' => 'acfe_validate_rules_and',
102
+ 'key' => 'acfe_validate_rules_and',
103
+ 'instructions' => '',
104
+ 'type' => 'repeater',
105
+ 'button_label' => __('+ AND'),
106
+ 'required' => false,
107
+ 'layout' => 'table',
108
+ 'sub_fields' => array(
109
+ array(
110
+ 'label' => 'Function',
111
+ 'name' => 'acfe_validate_function',
112
+ 'key' => 'acfe_validate_function',
113
+ 'prefix' => '',
114
+ '_name' => '',
115
+ '_prepare' => '',
116
+ 'type' => 'select',
117
+ 'choices' => $choices,
118
+ 'instructions' => false,
119
+ 'required' => false,
120
+ 'wrapper' => array(
121
+ 'width' => '',
122
+ 'class' => '',
123
+ 'id' => '',
124
+ ),
125
+ ),
126
+ array(
127
+ 'label' => 'Operator',
128
+ 'name' => 'acfe_validate_operator',
129
+ 'key' => 'acfe_validate_operator',
130
+ 'prefix' => '',
131
+ '_name' => '',
132
+ '_prepare' => '',
133
+ 'type' => 'select',
134
+ 'choices' => array(
135
+ '==' => 'Equal',
136
+ '!=' => 'Not equal',
137
+ ),
138
+ 'instructions' => false,
139
+ 'required' => false,
140
+ 'wrapper' => array(
141
+ 'width' => '',
142
+ 'class' => '',
143
+ 'id' => '',
144
+ ),
145
+ ),
146
+ array(
147
+ 'label' => 'Match',
148
+ 'name' => 'acfe_validate_match',
149
+ 'key' => 'acfe_validate_match',
150
+ 'prefix' => '',
151
+ '_name' => '',
152
+ '_prepare' => '',
153
+ 'type' => 'select',
154
+ 'choices' => array(
155
+ 'true' => 'True',
156
+ 'false' => 'False',
157
+ 'empty' => 'Empty',
158
+ ),
159
+ 'instructions' => false,
160
+ 'required' => false,
161
+ 'wrapper' => array(
162
+ 'width' => '',
163
+ 'class' => '',
164
+ 'id' => '',
165
+ ),
166
+ ),
167
+ )
168
+ ),
169
+ array(
170
+ 'label' => 'Error',
171
+ 'name' => 'acfe_validate_error',
172
+ 'key' => 'acfe_validate_error',
173
+ 'prefix' => '',
174
+ '_name' => '',
175
+ '_prepare' => '',
176
+ 'type' => 'text',
177
+ 'instructions' => false,
178
+ 'required' => false,
179
+ 'wrapper' => array(
180
+ 'width' => '',
181
+ 'class' => '',
182
+ 'id' => '',
183
+ ),
184
+ ),
185
+ )
186
+ ), true);
187
+
188
+ }
189
+
190
+ add_filter('acf/validate_value', 'acfe_validate_value', 99, 4);
191
+ function acfe_validate_value($valid, $value, $field, $input){
192
+ if(!$valid)
193
+ return $valid;
194
+
195
+ if(!isset($field['acfe_validate']) || empty($field['acfe_validate']))
196
+ return $valid;
197
+
198
+ $exclude = false;
199
+ $exclude = apply_filters('acfe/validate/exclude/key=' . $field['key'], $exclude, $field);
200
+ $exclude = apply_filters('acfe/validate/exclude/name=' . $field['name'], $exclude, $field);
201
+ $exclude = apply_filters('acfe/validate/exclude/type=' . $field['type'], $exclude, $field);
202
+
203
+ if($exclude)
204
+ return $valid;
205
+
206
+ foreach($field['acfe_validate'] as $orkey => $rules){
207
+
208
+ $acfe_validate_rules_and = isset($rules['acfe_validate_rules_and']) && !empty($rules['acfe_validate_rules_and']);
209
+ if(!$acfe_validate_rules_and)
210
+ continue;
211
+
212
+ $rule_match = true;
213
+
214
+ foreach($rules['acfe_validate_rules_and'] as $andkey => $rule){
215
+
216
+ if(!$rule_match)
217
+ break;
218
+
219
+ $rule_match = false;
220
+
221
+ // Check filters
222
+ $filters = array(
223
+ 'acfe/validate/function/' . $rule['acfe_validate_function'] . '/key=' . $field['key'],
224
+ 'acfe/validate/function/' . $rule['acfe_validate_function'] . '/name=' . $field['name'],
225
+ 'acfe/validate/function/' . $rule['acfe_validate_function'] . '/type=' . $field['type'],
226
+ 'acfe/validate/function/' . $rule['acfe_validate_function'],
227
+ );
228
+
229
+ $filter_call = false;
230
+ foreach($filters as $filter){
231
+ if(has_filter($filter))
232
+ $filter_call = $filter;
233
+ }
234
+
235
+ if(!$filter_call && !is_callable($rule['acfe_validate_function']))
236
+ continue;
237
+
238
+ // Apply Filter
239
+ if($filter_call)
240
+ $result = apply_filters($filter_call, false, $value, $field);
241
+
242
+ // [or] Call Function
243
+ else
244
+ $result = call_user_func($rule['acfe_validate_function'], $value);
245
+
246
+ // Vars
247
+ $operator = $rule['acfe_validate_operator'];
248
+ $match = $rule['acfe_validate_match'];
249
+
250
+ // Equal
251
+ if($operator == '==' && (($match == 'true' && $result) || ($match == 'false' && !$result) || ($match == 'empty' && empty($result)))){
252
+ $rule_match = true;
253
+ }
254
+
255
+ // Not Equal
256
+ elseif($operator == '!=' && (($match == 'true' && !$result) || ($match == 'false' && $result) || ($match == 'empty' && !empty($result)))){
257
+ $rule_match = true;
258
+ }
259
+
260
+ }
261
+
262
+ // Error
263
+ $error = $rules['acfe_validate_error'];
264
+
265
+ if($rule_match && !empty($error))
266
+ $valid = $error;
267
+
268
+ if(!$valid || is_string($valid))
269
+ break;
270
+
271
+ }
272
+
273
+ return $valid;
274
+ }
includes/modules/autosync.php ADDED
@@ -0,0 +1,291 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ABSPATH'))
4
+ exit;
5
+
6
+ /**
7
+ * Auto Sync: Includes
8
+ */
9
+ $acfe_php = acf_get_setting('acfe_php');
10
+ $acfe_php_load = acf_get_setting('acfe_php_load');
11
+
12
+ if(!empty($acfe_php) && !empty($acfe_php_load)){
13
+ foreach($acfe_php_load as $path){
14
+ if(!is_readable($path))
15
+ continue;
16
+
17
+ acf_update_setting('acfe_php_found', true);
18
+
19
+ $files = glob($path . '/*.php');
20
+ if(empty($files))
21
+ continue;
22
+
23
+ foreach($files as $file){
24
+ require_once($file);
25
+ }
26
+
27
+ }
28
+ }
29
+
30
+ /**
31
+ * Auto Sync: Disable json
32
+ */
33
+ add_action('acf/update_field_group', 'acfe_autosync_json_update_field_group', 9);
34
+ function acfe_autosync_json_update_field_group($field_group){
35
+
36
+ // Validate
37
+ if(!acf_get_setting('json'))
38
+ return;
39
+
40
+ // Disable json sync for this field group
41
+ if(!acfe_has_field_group_autosync($field_group, 'json'))
42
+ add_filter('acf/settings/json', 'acfe_autosync_temp_disable_json');
43
+
44
+ }
45
+
46
+ /**
47
+ * Auto Sync: Re-enable json
48
+ */
49
+ add_action('acf/update_field_group', 'acfe_autosync_json_after_update_field_group', 11);
50
+ function acfe_autosync_json_after_update_field_group($field_group){
51
+
52
+ // Validate
53
+ if(!acf_get_setting('json'))
54
+ return;
55
+
56
+ remove_filter('acf/settings/json', 'acfe_autosync_temp_disable_json');
57
+
58
+ }
59
+
60
+ /**
61
+ * Auto Sync: Disable json (function)
62
+ */
63
+ function acfe_autosync_temp_disable_json(){
64
+ return false;
65
+ }
66
+
67
+ /**
68
+ * Auto Sync: PHP
69
+ */
70
+ add_action('acf/update_field_group', 'acfe_autosync_php_update_field_group');
71
+ function acfe_autosync_php_update_field_group($field_group){
72
+
73
+ // Validate
74
+ if(!acf_get_setting('acfe_php'))
75
+ return;
76
+
77
+ if(!acfe_has_field_group_autosync($field_group, 'php'))
78
+ return;
79
+
80
+ $field_group['fields'] = acf_get_fields($field_group);
81
+ acfe_autosync_write_php($field_group);
82
+
83
+ }
84
+
85
+ /**
86
+ * Auto Sync: Write PHP
87
+ */
88
+ function acfe_autosync_write_php($field_group){
89
+
90
+ $path = acf_get_setting('acfe_php_save');
91
+ if(empty($path))
92
+ return false;
93
+
94
+ // vars
95
+ $path = untrailingslashit($path);
96
+ $file = $field_group['key'] . '.php';
97
+
98
+ // bail early if dir does not exist
99
+ if(!is_writable($path))
100
+ return false;
101
+
102
+ // prepare for export
103
+ $id = acf_extract_var($field_group, 'ID');
104
+ $field_group = acf_prepare_field_group_for_export($field_group);
105
+
106
+ // add modified time
107
+ $field_group['modified'] = get_post_modified_time('U', true, $id, true);
108
+
109
+
110
+ // Prepare
111
+ $str_replace = array(
112
+ " " => "\t",
113
+ "'!!__(!!\'" => "__('",
114
+ "!!\', !!\'" => "', '",
115
+ "!!\')!!'" => "')",
116
+ "array (" => "array("
117
+ );
118
+
119
+ $preg_replace = array(
120
+ '/([\t\r\n]+?)array/' => 'array',
121
+ '/[0-9]+ => array/' => 'array'
122
+ );
123
+
124
+ ob_start();
125
+
126
+ echo "<?php " . "\r\n" . "\r\n";
127
+ echo "if( function_exists('acf_add_local_field_group') ):" . "\r\n" . "\r\n";
128
+
129
+ // code
130
+ $code = var_export($field_group, true);
131
+
132
+
133
+ // change double spaces to tabs
134
+ $code = str_replace( array_keys($str_replace), array_values($str_replace), $code );
135
+
136
+
137
+ // correctly formats "=> array("
138
+ $code = preg_replace( array_keys($preg_replace), array_values($preg_replace), $code );
139
+
140
+
141
+ // esc_textarea
142
+ $code = $code;
143
+
144
+ // echo
145
+ echo "acf_add_local_field_group({$code});" . "\r\n" . "\r\n";
146
+
147
+ echo "endif;";
148
+
149
+ $output = ob_get_clean();
150
+
151
+ // write file
152
+ $f = fopen("{$path}/{$file}", 'w');
153
+ fwrite($f, $output);
154
+ fclose($f);
155
+
156
+ // return
157
+ return true;
158
+
159
+ }
160
+
161
+ /**
162
+ * Auto Sync: Helper - is field group json desync
163
+ */
164
+ function acfe_is_field_group_json_desync($field_group){
165
+
166
+ acf_enable_filter('local');
167
+ $group = acf_get_local_field_group($field_group['key']);
168
+ acf_disable_filter('local');
169
+
170
+ $private = acf_maybe_get($group, 'private', false);
171
+ $local = acf_maybe_get($group, 'local', false);
172
+ $modified = acf_maybe_get($group, 'modified', 0);
173
+
174
+ if($private){
175
+ return false;
176
+ }
177
+
178
+ elseif($local !== 'json'){
179
+ return false;
180
+ }
181
+
182
+ elseif($modified && $modified > get_post_modified_time('U', true, $field_group['ID'], true)){
183
+ return true;
184
+ }
185
+
186
+ return false;
187
+
188
+ }
189
+
190
+ /**
191
+ * Auto Sync: Helper - Has field group autosync
192
+ */
193
+ function acfe_has_field_group_autosync($field_group, $type = false){
194
+ $acfe_autosync = acf_maybe_get($field_group, 'acfe_autosync', array());
195
+
196
+ if(!$type)
197
+ return acf_is_array($acfe_autosync);
198
+
199
+ if($type == 'json')
200
+ return is_array($acfe_autosync) && in_array('json', $acfe_autosync);
201
+
202
+ elseif($type == 'php')
203
+ return is_array($acfe_autosync) && in_array('php', $acfe_autosync);
204
+
205
+ return false;
206
+ }
207
+
208
+ /**
209
+ * Auto Sync: Helper - Has field group autosync found register/file
210
+ */
211
+ function acfe_has_field_group_autosync_file($field_group, $type = 'json'){
212
+
213
+ if($type == 'json'){
214
+
215
+ // acf_is_local_field_group = true if json file found
216
+ $found = false;
217
+ if(acf_is_local_field_group($field_group['key'])){
218
+
219
+ $local_field_group = acf_get_local_field_group($field_group['key']);
220
+ $get_local = acf_maybe_get($local_field_group, 'local', false);
221
+
222
+ if($get_local == 'json'){
223
+
224
+ $found = true;
225
+
226
+ }else{
227
+
228
+ $paths = acf_get_setting('load_json');
229
+
230
+ if(!empty($paths)){
231
+ foreach($paths as $path){
232
+
233
+ $path = untrailingslashit($path);
234
+ $file = $field_group['key'] . '.json';
235
+
236
+ if(is_readable("{$path}/{$file}")){
237
+ $found = true;
238
+ break;
239
+ }
240
+
241
+ }
242
+ }
243
+
244
+ }
245
+
246
+ }
247
+
248
+ else{
249
+
250
+ $paths = acf_get_setting('load_json');
251
+
252
+ if(!empty($paths)){
253
+ foreach($paths as $path){
254
+
255
+ $path = untrailingslashit($path);
256
+ $file = $field_group['key'] . '.json';
257
+
258
+ if(is_readable("{$path}/{$file}")){
259
+ $found = true;
260
+ break;
261
+ }
262
+
263
+ }
264
+ }
265
+
266
+ }
267
+
268
+ return $found;
269
+
270
+ }
271
+
272
+ elseif($type == 'php'){
273
+
274
+ // acf_is_local_field_group = true if php registered
275
+ $found = false;
276
+ if(acf_is_local_field_group($field_group['key'])){
277
+
278
+ $local_field_group = acf_get_local_field_group($field_group['key']);
279
+ $get_local = acf_maybe_get($local_field_group, 'local', false);
280
+ if($get_local == 'php')
281
+ $found = true;
282
+
283
+ }
284
+
285
+ return $found;
286
+
287
+ }
288
+
289
+ return false;
290
+
291
+ }
readme.txt ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Advanced Custom Fields: Extended ===
2
+ Contributors: hwk-fr
3
+ Donate link: https://hwk.fr/
4
+ Tags: acf, custom fields, meta, admin, fields, form, repeater, content
5
+ Requires at least: 4.9
6
+ Tested up to: 5.1.1
7
+ Requires PHP: 5.6
8
+ Stable tag: 0.5
9
+ License: GPLv2 or later
10
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
+
12
+ Enhancement Suite which improves Advanced Custom Fields administration
13
+
14
+ == Description ==
15
+
16
+ **Advanced Custom Fields: Extended requires at least ACF Pro 5.7.10**
17
+
18
+ == Features: Field Groups ==
19
+
20
+ **Auto Sync PHP**
21
+ Automatically synchronize field groups with local PHP files upon field group updates. This feature will create, include and update a local PHP file for each field group (just like the native Json sync feature).
22
+
23
+ Default folder: `/wp-content/themes/my-theme/acfe-php/`
24
+
25
+ **Auto Sync Json**
26
+ Control which field groups you want to synchronize with local Json files. Display warnings if the Json file has been manually deleted. Manually synchronize Json from field group screen.
27
+
28
+ **Categories**
29
+ Spice up your field groups with a custom taxonomy and filter field groups by terms.
30
+
31
+ **Permissions**
32
+ Add permission layer in field groups. Choose which roles can view & edit field groups in the post edition screen.
33
+
34
+ **Alternative Title**
35
+ Display an alternative field group title in post edition screen.
36
+
37
+ **Note**
38
+ Add a personal note in the field group administration. Only visible to administrators
39
+
40
+ **Custom meta data**
41
+ Add custom metas (key/value) in the field group administration
42
+
43
+ **View raw data**
44
+ Display raw field group data in a modal to check your configuration & settings
45
+
46
+ **Custom key**
47
+ Set custom field group key. ie: `group_custom_name`
48
+
49
+ == Features: Field Groups List ==
50
+
51
+ **Column: Category**
52
+ Display and filter field groups categories
53
+
54
+ **Column: Locations**
55
+ Quick view of field groups locations informations using icons & popover
56
+
57
+ **Column: Load**
58
+ Quick view of field groups load engine (DB or PHP. See Sync PHP)
59
+
60
+ **Column: Sync PHP / Json**
61
+ Quick view of field groups synchronization status with warnings
62
+
63
+ **Row action: Export PHP / Json**
64
+ One-click export for each field groups
65
+
66
+ **Row action: Field group key**
67
+ Quick view of field groups keys
68
+
69
+ == Features: Fields ==
70
+
71
+ **Avanced validation**
72
+ A more sophisticated validation conditions (AND/OR) with custom error messages in the post edition screen.
73
+
74
+ **Advanced update filter**
75
+ Add specific PHP filters right before the value is saved in the database.
76
+
77
+ **Permissions**
78
+ Add permission layer in fields. Choose which roles can view & edit fields in the post edition screen. (can be combinated with field groups permissions)
79
+
80
+ **View raw data**
81
+ Display raw field data in a modal to check your configuration & settings
82
+
83
+ == Features: Settings ==
84
+
85
+ **Settings page**
86
+ Display all ACF settings in one page
87
+
88
+ == Installation ==
89
+
90
+ = Wordpress Install =
91
+
92
+ 1. Install Advanced Custom Fields: Pro
93
+ 2. Upload the plugin files to the `/wp-content/plugins/advanced-custom-fields-extended` directory, or install the plugin through the WordPress plugins screen directly.
94
+ 3. Activate the plugin through the 'Plugins' screen in WordPress.
95
+ 4. Everything is ready!
96
+
97
+ == Frequently Asked Questions ==
98
+
99
+ = How to activate Auto Sync PHP? =
100
+
101
+ Create a folder `/acfe-php/` in your theme. Go to your field group administration, check to 'Sync PHP' option in the sidebar and save the field group.
102
+
103
+ == Screenshots ==
104
+
105
+ 1. ACF Extended
106
+
107
+ == Changelog ==
108
+
109
+ = 0.5 =
110
+ * Initial release
111
+
112
+ == Upgrade Notice ==
113
+
114
+ None