Version Description
- Field: Advanced Link - Added "Allowed Post Types" & "Allowed Taxonomies" setting to filter allowed Post types & Taxonomy terms in the post selection
- Field: Flexible Content - Categories in the Layouts Selection Modal are now sticky, the vertical scrollbar is now applied to layouts (Thanks @Damien C.)
- Field: Flexible Content - Added filter to disable a potentially unecessary ACF ajax call when closing a layout:
filter('acfe/flexible/remove_ajax_title/name=my_flexible', false, $field);
- Field: Flexible Content - Fixed Layout Title Edition input which could disappear in some rare cases
- Field: Flexible Content - Fixed
z-index
CSS conflict in modals when the flexible content was inside an accordion field (Thanks @Damian P.) - Field: Flexible Content - Fixed
border-bottom
CSS on layout handle when edition modal is set to ON - Field: Flexible Content - Fixed an issue where Categories in the Layouts Modal would still appear when setting was set to ON then to OFF
- Field: Post Object - Added "Allow custom value" setting when "Advanced UI" is ON
- Field: Post Object - Added "Save custom value as post" setting when "Allow custom value" is ON
- Field: reCaptcha - Changed
file_get_contents()
tocurl
method for better compatibility (Thanks @Brandon A.) - Field: Select - Placeholder setting is now also available if "Advanced UI" is set to ON
- Fields: Select2 - CSS enhancements have been moved to the WP admin and are not enqueued in the front-end anymore (Thanks @jaakkosaarenketo)
- Field: Taxonomy Terms - Added "Load Terms" & "Save Terms" allowing the user the load & add terms to the current post, just like ACF does with the "Taxonomy" field (Feature request: @gptrading)
- Field Settings: Bidirectional - Fixed multiple sub fields check which bail too early during the field relation selection process (Thanks @doublesharp)
- Fields Groups: Fixed Json/PHP Sync warnings that were not properly checking the ACF setting
load_json
paths (Thanks @doublesharp) - Fields Groups: Added Export Json & PHP in the Field Group single view (sidebar)
- Fields Groups: Categories are now synced with field groups during the export/import process
- Module: Author - Fixed duplicated post revision when udpating an ACF value (Thanks: @Franois B.)
- Module: Author - Fixed an issue where the module would not show up on post types which are registered using a priority higher or equal to 5 (Thanks @yangkennyk)
- Module: Dev Mode - Added fields counter in the metabox title (Feature request: @Damien C.)
- Module: Dynamic Forms - Added the ability to use
{field:field_name}
&{field:field_key}
values in the "Updated message" setting (Feature request: @alexene22) - Module: Dynamic Forms - Better handling of select/checkbox/radio values render (Thanks @jabbadu)
- Module: Dynamic Forms - Fixed the ACF form submit button which would be still displayed, even if the setting was set to OFF (Thanks @Damien C.)
- Module: Dynamic Forms - Added "Post field groups" setting in the "Advanced" tab to override displayed field groups by a specific post field groups
- Module: Dynamic Forms - Added fallback when rendering complex fields values (array)
- Module: Dynamic Forms - Added
filter('acfe/form/format_value/name=my_field', $value, $unformatted_value, $post_id, $field)
to format field output used in email/post/term/user actions. (Also works with/type
&/key
selectors) - Module: Dynamic Forms - Added Javascript ACF Action on successful form submission:
acf.doAction('acfe/form/submit/success/name=my-form')
- Module: Dynamic Forms - Added compatibility fix for the plugin "MC ACF Flexible Template" (Thanks @MarcinKilarski)
- Module: Dynamic Forms - Added Manual Json Export & Import tools
- Module: Dynamic Forms / Post Types / Taxonomies / Block Types / Options - Added Manual Export in the single view
- Module: Dynamic Forms / Post Types / Taxonomies / Block Types / Options - Added compatibility fix for PolyLang, allowing user to translate modules items (Thanks @Drashka)
- Module: Dynamic Post Types / Taxonomies / Block Types / Options - Added Manual PHP Export action (Feature request: @jaakkosaarenketo)
- General: Added CSS styles to match WP 5.3 Update UI
Download this release
Release Info
Developer | hwk-fr |
Plugin | Advanced Custom Fields: Extended |
Version | 0.8.3 |
Comparing to | |
See all releases |
Code changes from version 0.8.2 to 0.8.3
- acf-extended.php +275 -268
- assets/acf-extended-admin.css +96 -12
- assets/acf-extended-fc-control.css +80 -79
- assets/acf-extended-fc-control.js +803 -794
- assets/acf-extended-fc.css +328 -316
- assets/acf-extended-fg.css +233 -222
- assets/acf-extended-fg.js +30 -26
- assets/acf-extended-fields.js +802 -718
- assets/acf-extended-form.js +151 -139
- assets/acf-extended-modal.css +496 -487
- assets/acf-extended-repeater.css +82 -66
- assets/acf-extended.css +282 -302
- assets/acf-extended.js +198 -192
- includes/admin/settings.php +398 -392
- includes/admin/tools/dbt-export.php +384 -183
- includes/admin/tools/dop-export.php +381 -183
- includes/admin/tools/dpt-export.php +378 -183
- includes/admin/tools/dt-export.php +388 -183
- includes/admin/tools/fg-export.php +65 -0
- includes/admin/tools/form-export.php +239 -0
- includes/admin/tools/form-import.php +149 -0
- includes/core/compatibility.php +184 -132
- includes/core/enqueue.php +96 -90
- includes/core/helpers.php +772 -784
- includes/field-groups/field-group.php +661 -587
- includes/field-groups/field-groups.php +469 -478
- includes/fields-settings/bidirectional.php +607 -605
- includes/fields/field-advanced-link.php +337 -319
- includes/fields/field-flexible-content.php +1022 -1010
- includes/fields/field-forms.php +393 -380
- includes/fields/field-post-object.php +130 -0
- includes/fields/field-post-statuses.php +391 -378
- includes/fields/field-post-types.php +391 -378
- includes/fields/field-recaptcha.php +297 -290
- includes/fields/field-select.php +33 -26
- includes/fields/field-taxonomies.php +391 -378
- includes/fields/field-taxonomy-terms.php +234 -72
- includes/fields/field-user-roles.php +348 -335
- includes/modules/author.php +216 -230
- includes/modules/autosync.php +320 -297
- includes/modules/dev.php +340 -340
- includes/modules/dynamic-block-type.php +1343 -1326
- includes/modules/dynamic-options-page.php +821 -804
- includes/modules/dynamic-post-type.php +0 -2037
acf-extended.php
CHANGED
@@ -1,269 +1,276 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Plugin Name: Advanced Custom Fields: Extended
|
4 |
-
* Description: Enhancement Suite which improves Advanced Custom Fields administration
|
5 |
-
* Version: 0.8.
|
6 |
-
* Author: ACF Extended
|
7 |
-
* Author URI: https://www.acf-extended.com
|
8 |
-
* Text Domain: acfe
|
9 |
-
*/
|
10 |
-
|
11 |
-
if(!defined('ABSPATH'))
|
12 |
-
exit;
|
13 |
-
|
14 |
-
if(!class_exists('ACFE')):
|
15 |
-
|
16 |
-
class ACFE{
|
17 |
-
|
18 |
-
// Version
|
19 |
-
var $version = '0.8.
|
20 |
-
|
21 |
-
// Settings
|
22 |
-
var $settings = array();
|
23 |
-
|
24 |
-
// ACF
|
25 |
-
var $acf = false;
|
26 |
-
|
27 |
-
/**
|
28 |
-
* ACFE: Construct
|
29 |
-
*/
|
30 |
-
function __construct(){
|
31 |
-
// ...
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* ACFE: Initialize
|
36 |
-
*/
|
37 |
-
function initialize(){
|
38 |
-
|
39 |
-
// Constants
|
40 |
-
$this->define('ACFE', true);
|
41 |
-
$this->define('ACFE_FILE', __FILE__);
|
42 |
-
$this->define('ACFE_PATH', plugin_dir_path(__FILE__));
|
43 |
-
$this->define('ACFE_URL', plugin_dir_url(__FILE__));
|
44 |
-
$this->define('ACFE_VERSION', $this->version);
|
45 |
-
$this->define('ACFE_BASENAME', plugin_basename(__FILE__));
|
46 |
-
$this->define('ACFE_THEME_PATH', get_stylesheet_directory());
|
47 |
-
$this->define('ACFE_THEME_URL', get_stylesheet_directory_uri());
|
48 |
-
|
49 |
-
// Define settings
|
50 |
-
$this->settings = array(
|
51 |
-
'acfe/php' => true,
|
52 |
-
'acfe/php_save' => ACFE_THEME_PATH . '/acfe-php',
|
53 |
-
'acfe/php_load' => array(ACFE_THEME_PATH . '/acfe-php'),
|
54 |
-
'acfe/php_found' => false,
|
55 |
-
'acfe/
|
56 |
-
'acfe/
|
57 |
-
'acfe/modules/
|
58 |
-
'acfe/modules/
|
59 |
-
'acfe/modules/
|
60 |
-
'acfe/modules/
|
61 |
-
'acfe/modules/
|
62 |
-
'acfe/modules/
|
63 |
-
'acfe/modules/
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
acfe_include('includes/fields/field-
|
130 |
-
acfe_include('includes/fields/field-
|
131 |
-
acfe_include('includes/fields/field-
|
132 |
-
acfe_include('includes/fields/field-
|
133 |
-
acfe_include('includes/fields/field-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
acfe_include('includes/fields-settings/
|
143 |
-
acfe_include('includes/fields-settings/
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
acfe_include('includes/modules/
|
169 |
-
acfe_include('includes/modules/
|
170 |
-
acfe_include('includes/modules/dynamic-
|
171 |
-
acfe_include('includes/modules/
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
acfe_include('includes/fields/field-
|
194 |
-
acfe_include('includes/fields/field-
|
195 |
-
acfe_include('includes/fields/field-
|
196 |
-
acfe_include('includes/fields/field-
|
197 |
-
acfe_include('includes/fields/field-
|
198 |
-
acfe_include('includes/fields/field-
|
199 |
-
acfe_include('includes/fields/field-
|
200 |
-
acfe_include('includes/fields/field-
|
201 |
-
acfe_include('includes/fields/field-
|
202 |
-
acfe_include('includes/fields/field-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
acfe_include('includes/admin/tools/
|
216 |
-
acfe_include('includes/admin/tools/
|
217 |
-
acfe_include('includes/admin/tools/
|
218 |
-
acfe_include('includes/admin/tools/
|
219 |
-
|
220 |
-
acfe_include('includes/admin/tools/
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
269 |
endif;
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Plugin Name: Advanced Custom Fields: Extended
|
4 |
+
* Description: Enhancement Suite which improves Advanced Custom Fields administration
|
5 |
+
* Version: 0.8.3
|
6 |
+
* Author: ACF Extended
|
7 |
+
* Author URI: https://www.acf-extended.com
|
8 |
+
* Text Domain: acfe
|
9 |
+
*/
|
10 |
+
|
11 |
+
if(!defined('ABSPATH'))
|
12 |
+
exit;
|
13 |
+
|
14 |
+
if(!class_exists('ACFE')):
|
15 |
+
|
16 |
+
class ACFE{
|
17 |
+
|
18 |
+
// Version
|
19 |
+
var $version = '0.8.3';
|
20 |
+
|
21 |
+
// Settings
|
22 |
+
var $settings = array();
|
23 |
+
|
24 |
+
// ACF
|
25 |
+
var $acf = false;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* ACFE: Construct
|
29 |
+
*/
|
30 |
+
function __construct(){
|
31 |
+
// ...
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* ACFE: Initialize
|
36 |
+
*/
|
37 |
+
function initialize(){
|
38 |
+
|
39 |
+
// Constants
|
40 |
+
$this->define('ACFE', true);
|
41 |
+
$this->define('ACFE_FILE', __FILE__);
|
42 |
+
$this->define('ACFE_PATH', plugin_dir_path(__FILE__));
|
43 |
+
$this->define('ACFE_URL', plugin_dir_url(__FILE__));
|
44 |
+
$this->define('ACFE_VERSION', $this->version);
|
45 |
+
$this->define('ACFE_BASENAME', plugin_basename(__FILE__));
|
46 |
+
$this->define('ACFE_THEME_PATH', get_stylesheet_directory());
|
47 |
+
$this->define('ACFE_THEME_URL', get_stylesheet_directory_uri());
|
48 |
+
|
49 |
+
// Define settings
|
50 |
+
$this->settings = array(
|
51 |
+
'acfe/php' => true,
|
52 |
+
'acfe/php_save' => ACFE_THEME_PATH . '/acfe-php',
|
53 |
+
'acfe/php_load' => array(ACFE_THEME_PATH . '/acfe-php'),
|
54 |
+
'acfe/php_found' => false,
|
55 |
+
'acfe/json_found' => false,
|
56 |
+
'acfe/dev' => false,
|
57 |
+
'acfe/modules/author' => true,
|
58 |
+
'acfe/modules/dynamic_block_types' => true,
|
59 |
+
'acfe/modules/dynamic_forms' => true,
|
60 |
+
'acfe/modules/dynamic_options_pages' => true,
|
61 |
+
'acfe/modules/dynamic_post_types' => true,
|
62 |
+
'acfe/modules/dynamic_taxonomies' => true,
|
63 |
+
'acfe/modules/options' => true,
|
64 |
+
'acfe/modules/taxonomies' => true,
|
65 |
+
);
|
66 |
+
|
67 |
+
// Init
|
68 |
+
include_once(ACFE_PATH . 'init.php');
|
69 |
+
|
70 |
+
// Load
|
71 |
+
add_action('plugins_loaded', array($this, 'load'));
|
72 |
+
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* ACFE: Load
|
77 |
+
*/
|
78 |
+
function load(){
|
79 |
+
|
80 |
+
if(!$this->has_acf())
|
81 |
+
return;
|
82 |
+
|
83 |
+
// Settings
|
84 |
+
foreach($this->settings as $name => $value){
|
85 |
+
|
86 |
+
acf_update_setting($name, $value);
|
87 |
+
|
88 |
+
}
|
89 |
+
|
90 |
+
// Load
|
91 |
+
add_action('acf/init', array($this, 'includes'), 99);
|
92 |
+
|
93 |
+
// AutoSync
|
94 |
+
add_action('acf/include_fields', array($this, 'autosync'), 5);
|
95 |
+
|
96 |
+
// Fields
|
97 |
+
add_action('acf/include_field_types', array($this, 'fields'));
|
98 |
+
|
99 |
+
// Tools
|
100 |
+
add_action('acf/include_admin_tools', array($this, 'tools'));
|
101 |
+
|
102 |
+
// Compatibility
|
103 |
+
acfe_include('includes/core/compatibility.php');
|
104 |
+
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* ACFE: includes
|
109 |
+
*/
|
110 |
+
function includes(){
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Core
|
114 |
+
*/
|
115 |
+
acfe_include('includes/core/enqueue.php');
|
116 |
+
acfe_include('includes/core/helpers.php');
|
117 |
+
acfe_include('includes/core/menu.php');
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Admin Pages
|
121 |
+
*/
|
122 |
+
acfe_include('includes/admin/options.php');
|
123 |
+
acfe_include('includes/admin/plugins.php');
|
124 |
+
acfe_include('includes/admin/settings.php');
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Fields
|
128 |
+
*/
|
129 |
+
acfe_include('includes/fields/field-clone.php');
|
130 |
+
acfe_include('includes/fields/field-file.php');
|
131 |
+
acfe_include('includes/fields/field-flexible-content.php');
|
132 |
+
acfe_include('includes/fields/field-group.php');
|
133 |
+
acfe_include('includes/fields/field-image.php');
|
134 |
+
acfe_include('includes/fields/field-post-object.php');
|
135 |
+
acfe_include('includes/fields/field-repeater.php');
|
136 |
+
acfe_include('includes/fields/field-select.php');
|
137 |
+
acfe_include('includes/fields/field-textarea.php');
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Fields settings
|
141 |
+
*/
|
142 |
+
acfe_include('includes/fields-settings/bidirectional.php');
|
143 |
+
acfe_include('includes/fields-settings/data.php');
|
144 |
+
acfe_include('includes/fields-settings/fields.php');
|
145 |
+
acfe_include('includes/fields-settings/permissions.php');
|
146 |
+
acfe_include('includes/fields-settings/settings.php');
|
147 |
+
acfe_include('includes/fields-settings/validation.php');
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Field Groups
|
151 |
+
*/
|
152 |
+
acfe_include('includes/field-groups/field-group.php');
|
153 |
+
acfe_include('includes/field-groups/field-group-category.php');
|
154 |
+
acfe_include('includes/field-groups/field-groups.php');
|
155 |
+
acfe_include('includes/field-groups/field-groups-third-party.php');
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Locations
|
159 |
+
*/
|
160 |
+
acfe_include('includes/locations/post-type-all.php');
|
161 |
+
acfe_include('includes/locations/post-type-archive.php');
|
162 |
+
acfe_include('includes/locations/post-type-list.php');
|
163 |
+
acfe_include('includes/locations/taxonomy-list.php');
|
164 |
+
|
165 |
+
/**
|
166 |
+
* Modules
|
167 |
+
*/
|
168 |
+
acfe_include('includes/modules/author.php');
|
169 |
+
acfe_include('includes/modules/dev.php');
|
170 |
+
acfe_include('includes/modules/dynamic-block-type.php');
|
171 |
+
acfe_include('includes/modules/dynamic-form.php');
|
172 |
+
acfe_include('includes/modules/dynamic-options-page.php');
|
173 |
+
acfe_include('includes/modules/dynamic-post-type.php');
|
174 |
+
acfe_include('includes/modules/dynamic-taxonomy.php');
|
175 |
+
acfe_include('includes/modules/taxonomy.php');
|
176 |
+
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
* ACFE: AutoSync
|
181 |
+
*/
|
182 |
+
function autosync(){
|
183 |
+
|
184 |
+
acfe_include('includes/modules/autosync.php');
|
185 |
+
|
186 |
+
}
|
187 |
+
|
188 |
+
/**
|
189 |
+
* ACFE: Fields
|
190 |
+
*/
|
191 |
+
function fields(){
|
192 |
+
|
193 |
+
acfe_include('includes/fields/field-advanced-link.php');
|
194 |
+
acfe_include('includes/fields/field-button.php');
|
195 |
+
acfe_include('includes/fields/field-code-editor.php');
|
196 |
+
acfe_include('includes/fields/field-column.php');
|
197 |
+
acfe_include('includes/fields/field-dynamic-message.php');
|
198 |
+
acfe_include('includes/fields/field-forms.php');
|
199 |
+
acfe_include('includes/fields/field-hidden.php');
|
200 |
+
acfe_include('includes/fields/field-post-statuses.php');
|
201 |
+
acfe_include('includes/fields/field-post-types.php');
|
202 |
+
acfe_include('includes/fields/field-recaptcha.php');
|
203 |
+
acfe_include('includes/fields/field-slug.php');
|
204 |
+
acfe_include('includes/fields/field-taxonomies.php');
|
205 |
+
acfe_include('includes/fields/field-taxonomy-terms.php');
|
206 |
+
acfe_include('includes/fields/field-user-roles.php');
|
207 |
+
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* ACFE: Tools
|
212 |
+
*/
|
213 |
+
function tools(){
|
214 |
+
|
215 |
+
acfe_include('includes/admin/tools/dbt-export.php');
|
216 |
+
acfe_include('includes/admin/tools/dbt-import.php');
|
217 |
+
acfe_include('includes/admin/tools/dpt-export.php');
|
218 |
+
acfe_include('includes/admin/tools/dpt-import.php');
|
219 |
+
acfe_include('includes/admin/tools/dt-export.php');
|
220 |
+
acfe_include('includes/admin/tools/dt-import.php');
|
221 |
+
acfe_include('includes/admin/tools/dop-export.php');
|
222 |
+
acfe_include('includes/admin/tools/dop-import.php');
|
223 |
+
|
224 |
+
acfe_include('includes/admin/tools/form-export.php');
|
225 |
+
acfe_include('includes/admin/tools/form-import.php');
|
226 |
+
acfe_include('includes/admin/tools/fg-local.php');
|
227 |
+
acfe_include('includes/admin/tools/fg-export.php');
|
228 |
+
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* ACFE: Define
|
233 |
+
*/
|
234 |
+
function define($name, $value = true){
|
235 |
+
|
236 |
+
if(!defined($name))
|
237 |
+
define($name, $value);
|
238 |
+
|
239 |
+
}
|
240 |
+
|
241 |
+
/**
|
242 |
+
* ACFE: Has ACF
|
243 |
+
*/
|
244 |
+
function has_acf(){
|
245 |
+
|
246 |
+
if($this->acf)
|
247 |
+
return true;
|
248 |
+
|
249 |
+
$this->acf = class_exists('ACF') && defined('ACF_PRO') && defined('ACF_VERSION') && version_compare(ACF_VERSION, '5.7.10', '>=');
|
250 |
+
|
251 |
+
return $this->acf;
|
252 |
+
|
253 |
+
}
|
254 |
+
|
255 |
+
}
|
256 |
+
|
257 |
+
|
258 |
+
function acfe(){
|
259 |
+
|
260 |
+
global $acfe;
|
261 |
+
|
262 |
+
if(!isset($acfe)){
|
263 |
+
|
264 |
+
$acfe = new ACFE();
|
265 |
+
$acfe->initialize();
|
266 |
+
|
267 |
+
}
|
268 |
+
|
269 |
+
return $acfe;
|
270 |
+
|
271 |
+
}
|
272 |
+
|
273 |
+
// Instantiate.
|
274 |
+
acfe();
|
275 |
+
|
276 |
endif;
|
assets/acf-extended-admin.css
CHANGED
@@ -59,31 +59,68 @@ code, kbd, pre, samp{
|
|
59 |
/*
|
60 |
* ACFE: Dynamic Post Type
|
61 |
*/
|
62 |
-
body.post-type-acfe-dpt #
|
|
|
|
|
63 |
display:none;
|
64 |
}
|
65 |
|
|
|
|
|
|
|
|
|
66 |
/*
|
67 |
* ACFE: Dynamic Taxonomy
|
68 |
*/
|
69 |
-
body.post-type-acfe-dt #
|
|
|
|
|
70 |
display:none;
|
71 |
}
|
72 |
|
|
|
|
|
|
|
|
|
73 |
/*
|
74 |
* ACFE: Dynamic Options Page
|
75 |
*/
|
76 |
-
body.post-type-acfe-dop #
|
|
|
|
|
77 |
display:none;
|
78 |
}
|
79 |
|
|
|
|
|
|
|
|
|
80 |
/*
|
81 |
* ACFE: Dynamic Block Type
|
82 |
*/
|
83 |
-
body.post-type-acfe-dbt #
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
display:none;
|
85 |
}
|
86 |
|
|
|
|
|
|
|
|
|
87 |
/*
|
88 |
* ACFE: Author Label
|
89 |
*/
|
@@ -179,14 +216,6 @@ body.post-type-acfe-dbt #minor-publishing{
|
|
179 |
text-align:left;
|
180 |
}
|
181 |
|
182 |
-
.acf-field-repeater.acf-field-acfe-form-email-files > .acf-input > .acf-repeater > .acf-actions > .acf-button{
|
183 |
-
color: #555;
|
184 |
-
border-color: #ccc;
|
185 |
-
background: #f7f7f7;
|
186 |
-
box-shadow: 0 1px 0 #ccc;
|
187 |
-
text-shadow:none;
|
188 |
-
}
|
189 |
-
|
190 |
/*
|
191 |
* ACFE Dev Mode
|
192 |
*/
|
@@ -194,4 +223,59 @@ body.post-type-acfe-dbt #minor-publishing{
|
|
194 |
.postbox#acfe-acf-custom-fields > .inside{
|
195 |
padding:0;
|
196 |
margin:0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
197 |
}
|
59 |
/*
|
60 |
* ACFE: Dynamic Post Type
|
61 |
*/
|
62 |
+
body.post-type-acfe-dpt.post-new-php #misc-publishing-actions,
|
63 |
+
body.post-type-acfe-dpt .misc-pub-post-status,
|
64 |
+
body.post-type-acfe-dpt .misc-pub-visibility{
|
65 |
display:none;
|
66 |
}
|
67 |
|
68 |
+
body.post-type-acfe-dpt.post-new-php #major-publishing-actions{
|
69 |
+
border-top:0;
|
70 |
+
}
|
71 |
+
|
72 |
/*
|
73 |
* ACFE: Dynamic Taxonomy
|
74 |
*/
|
75 |
+
body.post-type-acfe-dt.post-new-php #misc-publishing-actions,
|
76 |
+
body.post-type-acfe-dt .misc-pub-post-status,
|
77 |
+
body.post-type-acfe-dt .misc-pub-visibility{
|
78 |
display:none;
|
79 |
}
|
80 |
|
81 |
+
body.post-type-acfe-dt.post-new-php #major-publishing-actions{
|
82 |
+
border-top:0;
|
83 |
+
}
|
84 |
+
|
85 |
/*
|
86 |
* ACFE: Dynamic Options Page
|
87 |
*/
|
88 |
+
body.post-type-acfe-dop.post-new-php #misc-publishing-actions,
|
89 |
+
body.post-type-acfe-dop .misc-pub-post-status,
|
90 |
+
body.post-type-acfe-dop .misc-pub-visibility{
|
91 |
display:none;
|
92 |
}
|
93 |
|
94 |
+
body.post-type-acfe-dop.post-new-php #major-publishing-actions{
|
95 |
+
border-top:0;
|
96 |
+
}
|
97 |
+
|
98 |
/*
|
99 |
* ACFE: Dynamic Block Type
|
100 |
*/
|
101 |
+
body.post-type-acfe-dbt.post-new-php #misc-publishing-actions,
|
102 |
+
body.post-type-acfe-dbt .misc-pub-post-status,
|
103 |
+
body.post-type-acfe-dbt .misc-pub-visibility{
|
104 |
+
display:none;
|
105 |
+
}
|
106 |
+
|
107 |
+
body.post-type-acfe-dbt.post-new-php #major-publishing-actions{
|
108 |
+
border-top:0;
|
109 |
+
}
|
110 |
+
|
111 |
+
/*
|
112 |
+
* ACFE: Dynamic Forms
|
113 |
+
*/
|
114 |
+
body.post-type-acfe-form.post-new-php #misc-publishing-actions,
|
115 |
+
body.post-type-acfe-form .misc-pub-post-status,
|
116 |
+
body.post-type-acfe-form .misc-pub-visibility{
|
117 |
display:none;
|
118 |
}
|
119 |
|
120 |
+
body.post-type-acfe-form.post-new-php #major-publishing-actions{
|
121 |
+
border-top:0;
|
122 |
+
}
|
123 |
+
|
124 |
/*
|
125 |
* ACFE: Author Label
|
126 |
*/
|
216 |
text-align:left;
|
217 |
}
|
218 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
/*
|
220 |
* ACFE Dev Mode
|
221 |
*/
|
223 |
.postbox#acfe-acf-custom-fields > .inside{
|
224 |
padding:0;
|
225 |
margin:0;
|
226 |
+
}
|
227 |
+
|
228 |
+
/*
|
229 |
+
* ACF Field: Select2 Fix
|
230 |
+
*/
|
231 |
+
|
232 |
+
body:not(.acf-admin-5-3) .select2-container .select2-selection{
|
233 |
+
border-color: #dfdfdf !important;
|
234 |
+
border-radius:0 !important;
|
235 |
+
}
|
236 |
+
|
237 |
+
body:not(.acf-admin-5-3) .select2-container .select2-selection__choice{
|
238 |
+
border-color: #dfdfdf !important;
|
239 |
+
border-radius:0 !important;
|
240 |
+
}
|
241 |
+
|
242 |
+
body:not(.acf-admin-5-3) .select2-dropdown{
|
243 |
+
border-color: #dfdfdf !important;
|
244 |
+
border-radius:0 !important;
|
245 |
+
}
|
246 |
+
|
247 |
+
|
248 |
+
.select2-container .select2-selection--single{
|
249 |
+
height: 30px !important;
|
250 |
+
}
|
251 |
+
|
252 |
+
.select2-container .select2-selection--single .select2-selection__arrow{
|
253 |
+
height:28px !important;
|
254 |
+
}
|
255 |
+
|
256 |
+
.select2-container .select2-selection--single .select2-selection__rendered{
|
257 |
+
font-size:14px;
|
258 |
+
}
|
259 |
+
|
260 |
+
.select2-container .select2-selection--single .select2-selection__clear{
|
261 |
+
line-height: 26px;
|
262 |
+
height: 28px;
|
263 |
+
}
|
264 |
+
|
265 |
+
.select2-container .select2-selection--multiple{
|
266 |
+
height: 30px !important;
|
267 |
+
min-height: 30px !important;
|
268 |
+
}
|
269 |
+
|
270 |
+
.select2-container--default .select2-selection--multiple .select2-selection__rendered{
|
271 |
+
padding: 0 4px !important;
|
272 |
+
}
|
273 |
+
|
274 |
+
.select2-container--default .select2-selection--multiple .select2-selection__choice{
|
275 |
+
margin-right: 4px !important;
|
276 |
+
margin-top: 4px !important;
|
277 |
+
}
|
278 |
+
|
279 |
+
.select2-container--default.select2-container--focus .select2-selection--multiple{
|
280 |
+
border-color:#7e8993 !important;
|
281 |
}
|
assets/acf-extended-fc-control.css
CHANGED
@@ -1,80 +1,81 @@
|
|
1 |
-
/*
|
2 |
-
* ACFE: Flexible Icons
|
3 |
-
*/
|
4 |
-
.acf-flexible-content .layout .acf-icon.acfe-flexible-icon.dashicons{
|
5 |
-
visibility: hidden;
|
6 |
-
}
|
7 |
-
|
8 |
-
.acf-flexible-content .layout .acf-icon.acfe-flexible-icon.dashicons:before{
|
9 |
-
font-family: dashicons;
|
10 |
-
}
|
11 |
-
|
12 |
-
.acf-flexible-content .layout:hover > .acf-fc-layout-controls .acf-icon.acfe-flexible-icon.dashicons{
|
13 |
-
visibility: visible;
|
14 |
-
}
|
15 |
-
|
16 |
-
.acf-flexible-content .layout:hover .acf-fc-layout-controls .acf-icon.-plus,
|
17 |
-
.acf-flexible-content .layout:hover .acf-fc-layout-controls .acf-icon.-minus,
|
18 |
-
.acf-flexible-content .layout.-hover .acf-fc-layout-controls .acf-icon.-plus,
|
19 |
-
.acf-flexible-content .layout.-hover .acf-fc-layout-controls .acf-icon.-minus{
|
20 |
-
visibility: hidden;
|
21 |
-
}
|
22 |
-
|
23 |
-
.acf-flexible-content .layout:hover > .acf-fc-layout-controls .acf-icon.-plus,
|
24 |
-
.acf-flexible-content .layout:hover > .acf-fc-layout-controls .acf-icon.-minus,
|
25 |
-
.acf-flexible-content .layout.-hover > .acf-fc-layout-controls .acf-icon.-plus,
|
26 |
-
.acf-flexible-content .layout.-hover > .acf-fc-layout-controls .acf-icon.-minus{
|
27 |
-
visibility: visible;
|
28 |
-
}
|
29 |
-
|
30 |
-
.acf-flexible-content .layout > .acf-fc-layout-controls .acf-icon.disabled{
|
31 |
-
color: #ccc;
|
32 |
-
cursor: initial;
|
33 |
-
}
|
34 |
-
|
35 |
-
.acf-flexible-content .layout > .acf-fc-layout-controls .acf-icon.disabled:hover{
|
36 |
-
color: #ccc;
|
37 |
-
background: #F5F5F5;
|
38 |
-
}
|
39 |
-
|
40 |
-
.acf-flexible-content[data-acfe-flexible-lock="1"] .layout .acf-fc-layout-handle{
|
41 |
-
cursor:initial;
|
42 |
-
}
|
43 |
-
|
44 |
-
|
45 |
-
/*
|
46 |
-
* ACFE: Title Edit
|
47 |
-
*/
|
48 |
-
.acf-field-acfe-flexible-layout-title{
|
49 |
-
display:none;
|
50 |
-
}
|
51 |
-
|
52 |
-
input.acfe-flexible-control-title{
|
53 |
-
border:none;
|
54 |
-
box-shadow:none !important;
|
55 |
-
outline:none !important;
|
56 |
-
border-radius:0;
|
57 |
-
border-bottom:1px solid transparent !important;
|
58 |
-
font-weight:600;
|
59 |
-
width:auto !important;
|
60 |
-
padding:0 !important;
|
61 |
-
display:none;
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
|
|
80 |
}
|
1 |
+
/*
|
2 |
+
* ACFE: Flexible Icons
|
3 |
+
*/
|
4 |
+
.acf-flexible-content .layout .acf-icon.acfe-flexible-icon.dashicons{
|
5 |
+
visibility: hidden;
|
6 |
+
}
|
7 |
+
|
8 |
+
.acf-flexible-content .layout .acf-icon.acfe-flexible-icon.dashicons:before{
|
9 |
+
font-family: dashicons;
|
10 |
+
}
|
11 |
+
|
12 |
+
.acf-flexible-content .layout:hover > .acf-fc-layout-controls .acf-icon.acfe-flexible-icon.dashicons{
|
13 |
+
visibility: visible;
|
14 |
+
}
|
15 |
+
|
16 |
+
.acf-flexible-content .layout:hover .acf-fc-layout-controls .acf-icon.-plus,
|
17 |
+
.acf-flexible-content .layout:hover .acf-fc-layout-controls .acf-icon.-minus,
|
18 |
+
.acf-flexible-content .layout.-hover .acf-fc-layout-controls .acf-icon.-plus,
|
19 |
+
.acf-flexible-content .layout.-hover .acf-fc-layout-controls .acf-icon.-minus{
|
20 |
+
visibility: hidden;
|
21 |
+
}
|
22 |
+
|
23 |
+
.acf-flexible-content .layout:hover > .acf-fc-layout-controls .acf-icon.-plus,
|
24 |
+
.acf-flexible-content .layout:hover > .acf-fc-layout-controls .acf-icon.-minus,
|
25 |
+
.acf-flexible-content .layout.-hover > .acf-fc-layout-controls .acf-icon.-plus,
|
26 |
+
.acf-flexible-content .layout.-hover > .acf-fc-layout-controls .acf-icon.-minus{
|
27 |
+
visibility: visible;
|
28 |
+
}
|
29 |
+
|
30 |
+
.acf-flexible-content .layout > .acf-fc-layout-controls .acf-icon.disabled{
|
31 |
+
color: #ccc;
|
32 |
+
cursor: initial;
|
33 |
+
}
|
34 |
+
|
35 |
+
.acf-flexible-content .layout > .acf-fc-layout-controls .acf-icon.disabled:hover{
|
36 |
+
color: #ccc;
|
37 |
+
background: #F5F5F5;
|
38 |
+
}
|
39 |
+
|
40 |
+
.acf-flexible-content[data-acfe-flexible-lock="1"] .layout .acf-fc-layout-handle{
|
41 |
+
cursor:initial;
|
42 |
+
}
|
43 |
+
|
44 |
+
|
45 |
+
/*
|
46 |
+
* ACFE: Title Edit
|
47 |
+
*/
|
48 |
+
.acf-field-acfe-flexible-layout-title{
|
49 |
+
display:none;
|
50 |
+
}
|
51 |
+
|
52 |
+
input.acfe-flexible-control-title{
|
53 |
+
border:none;
|
54 |
+
box-shadow:none !important;
|
55 |
+
outline:none !important;
|
56 |
+
border-radius:0;
|
57 |
+
border-bottom:1px solid transparent !important;
|
58 |
+
font-weight:600;
|
59 |
+
width:auto !important;
|
60 |
+
padding:0 !important;
|
61 |
+
display:none;
|
62 |
+
min-height:20px;
|
63 |
+
}
|
64 |
+
|
65 |
+
.layout > .acf-fc-layout-handle .acfe-layout-title{
|
66 |
+
cursor:text;
|
67 |
+
position:relative;
|
68 |
+
}
|
69 |
+
|
70 |
+
.layout > .acf-fc-layout-handle .acfe-layout-title:hover{
|
71 |
+
background:#f4f4f4;
|
72 |
+
}
|
73 |
+
|
74 |
+
.layout.acfe-flexible-title-edition > .acf-fc-layout-handle .acfe-layout-title input.acfe-flexible-control-title{
|
75 |
+
display:inline-block;
|
76 |
+
border-bottom:1px solid #ddd !important;
|
77 |
+
}
|
78 |
+
|
79 |
+
.layout.acfe-flexible-title-edition > .acf-fc-layout-handle .acfe-layout-title .acfe-layout-title-text{
|
80 |
+
display:none;
|
81 |
}
|
assets/acf-extended-fc-control.js
CHANGED
@@ -1,795 +1,804 @@
|
|
1 |
-
(function($){
|
2 |
-
|
3 |
-
if(typeof acf === 'undefined')
|
4 |
-
return;
|
5 |
-
|
6 |
-
/*
|
7 |
-
* Init
|
8 |
-
*/
|
9 |
-
var flexible = acf.getFieldType('flexible_content');
|
10 |
-
var model = flexible.prototype;
|
11 |
-
|
12 |
-
/*
|
13 |
-
* Actions
|
14 |
-
*/
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
model.
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
model.events['click .acfe-layout-title-text'] = 'acfeEditLayoutTitle';
|
39 |
-
model.acfeEditLayoutTitle = function(e, $el){
|
40 |
-
|
41 |
-
// Get Flexible
|
42 |
-
var flexible = this;
|
43 |
-
|
44 |
-
// Title Edition
|
45 |
-
if(!flexible.has('acfeFlexibleTitleEdition'))
|
46 |
-
return;
|
47 |
-
|
48 |
-
// Stop propagation
|
49 |
-
e.stopPropagation();
|
50 |
-
|
51 |
-
// Toggle
|
52 |
-
flexible.acfeEditLayoutTitleToggle(e, $el);
|
53 |
-
|
54 |
-
}
|
55 |
-
|
56 |
-
model.
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
var $
|
63 |
-
var $
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
$
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
model.
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
model.
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
var $
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
model.
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
model.
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
var
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
var $
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
var
|
152 |
-
var
|
153 |
-
var
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
model.
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
var
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
$input
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
var
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
$input
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
var
|
281 |
-
var
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
var $
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
var
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
var
|
311 |
-
var
|
312 |
-
var
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
var
|
339 |
-
var
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
model.
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
this
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
return
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
$input.find('.wp-editor-container
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
var $
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
flexible.$layouts().find('> .acf-fc-layout-controls > [data-name="
|
688 |
-
flexible.$layouts().find('> .acf-fc-layout-controls > [data-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
'
|
712 |
-
'
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
'
|
735 |
-
'
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
795 |
})(jQuery);
|
1 |
+
(function($){
|
2 |
+
|
3 |
+
if(typeof acf === 'undefined')
|
4 |
+
return;
|
5 |
+
|
6 |
+
/*
|
7 |
+
* Init
|
8 |
+
*/
|
9 |
+
var flexible = acf.getFieldType('flexible_content');
|
10 |
+
var model = flexible.prototype;
|
11 |
+
|
12 |
+
/*
|
13 |
+
* Actions
|
14 |
+
*/
|
15 |
+
/*
|
16 |
+
* Actions
|
17 |
+
*/
|
18 |
+
model.events['click .acf-fc-layout-handle'] = 'acfeEditLayoutTitleToggleHandle';
|
19 |
+
model.acfeEditLayoutTitleToggleHandle = function(e, $el){
|
20 |
+
|
21 |
+
var flexible = this;
|
22 |
+
|
23 |
+
// Title Edition
|
24 |
+
if(!flexible.has('acfeFlexibleTitleEdition'))
|
25 |
+
return;
|
26 |
+
|
27 |
+
// Vars
|
28 |
+
var $layout = $el.closest('.layout');
|
29 |
+
|
30 |
+
if($layout.hasClass('acfe-flexible-title-edition')){
|
31 |
+
|
32 |
+
$layout.find('> .acf-fc-layout-handle > .acfe-layout-title > input.acfe-flexible-control-title').trigger('blur');
|
33 |
+
|
34 |
+
}
|
35 |
+
|
36 |
+
}
|
37 |
+
|
38 |
+
model.events['click .acfe-layout-title-text'] = 'acfeEditLayoutTitle';
|
39 |
+
model.acfeEditLayoutTitle = function(e, $el){
|
40 |
+
|
41 |
+
// Get Flexible
|
42 |
+
var flexible = this;
|
43 |
+
|
44 |
+
// Title Edition
|
45 |
+
if(!flexible.has('acfeFlexibleTitleEdition'))
|
46 |
+
return;
|
47 |
+
|
48 |
+
// Stop propagation
|
49 |
+
e.stopPropagation();
|
50 |
+
|
51 |
+
// Toggle
|
52 |
+
flexible.acfeEditLayoutTitleToggle(e, $el);
|
53 |
+
|
54 |
+
}
|
55 |
+
|
56 |
+
model.events['blur input.acfe-flexible-control-title'] = 'acfeEditLayoutTitleToggle';
|
57 |
+
model.acfeEditLayoutTitleToggle = function(e, $el){
|
58 |
+
|
59 |
+
var flexible = this;
|
60 |
+
|
61 |
+
// Vars
|
62 |
+
var $layout = $el.closest('.layout');
|
63 |
+
var $handle = $layout.find('> .acf-fc-layout-handle');
|
64 |
+
var $title = $handle.find('.acfe-layout-title');
|
65 |
+
|
66 |
+
if($layout.hasClass('acfe-flexible-title-edition')){
|
67 |
+
|
68 |
+
var $input = $title.find('> input[data-acfe-flexible-control-title-input]');
|
69 |
+
|
70 |
+
if($input.val() === '')
|
71 |
+
$input.val($input.attr('placeholder')).trigger('input');
|
72 |
+
|
73 |
+
$layout.removeClass('acfe-flexible-title-edition');
|
74 |
+
|
75 |
+
$input.insertAfter($handle);
|
76 |
+
|
77 |
+
}
|
78 |
+
|
79 |
+
else{
|
80 |
+
|
81 |
+
var $input = $layout.find('> input[data-acfe-flexible-control-title-input]');
|
82 |
+
|
83 |
+
var $input = $input.appendTo($title);
|
84 |
+
|
85 |
+
$layout.addClass('acfe-flexible-title-edition');
|
86 |
+
$input.focus().attr('size', $input.val().length);
|
87 |
+
|
88 |
+
}
|
89 |
+
|
90 |
+
}
|
91 |
+
|
92 |
+
// Layout: Edit Title
|
93 |
+
model.events['click input.acfe-flexible-control-title'] = 'acfeEditLayoutTitlePropagation';
|
94 |
+
model.acfeEditLayoutTitlePropagation = function(e, $el){
|
95 |
+
|
96 |
+
e.stopPropagation();
|
97 |
+
|
98 |
+
}
|
99 |
+
|
100 |
+
// Layout: Edit Title Input
|
101 |
+
model.events['input [data-acfe-flexible-control-title-input]'] = 'acfeEditLayoutTitleInput';
|
102 |
+
model.acfeEditLayoutTitleInput = function(e, $el){
|
103 |
+
|
104 |
+
// Vars
|
105 |
+
var $layout = $el.closest('.layout');
|
106 |
+
var $title = $layout.find('> .acf-fc-layout-handle .acfe-layout-title .acfe-layout-title-text');
|
107 |
+
|
108 |
+
var val = $el.val();
|
109 |
+
|
110 |
+
$el.attr('size', val.length);
|
111 |
+
|
112 |
+
$title.html(val);
|
113 |
+
|
114 |
+
}
|
115 |
+
|
116 |
+
// Layout: Edit Title Input Enter
|
117 |
+
model.events['keypress [data-acfe-flexible-control-title-input]'] = 'acfeEditLayoutTitleInputEnter';
|
118 |
+
model.acfeEditLayoutTitleInputEnter = function(e, $el){
|
119 |
+
|
120 |
+
// Enter Key
|
121 |
+
if(e.keyCode != 13)
|
122 |
+
return;
|
123 |
+
|
124 |
+
e.preventDefault();
|
125 |
+
$el.blur();
|
126 |
+
|
127 |
+
}
|
128 |
+
|
129 |
+
// Layout: Clone
|
130 |
+
model.events['click [data-acfe-flexible-control-clone]'] = 'acfeCloneLayout';
|
131 |
+
model.acfeCloneLayout = function(e, $el){
|
132 |
+
|
133 |
+
// Get Flexible
|
134 |
+
var flexible = this;
|
135 |
+
|
136 |
+
// Vars
|
137 |
+
var $layout = $el.closest('.layout');
|
138 |
+
var layout_name = $layout.data('layout');
|
139 |
+
|
140 |
+
// Popup min/max
|
141 |
+
var $popup = $(flexible.$popup().html());
|
142 |
+
var $layouts = flexible.$layouts();
|
143 |
+
|
144 |
+
var countLayouts = function(name){
|
145 |
+
return $layouts.filter(function(){
|
146 |
+
return $(this).data('layout') === name;
|
147 |
+
}).length;
|
148 |
+
};
|
149 |
+
|
150 |
+
// vars
|
151 |
+
var $a = $popup.find('[data-layout="' + layout_name + '"]');
|
152 |
+
var min = $a.data('min') || 0;
|
153 |
+
var max = $a.data('max') || 0;
|
154 |
+
var count = countLayouts(layout_name);
|
155 |
+
|
156 |
+
// max
|
157 |
+
if(max && count >= max){
|
158 |
+
|
159 |
+
$el.addClass('disabled');
|
160 |
+
return false;
|
161 |
+
|
162 |
+
}else{
|
163 |
+
|
164 |
+
$el.removeClass('disabled');
|
165 |
+
|
166 |
+
}
|
167 |
+
|
168 |
+
// Fix inputs
|
169 |
+
flexible.acfeFixInputs($layout);
|
170 |
+
|
171 |
+
var $_layout = $layout.clone();
|
172 |
+
|
173 |
+
// Clean Layout
|
174 |
+
flexible.acfeCleanLayouts($_layout);
|
175 |
+
|
176 |
+
var parent = $el.closest('.acf-flexible-content').find('> input[type=hidden]').attr('name');
|
177 |
+
|
178 |
+
// Clone
|
179 |
+
var $layout_added = flexible.acfeDuplicate({
|
180 |
+
layout: $_layout,
|
181 |
+
before: $layout,
|
182 |
+
parent: parent
|
183 |
+
});
|
184 |
+
|
185 |
+
}
|
186 |
+
|
187 |
+
// Layout: Copy
|
188 |
+
model.events['click [data-acfe-flexible-control-copy]'] = 'acfeCopyLayout';
|
189 |
+
model.acfeCopyLayout = function(e, $el){
|
190 |
+
|
191 |
+
// Get Flexible
|
192 |
+
var flexible = this;
|
193 |
+
|
194 |
+
// Vars
|
195 |
+
var $layout = $el.closest('.layout').clone();
|
196 |
+
var source = flexible.$control().find('> input[type=hidden]').attr('name');
|
197 |
+
|
198 |
+
// Fix inputs
|
199 |
+
flexible.acfeFixInputs($layout);
|
200 |
+
|
201 |
+
// Clean layout
|
202 |
+
flexible.acfeCleanLayouts($layout);
|
203 |
+
|
204 |
+
// Get layout data
|
205 |
+
var data = JSON.stringify({
|
206 |
+
source: source,
|
207 |
+
layouts: $layout[0].outerHTML
|
208 |
+
});
|
209 |
+
|
210 |
+
// Append Temp Input
|
211 |
+
var $input = $('<input type="text" style="clip:rect(0,0,0,0);clip-path:rect(0,0,0,0);position:absolute;" value="" />').appendTo($el);
|
212 |
+
$input.attr('value', data).select();
|
213 |
+
|
214 |
+
// Command: Copy
|
215 |
+
if(document.execCommand('copy'))
|
216 |
+
alert('Layout has been transferred to your clipboard');
|
217 |
+
|
218 |
+
// Prompt
|
219 |
+
else
|
220 |
+
prompt('Copy the following layout data to your clipboard', data);
|
221 |
+
|
222 |
+
// Remove the temp input
|
223 |
+
$input.remove();
|
224 |
+
|
225 |
+
}
|
226 |
+
|
227 |
+
// Flexible: Copy Layouts
|
228 |
+
model.acfeCopyLayouts = function(){
|
229 |
+
|
230 |
+
// Get Flexible
|
231 |
+
var flexible = this;
|
232 |
+
|
233 |
+
// Get layouts
|
234 |
+
var $layouts = flexible.$layoutsWrap().clone();
|
235 |
+
var source = flexible.$control().find('> input[type=hidden]').attr('name');
|
236 |
+
|
237 |
+
// Fix inputs
|
238 |
+
flexible.acfeFixInputs($layouts);
|
239 |
+
|
240 |
+
// Clean layout
|
241 |
+
flexible.acfeCleanLayouts($layouts);
|
242 |
+
|
243 |
+
// Get layouts data
|
244 |
+
var data = JSON.stringify({
|
245 |
+
source: source,
|
246 |
+
layouts: $layouts.html()
|
247 |
+
});
|
248 |
+
|
249 |
+
// Append Temp Input
|
250 |
+
var $input = $('<input type="text" style="clip:rect(0,0,0,0);clip-path:rect(0,0,0,0);position:absolute;" value="" />').appendTo(flexible.$el);
|
251 |
+
$input.attr('value', data).select();
|
252 |
+
|
253 |
+
// Command: Copy
|
254 |
+
if(document.execCommand('copy'))
|
255 |
+
alert('Layouts have been transferred to your clipboard');
|
256 |
+
|
257 |
+
// Prompt
|
258 |
+
else
|
259 |
+
prompt('Copy the following layouts data to your clipboard', data);
|
260 |
+
|
261 |
+
$input.remove();
|
262 |
+
|
263 |
+
}
|
264 |
+
|
265 |
+
// Flexible: Paste Layouts
|
266 |
+
model.acfePasteLayouts = function(){
|
267 |
+
|
268 |
+
// Get Flexible
|
269 |
+
var flexible = this;
|
270 |
+
|
271 |
+
var paste = prompt('Paste layouts data in the following field');
|
272 |
+
|
273 |
+
// No input
|
274 |
+
if(paste == null || paste === '')
|
275 |
+
return;
|
276 |
+
|
277 |
+
try{
|
278 |
+
|
279 |
+
// Paste HTML
|
280 |
+
var data = JSON.parse(paste);
|
281 |
+
var source = data.source;
|
282 |
+
var $html = $(data.layouts);
|
283 |
+
|
284 |
+
// Parsed layouts
|
285 |
+
var $html_layouts = $html.closest('[data-layout]');
|
286 |
+
|
287 |
+
if(!$html_layouts.length)
|
288 |
+
return alert('No layouts data available');
|
289 |
+
|
290 |
+
// Popup min/max
|
291 |
+
var $popup = $(flexible.$popup().html());
|
292 |
+
var $layouts = flexible.$layouts();
|
293 |
+
|
294 |
+
var countLayouts = function(name){
|
295 |
+
return $layouts.filter(function(){
|
296 |
+
return $(this).data('layout') === name;
|
297 |
+
}).length;
|
298 |
+
};
|
299 |
+
|
300 |
+
// init
|
301 |
+
var validated_layouts = [];
|
302 |
+
|
303 |
+
// Each first level layouts
|
304 |
+
$html_layouts.each(function(){
|
305 |
+
|
306 |
+
var $this = $(this);
|
307 |
+
var layout_name = $this.data('layout');
|
308 |
+
|
309 |
+
// vars
|
310 |
+
var $a = $popup.find('[data-layout="' + layout_name + '"]');
|
311 |
+
var min = $a.data('min') || 0;
|
312 |
+
var max = $a.data('max') || 0;
|
313 |
+
var count = countLayouts(layout_name);
|
314 |
+
|
315 |
+
// max
|
316 |
+
if(max && count >= max)
|
317 |
+
return;
|
318 |
+
|
319 |
+
// Validate layout against available layouts
|
320 |
+
var get_clone_layout = flexible.$clone($this.attr('data-layout'));
|
321 |
+
|
322 |
+
// Layout is invalid
|
323 |
+
if(!get_clone_layout.length)
|
324 |
+
return;
|
325 |
+
|
326 |
+
// Add validated layout
|
327 |
+
validated_layouts.push($this);
|
328 |
+
|
329 |
+
});
|
330 |
+
|
331 |
+
// Nothing to add
|
332 |
+
if(!validated_layouts.length)
|
333 |
+
return alert('No layouts could be pasted');
|
334 |
+
|
335 |
+
// Add layouts
|
336 |
+
$.each(validated_layouts, function(){
|
337 |
+
|
338 |
+
var $layout = $(this);
|
339 |
+
var search = source + '[' + $layout.attr('data-id') + ']';
|
340 |
+
var target = flexible.$control().find('> input[type=hidden]').attr('name');
|
341 |
+
|
342 |
+
flexible.acfeDuplicate({
|
343 |
+
layout: $layout,
|
344 |
+
before: false,
|
345 |
+
search: search,
|
346 |
+
parent: target
|
347 |
+
});
|
348 |
+
|
349 |
+
});
|
350 |
+
|
351 |
+
}catch(e){
|
352 |
+
|
353 |
+
console.log(e);
|
354 |
+
alert('Invalid data');
|
355 |
+
|
356 |
+
}
|
357 |
+
|
358 |
+
}
|
359 |
+
|
360 |
+
// Flexible: Dropdown
|
361 |
+
model.events['click [data-name="acfe-flexible-control-button"]'] = 'acfeControl';
|
362 |
+
model.acfeControl = function(e, $el){
|
363 |
+
|
364 |
+
// Get Flexible
|
365 |
+
var flexible = this;
|
366 |
+
|
367 |
+
// Vars
|
368 |
+
var $dropdown = $el.next('.tmpl-acfe-flexible-control-popup').html();
|
369 |
+
|
370 |
+
// Init Popup
|
371 |
+
var Popup = acf.models.TooltipConfirm.extend({
|
372 |
+
render: function(){
|
373 |
+
this.html(this.get('text'));
|
374 |
+
this.$el.addClass('acf-fc-popup');
|
375 |
+
}
|
376 |
+
});
|
377 |
+
|
378 |
+
// New Popup
|
379 |
+
var popup = new Popup({
|
380 |
+
target: $el,
|
381 |
+
targetConfirm: false,
|
382 |
+
text: $dropdown,
|
383 |
+
context: flexible,
|
384 |
+
confirm: function(e, $el){
|
385 |
+
|
386 |
+
if($el.attr('data-acfe-flexible-control-action') === 'paste')
|
387 |
+
flexible.acfePasteLayouts();
|
388 |
+
|
389 |
+
else if($el.attr('data-acfe-flexible-control-action') === 'copy')
|
390 |
+
flexible.acfeCopyLayouts();
|
391 |
+
|
392 |
+
}
|
393 |
+
});
|
394 |
+
|
395 |
+
popup.on('click', 'a', 'onConfirm');
|
396 |
+
|
397 |
+
}
|
398 |
+
|
399 |
+
// Flexible: Duplicate
|
400 |
+
model.acfeDuplicate = function(args){
|
401 |
+
|
402 |
+
// Arguments
|
403 |
+
args = acf.parseArgs(args, {
|
404 |
+
layout: '',
|
405 |
+
before: false,
|
406 |
+
parent: false,
|
407 |
+
search: '',
|
408 |
+
replace: '',
|
409 |
+
});
|
410 |
+
|
411 |
+
// Validate
|
412 |
+
if(!this.allowAdd())
|
413 |
+
return false;
|
414 |
+
|
415 |
+
var uniqid = acf.uniqid();
|
416 |
+
|
417 |
+
if(args.parent){
|
418 |
+
|
419 |
+
if(!args.search){
|
420 |
+
|
421 |
+
args.search = args.parent + '[' + args.layout.attr('data-id') + ']';
|
422 |
+
|
423 |
+
}
|
424 |
+
|
425 |
+
args.replace = args.parent + '[' + uniqid + ']';
|
426 |
+
|
427 |
+
}
|
428 |
+
|
429 |
+
// Add row
|
430 |
+
var $el = acf.duplicate({
|
431 |
+
target: args.layout,
|
432 |
+
search: args.search,
|
433 |
+
replace: args.replace,
|
434 |
+
append: this.proxy(function($el, $el2){
|
435 |
+
|
436 |
+
// Add class to duplicated layout
|
437 |
+
$el2.addClass('acfe-layout-duplicated');
|
438 |
+
|
439 |
+
// Reset UniqID
|
440 |
+
$el2.attr('data-id', uniqid);
|
441 |
+
|
442 |
+
// append before
|
443 |
+
if(args.before){
|
444 |
+
|
445 |
+
// Fix clone: Use after() instead of native before()
|
446 |
+
args.before.after($el2);
|
447 |
+
|
448 |
+
}
|
449 |
+
|
450 |
+
// append end
|
451 |
+
else{
|
452 |
+
|
453 |
+
this.$layoutsWrap().append($el2);
|
454 |
+
|
455 |
+
}
|
456 |
+
|
457 |
+
// enable
|
458 |
+
acf.enable($el2, this.cid);
|
459 |
+
|
460 |
+
// render
|
461 |
+
this.render();
|
462 |
+
|
463 |
+
})
|
464 |
+
});
|
465 |
+
|
466 |
+
// trigger change for validation errors
|
467 |
+
this.$input().trigger('change');
|
468 |
+
|
469 |
+
// return
|
470 |
+
return $el;
|
471 |
+
|
472 |
+
}
|
473 |
+
|
474 |
+
// Flexible: Fix Inputs
|
475 |
+
model.acfeFixInputs = function($layout){
|
476 |
+
|
477 |
+
$layout.find('input').each(function(){
|
478 |
+
|
479 |
+
$(this).attr('value', this.value);
|
480 |
+
|
481 |
+
});
|
482 |
+
|
483 |
+
$layout.find('textarea').each(function(){
|
484 |
+
|
485 |
+
$(this).html(this.value);
|
486 |
+
|
487 |
+
});
|
488 |
+
|
489 |
+
$layout.find('input:radio,input:checkbox').each(function() {
|
490 |
+
|
491 |
+
if(this.checked)
|
492 |
+
$(this).attr('checked', 'checked');
|
493 |
+
|
494 |
+
else
|
495 |
+
$(this).attr('checked', false);
|
496 |
+
|
497 |
+
});
|
498 |
+
|
499 |
+
$layout.find('option').each(function(){
|
500 |
+
|
501 |
+
if(this.selected)
|
502 |
+
$(this).attr('selected', 'selected');
|
503 |
+
|
504 |
+
else
|
505 |
+
$(this).attr('selected', false);
|
506 |
+
|
507 |
+
});
|
508 |
+
|
509 |
+
}
|
510 |
+
|
511 |
+
// Flexible: Clean Layout
|
512 |
+
model.acfeCleanLayouts = function($layout){
|
513 |
+
|
514 |
+
// Clean WP Editor
|
515 |
+
$layout.find('.acf-editor-wrap').each(function(){
|
516 |
+
|
517 |
+
var $input = $(this);
|
518 |
+
|
519 |
+
$input.find('.wp-editor-container div').remove();
|
520 |
+
$input.find('.wp-editor-container textarea').css('display', '');
|
521 |
+
|
522 |
+
});
|
523 |
+
|
524 |
+
// Clean Date
|
525 |
+
$layout.find('.acf-date-picker').each(function(){
|
526 |
+
|
527 |
+
var $input = $(this);
|
528 |
+
|
529 |
+
$input.find('input.input').removeClass('hasDatepicker').removeAttr('id');
|
530 |
+
|
531 |
+
});
|
532 |
+
|
533 |
+
// Clean Time
|
534 |
+
$layout.find('.acf-time-picker').each(function(){
|
535 |
+
|
536 |
+
var $input = $(this);
|
537 |
+
|
538 |
+
$input.find('input.input').removeClass('hasDatepicker').removeAttr('id');
|
539 |
+
|
540 |
+
});
|
541 |
+
|
542 |
+
// Clean DateTime
|
543 |
+
$layout.find('.acf-date-time-picker').each(function(){
|
544 |
+
|
545 |
+
var $input = $(this);
|
546 |
+
|
547 |
+
$input.find('input.input').removeClass('hasDatepicker').removeAttr('id');
|
548 |
+
|
549 |
+
});
|
550 |
+
|
551 |
+
// Clean Color Picker
|
552 |
+
$layout.find('.acf-color-picker').each(function(){
|
553 |
+
|
554 |
+
var $input = $(this);
|
555 |
+
|
556 |
+
var $color_picker = $input.find('> input');
|
557 |
+
var $color_picker_proxy = $input.find('.wp-picker-container input.wp-color-picker').clone();
|
558 |
+
|
559 |
+
$color_picker.after($color_picker_proxy);
|
560 |
+
|
561 |
+
$input.find('.wp-picker-container').remove();
|
562 |
+
|
563 |
+
});
|
564 |
+
|
565 |
+
// Clean Post Object
|
566 |
+
$layout.find('.acf-field-post-object').each(function(){
|
567 |
+
|
568 |
+
var $input = $(this);
|
569 |
+
|
570 |
+
$input.find('> .acf-input span').remove();
|
571 |
+
|
572 |
+
$input.find('> .acf-input select').removeAttr('tabindex aria-hidden').removeClass();
|
573 |
+
|
574 |
+
});
|
575 |
+
|
576 |
+
// Clean Page Link
|
577 |
+
$layout.find('.acf-field-page-link').each(function(){
|
578 |
+
|
579 |
+
var $input = $(this);
|
580 |
+
|
581 |
+
$input.find('> .acf-input span').remove();
|
582 |
+
|
583 |
+
$input.find('> .acf-input select').removeAttr('tabindex aria-hidden').removeClass();
|
584 |
+
|
585 |
+
});
|
586 |
+
|
587 |
+
// Clean Select2
|
588 |
+
$layout.find('.acf-field-select').each(function(){
|
589 |
+
|
590 |
+
var $input = $(this);
|
591 |
+
|
592 |
+
$input.find('> .acf-input span').remove();
|
593 |
+
|
594 |
+
$input.find('> .acf-input select').removeAttr('tabindex aria-hidden').removeClass();
|
595 |
+
|
596 |
+
});
|
597 |
+
|
598 |
+
// Clean FontAwesome
|
599 |
+
$layout.find('.acf-field-font-awesome').each(function(){
|
600 |
+
|
601 |
+
var $input = $(this);
|
602 |
+
|
603 |
+
$input.find('> .acf-input span').remove();
|
604 |
+
|
605 |
+
$input.find('> .acf-input select').removeAttr('tabindex aria-hidden');
|
606 |
+
|
607 |
+
});
|
608 |
+
|
609 |
+
// Clean Tab
|
610 |
+
$layout.find('.acf-tab-wrap').each(function(){
|
611 |
+
|
612 |
+
var $wrap = $(this);
|
613 |
+
|
614 |
+
var $content = $wrap.closest('.acf-fields');
|
615 |
+
|
616 |
+
var tabs = []
|
617 |
+
$.each($wrap.find('li a'), function(){
|
618 |
+
|
619 |
+
tabs.push($(this));
|
620 |
+
|
621 |
+
});
|
622 |
+
|
623 |
+
$content.find('> .acf-field-tab').each(function(){
|
624 |
+
|
625 |
+
$current_tab = $(this);
|
626 |
+
|
627 |
+
$.each(tabs, function(){
|
628 |
+
|
629 |
+
var $this = $(this);
|
630 |
+
|
631 |
+
if($this.attr('data-key') != $current_tab.attr('data-key'))
|
632 |
+
return;
|
633 |
+
|
634 |
+
$current_tab.find('> .acf-input').append($this);
|
635 |
+
|
636 |
+
});
|
637 |
+
|
638 |
+
});
|
639 |
+
|
640 |
+
$wrap.remove();
|
641 |
+
|
642 |
+
});
|
643 |
+
|
644 |
+
// Clean Accordion
|
645 |
+
$layout.find('.acf-field-accordion').each(function(){
|
646 |
+
|
647 |
+
var $input = $(this);
|
648 |
+
|
649 |
+
$input.find('> .acf-accordion-title > .acf-accordion-icon').remove();
|
650 |
+
|
651 |
+
// Append virtual endpoint after each accordion
|
652 |
+
$input.after('<div class="acf-field acf-field-accordion" data-type="accordion"><div class="acf-input"><div class="acf-fields" data-endpoint="1"></div></div></div>');
|
653 |
+
|
654 |
+
});
|
655 |
+
|
656 |
+
}
|
657 |
+
|
658 |
+
// Flexible: Lock Layouts
|
659 |
+
model.acfeOnHover = function(){
|
660 |
+
|
661 |
+
var flexible = this;
|
662 |
+
|
663 |
+
// remove event
|
664 |
+
flexible.off('mouseover');
|
665 |
+
|
666 |
+
}
|
667 |
+
|
668 |
+
/*
|
669 |
+
* Spawn
|
670 |
+
*/
|
671 |
+
acf.addAction('new_field/type=flexible_content', function(flexible){
|
672 |
+
|
673 |
+
// ACFE: Lock
|
674 |
+
if(flexible.has('acfeFlexibleLock')){
|
675 |
+
|
676 |
+
flexible.removeEvents({'mouseover': 'onHover'});
|
677 |
+
|
678 |
+
flexible.addEvents({'mouseover': 'acfeOnHover'});
|
679 |
+
|
680 |
+
}
|
681 |
+
|
682 |
+
// ACFE: Remove Actions
|
683 |
+
if(flexible.has('acfeFlexibleRemoveActions')){
|
684 |
+
|
685 |
+
flexible.$actions().remove();
|
686 |
+
|
687 |
+
flexible.$layouts().find('> .acf-fc-layout-controls > [data-name="add-layout"]').remove();
|
688 |
+
flexible.$layouts().find('> .acf-fc-layout-controls > [data-name="remove-layout"]').remove();
|
689 |
+
flexible.$layouts().find('> .acf-fc-layout-controls > [data-acfe-flexible-control-clone="layout"]').remove();
|
690 |
+
|
691 |
+
flexible.$control().find('> .acfe-flexible-stylised-button').remove();
|
692 |
+
|
693 |
+
|
694 |
+
}
|
695 |
+
|
696 |
+
// ACFE: Remove Ajax Title
|
697 |
+
if(flexible.has('acfeFlexibleRemoveAjaxTitle')){
|
698 |
+
|
699 |
+
flexible.renderLayout = function($layout){};
|
700 |
+
|
701 |
+
|
702 |
+
}
|
703 |
+
|
704 |
+
if(flexible.has('acfeFlexibleCopyPaste')){
|
705 |
+
|
706 |
+
/*
|
707 |
+
* Stylised Button
|
708 |
+
*/
|
709 |
+
if(flexible.has('acfeFlexibleStylisedButton')){
|
710 |
+
|
711 |
+
var $dropdown = $('' +
|
712 |
+
'<a href="#" class="button" style="padding-left:5px;padding-right:5px; margin-left:3px;" data-name="acfe-flexible-control-button">' +
|
713 |
+
' <span class="dashicons dashicons-arrow-down-alt2" style="vertical-align:text-top;width:auto;height:auto;font-size:13px;line-height:20px;"></span>' +
|
714 |
+
'</a>' +
|
715 |
+
|
716 |
+
'<script type="text-html" class="tmpl-acfe-flexible-control-popup">' +
|
717 |
+
' <ul>' +
|
718 |
+
' <li><a href="#" data-acfe-flexible-control-action="copy">Copy layouts</a></li>' +
|
719 |
+
' <li><a href="#" data-acfe-flexible-control-action="paste">Paste layouts</a></li>' +
|
720 |
+
' </ul>' +
|
721 |
+
'</script>');
|
722 |
+
|
723 |
+
// Add button
|
724 |
+
flexible.$el.find('> .acf-input > .acf-flexible-content > .acfe-flexible-stylised-button > .acf-actions > .acf-button').after($dropdown);
|
725 |
+
|
726 |
+
|
727 |
+
}
|
728 |
+
|
729 |
+
/*
|
730 |
+
* Unstylised
|
731 |
+
*/
|
732 |
+
else{
|
733 |
+
|
734 |
+
var $dropdown = $('' +
|
735 |
+
'<a href="#" class="button button-primary" style="padding-left:5px;padding-right:5px; margin-left:3px;" data-name="acfe-flexible-control-button">' +
|
736 |
+
' <span class="dashicons dashicons-arrow-down-alt2" style="vertical-align:text-top;width:auto;height:auto;font-size:13px;line-height:20px;"></span>' +
|
737 |
+
'</a>' +
|
738 |
+
|
739 |
+
'<script type="text-html" class="tmpl-acfe-flexible-control-popup">' +
|
740 |
+
' <ul>' +
|
741 |
+
' <li><a href="#" data-acfe-flexible-control-action="copy">Copy layouts</a></li>' +
|
742 |
+
' <li><a href="#" data-acfe-flexible-control-action="paste">Paste layouts</a></li>' +
|
743 |
+
' </ul>' +
|
744 |
+
'</script>');
|
745 |
+
|
746 |
+
// Add button
|
747 |
+
flexible.$el.find('> .acf-input > .acf-flexible-content > .acf-actions > .acf-button').after($dropdown);
|
748 |
+
|
749 |
+
}
|
750 |
+
|
751 |
+
}
|
752 |
+
|
753 |
+
});
|
754 |
+
|
755 |
+
acf.addAction('acfe/flexible/layouts', function($layout, flexible){
|
756 |
+
|
757 |
+
// vars
|
758 |
+
var $controls = $layout.find('> .acf-fc-layout-controls');
|
759 |
+
var $handle = $layout.find('> .acf-fc-layout-handle');
|
760 |
+
|
761 |
+
// Button: Copy
|
762 |
+
if(flexible.has('acfeFlexibleCopyPaste') && !$controls.has('[data-acfe-flexible-control-copy]').length){
|
763 |
+
|
764 |
+
$controls.prepend('<a class="acf-icon small light acf-js-tooltip acfe-flexible-icon dashicons dashicons-category" href="#" title="Copy layout" data-acfe-flexible-control-copy="' + $layout.attr('data-layout') + '"></a>');
|
765 |
+
|
766 |
+
}
|
767 |
+
|
768 |
+
// Button: Clone
|
769 |
+
if(!$controls.has('[data-acfe-flexible-control-clone]').length){
|
770 |
+
|
771 |
+
$controls.prepend('<a class="acf-icon small light acf-js-tooltip acfe-flexible-icon dashicons dashicons-admin-page" href="#" title="Clone layout" data-acfe-flexible-control-clone="' + $layout.attr('data-layout') + '"></a>');
|
772 |
+
|
773 |
+
}
|
774 |
+
|
775 |
+
if(flexible.has('acfeFlexibleTitleEdition')){
|
776 |
+
|
777 |
+
if(flexible.has('acfeFlexibleModalEdition')){
|
778 |
+
|
779 |
+
var $hidden = $layout.find('> .acfe-modal > .acfe-modal-wrapper > .acfe-modal-content > .acf-fields > .acf-field-acfe-flexible-layout-title > .acf-input > .acf-input-wrap > input');
|
780 |
+
|
781 |
+
}else{
|
782 |
+
|
783 |
+
var $hidden = $layout.find('> .acf-fields > .acf-field-acfe-flexible-layout-title > .acf-input > .acf-input-wrap > input');
|
784 |
+
|
785 |
+
}
|
786 |
+
|
787 |
+
// Hidden Input
|
788 |
+
if($hidden.length){
|
789 |
+
|
790 |
+
// Add Edit Title
|
791 |
+
$hidden.addClass('acfe-flexible-control-title').attr('data-acfe-flexible-control-title-input', 1).insertAfter($handle);
|
792 |
+
|
793 |
+
// Remove legacy field
|
794 |
+
$layout.find('> .acf-fields > .acf-field-acfe-flexible-layout-title').remove();
|
795 |
+
|
796 |
+
}
|
797 |
+
|
798 |
+
}
|
799 |
+
|
800 |
+
|
801 |
+
|
802 |
+
});
|
803 |
+
|
804 |
})(jQuery);
|
assets/acf-extended-fc.css
CHANGED
@@ -1,317 +1,329 @@
|
|
1 |
-
/*
|
2 |
-
* Flexible: Sortable
|
3 |
-
*/
|
4 |
-
.acf-flexible-content > .values > .ui-sortable-placeholder{
|
5 |
-
height:147px;
|
6 |
-
border-width:2px;
|
7 |
-
border-color:#ccc;
|
8 |
-
}
|
9 |
-
|
10 |
-
/*
|
11 |
-
* Flexible: Layout Handle
|
12 |
-
*/
|
13 |
-
.acf-flexible-content .layout .acf-fc-layout-handle {
|
14 |
-
color: #444;
|
15 |
-
font-weight: 600;
|
16 |
-
}
|
17 |
-
|
18 |
-
/*
|
19 |
-
* Flexible: Field Error
|
20 |
-
*/
|
21 |
-
.layout.acfe-flexible-modal-edit-error > .acf-fc-layout-handle{
|
22 |
-
color:#f33b28;
|
23 |
-
}
|
24 |
-
|
25 |
-
.layout.acfe-flexible-modal-edit-error > .acf-fc-layout-handle > .acf-fc-layout-order{
|
26 |
-
background:#f33b28;
|
27 |
-
color:#fff;
|
28 |
-
}
|
29 |
-
|
30 |
-
/*
|
31 |
-
* Flexible: Layout Collapsed
|
32 |
-
*/
|
33 |
-
.acf-field-flexible-content[data-acfe-flexible-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
.acf-field-flexible-content[data-acfe-flexible-
|
39 |
-
|
40 |
-
}
|
41 |
-
|
42 |
-
.acf-field-flexible-content[data-acfe-flexible-
|
43 |
-
cursor:initial;
|
44 |
-
}
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
border-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
.acf-
|
70 |
-
|
71 |
-
}
|
72 |
-
|
73 |
-
.acf-fc-popup.acfe-fc-popup-grey a
|
74 |
-
color: #
|
75 |
-
}
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
-
|
176 |
-
|
177 |
-
|
178 |
-
}
|
179 |
-
|
180 |
-
.layout > .acfe-flexible-collapsed-placeholder
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
.layout > .acfe-flexible-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
.acfe-flexible-layout-thumbnail
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
}
|
249 |
-
|
250 |
-
.acfe-col-
|
251 |
-
height:
|
252 |
-
}
|
253 |
-
|
254 |
-
|
255 |
-
.
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
.
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
}
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
}
|
290 |
-
|
291 |
-
.
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
317 |
}
|
1 |
+
/*
|
2 |
+
* Flexible: Sortable
|
3 |
+
*/
|
4 |
+
.acf-flexible-content > .values > .ui-sortable-placeholder{
|
5 |
+
height:147px;
|
6 |
+
border-width:2px;
|
7 |
+
border-color:#ccc;
|
8 |
+
}
|
9 |
+
|
10 |
+
/*
|
11 |
+
* Flexible: Layout Handle
|
12 |
+
*/
|
13 |
+
.acf-flexible-content .layout .acf-fc-layout-handle {
|
14 |
+
color: #444;
|
15 |
+
font-weight: 600;
|
16 |
+
}
|
17 |
+
|
18 |
+
/*
|
19 |
+
* Flexible: Field Error
|
20 |
+
*/
|
21 |
+
.layout.acfe-flexible-modal-edit-error > .acf-fc-layout-handle{
|
22 |
+
color:#f33b28;
|
23 |
+
}
|
24 |
+
|
25 |
+
.layout.acfe-flexible-modal-edit-error > .acf-fc-layout-handle > .acf-fc-layout-order{
|
26 |
+
background:#f33b28;
|
27 |
+
color:#fff;
|
28 |
+
}
|
29 |
+
|
30 |
+
/*
|
31 |
+
* Flexible: Layout Collapsed
|
32 |
+
*/
|
33 |
+
.acf-field-flexible-content[data-acfe-flexible-modal-edition="1"] > .acf-input > .acf-flexible-content > .values > .layout > .acf-fc-layout-handle{
|
34 |
+
border-bottom-width:0;
|
35 |
+
}
|
36 |
+
|
37 |
+
.acf-field-flexible-content[data-acfe-flexible-placeholder="1"] > .acf-input > .acf-flexible-content > .values > .layout.-collapsed > .acf-fc-layout-handle,
|
38 |
+
.acf-field-flexible-content[data-acfe-flexible-preview="1"] > .acf-input > .acf-flexible-content > .values > .layout.-collapsed > .acf-fc-layout-handle{
|
39 |
+
border-bottom-width:1px;
|
40 |
+
}
|
41 |
+
|
42 |
+
.acf-field-flexible-content[data-acfe-flexible-lock="1"] > .acf-input > .acf-flexible-content > .values > .layout > .acf-fc-layout-handle{
|
43 |
+
cursor:initial;
|
44 |
+
}
|
45 |
+
|
46 |
+
.acf-field-flexible-content[data-acfe-flexible-remove-collapse="1"][data-acfe-flexible-lock!="1"] > .acf-input > .acf-flexible-content > .values > .layout > .acf-fc-layout-handle{
|
47 |
+
cursor:initial;
|
48 |
+
}
|
49 |
+
|
50 |
+
/*
|
51 |
+
* Flexible: Popup Grey
|
52 |
+
*/
|
53 |
+
.acf-fc-popup.top.acfe-fc-popup-grey:before{
|
54 |
+
border-top-color: #e1e1e1;
|
55 |
+
}
|
56 |
+
.acf-tooltip.bottom.acfe-fc-popup-grey:before{
|
57 |
+
border-bottom-color: #e1e1e1;
|
58 |
+
}
|
59 |
+
.acf-fc-popup.acfe-fc-popup-grey{
|
60 |
+
background: #fcfcfc;
|
61 |
+
border-radius: 3px;
|
62 |
+
color: #444;
|
63 |
+
border: 1px solid #e1e1e1;
|
64 |
+
font-size: 13px;
|
65 |
+
}
|
66 |
+
.acf-tooltip.top.acfe-fc-popup-grey{
|
67 |
+
margin-top: -16px;
|
68 |
+
}
|
69 |
+
.acf-tooltip.bottom.acfe-fc-popup-grey{
|
70 |
+
margin-bottom: -16px;
|
71 |
+
}
|
72 |
+
|
73 |
+
.acf-fc-popup.acfe-fc-popup-grey a{
|
74 |
+
color: #444;
|
75 |
+
}
|
76 |
+
|
77 |
+
.acf-fc-popup.acfe-fc-popup-grey a:hover{
|
78 |
+
color: #fff;
|
79 |
+
}
|
80 |
+
|
81 |
+
/*
|
82 |
+
* Flexible Layout: Placeholder
|
83 |
+
*/
|
84 |
+
.layout > .acfe-flexible-collapsed-placeholder{
|
85 |
+
text-align:center;
|
86 |
+
background:#f9f9f9;
|
87 |
+
display:block;
|
88 |
+
text-decoration:none;
|
89 |
+
position:relative;
|
90 |
+
cursor:pointer;
|
91 |
+
}
|
92 |
+
|
93 |
+
.layout > .acfe-flexible-collapsed-placeholder:focus{
|
94 |
+
border-color: #ccc;
|
95 |
+
box-shadow: none;
|
96 |
+
}
|
97 |
+
|
98 |
+
.layout > .acfe-flexible-collapsed-placeholder > .acfe-flexible-placeholder{
|
99 |
+
height:110px;
|
100 |
+
overflow:hidden;
|
101 |
+
text-align:initial;
|
102 |
+
}
|
103 |
+
|
104 |
+
.layout > .acfe-flexible-collapsed-placeholder > button{
|
105 |
+
z-index:2;
|
106 |
+
position:absolute;
|
107 |
+
top:50%;
|
108 |
+
left:50%;
|
109 |
+
transform:translate(-50%, -50%);
|
110 |
+
border-color: #ccd0d4;
|
111 |
+
color: #23282d;
|
112 |
+
border-radius:100px;
|
113 |
+
box-shadow:none;
|
114 |
+
background:#fff;
|
115 |
+
width: 30px;
|
116 |
+
height: 30px;
|
117 |
+
padding:0;
|
118 |
+
display:block;
|
119 |
+
}
|
120 |
+
|
121 |
+
body:not(.acf-admin-5-3) .layout > .acfe-flexible-collapsed-placeholder > button{
|
122 |
+
border-color: #999;
|
123 |
+
}
|
124 |
+
|
125 |
+
.layout > .acfe-flexible-collapsed-placeholder > button:active{
|
126 |
+
transform:translate(-50%, -50%);
|
127 |
+
}
|
128 |
+
|
129 |
+
.layout > .acfe-flexible-collapsed-placeholder > button:focus{
|
130 |
+
border-color: #cccccc;
|
131 |
+
box-shadow: none;
|
132 |
+
}
|
133 |
+
|
134 |
+
.layout > .acfe-flexible-collapsed-placeholder > button span{
|
135 |
+
width: 28px;
|
136 |
+
height: 28px;
|
137 |
+
vertical-align:middle;
|
138 |
+
line-height: 28px;
|
139 |
+
font-size:18px;
|
140 |
+
}
|
141 |
+
|
142 |
+
body:not(.acf-admin-5-3) .layout > .acfe-flexible-collapsed-placeholder > button span{
|
143 |
+
width: 30px;
|
144 |
+
height: 30px;
|
145 |
+
}
|
146 |
+
|
147 |
+
.layout > .acfe-flexible-collapsed-placeholder.acfe-flexible-collapsed-preview{
|
148 |
+
background:none;
|
149 |
+
}
|
150 |
+
|
151 |
+
.layout > .acfe-flexible-collapsed-placeholder.acfe-flexible-collapsed-preview > .acfe-flexible-placeholder{
|
152 |
+
min-height:55px;
|
153 |
+
height:auto;
|
154 |
+
}
|
155 |
+
|
156 |
+
.layout > .acfe-flexible-collapsed-placeholder.acfe-flexible-collapsed-preview > button{
|
157 |
+
display:none;
|
158 |
+
}
|
159 |
+
|
160 |
+
.layout > .acfe-flexible-collapsed-placeholder.acfe-flexible-collapsed-preview:hover > button{
|
161 |
+
display:block;
|
162 |
+
}
|
163 |
+
|
164 |
+
.layout > .acfe-flexible-collapsed-placeholder.acfe-flexible-collapsed-preview.acfe-is-loading{
|
165 |
+
background:#f9f9f9;
|
166 |
+
min-height:110px;
|
167 |
+
}
|
168 |
+
|
169 |
+
.layout > .acfe-flexible-collapsed-placeholder.acfe-flexible-collapsed-preview.acfe-is-loading > .acfe-flexible-placeholder > .spinner{
|
170 |
+
visibility:visible;
|
171 |
+
float:none;
|
172 |
+
position:absolute;
|
173 |
+
top:50%;
|
174 |
+
left:50%;
|
175 |
+
transform:translate(-50%, -50%);
|
176 |
+
margin:0;
|
177 |
+
z-index:10000;
|
178 |
+
}
|
179 |
+
|
180 |
+
.layout > .acfe-flexible-collapsed-placeholder .acfe-flexible-collapsed-overlay{
|
181 |
+
z-index:1;
|
182 |
+
position:absolute;
|
183 |
+
width:100%;
|
184 |
+
height:100%;
|
185 |
+
padding:0;
|
186 |
+
background-color:rgba(255,255,255,0);
|
187 |
+
-webkit-transition: background-color 200ms linear;
|
188 |
+
-ms-transition: background-color 200ms linear;
|
189 |
+
transition: background-color 200ms linear;
|
190 |
+
}
|
191 |
+
|
192 |
+
.layout > .acfe-flexible-collapsed-placeholder:hover .acfe-flexible-collapsed-overlay,
|
193 |
+
.layout > .acfe-flexible-collapsed-placeholder .acfe-flexible-collapsed-overlay.-hover{
|
194 |
+
background-color:rgba(255,255,255,0.7);
|
195 |
+
}
|
196 |
+
|
197 |
+
.layout > .acfe-flexible-collapsed-placeholder.acfe-flexible-collapsed-preview.acfe-is-loading > button span{
|
198 |
+
visibility:hidden;
|
199 |
+
}
|
200 |
+
|
201 |
+
/*
|
202 |
+
* Flexible Layout Collapsed
|
203 |
+
*/
|
204 |
+
.layout > .acfe-flexible-opened-actions{
|
205 |
+
background:#f9f9f9;
|
206 |
+
border-top:1px solid #e1e1e1;
|
207 |
+
padding:12px;
|
208 |
+
text-align:right;
|
209 |
+
}
|
210 |
+
|
211 |
+
/*
|
212 |
+
* Flexible Thumbnails
|
213 |
+
*
|
214 |
+
*/
|
215 |
+
.acfe-flexible-layout-thumbnail{
|
216 |
+
display:block;
|
217 |
+
width:100%;
|
218 |
+
height: 9.8vw; /* 200px / 1080p */
|
219 |
+
background-color:#eee;
|
220 |
+
background-size:cover;
|
221 |
+
background-repeat:no-repeat;
|
222 |
+
background-position:center;
|
223 |
+
position:relative;
|
224 |
+
margin-bottom:15px;
|
225 |
+
}
|
226 |
+
|
227 |
+
.acfe-flexible-layout-thumbnail.acfe-flexible-layout-thumbnail-not-found:after{
|
228 |
+
content: "\f180";
|
229 |
+
font-family: dashicons;
|
230 |
+
display: inline-block;
|
231 |
+
line-height: 1;
|
232 |
+
font-weight: 400;
|
233 |
+
font-style: normal;
|
234 |
+
speak: none;
|
235 |
+
text-decoration: inherit;
|
236 |
+
text-transform: none;
|
237 |
+
text-rendering: auto;
|
238 |
+
-webkit-font-smoothing: antialiased;
|
239 |
+
-moz-osx-font-smoothing: grayscale;
|
240 |
+
vertical-align: top;
|
241 |
+
text-align: center;
|
242 |
+
position:absolute;
|
243 |
+
top:50%;
|
244 |
+
left:50%;
|
245 |
+
transform: translate(-50%, -50%);
|
246 |
+
color:#ccc;
|
247 |
+
font-size: 110px;
|
248 |
+
}
|
249 |
+
|
250 |
+
.acfe-col-2 .acfe-flexible-layout-thumbnail{
|
251 |
+
height:20.5vw;
|
252 |
+
}
|
253 |
+
|
254 |
+
.acfe-col-3 .acfe-flexible-layout-thumbnail{
|
255 |
+
height:13.3vw;
|
256 |
+
}
|
257 |
+
|
258 |
+
.acfe-col-5 .acfe-flexible-layout-thumbnail{
|
259 |
+
height:7.65vw;
|
260 |
+
}
|
261 |
+
|
262 |
+
.acfe-col-6 .acfe-flexible-layout-thumbnail{
|
263 |
+
height:6.2vw;
|
264 |
+
}
|
265 |
+
|
266 |
+
@media only screen and (max-width:960px){
|
267 |
+
.acfe-flexible-layout-thumbnail,
|
268 |
+
.acfe-flex-container .acfe-flexible-layout-thumbnail{
|
269 |
+
height: 18.4vw; /* 200px */
|
270 |
+
}
|
271 |
+
}
|
272 |
+
|
273 |
+
@media only screen and (max-width:720px){
|
274 |
+
.acfe-flexible-layout-thumbnail,
|
275 |
+
.acfe-flex-container .acfe-flexible-layout-thumbnail{
|
276 |
+
height: 37.2vw; /* 200px */
|
277 |
+
}
|
278 |
+
}
|
279 |
+
|
280 |
+
/*
|
281 |
+
* Flexible Thumbnails (no modal)
|
282 |
+
*
|
283 |
+
*/
|
284 |
+
.acfe-flexible-layout-thumbnail.acfe-flexible-layout-thumbnail-no-modal{
|
285 |
+
display:block;
|
286 |
+
width: 230px;
|
287 |
+
height: 103px;
|
288 |
+
background-color:#1f2329;
|
289 |
+
}
|
290 |
+
|
291 |
+
.acfe-flexible-layout-thumbnail.acfe-flexible-layout-thumbnail-no-modal.acfe-flexible-layout-thumbnail-not-found:after{
|
292 |
+
color:#2F353E;
|
293 |
+
}
|
294 |
+
|
295 |
+
/*
|
296 |
+
* Flexible Stylised Button
|
297 |
+
*
|
298 |
+
*/
|
299 |
+
.acf-field.acf-field-flexible-content[data-acfe-flexible-stylised-button="1"] > .acf-input > .acf-flexible-content:not(.empty) > .values{
|
300 |
+
margin-bottom:15px;
|
301 |
+
}
|
302 |
+
|
303 |
+
.acf-field.acf-field-flexible-content > .acf-input > .acf-flexible-content > .acfe-flexible-stylised-button{
|
304 |
+
padding: 40px 20px;
|
305 |
+
border: #ccc dashed 2px;
|
306 |
+
text-align: center;
|
307 |
+
}
|
308 |
+
|
309 |
+
.acf-field.acf-field-flexible-content > .acf-input > .acf-flexible-content > .acfe-flexible-stylised-button > .acf-actions{
|
310 |
+
text-align: center;
|
311 |
+
}
|
312 |
+
|
313 |
+
.acf-field.acf-field-flexible-content > .acf-input > .acf-flexible-content .acf-actions .acf-button .dashicons{
|
314 |
+
width: auto;
|
315 |
+
height: auto;
|
316 |
+
vertical-align: text-top;
|
317 |
+
}
|
318 |
+
|
319 |
+
/*
|
320 |
+
* Flexible Hide Empty Message
|
321 |
+
*
|
322 |
+
*/
|
323 |
+
.acf-field.acf-field-flexible-content[data-acfe-flexible-hide-empty-message="1"] > .acf-input > .acf-flexible-content > .no-value-message{
|
324 |
+
display:none;
|
325 |
+
}
|
326 |
+
|
327 |
+
.acf-field.acf-field-flexible-content[data-acfe-flexible-hide-empty-message="1"] > .acf-input > .acf-flexible-content.-empty > .values{
|
328 |
+
margin-bottom:0;
|
329 |
}
|
assets/acf-extended-fg.css
CHANGED
@@ -1,223 +1,234 @@
|
|
1 |
-
.acf-field-setting-acfe_permissions > .acf-input > .acf-fields,
|
2 |
-
.acf-field-setting-acfe_settings > .acf-input > .acf-fields,
|
3 |
-
.acf-field-setting-acfe_validate > .acf-input > .acf-fields,
|
4 |
-
.acf-field-setting-acfe_update > .acf-input > .acf-fields,
|
5 |
-
|
6 |
-
.acf-field-setting-acfe_bidirectional > .acf-input > .acf-fields,
|
7 |
-
.acf-field-setting-acfe_settings > .acf-input > .acf-fields > .acf-field.acf-field-acfe-settings-rules-or,
|
8 |
-
.acf-field-setting-acfe_validate > .acf-input > .acf-fields > .acf-field.acf-field-acfe-validate-rules-or,
|
9 |
-
.acf-field-setting-acfe_update > .acf-input > .acf-fields > .acf-field.acf-field-acfe-update-functions{
|
10 |
-
border:0;
|
11 |
-
}
|
12 |
-
|
13 |
-
.acf-field-setting-acfe_bidirectional > .acf-input > .acf-fields > .acf-field,
|
14 |
-
.acf-field-setting-acfe_permissions > .acf-input > .acf-fields > .acf-field,
|
15 |
-
.acf-field-setting-acfe_settings > .acf-input > .acf-fields > .acf-field,
|
16 |
-
.acf-field-setting-acfe_validate > .acf-input > .acf-fields > .acf-field,
|
17 |
-
.acf-field-setting-acfe_update > .acf-input > .acf-fields > .acf-field{
|
18 |
-
padding:0;
|
19 |
-
}
|
20 |
-
|
21 |
-
.acf-field-setting-acfe_field_data{
|
22 |
-
display:none;
|
23 |
-
}
|
24 |
-
|
25 |
-
.acf-field-setting-acfe_bidirectional > .acf-input > .acf-fields > .acf-field.acf-field-acfe-bidirectional-enabled > .acf-label,
|
26 |
-
.acf-field-setting-acfe_bidirectional > .acf-input > .acf-fields > .acf-field.acf-field-acfe-bidirectional-related > .acf-label,
|
27 |
-
.acf-field-setting-acfe_settings > .acf-input > .acf-fields > .acf-field.acf-field-acfe-settings-activate > .acf-label,
|
28 |
-
.acf-field-setting-acfe_validate > .acf-input > .acf-fields > .acf-field.acf-field-acfe-validate-activate > .acf-label,
|
29 |
-
.acf-field-setting-acfe_update > .acf-input > .acf-fields > .acf-field.acf-field-acfe-update-activate > .acf-label{
|
30 |
-
display:none;
|
31 |
-
}
|
32 |
-
|
33 |
-
.acf-field-setting-acfe_update > .acf-input .acf-repeater.-empty.-table > table,
|
34 |
-
.acf-field-setting-acfe_settings > .acf-input .acf-repeater.-empty.-table > table,
|
35 |
-
.acf-field-setting-acfe_validate > .acf-input .acf-repeater.-empty.-table > table,
|
36 |
-
.acf-field-acfe-meta > .acf-input .acf-repeater.-empty.-table > table{
|
37 |
-
border:0;
|
38 |
-
display:none;
|
39 |
-
}
|
40 |
-
|
41 |
-
.acf-field-setting-acfe_update > .acf-input .acf-repeater.-empty.-table > table > thead,
|
42 |
-
.acf-field-setting-acfe_settings > .acf-input .acf-repeater.-empty.-table > table > thead,
|
43 |
-
.acf-field-setting-acfe_validate > .acf-input .acf-repeater.-empty.-table > table > thead,
|
44 |
-
.acf-field-acfe-meta > .acf-input .acf-repeater.-empty.-table > table > thead{
|
45 |
-
display:none;
|
46 |
-
}
|
47 |
-
|
48 |
-
.acf-field-setting-acfe_update > .acf-input > .acf-repeater .acf-actions,
|
49 |
-
.acf-field-setting-acfe_settings > .acf-input > .acf-repeater .acf-actions,
|
50 |
-
.acf-field-setting-acfe_validate > .acf-input > .acf-repeater .acf-actions,
|
51 |
-
.acf-field-acfe-meta > .acf-input > .acf-repeater .acf-actions{
|
52 |
-
text-align:left;
|
53 |
-
}
|
54 |
-
|
55 |
-
.acf-
|
56 |
-
.acf-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
border
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
.acf-repeater.-
|
67 |
-
|
68 |
-
border-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
.acf-repeater.-
|
78 |
-
|
79 |
-
border-
|
80 |
-
}
|
81 |
-
|
82 |
-
.acf-repeater.-row > table > tbody > tr > td,
|
83 |
-
.acf-repeater.-block > table > tbody > tr > td{
|
84 |
-
border-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
.acf-repeater.-
|
89 |
-
|
90 |
-
border-
|
91 |
-
}
|
92 |
-
|
93 |
-
.acf-repeater.-row > table > tbody > tr > td:
|
94 |
-
.acf-repeater.-block > table > tbody > tr > td:
|
95 |
-
border-
|
96 |
-
}
|
97 |
-
|
98 |
-
.acf-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
.column-acfe-
|
141 |
-
width:
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
.
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
padding
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
.acf-field-
|
177 |
-
.acf-field-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
.acf-field-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
.acf-field-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
}
|
220 |
-
|
221 |
-
.acf-field-
|
222 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
}
|
1 |
+
.acf-field-setting-acfe_permissions > .acf-input > .acf-fields,
|
2 |
+
.acf-field-setting-acfe_settings > .acf-input > .acf-fields,
|
3 |
+
.acf-field-setting-acfe_validate > .acf-input > .acf-fields,
|
4 |
+
.acf-field-setting-acfe_update > .acf-input > .acf-fields,
|
5 |
+
|
6 |
+
.acf-field-setting-acfe_bidirectional > .acf-input > .acf-fields,
|
7 |
+
.acf-field-setting-acfe_settings > .acf-input > .acf-fields > .acf-field.acf-field-acfe-settings-rules-or,
|
8 |
+
.acf-field-setting-acfe_validate > .acf-input > .acf-fields > .acf-field.acf-field-acfe-validate-rules-or,
|
9 |
+
.acf-field-setting-acfe_update > .acf-input > .acf-fields > .acf-field.acf-field-acfe-update-functions{
|
10 |
+
border:0;
|
11 |
+
}
|
12 |
+
|
13 |
+
.acf-field-setting-acfe_bidirectional > .acf-input > .acf-fields > .acf-field,
|
14 |
+
.acf-field-setting-acfe_permissions > .acf-input > .acf-fields > .acf-field,
|
15 |
+
.acf-field-setting-acfe_settings > .acf-input > .acf-fields > .acf-field,
|
16 |
+
.acf-field-setting-acfe_validate > .acf-input > .acf-fields > .acf-field,
|
17 |
+
.acf-field-setting-acfe_update > .acf-input > .acf-fields > .acf-field{
|
18 |
+
padding:0;
|
19 |
+
}
|
20 |
+
|
21 |
+
.acf-field-setting-acfe_field_data{
|
22 |
+
display:none;
|
23 |
+
}
|
24 |
+
|
25 |
+
.acf-field-setting-acfe_bidirectional > .acf-input > .acf-fields > .acf-field.acf-field-acfe-bidirectional-enabled > .acf-label,
|
26 |
+
.acf-field-setting-acfe_bidirectional > .acf-input > .acf-fields > .acf-field.acf-field-acfe-bidirectional-related > .acf-label,
|
27 |
+
.acf-field-setting-acfe_settings > .acf-input > .acf-fields > .acf-field.acf-field-acfe-settings-activate > .acf-label,
|
28 |
+
.acf-field-setting-acfe_validate > .acf-input > .acf-fields > .acf-field.acf-field-acfe-validate-activate > .acf-label,
|
29 |
+
.acf-field-setting-acfe_update > .acf-input > .acf-fields > .acf-field.acf-field-acfe-update-activate > .acf-label{
|
30 |
+
display:none;
|
31 |
+
}
|
32 |
+
|
33 |
+
.acf-field-setting-acfe_update > .acf-input .acf-repeater.-empty.-table > table,
|
34 |
+
.acf-field-setting-acfe_settings > .acf-input .acf-repeater.-empty.-table > table,
|
35 |
+
.acf-field-setting-acfe_validate > .acf-input .acf-repeater.-empty.-table > table,
|
36 |
+
.acf-field-acfe-meta > .acf-input .acf-repeater.-empty.-table > table{
|
37 |
+
border:0;
|
38 |
+
display:none;
|
39 |
+
}
|
40 |
+
|
41 |
+
.acf-field-setting-acfe_update > .acf-input .acf-repeater.-empty.-table > table > thead,
|
42 |
+
.acf-field-setting-acfe_settings > .acf-input .acf-repeater.-empty.-table > table > thead,
|
43 |
+
.acf-field-setting-acfe_validate > .acf-input .acf-repeater.-empty.-table > table > thead,
|
44 |
+
.acf-field-acfe-meta > .acf-input .acf-repeater.-empty.-table > table > thead{
|
45 |
+
display:none;
|
46 |
+
}
|
47 |
+
|
48 |
+
.acf-field-setting-acfe_update > .acf-input > .acf-repeater .acf-actions,
|
49 |
+
.acf-field-setting-acfe_settings > .acf-input > .acf-repeater .acf-actions,
|
50 |
+
.acf-field-setting-acfe_validate > .acf-input > .acf-repeater .acf-actions,
|
51 |
+
.acf-field-acfe-meta > .acf-input > .acf-repeater .acf-actions{
|
52 |
+
text-align:left;
|
53 |
+
}
|
54 |
+
|
55 |
+
.acf-repeater.-row > table,
|
56 |
+
.acf-repeater.-block > table{
|
57 |
+
border-collapse: separate;
|
58 |
+
border-spacing: 0 15px;
|
59 |
+
background: none;
|
60 |
+
border: 0;
|
61 |
+
margin-top: -15px;
|
62 |
+
margin-bottom: -7px;
|
63 |
+
}
|
64 |
+
|
65 |
+
.acf-repeater.-row > table > *,
|
66 |
+
.acf-repeater.-block > table > *{
|
67 |
+
border-collapse: collapse;
|
68 |
+
border-spacing: 0;
|
69 |
+
}
|
70 |
+
|
71 |
+
.acf-repeater.-row > table > tbody > tr > td,
|
72 |
+
.acf-repeater.-block > table > tbody > tr > td{
|
73 |
+
border-top: 1px solid #ccd0d4 !important;
|
74 |
+
border-bottom: 1px solid #ccd0d4 !important;
|
75 |
+
}
|
76 |
+
|
77 |
+
.acf-repeater.-row > table > tbody > tr > td:first-of-type,
|
78 |
+
.acf-repeater.-block > table > tbody > tr > td:first-of-type{
|
79 |
+
border-left: 1px solid #ccd0d4 !important;
|
80 |
+
}
|
81 |
+
|
82 |
+
.acf-repeater.-row > table > tbody > tr > td:last-of-type,
|
83 |
+
.acf-repeater.-block > table > tbody > tr > td:last-of-type{
|
84 |
+
border-right: 1px solid #ccd0d4 !important;
|
85 |
+
}
|
86 |
+
|
87 |
+
body:not(.acf-admin-5-3) .acf-repeater.-row > table > tbody > tr > td,
|
88 |
+
body:not(.acf-admin-5-3) .acf-repeater.-block > table > tbody > tr > td{
|
89 |
+
border-top: 1px solid #E1E1E1;
|
90 |
+
border-bottom: 1px solid #E1E1E1;
|
91 |
+
}
|
92 |
+
|
93 |
+
body:not(.acf-admin-5-3) .acf-repeater.-row > table > tbody > tr > td:first-of-type,
|
94 |
+
body:not(.acf-admin-5-3) .acf-repeater.-block > table > tbody > tr > td:first-of-type{
|
95 |
+
border-left: 1px solid #E1E1E1;
|
96 |
+
}
|
97 |
+
|
98 |
+
body:not(.acf-admin-5-3) .acf-repeater.-row > table > tbody > tr > td:last-of-type,
|
99 |
+
body:not(.acf-admin-5-3) .acf-repeater.-block > table > tbody > tr > td:last-of-type{
|
100 |
+
border-right: 1px solid #E1E1E1;
|
101 |
+
}
|
102 |
+
|
103 |
+
.acf-field-setting-acfe_bidirectional > .acf-input > .acf-fields > .acf-field.acf-field-acfe-bidirectional-related{
|
104 |
+
margin-left:10px;
|
105 |
+
}
|
106 |
+
|
107 |
+
.acfe_width_auto{
|
108 |
+
width:auto !important;
|
109 |
+
}
|
110 |
+
|
111 |
+
.column-acf-field-group-category{
|
112 |
+
width:125px;
|
113 |
+
}
|
114 |
+
|
115 |
+
td.acf-field-group-category a{
|
116 |
+
word-wrap: break-word;
|
117 |
+
padding: 2px 5px;
|
118 |
+
margin: 0 1px;
|
119 |
+
border-radius:2px;
|
120 |
+
background: rgba(0,0,0,.06);
|
121 |
+
color:#23282d;
|
122 |
+
}
|
123 |
+
|
124 |
+
.column-acfe-locations{
|
125 |
+
width:100px;
|
126 |
+
}
|
127 |
+
|
128 |
+
#acf-field-group-wrap .wp-list-table .column-acf-fg-status{
|
129 |
+
width:70px;
|
130 |
+
}
|
131 |
+
|
132 |
+
#acf-field-group-wrap .wp-list-table .column-acf-fg-count{
|
133 |
+
width:70px;
|
134 |
+
}
|
135 |
+
|
136 |
+
.column-acfe-local{
|
137 |
+
width:50px;
|
138 |
+
}
|
139 |
+
|
140 |
+
.column-acfe-source{
|
141 |
+
width:150px;
|
142 |
+
}
|
143 |
+
|
144 |
+
.column-acfe-autosync-php,
|
145 |
+
.column-acfe-autosync-json{
|
146 |
+
width:65px;
|
147 |
+
text-align:center;
|
148 |
+
}
|
149 |
+
|
150 |
+
.acf-field-image[data-name="acfe_flexible_thumbnail"] > .acf-input > .acf-image-uploader.has-value > .show-if-value.image-wrap{
|
151 |
+
max-width:85px !important;
|
152 |
+
}
|
153 |
+
|
154 |
+
/*
|
155 |
+
* ACFE: Flexible Content
|
156 |
+
*
|
157 |
+
*/
|
158 |
+
|
159 |
+
/* Fix ACF not setting proper border color on Flexible Row Style*/
|
160 |
+
body.acf-admin-5-3 .acf-field-setting-fc_layout .acf-input-wrap.select{
|
161 |
+
border-color: #7e8993;
|
162 |
+
}
|
163 |
+
|
164 |
+
.acf-field-acfe-flexible-modal > .acf-input > .acf-fields{
|
165 |
+
border:0;
|
166 |
+
}
|
167 |
+
|
168 |
+
.acf-field-acfe-flexible-modal > .acf-input > .acf-fields .acf-field-acfe-flexible-modal-enabled{
|
169 |
+
padding:0;
|
170 |
+
}
|
171 |
+
|
172 |
+
.acf-field-acfe-flexible-modal > .acf-input > .acf-fields .acf-field-acfe-flexible-modal-enabled .acf-label{
|
173 |
+
display:none;
|
174 |
+
}
|
175 |
+
|
176 |
+
.acf-field-acfe-flexible-modal > .acf-input > .acf-fields .acf-field-acfe-flexible-modal-title,
|
177 |
+
.acf-field-acfe-flexible-modal > .acf-input > .acf-fields .acf-field-acfe-flexible-modal-col,
|
178 |
+
.acf-field-acfe-flexible-modal > .acf-input > .acf-fields .acf-field-acfe-flexible-modal-categories{
|
179 |
+
padding-bottom:0;
|
180 |
+
padding-left:0;
|
181 |
+
border-top:0;
|
182 |
+
border-left:0 !important;
|
183 |
+
min-height:55px;
|
184 |
+
}
|
185 |
+
|
186 |
+
.acf-field-setting-fc_layout > .acf-input > .acf-fc-meta .acf-field[data-name=acfe_flexible_settings_label],
|
187 |
+
.acf-field-setting-fc_layout > .acf-input > .acf-fc-meta .acf-field[data-name=acfe_flexible_thumbnail],
|
188 |
+
.acf-field-setting-fc_layout > .acf-input > .acf-fc-meta .acf-field[data-name=acfe_flexible_category]{
|
189 |
+
margin:0;
|
190 |
+
}
|
191 |
+
|
192 |
+
.acf-field-setting-fc_layout > .acf-input > .acf-fc-meta .acf-field[data-name=acfe_flexible_settings_label] > .acf-input{
|
193 |
+
margin:0;
|
194 |
+
}
|
195 |
+
|
196 |
+
.acf-field-setting-fc_layout > .acf-input > .acf-fc-meta > .acf-fc-meta-label:first-of-type{
|
197 |
+
margin:0;
|
198 |
+
}
|
199 |
+
|
200 |
+
/*
|
201 |
+
* ACFE Column
|
202 |
+
*/
|
203 |
+
.acf-field-object-acfe-column .acf-field-setting-label,
|
204 |
+
.acf-field-object-acfe-column .acf-field-setting-name,
|
205 |
+
.acf-field-object-acfe-column .acf-field-setting-instructions,
|
206 |
+
.acf-field-object-acfe-column .acf-field-setting-required,
|
207 |
+
.acf-field-object-acfe-column .acf-field-setting-warning,
|
208 |
+
.acf-field-object-acfe-column .acf-field-setting-wrapper{
|
209 |
+
display: none;
|
210 |
+
}
|
211 |
+
|
212 |
+
.acf-field-object + .acf-field-object-acfe-column:before {
|
213 |
+
display: block;
|
214 |
+
content: "";
|
215 |
+
height: 5px;
|
216 |
+
width: 100%;
|
217 |
+
background: #f9f9f9;
|
218 |
+
border-bottom: #f0f0f0 solid 1px;
|
219 |
+
}
|
220 |
+
|
221 |
+
.acf-field-object-acfe-column .li-field-name{
|
222 |
+
visibility: hidden;
|
223 |
+
}
|
224 |
+
|
225 |
+
/*
|
226 |
+
* ACFE Taxonomy Terms
|
227 |
+
*/
|
228 |
+
.acf-field-setting-allow_terms > .acf-input > ul > li:first-of-type{
|
229 |
+
width: calc(100% - 110px);
|
230 |
+
}
|
231 |
+
|
232 |
+
.acf-field-setting-allow_terms > .acf-input > ul > li:last-of-type{
|
233 |
+
width: 110px;
|
234 |
}
|
assets/acf-extended-fg.js
CHANGED
@@ -1,27 +1,31 @@
|
|
1 |
-
jQuery(document).ready(function($){
|
2 |
-
|
3 |
-
$('.button.edit-field').each(function(k, v){
|
4 |
-
var tbody = $(this).closest('tbody');
|
5 |
-
$(tbody).find('.acfe_modal_open:first').insertAfter($(this));
|
6 |
-
$(tbody).find('.acfe-modal:first').appendTo($('body'));
|
7 |
-
$(tbody).find('tr.acf-field-setting-acfe_field_data:first').remove();
|
8 |
-
});
|
9 |
-
|
10 |
-
$('.acfe_modal_open').click(function(e){
|
11 |
-
|
12 |
-
e.preventDefault();
|
13 |
-
|
14 |
-
var key = $(this).attr('data-modal-key');
|
15 |
-
|
16 |
-
var $modal = $('.acfe-modal[data-modal-key=' + key + ']');
|
17 |
-
|
18 |
-
acfe.modal.open($modal, {
|
19 |
-
title: 'Data',
|
20 |
-
size: 'small'
|
21 |
-
});
|
22 |
-
|
23 |
-
});
|
24 |
-
|
25 |
-
$('.acf-field[data-name="active"]').after($('.acf-field[data-name="acfe_form"]'));
|
26 |
-
|
|
|
|
|
|
|
|
|
27 |
});
|
1 |
+
jQuery(document).ready(function($){
|
2 |
+
|
3 |
+
$('.button.edit-field').each(function(k, v){
|
4 |
+
var tbody = $(this).closest('tbody');
|
5 |
+
$(tbody).find('.acfe_modal_open:first').insertAfter($(this));
|
6 |
+
$(tbody).find('.acfe-modal:first').appendTo($('body'));
|
7 |
+
$(tbody).find('tr.acf-field-setting-acfe_field_data:first').remove();
|
8 |
+
});
|
9 |
+
|
10 |
+
$('.acfe_modal_open').click(function(e){
|
11 |
+
|
12 |
+
e.preventDefault();
|
13 |
+
|
14 |
+
var key = $(this).attr('data-modal-key');
|
15 |
+
|
16 |
+
var $modal = $('.acfe-modal[data-modal-key=' + key + ']');
|
17 |
+
|
18 |
+
acfe.modal.open($modal, {
|
19 |
+
title: 'Data',
|
20 |
+
size: 'small'
|
21 |
+
});
|
22 |
+
|
23 |
+
});
|
24 |
+
|
25 |
+
$('.acf-field[data-name="active"]').after($('.acf-field[data-name="acfe_form"]'));
|
26 |
+
|
27 |
+
$('.acf-field-setting-acfe_settings > .acf-input > .acf-repeater .acf-actions .acf-button').removeClass('button-primary');
|
28 |
+
$('.acf-field-setting-acfe_validate > .acf-input > .acf-repeater .acf-actions .acf-button').removeClass('button-primary');
|
29 |
+
$('.acf-field-acfe-meta > .acf-input > .acf-repeater .acf-actions .acf-button').removeClass('button-primary');
|
30 |
+
|
31 |
});
|
assets/acf-extended-fields.js
CHANGED
@@ -1,719 +1,803 @@
|
|
1 |
-
function acfe_recaptcha(){
|
2 |
-
|
3 |
-
(function($){
|
4 |
-
|
5 |
-
if(typeof acf === 'undefined')
|
6 |
-
return;
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
'
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
this.
|
160 |
-
this.
|
161 |
-
|
162 |
-
this.
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
this.editor.
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
this
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
/**
|
256 |
-
* Field: Slug
|
257 |
-
*/
|
258 |
-
var ACFE_Slug = acf.Field.extend({
|
259 |
-
|
260 |
-
type: 'acfe_slug',
|
261 |
-
|
262 |
-
events: {
|
263 |
-
'input input': 'onInput',
|
264 |
-
'focusout input': 'onFocusOut',
|
265 |
-
},
|
266 |
-
|
267 |
-
onInput: function(e, $el){
|
268 |
-
|
269 |
-
$el.val($el.val().toLowerCase()
|
270 |
-
.replace(/\s+/g, '-') // Replace spaces with -
|
271 |
-
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
|
272 |
-
.replace(/\-\-+/g, '-') // Replace multiple - with single -
|
273 |
-
.replace(/\_\_+/g, '_') // Replace multiple _ with single _
|
274 |
-
.replace(/^-+/, '')); // Trim - from start of text
|
275 |
-
|
276 |
-
},
|
277 |
-
|
278 |
-
onFocusOut: function(e, $el){
|
279 |
-
|
280 |
-
$el.val($el.val().toLowerCase()
|
281 |
-
.replace(/-+$/, '') // Trim - from end of text
|
282 |
-
.replace(/_+$/, '')); // Trim _ from end of text
|
283 |
-
|
284 |
-
},
|
285 |
-
|
286 |
-
});
|
287 |
-
|
288 |
-
acf.registerFieldType(ACFE_Slug);
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
'click
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
'click a[data-name="
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
this.$('.input-
|
440 |
-
this.$('.input-
|
441 |
-
this.$('.input-
|
442 |
-
this.$('.input-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
var
|
453 |
-
|
454 |
-
var
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
acf.addFilter('select2_ajax_data', function(ajaxData, data, $el, field, select){
|
635 |
-
|
636 |
-
if(ajaxData.action !== '
|
637 |
-
return ajaxData;
|
638 |
-
|
639 |
-
// Taxonomies
|
640 |
-
var $taxonomies = $el.closest('.acf-field-settings').find('> .acf-field-setting-taxonomy > .acf-input > select > option:selected');
|
641 |
-
|
642 |
-
var tax = [];
|
643 |
-
|
644 |
-
$taxonomies.each(function(){
|
645 |
-
tax.push($(this).val());
|
646 |
-
});
|
647 |
-
|
648 |
-
ajaxData.taxonomies = tax;
|
649 |
-
|
650 |
-
// Terms level
|
651 |
-
var $level = $el.closest('.acf-field-settings').find('> .acf-field-setting-allow_terms > .acf-input input[type="number"]');
|
652 |
-
|
653 |
-
ajaxData.level = $level.val();
|
654 |
-
|
655 |
-
return ajaxData;
|
656 |
-
|
657 |
-
});
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
719 |
})(jQuery);
|
1 |
+
function acfe_recaptcha(){
|
2 |
+
|
3 |
+
(function($){
|
4 |
+
|
5 |
+
if(typeof acf === 'undefined')
|
6 |
+
return;
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Field: reCaptcha (render)
|
10 |
+
*/
|
11 |
+
$.each(acf.getFields({type: 'acfe_recaptcha'}), function(i, field){
|
12 |
+
|
13 |
+
field.render();
|
14 |
+
|
15 |
+
});
|
16 |
+
|
17 |
+
})(jQuery);
|
18 |
+
|
19 |
+
}
|
20 |
+
|
21 |
+
(function($){
|
22 |
+
|
23 |
+
if(typeof acf === 'undefined')
|
24 |
+
return;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Field: reCaptcha
|
28 |
+
*/
|
29 |
+
var reCaptcha = acf.Field.extend({
|
30 |
+
|
31 |
+
type: 'acfe_recaptcha',
|
32 |
+
|
33 |
+
actions: {
|
34 |
+
'validation_failure' : 'validationFailure'
|
35 |
+
},
|
36 |
+
|
37 |
+
$control: function(){
|
38 |
+
return this.$('.acfe-field-recaptcha');
|
39 |
+
},
|
40 |
+
|
41 |
+
$input: function(){
|
42 |
+
return this.$('input[type="hidden"]');
|
43 |
+
},
|
44 |
+
|
45 |
+
$selector: function(){
|
46 |
+
return this.$control().find('> div');
|
47 |
+
},
|
48 |
+
|
49 |
+
selector: function(){
|
50 |
+
return this.$selector()[0];
|
51 |
+
},
|
52 |
+
|
53 |
+
version: function(){
|
54 |
+
return this.get('version');
|
55 |
+
},
|
56 |
+
|
57 |
+
render: function(){
|
58 |
+
|
59 |
+
var field = this;
|
60 |
+
|
61 |
+
if(this.version() === 'v2'){
|
62 |
+
|
63 |
+
this.recaptcha = grecaptcha.render(this.selector(), {
|
64 |
+
'sitekey': this.$control().data('site-key'),
|
65 |
+
'theme': this.$control().data('size'),
|
66 |
+
'size': this.$control().data('theme'),
|
67 |
+
|
68 |
+
|
69 |
+
'callback': function(response){
|
70 |
+
|
71 |
+
field.$input().val(response).change();
|
72 |
+
field.$input().closest('.acf-input').find('> .acf-notice.-error').hide();
|
73 |
+
|
74 |
+
},
|
75 |
+
|
76 |
+
'error-callback': function(){
|
77 |
+
|
78 |
+
field.$input().val('error').change();
|
79 |
+
|
80 |
+
},
|
81 |
+
|
82 |
+
'expired-callback': function(){
|
83 |
+
|
84 |
+
field.$input().val('expired').change();
|
85 |
+
|
86 |
+
}
|
87 |
+
});
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
else if(this.version() === 'v3'){
|
92 |
+
|
93 |
+
this.recaptcha = function(){
|
94 |
+
|
95 |
+
grecaptcha.ready(function(){
|
96 |
+
grecaptcha.execute(this.$control().data('site-key'), {action: 'homepage'}).then(function(response){
|
97 |
+
|
98 |
+
field.$input().val(response).change();
|
99 |
+
field.$input().closest('.acf-input').find('> .acf-notice.-error').hide();
|
100 |
+
|
101 |
+
});
|
102 |
+
});
|
103 |
+
|
104 |
+
};
|
105 |
+
|
106 |
+
}
|
107 |
+
|
108 |
+
},
|
109 |
+
|
110 |
+
validationFailure: function($form){
|
111 |
+
|
112 |
+
grecaptcha.reset(this.recaptcha);
|
113 |
+
|
114 |
+
}
|
115 |
+
|
116 |
+
});
|
117 |
+
|
118 |
+
acf.registerFieldType(reCaptcha);
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Field: Code Editor
|
122 |
+
*/
|
123 |
+
var CodeEditor = acf.Field.extend({
|
124 |
+
|
125 |
+
wait: 'ready',
|
126 |
+
|
127 |
+
type: 'acfe_code_editor',
|
128 |
+
|
129 |
+
events: {
|
130 |
+
'showField': 'onShow',
|
131 |
+
},
|
132 |
+
|
133 |
+
$control: function(){
|
134 |
+
|
135 |
+
return this.$el.find('> .acf-input > .acf-input-wrap');
|
136 |
+
|
137 |
+
},
|
138 |
+
|
139 |
+
$input: function(){
|
140 |
+
|
141 |
+
return this.$el.find('> .acf-input > .acf-input-wrap > textarea');
|
142 |
+
|
143 |
+
},
|
144 |
+
|
145 |
+
input: function(){
|
146 |
+
|
147 |
+
return this.$input()[0];
|
148 |
+
|
149 |
+
},
|
150 |
+
|
151 |
+
rows: function(){
|
152 |
+
|
153 |
+
return this.$input().attr('rows');
|
154 |
+
|
155 |
+
},
|
156 |
+
|
157 |
+
initialize: function(){
|
158 |
+
|
159 |
+
this.rows = this.$input().attr('rows');
|
160 |
+
this.mode = this.$control().data('mode');
|
161 |
+
this.lines = this.$control().data('lines');
|
162 |
+
this.indentUnit = this.$control().data('indent_unit');
|
163 |
+
|
164 |
+
this.editor = wp.CodeMirror.fromTextArea(this.input(), {
|
165 |
+
lineNumbers: this.lines,
|
166 |
+
lineWrapping: true,
|
167 |
+
styleActiveLine: false,
|
168 |
+
continueComments: true,
|
169 |
+
indentUnit: this.indentUnit,
|
170 |
+
tabSize: 1,
|
171 |
+
indentWithTabs: true,
|
172 |
+
mode: this.mode,
|
173 |
+
//mode: 'htmlmixed',
|
174 |
+
extraKeys: {
|
175 |
+
Tab: function(cm){
|
176 |
+
cm.execCommand("indentMore")
|
177 |
+
},
|
178 |
+
"Shift-Tab": function(cm){
|
179 |
+
cm.execCommand("indentLess")
|
180 |
+
},
|
181 |
+
},
|
182 |
+
});
|
183 |
+
|
184 |
+
if(this.rows){
|
185 |
+
|
186 |
+
this.editor.getScrollerElement().style.minHeight = this.rows * 22 + 'px';
|
187 |
+
|
188 |
+
this.editor.refresh();
|
189 |
+
|
190 |
+
}
|
191 |
+
|
192 |
+
field = this;
|
193 |
+
|
194 |
+
this.editor.on('change', function(){
|
195 |
+
|
196 |
+
field.editor.save();
|
197 |
+
|
198 |
+
});
|
199 |
+
|
200 |
+
},
|
201 |
+
|
202 |
+
onShow: function(){
|
203 |
+
|
204 |
+
if(this.editor){
|
205 |
+
|
206 |
+
this.editor.refresh();
|
207 |
+
|
208 |
+
}
|
209 |
+
|
210 |
+
}
|
211 |
+
|
212 |
+
});
|
213 |
+
|
214 |
+
acf.registerFieldType(CodeEditor);
|
215 |
+
|
216 |
+
/**
|
217 |
+
* Field: Textarea
|
218 |
+
*/
|
219 |
+
var Textarea = acf.Field.extend({
|
220 |
+
|
221 |
+
type: 'textarea',
|
222 |
+
|
223 |
+
events: {
|
224 |
+
'keydown textarea': 'onInput',
|
225 |
+
},
|
226 |
+
|
227 |
+
onInput: function(e, $el){
|
228 |
+
|
229 |
+
if(!this.has('acfeTextareaCode'))
|
230 |
+
return;
|
231 |
+
|
232 |
+
if(e.keyCode !== 9)
|
233 |
+
return;
|
234 |
+
|
235 |
+
e.preventDefault();
|
236 |
+
|
237 |
+
var input = this.$el.find('textarea')[0];
|
238 |
+
|
239 |
+
var s = input.selectionStart;
|
240 |
+
|
241 |
+
this.$el.find('textarea').val(function(i, v){
|
242 |
+
|
243 |
+
return v.substring(0, s) + " " + v.substring(input.selectionEnd)
|
244 |
+
|
245 |
+
});
|
246 |
+
|
247 |
+
input.selectionEnd = s + 4;
|
248 |
+
|
249 |
+
},
|
250 |
+
|
251 |
+
});
|
252 |
+
|
253 |
+
acf.registerFieldType(Textarea);
|
254 |
+
|
255 |
+
/**
|
256 |
+
* Field: Slug
|
257 |
+
*/
|
258 |
+
var ACFE_Slug = acf.Field.extend({
|
259 |
+
|
260 |
+
type: 'acfe_slug',
|
261 |
+
|
262 |
+
events: {
|
263 |
+
'input input': 'onInput',
|
264 |
+
'focusout input': 'onFocusOut',
|
265 |
+
},
|
266 |
+
|
267 |
+
onInput: function(e, $el){
|
268 |
+
|
269 |
+
$el.val($el.val().toLowerCase()
|
270 |
+
.replace(/\s+/g, '-') // Replace spaces with -
|
271 |
+
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
|
272 |
+
.replace(/\-\-+/g, '-') // Replace multiple - with single -
|
273 |
+
.replace(/\_\_+/g, '_') // Replace multiple _ with single _
|
274 |
+
.replace(/^-+/, '')); // Trim - from start of text
|
275 |
+
|
276 |
+
},
|
277 |
+
|
278 |
+
onFocusOut: function(e, $el){
|
279 |
+
|
280 |
+
$el.val($el.val().toLowerCase()
|
281 |
+
.replace(/-+$/, '') // Trim - from end of text
|
282 |
+
.replace(/_+$/, '')); // Trim _ from end of text
|
283 |
+
|
284 |
+
},
|
285 |
+
|
286 |
+
});
|
287 |
+
|
288 |
+
acf.registerFieldType(ACFE_Slug);
|
289 |
+
|
290 |
+
/**
|
291 |
+
* Field: Button
|
292 |
+
*/
|
293 |
+
var ACFE_Button = acf.Field.extend({
|
294 |
+
|
295 |
+
type: 'acfe_button',
|
296 |
+
|
297 |
+
events: {
|
298 |
+
'click input': 'onClick',
|
299 |
+
'click button': 'onClick',
|
300 |
+
},
|
301 |
+
|
302 |
+
$input: function(){
|
303 |
+
|
304 |
+
if(this.$('input').length){
|
305 |
+
|
306 |
+
return this.$('input');
|
307 |
+
|
308 |
+
}else if(this.$('button').length){
|
309 |
+
|
310 |
+
return this.$('button');
|
311 |
+
|
312 |
+
}
|
313 |
+
|
314 |
+
},
|
315 |
+
|
316 |
+
initialize: function(){
|
317 |
+
|
318 |
+
// vars
|
319 |
+
var $button = this.$input();
|
320 |
+
|
321 |
+
// inherit data
|
322 |
+
this.inherit($button);
|
323 |
+
|
324 |
+
},
|
325 |
+
|
326 |
+
onClick: function(e, $el){
|
327 |
+
|
328 |
+
if(this.get('ajax')){
|
329 |
+
|
330 |
+
e.preventDefault();
|
331 |
+
|
332 |
+
// serialize form data
|
333 |
+
var data = {
|
334 |
+
action: 'acfe/fields/button',
|
335 |
+
field_name: this.get('name'),
|
336 |
+
field_key: this.get('key')
|
337 |
+
};
|
338 |
+
|
339 |
+
acf.doAction('acfe/fields/button/before_ajax', this.$el, data);
|
340 |
+
|
341 |
+
// ajax
|
342 |
+
$.ajax({
|
343 |
+
url: acf.get('ajaxurl'),
|
344 |
+
data: acf.prepareForAjax(data),
|
345 |
+
type: 'post',
|
346 |
+
dataType: 'json',
|
347 |
+
context: this,
|
348 |
+
success: function(response){
|
349 |
+
|
350 |
+
acf.doAction('acfe/fields/button/ajax_success', response, this.$el, data);
|
351 |
+
|
352 |
+
}
|
353 |
+
});
|
354 |
+
|
355 |
+
}
|
356 |
+
|
357 |
+
}
|
358 |
+
|
359 |
+
});
|
360 |
+
|
361 |
+
acf.registerFieldType(ACFE_Button);
|
362 |
+
|
363 |
+
/**
|
364 |
+
* Field: Advanced Link
|
365 |
+
*/
|
366 |
+
var ACFE_Advanced_Link = acf.Field.extend({
|
367 |
+
|
368 |
+
type: 'acfe_advanced_link',
|
369 |
+
|
370 |
+
events: {
|
371 |
+
'click a[data-name="add"]': 'onClickEdit',
|
372 |
+
'click a[data-name="edit"]': 'onClickEdit',
|
373 |
+
'click a[data-name="remove"]': 'onClickRemove',
|
374 |
+
},
|
375 |
+
|
376 |
+
$control: function(){
|
377 |
+
return this.$('.acf-link');
|
378 |
+
},
|
379 |
+
|
380 |
+
initialize: function(){
|
381 |
+
|
382 |
+
this.on('change', '.input-post', this.onPostChange);
|
383 |
+
|
384 |
+
},
|
385 |
+
|
386 |
+
getValue: function(){
|
387 |
+
|
388 |
+
// return
|
389 |
+
var data = {
|
390 |
+
type: this.$('.input-type :checked').val(),
|
391 |
+
title: this.$('.input-title').val(),
|
392 |
+
url: this.$('.input-url').val(),
|
393 |
+
post: this.$('.input-post :selected').text(),
|
394 |
+
target: this.$('.input-target').is(':checked')
|
395 |
+
};
|
396 |
+
|
397 |
+
if(data.type === 'post'){
|
398 |
+
|
399 |
+
data.url = data.post;
|
400 |
+
|
401 |
+
}
|
402 |
+
|
403 |
+
return data;
|
404 |
+
|
405 |
+
},
|
406 |
+
|
407 |
+
setValue: function( val ){
|
408 |
+
|
409 |
+
// default
|
410 |
+
val = acf.parseArgs(val, {
|
411 |
+
remove: false,
|
412 |
+
title: '',
|
413 |
+
url: '',
|
414 |
+
target: false
|
415 |
+
});
|
416 |
+
|
417 |
+
// vars
|
418 |
+
var $div = this.$control();
|
419 |
+
|
420 |
+
// remove class
|
421 |
+
$div.removeClass('-value -external');
|
422 |
+
|
423 |
+
// add class
|
424 |
+
if(val.url)
|
425 |
+
$div.addClass('-value');
|
426 |
+
|
427 |
+
if(val.target)
|
428 |
+
$div.addClass('-external');
|
429 |
+
|
430 |
+
// update text
|
431 |
+
this.$('.link-title').html( val.title );
|
432 |
+
this.$('.link-url').attr('href', val.url).html( val.url );
|
433 |
+
|
434 |
+
// remove inputs data
|
435 |
+
if(val.remove){
|
436 |
+
|
437 |
+
this.$('.input-type :checked').prop('checked', false);
|
438 |
+
this.$('.input-type [value="url"]').prop('checked', true).trigger('change');
|
439 |
+
this.$('.input-title').val('');
|
440 |
+
this.$('.input-target').prop('checked', false);
|
441 |
+
this.$('.input-url').val('').trigger('change');
|
442 |
+
this.$('.input-post').val('').trigger('change');
|
443 |
+
|
444 |
+
}
|
445 |
+
|
446 |
+
},
|
447 |
+
|
448 |
+
onClickEdit: function(e, $el){
|
449 |
+
|
450 |
+
var $modal = $el.closest('.acf-input').find('.acfe-modal');
|
451 |
+
|
452 |
+
var title = $modal.attr('data-modal-title');
|
453 |
+
|
454 |
+
var model = this;
|
455 |
+
|
456 |
+
acfe.modal.open($modal, {
|
457 |
+
title: title,
|
458 |
+
size: 'small',
|
459 |
+
onClose: function(){
|
460 |
+
model.onChange();
|
461 |
+
}
|
462 |
+
});
|
463 |
+
|
464 |
+
},
|
465 |
+
|
466 |
+
onClickRemove: function( e, $el ){
|
467 |
+
|
468 |
+
this.setValue({
|
469 |
+
remove: true
|
470 |
+
});
|
471 |
+
|
472 |
+
},
|
473 |
+
|
474 |
+
onChange: function( e, $el ){
|
475 |
+
|
476 |
+
// get the changed value
|
477 |
+
var val = this.getValue();
|
478 |
+
|
479 |
+
// update inputs
|
480 |
+
this.setValue(val);
|
481 |
+
|
482 |
+
},
|
483 |
+
|
484 |
+
onPostChange: function(e){
|
485 |
+
|
486 |
+
var $el = $(this);
|
487 |
+
var model = acf.getInstance($el.closest('.acf-field-acfe-advanced-link'));
|
488 |
+
|
489 |
+
},
|
490 |
+
|
491 |
+
});
|
492 |
+
|
493 |
+
acf.registerFieldType(ACFE_Advanced_Link);
|
494 |
+
|
495 |
+
/**
|
496 |
+
* Field: Group
|
497 |
+
*/
|
498 |
+
var Group = acf.Field.extend({
|
499 |
+
|
500 |
+
type: 'group',
|
501 |
+
|
502 |
+
events: {
|
503 |
+
'click [data-name="edit"]': 'onClick',
|
504 |
+
},
|
505 |
+
|
506 |
+
initialize: function(){
|
507 |
+
|
508 |
+
if(this.has('acfeGroupModal')){
|
509 |
+
|
510 |
+
var edit = this.get('acfeGroupModalButton');
|
511 |
+
|
512 |
+
this.$el.find('> .acf-input > .acf-fields, > .acf-input > .acf-table').wrapAll('<div class="acfe-modal"><div class="acfe-modal-wrapper"><div class="acfe-modal-content"></div></div></div>');
|
513 |
+
this.$el.find('> .acf-input').append('<a data-name="edit" class="acf-button button" href="#">' + edit + '</a>');
|
514 |
+
|
515 |
+
}
|
516 |
+
|
517 |
+
},
|
518 |
+
|
519 |
+
onClick: function(e, $el){
|
520 |
+
|
521 |
+
var title = this.$el.find('> .acf-label').text().trim();
|
522 |
+
var $modal = this.$el.find('> .acf-input > .acfe-modal');
|
523 |
+
|
524 |
+
if(!title.length)
|
525 |
+
title = this.get('acfeGroupModalButton');
|
526 |
+
|
527 |
+
// Open modal
|
528 |
+
acfe.modal.open($modal, {
|
529 |
+
title: title
|
530 |
+
});
|
531 |
+
|
532 |
+
},
|
533 |
+
|
534 |
+
});
|
535 |
+
|
536 |
+
acf.registerFieldType(Group);
|
537 |
+
|
538 |
+
/**
|
539 |
+
* Field: Clone
|
540 |
+
*/
|
541 |
+
var Clone = acf.Field.extend({
|
542 |
+
|
543 |
+
type: 'clone',
|
544 |
+
|
545 |
+
events: {
|
546 |
+
'click [data-name="edit"]': 'onClick',
|
547 |
+
},
|
548 |
+
|
549 |
+
initialize: function(){
|
550 |
+
|
551 |
+
if(this.has('acfeCloneModal')){
|
552 |
+
|
553 |
+
var edit = this.get('acfeCloneModalButton');
|
554 |
+
|
555 |
+
this.$el.find('> .acf-input > .acf-fields, > .acf-input > .acf-table').wrapAll('<div class="acfe-modal"><div class="acfe-modal-wrapper"><div class="acfe-modal-content"></div></div></div>');
|
556 |
+
this.$el.find('> .acf-input').append('<a data-name="edit" class="acf-button button" href="#">' + edit + '</a>');
|
557 |
+
|
558 |
+
}
|
559 |
+
|
560 |
+
},
|
561 |
+
|
562 |
+
onClick: function(e, $el){
|
563 |
+
|
564 |
+
var title = this.$el.find('> .acf-label').text().trim();
|
565 |
+
var $modal = this.$el.find('> .acf-input > .acfe-modal');
|
566 |
+
|
567 |
+
if(!title.length)
|
568 |
+
title = this.get('acfeCloneModalButton');
|
569 |
+
|
570 |
+
// Open modal
|
571 |
+
acfe.modal.open($modal, {
|
572 |
+
title: title
|
573 |
+
});
|
574 |
+
|
575 |
+
},
|
576 |
+
|
577 |
+
});
|
578 |
+
|
579 |
+
acf.registerFieldType(Clone);
|
580 |
+
|
581 |
+
/**
|
582 |
+
* Field: Column
|
583 |
+
*/
|
584 |
+
var Column = acf.Field.extend({
|
585 |
+
|
586 |
+
wait: 'new_field',
|
587 |
+
|
588 |
+
type: 'acfe_column',
|
589 |
+
|
590 |
+
$control: function(){
|
591 |
+
return this.$('.acf-fields:first');
|
592 |
+
},
|
593 |
+
|
594 |
+
initialize: function(){
|
595 |
+
|
596 |
+
if(this.$el.is('td')){
|
597 |
+
|
598 |
+
var $table = this.$el.closest('.acf-table').find('th[data-type="acfe_column"]').remove();
|
599 |
+
this.remove();
|
600 |
+
|
601 |
+
}
|
602 |
+
|
603 |
+
if(this.get('endpoint')){
|
604 |
+
|
605 |
+
this.$el.find('> .acf-label').remove();
|
606 |
+
this.$el.find('> .acf-input').remove();
|
607 |
+
|
608 |
+
return;
|
609 |
+
|
610 |
+
}
|
611 |
+
|
612 |
+
var $field = this.$el;
|
613 |
+
var $label = this.$el.find('> .acf-label');
|
614 |
+
var $input = this.$inputWrap();
|
615 |
+
var $wrap = this.$control();
|
616 |
+
|
617 |
+
$label.remove();
|
618 |
+
|
619 |
+
var $parent = $field.parent();
|
620 |
+
$wrap.addClass($parent.hasClass('-left') ? '-left' : '');
|
621 |
+
$wrap.addClass($parent.hasClass('-clear') ? '-clear' : '');
|
622 |
+
|
623 |
+
$wrap.append($field.nextUntil('.acf-field-acfe-column', '.acf-field'));
|
624 |
+
|
625 |
+
}
|
626 |
+
|
627 |
+
});
|
628 |
+
|
629 |
+
acf.registerFieldType(Column);
|
630 |
+
|
631 |
+
/**
|
632 |
+
* Field: Taxonomy Terms - Ajax
|
633 |
+
*/
|
634 |
+
acf.addFilter('select2_ajax_data', function(ajaxData, data, $el, field, select){
|
635 |
+
|
636 |
+
if(ajaxData.action !== 'acfe/fields/taxonomy_terms/allow_query')
|
637 |
+
return ajaxData;
|
638 |
+
|
639 |
+
// Taxonomies
|
640 |
+
var $taxonomies = $el.closest('.acf-field-settings').find('> .acf-field-setting-taxonomy > .acf-input > select > option:selected');
|
641 |
+
|
642 |
+
var tax = [];
|
643 |
+
|
644 |
+
$taxonomies.each(function(){
|
645 |
+
tax.push($(this).val());
|
646 |
+
});
|
647 |
+
|
648 |
+
ajaxData.taxonomies = tax;
|
649 |
+
|
650 |
+
// Terms level
|
651 |
+
var $level = $el.closest('.acf-field-settings').find('> .acf-field-setting-allow_terms > .acf-input input[type="number"]');
|
652 |
+
|
653 |
+
ajaxData.level = $level.val();
|
654 |
+
|
655 |
+
return ajaxData;
|
656 |
+
|
657 |
+
});
|
658 |
+
|
659 |
+
/**
|
660 |
+
* Field: Post Object - Ajax
|
661 |
+
*/
|
662 |
+
acf.addFilter('select2_ajax_data', function(ajaxData, data, $el, field, select){
|
663 |
+
|
664 |
+
if(field.get('key') !== 'post' || field.get('type') !== 'post_object')
|
665 |
+
return ajaxData;
|
666 |
+
|
667 |
+
var advanced_link = acf.getInstance($el.closest('.acf-field-acfe-advanced-link'));
|
668 |
+
|
669 |
+
ajaxData.field_key = advanced_link.get('key');
|
670 |
+
|
671 |
+
return ajaxData;
|
672 |
+
|
673 |
+
});
|
674 |
+
|
675 |
+
/**
|
676 |
+
* Field: Post Object - Args
|
677 |
+
*/
|
678 |
+
acf.addFilter('select2_args', function(options, $select, data, field, instance){
|
679 |
+
|
680 |
+
if(field.get('type') !== 'post_object' || !field.get('acfeAllowCustom'))
|
681 |
+
return options;
|
682 |
+
|
683 |
+
options.tags = true;
|
684 |
+
|
685 |
+
options.createTag = function (params){
|
686 |
+
|
687 |
+
var term = $.trim(params.term);
|
688 |
+
|
689 |
+
if(term === '')
|
690 |
+
return null;
|
691 |
+
|
692 |
+
return {
|
693 |
+
id: term,
|
694 |
+
text: term,
|
695 |
+
newTag: true
|
696 |
+
}
|
697 |
+
|
698 |
+
};
|
699 |
+
|
700 |
+
options.insertTag = function(data, tag){
|
701 |
+
|
702 |
+
var found = false;
|
703 |
+
|
704 |
+
$.each(data, function(index, value){
|
705 |
+
|
706 |
+
if($.trim(tag.text).toUpperCase() === $.trim(value.text).toUpperCase()){
|
707 |
+
|
708 |
+
found = true;
|
709 |
+
return false;
|
710 |
+
|
711 |
+
}
|
712 |
+
|
713 |
+
});
|
714 |
+
|
715 |
+
if(!found)
|
716 |
+
data.unshift(tag);
|
717 |
+
|
718 |
+
}
|
719 |
+
|
720 |
+
return options;
|
721 |
+
|
722 |
+
});
|
723 |
+
|
724 |
+
/**
|
725 |
+
* Module: Author
|
726 |
+
*/
|
727 |
+
acf.add_action('new_field/name=acfe_author', function(field){
|
728 |
+
|
729 |
+
field.on('change', function(e){
|
730 |
+
|
731 |
+
e.stopPropagation();
|
732 |
+
|
733 |
+
});
|
734 |
+
|
735 |
+
});
|
736 |
+
|
737 |
+
/**
|
738 |
+
* Module: Dynamic Forms - Fields Mapping
|
739 |
+
*/
|
740 |
+
var acfe_form_map_fields = function(field){
|
741 |
+
|
742 |
+
var name = field.get('name');
|
743 |
+
var $layout = field.$el.closest('.layout');
|
744 |
+
var $message = $layout.find('.acf-field[data-name="' + name + '_message"] > .acf-input');
|
745 |
+
|
746 |
+
var selected = field.$input().find('option:selected').text();
|
747 |
+
|
748 |
+
if(selected.length){
|
749 |
+
$message.html(selected);
|
750 |
+
}
|
751 |
+
|
752 |
+
field.$input().on('change', function(){
|
753 |
+
|
754 |
+
$message.html($(this).find('option:selected').text());
|
755 |
+
|
756 |
+
});
|
757 |
+
|
758 |
+
};
|
759 |
+
|
760 |
+
acf.addAction('new_field/name=acfe_form_post_map_target', acfe_form_map_fields);
|
761 |
+
acf.addAction('new_field/name=acfe_form_post_map_post_type', acfe_form_map_fields);
|
762 |
+
acf.addAction('new_field/name=acfe_form_post_map_post_status', acfe_form_map_fields);
|
763 |
+
acf.addAction('new_field/name=acfe_form_post_map_post_title', acfe_form_map_fields);
|
764 |
+
acf.addAction('new_field/name=acfe_form_post_map_post_name', acfe_form_map_fields);
|
765 |
+
acf.addAction('new_field/name=acfe_form_post_map_post_content', acfe_form_map_fields);
|
766 |
+
acf.addAction('new_field/name=acfe_form_post_map_post_author', acfe_form_map_fields);
|
767 |
+
acf.addAction('new_field/name=acfe_form_post_map_post_parent', acfe_form_map_fields);
|
768 |
+
acf.addAction('new_field/name=acfe_form_post_map_post_terms', acfe_form_map_fields);
|
769 |
+
|
770 |
+
acf.addAction('new_field/name=acfe_form_user_map_email', acfe_form_map_fields);
|
771 |
+
acf.addAction('new_field/name=acfe_form_user_map_username', acfe_form_map_fields);
|
772 |
+
acf.addAction('new_field/name=acfe_form_user_map_password', acfe_form_map_fields);
|
773 |
+
acf.addAction('new_field/name=acfe_form_user_map_first_name', acfe_form_map_fields);
|
774 |
+
acf.addAction('new_field/name=acfe_form_user_map_last_name', acfe_form_map_fields);
|
775 |
+
acf.addAction('new_field/name=acfe_form_user_map_nickname', acfe_form_map_fields);
|
776 |
+
acf.addAction('new_field/name=acfe_form_user_map_display_name', acfe_form_map_fields);
|
777 |
+
acf.addAction('new_field/name=acfe_form_user_map_website', acfe_form_map_fields);
|
778 |
+
acf.addAction('new_field/name=acfe_form_user_map_description', acfe_form_map_fields);
|
779 |
+
acf.addAction('new_field/name=acfe_form_user_map_role', acfe_form_map_fields);
|
780 |
+
|
781 |
+
acf.addAction('new_field/name=acfe_form_term_map_name', acfe_form_map_fields);
|
782 |
+
acf.addAction('new_field/name=acfe_form_term_map_slug', acfe_form_map_fields);
|
783 |
+
acf.addAction('new_field/name=acfe_form_term_map_taxonomy', acfe_form_map_fields);
|
784 |
+
acf.addAction('new_field/name=acfe_form_term_map_parent', acfe_form_map_fields);
|
785 |
+
acf.addAction('new_field/name=acfe_form_term_map_description', acfe_form_map_fields);
|
786 |
+
|
787 |
+
/**
|
788 |
+
* Module: Dynamic Forms (actions)
|
789 |
+
*/
|
790 |
+
acf.addAction('new_field/type=flexible_content', function(flexible){
|
791 |
+
|
792 |
+
if(flexible.get('name') !== 'acfe_form_actions')
|
793 |
+
return;
|
794 |
+
|
795 |
+
flexible.on('click', '[data-name="add-layout"]', function(e){
|
796 |
+
|
797 |
+
$('body').find('.acf-fc-popup').addClass('acfe-fc-popup-grey');
|
798 |
+
|
799 |
+
});
|
800 |
+
|
801 |
+
});
|
802 |
+
|
803 |
})(jQuery);
|
assets/acf-extended-form.js
CHANGED
@@ -1,140 +1,152 @@
|
|
1 |
-
(function($){
|
2 |
-
|
3 |
-
if(typeof acf === 'undefined')
|
4 |
-
return;
|
5 |
-
|
6 |
-
$(document).ready(function($){
|
7 |
-
|
8 |
-
if($('.acfe-form[data-hide-unload="1"]').length){
|
9 |
-
|
10 |
-
acf.unload.disable();
|
11 |
-
|
12 |
-
}
|
13 |
-
|
14 |
-
});
|
15 |
-
|
16 |
-
// Datepicker: Add field class
|
17 |
-
acf.addAction('new_field/type=date_picker', function(field){
|
18 |
-
|
19 |
-
var $form = field.$el.closest('form.acfe-form');
|
20 |
-
|
21 |
-
if(!$form.length)
|
22 |
-
return;
|
23 |
-
|
24 |
-
var field_class = $form.data('fields-class');
|
25 |
-
|
26 |
-
if(field_class)
|
27 |
-
field.$inputText().addClass(field_class);
|
28 |
-
|
29 |
-
});
|
30 |
-
|
31 |
-
// Google Maps: Add field class
|
32 |
-
acf.addAction('new_field/type=google_map', function(field){
|
33 |
-
|
34 |
-
var $form = field.$el.closest('form.acfe-form');
|
35 |
-
|
36 |
-
if(!$form.length)
|
37 |
-
return;
|
38 |
-
|
39 |
-
var field_class = $form.data('fields-class');
|
40 |
-
|
41 |
-
if(field_class)
|
42 |
-
field.$search().addClass(field_class);
|
43 |
-
|
44 |
-
});
|
45 |
-
|
46 |
-
// Error: Move error
|
47 |
-
acf.addAction('invalid_field', function(field){
|
48 |
-
|
49 |
-
var $form = field.$el.closest('form.acfe-form');
|
50 |
-
|
51 |
-
if(!$form.length)
|
52 |
-
return;
|
53 |
-
|
54 |
-
var errors_position = $form.data('errors-position');
|
55 |
-
var errors_class = $form.data('errors-class');
|
56 |
-
|
57 |
-
// Class
|
58 |
-
if(errors_class && errors_class.length){
|
59 |
-
|
60 |
-
field.$el.find('.acf-notice.-error').addClass(errors_class);
|
61 |
-
|
62 |
-
}
|
63 |
-
|
64 |
-
// Move below
|
65 |
-
if(errors_position && errors_position === 'below'){
|
66 |
-
|
67 |
-
if(field.$control().length){
|
68 |
-
|
69 |
-
field.$el.find('.acf-notice.-error').insertAfter(field.$control());
|
70 |
-
|
71 |
-
}else if(field.$input().length){
|
72 |
-
|
73 |
-
field.$el.find('.acf-notice.-error').insertAfter(field.$input());
|
74 |
-
|
75 |
-
}
|
76 |
-
|
77 |
-
var $selector = false;
|
78 |
-
|
79 |
-
if(field.$control().length){
|
80 |
-
|
81 |
-
$selector = field.$control();
|
82 |
-
|
83 |
-
}else if(field.$input().length){
|
84 |
-
|
85 |
-
$selector = field.$input();
|
86 |
-
|
87 |
-
}
|
88 |
-
|
89 |
-
if($selector)
|
90 |
-
field.$el.find('.acf-notice.-error').insertAfter($selector);
|
91 |
-
|
92 |
-
}
|
93 |
-
|
94 |
-
// Group errors
|
95 |
-
else if(errors_position && errors_position === 'group'){
|
96 |
-
|
97 |
-
var label = field.$el.find('.acf-label label').text().trim();
|
98 |
-
var placeholder = field.$el.find('.acf-input-wrap [placeholder!=""]').attr('placeholder');
|
99 |
-
var message = field.$el.find('.acf-notice.-error').text().trim();
|
100 |
-
|
101 |
-
field.$el.find('.acf-notice.-error').remove();
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
})(jQuery);
|
1 |
+
(function($){
|
2 |
+
|
3 |
+
if(typeof acf === 'undefined')
|
4 |
+
return;
|
5 |
+
|
6 |
+
$(document).ready(function($){
|
7 |
+
|
8 |
+
if($('.acfe-form[data-hide-unload="1"]').length){
|
9 |
+
|
10 |
+
acf.unload.disable();
|
11 |
+
|
12 |
+
}
|
13 |
+
|
14 |
+
});
|
15 |
+
|
16 |
+
// Datepicker: Add field class
|
17 |
+
acf.addAction('new_field/type=date_picker', function(field){
|
18 |
+
|
19 |
+
var $form = field.$el.closest('form.acfe-form');
|
20 |
+
|
21 |
+
if(!$form.length)
|
22 |
+
return;
|
23 |
+
|
24 |
+
var field_class = $form.data('fields-class');
|
25 |
+
|
26 |
+
if(field_class)
|
27 |
+
field.$inputText().addClass(field_class);
|
28 |
+
|
29 |
+
});
|
30 |
+
|
31 |
+
// Google Maps: Add field class
|
32 |
+
acf.addAction('new_field/type=google_map', function(field){
|
33 |
+
|
34 |
+
var $form = field.$el.closest('form.acfe-form');
|
35 |
+
|
36 |
+
if(!$form.length)
|
37 |
+
return;
|
38 |
+
|
39 |
+
var field_class = $form.data('fields-class');
|
40 |
+
|
41 |
+
if(field_class)
|
42 |
+
field.$search().addClass(field_class);
|
43 |
+
|
44 |
+
});
|
45 |
+
|
46 |
+
// Error: Move error
|
47 |
+
acf.addAction('invalid_field', function(field){
|
48 |
+
|
49 |
+
var $form = field.$el.closest('form.acfe-form');
|
50 |
+
|
51 |
+
if(!$form.length)
|
52 |
+
return;
|
53 |
+
|
54 |
+
var errors_position = $form.data('errors-position');
|
55 |
+
var errors_class = $form.data('errors-class');
|
56 |
+
|
57 |
+
// Class
|
58 |
+
if(errors_class && errors_class.length){
|
59 |
+
|
60 |
+
field.$el.find('.acf-notice.-error').addClass(errors_class);
|
61 |
+
|
62 |
+
}
|
63 |
+
|
64 |
+
// Move below
|
65 |
+
if(errors_position && errors_position === 'below'){
|
66 |
+
|
67 |
+
if(field.$control().length){
|
68 |
+
|
69 |
+
field.$el.find('.acf-notice.-error').insertAfter(field.$control());
|
70 |
+
|
71 |
+
}else if(field.$input().length){
|
72 |
+
|
73 |
+
field.$el.find('.acf-notice.-error').insertAfter(field.$input());
|
74 |
+
|
75 |
+
}
|
76 |
+
|
77 |
+
var $selector = false;
|
78 |
+
|
79 |
+
if(field.$control().length){
|
80 |
+
|
81 |
+
$selector = field.$control();
|
82 |
+
|
83 |
+
}else if(field.$input().length){
|
84 |
+
|
85 |
+
$selector = field.$input();
|
86 |
+
|
87 |
+
}
|
88 |
+
|
89 |
+
if($selector)
|
90 |
+
field.$el.find('.acf-notice.-error').insertAfter($selector);
|
91 |
+
|
92 |
+
}
|
93 |
+
|
94 |
+
// Group errors
|
95 |
+
else if(errors_position && errors_position === 'group'){
|
96 |
+
|
97 |
+
var label = field.$el.find('.acf-label label').text().trim();
|
98 |
+
var placeholder = field.$el.find('.acf-input-wrap [placeholder!=""]').attr('placeholder');
|
99 |
+
var message = field.$el.find('.acf-notice.-error').text().trim();
|
100 |
+
|
101 |
+
field.$el.find('.acf-notice.-error').remove();
|
102 |
+
|
103 |
+
// Try label
|
104 |
+
if(label && label.length && label !== '*'){
|
105 |
+
|
106 |
+
message = label + ': ' + message;
|
107 |
+
|
108 |
+
}
|
109 |
+
|
110 |
+
// Try placeholder
|
111 |
+
else if(placeholder && placeholder.length && placeholder !== ''){
|
112 |
+
|
113 |
+
message = placeholder + ': ' + message;
|
114 |
+
|
115 |
+
}
|
116 |
+
|
117 |
+
// If everything fails, use field name
|
118 |
+
else{
|
119 |
+
|
120 |
+
message = field.get('name') + ': ' + message;
|
121 |
+
|
122 |
+
}
|
123 |
+
|
124 |
+
var $form_error = $form.find('> .acfe-form-error')
|
125 |
+
|
126 |
+
if(!$form_error.length)
|
127 |
+
$form_error = $('<div class="acf-notice -error acf-error-message acfe-form-error" />').prependTo($form);
|
128 |
+
|
129 |
+
$form_error.append('<p>' + message + '</p>');
|
130 |
+
|
131 |
+
}
|
132 |
+
|
133 |
+
// Hide errors
|
134 |
+
else if(errors_position && errors_position === 'hide'){
|
135 |
+
|
136 |
+
field.$el.find('.acf-notice.-error').remove();
|
137 |
+
|
138 |
+
}
|
139 |
+
|
140 |
+
});
|
141 |
+
|
142 |
+
// Remove error message on validation
|
143 |
+
acf.addAction('validation_begin', function($form){
|
144 |
+
|
145 |
+
if(typeof $form === 'undefined')
|
146 |
+
return;
|
147 |
+
|
148 |
+
$form.find('.acf-error-message').remove();
|
149 |
+
|
150 |
+
});
|
151 |
+
|
152 |
})(jQuery);
|
assets/acf-extended-modal.css
CHANGED
@@ -1,488 +1,497 @@
|
|
1 |
-
/*
|
2 |
-
* ACFE Modal Body
|
3 |
-
*/
|
4 |
-
body.acfe-modal-opened{
|
5 |
-
overflow:hidden;
|
6 |
-
}
|
7 |
-
|
8 |
-
/*
|
9 |
-
* ACFE Modal Overlay
|
10 |
-
*/
|
11 |
-
.acfe-modal-overlay{
|
12 |
-
background:rgba(0,0,0,.7);
|
13 |
-
position:fixed;
|
14 |
-
top:0;
|
15 |
-
left:0;
|
16 |
-
right:0;
|
17 |
-
bottom:0;
|
18 |
-
height:100%;
|
19 |
-
width:100%;
|
20 |
-
z-index:100000;
|
21 |
-
}
|
22 |
-
|
23 |
-
/*
|
24 |
-
* ACFE Modal
|
25 |
-
*/
|
26 |
-
.acfe-modal{
|
27 |
-
display:none;
|
28 |
-
-webkit-transition: all 0.3s ease-in-out;
|
29 |
-
-o-transition: all 0.3s ease-in-out;
|
30 |
-
transition: all 0.3s ease-in-out;
|
31 |
-
}
|
32 |
-
|
33 |
-
.acfe-modal.-open{
|
34 |
-
position:fixed;
|
35 |
-
z-index:100001;
|
36 |
-
height:100%;
|
37 |
-
width:100%;
|
38 |
-
top:0;
|
39 |
-
left:0;
|
40 |
-
bottom:0;
|
41 |
-
right:0;
|
42 |
-
-webkit-font-smoothing: subpixel-antialiased;
|
43 |
-
|
44 |
-
display: -webkit-box;
|
45 |
-
display: -ms-flexbox;
|
46 |
-
display: flex;
|
47 |
-
-webkit-box-orient: vertical;
|
48 |
-
-webkit-box-direction: normal;
|
49 |
-
-ms-flex-direction: column;
|
50 |
-
flex-direction: column;
|
51 |
-
-webkit-box-pack: center;
|
52 |
-
-ms-flex-pack: center;
|
53 |
-
justify-content: center;
|
54 |
-
-webkit-box-align: center;
|
55 |
-
-ms-flex-align: center;
|
56 |
-
align-items: center;
|
57 |
-
|
58 |
-
pointer-events:none;
|
59 |
-
}
|
60 |
-
|
61 |
-
/*
|
62 |
-
* ACFE Modal: Wrapper
|
63 |
-
*/
|
64 |
-
.acfe-modal.-open > .acfe-modal-wrapper{
|
65 |
-
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.7);
|
66 |
-
display: -webkit-box;
|
67 |
-
display: -ms-flexbox;
|
68 |
-
display: flex;
|
69 |
-
-webkit-box-orient: vertical;
|
70 |
-
-webkit-box-direction: normal;
|
71 |
-
-ms-flex-direction: column;
|
72 |
-
flex-direction: column;
|
73 |
-
|
74 |
-
width: calc(100vw - 60px);
|
75 |
-
max-width:1100px;
|
76 |
-
max-height: calc(100vh - 60px);
|
77 |
-
position:relative;
|
78 |
-
}
|
79 |
-
|
80 |
-
.acfe-modal.-open.acfe-modal-sub > .acfe-modal-wrapper > .acfe-modal-wrapper-overlay{
|
81 |
-
position:absolute;
|
82 |
-
z-index:1;
|
83 |
-
background:rgba(0,0,0,0.7);
|
84 |
-
height:100%;
|
85 |
-
width:100%;
|
86 |
-
pointer-events:none;
|
87 |
-
}
|
88 |
-
|
89 |
-
/*
|
90 |
-
* ACFE Modal: Sizes
|
91 |
-
*/
|
92 |
-
.acfe-modal.-open.-small > .acfe-modal-wrapper{
|
93 |
-
max-width:700px;
|
94 |
-
}
|
95 |
-
|
96 |
-
.acfe-modal.-open.-full > .acfe-modal-wrapper{
|
97 |
-
max-width:100%;
|
98 |
-
-webkit-box-flex: 1;
|
99 |
-
-ms-flex: 1;
|
100 |
-
flex: 1;
|
101 |
-
}
|
102 |
-
|
103 |
-
/*
|
104 |
-
* ACFE Modal Title
|
105 |
-
*/
|
106 |
-
|
107 |
-
.acfe-modal.-open >.acfe-modal-title,
|
108 |
-
.acfe-modal.-open .acfe-modal-title *{
|
109 |
-
-webkit-box-sizing:border-box;
|
110 |
-
box-sizing:border-box;
|
111 |
-
}
|
112 |
-
|
113 |
-
.acfe-modal.-open .acfe-modal-title{
|
114 |
-
display:block;
|
115 |
-
height: 50px;
|
116 |
-
line-height: 50px;
|
117 |
-
font-size: 22px;
|
118 |
-
color: #23282d;
|
119 |
-
border-bottom: 1px solid #ddd;
|
120 |
-
text-overflow: ellipsis;
|
121 |
-
background: #fcfcfc;
|
122 |
-
padding: 0 0 0 16px;
|
123 |
-
position:relative;
|
124 |
-
text-align:left;
|
125 |
-
pointer-events: auto;
|
126 |
-
}
|
127 |
-
|
128 |
-
.acfe-modal.-open.acfe-modal-sub > .acfe-modal-wrapper > .acfe-modal-title{
|
129 |
-
pointer-events: none;
|
130 |
-
}
|
131 |
-
|
132 |
-
.acfe-modal.-open .acfe-modal-title > span.title{
|
133 |
-
line-height: 50px;
|
134 |
-
color: #23282d;
|
135 |
-
font-weight: 600;
|
136 |
-
}
|
137 |
-
|
138 |
-
.acfe-modal.-open .acfe-modal-title > span.title .acf-fc-layout-order{
|
139 |
-
width: 30px;
|
140 |
-
height: 30px;
|
141 |
-
border-radius: 30px;
|
142 |
-
display: inline-block;
|
143 |
-
text-align: center;
|
144 |
-
line-height: 30px;
|
145 |
-
margin: 0 2px 0 0;
|
146 |
-
background: #F1F1F1;
|
147 |
-
font-size: 14px;
|
148 |
-
color: #666;
|
149 |
-
vertical-align: 2px;
|
150 |
-
}
|
151 |
-
|
152 |
-
.acfe-modal.-open .acfe-modal-title > button.close{
|
153 |
-
height: 50px;
|
154 |
-
width: 50px;
|
155 |
-
color: #666;
|
156 |
-
border:0;
|
157 |
-
border-left: 0;
|
158 |
-
margin: 0;
|
159 |
-
padding:0;
|
160 |
-
border-radius: 0;
|
161 |
-
position: absolute;
|
162 |
-
top:0;
|
163 |
-
right:0;
|
164 |
-
transition: color .1s ease-in-out, background .1s ease-in-out;
|
165 |
-
background:none;
|
166 |
-
cursor:pointer;
|
167 |
-
margin: 0;
|
168 |
-
}
|
169 |
-
|
170 |
-
.acfe-modal.-open .acfe-modal-title > button.close:hover{
|
171 |
-
color: #00a0d2;
|
172 |
-
}
|
173 |
-
|
174 |
-
.acfe-modal.-open .acfe-modal-title > button.close:before{
|
175 |
-
height: 50px;
|
176 |
-
width: 50px;
|
177 |
-
line-height: 50px !important;
|
178 |
-
font: normal 20px/1 dashicons;
|
179 |
-
content: "\f158";
|
180 |
-
margin: 0;
|
181 |
-
padding:0;
|
182 |
-
}
|
183 |
-
|
184 |
-
/*
|
185 |
-
* ACFE Modal Content
|
186 |
-
*/
|
187 |
-
.acfe-modal.-open .acfe-modal-content{
|
188 |
-
height:100%;
|
189 |
-
background:#fff;
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
}
|
195 |
-
|
196 |
-
.acfe-modal.-open.acfe-modal-sub > .acfe-modal-wrapper > .acfe-modal-content{
|
197 |
-
pointer-events: none;
|
198 |
-
}
|
199 |
-
|
200 |
-
/*
|
201 |
-
* ACFE Modal Content: Tabs
|
202 |
-
*/
|
203 |
-
.acfe-modal.-open .acfe-modal-content .nav-tab-wrapper{
|
204 |
-
padding:0;
|
205 |
-
margin:0;
|
206 |
-
border-
|
207 |
-
}
|
208 |
-
|
209 |
-
.acfe-modal.-open .acfe-modal-content .nav-tab-wrapper a{
|
210 |
-
margin:0;
|
211 |
-
border-left:0;
|
212 |
-
border-top:0;
|
213 |
-
border-bottom:0;
|
214 |
-
background:#fff;
|
215 |
-
transition:color .1s ease-in-out, background .1s ease-in-out;
|
216 |
-
padding:7px 15px;
|
217 |
-
border-color:#ddd;
|
218 |
-
}
|
219 |
-
|
220 |
-
.acfe-modal.-open .acfe-modal-content .nav-tab-wrapper a span.dashicons-menu{
|
221 |
-
line-height:27px;
|
222 |
-
}
|
223 |
-
|
224 |
-
.acfe-modal.-open > .acfe-modal-content .nav-tab-wrapper a:hover{
|
225 |
-
background:#f9f9f9;
|
226 |
-
color:#23282d;
|
227 |
-
}
|
228 |
-
|
229 |
-
.acfe-modal.-open .acfe-modal-content .nav-tab-wrapper a.nav-tab-active,
|
230 |
-
.acfe-modal.-open .acfe-modal-content .nav-tab-wrapper a.nav-tab-active:hover{
|
231 |
-
background:#fcfcfc;
|
232 |
-
color:#23282d;
|
233 |
-
}
|
234 |
-
|
235 |
-
.acfe-modal.-open .acfe-modal-content .nav-tab:focus,
|
236 |
-
.acfe-modal.-open .acfe-modal-content .nav-tab:focus:active {
|
237 |
-
border-bottom: 0;
|
238 |
-
box-shadow: none;
|
239 |
-
outline:0;
|
240 |
-
}
|
241 |
-
|
242 |
-
/*
|
243 |
-
* ACFE Modal Content: Flex
|
244 |
-
*/
|
245 |
-
.acfe-modal.-open .acfe-modal-content .acfe-flex-container,
|
246 |
-
.acfe-modal.-open .acfe-modal-content .acfe-flex-container *{
|
247 |
-
-webkit-box-sizing:border-box;
|
248 |
-
box-sizing:border-box;
|
249 |
-
}
|
250 |
-
|
251 |
-
.acfe-modal.-open .acfe-modal-content .acfe-flex-container{
|
252 |
-
width: 100%;
|
253 |
-
padding: 14px;
|
254 |
-
margin-right: auto;
|
255 |
-
margin-left: auto;
|
256 |
-
}
|
257 |
-
|
258 |
-
.acfe-modal.-open .acfe-modal-content .acfe-flex-container
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
}
|
303 |
-
|
304 |
-
.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
}
|
319 |
-
|
320 |
-
.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a.
|
321 |
-
|
322 |
-
}
|
323 |
-
|
324 |
-
.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a.disabled
|
325 |
-
|
326 |
-
|
327 |
-
}
|
328 |
-
|
329 |
-
.acfe-modal.-open .acfe-modal-content .acfe-flex-container
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
}
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
body.block-editor-page .edit-post-layout .acfe-modal.-open
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
}
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
}
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
488 |
}
|
1 |
+
/*
|
2 |
+
* ACFE Modal Body
|
3 |
+
*/
|
4 |
+
body.acfe-modal-opened{
|
5 |
+
overflow:hidden;
|
6 |
+
}
|
7 |
+
|
8 |
+
/*
|
9 |
+
* ACFE Modal Overlay
|
10 |
+
*/
|
11 |
+
.acfe-modal-overlay{
|
12 |
+
background:rgba(0,0,0,.7);
|
13 |
+
position:fixed;
|
14 |
+
top:0;
|
15 |
+
left:0;
|
16 |
+
right:0;
|
17 |
+
bottom:0;
|
18 |
+
height:100%;
|
19 |
+
width:100%;
|
20 |
+
z-index:100000;
|
21 |
+
}
|
22 |
+
|
23 |
+
/*
|
24 |
+
* ACFE Modal
|
25 |
+
*/
|
26 |
+
.acfe-modal{
|
27 |
+
display:none;
|
28 |
+
-webkit-transition: all 0.3s ease-in-out;
|
29 |
+
-o-transition: all 0.3s ease-in-out;
|
30 |
+
transition: all 0.3s ease-in-out;
|
31 |
+
}
|
32 |
+
|
33 |
+
.acfe-modal.-open{
|
34 |
+
position:fixed;
|
35 |
+
z-index:100001;
|
36 |
+
height:100%;
|
37 |
+
width:100%;
|
38 |
+
top:0;
|
39 |
+
left:0;
|
40 |
+
bottom:0;
|
41 |
+
right:0;
|
42 |
+
-webkit-font-smoothing: subpixel-antialiased;
|
43 |
+
|
44 |
+
display: -webkit-box;
|
45 |
+
display: -ms-flexbox;
|
46 |
+
display: flex;
|
47 |
+
-webkit-box-orient: vertical;
|
48 |
+
-webkit-box-direction: normal;
|
49 |
+
-ms-flex-direction: column;
|
50 |
+
flex-direction: column;
|
51 |
+
-webkit-box-pack: center;
|
52 |
+
-ms-flex-pack: center;
|
53 |
+
justify-content: center;
|
54 |
+
-webkit-box-align: center;
|
55 |
+
-ms-flex-align: center;
|
56 |
+
align-items: center;
|
57 |
+
|
58 |
+
pointer-events:none;
|
59 |
+
}
|
60 |
+
|
61 |
+
/*
|
62 |
+
* ACFE Modal: Wrapper
|
63 |
+
*/
|
64 |
+
.acfe-modal.-open > .acfe-modal-wrapper{
|
65 |
+
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.7);
|
66 |
+
display: -webkit-box;
|
67 |
+
display: -ms-flexbox;
|
68 |
+
display: flex;
|
69 |
+
-webkit-box-orient: vertical;
|
70 |
+
-webkit-box-direction: normal;
|
71 |
+
-ms-flex-direction: column;
|
72 |
+
flex-direction: column;
|
73 |
+
|
74 |
+
width: calc(100vw - 60px);
|
75 |
+
max-width:1100px;
|
76 |
+
max-height: calc(100vh - 60px);
|
77 |
+
position:relative;
|
78 |
+
}
|
79 |
+
|
80 |
+
.acfe-modal.-open.acfe-modal-sub > .acfe-modal-wrapper > .acfe-modal-wrapper-overlay{
|
81 |
+
position:absolute;
|
82 |
+
z-index:1;
|
83 |
+
background:rgba(0,0,0,0.7);
|
84 |
+
height:100%;
|
85 |
+
width:100%;
|
86 |
+
pointer-events:none;
|
87 |
+
}
|
88 |
+
|
89 |
+
/*
|
90 |
+
* ACFE Modal: Sizes
|
91 |
+
*/
|
92 |
+
.acfe-modal.-open.-small > .acfe-modal-wrapper{
|
93 |
+
max-width:700px;
|
94 |
+
}
|
95 |
+
|
96 |
+
.acfe-modal.-open.-full > .acfe-modal-wrapper{
|
97 |
+
max-width:100%;
|
98 |
+
-webkit-box-flex: 1;
|
99 |
+
-ms-flex: 1;
|
100 |
+
flex: 1;
|
101 |
+
}
|
102 |
+
|
103 |
+
/*
|
104 |
+
* ACFE Modal Title
|
105 |
+
*/
|
106 |
+
|
107 |
+
.acfe-modal.-open >.acfe-modal-title,
|
108 |
+
.acfe-modal.-open .acfe-modal-title *{
|
109 |
+
-webkit-box-sizing:border-box;
|
110 |
+
box-sizing:border-box;
|
111 |
+
}
|
112 |
+
|
113 |
+
.acfe-modal.-open .acfe-modal-title{
|
114 |
+
display:block;
|
115 |
+
height: 50px;
|
116 |
+
line-height: 50px;
|
117 |
+
font-size: 22px;
|
118 |
+
color: #23282d;
|
119 |
+
border-bottom: 1px solid #ddd;
|
120 |
+
text-overflow: ellipsis;
|
121 |
+
background: #fcfcfc;
|
122 |
+
padding: 0 0 0 16px;
|
123 |
+
position:relative;
|
124 |
+
text-align:left;
|
125 |
+
pointer-events: auto;
|
126 |
+
}
|
127 |
+
|
128 |
+
.acfe-modal.-open.acfe-modal-sub > .acfe-modal-wrapper > .acfe-modal-title{
|
129 |
+
pointer-events: none;
|
130 |
+
}
|
131 |
+
|
132 |
+
.acfe-modal.-open .acfe-modal-title > span.title{
|
133 |
+
line-height: 50px;
|
134 |
+
color: #23282d;
|
135 |
+
font-weight: 600;
|
136 |
+
}
|
137 |
+
|
138 |
+
.acfe-modal.-open .acfe-modal-title > span.title .acf-fc-layout-order{
|
139 |
+
width: 30px;
|
140 |
+
height: 30px;
|
141 |
+
border-radius: 30px;
|
142 |
+
display: inline-block;
|
143 |
+
text-align: center;
|
144 |
+
line-height: 30px;
|
145 |
+
margin: 0 2px 0 0;
|
146 |
+
background: #F1F1F1;
|
147 |
+
font-size: 14px;
|
148 |
+
color: #666;
|
149 |
+
vertical-align: 2px;
|
150 |
+
}
|
151 |
+
|
152 |
+
.acfe-modal.-open .acfe-modal-title > button.close{
|
153 |
+
height: 50px;
|
154 |
+
width: 50px;
|
155 |
+
color: #666;
|
156 |
+
border:0;
|
157 |
+
border-left: 0;
|
158 |
+
margin: 0;
|
159 |
+
padding:0;
|
160 |
+
border-radius: 0;
|
161 |
+
position: absolute;
|
162 |
+
top:0;
|
163 |
+
right:0;
|
164 |
+
transition: color .1s ease-in-out, background .1s ease-in-out;
|
165 |
+
background:none;
|
166 |
+
cursor:pointer;
|
167 |
+
margin: 0;
|
168 |
+
}
|
169 |
+
|
170 |
+
.acfe-modal.-open .acfe-modal-title > button.close:hover{
|
171 |
+
color: #00a0d2;
|
172 |
+
}
|
173 |
+
|
174 |
+
.acfe-modal.-open .acfe-modal-title > button.close:before{
|
175 |
+
height: 50px;
|
176 |
+
width: 50px;
|
177 |
+
line-height: 50px !important;
|
178 |
+
font: normal 20px/1 dashicons;
|
179 |
+
content: "\f158";
|
180 |
+
margin: 0;
|
181 |
+
padding:0;
|
182 |
+
}
|
183 |
+
|
184 |
+
/*
|
185 |
+
* ACFE Modal Content
|
186 |
+
*/
|
187 |
+
.acfe-modal.-open .acfe-modal-content{
|
188 |
+
height:100%;
|
189 |
+
background:#fff;
|
190 |
+
display:block;
|
191 |
+
position:relative;
|
192 |
+
pointer-events: auto;
|
193 |
+
overflow:auto;
|
194 |
+
}
|
195 |
+
|
196 |
+
.acfe-modal.-open.acfe-modal-sub > .acfe-modal-wrapper > .acfe-modal-content{
|
197 |
+
pointer-events: none;
|
198 |
+
}
|
199 |
+
|
200 |
+
/*
|
201 |
+
* ACFE Modal Content: Tabs
|
202 |
+
*/
|
203 |
+
.acfe-modal.-open .acfe-modal-content .nav-tab-wrapper{
|
204 |
+
padding:0;
|
205 |
+
margin:0;
|
206 |
+
border-bottom:1px solid #ddd;
|
207 |
+
}
|
208 |
+
|
209 |
+
.acfe-modal.-open .acfe-modal-content .nav-tab-wrapper a{
|
210 |
+
margin:0;
|
211 |
+
border-left:0;
|
212 |
+
border-top:0;
|
213 |
+
border-bottom:0;
|
214 |
+
background:#fff;
|
215 |
+
transition:color .1s ease-in-out, background .1s ease-in-out;
|
216 |
+
padding:7px 15px;
|
217 |
+
border-color:#ddd;
|
218 |
+
}
|
219 |
+
|
220 |
+
.acfe-modal.-open .acfe-modal-content .nav-tab-wrapper a span.dashicons-menu{
|
221 |
+
line-height:27px;
|
222 |
+
}
|
223 |
+
|
224 |
+
.acfe-modal.-open > .acfe-modal-content .nav-tab-wrapper a:hover{
|
225 |
+
background:#f9f9f9;
|
226 |
+
color:#23282d;
|
227 |
+
}
|
228 |
+
|
229 |
+
.acfe-modal.-open .acfe-modal-content .nav-tab-wrapper a.nav-tab-active,
|
230 |
+
.acfe-modal.-open .acfe-modal-content .nav-tab-wrapper a.nav-tab-active:hover{
|
231 |
+
background:#fcfcfc;
|
232 |
+
color:#23282d;
|
233 |
+
}
|
234 |
+
|
235 |
+
.acfe-modal.-open .acfe-modal-content .nav-tab:focus,
|
236 |
+
.acfe-modal.-open .acfe-modal-content .nav-tab:focus:active {
|
237 |
+
border-bottom: 0;
|
238 |
+
box-shadow: none;
|
239 |
+
outline:0;
|
240 |
+
}
|
241 |
+
|
242 |
+
/*
|
243 |
+
* ACFE Modal Content: Flex
|
244 |
+
*/
|
245 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container,
|
246 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container *{
|
247 |
+
-webkit-box-sizing:border-box;
|
248 |
+
box-sizing:border-box;
|
249 |
+
}
|
250 |
+
|
251 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container{
|
252 |
+
width: 100%;
|
253 |
+
padding: 14px;
|
254 |
+
margin-right: auto;
|
255 |
+
margin-left: auto;
|
256 |
+
}
|
257 |
+
|
258 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flexible-categories ~ .acfe-flex-container{
|
259 |
+
overflow:auto;
|
260 |
+
height:calc(100% - 39px);
|
261 |
+
}
|
262 |
+
|
263 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul{
|
264 |
+
margin: 0;
|
265 |
+
margin-right: -7px;
|
266 |
+
margin-left: -7px;
|
267 |
+
|
268 |
+
display: -webkit-box;
|
269 |
+
display: -ms-flexbox;
|
270 |
+
display: flex;
|
271 |
+
-ms-flex-wrap: wrap;
|
272 |
+
flex-wrap: wrap;
|
273 |
+
}
|
274 |
+
|
275 |
+
.acfe-modal.-open >.acfe-modal-content .acfe-flex-container ul:after{
|
276 |
+
content:"";
|
277 |
+
clear:both;
|
278 |
+
display:table;
|
279 |
+
}
|
280 |
+
|
281 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li{
|
282 |
+
position: relative;
|
283 |
+
width: 100%;
|
284 |
+
padding-right: 7px;
|
285 |
+
padding-left: 7px;
|
286 |
+
padding-bottom: 14px;
|
287 |
+
margin:0;
|
288 |
+
|
289 |
+
-webkit-box-flex: 0;
|
290 |
+
-ms-flex: 0 0 25%;
|
291 |
+
flex: 0 0 25%;
|
292 |
+
max-width: 25%;
|
293 |
+
}
|
294 |
+
|
295 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a{
|
296 |
+
border:1px solid #ddd;
|
297 |
+
background:#F9F9F9;
|
298 |
+
padding:15px;
|
299 |
+
color:#333;
|
300 |
+
display:block;
|
301 |
+
text-decoration:none;
|
302 |
+
}
|
303 |
+
|
304 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a:hover{
|
305 |
+
background:#007cba;
|
306 |
+
color:#fff;
|
307 |
+
}
|
308 |
+
|
309 |
+
body:not(.acf-admin-5-3) .acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a:hover{
|
310 |
+
background:#0073aa;
|
311 |
+
}
|
312 |
+
|
313 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a span{
|
314 |
+
display:block;
|
315 |
+
font-size:16px;
|
316 |
+
text-align:center;
|
317 |
+
font-weight:600;
|
318 |
+
}
|
319 |
+
|
320 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a span.no-thumbnail{
|
321 |
+
text-align:left;
|
322 |
+
}
|
323 |
+
|
324 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a.disabled{
|
325 |
+
pointer-events:none;
|
326 |
+
opacity:0.67;
|
327 |
+
}
|
328 |
+
|
329 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a.disabled:hover{
|
330 |
+
cursor:default;
|
331 |
+
}
|
332 |
+
|
333 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a.disabled:focus{
|
334 |
+
box-shadow:none;
|
335 |
+
outline:none;
|
336 |
+
}
|
337 |
+
|
338 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-1 ul li{
|
339 |
+
-ms-flex: 0 0 100%;
|
340 |
+
flex: 0 0 100%;
|
341 |
+
max-width: 100%;
|
342 |
+
}
|
343 |
+
|
344 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-2 ul li{
|
345 |
+
-ms-flex: 0 0 50%;
|
346 |
+
flex: 0 0 50%;
|
347 |
+
max-width: 50%;
|
348 |
+
}
|
349 |
+
|
350 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-3 ul li{
|
351 |
+
-ms-flex: 0 0 33.333333%;
|
352 |
+
flex: 0 0 33.333333%;
|
353 |
+
max-width: 33.333333%;
|
354 |
+
}
|
355 |
+
|
356 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-4 ul li{
|
357 |
+
-ms-flex: 0 0 25%;
|
358 |
+
flex: 0 0 25%;
|
359 |
+
max-width: 25%;
|
360 |
+
}
|
361 |
+
|
362 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-5 ul li{
|
363 |
+
-ms-flex: 0 0 20%;
|
364 |
+
flex: 0 0 20%;
|
365 |
+
max-width: 20%;
|
366 |
+
}
|
367 |
+
|
368 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-6 ul li{
|
369 |
+
-ms-flex: 0 0 16.66%;
|
370 |
+
flex: 0 0 16.66%;
|
371 |
+
max-width: 16.66%;
|
372 |
+
}
|
373 |
+
|
374 |
+
@media only screen and (max-width:960px){
|
375 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li{
|
376 |
+
-ms-flex: 0 0 50% !important;
|
377 |
+
flex: 0 0 50% !important;
|
378 |
+
max-width: 50% !important;
|
379 |
+
}
|
380 |
+
|
381 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-1 ul li{
|
382 |
+
-ms-flex: 0 0 100% !important;
|
383 |
+
flex: 0 0 100% !important;
|
384 |
+
max-width: 100% !important;
|
385 |
+
}
|
386 |
+
|
387 |
+
.acfe-modal.-open .acfe-modal-content ul li a{
|
388 |
+
padding:7px;
|
389 |
+
}
|
390 |
+
}
|
391 |
+
|
392 |
+
@media only screen and (max-width:720px){
|
393 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li{
|
394 |
+
-ms-flex: 0 0 100% !important;
|
395 |
+
flex: 0 0 100% !important;
|
396 |
+
max-width: 100% !important;
|
397 |
+
}
|
398 |
+
|
399 |
+
.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-1 ul li{
|
400 |
+
-ms-flex: 0 0 100% !important;
|
401 |
+
flex: 0 0 100% !important;
|
402 |
+
max-width: 100% !important;
|
403 |
+
}
|
404 |
+
}
|
405 |
+
|
406 |
+
/*
|
407 |
+
* ACFE Modal footer
|
408 |
+
*/
|
409 |
+
.acfe-modal.-open .acfe-modal-footer,
|
410 |
+
.acfe-modal.-open .acfe-modal-footer *{
|
411 |
+
-webkit-box-sizing:border-box;
|
412 |
+
box-sizing:border-box;
|
413 |
+
}
|
414 |
+
|
415 |
+
.acfe-modal.-open .acfe-modal-footer{
|
416 |
+
display:block;
|
417 |
+
height: 50px;
|
418 |
+
line-height: 50px;
|
419 |
+
color: #23282d;
|
420 |
+
background: #fcfcfc;
|
421 |
+
padding: 0 16px;
|
422 |
+
position:relative;
|
423 |
+
text-align:right;
|
424 |
+
border-top: 1px solid #ddd;
|
425 |
+
pointer-events: auto;
|
426 |
+
}
|
427 |
+
|
428 |
+
.acfe-modal.-open.acfe-modal-sub > .acfe-modal-wrapper > .acfe-modal-footer{
|
429 |
+
pointer-events: none;
|
430 |
+
}
|
431 |
+
|
432 |
+
.acfe-modal.-open .acfe-modal-footer > button{
|
433 |
+
vertical-align: baseline;
|
434 |
+
}
|
435 |
+
|
436 |
+
/*
|
437 |
+
* ACFE Modal Gutenberg Fix
|
438 |
+
*/
|
439 |
+
body.block-editor-page .edit-post-layout .acfe-modal.-open{
|
440 |
+
-webkit-box-pack: start;
|
441 |
+
-ms-flex-pack: start;
|
442 |
+
justify-content: start;
|
443 |
+
-webkit-box-align: start;
|
444 |
+
-ms-flex-align: start;
|
445 |
+
align-items: start;
|
446 |
+
}
|
447 |
+
|
448 |
+
body.block-editor-page .edit-post-layout .acfe-modal.-open > .acfe-modal-wrapper{
|
449 |
+
margin-top: 88px;
|
450 |
+
height: 100%;
|
451 |
+
width: 100%;
|
452 |
+
max-height: calc(100vh - 88px);
|
453 |
+
}
|
454 |
+
|
455 |
+
@media only screen and (max-width: 1080px) {
|
456 |
+
body.block-editor-page .edit-post-layout .acfe-modal.-open > .acfe-modal-wrapper{
|
457 |
+
margin-top: 125px;
|
458 |
+
}
|
459 |
+
}
|
460 |
+
|
461 |
+
body.block-editor-page .edit-post-layout .acfe-modal.-open > .acfe-modal-wrapper{
|
462 |
+
max-width: calc(100vw - 160px);
|
463 |
+
margin-left: 160px;
|
464 |
+
}
|
465 |
+
|
466 |
+
body.block-editor-page .edit-post-layout.is-sidebar-opened .acfe-modal.-open > .acfe-modal-wrapper{
|
467 |
+
max-width: calc(100vw - 440px);
|
468 |
+
}
|
469 |
+
|
470 |
+
|
471 |
+
body.block-editor-page.folded .edit-post-layout .acfe-modal.-open > .acfe-modal-wrapper{
|
472 |
+
max-width: calc(100vw - 36px);
|
473 |
+
margin-left:36px;
|
474 |
+
}
|
475 |
+
|
476 |
+
@media only screen and (max-width: 960px) {
|
477 |
+
body.block-editor-page.auto-fold .edit-post-layout .acfe-modal.-open > .acfe-modal-wrapper{
|
478 |
+
max-width: calc(100vw - 36px);
|
479 |
+
margin-left:36px;
|
480 |
+
}
|
481 |
+
}
|
482 |
+
|
483 |
+
@media only screen and (max-width: 782px) {
|
484 |
+
body.block-editor-page.auto-fold .edit-post-layout .acfe-modal.-open > .acfe-modal-wrapper{
|
485 |
+
max-width: 100vw;
|
486 |
+
margin-left:0;
|
487 |
+
margin-top: 100px;
|
488 |
+
}
|
489 |
+
}
|
490 |
+
|
491 |
+
body.block-editor-page.folded .edit-post-layout.is-sidebar-opened .acfe-modal.-open > .acfe-modal-wrapper{
|
492 |
+
max-width: calc(100vw - 316px);
|
493 |
+
}
|
494 |
+
|
495 |
+
body.block-editor-page .acfe-modal-overlay{
|
496 |
+
display:none;
|
497 |
}
|
assets/acf-extended-repeater.css
CHANGED
@@ -1,67 +1,83 @@
|
|
1 |
-
/*
|
2 |
-
* ACF Field: Repeater Lock
|
3 |
-
*/
|
4 |
-
.acf-field-repeater[data-acfe-repeater-lock="1"] > .acf-input > .acf-repeater > .acf-table > tbody > .acf-row > .acf-row-handle{
|
5 |
-
cursor:initial;
|
6 |
-
}
|
7 |
-
|
8 |
-
/*
|
9 |
-
* ACF Field: Repeater Block Fix (Add spacing)
|
10 |
-
*/
|
11 |
-
.acf-repeater.-row > table,
|
12 |
-
.acf-repeater.-block > table{
|
13 |
-
border-collapse: separate;
|
14 |
-
border-spacing: 0 15px;
|
15 |
-
background: none;
|
16 |
-
border: 0;
|
17 |
-
margin-top: -15px;
|
18 |
-
margin-bottom: -7px;
|
19 |
-
}
|
20 |
-
|
21 |
-
.acf-repeater.-row > table > *,
|
22 |
-
.acf-repeater.-block > table > *{
|
23 |
-
border-collapse: collapse;
|
24 |
-
border-spacing: 0;
|
25 |
-
}
|
26 |
-
|
27 |
-
.acf-repeater.-row > table > tbody > tr > td,
|
28 |
-
.acf-repeater.-block > table > tbody > tr > td{
|
29 |
-
border-top: 1px solid #
|
30 |
-
border-bottom: 1px solid #
|
31 |
-
}
|
32 |
-
|
33 |
-
.acf-repeater.-row > table > tbody > tr > td:first-of-type,
|
34 |
-
.acf-repeater.-block > table > tbody > tr > td:first-of-type{
|
35 |
-
border-left: 1px solid #
|
36 |
-
}
|
37 |
-
|
38 |
-
.acf-repeater.-row > table > tbody > tr > td:last-of-type,
|
39 |
-
.acf-repeater.-block > table > tbody > tr > td:last-of-type{
|
40 |
-
border-right: 1px solid #
|
41 |
-
}
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
}
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
}
|
1 |
+
/*
|
2 |
+
* ACF Field: Repeater Lock
|
3 |
+
*/
|
4 |
+
.acf-field-repeater[data-acfe-repeater-lock="1"] > .acf-input > .acf-repeater > .acf-table > tbody > .acf-row > .acf-row-handle{
|
5 |
+
cursor:initial;
|
6 |
+
}
|
7 |
+
|
8 |
+
/*
|
9 |
+
* ACF Field: Repeater Block Fix (Add spacing)
|
10 |
+
*/
|
11 |
+
.acf-repeater.-row > table,
|
12 |
+
.acf-repeater.-block > table{
|
13 |
+
border-collapse: separate;
|
14 |
+
border-spacing: 0 15px;
|
15 |
+
background: none;
|
16 |
+
border: 0;
|
17 |
+
margin-top: -15px;
|
18 |
+
margin-bottom: -7px;
|
19 |
+
}
|
20 |
+
|
21 |
+
.acf-repeater.-row > table > *,
|
22 |
+
.acf-repeater.-block > table > *{
|
23 |
+
border-collapse: collapse;
|
24 |
+
border-spacing: 0;
|
25 |
+
}
|
26 |
+
|
27 |
+
.acf-repeater.-row > table > tbody > tr > td,
|
28 |
+
.acf-repeater.-block > table > tbody > tr > td{
|
29 |
+
border-top: 1px solid #ccd0d4 !important;
|
30 |
+
border-bottom: 1px solid #ccd0d4 !important;
|
31 |
+
}
|
32 |
+
|
33 |
+
.acf-repeater.-row > table > tbody > tr > td:first-of-type,
|
34 |
+
.acf-repeater.-block > table > tbody > tr > td:first-of-type{
|
35 |
+
border-left: 1px solid #ccd0d4 !important;
|
36 |
+
}
|
37 |
+
|
38 |
+
.acf-repeater.-row > table > tbody > tr > td:last-of-type,
|
39 |
+
.acf-repeater.-block > table > tbody > tr > td:last-of-type{
|
40 |
+
border-right: 1px solid #ccd0d4 !important;
|
41 |
+
}
|
42 |
+
|
43 |
+
body:not(.acf-admin-5-3) .acf-repeater.-row > table > tbody > tr > td,
|
44 |
+
body:not(.acf-admin-5-3) .acf-repeater.-block > table > tbody > tr > td{
|
45 |
+
border-top: 1px solid #E1E1E1;
|
46 |
+
border-bottom: 1px solid #E1E1E1;
|
47 |
+
}
|
48 |
+
|
49 |
+
body:not(.acf-admin-5-3) .acf-repeater.-row > table > tbody > tr > td:first-of-type,
|
50 |
+
body:not(.acf-admin-5-3) .acf-repeater.-block > table > tbody > tr > td:first-of-type{
|
51 |
+
border-left: 1px solid #E1E1E1;
|
52 |
+
}
|
53 |
+
|
54 |
+
body:not(.acf-admin-5-3) .acf-repeater.-row > table > tbody > tr > td:last-of-type,
|
55 |
+
body:not(.acf-admin-5-3) .acf-repeater.-block > table > tbody > tr > td:last-of-type{
|
56 |
+
border-right: 1px solid #E1E1E1;
|
57 |
+
}
|
58 |
+
|
59 |
+
/*
|
60 |
+
* ACF Field: Repeater Table Fix (Remove headings when empty)
|
61 |
+
*/
|
62 |
+
.acf-repeater.-table.-empty > .acf-table{
|
63 |
+
display:none;
|
64 |
+
}
|
65 |
+
|
66 |
+
/*
|
67 |
+
* ACF Field: Repeater Add Row
|
68 |
+
*/
|
69 |
+
.acf-field-repeater > .acf-input > .acf-repeater > .acfe-repeater-stylised-button{
|
70 |
+
padding: 40px 20px;
|
71 |
+
border: #ccc dashed 2px;
|
72 |
+
text-align: center;
|
73 |
+
}
|
74 |
+
|
75 |
+
.acf-field-repeater > .acf-input > .acf-repeater > .acfe-repeater-stylised-button > .acf-actions{
|
76 |
+
text-align: center;
|
77 |
+
}
|
78 |
+
|
79 |
+
.acf-field-flexible-content > .acf-input > .acf-repeater .acf-actions .acf-button .dashicons{
|
80 |
+
width: auto;
|
81 |
+
height: auto;
|
82 |
+
vertical-align: text-top;
|
83 |
}
|
assets/acf-extended.css
CHANGED
@@ -1,303 +1,283 @@
|
|
1 |
-
/*
|
2 |
-
* ACF: Field fix
|
3 |
-
*/
|
4 |
-
.acf-field .acf-label label{
|
5 |
-
font-weight:600 !important;
|
6 |
-
}
|
7 |
-
|
8 |
-
.acf-field p.description{
|
9 |
-
word-break: break-word;
|
10 |
-
}
|
11 |
-
|
12 |
-
/*
|
13 |
-
* ACF: Field fix empty label on field group label placement left
|
14 |
-
*/
|
15 |
-
.acf-fields.-left > .acf-field > .acf-label{
|
16 |
-
min-height:1px;
|
17 |
-
}
|
18 |
-
|
19 |
-
.acf-field.acfe-no-label > .acf-label{
|
20 |
-
margin:0;
|
21 |
-
}
|
22 |
-
|
23 |
-
.acf-field.acfe-no-label > .acf-label > label{
|
24 |
-
display:none;
|
25 |
-
}
|
26 |
-
|
27 |
-
.acf-field.acfe-no-label > .acf-label > p.description{
|
28 |
-
margin-bottom:10px;
|
29 |
-
}
|
30 |
-
|
31 |
-
/*
|
32 |
-
* ACF Field: Textarea
|
33 |
-
*/
|
34 |
-
.acf-field-textarea[data-acfe-textarea-code="1"] > .acf-input > textarea{
|
35 |
-
font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
|
36 |
-
font-size: 1em;
|
37 |
-
}
|
38 |
-
|
39 |
-
/*
|
40 |
-
* ACFE Field: Code Editor
|
41 |
-
*/
|
42 |
-
.acf-field-acfe-code-editor > .acf-input > .acf-input-wrap > .CodeMirror-wrap{
|
43 |
-
border:1px solid #
|
44 |
-
height: auto;
|
45 |
-
}
|
46 |
-
|
47 |
-
.acf-field-acfe-code-editor > .acf-input > .acf-input-wrap > .CodeMirror-wrap
|
48 |
-
|
49 |
-
}
|
50 |
-
|
51 |
-
.acf-field-acfe-code-editor > .acf-input > .acf-input-wrap > .CodeMirror-wrap .CodeMirror-
|
52 |
-
background:#
|
53 |
-
}
|
54 |
-
|
55 |
-
.acf-field-acfe-code-editor > .acf-input > .acf-input-wrap > .CodeMirror-wrap .CodeMirror-
|
56 |
-
background:#
|
57 |
-
}
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
.
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
margin
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
.acf-fields > .acf-field-group.acfe-field-group-layout-
|
112 |
-
border-width:0;
|
113 |
-
}
|
114 |
-
|
115 |
-
.acf-fields
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
.acf-fields
|
122 |
-
.acf-fields
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
.acf-
|
142 |
-
.acf-
|
143 |
-
margin:
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
.acf-
|
148 |
-
.acf-
|
149 |
-
|
150 |
-
}
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
.acf-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
margin
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
.acf-fields > .acf-field-clone.acfe-field-clone-layout-
|
180 |
-
border-width:0;
|
181 |
-
}
|
182 |
-
|
183 |
-
.acf-fields
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
.acf-fields
|
190 |
-
.acf-fields
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
.
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
.acf-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
}
|
249 |
-
|
250 |
-
.acf-fields
|
251 |
-
|
252 |
-
}
|
253 |
-
|
254 |
-
.acf-fields
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
}
|
279 |
-
|
280 |
-
.acf-fields > .acf-field.acf-field-acfe-column[data-columns="
|
281 |
-
width:
|
282 |
-
|
283 |
-
|
284 |
-
.acf-fields > .acf-field.acf-field-acfe-column[data-columns="2/6"] {
|
285 |
-
width: 33.33333%;
|
286 |
-
}
|
287 |
-
|
288 |
-
.acf-fields > .acf-field.acf-field-acfe-column[data-columns="3/6"] {
|
289 |
-
width: 50%;
|
290 |
-
}
|
291 |
-
|
292 |
-
.acf-fields > .acf-field.acf-field-acfe-column[data-columns="4/6"] {
|
293 |
-
width: 66.66666%;
|
294 |
-
}
|
295 |
-
|
296 |
-
.acf-fields > .acf-field.acf-field-acfe-column[data-columns="5/6"] {
|
297 |
-
width: 83.33333%;
|
298 |
-
}
|
299 |
-
|
300 |
-
.acf-fields > .acf-field.acf-field-acfe-column[data-columns="6/6"] {
|
301 |
-
width: 100%;
|
302 |
-
border-right:0;
|
303 |
}
|
1 |
+
/*
|
2 |
+
* ACF: Field fix
|
3 |
+
*/
|
4 |
+
.acf-field .acf-label label{
|
5 |
+
font-weight:600 !important;
|
6 |
+
}
|
7 |
+
|
8 |
+
.acf-field p.description{
|
9 |
+
word-break: break-word;
|
10 |
+
}
|
11 |
+
|
12 |
+
/*
|
13 |
+
* ACF: Field fix empty label on field group label placement left
|
14 |
+
*/
|
15 |
+
.acf-fields.-left > .acf-field > .acf-label{
|
16 |
+
min-height:1px;
|
17 |
+
}
|
18 |
+
|
19 |
+
.acf-field.acfe-no-label > .acf-label{
|
20 |
+
margin:0;
|
21 |
+
}
|
22 |
+
|
23 |
+
.acf-field.acfe-no-label > .acf-label > label{
|
24 |
+
display:none;
|
25 |
+
}
|
26 |
+
|
27 |
+
.acf-field.acfe-no-label > .acf-label > p.description{
|
28 |
+
margin-bottom:10px;
|
29 |
+
}
|
30 |
+
|
31 |
+
/*
|
32 |
+
* ACF Field: Textarea
|
33 |
+
*/
|
34 |
+
.acf-field-textarea[data-acfe-textarea-code="1"] > .acf-input > textarea{
|
35 |
+
font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
|
36 |
+
font-size: 1em;
|
37 |
+
}
|
38 |
+
|
39 |
+
/*
|
40 |
+
* ACFE Field: Code Editor
|
41 |
+
*/
|
42 |
+
.acf-field-acfe-code-editor > .acf-input > .acf-input-wrap > .CodeMirror-wrap{
|
43 |
+
border:1px solid #7e8993;
|
44 |
+
height: auto;
|
45 |
+
}
|
46 |
+
|
47 |
+
body:not(.acf-admin-5-3) .acf-field-acfe-code-editor > .acf-input > .acf-input-wrap > .CodeMirror-wrap{
|
48 |
+
border-color:#dfdfdf;
|
49 |
+
}
|
50 |
+
|
51 |
+
.acf-field-acfe-code-editor > .acf-input > .acf-input-wrap > .CodeMirror-wrap .CodeMirror-activeline-background{
|
52 |
+
background:#f9f9f9;
|
53 |
+
}
|
54 |
+
|
55 |
+
.acf-field-acfe-code-editor > .acf-input > .acf-input-wrap > .CodeMirror-wrap .CodeMirror-selected{
|
56 |
+
background:#f0f0f0 !important;
|
57 |
+
}
|
58 |
+
|
59 |
+
.acf-field-acfe-code-editor > .acf-input > .acf-input-wrap > .CodeMirror-wrap .CodeMirror-gutters{
|
60 |
+
background:#f9f9f9;
|
61 |
+
}
|
62 |
+
|
63 |
+
/*
|
64 |
+
* ACF Field: Accordion
|
65 |
+
*/
|
66 |
+
.acf-accordion{
|
67 |
+
z-index:initial;
|
68 |
+
}
|
69 |
+
|
70 |
+
/*
|
71 |
+
* ACF Field: Group
|
72 |
+
*/
|
73 |
+
.acf-fields > .acf-field-group.acfe-field-group-layout-block.acfe-seemless-style:not([data-acfe-group-modal="1"]) > .acf-input,
|
74 |
+
.acf-fields > .acf-field-group.acfe-field-group-layout-row.acfe-seemless-style:not([data-acfe-group-modal="1"]) > .acf-input{
|
75 |
+
margin-left: -12px;
|
76 |
+
margin-right: -12px;
|
77 |
+
margin-bottom: -15px;
|
78 |
+
}
|
79 |
+
.acf-fields > .acf-field-group.acfe-field-group-layout-block.acfe-seemless-style.acfe-no-label:not([data-acfe-group-modal="1"]) > .acf-input,
|
80 |
+
.acf-fields > .acf-field-group.acfe-field-group-layout-row.acfe-seemless-style.acfe-no-label:not([data-acfe-group-modal="1"]) > .acf-input{
|
81 |
+
margin-top: -15px;
|
82 |
+
}
|
83 |
+
.acf-fields > .acf-field-group.acfe-field-group-layout-row.acfe-seemless-style.acfe-no-label > .acf-input > .acf-fields{
|
84 |
+
border-width:0;
|
85 |
+
}
|
86 |
+
.acf-fields > .acf-field-group.acfe-field-group-layout-row.acfe-seemless-style > .acf-input > .acf-fields{
|
87 |
+
border-left-width:0;
|
88 |
+
border-right-width:0;
|
89 |
+
border-bottom-width:0;
|
90 |
+
}
|
91 |
+
.acf-fields > .acf-field-group.acfe-field-group-layout-block.acfe-seemless-style > .acf-input > .acf-fields{
|
92 |
+
border-width:0;
|
93 |
+
}
|
94 |
+
|
95 |
+
.acf-fields.-left > .acf-field-group.acfe-field-group-layout-row.acfe-seemless-style > .acf-input{
|
96 |
+
margin:0;
|
97 |
+
}
|
98 |
+
.acf-fields.-left > .acf-field-group.acfe-field-group-layout-row.acfe-seemless-style > .acf-input > .acf-fields{
|
99 |
+
border-width:1px;
|
100 |
+
}
|
101 |
+
.acf-fields.-left > .acf-field-group.acfe-field-group-layout-block.acfe-seemless-style:not([data-acfe-group-modal="1"]) > .acf-input,
|
102 |
+
.acf-fields.-left > .acf-field-group.acfe-field-group-layout-table.acfe-seemless-style:not([data-acfe-group-modal="1"]) > .acf-input{
|
103 |
+
padding:0;
|
104 |
+
padding-left:1px;
|
105 |
+
margin-top: -15px;
|
106 |
+
margin-bottom: -15px;
|
107 |
+
margin-left: 0;
|
108 |
+
margin-right: 0;
|
109 |
+
}
|
110 |
+
.acf-fields.-left > .acf-field-group.acfe-field-group-layout-block.acfe-seemless-style > .acf-input > .acf-fields,
|
111 |
+
.acf-fields.-left > .acf-field-group.acfe-field-group-layout-table.acfe-seemless-style > .acf-input > .acf-table{
|
112 |
+
border-width:0;
|
113 |
+
}
|
114 |
+
|
115 |
+
.acf-fields > .acf-field-group[data-acfe-group-modal="1"] > .acf-input > .acfe-modal > .acfe-modal-wrapper > .acfe-modal-content > .acf-table,
|
116 |
+
.acf-fields > .acf-field-group[data-acfe-group-modal="1"] > .acf-input > .acfe-modal > .acfe-modal-wrapper > .acfe-modal-content > .acf-fields{
|
117 |
+
border-width:0;
|
118 |
+
}
|
119 |
+
|
120 |
+
.acf-postbox.seamless > .acf-fields > .acf-field-group.acfe-field-group-layout-block.acfe-seemless-style > .acf-input,
|
121 |
+
.acf-postbox.seamless > .acf-fields > .acf-field-group.acfe-field-group-layout-row.acfe-seemless-style > .acf-input,
|
122 |
+
.acf-postbox.seamless > .acf-fields > .acf-field-group.acfe-field-group-layout-table.acfe-seemless-style > .acf-table{
|
123 |
+
margin:0;
|
124 |
+
}
|
125 |
+
|
126 |
+
.acf-postbox.seamless > .acf-fields > .acf-field-group.acfe-field-group-layout-block.acfe-seemless-style > .acf-input > .acf-fields,
|
127 |
+
.acf-postbox.seamless > .acf-fields > .acf-field-group.acfe-field-group-layout-row.acfe-seemless-style > .acf-input > .acf-fields,
|
128 |
+
.acf-postbox.seamless > .acf-fields > .acf-field-group.acfe-field-group-layout-table.acfe-seemless-style > .acf-input > .acf-table{
|
129 |
+
border-width:1px;
|
130 |
+
}
|
131 |
+
|
132 |
+
.acf-postbox.seamless > .acf-fields.-left > .acf-field-group.acfe-field-group-layout-block.acfe-seemless-style > .acf-input,
|
133 |
+
.acf-postbox.seamless > .acf-fields.-left > .acf-field-group.acfe-field-group-layout-row.acfe-seemless-style > .acf-input,
|
134 |
+
.acf-postbox.seamless > .acf-fields.-left > .acf-field-group.acfe-field-group-layout-table.acfe-seemless-style > .acf-input{
|
135 |
+
padding:0 12px;
|
136 |
+
}
|
137 |
+
|
138 |
+
/*
|
139 |
+
* ACF Field: Clone
|
140 |
+
*/
|
141 |
+
.acf-fields > .acf-field-clone.acfe-field-clone-layout-block.acfe-seemless-style:not([data-acfe-clone-modal="1"]) > .acf-input,
|
142 |
+
.acf-fields > .acf-field-clone.acfe-field-clone-layout-row.acfe-seemless-style:not([data-acfe-clone-modal="1"]) > .acf-input{
|
143 |
+
margin-left: -12px;
|
144 |
+
margin-right: -12px;
|
145 |
+
margin-bottom: -15px;
|
146 |
+
}
|
147 |
+
.acf-fields > .acf-field-clone.acfe-field-clone-layout-block.acfe-no-label.acfe-seemless-style:not([data-acfe-clone-modal="1"]) > .acf-input,
|
148 |
+
.acf-fields > .acf-field-clone.acfe-field-clone-layout-row.acfe-no-label.acfe-seemless-style:not([data-acfe-clone-modal="1"]) > .acf-input{
|
149 |
+
margin-top: -15px;
|
150 |
+
}
|
151 |
+
.acf-fields > .acf-field-clone.acfe-field-clone-layout-row.acfe-no-label.acfe-seemless-style > .acf-input > .acf-fields{
|
152 |
+
border-width:0;
|
153 |
+
}
|
154 |
+
.acf-fields > .acf-field-clone.acfe-field-clone-layout-row.acfe-seemless-style > .acf-input > .acf-fields{
|
155 |
+
border-left-width:0;
|
156 |
+
border-right-width:0;
|
157 |
+
border-bottom-width:0;
|
158 |
+
}
|
159 |
+
.acf-fields > .acf-field-clone.acfe-field-clone-layout-block.acfe-seemless-style > .acf-input > .acf-fields{
|
160 |
+
border-width:0;
|
161 |
+
}
|
162 |
+
|
163 |
+
.acf-fields.-left > .acf-field-clone.acfe-field-clone-layout-row.acfe-seemless-style > .acf-input{
|
164 |
+
margin:0;
|
165 |
+
}
|
166 |
+
.acf-fields.-left > .acf-field-clone.acfe-field-clone-layout-row.acfe-seemless-style > .acf-input > .acf-fields{
|
167 |
+
border-width:1px;
|
168 |
+
}
|
169 |
+
.acf-fields.-left > .acf-field-clone.acfe-field-clone-layout-block.acfe-seemless-style:not([data-acfe-clone-modal="1"]) > .acf-input,
|
170 |
+
.acf-fields.-left > .acf-field-clone.acfe-field-clone-layout-table.acfe-seemless-style:not([data-acfe-clone-modal="1"]) > .acf-input{
|
171 |
+
padding:0;
|
172 |
+
padding-left:1px;
|
173 |
+
margin-top: -15px;
|
174 |
+
margin-bottom: -15px;
|
175 |
+
margin-left: 0;
|
176 |
+
margin-right: 0;
|
177 |
+
}
|
178 |
+
.acf-fields.-left > .acf-field-clone.acfe-field-clone-layout-block.acfe-seemless-style > .acf-input > .acf-fields,
|
179 |
+
.acf-fields.-left > .acf-field-clone.acfe-field-clone-layout-table.acfe-seemless-style > .acf-input > .acf-table{
|
180 |
+
border-width:0;
|
181 |
+
}
|
182 |
+
|
183 |
+
.acf-fields > .acf-field-clone[data-acfe-clone-modal="1"] > .acf-input > .acfe-modal > .acfe-modal-wrapper > .acfe-modal-content > .acf-table,
|
184 |
+
.acf-fields > .acf-field-clone[data-acfe-clone-modal="1"] > .acf-input > .acfe-modal > .acfe-modal-wrapper > .acfe-modal-content > .acf-fields{
|
185 |
+
border-width:0;
|
186 |
+
}
|
187 |
+
|
188 |
+
.acf-postbox.seamless > .acf-fields > .acf-field-clone.acfe-field-clone-layout-block.acfe-seemless-style > .acf-input,
|
189 |
+
.acf-postbox.seamless > .acf-fields > .acf-field-clone.acfe-field-clone-layout-row.acfe-seemless-style > .acf-input,
|
190 |
+
.acf-postbox.seamless > .acf-fields > .acf-field-clone.acfe-field-clone-layout-table.acfe-seemless-style > .acf-table{
|
191 |
+
margin:0;
|
192 |
+
}
|
193 |
+
|
194 |
+
.acf-postbox.seamless > .acf-fields > .acf-field-clone.acfe-field-clone-layout-block.acfe-seemless-style > .acf-input > .acf-fields,
|
195 |
+
.acf-postbox.seamless > .acf-fields > .acf-field-clone.acfe-field-clone-layout-row.acfe-seemless-style > .acf-input > .acf-fields,
|
196 |
+
.acf-postbox.seamless > .acf-fields > .acf-field-clone.acfe-field-clone-layout-table.acfe-seemless-style > .acf-input > .acf-table{
|
197 |
+
border-width:1px;
|
198 |
+
}
|
199 |
+
|
200 |
+
.acf-postbox.seamless > .acf-fields.-left > .acf-field-clone.acfe-field-clone-layout-block.acfe-seemless-style > .acf-input,
|
201 |
+
.acf-postbox.seamless > .acf-fields.-left > .acf-field-clone.acfe-field-clone-layout-row.acfe-seemless-style > .acf-input,
|
202 |
+
.acf-postbox.seamless > .acf-fields.-left > .acf-field-clone.acfe-field-clone-layout-table.acfe-seemless-style > .acf-input{
|
203 |
+
padding:0 12px;
|
204 |
+
}
|
205 |
+
|
206 |
+
/*
|
207 |
+
* ACFE Form
|
208 |
+
*/
|
209 |
+
form.acfe-form.is-invalid[data-hide-error="1"] > .acf-error-message.-dismiss{
|
210 |
+
display:none;
|
211 |
+
}
|
212 |
+
|
213 |
+
form.acfe-form.is-invalid[data-errors-position="below"] .acf-field .acf-notice{
|
214 |
+
margin:15px 0 0;
|
215 |
+
}
|
216 |
+
|
217 |
+
/*
|
218 |
+
* ACFE Column
|
219 |
+
*/
|
220 |
+
.acf-fields > .acf-field.acf-field-acfe-column{
|
221 |
+
float: left;
|
222 |
+
clear: none;
|
223 |
+
-webkit-box-sizing: border-box;
|
224 |
+
-moz-box-sizing: border-box;
|
225 |
+
box-sizing: border-box;
|
226 |
+
padding:0;
|
227 |
+
border-top-width:0;
|
228 |
+
}
|
229 |
+
|
230 |
+
.acf-fields.-left > .acf-field.acf-field-acfe-column{
|
231 |
+
border-right: 1px solid #eee;
|
232 |
+
}
|
233 |
+
|
234 |
+
.acf-fields.-left > .acf-field.acf-field-acfe-column:before{
|
235 |
+
content: "";
|
236 |
+
display: block;
|
237 |
+
position: initial;
|
238 |
+
background: none;
|
239 |
+
border: 0;
|
240 |
+
width: auto;
|
241 |
+
}
|
242 |
+
|
243 |
+
.acf-fields.-left > .acf-field.acf-field-acfe-column > .acf-input{
|
244 |
+
float:none;
|
245 |
+
width:auto;
|
246 |
+
margin:0;
|
247 |
+
padding:0;
|
248 |
+
}
|
249 |
+
|
250 |
+
.acf-fields > .acf-field.acf-field-acfe-column > .acf-input > .acf-fields > .acf-field{
|
251 |
+
border-top-width:0;
|
252 |
+
}
|
253 |
+
|
254 |
+
.acf-fields > .acf-field.acf-field-acfe-column[data-endpoint="1"]{
|
255 |
+
clear: both;
|
256 |
+
border-top: 1px solid #eee;
|
257 |
+
width:100%;
|
258 |
+
}
|
259 |
+
|
260 |
+
.acf-fields > .acf-field.acf-field-acfe-column[data-columns="1/6"] {
|
261 |
+
width: 16.66666666%;
|
262 |
+
}
|
263 |
+
|
264 |
+
.acf-fields > .acf-field.acf-field-acfe-column[data-columns="2/6"] {
|
265 |
+
width: 33.33333%;
|
266 |
+
}
|
267 |
+
|
268 |
+
.acf-fields > .acf-field.acf-field-acfe-column[data-columns="3/6"] {
|
269 |
+
width: 50%;
|
270 |
+
}
|
271 |
+
|
272 |
+
.acf-fields > .acf-field.acf-field-acfe-column[data-columns="4/6"] {
|
273 |
+
width: 66.66666%;
|
274 |
+
}
|
275 |
+
|
276 |
+
.acf-fields > .acf-field.acf-field-acfe-column[data-columns="5/6"] {
|
277 |
+
width: 83.33333%;
|
278 |
+
}
|
279 |
+
|
280 |
+
.acf-fields > .acf-field.acf-field-acfe-column[data-columns="6/6"] {
|
281 |
+
width: 100%;
|
282 |
+
border-right:0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
283 |
}
|
assets/acf-extended.js
CHANGED
@@ -1,193 +1,199 @@
|
|
1 |
-
(function($){
|
2 |
-
|
3 |
-
// init
|
4 |
-
var acfe = {};
|
5 |
-
|
6 |
-
window.acfe = acfe;
|
7 |
-
|
8 |
-
acfe.modal = {
|
9 |
-
|
10 |
-
modals: [],
|
11 |
-
|
12 |
-
// Open
|
13 |
-
open: function($target, args){
|
14 |
-
|
15 |
-
var model = this;
|
16 |
-
|
17 |
-
args = acf.parseArgs(args, {
|
18 |
-
title: '',
|
19 |
-
footer: false,
|
20 |
-
size: false,
|
21 |
-
destroy: false,
|
22 |
-
onClose: false,
|
23 |
-
});
|
24 |
-
|
25 |
-
model.args = args;
|
26 |
-
|
27 |
-
$target.addClass('-open');
|
28 |
-
|
29 |
-
if(args.size){
|
30 |
-
|
31 |
-
$target.addClass('-' + args.size);
|
32 |
-
|
33 |
-
}
|
34 |
-
|
35 |
-
if(!$target.find('> .acfe-modal-wrapper').length){
|
36 |
-
|
37 |
-
$target.wrapInner('<div class="acfe-modal-wrapper" />');
|
38 |
-
|
39 |
-
}
|
40 |
-
|
41 |
-
if(!$target.find('> .acfe-modal-wrapper > .acfe-modal-content').length){
|
42 |
-
|
43 |
-
$target.find('> .acfe-modal-wrapper').wrapInner('<div class="acfe-modal-content" />');
|
44 |
-
|
45 |
-
}
|
46 |
-
|
47 |
-
$target.find('> .acfe-modal-wrapper').prepend('<div class="acfe-modal-wrapper-overlay"></div><div class="acfe-modal-title"><span class="title">' + args.title + '</span><button class="close"></button></div>');
|
48 |
-
|
49 |
-
$target.find('.acfe-modal-title > .close').click(function(e){
|
50 |
-
|
51 |
-
e.preventDefault();
|
52 |
-
model.close(args);
|
53 |
-
|
54 |
-
});
|
55 |
-
|
56 |
-
if(args.footer){
|
57 |
-
|
58 |
-
$target.find('> .acfe-modal-wrapper').append('<div class="acfe-modal-footer"><button class="button button-primary">' + args.footer + '</button></div>');
|
59 |
-
|
60 |
-
$target.find('.acfe-modal-footer > button').click(function(e){
|
61 |
-
|
62 |
-
e.preventDefault();
|
63 |
-
model.close(args);
|
64 |
-
|
65 |
-
});
|
66 |
-
|
67 |
-
}
|
68 |
-
|
69 |
-
acfe.modal.modals.push($target);
|
70 |
-
|
71 |
-
var $body = $('body');
|
72 |
-
|
73 |
-
if(!$body.hasClass('acfe-modal-opened')){
|
74 |
-
|
75 |
-
var overlay = $('<div class="acfe-modal-overlay" />');
|
76 |
-
|
77 |
-
$body.addClass('acfe-modal-opened').append(overlay);
|
78 |
-
|
79 |
-
$body.find('.acfe-modal-overlay').click(function(e){
|
80 |
-
|
81 |
-
e.preventDefault();
|
82 |
-
model.close(model.args);
|
83 |
-
|
84 |
-
});
|
85 |
-
|
86 |
-
$(window).keydown(function(e){
|
87 |
-
|
88 |
-
if(e.keyCode !== 27 || !$('body').hasClass('acfe-modal-opened'))
|
89 |
-
return;
|
90 |
-
|
91 |
-
e.preventDefault();
|
92 |
-
model.close(model.args);
|
93 |
-
|
94 |
-
});
|
95 |
-
|
96 |
-
}
|
97 |
-
|
98 |
-
acfe.modal.multiple();
|
99 |
-
|
100 |
-
return $target;
|
101 |
-
|
102 |
-
},
|
103 |
-
|
104 |
-
// Close
|
105 |
-
close: function(args){
|
106 |
-
|
107 |
-
args = acf.parseArgs(args, {
|
108 |
-
destroy: false,
|
109 |
-
onClose: false,
|
110 |
-
});
|
111 |
-
|
112 |
-
var $target = acfe.modal.modals.pop();
|
113 |
-
|
114 |
-
$target.find('.acfe-modal-wrapper-overlay').remove();
|
115 |
-
$target.find('.acfe-modal-title').remove();
|
116 |
-
$target.find('.acfe-modal-footer').remove();
|
117 |
-
|
118 |
-
$target.removeAttr('style');
|
119 |
-
|
120 |
-
$target.removeClass('-open -small -full');
|
121 |
-
|
122 |
-
if(args.destroy){
|
123 |
-
|
124 |
-
$target.remove();
|
125 |
-
|
126 |
-
}
|
127 |
-
|
128 |
-
if(!acfe.modal.modals.length){
|
129 |
-
|
130 |
-
$('.acfe-modal-overlay').remove();
|
131 |
-
$('body').removeClass('acfe-modal-opened');
|
132 |
-
|
133 |
-
}
|
134 |
-
|
135 |
-
acfe.modal.multiple();
|
136 |
-
|
137 |
-
acfe.modal.onClose($target, args);
|
138 |
-
|
139 |
-
},
|
140 |
-
|
141 |
-
// Multiple
|
142 |
-
multiple: function(){
|
143 |
-
|
144 |
-
var last = acfe.modal.modals.length - 1;
|
145 |
-
|
146 |
-
$.each(acfe.modal.modals, function(i){
|
147 |
-
|
148 |
-
if(last == i){
|
149 |
-
$(this).removeClass('acfe-modal-sub').css('margin-left', '');
|
150 |
-
return;
|
151 |
-
}
|
152 |
-
|
153 |
-
$(this).addClass('acfe-modal-sub').css('margin-left', - (500 / (i+1)));
|
154 |
-
|
155 |
-
});
|
156 |
-
|
157 |
-
},
|
158 |
-
|
159 |
-
onClose: function($target, args){
|
160 |
-
|
161 |
-
if(!args.onClose || !(args.onClose instanceof Function))
|
162 |
-
return;
|
163 |
-
|
164 |
-
args.onClose($target);
|
165 |
-
|
166 |
-
}
|
167 |
-
|
168 |
-
};
|
169 |
-
|
170 |
-
acf.addAction('ready_field', function(field){
|
171 |
-
|
172 |
-
if(!field.has('acfeInstructionsTooltip'))
|
173 |
-
return;
|
174 |
-
|
175 |
-
var $label = field.$el.find('> .acf-label > label');
|
176 |
-
|
177 |
-
if($label.length){
|
178 |
-
|
179 |
-
$label.before('<span class="acf-js-tooltip dashicons dashicons-info" style="float:right; font-size:16px; color:#ccc;" title="' + _.escape(field.get('acfeInstructionsTooltip')) + '"></span>');
|
180 |
-
|
181 |
-
}
|
182 |
-
|
183 |
-
});
|
184 |
-
|
185 |
-
acf.addAction('new_field/name=acfe_form_custom_action', function(field){
|
186 |
-
|
187 |
-
var $instructions = field.$el.find('> .acf-label > .description');
|
188 |
-
|
189 |
-
field.$el.find('> .acf-input').append($instructions);
|
190 |
-
|
191 |
-
});
|
192 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
})(jQuery);
|
1 |
+
(function($){
|
2 |
+
|
3 |
+
// init
|
4 |
+
var acfe = {};
|
5 |
+
|
6 |
+
window.acfe = acfe;
|
7 |
+
|
8 |
+
acfe.modal = {
|
9 |
+
|
10 |
+
modals: [],
|
11 |
+
|
12 |
+
// Open
|
13 |
+
open: function($target, args){
|
14 |
+
|
15 |
+
var model = this;
|
16 |
+
|
17 |
+
args = acf.parseArgs(args, {
|
18 |
+
title: '',
|
19 |
+
footer: false,
|
20 |
+
size: false,
|
21 |
+
destroy: false,
|
22 |
+
onClose: false,
|
23 |
+
});
|
24 |
+
|
25 |
+
model.args = args;
|
26 |
+
|
27 |
+
$target.addClass('-open');
|
28 |
+
|
29 |
+
if(args.size){
|
30 |
+
|
31 |
+
$target.addClass('-' + args.size);
|
32 |
+
|
33 |
+
}
|
34 |
+
|
35 |
+
if(!$target.find('> .acfe-modal-wrapper').length){
|
36 |
+
|
37 |
+
$target.wrapInner('<div class="acfe-modal-wrapper" />');
|
38 |
+
|
39 |
+
}
|
40 |
+
|
41 |
+
if(!$target.find('> .acfe-modal-wrapper > .acfe-modal-content').length){
|
42 |
+
|
43 |
+
$target.find('> .acfe-modal-wrapper').wrapInner('<div class="acfe-modal-content" />');
|
44 |
+
|
45 |
+
}
|
46 |
+
|
47 |
+
$target.find('> .acfe-modal-wrapper').prepend('<div class="acfe-modal-wrapper-overlay"></div><div class="acfe-modal-title"><span class="title">' + args.title + '</span><button class="close"></button></div>');
|
48 |
+
|
49 |
+
$target.find('.acfe-modal-title > .close').click(function(e){
|
50 |
+
|
51 |
+
e.preventDefault();
|
52 |
+
model.close(args);
|
53 |
+
|
54 |
+
});
|
55 |
+
|
56 |
+
if(args.footer){
|
57 |
+
|
58 |
+
$target.find('> .acfe-modal-wrapper').append('<div class="acfe-modal-footer"><button class="button button-primary">' + args.footer + '</button></div>');
|
59 |
+
|
60 |
+
$target.find('.acfe-modal-footer > button').click(function(e){
|
61 |
+
|
62 |
+
e.preventDefault();
|
63 |
+
model.close(args);
|
64 |
+
|
65 |
+
});
|
66 |
+
|
67 |
+
}
|
68 |
+
|
69 |
+
acfe.modal.modals.push($target);
|
70 |
+
|
71 |
+
var $body = $('body');
|
72 |
+
|
73 |
+
if(!$body.hasClass('acfe-modal-opened')){
|
74 |
+
|
75 |
+
var overlay = $('<div class="acfe-modal-overlay" />');
|
76 |
+
|
77 |
+
$body.addClass('acfe-modal-opened').append(overlay);
|
78 |
+
|
79 |
+
$body.find('.acfe-modal-overlay').click(function(e){
|
80 |
+
|
81 |
+
e.preventDefault();
|
82 |
+
model.close(model.args);
|
83 |
+
|
84 |
+
});
|
85 |
+
|
86 |
+
$(window).keydown(function(e){
|
87 |
+
|
88 |
+
if(e.keyCode !== 27 || !$('body').hasClass('acfe-modal-opened'))
|
89 |
+
return;
|
90 |
+
|
91 |
+
e.preventDefault();
|
92 |
+
model.close(model.args);
|
93 |
+
|
94 |
+
});
|
95 |
+
|
96 |
+
}
|
97 |
+
|
98 |
+
acfe.modal.multiple();
|
99 |
+
|
100 |
+
return $target;
|
101 |
+
|
102 |
+
},
|
103 |
+
|
104 |
+
// Close
|
105 |
+
close: function(args){
|
106 |
+
|
107 |
+
args = acf.parseArgs(args, {
|
108 |
+
destroy: false,
|
109 |
+
onClose: false,
|
110 |
+
});
|
111 |
+
|
112 |
+
var $target = acfe.modal.modals.pop();
|
113 |
+
|
114 |
+
$target.find('.acfe-modal-wrapper-overlay').remove();
|
115 |
+
$target.find('.acfe-modal-title').remove();
|
116 |
+
$target.find('.acfe-modal-footer').remove();
|
117 |
+
|
118 |
+
$target.removeAttr('style');
|
119 |
+
|
120 |
+
$target.removeClass('-open -small -full');
|
121 |
+
|
122 |
+
if(args.destroy){
|
123 |
+
|
124 |
+
$target.remove();
|
125 |
+
|
126 |
+
}
|
127 |
+
|
128 |
+
if(!acfe.modal.modals.length){
|
129 |
+
|
130 |
+
$('.acfe-modal-overlay').remove();
|
131 |
+
$('body').removeClass('acfe-modal-opened');
|
132 |
+
|
133 |
+
}
|
134 |
+
|
135 |
+
acfe.modal.multiple();
|
136 |
+
|
137 |
+
acfe.modal.onClose($target, args);
|
138 |
+
|
139 |
+
},
|
140 |
+
|
141 |
+
// Multiple
|
142 |
+
multiple: function(){
|
143 |
+
|
144 |
+
var last = acfe.modal.modals.length - 1;
|
145 |
+
|
146 |
+
$.each(acfe.modal.modals, function(i){
|
147 |
+
|
148 |
+
if(last == i){
|
149 |
+
$(this).removeClass('acfe-modal-sub').css('margin-left', '');
|
150 |
+
return;
|
151 |
+
}
|
152 |
+
|
153 |
+
$(this).addClass('acfe-modal-sub').css('margin-left', - (500 / (i+1)));
|
154 |
+
|
155 |
+
});
|
156 |
+
|
157 |
+
},
|
158 |
+
|
159 |
+
onClose: function($target, args){
|
160 |
+
|
161 |
+
if(!args.onClose || !(args.onClose instanceof Function))
|
162 |
+
return;
|
163 |
+
|
164 |
+
args.onClose($target);
|
165 |
+
|
166 |
+
}
|
167 |
+
|
168 |
+
};
|
169 |
+
|
170 |
+
acf.addAction('ready_field', function(field){
|
171 |
+
|
172 |
+
if(!field.has('acfeInstructionsTooltip'))
|
173 |
+
return;
|
174 |
+
|
175 |
+
var $label = field.$el.find('> .acf-label > label');
|
176 |
+
|
177 |
+
if($label.length){
|
178 |
+
|
179 |
+
$label.before('<span class="acf-js-tooltip dashicons dashicons-info" style="float:right; font-size:16px; color:#ccc;" title="' + _.escape(field.get('acfeInstructionsTooltip')) + '"></span>');
|
180 |
+
|
181 |
+
}
|
182 |
+
|
183 |
+
});
|
184 |
+
|
185 |
+
acf.addAction('new_field/name=acfe_form_custom_action', function(field){
|
186 |
+
|
187 |
+
var $instructions = field.$el.find('> .acf-label > .description');
|
188 |
+
|
189 |
+
field.$el.find('> .acf-input').append($instructions);
|
190 |
+
|
191 |
+
});
|
192 |
+
|
193 |
+
acf.addAction('new_field/name=acfe_form_email_files', function(field){
|
194 |
+
|
195 |
+
field.$el.find('> .acf-input > .acf-repeater > .acf-actions > .acf-button').removeClass('button-primary');
|
196 |
+
|
197 |
+
});
|
198 |
+
|
199 |
})(jQuery);
|
includes/admin/settings.php
CHANGED
@@ -1,393 +1,399 @@
|
|
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 |
-
|
9 |
-
if(!acf_get_setting('show_admin'))
|
10 |
-
return;
|
11 |
-
|
12 |
-
$submenu_page = add_submenu_page('edit.php?post_type=acf-field-group', __('Settings'), __('Settings'), acf_get_setting('capability'), 'acfe-settings', 'acfe_admin_settings_html');
|
13 |
-
|
14 |
-
add_action('admin_print_scripts-' . $submenu_page, function(){
|
15 |
-
acf_enqueue_scripts();
|
16 |
-
});
|
17 |
-
|
18 |
-
}
|
19 |
-
|
20 |
-
function acfe_admin_settings_html(){
|
21 |
-
?>
|
22 |
-
<div class="wrap" id="acfe-admin-settings">
|
23 |
-
|
24 |
-
<h1><?php _e('Settings'); ?></h1>
|
25 |
-
|
26 |
-
<div id="poststuff">
|
27 |
-
|
28 |
-
<div class="postbox acf-postbox">
|
29 |
-
<h2 class="hndle ui-sortable-handle"><span><?php _e('Settings'); ?></span></h2>
|
30 |
-
<div class="inside acf-fields -left">
|
31 |
-
|
32 |
-
<?php
|
33 |
-
acf_render_field_wrap(array(
|
34 |
-
'type' => 'tab',
|
35 |
-
'label' => 'ACF',
|
36 |
-
));
|
37 |
-
?>
|
38 |
-
|
39 |
-
<?php
|
40 |
-
|
41 |
-
$load_json = acf_get_setting('load_json');
|
42 |
-
$load_json_text = '';
|
43 |
-
|
44 |
-
if(!empty($load_json))
|
45 |
-
$load_json_text = implode("<br />", $load_json);
|
46 |
-
|
47 |
-
$settings = array(
|
48 |
-
array(
|
49 |
-
'name' => 'path',
|
50 |
-
'label' => 'Path',
|
51 |
-
'value' => '<code>' . acf_get_setting('path') . '</code>',
|
52 |
-
'description' => 'Absolute path to ACF plugin folder including trailing slash.<br />Defaults to plugin_dir_path'
|
53 |
-
),
|
54 |
-
array(
|
55 |
-
'name' => 'dir',
|
56 |
-
'label' => 'Directory',
|
57 |
-
'value' => '<code>' . acf_get_setting('dir') . '</code>',
|
58 |
-
'description' => 'URL to ACF plugin folder including trailing slash. Defaults to plugin_dir_url'
|
59 |
-
),
|
60 |
-
array(
|
61 |
-
'name' => 'show_admin',
|
62 |
-
'label' => 'Show menu',
|
63 |
-
'value' => '<code>' . (acf_get_setting('show_admin') ? __('True'): __('False')) . '</code>',
|
64 |
-
'description' => 'Show/hide ACF menu item. Defaults to true'
|
65 |
-
),
|
66 |
-
array(
|
67 |
-
'name' => 'stripslashes',
|
68 |
-
'label' => 'Strip slashes',
|
69 |
-
'value' => '<code>' . (acf_get_setting('stripslashes') ? __('True'): __('False')) . '</code>',
|
70 |
-
'description' => 'Runs the function stripslashes on all $_POST data. Some servers / WP instals may require this extra functioanlity. Defaults to false'
|
71 |
-
),
|
72 |
-
array(
|
73 |
-
'name' => 'local',
|
74 |
-
'label' => 'PHP/Json',
|
75 |
-
'value' => '<code>' . (acf_get_setting('local') ? __('True'): __('False')) . '</code>',
|
76 |
-
'description' => 'Enable/Disable local (PHP/json) fields. Defaults to true'
|
77 |
-
),
|
78 |
-
array(
|
79 |
-
'name' => 'json',
|
80 |
-
'label' => 'Json',
|
81 |
-
'value' => '<code>' . (acf_get_setting('json') ? __('True'): __('False')) . '</code>',
|
82 |
-
'description' => 'Enable/Disable json fields. Defaults to true'
|
83 |
-
),
|
84 |
-
array(
|
85 |
-
'name' => 'save_json',
|
86 |
-
'label' => 'Json folder (save)',
|
87 |
-
'value' => '<code>' . acf_get_setting('save_json') . '</code>',
|
88 |
-
'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'
|
89 |
-
),
|
90 |
-
array(
|
91 |
-
'name' => 'load_json',
|
92 |
-
'label' => 'Json folder (load)',
|
93 |
-
'value' => '<code>' . $load_json_text . '</code>',
|
94 |
-
'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'
|
95 |
-
),
|
96 |
-
array(
|
97 |
-
'name' => 'default_language',
|
98 |
-
'label' => 'Default language',
|
99 |
-
'value' => '<code>' . acf_get_setting('default_language') . '</code>',
|
100 |
-
'description' => 'Language code of the default language. Defaults to ”.<br />If WPML is active, ACF will default this to the WPML default language setting'
|
101 |
-
),
|
102 |
-
array(
|
103 |
-
'name' => 'current_language',
|
104 |
-
'label' => 'Current language',
|
105 |
-
'value' => '<code>' . acf_get_setting('current_language') . '</code>',
|
106 |
-
'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'
|
107 |
-
),
|
108 |
-
array(
|
109 |
-
'name' => 'capability',
|
110 |
-
'label' => 'Capability',
|
111 |
-
'value' => '<code>' . acf_get_setting('capability') . '</code>',
|
112 |
-
'description' => 'Capability used for ACF post types and if the current user can see the ACF menu item.<br />Defaults to ‘manage_options’.'
|
113 |
-
),
|
114 |
-
array(
|
115 |
-
'name' => 'show_updates',
|
116 |
-
'label' => 'Show updates',
|
117 |
-
'value' => '<code>' . (acf_get_setting('show_updates') ? __('True'): __('False')) . '</code>',
|
118 |
-
'description' => 'Enable/Disable updates to appear in plugin list and show/hide the ACF updates admin page.<br />Defaults to true.'
|
119 |
-
),
|
120 |
-
array(
|
121 |
-
'name' => 'export_textdomain',
|
122 |
-
'label' => 'Export textdomain',
|
123 |
-
'value' => '<code>' . (acf_get_setting('export_textdomain') ? __('True'): __('False')) . '</code>',
|
124 |
-
'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'
|
125 |
-
),
|
126 |
-
array(
|
127 |
-
'name' => 'export_translate',
|
128 |
-
'label' => 'Export translate',
|
129 |
-
'value' => '<code>' . print_r(acf_get_setting('export_translate'), true) . '</code>',
|
130 |
-
'description' => 'Used during the ‘Export to PHP’ feature to wrap strings within the __() function.<br />Depreciated in v5.4.4 – please see l10n_textdomain'
|
131 |
-
),
|
132 |
-
array(
|
133 |
-
'name' => 'autoload',
|
134 |
-
'label' => 'Auto load',
|
135 |
-
'value' => '<code>' . (acf_get_setting('autoload') ? __('True'): __('False')) . '</code>',
|
136 |
-
'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'
|
137 |
-
),
|
138 |
-
array(
|
139 |
-
'name' => 'l10n',
|
140 |
-
'label' => 'l10n',
|
141 |
-
'value' => '<code>' . (acf_get_setting('l10n') ? __('True'): __('False')) . '</code>',
|
142 |
-
'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'
|
143 |
-
),
|
144 |
-
array(
|
145 |
-
'name' => 'l10n_textdomain',
|
146 |
-
'label' => 'l10n Textdomain',
|
147 |
-
'value' => '<code>' . (acf_get_setting('l10n') ? __('True'): __('False')) . '</code>',
|
148 |
-
'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'
|
149 |
-
),
|
150 |
-
array(
|
151 |
-
'name' => 'l10n_field',
|
152 |
-
'label' => 'l10n Field',
|
153 |
-
'value' => '<code>' . print_r(acf_get_setting('l10n_field'), true) . '</code>',
|
154 |
-
'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'
|
155 |
-
),
|
156 |
-
array(
|
157 |
-
'name' => 'l10n_field_group',
|
158 |
-
'label' => 'l10n Field group',
|
159 |
-
'value' => '<code>' . print_r(acf_get_setting('l10n_field_group'), true) . '</code>',
|
160 |
-
'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'
|
161 |
-
),
|
162 |
-
array(
|
163 |
-
'name' => 'google_api_key',
|
164 |
-
'label' => 'Google API Key',
|
165 |
-
'value' => '<code>' . acf_get_setting('google_api_key') . '</code>',
|
166 |
-
'description' => 'Specify a Google Maps API authentication key to prevent usage limits.<br />Defaults to ”'
|
167 |
-
),
|
168 |
-
array(
|
169 |
-
'name' => 'google_api_client',
|
170 |
-
'label' => 'Google API Key',
|
171 |
-
'value' => '<code>' . acf_get_setting('google_api_client') . '</code>',
|
172 |
-
'description' => 'Specify a Google Maps API Client ID to prevent usage limits.<br />Not needed if using google_api_key. Defaults to ”'
|
173 |
-
),
|
174 |
-
array(
|
175 |
-
'name' => 'enqueue_google_maps',
|
176 |
-
'label' => 'Enqueue Google Maps',
|
177 |
-
'value' => '<code>' . (acf_get_setting('enqueue_google_maps') ? __('True'): __('False')) . '</code>',
|
178 |
-
'description' => 'Allows ACF to enqueue and load the Google Maps API JS library.<br />Defaults to true'
|
179 |
-
),
|
180 |
-
array(
|
181 |
-
'name' => 'enqueue_select2',
|
182 |
-
'label' => 'Enqueue Select2',
|
183 |
-
'value' => '<code>' . (acf_get_setting('enqueue_select2') ? __('True'): __('False')) . '</code>',
|
184 |
-
'description' => 'Allows ACF to enqueue and load the Select2 JS/CSS library.<br />Defaults to true'
|
185 |
-
),
|
186 |
-
array(
|
187 |
-
'name' => 'select2_version',
|
188 |
-
'label' => 'Select2 version',
|
189 |
-
'value' => '<code>' . acf_get_setting('select2_version') . '</code>',
|
190 |
-
'description' => 'Defines which version of Select2 library to enqueue. Either 3 or 4.<br />Defaults to 4 since ACF 5.6.0'
|
191 |
-
),
|
192 |
-
array(
|
193 |
-
'name' => 'enqueue_datepicker',
|
194 |
-
'label' => 'Enqueue Datepicker',
|
195 |
-
'value' => '<code>' . (acf_get_setting('enqueue_datepicker') ? __('True'): __('False')) . '</code>',
|
196 |
-
'description' => 'Allows ACF to enqueue and load the WP datepicker JS/CSS library.<br />Defaults to true'
|
197 |
-
),
|
198 |
-
array(
|
199 |
-
'name' => 'enqueue_datetimepicker',
|
200 |
-
'label' => 'Enqueue Date/timepicker',
|
201 |
-
'value' => '<code>' . (acf_get_setting('enqueue_datetimepicker') ? __('True'): __('False')) . '</code>',
|
202 |
-
'description' => 'Allows ACF to enqueue and load the datetimepicker JS/CSS library.<br />Defaults to true'
|
203 |
-
),
|
204 |
-
array(
|
205 |
-
'name' => 'row_index_offset',
|
206 |
-
'label' => 'Row index offset',
|
207 |
-
'value' => '<code>' . acf_get_setting('row_index_offset') . '</code>',
|
208 |
-
'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)'
|
209 |
-
),
|
210 |
-
array(
|
211 |
-
'name' => 'remove_wp_meta_box',
|
212 |
-
'label' => 'Remove WP meta box',
|
213 |
-
'value' => '<code>' . (acf_get_setting('remove_wp_meta_box') ? __('True'): __('False')) . '</code>',
|
214 |
-
'description' => 'Allows ACF to remove the default WP custom fields metabox. Defaults to true'
|
215 |
-
),
|
216 |
-
);
|
217 |
-
|
218 |
-
?>
|
219 |
-
|
220 |
-
<?php foreach($settings as $setting){ ?>
|
221 |
-
<div class="acf-field">
|
222 |
-
<div class="acf-label">
|
223 |
-
<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>
|
224 |
-
<p class="description"><code><?php echo $setting['name']; ?></code></p>
|
225 |
-
</div>
|
226 |
-
<div class="acf-input">
|
227 |
-
<?php echo $setting['value']; ?>
|
228 |
-
</div>
|
229 |
-
</div>
|
230 |
-
<?php } ?>
|
231 |
-
|
232 |
-
<?php
|
233 |
-
acf_render_field_wrap(array(
|
234 |
-
'type' => 'tab',
|
235 |
-
'label' => 'ACF: Extended',
|
236 |
-
));
|
237 |
-
?>
|
238 |
-
|
239 |
-
<?php
|
240 |
-
|
241 |
-
$load_php = acf_get_setting('acfe/php_load');
|
242 |
-
$load_php_text = '';
|
243 |
-
|
244 |
-
if(!empty($load_php))
|
245 |
-
$load_php_text = implode("<br />", $load_php);
|
246 |
-
|
247 |
-
$settings = array(
|
248 |
-
array(
|
249 |
-
'name' => 'acfe/modules/author',
|
250 |
-
'label' => 'Module: Author',
|
251 |
-
'value' => '<code>' . (acf_get_setting('acfe/modules/author', true) ? __('True'): __('False')) . '</code>',
|
252 |
-
'description' => 'Show/hide the Author module. Defaults to true'
|
253 |
-
),
|
254 |
-
array(
|
255 |
-
'name' => 'acfe/modules/dynamic_block_types',
|
256 |
-
'label' => 'Module: Dynamic Block Types',
|
257 |
-
'value' => '<code>' . (acf_get_setting('acfe/modules/dynamic_block_types', true) ? __('True'): __('False')) . '</code>',
|
258 |
-
'description' => 'Show/hide the Block Types module. Defaults to true'
|
259 |
-
),
|
260 |
-
array(
|
261 |
-
'name' => 'acfe/modules/dynamic_forms',
|
262 |
-
'label' => 'Module: Dynamic Forms',
|
263 |
-
'value' => '<code>' . (acf_get_setting('acfe/modules/dynamic_forms', true) ? __('True'): __('False')) . '</code>',
|
264 |
-
'description' => 'Show/hide the Forms module. Defaults to true'
|
265 |
-
),
|
266 |
-
array(
|
267 |
-
'name' => 'acfe/modules/dynamic_post_types',
|
268 |
-
'label' => 'Module: Dynamic Post Types',
|
269 |
-
'value' => '<code>' . (acf_get_setting('acfe/modules/dynamic_post_types', true) ? __('True'): __('False')) . '</code>',
|
270 |
-
'description' => 'Show/hide the Post Types module. Defaults to true'
|
271 |
-
),
|
272 |
-
array(
|
273 |
-
'name' => 'acfe/modules/dynamic_taxonomies',
|
274 |
-
'label' => 'Module: Dynamic Taxonomies',
|
275 |
-
'value' => '<code>' . (acf_get_setting('acfe/modules/dynamic_taxonomies', true) ? __('True'): __('False')) . '</code>',
|
276 |
-
'description' => 'Show/hide the Taxonomies module. Defaults to true'
|
277 |
-
),
|
278 |
-
array(
|
279 |
-
'name' => 'acfe/modules/dynamic_options_pages',
|
280 |
-
'label' => 'Module: Dynamic Options Pages',
|
281 |
-
'value' => '<code>' . (acf_get_setting('acfe/modules/dynamic_options_pages', true) ? __('True'): __('False')) . '</code>',
|
282 |
-
'description' => 'Show/hide the Options Pages module. Defaults to true'
|
283 |
-
),
|
284 |
-
array(
|
285 |
-
'name' => 'acfe/modules/options',
|
286 |
-
'label' => 'Module: Options',
|
287 |
-
'value' => '<code>' . (acf_get_setting('acfe/modules/options', true) ? __('True'): __('False')) . '</code>',
|
288 |
-
'description' => 'Show/hide the Options module. Defaults to true'
|
289 |
-
),
|
290 |
-
array(
|
291 |
-
'name' => 'acfe/modules/taxonomies',
|
292 |
-
'label' => 'Module: Taxonomies Enhancements',
|
293 |
-
'value' => '<code>' . (acf_get_setting('acfe/modules/taxonomies', true) ? __('True'): __('False')) . '</code>',
|
294 |
-
'description' => 'Show/hide the Taxonomies enhancements module. Defaults to true'
|
295 |
-
),
|
296 |
-
array(
|
297 |
-
'name' => 'acfe/field/recaptcha/site_key',
|
298 |
-
'label' => 'Field: reCaptcha site key',
|
299 |
-
'value' => '<code>' . acf_get_setting('acfe/field/recaptcha/site_key') . '</code>',
|
300 |
-
'description' => 'The default reCaptcha site key'
|
301 |
-
),
|
302 |
-
array(
|
303 |
-
'name' => 'acfe/field/recaptcha/secret_key',
|
304 |
-
'label' => 'Field: reCaptcha secret key',
|
305 |
-
'value' => '<code>' . acf_get_setting('acfe/field/recaptcha/secret_key') . '</code>',
|
306 |
-
'description' => 'The default reCaptcha secret key'
|
307 |
-
),
|
308 |
-
array(
|
309 |
-
'name' => 'acfe/field/recaptcha/version',
|
310 |
-
'label' => 'Field: reCaptcha version',
|
311 |
-
'value' => '<code>' . acf_get_setting('acfe/field/recaptcha/version', 'v2') . '</code>',
|
312 |
-
'description' => 'The default reCaptcha version'
|
313 |
-
),
|
314 |
-
array(
|
315 |
-
'name' => 'acfe/field/recaptcha/v2/theme',
|
316 |
-
'label' => 'Field: reCaptcha v2 theme',
|
317 |
-
'value' => '<code>' . acf_get_setting('acfe/field/recaptcha/v2/theme', 'light') . '</code>',
|
318 |
-
'description' => 'The default reCaptcha v2 theme'
|
319 |
-
),
|
320 |
-
array(
|
321 |
-
'name' => 'acfe/field/recaptcha/v2/size',
|
322 |
-
'label' => 'Field: reCaptcha v2 size',
|
323 |
-
'value' => '<code>' . acf_get_setting('acfe/field/recaptcha/v2/size', 'normal') . '</code>',
|
324 |
-
'description' => 'The default reCaptcha v2 size'
|
325 |
-
),
|
326 |
-
array(
|
327 |
-
'name' => 'acfe/field/recaptcha/v3/hide_logo',
|
328 |
-
'label' => 'Field: reCaptcha v3 hide logo',
|
329 |
-
'value' => '<code>' . acf_get_setting('acfe/field/recaptcha/v3/hide_logo') . '</code>',
|
330 |
-
'description' => 'Show/hide reCaptcha v3 logo'
|
331 |
-
),
|
332 |
-
array(
|
333 |
-
'name' => 'acfe/dev',
|
334 |
-
'label' => 'Dev mode',
|
335 |
-
'value' => '<code>' . (acf_get_setting('acfe/dev') ? __('True'): __('False')) . '</code>',
|
336 |
-
'description' => 'Show/hide the advanced WP post meta box. Defaults to false'
|
337 |
-
),
|
338 |
-
array(
|
339 |
-
'name' => 'acfe/php',
|
340 |
-
'label' => 'PHP',
|
341 |
-
'value' => '<code>' . (acf_get_setting('acfe/php') ? __('True'): __('False')) . '</code>',
|
342 |
-
'description' => 'Allow PHP Sync'
|
343 |
-
),
|
344 |
-
array(
|
345 |
-
'name' => 'acfe/php_found',
|
346 |
-
'label' => 'PHP: Found',
|
347 |
-
'value' => '<code>' . (acf_get_setting('acfe/php_found') ? __('True'): __('False')) . '</code>',
|
348 |
-
'description' => 'Found PHP Sync
|
349 |
-
),
|
350 |
-
array(
|
351 |
-
'name' => 'acfe/php_save',
|
352 |
-
'label' => 'PHP: Save',
|
353 |
-
'value' => '<code>' . acf_get_setting('acfe/php_save') . '</code>',
|
354 |
-
'description' => 'PHP Sync
|
355 |
-
),
|
356 |
-
array(
|
357 |
-
'name' => 'acfe/php_load',
|
358 |
-
'label' => 'PHP: Load',
|
359 |
-
'value' => '<code>' . $load_php_text . '</code>',
|
360 |
-
'description' => 'PHP Sync Load path'
|
361 |
-
),
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
393 |
}
|
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 |
+
|
9 |
+
if(!acf_get_setting('show_admin'))
|
10 |
+
return;
|
11 |
+
|
12 |
+
$submenu_page = add_submenu_page('edit.php?post_type=acf-field-group', __('Settings'), __('Settings'), acf_get_setting('capability'), 'acfe-settings', 'acfe_admin_settings_html');
|
13 |
+
|
14 |
+
add_action('admin_print_scripts-' . $submenu_page, function(){
|
15 |
+
acf_enqueue_scripts();
|
16 |
+
});
|
17 |
+
|
18 |
+
}
|
19 |
+
|
20 |
+
function acfe_admin_settings_html(){
|
21 |
+
?>
|
22 |
+
<div class="wrap" id="acfe-admin-settings">
|
23 |
+
|
24 |
+
<h1><?php _e('Settings'); ?></h1>
|
25 |
+
|
26 |
+
<div id="poststuff">
|
27 |
+
|
28 |
+
<div class="postbox acf-postbox">
|
29 |
+
<h2 class="hndle ui-sortable-handle"><span><?php _e('Settings'); ?></span></h2>
|
30 |
+
<div class="inside acf-fields -left">
|
31 |
+
|
32 |
+
<?php
|
33 |
+
acf_render_field_wrap(array(
|
34 |
+
'type' => 'tab',
|
35 |
+
'label' => 'ACF',
|
36 |
+
));
|
37 |
+
?>
|
38 |
+
|
39 |
+
<?php
|
40 |
+
|
41 |
+
$load_json = acf_get_setting('load_json');
|
42 |
+
$load_json_text = '';
|
43 |
+
|
44 |
+
if(!empty($load_json))
|
45 |
+
$load_json_text = implode("<br />", $load_json);
|
46 |
+
|
47 |
+
$settings = array(
|
48 |
+
array(
|
49 |
+
'name' => 'path',
|
50 |
+
'label' => 'Path',
|
51 |
+
'value' => '<code>' . acf_get_setting('path') . '</code>',
|
52 |
+
'description' => 'Absolute path to ACF plugin folder including trailing slash.<br />Defaults to plugin_dir_path'
|
53 |
+
),
|
54 |
+
array(
|
55 |
+
'name' => 'dir',
|
56 |
+
'label' => 'Directory',
|
57 |
+
'value' => '<code>' . acf_get_setting('dir') . '</code>',
|
58 |
+
'description' => 'URL to ACF plugin folder including trailing slash. Defaults to plugin_dir_url'
|
59 |
+
),
|
60 |
+
array(
|
61 |
+
'name' => 'show_admin',
|
62 |
+
'label' => 'Show menu',
|
63 |
+
'value' => '<code>' . (acf_get_setting('show_admin') ? __('True'): __('False')) . '</code>',
|
64 |
+
'description' => 'Show/hide ACF menu item. Defaults to true'
|
65 |
+
),
|
66 |
+
array(
|
67 |
+
'name' => 'stripslashes',
|
68 |
+
'label' => 'Strip slashes',
|
69 |
+
'value' => '<code>' . (acf_get_setting('stripslashes') ? __('True'): __('False')) . '</code>',
|
70 |
+
'description' => 'Runs the function stripslashes on all $_POST data. Some servers / WP instals may require this extra functioanlity. Defaults to false'
|
71 |
+
),
|
72 |
+
array(
|
73 |
+
'name' => 'local',
|
74 |
+
'label' => 'PHP/Json',
|
75 |
+
'value' => '<code>' . (acf_get_setting('local') ? __('True'): __('False')) . '</code>',
|
76 |
+
'description' => 'Enable/Disable local (PHP/json) fields. Defaults to true'
|
77 |
+
),
|
78 |
+
array(
|
79 |
+
'name' => 'json',
|
80 |
+
'label' => 'Json',
|
81 |
+
'value' => '<code>' . (acf_get_setting('json') ? __('True'): __('False')) . '</code>',
|
82 |
+
'description' => 'Enable/Disable json fields. Defaults to true'
|
83 |
+
),
|
84 |
+
array(
|
85 |
+
'name' => 'save_json',
|
86 |
+
'label' => 'Json folder (save)',
|
87 |
+
'value' => '<code>' . acf_get_setting('save_json') . '</code>',
|
88 |
+
'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'
|
89 |
+
),
|
90 |
+
array(
|
91 |
+
'name' => 'load_json',
|
92 |
+
'label' => 'Json folder (load)',
|
93 |
+
'value' => '<code>' . $load_json_text . '</code>',
|
94 |
+
'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'
|
95 |
+
),
|
96 |
+
array(
|
97 |
+
'name' => 'default_language',
|
98 |
+
'label' => 'Default language',
|
99 |
+
'value' => '<code>' . acf_get_setting('default_language') . '</code>',
|
100 |
+
'description' => 'Language code of the default language. Defaults to ”.<br />If WPML is active, ACF will default this to the WPML default language setting'
|
101 |
+
),
|
102 |
+
array(
|
103 |
+
'name' => 'current_language',
|
104 |
+
'label' => 'Current language',
|
105 |
+
'value' => '<code>' . acf_get_setting('current_language') . '</code>',
|
106 |
+
'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'
|
107 |
+
),
|
108 |
+
array(
|
109 |
+
'name' => 'capability',
|
110 |
+
'label' => 'Capability',
|
111 |
+
'value' => '<code>' . acf_get_setting('capability') . '</code>',
|
112 |
+
'description' => 'Capability used for ACF post types and if the current user can see the ACF menu item.<br />Defaults to ‘manage_options’.'
|
113 |
+
),
|
114 |
+
array(
|
115 |
+
'name' => 'show_updates',
|
116 |
+
'label' => 'Show updates',
|
117 |
+
'value' => '<code>' . (acf_get_setting('show_updates') ? __('True'): __('False')) . '</code>',
|
118 |
+
'description' => 'Enable/Disable updates to appear in plugin list and show/hide the ACF updates admin page.<br />Defaults to true.'
|
119 |
+
),
|
120 |
+
array(
|
121 |
+
'name' => 'export_textdomain',
|
122 |
+
'label' => 'Export textdomain',
|
123 |
+
'value' => '<code>' . (acf_get_setting('export_textdomain') ? __('True'): __('False')) . '</code>',
|
124 |
+
'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'
|
125 |
+
),
|
126 |
+
array(
|
127 |
+
'name' => 'export_translate',
|
128 |
+
'label' => 'Export translate',
|
129 |
+
'value' => '<code>' . print_r(acf_get_setting('export_translate'), true) . '</code>',
|
130 |
+
'description' => 'Used during the ‘Export to PHP’ feature to wrap strings within the __() function.<br />Depreciated in v5.4.4 – please see l10n_textdomain'
|
131 |
+
),
|
132 |
+
array(
|
133 |
+
'name' => 'autoload',
|
134 |
+
'label' => 'Auto load',
|
135 |
+
'value' => '<code>' . (acf_get_setting('autoload') ? __('True'): __('False')) . '</code>',
|
136 |
+
'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'
|
137 |
+
),
|
138 |
+
array(
|
139 |
+
'name' => 'l10n',
|
140 |
+
'label' => 'l10n',
|
141 |
+
'value' => '<code>' . (acf_get_setting('l10n') ? __('True'): __('False')) . '</code>',
|
142 |
+
'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'
|
143 |
+
),
|
144 |
+
array(
|
145 |
+
'name' => 'l10n_textdomain',
|
146 |
+
'label' => 'l10n Textdomain',
|
147 |
+
'value' => '<code>' . (acf_get_setting('l10n') ? __('True'): __('False')) . '</code>',
|
148 |
+
'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'
|
149 |
+
),
|
150 |
+
array(
|
151 |
+
'name' => 'l10n_field',
|
152 |
+
'label' => 'l10n Field',
|
153 |
+
'value' => '<code>' . print_r(acf_get_setting('l10n_field'), true) . '</code>',
|
154 |
+
'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'
|
155 |
+
),
|
156 |
+
array(
|
157 |
+
'name' => 'l10n_field_group',
|
158 |
+
'label' => 'l10n Field group',
|
159 |
+
'value' => '<code>' . print_r(acf_get_setting('l10n_field_group'), true) . '</code>',
|
160 |
+
'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'
|
161 |
+
),
|
162 |
+
array(
|
163 |
+
'name' => 'google_api_key',
|
164 |
+
'label' => 'Google API Key',
|
165 |
+
'value' => '<code>' . acf_get_setting('google_api_key') . '</code>',
|
166 |
+
'description' => 'Specify a Google Maps API authentication key to prevent usage limits.<br />Defaults to ”'
|
167 |
+
),
|
168 |
+
array(
|
169 |
+
'name' => 'google_api_client',
|
170 |
+
'label' => 'Google API Key',
|
171 |
+
'value' => '<code>' . acf_get_setting('google_api_client') . '</code>',
|
172 |
+
'description' => 'Specify a Google Maps API Client ID to prevent usage limits.<br />Not needed if using google_api_key. Defaults to ”'
|
173 |
+
),
|
174 |
+
array(
|
175 |
+
'name' => 'enqueue_google_maps',
|
176 |
+
'label' => 'Enqueue Google Maps',
|
177 |
+
'value' => '<code>' . (acf_get_setting('enqueue_google_maps') ? __('True'): __('False')) . '</code>',
|
178 |
+
'description' => 'Allows ACF to enqueue and load the Google Maps API JS library.<br />Defaults to true'
|
179 |
+
),
|
180 |
+
array(
|
181 |
+
'name' => 'enqueue_select2',
|
182 |
+
'label' => 'Enqueue Select2',
|
183 |
+
'value' => '<code>' . (acf_get_setting('enqueue_select2') ? __('True'): __('False')) . '</code>',
|
184 |
+
'description' => 'Allows ACF to enqueue and load the Select2 JS/CSS library.<br />Defaults to true'
|
185 |
+
),
|
186 |
+
array(
|
187 |
+
'name' => 'select2_version',
|
188 |
+
'label' => 'Select2 version',
|
189 |
+
'value' => '<code>' . acf_get_setting('select2_version') . '</code>',
|
190 |
+
'description' => 'Defines which version of Select2 library to enqueue. Either 3 or 4.<br />Defaults to 4 since ACF 5.6.0'
|
191 |
+
),
|
192 |
+
array(
|
193 |
+
'name' => 'enqueue_datepicker',
|
194 |
+
'label' => 'Enqueue Datepicker',
|
195 |
+
'value' => '<code>' . (acf_get_setting('enqueue_datepicker') ? __('True'): __('False')) . '</code>',
|
196 |
+
'description' => 'Allows ACF to enqueue and load the WP datepicker JS/CSS library.<br />Defaults to true'
|
197 |
+
),
|
198 |
+
array(
|
199 |
+
'name' => 'enqueue_datetimepicker',
|
200 |
+
'label' => 'Enqueue Date/timepicker',
|
201 |
+
'value' => '<code>' . (acf_get_setting('enqueue_datetimepicker') ? __('True'): __('False')) . '</code>',
|
202 |
+
'description' => 'Allows ACF to enqueue and load the datetimepicker JS/CSS library.<br />Defaults to true'
|
203 |
+
),
|
204 |
+
array(
|
205 |
+
'name' => 'row_index_offset',
|
206 |
+
'label' => 'Row index offset',
|
207 |
+
'value' => '<code>' . acf_get_setting('row_index_offset') . '</code>',
|
208 |
+
'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)'
|
209 |
+
),
|
210 |
+
array(
|
211 |
+
'name' => 'remove_wp_meta_box',
|
212 |
+
'label' => 'Remove WP meta box',
|
213 |
+
'value' => '<code>' . (acf_get_setting('remove_wp_meta_box') ? __('True'): __('False')) . '</code>',
|
214 |
+
'description' => 'Allows ACF to remove the default WP custom fields metabox. Defaults to true'
|
215 |
+
),
|
216 |
+
);
|
217 |
+
|
218 |
+
?>
|
219 |
+
|
220 |
+
<?php foreach($settings as $setting){ ?>
|
221 |
+
<div class="acf-field">
|
222 |
+
<div class="acf-label">
|
223 |
+
<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>
|
224 |
+
<p class="description"><code><?php echo $setting['name']; ?></code></p>
|
225 |
+
</div>
|
226 |
+
<div class="acf-input">
|
227 |
+
<?php echo $setting['value']; ?>
|
228 |
+
</div>
|
229 |
+
</div>
|
230 |
+
<?php } ?>
|
231 |
+
|
232 |
+
<?php
|
233 |
+
acf_render_field_wrap(array(
|
234 |
+
'type' => 'tab',
|
235 |
+
'label' => 'ACF: Extended',
|
236 |
+
));
|
237 |
+
?>
|
238 |
+
|
239 |
+
<?php
|
240 |
+
|
241 |
+
$load_php = acf_get_setting('acfe/php_load');
|
242 |
+
$load_php_text = '';
|
243 |
+
|
244 |
+
if(!empty($load_php))
|
245 |
+
$load_php_text = implode("<br />", $load_php);
|
246 |
+
|
247 |
+
$settings = array(
|
248 |
+
array(
|
249 |
+
'name' => 'acfe/modules/author',
|
250 |
+
'label' => 'Module: Author',
|
251 |
+
'value' => '<code>' . (acf_get_setting('acfe/modules/author', true) ? __('True'): __('False')) . '</code>',
|
252 |
+
'description' => 'Show/hide the Author module. Defaults to true'
|
253 |
+
),
|
254 |
+
array(
|
255 |
+
'name' => 'acfe/modules/dynamic_block_types',
|
256 |
+
'label' => 'Module: Dynamic Block Types',
|
257 |
+
'value' => '<code>' . (acf_get_setting('acfe/modules/dynamic_block_types', true) ? __('True'): __('False')) . '</code>',
|
258 |
+
'description' => 'Show/hide the Block Types module. Defaults to true'
|
259 |
+
),
|
260 |
+
array(
|
261 |
+
'name' => 'acfe/modules/dynamic_forms',
|
262 |
+
'label' => 'Module: Dynamic Forms',
|
263 |
+
'value' => '<code>' . (acf_get_setting('acfe/modules/dynamic_forms', true) ? __('True'): __('False')) . '</code>',
|
264 |
+
'description' => 'Show/hide the Forms module. Defaults to true'
|
265 |
+
),
|
266 |
+
array(
|
267 |
+
'name' => 'acfe/modules/dynamic_post_types',
|
268 |
+
'label' => 'Module: Dynamic Post Types',
|
269 |
+
'value' => '<code>' . (acf_get_setting('acfe/modules/dynamic_post_types', true) ? __('True'): __('False')) . '</code>',
|
270 |
+
'description' => 'Show/hide the Post Types module. Defaults to true'
|
271 |
+
),
|
272 |
+
array(
|
273 |
+
'name' => 'acfe/modules/dynamic_taxonomies',
|
274 |
+
'label' => 'Module: Dynamic Taxonomies',
|
275 |
+
'value' => '<code>' . (acf_get_setting('acfe/modules/dynamic_taxonomies', true) ? __('True'): __('False')) . '</code>',
|
276 |
+
'description' => 'Show/hide the Taxonomies module. Defaults to true'
|
277 |
+
),
|
278 |
+
array(
|
279 |
+
'name' => 'acfe/modules/dynamic_options_pages',
|
280 |
+
'label' => 'Module: Dynamic Options Pages',
|
281 |
+
'value' => '<code>' . (acf_get_setting('acfe/modules/dynamic_options_pages', true) ? __('True'): __('False')) . '</code>',
|
282 |
+
'description' => 'Show/hide the Options Pages module. Defaults to true'
|
283 |
+
),
|
284 |
+
array(
|
285 |
+
'name' => 'acfe/modules/options',
|
286 |
+
'label' => 'Module: Options',
|
287 |
+
'value' => '<code>' . (acf_get_setting('acfe/modules/options', true) ? __('True'): __('False')) . '</code>',
|
288 |
+
'description' => 'Show/hide the Options module. Defaults to true'
|
289 |
+
),
|
290 |
+
array(
|
291 |
+
'name' => 'acfe/modules/taxonomies',
|
292 |
+
'label' => 'Module: Taxonomies Enhancements',
|
293 |
+
'value' => '<code>' . (acf_get_setting('acfe/modules/taxonomies', true) ? __('True'): __('False')) . '</code>',
|
294 |
+
'description' => 'Show/hide the Taxonomies enhancements module. Defaults to true'
|
295 |
+
),
|
296 |
+
array(
|
297 |
+
'name' => 'acfe/field/recaptcha/site_key',
|
298 |
+
'label' => 'Field: reCaptcha site key',
|
299 |
+
'value' => '<code>' . acf_get_setting('acfe/field/recaptcha/site_key') . '</code>',
|
300 |
+
'description' => 'The default reCaptcha site key'
|
301 |
+
),
|
302 |
+
array(
|
303 |
+
'name' => 'acfe/field/recaptcha/secret_key',
|
304 |
+
'label' => 'Field: reCaptcha secret key',
|
305 |
+
'value' => '<code>' . acf_get_setting('acfe/field/recaptcha/secret_key') . '</code>',
|
306 |
+
'description' => 'The default reCaptcha secret key'
|
307 |
+
),
|
308 |
+
array(
|
309 |
+
'name' => 'acfe/field/recaptcha/version',
|
310 |
+
'label' => 'Field: reCaptcha version',
|
311 |
+
'value' => '<code>' . acf_get_setting('acfe/field/recaptcha/version', 'v2') . '</code>',
|
312 |
+
'description' => 'The default reCaptcha version'
|
313 |
+
),
|
314 |
+
array(
|
315 |
+
'name' => 'acfe/field/recaptcha/v2/theme',
|
316 |
+
'label' => 'Field: reCaptcha v2 theme',
|
317 |
+
'value' => '<code>' . acf_get_setting('acfe/field/recaptcha/v2/theme', 'light') . '</code>',
|
318 |
+
'description' => 'The default reCaptcha v2 theme'
|
319 |
+
),
|
320 |
+
array(
|
321 |
+
'name' => 'acfe/field/recaptcha/v2/size',
|
322 |
+
'label' => 'Field: reCaptcha v2 size',
|
323 |
+
'value' => '<code>' . acf_get_setting('acfe/field/recaptcha/v2/size', 'normal') . '</code>',
|
324 |
+
'description' => 'The default reCaptcha v2 size'
|
325 |
+
),
|
326 |
+
array(
|
327 |
+
'name' => 'acfe/field/recaptcha/v3/hide_logo',
|
328 |
+
'label' => 'Field: reCaptcha v3 hide logo',
|
329 |
+
'value' => '<code>' . acf_get_setting('acfe/field/recaptcha/v3/hide_logo') . '</code>',
|
330 |
+
'description' => 'Show/hide reCaptcha v3 logo'
|
331 |
+
),
|
332 |
+
array(
|
333 |
+
'name' => 'acfe/dev',
|
334 |
+
'label' => 'Dev mode',
|
335 |
+
'value' => '<code>' . (acf_get_setting('acfe/dev') ? __('True'): __('False')) . '</code>',
|
336 |
+
'description' => 'Show/hide the advanced WP post meta box. Defaults to false'
|
337 |
+
),
|
338 |
+
array(
|
339 |
+
'name' => 'acfe/php',
|
340 |
+
'label' => 'PHP',
|
341 |
+
'value' => '<code>' . (acf_get_setting('acfe/php') ? __('True'): __('False')) . '</code>',
|
342 |
+
'description' => 'Allow PHP Sync'
|
343 |
+
),
|
344 |
+
array(
|
345 |
+
'name' => 'acfe/php_found',
|
346 |
+
'label' => 'PHP: Found',
|
347 |
+
'value' => '<code>' . (acf_get_setting('acfe/php_found') ? __('True'): __('False')) . '</code>',
|
348 |
+
'description' => 'Found PHP Sync load folder'
|
349 |
+
),
|
350 |
+
array(
|
351 |
+
'name' => 'acfe/php_save',
|
352 |
+
'label' => 'PHP: Save',
|
353 |
+
'value' => '<code>' . acf_get_setting('acfe/php_save') . '</code>',
|
354 |
+
'description' => 'Found PHP Sync save folder'
|
355 |
+
),
|
356 |
+
array(
|
357 |
+
'name' => 'acfe/php_load',
|
358 |
+
'label' => 'PHP: Load',
|
359 |
+
'value' => '<code>' . $load_php_text . '</code>',
|
360 |
+
'description' => 'PHP Sync Load path'
|
361 |
+
),
|
362 |
+
array(
|
363 |
+
'name' => 'acfe/json_found',
|
364 |
+
'label' => 'Json: Found',
|
365 |
+
'value' => '<code>' . (acf_get_setting('acfe/json_found') ? __('True'): __('False')) . '</code>',
|
366 |
+
'description' => 'Found Json Sync load folder'
|
367 |
+
),
|
368 |
+
);
|
369 |
+
?>
|
370 |
+
|
371 |
+
<?php foreach($settings as $setting){ ?>
|
372 |
+
<div class="acf-field">
|
373 |
+
<div class="acf-label">
|
374 |
+
<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>
|
375 |
+
<p class="description"><code><?php echo $setting['name']; ?></code></p>
|
376 |
+
</div>
|
377 |
+
<div class="acf-input">
|
378 |
+
<?php echo $setting['value']; ?>
|
379 |
+
</div>
|
380 |
+
</div>
|
381 |
+
<?php } ?>
|
382 |
+
|
383 |
+
<script type="text/javascript">
|
384 |
+
if( typeof acf !== 'undefined' ) {
|
385 |
+
|
386 |
+
acf.newPostbox({
|
387 |
+
'id': 'acfe-settings',
|
388 |
+
'label': 'left'
|
389 |
+
});
|
390 |
+
|
391 |
+
}
|
392 |
+
</script>
|
393 |
+
</div>
|
394 |
+
</div>
|
395 |
+
</div>
|
396 |
+
|
397 |
+
</div>
|
398 |
+
<?php
|
399 |
}
|
includes/admin/tools/dbt-export.php
CHANGED
@@ -1,184 +1,385 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
// Check setting
|
7 |
-
if(!acf_get_setting('acfe/modules/dynamic_block_types'))
|
8 |
-
return;
|
9 |
-
|
10 |
-
if(!class_exists('ACFE_Admin_Tool_Export_DBT')):
|
11 |
-
|
12 |
-
class ACFE_Admin_Tool_Export_DBT extends ACF_Admin_Tool{
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
// Check setting
|
7 |
+
if(!acf_get_setting('acfe/modules/dynamic_block_types'))
|
8 |
+
return;
|
9 |
+
|
10 |
+
if(!class_exists('ACFE_Admin_Tool_Export_DBT')):
|
11 |
+
|
12 |
+
class ACFE_Admin_Tool_Export_DBT extends ACF_Admin_Tool{
|
13 |
+
|
14 |
+
public $action = false;
|
15 |
+
public $data = array();
|
16 |
+
|
17 |
+
function initialize(){
|
18 |
+
|
19 |
+
// vars
|
20 |
+
$this->name = 'acfe_tool_dbt_export';
|
21 |
+
$this->title = __('Export Block Types');
|
22 |
+
$this->icon = 'dashicons-upload';
|
23 |
+
|
24 |
+
}
|
25 |
+
|
26 |
+
function html(){
|
27 |
+
|
28 |
+
// Single
|
29 |
+
if($this->is_active()){
|
30 |
+
|
31 |
+
$this->html_single();
|
32 |
+
|
33 |
+
|
34 |
+
// Archive
|
35 |
+
}else{
|
36 |
+
|
37 |
+
$this->html_archive();
|
38 |
+
|
39 |
+
}
|
40 |
+
|
41 |
+
}
|
42 |
+
|
43 |
+
function html_archive(){
|
44 |
+
|
45 |
+
// vars
|
46 |
+
$choices = array();
|
47 |
+
|
48 |
+
$dynamic_block_types = get_option('acfe_dynamic_block_types', array());
|
49 |
+
|
50 |
+
if($dynamic_block_types){
|
51 |
+
|
52 |
+
foreach($dynamic_block_types as $block_type_name => $args){
|
53 |
+
|
54 |
+
$choices[$block_type_name] = esc_html($args['title']);
|
55 |
+
|
56 |
+
}
|
57 |
+
|
58 |
+
}
|
59 |
+
|
60 |
+
?>
|
61 |
+
<p><?php _e('Export Block Types', 'acf'); ?></p>
|
62 |
+
|
63 |
+
<div class="acf-fields">
|
64 |
+
<?php
|
65 |
+
|
66 |
+
if(!empty($choices)){
|
67 |
+
|
68 |
+
// render
|
69 |
+
acf_render_field_wrap(array(
|
70 |
+
'label' => __('Select Block Types', 'acf'),
|
71 |
+
'type' => 'checkbox',
|
72 |
+
'name' => 'keys',
|
73 |
+
'prefix' => false,
|
74 |
+
'value' => false,
|
75 |
+
'toggle' => true,
|
76 |
+
'choices' => $choices,
|
77 |
+
));
|
78 |
+
|
79 |
+
}
|
80 |
+
|
81 |
+
else{
|
82 |
+
|
83 |
+
echo '<div style="padding:15px 12px;">';
|
84 |
+
_e('No dynamic block type available.');
|
85 |
+
echo '</div>';
|
86 |
+
|
87 |
+
}
|
88 |
+
|
89 |
+
?>
|
90 |
+
</div>
|
91 |
+
|
92 |
+
<?php
|
93 |
+
|
94 |
+
$disabled = '';
|
95 |
+
if(empty($choices))
|
96 |
+
$disabled = 'disabled="disabled"';
|
97 |
+
|
98 |
+
?>
|
99 |
+
|
100 |
+
<p class="acf-submit">
|
101 |
+
<button type="submit" name="action" class="button button-primary" value="json" <?php echo $disabled; ?>><?php _e('Export File'); ?></button>
|
102 |
+
<button type="submit" name="action" class="button" value="php" <?php echo $disabled; ?>><?php _e('Generate PHP'); ?></button>
|
103 |
+
</p>
|
104 |
+
<?php
|
105 |
+
|
106 |
+
}
|
107 |
+
|
108 |
+
function html_single(){
|
109 |
+
|
110 |
+
?>
|
111 |
+
<div class="acf-postbox-columns">
|
112 |
+
<div class="acf-postbox-main">
|
113 |
+
|
114 |
+
<?php
|
115 |
+
// prevent default translation and fake __() within string
|
116 |
+
acf_update_setting('l10n_var_export', true);
|
117 |
+
|
118 |
+
$str_replace = array(
|
119 |
+
" " => "\t",
|
120 |
+
"'!!__(!!\'" => "__('",
|
121 |
+
"!!\', !!\'" => "', '",
|
122 |
+
"!!\')!!'" => "')",
|
123 |
+
"array (" => "array("
|
124 |
+
);
|
125 |
+
|
126 |
+
$preg_replace = array(
|
127 |
+
'/([\t\r\n]+?)array/' => 'array',
|
128 |
+
'/[0-9]+ => array/' => 'array'
|
129 |
+
);
|
130 |
+
|
131 |
+
|
132 |
+
?>
|
133 |
+
<p><?php _e("The following code can be used to register a block type. Simply copy and paste the following code to your theme's functions.php file or include it within an external file.", 'acf'); ?></p>
|
134 |
+
|
135 |
+
<div id="acf-admin-tool-export">
|
136 |
+
|
137 |
+
<textarea id="acf-export-textarea" readonly="true"><?php
|
138 |
+
|
139 |
+
echo "if( function_exists('acf_register_block_type') ):" . "\r\n" . "\r\n";
|
140 |
+
|
141 |
+
foreach($this->data as $args){
|
142 |
+
|
143 |
+
// code
|
144 |
+
$code = var_export($args, true);
|
145 |
+
|
146 |
+
|
147 |
+
// change double spaces to tabs
|
148 |
+
$code = str_replace( array_keys($str_replace), array_values($str_replace), $code );
|
149 |
+
|
150 |
+
|
151 |
+
// correctly formats "=> array("
|
152 |
+
$code = preg_replace( array_keys($preg_replace), array_values($preg_replace), $code );
|
153 |
+
|
154 |
+
|
155 |
+
// esc_textarea
|
156 |
+
$code = esc_textarea( $code );
|
157 |
+
|
158 |
+
|
159 |
+
// echo
|
160 |
+
echo "acf_register_block_type({$code});" . "\r\n" . "\r\n";
|
161 |
+
|
162 |
+
}
|
163 |
+
|
164 |
+
echo "endif;";
|
165 |
+
|
166 |
+
?></textarea>
|
167 |
+
|
168 |
+
</div>
|
169 |
+
|
170 |
+
<p class="acf-submit">
|
171 |
+
<a class="button" id="acf-export-copy"><?php _e( 'Copy to clipboard', 'acf' ); ?></a>
|
172 |
+
</p>
|
173 |
+
<script type="text/javascript">
|
174 |
+
(function($){
|
175 |
+
|
176 |
+
// vars
|
177 |
+
var $a = $('#acf-export-copy');
|
178 |
+
var $textarea = $('#acf-export-textarea');
|
179 |
+
|
180 |
+
|
181 |
+
// remove $a if 'copy' is not supported
|
182 |
+
if( !document.queryCommandSupported('copy') ) {
|
183 |
+
return $a.remove();
|
184 |
+
}
|
185 |
+
|
186 |
+
|
187 |
+
// event
|
188 |
+
$a.on('click', function( e ){
|
189 |
+
|
190 |
+
// prevent default
|
191 |
+
e.preventDefault();
|
192 |
+
|
193 |
+
|
194 |
+
// select
|
195 |
+
$textarea.get(0).select();
|
196 |
+
|
197 |
+
|
198 |
+
// try
|
199 |
+
try {
|
200 |
+
|
201 |
+
// copy
|
202 |
+
var copy = document.execCommand('copy');
|
203 |
+
if( !copy ) return;
|
204 |
+
|
205 |
+
|
206 |
+
// tooltip
|
207 |
+
acf.newTooltip({
|
208 |
+
text: "<?php _e('Copied', 'acf' ); ?>",
|
209 |
+
timeout: 250,
|
210 |
+
target: $(this),
|
211 |
+
});
|
212 |
+
|
213 |
+
} catch (err) {
|
214 |
+
|
215 |
+
// do nothing
|
216 |
+
|
217 |
+
}
|
218 |
+
|
219 |
+
});
|
220 |
+
|
221 |
+
})(jQuery);
|
222 |
+
</script>
|
223 |
+
</div>
|
224 |
+
</div>
|
225 |
+
<?php
|
226 |
+
|
227 |
+
}
|
228 |
+
|
229 |
+
function load(){
|
230 |
+
|
231 |
+
if($this->is_active()){
|
232 |
+
|
233 |
+
$this->action = $this->get_action();
|
234 |
+
$this->data = $this->get_selected();
|
235 |
+
|
236 |
+
// Json submit
|
237 |
+
if($this->action === 'json')
|
238 |
+
$this->submit();
|
239 |
+
|
240 |
+
// add notice
|
241 |
+
if(!empty($this->data)){
|
242 |
+
|
243 |
+
$count = count($this->data);
|
244 |
+
$text = sprintf(_n( 'Exported 1 block type.', 'Exported %s block types.', $count, 'acf' ), $count);
|
245 |
+
|
246 |
+
acf_add_admin_notice($text, 'success');
|
247 |
+
|
248 |
+
}
|
249 |
+
|
250 |
+
}
|
251 |
+
|
252 |
+
}
|
253 |
+
|
254 |
+
function submit(){
|
255 |
+
|
256 |
+
$this->action = $this->get_action();
|
257 |
+
$this->data = $this->get_selected();
|
258 |
+
|
259 |
+
// validate
|
260 |
+
if($this->data === false)
|
261 |
+
return acf_add_admin_notice(__('No block types selected'), 'warning');
|
262 |
+
|
263 |
+
$keys = array();
|
264 |
+
foreach($this->data as $key => $args){
|
265 |
+
|
266 |
+
$keys[] = $key;
|
267 |
+
|
268 |
+
}
|
269 |
+
|
270 |
+
if($this->action === 'json'){
|
271 |
+
|
272 |
+
// Prefix
|
273 |
+
$prefix = (count($keys) > 1) ? 'block-types' : 'block-type';
|
274 |
+
|
275 |
+
// Slugs
|
276 |
+
$slugs = implode('-', $keys);
|
277 |
+
|
278 |
+
// Date
|
279 |
+
$date = date('Y-m-d');
|
280 |
+
|
281 |
+
// file
|
282 |
+
$file_name = 'acfe-export-' . $prefix . '-' . $slugs . '-' . $date . '.json';
|
283 |
+
|
284 |
+
// headers
|
285 |
+
header("Content-Description: File Transfer");
|
286 |
+
header("Content-Disposition: attachment; filename={$file_name}");
|
287 |
+
header("Content-Type: application/json; charset=utf-8");
|
288 |
+
|
289 |
+
// return
|
290 |
+
echo acf_json_encode($this->data);
|
291 |
+
die;
|
292 |
+
|
293 |
+
}
|
294 |
+
|
295 |
+
elseif($this->action === 'php'){
|
296 |
+
|
297 |
+
// url
|
298 |
+
$url = add_query_arg(array(
|
299 |
+
'keys' => implode('+', $keys),
|
300 |
+
'action' => 'php'
|
301 |
+
), $this->get_url());
|
302 |
+
|
303 |
+
// redirect
|
304 |
+
wp_redirect($url);
|
305 |
+
exit;
|
306 |
+
|
307 |
+
}
|
308 |
+
|
309 |
+
}
|
310 |
+
|
311 |
+
function get_selected(){
|
312 |
+
|
313 |
+
// vars
|
314 |
+
$selected = $this->get_selected_keys();
|
315 |
+
|
316 |
+
if(!$selected)
|
317 |
+
return false;
|
318 |
+
|
319 |
+
$dynamic_block_types = get_option('acfe_dynamic_block_types', array());
|
320 |
+
if(empty($dynamic_block_types))
|
321 |
+
return false;
|
322 |
+
|
323 |
+
$data = array();
|
324 |
+
|
325 |
+
// construct data
|
326 |
+
foreach($selected as $key){
|
327 |
+
|
328 |
+
if(!isset($dynamic_block_types[$key]))
|
329 |
+
continue;
|
330 |
+
|
331 |
+
// add to data array
|
332 |
+
$data[$key] = $dynamic_block_types[$key];
|
333 |
+
|
334 |
+
}
|
335 |
+
|
336 |
+
// return
|
337 |
+
return $data;
|
338 |
+
|
339 |
+
}
|
340 |
+
|
341 |
+
function get_selected_keys(){
|
342 |
+
|
343 |
+
// check $_POST
|
344 |
+
if($keys = acf_maybe_get_POST('keys')){
|
345 |
+
|
346 |
+
return (array) $keys;
|
347 |
+
|
348 |
+
}
|
349 |
+
|
350 |
+
// check $_GET
|
351 |
+
if($keys = acf_maybe_get_GET('keys')){
|
352 |
+
|
353 |
+
$keys = str_replace(' ', '+', $keys);
|
354 |
+
return explode('+', $keys);
|
355 |
+
|
356 |
+
}
|
357 |
+
|
358 |
+
// return
|
359 |
+
return false;
|
360 |
+
|
361 |
+
}
|
362 |
+
|
363 |
+
function get_action(){
|
364 |
+
|
365 |
+
// init
|
366 |
+
$type = 'json';
|
367 |
+
|
368 |
+
// check GET / POST
|
369 |
+
if(($action = acf_maybe_get_GET('action')) || ($action = acf_maybe_get_POST('action'))){
|
370 |
+
|
371 |
+
if(in_array($action, array('json', 'php')))
|
372 |
+
$type = $action;
|
373 |
+
|
374 |
+
}
|
375 |
+
|
376 |
+
// return
|
377 |
+
return $type;
|
378 |
+
|
379 |
+
}
|
380 |
+
|
381 |
+
}
|
382 |
+
|
383 |
+
acf_register_admin_tool('ACFE_Admin_Tool_Export_DBT');
|
384 |
+
|
385 |
endif;
|
includes/admin/tools/dop-export.php
CHANGED
@@ -1,184 +1,382 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
// Check setting
|
7 |
-
if(!acf_get_setting('acfe/modules/dynamic_options_pages'))
|
8 |
-
return;
|
9 |
-
|
10 |
-
if(!class_exists('ACFE_Admin_Tool_Export_DOP')):
|
11 |
-
|
12 |
-
class ACFE_Admin_Tool_Export_DOP extends ACF_Admin_Tool{
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
// Check setting
|
7 |
+
if(!acf_get_setting('acfe/modules/dynamic_options_pages'))
|
8 |
+
return;
|
9 |
+
|
10 |
+
if(!class_exists('ACFE_Admin_Tool_Export_DOP')):
|
11 |
+
|
12 |
+
class ACFE_Admin_Tool_Export_DOP extends ACF_Admin_Tool{
|
13 |
+
|
14 |
+
public $action = false;
|
15 |
+
public $data = array();
|
16 |
+
|
17 |
+
function initialize(){
|
18 |
+
|
19 |
+
// vars
|
20 |
+
$this->name = 'acfe_tool_dop_export';
|
21 |
+
$this->title = __('Export Options Pages');
|
22 |
+
$this->icon = 'dashicons-upload';
|
23 |
+
|
24 |
+
}
|
25 |
+
|
26 |
+
function html(){
|
27 |
+
|
28 |
+
// Single
|
29 |
+
if($this->is_active()){
|
30 |
+
|
31 |
+
$this->html_single();
|
32 |
+
|
33 |
+
|
34 |
+
// Archive
|
35 |
+
}else{
|
36 |
+
|
37 |
+
$this->html_archive();
|
38 |
+
|
39 |
+
}
|
40 |
+
|
41 |
+
}
|
42 |
+
|
43 |
+
function html_archive(){
|
44 |
+
|
45 |
+
// vars
|
46 |
+
$choices = array();
|
47 |
+
|
48 |
+
$dynamic_options_pages = get_option('acfe_dynamic_options_pages', array());
|
49 |
+
|
50 |
+
if($dynamic_options_pages){
|
51 |
+
foreach($dynamic_options_pages as $options_page_name => $args){
|
52 |
+
|
53 |
+
$choices[$options_page_name] = esc_html($args['page_title']);
|
54 |
+
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
?>
|
59 |
+
<p><?php _e('Export Options Pages', 'acf'); ?></p>
|
60 |
+
|
61 |
+
<div class="acf-fields">
|
62 |
+
<?php
|
63 |
+
|
64 |
+
if(!empty($choices)){
|
65 |
+
|
66 |
+
// render
|
67 |
+
acf_render_field_wrap(array(
|
68 |
+
'label' => __('Select Options Pages', 'acf'),
|
69 |
+
'type' => 'checkbox',
|
70 |
+
'name' => 'keys',
|
71 |
+
'prefix' => false,
|
72 |
+
'value' => false,
|
73 |
+
'toggle' => true,
|
74 |
+
'choices' => $choices,
|
75 |
+
));
|
76 |
+
|
77 |
+
}
|
78 |
+
|
79 |
+
else{
|
80 |
+
|
81 |
+
echo '<div style="padding:15px 12px;">';
|
82 |
+
_e('No options page available.');
|
83 |
+
echo '</div>';
|
84 |
+
|
85 |
+
}
|
86 |
+
|
87 |
+
?>
|
88 |
+
</div>
|
89 |
+
|
90 |
+
<?php
|
91 |
+
|
92 |
+
$disabled = '';
|
93 |
+
if(empty($choices))
|
94 |
+
$disabled = 'disabled="disabled"';
|
95 |
+
|
96 |
+
?>
|
97 |
+
|
98 |
+
<p class="acf-submit">
|
99 |
+
<button type="submit" name="action" class="button button-primary" value="json" <?php echo $disabled; ?>><?php _e('Export File'); ?></button>
|
100 |
+
<button type="submit" name="action" class="button" value="php" <?php echo $disabled; ?>><?php _e('Generate PHP'); ?></button>
|
101 |
+
</p>
|
102 |
+
<?php
|
103 |
+
|
104 |
+
}
|
105 |
+
|
106 |
+
function html_single(){
|
107 |
+
|
108 |
+
?>
|
109 |
+
<div class="acf-postbox-columns">
|
110 |
+
<div class="acf-postbox-main">
|
111 |
+
|
112 |
+
<?php
|
113 |
+
// prevent default translation and fake __() within string
|
114 |
+
acf_update_setting('l10n_var_export', true);
|
115 |
+
|
116 |
+
$str_replace = array(
|
117 |
+
" " => "\t",
|
118 |
+
"'!!__(!!\'" => "__('",
|
119 |
+
"!!\', !!\'" => "', '",
|
120 |
+
"!!\')!!'" => "')",
|
121 |
+
"array (" => "array("
|
122 |
+
);
|
123 |
+
|
124 |
+
$preg_replace = array(
|
125 |
+
'/([\t\r\n]+?)array/' => 'array',
|
126 |
+
'/[0-9]+ => array/' => 'array'
|
127 |
+
);
|
128 |
+
|
129 |
+
|
130 |
+
?>
|
131 |
+
<p><?php _e("The following code can be used to register a option page. Simply copy and paste the following code to your theme's functions.php file or include it within an external file.", 'acf'); ?></p>
|
132 |
+
|
133 |
+
<div id="acf-admin-tool-export">
|
134 |
+
|
135 |
+
<textarea id="acf-export-textarea" readonly="true"><?php
|
136 |
+
|
137 |
+
echo "if( function_exists('acf_add_options_page') ):" . "\r\n" . "\r\n";
|
138 |
+
|
139 |
+
foreach($this->data as $args){
|
140 |
+
|
141 |
+
// code
|
142 |
+
$code = var_export($args, true);
|
143 |
+
|
144 |
+
|
145 |
+
// change double spaces to tabs
|
146 |
+
$code = str_replace( array_keys($str_replace), array_values($str_replace), $code );
|
147 |
+
|
148 |
+
|
149 |
+
// correctly formats "=> array("
|
150 |
+
$code = preg_replace( array_keys($preg_replace), array_values($preg_replace), $code );
|
151 |
+
|
152 |
+
|
153 |
+
// esc_textarea
|
154 |
+
$code = esc_textarea( $code );
|
155 |
+
|
156 |
+
|
157 |
+
// echo
|
158 |
+
echo "acf_add_options_page({$code});" . "\r\n" . "\r\n";
|
159 |
+
|
160 |
+
}
|
161 |
+
|
162 |
+
echo "endif;";
|
163 |
+
|
164 |
+
?></textarea>
|
165 |
+
|
166 |
+
</div>
|
167 |
+
|
168 |
+
<p class="acf-submit">
|
169 |
+
<a class="button" id="acf-export-copy"><?php _e( 'Copy to clipboard', 'acf' ); ?></a>
|
170 |
+
</p>
|
171 |
+
<script type="text/javascript">
|
172 |
+
(function($){
|
173 |
+
|
174 |
+
// vars
|
175 |
+
var $a = $('#acf-export-copy');
|
176 |
+
var $textarea = $('#acf-export-textarea');
|
177 |
+
|
178 |
+
|
179 |
+
// remove $a if 'copy' is not supported
|
180 |
+
if( !document.queryCommandSupported('copy') ) {
|
181 |
+
return $a.remove();
|
182 |
+
}
|
183 |
+
|
184 |
+
|
185 |
+
// event
|
186 |
+
$a.on('click', function( e ){
|
187 |
+
|
188 |
+
// prevent default
|
189 |
+
e.preventDefault();
|
190 |
+
|
191 |
+
|
192 |
+
// select
|
193 |
+
$textarea.get(0).select();
|
194 |
+
|
195 |
+
|
196 |
+
// try
|
197 |
+
try {
|
198 |
+
|
199 |
+
// copy
|
200 |
+
var copy = document.execCommand('copy');
|
201 |
+
if( !copy ) return;
|
202 |
+
|
203 |
+
|
204 |
+
// tooltip
|
205 |
+
acf.newTooltip({
|
206 |
+
text: "<?php _e('Copied', 'acf' ); ?>",
|
207 |
+
timeout: 250,
|
208 |
+
target: $(this),
|
209 |
+
});
|
210 |
+
|
211 |
+
} catch (err) {
|
212 |
+
|
213 |
+
// do nothing
|
214 |
+
|
215 |
+
}
|
216 |
+
|
217 |
+
});
|
218 |
+
|
219 |
+
})(jQuery);
|
220 |
+
</script>
|
221 |
+
</div>
|
222 |
+
</div>
|
223 |
+
<?php
|
224 |
+
|
225 |
+
}
|
226 |
+
|
227 |
+
function load(){
|
228 |
+
|
229 |
+
if($this->is_active()){
|
230 |
+
|
231 |
+
$this->action = $this->get_action();
|
232 |
+
$this->data = $this->get_selected();
|
233 |
+
|
234 |
+
// Json submit
|
235 |
+
if($this->action === 'json')
|
236 |
+
$this->submit();
|
237 |
+
|
238 |
+
// add notice
|
239 |
+
if(!empty($this->data)){
|
240 |
+
|
241 |
+
$count = count($this->data);
|
242 |
+
$text = sprintf(_n( 'Exported 1 option page.', 'Exported %s option pages.', $count, 'acf' ), $count);
|
243 |
+
|
244 |
+
acf_add_admin_notice($text, 'success');
|
245 |
+
|
246 |
+
}
|
247 |
+
|
248 |
+
}
|
249 |
+
|
250 |
+
}
|
251 |
+
|
252 |
+
function submit(){
|
253 |
+
|
254 |
+
$this->action = $this->get_action();
|
255 |
+
$this->data = $this->get_selected();
|
256 |
+
|
257 |
+
// validate
|
258 |
+
if($this->data === false)
|
259 |
+
return acf_add_admin_notice(__('No options page selected'), 'warning');
|
260 |
+
|
261 |
+
$keys = array();
|
262 |
+
foreach($this->data as $key => $args){
|
263 |
+
|
264 |
+
$keys[] = $key;
|
265 |
+
|
266 |
+
}
|
267 |
+
|
268 |
+
if($this->action === 'json'){
|
269 |
+
|
270 |
+
// Prefix
|
271 |
+
$prefix = (count($keys) > 1) ? 'options-pages' : 'options-page';
|
272 |
+
|
273 |
+
// Slugs
|
274 |
+
$slugs = implode('-', $keys);
|
275 |
+
|
276 |
+
// Date
|
277 |
+
$date = date('Y-m-d');
|
278 |
+
|
279 |
+
// file
|
280 |
+
$file_name = 'acfe-export-' . $prefix . '-' . $slugs . '-' . $date . '.json';
|
281 |
+
|
282 |
+
// headers
|
283 |
+
header("Content-Description: File Transfer");
|
284 |
+
header("Content-Disposition: attachment; filename={$file_name}");
|
285 |
+
header("Content-Type: application/json; charset=utf-8");
|
286 |
+
|
287 |
+
// return
|
288 |
+
echo acf_json_encode($this->data);
|
289 |
+
die;
|
290 |
+
|
291 |
+
}
|
292 |
+
|
293 |
+
elseif($this->action === 'php'){
|
294 |
+
|
295 |
+
// url
|
296 |
+
$url = add_query_arg(array(
|
297 |
+
'keys' => implode('+', $keys),
|
298 |
+
'action' => 'php'
|
299 |
+
), $this->get_url());
|
300 |
+
|
301 |
+
// redirect
|
302 |
+
wp_redirect($url);
|
303 |
+
exit;
|
304 |
+
|
305 |
+
}
|
306 |
+
|
307 |
+
}
|
308 |
+
|
309 |
+
function get_selected(){
|
310 |
+
|
311 |
+
// vars
|
312 |
+
$selected = $this->get_selected_keys();
|
313 |
+
$data = array();
|
314 |
+
|
315 |
+
if(!$selected)
|
316 |
+
return false;
|
317 |
+
|
318 |
+
$dynamic_options_pages = get_option('acfe_dynamic_options_pages', array());
|
319 |
+
if(empty($dynamic_options_pages))
|
320 |
+
return false;
|
321 |
+
|
322 |
+
// construct data
|
323 |
+
foreach($selected as $key){
|
324 |
+
|
325 |
+
if(!isset($dynamic_options_pages[$key]))
|
326 |
+
continue;
|
327 |
+
|
328 |
+
// add to data array
|
329 |
+
$data[$key] = $dynamic_options_pages[$key];
|
330 |
+
|
331 |
+
}
|
332 |
+
|
333 |
+
// return
|
334 |
+
return $data;
|
335 |
+
|
336 |
+
}
|
337 |
+
|
338 |
+
function get_selected_keys(){
|
339 |
+
|
340 |
+
// check $_POST
|
341 |
+
if($keys = acf_maybe_get_POST('keys')){
|
342 |
+
|
343 |
+
return (array) $keys;
|
344 |
+
|
345 |
+
}
|
346 |
+
|
347 |
+
// check $_GET
|
348 |
+
if($keys = acf_maybe_get_GET('keys')){
|
349 |
+
|
350 |
+
$keys = str_replace(' ', '+', $keys);
|
351 |
+
return explode('+', $keys);
|
352 |
+
|
353 |
+
}
|
354 |
+
|
355 |
+
// return
|
356 |
+
return false;
|
357 |
+
|
358 |
+
}
|
359 |
+
|
360 |
+
function get_action(){
|
361 |
+
|
362 |
+
// init
|
363 |
+
$type = 'json';
|
364 |
+
|
365 |
+
// check GET / POST
|
366 |
+
if(($action = acf_maybe_get_GET('action')) || ($action = acf_maybe_get_POST('action'))){
|
367 |
+
|
368 |
+
if(in_array($action, array('json', 'php')))
|
369 |
+
$type = $action;
|
370 |
+
|
371 |
+
}
|
372 |
+
|
373 |
+
// return
|
374 |
+
return $type;
|
375 |
+
|
376 |
+
}
|
377 |
+
|
378 |
+
}
|
379 |
+
|
380 |
+
acf_register_admin_tool('ACFE_Admin_Tool_Export_DOP');
|
381 |
+
|
382 |
endif;
|
includes/admin/tools/dpt-export.php
CHANGED
@@ -1,184 +1,379 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
// Check setting
|
7 |
-
if(!acf_get_setting('acfe/modules/dynamic_post_types'))
|
8 |
-
return;
|
9 |
-
|
10 |
-
if(!class_exists('ACFE_Admin_Tool_Export_DPT')):
|
11 |
-
|
12 |
-
class ACFE_Admin_Tool_Export_DPT extends ACF_Admin_Tool{
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
// Check setting
|
7 |
+
if(!acf_get_setting('acfe/modules/dynamic_post_types'))
|
8 |
+
return;
|
9 |
+
|
10 |
+
if(!class_exists('ACFE_Admin_Tool_Export_DPT')):
|
11 |
+
|
12 |
+
class ACFE_Admin_Tool_Export_DPT extends ACF_Admin_Tool{
|
13 |
+
|
14 |
+
public $action = false;
|
15 |
+
public $data = array();
|
16 |
+
|
17 |
+
function initialize(){
|
18 |
+
|
19 |
+
// vars
|
20 |
+
$this->name = 'acfe_tool_dpt_export';
|
21 |
+
$this->title = __('Export Post Types');
|
22 |
+
$this->icon = 'dashicons-upload';
|
23 |
+
|
24 |
+
}
|
25 |
+
|
26 |
+
function html(){
|
27 |
+
|
28 |
+
// Single
|
29 |
+
if($this->is_active()){
|
30 |
+
|
31 |
+
$this->html_single();
|
32 |
+
|
33 |
+
|
34 |
+
// Archive
|
35 |
+
}else{
|
36 |
+
|
37 |
+
$this->html_archive();
|
38 |
+
|
39 |
+
}
|
40 |
+
|
41 |
+
}
|
42 |
+
|
43 |
+
function html_archive(){
|
44 |
+
|
45 |
+
// vars
|
46 |
+
$choices = array();
|
47 |
+
|
48 |
+
$dynamic_post_types = get_option('acfe_dynamic_post_types', array());
|
49 |
+
|
50 |
+
if($dynamic_post_types){
|
51 |
+
foreach($dynamic_post_types as $post_type_name => $args){
|
52 |
+
|
53 |
+
$choices[$post_type_name] = esc_html($args['label']);
|
54 |
+
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
?>
|
59 |
+
<p><?php _e('Export Post Types', 'acf'); ?></p>
|
60 |
+
|
61 |
+
<div class="acf-fields">
|
62 |
+
<?php
|
63 |
+
|
64 |
+
if(!empty($choices)){
|
65 |
+
|
66 |
+
// render
|
67 |
+
acf_render_field_wrap(array(
|
68 |
+
'label' => __('Select Post Types', 'acf'),
|
69 |
+
'type' => 'checkbox',
|
70 |
+
'name' => 'keys',
|
71 |
+
'prefix' => false,
|
72 |
+
'value' => false,
|
73 |
+
'toggle' => true,
|
74 |
+
'choices' => $choices,
|
75 |
+
));
|
76 |
+
|
77 |
+
}
|
78 |
+
|
79 |
+
else{
|
80 |
+
|
81 |
+
echo '<div style="padding:15px 12px;">';
|
82 |
+
_e('No dynamic post type available.');
|
83 |
+
echo '</div>';
|
84 |
+
|
85 |
+
}
|
86 |
+
|
87 |
+
?>
|
88 |
+
</div>
|
89 |
+
|
90 |
+
<?php
|
91 |
+
|
92 |
+
$disabled = '';
|
93 |
+
if(empty($choices))
|
94 |
+
$disabled = 'disabled="disabled"';
|
95 |
+
|
96 |
+
?>
|
97 |
+
|
98 |
+
<p class="acf-submit">
|
99 |
+
<button type="submit" name="action" class="button button-primary" value="json" <?php echo $disabled; ?>><?php _e('Export File'); ?></button>
|
100 |
+
<button type="submit" name="action" class="button" value="php" <?php echo $disabled; ?>><?php _e('Generate PHP'); ?></button>
|
101 |
+
</p>
|
102 |
+
<?php
|
103 |
+
|
104 |
+
}
|
105 |
+
|
106 |
+
function html_single(){
|
107 |
+
|
108 |
+
?>
|
109 |
+
<div class="acf-postbox-columns">
|
110 |
+
<div class="acf-postbox-main">
|
111 |
+
|
112 |
+
<?php
|
113 |
+
// prevent default translation and fake __() within string
|
114 |
+
acf_update_setting('l10n_var_export', true);
|
115 |
+
|
116 |
+
$str_replace = array(
|
117 |
+
" " => "\t",
|
118 |
+
"'!!__(!!\'" => "__('",
|
119 |
+
"!!\', !!\'" => "', '",
|
120 |
+
"!!\')!!'" => "')",
|
121 |
+
"array (" => "array("
|
122 |
+
);
|
123 |
+
|
124 |
+
$preg_replace = array(
|
125 |
+
'/([\t\r\n]+?)array/' => 'array',
|
126 |
+
'/[0-9]+ => array/' => 'array'
|
127 |
+
);
|
128 |
+
|
129 |
+
|
130 |
+
?>
|
131 |
+
<p><?php _e("The following code can be used to register a post type. Simply copy and paste the following code to your theme's functions.php file or include it within an external file.", 'acf'); ?></p>
|
132 |
+
|
133 |
+
<div id="acf-admin-tool-export">
|
134 |
+
|
135 |
+
<textarea id="acf-export-textarea" readonly="true"><?php
|
136 |
+
|
137 |
+
foreach($this->data as $post_type => $args){
|
138 |
+
|
139 |
+
// code
|
140 |
+
$code = var_export($args, true);
|
141 |
+
|
142 |
+
|
143 |
+
// change double spaces to tabs
|
144 |
+
$code = str_replace( array_keys($str_replace), array_values($str_replace), $code );
|
145 |
+
|
146 |
+
|
147 |
+
// correctly formats "=> array("
|
148 |
+
$code = preg_replace( array_keys($preg_replace), array_values($preg_replace), $code );
|
149 |
+
|
150 |
+
|
151 |
+
// esc_textarea
|
152 |
+
$code = esc_textarea( $code );
|
153 |
+
|
154 |
+
|
155 |
+
// echo
|
156 |
+
echo "register_post_type('{$post_type}', {$code});" . "\r\n" . "\r\n";
|
157 |
+
|
158 |
+
}
|
159 |
+
|
160 |
+
?></textarea>
|
161 |
+
|
162 |
+
</div>
|
163 |
+
|
164 |
+
<p class="acf-submit">
|
165 |
+
<a class="button" id="acf-export-copy"><?php _e( 'Copy to clipboard', 'acf' ); ?></a>
|
166 |
+
</p>
|
167 |
+
<script type="text/javascript">
|
168 |
+
(function($){
|
169 |
+
|
170 |
+
// vars
|
171 |
+
var $a = $('#acf-export-copy');
|
172 |
+
var $textarea = $('#acf-export-textarea');
|
173 |
+
|
174 |
+
|
175 |
+
// remove $a if 'copy' is not supported
|
176 |
+
if( !document.queryCommandSupported('copy') ) {
|
177 |
+
return $a.remove();
|
178 |
+
}
|
179 |
+
|
180 |
+
|
181 |
+
// event
|
182 |
+
$a.on('click', function( e ){
|
183 |
+
|
184 |
+
// prevent default
|
185 |
+
e.preventDefault();
|
186 |
+
|
187 |
+
|
188 |
+
// select
|
189 |
+
$textarea.get(0).select();
|
190 |
+
|
191 |
+
|
192 |
+
// try
|
193 |
+
try {
|
194 |
+
|
195 |
+
// copy
|
196 |
+
var copy = document.execCommand('copy');
|
197 |
+
if( !copy ) return;
|
198 |
+
|
199 |
+
|
200 |
+
// tooltip
|
201 |
+
acf.newTooltip({
|
202 |
+
text: "<?php _e('Copied', 'acf' ); ?>",
|
203 |
+
timeout: 250,
|
204 |
+
target: $(this),
|
205 |
+
});
|
206 |
+
|
207 |
+
} catch (err) {
|
208 |
+
|
209 |
+
// do nothing
|
210 |
+
|
211 |
+
}
|
212 |
+
|
213 |
+
});
|
214 |
+
|
215 |
+
})(jQuery);
|
216 |
+
</script>
|
217 |
+
</div>
|
218 |
+
</div>
|
219 |
+
<?php
|
220 |
+
|
221 |
+
}
|
222 |
+
|
223 |
+
function load(){
|
224 |
+
|
225 |
+
if($this->is_active()){
|
226 |
+
|
227 |
+
$this->action = $this->get_action();
|
228 |
+
$this->data = $this->get_selected();
|
229 |
+
|
230 |
+
// Json submit
|
231 |
+
if($this->action === 'json')
|
232 |
+
$this->submit();
|
233 |
+
|
234 |
+
// add notice
|
235 |
+
if(!empty($this->data)){
|
236 |
+
|
237 |
+
$count = count($this->data);
|
238 |
+
$text = sprintf(_n( 'Exported 1 post type.', 'Exported %s post types.', $count, 'acf' ), $count);
|
239 |
+
|
240 |
+
acf_add_admin_notice($text, 'success');
|
241 |
+
|
242 |
+
}
|
243 |
+
|
244 |
+
}
|
245 |
+
|
246 |
+
}
|
247 |
+
|
248 |
+
function submit(){
|
249 |
+
|
250 |
+
$this->action = $this->get_action();
|
251 |
+
$this->data = $this->get_selected();
|
252 |
+
|
253 |
+
// validate
|
254 |
+
if($this->data === false)
|
255 |
+
return acf_add_admin_notice(__('No post types selected'), 'warning');
|
256 |
+
|
257 |
+
$keys = array();
|
258 |
+
foreach($this->data as $key => $args){
|
259 |
+
|
260 |
+
$keys[] = $key;
|
261 |
+
|
262 |
+
}
|
263 |
+
|
264 |
+
if($this->action === 'json'){
|
265 |
+
|
266 |
+
// Prefix
|
267 |
+
$prefix = (count($keys) > 1) ? 'post-types' : 'post-type';
|
268 |
+
|
269 |
+
// Slugs
|
270 |
+
$slugs = implode('-', $keys);
|
271 |
+
|
272 |
+
// Date
|
273 |
+
$date = date('Y-m-d');
|
274 |
+
|
275 |
+
// file
|
276 |
+
$file_name = 'acfe-export-' . $prefix . '-' . $slugs . '-' . $date . '.json';
|
277 |
+
|
278 |
+
// headers
|
279 |
+
header("Content-Description: File Transfer");
|
280 |
+
header("Content-Disposition: attachment; filename={$file_name}");
|
281 |
+
header("Content-Type: application/json; charset=utf-8");
|
282 |
+
|
283 |
+
// return
|
284 |
+
echo acf_json_encode($this->data);
|
285 |
+
die;
|
286 |
+
|
287 |
+
}
|
288 |
+
|
289 |
+
elseif($this->action === 'php'){
|
290 |
+
|
291 |
+
// url
|
292 |
+
$url = add_query_arg(array(
|
293 |
+
'keys' => implode('+', $keys),
|
294 |
+
'action' => 'php'
|
295 |
+
), $this->get_url());
|
296 |
+
|
297 |
+
// redirect
|
298 |
+
wp_redirect($url);
|
299 |
+
exit;
|
300 |
+
|
301 |
+
}
|
302 |
+
|
303 |
+
}
|
304 |
+
|
305 |
+
function get_selected(){
|
306 |
+
|
307 |
+
// vars
|
308 |
+
$selected = $this->get_selected_keys();
|
309 |
+
|
310 |
+
if(!$selected)
|
311 |
+
return false;
|
312 |
+
|
313 |
+
$dynamic_post_types = get_option('acfe_dynamic_post_types', array());
|
314 |
+
if(empty($dynamic_post_types))
|
315 |
+
return false;
|
316 |
+
|
317 |
+
$data = array();
|
318 |
+
|
319 |
+
// construct Data
|
320 |
+
foreach($selected as $key){
|
321 |
+
|
322 |
+
if(!isset($dynamic_post_types[$key]))
|
323 |
+
continue;
|
324 |
+
|
325 |
+
// add to data array
|
326 |
+
$data[$key] = $dynamic_post_types[$key];
|
327 |
+
|
328 |
+
}
|
329 |
+
|
330 |
+
// return
|
331 |
+
return $data;
|
332 |
+
|
333 |
+
}
|
334 |
+
|
335 |
+
function get_selected_keys(){
|
336 |
+
|
337 |
+
// check $_POST
|
338 |
+
if($keys = acf_maybe_get_POST('keys')){
|
339 |
+
|
340 |
+
return (array) $keys;
|
341 |
+
|
342 |
+
}
|
343 |
+
|
344 |
+
// check $_GET
|
345 |
+
if($keys = acf_maybe_get_GET('keys')){
|
346 |
+
|
347 |
+
$keys = str_replace(' ', '+', $keys);
|
348 |
+
return explode('+', $keys);
|
349 |
+
|
350 |
+
}
|
351 |
+
|
352 |
+
// return
|
353 |
+
return false;
|
354 |
+
|
355 |
+
}
|
356 |
+
|
357 |
+
function get_action(){
|
358 |
+
|
359 |
+
// init
|
360 |
+
$type = 'json';
|
361 |
+
|
362 |
+
// check GET / POST
|
363 |
+
if(($action = acf_maybe_get_GET('action')) || ($action = acf_maybe_get_POST('action'))){
|
364 |
+
|
365 |
+
if(in_array($action, array('json', 'php')))
|
366 |
+
$type = $action;
|
367 |
+
|
368 |
+
}
|
369 |
+
|
370 |
+
// return
|
371 |
+
return $type;
|
372 |
+
|
373 |
+
}
|
374 |
+
|
375 |
+
}
|
376 |
+
|
377 |
+
acf_register_admin_tool('ACFE_Admin_Tool_Export_DPT');
|
378 |
+
|
379 |
endif;
|
includes/admin/tools/dt-export.php
CHANGED
@@ -1,184 +1,389 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
// Check setting
|
7 |
-
if(!acf_get_setting('acfe/modules/dynamic_taxonomies'))
|
8 |
-
return;
|
9 |
-
|
10 |
-
if(!class_exists('ACFE_Admin_Tool_Export_DT')):
|
11 |
-
|
12 |
-
class ACFE_Admin_Tool_Export_DT extends ACF_Admin_Tool{
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
// Check setting
|
7 |
+
if(!acf_get_setting('acfe/modules/dynamic_taxonomies'))
|
8 |
+
return;
|
9 |
+
|
10 |
+
if(!class_exists('ACFE_Admin_Tool_Export_DT')):
|
11 |
+
|
12 |
+
class ACFE_Admin_Tool_Export_DT extends ACF_Admin_Tool{
|
13 |
+
|
14 |
+
public $action = false;
|
15 |
+
public $data = array();
|
16 |
+
|
17 |
+
function initialize(){
|
18 |
+
|
19 |
+
// vars
|
20 |
+
$this->name = 'acfe_tool_dt_export';
|
21 |
+
$this->title = __('Export Taxonomies');
|
22 |
+
$this->icon = 'dashicons-upload';
|
23 |
+
|
24 |
+
}
|
25 |
+
|
26 |
+
function html(){
|
27 |
+
|
28 |
+
// Single
|
29 |
+
if($this->is_active()){
|
30 |
+
|
31 |
+
$this->html_single();
|
32 |
+
|
33 |
+
|
34 |
+
// Archive
|
35 |
+
}else{
|
36 |
+
|
37 |
+
$this->html_archive();
|
38 |
+
|
39 |
+
}
|
40 |
+
|
41 |
+
}
|
42 |
+
|
43 |
+
function html_archive(){
|
44 |
+
|
45 |
+
// vars
|
46 |
+
$choices = array();
|
47 |
+
|
48 |
+
$dynamic_taxonomies = get_option('acfe_dynamic_taxonomies', array());
|
49 |
+
|
50 |
+
if($dynamic_taxonomies){
|
51 |
+
foreach($dynamic_taxonomies as $taxonomy_name => $args){
|
52 |
+
|
53 |
+
$choices[$taxonomy_name] = esc_html($args['label']);
|
54 |
+
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
?>
|
59 |
+
<p><?php _e('Export Taxonomies', 'acf'); ?></p>
|
60 |
+
|
61 |
+
<div class="acf-fields">
|
62 |
+
<?php
|
63 |
+
|
64 |
+
if(!empty($choices)){
|
65 |
+
|
66 |
+
// render
|
67 |
+
acf_render_field_wrap(array(
|
68 |
+
'label' => __('Select Taxonomies', 'acf'),
|
69 |
+
'type' => 'checkbox',
|
70 |
+
'name' => 'keys',
|
71 |
+
'prefix' => false,
|
72 |
+
'value' => false,
|
73 |
+
'toggle' => true,
|
74 |
+
'choices' => $choices,
|
75 |
+
));
|
76 |
+
|
77 |
+
}
|
78 |
+
|
79 |
+
else{
|
80 |
+
|
81 |
+
echo '<div style="padding:15px 12px;">';
|
82 |
+
_e('No dynamic taxonomy available.');
|
83 |
+
echo '</div>';
|
84 |
+
|
85 |
+
}
|
86 |
+
|
87 |
+
?>
|
88 |
+
</div>
|
89 |
+
|
90 |
+
<?php
|
91 |
+
|
92 |
+
$disabled = '';
|
93 |
+
if(empty($choices))
|
94 |
+
$disabled = 'disabled="disabled"';
|
95 |
+
|
96 |
+
?>
|
97 |
+
|
98 |
+
<p class="acf-submit">
|
99 |
+
<button type="submit" name="action" class="button button-primary" value="json" <?php echo $disabled; ?>><?php _e('Export File'); ?></button>
|
100 |
+
<button type="submit" name="action" class="button" value="php" <?php echo $disabled; ?>><?php _e('Generate PHP'); ?></button>
|
101 |
+
</p>
|
102 |
+
<?php
|
103 |
+
|
104 |
+
}
|
105 |
+
|
106 |
+
function html_single(){
|
107 |
+
|
108 |
+
?>
|
109 |
+
<div class="acf-postbox-columns">
|
110 |
+
<div class="acf-postbox-main">
|
111 |
+
|
112 |
+
<?php
|
113 |
+
// prevent default translation and fake __() within string
|
114 |
+
acf_update_setting('l10n_var_export', true);
|
115 |
+
|
116 |
+
$str_replace = array(
|
117 |
+
" " => "\t",
|
118 |
+
"'!!__(!!\'" => "__('",
|
119 |
+
"!!\', !!\'" => "', '",
|
120 |
+
"!!\')!!'" => "')",
|
121 |
+
"array (" => "array("
|
122 |
+
);
|
123 |
+
|
124 |
+
$preg_replace = array(
|
125 |
+
'/([\t\r\n]+?)array/' => 'array',
|
126 |
+
'/[0-9]+ => array/' => 'array'
|
127 |
+
);
|
128 |
+
|
129 |
+
|
130 |
+
?>
|
131 |
+
<p><?php _e("The following code can be used to register a taxonomy. Simply copy and paste the following code to your theme's functions.php file or include it within an external file.", 'acf'); ?></p>
|
132 |
+
|
133 |
+
<div id="acf-admin-tool-export">
|
134 |
+
|
135 |
+
<textarea id="acf-export-textarea" readonly="true"><?php
|
136 |
+
|
137 |
+
foreach($this->data as $taxonomy => $args){
|
138 |
+
|
139 |
+
$post_types = array();
|
140 |
+
if(acf_maybe_get($args, 'post_types')){
|
141 |
+
|
142 |
+
$post_types = $args['post_types'];
|
143 |
+
|
144 |
+
}
|
145 |
+
|
146 |
+
$post_types = var_export($post_types, true);
|
147 |
+
$post_types = str_replace( array_keys($str_replace), array_values($str_replace), $post_types );
|
148 |
+
$post_types = preg_replace( array_keys($preg_replace), array_values($preg_replace), $post_types );
|
149 |
+
|
150 |
+
|
151 |
+
// code
|
152 |
+
$code = var_export($args, true);
|
153 |
+
|
154 |
+
|
155 |
+
// change double spaces to tabs
|
156 |
+
$code = str_replace( array_keys($str_replace), array_values($str_replace), $code );
|
157 |
+
|
158 |
+
|
159 |
+
// correctly formats "=> array("
|
160 |
+
$code = preg_replace( array_keys($preg_replace), array_values($preg_replace), $code );
|
161 |
+
|
162 |
+
|
163 |
+
// esc_textarea
|
164 |
+
$code = esc_textarea( $code );
|
165 |
+
|
166 |
+
// echo
|
167 |
+
echo "register_taxonomy('{$taxonomy}', {$post_types}, {$code});" . "\r\n" . "\r\n";
|
168 |
+
|
169 |
+
}
|
170 |
+
|
171 |
+
?></textarea>
|
172 |
+
|
173 |
+
</div>
|
174 |
+
|
175 |
+
<p class="acf-submit">
|
176 |
+
<a class="button" id="acf-export-copy"><?php _e( 'Copy to clipboard', 'acf' ); ?></a>
|
177 |
+
</p>
|
178 |
+
<script type="text/javascript">
|
179 |
+
(function($){
|
180 |
+
|
181 |
+
// vars
|
182 |
+
var $a = $('#acf-export-copy');
|
183 |
+
var $textarea = $('#acf-export-textarea');
|
184 |
+
|
185 |
+
|
186 |
+
// remove $a if 'copy' is not supported
|
187 |
+
if( !document.queryCommandSupported('copy') ) {
|
188 |
+
return $a.remove();
|
189 |
+
}
|
190 |
+
|
191 |
+
|
192 |
+
// event
|
193 |
+
$a.on('click', function( e ){
|
194 |
+
|
195 |
+
// prevent default
|
196 |
+
e.preventDefault();
|
197 |
+
|
198 |
+
|
199 |
+
// select
|
200 |
+
$textarea.get(0).select();
|
201 |
+
|
202 |
+
|
203 |
+
// try
|
204 |
+
try {
|
205 |
+
|
206 |
+
// copy
|
207 |
+
var copy = document.execCommand('copy');
|
208 |
+
if( !copy ) return;
|
209 |
+
|
210 |
+
|
211 |
+
// tooltip
|
212 |
+
acf.newTooltip({
|
213 |
+
text: "<?php _e('Copied', 'acf' ); ?>",
|
214 |
+
timeout: 250,
|
215 |
+
target: $(this),
|
216 |
+
});
|
217 |
+
|
218 |
+
} catch (err) {
|
219 |
+
|
220 |
+
// do nothing
|
221 |
+
|
222 |
+
}
|
223 |
+
|
224 |
+
});
|
225 |
+
|
226 |
+
})(jQuery);
|
227 |
+
</script>
|
228 |
+
</div>
|
229 |
+
</div>
|
230 |
+
<?php
|
231 |
+
|
232 |
+
}
|
233 |
+
|
234 |
+
function load(){
|
235 |
+
|
236 |
+
if($this->is_active()){
|
237 |
+
|
238 |
+
$this->action = $this->get_action();
|
239 |
+
$this->data = $this->get_selected();
|
240 |
+
|
241 |
+
// Json submit
|
242 |
+
if($this->action === 'json')
|
243 |
+
$this->submit();
|
244 |
+
|
245 |
+
// add notice
|
246 |
+
if(!empty($this->data)){
|
247 |
+
|
248 |
+
$count = count($this->data);
|
249 |
+
$text = sprintf(_n( 'Exported 1 taxonomy.', 'Exported %s taxonomies.', $count, 'acf' ), $count);
|
250 |
+
|
251 |
+
acf_add_admin_notice($text, 'success');
|
252 |
+
|
253 |
+
}
|
254 |
+
|
255 |
+
}
|
256 |
+
|
257 |
+
}
|
258 |
+
|
259 |
+
function submit(){
|
260 |
+
|
261 |
+
$this->action = $this->get_action();
|
262 |
+
$this->data = $this->get_selected();
|
263 |
+
|
264 |
+
// validate
|
265 |
+
if($this->data === false)
|
266 |
+
return acf_add_admin_notice(__('No taxonomies selected'), 'warning');
|
267 |
+
|
268 |
+
$keys = array();
|
269 |
+
foreach($this->data as $key => $args){
|
270 |
+
|
271 |
+
$keys[] = $key;
|
272 |
+
|
273 |
+
}
|
274 |
+
|
275 |
+
if($this->action === 'json'){
|
276 |
+
|
277 |
+
// Prefix
|
278 |
+
$prefix = (count($keys) > 1) ? 'taxonomies' : 'taxonomy';
|
279 |
+
|
280 |
+
// Slugs
|
281 |
+
$slugs = implode('-', $keys);
|
282 |
+
|
283 |
+
// Date
|
284 |
+
$date = date('Y-m-d');
|
285 |
+
|
286 |
+
// file
|
287 |
+
$file_name = 'acfe-export-' . $prefix . '-' . $slugs . '-' . $date . '.json';
|
288 |
+
|
289 |
+
// headers
|
290 |
+
header("Content-Description: File Transfer");
|
291 |
+
header("Content-Disposition: attachment; filename={$file_name}");
|
292 |
+
header("Content-Type: application/json; charset=utf-8");
|
293 |
+
|
294 |
+
// return
|
295 |
+
echo acf_json_encode($this->data);
|
296 |
+
die;
|
297 |
+
|
298 |
+
}
|
299 |
+
|
300 |
+
elseif($this->action === 'php'){
|
301 |
+
|
302 |
+
// url
|
303 |
+
$url = add_query_arg(array(
|
304 |
+
'keys' => implode('+', $keys),
|
305 |
+
'action' => 'php'
|
306 |
+
), $this->get_url());
|
307 |
+
|
308 |
+
// redirect
|
309 |
+
wp_redirect($url);
|
310 |
+
exit;
|
311 |
+
|
312 |
+
}
|
313 |
+
|
314 |
+
}
|
315 |
+
|
316 |
+
function get_selected(){
|
317 |
+
|
318 |
+
// vars
|
319 |
+
$selected = $this->get_selected_keys();
|
320 |
+
$json = array();
|
321 |
+
|
322 |
+
if(!$selected)
|
323 |
+
return false;
|
324 |
+
|
325 |
+
$dynamic_taxonomies = get_option('acfe_dynamic_taxonomies', array());
|
326 |
+
if(empty($dynamic_taxonomies))
|
327 |
+
return false;
|
328 |
+
|
329 |
+
// construct JSON
|
330 |
+
foreach($selected as $key){
|
331 |
+
|
332 |
+
if(!isset($dynamic_taxonomies[$key]))
|
333 |
+
continue;
|
334 |
+
|
335 |
+
// add to json array
|
336 |
+
$json[$key] = $dynamic_taxonomies[$key];
|
337 |
+
|
338 |
+
}
|
339 |
+
|
340 |
+
// return
|
341 |
+
return $json;
|
342 |
+
|
343 |
+
}
|
344 |
+
|
345 |
+
function get_selected_keys(){
|
346 |
+
|
347 |
+
// check $_POST
|
348 |
+
if($keys = acf_maybe_get_POST('keys')){
|
349 |
+
|
350 |
+
return (array) $keys;
|
351 |
+
|
352 |
+
}
|
353 |
+
|
354 |
+
// check $_GET
|
355 |
+
if($keys = acf_maybe_get_GET('keys')){
|
356 |
+
|
357 |
+
$keys = str_replace(' ', '+', $keys);
|
358 |
+
return explode('+', $keys);
|
359 |
+
|
360 |
+
}
|
361 |
+
|
362 |
+
// return
|
363 |
+
return false;
|
364 |
+
|
365 |
+
}
|
366 |
+
|
367 |
+
function get_action(){
|
368 |
+
|
369 |
+
// init
|
370 |
+
$type = 'json';
|
371 |
+
|
372 |
+
// check GET / POST
|
373 |
+
if(($action = acf_maybe_get_GET('action')) || ($action = acf_maybe_get_POST('action'))){
|
374 |
+
|
375 |
+
if(in_array($action, array('json', 'php')))
|
376 |
+
$type = $action;
|
377 |
+
|
378 |
+
}
|
379 |
+
|
380 |
+
// return
|
381 |
+
return $type;
|
382 |
+
|
383 |
+
}
|
384 |
+
|
385 |
+
}
|
386 |
+
|
387 |
+
acf_register_admin_tool('ACFE_Admin_Tool_Export_DT');
|
388 |
+
|
389 |
endif;
|
includes/admin/tools/fg-export.php
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
if(!class_exists('ACFE_Admin_Tool_Export_FG')):
|
7 |
+
|
8 |
+
class ACFE_Admin_Tool_Export_FG extends ACF_Admin_Tool{
|
9 |
+
|
10 |
+
function initialize(){
|
11 |
+
|
12 |
+
// vars
|
13 |
+
$this->name = 'acfe-export';
|
14 |
+
|
15 |
+
}
|
16 |
+
|
17 |
+
function load(){
|
18 |
+
|
19 |
+
$action = $this->get_action();
|
20 |
+
|
21 |
+
if($action === 'json'){
|
22 |
+
|
23 |
+
acf()->admin_tools->get_tool('export')->submit_download();
|
24 |
+
|
25 |
+
}
|
26 |
+
|
27 |
+
// active
|
28 |
+
if($this->is_active()){
|
29 |
+
|
30 |
+
// get selected keys
|
31 |
+
$selected = acf()->admin_tools->get_tool('export')->get_selected_keys();
|
32 |
+
|
33 |
+
// add notice
|
34 |
+
if( $selected ) {
|
35 |
+
$count = count($selected);
|
36 |
+
$text = sprintf( _n( 'Exported 1 field group.', 'Exported %s field groups.', $count, 'acf' ), $count );
|
37 |
+
acf_add_admin_notice( $text, 'success' );
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
}
|
42 |
+
|
43 |
+
function get_action(){
|
44 |
+
|
45 |
+
// init
|
46 |
+
$type = false;
|
47 |
+
|
48 |
+
// check GET / POST
|
49 |
+
if(($action = acf_maybe_get_GET('action')) || ($action = acf_maybe_get_POST('action'))){
|
50 |
+
|
51 |
+
if(in_array($action, array('json', 'php')))
|
52 |
+
$type = $action;
|
53 |
+
|
54 |
+
}
|
55 |
+
|
56 |
+
// return
|
57 |
+
return $type;
|
58 |
+
|
59 |
+
}
|
60 |
+
|
61 |
+
}
|
62 |
+
|
63 |
+
acf_register_admin_tool('ACFE_Admin_Tool_Export_FG');
|
64 |
+
|
65 |
+
endif;
|
includes/admin/tools/form-export.php
ADDED
@@ -0,0 +1,239 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
// Check setting
|
7 |
+
if(!acf_get_setting('acfe/modules/dynamic_forms'))
|
8 |
+
return;
|
9 |
+
|
10 |
+
if(!class_exists('ACFE_Admin_Tool_Export_Form')):
|
11 |
+
|
12 |
+
class ACFE_Admin_Tool_Export_Form extends ACF_Admin_Tool{
|
13 |
+
|
14 |
+
public $action = false;
|
15 |
+
public $data = array();
|
16 |
+
|
17 |
+
function initialize(){
|
18 |
+
|
19 |
+
// vars
|
20 |
+
$this->name = 'acfe_tool_form_export';
|
21 |
+
$this->title = __('Export Forms');
|
22 |
+
$this->icon = 'dashicons-upload';
|
23 |
+
|
24 |
+
}
|
25 |
+
|
26 |
+
function html(){
|
27 |
+
|
28 |
+
// Archive
|
29 |
+
if(!$this->is_active()){
|
30 |
+
|
31 |
+
$this->html_archive();
|
32 |
+
|
33 |
+
}
|
34 |
+
|
35 |
+
}
|
36 |
+
|
37 |
+
function html_archive(){
|
38 |
+
|
39 |
+
// vars
|
40 |
+
$choices = array();
|
41 |
+
|
42 |
+
$get_forms = get_posts(array(
|
43 |
+
'post_type' => 'acfe-form',
|
44 |
+
'posts_per_page' => -1,
|
45 |
+
'fields' => 'ids'
|
46 |
+
));
|
47 |
+
|
48 |
+
if($get_forms){
|
49 |
+
foreach($get_forms as $form_id){
|
50 |
+
|
51 |
+
$name = get_field('acfe_form_name', $form_id);
|
52 |
+
|
53 |
+
$choices[$name] = esc_html(get_the_title($form_id));
|
54 |
+
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
?>
|
59 |
+
<p><?php _e('Export Forms', 'acf'); ?></p>
|
60 |
+
|
61 |
+
<div class="acf-fields">
|
62 |
+
<?php
|
63 |
+
|
64 |
+
if(!empty($choices)){
|
65 |
+
|
66 |
+
// render
|
67 |
+
acf_render_field_wrap(array(
|
68 |
+
'label' => __('Select Forms', 'acf'),
|
69 |
+
'type' => 'checkbox',
|
70 |
+
'name' => 'keys',
|
71 |
+
'prefix' => false,
|
72 |
+
'value' => false,
|
73 |
+
'toggle' => true,
|
74 |
+
'choices' => $choices,
|
75 |
+
));
|
76 |
+
|
77 |
+
}
|
78 |
+
|
79 |
+
else{
|
80 |
+
|
81 |
+
echo '<div style="padding:15px 12px;">';
|
82 |
+
_e('No dynamic form available.');
|
83 |
+
echo '</div>';
|
84 |
+
|
85 |
+
}
|
86 |
+
|
87 |
+
?>
|
88 |
+
</div>
|
89 |
+
|
90 |
+
<?php
|
91 |
+
|
92 |
+
$disabled = '';
|
93 |
+
if(empty($choices))
|
94 |
+
$disabled = 'disabled="disabled"';
|
95 |
+
|
96 |
+
?>
|
97 |
+
|
98 |
+
<p class="acf-submit">
|
99 |
+
<button type="submit" name="action" class="button button-primary" value="json" <?php echo $disabled; ?>><?php _e('Export File'); ?></button>
|
100 |
+
</p>
|
101 |
+
<?php
|
102 |
+
|
103 |
+
}
|
104 |
+
|
105 |
+
function load(){
|
106 |
+
|
107 |
+
if($this->is_active()){
|
108 |
+
|
109 |
+
$this->action = $this->get_action();
|
110 |
+
$this->data = $this->get_selected();
|
111 |
+
|
112 |
+
// Json submit
|
113 |
+
if($this->action === 'json')
|
114 |
+
$this->submit();
|
115 |
+
|
116 |
+
// add notice
|
117 |
+
if(!empty($this->data)){
|
118 |
+
|
119 |
+
$count = count($this->data);
|
120 |
+
$text = sprintf(_n( 'Exported 1 form.', 'Exported %s forms.', $count, 'acf' ), $count);
|
121 |
+
|
122 |
+
acf_add_admin_notice($text, 'success');
|
123 |
+
|
124 |
+
}
|
125 |
+
|
126 |
+
}
|
127 |
+
|
128 |
+
}
|
129 |
+
|
130 |
+
function submit(){
|
131 |
+
|
132 |
+
$this->action = $this->get_action();
|
133 |
+
$this->data = $this->get_selected();
|
134 |
+
|
135 |
+
// validate
|
136 |
+
if($this->data === false)
|
137 |
+
return acf_add_admin_notice(__('No forms selected'), 'warning');
|
138 |
+
|
139 |
+
$keys = array();
|
140 |
+
foreach($this->data as $key => $args){
|
141 |
+
|
142 |
+
$keys[] = $key;
|
143 |
+
|
144 |
+
}
|
145 |
+
|
146 |
+
if($this->action === 'json'){
|
147 |
+
|
148 |
+
// Prefix
|
149 |
+
$prefix = (count($keys) > 1) ? 'forms' : 'forms';
|
150 |
+
|
151 |
+
// Slugs
|
152 |
+
$slugs = implode('-', $keys);
|
153 |
+
|
154 |
+
// Date
|
155 |
+
$date = date('Y-m-d');
|
156 |
+
|
157 |
+
// file
|
158 |
+
$file_name = 'acfe-export-' . $prefix . '-' . $slugs . '-' . $date . '.json';
|
159 |
+
|
160 |
+
// headers
|
161 |
+
header("Content-Description: File Transfer");
|
162 |
+
header("Content-Disposition: attachment; filename={$file_name}");
|
163 |
+
header("Content-Type: application/json; charset=utf-8");
|
164 |
+
|
165 |
+
// return
|
166 |
+
echo acf_json_encode($this->data);
|
167 |
+
die;
|
168 |
+
|
169 |
+
}
|
170 |
+
|
171 |
+
}
|
172 |
+
|
173 |
+
function get_selected(){
|
174 |
+
|
175 |
+
// vars
|
176 |
+
$selected = $this->get_selected_keys();
|
177 |
+
|
178 |
+
if(!$selected)
|
179 |
+
return false;
|
180 |
+
|
181 |
+
$data = array();
|
182 |
+
|
183 |
+
acf_enable_filter('local');
|
184 |
+
|
185 |
+
// construct Data
|
186 |
+
foreach($selected as $key){
|
187 |
+
|
188 |
+
if(!$form = get_page_by_path($key, OBJECT, 'acfe-form'))
|
189 |
+
continue;
|
190 |
+
|
191 |
+
// add to data array
|
192 |
+
$data[$key] = array_merge(array('title' => get_the_title($form->ID)), get_fields($form->ID, false));
|
193 |
+
|
194 |
+
}
|
195 |
+
|
196 |
+
acf_disable_filter('local');
|
197 |
+
|
198 |
+
// return
|
199 |
+
return $data;
|
200 |
+
|
201 |
+
}
|
202 |
+
|
203 |
+
function get_selected_keys(){
|
204 |
+
|
205 |
+
// check $_POST
|
206 |
+
if($keys = acf_maybe_get_POST('keys')){
|
207 |
+
|
208 |
+
return (array) $keys;
|
209 |
+
|
210 |
+
}
|
211 |
+
|
212 |
+
// check $_GET
|
213 |
+
if($keys = acf_maybe_get_GET('keys')){
|
214 |
+
|
215 |
+
$keys = str_replace(' ', '+', $keys);
|
216 |
+
return explode('+', $keys);
|
217 |
+
|
218 |
+
}
|
219 |
+
|
220 |
+
// return
|
221 |
+
return false;
|
222 |
+
|
223 |
+
}
|
224 |
+
|
225 |
+
function get_action(){
|
226 |
+
|
227 |
+
// init
|
228 |
+
$type = 'json';
|
229 |
+
|
230 |
+
// return
|
231 |
+
return $type;
|
232 |
+
|
233 |
+
}
|
234 |
+
|
235 |
+
}
|
236 |
+
|
237 |
+
acf_register_admin_tool('ACFE_Admin_Tool_Export_Form');
|
238 |
+
|
239 |
+
endif;
|
includes/admin/tools/form-import.php
ADDED
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
// Check setting
|
7 |
+
if(!acf_get_setting('acfe/modules/dynamic_forms'))
|
8 |
+
return;
|
9 |
+
|
10 |
+
if(!class_exists('ACFE_Admin_Tool_Import_Form')):
|
11 |
+
|
12 |
+
class ACFE_Admin_Tool_Import_Form extends ACF_Admin_Tool{
|
13 |
+
|
14 |
+
function initialize(){
|
15 |
+
|
16 |
+
// vars
|
17 |
+
$this->name = 'acfe_tool_form_import';
|
18 |
+
$this->title = __('Import Forms');
|
19 |
+
$this->icon = 'dashicons-upload';
|
20 |
+
|
21 |
+
}
|
22 |
+
|
23 |
+
function html(){
|
24 |
+
|
25 |
+
?>
|
26 |
+
<p><?php _e('Import Forms', 'acf'); ?></p>
|
27 |
+
|
28 |
+
<div class="acf-fields">
|
29 |
+
<?php
|
30 |
+
|
31 |
+
acf_render_field_wrap(array(
|
32 |
+
'label' => __('Select File', 'acf'),
|
33 |
+
'type' => 'file',
|
34 |
+
'name' => 'acf_import_file',
|
35 |
+
'value' => false,
|
36 |
+
'uploader' => 'basic',
|
37 |
+
));
|
38 |
+
|
39 |
+
?>
|
40 |
+
</div>
|
41 |
+
|
42 |
+
<p class="acf-submit">
|
43 |
+
<button type="submit" name="action" class="button button-primary"><?php _e('Import File'); ?></button>
|
44 |
+
</p>
|
45 |
+
<?php
|
46 |
+
|
47 |
+
}
|
48 |
+
|
49 |
+
function submit(){
|
50 |
+
|
51 |
+
// Check file size.
|
52 |
+
if(empty($_FILES['acf_import_file']['size']))
|
53 |
+
return acf_add_admin_notice(__("No file selected", 'acf'), 'warning');
|
54 |
+
|
55 |
+
// Get file data.
|
56 |
+
$file = $_FILES['acf_import_file'];
|
57 |
+
|
58 |
+
// Check errors.
|
59 |
+
if($file['error'])
|
60 |
+
return acf_add_admin_notice(__("Error uploading file. Please try again", 'acf'), 'warning');
|
61 |
+
|
62 |
+
// Check file type.
|
63 |
+
if(pathinfo($file['name'], PATHINFO_EXTENSION) !== 'json')
|
64 |
+
return acf_add_admin_notice(__("Incorrect file type", 'acf'), 'warning');
|
65 |
+
|
66 |
+
// Read JSON.
|
67 |
+
$json = file_get_contents($file['tmp_name']);
|
68 |
+
$json = json_decode($json, true);
|
69 |
+
|
70 |
+
// Check if empty.
|
71 |
+
if(!$json || !is_array($json))
|
72 |
+
return acf_add_admin_notice(__("Import file empty", 'acf'), 'warning');
|
73 |
+
|
74 |
+
$ids = array();
|
75 |
+
|
76 |
+
// Loop over json
|
77 |
+
foreach($json as $form_name => $args){
|
78 |
+
|
79 |
+
// Check if already exists
|
80 |
+
if(get_page_by_path($form_name, OBJECT, 'acfe-form')){
|
81 |
+
|
82 |
+
acf_add_admin_notice(__("Form {$args['title']} already exists. Import aborted."), 'warning');
|
83 |
+
continue;
|
84 |
+
|
85 |
+
}
|
86 |
+
|
87 |
+
// Vars
|
88 |
+
$title = acf_extract_var($args, 'title');
|
89 |
+
$name = $form_name;
|
90 |
+
|
91 |
+
// Insert post
|
92 |
+
$post_id = wp_insert_post(array(
|
93 |
+
'post_title' => $title,
|
94 |
+
'post_name' => $name,
|
95 |
+
'post_type' => 'acfe-form',
|
96 |
+
'post_status' => 'publish'
|
97 |
+
));
|
98 |
+
|
99 |
+
// Insert error
|
100 |
+
if(is_wp_error($post_id)){
|
101 |
+
|
102 |
+
acf_add_admin_notice(__("Something went wrong with the form {$title}. Import aborted."), 'warning');
|
103 |
+
continue;
|
104 |
+
|
105 |
+
}
|
106 |
+
|
107 |
+
acf_enable_filter('local');
|
108 |
+
|
109 |
+
acf_update_values($args, $post_id);
|
110 |
+
|
111 |
+
acf_disable_filter('local');
|
112 |
+
|
113 |
+
// append message
|
114 |
+
$ids[] = $post_id;
|
115 |
+
|
116 |
+
}
|
117 |
+
|
118 |
+
if(empty($ids))
|
119 |
+
return;
|
120 |
+
|
121 |
+
// Count total
|
122 |
+
$total = count($ids);
|
123 |
+
|
124 |
+
// Generate text
|
125 |
+
$text = sprintf(_n('1 form imported', '%s forms imported', $total, 'acf'), $total);
|
126 |
+
|
127 |
+
// Add links to text
|
128 |
+
$links = array();
|
129 |
+
foreach($ids as $id){
|
130 |
+
|
131 |
+
$links[] = '<a href="' . get_edit_post_link($id) . '">' . get_the_title($id) . '</a>';
|
132 |
+
|
133 |
+
}
|
134 |
+
|
135 |
+
$text .= ': ' . implode(', ', $links);
|
136 |
+
|
137 |
+
// Add notice
|
138 |
+
acf_add_admin_notice($text, 'success');
|
139 |
+
|
140 |
+
// Flush permalinks
|
141 |
+
flush_rewrite_rules();
|
142 |
+
|
143 |
+
}
|
144 |
+
|
145 |
+
}
|
146 |
+
|
147 |
+
acf_register_admin_tool('ACFE_Admin_Tool_Import_Form');
|
148 |
+
|
149 |
+
endif;
|
includes/core/compatibility.php
CHANGED
@@ -1,132 +1,184 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
}
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
}
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
if(!class_exists('acfe_compatibility')):
|
7 |
+
|
8 |
+
class acfe_compatibility{
|
9 |
+
|
10 |
+
function __construct(){
|
11 |
+
|
12 |
+
add_action('acf/init', array($this, 'init'), 99);
|
13 |
+
|
14 |
+
add_filter('pll_get_post_types', array($this, 'polylang'), 10, 2);
|
15 |
+
|
16 |
+
}
|
17 |
+
|
18 |
+
function init(){
|
19 |
+
|
20 |
+
/**
|
21 |
+
* ACF Extended: 0.8
|
22 |
+
* Settings: Renamed acfe_php* to acfe/php*
|
23 |
+
*/
|
24 |
+
if(acf_get_setting('acfe_php') !== null){
|
25 |
+
acf_update_setting('acfe/php', acf_get_setting('acfe_php'));
|
26 |
+
}
|
27 |
+
|
28 |
+
if(acf_get_setting('php_save') !== null){
|
29 |
+
acf_update_setting('acfe/php_save', acf_get_setting('php_save'));
|
30 |
+
}
|
31 |
+
|
32 |
+
if(acf_get_setting('php_load') !== null){
|
33 |
+
acf_update_setting('acfe/php_load', acf_get_setting('php_load'));
|
34 |
+
}
|
35 |
+
|
36 |
+
if(acf_get_setting('php_found') !== null){
|
37 |
+
acf_update_setting('acfe/php_found', acf_get_setting('php_found'));
|
38 |
+
}
|
39 |
+
|
40 |
+
add_filter('acf/validate_field_group', array($this, 'field_group_location_list'), 20);
|
41 |
+
add_filter('acf/validate_field', array($this, 'field_acfe_update'), 20);
|
42 |
+
add_filter('pto/posts_orderby/ignore', array($this, 'pto_acf_field_group'), 10, 3);
|
43 |
+
add_action('admin_menu', array($this, 'cotto_submenu'), 999);
|
44 |
+
add_filter('rank_math/metabox/priority', array($this, 'rankmath_metaboxes_priority'));
|
45 |
+
add_filter('wpseo_metabox_prio', array($this, 'yoast_metaboxes_priority'));
|
46 |
+
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* ACF Extended: 0.8
|
51 |
+
* Field Group Location: Archive renamed to List
|
52 |
+
*/
|
53 |
+
function field_group_location_list($field_group){
|
54 |
+
|
55 |
+
if(!acf_maybe_get($field_group, 'location'))
|
56 |
+
return $field_group;
|
57 |
+
|
58 |
+
foreach($field_group['location'] as &$or){
|
59 |
+
|
60 |
+
foreach($or as &$and){
|
61 |
+
|
62 |
+
if(!isset($and['value']))
|
63 |
+
continue;
|
64 |
+
|
65 |
+
// Post Type List
|
66 |
+
if($and['param'] === 'post_type' && acfe_ends_with($and['value'], '_archive')){
|
67 |
+
|
68 |
+
$and['param'] = 'post_type_list';
|
69 |
+
$and['value'] = substr_replace($and['value'], '', -8);
|
70 |
+
|
71 |
+
}
|
72 |
+
|
73 |
+
// Taxonomy List
|
74 |
+
elseif($and['param'] === 'taxonomy' && acfe_ends_with($and['value'], '_archive')){
|
75 |
+
|
76 |
+
$and['param'] = 'taxonomy_list';
|
77 |
+
$and['value'] = substr_replace($and['value'], '', -8);
|
78 |
+
|
79 |
+
}
|
80 |
+
|
81 |
+
}
|
82 |
+
|
83 |
+
}
|
84 |
+
|
85 |
+
return $field_group;
|
86 |
+
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* ACF Extended: 0.8
|
91 |
+
* Field Filter Value: Removed from this version
|
92 |
+
*/
|
93 |
+
function field_acfe_update($field){
|
94 |
+
|
95 |
+
if(!acf_maybe_get($field, 'acfe_update'))
|
96 |
+
return $field;
|
97 |
+
|
98 |
+
unset($field['acfe_update']);
|
99 |
+
|
100 |
+
return $field;
|
101 |
+
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Plugin: Post Types Order
|
106 |
+
* https://wordpress.org/plugins/post-types-order/
|
107 |
+
* The plugin apply custom order to 'acf-field-group' Post Type. We have to fix this
|
108 |
+
*/
|
109 |
+
function pto_acf_field_group($ignore, $orderby, $query){
|
110 |
+
|
111 |
+
if(is_admin() && $query->is_main_query() && $query->get('post_type') === 'acf-field-group')
|
112 |
+
$ignore = true;
|
113 |
+
|
114 |
+
return $ignore;
|
115 |
+
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Plugin: Category Order and Taxonomy Terms Order
|
120 |
+
* https://wordpress.org/plugins/taxonomy-terms-order/
|
121 |
+
* The plugin add a submenu to 'Custom Fields' to order Field Group Categories. It's unecessary
|
122 |
+
*/
|
123 |
+
function cotto_submenu(){
|
124 |
+
|
125 |
+
remove_submenu_page('edit.php?post_type=acf-field-group', 'to-interface-acf-field-group');
|
126 |
+
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Plugin: Rank Math SEO
|
131 |
+
* https://wordpress.org/plugins/seo-by-rank-math/
|
132 |
+
* Fix the plugin post metabox which is always above ACF metaboxes
|
133 |
+
*/
|
134 |
+
function rankmath_metaboxes_priority(){
|
135 |
+
|
136 |
+
return 'default';
|
137 |
+
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* Plugin: YOAST SEO
|
142 |
+
* https://wordpress.org/plugins/wordpress-seo/
|
143 |
+
* Fix the plugin post metabox which is always above ACF metaboxes
|
144 |
+
*/
|
145 |
+
function yoast_metaboxes_priority(){
|
146 |
+
|
147 |
+
return 'default';
|
148 |
+
|
149 |
+
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* ACF Extended: 0.8.3
|
153 |
+
* Modules: Enable PolyLang Translation for Modules Post Types
|
154 |
+
* https://polylang.pro/doc/filter-reference/
|
155 |
+
*/
|
156 |
+
function polylang($post_types, $is_settings){
|
157 |
+
|
158 |
+
if($is_settings){
|
159 |
+
|
160 |
+
unset($post_types['acfe-dbt']);
|
161 |
+
unset($post_types['acfe-dt']);
|
162 |
+
unset($post_types['acfe-dop']);
|
163 |
+
unset($post_types['acfe-dpt']);
|
164 |
+
unset($post_types['acfe-form']);
|
165 |
+
|
166 |
+
}else{
|
167 |
+
|
168 |
+
$post_types['acfe-dbt'] = 'acfe-dbt';
|
169 |
+
$post_types['acfe-dt'] = 'acfe-dt';
|
170 |
+
$post_types['acfe-dop'] = 'acfe-dop';
|
171 |
+
$post_types['acfe-dpt'] = 'acfe-dpt';
|
172 |
+
$post_types['acfe-form'] = 'acfe-form';
|
173 |
+
|
174 |
+
}
|
175 |
+
|
176 |
+
return $post_types;
|
177 |
+
|
178 |
+
}
|
179 |
+
|
180 |
+
}
|
181 |
+
|
182 |
+
new acfe_compatibility();
|
183 |
+
|
184 |
+
endif;
|
includes/core/enqueue.php
CHANGED
@@ -1,91 +1,97 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Admin: Enqueue everywhere + conditional
|
8 |
-
*/
|
9 |
-
add_action('admin_enqueue_scripts', 'acfe_enqueue_admin_scripts');
|
10 |
-
function acfe_enqueue_admin_scripts(){
|
11 |
-
|
12 |
-
// Enqueue ACF input
|
13 |
-
wp_enqueue_style('acf-input');
|
14 |
-
wp_enqueue_script('acf-input');
|
15 |
-
|
16 |
-
// ACF Extended
|
17 |
-
wp_enqueue_script('acf-extended', plugins_url('assets/acf-extended.js', ACFE_FILE), array('jquery'), ACFE_VERSION);
|
18 |
-
wp_enqueue_style('acf-extended', plugins_url('assets/acf-extended.css', ACFE_FILE), false, ACFE_VERSION);
|
19 |
-
wp_enqueue_style('acf-extended-admin', plugins_url('assets/acf-extended-admin.css', ACFE_FILE), false, ACFE_VERSION);
|
20 |
-
|
21 |
-
// Better Taxonomies
|
22 |
-
if(acf_get_setting('acfe/modules/taxonomies')){
|
23 |
-
|
24 |
-
wp_enqueue_style('acf-extended-taxonomies', plugins_url('assets/acf-extended-taxonomies.css', ACFE_FILE), false, ACFE_VERSION);
|
25 |
-
|
26 |
-
}
|
27 |
-
|
28 |
-
// ACF Extended: Field Groups only
|
29 |
-
if(acf_is_screen(array('edit-acf-field-group', 'acf-field-group'))){
|
30 |
-
|
31 |
-
wp_enqueue_script('acf-extended-fg', plugins_url('assets/acf-extended-fg.js', ACFE_FILE), array('jquery'), ACFE_VERSION);
|
32 |
-
wp_enqueue_style('acf-extended-fg', plugins_url('assets/acf-extended-fg.css', ACFE_FILE), false, ACFE_VERSION);
|
33 |
-
|
34 |
-
}
|
35 |
-
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Admin + WP: Enqueue where ACF is loaded
|
40 |
-
*/
|
41 |
-
add_action('acf/enqueue_scripts', 'acfe_enqueue_scripts');
|
42 |
-
function acfe_enqueue_scripts(){
|
43 |
-
|
44 |
-
// ACF Extended
|
45 |
-
wp_enqueue_script('acf-extended', plugins_url('assets/acf-extended.js', ACFE_FILE), array('jquery'), ACFE_VERSION);
|
46 |
-
wp_enqueue_style('acf-extended', plugins_url('assets/acf-extended.css', ACFE_FILE), false, ACFE_VERSION);
|
47 |
-
|
48 |
-
// ACF Extended: Fields
|
49 |
-
wp_enqueue_script('acf-extended-fields', plugins_url('assets/acf-extended-fields.js', ACFE_FILE), array('jquery'), ACFE_VERSION);
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Admin: Enqueue everywhere + conditional
|
8 |
+
*/
|
9 |
+
add_action('admin_enqueue_scripts', 'acfe_enqueue_admin_scripts');
|
10 |
+
function acfe_enqueue_admin_scripts(){
|
11 |
+
|
12 |
+
// Enqueue ACF input
|
13 |
+
wp_enqueue_style('acf-input');
|
14 |
+
wp_enqueue_script('acf-input');
|
15 |
+
|
16 |
+
// ACF Extended
|
17 |
+
wp_enqueue_script('acf-extended', plugins_url('assets/acf-extended.js', ACFE_FILE), array('jquery'), ACFE_VERSION);
|
18 |
+
wp_enqueue_style('acf-extended', plugins_url('assets/acf-extended.css', ACFE_FILE), false, ACFE_VERSION);
|
19 |
+
wp_enqueue_style('acf-extended-admin', plugins_url('assets/acf-extended-admin.css', ACFE_FILE), false, ACFE_VERSION);
|
20 |
+
|
21 |
+
// Better Taxonomies
|
22 |
+
if(acf_get_setting('acfe/modules/taxonomies')){
|
23 |
+
|
24 |
+
wp_enqueue_style('acf-extended-taxonomies', plugins_url('assets/acf-extended-taxonomies.css', ACFE_FILE), false, ACFE_VERSION);
|
25 |
+
|
26 |
+
}
|
27 |
+
|
28 |
+
// ACF Extended: Field Groups only
|
29 |
+
if(acf_is_screen(array('edit-acf-field-group', 'acf-field-group'))){
|
30 |
+
|
31 |
+
wp_enqueue_script('acf-extended-fg', plugins_url('assets/acf-extended-fg.js', ACFE_FILE), array('jquery'), ACFE_VERSION);
|
32 |
+
wp_enqueue_style('acf-extended-fg', plugins_url('assets/acf-extended-fg.css', ACFE_FILE), false, ACFE_VERSION);
|
33 |
+
|
34 |
+
}
|
35 |
+
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Admin + WP: Enqueue where ACF is loaded
|
40 |
+
*/
|
41 |
+
add_action('acf/enqueue_scripts', 'acfe_enqueue_scripts');
|
42 |
+
function acfe_enqueue_scripts(){
|
43 |
+
|
44 |
+
// ACF Extended
|
45 |
+
wp_enqueue_script('acf-extended', plugins_url('assets/acf-extended.js', ACFE_FILE), array('jquery'), ACFE_VERSION);
|
46 |
+
wp_enqueue_style('acf-extended', plugins_url('assets/acf-extended.css', ACFE_FILE), false, ACFE_VERSION);
|
47 |
+
|
48 |
+
// ACF Extended: Fields
|
49 |
+
wp_enqueue_script('acf-extended-fields', plugins_url('assets/acf-extended-fields.js', ACFE_FILE), array('jquery'), ACFE_VERSION);
|
50 |
+
|
51 |
+
// Front only
|
52 |
+
if(!is_admin()){
|
53 |
+
|
54 |
+
wp_enqueue_script('acf-extended-form', plugins_url('assets/acf-extended-form.js', ACFE_FILE), array('jquery'), ACFE_VERSION);
|
55 |
+
|
56 |
+
}
|
57 |
+
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Admin: Enqueue where ACF is loaded
|
62 |
+
*/
|
63 |
+
add_action('acf/input/admin_enqueue_scripts', 'acfe_enqueue_admin_input_scripts');
|
64 |
+
function acfe_enqueue_admin_input_scripts(){
|
65 |
+
|
66 |
+
// ACF Extended: Modal
|
67 |
+
wp_enqueue_style('acf-extended-modal', plugins_url('assets/acf-extended-modal.css', ACFE_FILE), false, ACFE_VERSION);
|
68 |
+
|
69 |
+
// Do not enqueue on ACF Field Groups views
|
70 |
+
if(acf_is_screen(array('edit-acf-field-group', 'acf-field-group')))
|
71 |
+
return;
|
72 |
+
|
73 |
+
// ACF Extended: Repeater
|
74 |
+
wp_enqueue_style('acf-extended-repeater', plugins_url('assets/acf-extended-repeater.css', ACFE_FILE), false, ACFE_VERSION);
|
75 |
+
wp_enqueue_script('acf-extended-repeater', plugins_url('assets/acf-extended-repeater.js', ACFE_FILE), array('jquery'), ACFE_VERSION);
|
76 |
+
|
77 |
+
// ACF Extended: Flexible Content
|
78 |
+
wp_enqueue_style('acf-extended-fc', plugins_url('assets/acf-extended-fc.css', ACFE_FILE), false, ACFE_VERSION);
|
79 |
+
wp_enqueue_script('acf-extended-fc', plugins_url('assets/acf-extended-fc.js', ACFE_FILE), array('jquery'), ACFE_VERSION);
|
80 |
+
|
81 |
+
// ACF Extended: Flexible Content Control
|
82 |
+
wp_enqueue_style('acf-extended-fc-control', plugins_url('assets/acf-extended-fc-control.css', ACFE_FILE), false, ACFE_VERSION);
|
83 |
+
wp_enqueue_script('acf-extended-fc-control', plugins_url('assets/acf-extended-fc-control.js', ACFE_FILE), array('jquery'), ACFE_VERSION);
|
84 |
+
|
85 |
+
// ACF Extended: Flexible Content Modal Select
|
86 |
+
wp_enqueue_style('acf-extended-fc-modal-select', plugins_url('assets/acf-extended-fc-modal-select.css', ACFE_FILE), false, ACFE_VERSION);
|
87 |
+
wp_enqueue_script('acf-extended-fc-modal-select', plugins_url('assets/acf-extended-fc-modal-select.js', ACFE_FILE), array('jquery'), ACFE_VERSION);
|
88 |
+
|
89 |
+
// ACF Extended: Flexible Content Modal Edit
|
90 |
+
wp_enqueue_style('acf-extended-fc-modal-edit', plugins_url('assets/acf-extended-fc-modal-edit.css', ACFE_FILE), false, ACFE_VERSION);
|
91 |
+
wp_enqueue_script('acf-extended-fc-modal-edit', plugins_url('assets/acf-extended-fc-modal-edit.js', ACFE_FILE), array('jquery'), ACFE_VERSION);
|
92 |
+
|
93 |
+
acf_localize_data(array(
|
94 |
+
'close' => __('Close', 'acfe')
|
95 |
+
));
|
96 |
+
|
97 |
}
|
includes/core/helpers.php
CHANGED
@@ -1,785 +1,773 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Get Flexible
|
8 |
-
*/
|
9 |
-
if(!function_exists('get_flexible')){
|
10 |
-
|
11 |
-
function get_flexible($selector, $post_id = false){
|
12 |
-
|
13 |
-
if(!have_rows($selector, $post_id))
|
14 |
-
return;
|
15 |
-
|
16 |
-
// Vars
|
17 |
-
$field = acf_get_field($selector);
|
18 |
-
$flexible = acf_get_field_type('flexible_content');
|
19 |
-
$is_preview = false;
|
20 |
-
|
21 |
-
// Actions
|
22 |
-
do_action('acfe/flexible/enqueue', $field, $is_preview);
|
23 |
-
do_action('acfe/flexible/enqueue/name=' . $field['_name'], $field, $is_preview);
|
24 |
-
do_action('acfe/flexible/enqueue/key=' . $field['key'], $field, $is_preview);
|
25 |
-
|
26 |
-
ob_start();
|
27 |
-
|
28 |
-
while(have_rows($selector, $post_id)): the_row();
|
29 |
-
|
30 |
-
// Vars
|
31 |
-
$layout_name = get_row_layout();
|
32 |
-
$layout = $flexible->get_layout($layout_name, $field);
|
33 |
-
|
34 |
-
// Render: HTML Comment
|
35 |
-
echo "\n" . '<!-- ' . $layout['label'] . ' -->' . "\n";
|
36 |
-
|
37 |
-
// Render: Enqueue
|
38 |
-
acfe_flexible_render_layout_enqueue($layout, $field);
|
39 |
-
|
40 |
-
// Render: Template
|
41 |
-
acfe_flexible_render_layout_template($layout, $field);
|
42 |
-
|
43 |
-
endwhile;
|
44 |
-
|
45 |
-
return ob_get_clean();
|
46 |
-
|
47 |
-
}
|
48 |
-
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* The Flexible
|
53 |
-
*/
|
54 |
-
if(!function_exists('the_flexible')){
|
55 |
-
|
56 |
-
function the_flexible($selector, $post_id = false){
|
57 |
-
|
58 |
-
echo get_flexible($selector, $post_id);
|
59 |
-
|
60 |
-
}
|
61 |
-
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* Has Flexible
|
66 |
-
*/
|
67 |
-
if(!function_exists('has_flexible')){
|
68 |
-
|
69 |
-
function has_flexible($selector, $post_id = false){
|
70 |
-
|
71 |
-
return have_rows($selector, $post_id);
|
72 |
-
|
73 |
-
}
|
74 |
-
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* ACFE Flexible: Render Template
|
79 |
-
*/
|
80 |
-
function acfe_flexible_render_layout_template($layout, $field){
|
81 |
-
|
82 |
-
// Vars
|
83 |
-
global $is_preview;
|
84 |
-
|
85 |
-
// Template
|
86 |
-
$acfe_flexible_render_template = false;
|
87 |
-
|
88 |
-
// Filters
|
89 |
-
$acfe_flexible_render_template = apply_filters('acfe/flexible/render/template', $acfe_flexible_render_template, $field, $layout, $is_preview);
|
90 |
-
$acfe_flexible_render_template = apply_filters('acfe/flexible/render/template/name=' . $field['_name'], $acfe_flexible_render_template, $field, $layout, $is_preview);
|
91 |
-
$acfe_flexible_render_template = apply_filters('acfe/flexible/render/template/key=' . $field['key'], $acfe_flexible_render_template, $field, $layout, $is_preview);
|
92 |
-
|
93 |
-
$acfe_flexible_render_template = apply_filters('acfe/flexible/layout/render/template/layout=' . $layout['name'], $acfe_flexible_render_template, $field, $layout, $is_preview);
|
94 |
-
$acfe_flexible_render_template = apply_filters('acfe/flexible/layout/render/template/name=' . $field['_name'] . '&layout=' . $layout['name'], $acfe_flexible_render_template, $field, $layout, $is_preview);
|
95 |
-
$acfe_flexible_render_template = apply_filters('acfe/flexible/layout/render/template/key=' . $field['key'] . '&layout=' . $layout['name'], $acfe_flexible_render_template, $field, $layout, $is_preview);
|
96 |
-
|
97 |
-
// Render: Template
|
98 |
-
if(!empty($acfe_flexible_render_template)){
|
99 |
-
|
100 |
-
$acfe_flexible_render_template_path = false;
|
101 |
-
|
102 |
-
// Full path
|
103 |
-
if(file_exists($acfe_flexible_render_template)){
|
104 |
-
|
105 |
-
$acfe_flexible_render_template_path = $acfe_flexible_render_template;
|
106 |
-
|
107 |
-
}
|
108 |
-
|
109 |
-
// Parent/child relative
|
110 |
-
else{
|
111 |
-
|
112 |
-
$acfe_flexible_render_template_path = locate_template(array($acfe_flexible_render_template));
|
113 |
-
|
114 |
-
}
|
115 |
-
|
116 |
-
// Include
|
117 |
-
if(!empty($acfe_flexible_render_template_path)){
|
118 |
-
|
119 |
-
do_action('acfe/flexible/render/before_template', $field, $layout, $is_preview);
|
120 |
-
do_action('acfe/flexible/render/before_template/name=' . $field['_name'], $field, $layout, $is_preview);
|
121 |
-
do_action('acfe/flexible/render/before_template/key=' . $field['key'], $field, $layout, $is_preview);
|
122 |
-
|
123 |
-
do_action('acfe/flexible/layout/render/before_template/layout=' . $layout['name'], $field, $layout, $is_preview);
|
124 |
-
do_action('acfe/flexible/layout/render/before_template/name=' . $field['_name'] . '&layout=' . $layout['name'], $field, $layout, $is_preview);
|
125 |
-
do_action('acfe/flexible/layout/render/before_template/key=' . $field['key'] . '&layout=' . $layout['name'], $field, $layout, $is_preview);
|
126 |
-
|
127 |
-
include($acfe_flexible_render_template_path);
|
128 |
-
|
129 |
-
do_action('acfe/flexible/render/after_template', $field, $layout, $is_preview);
|
130 |
-
do_action('acfe/flexible/render/after_template/name=' . $field['_name'], $field, $layout, $is_preview);
|
131 |
-
do_action('acfe/flexible/render/after_template/key=' . $field['key'], $field, $layout, $is_preview);
|
132 |
-
|
133 |
-
do_action('acfe/flexible/layout/render/after_template/layout=' . $layout['name'], $field, $layout, $is_preview);
|
134 |
-
do_action('acfe/flexible/layout/render/after_template/name=' . $field['_name'] . '&layout=' . $layout['name'], $field, $layout, $is_preview);
|
135 |
-
do_action('acfe/flexible/layout/render/after_template/key=' . $field['key'] . '&layout=' . $layout['name'], $field, $layout, $is_preview);
|
136 |
-
|
137 |
-
}
|
138 |
-
|
139 |
-
}
|
140 |
-
|
141 |
-
}
|
142 |
-
|
143 |
-
/**
|
144 |
-
* ACFE Flexible: Render Enqueue
|
145 |
-
*/
|
146 |
-
function acfe_flexible_render_layout_enqueue($layout, $field){
|
147 |
-
|
148 |
-
// Vars
|
149 |
-
global $is_preview;
|
150 |
-
$handle = acf_slugify($field['name']) . '-layout-' . acf_slugify($layout['name']);
|
151 |
-
|
152 |
-
/**
|
153 |
-
* Actions
|
154 |
-
*/
|
155 |
-
do_action('acfe/flexible/layout/enqueue/layout=' . $layout['name'], $field, $layout, $is_preview);
|
156 |
-
do_action('acfe/flexible/layout/enqueue/name=' . $field['_name'] . '&layout=' . $layout['name'], $field, $layout, $is_preview);
|
157 |
-
do_action('acfe/flexible/layout/enqueue/key=' . $field['key'] . '&layout=' . $layout['name'], $field, $layout, $is_preview);
|
158 |
-
|
159 |
-
/**
|
160 |
-
* Style
|
161 |
-
*/
|
162 |
-
$acfe_flexible_render_style = false;
|
163 |
-
|
164 |
-
// Filters
|
165 |
-
$acfe_flexible_render_style = apply_filters('acfe/flexible/render/style', $acfe_flexible_render_style, $field, $layout, $is_preview);
|
166 |
-
$acfe_flexible_render_style = apply_filters('acfe/flexible/render/style/name=' . $field['_name'], $acfe_flexible_render_style, $field, $layout, $is_preview);
|
167 |
-
$acfe_flexible_render_style = apply_filters('acfe/flexible/render/style/key=' . $field['key'], $acfe_flexible_render_style, $field, $layout, $is_preview);
|
168 |
-
|
169 |
-
$acfe_flexible_render_style = apply_filters('acfe/flexible/layout/render/style/layout=' . $layout['name'], $acfe_flexible_render_style, $field, $layout, $is_preview);
|
170 |
-
$acfe_flexible_render_style = apply_filters('acfe/flexible/layout/render/style/name=' . $field['_name'] . '&layout=' . $layout['name'], $acfe_flexible_render_style, $field, $layout, $is_preview);
|
171 |
-
$acfe_flexible_render_style = apply_filters('acfe/flexible/layout/render/style/key=' . $field['key'] . '&layout=' . $layout['name'], $acfe_flexible_render_style, $field, $layout, $is_preview);
|
172 |
-
|
173 |
-
// Enqueue
|
174 |
-
if(!empty($acfe_flexible_render_style)){
|
175 |
-
|
176 |
-
$acfe_flexible_render_style_url = false;
|
177 |
-
|
178 |
-
// URL: https://www.domain.com/template/style.js
|
179 |
-
if(stripos($acfe_flexible_render_style, 'http://') === 0 || stripos($acfe_flexible_render_style, 'https://') === 0 || stripos($acfe_flexible_render_style, '//') === 0){
|
180 |
-
|
181 |
-
$acfe_flexible_render_style_url = $acfe_flexible_render_style;
|
182 |
-
|
183 |
-
}
|
184 |
-
|
185 |
-
// Path: template/style.css
|
186 |
-
else{
|
187 |
-
|
188 |
-
$acfe_flexible_render_style_url = acfe_locate_file_url(array($acfe_flexible_render_style));
|
189 |
-
|
190 |
-
}
|
191 |
-
|
192 |
-
// Include
|
193 |
-
if(!empty($acfe_flexible_render_style_url))
|
194 |
-
wp_enqueue_style($handle, $acfe_flexible_render_style_url, array(), false, 'all');
|
195 |
-
|
196 |
-
}
|
197 |
-
|
198 |
-
/**
|
199 |
-
* Script
|
200 |
-
*/
|
201 |
-
$acfe_flexible_render_script = false;
|
202 |
-
|
203 |
-
// Filters
|
204 |
-
$acfe_flexible_render_script = apply_filters('acfe/flexible/render/script', $acfe_flexible_render_script, $field, $layout, $is_preview);
|
205 |
-
$acfe_flexible_render_script = apply_filters('acfe/flexible/render/script/name=' . $field['_name'], $acfe_flexible_render_script, $field, $layout, $is_preview);
|
206 |
-
$acfe_flexible_render_script = apply_filters('acfe/flexible/render/script/key=' . $field['key'], $acfe_flexible_render_script, $field, $layout, $is_preview);
|
207 |
-
|
208 |
-
$acfe_flexible_render_script = apply_filters('acfe/flexible/layout/render/script/layout=' . $layout['name'], $acfe_flexible_render_script, $field, $layout, $is_preview);
|
209 |
-
$acfe_flexible_render_script = apply_filters('acfe/flexible/layout/render/script/name=' . $field['_name'] . '&layout=' . $layout['name'], $acfe_flexible_render_script, $field, $layout, $is_preview);
|
210 |
-
$acfe_flexible_render_script = apply_filters('acfe/flexible/layout/render/script/key=' . $field['key'] . '&layout=' . $layout['name'], $acfe_flexible_render_script, $field, $layout, $is_preview);
|
211 |
-
|
212 |
-
// Enqueue
|
213 |
-
if(!empty($acfe_flexible_render_script)){
|
214 |
-
|
215 |
-
$acfe_flexible_render_script_url = false;
|
216 |
-
|
217 |
-
// URL: https://www.domain.com/template/script.js
|
218 |
-
if(stripos($acfe_flexible_render_script, 'http://') === 0 || stripos($acfe_flexible_render_script, 'https://') === 0 || stripos($acfe_flexible_render_script, '//') === 0){
|
219 |
-
|
220 |
-
$acfe_flexible_render_script_url = $acfe_flexible_render_script;
|
221 |
-
|
222 |
-
}
|
223 |
-
|
224 |
-
// Path: template/script.js
|
225 |
-
else{
|
226 |
-
|
227 |
-
$acfe_flexible_render_script_url = acfe_locate_file_url(array($acfe_flexible_render_script));
|
228 |
-
|
229 |
-
}
|
230 |
-
|
231 |
-
// Include
|
232 |
-
if(!empty($acfe_flexible_render_script_url))
|
233 |
-
wp_enqueue_script($handle, $acfe_flexible_render_script_url, array(), false, true);
|
234 |
-
|
235 |
-
}
|
236 |
-
|
237 |
-
}
|
238 |
-
|
239 |
-
/**
|
240 |
-
* Get Field Group from Field
|
241 |
-
*/
|
242 |
-
function acfe_get_field_group_from_field($field){
|
243 |
-
|
244 |
-
if(!acf_maybe_get($field, 'parent'))
|
245 |
-
return false;
|
246 |
-
|
247 |
-
$field_parent = $field['parent'];
|
248 |
-
|
249 |
-
if(!$field_ancestors = acf_get_field_ancestors($field))
|
250 |
-
return acf_get_field_group($field_parent);
|
251 |
-
|
252 |
-
// Reverse for DESC order (Top field first)
|
253 |
-
$field_ancestors = array_reverse($field_ancestors);
|
254 |
-
|
255 |
-
$field_top_ancestor = $field_ancestors[0];
|
256 |
-
$field_top_ancestor = acf_get_field($field_top_ancestor);
|
257 |
-
|
258 |
-
return acf_get_field_group($field_top_ancestor['parent']);
|
259 |
-
|
260 |
-
}
|
261 |
-
|
262 |
-
/**
|
263 |
-
* Add custom key to fields and all sub fields
|
264 |
-
*/
|
265 |
-
function acfe_field_add_key_recursive(&$field, $key, $value){
|
266 |
-
|
267 |
-
if(isset($field['sub_fields'])){
|
268 |
-
|
269 |
-
foreach($field['sub_fields'] as &$sub_field){
|
270 |
-
|
271 |
-
acfe_field_add_key_recursive($sub_field, $key, $value);
|
272 |
-
|
273 |
-
}
|
274 |
-
|
275 |
-
}
|
276 |
-
|
277 |
-
elseif(isset($field['layouts'])){
|
278 |
-
|
279 |
-
foreach($field['layouts'] as &$layout){
|
280 |
-
|
281 |
-
acfe_field_add_key_recursive($layout, $key, $value);
|
282 |
-
|
283 |
-
}
|
284 |
-
|
285 |
-
}
|
286 |
-
|
287 |
-
$field[$key] = $value;
|
288 |
-
|
289 |
-
}
|
290 |
-
|
291 |
-
/**
|
292 |
-
* Is Json
|
293 |
-
* Source: https://stackoverflow.com/a/6041773
|
294 |
-
*/
|
295 |
-
function acfe_is_json($string){
|
296 |
-
|
297 |
-
// in case string = 1
|
298 |
-
if(is_numeric($string))
|
299 |
-
return false;
|
300 |
-
|
301 |
-
json_decode($string);
|
302 |
-
|
303 |
-
return (json_last_error() == JSON_ERROR_NONE);
|
304 |
-
|
305 |
-
}
|
306 |
-
|
307 |
-
/**
|
308 |
-
*
|
309 |
-
*/
|
310 |
-
function
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
$length
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
function
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
//
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
//
|
736 |
-
|
737 |
-
|
738 |
-
$
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
}
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
if(!in_array(($num % 100), array(11,12,13))){
|
774 |
-
|
775 |
-
switch($num % 10){
|
776 |
-
case 1: return $num . 'st';
|
777 |
-
case 2: return $num . 'nd';
|
778 |
-
case 3: return $num . 'rd';
|
779 |
-
}
|
780 |
-
|
781 |
-
}
|
782 |
-
|
783 |
-
return $num . 'th';
|
784 |
-
|
785 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Get Flexible
|
8 |
+
*/
|
9 |
+
if(!function_exists('get_flexible')){
|
10 |
+
|
11 |
+
function get_flexible($selector, $post_id = false){
|
12 |
+
|
13 |
+
if(!have_rows($selector, $post_id))
|
14 |
+
return;
|
15 |
+
|
16 |
+
// Vars
|
17 |
+
$field = acf_get_field($selector);
|
18 |
+
$flexible = acf_get_field_type('flexible_content');
|
19 |
+
$is_preview = false;
|
20 |
+
|
21 |
+
// Actions
|
22 |
+
do_action('acfe/flexible/enqueue', $field, $is_preview);
|
23 |
+
do_action('acfe/flexible/enqueue/name=' . $field['_name'], $field, $is_preview);
|
24 |
+
do_action('acfe/flexible/enqueue/key=' . $field['key'], $field, $is_preview);
|
25 |
+
|
26 |
+
ob_start();
|
27 |
+
|
28 |
+
while(have_rows($selector, $post_id)): the_row();
|
29 |
+
|
30 |
+
// Vars
|
31 |
+
$layout_name = get_row_layout();
|
32 |
+
$layout = $flexible->get_layout($layout_name, $field);
|
33 |
+
|
34 |
+
// Render: HTML Comment
|
35 |
+
echo "\n" . '<!-- ' . $layout['label'] . ' -->' . "\n";
|
36 |
+
|
37 |
+
// Render: Enqueue
|
38 |
+
acfe_flexible_render_layout_enqueue($layout, $field);
|
39 |
+
|
40 |
+
// Render: Template
|
41 |
+
acfe_flexible_render_layout_template($layout, $field);
|
42 |
+
|
43 |
+
endwhile;
|
44 |
+
|
45 |
+
return ob_get_clean();
|
46 |
+
|
47 |
+
}
|
48 |
+
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* The Flexible
|
53 |
+
*/
|
54 |
+
if(!function_exists('the_flexible')){
|
55 |
+
|
56 |
+
function the_flexible($selector, $post_id = false){
|
57 |
+
|
58 |
+
echo get_flexible($selector, $post_id);
|
59 |
+
|
60 |
+
}
|
61 |
+
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Has Flexible
|
66 |
+
*/
|
67 |
+
if(!function_exists('has_flexible')){
|
68 |
+
|
69 |
+
function has_flexible($selector, $post_id = false){
|
70 |
+
|
71 |
+
return have_rows($selector, $post_id);
|
72 |
+
|
73 |
+
}
|
74 |
+
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* ACFE Flexible: Render Template
|
79 |
+
*/
|
80 |
+
function acfe_flexible_render_layout_template($layout, $field){
|
81 |
+
|
82 |
+
// Vars
|
83 |
+
global $is_preview;
|
84 |
+
|
85 |
+
// Template
|
86 |
+
$acfe_flexible_render_template = false;
|
87 |
+
|
88 |
+
// Filters
|
89 |
+
$acfe_flexible_render_template = apply_filters('acfe/flexible/render/template', $acfe_flexible_render_template, $field, $layout, $is_preview);
|
90 |
+
$acfe_flexible_render_template = apply_filters('acfe/flexible/render/template/name=' . $field['_name'], $acfe_flexible_render_template, $field, $layout, $is_preview);
|
91 |
+
$acfe_flexible_render_template = apply_filters('acfe/flexible/render/template/key=' . $field['key'], $acfe_flexible_render_template, $field, $layout, $is_preview);
|
92 |
+
|
93 |
+
$acfe_flexible_render_template = apply_filters('acfe/flexible/layout/render/template/layout=' . $layout['name'], $acfe_flexible_render_template, $field, $layout, $is_preview);
|
94 |
+
$acfe_flexible_render_template = apply_filters('acfe/flexible/layout/render/template/name=' . $field['_name'] . '&layout=' . $layout['name'], $acfe_flexible_render_template, $field, $layout, $is_preview);
|
95 |
+
$acfe_flexible_render_template = apply_filters('acfe/flexible/layout/render/template/key=' . $field['key'] . '&layout=' . $layout['name'], $acfe_flexible_render_template, $field, $layout, $is_preview);
|
96 |
+
|
97 |
+
// Render: Template
|
98 |
+
if(!empty($acfe_flexible_render_template)){
|
99 |
+
|
100 |
+
$acfe_flexible_render_template_path = false;
|
101 |
+
|
102 |
+
// Full path
|
103 |
+
if(file_exists($acfe_flexible_render_template)){
|
104 |
+
|
105 |
+
$acfe_flexible_render_template_path = $acfe_flexible_render_template;
|
106 |
+
|
107 |
+
}
|
108 |
+
|
109 |
+
// Parent/child relative
|
110 |
+
else{
|
111 |
+
|
112 |
+
$acfe_flexible_render_template_path = locate_template(array($acfe_flexible_render_template));
|
113 |
+
|
114 |
+
}
|
115 |
+
|
116 |
+
// Include
|
117 |
+
if(!empty($acfe_flexible_render_template_path)){
|
118 |
+
|
119 |
+
do_action('acfe/flexible/render/before_template', $field, $layout, $is_preview);
|
120 |
+
do_action('acfe/flexible/render/before_template/name=' . $field['_name'], $field, $layout, $is_preview);
|
121 |
+
do_action('acfe/flexible/render/before_template/key=' . $field['key'], $field, $layout, $is_preview);
|
122 |
+
|
123 |
+
do_action('acfe/flexible/layout/render/before_template/layout=' . $layout['name'], $field, $layout, $is_preview);
|
124 |
+
do_action('acfe/flexible/layout/render/before_template/name=' . $field['_name'] . '&layout=' . $layout['name'], $field, $layout, $is_preview);
|
125 |
+
do_action('acfe/flexible/layout/render/before_template/key=' . $field['key'] . '&layout=' . $layout['name'], $field, $layout, $is_preview);
|
126 |
+
|
127 |
+
include($acfe_flexible_render_template_path);
|
128 |
+
|
129 |
+
do_action('acfe/flexible/render/after_template', $field, $layout, $is_preview);
|
130 |
+
do_action('acfe/flexible/render/after_template/name=' . $field['_name'], $field, $layout, $is_preview);
|
131 |
+
do_action('acfe/flexible/render/after_template/key=' . $field['key'], $field, $layout, $is_preview);
|
132 |
+
|
133 |
+
do_action('acfe/flexible/layout/render/after_template/layout=' . $layout['name'], $field, $layout, $is_preview);
|
134 |
+
do_action('acfe/flexible/layout/render/after_template/name=' . $field['_name'] . '&layout=' . $layout['name'], $field, $layout, $is_preview);
|
135 |
+
do_action('acfe/flexible/layout/render/after_template/key=' . $field['key'] . '&layout=' . $layout['name'], $field, $layout, $is_preview);
|
136 |
+
|
137 |
+
}
|
138 |
+
|
139 |
+
}
|
140 |
+
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* ACFE Flexible: Render Enqueue
|
145 |
+
*/
|
146 |
+
function acfe_flexible_render_layout_enqueue($layout, $field){
|
147 |
+
|
148 |
+
// Vars
|
149 |
+
global $is_preview;
|
150 |
+
$handle = acf_slugify($field['name']) . '-layout-' . acf_slugify($layout['name']);
|
151 |
+
|
152 |
+
/**
|
153 |
+
* Actions
|
154 |
+
*/
|
155 |
+
do_action('acfe/flexible/layout/enqueue/layout=' . $layout['name'], $field, $layout, $is_preview);
|
156 |
+
do_action('acfe/flexible/layout/enqueue/name=' . $field['_name'] . '&layout=' . $layout['name'], $field, $layout, $is_preview);
|
157 |
+
do_action('acfe/flexible/layout/enqueue/key=' . $field['key'] . '&layout=' . $layout['name'], $field, $layout, $is_preview);
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Style
|
161 |
+
*/
|
162 |
+
$acfe_flexible_render_style = false;
|
163 |
+
|
164 |
+
// Filters
|
165 |
+
$acfe_flexible_render_style = apply_filters('acfe/flexible/render/style', $acfe_flexible_render_style, $field, $layout, $is_preview);
|
166 |
+
$acfe_flexible_render_style = apply_filters('acfe/flexible/render/style/name=' . $field['_name'], $acfe_flexible_render_style, $field, $layout, $is_preview);
|
167 |
+
$acfe_flexible_render_style = apply_filters('acfe/flexible/render/style/key=' . $field['key'], $acfe_flexible_render_style, $field, $layout, $is_preview);
|
168 |
+
|
169 |
+
$acfe_flexible_render_style = apply_filters('acfe/flexible/layout/render/style/layout=' . $layout['name'], $acfe_flexible_render_style, $field, $layout, $is_preview);
|
170 |
+
$acfe_flexible_render_style = apply_filters('acfe/flexible/layout/render/style/name=' . $field['_name'] . '&layout=' . $layout['name'], $acfe_flexible_render_style, $field, $layout, $is_preview);
|
171 |
+
$acfe_flexible_render_style = apply_filters('acfe/flexible/layout/render/style/key=' . $field['key'] . '&layout=' . $layout['name'], $acfe_flexible_render_style, $field, $layout, $is_preview);
|
172 |
+
|
173 |
+
// Enqueue
|
174 |
+
if(!empty($acfe_flexible_render_style)){
|
175 |
+
|
176 |
+
$acfe_flexible_render_style_url = false;
|
177 |
+
|
178 |
+
// URL: https://www.domain.com/template/style.js
|
179 |
+
if(stripos($acfe_flexible_render_style, 'http://') === 0 || stripos($acfe_flexible_render_style, 'https://') === 0 || stripos($acfe_flexible_render_style, '//') === 0){
|
180 |
+
|
181 |
+
$acfe_flexible_render_style_url = $acfe_flexible_render_style;
|
182 |
+
|
183 |
+
}
|
184 |
+
|
185 |
+
// Path: template/style.css
|
186 |
+
else{
|
187 |
+
|
188 |
+
$acfe_flexible_render_style_url = acfe_locate_file_url(array($acfe_flexible_render_style));
|
189 |
+
|
190 |
+
}
|
191 |
+
|
192 |
+
// Include
|
193 |
+
if(!empty($acfe_flexible_render_style_url))
|
194 |
+
wp_enqueue_style($handle, $acfe_flexible_render_style_url, array(), false, 'all');
|
195 |
+
|
196 |
+
}
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Script
|
200 |
+
*/
|
201 |
+
$acfe_flexible_render_script = false;
|
202 |
+
|
203 |
+
// Filters
|
204 |
+
$acfe_flexible_render_script = apply_filters('acfe/flexible/render/script', $acfe_flexible_render_script, $field, $layout, $is_preview);
|
205 |
+
$acfe_flexible_render_script = apply_filters('acfe/flexible/render/script/name=' . $field['_name'], $acfe_flexible_render_script, $field, $layout, $is_preview);
|
206 |
+
$acfe_flexible_render_script = apply_filters('acfe/flexible/render/script/key=' . $field['key'], $acfe_flexible_render_script, $field, $layout, $is_preview);
|
207 |
+
|
208 |
+
$acfe_flexible_render_script = apply_filters('acfe/flexible/layout/render/script/layout=' . $layout['name'], $acfe_flexible_render_script, $field, $layout, $is_preview);
|
209 |
+
$acfe_flexible_render_script = apply_filters('acfe/flexible/layout/render/script/name=' . $field['_name'] . '&layout=' . $layout['name'], $acfe_flexible_render_script, $field, $layout, $is_preview);
|
210 |
+
$acfe_flexible_render_script = apply_filters('acfe/flexible/layout/render/script/key=' . $field['key'] . '&layout=' . $layout['name'], $acfe_flexible_render_script, $field, $layout, $is_preview);
|
211 |
+
|
212 |
+
// Enqueue
|
213 |
+
if(!empty($acfe_flexible_render_script)){
|
214 |
+
|
215 |
+
$acfe_flexible_render_script_url = false;
|
216 |
+
|
217 |
+
// URL: https://www.domain.com/template/script.js
|
218 |
+
if(stripos($acfe_flexible_render_script, 'http://') === 0 || stripos($acfe_flexible_render_script, 'https://') === 0 || stripos($acfe_flexible_render_script, '//') === 0){
|
219 |
+
|
220 |
+
$acfe_flexible_render_script_url = $acfe_flexible_render_script;
|
221 |
+
|
222 |
+
}
|
223 |
+
|
224 |
+
// Path: template/script.js
|
225 |
+
else{
|
226 |
+
|
227 |
+
$acfe_flexible_render_script_url = acfe_locate_file_url(array($acfe_flexible_render_script));
|
228 |
+
|
229 |
+
}
|
230 |
+
|
231 |
+
// Include
|
232 |
+
if(!empty($acfe_flexible_render_script_url))
|
233 |
+
wp_enqueue_script($handle, $acfe_flexible_render_script_url, array(), false, true);
|
234 |
+
|
235 |
+
}
|
236 |
+
|
237 |
+
}
|
238 |
+
|
239 |
+
/**
|
240 |
+
* Get Field Group from Field
|
241 |
+
*/
|
242 |
+
function acfe_get_field_group_from_field($field){
|
243 |
+
|
244 |
+
if(!acf_maybe_get($field, 'parent'))
|
245 |
+
return false;
|
246 |
+
|
247 |
+
$field_parent = $field['parent'];
|
248 |
+
|
249 |
+
if(!$field_ancestors = acf_get_field_ancestors($field))
|
250 |
+
return acf_get_field_group($field_parent);
|
251 |
+
|
252 |
+
// Reverse for DESC order (Top field first)
|
253 |
+
$field_ancestors = array_reverse($field_ancestors);
|
254 |
+
|
255 |
+
$field_top_ancestor = $field_ancestors[0];
|
256 |
+
$field_top_ancestor = acf_get_field($field_top_ancestor);
|
257 |
+
|
258 |
+
return acf_get_field_group($field_top_ancestor['parent']);
|
259 |
+
|
260 |
+
}
|
261 |
+
|
262 |
+
/**
|
263 |
+
* Add custom key to fields and all sub fields
|
264 |
+
*/
|
265 |
+
function acfe_field_add_key_recursive(&$field, $key, $value){
|
266 |
+
|
267 |
+
if(isset($field['sub_fields'])){
|
268 |
+
|
269 |
+
foreach($field['sub_fields'] as &$sub_field){
|
270 |
+
|
271 |
+
acfe_field_add_key_recursive($sub_field, $key, $value);
|
272 |
+
|
273 |
+
}
|
274 |
+
|
275 |
+
}
|
276 |
+
|
277 |
+
elseif(isset($field['layouts'])){
|
278 |
+
|
279 |
+
foreach($field['layouts'] as &$layout){
|
280 |
+
|
281 |
+
acfe_field_add_key_recursive($layout, $key, $value);
|
282 |
+
|
283 |
+
}
|
284 |
+
|
285 |
+
}
|
286 |
+
|
287 |
+
$field[$key] = $value;
|
288 |
+
|
289 |
+
}
|
290 |
+
|
291 |
+
/**
|
292 |
+
* Is Json
|
293 |
+
* Source: https://stackoverflow.com/a/6041773
|
294 |
+
*/
|
295 |
+
function acfe_is_json($string){
|
296 |
+
|
297 |
+
// in case string = 1
|
298 |
+
if(is_numeric($string))
|
299 |
+
return false;
|
300 |
+
|
301 |
+
json_decode($string);
|
302 |
+
|
303 |
+
return (json_last_error() == JSON_ERROR_NONE);
|
304 |
+
|
305 |
+
}
|
306 |
+
|
307 |
+
/**
|
308 |
+
* Array Keys Recursive
|
309 |
+
*/
|
310 |
+
function acfe_array_keys_r($array){
|
311 |
+
|
312 |
+
$keys = array_keys($array);
|
313 |
+
|
314 |
+
foreach($array as $i){
|
315 |
+
|
316 |
+
if(!is_array($i))
|
317 |
+
continue;
|
318 |
+
|
319 |
+
$keys = array_merge($keys, acfe_array_keys_r($i));
|
320 |
+
|
321 |
+
}
|
322 |
+
|
323 |
+
return $keys;
|
324 |
+
|
325 |
+
}
|
326 |
+
|
327 |
+
/**
|
328 |
+
* Locate File URL
|
329 |
+
* Check if file exists locally and return URL (supports parent/child theme)
|
330 |
+
*/
|
331 |
+
function acfe_locate_file_url($filenames){
|
332 |
+
|
333 |
+
$located = '';
|
334 |
+
|
335 |
+
foreach((array) $filenames as $filename){
|
336 |
+
|
337 |
+
if(!$filename)
|
338 |
+
continue;
|
339 |
+
|
340 |
+
// Child
|
341 |
+
if(file_exists(STYLESHEETPATH . '/' . $filename)){
|
342 |
+
|
343 |
+
$located = get_stylesheet_directory_uri() . '/' . $filename;
|
344 |
+
break;
|
345 |
+
|
346 |
+
}
|
347 |
+
|
348 |
+
// Parent
|
349 |
+
elseif(file_exists(TEMPLATEPATH . '/' . $filename)){
|
350 |
+
|
351 |
+
$located = get_template_directory_uri() . '/' . $filename;
|
352 |
+
break;
|
353 |
+
|
354 |
+
}
|
355 |
+
|
356 |
+
}
|
357 |
+
|
358 |
+
return $located;
|
359 |
+
|
360 |
+
}
|
361 |
+
|
362 |
+
/**
|
363 |
+
* Get Roles
|
364 |
+
*/
|
365 |
+
function acfe_get_roles($user_roles = array()){
|
366 |
+
|
367 |
+
if(empty($user_roles)){
|
368 |
+
|
369 |
+
$user_roles = array();
|
370 |
+
|
371 |
+
global $wp_roles;
|
372 |
+
|
373 |
+
if(is_multisite())
|
374 |
+
$user_roles['super_admin'] = __('Super Admin');
|
375 |
+
|
376 |
+
foreach($wp_roles->roles as $role => $settings){
|
377 |
+
|
378 |
+
$user_roles[$role] = $settings['name'];
|
379 |
+
|
380 |
+
}
|
381 |
+
|
382 |
+
}
|
383 |
+
|
384 |
+
return $user_roles;
|
385 |
+
|
386 |
+
}
|
387 |
+
|
388 |
+
/**
|
389 |
+
* Get Current Roles
|
390 |
+
*/
|
391 |
+
function acfe_get_current_user_roles(){
|
392 |
+
|
393 |
+
global $current_user;
|
394 |
+
|
395 |
+
if(!is_object($current_user) || !isset($current_user->roles))
|
396 |
+
return false;
|
397 |
+
|
398 |
+
$roles = $current_user->roles;
|
399 |
+
|
400 |
+
if(is_multisite() && current_user_can('setup_network'))
|
401 |
+
$roles[] = 'super_admin';
|
402 |
+
|
403 |
+
return $roles;
|
404 |
+
|
405 |
+
}
|
406 |
+
|
407 |
+
/**
|
408 |
+
* Get post types objects
|
409 |
+
*/
|
410 |
+
function acfe_get_post_type_objects($args = array()){
|
411 |
+
|
412 |
+
// vars
|
413 |
+
$return = array();
|
414 |
+
|
415 |
+
// Post Types
|
416 |
+
$posts_types = acf_get_post_types($args);
|
417 |
+
|
418 |
+
// Choices
|
419 |
+
if(!empty($posts_types)){
|
420 |
+
|
421 |
+
foreach($posts_types as $post_type){
|
422 |
+
|
423 |
+
$post_type_object = get_post_type_object($post_type);
|
424 |
+
|
425 |
+
$return[$post_type_object->name] = $post_type_object;
|
426 |
+
|
427 |
+
}
|
428 |
+
|
429 |
+
}
|
430 |
+
|
431 |
+
return $return;
|
432 |
+
|
433 |
+
}
|
434 |
+
|
435 |
+
/**
|
436 |
+
* Get taxonomy objects
|
437 |
+
*/
|
438 |
+
function acfe_get_taxonomy_objects($args = array()){
|
439 |
+
|
440 |
+
// vars
|
441 |
+
$return = array();
|
442 |
+
|
443 |
+
// Post Types
|
444 |
+
$taxonomies = acf_get_taxonomies($args);
|
445 |
+
|
446 |
+
// Choices
|
447 |
+
if(!empty($taxonomies)){
|
448 |
+
|
449 |
+
foreach($taxonomies as $taxonomy){
|
450 |
+
|
451 |
+
$taxonomy_object = get_taxonomy($taxonomy);
|
452 |
+
|
453 |
+
$return[$taxonomy_object->name] = $taxonomy_object;
|
454 |
+
|
455 |
+
}
|
456 |
+
|
457 |
+
}
|
458 |
+
|
459 |
+
return $return;
|
460 |
+
|
461 |
+
}
|
462 |
+
|
463 |
+
/**
|
464 |
+
* Get post statuses
|
465 |
+
*/
|
466 |
+
function acfe_get_pretty_post_statuses($posts_statuses = array()){
|
467 |
+
|
468 |
+
if(empty($posts_statuses)){
|
469 |
+
|
470 |
+
$posts_statuses = get_post_stati(array(), 'names');
|
471 |
+
|
472 |
+
}
|
473 |
+
|
474 |
+
$return = array();
|
475 |
+
|
476 |
+
// Choices
|
477 |
+
if(!empty($posts_statuses)){
|
478 |
+
|
479 |
+
foreach($posts_statuses as $post_status){
|
480 |
+
|
481 |
+
$post_status_object = get_post_status_object($post_status);
|
482 |
+
|
483 |
+
$return[$post_status_object->name] = $post_status_object->label . ' (' . $post_status_object->name . ')';
|
484 |
+
|
485 |
+
}
|
486 |
+
|
487 |
+
}
|
488 |
+
|
489 |
+
return $return;
|
490 |
+
|
491 |
+
}
|
492 |
+
|
493 |
+
/**
|
494 |
+
* Get forms
|
495 |
+
*/
|
496 |
+
function acfe_get_pretty_forms($forms = array()){
|
497 |
+
|
498 |
+
if(empty($forms)){
|
499 |
+
|
500 |
+
$forms = get_posts(array(
|
501 |
+
'post_type' => 'acfe-form',
|
502 |
+
'posts_per_page' => -1,
|
503 |
+
'fields' => 'ids',
|
504 |
+
));
|
505 |
+
|
506 |
+
}
|
507 |
+
|
508 |
+
$return = array();
|
509 |
+
|
510 |
+
// Choices
|
511 |
+
if(!empty($forms)){
|
512 |
+
|
513 |
+
foreach($forms as $form_id){
|
514 |
+
|
515 |
+
$form_name = get_the_title($form_id);
|
516 |
+
|
517 |
+
$return[$form_id] = $form_name;
|
518 |
+
|
519 |
+
}
|
520 |
+
|
521 |
+
}
|
522 |
+
|
523 |
+
return $return;
|
524 |
+
|
525 |
+
}
|
526 |
+
|
527 |
+
/**
|
528 |
+
* Starts with
|
529 |
+
*/
|
530 |
+
function acfe_starts_with($haystack, $needle){
|
531 |
+
|
532 |
+
$length = strlen($needle);
|
533 |
+
return (substr($haystack, 0, $length) === $needle);
|
534 |
+
|
535 |
+
}
|
536 |
+
|
537 |
+
/**
|
538 |
+
* Ends with
|
539 |
+
*/
|
540 |
+
function acfe_ends_with($haystack, $needle){
|
541 |
+
|
542 |
+
$length = strlen($needle);
|
543 |
+
|
544 |
+
if($length == 0)
|
545 |
+
return true;
|
546 |
+
|
547 |
+
return (substr($haystack, -$length) === $needle);
|
548 |
+
|
549 |
+
}
|
550 |
+
|
551 |
+
add_filter('acf/load_field', 'acfe_load_field');
|
552 |
+
function acfe_load_field($field){
|
553 |
+
|
554 |
+
if(acf_is_screen(array('edit-acf-field-group', 'acf-field-group', 'acf_page_acf-tools')))
|
555 |
+
return $field;
|
556 |
+
|
557 |
+
// Everywhere
|
558 |
+
$field = apply_filters('acfe/load_field', $field);
|
559 |
+
|
560 |
+
// Admin
|
561 |
+
if(acfe_form_is_admin()){
|
562 |
+
|
563 |
+
$field = apply_filters('acfe/load_field_admin', $field);
|
564 |
+
|
565 |
+
}
|
566 |
+
|
567 |
+
// Front
|
568 |
+
elseif(acfe_form_is_front()){
|
569 |
+
|
570 |
+
$field = apply_filters('acfe/load_field_front', $field);
|
571 |
+
|
572 |
+
}
|
573 |
+
|
574 |
+
return $field;
|
575 |
+
|
576 |
+
}
|
577 |
+
|
578 |
+
if(function_exists('acf_add_filter_variations')){
|
579 |
+
|
580 |
+
acf_add_filter_variations('acfe/load_field', array('type', 'name', 'key'), 0);
|
581 |
+
acf_add_filter_variations('acfe/load_field_front', array('type', 'name', 'key'), 0);
|
582 |
+
acf_add_filter_variations('acfe/load_field_admin', array('type', 'name', 'key'), 0);
|
583 |
+
|
584 |
+
}
|
585 |
+
|
586 |
+
function acfe_form_is_admin(){
|
587 |
+
|
588 |
+
if((is_admin() && !wp_doing_ajax()) || (is_admin() && wp_doing_ajax() && acf_maybe_get_POST('_acf_screen') !== 'acfe_form' && acf_maybe_get_POST('_acf_screen') !== 'acf_form'))
|
589 |
+
return true;
|
590 |
+
|
591 |
+
return false;
|
592 |
+
|
593 |
+
}
|
594 |
+
|
595 |
+
function acfe_form_is_front(){
|
596 |
+
|
597 |
+
if(!is_admin() || (is_admin() && wp_doing_ajax() && (acf_maybe_get_POST('_acf_screen') === 'acfe_form' || acf_maybe_get_POST('_acf_screen') === 'acf_form')))
|
598 |
+
return true;
|
599 |
+
|
600 |
+
return false;
|
601 |
+
|
602 |
+
}
|
603 |
+
|
604 |
+
function acfe_form_decrypt_args(){
|
605 |
+
|
606 |
+
if(!acf_maybe_get_POST('_acf_form'))
|
607 |
+
return false;
|
608 |
+
|
609 |
+
$form = json_decode(acf_decrypt($_POST['_acf_form']), true);
|
610 |
+
|
611 |
+
if(empty($form))
|
612 |
+
return false;
|
613 |
+
|
614 |
+
return $form;
|
615 |
+
|
616 |
+
}
|
617 |
+
|
618 |
+
function acfe_array_insert_before($key, array &$array, $new_key, $new_value){
|
619 |
+
|
620 |
+
if(!array_key_exists($key, $array))
|
621 |
+
return $array;
|
622 |
+
|
623 |
+
$new = array();
|
624 |
+
|
625 |
+
foreach($array as $k => $value){
|
626 |
+
|
627 |
+
if($k === $key)
|
628 |
+
$new[$new_key] = $new_value;
|
629 |
+
|
630 |
+
$new[$k] = $value;
|
631 |
+
|
632 |
+
}
|
633 |
+
|
634 |
+
return $new;
|
635 |
+
|
636 |
+
}
|
637 |
+
|
638 |
+
function acfe_array_insert_after($key, array &$array, $new_key, $new_value){
|
639 |
+
|
640 |
+
if(!array_key_exists($key, $array))
|
641 |
+
return $array;
|
642 |
+
|
643 |
+
$new = array();
|
644 |
+
|
645 |
+
foreach($array as $k => $value){
|
646 |
+
|
647 |
+
$new[$k] = $value;
|
648 |
+
|
649 |
+
if($k === $key)
|
650 |
+
$new[$new_key] = $new_value;
|
651 |
+
|
652 |
+
}
|
653 |
+
|
654 |
+
return $new;
|
655 |
+
|
656 |
+
}
|
657 |
+
|
658 |
+
function acfe_add_validation_error($selector = '', $message = ''){
|
659 |
+
|
660 |
+
// General error
|
661 |
+
if(empty($selector))
|
662 |
+
return acf_add_validation_error('', $message);
|
663 |
+
|
664 |
+
$row = acf_get_loop('active');
|
665 |
+
|
666 |
+
if($row){
|
667 |
+
|
668 |
+
$field = acf_get_sub_field($selector, $row['field']);
|
669 |
+
|
670 |
+
}
|
671 |
+
|
672 |
+
else{
|
673 |
+
|
674 |
+
$field = acf_get_field($selector);
|
675 |
+
|
676 |
+
}
|
677 |
+
|
678 |
+
|
679 |
+
|
680 |
+
// Field not found: General error
|
681 |
+
if(!$field)
|
682 |
+
return acf_add_validation_error('', $message);
|
683 |
+
|
684 |
+
// Specific field error
|
685 |
+
add_filter('acf/validate_value/key=' . $field['key'], function($valid) use($message){
|
686 |
+
|
687 |
+
return $message;
|
688 |
+
|
689 |
+
});
|
690 |
+
|
691 |
+
}
|
692 |
+
|
693 |
+
/*
|
694 |
+
* Similar to acf_get_taxonomy_terms() but returns array('256' => 'Category name') instead of array('category:category_name' => 'Category name')
|
695 |
+
*/
|
696 |
+
function acfe_get_taxonomy_terms_ids($taxonomies = array()){
|
697 |
+
|
698 |
+
// force array
|
699 |
+
$taxonomies = acf_get_array($taxonomies);
|
700 |
+
|
701 |
+
// get pretty taxonomy names
|
702 |
+
$taxonomies = acf_get_pretty_taxonomies( $taxonomies );
|
703 |
+
|
704 |
+
// vars
|
705 |
+
$r = array();
|
706 |
+
|
707 |
+
// populate $r
|
708 |
+
foreach( array_keys($taxonomies) as $taxonomy ) {
|
709 |
+
|
710 |
+
// vars
|
711 |
+
$label = $taxonomies[ $taxonomy ];
|
712 |
+
$is_hierarchical = is_taxonomy_hierarchical( $taxonomy );
|
713 |
+
$terms = acf_get_terms(array(
|
714 |
+
'taxonomy' => $taxonomy,
|
715 |
+
'hide_empty' => false
|
716 |
+
));
|
717 |
+
|
718 |
+
|
719 |
+
// bail early i no terms
|
720 |
+
if( empty($terms) ) continue;
|
721 |
+
|
722 |
+
|
723 |
+
// sort into hierachial order!
|
724 |
+
if( $is_hierarchical ) {
|
725 |
+
|
726 |
+
$terms = _get_term_children( 0, $terms, $taxonomy );
|
727 |
+
|
728 |
+
}
|
729 |
+
|
730 |
+
|
731 |
+
// add placeholder
|
732 |
+
$r[ $label ] = array();
|
733 |
+
|
734 |
+
|
735 |
+
// add choices
|
736 |
+
foreach( $terms as $term ) {
|
737 |
+
|
738 |
+
$k = "{$term->term_id}";
|
739 |
+
$r[ $label ][ $k ] = acf_get_term_title( $term );
|
740 |
+
|
741 |
+
}
|
742 |
+
|
743 |
+
}
|
744 |
+
|
745 |
+
|
746 |
+
// return
|
747 |
+
return $r;
|
748 |
+
|
749 |
+
}
|
750 |
+
|
751 |
+
function acfe_get_term_level($term, $taxonomy){
|
752 |
+
|
753 |
+
$ancestors = get_ancestors($term, $taxonomy);
|
754 |
+
|
755 |
+
return count($ancestors) + 1;
|
756 |
+
|
757 |
+
}
|
758 |
+
|
759 |
+
function acfe_number_suffix($num){
|
760 |
+
|
761 |
+
if(!in_array(($num % 100), array(11,12,13))){
|
762 |
+
|
763 |
+
switch($num % 10){
|
764 |
+
case 1: return $num . 'st';
|
765 |
+
case 2: return $num . 'nd';
|
766 |
+
case 3: return $num . 'rd';
|
767 |
+
}
|
768 |
+
|
769 |
+
}
|
770 |
+
|
771 |
+
return $num . 'th';
|
772 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
773 |
}
|
includes/field-groups/field-group.php
CHANGED
@@ -1,588 +1,662 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
add_action('acf/update_field_group', 'acfe_field_group_update', 0);
|
7 |
-
function acfe_field_group_update($field_group){
|
8 |
-
|
9 |
-
// Get Fields
|
10 |
-
$fields = acf_get_fields($field_group);
|
11 |
-
if(empty($fields))
|
12 |
-
return;
|
13 |
-
|
14 |
-
// Add acfe_form
|
15 |
-
if(acf_maybe_get($field_group, 'acfe_form')){
|
16 |
-
|
17 |
-
// Update Fields
|
18 |
-
acfe_field_group_fields_add_fields_form($fields);
|
19 |
-
|
20 |
-
}
|
21 |
-
|
22 |
-
// Remove acfe_form
|
23 |
-
else{
|
24 |
-
|
25 |
-
// Update Fields
|
26 |
-
acfe_field_group_fields_add_fields_form($fields, false);
|
27 |
-
|
28 |
-
}
|
29 |
-
|
30 |
-
}
|
31 |
-
|
32 |
-
function acfe_field_group_fields_add_fields_form($fields, $add = true){
|
33 |
-
|
34 |
-
if(empty($fields))
|
35 |
-
return;
|
36 |
-
|
37 |
-
foreach($fields as $field){
|
38 |
-
|
39 |
-
// bypass clone
|
40 |
-
if($field['type'] === 'clone')
|
41 |
-
continue;
|
42 |
-
|
43 |
-
// Group / Clone
|
44 |
-
if(isset($field['sub_fields']) && !empty($field['sub_fields'])){
|
45 |
-
|
46 |
-
acfe_field_group_fields_add_fields_form($field['sub_fields'], $add);
|
47 |
-
|
48 |
-
}
|
49 |
-
|
50 |
-
// Flexible Content
|
51 |
-
elseif(isset($field['layouts']) && !empty($field['layouts'])){
|
52 |
-
|
53 |
-
foreach($field['layouts'] as $layout){
|
54 |
-
|
55 |
-
if(isset($layout['sub_fields']) && !empty($layout['sub_fields'])){
|
56 |
-
|
57 |
-
acfe_field_group_fields_add_fields_form($layout['sub_fields'], $add);
|
58 |
-
|
59 |
-
}
|
60 |
-
}
|
61 |
-
|
62 |
-
}
|
63 |
-
|
64 |
-
// Add
|
65 |
-
if($add){
|
66 |
-
|
67 |
-
if(acf_maybe_get($field, 'acfe_form'))
|
68 |
-
continue;
|
69 |
-
|
70 |
-
$field['acfe_form'] = true;
|
71 |
-
|
72 |
-
}
|
73 |
-
|
74 |
-
// Remove
|
75 |
-
else{
|
76 |
-
|
77 |
-
if(!acf_maybe_get($field, 'acfe_form'))
|
78 |
-
continue;
|
79 |
-
|
80 |
-
unset($field['acfe_form']);
|
81 |
-
|
82 |
-
if(isset($field['acfe_settings']))
|
83 |
-
unset($field['acfe_settings']);
|
84 |
-
|
85 |
-
if(isset($field['acfe_validate']))
|
86 |
-
unset($field['acfe_validate']);
|
87 |
-
|
88 |
-
}
|
89 |
-
|
90 |
-
acf_update_field($field);
|
91 |
-
|
92 |
-
}
|
93 |
-
|
94 |
-
}
|
95 |
-
|
96 |
-
add_filter('acf/prepare_field/name=acfe_meta', 'acfe_field_group_meta_fix_repeater');
|
97 |
-
add_filter('acf/prepare_field/name=acfe_meta_key', 'acfe_field_group_meta_fix_repeater');
|
98 |
-
add_filter('acf/prepare_field/name=acfe_meta_value', 'acfe_field_group_meta_fix_repeater');
|
99 |
-
function acfe_field_group_meta_fix_repeater($field){
|
100 |
-
|
101 |
-
$field['prefix'] = str_replace('row-', '', $field['prefix']);
|
102 |
-
$field['name'] = str_replace('row-', '', $field['name']);
|
103 |
-
|
104 |
-
return $field;
|
105 |
-
|
106 |
-
}
|
107 |
-
|
108 |
-
/**
|
109 |
-
* Field Group Options: Data
|
110 |
-
*/
|
111 |
-
add_action('acf/field_group/admin_head', 'acfe_render_field_group_settings');
|
112 |
-
function acfe_render_field_group_settings(){
|
113 |
-
|
114 |
-
add_meta_box('acf-field-group-acfe', __('Field group', 'acf'), function(){
|
115 |
-
|
116 |
-
global $field_group;
|
117 |
-
|
118 |
-
// Form settings
|
119 |
-
acf_render_field_wrap(array(
|
120 |
-
'label' => __('Advanced settings'),
|
121 |
-
'name' => 'acfe_form',
|
122 |
-
'prefix' => 'acf_field_group',
|
123 |
-
'type' => 'true_false',
|
124 |
-
'ui' => 1,
|
125 |
-
'instructions' => __('Enable advanced fields settings & validation'),
|
126 |
-
'value' => (isset($field_group['acfe_form'])) ? $field_group['acfe_form'] : '',
|
127 |
-
'required' => false,
|
128 |
-
));
|
129 |
-
|
130 |
-
// Meta
|
131 |
-
acf_render_field_wrap(array(
|
132 |
-
'label' => __('Custom meta data'),
|
133 |
-
'name' => 'acfe_meta',
|
134 |
-
'key' => 'acfe_meta',
|
135 |
-
'instructions' => __('Add custom meta data to the field group. Can be retrived using <code>acf_get_field_group()</code>'),
|
136 |
-
'prefix' => 'acf_field_group',
|
137 |
-
'type' => 'repeater',
|
138 |
-
'button_label' => __('+ Meta'),
|
139 |
-
'required' => false,
|
140 |
-
'layout' => 'table',
|
141 |
-
'value' => (isset($field_group['acfe_meta'])) ? $field_group['acfe_meta'] : array(),
|
142 |
-
'sub_fields' => array(
|
143 |
-
array(
|
144 |
-
'label' => __('Key'),
|
145 |
-
'name' => 'acfe_meta_key',
|
146 |
-
'key' => 'acfe_meta_key',
|
147 |
-
'prefix' => '',
|
148 |
-
'_name' => '',
|
149 |
-
'_prepare' => '',
|
150 |
-
'type' => 'text',
|
151 |
-
'instructions' => false,
|
152 |
-
'required' => false,
|
153 |
-
'wrapper' => array(
|
154 |
-
'width' => '',
|
155 |
-
'class' => '',
|
156 |
-
'id' => '',
|
157 |
-
),
|
158 |
-
),
|
159 |
-
array(
|
160 |
-
'label' => __('Value'),
|
161 |
-
'name' => 'acfe_meta_value',
|
162 |
-
'key' => 'acfe_meta_value',
|
163 |
-
'prefix' => '',
|
164 |
-
'_name' => '',
|
165 |
-
'_prepare' => '',
|
166 |
-
'type' => 'text',
|
167 |
-
'instructions' => false,
|
168 |
-
'required' => false,
|
169 |
-
'wrapper' => array(
|
170 |
-
'width' => '',
|
171 |
-
'class' => '',
|
172 |
-
'id' => '',
|
173 |
-
),
|
174 |
-
),
|
175 |
-
)
|
176 |
-
));
|
177 |
-
|
178 |
-
// Data
|
179 |
-
|
180 |
-
acf_render_field_wrap(array(
|
181 |
-
'label' => __('Field group data'),
|
182 |
-
'instructions' => __('View raw field group data, for development use'),
|
183 |
-
'type' => 'acfe_dynamic_message',
|
184 |
-
'name' => 'acfe_data',
|
185 |
-
'prefix' => 'acf_field_group',
|
186 |
-
'value' => $field_group['key'],
|
187 |
-
));
|
188 |
-
|
189 |
-
// Note
|
190 |
-
acf_render_field_wrap(array(
|
191 |
-
'label' => __('Note'),
|
192 |
-
'name' => 'acfe_note',
|
193 |
-
'prefix' => 'acf_field_group',
|
194 |
-
'type' => 'textarea',
|
195 |
-
'instructions' => __('Add personal note. Only visible to administrators'),
|
196 |
-
'value' => (isset($field_group['acfe_note'])) ? $field_group['acfe_note'] : '',
|
197 |
-
'required' => false,
|
198 |
-
));
|
199 |
-
|
200 |
-
?>
|
201 |
-
<script type="text/javascript">
|
202 |
-
if(typeof acf !== 'undefined'){
|
203 |
-
acf.postbox.render({
|
204 |
-
'id': 'acf-field-group-acfe',
|
205 |
-
'label': 'left'
|
206 |
-
});
|
207 |
-
}
|
208 |
-
|
209 |
-
jQuery(document).ready(function($){
|
210 |
-
$('#post_name').on('keyup', function(){
|
211 |
-
var val = $(this).val();
|
212 |
-
if(!val.startsWith('group_')){
|
213 |
-
var val = 'group_' + val;
|
214 |
-
$(this).val(val);
|
215 |
-
}
|
216 |
-
|
217 |
-
$('[name="acf_field_group[key]"]').val(val);
|
218 |
-
$('.misc-pub-acfe-field-group-key code').html(val);
|
219 |
-
});
|
220 |
-
});
|
221 |
-
</script>
|
222 |
-
<?php
|
223 |
-
}, 'acf-field-group', 'normal');
|
224 |
-
|
225 |
-
}
|
226 |
-
|
227 |
-
/**
|
228 |
-
* Field Group Options: Sidebar - Submit Div
|
229 |
-
*/
|
230 |
-
add_action('post_submitbox_misc_actions', 'acfe_render_field_group_submitbox');
|
231 |
-
function acfe_render_field_group_submitbox(){
|
232 |
-
|
233 |
-
if(
|
234 |
-
return;
|
235 |
-
|
236 |
-
$field_group
|
237 |
-
?>
|
238 |
-
<div class="misc-pub-section misc-pub-acfe-field-group-key">
|
239 |
-
<span style="font-size:16px;color: #82878c;" class="dashicons dashicons-tag"></span> <code style="font-size: 12px;"><?php echo $field_group['key']; ?></code>
|
240 |
-
</div>
|
241 |
-
<
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
}
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
'
|
270 |
-
'
|
271 |
-
'
|
272 |
-
'
|
273 |
-
'
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
'
|
283 |
-
'
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
'
|
329 |
-
'
|
330 |
-
'
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
'
|
342 |
-
'
|
343 |
-
'
|
344 |
-
'
|
345 |
-
'
|
346 |
-
'
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
$('#acf_field_group-acfe_autosync-json').
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
$('#acf_field_group-acfe_autosync-php').
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
$
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
echo '<p class="description"><span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="dashicons dashicons-warning"></span>
|
448 |
-
}
|
449 |
-
|
450 |
-
elseif(acfe_has_field_group_autosync($field_group, 'php') &&
|
451 |
-
echo '<p class="description"><span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="dashicons dashicons-warning"></span>
|
452 |
-
}
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
}
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
break;
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
}
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
588 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
add_action('acf/update_field_group', 'acfe_field_group_update', 0);
|
7 |
+
function acfe_field_group_update($field_group){
|
8 |
+
|
9 |
+
// Get Fields
|
10 |
+
$fields = acf_get_fields($field_group);
|
11 |
+
if(empty($fields))
|
12 |
+
return;
|
13 |
+
|
14 |
+
// Add acfe_form
|
15 |
+
if(acf_maybe_get($field_group, 'acfe_form')){
|
16 |
+
|
17 |
+
// Update Fields
|
18 |
+
acfe_field_group_fields_add_fields_form($fields);
|
19 |
+
|
20 |
+
}
|
21 |
+
|
22 |
+
// Remove acfe_form
|
23 |
+
else{
|
24 |
+
|
25 |
+
// Update Fields
|
26 |
+
acfe_field_group_fields_add_fields_form($fields, false);
|
27 |
+
|
28 |
+
}
|
29 |
+
|
30 |
+
}
|
31 |
+
|
32 |
+
function acfe_field_group_fields_add_fields_form($fields, $add = true){
|
33 |
+
|
34 |
+
if(empty($fields))
|
35 |
+
return;
|
36 |
+
|
37 |
+
foreach($fields as $field){
|
38 |
+
|
39 |
+
// bypass clone
|
40 |
+
if($field['type'] === 'clone')
|
41 |
+
continue;
|
42 |
+
|
43 |
+
// Group / Clone
|
44 |
+
if(isset($field['sub_fields']) && !empty($field['sub_fields'])){
|
45 |
+
|
46 |
+
acfe_field_group_fields_add_fields_form($field['sub_fields'], $add);
|
47 |
+
|
48 |
+
}
|
49 |
+
|
50 |
+
// Flexible Content
|
51 |
+
elseif(isset($field['layouts']) && !empty($field['layouts'])){
|
52 |
+
|
53 |
+
foreach($field['layouts'] as $layout){
|
54 |
+
|
55 |
+
if(isset($layout['sub_fields']) && !empty($layout['sub_fields'])){
|
56 |
+
|
57 |
+
acfe_field_group_fields_add_fields_form($layout['sub_fields'], $add);
|
58 |
+
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
}
|
63 |
+
|
64 |
+
// Add
|
65 |
+
if($add){
|
66 |
+
|
67 |
+
if(acf_maybe_get($field, 'acfe_form'))
|
68 |
+
continue;
|
69 |
+
|
70 |
+
$field['acfe_form'] = true;
|
71 |
+
|
72 |
+
}
|
73 |
+
|
74 |
+
// Remove
|
75 |
+
else{
|
76 |
+
|
77 |
+
if(!acf_maybe_get($field, 'acfe_form'))
|
78 |
+
continue;
|
79 |
+
|
80 |
+
unset($field['acfe_form']);
|
81 |
+
|
82 |
+
if(isset($field['acfe_settings']))
|
83 |
+
unset($field['acfe_settings']);
|
84 |
+
|
85 |
+
if(isset($field['acfe_validate']))
|
86 |
+
unset($field['acfe_validate']);
|
87 |
+
|
88 |
+
}
|
89 |
+
|
90 |
+
acf_update_field($field);
|
91 |
+
|
92 |
+
}
|
93 |
+
|
94 |
+
}
|
95 |
+
|
96 |
+
add_filter('acf/prepare_field/name=acfe_meta', 'acfe_field_group_meta_fix_repeater');
|
97 |
+
add_filter('acf/prepare_field/name=acfe_meta_key', 'acfe_field_group_meta_fix_repeater');
|
98 |
+
add_filter('acf/prepare_field/name=acfe_meta_value', 'acfe_field_group_meta_fix_repeater');
|
99 |
+
function acfe_field_group_meta_fix_repeater($field){
|
100 |
+
|
101 |
+
$field['prefix'] = str_replace('row-', '', $field['prefix']);
|
102 |
+
$field['name'] = str_replace('row-', '', $field['name']);
|
103 |
+
|
104 |
+
return $field;
|
105 |
+
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Field Group Options: Data
|
110 |
+
*/
|
111 |
+
add_action('acf/field_group/admin_head', 'acfe_render_field_group_settings');
|
112 |
+
function acfe_render_field_group_settings(){
|
113 |
+
|
114 |
+
add_meta_box('acf-field-group-acfe', __('Field group', 'acf'), function(){
|
115 |
+
|
116 |
+
global $field_group;
|
117 |
+
|
118 |
+
// Form settings
|
119 |
+
acf_render_field_wrap(array(
|
120 |
+
'label' => __('Advanced settings'),
|
121 |
+
'name' => 'acfe_form',
|
122 |
+
'prefix' => 'acf_field_group',
|
123 |
+
'type' => 'true_false',
|
124 |
+
'ui' => 1,
|
125 |
+
'instructions' => __('Enable advanced fields settings & validation'),
|
126 |
+
'value' => (isset($field_group['acfe_form'])) ? $field_group['acfe_form'] : '',
|
127 |
+
'required' => false,
|
128 |
+
));
|
129 |
+
|
130 |
+
// Meta
|
131 |
+
acf_render_field_wrap(array(
|
132 |
+
'label' => __('Custom meta data'),
|
133 |
+
'name' => 'acfe_meta',
|
134 |
+
'key' => 'acfe_meta',
|
135 |
+
'instructions' => __('Add custom meta data to the field group. Can be retrived using <code>acf_get_field_group()</code>'),
|
136 |
+
'prefix' => 'acf_field_group',
|
137 |
+
'type' => 'repeater',
|
138 |
+
'button_label' => __('+ Meta'),
|
139 |
+
'required' => false,
|
140 |
+
'layout' => 'table',
|
141 |
+
'value' => (isset($field_group['acfe_meta'])) ? $field_group['acfe_meta'] : array(),
|
142 |
+
'sub_fields' => array(
|
143 |
+
array(
|
144 |
+
'label' => __('Key'),
|
145 |
+
'name' => 'acfe_meta_key',
|
146 |
+
'key' => 'acfe_meta_key',
|
147 |
+
'prefix' => '',
|
148 |
+
'_name' => '',
|
149 |
+
'_prepare' => '',
|
150 |
+
'type' => 'text',
|
151 |
+
'instructions' => false,
|
152 |
+
'required' => false,
|
153 |
+
'wrapper' => array(
|
154 |
+
'width' => '',
|
155 |
+
'class' => '',
|
156 |
+
'id' => '',
|
157 |
+
),
|
158 |
+
),
|
159 |
+
array(
|
160 |
+
'label' => __('Value'),
|
161 |
+
'name' => 'acfe_meta_value',
|
162 |
+
'key' => 'acfe_meta_value',
|
163 |
+
'prefix' => '',
|
164 |
+
'_name' => '',
|
165 |
+
'_prepare' => '',
|
166 |
+
'type' => 'text',
|
167 |
+
'instructions' => false,
|
168 |
+
'required' => false,
|
169 |
+
'wrapper' => array(
|
170 |
+
'width' => '',
|
171 |
+
'class' => '',
|
172 |
+
'id' => '',
|
173 |
+
),
|
174 |
+
),
|
175 |
+
)
|
176 |
+
));
|
177 |
+
|
178 |
+
// Data
|
179 |
+
|
180 |
+
acf_render_field_wrap(array(
|
181 |
+
'label' => __('Field group data'),
|
182 |
+
'instructions' => __('View raw field group data, for development use'),
|
183 |
+
'type' => 'acfe_dynamic_message',
|
184 |
+
'name' => 'acfe_data',
|
185 |
+
'prefix' => 'acf_field_group',
|
186 |
+
'value' => $field_group['key'],
|
187 |
+
));
|
188 |
+
|
189 |
+
// Note
|
190 |
+
acf_render_field_wrap(array(
|
191 |
+
'label' => __('Note'),
|
192 |
+
'name' => 'acfe_note',
|
193 |
+
'prefix' => 'acf_field_group',
|
194 |
+
'type' => 'textarea',
|
195 |
+
'instructions' => __('Add personal note. Only visible to administrators'),
|
196 |
+
'value' => (isset($field_group['acfe_note'])) ? $field_group['acfe_note'] : '',
|
197 |
+
'required' => false,
|
198 |
+
));
|
199 |
+
|
200 |
+
?>
|
201 |
+
<script type="text/javascript">
|
202 |
+
if(typeof acf !== 'undefined'){
|
203 |
+
acf.postbox.render({
|
204 |
+
'id': 'acf-field-group-acfe',
|
205 |
+
'label': 'left'
|
206 |
+
});
|
207 |
+
}
|
208 |
+
|
209 |
+
jQuery(document).ready(function($){
|
210 |
+
$('#post_name').on('keyup', function(){
|
211 |
+
var val = $(this).val();
|
212 |
+
if(!val.startsWith('group_')){
|
213 |
+
var val = 'group_' + val;
|
214 |
+
$(this).val(val);
|
215 |
+
}
|
216 |
+
|
217 |
+
$('[name="acf_field_group[key]"]').val(val);
|
218 |
+
$('.misc-pub-acfe-field-group-key code').html(val);
|
219 |
+
});
|
220 |
+
});
|
221 |
+
</script>
|
222 |
+
<?php
|
223 |
+
}, 'acf-field-group', 'normal');
|
224 |
+
|
225 |
+
}
|
226 |
+
|
227 |
+
/**
|
228 |
+
* Field Group Options: Sidebar - Submit Div
|
229 |
+
*/
|
230 |
+
add_action('post_submitbox_misc_actions', 'acfe_render_field_group_submitbox', 11);
|
231 |
+
function acfe_render_field_group_submitbox($post){
|
232 |
+
|
233 |
+
if($post->post_type !== 'acf-field-group')
|
234 |
+
return;
|
235 |
+
|
236 |
+
global $field_group;
|
237 |
+
?>
|
238 |
+
<div class="misc-pub-section misc-pub-acfe-field-group-key" style="padding-top:2px;">
|
239 |
+
<span style="font-size:16px;color: #82878c;width: 20px;margin-right: 2px;" class="dashicons dashicons-tag"></span> <code style="font-size: 12px;"><?php echo $field_group['key']; ?></code>
|
240 |
+
</div>
|
241 |
+
<div class="misc-pub-section misc-pub-acfe-field-group-export" style="padding-top:2px;">
|
242 |
+
<span style="font-size:17px;color: #82878c;line-height: 1.3;width: 20px;margin-right: 2px;" class="dashicons dashicons-editor-code"></span> Export: <a href="<?php echo admin_url('edit.php?post_type=acf-field-group&page=acf-tools&tool=export&action=php&keys=' . $field_group['key']); ?>">PHP</a> <a href="<?php echo admin_url('edit.php?post_type=acf-field-group&page=acf-tools&tool=export&action=json&keys=' . $field_group['key']); ?>">Json</a>
|
243 |
+
</div>
|
244 |
+
<script type="text/javascript">
|
245 |
+
(function($) {
|
246 |
+
$('.misc-pub-acfe-field-group-key').insertAfter('.misc-pub-post-status');
|
247 |
+
$('.misc-pub-acfe-field-group-export').insertAfter('.misc-pub-post-status');
|
248 |
+
})(jQuery);
|
249 |
+
</script>
|
250 |
+
<?php
|
251 |
+
|
252 |
+
}
|
253 |
+
|
254 |
+
/**
|
255 |
+
* Field Group Options: Sidebar
|
256 |
+
*/
|
257 |
+
add_action('acf/field_group/admin_head', 'acfe_render_field_group_settings_side');
|
258 |
+
function acfe_render_field_group_settings_side(){
|
259 |
+
|
260 |
+
add_meta_box('acf-field-group-acfe-side', __('Advanced Settings', 'acfe'), function(){
|
261 |
+
|
262 |
+
// Global
|
263 |
+
global $field_group;
|
264 |
+
|
265 |
+
// Proxy
|
266 |
+
$_field_group = $field_group;
|
267 |
+
|
268 |
+
acf_render_field_wrap(array(
|
269 |
+
'label' => __('Display title', 'acfe'),
|
270 |
+
'instructions' => __('Render this title on edit post screen', 'acfe'),
|
271 |
+
'type' => 'text',
|
272 |
+
'name' => 'acfe_display_title',
|
273 |
+
'prefix' => 'acf_field_group',
|
274 |
+
'value' => (isset($field_group['acfe_display_title'])) ? $field_group['acfe_display_title'] : '',
|
275 |
+
'placeholder' => '',
|
276 |
+
'prepend' => '',
|
277 |
+
'append' => ''
|
278 |
+
));
|
279 |
+
|
280 |
+
if(acfe_is_field_group_json_desync($field_group)){
|
281 |
+
acf_render_field_wrap(array(
|
282 |
+
'label' => __('Json Desync'),
|
283 |
+
'instructions' => __('Local json file is different from this version. If you manually synchronize it, you will lose your current field group settings'),
|
284 |
+
'type' => 'acfe_dynamic_message',
|
285 |
+
'name' => 'acfe_sync_available',
|
286 |
+
'prefix' => 'acf_field_group',
|
287 |
+
'value' => $field_group['key'],
|
288 |
+
));
|
289 |
+
}
|
290 |
+
|
291 |
+
|
292 |
+
$force_json_sync = false;
|
293 |
+
$json_text = 'Json';
|
294 |
+
|
295 |
+
if(acfe_has_field_group_autosync_file($_field_group, 'json')){
|
296 |
+
|
297 |
+
if(isset($_field_group['acfe_autosync']) && is_array($_field_group['acfe_autosync']))
|
298 |
+
$_field_group['acfe_autosync'][] = 'json';
|
299 |
+
else
|
300 |
+
$_field_group['acfe_autosync'] = array('json');
|
301 |
+
|
302 |
+
$json_text = '<span class="acf-js-tooltip" title="To disable the Json Sync you must manually delete the file: '.$_field_group['key'].'.json">Json</span>';
|
303 |
+
|
304 |
+
$force_json_sync = true;
|
305 |
+
|
306 |
+
}
|
307 |
+
|
308 |
+
$force_php_sync = false;
|
309 |
+
$php_text = 'PHP';
|
310 |
+
acf_enable_filter('local');
|
311 |
+
|
312 |
+
if(acfe_has_field_group_autosync_file($_field_group, 'php')){
|
313 |
+
|
314 |
+
acf_disable_filter('local');
|
315 |
+
|
316 |
+
if(isset($_field_group['acfe_autosync']) && is_array($_field_group['acfe_autosync']))
|
317 |
+
$_field_group['acfe_autosync'][] = 'php';
|
318 |
+
else
|
319 |
+
$_field_group['acfe_autosync'] = array('php');
|
320 |
+
|
321 |
+
$php_text = '<span class="acf-js-tooltip" title="To disable the PHP Sync you must manually delete the file: '.$_field_group['key'].'.php">PHP</span>';
|
322 |
+
|
323 |
+
$force_php_sync = true;
|
324 |
+
|
325 |
+
}
|
326 |
+
|
327 |
+
acf_render_field_wrap(array(
|
328 |
+
'label' => __('Auto Sync'),
|
329 |
+
'instructions' => '',
|
330 |
+
'type' => 'checkbox',
|
331 |
+
'name' => 'acfe_autosync',
|
332 |
+
'prefix' => 'acf_field_group',
|
333 |
+
'value' => (isset($_field_group['acfe_autosync']) && !empty($_field_group['acfe_autosync'])) ? $_field_group['acfe_autosync'] : array(),
|
334 |
+
'choices' => array(
|
335 |
+
'php' => $php_text,
|
336 |
+
'json' => $json_text,
|
337 |
+
)
|
338 |
+
));
|
339 |
+
|
340 |
+
acf_render_field_wrap(array(
|
341 |
+
'label' => __('Permissions'),
|
342 |
+
'name' => 'acfe_permissions',
|
343 |
+
'prefix' => 'acf_field_group',
|
344 |
+
'type' => 'checkbox',
|
345 |
+
'instructions' => __('Select user roles that are allowed to view and edit this field group in post edition'),
|
346 |
+
'required' => false,
|
347 |
+
'default_value' => false,
|
348 |
+
'choices' => acfe_get_roles(),
|
349 |
+
'value' => (isset($field_group['acfe_permissions'])) ? $field_group['acfe_permissions'] : array(),
|
350 |
+
'layout' => 'vertical'
|
351 |
+
));
|
352 |
+
|
353 |
+
?>
|
354 |
+
<script type="text/javascript">
|
355 |
+
if(typeof acf !== 'undefined'){
|
356 |
+
acf.postbox.render({
|
357 |
+
'id': 'acf-field-group-acfe-side',
|
358 |
+
'label': 'top'
|
359 |
+
});
|
360 |
+
}
|
361 |
+
|
362 |
+
(function($){
|
363 |
+
|
364 |
+
<?php if($force_json_sync){ ?>
|
365 |
+
|
366 |
+
$('#acf_field_group-acfe_autosync-json').prop('readonly', true).addClass('disabled').click(function(){
|
367 |
+
return false;
|
368 |
+
});
|
369 |
+
|
370 |
+
$('#acf_field_group-acfe_autosync-json').closest('label').css('color', '#999');
|
371 |
+
|
372 |
+
<?php } ?>
|
373 |
+
|
374 |
+
<?php if($force_php_sync){ ?>
|
375 |
+
|
376 |
+
$('#acf_field_group-acfe_autosync-php').prop('readonly', true).addClass('disabled').click(function(){
|
377 |
+
return false;
|
378 |
+
});
|
379 |
+
|
380 |
+
$('#acf_field_group-acfe_autosync-php').closest('label').css('color', '#999');
|
381 |
+
|
382 |
+
<?php } ?>
|
383 |
+
|
384 |
+
if($('[data-name=acfe_sync_available]').length){
|
385 |
+
|
386 |
+
if($('[data-name=acfe_sync_available]').find('[data-acfe-autosync-json-active]').attr('data-acfe-autosync-json-active') === '0'){
|
387 |
+
$('#acf_field_group-acfe_autosync-json').change(function(e){
|
388 |
+
if($(this).prop('checked')){
|
389 |
+
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')){
|
390 |
+
$(this).prop('checked', false);
|
391 |
+
return false;
|
392 |
+
}
|
393 |
+
}
|
394 |
+
});
|
395 |
+
}
|
396 |
+
|
397 |
+
else{
|
398 |
+
|
399 |
+
$('#publish').click(function(e){
|
400 |
+
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'))
|
401 |
+
e.preventDefault();
|
402 |
+
});
|
403 |
+
|
404 |
+
}
|
405 |
+
}
|
406 |
+
})(jQuery);
|
407 |
+
</script>
|
408 |
+
<?php
|
409 |
+
}, 'acf-field-group', 'side');
|
410 |
+
|
411 |
+
}
|
412 |
+
|
413 |
+
/**
|
414 |
+
* Render: Sync Available
|
415 |
+
*/
|
416 |
+
add_action('acf/render_field/name=acfe_sync_available', 'acfe_render_field_sync_available');
|
417 |
+
function acfe_render_field_sync_available($field){
|
418 |
+
|
419 |
+
$field_group = acf_get_field_group($field['value']);
|
420 |
+
|
421 |
+
$acfe_autosync_active = 0;
|
422 |
+
if(isset($field_group['acfe_autosync']) && is_array($field_group['acfe_autosync']) && in_array('json', $field_group['acfe_autosync']))
|
423 |
+
$acfe_autosync_active = 1;
|
424 |
+
|
425 |
+
$nonce = wp_create_nonce('bulk-posts');
|
426 |
+
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>';
|
427 |
+
|
428 |
+
}
|
429 |
+
|
430 |
+
/**
|
431 |
+
* Render: Sync Warnings
|
432 |
+
*/
|
433 |
+
add_action('acf/render_field', 'acfe_render_field_acfe_sync_warnings', 5);
|
434 |
+
function acfe_render_field_acfe_sync_warnings($field){
|
435 |
+
|
436 |
+
if($field['_name'] !== 'acfe_autosync')
|
437 |
+
return;
|
438 |
+
|
439 |
+
global $field_group;
|
440 |
+
|
441 |
+
// PHP
|
442 |
+
|
443 |
+
// Fix to load local fiel groups
|
444 |
+
acf_enable_filters();
|
445 |
+
|
446 |
+
if(acfe_has_field_group_autosync($field_group, 'php') && !acf_get_setting('acfe/php_found')){
|
447 |
+
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>';
|
448 |
+
}
|
449 |
+
|
450 |
+
elseif(!acfe_has_field_group_autosync($field_group, 'php') && acfe_has_field_group_autosync_file($field_group, 'php')){
|
451 |
+
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>';
|
452 |
+
}
|
453 |
+
|
454 |
+
elseif(acfe_has_field_group_autosync($field_group, 'php') && !acfe_has_field_group_autosync_file($field_group, 'php')){
|
455 |
+
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'] . '.php</code> will be created upon update</p>';
|
456 |
+
}
|
457 |
+
|
458 |
+
// Re-disable filters, as natively
|
459 |
+
acf_disable_filters();
|
460 |
+
|
461 |
+
// Json
|
462 |
+
if(acfe_has_field_group_autosync($field_group, 'json') && !acfe_has_field_group_autosync_file($field_group, 'json')){
|
463 |
+
|
464 |
+
if(!acf_get_setting('acfe/json_found')){
|
465 |
+
|
466 |
+
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;">/acf-json</code> was not found in your theme. You must create it to activate Json Sync.</p>';
|
467 |
+
|
468 |
+
}
|
469 |
+
|
470 |
+
else{
|
471 |
+
|
472 |
+
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> will be created upon update.</p>';
|
473 |
+
|
474 |
+
}
|
475 |
+
}
|
476 |
+
|
477 |
+
}
|
478 |
+
|
479 |
+
/**
|
480 |
+
* Render: Data button
|
481 |
+
*/
|
482 |
+
add_action('acf/render_field/name=acfe_data', 'acfe_render_field_group_data');
|
483 |
+
function acfe_render_field_group_data($field){
|
484 |
+
|
485 |
+
$field_group = acf_get_field_group($field['value']);
|
486 |
+
if(!$field_group){
|
487 |
+
echo '<a href="#" class="button disabled" disabled>' . __('Data') . '</a>';
|
488 |
+
return;
|
489 |
+
}
|
490 |
+
|
491 |
+
echo '<a href="#" class="button acfe_modal_open" data-modal-key="' . $field_group['key'] . '">' . __('Data') . '</a>';
|
492 |
+
echo '<div class="acfe-modal" data-modal-key="' . $field_group['key'] . '"><div style="padding:15px;"><pre>' . print_r($field_group, true) . '</pre></div></div>';
|
493 |
+
|
494 |
+
}
|
495 |
+
|
496 |
+
/**
|
497 |
+
* Hooks: Display title (post edit)
|
498 |
+
*/
|
499 |
+
add_filter('acf/get_field_groups', 'acfe_render_field_groups', 999);
|
500 |
+
function acfe_render_field_groups($field_groups){
|
501 |
+
|
502 |
+
if(!is_admin())
|
503 |
+
return $field_groups;
|
504 |
+
|
505 |
+
$check_current_screen = acf_is_screen(array(
|
506 |
+
'edit-acf-field-group',
|
507 |
+
'acf-field-group',
|
508 |
+
'acf_page_acf-tools'
|
509 |
+
));
|
510 |
+
|
511 |
+
if($check_current_screen)
|
512 |
+
return $field_groups;
|
513 |
+
|
514 |
+
foreach($field_groups as &$field_group){
|
515 |
+
if(!isset($field_group['acfe_display_title']) || empty($field_group['acfe_display_title']))
|
516 |
+
continue;
|
517 |
+
|
518 |
+
$field_group['title'] = $field_group['acfe_display_title'];
|
519 |
+
}
|
520 |
+
|
521 |
+
return $field_groups;
|
522 |
+
|
523 |
+
}
|
524 |
+
|
525 |
+
/**
|
526 |
+
* Hooks: Permissions (post edit)
|
527 |
+
*/
|
528 |
+
add_filter('acf/get_field_groups', 'acfe_permissions_field_groups', 999);
|
529 |
+
function acfe_permissions_field_groups($field_groups){
|
530 |
+
|
531 |
+
if(!is_admin())
|
532 |
+
return $field_groups;
|
533 |
+
|
534 |
+
$check_current_screen = acf_is_screen(array(
|
535 |
+
'edit-acf-field-group',
|
536 |
+
'acf-field-group',
|
537 |
+
'acf_page_acf-tools'
|
538 |
+
));
|
539 |
+
|
540 |
+
if($check_current_screen)
|
541 |
+
return $field_groups;
|
542 |
+
|
543 |
+
$current_user_roles = acfe_get_current_user_roles();
|
544 |
+
|
545 |
+
foreach($field_groups as $key => $field_group){
|
546 |
+
if(!isset($field_group['acfe_permissions']) || empty($field_group['acfe_permissions']))
|
547 |
+
continue;
|
548 |
+
|
549 |
+
$render_field_group = false;
|
550 |
+
|
551 |
+
foreach($current_user_roles as $current_user_role){
|
552 |
+
foreach($field_group['acfe_permissions'] as $field_group_role){
|
553 |
+
if($current_user_role !== $field_group_role)
|
554 |
+
continue;
|
555 |
+
|
556 |
+
$render_field_group = true;
|
557 |
+
break;
|
558 |
+
}
|
559 |
+
|
560 |
+
if($render_field_group)
|
561 |
+
break;
|
562 |
+
}
|
563 |
+
|
564 |
+
if(!$render_field_group)
|
565 |
+
unset($field_groups[$key]);
|
566 |
+
}
|
567 |
+
|
568 |
+
return $field_groups;
|
569 |
+
|
570 |
+
}
|
571 |
+
|
572 |
+
add_filter('acf/prepare_field/name=instruction_placement', 'acfe_field_group_instruction_placement');
|
573 |
+
function acfe_field_group_instruction_placement($field){
|
574 |
+
|
575 |
+
$field['choices'] = array_merge($field['choices'], array('acfe_instructions_tooltip' => 'Tooltip'));
|
576 |
+
|
577 |
+
return $field;
|
578 |
+
|
579 |
+
}
|
580 |
+
|
581 |
+
/**
|
582 |
+
* Hooks: Default label placement - Left
|
583 |
+
*/
|
584 |
+
add_filter('acf/validate_field_group', 'acfc_field_group_default_options');
|
585 |
+
function acfc_field_group_default_options($field_group){
|
586 |
+
|
587 |
+
if(!isset($field_group['location']) || empty($field_group['location']))
|
588 |
+
$field_group['label_placement'] = 'left';
|
589 |
+
|
590 |
+
return $field_group;
|
591 |
+
|
592 |
+
}
|
593 |
+
|
594 |
+
add_filter('acf/prepare_field_group_for_export', 'acfc_field_group_export_categories');
|
595 |
+
function acfc_field_group_export_categories($field_group){
|
596 |
+
|
597 |
+
$_field_group = acf_get_field_group($field_group['key']);
|
598 |
+
if(empty($_field_group))
|
599 |
+
return $field_group;
|
600 |
+
|
601 |
+
if(!acf_maybe_get($_field_group, 'ID'))
|
602 |
+
return $field_group;
|
603 |
+
|
604 |
+
$categories = get_the_terms($_field_group['ID'], 'acf-field-group-category');
|
605 |
+
|
606 |
+
if(empty($categories) || is_wp_error($categories))
|
607 |
+
return $field_group;
|
608 |
+
|
609 |
+
$field_group['acfe_categories'] = array();
|
610 |
+
|
611 |
+
foreach($categories as $term){
|
612 |
+
|
613 |
+
$field_group['acfe_categories'][$term->slug] = $term->name;
|
614 |
+
|
615 |
+
}
|
616 |
+
|
617 |
+
return $field_group;
|
618 |
+
|
619 |
+
}
|
620 |
+
|
621 |
+
add_action('acf/import_field_group', 'acfc_field_group_import_categories');
|
622 |
+
function acfc_field_group_import_categories($field_group){
|
623 |
+
|
624 |
+
if(!$categories = acf_maybe_get($field_group, 'acfe_categories'))
|
625 |
+
return;
|
626 |
+
|
627 |
+
foreach($categories as $term_slug => $term_name){
|
628 |
+
|
629 |
+
$new_term_id = false;
|
630 |
+
$get_term = get_term_by('slug', $term_slug, 'acf-field-group-category');
|
631 |
+
|
632 |
+
// Term doesn't exists
|
633 |
+
if(empty($get_term)){
|
634 |
+
|
635 |
+
$new_term = wp_insert_term($term_name, 'acf-field-group-category', array(
|
636 |
+
'slug' => $term_slug
|
637 |
+
));
|
638 |
+
|
639 |
+
if(!is_wp_error($new_term)){
|
640 |
+
|
641 |
+
$new_term_id = $new_term->term_id;
|
642 |
+
|
643 |
+
}
|
644 |
+
|
645 |
+
}
|
646 |
+
|
647 |
+
// Term already exists
|
648 |
+
else{
|
649 |
+
|
650 |
+
$new_term_id = $get_term->term_id;
|
651 |
+
|
652 |
+
}
|
653 |
+
|
654 |
+
if($new_term_id){
|
655 |
+
|
656 |
+
wp_set_post_terms($field_group['ID'], array($new_term_id), 'acf-field-group-category', true);
|
657 |
+
|
658 |
+
}
|
659 |
+
|
660 |
+
}
|
661 |
+
|
662 |
}
|
includes/field-groups/field-groups.php
CHANGED
@@ -1,479 +1,470 @@
|
|
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 |
-
|
12 |
-
if(!acf_is_screen('edit-acf-field-group'))
|
13 |
-
return $states;
|
14 |
-
|
15 |
-
if(get_post_type($post->ID) != 'acf-field-group')
|
16 |
-
return $states;
|
17 |
-
|
18 |
-
$field_group = acf_get_field_group($post->ID);
|
19 |
-
|
20 |
-
if(!$field_group || !isset($field_group['acfe_display_title']) || empty($field_group['acfe_display_title']))
|
21 |
-
return $states;
|
22 |
-
|
23 |
-
$states[] = $field_group['acfe_display_title'];
|
24 |
-
|
25 |
-
return $states;
|
26 |
-
|
27 |
-
}
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Table Columns
|
31 |
-
*/
|
32 |
-
add_filter('manage_edit-acf-field-group_columns', 'acfe_field_groups_column', 999);
|
33 |
-
function acfe_field_groups_column($columns){
|
34 |
-
|
35 |
-
// Locations
|
36 |
-
$columns['acfe-locations'] = __('Locations');
|
37 |
-
|
38 |
-
// Load
|
39 |
-
$columns['acfe-local'] = __('Load');
|
40 |
-
|
41 |
-
// PHP sync
|
42 |
-
if(acf_get_setting('acfe/php'))
|
43 |
-
$columns['acfe-autosync-php'] = __('PHP sync');
|
44 |
-
|
45 |
-
// Json sync
|
46 |
-
if(acf_get_setting('json'))
|
47 |
-
$columns['acfe-autosync-json'] = __('Json sync');
|
48 |
-
|
49 |
-
// Fix 'Sync' screen columns
|
50 |
-
if(acf_maybe_get_GET('post_status') === 'sync'){
|
51 |
-
|
52 |
-
unset($columns['acf-field-group-category']);
|
53 |
-
|
54 |
-
unset($columns['acfe-locations']);
|
55 |
-
unset($columns['acfe-local']);
|
56 |
-
|
57 |
-
if(isset($columns['acfe-autosync-php']))
|
58 |
-
unset($columns['acfe-autosync-php']);
|
59 |
-
|
60 |
-
if(isset($columns['acfe-autosync-json']))
|
61 |
-
unset($columns['acfe-autosync-json']);
|
62 |
-
|
63 |
-
}
|
64 |
-
|
65 |
-
// Fix 'Third party' screen columns
|
66 |
-
elseif(acf_maybe_get_GET('post_status') === 'acfe-third-party'){
|
67 |
-
|
68 |
-
$columns = array(
|
69 |
-
'title' => __('Title', 'acf'),
|
70 |
-
'acfe-source' => __('Source', 'acf'),
|
71 |
-
'acf-fg-count' => __('Fields', 'acf'),
|
72 |
-
'acfe-locations' => __('Locations', 'acf'),
|
73 |
-
'acfe-local' => __('Load', 'acf'),
|
74 |
-
);
|
75 |
-
|
76 |
-
}
|
77 |
-
|
78 |
-
// Remove 'Field Group Category' column if there is no terms
|
79 |
-
$categories = get_terms(array(
|
80 |
-
'taxonomy' => 'acf-field-group-category',
|
81 |
-
'hide_empty' => false,
|
82 |
-
));
|
83 |
-
|
84 |
-
if(empty($categories) && isset($columns['acf-field-group-category']))
|
85 |
-
unset($columns['acf-field-group-category']);
|
86 |
-
|
87 |
-
return $columns;
|
88 |
-
|
89 |
-
}
|
90 |
-
|
91 |
-
/**
|
92 |
-
* Table Columns HTML
|
93 |
-
*/
|
94 |
-
add_action('manage_acf-field-group_posts_custom_column', 'acfe_field_groups_column_html', 10, 2);
|
95 |
-
function acfe_field_groups_column_html($column, $post_id){
|
96 |
-
|
97 |
-
/**
|
98 |
-
* Count
|
99 |
-
*/
|
100 |
-
if($column === 'acfe-count'){
|
101 |
-
|
102 |
-
$field_group = acf_get_field_group($post_id);
|
103 |
-
echo esc_html(acf_get_field_count($field_group));
|
104 |
-
|
105 |
-
}
|
106 |
-
|
107 |
-
/**
|
108 |
-
* Count
|
109 |
-
*/
|
110 |
-
elseif($column === 'acfe-source'){
|
111 |
-
|
112 |
-
$field_group = acf_get_field_group($post_id);
|
113 |
-
|
114 |
-
$source = false;
|
115 |
-
|
116 |
-
// ACF Extended
|
117 |
-
if(strpos($post_id, 'group_acfe_') === 0){
|
118 |
-
|
119 |
-
$source = 'ACF Extended';
|
120 |
-
|
121 |
-
}
|
122 |
-
|
123 |
-
// Advanced Forms
|
124 |
-
elseif($post_id === 'group_form_settings' || $post_id === 'group_entry_data'){
|
125 |
-
|
126 |
-
$source = 'Advanced Forms';
|
127 |
-
|
128 |
-
}
|
129 |
-
|
130 |
-
else{
|
131 |
-
|
132 |
-
$source = '<span style="color:#aaa;">' . __('Unknown', 'acf') . '</span>';
|
133 |
-
|
134 |
-
}
|
135 |
-
|
136 |
-
$source = apply_filters('acfe/field_groups_third_party/source', $source, $post_id, $field_group);
|
137 |
-
|
138 |
-
echo $source;
|
139 |
-
|
140 |
-
}
|
141 |
-
|
142 |
-
/**
|
143 |
-
* Locations
|
144 |
-
*/
|
145 |
-
elseif($column === 'acfe-locations'){
|
146 |
-
|
147 |
-
$field_group = acf_get_field_group($post_id);
|
148 |
-
$choices = acf_get_location_rule_types();
|
149 |
-
|
150 |
-
if(!isset($field_group['location']) || empty($field_group['location']) ||empty($choices))
|
151 |
-
return;
|
152 |
-
|
153 |
-
$final = array();
|
154 |
-
|
155 |
-
$icon_default = 'admin-generic';
|
156 |
-
|
157 |
-
$icons = array(
|
158 |
-
'edit' => array(
|
159 |
-
'post_type',
|
160 |
-
'post_template',
|
161 |
-
'post_status',
|
162 |
-
'post_format',
|
163 |
-
'post',
|
164 |
-
),
|
165 |
-
'media-default' => array(
|
166 |
-
'page_template',
|
167 |
-
'page_type',
|
168 |
-
'page_parent',
|
169 |
-
'page',
|
170 |
-
),
|
171 |
-
'admin-users' => array(
|
172 |
-
'current_user',
|
173 |
-
'user_form',
|
174 |
-
),
|
175 |
-
'welcome-widgets-menus' => array(
|
176 |
-
'widget',
|
177 |
-
'nav_menu',
|
178 |
-
'nav_menu_item',
|
179 |
-
),
|
180 |
-
'category' => array(
|
181 |
-
'taxonomy',
|
182 |
-
'post_category',
|
183 |
-
'post_taxonomy',
|
184 |
-
),
|
185 |
-
'admin-comments' => array(
|
186 |
-
'comment',
|
187 |
-
),
|
188 |
-
'paperclip' => array(
|
189 |
-
'attachment',
|
190 |
-
),
|
191 |
-
'admin-settings' => array(
|
192 |
-
'options_page',
|
193 |
-
),
|
194 |
-
'businessman' => array(
|
195 |
-
'current_user_role',
|
196 |
-
'user_role',
|
197 |
-
),
|
198 |
-
);
|
199 |
-
|
200 |
-
foreach($choices as $key => $sub_choices){
|
201 |
-
|
202 |
-
foreach($sub_choices as $choice_slug => $choice_name){
|
203 |
-
|
204 |
-
$final_icon = $icon_default;
|
205 |
-
foreach($icons as $icon => $icon_slugs){
|
206 |
-
foreach($icon_slugs as $icon_slug){
|
207 |
-
if($choice_slug != $icon_slug)
|
208 |
-
continue;
|
209 |
-
|
210 |
-
$final_icon = $icon;
|
211 |
-
break(2);
|
212 |
-
}
|
213 |
-
}
|
214 |
-
|
215 |
-
$final[$choice_slug] = array(
|
216 |
-
'name' => $choice_name,
|
217 |
-
'icon' => $final_icon
|
218 |
-
);
|
219 |
-
|
220 |
-
}
|
221 |
-
|
222 |
-
}
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
$html = array();
|
227 |
-
foreach($field_group['location'] as $or){
|
228 |
-
|
229 |
-
foreach($or as $and){
|
230 |
-
|
231 |
-
if(!isset($final[$and['param']])|| !isset($and['value']))
|
232 |
-
continue;
|
233 |
-
|
234 |
-
$final_name = $and['value'];
|
235 |
-
$values = acf_get_location_rule_values($and);
|
236 |
-
|
237 |
-
if(!empty($values) && is_array($values)){
|
238 |
-
|
239 |
-
foreach($values as $value_slug => $value_name){
|
240 |
-
|
241 |
-
if($and['value'] != $value_slug)
|
242 |
-
continue;
|
243 |
-
|
244 |
-
if(is_array($value_name) && isset($value_name[$and['value']])){
|
245 |
-
|
246 |
-
$final_name = $value_name[$and['value']];
|
247 |
-
|
248 |
-
}else{
|
249 |
-
|
250 |
-
$final_name = $value_name;
|
251 |
-
|
252 |
-
}
|
253 |
-
|
254 |
-
break;
|
255 |
-
|
256 |
-
}
|
257 |
-
|
258 |
-
}
|
259 |
-
|
260 |
-
$name = '<span class="acf-js-tooltip dashicons dashicons-' . $final[$and['param']]['icon'] . '" title="' . $final[$and['param']]['name'] . ' = ' . $final_name . '"></span>';
|
261 |
-
if($and['operator'] === '!=')
|
262 |
-
$name = '<span class="acf-js-tooltip dashicons dashicons-' . $final[$and['param']]['icon'] . '" title="' . $final[$and['param']]['name'] . ' != ' . $final_name . '" style="color:#ccc;"></span>';
|
263 |
-
|
264 |
-
$html[] = $name;
|
265 |
-
|
266 |
-
}
|
267 |
-
|
268 |
-
}
|
269 |
-
|
270 |
-
echo implode(' ', $html);
|
271 |
-
|
272 |
-
}
|
273 |
-
|
274 |
-
/**
|
275 |
-
* Load
|
276 |
-
*/
|
277 |
-
elseif($column === 'acfe-local'){
|
278 |
-
|
279 |
-
if(!$field_group = acf_get_field_group($post_id))
|
280 |
-
return;
|
281 |
-
|
282 |
-
$local_field_group = acf_get_local_field_group($field_group['key']);
|
283 |
-
$local_field_group_type = acf_maybe_get($local_field_group, 'local', false);
|
284 |
-
|
285 |
-
if($local_field_group_type === 'php'){
|
286 |
-
|
287 |
-
echo '<span class="acf-js-tooltip" title="' . $field_group['key'] . ' is registered locally">php</span>';
|
288 |
-
|
289 |
-
return;
|
290 |
-
|
291 |
-
}
|
292 |
-
|
293 |
-
elseif($local_field_group_type === 'json'){
|
294 |
-
|
295 |
-
echo '<span class="acf-js-tooltip" title="' . $field_group['key'] . ' is registered locally">json</span>';
|
296 |
-
|
297 |
-
return;
|
298 |
-
|
299 |
-
}
|
300 |
-
|
301 |
-
else{
|
302 |
-
|
303 |
-
echo '<span class="acf-js-tooltip" title="' . $field_group['key'] . ' is not registered locally">DB</span>';
|
304 |
-
|
305 |
-
return;
|
306 |
-
|
307 |
-
}
|
308 |
-
|
309 |
-
}
|
310 |
-
|
311 |
-
/**
|
312 |
-
* PHP sync
|
313 |
-
*/
|
314 |
-
elseif($column === 'acfe-autosync-php'){
|
315 |
-
|
316 |
-
if(!$field_group = acf_get_field_group($post_id))
|
317 |
-
return;
|
318 |
-
|
319 |
-
if(!acfe_has_field_group_autosync($field_group, 'php')){
|
320 |
-
|
321 |
-
echo '<span style="color:#ccc" class="dashicons dashicons-no-alt"></span>';
|
322 |
-
|
323 |
-
if(acfe_has_field_group_autosync_file($field_group, 'php')){
|
324 |
-
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>';
|
325 |
-
}
|
326 |
-
|
327 |
-
return;
|
328 |
-
|
329 |
-
}
|
330 |
-
|
331 |
-
if(!acf_get_setting('acfe/php_found')){
|
332 |
-
|
333 |
-
echo '<span style="color:#ccc" class="dashicons dashicons-yes"></span>';
|
334 |
-
|
335 |
-
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>';
|
336 |
-
|
337 |
-
}
|
338 |
-
|
339 |
-
elseif(!acfe_has_field_group_autosync_file($field_group, 'php')){
|
340 |
-
|
341 |
-
echo '<span style="color:#ccc" class="dashicons dashicons-yes"></span>';
|
342 |
-
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'] . '.php will be created upon update"></span>';
|
343 |
-
|
344 |
-
}
|
345 |
-
|
346 |
-
else{
|
347 |
-
|
348 |
-
echo '<span class="dashicons dashicons-yes"></span>';
|
349 |
-
|
350 |
-
}
|
351 |
-
|
352 |
-
}
|
353 |
-
|
354 |
-
/**
|
355 |
-
* Json sync
|
356 |
-
*/
|
357 |
-
elseif($column === 'acfe-autosync-json'){
|
358 |
-
|
359 |
-
if(!$field_group = acf_get_field_group($post_id))
|
360 |
-
return;
|
361 |
-
|
362 |
-
if(acfe_has_field_group_autosync_file($field_group, 'json')){
|
363 |
-
|
364 |
-
echo '<span class="dashicons dashicons-yes"></span>';
|
365 |
-
|
366 |
-
}
|
367 |
-
|
368 |
-
else{
|
369 |
-
|
370 |
-
if(!acfe_has_field_group_autosync($field_group, 'json')){
|
371 |
-
|
372 |
-
echo '<span style="color:#ccc" class="dashicons dashicons-no-alt"></span>';
|
373 |
-
|
374 |
-
}else{
|
375 |
-
|
376 |
-
echo '<span style="color:#ccc" class="dashicons dashicons-yes"></span>';
|
377 |
-
|
378 |
-
if(!
|
379 |
-
|
380 |
-
echo '<span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="acf-js-tooltip dashicons dashicons-warning" title="Folder \'/acf-json\' was not found in your theme.<br />You must create it to activate this setting"></span>';
|
381 |
-
|
382 |
-
}
|
383 |
-
|
384 |
-
else{
|
385 |
-
|
386 |
-
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 will be created upon update."></span>';
|
387 |
-
|
388 |
-
}
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
}
|
393 |
-
|
394 |
-
}
|
395 |
-
|
396 |
-
}
|
397 |
-
}
|
398 |
-
|
399 |
-
/**
|
400 |
-
* Table Row Actions
|
401 |
-
*/
|
402 |
-
add_filter('page_row_actions', 'hwk_post_type_exemple_row_actions', 10, 2);
|
403 |
-
function hwk_post_type_exemple_row_actions($actions, $post){
|
404 |
-
|
405 |
-
if(!isset($post->post_type) || $post->post_type != 'acf-field-group')
|
406 |
-
return $actions;
|
407 |
-
|
408 |
-
$field_group = acf_get_field_group($post->ID);
|
409 |
-
|
410 |
-
$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>';
|
411 |
-
$actions['acfe-export-json'] = '<
|
412 |
-
|
413 |
-
$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>';
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
/**
|
472 |
-
* Hooks: Posts per page
|
473 |
-
*/
|
474 |
-
add_filter('edit_acf-field-group_per_page', 'acfe_field_groups_posts_per_page');
|
475 |
-
function acfe_field_groups_posts_per_page(){
|
476 |
-
|
477 |
-
return 999;
|
478 |
-
|
479 |
}
|
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 |
+
|
12 |
+
if(!acf_is_screen('edit-acf-field-group'))
|
13 |
+
return $states;
|
14 |
+
|
15 |
+
if(get_post_type($post->ID) != 'acf-field-group')
|
16 |
+
return $states;
|
17 |
+
|
18 |
+
$field_group = acf_get_field_group($post->ID);
|
19 |
+
|
20 |
+
if(!$field_group || !isset($field_group['acfe_display_title']) || empty($field_group['acfe_display_title']))
|
21 |
+
return $states;
|
22 |
+
|
23 |
+
$states[] = $field_group['acfe_display_title'];
|
24 |
+
|
25 |
+
return $states;
|
26 |
+
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Table Columns
|
31 |
+
*/
|
32 |
+
add_filter('manage_edit-acf-field-group_columns', 'acfe_field_groups_column', 999);
|
33 |
+
function acfe_field_groups_column($columns){
|
34 |
+
|
35 |
+
// Locations
|
36 |
+
$columns['acfe-locations'] = __('Locations');
|
37 |
+
|
38 |
+
// Load
|
39 |
+
$columns['acfe-local'] = __('Load');
|
40 |
+
|
41 |
+
// PHP sync
|
42 |
+
if(acf_get_setting('acfe/php'))
|
43 |
+
$columns['acfe-autosync-php'] = __('PHP sync');
|
44 |
+
|
45 |
+
// Json sync
|
46 |
+
if(acf_get_setting('json'))
|
47 |
+
$columns['acfe-autosync-json'] = __('Json sync');
|
48 |
+
|
49 |
+
// Fix 'Sync' screen columns
|
50 |
+
if(acf_maybe_get_GET('post_status') === 'sync'){
|
51 |
+
|
52 |
+
unset($columns['acf-field-group-category']);
|
53 |
+
|
54 |
+
unset($columns['acfe-locations']);
|
55 |
+
unset($columns['acfe-local']);
|
56 |
+
|
57 |
+
if(isset($columns['acfe-autosync-php']))
|
58 |
+
unset($columns['acfe-autosync-php']);
|
59 |
+
|
60 |
+
if(isset($columns['acfe-autosync-json']))
|
61 |
+
unset($columns['acfe-autosync-json']);
|
62 |
+
|
63 |
+
}
|
64 |
+
|
65 |
+
// Fix 'Third party' screen columns
|
66 |
+
elseif(acf_maybe_get_GET('post_status') === 'acfe-third-party'){
|
67 |
+
|
68 |
+
$columns = array(
|
69 |
+
'title' => __('Title', 'acf'),
|
70 |
+
'acfe-source' => __('Source', 'acf'),
|
71 |
+
'acf-fg-count' => __('Fields', 'acf'),
|
72 |
+
'acfe-locations' => __('Locations', 'acf'),
|
73 |
+
'acfe-local' => __('Load', 'acf'),
|
74 |
+
);
|
75 |
+
|
76 |
+
}
|
77 |
+
|
78 |
+
// Remove 'Field Group Category' column if there is no terms
|
79 |
+
$categories = get_terms(array(
|
80 |
+
'taxonomy' => 'acf-field-group-category',
|
81 |
+
'hide_empty' => false,
|
82 |
+
));
|
83 |
+
|
84 |
+
if(empty($categories) && isset($columns['acf-field-group-category']))
|
85 |
+
unset($columns['acf-field-group-category']);
|
86 |
+
|
87 |
+
return $columns;
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Table Columns HTML
|
93 |
+
*/
|
94 |
+
add_action('manage_acf-field-group_posts_custom_column', 'acfe_field_groups_column_html', 10, 2);
|
95 |
+
function acfe_field_groups_column_html($column, $post_id){
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Count
|
99 |
+
*/
|
100 |
+
if($column === 'acfe-count'){
|
101 |
+
|
102 |
+
$field_group = acf_get_field_group($post_id);
|
103 |
+
echo esc_html(acf_get_field_count($field_group));
|
104 |
+
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Count
|
109 |
+
*/
|
110 |
+
elseif($column === 'acfe-source'){
|
111 |
+
|
112 |
+
$field_group = acf_get_field_group($post_id);
|
113 |
+
|
114 |
+
$source = false;
|
115 |
+
|
116 |
+
// ACF Extended
|
117 |
+
if(strpos($post_id, 'group_acfe_') === 0){
|
118 |
+
|
119 |
+
$source = 'ACF Extended';
|
120 |
+
|
121 |
+
}
|
122 |
+
|
123 |
+
// Advanced Forms
|
124 |
+
elseif($post_id === 'group_form_settings' || $post_id === 'group_entry_data'){
|
125 |
+
|
126 |
+
$source = 'Advanced Forms';
|
127 |
+
|
128 |
+
}
|
129 |
+
|
130 |
+
else{
|
131 |
+
|
132 |
+
$source = '<span style="color:#aaa;">' . __('Unknown', 'acf') . '</span>';
|
133 |
+
|
134 |
+
}
|
135 |
+
|
136 |
+
$source = apply_filters('acfe/field_groups_third_party/source', $source, $post_id, $field_group);
|
137 |
+
|
138 |
+
echo $source;
|
139 |
+
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Locations
|
144 |
+
*/
|
145 |
+
elseif($column === 'acfe-locations'){
|
146 |
+
|
147 |
+
$field_group = acf_get_field_group($post_id);
|
148 |
+
$choices = acf_get_location_rule_types();
|
149 |
+
|
150 |
+
if(!isset($field_group['location']) || empty($field_group['location']) ||empty($choices))
|
151 |
+
return;
|
152 |
+
|
153 |
+
$final = array();
|
154 |
+
|
155 |
+
$icon_default = 'admin-generic';
|
156 |
+
|
157 |
+
$icons = array(
|
158 |
+
'edit' => array(
|
159 |
+
'post_type',
|
160 |
+
'post_template',
|
161 |
+
'post_status',
|
162 |
+
'post_format',
|
163 |
+
'post',
|
164 |
+
),
|
165 |
+
'media-default' => array(
|
166 |
+
'page_template',
|
167 |
+
'page_type',
|
168 |
+
'page_parent',
|
169 |
+
'page',
|
170 |
+
),
|
171 |
+
'admin-users' => array(
|
172 |
+
'current_user',
|
173 |
+
'user_form',
|
174 |
+
),
|
175 |
+
'welcome-widgets-menus' => array(
|
176 |
+
'widget',
|
177 |
+
'nav_menu',
|
178 |
+
'nav_menu_item',
|
179 |
+
),
|
180 |
+
'category' => array(
|
181 |
+
'taxonomy',
|
182 |
+
'post_category',
|
183 |
+
'post_taxonomy',
|
184 |
+
),
|
185 |
+
'admin-comments' => array(
|
186 |
+
'comment',
|
187 |
+
),
|
188 |
+
'paperclip' => array(
|
189 |
+
'attachment',
|
190 |
+
),
|
191 |
+
'admin-settings' => array(
|
192 |
+
'options_page',
|
193 |
+
),
|
194 |
+
'businessman' => array(
|
195 |
+
'current_user_role',
|
196 |
+
'user_role',
|
197 |
+
),
|
198 |
+
);
|
199 |
+
|
200 |
+
foreach($choices as $key => $sub_choices){
|
201 |
+
|
202 |
+
foreach($sub_choices as $choice_slug => $choice_name){
|
203 |
+
|
204 |
+
$final_icon = $icon_default;
|
205 |
+
foreach($icons as $icon => $icon_slugs){
|
206 |
+
foreach($icon_slugs as $icon_slug){
|
207 |
+
if($choice_slug != $icon_slug)
|
208 |
+
continue;
|
209 |
+
|
210 |
+
$final_icon = $icon;
|
211 |
+
break(2);
|
212 |
+
}
|
213 |
+
}
|
214 |
+
|
215 |
+
$final[$choice_slug] = array(
|
216 |
+
'name' => $choice_name,
|
217 |
+
'icon' => $final_icon
|
218 |
+
);
|
219 |
+
|
220 |
+
}
|
221 |
+
|
222 |
+
}
|
223 |
+
|
224 |
+
|
225 |
+
|
226 |
+
$html = array();
|
227 |
+
foreach($field_group['location'] as $or){
|
228 |
+
|
229 |
+
foreach($or as $and){
|
230 |
+
|
231 |
+
if(!isset($final[$and['param']])|| !isset($and['value']))
|
232 |
+
continue;
|
233 |
+
|
234 |
+
$final_name = $and['value'];
|
235 |
+
$values = acf_get_location_rule_values($and);
|
236 |
+
|
237 |
+
if(!empty($values) && is_array($values)){
|
238 |
+
|
239 |
+
foreach($values as $value_slug => $value_name){
|
240 |
+
|
241 |
+
if($and['value'] != $value_slug)
|
242 |
+
continue;
|
243 |
+
|
244 |
+
if(is_array($value_name) && isset($value_name[$and['value']])){
|
245 |
+
|
246 |
+
$final_name = $value_name[$and['value']];
|
247 |
+
|
248 |
+
}else{
|
249 |
+
|
250 |
+
$final_name = $value_name;
|
251 |
+
|
252 |
+
}
|
253 |
+
|
254 |
+
break;
|
255 |
+
|
256 |
+
}
|
257 |
+
|
258 |
+
}
|
259 |
+
|
260 |
+
$name = '<span class="acf-js-tooltip dashicons dashicons-' . $final[$and['param']]['icon'] . '" title="' . $final[$and['param']]['name'] . ' = ' . $final_name . '"></span>';
|
261 |
+
if($and['operator'] === '!=')
|
262 |
+
$name = '<span class="acf-js-tooltip dashicons dashicons-' . $final[$and['param']]['icon'] . '" title="' . $final[$and['param']]['name'] . ' != ' . $final_name . '" style="color:#ccc;"></span>';
|
263 |
+
|
264 |
+
$html[] = $name;
|
265 |
+
|
266 |
+
}
|
267 |
+
|
268 |
+
}
|
269 |
+
|
270 |
+
echo implode(' ', $html);
|
271 |
+
|
272 |
+
}
|
273 |
+
|
274 |
+
/**
|
275 |
+
* Load
|
276 |
+
*/
|
277 |
+
elseif($column === 'acfe-local'){
|
278 |
+
|
279 |
+
if(!$field_group = acf_get_field_group($post_id))
|
280 |
+
return;
|
281 |
+
|
282 |
+
$local_field_group = acf_get_local_field_group($field_group['key']);
|
283 |
+
$local_field_group_type = acf_maybe_get($local_field_group, 'local', false);
|
284 |
+
|
285 |
+
if($local_field_group_type === 'php'){
|
286 |
+
|
287 |
+
echo '<span class="acf-js-tooltip" title="' . $field_group['key'] . ' is registered locally">php</span>';
|
288 |
+
|
289 |
+
return;
|
290 |
+
|
291 |
+
}
|
292 |
+
|
293 |
+
elseif($local_field_group_type === 'json'){
|
294 |
+
|
295 |
+
echo '<span class="acf-js-tooltip" title="' . $field_group['key'] . ' is registered locally">json</span>';
|
296 |
+
|
297 |
+
return;
|
298 |
+
|
299 |
+
}
|
300 |
+
|
301 |
+
else{
|
302 |
+
|
303 |
+
echo '<span class="acf-js-tooltip" title="' . $field_group['key'] . ' is not registered locally">DB</span>';
|
304 |
+
|
305 |
+
return;
|
306 |
+
|
307 |
+
}
|
308 |
+
|
309 |
+
}
|
310 |
+
|
311 |
+
/**
|
312 |
+
* PHP sync
|
313 |
+
*/
|
314 |
+
elseif($column === 'acfe-autosync-php'){
|
315 |
+
|
316 |
+
if(!$field_group = acf_get_field_group($post_id))
|
317 |
+
return;
|
318 |
+
|
319 |
+
if(!acfe_has_field_group_autosync($field_group, 'php')){
|
320 |
+
|
321 |
+
echo '<span style="color:#ccc" class="dashicons dashicons-no-alt"></span>';
|
322 |
+
|
323 |
+
if(acfe_has_field_group_autosync_file($field_group, 'php')){
|
324 |
+
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>';
|
325 |
+
}
|
326 |
+
|
327 |
+
return;
|
328 |
+
|
329 |
+
}
|
330 |
+
|
331 |
+
if(!acf_get_setting('acfe/php_found')){
|
332 |
+
|
333 |
+
echo '<span style="color:#ccc" class="dashicons dashicons-yes"></span>';
|
334 |
+
|
335 |
+
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>';
|
336 |
+
|
337 |
+
}
|
338 |
+
|
339 |
+
elseif(!acfe_has_field_group_autosync_file($field_group, 'php')){
|
340 |
+
|
341 |
+
echo '<span style="color:#ccc" class="dashicons dashicons-yes"></span>';
|
342 |
+
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'] . '.php will be created upon update"></span>';
|
343 |
+
|
344 |
+
}
|
345 |
+
|
346 |
+
else{
|
347 |
+
|
348 |
+
echo '<span class="dashicons dashicons-yes"></span>';
|
349 |
+
|
350 |
+
}
|
351 |
+
|
352 |
+
}
|
353 |
+
|
354 |
+
/**
|
355 |
+
* Json sync
|
356 |
+
*/
|
357 |
+
elseif($column === 'acfe-autosync-json'){
|
358 |
+
|
359 |
+
if(!$field_group = acf_get_field_group($post_id))
|
360 |
+
return;
|
361 |
+
|
362 |
+
if(acfe_has_field_group_autosync_file($field_group, 'json')){
|
363 |
+
|
364 |
+
echo '<span class="dashicons dashicons-yes"></span>';
|
365 |
+
|
366 |
+
}
|
367 |
+
|
368 |
+
else{
|
369 |
+
|
370 |
+
if(!acfe_has_field_group_autosync($field_group, 'json')){
|
371 |
+
|
372 |
+
echo '<span style="color:#ccc" class="dashicons dashicons-no-alt"></span>';
|
373 |
+
|
374 |
+
}else{
|
375 |
+
|
376 |
+
echo '<span style="color:#ccc" class="dashicons dashicons-yes"></span>';
|
377 |
+
|
378 |
+
if(!acf_get_setting('acfe/json_found')){
|
379 |
+
|
380 |
+
echo '<span style="color:#ccc;font-size:16px;vertical-align:text-top;" class="acf-js-tooltip dashicons dashicons-warning" title="Folder \'/acf-json\' was not found in your theme.<br />You must create it to activate this setting"></span>';
|
381 |
+
|
382 |
+
}
|
383 |
+
|
384 |
+
else{
|
385 |
+
|
386 |
+
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 will be created upon update."></span>';
|
387 |
+
|
388 |
+
}
|
389 |
+
|
390 |
+
|
391 |
+
|
392 |
+
}
|
393 |
+
|
394 |
+
}
|
395 |
+
|
396 |
+
}
|
397 |
+
}
|
398 |
+
|
399 |
+
/**
|
400 |
+
* Table Row Actions
|
401 |
+
*/
|
402 |
+
add_filter('page_row_actions', 'hwk_post_type_exemple_row_actions', 10, 2);
|
403 |
+
function hwk_post_type_exemple_row_actions($actions, $post){
|
404 |
+
|
405 |
+
if(!isset($post->post_type) || $post->post_type != 'acf-field-group')
|
406 |
+
return $actions;
|
407 |
+
|
408 |
+
$field_group = acf_get_field_group($post->ID);
|
409 |
+
|
410 |
+
$actions['acfe-export-php'] = '<a href="' . admin_url('edit.php?post_type=acf-field-group&page=acf-tools&tool=export&action=php&keys=' . $field_group['key']) . '">PHP</a>';
|
411 |
+
$actions['acfe-export-json'] = '<a href="' . admin_url('edit.php?post_type=acf-field-group&page=acf-tools&tool=export&action=json&keys=' . $field_group['key']) . '">Json</a>';
|
412 |
+
|
413 |
+
$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>';
|
414 |
+
|
415 |
+
//$actions['acfe-id'] = '<span style="color:#555;">ID: ' . $field_group['ID'] . '</span>';
|
416 |
+
|
417 |
+
return $actions;
|
418 |
+
|
419 |
+
}
|
420 |
+
|
421 |
+
/**
|
422 |
+
* Sidebar
|
423 |
+
*/
|
424 |
+
add_action('current_screen', function(){
|
425 |
+
|
426 |
+
if(!acf_is_screen('edit-acf-field-group'))
|
427 |
+
return;
|
428 |
+
|
429 |
+
add_action('admin_footer', function(){
|
430 |
+
?>
|
431 |
+
|
432 |
+
<!-- ACFE: Label -->
|
433 |
+
<script type="text/html" id="tmpl-acfe-label">
|
434 |
+
<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>
|
435 |
+
</script>
|
436 |
+
|
437 |
+
<!-- ACFE: Debug -->
|
438 |
+
<script type="text/html" id="tmpl-acfe-debug">
|
439 |
+
<div class="acf-box">
|
440 |
+
</div>
|
441 |
+
</script>
|
442 |
+
|
443 |
+
<script type="text/javascript">
|
444 |
+
(function($){
|
445 |
+
|
446 |
+
// ACFE: Label
|
447 |
+
$('.acf-column-2 > .acf-box > .inner > h2').append($('#tmpl-acfe-label').html());
|
448 |
+
|
449 |
+
// ACFE: Debug
|
450 |
+
//$('#posts-filter').append($('#tmpl-acfe-debug').html());
|
451 |
+
|
452 |
+
// Fix no field groups found
|
453 |
+
$('#the-list tr.no-items td').attr('colspan', 9);
|
454 |
+
|
455 |
+
})(jQuery);
|
456 |
+
</script>
|
457 |
+
<?php
|
458 |
+
});
|
459 |
+
|
460 |
+
});
|
461 |
+
|
462 |
+
/**
|
463 |
+
* Hooks: Posts per page
|
464 |
+
*/
|
465 |
+
add_filter('edit_acf-field-group_per_page', 'acfe_field_groups_posts_per_page');
|
466 |
+
function acfe_field_groups_posts_per_page(){
|
467 |
+
|
468 |
+
return 999;
|
469 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
470 |
}
|
includes/fields-settings/bidirectional.php
CHANGED
@@ -1,606 +1,608 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Field Setting
|
8 |
-
*/
|
9 |
-
add_action('acf/render_field_settings/type=relationship', 'acfe_bidirectional_settings');
|
10 |
-
add_action('acf/render_field_settings/type=post_object', 'acfe_bidirectional_settings');
|
11 |
-
add_action('acf/render_field_settings/type=user', 'acfe_bidirectional_settings');
|
12 |
-
add_action('acf/render_field_settings/type=taxonomy', 'acfe_bidirectional_settings');
|
13 |
-
function acfe_bidirectional_settings($field){
|
14 |
-
|
15 |
-
// Settings
|
16 |
-
acf_render_field_setting($field, array(
|
17 |
-
'label' => __('Bidirectional'),
|
18 |
-
'key' => 'acfe_bidirectional',
|
19 |
-
'name' => 'acfe_bidirectional',
|
20 |
-
'instructions' => __('Set the field as bidirectional'),
|
21 |
-
'type' => 'group',
|
22 |
-
'required' => false,
|
23 |
-
'conditional_logic' => false,
|
24 |
-
'wrapper' => array(
|
25 |
-
'width' => '',
|
26 |
-
'class' => '',
|
27 |
-
'id' => '',
|
28 |
-
),
|
29 |
-
'layout' => 'block',
|
30 |
-
'sub_fields' => array(
|
31 |
-
array(
|
32 |
-
'label' => false,
|
33 |
-
'key' => 'acfe_bidirectional_enabled',
|
34 |
-
'name' => 'acfe_bidirectional_enabled',
|
35 |
-
'type' => 'true_false',
|
36 |
-
'instructions' => '',
|
37 |
-
'required' => false,
|
38 |
-
'wrapper' => array(
|
39 |
-
'width' => '15',
|
40 |
-
'class' => 'acfe_width_auto',
|
41 |
-
'id' => '',
|
42 |
-
),
|
43 |
-
'message' => '',
|
44 |
-
'default_value' => false,
|
45 |
-
'ui' => true,
|
46 |
-
'ui_on_text' => '',
|
47 |
-
'ui_off_text' => '',
|
48 |
-
'conditional_logic' => false,
|
49 |
-
),
|
50 |
-
array(
|
51 |
-
'label' => false,
|
52 |
-
'key' => 'acfe_bidirectional_related',
|
53 |
-
'name' => 'acfe_bidirectional_related',
|
54 |
-
'type' => 'select',
|
55 |
-
'instructions' => '',
|
56 |
-
'required' => false,
|
57 |
-
'wrapper' => array(
|
58 |
-
'width' => 50,
|
59 |
-
'class' => '',
|
60 |
-
'id' => '',
|
61 |
-
),
|
62 |
-
'choices' => array(),
|
63 |
-
'default_value' => array(),
|
64 |
-
'allow_null' => 1,
|
65 |
-
'multiple' => 0,
|
66 |
-
'ui' => 1,
|
67 |
-
'ajax' => 1,
|
68 |
-
'return_format' => 'value',
|
69 |
-
'placeholder' => '',
|
70 |
-
'conditional_logic' => array(
|
71 |
-
array(
|
72 |
-
array(
|
73 |
-
'field' => 'acfe_bidirectional_enabled',
|
74 |
-
'operator' => '==',
|
75 |
-
'value' => '1',
|
76 |
-
),
|
77 |
-
),
|
78 |
-
),
|
79 |
-
),
|
80 |
-
),
|
81 |
-
));
|
82 |
-
|
83 |
-
}
|
84 |
-
|
85 |
-
/**
|
86 |
-
* Field Setting: Ajax Handler
|
87 |
-
*/
|
88 |
-
add_action('wp_ajax_acf/fields/select/query', 'acfe_bidirectional_ajax', 0);
|
89 |
-
add_action('wp_ajax_nopriv_acf/fields/select/query', 'acfe_bidirectional_ajax', 0);
|
90 |
-
function acfe_bidirectional_ajax(){
|
91 |
-
|
92 |
-
// Do not die to let ACF handle others ajax requests
|
93 |
-
if(!acf_verify_ajax())
|
94 |
-
return;
|
95 |
-
|
96 |
-
$options = acf_parse_args($_POST, array(
|
97 |
-
'post_id' => 0,
|
98 |
-
's' => '',
|
99 |
-
'field_key' => '',
|
100 |
-
'paged' => 1
|
101 |
-
));
|
102 |
-
|
103 |
-
// Not our field setting. Stop
|
104 |
-
if($options['field_key'] !== 'acfe_bidirectional_related')
|
105 |
-
return;
|
106 |
-
|
107 |
-
$response = acfe_bidirectional_ajax_query($options);
|
108 |
-
|
109 |
-
acf_send_ajax_results($response);
|
110 |
-
|
111 |
-
}
|
112 |
-
|
113 |
-
/**
|
114 |
-
* Field Setting: Ajax Query
|
115 |
-
*/
|
116 |
-
function acfe_bidirectional_ajax_query($options = array()){
|
117 |
-
|
118 |
-
// Current field group
|
119 |
-
$field_group = acf_get_field_group($options['post_id']);
|
120 |
-
|
121 |
-
acf_disable_filters();
|
122 |
-
|
123 |
-
// Get field groups
|
124 |
-
$r_field_groups = acf_get_field_groups();
|
125 |
-
if(empty($r_field_groups))
|
126 |
-
return false;
|
127 |
-
|
128 |
-
$choices = array();
|
129 |
-
|
130 |
-
foreach($r_field_groups as $r_field_group){
|
131 |
-
|
132 |
-
// Bypass current field group
|
133 |
-
if($r_field_group['key'] === $field_group['key'])
|
134 |
-
continue;
|
135 |
-
|
136 |
-
// Bypass ACFE native groups
|
137 |
-
if(in_array($r_field_group['key'], array('group_acfe_author', 'group_acfe_dynamic_post_type', 'group_acfe_dynamic_taxonomy')))
|
138 |
-
continue;
|
139 |
-
|
140 |
-
// Get related fields
|
141 |
-
$r_fields = acf_get_fields($r_field_group['key']);
|
142 |
-
if(empty($r_fields))
|
143 |
-
continue;
|
144 |
-
|
145 |
-
// Filter & find possible related fields
|
146 |
-
foreach($r_fields as $r_field){
|
147 |
-
|
148 |
-
acfe_bidirectional_setting_find_related($r_field, $r_field_group, $choices);
|
149 |
-
|
150 |
-
}
|
151 |
-
|
152 |
-
}
|
153 |
-
|
154 |
-
// vars
|
155 |
-
$results = array();
|
156 |
-
$s = null;
|
157 |
-
|
158 |
-
if(!empty($choices)){
|
159 |
-
|
160 |
-
// search
|
161 |
-
if($options['s'] !== ''){
|
162 |
-
|
163 |
-
// strip slashes (search may be integer)
|
164 |
-
$s = strval($options['s']);
|
165 |
-
$s = wp_unslash($s);
|
166 |
-
|
167 |
-
}
|
168 |
-
|
169 |
-
foreach($choices as $field_group_title => $childs){
|
170 |
-
|
171 |
-
$field_group_title = strval($field_group_title);
|
172 |
-
|
173 |
-
$childrens = array();
|
174 |
-
foreach($childs as $child_key => $child_label){
|
175 |
-
|
176 |
-
$child_label = strval($child_label);
|
177 |
-
|
178 |
-
// if searching, but doesn't exist
|
179 |
-
if(is_string($s) && stripos($child_label, $s) === false && stripos($field_group_title, $s) === false)
|
180 |
-
continue(2);
|
181 |
-
|
182 |
-
$childrens[] = array(
|
183 |
-
'id' => $child_key,
|
184 |
-
'text' => $child_label,
|
185 |
-
);
|
186 |
-
|
187 |
-
}
|
188 |
-
|
189 |
-
$results[] = array(
|
190 |
-
'text' => $field_group_title,
|
191 |
-
'children' => $childrens
|
192 |
-
);
|
193 |
-
|
194 |
-
}
|
195 |
-
|
196 |
-
}
|
197 |
-
|
198 |
-
return array(
|
199 |
-
'results' => $results
|
200 |
-
);
|
201 |
-
|
202 |
-
}
|
203 |
-
|
204 |
-
function acfe_bidirectional_setting_find_related($r_field, $r_field_group, &$choices){
|
205 |
-
|
206 |
-
if(in_array($r_field['type'], array('repeater', 'flexible_content')))
|
207 |
-
return;
|
208 |
-
|
209 |
-
// Recursive search for sub_fields (groups & clones)
|
210 |
-
if(isset($r_field['sub_fields']) && !empty($r_field['sub_fields'])){
|
211 |
-
|
212 |
-
foreach($r_field['sub_fields'] as $r_sub_field){
|
213 |
-
|
214 |
-
// Recursive call
|
215 |
-
|
216 |
-
|
217 |
-
}
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
$
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
add_filter('acf/update_field/type=
|
267 |
-
add_filter('acf/update_field/type=
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
add_filter('acf/delete_field/type=
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
add_filter('acf/update_value/type=
|
353 |
-
add_filter('acf/update_value/type=
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
//
|
374 |
-
|
375 |
-
//
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
$force_update =
|
402 |
-
$force_update = apply_filters('acfe/bidirectional/force_update
|
403 |
-
$force_update = apply_filters('acfe/bidirectional/force_update/
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
*
|
426 |
-
*
|
427 |
-
* $
|
428 |
-
* $
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
$r_mtype = '
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
*
|
543 |
-
*
|
544 |
-
*
|
545 |
-
*
|
546 |
-
*
|
547 |
-
*
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
}
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
|
|
|
|
606 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Field Setting
|
8 |
+
*/
|
9 |
+
add_action('acf/render_field_settings/type=relationship', 'acfe_bidirectional_settings');
|
10 |
+
add_action('acf/render_field_settings/type=post_object', 'acfe_bidirectional_settings');
|
11 |
+
add_action('acf/render_field_settings/type=user', 'acfe_bidirectional_settings');
|
12 |
+
add_action('acf/render_field_settings/type=taxonomy', 'acfe_bidirectional_settings');
|
13 |
+
function acfe_bidirectional_settings($field){
|
14 |
+
|
15 |
+
// Settings
|
16 |
+
acf_render_field_setting($field, array(
|
17 |
+
'label' => __('Bidirectional'),
|
18 |
+
'key' => 'acfe_bidirectional',
|
19 |
+
'name' => 'acfe_bidirectional',
|
20 |
+
'instructions' => __('Set the field as bidirectional'),
|
21 |
+
'type' => 'group',
|
22 |
+
'required' => false,
|
23 |
+
'conditional_logic' => false,
|
24 |
+
'wrapper' => array(
|
25 |
+
'width' => '',
|
26 |
+
'class' => '',
|
27 |
+
'id' => '',
|
28 |
+
),
|
29 |
+
'layout' => 'block',
|
30 |
+
'sub_fields' => array(
|
31 |
+
array(
|
32 |
+
'label' => false,
|
33 |
+
'key' => 'acfe_bidirectional_enabled',
|
34 |
+
'name' => 'acfe_bidirectional_enabled',
|
35 |
+
'type' => 'true_false',
|
36 |
+
'instructions' => '',
|
37 |
+
'required' => false,
|
38 |
+
'wrapper' => array(
|
39 |
+
'width' => '15',
|
40 |
+
'class' => 'acfe_width_auto',
|
41 |
+
'id' => '',
|
42 |
+
),
|
43 |
+
'message' => '',
|
44 |
+
'default_value' => false,
|
45 |
+
'ui' => true,
|
46 |
+
'ui_on_text' => '',
|
47 |
+
'ui_off_text' => '',
|
48 |
+
'conditional_logic' => false,
|
49 |
+
),
|
50 |
+
array(
|
51 |
+
'label' => false,
|
52 |
+
'key' => 'acfe_bidirectional_related',
|
53 |
+
'name' => 'acfe_bidirectional_related',
|
54 |
+
'type' => 'select',
|
55 |
+
'instructions' => '',
|
56 |
+
'required' => false,
|
57 |
+
'wrapper' => array(
|
58 |
+
'width' => 50,
|
59 |
+
'class' => '',
|
60 |
+
'id' => '',
|
61 |
+
),
|
62 |
+
'choices' => array(),
|
63 |
+
'default_value' => array(),
|
64 |
+
'allow_null' => 1,
|
65 |
+
'multiple' => 0,
|
66 |
+
'ui' => 1,
|
67 |
+
'ajax' => 1,
|
68 |
+
'return_format' => 'value',
|
69 |
+
'placeholder' => '',
|
70 |
+
'conditional_logic' => array(
|
71 |
+
array(
|
72 |
+
array(
|
73 |
+
'field' => 'acfe_bidirectional_enabled',
|
74 |
+
'operator' => '==',
|
75 |
+
'value' => '1',
|
76 |
+
),
|
77 |
+
),
|
78 |
+
),
|
79 |
+
),
|
80 |
+
),
|
81 |
+
));
|
82 |
+
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Field Setting: Ajax Handler
|
87 |
+
*/
|
88 |
+
add_action('wp_ajax_acf/fields/select/query', 'acfe_bidirectional_ajax', 0);
|
89 |
+
add_action('wp_ajax_nopriv_acf/fields/select/query', 'acfe_bidirectional_ajax', 0);
|
90 |
+
function acfe_bidirectional_ajax(){
|
91 |
+
|
92 |
+
// Do not die to let ACF handle others ajax requests
|
93 |
+
if(!acf_verify_ajax())
|
94 |
+
return;
|
95 |
+
|
96 |
+
$options = acf_parse_args($_POST, array(
|
97 |
+
'post_id' => 0,
|
98 |
+
's' => '',
|
99 |
+
'field_key' => '',
|
100 |
+
'paged' => 1
|
101 |
+
));
|
102 |
+
|
103 |
+
// Not our field setting. Stop
|
104 |
+
if($options['field_key'] !== 'acfe_bidirectional_related')
|
105 |
+
return;
|
106 |
+
|
107 |
+
$response = acfe_bidirectional_ajax_query($options);
|
108 |
+
|
109 |
+
acf_send_ajax_results($response);
|
110 |
+
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Field Setting: Ajax Query
|
115 |
+
*/
|
116 |
+
function acfe_bidirectional_ajax_query($options = array()){
|
117 |
+
|
118 |
+
// Current field group
|
119 |
+
$field_group = acf_get_field_group($options['post_id']);
|
120 |
+
|
121 |
+
acf_disable_filters();
|
122 |
+
|
123 |
+
// Get field groups
|
124 |
+
$r_field_groups = acf_get_field_groups();
|
125 |
+
if(empty($r_field_groups))
|
126 |
+
return false;
|
127 |
+
|
128 |
+
$choices = array();
|
129 |
+
|
130 |
+
foreach($r_field_groups as $r_field_group){
|
131 |
+
|
132 |
+
// Bypass current field group
|
133 |
+
if($r_field_group['key'] === $field_group['key'])
|
134 |
+
continue;
|
135 |
+
|
136 |
+
// Bypass ACFE native groups
|
137 |
+
if(in_array($r_field_group['key'], array('group_acfe_author', 'group_acfe_dynamic_post_type', 'group_acfe_dynamic_taxonomy')))
|
138 |
+
continue;
|
139 |
+
|
140 |
+
// Get related fields
|
141 |
+
$r_fields = acf_get_fields($r_field_group['key']);
|
142 |
+
if(empty($r_fields))
|
143 |
+
continue;
|
144 |
+
|
145 |
+
// Filter & find possible related fields
|
146 |
+
foreach($r_fields as $r_field){
|
147 |
+
|
148 |
+
acfe_bidirectional_setting_find_related($r_field, $r_field_group, $choices);
|
149 |
+
|
150 |
+
}
|
151 |
+
|
152 |
+
}
|
153 |
+
|
154 |
+
// vars
|
155 |
+
$results = array();
|
156 |
+
$s = null;
|
157 |
+
|
158 |
+
if(!empty($choices)){
|
159 |
+
|
160 |
+
// search
|
161 |
+
if($options['s'] !== ''){
|
162 |
+
|
163 |
+
// strip slashes (search may be integer)
|
164 |
+
$s = strval($options['s']);
|
165 |
+
$s = wp_unslash($s);
|
166 |
+
|
167 |
+
}
|
168 |
+
|
169 |
+
foreach($choices as $field_group_title => $childs){
|
170 |
+
|
171 |
+
$field_group_title = strval($field_group_title);
|
172 |
+
|
173 |
+
$childrens = array();
|
174 |
+
foreach($childs as $child_key => $child_label){
|
175 |
+
|
176 |
+
$child_label = strval($child_label);
|
177 |
+
|
178 |
+
// if searching, but doesn't exist
|
179 |
+
if(is_string($s) && stripos($child_label, $s) === false && stripos($field_group_title, $s) === false)
|
180 |
+
continue(2);
|
181 |
+
|
182 |
+
$childrens[] = array(
|
183 |
+
'id' => $child_key,
|
184 |
+
'text' => $child_label,
|
185 |
+
);
|
186 |
+
|
187 |
+
}
|
188 |
+
|
189 |
+
$results[] = array(
|
190 |
+
'text' => $field_group_title,
|
191 |
+
'children' => $childrens
|
192 |
+
);
|
193 |
+
|
194 |
+
}
|
195 |
+
|
196 |
+
}
|
197 |
+
|
198 |
+
return array(
|
199 |
+
'results' => $results
|
200 |
+
);
|
201 |
+
|
202 |
+
}
|
203 |
+
|
204 |
+
function acfe_bidirectional_setting_find_related($r_field, $r_field_group, &$choices){
|
205 |
+
|
206 |
+
if(in_array($r_field['type'], array('repeater', 'flexible_content')))
|
207 |
+
return;
|
208 |
+
|
209 |
+
// Recursive search for sub_fields (groups & clones)
|
210 |
+
if(isset($r_field['sub_fields']) && !empty($r_field['sub_fields'])){
|
211 |
+
|
212 |
+
foreach($r_field['sub_fields'] as $r_sub_field){
|
213 |
+
|
214 |
+
// Recursive call
|
215 |
+
acfe_bidirectional_setting_find_related($r_sub_field, $r_field_group, $choices);
|
216 |
+
|
217 |
+
}
|
218 |
+
|
219 |
+
return;
|
220 |
+
|
221 |
+
}
|
222 |
+
|
223 |
+
// Allow only specific fields
|
224 |
+
$allowed_fields_types = array('relationship', 'post_object', 'user', 'taxonomy');
|
225 |
+
if(!in_array($r_field['type'], $allowed_fields_types))
|
226 |
+
return false;
|
227 |
+
|
228 |
+
$choices[$r_field_group['title']][$r_field['key']] = (!empty($r_field['label']) ? $r_field['label'] : $r_field['name']) . ' (' . $r_field['key'] . ')';
|
229 |
+
|
230 |
+
}
|
231 |
+
|
232 |
+
/**
|
233 |
+
* Field Setting: Default Value
|
234 |
+
*/
|
235 |
+
add_filter('acf/prepare_field/name=acfe_bidirectional_related', 'acfe_bidirectional_setting_value');
|
236 |
+
function acfe_bidirectional_setting_value($field){
|
237 |
+
|
238 |
+
if(!isset($field['value']) || empty($field['value']))
|
239 |
+
return $field;
|
240 |
+
|
241 |
+
// Get related field
|
242 |
+
$r_field = acf_get_field($field['value']);
|
243 |
+
|
244 |
+
// Related field not found
|
245 |
+
if(!$r_field){
|
246 |
+
|
247 |
+
// Unset & updatevalue
|
248 |
+
$field['value'] = false;
|
249 |
+
acf_update_field($field);
|
250 |
+
|
251 |
+
return $field;
|
252 |
+
|
253 |
+
}
|
254 |
+
|
255 |
+
$r_field_group = acfe_get_field_group_from_field($r_field);
|
256 |
+
|
257 |
+
$field['choices'] = array($r_field['key'] => (!empty($r_field['label']) ? $r_field['label'] : $r_field['name']) . ' (' . $r_field['key'] . ')');
|
258 |
+
|
259 |
+
return $field;
|
260 |
+
|
261 |
+
}
|
262 |
+
|
263 |
+
/**
|
264 |
+
* Field Setting Update
|
265 |
+
*/
|
266 |
+
add_filter('acf/update_field/type=relationship', 'acfe_bidirectional_setting_update');
|
267 |
+
add_filter('acf/update_field/type=post_object', 'acfe_bidirectional_setting_update');
|
268 |
+
add_filter('acf/update_field/type=user', 'acfe_bidirectional_setting_update');
|
269 |
+
add_filter('acf/update_field/type=taxonomy', 'acfe_bidirectional_setting_update');
|
270 |
+
function acfe_bidirectional_setting_update($field){
|
271 |
+
|
272 |
+
$do_update = apply_filters('acfe/bidirectional/setting/update', true);
|
273 |
+
if(!$do_update)
|
274 |
+
return $field;
|
275 |
+
|
276 |
+
// Previous setting values
|
277 |
+
$_field = acf_get_field($field['key']);
|
278 |
+
|
279 |
+
// Turning off - Remove related field
|
280 |
+
if(acfe_has_field_bidirectional($_field) && !acfe_has_field_bidirectional($field)){
|
281 |
+
|
282 |
+
// Get related bidirectional related
|
283 |
+
$r_field = acf_get_field($_field['acfe_bidirectional']['acfe_bidirectional_related']);
|
284 |
+
|
285 |
+
// Reset related bidirectional related
|
286 |
+
$r_field['acfe_bidirectional']['acfe_bidirectional_enabled'] = false;
|
287 |
+
$r_field['acfe_bidirectional']['acfe_bidirectional_related'] = false;
|
288 |
+
|
289 |
+
add_filter('acfe/bidirectional/setting/update', '__return_false');
|
290 |
+
|
291 |
+
// Update related bidirectional
|
292 |
+
acf_update_field($r_field);
|
293 |
+
|
294 |
+
remove_filter('acfe/bidirectional/setting/update', '__return_false');
|
295 |
+
|
296 |
+
return $field;
|
297 |
+
|
298 |
+
}
|
299 |
+
|
300 |
+
// Turning on - Add related field
|
301 |
+
elseif(!acfe_has_field_bidirectional($_field) && acfe_has_field_bidirectional($field)){
|
302 |
+
|
303 |
+
// Get related bidirectional related
|
304 |
+
$r_field = acf_get_field($field['acfe_bidirectional']['acfe_bidirectional_related']);
|
305 |
+
|
306 |
+
// Reset related bidirectional related
|
307 |
+
$r_field['acfe_bidirectional']['acfe_bidirectional_enabled'] = true;
|
308 |
+
$r_field['acfe_bidirectional']['acfe_bidirectional_related'] = $field['key'];
|
309 |
+
|
310 |
+
add_filter('acfe/bidirectional/setting/update', '__return_false');
|
311 |
+
|
312 |
+
// Update related bidirectional
|
313 |
+
acf_update_field($r_field);
|
314 |
+
|
315 |
+
remove_filter('acfe/bidirectional/setting/update', '__return_false');
|
316 |
+
|
317 |
+
return $field;
|
318 |
+
|
319 |
+
}
|
320 |
+
|
321 |
+
// Return
|
322 |
+
return $field;
|
323 |
+
|
324 |
+
}
|
325 |
+
|
326 |
+
/**
|
327 |
+
* Field Setting Deleted
|
328 |
+
*/
|
329 |
+
add_action('acf/delete_field/type=relationship', 'acfe_bidirectional_setting_delete');
|
330 |
+
add_filter('acf/delete_field/type=post_object', 'acfe_bidirectional_setting_delete');
|
331 |
+
add_filter('acf/delete_field/type=user', 'acfe_bidirectional_setting_delete');
|
332 |
+
add_filter('acf/delete_field/type=taxonomy', 'acfe_bidirectional_setting_delete');
|
333 |
+
function acfe_bidirectional_setting_delete($field){
|
334 |
+
|
335 |
+
if(!acfe_has_field_bidirectional($field))
|
336 |
+
return;
|
337 |
+
|
338 |
+
// Get related bidirectional related
|
339 |
+
$r_field = acf_get_field($field['acfe_bidirectional']['acfe_bidirectional_related']);
|
340 |
+
|
341 |
+
// Reset related bidirectional related
|
342 |
+
$r_field['acfe_bidirectional']['acfe_bidirectional_related'] = false;
|
343 |
+
|
344 |
+
// Update related bidirectional
|
345 |
+
acf_update_field($r_field);
|
346 |
+
|
347 |
+
}
|
348 |
+
|
349 |
+
/**
|
350 |
+
* Update Value
|
351 |
+
*/
|
352 |
+
add_filter('acf/update_value/type=relationship', 'acfe_bidirectional_update_value', 11, 3);
|
353 |
+
add_filter('acf/update_value/type=post_object', 'acfe_bidirectional_update_value', 11, 3);
|
354 |
+
add_filter('acf/update_value/type=user', 'acfe_bidirectional_update_value', 11, 3);
|
355 |
+
add_filter('acf/update_value/type=taxonomy', 'acfe_bidirectional_update_value', 11, 3);
|
356 |
+
function acfe_bidirectional_update_value($value, $post_id, $field){
|
357 |
+
|
358 |
+
$ignore = apply_filters('acfe/bidirectional/ignore', false, $value, $post_id, $field);
|
359 |
+
if($ignore)
|
360 |
+
return $value;
|
361 |
+
|
362 |
+
// Check if bidirectional
|
363 |
+
if(!acfe_get_field_bidirectional($field))
|
364 |
+
return $value;
|
365 |
+
|
366 |
+
// Decode current post_id (ie: user_1)
|
367 |
+
$request = acf_decode_post_id($post_id);
|
368 |
+
|
369 |
+
// Values
|
370 |
+
$old_values = acf_get_array(acf_get_metadata($post_id, $field['name']));
|
371 |
+
$new_values = acf_get_array($value);
|
372 |
+
|
373 |
+
// Bail early if no difference
|
374 |
+
// if($old_values === $new_values)
|
375 |
+
// return $value;
|
376 |
+
|
377 |
+
// Values have been removed
|
378 |
+
if(!empty($old_values)){
|
379 |
+
foreach($old_values as $r_id){
|
380 |
+
|
381 |
+
if(in_array($r_id, $new_values))
|
382 |
+
continue;
|
383 |
+
|
384 |
+
acfe_bidirectional_relationship('remove', $r_id, $field, $request['id']);
|
385 |
+
|
386 |
+
}
|
387 |
+
}
|
388 |
+
|
389 |
+
// Values have been added
|
390 |
+
if(!empty($new_values)){
|
391 |
+
foreach($new_values as $r_id){
|
392 |
+
|
393 |
+
if(in_array($r_id, $old_values))
|
394 |
+
continue;
|
395 |
+
|
396 |
+
acfe_bidirectional_relationship('add', $r_id, $field, $request['id']);
|
397 |
+
|
398 |
+
}
|
399 |
+
}
|
400 |
+
|
401 |
+
$force_update = false;
|
402 |
+
$force_update = apply_filters('acfe/bidirectional/force_update', $force_update, $field, $post_id);
|
403 |
+
$force_update = apply_filters('acfe/bidirectional/force_update/type=' . $field['type'], $force_update, $field, $post_id);
|
404 |
+
$force_update = apply_filters('acfe/bidirectional/force_update/name=' . $field['name'], $force_update, $field, $post_id);
|
405 |
+
$force_update = apply_filters('acfe/bidirectional/force_update/key=' . $field['key'], $force_update, $field, $post_id);
|
406 |
+
|
407 |
+
if($force_update){
|
408 |
+
|
409 |
+
// Force new values to be saved
|
410 |
+
if(!empty($new_values)){
|
411 |
+
foreach($new_values as $r_id){
|
412 |
+
|
413 |
+
acfe_bidirectional_relationship('add', $r_id, $field, $request['id']);
|
414 |
+
|
415 |
+
}
|
416 |
+
}
|
417 |
+
|
418 |
+
}
|
419 |
+
|
420 |
+
return $value;
|
421 |
+
|
422 |
+
}
|
423 |
+
|
424 |
+
/**
|
425 |
+
* Establish Relationship
|
426 |
+
*
|
427 |
+
* $type: add|remove
|
428 |
+
* $r_id: the post_id to add the relationship to
|
429 |
+
* $p_field: the parent field
|
430 |
+
* $p_id: the relationship to add
|
431 |
+
*/
|
432 |
+
function acfe_bidirectional_relationship($type = 'add', $r_id, $p_field, $p_value){
|
433 |
+
|
434 |
+
// Get Related Field Configuration
|
435 |
+
$r_field = acf_get_field($p_field['acfe_bidirectional']['acfe_bidirectional_related']);
|
436 |
+
|
437 |
+
// Get if bidirectional is active
|
438 |
+
if(!acfe_get_field_bidirectional($r_field))
|
439 |
+
return;
|
440 |
+
|
441 |
+
// Get Related Data Type ({post_id}, user_{id} ...)
|
442 |
+
$r_mtype = '';
|
443 |
+
if($p_field['type'] === 'user')
|
444 |
+
$r_mtype = 'user_';
|
445 |
+
elseif($p_field['type'] === 'taxonomy')
|
446 |
+
$r_mtype = 'term_';
|
447 |
+
|
448 |
+
// Get Related Field Ancestors
|
449 |
+
$r_field_ancestors = acf_get_field_ancestors($r_field);
|
450 |
+
|
451 |
+
// Ancestors - Complexe field (group|clone)
|
452 |
+
if(!empty($r_field_ancestors)){
|
453 |
+
|
454 |
+
// Get ancestors
|
455 |
+
$r_field_ancestors = array_reverse($r_field_ancestors);
|
456 |
+
$r_field_ancestors_fields = array_map('acf_get_field', $r_field_ancestors);
|
457 |
+
|
458 |
+
// Get top ancestor
|
459 |
+
$r_ref_field = $r_field_ancestors_fields[0];
|
460 |
+
$r_ref_values = acf_get_array(acf_get_value($r_mtype.$r_id, $r_ref_field));
|
461 |
+
|
462 |
+
// Get values
|
463 |
+
$r_values = acf_get_array(acfe_get_value_from_ancestor($r_ref_values, $r_field));
|
464 |
+
|
465 |
+
// Unset top ancestor for update (not needed)
|
466 |
+
unset($r_field_ancestors_fields[0]);
|
467 |
+
|
468 |
+
// Add related field to get
|
469 |
+
$r_values_query = array($r_field['key']);
|
470 |
+
|
471 |
+
// If > 1 ancestors, return ancestors keys only
|
472 |
+
if(!empty($r_field_ancestors_fields)){
|
473 |
+
|
474 |
+
$r_field_ancestors_keys = array_map(function($field){
|
475 |
+
return $field['key'];
|
476 |
+
}, $r_field_ancestors_fields);
|
477 |
+
|
478 |
+
// Add ancestors to get
|
479 |
+
$r_values_query = array_merge($r_field_ancestors_keys, $r_values_query);
|
480 |
+
|
481 |
+
}
|
482 |
+
|
483 |
+
}
|
484 |
+
|
485 |
+
// No Ancestors - Simple field
|
486 |
+
else{
|
487 |
+
|
488 |
+
// Refence field
|
489 |
+
$r_ref_field = $r_field;
|
490 |
+
|
491 |
+
// Values
|
492 |
+
$r_values = acf_get_array(acf_get_value($r_mtype.$r_id, $r_field));
|
493 |
+
|
494 |
+
}
|
495 |
+
|
496 |
+
// Convert strings to integers
|
497 |
+
$r_values = acf_parse_types($r_values);
|
498 |
+
|
499 |
+
// Add Value
|
500 |
+
if($type === 'add'){
|
501 |
+
|
502 |
+
if(!in_array($p_value, $r_values))
|
503 |
+
$r_values[] = $p_value;
|
504 |
+
|
505 |
+
}
|
506 |
+
|
507 |
+
// Remove Value
|
508 |
+
elseif($type === 'remove'){
|
509 |
+
|
510 |
+
$r_new_values = array();
|
511 |
+
foreach($r_values as $r_value){
|
512 |
+
|
513 |
+
if($r_value === $p_value)
|
514 |
+
continue;
|
515 |
+
|
516 |
+
$r_new_values[] = $r_value;
|
517 |
+
|
518 |
+
}
|
519 |
+
|
520 |
+
$r_values = $r_new_values;
|
521 |
+
|
522 |
+
}
|
523 |
+
|
524 |
+
/*
|
525 |
+
* Post Object & User 'Allow Multiple' Disabled
|
526 |
+
* Value must not be inside array
|
527 |
+
*/
|
528 |
+
if(($r_ref_field['type'] === 'post_object' || $r_ref_field['type'] === 'user') && empty($r_ref_field['multiple']) && isset($r_values[0])){
|
529 |
+
|
530 |
+
// Get latest value
|
531 |
+
$r_values = end($r_values);
|
532 |
+
|
533 |
+
}
|
534 |
+
|
535 |
+
/*
|
536 |
+
* Remove potential empty serialized array in meta value 'a:0:{}'
|
537 |
+
*/
|
538 |
+
if(empty($r_values))
|
539 |
+
$r_values = false;
|
540 |
+
|
541 |
+
/*
|
542 |
+
* Construct a value array in case of ancestors. ie:
|
543 |
+
* $related_values = Array(
|
544 |
+
* [field_aaa] => Array(
|
545 |
+
* [field_bbb] => Array(
|
546 |
+
* [0] => xxxx
|
547 |
+
* )
|
548 |
+
* )
|
549 |
+
* )
|
550 |
+
*/
|
551 |
+
if(!empty($r_field_ancestors)){
|
552 |
+
|
553 |
+
for($i = count($r_values_query)-1; $i>=0; $i--){
|
554 |
+
$r_values = array($r_values_query[$i] => $r_values);
|
555 |
+
}
|
556 |
+
|
557 |
+
}
|
558 |
+
|
559 |
+
// Filter acf_update_value (to avoid infinite loop)
|
560 |
+
add_filter('acfe/bidirectional/ignore', '__return_true');
|
561 |
+
|
562 |
+
// Update Related Field
|
563 |
+
acf_update_value($r_values, $r_mtype.$r_id, $r_ref_field);
|
564 |
+
|
565 |
+
// Remove acf_update_value filter
|
566 |
+
remove_filter('acfe/bidirectional/ignore', '__return_true');
|
567 |
+
|
568 |
+
}
|
569 |
+
|
570 |
+
function acfe_get_value_from_ancestor($r_ref_values, $r_field){
|
571 |
+
|
572 |
+
foreach($r_ref_values as $r_ref_key => $r_ref_value){
|
573 |
+
|
574 |
+
if($r_ref_key != $r_field['key']){
|
575 |
+
|
576 |
+
if(is_array($r_ref_value))
|
577 |
+
return acfe_get_value_from_ancestor($r_ref_value, $r_field);
|
578 |
+
|
579 |
+
return false;
|
580 |
+
|
581 |
+
}
|
582 |
+
|
583 |
+
return $r_ref_value;
|
584 |
+
|
585 |
+
}
|
586 |
+
|
587 |
+
}
|
588 |
+
|
589 |
+
function acfe_is_field_bidirectional($field){
|
590 |
+
|
591 |
+
return isset($field['acfe_bidirectional']['acfe_bidirectional_enabled']) && !empty($field['acfe_bidirectional']['acfe_bidirectional_enabled']);
|
592 |
+
|
593 |
+
}
|
594 |
+
|
595 |
+
function acfe_has_field_bidirectional($field){
|
596 |
+
|
597 |
+
return isset($field['acfe_bidirectional']['acfe_bidirectional_related']) && !empty($field['acfe_bidirectional']['acfe_bidirectional_related']);
|
598 |
+
|
599 |
+
}
|
600 |
+
|
601 |
+
function acfe_get_field_bidirectional($field){
|
602 |
+
|
603 |
+
if(!acfe_is_field_bidirectional($field) || !acfe_has_field_bidirectional($field))
|
604 |
+
return false;
|
605 |
+
|
606 |
+
return $field['acfe_bidirectional']['acfe_bidirectional_related'];
|
607 |
+
|
608 |
}
|
includes/fields/field-advanced-link.php
CHANGED
@@ -1,320 +1,338 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
if(!class_exists('acfe_field_advanced_link')):
|
7 |
-
|
8 |
-
class acfe_field_advanced_link extends acf_field{
|
9 |
-
|
10 |
-
function __construct(){
|
11 |
-
|
12 |
-
$this->name = 'acfe_advanced_link';
|
13 |
-
$this->label = __('Advanced Link', 'acfe');
|
14 |
-
$this->category = 'relational';
|
15 |
-
$this->defaults = array(
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
'name'
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
'
|
94 |
-
'
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
$
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
//
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
$
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
'
|
187 |
-
'
|
188 |
-
'
|
189 |
-
'
|
190 |
-
'
|
191 |
-
'
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
'
|
205 |
-
'
|
206 |
-
'
|
207 |
-
'
|
208 |
-
'
|
209 |
-
'
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
'
|
226 |
-
'
|
227 |
-
'
|
228 |
-
'
|
229 |
-
'
|
230 |
-
'
|
231 |
-
'
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
'
|
244 |
-
'
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
<
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
//
|
307 |
-
if(empty($value)
|
308 |
-
|
309 |
-
|
310 |
-
//
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
320 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
if(!class_exists('acfe_field_advanced_link')):
|
7 |
+
|
8 |
+
class acfe_field_advanced_link extends acf_field{
|
9 |
+
|
10 |
+
function __construct(){
|
11 |
+
|
12 |
+
$this->name = 'acfe_advanced_link';
|
13 |
+
$this->label = __('Advanced Link', 'acfe');
|
14 |
+
$this->category = 'relational';
|
15 |
+
$this->defaults = array(
|
16 |
+
'post_type' => array(),
|
17 |
+
'taxonomy' => array(),
|
18 |
+
);
|
19 |
+
|
20 |
+
parent::__construct();
|
21 |
+
|
22 |
+
}
|
23 |
+
|
24 |
+
function render_field_settings($field){
|
25 |
+
|
26 |
+
// default_value
|
27 |
+
acf_render_field_setting($field, array(
|
28 |
+
'label' => __('Filter by Post Type','acf'),
|
29 |
+
'instructions' => '',
|
30 |
+
'type' => 'select',
|
31 |
+
'name' => 'post_type',
|
32 |
+
'choices' => acf_get_pretty_post_types(),
|
33 |
+
'multiple' => 1,
|
34 |
+
'ui' => 1,
|
35 |
+
'allow_null' => 1,
|
36 |
+
'placeholder' => __("All post types",'acf'),
|
37 |
+
));
|
38 |
+
|
39 |
+
// default_value
|
40 |
+
acf_render_field_setting($field, array(
|
41 |
+
'label' => __('Filter by Taxonomy','acf'),
|
42 |
+
'instructions' => '',
|
43 |
+
'type' => 'select',
|
44 |
+
'name' => 'taxonomy',
|
45 |
+
'choices' => acf_get_taxonomy_terms(),
|
46 |
+
'multiple' => 1,
|
47 |
+
'ui' => 1,
|
48 |
+
'allow_null' => 1,
|
49 |
+
'placeholder' => __("All taxonomies",'acf'),
|
50 |
+
));
|
51 |
+
|
52 |
+
$field_name = 'field_name';
|
53 |
+
if(acf_maybe_get($field, 'name'))
|
54 |
+
$field_name = $field['name'];
|
55 |
+
|
56 |
+
ob_start();
|
57 |
+
?>
|
58 |
+
Add your own fields using the following hook:<br /><br />
|
59 |
+
<pre>
|
60 |
+
add_filter('acfe/fields/advanced_link/fields/name=<?php echo $field_name; ?>', 'my_acf_advanced_link_fields', 10, 3);
|
61 |
+
function my_acf_advanced_link_fields($fields, $field, $value){
|
62 |
+
|
63 |
+
/**
|
64 |
+
* @array $fields Sub fields array
|
65 |
+
* @array $field Advanced Link field
|
66 |
+
* @array $value The field values
|
67 |
+
*/
|
68 |
+
|
69 |
+
$fields[] = array(
|
70 |
+
'prefix' => $field['name'],
|
71 |
+
'name' => 'my_field',
|
72 |
+
'key' => 'acfe_advanced_link_my_field',
|
73 |
+
'label' => 'My field',
|
74 |
+
'type' => 'true_false',
|
75 |
+
'ui' => true,
|
76 |
+
'value' => isset($value['my_field']) ? $value['my_field'] : ''
|
77 |
+
);
|
78 |
+
|
79 |
+
return $fields;
|
80 |
+
|
81 |
+
}
|
82 |
+
</pre>
|
83 |
+
<?php
|
84 |
+
|
85 |
+
$message = ob_get_clean();
|
86 |
+
|
87 |
+
// field_type
|
88 |
+
acf_render_field_setting($field, array(
|
89 |
+
'label' => __('Instructions','acf'),
|
90 |
+
'instructions' => '',
|
91 |
+
'type' => 'message',
|
92 |
+
'name' => 'instructions',
|
93 |
+
'message' => $message,
|
94 |
+
'new_lines' => false
|
95 |
+
));
|
96 |
+
|
97 |
+
}
|
98 |
+
|
99 |
+
function get_link($value = ''){
|
100 |
+
|
101 |
+
// vars
|
102 |
+
$value = wp_parse_args($value, array(
|
103 |
+
'post' => '',
|
104 |
+
'type' => 'url',
|
105 |
+
'url' => '',
|
106 |
+
'title' => '',
|
107 |
+
'target' => false,
|
108 |
+
));
|
109 |
+
|
110 |
+
$link = array(
|
111 |
+
'type' => 'url',
|
112 |
+
'url' => false,
|
113 |
+
'post' => '',
|
114 |
+
'title' => '',
|
115 |
+
'target' => false,
|
116 |
+
);
|
117 |
+
|
118 |
+
|
119 |
+
$link['type'] = $value['type'];
|
120 |
+
$link['title'] = $value['title'];
|
121 |
+
if($value['target'])
|
122 |
+
$link['target'] = '_blank';
|
123 |
+
|
124 |
+
// URL
|
125 |
+
if($value['type'] === 'url'){
|
126 |
+
|
127 |
+
$link['url'] = $value['url'];
|
128 |
+
|
129 |
+
// Post
|
130 |
+
}elseif($value['type'] === 'post'){
|
131 |
+
|
132 |
+
$link['post'] = $value['post'];
|
133 |
+
|
134 |
+
if(!empty($value['post'])){
|
135 |
+
|
136 |
+
$link['url'] = get_permalink($value['post']);
|
137 |
+
|
138 |
+
}
|
139 |
+
|
140 |
+
}
|
141 |
+
|
142 |
+
// return
|
143 |
+
return $link;
|
144 |
+
|
145 |
+
}
|
146 |
+
|
147 |
+
function render_field($field){
|
148 |
+
|
149 |
+
// vars
|
150 |
+
$div = array(
|
151 |
+
'id' => $field['id'],
|
152 |
+
'class' => $field['class'] . ' acf-link',
|
153 |
+
);
|
154 |
+
|
155 |
+
// get link
|
156 |
+
$link = $this->get_link($field['value']);
|
157 |
+
|
158 |
+
// classes
|
159 |
+
if($link['url'])
|
160 |
+
$div['class'] .= ' -value';
|
161 |
+
|
162 |
+
if($link['target'] === '_blank')
|
163 |
+
$div['class'] .= ' -external';
|
164 |
+
|
165 |
+
$link['url_title'] = '';
|
166 |
+
|
167 |
+
// URL
|
168 |
+
if($link['type'] === 'url'){
|
169 |
+
|
170 |
+
$link['url_title'] = $link['url'];
|
171 |
+
|
172 |
+
// Post
|
173 |
+
}elseif($link['type'] === 'post'){
|
174 |
+
|
175 |
+
if(!empty($link['post'])){
|
176 |
+
|
177 |
+
$link['url_title'] = get_the_title($link['post']);
|
178 |
+
|
179 |
+
}
|
180 |
+
|
181 |
+
}
|
182 |
+
|
183 |
+
$fields = array(
|
184 |
+
|
185 |
+
array(
|
186 |
+
'prefix' => $field['name'],
|
187 |
+
'name' => 'type',
|
188 |
+
'key' => 'type',
|
189 |
+
'label' => __('Type', 'acf'),
|
190 |
+
'type' => 'radio',
|
191 |
+
'value' => $link['type'],
|
192 |
+
'required' => false,
|
193 |
+
'class' => 'input-type',
|
194 |
+
'choices' => array(
|
195 |
+
'url' => __('URL', 'acf'),
|
196 |
+
'post' => __('Post', 'acf'),
|
197 |
+
),
|
198 |
+
),
|
199 |
+
|
200 |
+
array(
|
201 |
+
'prefix' => $field['name'],
|
202 |
+
'name' => 'url',
|
203 |
+
'key' => 'url',
|
204 |
+
'label' => __('URL', 'acf'),
|
205 |
+
'type' => 'text',
|
206 |
+
'value' => $link['url'],
|
207 |
+
'required' => false,
|
208 |
+
'class' => 'input-url',
|
209 |
+
'conditional_logic' => array(
|
210 |
+
array(
|
211 |
+
array(
|
212 |
+
'field' => 'type',
|
213 |
+
'operator' => '==',
|
214 |
+
'value' => 'url',
|
215 |
+
)
|
216 |
+
)
|
217 |
+
)
|
218 |
+
|
219 |
+
),
|
220 |
+
|
221 |
+
array(
|
222 |
+
'prefix' => $field['name'],
|
223 |
+
'name' => 'post',
|
224 |
+
'key' => 'post',
|
225 |
+
'label' => __('Post', 'acf'),
|
226 |
+
'type' => 'post_object',
|
227 |
+
'value' => $link['post'],
|
228 |
+
'required' => false,
|
229 |
+
'class' => 'input-post',
|
230 |
+
'allow_null' => 1,
|
231 |
+
'conditional_logic' => array(
|
232 |
+
array(
|
233 |
+
array(
|
234 |
+
'field' => 'type',
|
235 |
+
'operator' => '==',
|
236 |
+
'value' => 'post',
|
237 |
+
)
|
238 |
+
)
|
239 |
+
)
|
240 |
+
),
|
241 |
+
|
242 |
+
array(
|
243 |
+
'prefix' => $field['name'],
|
244 |
+
'name' => 'title',
|
245 |
+
'key' => 'title',
|
246 |
+
'label' => __('Link text', 'acf'),
|
247 |
+
'type' => 'text',
|
248 |
+
'value' => $link['title'],
|
249 |
+
'required' => false,
|
250 |
+
'class' => 'input-title',
|
251 |
+
),
|
252 |
+
|
253 |
+
array(
|
254 |
+
'prefix' => $field['name'],
|
255 |
+
'name' => 'target',
|
256 |
+
'key' => 'target',
|
257 |
+
'label' => __('Target', 'acf'),
|
258 |
+
'type' => 'true_false',
|
259 |
+
'value' => $link['target'],
|
260 |
+
'message' => __('Open in an new window', 'acf'),
|
261 |
+
'required' => false,
|
262 |
+
'class' => 'input-target',
|
263 |
+
),
|
264 |
+
|
265 |
+
);
|
266 |
+
|
267 |
+
$fields = apply_filters('acfe/fields/advanced_link/fields', $fields, $field, $link);
|
268 |
+
$fields = apply_filters('acfe/fields/advanced_link/fields/name=' . $field['_name'], $fields, $field, $link);
|
269 |
+
$fields = apply_filters('acfe/fields/advanced_link/fields/key=' . $field['key'], $fields, $field, $link);
|
270 |
+
|
271 |
+
?>
|
272 |
+
|
273 |
+
<div <?php acf_esc_attr_e($div); ?>>
|
274 |
+
|
275 |
+
<div class="acfe-modal" data-modal-title="<?php echo $field['label']; ?>">
|
276 |
+
<div class="acfe-modal-wrapper">
|
277 |
+
<div class="acfe-modal-content">
|
278 |
+
|
279 |
+
<div class="acf-fields acf-form-fields -left">
|
280 |
+
|
281 |
+
<?php acf_render_fields($fields, false, 'div', 'label'); ?>
|
282 |
+
|
283 |
+
</div>
|
284 |
+
|
285 |
+
</div>
|
286 |
+
</div>
|
287 |
+
</div>
|
288 |
+
|
289 |
+
<a href="#" class="button" data-name="add" target=""><?php _e('Select Link', 'acf'); ?></a>
|
290 |
+
|
291 |
+
<div class="link-wrap">
|
292 |
+
<span class="link-title"><?php echo esc_html($link['title']); ?></span>
|
293 |
+
<a class="link-url" href="<?php echo esc_url($link['url']); ?>" target="_blank"><?php echo esc_html($link['url_title']); ?></a>
|
294 |
+
<i class="acf-icon -link-ext acf-js-tooltip" title="<?php _e('Opens in a new window/tab', 'acf'); ?>"></i><?php
|
295 |
+
?><a class="acf-icon -pencil -clear acf-js-tooltip" data-name="edit" href="#" title="<?php _e('Edit', 'acf'); ?>"></a><?php
|
296 |
+
?><a class="acf-icon -cancel -clear acf-js-tooltip" data-name="remove" href="#" title="<?php _e('Remove', 'acf'); ?>"></a>
|
297 |
+
</div>
|
298 |
+
|
299 |
+
</div>
|
300 |
+
<?php
|
301 |
+
|
302 |
+
}
|
303 |
+
|
304 |
+
function format_value($value, $post_id, $field){
|
305 |
+
|
306 |
+
// bail early if no value
|
307 |
+
if(empty($value))
|
308 |
+
return $value;
|
309 |
+
|
310 |
+
// get link
|
311 |
+
$link = $this->get_link($value);
|
312 |
+
|
313 |
+
// return link
|
314 |
+
return $link;
|
315 |
+
|
316 |
+
}
|
317 |
+
|
318 |
+
function validate_value($valid, $value, $field, $input){
|
319 |
+
|
320 |
+
// bail early if not required
|
321 |
+
if(!$field['required'])
|
322 |
+
return $valid;
|
323 |
+
|
324 |
+
// URL is required
|
325 |
+
if(empty($value) || (empty($value['url'] && empty($value['post']))))
|
326 |
+
return false;
|
327 |
+
|
328 |
+
// return
|
329 |
+
return $valid;
|
330 |
+
|
331 |
+
}
|
332 |
+
|
333 |
+
}
|
334 |
+
|
335 |
+
// initialize
|
336 |
+
acf_register_field_type('acfe_field_advanced_link');
|
337 |
+
|
338 |
endif;
|
includes/fields/field-flexible-content.php
CHANGED
@@ -1,1011 +1,1023 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Add Settings
|
8 |
-
*/
|
9 |
-
add_action('acf/render_field_settings/type=flexible_content', 'acfe_flexible_settings', 0);
|
10 |
-
function acfe_flexible_settings($field){
|
11 |
-
|
12 |
-
// Stylised button
|
13 |
-
acf_render_field_setting($field, array(
|
14 |
-
'label' => __('Stylised Button'),
|
15 |
-
'name' => 'acfe_flexible_stylised_button',
|
16 |
-
'key' => 'acfe_flexible_stylised_button',
|
17 |
-
'instructions' => __('Better layouts button integration'),
|
18 |
-
'type' => 'true_false',
|
19 |
-
'message' => '',
|
20 |
-
'default_value' => false,
|
21 |
-
'ui' => true,
|
22 |
-
'ui_on_text' => '',
|
23 |
-
'ui_off_text' => '',
|
24 |
-
));
|
25 |
-
|
26 |
-
// Hide Empty Message
|
27 |
-
acf_render_field_setting($field, array(
|
28 |
-
'label' => __('Hide Empty Message'),
|
29 |
-
'name' => 'acfe_flexible_hide_empty_message',
|
30 |
-
'key' => 'acfe_flexible_hide_empty_message',
|
31 |
-
'instructions' => __('Hide the empty message box'),
|
32 |
-
'type' => 'true_false',
|
33 |
-
'message' => '',
|
34 |
-
'default_value' => false,
|
35 |
-
'ui' => true,
|
36 |
-
'ui_on_text' => '',
|
37 |
-
'ui_off_text' => '',
|
38 |
-
'conditional_logic' => array(
|
39 |
-
array(
|
40 |
-
array(
|
41 |
-
'field' => 'acfe_flexible_stylised_button',
|
42 |
-
'operator' => '!=',
|
43 |
-
'value' => '1',
|
44 |
-
),
|
45 |
-
)
|
46 |
-
)
|
47 |
-
));
|
48 |
-
|
49 |
-
// Empty Message
|
50 |
-
acf_render_field_setting($field, array(
|
51 |
-
'label' => __('Empty Message'),
|
52 |
-
'name' => 'acfe_flexible_empty_message',
|
53 |
-
'key' => 'acfe_flexible_empty_message',
|
54 |
-
'instructions' => __('Text displayed when the flexible field is empty'),
|
55 |
-
'type' => 'text',
|
56 |
-
'placeholder' => __('Click the "Add Row" button below to start creating your layout'),
|
57 |
-
'conditional_logic' => array(
|
58 |
-
array(
|
59 |
-
array(
|
60 |
-
'field' => 'acfe_flexible_stylised_button',
|
61 |
-
'operator' => '!=',
|
62 |
-
'value' => '1',
|
63 |
-
),
|
64 |
-
array(
|
65 |
-
'field' => 'acfe_flexible_hide_empty_message',
|
66 |
-
'operator' => '!=',
|
67 |
-
'value' => '1',
|
68 |
-
)
|
69 |
-
)
|
70 |
-
)
|
71 |
-
));
|
72 |
-
|
73 |
-
// Layouts thumbnails
|
74 |
-
acf_render_field_setting($field, array(
|
75 |
-
'label' => __('Layouts: Thumbnails'),
|
76 |
-
'name' => 'acfe_flexible_layouts_thumbnails',
|
77 |
-
'key' => 'acfe_flexible_layouts_thumbnails',
|
78 |
-
'instructions' => __('Set a thumbnail for each layouts. You must save the field group to apply this setting'),
|
79 |
-
'type' => 'true_false',
|
80 |
-
'message' => '',
|
81 |
-
'default_value' => false,
|
82 |
-
'ui' => true,
|
83 |
-
'ui_on_text' => '',
|
84 |
-
'ui_off_text' => '',
|
85 |
-
));
|
86 |
-
|
87 |
-
// Layouts: Render
|
88 |
-
acf_render_field_setting($field, array(
|
89 |
-
'label' => __('Layouts: Render'),
|
90 |
-
'name' => 'acfe_flexible_layouts_templates',
|
91 |
-
'key' => 'acfe_flexible_layouts_templates',
|
92 |
-
'instructions' => __('Set template, style & javascript files for each layouts. This setting is mandatory in order to use <code style="font-size:11px;">get_flexible()</code> function. You must save the field group to apply this setting'),
|
93 |
-
'type' => 'true_false',
|
94 |
-
'message' => '',
|
95 |
-
'default_value' => false,
|
96 |
-
'ui' => true,
|
97 |
-
'ui_on_text' => '',
|
98 |
-
'ui_off_text' => '',
|
99 |
-
));
|
100 |
-
|
101 |
-
// Layouts: Preview
|
102 |
-
acf_render_field_setting($field, array(
|
103 |
-
'label' => __('Layouts: Dynamic Preview'),
|
104 |
-
'name' => 'acfe_flexible_layouts_previews',
|
105 |
-
'key' => 'acfe_flexible_layouts_previews',
|
106 |
-
'instructions' => __('Use layouts render settings to display a dynamic preview in the post administration'),
|
107 |
-
'type' => 'true_false',
|
108 |
-
'message' => '',
|
109 |
-
'default_value' => false,
|
110 |
-
'ui' => true,
|
111 |
-
'ui_on_text' => '',
|
112 |
-
'ui_off_text' => '',
|
113 |
-
'conditional_logic' => array(
|
114 |
-
array(
|
115 |
-
array(
|
116 |
-
'field' => 'acfe_flexible_layouts_templates',
|
117 |
-
'operator' => '==',
|
118 |
-
'value' => '1',
|
119 |
-
)
|
120 |
-
)
|
121 |
-
)
|
122 |
-
));
|
123 |
-
|
124 |
-
// Layouts: Placholder
|
125 |
-
acf_render_field_setting($field, array(
|
126 |
-
'label' => __('Layouts: Placeholder'),
|
127 |
-
'name' => 'acfe_flexible_layouts_placeholder',
|
128 |
-
'key' => 'acfe_flexible_layouts_placeholder',
|
129 |
-
'instructions' => __('Display a placeholder with a pencil icon, making edition easier'),
|
130 |
-
'type' => 'true_false',
|
131 |
-
'message' => '',
|
132 |
-
'default_value' => false,
|
133 |
-
'ui' => true,
|
134 |
-
'ui_on_text' => '',
|
135 |
-
'ui_off_text' => '',
|
136 |
-
'conditional_logic' => array(
|
137 |
-
array(
|
138 |
-
array(
|
139 |
-
'field' => 'acfe_flexible_layouts_previews',
|
140 |
-
'operator' => '==',
|
141 |
-
'value' => '',
|
142 |
-
)
|
143 |
-
)
|
144 |
-
)
|
145 |
-
));
|
146 |
-
|
147 |
-
// Layouts: Close Button
|
148 |
-
acf_render_field_setting($field, array(
|
149 |
-
'label' => __('Layouts: Close Button'),
|
150 |
-
'name' => 'acfe_flexible_close_button',
|
151 |
-
'key' => 'acfe_flexible_close_button',
|
152 |
-
'instructions' => __('Display a close button to collapse the layout'),
|
153 |
-
'type' => 'true_false',
|
154 |
-
'message' => '',
|
155 |
-
'default_value' => false,
|
156 |
-
'ui' => true,
|
157 |
-
'ui_on_text' => '',
|
158 |
-
'ui_off_text' => '',
|
159 |
-
));
|
160 |
-
|
161 |
-
// Layouts: Title Edition
|
162 |
-
acf_render_field_setting($field, array(
|
163 |
-
'label' => __('Layouts: Title Edition'),
|
164 |
-
'name' => 'acfe_flexible_title_edition',
|
165 |
-
'key' => 'acfe_flexible_title_edition',
|
166 |
-
'instructions' => __('Allow layout title edition'),
|
167 |
-
'type' => 'true_false',
|
168 |
-
'message' => '',
|
169 |
-
'default_value' => false,
|
170 |
-
'ui' => true,
|
171 |
-
'ui_on_text' => '',
|
172 |
-
'ui_off_text' => '',
|
173 |
-
));
|
174 |
-
|
175 |
-
// Layouts: Copy/Paste
|
176 |
-
acf_render_field_setting($field, array(
|
177 |
-
'label' => __('Layouts: Copy/Paste'),
|
178 |
-
'name' => 'acfe_flexible_copy_paste',
|
179 |
-
'key' => 'acfe_flexible_copy_paste',
|
180 |
-
'instructions' => __('Allow copy/paste layouts functions'),
|
181 |
-
'type' => 'true_false',
|
182 |
-
'message' => '',
|
183 |
-
'default_value' => false,
|
184 |
-
'ui' => true,
|
185 |
-
'ui_on_text' => '',
|
186 |
-
'ui_off_text' => '',
|
187 |
-
));
|
188 |
-
|
189 |
-
// Modal: Edition
|
190 |
-
acf_render_field_setting($field, array(
|
191 |
-
'label' => __('Layouts Modal: Edition'),
|
192 |
-
'name' => 'acfe_flexible_modal_edition',
|
193 |
-
'key' => 'acfe_flexible_modal_edition',
|
194 |
-
'instructions' => __('Edit layout content in a modal'),
|
195 |
-
'type' => 'true_false',
|
196 |
-
'message' => '',
|
197 |
-
'default_value' => false,
|
198 |
-
'ui' => true,
|
199 |
-
'ui_on_text' => '',
|
200 |
-
'ui_off_text' => '',
|
201 |
-
));
|
202 |
-
|
203 |
-
// Modal: Selection
|
204 |
-
acf_render_field_setting($field, array(
|
205 |
-
'label' => __('Layouts Modal: Selection'),
|
206 |
-
'name' => 'acfe_flexible_modal',
|
207 |
-
'key' => 'acfe_flexible_modal',
|
208 |
-
'instructions' => __('Select layouts in a modal'),
|
209 |
-
'type' => 'group',
|
210 |
-
'layout' => 'block',
|
211 |
-
'sub_fields' => array(
|
212 |
-
array(
|
213 |
-
'label' => '',
|
214 |
-
'name' => 'acfe_flexible_modal_enabled',
|
215 |
-
'key' => 'acfe_flexible_modal_enabled',
|
216 |
-
'type' => 'true_false',
|
217 |
-
'instructions' => '',
|
218 |
-
'required' => false,
|
219 |
-
'wrapper' => array(
|
220 |
-
'width' => '',
|
221 |
-
'class' => '',
|
222 |
-
'id' => '',
|
223 |
-
),
|
224 |
-
'message' => '',
|
225 |
-
'default_value' => false,
|
226 |
-
'ui' => true,
|
227 |
-
'ui_on_text' => '',
|
228 |
-
'ui_off_text' => '',
|
229 |
-
'conditional_logic' => false,
|
230 |
-
),
|
231 |
-
array(
|
232 |
-
'label' => '',
|
233 |
-
'name' => 'acfe_flexible_modal_title',
|
234 |
-
'key' => 'acfe_flexible_modal_title',
|
235 |
-
'type' => 'text',
|
236 |
-
'prepend' => __('Modal Title'),
|
237 |
-
'placeholder' => 'Add Row',
|
238 |
-
'instructions' => false,
|
239 |
-
'required' => false,
|
240 |
-
'wrapper' => array(
|
241 |
-
'width' => '35',
|
242 |
-
'class' => '',
|
243 |
-
'id' => '',
|
244 |
-
),
|
245 |
-
'conditional_logic' => array(
|
246 |
-
array(
|
247 |
-
array(
|
248 |
-
'field' => 'acfe_flexible_modal_enabled',
|
249 |
-
'operator' => '==',
|
250 |
-
'value' => '1',
|
251 |
-
)
|
252 |
-
)
|
253 |
-
)
|
254 |
-
),
|
255 |
-
array(
|
256 |
-
'label' => '',
|
257 |
-
'name' => 'acfe_flexible_modal_col',
|
258 |
-
'key' => 'acfe_flexible_modal_col',
|
259 |
-
'type' => 'select',
|
260 |
-
'prepend' => '',
|
261 |
-
'instructions' => false,
|
262 |
-
'required' => false,
|
263 |
-
'choices' => array(
|
264 |
-
'1' => '1 column',
|
265 |
-
'2' => '2 columns',
|
266 |
-
'3' => '3 columns',
|
267 |
-
'4' => '4 columns',
|
268 |
-
'5' => '5 columns',
|
269 |
-
'6' => '6 columns',
|
270 |
-
),
|
271 |
-
'default_value' => '4',
|
272 |
-
'wrapper' => array(
|
273 |
-
'width' => '15',
|
274 |
-
'class' => '',
|
275 |
-
'id' => '',
|
276 |
-
),
|
277 |
-
'conditional_logic' => array(
|
278 |
-
array(
|
279 |
-
array(
|
280 |
-
'field' => 'acfe_flexible_modal_enabled',
|
281 |
-
'operator' => '==',
|
282 |
-
'value' => '1',
|
283 |
-
)
|
284 |
-
)
|
285 |
-
)
|
286 |
-
),
|
287 |
-
array(
|
288 |
-
'label' => '',
|
289 |
-
'name' => 'acfe_flexible_modal_categories',
|
290 |
-
'key' => 'acfe_flexible_modal_categories',
|
291 |
-
'type' => 'true_false',
|
292 |
-
'message' => __('Categories'),
|
293 |
-
'instructions' => false,
|
294 |
-
'required' => false,
|
295 |
-
'wrapper' => array(
|
296 |
-
'width' => '25',
|
297 |
-
'class' => '',
|
298 |
-
'id' => '',
|
299 |
-
),
|
300 |
-
'conditional_logic' => array(
|
301 |
-
array(
|
302 |
-
array(
|
303 |
-
'field' => 'acfe_flexible_modal_enabled',
|
304 |
-
'operator' => '==',
|
305 |
-
'value' => '1',
|
306 |
-
)
|
307 |
-
)
|
308 |
-
)
|
309 |
-
),
|
310 |
-
)
|
311 |
-
));
|
312 |
-
|
313 |
-
// Layouts: Force State
|
314 |
-
acf_render_field_setting($field, array(
|
315 |
-
'label' => __('Layouts: Force State'),
|
316 |
-
'name' => 'acfe_flexible_layouts_state',
|
317 |
-
'key' => 'acfe_flexible_layouts_state',
|
318 |
-
'instructions' => __('Force layouts to be collapsed or opened'),
|
319 |
-
'type' => 'select',
|
320 |
-
'allow_null' => true,
|
321 |
-
'choices' => array(
|
322 |
-
'collapse' => 'Collapsed',
|
323 |
-
'open' => 'Opened',
|
324 |
-
),
|
325 |
-
'conditional_logic' => array(
|
326 |
-
array(
|
327 |
-
array(
|
328 |
-
'field' => 'acfe_flexible_modal_edition',
|
329 |
-
'operator' => '!=',
|
330 |
-
'value' => '1',
|
331 |
-
)
|
332 |
-
)
|
333 |
-
)
|
334 |
-
));
|
335 |
-
|
336 |
-
// Layouts: Remove Collapse
|
337 |
-
acf_render_field_setting($field, array(
|
338 |
-
'label' => __('Layouts: Remove Collapse'),
|
339 |
-
'name' => 'acfe_flexible_layouts_remove_collapse',
|
340 |
-
'key' => 'acfe_flexible_layouts_remove_collapse',
|
341 |
-
'instructions' => __('Remove collapse action'),
|
342 |
-
'type' => 'true_false',
|
343 |
-
'message' => '',
|
344 |
-
'default_value' => false,
|
345 |
-
'ui' => true,
|
346 |
-
'ui_on_text' => '',
|
347 |
-
'ui_off_text' => '',
|
348 |
-
'conditional_logic' => array(
|
349 |
-
array(
|
350 |
-
array(
|
351 |
-
'field' => 'acfe_flexible_modal_edition',
|
352 |
-
'operator' => '!=',
|
353 |
-
'value' => '1',
|
354 |
-
),
|
355 |
-
array(
|
356 |
-
'field' => 'acfe_flexible_layouts_state',
|
357 |
-
'operator' => '==',
|
358 |
-
'value' => 'open',
|
359 |
-
)
|
360 |
-
)
|
361 |
-
)
|
362 |
-
));
|
363 |
-
|
364 |
-
}
|
365 |
-
|
366 |
-
add_action('acf/render_field', 'acfe_flexible_layouts_settings_before', 0);
|
367 |
-
function acfe_flexible_layouts_settings_before($field){
|
368 |
-
|
369 |
-
if($field['_name'] != 'label' || stripos($field['name'], '[layouts]') === false)
|
370 |
-
return;
|
371 |
-
|
372 |
-
echo '</li>';
|
373 |
-
|
374 |
-
acf_render_field_wrap(array(
|
375 |
-
'label' => __('Settings'),
|
376 |
-
'type' => 'hidden',
|
377 |
-
'name' => 'acfe_flexible_settings_label'
|
378 |
-
), 'ul');
|
379 |
-
|
380 |
-
echo '<li>';
|
381 |
-
|
382 |
-
}
|
383 |
-
|
384 |
-
add_action('acf/render_field', 'acfe_flexible_layouts_settings', 10);
|
385 |
-
function acfe_flexible_layouts_settings($field){
|
386 |
-
|
387 |
-
if($field['_name'] != 'max' || stripos($field['name'], '[layouts]') === false)
|
388 |
-
return;
|
389 |
-
|
390 |
-
$layout_prefix = $field['prefix'];
|
391 |
-
|
392 |
-
parse_str($layout_prefix, $output);
|
393 |
-
$keys = acfe_array_keys_r($output);
|
394 |
-
|
395 |
-
$_field_id = $keys[1];
|
396 |
-
$_layout_key = $keys[3];
|
397 |
-
|
398 |
-
$field_flexible = acf_get_field($_field_id);
|
399 |
-
$layout = $field_flexible['layouts'][$_layout_key];
|
400 |
-
|
401 |
-
$is_flexible_layouts_thumbnails = isset($field_flexible['acfe_flexible_layouts_thumbnails']) && !empty($field_flexible['acfe_flexible_layouts_thumbnails']);
|
402 |
-
$is_flexible_layouts_templates = isset($field_flexible['acfe_flexible_layouts_templates']) && !empty($field_flexible['acfe_flexible_layouts_templates']);
|
403 |
-
$is_flexible_modal_enabled = isset($field_flexible['acfe_flexible_modal']['acfe_flexible_modal_enabled']) && !empty($field_flexible['acfe_flexible_modal']['acfe_flexible_modal_enabled']);
|
404 |
-
$is_flexible_modal_categories = isset($field_flexible['acfe_flexible_modal']['acfe_flexible_modal_categories']) && !empty($field_flexible['acfe_flexible_modal']['acfe_flexible_modal_categories']);
|
405 |
-
|
406 |
-
// Category
|
407 |
-
if($is_flexible_modal_enabled && $is_flexible_modal_categories){
|
408 |
-
|
409 |
-
$acfe_flexible_category = isset($layout['acfe_flexible_category']) ? $layout['acfe_flexible_category'] : '';
|
410 |
-
|
411 |
-
acf_render_field_wrap(array(
|
412 |
-
'prepend' => __('Category'),
|
413 |
-
'name' => 'acfe_flexible_category',
|
414 |
-
'type' => 'text',
|
415 |
-
'class' => 'acf-fc-meta-name',
|
416 |
-
'prefix' => $layout_prefix,
|
417 |
-
'value' => $acfe_flexible_category,
|
418 |
-
'placeholder' => __('Multiple categories can be set using "|"')
|
419 |
-
|
420 |
-
/*
|
421 |
-
'conditional_logic' => array(
|
422 |
-
array(
|
423 |
-
array(
|
424 |
-
'field' => 'acfe_flexible_modal_enabled',
|
425 |
-
'operator' => '==',
|
426 |
-
'value' => '1',
|
427 |
-
),
|
428 |
-
array(
|
429 |
-
'field' => 'acfe_flexible_modal_categories',
|
430 |
-
'operator' => '==',
|
431 |
-
'value' => '1',
|
432 |
-
)
|
433 |
-
)
|
434 |
-
)
|
435 |
-
*/
|
436 |
-
|
437 |
-
), 'ul');
|
438 |
-
|
439 |
-
}
|
440 |
-
|
441 |
-
// Template
|
442 |
-
if($is_flexible_layouts_templates){
|
443 |
-
|
444 |
-
$acfe_flexible_render_template = isset($layout['acfe_flexible_render_template']) ? $layout['acfe_flexible_render_template'] : '';
|
445 |
-
|
446 |
-
acf_render_field_wrap(array(
|
447 |
-
'label' => __('Render'),
|
448 |
-
'prepend' => str_replace(home_url(), '', ACFE_THEME_URL) . '/',
|
449 |
-
'name' => 'acfe_flexible_render_template',
|
450 |
-
'type' => 'text',
|
451 |
-
'class' => 'acf-fc-meta-name',
|
452 |
-
'prefix' => $layout_prefix,
|
453 |
-
'value' => $acfe_flexible_render_template,
|
454 |
-
'placeholder' => 'template.php',
|
455 |
-
|
456 |
-
/*
|
457 |
-
'conditional_logic' => array(
|
458 |
-
array(
|
459 |
-
array(
|
460 |
-
'field' => 'acfe_flexible_layouts_templates',
|
461 |
-
'operator' => '==',
|
462 |
-
'value' => '1',
|
463 |
-
)
|
464 |
-
)
|
465 |
-
)
|
466 |
-
*/
|
467 |
-
|
468 |
-
), 'ul');
|
469 |
-
|
470 |
-
$acfe_flexible_render_style = isset($layout['acfe_flexible_render_style']) ? $layout['acfe_flexible_render_style'] : '';
|
471 |
-
|
472 |
-
acf_render_field_wrap(array(
|
473 |
-
'prepend' => str_replace(home_url(), '', ACFE_THEME_URL) . '/',
|
474 |
-
'name' => 'acfe_flexible_render_style',
|
475 |
-
'type' => 'text',
|
476 |
-
'class' => 'acf-fc-meta-name',
|
477 |
-
'prefix' => $layout_prefix,
|
478 |
-
'value' => $acfe_flexible_render_style,
|
479 |
-
'placeholder' => 'style.css',
|
480 |
-
|
481 |
-
/*
|
482 |
-
'conditional_logic' => array(
|
483 |
-
array(
|
484 |
-
array(
|
485 |
-
'field' => 'acfe_flexible_layouts_templates',
|
486 |
-
'operator' => '==',
|
487 |
-
'value' => '1',
|
488 |
-
)
|
489 |
-
)
|
490 |
-
)
|
491 |
-
*/
|
492 |
-
|
493 |
-
), 'ul');
|
494 |
-
|
495 |
-
$acfe_flexible_render_script = isset($layout['acfe_flexible_render_script']) ? $layout['acfe_flexible_render_script'] : '';
|
496 |
-
|
497 |
-
acf_render_field_wrap(array(
|
498 |
-
'prepend' => str_replace(home_url(), '', ACFE_THEME_URL) . '/',
|
499 |
-
'name' => 'acfe_flexible_render_script',
|
500 |
-
'type' => 'text',
|
501 |
-
'class' => 'acf-fc-meta-name',
|
502 |
-
'prefix' => $layout_prefix,
|
503 |
-
'value' => $acfe_flexible_render_script,
|
504 |
-
'placeholder' => 'script.js',
|
505 |
-
|
506 |
-
/*
|
507 |
-
'conditional_logic' => array(
|
508 |
-
array(
|
509 |
-
array(
|
510 |
-
'field' => 'acfe_flexible_layouts_templates',
|
511 |
-
'operator' => '==',
|
512 |
-
'value' => '1',
|
513 |
-
)
|
514 |
-
)
|
515 |
-
)
|
516 |
-
*/
|
517 |
-
|
518 |
-
), 'ul');
|
519 |
-
|
520 |
-
}
|
521 |
-
|
522 |
-
// Thumbnail
|
523 |
-
if($is_flexible_layouts_thumbnails){
|
524 |
-
|
525 |
-
$acfe_flexible_thumbnail = isset($layout['acfe_flexible_thumbnail']) ? $layout['acfe_flexible_thumbnail'] : '';
|
526 |
-
|
527 |
-
acf_render_field_wrap(array(
|
528 |
-
'label' => __('Thumbnail'),
|
529 |
-
'name' => 'acfe_flexible_thumbnail',
|
530 |
-
'type' => 'image',
|
531 |
-
'class' => '',
|
532 |
-
'prefix' => $layout_prefix,
|
533 |
-
'value' => $acfe_flexible_thumbnail,
|
534 |
-
'return_format' => 'array',
|
535 |
-
'preview_size' => 'thumbnail',
|
536 |
-
'library' => 'all',
|
537 |
-
|
538 |
-
/*
|
539 |
-
'conditional_logic' => array(
|
540 |
-
array(
|
541 |
-
array(
|
542 |
-
'field' => 'acfe_flexible_layouts_thumbnails',
|
543 |
-
'operator' => '==',
|
544 |
-
'value' => '1',
|
545 |
-
)
|
546 |
-
)
|
547 |
-
)
|
548 |
-
*/
|
549 |
-
|
550 |
-
), 'ul');
|
551 |
-
|
552 |
-
}
|
553 |
-
|
554 |
-
}
|
555 |
-
|
556 |
-
add_filter('acfe/field_wrapper_attributes/type=flexible_content', 'acfe_flexible_wrapper', 10, 2);
|
557 |
-
function acfe_flexible_wrapper($wrapper, $field){
|
558 |
-
|
559 |
-
// Stylised button
|
560 |
-
if(acf_maybe_get($field, 'acfe_flexible_stylised_button')){
|
561 |
-
|
562 |
-
$wrapper['data-acfe-flexible-stylised-button'] = 1;
|
563 |
-
|
564 |
-
}
|
565 |
-
|
566 |
-
// Hide Empty Message
|
567 |
-
if(acf_maybe_get($field, 'acfe_flexible_hide_empty_message') || acf_maybe_get($field, 'acfe_flexible_stylised_button')){
|
568 |
-
|
569 |
-
$wrapper['data-acfe-flexible-hide-empty-message'] = 1;
|
570 |
-
|
571 |
-
}
|
572 |
-
|
573 |
-
// Modal: Edition
|
574 |
-
if(acf_maybe_get($field, 'acfe_flexible_modal_edition')){
|
575 |
-
|
576 |
-
$wrapper['data-acfe-flexible-modal-edition'] = 1;
|
577 |
-
|
578 |
-
}
|
579 |
-
|
580 |
-
// Modal: Selection
|
581 |
-
if(isset($field['acfe_flexible_modal']['acfe_flexible_modal_enabled']) && !empty($field['acfe_flexible_modal']['acfe_flexible_modal_enabled'])){
|
582 |
-
|
583 |
-
$wrapper['data-acfe-flexible-modal'] = 1;
|
584 |
-
|
585 |
-
// Columns
|
586 |
-
if(isset($field['acfe_flexible_modal']['acfe_flexible_modal_col']) && !empty($field['acfe_flexible_modal']['acfe_flexible_modal_col']))
|
587 |
-
$wrapper['data-acfe-flexible-modal-col'] = $field['acfe_flexible_modal']['acfe_flexible_modal_col'];
|
588 |
-
|
589 |
-
// Title
|
590 |
-
if(isset($field['acfe_flexible_modal']['acfe_flexible_modal_title']) && !empty($field['acfe_flexible_modal']['acfe_flexible_modal_title']))
|
591 |
-
$wrapper['data-acfe-flexible-modal-title'] = $field['acfe_flexible_modal']['acfe_flexible_modal_title'];
|
592 |
-
|
593 |
-
}
|
594 |
-
|
595 |
-
// Layouts: Title Edition
|
596 |
-
if(acf_maybe_get($field, 'acfe_flexible_title_edition')){
|
597 |
-
|
598 |
-
$wrapper['data-acfe-flexible-title-edition'] = 1;
|
599 |
-
|
600 |
-
}
|
601 |
-
|
602 |
-
// Layouts: Close Button
|
603 |
-
if(acf_maybe_get($field, 'acfe_flexible_close_button')){
|
604 |
-
|
605 |
-
$wrapper['data-acfe-flexible-close-button'] = 1;
|
606 |
-
|
607 |
-
}
|
608 |
-
|
609 |
-
// Layouts: Copy/paste
|
610 |
-
if(acf_maybe_get($field, 'acfe_flexible_copy_paste')){
|
611 |
-
|
612 |
-
$wrapper['data-acfe-flexible-copy-paste'] = 1;
|
613 |
-
|
614 |
-
}
|
615 |
-
|
616 |
-
// Layouts: State
|
617 |
-
if(!acf_maybe_get($field, 'acfe_flexible_modal_edition')){
|
618 |
-
|
619 |
-
if(acf_maybe_get($field, 'acfe_flexible_layouts_state')){
|
620 |
-
|
621 |
-
// Collapse
|
622 |
-
if($field['acfe_flexible_layouts_state'] === 'collapse'){
|
623 |
-
|
624 |
-
$wrapper['data-acfe-flexible-close'] = 1;
|
625 |
-
|
626 |
-
}
|
627 |
-
|
628 |
-
// Open
|
629 |
-
elseif($field['acfe_flexible_layouts_state'] === 'open'){
|
630 |
-
|
631 |
-
$wrapper['data-acfe-flexible-open'] = 1;
|
632 |
-
|
633 |
-
}
|
634 |
-
|
635 |
-
}
|
636 |
-
|
637 |
-
// Layouts Remove Collapse
|
638 |
-
if(acf_maybe_get($field, 'acfe_flexible_layouts_remove_collapse')){
|
639 |
-
|
640 |
-
$wrapper['data-acfe-flexible-remove-collapse'] = 1;
|
641 |
-
|
642 |
-
}
|
643 |
-
|
644 |
-
}
|
645 |
-
|
646 |
-
// Layouts Placeholder
|
647 |
-
if(acf_maybe_get($field, 'acfe_flexible_layouts_placeholder')){
|
648 |
-
|
649 |
-
$wrapper['data-acfe-flexible-placeholder'] = 1;
|
650 |
-
|
651 |
-
}
|
652 |
-
|
653 |
-
// Layouts Previews
|
654 |
-
if(acf_maybe_get($field, 'acfe_flexible_layouts_templates') && acf_maybe_get($field, 'acfe_flexible_layouts_previews')){
|
655 |
-
|
656 |
-
$wrapper['data-acfe-flexible-preview'] = 1;
|
657 |
-
|
658 |
-
}
|
659 |
-
|
660 |
-
// Placeholder Icon
|
661 |
-
$layout_placeholder_icon = false;
|
662 |
-
$layout_placeholder_icon = apply_filters('acfe/flexible/placeholder/icon',
|
663 |
-
$layout_placeholder_icon = apply_filters('acfe/flexible/placeholder/icon/name=' . $field['_name'],
|
664 |
-
$layout_placeholder_icon = apply_filters('acfe/flexible/placeholder/icon/key=' . $field['key'],
|
665 |
-
|
666 |
-
if(!empty($layout_placeholder_icon)){
|
667 |
-
|
668 |
-
$wrapper['data-acfe-flexible-placeholder-icon'] = $layout_placeholder_icon;
|
669 |
-
|
670 |
-
}
|
671 |
-
|
672 |
-
// Lock sortable
|
673 |
-
$acfe_flexible_lock_sortable = false;
|
674 |
-
$acfe_flexible_lock_sortable = apply_filters('acfe/flexible/lock',
|
675 |
-
$acfe_flexible_lock_sortable = apply_filters('acfe/flexible/lock/name=' . $field['_name'],
|
676 |
-
$acfe_flexible_lock_sortable = apply_filters('acfe/flexible/lock/key=' . $field['key'],
|
677 |
-
|
678 |
-
if($acfe_flexible_lock_sortable){
|
679 |
-
|
680 |
-
$wrapper['data-acfe-flexible-lock'] = 1;
|
681 |
-
|
682 |
-
}
|
683 |
-
|
684 |
-
// Remove actions
|
685 |
-
$acfe_flexible_remove_actions = false;
|
686 |
-
$acfe_flexible_remove_actions = apply_filters('acfe/flexible/remove_actions',
|
687 |
-
$acfe_flexible_remove_actions = apply_filters('acfe/flexible/remove_actions/name=' . $field['_name'],
|
688 |
-
$acfe_flexible_remove_actions = apply_filters('acfe/flexible/remove_actions/key=' . $field['key'],
|
689 |
-
|
690 |
-
if($acfe_flexible_remove_actions){
|
691 |
-
|
692 |
-
$wrapper['data-acfe-flexible-remove-actions'] = 1;
|
693 |
-
|
694 |
-
}
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
//
|
741 |
-
$
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
$
|
746 |
-
|
747 |
-
|
748 |
-
if(!empty($acfe_flexible_thumbnail))
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
// Thumbnail
|
763 |
-
|
764 |
-
|
765 |
-
$
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
$
|
886 |
-
|
887 |
-
//
|
888 |
-
$layout
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
if(
|
977 |
-
return $
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1011 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Add Settings
|
8 |
+
*/
|
9 |
+
add_action('acf/render_field_settings/type=flexible_content', 'acfe_flexible_settings', 0);
|
10 |
+
function acfe_flexible_settings($field){
|
11 |
+
|
12 |
+
// Stylised button
|
13 |
+
acf_render_field_setting($field, array(
|
14 |
+
'label' => __('Stylised Button'),
|
15 |
+
'name' => 'acfe_flexible_stylised_button',
|
16 |
+
'key' => 'acfe_flexible_stylised_button',
|
17 |
+
'instructions' => __('Better layouts button integration'),
|
18 |
+
'type' => 'true_false',
|
19 |
+
'message' => '',
|
20 |
+
'default_value' => false,
|
21 |
+
'ui' => true,
|
22 |
+
'ui_on_text' => '',
|
23 |
+
'ui_off_text' => '',
|
24 |
+
));
|
25 |
+
|
26 |
+
// Hide Empty Message
|
27 |
+
acf_render_field_setting($field, array(
|
28 |
+
'label' => __('Hide Empty Message'),
|
29 |
+
'name' => 'acfe_flexible_hide_empty_message',
|
30 |
+
'key' => 'acfe_flexible_hide_empty_message',
|
31 |
+
'instructions' => __('Hide the empty message box'),
|
32 |
+
'type' => 'true_false',
|
33 |
+
'message' => '',
|
34 |
+
'default_value' => false,
|
35 |
+
'ui' => true,
|
36 |
+
'ui_on_text' => '',
|
37 |
+
'ui_off_text' => '',
|
38 |
+
'conditional_logic' => array(
|
39 |
+
array(
|
40 |
+
array(
|
41 |
+
'field' => 'acfe_flexible_stylised_button',
|
42 |
+
'operator' => '!=',
|
43 |
+
'value' => '1',
|
44 |
+
),
|
45 |
+
)
|
46 |
+
)
|
47 |
+
));
|
48 |
+
|
49 |
+
// Empty Message
|
50 |
+
acf_render_field_setting($field, array(
|
51 |
+
'label' => __('Empty Message'),
|
52 |
+
'name' => 'acfe_flexible_empty_message',
|
53 |
+
'key' => 'acfe_flexible_empty_message',
|
54 |
+
'instructions' => __('Text displayed when the flexible field is empty'),
|
55 |
+
'type' => 'text',
|
56 |
+
'placeholder' => __('Click the "Add Row" button below to start creating your layout'),
|
57 |
+
'conditional_logic' => array(
|
58 |
+
array(
|
59 |
+
array(
|
60 |
+
'field' => 'acfe_flexible_stylised_button',
|
61 |
+
'operator' => '!=',
|
62 |
+
'value' => '1',
|
63 |
+
),
|
64 |
+
array(
|
65 |
+
'field' => 'acfe_flexible_hide_empty_message',
|
66 |
+
'operator' => '!=',
|
67 |
+
'value' => '1',
|
68 |
+
)
|
69 |
+
)
|
70 |
+
)
|
71 |
+
));
|
72 |
+
|
73 |
+
// Layouts thumbnails
|
74 |
+
acf_render_field_setting($field, array(
|
75 |
+
'label' => __('Layouts: Thumbnails'),
|
76 |
+
'name' => 'acfe_flexible_layouts_thumbnails',
|
77 |
+
'key' => 'acfe_flexible_layouts_thumbnails',
|
78 |
+
'instructions' => __('Set a thumbnail for each layouts. You must save the field group to apply this setting'),
|
79 |
+
'type' => 'true_false',
|
80 |
+
'message' => '',
|
81 |
+
'default_value' => false,
|
82 |
+
'ui' => true,
|
83 |
+
'ui_on_text' => '',
|
84 |
+
'ui_off_text' => '',
|
85 |
+
));
|
86 |
+
|
87 |
+
// Layouts: Render
|
88 |
+
acf_render_field_setting($field, array(
|
89 |
+
'label' => __('Layouts: Render'),
|
90 |
+
'name' => 'acfe_flexible_layouts_templates',
|
91 |
+
'key' => 'acfe_flexible_layouts_templates',
|
92 |
+
'instructions' => __('Set template, style & javascript files for each layouts. This setting is mandatory in order to use <code style="font-size:11px;">get_flexible()</code> function. You must save the field group to apply this setting'),
|
93 |
+
'type' => 'true_false',
|
94 |
+
'message' => '',
|
95 |
+
'default_value' => false,
|
96 |
+
'ui' => true,
|
97 |
+
'ui_on_text' => '',
|
98 |
+
'ui_off_text' => '',
|
99 |
+
));
|
100 |
+
|
101 |
+
// Layouts: Preview
|
102 |
+
acf_render_field_setting($field, array(
|
103 |
+
'label' => __('Layouts: Dynamic Preview'),
|
104 |
+
'name' => 'acfe_flexible_layouts_previews',
|
105 |
+
'key' => 'acfe_flexible_layouts_previews',
|
106 |
+
'instructions' => __('Use layouts render settings to display a dynamic preview in the post administration'),
|
107 |
+
'type' => 'true_false',
|
108 |
+
'message' => '',
|
109 |
+
'default_value' => false,
|
110 |
+
'ui' => true,
|
111 |
+
'ui_on_text' => '',
|
112 |
+
'ui_off_text' => '',
|
113 |
+
'conditional_logic' => array(
|
114 |
+
array(
|
115 |
+
array(
|
116 |
+
'field' => 'acfe_flexible_layouts_templates',
|
117 |
+
'operator' => '==',
|
118 |
+
'value' => '1',
|
119 |
+
)
|
120 |
+
)
|
121 |
+
)
|
122 |
+
));
|
123 |
+
|
124 |
+
// Layouts: Placholder
|
125 |
+
acf_render_field_setting($field, array(
|
126 |
+
'label' => __('Layouts: Placeholder'),
|
127 |
+
'name' => 'acfe_flexible_layouts_placeholder',
|
128 |
+
'key' => 'acfe_flexible_layouts_placeholder',
|
129 |
+
'instructions' => __('Display a placeholder with a pencil icon, making edition easier'),
|
130 |
+
'type' => 'true_false',
|
131 |
+
'message' => '',
|
132 |
+
'default_value' => false,
|
133 |
+
'ui' => true,
|
134 |
+
'ui_on_text' => '',
|
135 |
+
'ui_off_text' => '',
|
136 |
+
'conditional_logic' => array(
|
137 |
+
array(
|
138 |
+
array(
|
139 |
+
'field' => 'acfe_flexible_layouts_previews',
|
140 |
+
'operator' => '==',
|
141 |
+
'value' => '',
|
142 |
+
)
|
143 |
+
)
|
144 |
+
)
|
145 |
+
));
|
146 |
+
|
147 |
+
// Layouts: Close Button
|
148 |
+
acf_render_field_setting($field, array(
|
149 |
+
'label' => __('Layouts: Close Button'),
|
150 |
+
'name' => 'acfe_flexible_close_button',
|
151 |
+
'key' => 'acfe_flexible_close_button',
|
152 |
+
'instructions' => __('Display a close button to collapse the layout'),
|
153 |
+
'type' => 'true_false',
|
154 |
+
'message' => '',
|
155 |
+
'default_value' => false,
|
156 |
+
'ui' => true,
|
157 |
+
'ui_on_text' => '',
|
158 |
+
'ui_off_text' => '',
|
159 |
+
));
|
160 |
+
|
161 |
+
// Layouts: Title Edition
|
162 |
+
acf_render_field_setting($field, array(
|
163 |
+
'label' => __('Layouts: Title Edition'),
|
164 |
+
'name' => 'acfe_flexible_title_edition',
|
165 |
+
'key' => 'acfe_flexible_title_edition',
|
166 |
+
'instructions' => __('Allow layout title edition'),
|
167 |
+
'type' => 'true_false',
|
168 |
+
'message' => '',
|
169 |
+
'default_value' => false,
|
170 |
+
'ui' => true,
|
171 |
+
'ui_on_text' => '',
|
172 |
+
'ui_off_text' => '',
|
173 |
+
));
|
174 |
+
|
175 |
+
// Layouts: Copy/Paste
|
176 |
+
acf_render_field_setting($field, array(
|
177 |
+
'label' => __('Layouts: Copy/Paste'),
|
178 |
+
'name' => 'acfe_flexible_copy_paste',
|
179 |
+
'key' => 'acfe_flexible_copy_paste',
|
180 |
+
'instructions' => __('Allow copy/paste layouts functions'),
|
181 |
+
'type' => 'true_false',
|
182 |
+
'message' => '',
|
183 |
+
'default_value' => false,
|
184 |
+
'ui' => true,
|
185 |
+
'ui_on_text' => '',
|
186 |
+
'ui_off_text' => '',
|
187 |
+
));
|
188 |
+
|
189 |
+
// Modal: Edition
|
190 |
+
acf_render_field_setting($field, array(
|
191 |
+
'label' => __('Layouts Modal: Edition'),
|
192 |
+
'name' => 'acfe_flexible_modal_edition',
|
193 |
+
'key' => 'acfe_flexible_modal_edition',
|
194 |
+
'instructions' => __('Edit layout content in a modal'),
|
195 |
+
'type' => 'true_false',
|
196 |
+
'message' => '',
|
197 |
+
'default_value' => false,
|
198 |
+
'ui' => true,
|
199 |
+
'ui_on_text' => '',
|
200 |
+
'ui_off_text' => '',
|
201 |
+
));
|
202 |
+
|
203 |
+
// Modal: Selection
|
204 |
+
acf_render_field_setting($field, array(
|
205 |
+
'label' => __('Layouts Modal: Selection'),
|
206 |
+
'name' => 'acfe_flexible_modal',
|
207 |
+
'key' => 'acfe_flexible_modal',
|
208 |
+
'instructions' => __('Select layouts in a modal'),
|
209 |
+
'type' => 'group',
|
210 |
+
'layout' => 'block',
|
211 |
+
'sub_fields' => array(
|
212 |
+
array(
|
213 |
+
'label' => '',
|
214 |
+
'name' => 'acfe_flexible_modal_enabled',
|
215 |
+
'key' => 'acfe_flexible_modal_enabled',
|
216 |
+
'type' => 'true_false',
|
217 |
+
'instructions' => '',
|
218 |
+
'required' => false,
|
219 |
+
'wrapper' => array(
|
220 |
+
'width' => '',
|
221 |
+
'class' => '',
|
222 |
+
'id' => '',
|
223 |
+
),
|
224 |
+
'message' => '',
|
225 |
+
'default_value' => false,
|
226 |
+
'ui' => true,
|
227 |
+
'ui_on_text' => '',
|
228 |
+
'ui_off_text' => '',
|
229 |
+
'conditional_logic' => false,
|
230 |
+
),
|
231 |
+
array(
|
232 |
+
'label' => '',
|
233 |
+
'name' => 'acfe_flexible_modal_title',
|
234 |
+
'key' => 'acfe_flexible_modal_title',
|
235 |
+
'type' => 'text',
|
236 |
+
'prepend' => __('Modal Title'),
|
237 |
+
'placeholder' => 'Add Row',
|
238 |
+
'instructions' => false,
|
239 |
+
'required' => false,
|
240 |
+
'wrapper' => array(
|
241 |
+
'width' => '35',
|
242 |
+
'class' => '',
|
243 |
+
'id' => '',
|
244 |
+
),
|
245 |
+
'conditional_logic' => array(
|
246 |
+
array(
|
247 |
+
array(
|
248 |
+
'field' => 'acfe_flexible_modal_enabled',
|
249 |
+
'operator' => '==',
|
250 |
+
'value' => '1',
|
251 |
+
)
|
252 |
+
)
|
253 |
+
)
|
254 |
+
),
|
255 |
+
array(
|
256 |
+
'label' => '',
|
257 |
+
'name' => 'acfe_flexible_modal_col',
|
258 |
+
'key' => 'acfe_flexible_modal_col',
|
259 |
+
'type' => 'select',
|
260 |
+
'prepend' => '',
|
261 |
+
'instructions' => false,
|
262 |
+
'required' => false,
|
263 |
+
'choices' => array(
|
264 |
+
'1' => '1 column',
|
265 |
+
'2' => '2 columns',
|
266 |
+
'3' => '3 columns',
|
267 |
+
'4' => '4 columns',
|
268 |
+
'5' => '5 columns',
|
269 |
+
'6' => '6 columns',
|
270 |
+
),
|
271 |
+
'default_value' => '4',
|
272 |
+
'wrapper' => array(
|
273 |
+
'width' => '15',
|
274 |
+
'class' => '',
|
275 |
+
'id' => '',
|
276 |
+
),
|
277 |
+
'conditional_logic' => array(
|
278 |
+
array(
|
279 |
+
array(
|
280 |
+
'field' => 'acfe_flexible_modal_enabled',
|
281 |
+
'operator' => '==',
|
282 |
+
'value' => '1',
|
283 |
+
)
|
284 |
+
)
|
285 |
+
)
|
286 |
+
),
|
287 |
+
array(
|
288 |
+
'label' => '',
|
289 |
+
'name' => 'acfe_flexible_modal_categories',
|
290 |
+
'key' => 'acfe_flexible_modal_categories',
|
291 |
+
'type' => 'true_false',
|
292 |
+
'message' => __('Categories'),
|
293 |
+
'instructions' => false,
|
294 |
+
'required' => false,
|
295 |
+
'wrapper' => array(
|
296 |
+
'width' => '25',
|
297 |
+
'class' => '',
|
298 |
+
'id' => '',
|
299 |
+
),
|
300 |
+
'conditional_logic' => array(
|
301 |
+
array(
|
302 |
+
array(
|
303 |
+
'field' => 'acfe_flexible_modal_enabled',
|
304 |
+
'operator' => '==',
|
305 |
+
'value' => '1',
|
306 |
+
)
|
307 |
+
)
|
308 |
+
)
|
309 |
+
),
|
310 |
+
)
|
311 |
+
));
|
312 |
+
|
313 |
+
// Layouts: Force State
|
314 |
+
acf_render_field_setting($field, array(
|
315 |
+
'label' => __('Layouts: Force State'),
|
316 |
+
'name' => 'acfe_flexible_layouts_state',
|
317 |
+
'key' => 'acfe_flexible_layouts_state',
|
318 |
+
'instructions' => __('Force layouts to be collapsed or opened'),
|
319 |
+
'type' => 'select',
|
320 |
+
'allow_null' => true,
|
321 |
+
'choices' => array(
|
322 |
+
'collapse' => 'Collapsed',
|
323 |
+
'open' => 'Opened',
|
324 |
+
),
|
325 |
+
'conditional_logic' => array(
|
326 |
+
array(
|
327 |
+
array(
|
328 |
+
'field' => 'acfe_flexible_modal_edition',
|
329 |
+
'operator' => '!=',
|
330 |
+
'value' => '1',
|
331 |
+
)
|
332 |
+
)
|
333 |
+
)
|
334 |
+
));
|
335 |
+
|
336 |
+
// Layouts: Remove Collapse
|
337 |
+
acf_render_field_setting($field, array(
|
338 |
+
'label' => __('Layouts: Remove Collapse'),
|
339 |
+
'name' => 'acfe_flexible_layouts_remove_collapse',
|
340 |
+
'key' => 'acfe_flexible_layouts_remove_collapse',
|
341 |
+
'instructions' => __('Remove collapse action'),
|
342 |
+
'type' => 'true_false',
|
343 |
+
'message' => '',
|
344 |
+
'default_value' => false,
|
345 |
+
'ui' => true,
|
346 |
+
'ui_on_text' => '',
|
347 |
+
'ui_off_text' => '',
|
348 |
+
'conditional_logic' => array(
|
349 |
+
array(
|
350 |
+
array(
|
351 |
+
'field' => 'acfe_flexible_modal_edition',
|
352 |
+
'operator' => '!=',
|
353 |
+
'value' => '1',
|
354 |
+
),
|
355 |
+
array(
|
356 |
+
'field' => 'acfe_flexible_layouts_state',
|
357 |
+
'operator' => '==',
|
358 |
+
'value' => 'open',
|
359 |
+
)
|
360 |
+
)
|
361 |
+
)
|
362 |
+
));
|
363 |
+
|
364 |
+
}
|
365 |
+
|
366 |
+
add_action('acf/render_field', 'acfe_flexible_layouts_settings_before', 0);
|
367 |
+
function acfe_flexible_layouts_settings_before($field){
|
368 |
+
|
369 |
+
if($field['_name'] != 'label' || stripos($field['name'], '[layouts]') === false)
|
370 |
+
return;
|
371 |
+
|
372 |
+
echo '</li>';
|
373 |
+
|
374 |
+
acf_render_field_wrap(array(
|
375 |
+
'label' => __('Settings'),
|
376 |
+
'type' => 'hidden',
|
377 |
+
'name' => 'acfe_flexible_settings_label'
|
378 |
+
), 'ul');
|
379 |
+
|
380 |
+
echo '<li>';
|
381 |
+
|
382 |
+
}
|
383 |
+
|
384 |
+
add_action('acf/render_field', 'acfe_flexible_layouts_settings', 10);
|
385 |
+
function acfe_flexible_layouts_settings($field){
|
386 |
+
|
387 |
+
if($field['_name'] != 'max' || stripos($field['name'], '[layouts]') === false)
|
388 |
+
return;
|
389 |
+
|
390 |
+
$layout_prefix = $field['prefix'];
|
391 |
+
|
392 |
+
parse_str($layout_prefix, $output);
|
393 |
+
$keys = acfe_array_keys_r($output);
|
394 |
+
|
395 |
+
$_field_id = $keys[1];
|
396 |
+
$_layout_key = $keys[3];
|
397 |
+
|
398 |
+
$field_flexible = acf_get_field($_field_id);
|
399 |
+
$layout = $field_flexible['layouts'][$_layout_key];
|
400 |
+
|
401 |
+
$is_flexible_layouts_thumbnails = isset($field_flexible['acfe_flexible_layouts_thumbnails']) && !empty($field_flexible['acfe_flexible_layouts_thumbnails']);
|
402 |
+
$is_flexible_layouts_templates = isset($field_flexible['acfe_flexible_layouts_templates']) && !empty($field_flexible['acfe_flexible_layouts_templates']);
|
403 |
+
$is_flexible_modal_enabled = isset($field_flexible['acfe_flexible_modal']['acfe_flexible_modal_enabled']) && !empty($field_flexible['acfe_flexible_modal']['acfe_flexible_modal_enabled']);
|
404 |
+
$is_flexible_modal_categories = isset($field_flexible['acfe_flexible_modal']['acfe_flexible_modal_categories']) && !empty($field_flexible['acfe_flexible_modal']['acfe_flexible_modal_categories']);
|
405 |
+
|
406 |
+
// Category
|
407 |
+
if($is_flexible_modal_enabled && $is_flexible_modal_categories){
|
408 |
+
|
409 |
+
$acfe_flexible_category = isset($layout['acfe_flexible_category']) ? $layout['acfe_flexible_category'] : '';
|
410 |
+
|
411 |
+
acf_render_field_wrap(array(
|
412 |
+
'prepend' => __('Category'),
|
413 |
+
'name' => 'acfe_flexible_category',
|
414 |
+
'type' => 'text',
|
415 |
+
'class' => 'acf-fc-meta-name',
|
416 |
+
'prefix' => $layout_prefix,
|
417 |
+
'value' => $acfe_flexible_category,
|
418 |
+
'placeholder' => __('Multiple categories can be set using "|"')
|
419 |
+
|
420 |
+
/*
|
421 |
+
'conditional_logic' => array(
|
422 |
+
array(
|
423 |
+
array(
|
424 |
+
'field' => 'acfe_flexible_modal_enabled',
|
425 |
+
'operator' => '==',
|
426 |
+
'value' => '1',
|
427 |
+
),
|
428 |
+
array(
|
429 |
+
'field' => 'acfe_flexible_modal_categories',
|
430 |
+
'operator' => '==',
|
431 |
+
'value' => '1',
|
432 |
+
)
|
433 |
+
)
|
434 |
+
)
|
435 |
+
*/
|
436 |
+
|
437 |
+
), 'ul');
|
438 |
+
|
439 |
+
}
|
440 |
+
|
441 |
+
// Template
|
442 |
+
if($is_flexible_layouts_templates){
|
443 |
+
|
444 |
+
$acfe_flexible_render_template = isset($layout['acfe_flexible_render_template']) ? $layout['acfe_flexible_render_template'] : '';
|
445 |
+
|
446 |
+
acf_render_field_wrap(array(
|
447 |
+
'label' => __('Render'),
|
448 |
+
'prepend' => str_replace(home_url(), '', ACFE_THEME_URL) . '/',
|
449 |
+
'name' => 'acfe_flexible_render_template',
|
450 |
+
'type' => 'text',
|
451 |
+
'class' => 'acf-fc-meta-name',
|
452 |
+
'prefix' => $layout_prefix,
|
453 |
+
'value' => $acfe_flexible_render_template,
|
454 |
+
'placeholder' => 'template.php',
|
455 |
+
|
456 |
+
/*
|
457 |
+
'conditional_logic' => array(
|
458 |
+
array(
|
459 |
+
array(
|
460 |
+
'field' => 'acfe_flexible_layouts_templates',
|
461 |
+
'operator' => '==',
|
462 |
+
'value' => '1',
|
463 |
+
)
|
464 |
+
)
|
465 |
+
)
|
466 |
+
*/
|
467 |
+
|
468 |
+
), 'ul');
|
469 |
+
|
470 |
+
$acfe_flexible_render_style = isset($layout['acfe_flexible_render_style']) ? $layout['acfe_flexible_render_style'] : '';
|
471 |
+
|
472 |
+
acf_render_field_wrap(array(
|
473 |
+
'prepend' => str_replace(home_url(), '', ACFE_THEME_URL) . '/',
|
474 |
+
'name' => 'acfe_flexible_render_style',
|
475 |
+
'type' => 'text',
|
476 |
+
'class' => 'acf-fc-meta-name',
|
477 |
+
'prefix' => $layout_prefix,
|
478 |
+
'value' => $acfe_flexible_render_style,
|
479 |
+
'placeholder' => 'style.css',
|
480 |
+
|
481 |
+
/*
|
482 |
+
'conditional_logic' => array(
|
483 |
+
array(
|
484 |
+
array(
|
485 |
+
'field' => 'acfe_flexible_layouts_templates',
|
486 |
+
'operator' => '==',
|
487 |
+
'value' => '1',
|
488 |
+
)
|
489 |
+
)
|
490 |
+
)
|
491 |
+
*/
|
492 |
+
|
493 |
+
), 'ul');
|
494 |
+
|
495 |
+
$acfe_flexible_render_script = isset($layout['acfe_flexible_render_script']) ? $layout['acfe_flexible_render_script'] : '';
|
496 |
+
|
497 |
+
acf_render_field_wrap(array(
|
498 |
+
'prepend' => str_replace(home_url(), '', ACFE_THEME_URL) . '/',
|
499 |
+
'name' => 'acfe_flexible_render_script',
|
500 |
+
'type' => 'text',
|
501 |
+
'class' => 'acf-fc-meta-name',
|
502 |
+
'prefix' => $layout_prefix,
|
503 |
+
'value' => $acfe_flexible_render_script,
|
504 |
+
'placeholder' => 'script.js',
|
505 |
+
|
506 |
+
/*
|
507 |
+
'conditional_logic' => array(
|
508 |
+
array(
|
509 |
+
array(
|
510 |
+
'field' => 'acfe_flexible_layouts_templates',
|
511 |
+
'operator' => '==',
|
512 |
+
'value' => '1',
|
513 |
+
)
|
514 |
+
)
|
515 |
+
)
|
516 |
+
*/
|
517 |
+
|
518 |
+
), 'ul');
|
519 |
+
|
520 |
+
}
|
521 |
+
|
522 |
+
// Thumbnail
|
523 |
+
if($is_flexible_layouts_thumbnails){
|
524 |
+
|
525 |
+
$acfe_flexible_thumbnail = isset($layout['acfe_flexible_thumbnail']) ? $layout['acfe_flexible_thumbnail'] : '';
|
526 |
+
|
527 |
+
acf_render_field_wrap(array(
|
528 |
+
'label' => __('Thumbnail'),
|
529 |
+
'name' => 'acfe_flexible_thumbnail',
|
530 |
+
'type' => 'image',
|
531 |
+
'class' => '',
|
532 |
+
'prefix' => $layout_prefix,
|
533 |
+
'value' => $acfe_flexible_thumbnail,
|
534 |
+
'return_format' => 'array',
|
535 |
+
'preview_size' => 'thumbnail',
|
536 |
+
'library' => 'all',
|
537 |
+
|
538 |
+
/*
|
539 |
+
'conditional_logic' => array(
|
540 |
+
array(
|
541 |
+
array(
|
542 |
+
'field' => 'acfe_flexible_layouts_thumbnails',
|
543 |
+
'operator' => '==',
|
544 |
+
'value' => '1',
|
545 |
+
)
|
546 |
+
)
|
547 |
+
)
|
548 |
+
*/
|
549 |
+
|
550 |
+
), 'ul');
|
551 |
+
|
552 |
+
}
|
553 |
+
|
554 |
+
}
|
555 |
+
|
556 |
+
add_filter('acfe/field_wrapper_attributes/type=flexible_content', 'acfe_flexible_wrapper', 10, 2);
|
557 |
+
function acfe_flexible_wrapper($wrapper, $field){
|
558 |
+
|
559 |
+
// Stylised button
|
560 |
+
if(acf_maybe_get($field, 'acfe_flexible_stylised_button')){
|
561 |
+
|
562 |
+
$wrapper['data-acfe-flexible-stylised-button'] = 1;
|
563 |
+
|
564 |
+
}
|
565 |
+
|
566 |
+
// Hide Empty Message
|
567 |
+
if(acf_maybe_get($field, 'acfe_flexible_hide_empty_message') || acf_maybe_get($field, 'acfe_flexible_stylised_button')){
|
568 |
+
|
569 |
+
$wrapper['data-acfe-flexible-hide-empty-message'] = 1;
|
570 |
+
|
571 |
+
}
|
572 |
+
|
573 |
+
// Modal: Edition
|
574 |
+
if(acf_maybe_get($field, 'acfe_flexible_modal_edition')){
|
575 |
+
|
576 |
+
$wrapper['data-acfe-flexible-modal-edition'] = 1;
|
577 |
+
|
578 |
+
}
|
579 |
+
|
580 |
+
// Modal: Selection
|
581 |
+
if(isset($field['acfe_flexible_modal']['acfe_flexible_modal_enabled']) && !empty($field['acfe_flexible_modal']['acfe_flexible_modal_enabled'])){
|
582 |
+
|
583 |
+
$wrapper['data-acfe-flexible-modal'] = 1;
|
584 |
+
|
585 |
+
// Columns
|
586 |
+
if(isset($field['acfe_flexible_modal']['acfe_flexible_modal_col']) && !empty($field['acfe_flexible_modal']['acfe_flexible_modal_col']))
|
587 |
+
$wrapper['data-acfe-flexible-modal-col'] = $field['acfe_flexible_modal']['acfe_flexible_modal_col'];
|
588 |
+
|
589 |
+
// Title
|
590 |
+
if(isset($field['acfe_flexible_modal']['acfe_flexible_modal_title']) && !empty($field['acfe_flexible_modal']['acfe_flexible_modal_title']))
|
591 |
+
$wrapper['data-acfe-flexible-modal-title'] = $field['acfe_flexible_modal']['acfe_flexible_modal_title'];
|
592 |
+
|
593 |
+
}
|
594 |
+
|
595 |
+
// Layouts: Title Edition
|
596 |
+
if(acf_maybe_get($field, 'acfe_flexible_title_edition')){
|
597 |
+
|
598 |
+
$wrapper['data-acfe-flexible-title-edition'] = 1;
|
599 |
+
|
600 |
+
}
|
601 |
+
|
602 |
+
// Layouts: Close Button
|
603 |
+
if(acf_maybe_get($field, 'acfe_flexible_close_button')){
|
604 |
+
|
605 |
+
$wrapper['data-acfe-flexible-close-button'] = 1;
|
606 |
+
|
607 |
+
}
|
608 |
+
|
609 |
+
// Layouts: Copy/paste
|
610 |
+
if(acf_maybe_get($field, 'acfe_flexible_copy_paste')){
|
611 |
+
|
612 |
+
$wrapper['data-acfe-flexible-copy-paste'] = 1;
|
613 |
+
|
614 |
+
}
|
615 |
+
|
616 |
+
// Layouts: State
|
617 |
+
if(!acf_maybe_get($field, 'acfe_flexible_modal_edition')){
|
618 |
+
|
619 |
+
if(acf_maybe_get($field, 'acfe_flexible_layouts_state')){
|
620 |
+
|
621 |
+
// Collapse
|
622 |
+
if($field['acfe_flexible_layouts_state'] === 'collapse'){
|
623 |
+
|
624 |
+
$wrapper['data-acfe-flexible-close'] = 1;
|
625 |
+
|
626 |
+
}
|
627 |
+
|
628 |
+
// Open
|
629 |
+
elseif($field['acfe_flexible_layouts_state'] === 'open'){
|
630 |
+
|
631 |
+
$wrapper['data-acfe-flexible-open'] = 1;
|
632 |
+
|
633 |
+
}
|
634 |
+
|
635 |
+
}
|
636 |
+
|
637 |
+
// Layouts Remove Collapse
|
638 |
+
if(acf_maybe_get($field, 'acfe_flexible_layouts_remove_collapse')){
|
639 |
+
|
640 |
+
$wrapper['data-acfe-flexible-remove-collapse'] = 1;
|
641 |
+
|
642 |
+
}
|
643 |
+
|
644 |
+
}
|
645 |
+
|
646 |
+
// Layouts Placeholder
|
647 |
+
if(acf_maybe_get($field, 'acfe_flexible_layouts_placeholder')){
|
648 |
+
|
649 |
+
$wrapper['data-acfe-flexible-placeholder'] = 1;
|
650 |
+
|
651 |
+
}
|
652 |
+
|
653 |
+
// Layouts Previews
|
654 |
+
if(acf_maybe_get($field, 'acfe_flexible_layouts_templates') && acf_maybe_get($field, 'acfe_flexible_layouts_previews')){
|
655 |
+
|
656 |
+
$wrapper['data-acfe-flexible-preview'] = 1;
|
657 |
+
|
658 |
+
}
|
659 |
+
|
660 |
+
// Placeholder Icon
|
661 |
+
$layout_placeholder_icon = false;
|
662 |
+
$layout_placeholder_icon = apply_filters('acfe/flexible/placeholder/icon', $layout_placeholder_icon, $field);
|
663 |
+
$layout_placeholder_icon = apply_filters('acfe/flexible/placeholder/icon/name=' . $field['_name'], $layout_placeholder_icon, $field);
|
664 |
+
$layout_placeholder_icon = apply_filters('acfe/flexible/placeholder/icon/key=' . $field['key'], $layout_placeholder_icon, $field);
|
665 |
+
|
666 |
+
if(!empty($layout_placeholder_icon)){
|
667 |
+
|
668 |
+
$wrapper['data-acfe-flexible-placeholder-icon'] = $layout_placeholder_icon;
|
669 |
+
|
670 |
+
}
|
671 |
+
|
672 |
+
// Lock sortable
|
673 |
+
$acfe_flexible_lock_sortable = false;
|
674 |
+
$acfe_flexible_lock_sortable = apply_filters('acfe/flexible/lock', $acfe_flexible_lock_sortable, $field);
|
675 |
+
$acfe_flexible_lock_sortable = apply_filters('acfe/flexible/lock/name=' . $field['_name'], $acfe_flexible_lock_sortable, $field);
|
676 |
+
$acfe_flexible_lock_sortable = apply_filters('acfe/flexible/lock/key=' . $field['key'], $acfe_flexible_lock_sortable, $field);
|
677 |
+
|
678 |
+
if($acfe_flexible_lock_sortable){
|
679 |
+
|
680 |
+
$wrapper['data-acfe-flexible-lock'] = 1;
|
681 |
+
|
682 |
+
}
|
683 |
+
|
684 |
+
// Remove actions
|
685 |
+
$acfe_flexible_remove_actions = false;
|
686 |
+
$acfe_flexible_remove_actions = apply_filters('acfe/flexible/remove_actions', $acfe_flexible_remove_actions, $field);
|
687 |
+
$acfe_flexible_remove_actions = apply_filters('acfe/flexible/remove_actions/name=' . $field['_name'], $acfe_flexible_remove_actions, $field);
|
688 |
+
$acfe_flexible_remove_actions = apply_filters('acfe/flexible/remove_actions/key=' . $field['key'], $acfe_flexible_remove_actions, $field);
|
689 |
+
|
690 |
+
if($acfe_flexible_remove_actions){
|
691 |
+
|
692 |
+
$wrapper['data-acfe-flexible-remove-actions'] = 1;
|
693 |
+
|
694 |
+
}
|
695 |
+
|
696 |
+
// Remove ajax 'layout_title' call
|
697 |
+
$acfe_flexible_remove_ajax_title = false;
|
698 |
+
$acfe_flexible_remove_ajax_title = apply_filters('acfe/flexible/remove_ajax_title', $acfe_flexible_remove_ajax_title, $field);
|
699 |
+
$acfe_flexible_remove_ajax_title = apply_filters('acfe/flexible/remove_ajax_title/name=' . $field['_name'], $acfe_flexible_remove_ajax_title, $field);
|
700 |
+
$acfe_flexible_remove_ajax_title = apply_filters('acfe/flexible/remove_ajax_title/key=' . $field['key'], $acfe_flexible_remove_ajax_title, $field);
|
701 |
+
|
702 |
+
if($acfe_flexible_remove_ajax_title){
|
703 |
+
|
704 |
+
$wrapper['data-acfe-flexible-remove-ajax-title'] = 1;
|
705 |
+
|
706 |
+
}
|
707 |
+
|
708 |
+
return $wrapper;
|
709 |
+
|
710 |
+
}
|
711 |
+
|
712 |
+
add_filter('acf/fields/flexible_content/no_value_message', 'acfe_flexible_empty_message', 10, 2);
|
713 |
+
function acfe_flexible_empty_message($message, $field){
|
714 |
+
|
715 |
+
if(!isset($field['acfe_flexible_empty_message']) || empty($field['acfe_flexible_empty_message']))
|
716 |
+
return $message;
|
717 |
+
|
718 |
+
return $field['acfe_flexible_empty_message'];
|
719 |
+
|
720 |
+
}
|
721 |
+
|
722 |
+
add_filter('acf/prepare_field/type=flexible_content', 'acfe_flexible_layout_title_prepare');
|
723 |
+
function acfe_flexible_layout_title_prepare($field){
|
724 |
+
|
725 |
+
if(empty($field['layouts']))
|
726 |
+
return $field;
|
727 |
+
|
728 |
+
foreach($field['layouts'] as $k => &$layout){
|
729 |
+
|
730 |
+
// vars
|
731 |
+
$thumbnail = false;
|
732 |
+
$span_class = false;
|
733 |
+
|
734 |
+
// thumbnail
|
735 |
+
if(isset($field['acfe_flexible_layouts_thumbnails']) && !empty($field['acfe_flexible_layouts_thumbnails'])){
|
736 |
+
|
737 |
+
$class = $style = array();
|
738 |
+
$class[] = 'acfe-flexible-layout-thumbnail';
|
739 |
+
|
740 |
+
// Modal disabled
|
741 |
+
if(!isset($field['acfe_flexible_modal']['acfe_flexible_modal_enabled']) || empty($field['acfe_flexible_modal']['acfe_flexible_modal_enabled']))
|
742 |
+
$class[] = 'acfe-flexible-layout-thumbnail-no-modal';
|
743 |
+
|
744 |
+
// Thumbnail is set
|
745 |
+
$thumbnail_found = false;
|
746 |
+
|
747 |
+
$acfe_flexible_thumbnail = false;
|
748 |
+
if(isset($layout['acfe_flexible_thumbnail']) && !empty($layout['acfe_flexible_thumbnail']))
|
749 |
+
$acfe_flexible_thumbnail = $layout['acfe_flexible_thumbnail'];
|
750 |
+
|
751 |
+
// Filter: acfe/flexible/layout/thumbnail/name={field:flexible:name}&layout={field:flexible:layout_name}
|
752 |
+
// Flexible Thumbnails
|
753 |
+
$acfe_flexible_thumbnail = apply_filters('acfe/flexible/thumbnail/name=' . $field['_name'], $acfe_flexible_thumbnail, $field, $layout);
|
754 |
+
$acfe_flexible_thumbnail = apply_filters('acfe/flexible/thumbnail/key=' . $field['key'], $acfe_flexible_thumbnail, $field, $layout);
|
755 |
+
|
756 |
+
$acfe_flexible_thumbnail = apply_filters('acfe/flexible/layout/thumbnail/layout=' . $layout['name'], $acfe_flexible_thumbnail, $field, $layout);
|
757 |
+
$acfe_flexible_thumbnail = apply_filters('acfe/flexible/layout/thumbnail/name=' . $field['_name'] . '&layout=' . $layout['name'], $acfe_flexible_thumbnail, $field, $layout);
|
758 |
+
$acfe_flexible_thumbnail = apply_filters('acfe/flexible/layout/thumbnail/key=' . $field['key'] . '&layout=' . $layout['name'], $acfe_flexible_thumbnail, $field, $layout);
|
759 |
+
|
760 |
+
if(!empty($acfe_flexible_thumbnail)){
|
761 |
+
|
762 |
+
// Thumbnail ID
|
763 |
+
if(is_numeric($acfe_flexible_thumbnail)){
|
764 |
+
|
765 |
+
if($thumbnail_src = wp_get_attachment_url($acfe_flexible_thumbnail)){
|
766 |
+
|
767 |
+
$thumbnail_found = true;
|
768 |
+
$style[] = 'background-image:url(' . $thumbnail_src . ');';
|
769 |
+
|
770 |
+
}
|
771 |
+
|
772 |
+
}
|
773 |
+
|
774 |
+
// Thumbnail URL
|
775 |
+
else{
|
776 |
+
|
777 |
+
$thumbnail_found = true;
|
778 |
+
$style[] = 'background-image:url(' . $acfe_flexible_thumbnail . ');';
|
779 |
+
|
780 |
+
}
|
781 |
+
|
782 |
+
}
|
783 |
+
|
784 |
+
// Thumbnail not found
|
785 |
+
if(!$thumbnail_found){
|
786 |
+
|
787 |
+
$class[] = 'acfe-flexible-layout-thumbnail-not-found';
|
788 |
+
|
789 |
+
}
|
790 |
+
|
791 |
+
$thumbnail = '<div class="' . implode(' ', $class) . '" style="' . implode(' ', $style) . '"></div>';
|
792 |
+
|
793 |
+
}
|
794 |
+
|
795 |
+
// No Thumbnails
|
796 |
+
else{
|
797 |
+
|
798 |
+
$span_class = 'class="no-thumbnail"';
|
799 |
+
|
800 |
+
}
|
801 |
+
|
802 |
+
// Category
|
803 |
+
$category = '';
|
804 |
+
if(acf_maybe_get($field['acfe_flexible_modal'], 'acfe_flexible_modal_categories') && acf_maybe_get($layout, 'acfe_flexible_category')){
|
805 |
+
|
806 |
+
$category = 'data-acfe-flexible-category="' . $layout['acfe_flexible_category'] . '"';
|
807 |
+
|
808 |
+
}
|
809 |
+
|
810 |
+
$layout['label'] = $thumbnail . '<span '.$category.' ' . $span_class . '>' . $layout['label'] . '</span>';
|
811 |
+
|
812 |
+
}
|
813 |
+
|
814 |
+
return $field;
|
815 |
+
|
816 |
+
}
|
817 |
+
|
818 |
+
add_filter('acf/fields/flexible_content/layout_title', 'acfe_flexible_layout_title_ajax', 0, 4);
|
819 |
+
function acfe_flexible_layout_title_ajax($title, $field, $layout, $i){
|
820 |
+
|
821 |
+
// Remove thumbnail
|
822 |
+
$title = preg_replace('#<div class="acfe-flexible-layout-thumbnail(.*?)</div>#', '', $title);
|
823 |
+
|
824 |
+
// Title Edition
|
825 |
+
if(isset($field['acfe_flexible_title_edition']) && !empty($field['acfe_flexible_title_edition'])){
|
826 |
+
|
827 |
+
// Get Layout Title
|
828 |
+
$acfe_flexible_layout_title = get_sub_field('acfe_flexible_layout_title');
|
829 |
+
if(!empty($acfe_flexible_layout_title))
|
830 |
+
$title = wp_unslash($acfe_flexible_layout_title);
|
831 |
+
|
832 |
+
// Return
|
833 |
+
return '<span class="acfe-layout-title acf-js-tooltip" title="' . __('Layout', 'acfe') . ': ' . esc_attr(strip_tags($layout['label'])) . '"><span class="acfe-layout-title-text">' . $title . '</span></span>';
|
834 |
+
|
835 |
+
}
|
836 |
+
|
837 |
+
// Return
|
838 |
+
return '<span class="acfe-layout-title-text">' . $title . '</span></span>';
|
839 |
+
|
840 |
+
}
|
841 |
+
|
842 |
+
add_action('acf/render_field/type=flexible_content', 'acfe_flexible_render_field');
|
843 |
+
function acfe_flexible_render_field($field){
|
844 |
+
|
845 |
+
if(!isset($field['acfe_flexible_layouts_templates']) || empty($field['acfe_flexible_layouts_templates']) || !isset($field['acfe_flexible_layouts_previews']) || empty($field['acfe_flexible_layouts_previews']) || empty($field['layouts']))
|
846 |
+
return;
|
847 |
+
|
848 |
+
// Vars
|
849 |
+
$is_preview = true;
|
850 |
+
|
851 |
+
// Actions
|
852 |
+
do_action('acfe/flexible/enqueue', $field, $is_preview);
|
853 |
+
do_action('acfe/flexible/enqueue/name=' . $field['_name'], $field, $is_preview);
|
854 |
+
do_action('acfe/flexible/enqueue/key=' . $field['key'], $field, $is_preview);
|
855 |
+
|
856 |
+
// Layouts Previews
|
857 |
+
foreach($field['layouts'] as $layout_key => $layout){
|
858 |
+
|
859 |
+
// Render: Enqueue
|
860 |
+
acfe_flexible_render_layout_enqueue($layout, $field);
|
861 |
+
|
862 |
+
}
|
863 |
+
|
864 |
+
}
|
865 |
+
|
866 |
+
add_action('wp_ajax_acfe/flexible/layout_preview', 'acfe_flexible_layout_preview');
|
867 |
+
function acfe_flexible_layout_preview(){
|
868 |
+
|
869 |
+
// Options
|
870 |
+
$options = acf_parse_args($_POST, array(
|
871 |
+
'post_id' => 0,
|
872 |
+
'i' => 0,
|
873 |
+
'field_key' => '',
|
874 |
+
'nonce' => '',
|
875 |
+
'layout' => '',
|
876 |
+
'value' => array()
|
877 |
+
));
|
878 |
+
|
879 |
+
// Load field
|
880 |
+
$field = acf_get_field($options['field_key']);
|
881 |
+
if(!$field)
|
882 |
+
die;
|
883 |
+
|
884 |
+
// Get Flexible
|
885 |
+
$flexible = acf_get_field_type('flexible_content');
|
886 |
+
|
887 |
+
// Vars
|
888 |
+
$layout = $flexible->get_layout($options['layout'], $field);
|
889 |
+
if(!$layout)
|
890 |
+
die;
|
891 |
+
|
892 |
+
if(!acf_maybe_get($layout, 'acfe_flexible_thumbnail'))
|
893 |
+
$layout['acfe_flexible_thumbnail'] = false;
|
894 |
+
|
895 |
+
// Flexible Thumbnails
|
896 |
+
$layout['acfe_flexible_thumbnail'] = apply_filters('acfe/flexible/thumbnail/name=' . $field['_name'], $layout['acfe_flexible_thumbnail'], $field, $layout);
|
897 |
+
$layout['acfe_flexible_thumbnail'] = apply_filters('acfe/flexible/thumbnail/key=' . $field['key'], $layout['acfe_flexible_thumbnail'], $field, $layout);
|
898 |
+
|
899 |
+
// Layout Thumbnails
|
900 |
+
$layout['acfe_flexible_thumbnail'] = apply_filters('acfe/flexible/layout/thumbnail/layout=' . $layout['name'], $layout['acfe_flexible_thumbnail'], $field, $layout);
|
901 |
+
$layout['acfe_flexible_thumbnail'] = apply_filters('acfe/flexible/layout/thumbnail/name=' . $field['_name'] . '&layout=' . $layout['name'], $layout['acfe_flexible_thumbnail'], $field, $layout);
|
902 |
+
$layout['acfe_flexible_thumbnail'] = apply_filters('acfe/flexible/layout/thumbnail/key=' . $field['key'] . '&layout=' . $layout['name'], $layout['acfe_flexible_thumbnail'], $field, $layout);
|
903 |
+
|
904 |
+
$get_field_object = get_field_object($options['field_key'], $options['post_id'], false, false);
|
905 |
+
|
906 |
+
$preview_key = 'preview_' . $options['field_key'];
|
907 |
+
$get_field_object['key'] = $preview_key;
|
908 |
+
|
909 |
+
acf_add_local_field($get_field_object);
|
910 |
+
|
911 |
+
add_filter('acf/load_value/key=' . $preview_key, function($value, $post_id, $field) use($options){
|
912 |
+
|
913 |
+
$value = array();
|
914 |
+
$value[0] = wp_unslash($options['value']);
|
915 |
+
|
916 |
+
return $value;
|
917 |
+
|
918 |
+
}, 10, 3);
|
919 |
+
|
920 |
+
if(have_rows($preview_key)):
|
921 |
+
while(have_rows($preview_key)): the_row();
|
922 |
+
|
923 |
+
// Flexible Preview
|
924 |
+
do_action('acfe/flexible/preview/name=' . $field['_name'], $field, $layout);
|
925 |
+
do_action('acfe/flexible/preview/key=' . $field['key'], $field, $layout);
|
926 |
+
|
927 |
+
// Flexible Layout Preview
|
928 |
+
do_action('acfe/flexible/layout/preview/layout=' . $layout['name'], $field, $layout);
|
929 |
+
do_action('acfe/flexible/layout/preview/name=' . $field['_name'] . '&layout=' . $layout['name'], $field, $layout);
|
930 |
+
do_action('acfe/flexible/layout/preview/key=' . $field['key'] . '&layout=' . $layout['name'], $field, $layout);
|
931 |
+
|
932 |
+
// ACFE: All Flexible Preview
|
933 |
+
do_action('acfe/flexible/preview', $field, $layout);
|
934 |
+
|
935 |
+
endwhile;
|
936 |
+
endif;
|
937 |
+
|
938 |
+
die;
|
939 |
+
|
940 |
+
}
|
941 |
+
|
942 |
+
add_action('acfe/flexible/preview', 'acfe_flexible_layout_preview_render', 99, 2);
|
943 |
+
function acfe_flexible_layout_preview_render($field, $layout){
|
944 |
+
|
945 |
+
global $is_preview;
|
946 |
+
|
947 |
+
$is_preview = true;
|
948 |
+
|
949 |
+
acfe_flexible_render_layout_template($layout, $field);
|
950 |
+
|
951 |
+
}
|
952 |
+
|
953 |
+
add_filter('acfe/flexible/render/template', 'acfe_flexible_layout_render_template_setting', 0, 4);
|
954 |
+
function acfe_flexible_layout_render_template_setting($return, $field, $layout, $is_preview){
|
955 |
+
|
956 |
+
if(isset($layout['acfe_flexible_render_template']) && !empty($layout['acfe_flexible_render_template']))
|
957 |
+
$return = $layout['acfe_flexible_render_template'];
|
958 |
+
|
959 |
+
return $return;
|
960 |
+
|
961 |
+
}
|
962 |
+
|
963 |
+
add_filter('acfe/flexible/render/style', 'acfe_flexible_layout_render_style_setting', 0, 4);
|
964 |
+
function acfe_flexible_layout_render_style_setting($return, $field, $layout, $is_preview){
|
965 |
+
|
966 |
+
if(isset($layout['acfe_flexible_render_style']) && !empty($layout['acfe_flexible_render_style']))
|
967 |
+
$return = $layout['acfe_flexible_render_style'];
|
968 |
+
|
969 |
+
return $return;
|
970 |
+
|
971 |
+
}
|
972 |
+
|
973 |
+
add_filter('acfe/flexible/render/script', 'acfe_flexible_layout_render_script_setting', 0, 4);
|
974 |
+
function acfe_flexible_layout_render_script_setting($return, $field, $layout, $is_preview){
|
975 |
+
|
976 |
+
if(isset($layout['acfe_flexible_render_script']) && !empty($layout['acfe_flexible_render_script']))
|
977 |
+
$return = $layout['acfe_flexible_render_script'];
|
978 |
+
|
979 |
+
return $return;
|
980 |
+
|
981 |
+
}
|
982 |
+
|
983 |
+
add_filter('acf/load_field/type=flexible_content', 'acfe_flexible_layout_title_subfield');
|
984 |
+
function acfe_flexible_layout_title_subfield($field){
|
985 |
+
|
986 |
+
global $typenow;
|
987 |
+
|
988 |
+
if(acf_is_screen(array('edit-acf-field-group', 'acf-field-group')) || (isset($typenow) && $typenow === 'acf-field-group'))
|
989 |
+
return $field;
|
990 |
+
|
991 |
+
if(!isset($field['layouts']) || empty($field['layouts']))
|
992 |
+
return $field;
|
993 |
+
|
994 |
+
if(!isset($field['acfe_flexible_title_edition']) || empty($field['acfe_flexible_title_edition']))
|
995 |
+
return $field;
|
996 |
+
|
997 |
+
foreach($field['layouts'] as $layout_key => &$layout){
|
998 |
+
|
999 |
+
// Add the input as the first sub_field
|
1000 |
+
array_unshift($layout['sub_fields'] , array(
|
1001 |
+
'ID' => false,
|
1002 |
+
'label' => false,
|
1003 |
+
'key' => 'field_acfe_flexible_layout_title',
|
1004 |
+
'name' => 'acfe_flexible_layout_title',
|
1005 |
+
'_name' => 'acfe_flexible_layout_title',
|
1006 |
+
'type' => 'text',
|
1007 |
+
'required' => 0,
|
1008 |
+
'maxlength' => null,
|
1009 |
+
'parent' => false,
|
1010 |
+
'default_value' => $layout['label'],
|
1011 |
+
'placeholder' => $layout['label'],
|
1012 |
+
'wrapper' => array(
|
1013 |
+
'id' => '',
|
1014 |
+
'class' => '',
|
1015 |
+
'width' => '',
|
1016 |
+
)
|
1017 |
+
));
|
1018 |
+
|
1019 |
+
}
|
1020 |
+
|
1021 |
+
return $field;
|
1022 |
+
|
1023 |
}
|
includes/fields/field-forms.php
CHANGED
@@ -1,381 +1,394 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
if(!class_exists('acfe_field_forms')):
|
7 |
-
|
8 |
-
class acfe_field_forms extends acf_field{
|
9 |
-
|
10 |
-
function __construct(){
|
11 |
-
|
12 |
-
$this->name = 'acfe_forms';
|
13 |
-
$this->label = __('Forms', 'acfe');
|
14 |
-
$this->category = 'relational';
|
15 |
-
$this->defaults = array(
|
16 |
-
'post_type' => array(),
|
17 |
-
'field_type' => 'checkbox',
|
18 |
-
'multiple' => 0,
|
19 |
-
'allow_null' => 0,
|
20 |
-
'choices' => array(),
|
21 |
-
'default_value' => '',
|
22 |
-
'ui' => 0,
|
23 |
-
'ajax' => 0,
|
24 |
-
'placeholder' => '',
|
25 |
-
'layout' => '',
|
26 |
-
'toggle' => 0,
|
27 |
-
'allow_custom' => 0,
|
28 |
-
'return_format' => 'name',
|
29 |
-
);
|
30 |
-
|
31 |
-
parent::__construct();
|
32 |
-
|
33 |
-
}
|
34 |
-
|
35 |
-
function prepare_field($field){
|
36 |
-
|
37 |
-
$field['choices'] = acfe_get_pretty_forms($field['forms']);
|
38 |
-
|
39 |
-
// Set Field Type
|
40 |
-
$field['type'] = $field['field_type'];
|
41 |
-
|
42 |
-
return $field;
|
43 |
-
|
44 |
-
}
|
45 |
-
|
46 |
-
function render_field_settings($field){
|
47 |
-
|
48 |
-
if(isset($field['default_value']))
|
49 |
-
$field['default_value'] = acf_encode_choices($field['default_value'], false);
|
50 |
-
|
51 |
-
// Allow Form
|
52 |
-
acf_render_field_setting($field, array(
|
53 |
-
'label' => __('Allow Forms','acf'),
|
54 |
-
'instructions' => '',
|
55 |
-
'type' => 'select',
|
56 |
-
'name' => 'forms',
|
57 |
-
'choices' => acfe_get_pretty_forms(),
|
58 |
-
'multiple' => 1,
|
59 |
-
'ui' => 1,
|
60 |
-
'allow_null' => 1,
|
61 |
-
'placeholder' => __("All forms",'acf'),
|
62 |
-
));
|
63 |
-
|
64 |
-
// field_type
|
65 |
-
acf_render_field_setting($field, array(
|
66 |
-
'label' => __('Appearance','acf'),
|
67 |
-
'instructions' => __('Select the appearance of this field', 'acf'),
|
68 |
-
'type' => 'select',
|
69 |
-
'name' => 'field_type',
|
70 |
-
'optgroup' => true,
|
71 |
-
'choices' => array(
|
72 |
-
'checkbox' => __('Checkbox', 'acf'),
|
73 |
-
'radio' => __('Radio Buttons', 'acf'),
|
74 |
-
'select' => _x('Select', 'noun', 'acf')
|
75 |
-
)
|
76 |
-
));
|
77 |
-
|
78 |
-
// default_value
|
79 |
-
acf_render_field_setting($field, array(
|
80 |
-
'label' => __('Default Value','acf'),
|
81 |
-
'instructions' => __('Enter each default value on a new line','acf'),
|
82 |
-
'name' => 'default_value',
|
83 |
-
'type' => 'textarea',
|
84 |
-
));
|
85 |
-
|
86 |
-
// return_format
|
87 |
-
acf_render_field_setting($field, array(
|
88 |
-
'label' => __('Return Value', 'acf'),
|
89 |
-
'instructions' => '',
|
90 |
-
'type' => 'radio',
|
91 |
-
'name' => 'return_format',
|
92 |
-
'choices' => array(
|
93 |
-
'id' => __('Form ID', 'acfe'),
|
94 |
-
'name' => __('Form name', 'acfe')
|
95 |
-
),
|
96 |
-
'layout' => 'horizontal',
|
97 |
-
));
|
98 |
-
|
99 |
-
// Select + Radio: allow_null
|
100 |
-
acf_render_field_setting($field, array(
|
101 |
-
'label' => __('Allow Null?','acf'),
|
102 |
-
'instructions' => '',
|
103 |
-
'name' => 'allow_null',
|
104 |
-
'type' => 'true_false',
|
105 |
-
'ui' => 1,
|
106 |
-
'conditions' => array(
|
107 |
-
array(
|
108 |
-
array(
|
109 |
-
'field' => 'field_type',
|
110 |
-
'operator' => '==',
|
111 |
-
'value' => 'select',
|
112 |
-
),
|
113 |
-
),
|
114 |
-
array(
|
115 |
-
array(
|
116 |
-
'field' => 'field_type',
|
117 |
-
'operator' => '==',
|
118 |
-
'value' => 'radio',
|
119 |
-
),
|
120 |
-
),
|
121 |
-
)
|
122 |
-
));
|
123 |
-
|
124 |
-
// placeholder
|
125 |
-
acf_render_field_setting($field, array(
|
126 |
-
'label' => __('Placeholder Text','acf'),
|
127 |
-
'instructions' => __('Appears within the input','acf'),
|
128 |
-
'type' => 'text',
|
129 |
-
'name' => 'placeholder',
|
130 |
-
'placeholder' => _x('Select', 'verb', 'acf'),
|
131 |
-
'conditional_logic' => array(
|
132 |
-
array(
|
133 |
-
array(
|
134 |
-
'field' => 'field_type',
|
135 |
-
'operator' => '==',
|
136 |
-
'value' => 'select',
|
137 |
-
),
|
138 |
-
array(
|
139 |
-
'field' => 'allow_null',
|
140 |
-
'operator' => '==',
|
141 |
-
'value' => '1',
|
142 |
-
),
|
143 |
-
|
144 |
-
)
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
}
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
381 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
if(!class_exists('acfe_field_forms')):
|
7 |
+
|
8 |
+
class acfe_field_forms extends acf_field{
|
9 |
+
|
10 |
+
function __construct(){
|
11 |
+
|
12 |
+
$this->name = 'acfe_forms';
|
13 |
+
$this->label = __('Forms', 'acfe');
|
14 |
+
$this->category = 'relational';
|
15 |
+
$this->defaults = array(
|
16 |
+
'post_type' => array(),
|
17 |
+
'field_type' => 'checkbox',
|
18 |
+
'multiple' => 0,
|
19 |
+
'allow_null' => 0,
|
20 |
+
'choices' => array(),
|
21 |
+
'default_value' => '',
|
22 |
+
'ui' => 0,
|
23 |
+
'ajax' => 0,
|
24 |
+
'placeholder' => '',
|
25 |
+
'layout' => '',
|
26 |
+
'toggle' => 0,
|
27 |
+
'allow_custom' => 0,
|
28 |
+
'return_format' => 'name',
|
29 |
+
);
|
30 |
+
|
31 |
+
parent::__construct();
|
32 |
+
|
33 |
+
}
|
34 |
+
|
35 |
+
function prepare_field($field){
|
36 |
+
|
37 |
+
$field['choices'] = acfe_get_pretty_forms($field['forms']);
|
38 |
+
|
39 |
+
// Set Field Type
|
40 |
+
$field['type'] = $field['field_type'];
|
41 |
+
|
42 |
+
return $field;
|
43 |
+
|
44 |
+
}
|
45 |
+
|
46 |
+
function render_field_settings($field){
|
47 |
+
|
48 |
+
if(isset($field['default_value']))
|
49 |
+
$field['default_value'] = acf_encode_choices($field['default_value'], false);
|
50 |
+
|
51 |
+
// Allow Form
|
52 |
+
acf_render_field_setting($field, array(
|
53 |
+
'label' => __('Allow Forms','acf'),
|
54 |
+
'instructions' => '',
|
55 |
+
'type' => 'select',
|
56 |
+
'name' => 'forms',
|
57 |
+
'choices' => acfe_get_pretty_forms(),
|
58 |
+
'multiple' => 1,
|
59 |
+
'ui' => 1,
|
60 |
+
'allow_null' => 1,
|
61 |
+
'placeholder' => __("All forms",'acf'),
|
62 |
+
));
|
63 |
+
|
64 |
+
// field_type
|
65 |
+
acf_render_field_setting($field, array(
|
66 |
+
'label' => __('Appearance','acf'),
|
67 |
+
'instructions' => __('Select the appearance of this field', 'acf'),
|
68 |
+
'type' => 'select',
|
69 |
+
'name' => 'field_type',
|
70 |
+
'optgroup' => true,
|
71 |
+
'choices' => array(
|
72 |
+
'checkbox' => __('Checkbox', 'acf'),
|
73 |
+
'radio' => __('Radio Buttons', 'acf'),
|
74 |
+
'select' => _x('Select', 'noun', 'acf')
|
75 |
+
)
|
76 |
+
));
|
77 |
+
|
78 |
+
// default_value
|
79 |
+
acf_render_field_setting($field, array(
|
80 |
+
'label' => __('Default Value','acf'),
|
81 |
+
'instructions' => __('Enter each default value on a new line','acf'),
|
82 |
+
'name' => 'default_value',
|
83 |
+
'type' => 'textarea',
|
84 |
+
));
|
85 |
+
|
86 |
+
// return_format
|
87 |
+
acf_render_field_setting($field, array(
|
88 |
+
'label' => __('Return Value', 'acf'),
|
89 |
+
'instructions' => '',
|
90 |
+
'type' => 'radio',
|
91 |
+
'name' => 'return_format',
|
92 |
+
'choices' => array(
|
93 |
+
'id' => __('Form ID', 'acfe'),
|
94 |
+
'name' => __('Form name', 'acfe')
|
95 |
+
),
|
96 |
+
'layout' => 'horizontal',
|
97 |
+
));
|
98 |
+
|
99 |
+
// Select + Radio: allow_null
|
100 |
+
acf_render_field_setting($field, array(
|
101 |
+
'label' => __('Allow Null?','acf'),
|
102 |
+
'instructions' => '',
|
103 |
+
'name' => 'allow_null',
|
104 |
+
'type' => 'true_false',
|
105 |
+
'ui' => 1,
|
106 |
+
'conditions' => array(
|
107 |
+
array(
|
108 |
+
array(
|
109 |
+
'field' => 'field_type',
|
110 |
+
'operator' => '==',
|
111 |
+
'value' => 'select',
|
112 |
+
),
|
113 |
+
),
|
114 |
+
array(
|
115 |
+
array(
|
116 |
+
'field' => 'field_type',
|
117 |
+
'operator' => '==',
|
118 |
+
'value' => 'radio',
|
119 |
+
),
|
120 |
+
),
|
121 |
+
)
|
122 |
+
));
|
123 |
+
|
124 |
+
// placeholder
|
125 |
+
acf_render_field_setting($field, array(
|
126 |
+
'label' => __('Placeholder Text','acf'),
|
127 |
+
'instructions' => __('Appears within the input','acf'),
|
128 |
+
'type' => 'text',
|
129 |
+
'name' => 'placeholder',
|
130 |
+
'placeholder' => _x('Select', 'verb', 'acf'),
|
131 |
+
'conditional_logic' => array(
|
132 |
+
array(
|
133 |
+
array(
|
134 |
+
'field' => 'field_type',
|
135 |
+
'operator' => '==',
|
136 |
+
'value' => 'select',
|
137 |
+
),
|
138 |
+
array(
|
139 |
+
'field' => 'allow_null',
|
140 |
+
'operator' => '==',
|
141 |
+
'value' => '1',
|
142 |
+
),
|
143 |
+
|
144 |
+
),
|
145 |
+
array(
|
146 |
+
array(
|
147 |
+
'field' => 'field_type',
|
148 |
+
'operator' => '==',
|
149 |
+
'value' => 'select',
|
150 |
+
),
|
151 |
+
array(
|
152 |
+
'field' => 'ui',
|
153 |
+
'operator' => '==',
|
154 |
+
'value' => '1',
|
155 |
+
),
|
156 |
+
|
157 |
+
),
|
158 |
+
)
|
159 |
+
));
|
160 |
+
|
161 |
+
// Select: multiple
|
162 |
+
acf_render_field_setting($field, array(
|
163 |
+
'label' => __('Select multiple values?','acf'),
|
164 |
+
'instructions' => '',
|
165 |
+
'name' => 'multiple',
|
166 |
+
'type' => 'true_false',
|
167 |
+
'ui' => 1,
|
168 |
+
'conditions' => array(
|
169 |
+
array(
|
170 |
+
array(
|
171 |
+
'field' => 'field_type',
|
172 |
+
'operator' => '==',
|
173 |
+
'value' => 'select',
|
174 |
+
),
|
175 |
+
),
|
176 |
+
)
|
177 |
+
));
|
178 |
+
|
179 |
+
// Select: ui
|
180 |
+
acf_render_field_setting($field, array(
|
181 |
+
'label' => __('Stylised UI','acf'),
|
182 |
+
'instructions' => '',
|
183 |
+
'name' => 'ui',
|
184 |
+
'type' => 'true_false',
|
185 |
+
'ui' => 1,
|
186 |
+
'conditions' => array(
|
187 |
+
array(
|
188 |
+
array(
|
189 |
+
'field' => 'field_type',
|
190 |
+
'operator' => '==',
|
191 |
+
'value' => 'select',
|
192 |
+
),
|
193 |
+
),
|
194 |
+
)
|
195 |
+
));
|
196 |
+
|
197 |
+
|
198 |
+
// Select: ajax
|
199 |
+
acf_render_field_setting($field, array(
|
200 |
+
'label' => __('Use AJAX to lazy load choices?','acf'),
|
201 |
+
'instructions' => '',
|
202 |
+
'name' => 'ajax',
|
203 |
+
'type' => 'true_false',
|
204 |
+
'ui' => 1,
|
205 |
+
'conditions' => array(
|
206 |
+
array(
|
207 |
+
array(
|
208 |
+
'field' => 'field_type',
|
209 |
+
'operator' => '==',
|
210 |
+
'value' => 'select',
|
211 |
+
),
|
212 |
+
array(
|
213 |
+
'field' => 'ui',
|
214 |
+
'operator' => '==',
|
215 |
+
'value' => 1,
|
216 |
+
),
|
217 |
+
),
|
218 |
+
)
|
219 |
+
));
|
220 |
+
|
221 |
+
// Radio: other_choice
|
222 |
+
acf_render_field_setting($field, array(
|
223 |
+
'label' => __('Other','acf'),
|
224 |
+
'instructions' => '',
|
225 |
+
'name' => 'other_choice',
|
226 |
+
'type' => 'true_false',
|
227 |
+
'ui' => 1,
|
228 |
+
'message' => __("Add 'other' choice to allow for custom values", 'acf'),
|
229 |
+
'conditions' => array(
|
230 |
+
array(
|
231 |
+
array(
|
232 |
+
'field' => 'field_type',
|
233 |
+
'operator' => '==',
|
234 |
+
'value' => 'radio',
|
235 |
+
),
|
236 |
+
),
|
237 |
+
)
|
238 |
+
));
|
239 |
+
|
240 |
+
|
241 |
+
// Radio: save_other_choice
|
242 |
+
acf_render_field_setting($field, array(
|
243 |
+
'label' => __('Save Other','acf'),
|
244 |
+
'instructions' => '',
|
245 |
+
'name' => 'save_other_choice',
|
246 |
+
'type' => 'true_false',
|
247 |
+
'ui' => 1,
|
248 |
+
'message' => __("Save 'other' values to the field's choices", 'acf'),
|
249 |
+
'conditions' => array(
|
250 |
+
array(
|
251 |
+
array(
|
252 |
+
'field' => 'field_type',
|
253 |
+
'operator' => '==',
|
254 |
+
'value' => 'radio',
|
255 |
+
),
|
256 |
+
array(
|
257 |
+
'field' => 'other_choice',
|
258 |
+
'operator' => '==',
|
259 |
+
'value' => 1,
|
260 |
+
),
|
261 |
+
),
|
262 |
+
)
|
263 |
+
));
|
264 |
+
|
265 |
+
// Checkbox: layout
|
266 |
+
acf_render_field_setting($field, array(
|
267 |
+
'label' => __('Layout','acf'),
|
268 |
+
'instructions' => '',
|
269 |
+
'type' => 'radio',
|
270 |
+
'name' => 'layout',
|
271 |
+
'layout' => 'horizontal',
|
272 |
+
'choices' => array(
|
273 |
+
'vertical' => __("Vertical",'acf'),
|
274 |
+
'horizontal' => __("Horizontal",'acf')
|
275 |
+
),
|
276 |
+
'conditions' => array(
|
277 |
+
array(
|
278 |
+
array(
|
279 |
+
'field' => 'field_type',
|
280 |
+
'operator' => '==',
|
281 |
+
'value' => 'checkbox',
|
282 |
+
),
|
283 |
+
),
|
284 |
+
array(
|
285 |
+
array(
|
286 |
+
'field' => 'field_type',
|
287 |
+
'operator' => '==',
|
288 |
+
'value' => 'radio',
|
289 |
+
),
|
290 |
+
),
|
291 |
+
)
|
292 |
+
));
|
293 |
+
|
294 |
+
// Checkbox: toggle
|
295 |
+
acf_render_field_setting($field, array(
|
296 |
+
'label' => __('Toggle','acf'),
|
297 |
+
'instructions' => __('Prepend an extra checkbox to toggle all choices','acf'),
|
298 |
+
'name' => 'toggle',
|
299 |
+
'type' => 'true_false',
|
300 |
+
'ui' => 1,
|
301 |
+
'conditions' => array(
|
302 |
+
array(
|
303 |
+
array(
|
304 |
+
'field' => 'field_type',
|
305 |
+
'operator' => '==',
|
306 |
+
'value' => 'checkbox',
|
307 |
+
),
|
308 |
+
),
|
309 |
+
)
|
310 |
+
));
|
311 |
+
|
312 |
+
// Checkbox: other_choice
|
313 |
+
acf_render_field_setting($field, array(
|
314 |
+
'label' => __('Allow Custom','acf'),
|
315 |
+
'instructions' => '',
|
316 |
+
'name' => 'allow_custom',
|
317 |
+
'type' => 'true_false',
|
318 |
+
'ui' => 1,
|
319 |
+
'message' => __("Allow 'custom' values to be added", 'acf'),
|
320 |
+
'conditions' => array(
|
321 |
+
array(
|
322 |
+
array(
|
323 |
+
'field' => 'field_type',
|
324 |
+
'operator' => '==',
|
325 |
+
'value' => 'checkbox',
|
326 |
+
),
|
327 |
+
),
|
328 |
+
)
|
329 |
+
));
|
330 |
+
|
331 |
+
|
332 |
+
// Checkbox: save_other_choice
|
333 |
+
acf_render_field_setting($field, array(
|
334 |
+
'label' => __('Save Custom','acf'),
|
335 |
+
'instructions' => '',
|
336 |
+
'name' => 'save_custom',
|
337 |
+
'type' => 'true_false',
|
338 |
+
'ui' => 1,
|
339 |
+
'message' => __("Save 'custom' values to the field's choices", 'acf'),
|
340 |
+
'conditions' => array(
|
341 |
+
array(
|
342 |
+
array(
|
343 |
+
'field' => 'field_type',
|
344 |
+
'operator' => '==',
|
345 |
+
'value' => 'checkbox',
|
346 |
+
),
|
347 |
+
array(
|
348 |
+
'field' => 'allow_custom',
|
349 |
+
'operator' => '==',
|
350 |
+
'value' => 1,
|
351 |
+
),
|
352 |
+
),
|
353 |
+
)
|
354 |
+
));
|
355 |
+
|
356 |
+
}
|
357 |
+
|
358 |
+
|
359 |
+
function format_value($value, $post_id, $field){
|
360 |
+
|
361 |
+
// Return: name
|
362 |
+
if($field['return_format'] === 'name'){
|
363 |
+
|
364 |
+
// array
|
365 |
+
if(acf_is_array($value)){
|
366 |
+
|
367 |
+
foreach($value as $i => $v){
|
368 |
+
|
369 |
+
$form_name = get_field('acfe_form_name', $v);
|
370 |
+
|
371 |
+
$value[$i] = $form_name;
|
372 |
+
|
373 |
+
}
|
374 |
+
|
375 |
+
// string
|
376 |
+
}else{
|
377 |
+
|
378 |
+
$value = get_field('acfe_form_name', $value);
|
379 |
+
|
380 |
+
}
|
381 |
+
|
382 |
+
}
|
383 |
+
|
384 |
+
// return
|
385 |
+
return $value;
|
386 |
+
|
387 |
+
}
|
388 |
+
|
389 |
+
}
|
390 |
+
|
391 |
+
// initialize
|
392 |
+
acf_register_field_type('acfe_field_forms');
|
393 |
+
|
394 |
endif;
|
includes/fields/field-post-object.php
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
add_action('acf/render_field_settings/type=post_object', 'acfe_field_post_object_settings');
|
7 |
+
function acfe_field_post_object_settings($field){
|
8 |
+
|
9 |
+
// other_choice
|
10 |
+
acf_render_field_setting($field, array(
|
11 |
+
'label' => __('Allow Custom','acf'),
|
12 |
+
'instructions' => '',
|
13 |
+
'name' => 'allow_custom',
|
14 |
+
'type' => 'true_false',
|
15 |
+
'ui' => 1,
|
16 |
+
'message' => __("Allow 'custom' values to be added", 'acf'),
|
17 |
+
));
|
18 |
+
|
19 |
+
// save other_choice
|
20 |
+
acf_render_field_setting($field, array(
|
21 |
+
'label' => __('Save Custom','acf'),
|
22 |
+
'instructions' => '',
|
23 |
+
'name' => 'save_custom',
|
24 |
+
'type' => 'true_false',
|
25 |
+
'ui' => 1,
|
26 |
+
'message' => __("Save 'custom' values as new post", 'acf'),
|
27 |
+
'conditions' => array(
|
28 |
+
'field' => 'allow_custom',
|
29 |
+
'operator' => '==',
|
30 |
+
'value' => 1
|
31 |
+
)
|
32 |
+
));
|
33 |
+
|
34 |
+
// save post_type
|
35 |
+
acf_render_field_setting($field, array(
|
36 |
+
'label' => __('New Post Arguments','acf'),
|
37 |
+
'instructions' => '',
|
38 |
+
'name' => 'save_post_type',
|
39 |
+
'type' => 'acfe_post_types',
|
40 |
+
'field_type' => 'select',
|
41 |
+
'conditions' => array(
|
42 |
+
'field' => 'save_custom',
|
43 |
+
'operator' => '==',
|
44 |
+
'value' => 1
|
45 |
+
)
|
46 |
+
));
|
47 |
+
|
48 |
+
// save post_status
|
49 |
+
acf_render_field_setting($field, array(
|
50 |
+
'label' => '',
|
51 |
+
'instructions' => '',
|
52 |
+
'name' => 'save_post_status',
|
53 |
+
'type' => 'acfe_post_statuses',
|
54 |
+
'field_type' => 'select',
|
55 |
+
'conditions' => array(
|
56 |
+
'field' => 'save_custom',
|
57 |
+
'operator' => '==',
|
58 |
+
'value' => 1
|
59 |
+
),
|
60 |
+
'_append' => 'save_post_type'
|
61 |
+
));
|
62 |
+
|
63 |
+
}
|
64 |
+
|
65 |
+
add_filter('acfe/field_wrapper_attributes/type=post_object', 'acfe_field_post_object_wrapper', 10, 2);
|
66 |
+
function acfe_field_post_object_wrapper($wrapper, $field){
|
67 |
+
|
68 |
+
if(acf_maybe_get($field, 'allow_custom')){
|
69 |
+
|
70 |
+
$wrapper['data-acfe-allow-custom'] = 1;
|
71 |
+
|
72 |
+
}
|
73 |
+
|
74 |
+
return $wrapper;
|
75 |
+
|
76 |
+
}
|
77 |
+
|
78 |
+
add_filter('acf/update_value/type=post_object', 'acfe_field_post_object_update_value', 5, 3);
|
79 |
+
function acfe_field_post_object_update_value($value, $post_id, $field){
|
80 |
+
|
81 |
+
// Allow + save custom value
|
82 |
+
if(empty(acf_maybe_get($field, 'allow_custom')) || empty(acf_maybe_get($field, 'save_custom')))
|
83 |
+
return $value;
|
84 |
+
|
85 |
+
// Bail early if value is numeric (normal behavior)
|
86 |
+
if(is_numeric($value))
|
87 |
+
return $value;
|
88 |
+
|
89 |
+
$value_slug = sanitize_title($value);
|
90 |
+
$value_post_type = 'post';
|
91 |
+
$value_post_status = 'publish';
|
92 |
+
|
93 |
+
if(acf_maybe_get($field, 'save_post_type'))
|
94 |
+
$value_post_type = $field['save_post_type'];
|
95 |
+
|
96 |
+
if(acf_maybe_get($field, 'save_post_status'))
|
97 |
+
$value_post_status = $field['save_post_status'];
|
98 |
+
|
99 |
+
$get_post = get_page_by_path($value_slug, OBJECT, $value_post_type);
|
100 |
+
|
101 |
+
// Post name with value has been found, return ID
|
102 |
+
if(!empty($get_post))
|
103 |
+
return $get_post->ID;
|
104 |
+
|
105 |
+
// Create new post
|
106 |
+
$args = array(
|
107 |
+
'post_title' => $value,
|
108 |
+
'post_type' => $value_post_type,
|
109 |
+
'post_status' => $value_post_status,
|
110 |
+
);
|
111 |
+
|
112 |
+
// Allow filters
|
113 |
+
$args = apply_filters('acfe/fields/post_object/custom_save_args', $args, $value, $post_id, $field);
|
114 |
+
$args = apply_filters('acfe/fields/post_object/custom_save_args/name=' . $field['name'], $args, $value, $post_id, $field);
|
115 |
+
$args = apply_filters('acfe/fields/post_object/custom_save_args/key=' . $field['key'], $args, $value, $post_id, $field);
|
116 |
+
|
117 |
+
// Insert post
|
118 |
+
$_post_id = wp_insert_post($args);
|
119 |
+
|
120 |
+
if(empty($_post_id) || is_wp_error($_post_id))
|
121 |
+
return $value;
|
122 |
+
|
123 |
+
// Allow actions after insert
|
124 |
+
do_action('acfe/fields/post_object/custom_save', $_post_id, $value, $post_id, $field);
|
125 |
+
do_action('acfe/fields/post_object/custom_save/name=' . $field['name'], $_post_id, $value, $post_id, $field);
|
126 |
+
do_action('acfe/fields/post_object/custom_save/key=' . $field['key'], $_post_id, $value, $post_id, $field);
|
127 |
+
|
128 |
+
return $_post_id;
|
129 |
+
|
130 |
+
}
|
includes/fields/field-post-statuses.php
CHANGED
@@ -1,379 +1,392 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
if(!class_exists('acfe_field_post_statuses')):
|
7 |
-
|
8 |
-
class acfe_field_post_statuses extends acf_field{
|
9 |
-
|
10 |
-
function __construct(){
|
11 |
-
|
12 |
-
$this->name = 'acfe_post_statuses';
|
13 |
-
$this->label = __('Post statuses', 'acfe');
|
14 |
-
$this->category = 'relational';
|
15 |
-
$this->defaults = array(
|
16 |
-
'post_status' => array(),
|
17 |
-
'field_type' => 'checkbox',
|
18 |
-
'multiple' => 0,
|
19 |
-
'allow_null' => 0,
|
20 |
-
'choices' => array(),
|
21 |
-
'default_value' => '',
|
22 |
-
'ui' => 0,
|
23 |
-
'ajax' => 0,
|
24 |
-
'placeholder' => '',
|
25 |
-
'layout' => '',
|
26 |
-
'toggle' => 0,
|
27 |
-
'allow_custom' => 0,
|
28 |
-
'return_format' => 'name',
|
29 |
-
);
|
30 |
-
|
31 |
-
parent::__construct();
|
32 |
-
|
33 |
-
}
|
34 |
-
|
35 |
-
function prepare_field($field){
|
36 |
-
|
37 |
-
$field['choices'] = acfe_get_pretty_post_statuses($field['post_status']);
|
38 |
-
|
39 |
-
// Set Field Type
|
40 |
-
$field['type'] = $field['field_type'];
|
41 |
-
|
42 |
-
return $field;
|
43 |
-
|
44 |
-
}
|
45 |
-
|
46 |
-
function render_field_settings($field){
|
47 |
-
|
48 |
-
if(isset($field['default_value']))
|
49 |
-
$field['default_value'] = acf_encode_choices($field['default_value'], false);
|
50 |
-
|
51 |
-
// Allow Post Status
|
52 |
-
acf_render_field_setting( $field, array(
|
53 |
-
'label' => __('Allow Post Status','acf'),
|
54 |
-
'instructions' => '',
|
55 |
-
'type' => 'select',
|
56 |
-
'name' => 'post_status',
|
57 |
-
'choices' => acfe_get_pretty_post_statuses(),
|
58 |
-
'multiple' => 1,
|
59 |
-
'ui' => 1,
|
60 |
-
'allow_null' => 1,
|
61 |
-
'placeholder' => __("All post statuses",'acf'),
|
62 |
-
));
|
63 |
-
|
64 |
-
// field_type
|
65 |
-
acf_render_field_setting($field, array(
|
66 |
-
'label' => __('Appearance','acf'),
|
67 |
-
'instructions' => __('Select the appearance of this field', 'acf'),
|
68 |
-
'type' => 'select',
|
69 |
-
'name' => 'field_type',
|
70 |
-
'optgroup' => true,
|
71 |
-
'choices' => array(
|
72 |
-
'checkbox' => __('Checkbox', 'acf'),
|
73 |
-
'radio' => __('Radio Buttons', 'acf'),
|
74 |
-
'select' => _x('Select', 'noun', 'acf')
|
75 |
-
)
|
76 |
-
));
|
77 |
-
|
78 |
-
// default_value
|
79 |
-
acf_render_field_setting( $field, array(
|
80 |
-
'label' => __('Default Value','acf'),
|
81 |
-
'instructions' => __('Enter each default value on a new line','acf'),
|
82 |
-
'name' => 'default_value',
|
83 |
-
'type' => 'textarea',
|
84 |
-
));
|
85 |
-
|
86 |
-
// return_format
|
87 |
-
acf_render_field_setting($field, array(
|
88 |
-
'label' => __('Return Value', 'acf'),
|
89 |
-
'instructions' => '',
|
90 |
-
'type' => 'radio',
|
91 |
-
'name' => 'return_format',
|
92 |
-
'choices' => array(
|
93 |
-
'object' => __('Post status object', 'acfe'),
|
94 |
-
'name' => __('Post status name', 'acfe')
|
95 |
-
),
|
96 |
-
'layout' => 'horizontal',
|
97 |
-
));
|
98 |
-
|
99 |
-
// Select + Radio: allow_null
|
100 |
-
acf_render_field_setting( $field, array(
|
101 |
-
'label' => __('Allow Null?','acf'),
|
102 |
-
'instructions' => '',
|
103 |
-
'name' => 'allow_null',
|
104 |
-
'type' => 'true_false',
|
105 |
-
'ui' => 1,
|
106 |
-
'conditions' => array(
|
107 |
-
array(
|
108 |
-
array(
|
109 |
-
'field' => 'field_type',
|
110 |
-
'operator' => '==',
|
111 |
-
'value' => 'select',
|
112 |
-
),
|
113 |
-
),
|
114 |
-
array(
|
115 |
-
array(
|
116 |
-
'field' => 'field_type',
|
117 |
-
'operator' => '==',
|
118 |
-
'value' => 'radio',
|
119 |
-
),
|
120 |
-
),
|
121 |
-
)
|
122 |
-
));
|
123 |
-
|
124 |
-
// placeholder
|
125 |
-
acf_render_field_setting($field, array(
|
126 |
-
'label' => __('Placeholder Text','acf'),
|
127 |
-
'instructions' => __('Appears within the input','acf'),
|
128 |
-
'type' => 'text',
|
129 |
-
'name' => 'placeholder',
|
130 |
-
'placeholder' => _x('Select', 'verb', 'acf'),
|
131 |
-
'conditional_logic' => array(
|
132 |
-
array(
|
133 |
-
array(
|
134 |
-
'field' => 'field_type',
|
135 |
-
'operator' => '==',
|
136 |
-
'value' => 'select',
|
137 |
-
),
|
138 |
-
array(
|
139 |
-
'field' => 'allow_null',
|
140 |
-
'operator' => '==',
|
141 |
-
'value' => '1',
|
142 |
-
),
|
143 |
-
|
144 |
-
)
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
}
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
379 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
if(!class_exists('acfe_field_post_statuses')):
|
7 |
+
|
8 |
+
class acfe_field_post_statuses extends acf_field{
|
9 |
+
|
10 |
+
function __construct(){
|
11 |
+
|
12 |
+
$this->name = 'acfe_post_statuses';
|
13 |
+
$this->label = __('Post statuses', 'acfe');
|
14 |
+
$this->category = 'relational';
|
15 |
+
$this->defaults = array(
|
16 |
+
'post_status' => array(),
|
17 |
+
'field_type' => 'checkbox',
|
18 |
+
'multiple' => 0,
|
19 |
+
'allow_null' => 0,
|
20 |
+
'choices' => array(),
|
21 |
+
'default_value' => '',
|
22 |
+
'ui' => 0,
|
23 |
+
'ajax' => 0,
|
24 |
+
'placeholder' => '',
|
25 |
+
'layout' => '',
|
26 |
+
'toggle' => 0,
|
27 |
+
'allow_custom' => 0,
|
28 |
+
'return_format' => 'name',
|
29 |
+
);
|
30 |
+
|
31 |
+
parent::__construct();
|
32 |
+
|
33 |
+
}
|
34 |
+
|
35 |
+
function prepare_field($field){
|
36 |
+
|
37 |
+
$field['choices'] = acfe_get_pretty_post_statuses($field['post_status']);
|
38 |
+
|
39 |
+
// Set Field Type
|
40 |
+
$field['type'] = $field['field_type'];
|
41 |
+
|
42 |
+
return $field;
|
43 |
+
|
44 |
+
}
|
45 |
+
|
46 |
+
function render_field_settings($field){
|
47 |
+
|
48 |
+
if(isset($field['default_value']))
|
49 |
+
$field['default_value'] = acf_encode_choices($field['default_value'], false);
|
50 |
+
|
51 |
+
// Allow Post Status
|
52 |
+
acf_render_field_setting( $field, array(
|
53 |
+
'label' => __('Allow Post Status','acf'),
|
54 |
+
'instructions' => '',
|
55 |
+
'type' => 'select',
|
56 |
+
'name' => 'post_status',
|
57 |
+
'choices' => acfe_get_pretty_post_statuses(),
|
58 |
+
'multiple' => 1,
|
59 |
+
'ui' => 1,
|
60 |
+
'allow_null' => 1,
|
61 |
+
'placeholder' => __("All post statuses",'acf'),
|
62 |
+
));
|
63 |
+
|
64 |
+
// field_type
|
65 |
+
acf_render_field_setting($field, array(
|
66 |
+
'label' => __('Appearance','acf'),
|
67 |
+
'instructions' => __('Select the appearance of this field', 'acf'),
|
68 |
+
'type' => 'select',
|
69 |
+
'name' => 'field_type',
|
70 |
+
'optgroup' => true,
|
71 |
+
'choices' => array(
|
72 |
+
'checkbox' => __('Checkbox', 'acf'),
|
73 |
+
'radio' => __('Radio Buttons', 'acf'),
|
74 |
+
'select' => _x('Select', 'noun', 'acf')
|
75 |
+
)
|
76 |
+
));
|
77 |
+
|
78 |
+
// default_value
|
79 |
+
acf_render_field_setting( $field, array(
|
80 |
+
'label' => __('Default Value','acf'),
|
81 |
+
'instructions' => __('Enter each default value on a new line','acf'),
|
82 |
+
'name' => 'default_value',
|
83 |
+
'type' => 'textarea',
|
84 |
+
));
|
85 |
+
|
86 |
+
// return_format
|
87 |
+
acf_render_field_setting($field, array(
|
88 |
+
'label' => __('Return Value', 'acf'),
|
89 |
+
'instructions' => '',
|
90 |
+
'type' => 'radio',
|
91 |
+
'name' => 'return_format',
|
92 |
+
'choices' => array(
|
93 |
+
'object' => __('Post status object', 'acfe'),
|
94 |
+
'name' => __('Post status name', 'acfe')
|
95 |
+
),
|
96 |
+
'layout' => 'horizontal',
|
97 |
+
));
|
98 |
+
|
99 |
+
// Select + Radio: allow_null
|
100 |
+
acf_render_field_setting( $field, array(
|
101 |
+
'label' => __('Allow Null?','acf'),
|
102 |
+
'instructions' => '',
|
103 |
+
'name' => 'allow_null',
|
104 |
+
'type' => 'true_false',
|
105 |
+
'ui' => 1,
|
106 |
+
'conditions' => array(
|
107 |
+
array(
|
108 |
+
array(
|
109 |
+
'field' => 'field_type',
|
110 |
+
'operator' => '==',
|
111 |
+
'value' => 'select',
|
112 |
+
),
|
113 |
+
),
|
114 |
+
array(
|
115 |
+
array(
|
116 |
+
'field' => 'field_type',
|
117 |
+
'operator' => '==',
|
118 |
+
'value' => 'radio',
|
119 |
+
),
|
120 |
+
),
|
121 |
+
)
|
122 |
+
));
|
123 |
+
|
124 |
+
// placeholder
|
125 |
+
acf_render_field_setting($field, array(
|
126 |
+
'label' => __('Placeholder Text','acf'),
|
127 |
+
'instructions' => __('Appears within the input','acf'),
|
128 |
+
'type' => 'text',
|
129 |
+
'name' => 'placeholder',
|
130 |
+
'placeholder' => _x('Select', 'verb', 'acf'),
|
131 |
+
'conditional_logic' => array(
|
132 |
+
array(
|
133 |
+
array(
|
134 |
+
'field' => 'field_type',
|
135 |
+
'operator' => '==',
|
136 |
+
'value' => 'select',
|
137 |
+
),
|
138 |
+
array(
|
139 |
+
'field' => 'allow_null',
|
140 |
+
'operator' => '==',
|
141 |
+
'value' => '1',
|
142 |
+
),
|
143 |
+
|
144 |
+
),
|
145 |
+
array(
|
146 |
+
array(
|
147 |
+
'field' => 'field_type',
|
148 |
+
'operator' => '==',
|
149 |
+
'value' => 'select',
|
150 |
+
),
|
151 |
+
array(
|
152 |
+
'field' => 'ui',
|
153 |
+
'operator' => '==',
|
154 |
+
'value' => '1',
|
155 |
+
),
|
156 |
+
|
157 |
+
),
|
158 |
+
)
|
159 |
+
));
|
160 |
+
|
161 |
+
// Select: multiple
|
162 |
+
acf_render_field_setting( $field, array(
|
163 |
+
'label' => __('Select multiple values?','acf'),
|
164 |
+
'instructions' => '',
|
165 |
+
'name' => 'multiple',
|
166 |
+
'type' => 'true_false',
|
167 |
+
'ui' => 1,
|
168 |
+
'conditions' => array(
|
169 |
+
array(
|
170 |
+
array(
|
171 |
+
'field' => 'field_type',
|
172 |
+
'operator' => '==',
|
173 |
+
'value' => 'select',
|
174 |
+
),
|
175 |
+
),
|
176 |
+
)
|
177 |
+
));
|
178 |
+
|
179 |
+
// Select: ui
|
180 |
+
acf_render_field_setting( $field, array(
|
181 |
+
'label' => __('Stylised UI','acf'),
|
182 |
+
'instructions' => '',
|
183 |
+
'name' => 'ui',
|
184 |
+
'type' => 'true_false',
|
185 |
+
'ui' => 1,
|
186 |
+
'conditions' => array(
|
187 |
+
array(
|
188 |
+
array(
|
189 |
+
'field' => 'field_type',
|
190 |
+
'operator' => '==',
|
191 |
+
'value' => 'select',
|
192 |
+
),
|
193 |
+
),
|
194 |
+
)
|
195 |
+
));
|
196 |
+
|
197 |
+
|
198 |
+
// Select: ajax
|
199 |
+
acf_render_field_setting( $field, array(
|
200 |
+
'label' => __('Use AJAX to lazy load choices?','acf'),
|
201 |
+
'instructions' => '',
|
202 |
+
'name' => 'ajax',
|
203 |
+
'type' => 'true_false',
|
204 |
+
'ui' => 1,
|
205 |
+
'conditions' => array(
|
206 |
+
array(
|
207 |
+
array(
|
208 |
+
'field' => 'field_type',
|
209 |
+
'operator' => '==',
|
210 |
+
'value' => 'select',
|
211 |
+
),
|
212 |
+
array(
|
213 |
+
'field' => 'ui',
|
214 |
+
'operator' => '==',
|
215 |
+
'value' => 1,
|
216 |
+
),
|
217 |
+
),
|
218 |
+
)
|
219 |
+
));
|
220 |
+
|
221 |
+
// Radio: other_choice
|
222 |
+
acf_render_field_setting( $field, array(
|
223 |
+
'label' => __('Other','acf'),
|
224 |
+
'instructions' => '',
|
225 |
+
'name' => 'other_choice',
|
226 |
+
'type' => 'true_false',
|
227 |
+
'ui' => 1,
|
228 |
+
'message' => __("Add 'other' choice to allow for custom values", 'acf'),
|
229 |
+
'conditions' => array(
|
230 |
+
array(
|
231 |
+
array(
|
232 |
+
'field' => 'field_type',
|
233 |
+
'operator' => '==',
|
234 |
+
'value' => 'radio',
|
235 |
+
),
|
236 |
+
),
|
237 |
+
)
|
238 |
+
));
|
239 |
+
|
240 |
+
|
241 |
+
// Radio: save_other_choice
|
242 |
+
acf_render_field_setting( $field, array(
|
243 |
+
'label' => __('Save Other','acf'),
|
244 |
+
'instructions' => '',
|
245 |
+
'name' => 'save_other_choice',
|
246 |
+
'type' => 'true_false',
|
247 |
+
'ui' => 1,
|
248 |
+
'message' => __("Save 'other' values to the field's choices", 'acf'),
|
249 |
+
'conditions' => array(
|
250 |
+
array(
|
251 |
+
array(
|
252 |
+
'field' => 'field_type',
|
253 |
+
'operator' => '==',
|
254 |
+
'value' => 'radio',
|
255 |
+
),
|
256 |
+
array(
|
257 |
+
'field' => 'other_choice',
|
258 |
+
'operator' => '==',
|
259 |
+
'value' => 1,
|
260 |
+
),
|
261 |
+
),
|
262 |
+
)
|
263 |
+
));
|
264 |
+
|
265 |
+
// Checkbox: layout
|
266 |
+
acf_render_field_setting( $field, array(
|
267 |
+
'label' => __('Layout','acf'),
|
268 |
+
'instructions' => '',
|
269 |
+
'type' => 'radio',
|
270 |
+
'name' => 'layout',
|
271 |
+
'layout' => 'horizontal',
|
272 |
+
'choices' => array(
|
273 |
+
'vertical' => __("Vertical",'acf'),
|
274 |
+
'horizontal' => __("Horizontal",'acf')
|
275 |
+
),
|
276 |
+
'conditions' => array(
|
277 |
+
array(
|
278 |
+
array(
|
279 |
+
'field' => 'field_type',
|
280 |
+
'operator' => '==',
|
281 |
+
'value' => 'checkbox',
|
282 |
+
),
|
283 |
+
),
|
284 |
+
array(
|
285 |
+
array(
|
286 |
+
'field' => 'field_type',
|
287 |
+
'operator' => '==',
|
288 |
+
'value' => 'radio',
|
289 |
+
),
|
290 |
+
),
|
291 |
+
)
|
292 |
+
));
|
293 |
+
|
294 |
+
// Checkbox: toggle
|
295 |
+
acf_render_field_setting( $field, array(
|
296 |
+
'label' => __('Toggle','acf'),
|
297 |
+
'instructions' => __('Prepend an extra checkbox to toggle all choices','acf'),
|
298 |
+
'name' => 'toggle',
|
299 |
+
'type' => 'true_false',
|
300 |
+
'ui' => 1,
|
301 |
+
'conditions' => array(
|
302 |
+
array(
|
303 |
+
array(
|
304 |
+
'field' => 'field_type',
|
305 |
+
'operator' => '==',
|
306 |
+
'value' => 'checkbox',
|
307 |
+
),
|
308 |
+
),
|
309 |
+
)
|
310 |
+
));
|
311 |
+
|
312 |
+
// Checkbox: other_choice
|
313 |
+
acf_render_field_setting( $field, array(
|
314 |
+
'label' => __('Allow Custom','acf'),
|
315 |
+
'instructions' => '',
|
316 |
+
'name' => 'allow_custom',
|
317 |
+
'type' => 'true_false',
|
318 |
+
'ui' => 1,
|
319 |
+
'message' => __("Allow 'custom' values to be added", 'acf'),
|
320 |
+
'conditions' => array(
|
321 |
+
array(
|
322 |
+
array(
|
323 |
+
'field' => 'field_type',
|
324 |
+
'operator' => '==',
|
325 |
+
'value' => 'checkbox',
|
326 |
+
),
|
327 |
+
),
|
328 |
+
)
|
329 |
+
));
|
330 |
+
|
331 |
+
|
332 |
+
// Checkbox: save_other_choice
|
333 |
+
acf_render_field_setting( $field, array(
|
334 |
+
'label' => __('Save Custom','acf'),
|
335 |
+
'instructions' => '',
|
336 |
+
'name' => 'save_custom',
|
337 |
+
'type' => 'true_false',
|
338 |
+
'ui' => 1,
|
339 |
+
'message' => __("Save 'custom' values to the field's choices", 'acf'),
|
340 |
+
'conditions' => array(
|
341 |
+
array(
|
342 |
+
array(
|
343 |
+
'field' => 'field_type',
|
344 |
+
'operator' => '==',
|
345 |
+
'value' => 'checkbox',
|
346 |
+
),
|
347 |
+
array(
|
348 |
+
'field' => 'allow_custom',
|
349 |
+
'operator' => '==',
|
350 |
+
'value' => 1,
|
351 |
+
),
|
352 |
+
),
|
353 |
+
)
|
354 |
+
));
|
355 |
+
|
356 |
+
}
|
357 |
+
|
358 |
+
|
359 |
+
function format_value($value, $post_id, $field){
|
360 |
+
|
361 |
+
// Return: object
|
362 |
+
if($field['return_format'] === 'object'){
|
363 |
+
|
364 |
+
// array
|
365 |
+
if(acf_is_array($value)){
|
366 |
+
|
367 |
+
foreach($value as $i => $v){
|
368 |
+
|
369 |
+
$value[$i] = get_post_status_object($v);
|
370 |
+
|
371 |
+
}
|
372 |
+
|
373 |
+
// string
|
374 |
+
}else{
|
375 |
+
|
376 |
+
$value = get_post_status_object($value);
|
377 |
+
|
378 |
+
}
|
379 |
+
|
380 |
+
}
|
381 |
+
|
382 |
+
// return
|
383 |
+
return $value;
|
384 |
+
|
385 |
+
}
|
386 |
+
|
387 |
+
}
|
388 |
+
|
389 |
+
// initialize
|
390 |
+
acf_register_field_type('acfe_field_post_statuses');
|
391 |
+
|
392 |
endif;
|
includes/fields/field-post-types.php
CHANGED
@@ -1,379 +1,392 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
if(!class_exists('acfe_field_post_types')):
|
7 |
-
|
8 |
-
class acfe_field_post_types extends acf_field{
|
9 |
-
|
10 |
-
function __construct(){
|
11 |
-
|
12 |
-
$this->name = 'acfe_post_types';
|
13 |
-
$this->label = __('Post types', 'acfe');
|
14 |
-
$this->category = 'relational';
|
15 |
-
$this->defaults = array(
|
16 |
-
'post_type' => array(),
|
17 |
-
'field_type' => 'checkbox',
|
18 |
-
'multiple' => 0,
|
19 |
-
'allow_null' => 0,
|
20 |
-
'choices' => array(),
|
21 |
-
'default_value' => '',
|
22 |
-
'ui' => 0,
|
23 |
-
'ajax' => 0,
|
24 |
-
'placeholder' => '',
|
25 |
-
'layout' => '',
|
26 |
-
'toggle' => 0,
|
27 |
-
'allow_custom' => 0,
|
28 |
-
'return_format' => 'name',
|
29 |
-
);
|
30 |
-
|
31 |
-
parent::__construct();
|
32 |
-
|
33 |
-
}
|
34 |
-
|
35 |
-
function prepare_field($field){
|
36 |
-
|
37 |
-
$field['choices'] = acf_get_pretty_post_types($field['post_type']);
|
38 |
-
|
39 |
-
// Set Field Type
|
40 |
-
$field['type'] = $field['field_type'];
|
41 |
-
|
42 |
-
return $field;
|
43 |
-
|
44 |
-
}
|
45 |
-
|
46 |
-
function render_field_settings($field){
|
47 |
-
|
48 |
-
if(isset($field['default_value']))
|
49 |
-
$field['default_value'] = acf_encode_choices($field['default_value'], false);
|
50 |
-
|
51 |
-
// Allow Post Type
|
52 |
-
acf_render_field_setting( $field, array(
|
53 |
-
'label' => __('Allow Post Type','acf'),
|
54 |
-
'instructions' => '',
|
55 |
-
'type' => 'select',
|
56 |
-
'name' => 'post_type',
|
57 |
-
'choices' => acf_get_pretty_post_types(),
|
58 |
-
'multiple' => 1,
|
59 |
-
'ui' => 1,
|
60 |
-
'allow_null' => 1,
|
61 |
-
'placeholder' => __("All post types",'acf'),
|
62 |
-
));
|
63 |
-
|
64 |
-
// field_type
|
65 |
-
acf_render_field_setting($field, array(
|
66 |
-
'label' => __('Appearance','acf'),
|
67 |
-
'instructions' => __('Select the appearance of this field', 'acf'),
|
68 |
-
'type' => 'select',
|
69 |
-
'name' => 'field_type',
|
70 |
-
'optgroup' => true,
|
71 |
-
'choices' => array(
|
72 |
-
'checkbox' => __('Checkbox', 'acf'),
|
73 |
-
'radio' => __('Radio Buttons', 'acf'),
|
74 |
-
'select' => _x('Select', 'noun', 'acf')
|
75 |
-
)
|
76 |
-
));
|
77 |
-
|
78 |
-
// default_value
|
79 |
-
acf_render_field_setting( $field, array(
|
80 |
-
'label' => __('Default Value','acf'),
|
81 |
-
'instructions' => __('Enter each default value on a new line','acf'),
|
82 |
-
'name' => 'default_value',
|
83 |
-
'type' => 'textarea',
|
84 |
-
));
|
85 |
-
|
86 |
-
// return_format
|
87 |
-
acf_render_field_setting($field, array(
|
88 |
-
'label' => __('Return Value', 'acf'),
|
89 |
-
'instructions' => '',
|
90 |
-
'type' => 'radio',
|
91 |
-
'name' => 'return_format',
|
92 |
-
'choices' => array(
|
93 |
-
'object' => __('Post type object', 'acfe'),
|
94 |
-
'name' => __('Post type name', 'acfe')
|
95 |
-
),
|
96 |
-
'layout' => 'horizontal',
|
97 |
-
));
|
98 |
-
|
99 |
-
// Select + Radio: allow_null
|
100 |
-
acf_render_field_setting( $field, array(
|
101 |
-
'label' => __('Allow Null?','acf'),
|
102 |
-
'instructions' => '',
|
103 |
-
'name' => 'allow_null',
|
104 |
-
'type' => 'true_false',
|
105 |
-
'ui' => 1,
|
106 |
-
'conditions' => array(
|
107 |
-
array(
|
108 |
-
array(
|
109 |
-
'field' => 'field_type',
|
110 |
-
'operator' => '==',
|
111 |
-
'value' => 'select',
|
112 |
-
),
|
113 |
-
),
|
114 |
-
array(
|
115 |
-
array(
|
116 |
-
'field' => 'field_type',
|
117 |
-
'operator' => '==',
|
118 |
-
'value' => 'radio',
|
119 |
-
),
|
120 |
-
),
|
121 |
-
)
|
122 |
-
));
|
123 |
-
|
124 |
-
// placeholder
|
125 |
-
acf_render_field_setting($field, array(
|
126 |
-
'label' => __('Placeholder Text','acf'),
|
127 |
-
'instructions' => __('Appears within the input','acf'),
|
128 |
-
'type' => 'text',
|
129 |
-
'name' => 'placeholder',
|
130 |
-
'placeholder' => _x('Select', 'verb', 'acf'),
|
131 |
-
'conditional_logic' => array(
|
132 |
-
array(
|
133 |
-
array(
|
134 |
-
'field' => 'field_type',
|
135 |
-
'operator' => '==',
|
136 |
-
'value' => 'select',
|
137 |
-
),
|
138 |
-
array(
|
139 |
-
'field' => 'allow_null',
|
140 |
-
'operator' => '==',
|
141 |
-
'value' => '1',
|
142 |
-
),
|
143 |
-
|
144 |
-
)
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
}
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
379 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
if(!class_exists('acfe_field_post_types')):
|
7 |
+
|
8 |
+
class acfe_field_post_types extends acf_field{
|
9 |
+
|
10 |
+
function __construct(){
|
11 |
+
|
12 |
+
$this->name = 'acfe_post_types';
|
13 |
+
$this->label = __('Post types', 'acfe');
|
14 |
+
$this->category = 'relational';
|
15 |
+
$this->defaults = array(
|
16 |
+
'post_type' => array(),
|
17 |
+
'field_type' => 'checkbox',
|
18 |
+
'multiple' => 0,
|
19 |
+
'allow_null' => 0,
|
20 |
+
'choices' => array(),
|
21 |
+
'default_value' => '',
|
22 |
+
'ui' => 0,
|
23 |
+
'ajax' => 0,
|
24 |
+
'placeholder' => '',
|
25 |
+
'layout' => '',
|
26 |
+
'toggle' => 0,
|
27 |
+
'allow_custom' => 0,
|
28 |
+
'return_format' => 'name',
|
29 |
+
);
|
30 |
+
|
31 |
+
parent::__construct();
|
32 |
+
|
33 |
+
}
|
34 |
+
|
35 |
+
function prepare_field($field){
|
36 |
+
|
37 |
+
$field['choices'] = acf_get_pretty_post_types($field['post_type']);
|
38 |
+
|
39 |
+
// Set Field Type
|
40 |
+
$field['type'] = $field['field_type'];
|
41 |
+
|
42 |
+
return $field;
|
43 |
+
|
44 |
+
}
|
45 |
+
|
46 |
+
function render_field_settings($field){
|
47 |
+
|
48 |
+
if(isset($field['default_value']))
|
49 |
+
$field['default_value'] = acf_encode_choices($field['default_value'], false);
|
50 |
+
|
51 |
+
// Allow Post Type
|
52 |
+
acf_render_field_setting( $field, array(
|
53 |
+
'label' => __('Allow Post Type','acf'),
|
54 |
+
'instructions' => '',
|
55 |
+
'type' => 'select',
|
56 |
+
'name' => 'post_type',
|
57 |
+
'choices' => acf_get_pretty_post_types(),
|
58 |
+
'multiple' => 1,
|
59 |
+
'ui' => 1,
|
60 |
+
'allow_null' => 1,
|
61 |
+
'placeholder' => __("All post types",'acf'),
|
62 |
+
));
|
63 |
+
|
64 |
+
// field_type
|
65 |
+
acf_render_field_setting($field, array(
|
66 |
+
'label' => __('Appearance','acf'),
|
67 |
+
'instructions' => __('Select the appearance of this field', 'acf'),
|
68 |
+
'type' => 'select',
|
69 |
+
'name' => 'field_type',
|
70 |
+
'optgroup' => true,
|
71 |
+
'choices' => array(
|
72 |
+
'checkbox' => __('Checkbox', 'acf'),
|
73 |
+
'radio' => __('Radio Buttons', 'acf'),
|
74 |
+
'select' => _x('Select', 'noun', 'acf')
|
75 |
+
)
|
76 |
+
));
|
77 |
+
|
78 |
+
// default_value
|
79 |
+
acf_render_field_setting( $field, array(
|
80 |
+
'label' => __('Default Value','acf'),
|
81 |
+
'instructions' => __('Enter each default value on a new line','acf'),
|
82 |
+
'name' => 'default_value',
|
83 |
+
'type' => 'textarea',
|
84 |
+
));
|
85 |
+
|
86 |
+
// return_format
|
87 |
+
acf_render_field_setting($field, array(
|
88 |
+
'label' => __('Return Value', 'acf'),
|
89 |
+
'instructions' => '',
|
90 |
+
'type' => 'radio',
|
91 |
+
'name' => 'return_format',
|
92 |
+
'choices' => array(
|
93 |
+
'object' => __('Post type object', 'acfe'),
|
94 |
+
'name' => __('Post type name', 'acfe')
|
95 |
+
),
|
96 |
+
'layout' => 'horizontal',
|
97 |
+
));
|
98 |
+
|
99 |
+
// Select + Radio: allow_null
|
100 |
+
acf_render_field_setting( $field, array(
|
101 |
+
'label' => __('Allow Null?','acf'),
|
102 |
+
'instructions' => '',
|
103 |
+
'name' => 'allow_null',
|
104 |
+
'type' => 'true_false',
|
105 |
+
'ui' => 1,
|
106 |
+
'conditions' => array(
|
107 |
+
array(
|
108 |
+
array(
|
109 |
+
'field' => 'field_type',
|
110 |
+
'operator' => '==',
|
111 |
+
'value' => 'select',
|
112 |
+
),
|
113 |
+
),
|
114 |
+
array(
|
115 |
+
array(
|
116 |
+
'field' => 'field_type',
|
117 |
+
'operator' => '==',
|
118 |
+
'value' => 'radio',
|
119 |
+
),
|
120 |
+
),
|
121 |
+
)
|
122 |
+
));
|
123 |
+
|
124 |
+
// placeholder
|
125 |
+
acf_render_field_setting($field, array(
|
126 |
+
'label' => __('Placeholder Text','acf'),
|
127 |
+
'instructions' => __('Appears within the input','acf'),
|
128 |
+
'type' => 'text',
|
129 |
+
'name' => 'placeholder',
|
130 |
+
'placeholder' => _x('Select', 'verb', 'acf'),
|
131 |
+
'conditional_logic' => array(
|
132 |
+
array(
|
133 |
+
array(
|
134 |
+
'field' => 'field_type',
|
135 |
+
'operator' => '==',
|
136 |
+
'value' => 'select',
|
137 |
+
),
|
138 |
+
array(
|
139 |
+
'field' => 'allow_null',
|
140 |
+
'operator' => '==',
|
141 |
+
'value' => '1',
|
142 |
+
),
|
143 |
+
|
144 |
+
),
|
145 |
+
array(
|
146 |
+
array(
|
147 |
+
'field' => 'field_type',
|
148 |
+
'operator' => '==',
|
149 |
+
'value' => 'select',
|
150 |
+
),
|
151 |
+
array(
|
152 |
+
'field' => 'ui',
|
153 |
+
'operator' => '==',
|
154 |
+
'value' => '1',
|
155 |
+
),
|
156 |
+
|
157 |
+
),
|
158 |
+
)
|
159 |
+
));
|
160 |
+
|
161 |
+
// Select: multiple
|
162 |
+
acf_render_field_setting( $field, array(
|
163 |
+
'label' => __('Select multiple values?','acf'),
|
164 |
+
'instructions' => '',
|
165 |
+
'name' => 'multiple',
|
166 |
+
'type' => 'true_false',
|
167 |
+
'ui' => 1,
|
168 |
+
'conditions' => array(
|
169 |
+
array(
|
170 |
+
array(
|
171 |
+
'field' => 'field_type',
|
172 |
+
'operator' => '==',
|
173 |
+
'value' => 'select',
|
174 |
+
),
|
175 |
+
),
|
176 |
+
)
|
177 |
+
));
|
178 |
+
|
179 |
+
// Select: ui
|
180 |
+
acf_render_field_setting( $field, array(
|
181 |
+
'label' => __('Stylised UI','acf'),
|
182 |
+
'instructions' => '',
|
183 |
+
'name' => 'ui',
|
184 |
+
'type' => 'true_false',
|
185 |
+
'ui' => 1,
|
186 |
+
'conditions' => array(
|
187 |
+
array(
|
188 |
+
array(
|
189 |
+
'field' => 'field_type',
|
190 |
+
'operator' => '==',
|
191 |
+
'value' => 'select',
|
192 |
+
),
|
193 |
+
),
|
194 |
+
)
|
195 |
+
));
|
196 |
+
|
197 |
+
|
198 |
+
// Select: ajax
|
199 |
+
acf_render_field_setting( $field, array(
|
200 |
+
'label' => __('Use AJAX to lazy load choices?','acf'),
|
201 |
+
'instructions' => '',
|
202 |
+
'name' => 'ajax',
|
203 |
+
'type' => 'true_false',
|
204 |
+
'ui' => 1,
|
205 |
+
'conditions' => array(
|
206 |
+
array(
|
207 |
+
array(
|
208 |
+
'field' => 'field_type',
|
209 |
+
'operator' => '==',
|
210 |
+
'value' => 'select',
|
211 |
+
),
|
212 |
+
array(
|
213 |
+
'field' => 'ui',
|
214 |
+
'operator' => '==',
|
215 |
+
'value' => 1,
|
216 |
+
),
|
217 |
+
),
|
218 |
+
)
|
219 |
+
));
|
220 |
+
|
221 |
+
// Radio: other_choice
|
222 |
+
acf_render_field_setting( $field, array(
|
223 |
+
'label' => __('Other','acf'),
|
224 |
+
'instructions' => '',
|
225 |
+
'name' => 'other_choice',
|
226 |
+
'type' => 'true_false',
|
227 |
+
'ui' => 1,
|
228 |
+
'message' => __("Add 'other' choice to allow for custom values", 'acf'),
|
229 |
+
'conditions' => array(
|
230 |
+
array(
|
231 |
+
array(
|
232 |
+
'field' => 'field_type',
|
233 |
+
'operator' => '==',
|
234 |
+
'value' => 'radio',
|
235 |
+
),
|
236 |
+
),
|
237 |
+
)
|
238 |
+
));
|
239 |
+
|
240 |
+
|
241 |
+
// Radio: save_other_choice
|
242 |
+
acf_render_field_setting( $field, array(
|
243 |
+
'label' => __('Save Other','acf'),
|
244 |
+
'instructions' => '',
|
245 |
+
'name' => 'save_other_choice',
|
246 |
+
'type' => 'true_false',
|
247 |
+
'ui' => 1,
|
248 |
+
'message' => __("Save 'other' values to the field's choices", 'acf'),
|
249 |
+
'conditions' => array(
|
250 |
+
array(
|
251 |
+
array(
|
252 |
+
'field' => 'field_type',
|
253 |
+
'operator' => '==',
|
254 |
+
'value' => 'radio',
|
255 |
+
),
|
256 |
+
array(
|
257 |
+
'field' => 'other_choice',
|
258 |
+
'operator' => '==',
|
259 |
+
'value' => 1,
|
260 |
+
),
|
261 |
+
),
|
262 |
+
)
|
263 |
+
));
|
264 |
+
|
265 |
+
// Checkbox: layout
|
266 |
+
acf_render_field_setting( $field, array(
|
267 |
+
'label' => __('Layout','acf'),
|
268 |
+
'instructions' => '',
|
269 |
+
'type' => 'radio',
|
270 |
+
'name' => 'layout',
|
271 |
+
'layout' => 'horizontal',
|
272 |
+
'choices' => array(
|
273 |
+
'vertical' => __("Vertical",'acf'),
|
274 |
+
'horizontal' => __("Horizontal",'acf')
|
275 |
+
),
|
276 |
+
'conditions' => array(
|
277 |
+
array(
|
278 |
+
array(
|
279 |
+
'field' => 'field_type',
|
280 |
+
'operator' => '==',
|
281 |
+
'value' => 'checkbox',
|
282 |
+
),
|
283 |
+
),
|
284 |
+
array(
|
285 |
+
array(
|
286 |
+
'field' => 'field_type',
|
287 |
+
'operator' => '==',
|
288 |
+
'value' => 'radio',
|
289 |
+
),
|
290 |
+
),
|
291 |
+
)
|
292 |
+
));
|
293 |
+
|
294 |
+
// Checkbox: toggle
|
295 |
+
acf_render_field_setting( $field, array(
|
296 |
+
'label' => __('Toggle','acf'),
|
297 |
+
'instructions' => __('Prepend an extra checkbox to toggle all choices','acf'),
|
298 |
+
'name' => 'toggle',
|
299 |
+
'type' => 'true_false',
|
300 |
+
'ui' => 1,
|
301 |
+
'conditions' => array(
|
302 |
+
array(
|
303 |
+
array(
|
304 |
+
'field' => 'field_type',
|
305 |
+
'operator' => '==',
|
306 |
+
'value' => 'checkbox',
|
307 |
+
),
|
308 |
+
),
|
309 |
+
)
|
310 |
+
));
|
311 |
+
|
312 |
+
// Checkbox: other_choice
|
313 |
+
acf_render_field_setting( $field, array(
|
314 |
+
'label' => __('Allow Custom','acf'),
|
315 |
+
'instructions' => '',
|
316 |
+
'name' => 'allow_custom',
|
317 |
+
'type' => 'true_false',
|
318 |
+
'ui' => 1,
|
319 |
+
'message' => __("Allow 'custom' values to be added", 'acf'),
|
320 |
+
'conditions' => array(
|
321 |
+
array(
|
322 |
+
array(
|
323 |
+
'field' => 'field_type',
|
324 |
+
'operator' => '==',
|
325 |
+
'value' => 'checkbox',
|
326 |
+
),
|
327 |
+
),
|
328 |
+
)
|
329 |
+
));
|
330 |
+
|
331 |
+
|
332 |
+
// Checkbox: save_other_choice
|
333 |
+
acf_render_field_setting( $field, array(
|
334 |
+
'label' => __('Save Custom','acf'),
|
335 |
+
'instructions' => '',
|
336 |
+
'name' => 'save_custom',
|
337 |
+
'type' => 'true_false',
|
338 |
+
'ui' => 1,
|
339 |
+
'message' => __("Save 'custom' values to the field's choices", 'acf'),
|
340 |
+
'conditions' => array(
|
341 |
+
array(
|
342 |
+
array(
|
343 |
+
'field' => 'field_type',
|
344 |
+
'operator' => '==',
|
345 |
+
'value' => 'checkbox',
|
346 |
+
),
|
347 |
+
array(
|
348 |
+
'field' => 'allow_custom',
|
349 |
+
'operator' => '==',
|
350 |
+
'value' => 1,
|
351 |
+
),
|
352 |
+
),
|
353 |
+
)
|
354 |
+
));
|
355 |
+
|
356 |
+
}
|
357 |
+
|
358 |
+
|
359 |
+
function format_value($value, $post_id, $field){
|
360 |
+
|
361 |
+
// Return: object
|
362 |
+
if($field['return_format'] === 'object'){
|
363 |
+
|
364 |
+
// array
|
365 |
+
if(acf_is_array($value)){
|
366 |
+
|
367 |
+
foreach($value as $i => $v){
|
368 |
+
|
369 |
+
$value[$i] = get_post_type_object($v);
|
370 |
+
|
371 |
+
}
|
372 |
+
|
373 |
+
// string
|
374 |
+
}else{
|
375 |
+
|
376 |
+
$value = get_post_type_object($value);
|
377 |
+
|
378 |
+
}
|
379 |
+
|
380 |
+
}
|
381 |
+
|
382 |
+
// return
|
383 |
+
return $value;
|
384 |
+
|
385 |
+
}
|
386 |
+
|
387 |
+
}
|
388 |
+
|
389 |
+
// initialize
|
390 |
+
acf_register_field_type('acfe_field_post_types');
|
391 |
+
|
392 |
endif;
|
includes/fields/field-recaptcha.php
CHANGED
@@ -1,291 +1,298 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
class acfe_field_recaptcha extends acf_field{
|
7 |
-
|
8 |
-
function __construct(){
|
9 |
-
|
10 |
-
$this->name = 'acfe_recaptcha';
|
11 |
-
$this->label = __('reCAPTCHA', 'acf');
|
12 |
-
$this->category = 'jquery';
|
13 |
-
$this->defaults = array(
|
14 |
-
'required' => 0,
|
15 |
-
'disabled' => 0,
|
16 |
-
'readonly' => 0,
|
17 |
-
'version' => 'v2',
|
18 |
-
'v2_theme' => 'light',
|
19 |
-
'v2_size' => 'normal',
|
20 |
-
'v3_hide_logo' => false,
|
21 |
-
'site_key' => '',
|
22 |
-
'secret_key' => '',
|
23 |
-
);
|
24 |
-
|
25 |
-
parent::__construct();
|
26 |
-
|
27 |
-
}
|
28 |
-
|
29 |
-
function render_field_settings($field){
|
30 |
-
|
31 |
-
// Version
|
32 |
-
acf_render_field_setting($field, array(
|
33 |
-
'label' => __('Version', 'acf'),
|
34 |
-
'instructions' => __('Select the reCaptcha version', 'acf'),
|
35 |
-
'type' => 'select',
|
36 |
-
'name' => 'version',
|
37 |
-
'choices' => array(
|
38 |
-
'v2' => __('reCaptcha V2', 'acf'),
|
39 |
-
'v3' => __('reCaptcha V3', 'acf'),
|
40 |
-
)
|
41 |
-
));
|
42 |
-
|
43 |
-
// V2 Theme
|
44 |
-
acf_render_field_setting($field, array(
|
45 |
-
'label' => __('Theme', 'acf'),
|
46 |
-
'instructions' => __('Select the reCaptcha theme', 'acf'),
|
47 |
-
'type' => 'select',
|
48 |
-
'name' => 'v2_theme',
|
49 |
-
'choices' => array(
|
50 |
-
'light' => __('Light', 'acf'),
|
51 |
-
'dark' => __('Dark', 'acf'),
|
52 |
-
),
|
53 |
-
'conditional_logic' => array(
|
54 |
-
array(
|
55 |
-
array(
|
56 |
-
'field' => 'version',
|
57 |
-
'operator' => '==',
|
58 |
-
'value' => 'v2',
|
59 |
-
)
|
60 |
-
)
|
61 |
-
)
|
62 |
-
));
|
63 |
-
|
64 |
-
// V2 Size
|
65 |
-
acf_render_field_setting($field, array(
|
66 |
-
'label' => __('Size', 'acf'),
|
67 |
-
'instructions' => __('Select the reCaptcha size', 'acf'),
|
68 |
-
'type' => 'select',
|
69 |
-
'name' => 'v2_size',
|
70 |
-
'choices' => array(
|
71 |
-
'normal' => __('Normal', 'acf'),
|
72 |
-
'compact' => __('Compact', 'acf'),
|
73 |
-
),
|
74 |
-
'conditional_logic' => array(
|
75 |
-
array(
|
76 |
-
array(
|
77 |
-
'field' => 'version',
|
78 |
-
'operator' => '==',
|
79 |
-
'value' => 'v2',
|
80 |
-
)
|
81 |
-
)
|
82 |
-
)
|
83 |
-
));
|
84 |
-
|
85 |
-
// V3 Hide Logo
|
86 |
-
acf_render_field_setting($field, array(
|
87 |
-
'label' => __('Hide logo', 'acf'),
|
88 |
-
'instructions' => __('Hide the reCaptcha logo', 'acf'),
|
89 |
-
'type' => 'true_false',
|
90 |
-
'name' => 'v3_hide_logo',
|
91 |
-
'ui' => true,
|
92 |
-
'conditional_logic' => array(
|
93 |
-
array(
|
94 |
-
array(
|
95 |
-
'field' => 'version',
|
96 |
-
'operator' => '==',
|
97 |
-
'value' => 'v3',
|
98 |
-
)
|
99 |
-
)
|
100 |
-
)
|
101 |
-
));
|
102 |
-
|
103 |
-
// Site Key
|
104 |
-
acf_render_field_setting($field, array(
|
105 |
-
'label' => __('Site key', 'acf'),
|
106 |
-
'instructions' => __('Enter the site key. <a href="https://www.google.com/recaptcha/admin" target="_blank">reCaptcha API Admin</a>', 'acf'),
|
107 |
-
'type' => 'text',
|
108 |
-
'name' => 'site_key',
|
109 |
-
));
|
110 |
-
|
111 |
-
// Site Secret
|
112 |
-
acf_render_field_setting($field, array(
|
113 |
-
'label' => __('Secret key', 'acf'),
|
114 |
-
'instructions' => __('Enter the secret key. <a href="https://www.google.com/recaptcha/admin" target="_blank">reCaptcha API Admin</a>', 'acf'),
|
115 |
-
'type' => 'text',
|
116 |
-
'name' => 'secret_key',
|
117 |
-
));
|
118 |
-
|
119 |
-
}
|
120 |
-
|
121 |
-
function prepare_field($field){
|
122 |
-
|
123 |
-
if($field['version'] === 'v3'){
|
124 |
-
|
125 |
-
$field['wrapper']['class'] = 'acf-hidden';
|
126 |
-
|
127 |
-
}
|
128 |
-
|
129 |
-
return $field;
|
130 |
-
|
131 |
-
}
|
132 |
-
|
133 |
-
function render_field($field){
|
134 |
-
|
135 |
-
// Site key
|
136 |
-
$site_key = acf_get_setting('acfe/field/recaptcha/site_key', $field['site_key']);
|
137 |
-
|
138 |
-
// Version
|
139 |
-
$field['version'] = acf_get_setting('acfe/field/recaptcha/version', $field['version']);
|
140 |
-
|
141 |
-
// V2
|
142 |
-
if($field['version'] === 'v2'){ ?>
|
143 |
-
|
144 |
-
<?php
|
145 |
-
// Theme & Size
|
146 |
-
$field['v2_theme'] = acf_get_setting('acfe/field/recaptcha/v2/theme', $field['v2_theme']);
|
147 |
-
$field['v2_size'] = acf_get_setting('acfe/field/recaptcha/v2/size', $field['v2_size']);
|
148 |
-
|
149 |
-
$wrapper = array(
|
150 |
-
'class' => 'acf-input-wrap acfe-field-recaptcha',
|
151 |
-
'data-site-key' => $site_key,
|
152 |
-
'data-version' => 'v2',
|
153 |
-
'data-size' => $field['v2_size'],
|
154 |
-
'data-theme' => $field['v2_theme'],
|
155 |
-
);
|
156 |
-
|
157 |
-
$hidden_input = array(
|
158 |
-
'id' => $field['id'],
|
159 |
-
'name' => $field['name'],
|
160 |
-
);
|
161 |
-
|
162 |
-
?>
|
163 |
-
<div <?php acf_esc_attr_e($wrapper); ?>>
|
164 |
-
|
165 |
-
<div></div>
|
166 |
-
<?php acf_hidden_input($hidden_input); ?>
|
167 |
-
|
168 |
-
</div>
|
169 |
-
|
170 |
-
<script src="https://www.google.com/recaptcha/api.js?onload=acfe_recaptcha&render=explicit" async defer></script>
|
171 |
-
|
172 |
-
<?php
|
173 |
-
return;
|
174 |
-
|
175 |
-
}
|
176 |
-
|
177 |
-
// V3
|
178 |
-
elseif($field['version'] === 'v3'){
|
179 |
-
|
180 |
-
// Hide logo
|
181 |
-
$field['v3_hide_logo'] = acf_get_setting('acfe/field/recaptcha/v3/hide_logo', $field['v3_hide_logo']);
|
182 |
-
|
183 |
-
$wrapper = array(
|
184 |
-
'class' => 'acf-input-wrap acfe-field-recaptcha',
|
185 |
-
'data-site-key' => $site_key,
|
186 |
-
'data-version' => 'v3',
|
187 |
-
);
|
188 |
-
|
189 |
-
$hidden_input = array(
|
190 |
-
'id' => $field['id'],
|
191 |
-
'name' => $field['name'],
|
192 |
-
);
|
193 |
-
|
194 |
-
?>
|
195 |
-
<div <?php acf_esc_attr_e($wrapper); ?>>
|
196 |
-
|
197 |
-
<div></div>
|
198 |
-
<?php acf_hidden_input($hidden_input); ?>
|
199 |
-
|
200 |
-
</div>
|
201 |
-
|
202 |
-
<?php if($field['v3_hide_logo']){ ?>
|
203 |
-
<style>
|
204 |
-
.grecaptcha-badge{
|
205 |
-
display: none;
|
206 |
-
visibility: hidden;
|
207 |
-
}
|
208 |
-
</style>
|
209 |
-
<?php } ?>
|
210 |
-
|
211 |
-
<script src="https://www.google.com/recaptcha/api.js?render=<?php echo $site_key; ?>&onload=acfe_recaptcha" async defer></script>
|
212 |
-
|
213 |
-
<?php
|
214 |
-
return;
|
215 |
-
|
216 |
-
}
|
217 |
-
|
218 |
-
}
|
219 |
-
|
220 |
-
function validate_value($valid, $value, $field, $input){
|
221 |
-
|
222 |
-
// Expired
|
223 |
-
if($value === 'expired'){
|
224 |
-
|
225 |
-
return __('reCaptcha has expired.');
|
226 |
-
|
227 |
-
}
|
228 |
-
|
229 |
-
// Error
|
230 |
-
elseif($value === 'error'){
|
231 |
-
|
232 |
-
return __('An error has occured.');
|
233 |
-
|
234 |
-
}
|
235 |
-
|
236 |
-
// Only true submission
|
237 |
-
elseif(!wp_doing_ajax()){
|
238 |
-
|
239 |
-
// Empty & Required
|
240 |
-
if(empty($value) && $field['required']){
|
241 |
-
|
242 |
-
return $valid;
|
243 |
-
|
244 |
-
}
|
245 |
-
|
246 |
-
// Success
|
247 |
-
else{
|
248 |
-
|
249 |
-
// Secret key
|
250 |
-
$secret_key = acf_get_setting('acfe/field/recaptcha/secret_key', $field['secret_key']);
|
251 |
-
|
252 |
-
// API Call
|
253 |
-
$
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
return
|
285 |
-
|
286 |
-
}
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
291 |
acf_register_field_type('acfe_field_recaptcha');
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
class acfe_field_recaptcha extends acf_field{
|
7 |
+
|
8 |
+
function __construct(){
|
9 |
+
|
10 |
+
$this->name = 'acfe_recaptcha';
|
11 |
+
$this->label = __('reCAPTCHA', 'acf');
|
12 |
+
$this->category = 'jquery';
|
13 |
+
$this->defaults = array(
|
14 |
+
'required' => 0,
|
15 |
+
'disabled' => 0,
|
16 |
+
'readonly' => 0,
|
17 |
+
'version' => 'v2',
|
18 |
+
'v2_theme' => 'light',
|
19 |
+
'v2_size' => 'normal',
|
20 |
+
'v3_hide_logo' => false,
|
21 |
+
'site_key' => '',
|
22 |
+
'secret_key' => '',
|
23 |
+
);
|
24 |
+
|
25 |
+
parent::__construct();
|
26 |
+
|
27 |
+
}
|
28 |
+
|
29 |
+
function render_field_settings($field){
|
30 |
+
|
31 |
+
// Version
|
32 |
+
acf_render_field_setting($field, array(
|
33 |
+
'label' => __('Version', 'acf'),
|
34 |
+
'instructions' => __('Select the reCaptcha version', 'acf'),
|
35 |
+
'type' => 'select',
|
36 |
+
'name' => 'version',
|
37 |
+
'choices' => array(
|
38 |
+
'v2' => __('reCaptcha V2', 'acf'),
|
39 |
+
'v3' => __('reCaptcha V3', 'acf'),
|
40 |
+
)
|
41 |
+
));
|
42 |
+
|
43 |
+
// V2 Theme
|
44 |
+
acf_render_field_setting($field, array(
|
45 |
+
'label' => __('Theme', 'acf'),
|
46 |
+
'instructions' => __('Select the reCaptcha theme', 'acf'),
|
47 |
+
'type' => 'select',
|
48 |
+
'name' => 'v2_theme',
|
49 |
+
'choices' => array(
|
50 |
+
'light' => __('Light', 'acf'),
|
51 |
+
'dark' => __('Dark', 'acf'),
|
52 |
+
),
|
53 |
+
'conditional_logic' => array(
|
54 |
+
array(
|
55 |
+
array(
|
56 |
+
'field' => 'version',
|
57 |
+
'operator' => '==',
|
58 |
+
'value' => 'v2',
|
59 |
+
)
|
60 |
+
)
|
61 |
+
)
|
62 |
+
));
|
63 |
+
|
64 |
+
// V2 Size
|
65 |
+
acf_render_field_setting($field, array(
|
66 |
+
'label' => __('Size', 'acf'),
|
67 |
+
'instructions' => __('Select the reCaptcha size', 'acf'),
|
68 |
+
'type' => 'select',
|
69 |
+
'name' => 'v2_size',
|
70 |
+
'choices' => array(
|
71 |
+
'normal' => __('Normal', 'acf'),
|
72 |
+
'compact' => __('Compact', 'acf'),
|
73 |
+
),
|
74 |
+
'conditional_logic' => array(
|
75 |
+
array(
|
76 |
+
array(
|
77 |
+
'field' => 'version',
|
78 |
+
'operator' => '==',
|
79 |
+
'value' => 'v2',
|
80 |
+
)
|
81 |
+
)
|
82 |
+
)
|
83 |
+
));
|
84 |
+
|
85 |
+
// V3 Hide Logo
|
86 |
+
acf_render_field_setting($field, array(
|
87 |
+
'label' => __('Hide logo', 'acf'),
|
88 |
+
'instructions' => __('Hide the reCaptcha logo', 'acf'),
|
89 |
+
'type' => 'true_false',
|
90 |
+
'name' => 'v3_hide_logo',
|
91 |
+
'ui' => true,
|
92 |
+
'conditional_logic' => array(
|
93 |
+
array(
|
94 |
+
array(
|
95 |
+
'field' => 'version',
|
96 |
+
'operator' => '==',
|
97 |
+
'value' => 'v3',
|
98 |
+
)
|
99 |
+
)
|
100 |
+
)
|
101 |
+
));
|
102 |
+
|
103 |
+
// Site Key
|
104 |
+
acf_render_field_setting($field, array(
|
105 |
+
'label' => __('Site key', 'acf'),
|
106 |
+
'instructions' => __('Enter the site key. <a href="https://www.google.com/recaptcha/admin" target="_blank">reCaptcha API Admin</a>', 'acf'),
|
107 |
+
'type' => 'text',
|
108 |
+
'name' => 'site_key',
|
109 |
+
));
|
110 |
+
|
111 |
+
// Site Secret
|
112 |
+
acf_render_field_setting($field, array(
|
113 |
+
'label' => __('Secret key', 'acf'),
|
114 |
+
'instructions' => __('Enter the secret key. <a href="https://www.google.com/recaptcha/admin" target="_blank">reCaptcha API Admin</a>', 'acf'),
|
115 |
+
'type' => 'text',
|
116 |
+
'name' => 'secret_key',
|
117 |
+
));
|
118 |
+
|
119 |
+
}
|
120 |
+
|
121 |
+
function prepare_field($field){
|
122 |
+
|
123 |
+
if($field['version'] === 'v3'){
|
124 |
+
|
125 |
+
$field['wrapper']['class'] = 'acf-hidden';
|
126 |
+
|
127 |
+
}
|
128 |
+
|
129 |
+
return $field;
|
130 |
+
|
131 |
+
}
|
132 |
+
|
133 |
+
function render_field($field){
|
134 |
+
|
135 |
+
// Site key
|
136 |
+
$site_key = acf_get_setting('acfe/field/recaptcha/site_key', $field['site_key']);
|
137 |
+
|
138 |
+
// Version
|
139 |
+
$field['version'] = acf_get_setting('acfe/field/recaptcha/version', $field['version']);
|
140 |
+
|
141 |
+
// V2
|
142 |
+
if($field['version'] === 'v2'){ ?>
|
143 |
+
|
144 |
+
<?php
|
145 |
+
// Theme & Size
|
146 |
+
$field['v2_theme'] = acf_get_setting('acfe/field/recaptcha/v2/theme', $field['v2_theme']);
|
147 |
+
$field['v2_size'] = acf_get_setting('acfe/field/recaptcha/v2/size', $field['v2_size']);
|
148 |
+
|
149 |
+
$wrapper = array(
|
150 |
+
'class' => 'acf-input-wrap acfe-field-recaptcha',
|
151 |
+
'data-site-key' => $site_key,
|
152 |
+
'data-version' => 'v2',
|
153 |
+
'data-size' => $field['v2_size'],
|
154 |
+
'data-theme' => $field['v2_theme'],
|
155 |
+
);
|
156 |
+
|
157 |
+
$hidden_input = array(
|
158 |
+
'id' => $field['id'],
|
159 |
+
'name' => $field['name'],
|
160 |
+
);
|
161 |
+
|
162 |
+
?>
|
163 |
+
<div <?php acf_esc_attr_e($wrapper); ?>>
|
164 |
+
|
165 |
+
<div></div>
|
166 |
+
<?php acf_hidden_input($hidden_input); ?>
|
167 |
+
|
168 |
+
</div>
|
169 |
+
|
170 |
+
<script src="https://www.google.com/recaptcha/api.js?onload=acfe_recaptcha&render=explicit" async defer></script>
|
171 |
+
|
172 |
+
<?php
|
173 |
+
return;
|
174 |
+
|
175 |
+
}
|
176 |
+
|
177 |
+
// V3
|
178 |
+
elseif($field['version'] === 'v3'){
|
179 |
+
|
180 |
+
// Hide logo
|
181 |
+
$field['v3_hide_logo'] = acf_get_setting('acfe/field/recaptcha/v3/hide_logo', $field['v3_hide_logo']);
|
182 |
+
|
183 |
+
$wrapper = array(
|
184 |
+
'class' => 'acf-input-wrap acfe-field-recaptcha',
|
185 |
+
'data-site-key' => $site_key,
|
186 |
+
'data-version' => 'v3',
|
187 |
+
);
|
188 |
+
|
189 |
+
$hidden_input = array(
|
190 |
+
'id' => $field['id'],
|
191 |
+
'name' => $field['name'],
|
192 |
+
);
|
193 |
+
|
194 |
+
?>
|
195 |
+
<div <?php acf_esc_attr_e($wrapper); ?>>
|
196 |
+
|
197 |
+
<div></div>
|
198 |
+
<?php acf_hidden_input($hidden_input); ?>
|
199 |
+
|
200 |
+
</div>
|
201 |
+
|
202 |
+
<?php if($field['v3_hide_logo']){ ?>
|
203 |
+
<style>
|
204 |
+
.grecaptcha-badge{
|
205 |
+
display: none;
|
206 |
+
visibility: hidden;
|
207 |
+
}
|
208 |
+
</style>
|
209 |
+
<?php } ?>
|
210 |
+
|
211 |
+
<script src="https://www.google.com/recaptcha/api.js?render=<?php echo $site_key; ?>&onload=acfe_recaptcha" async defer></script>
|
212 |
+
|
213 |
+
<?php
|
214 |
+
return;
|
215 |
+
|
216 |
+
}
|
217 |
+
|
218 |
+
}
|
219 |
+
|
220 |
+
function validate_value($valid, $value, $field, $input){
|
221 |
+
|
222 |
+
// Expired
|
223 |
+
if($value === 'expired'){
|
224 |
+
|
225 |
+
return __('reCaptcha has expired.');
|
226 |
+
|
227 |
+
}
|
228 |
+
|
229 |
+
// Error
|
230 |
+
elseif($value === 'error'){
|
231 |
+
|
232 |
+
return __('An error has occured.');
|
233 |
+
|
234 |
+
}
|
235 |
+
|
236 |
+
// Only true submission
|
237 |
+
elseif(!wp_doing_ajax()){
|
238 |
+
|
239 |
+
// Empty & Required
|
240 |
+
if(empty($value) && $field['required']){
|
241 |
+
|
242 |
+
return $valid;
|
243 |
+
|
244 |
+
}
|
245 |
+
|
246 |
+
// Success
|
247 |
+
else{
|
248 |
+
|
249 |
+
// Secret key
|
250 |
+
$secret_key = acf_get_setting('acfe/field/recaptcha/secret_key', $field['secret_key']);
|
251 |
+
|
252 |
+
// API Call
|
253 |
+
$curl = curl_init();
|
254 |
+
|
255 |
+
curl_setopt($curl, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify?secret={$secret_key}&response={$value}");
|
256 |
+
curl_setopt($curl, CURLOPT_HEADER, 0);
|
257 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
258 |
+
$api = curl_exec($curl);
|
259 |
+
|
260 |
+
curl_close($curl);
|
261 |
+
|
262 |
+
// No response
|
263 |
+
if(empty($api))
|
264 |
+
return false;
|
265 |
+
|
266 |
+
$response = json_decode($api);
|
267 |
+
|
268 |
+
if($response->success === false){
|
269 |
+
|
270 |
+
$valid = false;
|
271 |
+
|
272 |
+
}
|
273 |
+
|
274 |
+
elseif($response->success === true){
|
275 |
+
|
276 |
+
$valid = true;
|
277 |
+
|
278 |
+
}
|
279 |
+
|
280 |
+
}
|
281 |
+
|
282 |
+
}
|
283 |
+
|
284 |
+
return $valid;
|
285 |
+
|
286 |
+
}
|
287 |
+
|
288 |
+
function update_value($value, $post_id, $field){
|
289 |
+
|
290 |
+
// Do not save field value
|
291 |
+
return null;
|
292 |
+
|
293 |
+
}
|
294 |
+
|
295 |
+
}
|
296 |
+
|
297 |
+
// initialize
|
298 |
acf_register_field_type('acfe_field_recaptcha');
|
includes/fields/field-select.php
CHANGED
@@ -1,27 +1,34 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
add_action('acf/render_field_settings/type=select', 'acfe_field_select_settings');
|
7 |
-
function acfe_field_select_settings($field){
|
8 |
-
|
9 |
-
// placeholder
|
10 |
-
acf_render_field_setting($field, array(
|
11 |
-
'label' => __('Placeholder Text','acf'),
|
12 |
-
'instructions' => __('Appears within the input','acf'),
|
13 |
-
'type' => 'text',
|
14 |
-
'name' => 'placeholder',
|
15 |
-
'placeholder' => _x('Select', 'verb', 'acf'),
|
16 |
-
'conditional_logic' => array(
|
17 |
-
array(
|
18 |
-
array(
|
19 |
-
'field' => '
|
20 |
-
'operator' => '==',
|
21 |
-
'value' => '1',
|
22 |
-
)
|
23 |
-
)
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
add_action('acf/render_field_settings/type=select', 'acfe_field_select_settings');
|
7 |
+
function acfe_field_select_settings($field){
|
8 |
+
|
9 |
+
// placeholder
|
10 |
+
acf_render_field_setting($field, array(
|
11 |
+
'label' => __('Placeholder Text','acf'),
|
12 |
+
'instructions' => __('Appears within the input','acf'),
|
13 |
+
'type' => 'text',
|
14 |
+
'name' => 'placeholder',
|
15 |
+
'placeholder' => _x('Select', 'verb', 'acf'),
|
16 |
+
'conditional_logic' => array(
|
17 |
+
array(
|
18 |
+
array(
|
19 |
+
'field' => 'ui',
|
20 |
+
'operator' => '==',
|
21 |
+
'value' => '1',
|
22 |
+
)
|
23 |
+
),
|
24 |
+
array(
|
25 |
+
array(
|
26 |
+
'field' => 'allow_null',
|
27 |
+
'operator' => '==',
|
28 |
+
'value' => '1',
|
29 |
+
)
|
30 |
+
),
|
31 |
+
)
|
32 |
+
));
|
33 |
+
|
34 |
}
|
includes/fields/field-taxonomies.php
CHANGED
@@ -1,379 +1,392 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
if(!class_exists('acfe_field_taxonomies')):
|
7 |
-
|
8 |
-
class acfe_field_taxonomies extends acf_field{
|
9 |
-
|
10 |
-
function __construct(){
|
11 |
-
|
12 |
-
$this->name = 'acfe_taxonomies';
|
13 |
-
$this->label = __('Taxonomies', 'acfe');
|
14 |
-
$this->category = 'relational';
|
15 |
-
$this->defaults = array(
|
16 |
-
'taxonomy' => array(),
|
17 |
-
'field_type' => 'checkbox',
|
18 |
-
'multiple' => 0,
|
19 |
-
'allow_null' => 0,
|
20 |
-
'choices' => array(),
|
21 |
-
'default_value' => '',
|
22 |
-
'ui' => 0,
|
23 |
-
'ajax' => 0,
|
24 |
-
'placeholder' => '',
|
25 |
-
'layout' => '',
|
26 |
-
'toggle' => 0,
|
27 |
-
'allow_custom' => 0,
|
28 |
-
'return_format' => 'name',
|
29 |
-
);
|
30 |
-
|
31 |
-
parent::__construct();
|
32 |
-
|
33 |
-
}
|
34 |
-
|
35 |
-
function prepare_field($field){
|
36 |
-
|
37 |
-
$field['choices'] = acf_get_taxonomy_labels($field['taxonomy']);
|
38 |
-
|
39 |
-
// Set Field Type
|
40 |
-
$field['type'] = $field['field_type'];
|
41 |
-
|
42 |
-
return $field;
|
43 |
-
|
44 |
-
}
|
45 |
-
|
46 |
-
function render_field_settings($field){
|
47 |
-
|
48 |
-
if(isset($field['default_value']))
|
49 |
-
$field['default_value'] = acf_encode_choices($field['default_value'], false);
|
50 |
-
|
51 |
-
// Allow Taxonomy
|
52 |
-
acf_render_field_setting( $field, array(
|
53 |
-
'label' => __('Allow Taxonomy','acf'),
|
54 |
-
'instructions' => '',
|
55 |
-
'type' => 'select',
|
56 |
-
'name' => 'taxonomy',
|
57 |
-
'choices' => acf_get_taxonomy_labels(),
|
58 |
-
'multiple' => 1,
|
59 |
-
'ui' => 1,
|
60 |
-
'allow_null' => 1,
|
61 |
-
'placeholder' => __("All taxonomies",'acf'),
|
62 |
-
));
|
63 |
-
|
64 |
-
// field_type
|
65 |
-
acf_render_field_setting($field, array(
|
66 |
-
'label' => __('Appearance','acf'),
|
67 |
-
'instructions' => __('Select the appearance of this field', 'acf'),
|
68 |
-
'type' => 'select',
|
69 |
-
'name' => 'field_type',
|
70 |
-
'optgroup' => true,
|
71 |
-
'choices' => array(
|
72 |
-
'checkbox' => __('Checkbox', 'acf'),
|
73 |
-
'radio' => __('Radio Buttons', 'acf'),
|
74 |
-
'select' => _x('Select', 'noun', 'acf')
|
75 |
-
)
|
76 |
-
));
|
77 |
-
|
78 |
-
// default_value
|
79 |
-
acf_render_field_setting( $field, array(
|
80 |
-
'label' => __('Default Value','acf'),
|
81 |
-
'instructions' => __('Enter each default value on a new line','acf'),
|
82 |
-
'name' => 'default_value',
|
83 |
-
'type' => 'textarea',
|
84 |
-
));
|
85 |
-
|
86 |
-
// return_format
|
87 |
-
acf_render_field_setting($field, array(
|
88 |
-
'label' => __('Return Value', 'acf'),
|
89 |
-
'instructions' => '',
|
90 |
-
'type' => 'radio',
|
91 |
-
'name' => 'return_format',
|
92 |
-
'choices' => array(
|
93 |
-
'object' => __('Taxonomy object', 'acfe'),
|
94 |
-
'name' => __('Taxonomy name', 'acfe')
|
95 |
-
),
|
96 |
-
'layout' => 'horizontal',
|
97 |
-
));
|
98 |
-
|
99 |
-
// Select + Radio: allow_null
|
100 |
-
acf_render_field_setting( $field, array(
|
101 |
-
'label' => __('Allow Null?','acf'),
|
102 |
-
'instructions' => '',
|
103 |
-
'name' => 'allow_null',
|
104 |
-
'type' => 'true_false',
|
105 |
-
'ui' => 1,
|
106 |
-
'conditions' => array(
|
107 |
-
array(
|
108 |
-
array(
|
109 |
-
'field' => 'field_type',
|
110 |
-
'operator' => '==',
|
111 |
-
'value' => 'select',
|
112 |
-
),
|
113 |
-
),
|
114 |
-
array(
|
115 |
-
array(
|
116 |
-
'field' => 'field_type',
|
117 |
-
'operator' => '==',
|
118 |
-
'value' => 'radio',
|
119 |
-
),
|
120 |
-
),
|
121 |
-
)
|
122 |
-
));
|
123 |
-
|
124 |
-
// placeholder
|
125 |
-
acf_render_field_setting($field, array(
|
126 |
-
'label' => __('Placeholder Text','acf'),
|
127 |
-
'instructions' => __('Appears within the input','acf'),
|
128 |
-
'type' => 'text',
|
129 |
-
'name' => 'placeholder',
|
130 |
-
'placeholder' => _x('Select', 'verb', 'acf'),
|
131 |
-
'conditional_logic' => array(
|
132 |
-
array(
|
133 |
-
array(
|
134 |
-
'field' => 'field_type',
|
135 |
-
'operator' => '==',
|
136 |
-
'value' => 'select',
|
137 |
-
),
|
138 |
-
array(
|
139 |
-
'field' => 'allow_null',
|
140 |
-
'operator' => '==',
|
141 |
-
'value' => '1',
|
142 |
-
),
|
143 |
-
|
144 |
-
)
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
}
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
379 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
if(!class_exists('acfe_field_taxonomies')):
|
7 |
+
|
8 |
+
class acfe_field_taxonomies extends acf_field{
|
9 |
+
|
10 |
+
function __construct(){
|
11 |
+
|
12 |
+
$this->name = 'acfe_taxonomies';
|
13 |
+
$this->label = __('Taxonomies', 'acfe');
|
14 |
+
$this->category = 'relational';
|
15 |
+
$this->defaults = array(
|
16 |
+
'taxonomy' => array(),
|
17 |
+
'field_type' => 'checkbox',
|
18 |
+
'multiple' => 0,
|
19 |
+
'allow_null' => 0,
|
20 |
+
'choices' => array(),
|
21 |
+
'default_value' => '',
|
22 |
+
'ui' => 0,
|
23 |
+
'ajax' => 0,
|
24 |
+
'placeholder' => '',
|
25 |
+
'layout' => '',
|
26 |
+
'toggle' => 0,
|
27 |
+
'allow_custom' => 0,
|
28 |
+
'return_format' => 'name',
|
29 |
+
);
|
30 |
+
|
31 |
+
parent::__construct();
|
32 |
+
|
33 |
+
}
|
34 |
+
|
35 |
+
function prepare_field($field){
|
36 |
+
|
37 |
+
$field['choices'] = acf_get_taxonomy_labels($field['taxonomy']);
|
38 |
+
|
39 |
+
// Set Field Type
|
40 |
+
$field['type'] = $field['field_type'];
|
41 |
+
|
42 |
+
return $field;
|
43 |
+
|
44 |
+
}
|
45 |
+
|
46 |
+
function render_field_settings($field){
|
47 |
+
|
48 |
+
if(isset($field['default_value']))
|
49 |
+
$field['default_value'] = acf_encode_choices($field['default_value'], false);
|
50 |
+
|
51 |
+
// Allow Taxonomy
|
52 |
+
acf_render_field_setting( $field, array(
|
53 |
+
'label' => __('Allow Taxonomy','acf'),
|
54 |
+
'instructions' => '',
|
55 |
+
'type' => 'select',
|
56 |
+
'name' => 'taxonomy',
|
57 |
+
'choices' => acf_get_taxonomy_labels(),
|
58 |
+
'multiple' => 1,
|
59 |
+
'ui' => 1,
|
60 |
+
'allow_null' => 1,
|
61 |
+
'placeholder' => __("All taxonomies",'acf'),
|
62 |
+
));
|
63 |
+
|
64 |
+
// field_type
|
65 |
+
acf_render_field_setting($field, array(
|
66 |
+
'label' => __('Appearance','acf'),
|
67 |
+
'instructions' => __('Select the appearance of this field', 'acf'),
|
68 |
+
'type' => 'select',
|
69 |
+
'name' => 'field_type',
|
70 |
+
'optgroup' => true,
|
71 |
+
'choices' => array(
|
72 |
+
'checkbox' => __('Checkbox', 'acf'),
|
73 |
+
'radio' => __('Radio Buttons', 'acf'),
|
74 |
+
'select' => _x('Select', 'noun', 'acf')
|
75 |
+
)
|
76 |
+
));
|
77 |
+
|
78 |
+
// default_value
|
79 |
+
acf_render_field_setting( $field, array(
|
80 |
+
'label' => __('Default Value','acf'),
|
81 |
+
'instructions' => __('Enter each default value on a new line','acf'),
|
82 |
+
'name' => 'default_value',
|
83 |
+
'type' => 'textarea',
|
84 |
+
));
|
85 |
+
|
86 |
+
// return_format
|
87 |
+
acf_render_field_setting($field, array(
|
88 |
+
'label' => __('Return Value', 'acf'),
|
89 |
+
'instructions' => '',
|
90 |
+
'type' => 'radio',
|
91 |
+
'name' => 'return_format',
|
92 |
+
'choices' => array(
|
93 |
+
'object' => __('Taxonomy object', 'acfe'),
|
94 |
+
'name' => __('Taxonomy name', 'acfe')
|
95 |
+
),
|
96 |
+
'layout' => 'horizontal',
|
97 |
+
));
|
98 |
+
|
99 |
+
// Select + Radio: allow_null
|
100 |
+
acf_render_field_setting( $field, array(
|
101 |
+
'label' => __('Allow Null?','acf'),
|
102 |
+
'instructions' => '',
|
103 |
+
'name' => 'allow_null',
|
104 |
+
'type' => 'true_false',
|
105 |
+
'ui' => 1,
|
106 |
+
'conditions' => array(
|
107 |
+
array(
|
108 |
+
array(
|
109 |
+
'field' => 'field_type',
|
110 |
+
'operator' => '==',
|
111 |
+
'value' => 'select',
|
112 |
+
),
|
113 |
+
),
|
114 |
+
array(
|
115 |
+
array(
|
116 |
+
'field' => 'field_type',
|
117 |
+
'operator' => '==',
|
118 |
+
'value' => 'radio',
|
119 |
+
),
|
120 |
+
),
|
121 |
+
)
|
122 |
+
));
|
123 |
+
|
124 |
+
// placeholder
|
125 |
+
acf_render_field_setting($field, array(
|
126 |
+
'label' => __('Placeholder Text','acf'),
|
127 |
+
'instructions' => __('Appears within the input','acf'),
|
128 |
+
'type' => 'text',
|
129 |
+
'name' => 'placeholder',
|
130 |
+
'placeholder' => _x('Select', 'verb', 'acf'),
|
131 |
+
'conditional_logic' => array(
|
132 |
+
array(
|
133 |
+
array(
|
134 |
+
'field' => 'field_type',
|
135 |
+
'operator' => '==',
|
136 |
+
'value' => 'select',
|
137 |
+
),
|
138 |
+
array(
|
139 |
+
'field' => 'allow_null',
|
140 |
+
'operator' => '==',
|
141 |
+
'value' => '1',
|
142 |
+
),
|
143 |
+
|
144 |
+
),
|
145 |
+
array(
|
146 |
+
array(
|
147 |
+
'field' => 'field_type',
|
148 |
+
'operator' => '==',
|
149 |
+
'value' => 'select',
|
150 |
+
),
|
151 |
+
array(
|
152 |
+
'field' => 'ui',
|
153 |
+
'operator' => '==',
|
154 |
+
'value' => '1',
|
155 |
+
),
|
156 |
+
|
157 |
+
),
|
158 |
+
)
|
159 |
+
));
|
160 |
+
|
161 |
+
// Select: multiple
|
162 |
+
acf_render_field_setting( $field, array(
|
163 |
+
'label' => __('Select multiple values?','acf'),
|
164 |
+
'instructions' => '',
|
165 |
+
'name' => 'multiple',
|
166 |
+
'type' => 'true_false',
|
167 |
+
'ui' => 1,
|
168 |
+
'conditions' => array(
|
169 |
+
array(
|
170 |
+
array(
|
171 |
+
'field' => 'field_type',
|
172 |
+
'operator' => '==',
|
173 |
+
'value' => 'select',
|
174 |
+
),
|
175 |
+
),
|
176 |
+
)
|
177 |
+
));
|
178 |
+
|
179 |
+
// Select: ui
|
180 |
+
acf_render_field_setting( $field, array(
|
181 |
+
'label' => __('Stylised UI','acf'),
|
182 |
+
'instructions' => '',
|
183 |
+
'name' => 'ui',
|
184 |
+
'type' => 'true_false',
|
185 |
+
'ui' => 1,
|
186 |
+
'conditions' => array(
|
187 |
+
array(
|
188 |
+
array(
|
189 |
+
'field' => 'field_type',
|
190 |
+
'operator' => '==',
|
191 |
+
'value' => 'select',
|
192 |
+
),
|
193 |
+
),
|
194 |
+
)
|
195 |
+
));
|
196 |
+
|
197 |
+
|
198 |
+
// Select: ajax
|
199 |
+
acf_render_field_setting( $field, array(
|
200 |
+
'label' => __('Use AJAX to lazy load choices?','acf'),
|
201 |
+
'instructions' => '',
|
202 |
+
'name' => 'ajax',
|
203 |
+
'type' => 'true_false',
|
204 |
+
'ui' => 1,
|
205 |
+
'conditions' => array(
|
206 |
+
array(
|
207 |
+
array(
|
208 |
+
'field' => 'field_type',
|
209 |
+
'operator' => '==',
|
210 |
+
'value' => 'select',
|
211 |
+
),
|
212 |
+
array(
|
213 |
+
'field' => 'ui',
|
214 |
+
'operator' => '==',
|
215 |
+
'value' => 1,
|
216 |
+
),
|
217 |
+
),
|
218 |
+
)
|
219 |
+
));
|
220 |
+
|
221 |
+
// Radio: other_choice
|
222 |
+
acf_render_field_setting( $field, array(
|
223 |
+
'label' => __('Other','acf'),
|
224 |
+
'instructions' => '',
|
225 |
+
'name' => 'other_choice',
|
226 |
+
'type' => 'true_false',
|
227 |
+
'ui' => 1,
|
228 |
+
'message' => __("Add 'other' choice to allow for custom values", 'acf'),
|
229 |
+
'conditions' => array(
|
230 |
+
array(
|
231 |
+
array(
|
232 |
+
'field' => 'field_type',
|
233 |
+
'operator' => '==',
|
234 |
+
'value' => 'radio',
|
235 |
+
),
|
236 |
+
),
|
237 |
+
)
|
238 |
+
));
|
239 |
+
|
240 |
+
|
241 |
+
// Radio: save_other_choice
|
242 |
+
acf_render_field_setting( $field, array(
|
243 |
+
'label' => __('Save Other','acf'),
|
244 |
+
'instructions' => '',
|
245 |
+
'name' => 'save_other_choice',
|
246 |
+
'type' => 'true_false',
|
247 |
+
'ui' => 1,
|
248 |
+
'message' => __("Save 'other' values to the field's choices", 'acf'),
|
249 |
+
'conditions' => array(
|
250 |
+
array(
|
251 |
+
array(
|
252 |
+
'field' => 'field_type',
|
253 |
+
'operator' => '==',
|
254 |
+
'value' => 'radio',
|
255 |
+
),
|
256 |
+
array(
|
257 |
+
'field' => 'other_choice',
|
258 |
+
'operator' => '==',
|
259 |
+
'value' => 1,
|
260 |
+
),
|
261 |
+
),
|
262 |
+
)
|
263 |
+
));
|
264 |
+
|
265 |
+
// Checkbox: layout
|
266 |
+
acf_render_field_setting( $field, array(
|
267 |
+
'label' => __('Layout','acf'),
|
268 |
+
'instructions' => '',
|
269 |
+
'type' => 'radio',
|
270 |
+
'name' => 'layout',
|
271 |
+
'layout' => 'horizontal',
|
272 |
+
'choices' => array(
|
273 |
+
'vertical' => __("Vertical",'acf'),
|
274 |
+
'horizontal' => __("Horizontal",'acf')
|
275 |
+
),
|
276 |
+
'conditions' => array(
|
277 |
+
array(
|
278 |
+
array(
|
279 |
+
'field' => 'field_type',
|
280 |
+
'operator' => '==',
|
281 |
+
'value' => 'checkbox',
|
282 |
+
),
|
283 |
+
),
|
284 |
+
array(
|
285 |
+
array(
|
286 |
+
'field' => 'field_type',
|
287 |
+
'operator' => '==',
|
288 |
+
'value' => 'radio',
|
289 |
+
),
|
290 |
+
),
|
291 |
+
)
|
292 |
+
));
|
293 |
+
|
294 |
+
// Checkbox: toggle
|
295 |
+
acf_render_field_setting( $field, array(
|
296 |
+
'label' => __('Toggle','acf'),
|
297 |
+
'instructions' => __('Prepend an extra checkbox to toggle all choices','acf'),
|
298 |
+
'name' => 'toggle',
|
299 |
+
'type' => 'true_false',
|
300 |
+
'ui' => 1,
|
301 |
+
'conditions' => array(
|
302 |
+
array(
|
303 |
+
array(
|
304 |
+
'field' => 'field_type',
|
305 |
+
'operator' => '==',
|
306 |
+
'value' => 'checkbox',
|
307 |
+
),
|
308 |
+
),
|
309 |
+
)
|
310 |
+
));
|
311 |
+
|
312 |
+
// Checkbox: other_choice
|
313 |
+
acf_render_field_setting( $field, array(
|
314 |
+
'label' => __('Allow Custom','acf'),
|
315 |
+
'instructions' => '',
|
316 |
+
'name' => 'allow_custom',
|
317 |
+
'type' => 'true_false',
|
318 |
+
'ui' => 1,
|
319 |
+
'message' => __("Allow 'custom' values to be added", 'acf'),
|
320 |
+
'conditions' => array(
|
321 |
+
array(
|
322 |
+
array(
|
323 |
+
'field' => 'field_type',
|
324 |
+
'operator' => '==',
|
325 |
+
'value' => 'checkbox',
|
326 |
+
),
|
327 |
+
),
|
328 |
+
)
|
329 |
+
));
|
330 |
+
|
331 |
+
|
332 |
+
// Checkbox: save_other_choice
|
333 |
+
acf_render_field_setting( $field, array(
|
334 |
+
'label' => __('Save Custom','acf'),
|
335 |
+
'instructions' => '',
|
336 |
+
'name' => 'save_custom',
|
337 |
+
'type' => 'true_false',
|
338 |
+
'ui' => 1,
|
339 |
+
'message' => __("Save 'custom' values to the field's choices", 'acf'),
|
340 |
+
'conditions' => array(
|
341 |
+
array(
|
342 |
+
array(
|
343 |
+
'field' => 'field_type',
|
344 |
+
'operator' => '==',
|
345 |
+
'value' => 'checkbox',
|
346 |
+
),
|
347 |
+
array(
|
348 |
+
'field' => 'allow_custom',
|
349 |
+
'operator' => '==',
|
350 |
+
'value' => 1,
|
351 |
+
),
|
352 |
+
),
|
353 |
+
)
|
354 |
+
));
|
355 |
+
|
356 |
+
}
|
357 |
+
|
358 |
+
|
359 |
+
function format_value($value, $post_id, $field){
|
360 |
+
|
361 |
+
// Return: object
|
362 |
+
if($field['return_format'] === 'object'){
|
363 |
+
|
364 |
+
// array
|
365 |
+
if(acf_is_array($value)){
|
366 |
+
|
367 |
+
foreach($value as $i => $v){
|
368 |
+
|
369 |
+
$value[$i] = get_taxonomy($v);
|
370 |
+
|
371 |
+
}
|
372 |
+
|
373 |
+
// string
|
374 |
+
}else{
|
375 |
+
|
376 |
+
$value = get_taxonomy($value);
|
377 |
+
|
378 |
+
}
|
379 |
+
|
380 |
+
}
|
381 |
+
|
382 |
+
// return
|
383 |
+
return $value;
|
384 |
+
|
385 |
+
}
|
386 |
+
|
387 |
+
}
|
388 |
+
|
389 |
+
// initialize
|
390 |
+
acf_register_field_type('acfe_field_taxonomies');
|
391 |
+
|
392 |
endif;
|
includes/fields/field-taxonomy-terms.php
CHANGED
@@ -7,6 +7,9 @@ if(!class_exists('acfe_field_taxonomy_terms')):
|
|
7 |
|
8 |
class acfe_field_taxonomy_terms extends acf_field{
|
9 |
|
|
|
|
|
|
|
10 |
function __construct(){
|
11 |
|
12 |
$this->name = 'acfe_taxonomy_terms';
|
@@ -16,22 +19,30 @@ class acfe_field_taxonomy_terms extends acf_field{
|
|
16 |
'taxonomy' => array(),
|
17 |
'allow_terms' => array(),
|
18 |
'field_type' => 'checkbox',
|
|
|
|
|
|
|
|
|
19 |
'multiple' => 0,
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
'ui' => 0,
|
24 |
-
'ajax' => 0,
|
25 |
-
'placeholder' => '',
|
26 |
'layout' => '',
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
30 |
);
|
31 |
|
32 |
// ajax
|
33 |
-
add_action('
|
34 |
-
add_action('
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
parent::__construct();
|
37 |
|
@@ -48,10 +59,30 @@ class acfe_field_taxonomy_terms extends acf_field{
|
|
48 |
|
49 |
// return
|
50 |
acf_send_ajax_results($response);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
}
|
53 |
|
54 |
-
function
|
55 |
|
56 |
// defaults
|
57 |
$options = acf_parse_args($options, array(
|
@@ -169,8 +200,8 @@ class acfe_field_taxonomy_terms extends acf_field{
|
|
169 |
return $response;
|
170 |
|
171 |
}
|
172 |
-
|
173 |
-
function
|
174 |
|
175 |
// Allow Terms
|
176 |
$choices = array();
|
@@ -313,12 +344,24 @@ class acfe_field_taxonomy_terms extends acf_field{
|
|
313 |
|
314 |
}
|
315 |
|
316 |
-
|
317 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
318 |
|
319 |
// Set Field Type
|
320 |
$field['type'] = $field['field_type'];
|
321 |
|
|
|
|
|
|
|
|
|
|
|
|
|
322 |
return $field;
|
323 |
|
324 |
}
|
@@ -419,7 +462,7 @@ class acfe_field_taxonomy_terms extends acf_field{
|
|
419 |
'allow_null' => 1,
|
420 |
'ajax' => 1,
|
421 |
'placeholder' => __("All terms",'acf'),
|
422 |
-
'ajax_action' => '
|
423 |
));
|
424 |
|
425 |
// Select: Terms level
|
@@ -470,7 +513,25 @@ class acfe_field_taxonomy_terms extends acf_field{
|
|
470 |
'layout' => 'horizontal',
|
471 |
));
|
472 |
|
473 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
474 |
acf_render_field_setting($field, array(
|
475 |
'label' => __('Allow Null?','acf'),
|
476 |
'instructions' => '',
|
@@ -503,38 +564,33 @@ class acfe_field_taxonomy_terms extends acf_field{
|
|
503 |
'value' => 'select',
|
504 |
),
|
505 |
array(
|
506 |
-
'field' => '
|
507 |
'operator' => '==',
|
508 |
'value' => '1',
|
509 |
),
|
510 |
|
511 |
-
)
|
512 |
-
)
|
513 |
-
));
|
514 |
-
|
515 |
-
// Select: multiple
|
516 |
-
acf_render_field_setting( $field, array(
|
517 |
-
'label' => __('Select multiple values?','acf'),
|
518 |
-
'instructions' => '',
|
519 |
-
'name' => 'multiple',
|
520 |
-
'type' => 'true_false',
|
521 |
-
'ui' => 1,
|
522 |
-
'conditions' => array(
|
523 |
array(
|
524 |
array(
|
525 |
'field' => 'field_type',
|
526 |
'operator' => '==',
|
527 |
'value' => 'select',
|
528 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
529 |
),
|
530 |
)
|
531 |
-
|
532 |
|
533 |
-
// Select:
|
534 |
acf_render_field_setting( $field, array(
|
535 |
-
'label' => __('
|
536 |
'instructions' => '',
|
537 |
-
'name' => '
|
538 |
'type' => 'true_false',
|
539 |
'ui' => 1,
|
540 |
'conditions' => array(
|
@@ -547,8 +603,7 @@ class acfe_field_taxonomy_terms extends acf_field{
|
|
547 |
),
|
548 |
)
|
549 |
));
|
550 |
-
|
551 |
-
|
552 |
// Select: ajax
|
553 |
acf_render_field_setting( $field, array(
|
554 |
'label' => __('Use AJAX to lazy load choices?','acf'),
|
@@ -612,52 +667,159 @@ class acfe_field_taxonomy_terms extends acf_field{
|
|
612 |
)
|
613 |
));
|
614 |
|
615 |
-
//
|
616 |
acf_render_field_setting( $field, array(
|
617 |
-
'label' => __('
|
618 |
-
'instructions' => '',
|
619 |
-
'name' => '
|
620 |
'type' => 'true_false',
|
621 |
'ui' => 1,
|
622 |
-
'message' => __("Allow 'custom' values to be added", 'acf'),
|
623 |
-
'conditions' => array(
|
624 |
-
array(
|
625 |
-
array(
|
626 |
-
'field' => 'field_type',
|
627 |
-
'operator' => '==',
|
628 |
-
'value' => 'checkbox',
|
629 |
-
),
|
630 |
-
),
|
631 |
-
)
|
632 |
));
|
633 |
-
|
634 |
-
|
635 |
-
// Checkbox: save_other_choice
|
636 |
acf_render_field_setting( $field, array(
|
637 |
-
'label' => __('
|
638 |
-
'instructions' => '',
|
639 |
-
'name' => '
|
640 |
'type' => 'true_false',
|
641 |
'ui' => 1,
|
642 |
-
'message' => __("Save 'custom' values to the field's choices", 'acf'),
|
643 |
-
'conditions' => array(
|
644 |
-
array(
|
645 |
-
array(
|
646 |
-
'field' => 'field_type',
|
647 |
-
'operator' => '==',
|
648 |
-
'value' => 'checkbox',
|
649 |
-
),
|
650 |
-
array(
|
651 |
-
'field' => 'allow_custom',
|
652 |
-
'operator' => '==',
|
653 |
-
'value' => 1,
|
654 |
-
),
|
655 |
-
),
|
656 |
-
)
|
657 |
));
|
658 |
|
659 |
}
|
660 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
661 |
function format_value($value, $post_id, $field){
|
662 |
|
663 |
if(empty($value))
|
7 |
|
8 |
class acfe_field_taxonomy_terms extends acf_field{
|
9 |
|
10 |
+
// vars
|
11 |
+
var $save_post_terms = array();
|
12 |
+
|
13 |
function __construct(){
|
14 |
|
15 |
$this->name = 'acfe_taxonomy_terms';
|
19 |
'taxonomy' => array(),
|
20 |
'allow_terms' => array(),
|
21 |
'field_type' => 'checkbox',
|
22 |
+
'choices' => array(),
|
23 |
+
'default_value' => '',
|
24 |
+
'return_format' => 'id',
|
25 |
+
'ui' => 0,
|
26 |
'multiple' => 0,
|
27 |
+
'allow_null' => 0,
|
28 |
+
'ajax' => 0,
|
29 |
+
'placeholder' => '',
|
|
|
|
|
|
|
30 |
'layout' => '',
|
31 |
+
'toggle' => 0,
|
32 |
+
'load_terms' => 0,
|
33 |
+
'save_terms' => 0,
|
34 |
+
'allow_custom' => 0,
|
35 |
);
|
36 |
|
37 |
// ajax
|
38 |
+
add_action('wp_ajax_acfe/fields/taxonomy_terms/allow_query', array($this, 'ajax_query_allowed_terms'));
|
39 |
+
add_action('wp_ajax_nopriv_acfe/fields/taxonomy_terms/allow_query', array($this, 'ajax_query_allowed_terms'));
|
40 |
+
|
41 |
+
add_action('wp_ajax_acf/fields/acfe_taxonomy_terms/query', array($this, 'ajax_query'));
|
42 |
+
add_action('wp_ajax_nopriv_acf/fields/acfe_taxonomy_terms/query', array($this, 'ajax_query'));
|
43 |
+
|
44 |
+
// actions
|
45 |
+
add_action('acf/save_post', array($this, 'save_post'), 15, 1);
|
46 |
|
47 |
parent::__construct();
|
48 |
|
59 |
|
60 |
// return
|
61 |
acf_send_ajax_results($response);
|
62 |
+
|
63 |
+
}
|
64 |
+
|
65 |
+
function get_ajax_query($options = array()){
|
66 |
+
|
67 |
+
//acf_log($options);
|
68 |
+
|
69 |
+
}
|
70 |
+
|
71 |
+
function ajax_query_allowed_terms(){
|
72 |
+
|
73 |
+
// validate
|
74 |
+
if(!acf_verify_ajax())
|
75 |
+
die();
|
76 |
+
|
77 |
+
// get choices
|
78 |
+
$response = $this->get_ajax_query_allowed_terms($_POST);
|
79 |
+
|
80 |
+
// return
|
81 |
+
acf_send_ajax_results($response);
|
82 |
|
83 |
}
|
84 |
|
85 |
+
function get_ajax_query_allowed_terms($options = array()){
|
86 |
|
87 |
// defaults
|
88 |
$options = acf_parse_args($options, array(
|
200 |
return $response;
|
201 |
|
202 |
}
|
203 |
+
|
204 |
+
function get_available_terms($field){
|
205 |
|
206 |
// Allow Terms
|
207 |
$choices = array();
|
344 |
|
345 |
}
|
346 |
|
347 |
+
return $choices;
|
348 |
+
|
349 |
+
}
|
350 |
+
|
351 |
+
function prepare_field($field){
|
352 |
+
|
353 |
+
// Available choices
|
354 |
+
$field['choices'] = $this->get_available_terms($field);
|
355 |
|
356 |
// Set Field Type
|
357 |
$field['type'] = $field['field_type'];
|
358 |
|
359 |
+
if($field['type'] === 'select' && $field['ui'] && $field['ajax']){
|
360 |
+
|
361 |
+
$field['ajax_action'] = 'acf/fields/acfe_taxonomy_terms/query';
|
362 |
+
|
363 |
+
}
|
364 |
+
|
365 |
return $field;
|
366 |
|
367 |
}
|
462 |
'allow_null' => 1,
|
463 |
'ajax' => 1,
|
464 |
'placeholder' => __("All terms",'acf'),
|
465 |
+
'ajax_action' => 'acfe/fields/taxonomy_terms/allow_query',
|
466 |
));
|
467 |
|
468 |
// Select: Terms level
|
513 |
'layout' => 'horizontal',
|
514 |
));
|
515 |
|
516 |
+
// Select: ui
|
517 |
+
acf_render_field_setting( $field, array(
|
518 |
+
'label' => __('Stylised UI','acf'),
|
519 |
+
'instructions' => '',
|
520 |
+
'name' => 'ui',
|
521 |
+
'type' => 'true_false',
|
522 |
+
'ui' => 1,
|
523 |
+
'conditions' => array(
|
524 |
+
array(
|
525 |
+
array(
|
526 |
+
'field' => 'field_type',
|
527 |
+
'operator' => '==',
|
528 |
+
'value' => 'select',
|
529 |
+
),
|
530 |
+
),
|
531 |
+
)
|
532 |
+
));
|
533 |
+
|
534 |
+
// Select: allow_null
|
535 |
acf_render_field_setting($field, array(
|
536 |
'label' => __('Allow Null?','acf'),
|
537 |
'instructions' => '',
|
564 |
'value' => 'select',
|
565 |
),
|
566 |
array(
|
567 |
+
'field' => 'ui',
|
568 |
'operator' => '==',
|
569 |
'value' => '1',
|
570 |
),
|
571 |
|
572 |
+
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
573 |
array(
|
574 |
array(
|
575 |
'field' => 'field_type',
|
576 |
'operator' => '==',
|
577 |
'value' => 'select',
|
578 |
),
|
579 |
+
array(
|
580 |
+
'field' => 'allow_null',
|
581 |
+
'operator' => '==',
|
582 |
+
'value' => '1',
|
583 |
+
),
|
584 |
+
|
585 |
),
|
586 |
)
|
587 |
+
));
|
588 |
|
589 |
+
// Select: multiple
|
590 |
acf_render_field_setting( $field, array(
|
591 |
+
'label' => __('Select multiple values?','acf'),
|
592 |
'instructions' => '',
|
593 |
+
'name' => 'multiple',
|
594 |
'type' => 'true_false',
|
595 |
'ui' => 1,
|
596 |
'conditions' => array(
|
603 |
),
|
604 |
)
|
605 |
));
|
606 |
+
|
|
|
607 |
// Select: ajax
|
608 |
acf_render_field_setting( $field, array(
|
609 |
'label' => __('Use AJAX to lazy load choices?','acf'),
|
667 |
)
|
668 |
));
|
669 |
|
670 |
+
// save_terms
|
671 |
acf_render_field_setting( $field, array(
|
672 |
+
'label' => __('Save Terms','acf'),
|
673 |
+
'instructions' => __('Connect selected terms to the post','acf'),
|
674 |
+
'name' => 'save_terms',
|
675 |
'type' => 'true_false',
|
676 |
'ui' => 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
677 |
));
|
678 |
+
|
679 |
+
// load_terms
|
|
|
680 |
acf_render_field_setting( $field, array(
|
681 |
+
'label' => __('Load Terms','acf'),
|
682 |
+
'instructions' => __('Load value from posts terms','acf'),
|
683 |
+
'name' => 'load_terms',
|
684 |
'type' => 'true_false',
|
685 |
'ui' => 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
686 |
));
|
687 |
|
688 |
}
|
689 |
|
690 |
+
function load_value($value, $post_id, $field){
|
691 |
+
|
692 |
+
// get valid terms
|
693 |
+
//$value = acf_get_valid_terms($value, $field['taxonomy']);
|
694 |
+
|
695 |
+
// load_terms
|
696 |
+
if($field['load_terms']){
|
697 |
+
|
698 |
+
$taxonomy = $field['taxonomy'];
|
699 |
+
|
700 |
+
if(empty($taxonomy))
|
701 |
+
$taxonomy = acf_get_taxonomies();
|
702 |
+
|
703 |
+
// get terms
|
704 |
+
$info = acf_get_post_id_info($post_id);
|
705 |
+
$term_ids = wp_get_object_terms($info['id'], $taxonomy, array('fields' => 'ids', 'orderby' => 'none'));
|
706 |
+
|
707 |
+
// bail early if no terms
|
708 |
+
if(empty($term_ids) || is_wp_error($term_ids))
|
709 |
+
return false;
|
710 |
+
|
711 |
+
// sort
|
712 |
+
if(!empty($value)){
|
713 |
+
|
714 |
+
$order = array();
|
715 |
+
|
716 |
+
foreach($term_ids as $i => $v){
|
717 |
+
|
718 |
+
$order[$i] = array_search($v, $value);
|
719 |
+
|
720 |
+
}
|
721 |
+
|
722 |
+
array_multisort($order, $term_ids);
|
723 |
+
|
724 |
+
}
|
725 |
+
|
726 |
+
// update value
|
727 |
+
$value = $term_ids;
|
728 |
+
|
729 |
+
}
|
730 |
+
|
731 |
+
// return
|
732 |
+
return $value;
|
733 |
+
|
734 |
+
}
|
735 |
+
|
736 |
+
function update_value($value, $post_id, $field){
|
737 |
+
|
738 |
+
// vars
|
739 |
+
if(is_array($value)){
|
740 |
+
|
741 |
+
$value = array_filter($value);
|
742 |
+
|
743 |
+
}
|
744 |
+
|
745 |
+
|
746 |
+
// save_terms
|
747 |
+
if($field['save_terms']){
|
748 |
+
|
749 |
+
// vars
|
750 |
+
$taxonomies = $field['taxonomy'];
|
751 |
+
|
752 |
+
if(empty($taxonomies))
|
753 |
+
$taxonomies = acf_get_taxonomies();
|
754 |
+
|
755 |
+
// force value to array
|
756 |
+
$term_ids = acf_get_array($value);
|
757 |
+
|
758 |
+
// convert to int
|
759 |
+
$term_ids = array_map('intval', $term_ids);
|
760 |
+
|
761 |
+
foreach($taxonomies as $taxonomy){
|
762 |
+
|
763 |
+
$terms = array();
|
764 |
+
|
765 |
+
foreach($term_ids as $term_id){
|
766 |
+
|
767 |
+
$term = get_term($term_id);
|
768 |
+
$term_taxonomy = $term->taxonomy;
|
769 |
+
|
770 |
+
if($term_taxonomy !== $taxonomy)
|
771 |
+
continue;
|
772 |
+
|
773 |
+
$terms[] = $term_id;
|
774 |
+
|
775 |
+
}
|
776 |
+
|
777 |
+
// get existing term id's (from a previously saved field)
|
778 |
+
$old_term_ids = isset($this->save_post_terms[$taxonomy]) ? $this->save_post_terms[$taxonomy] : array();
|
779 |
+
|
780 |
+
// append
|
781 |
+
$this->save_post_terms[$taxonomy] = array_merge($old_term_ids, $terms);
|
782 |
+
|
783 |
+
}
|
784 |
+
|
785 |
+
// if called directly from frontend update_field()
|
786 |
+
if(!did_action('acf/save_post')){
|
787 |
+
|
788 |
+
$this->save_post($post_id);
|
789 |
+
|
790 |
+
return $value;
|
791 |
+
|
792 |
+
}
|
793 |
+
|
794 |
+
}
|
795 |
+
|
796 |
+
// return
|
797 |
+
return $value;
|
798 |
+
|
799 |
+
}
|
800 |
+
|
801 |
+
function save_post($post_id){
|
802 |
+
|
803 |
+
// bail ealry if no terms
|
804 |
+
if(empty($this->save_post_terms))
|
805 |
+
return;
|
806 |
+
|
807 |
+
// vars
|
808 |
+
$info = acf_get_post_id_info($post_id);
|
809 |
+
|
810 |
+
// loop
|
811 |
+
foreach($this->save_post_terms as $taxonomy => $term_ids){
|
812 |
+
|
813 |
+
// save
|
814 |
+
wp_set_object_terms($info['id'], $term_ids, $taxonomy, false);
|
815 |
+
|
816 |
+
}
|
817 |
+
|
818 |
+
// reset array ( WP saves twice )
|
819 |
+
$this->save_post_terms = array();
|
820 |
+
|
821 |
+
}
|
822 |
+
|
823 |
function format_value($value, $post_id, $field){
|
824 |
|
825 |
if(empty($value))
|
includes/fields/field-user-roles.php
CHANGED
@@ -1,336 +1,349 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
if(!class_exists('acfe_field_user_roles')):
|
7 |
-
|
8 |
-
class acfe_field_user_roles extends acf_field{
|
9 |
-
|
10 |
-
function __construct(){
|
11 |
-
|
12 |
-
$this->name = 'acfe_user_roles';
|
13 |
-
$this->label = __('User Roles', 'acfe');
|
14 |
-
$this->category = 'relational';
|
15 |
-
$this->defaults = array(
|
16 |
-
'user_role' => array(),
|
17 |
-
'field_type' => 'checkbox',
|
18 |
-
'multiple' => 0,
|
19 |
-
'allow_null' => 0,
|
20 |
-
'choices' => array(),
|
21 |
-
'default_value' => '',
|
22 |
-
'ui' => 0,
|
23 |
-
'ajax' => 0,
|
24 |
-
'placeholder' => '',
|
25 |
-
'layout' => '',
|
26 |
-
'toggle' => 0,
|
27 |
-
'allow_custom' => 0,
|
28 |
-
);
|
29 |
-
|
30 |
-
parent::__construct();
|
31 |
-
|
32 |
-
}
|
33 |
-
|
34 |
-
function prepare_field($field){
|
35 |
-
|
36 |
-
$field['choices'] = acfe_get_roles($field['user_role']);
|
37 |
-
|
38 |
-
// Set Field Type
|
39 |
-
$field['type'] = $field['field_type'];
|
40 |
-
|
41 |
-
return $field;
|
42 |
-
|
43 |
-
}
|
44 |
-
|
45 |
-
function render_field_settings($field){
|
46 |
-
|
47 |
-
if(isset($field['default_value']))
|
48 |
-
$field['default_value'] = acf_encode_choices($field['default_value'], false);
|
49 |
-
|
50 |
-
// Allow User Role
|
51 |
-
acf_render_field_setting( $field, array(
|
52 |
-
'label' => __('Allow User Role','acf'),
|
53 |
-
'instructions' => '',
|
54 |
-
'type' => 'select',
|
55 |
-
'name' => 'user_role',
|
56 |
-
'choices' => acfe_get_roles(),
|
57 |
-
'multiple' => 1,
|
58 |
-
'ui' => 1,
|
59 |
-
'allow_null' => 1,
|
60 |
-
'placeholder' => __("All user roles",'acf'),
|
61 |
-
));
|
62 |
-
|
63 |
-
// field_type
|
64 |
-
acf_render_field_setting($field, array(
|
65 |
-
'label' => __('Appearance','acf'),
|
66 |
-
'instructions' => __('Select the appearance of this field', 'acf'),
|
67 |
-
'type' => 'select',
|
68 |
-
'name' => 'field_type',
|
69 |
-
'optgroup' => true,
|
70 |
-
'choices' => array(
|
71 |
-
'checkbox' => __('Checkbox', 'acf'),
|
72 |
-
'radio' => __('Radio Buttons', 'acf'),
|
73 |
-
'select' => _x('Select', 'noun', 'acf')
|
74 |
-
)
|
75 |
-
));
|
76 |
-
|
77 |
-
// default_value
|
78 |
-
acf_render_field_setting( $field, array(
|
79 |
-
'label' => __('Default Value','acf'),
|
80 |
-
'instructions' => __('Enter each default value on a new line','acf'),
|
81 |
-
'name' => 'default_value',
|
82 |
-
'type' => 'textarea',
|
83 |
-
));
|
84 |
-
|
85 |
-
// Select + Radio: allow_null
|
86 |
-
acf_render_field_setting( $field, array(
|
87 |
-
'label' => __('Allow Null?','acf'),
|
88 |
-
'instructions' => '',
|
89 |
-
'name' => 'allow_null',
|
90 |
-
'type' => 'true_false',
|
91 |
-
'ui' => 1,
|
92 |
-
'conditions' => array(
|
93 |
-
array(
|
94 |
-
array(
|
95 |
-
'field' => 'field_type',
|
96 |
-
'operator' => '==',
|
97 |
-
'value' => 'select',
|
98 |
-
),
|
99 |
-
),
|
100 |
-
array(
|
101 |
-
array(
|
102 |
-
'field' => 'field_type',
|
103 |
-
'operator' => '==',
|
104 |
-
'value' => 'radio',
|
105 |
-
),
|
106 |
-
),
|
107 |
-
)
|
108 |
-
));
|
109 |
-
|
110 |
-
// placeholder
|
111 |
-
acf_render_field_setting($field, array(
|
112 |
-
'label' => __('Placeholder Text','acf'),
|
113 |
-
'instructions' => __('Appears within the input','acf'),
|
114 |
-
'type' => 'text',
|
115 |
-
'name' => 'placeholder',
|
116 |
-
'placeholder' => _x('Select', 'verb', 'acf'),
|
117 |
-
'conditional_logic' => array(
|
118 |
-
array(
|
119 |
-
array(
|
120 |
-
'field' => 'field_type',
|
121 |
-
'operator' => '==',
|
122 |
-
'value' => 'select',
|
123 |
-
),
|
124 |
-
array(
|
125 |
-
'field' => 'allow_null',
|
126 |
-
'operator' => '==',
|
127 |
-
'value' => '1',
|
128 |
-
),
|
129 |
-
|
130 |
-
)
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
336 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
if(!class_exists('acfe_field_user_roles')):
|
7 |
+
|
8 |
+
class acfe_field_user_roles extends acf_field{
|
9 |
+
|
10 |
+
function __construct(){
|
11 |
+
|
12 |
+
$this->name = 'acfe_user_roles';
|
13 |
+
$this->label = __('User Roles', 'acfe');
|
14 |
+
$this->category = 'relational';
|
15 |
+
$this->defaults = array(
|
16 |
+
'user_role' => array(),
|
17 |
+
'field_type' => 'checkbox',
|
18 |
+
'multiple' => 0,
|
19 |
+
'allow_null' => 0,
|
20 |
+
'choices' => array(),
|
21 |
+
'default_value' => '',
|
22 |
+
'ui' => 0,
|
23 |
+
'ajax' => 0,
|
24 |
+
'placeholder' => '',
|
25 |
+
'layout' => '',
|
26 |
+
'toggle' => 0,
|
27 |
+
'allow_custom' => 0,
|
28 |
+
);
|
29 |
+
|
30 |
+
parent::__construct();
|
31 |
+
|
32 |
+
}
|
33 |
+
|
34 |
+
function prepare_field($field){
|
35 |
+
|
36 |
+
$field['choices'] = acfe_get_roles($field['user_role']);
|
37 |
+
|
38 |
+
// Set Field Type
|
39 |
+
$field['type'] = $field['field_type'];
|
40 |
+
|
41 |
+
return $field;
|
42 |
+
|
43 |
+
}
|
44 |
+
|
45 |
+
function render_field_settings($field){
|
46 |
+
|
47 |
+
if(isset($field['default_value']))
|
48 |
+
$field['default_value'] = acf_encode_choices($field['default_value'], false);
|
49 |
+
|
50 |
+
// Allow User Role
|
51 |
+
acf_render_field_setting( $field, array(
|
52 |
+
'label' => __('Allow User Role','acf'),
|
53 |
+
'instructions' => '',
|
54 |
+
'type' => 'select',
|
55 |
+
'name' => 'user_role',
|
56 |
+
'choices' => acfe_get_roles(),
|
57 |
+
'multiple' => 1,
|
58 |
+
'ui' => 1,
|
59 |
+
'allow_null' => 1,
|
60 |
+
'placeholder' => __("All user roles",'acf'),
|
61 |
+
));
|
62 |
+
|
63 |
+
// field_type
|
64 |
+
acf_render_field_setting($field, array(
|
65 |
+
'label' => __('Appearance','acf'),
|
66 |
+
'instructions' => __('Select the appearance of this field', 'acf'),
|
67 |
+
'type' => 'select',
|
68 |
+
'name' => 'field_type',
|
69 |
+
'optgroup' => true,
|
70 |
+
'choices' => array(
|
71 |
+
'checkbox' => __('Checkbox', 'acf'),
|
72 |
+
'radio' => __('Radio Buttons', 'acf'),
|
73 |
+
'select' => _x('Select', 'noun', 'acf')
|
74 |
+
)
|
75 |
+
));
|
76 |
+
|
77 |
+
// default_value
|
78 |
+
acf_render_field_setting( $field, array(
|
79 |
+
'label' => __('Default Value','acf'),
|
80 |
+
'instructions' => __('Enter each default value on a new line','acf'),
|
81 |
+
'name' => 'default_value',
|
82 |
+
'type' => 'textarea',
|
83 |
+
));
|
84 |
+
|
85 |
+
// Select + Radio: allow_null
|
86 |
+
acf_render_field_setting( $field, array(
|
87 |
+
'label' => __('Allow Null?','acf'),
|
88 |
+
'instructions' => '',
|
89 |
+
'name' => 'allow_null',
|
90 |
+
'type' => 'true_false',
|
91 |
+
'ui' => 1,
|
92 |
+
'conditions' => array(
|
93 |
+
array(
|
94 |
+
array(
|
95 |
+
'field' => 'field_type',
|
96 |
+
'operator' => '==',
|
97 |
+
'value' => 'select',
|
98 |
+
),
|
99 |
+
),
|
100 |
+
array(
|
101 |
+
array(
|
102 |
+
'field' => 'field_type',
|
103 |
+
'operator' => '==',
|
104 |
+
'value' => 'radio',
|
105 |
+
),
|
106 |
+
),
|
107 |
+
)
|
108 |
+
));
|
109 |
+
|
110 |
+
// placeholder
|
111 |
+
acf_render_field_setting($field, array(
|
112 |
+
'label' => __('Placeholder Text','acf'),
|
113 |
+
'instructions' => __('Appears within the input','acf'),
|
114 |
+
'type' => 'text',
|
115 |
+
'name' => 'placeholder',
|
116 |
+
'placeholder' => _x('Select', 'verb', 'acf'),
|
117 |
+
'conditional_logic' => array(
|
118 |
+
array(
|
119 |
+
array(
|
120 |
+
'field' => 'field_type',
|
121 |
+
'operator' => '==',
|
122 |
+
'value' => 'select',
|
123 |
+
),
|
124 |
+
array(
|
125 |
+
'field' => 'allow_null',
|
126 |
+
'operator' => '==',
|
127 |
+
'value' => '1',
|
128 |
+
),
|
129 |
+
|
130 |
+
),
|
131 |
+
array(
|
132 |
+
array(
|
133 |
+
'field' => 'field_type',
|
134 |
+
'operator' => '==',
|
135 |
+
'value' => 'select',
|
136 |
+
),
|
137 |
+
array(
|
138 |
+
'field' => 'ui',
|
139 |
+
'operator' => '==',
|
140 |
+
'value' => '1',
|
141 |
+
),
|
142 |
+
|
143 |
+
),
|
144 |
+
)
|
145 |
+
));
|
146 |
+
|
147 |
+
// Select: multiple
|
148 |
+
acf_render_field_setting( $field, array(
|
149 |
+
'label' => __('Select multiple values?','acf'),
|
150 |
+
'instructions' => '',
|
151 |
+
'name' => 'multiple',
|
152 |
+
'type' => 'true_false',
|
153 |
+
'ui' => 1,
|
154 |
+
'conditions' => array(
|
155 |
+
array(
|
156 |
+
array(
|
157 |
+
'field' => 'field_type',
|
158 |
+
'operator' => '==',
|
159 |
+
'value' => 'select',
|
160 |
+
),
|
161 |
+
),
|
162 |
+
)
|
163 |
+
));
|
164 |
+
|
165 |
+
// Select: ui
|
166 |
+
acf_render_field_setting( $field, array(
|
167 |
+
'label' => __('Stylised UI','acf'),
|
168 |
+
'instructions' => '',
|
169 |
+
'name' => 'ui',
|
170 |
+
'type' => 'true_false',
|
171 |
+
'ui' => 1,
|
172 |
+
'conditions' => array(
|
173 |
+
array(
|
174 |
+
array(
|
175 |
+
'field' => 'field_type',
|
176 |
+
'operator' => '==',
|
177 |
+
'value' => 'select',
|
178 |
+
),
|
179 |
+
),
|
180 |
+
)
|
181 |
+
));
|
182 |
+
|
183 |
+
|
184 |
+
// Select: ajax
|
185 |
+
acf_render_field_setting( $field, array(
|
186 |
+
'label' => __('Use AJAX to lazy load choices?','acf'),
|
187 |
+
'instructions' => '',
|
188 |
+
'name' => 'ajax',
|
189 |
+
'type' => 'true_false',
|
190 |
+
'ui' => 1,
|
191 |
+
'conditions' => array(
|
192 |
+
array(
|
193 |
+
array(
|
194 |
+
'field' => 'field_type',
|
195 |
+
'operator' => '==',
|
196 |
+
'value' => 'select',
|
197 |
+
),
|
198 |
+
array(
|
199 |
+
'field' => 'ui',
|
200 |
+
'operator' => '==',
|
201 |
+
'value' => 1,
|
202 |
+
),
|
203 |
+
),
|
204 |
+
)
|
205 |
+
));
|
206 |
+
|
207 |
+
// Radio: other_choice
|
208 |
+
acf_render_field_setting( $field, array(
|
209 |
+
'label' => __('Other','acf'),
|
210 |
+
'instructions' => '',
|
211 |
+
'name' => 'other_choice',
|
212 |
+
'type' => 'true_false',
|
213 |
+
'ui' => 1,
|
214 |
+
'message' => __("Add 'other' choice to allow for custom values", 'acf'),
|
215 |
+
'conditions' => array(
|
216 |
+
array(
|
217 |
+
array(
|
218 |
+
'field' => 'field_type',
|
219 |
+
'operator' => '==',
|
220 |
+
'value' => 'radio',
|
221 |
+
),
|
222 |
+
),
|
223 |
+
)
|
224 |
+
));
|
225 |
+
|
226 |
+
|
227 |
+
// Radio: save_other_choice
|
228 |
+
acf_render_field_setting( $field, array(
|
229 |
+
'label' => __('Save Other','acf'),
|
230 |
+
'instructions' => '',
|
231 |
+
'name' => 'save_other_choice',
|
232 |
+
'type' => 'true_false',
|
233 |
+
'ui' => 1,
|
234 |
+
'message' => __("Save 'other' values to the field's choices", 'acf'),
|
235 |
+
'conditions' => array(
|
236 |
+
array(
|
237 |
+
array(
|
238 |
+
'field' => 'field_type',
|
239 |
+
'operator' => '==',
|
240 |
+
'value' => 'radio',
|
241 |
+
),
|
242 |
+
array(
|
243 |
+
'field' => 'other_choice',
|
244 |
+
'operator' => '==',
|
245 |
+
'value' => 1,
|
246 |
+
),
|
247 |
+
),
|
248 |
+
)
|
249 |
+
));
|
250 |
+
|
251 |
+
// Checkbox: layout
|
252 |
+
acf_render_field_setting( $field, array(
|
253 |
+
'label' => __('Layout','acf'),
|
254 |
+
'instructions' => '',
|
255 |
+
'type' => 'radio',
|
256 |
+
'name' => 'layout',
|
257 |
+
'layout' => 'horizontal',
|
258 |
+
'choices' => array(
|
259 |
+
'vertical' => __("Vertical",'acf'),
|
260 |
+
'horizontal' => __("Horizontal",'acf')
|
261 |
+
),
|
262 |
+
'conditions' => array(
|
263 |
+
array(
|
264 |
+
array(
|
265 |
+
'field' => 'field_type',
|
266 |
+
'operator' => '==',
|
267 |
+
'value' => 'checkbox',
|
268 |
+
),
|
269 |
+
),
|
270 |
+
array(
|
271 |
+
array(
|
272 |
+
'field' => 'field_type',
|
273 |
+
'operator' => '==',
|
274 |
+
'value' => 'radio',
|
275 |
+
),
|
276 |
+
),
|
277 |
+
)
|
278 |
+
));
|
279 |
+
|
280 |
+
// Checkbox: toggle
|
281 |
+
acf_render_field_setting( $field, array(
|
282 |
+
'label' => __('Toggle','acf'),
|
283 |
+
'instructions' => __('Prepend an extra checkbox to toggle all choices','acf'),
|
284 |
+
'name' => 'toggle',
|
285 |
+
'type' => 'true_false',
|
286 |
+
'ui' => 1,
|
287 |
+
'conditions' => array(
|
288 |
+
array(
|
289 |
+
array(
|
290 |
+
'field' => 'field_type',
|
291 |
+
'operator' => '==',
|
292 |
+
'value' => 'checkbox',
|
293 |
+
),
|
294 |
+
),
|
295 |
+
)
|
296 |
+
));
|
297 |
+
|
298 |
+
// Checkbox: other_choice
|
299 |
+
acf_render_field_setting( $field, array(
|
300 |
+
'label' => __('Allow Custom','acf'),
|
301 |
+
'instructions' => '',
|
302 |
+
'name' => 'allow_custom',
|
303 |
+
'type' => 'true_false',
|
304 |
+
'ui' => 1,
|
305 |
+
'message' => __("Allow 'custom' values to be added", 'acf'),
|
306 |
+
'conditions' => array(
|
307 |
+
array(
|
308 |
+
array(
|
309 |
+
'field' => 'field_type',
|
310 |
+
'operator' => '==',
|
311 |
+
'value' => 'checkbox',
|
312 |
+
),
|
313 |
+
),
|
314 |
+
)
|
315 |
+
));
|
316 |
+
|
317 |
+
|
318 |
+
// Checkbox: save_other_choice
|
319 |
+
acf_render_field_setting( $field, array(
|
320 |
+
'label' => __('Save Custom','acf'),
|
321 |
+
'instructions' => '',
|
322 |
+
'name' => 'save_custom',
|
323 |
+
'type' => 'true_false',
|
324 |
+
'ui' => 1,
|
325 |
+
'message' => __("Save 'custom' values to the field's choices", 'acf'),
|
326 |
+
'conditions' => array(
|
327 |
+
array(
|
328 |
+
array(
|
329 |
+
'field' => 'field_type',
|
330 |
+
'operator' => '==',
|
331 |
+
'value' => 'checkbox',
|
332 |
+
),
|
333 |
+
array(
|
334 |
+
'field' => 'allow_custom',
|
335 |
+
'operator' => '==',
|
336 |
+
'value' => 1,
|
337 |
+
),
|
338 |
+
),
|
339 |
+
)
|
340 |
+
));
|
341 |
+
|
342 |
+
}
|
343 |
+
|
344 |
+
}
|
345 |
+
|
346 |
+
// initialize
|
347 |
+
acf_register_field_type('acfe_field_user_roles');
|
348 |
+
|
349 |
endif;
|
includes/modules/author.php
CHANGED
@@ -1,230 +1,216 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
// Check setting
|
7 |
-
if(!acf_get_setting('acfe/modules/author'))
|
8 |
-
return;
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
'acf
|
22 |
-
'
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
function
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
)
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
'
|
205 |
-
'
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
'allow_null' => 0,
|
218 |
-
'multiple' => 0,
|
219 |
-
'return_format' => 'array',
|
220 |
-
'role' => $authors_roles,
|
221 |
-
'wrapper' => array(
|
222 |
-
'width' => '',
|
223 |
-
'class' => '',
|
224 |
-
'id' => '',
|
225 |
-
)
|
226 |
-
),
|
227 |
-
)
|
228 |
-
));
|
229 |
-
|
230 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
// Check setting
|
7 |
+
if(!acf_get_setting('acfe/modules/author'))
|
8 |
+
return;
|
9 |
+
|
10 |
+
if(!class_exists('acfe_author')):
|
11 |
+
|
12 |
+
class acfe_author{
|
13 |
+
|
14 |
+
public $post_types = array();
|
15 |
+
|
16 |
+
function __construct(){
|
17 |
+
|
18 |
+
add_action('init', array($this, 'init'), 999);
|
19 |
+
add_action('admin_menu', array($this, 'admin_menu'));
|
20 |
+
|
21 |
+
add_action('acf/save_post', array($this, 'save_post'), 0);
|
22 |
+
add_filter('acf/load_value/name=acfe_author', array($this, 'load_value'), 10, 3);
|
23 |
+
add_filter('acf/pre_update_value', array($this, 'update_value'), 10, 4);
|
24 |
+
|
25 |
+
add_filter('acf/get_field_group_style', array($this, 'hide_on_screen'), 10, 2);
|
26 |
+
|
27 |
+
}
|
28 |
+
|
29 |
+
function init(){
|
30 |
+
|
31 |
+
// Get Post Types Locations
|
32 |
+
$get_post_types = get_post_types_by_support('author');
|
33 |
+
if(empty($get_post_types))
|
34 |
+
return;
|
35 |
+
|
36 |
+
foreach($get_post_types as $post_type){
|
37 |
+
|
38 |
+
if(in_array($post_type, array('attachment', 'revision', 'customize_changeset')))
|
39 |
+
continue;
|
40 |
+
|
41 |
+
$post_type_object = get_post_type_object($post_type);
|
42 |
+
|
43 |
+
if(!current_user_can($post_type_object->cap->edit_others_posts))
|
44 |
+
continue;
|
45 |
+
|
46 |
+
$this->post_types[] = $post_type;
|
47 |
+
|
48 |
+
}
|
49 |
+
|
50 |
+
if(!empty($this->post_types)){
|
51 |
+
|
52 |
+
// Locations init
|
53 |
+
$locations = array();
|
54 |
+
|
55 |
+
foreach($this->post_types as $post_type){
|
56 |
+
|
57 |
+
// Set Location
|
58 |
+
$locations[] = array(
|
59 |
+
array(
|
60 |
+
'param' => 'post_type',
|
61 |
+
'operator' => '==',
|
62 |
+
'value' => $post_type,
|
63 |
+
)
|
64 |
+
);
|
65 |
+
|
66 |
+
}
|
67 |
+
|
68 |
+
// Roles
|
69 |
+
global $wp_roles;
|
70 |
+
|
71 |
+
$authors_roles = array();
|
72 |
+
foreach($wp_roles->roles as $role_name => $role){
|
73 |
+
|
74 |
+
if(!isset($role['capabilities']['level_1']) || empty($role['capabilities']['level_1']))
|
75 |
+
continue;
|
76 |
+
|
77 |
+
$authors_roles[] = $role_name;
|
78 |
+
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Add Local Field Group
|
83 |
+
*/
|
84 |
+
acf_add_local_field_group(array(
|
85 |
+
'title' => __('Author'),
|
86 |
+
'key' => 'group_acfe_author',
|
87 |
+
'menu_order' => 99999,
|
88 |
+
'position' => 'side',
|
89 |
+
'style' => 'default',
|
90 |
+
'label_placement' => 'top',
|
91 |
+
'instruction_placement' => 'label',
|
92 |
+
'hide_on_screen' => '',
|
93 |
+
'active' => 1,
|
94 |
+
'description' => '',
|
95 |
+
'location' => $locations,
|
96 |
+
'fields' => array(
|
97 |
+
array(
|
98 |
+
'label' => '',
|
99 |
+
'key' => 'acfe_author',
|
100 |
+
'name' => 'acfe_author',
|
101 |
+
'type' => 'user',
|
102 |
+
'instructions' => '',
|
103 |
+
'required' => 0,
|
104 |
+
'conditional_logic' => 0,
|
105 |
+
'allow_null' => 0,
|
106 |
+
'multiple' => 0,
|
107 |
+
'return_format' => 'array',
|
108 |
+
'role' => $authors_roles,
|
109 |
+
'wrapper' => array(
|
110 |
+
'width' => '',
|
111 |
+
'class' => '',
|
112 |
+
'id' => '',
|
113 |
+
)
|
114 |
+
),
|
115 |
+
)
|
116 |
+
));
|
117 |
+
|
118 |
+
}
|
119 |
+
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Remove Legacy Authordiv
|
124 |
+
*/
|
125 |
+
function admin_menu(){
|
126 |
+
|
127 |
+
foreach($this->post_types as $post_type){
|
128 |
+
|
129 |
+
// Remove Metabox
|
130 |
+
remove_meta_box('authordiv', $post_type, 'normal');
|
131 |
+
|
132 |
+
}
|
133 |
+
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Save Post Action
|
138 |
+
*/
|
139 |
+
function save_post($post_id){
|
140 |
+
|
141 |
+
// Check Field Exists
|
142 |
+
if(!isset($_POST['acf']['acfe_author']))
|
143 |
+
return;
|
144 |
+
|
145 |
+
$post_author = (int) $_POST['acf']['acfe_author'];
|
146 |
+
$_post_author = get_post_field('post_author', $post_id);
|
147 |
+
|
148 |
+
// Check if author has been changed
|
149 |
+
if($_post_author === $post_author)
|
150 |
+
return;
|
151 |
+
|
152 |
+
$post_type = get_post_type($post_id);
|
153 |
+
if(!in_array($post_type, $this->post_types))
|
154 |
+
return false;
|
155 |
+
|
156 |
+
// Validate Author
|
157 |
+
if(!get_user_by('ID', $post_author))
|
158 |
+
return;
|
159 |
+
|
160 |
+
remove_action('post_updated', 'wp_save_post_revision');
|
161 |
+
|
162 |
+
// Update Post Author
|
163 |
+
wp_update_post(array(
|
164 |
+
'ID' => $post_id,
|
165 |
+
'post_author' => $post_author
|
166 |
+
));
|
167 |
+
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
* Load Default Value
|
172 |
+
*/
|
173 |
+
function load_value($value, $post_id, $field){
|
174 |
+
|
175 |
+
$post_type = get_post_type($post_id);
|
176 |
+
if(!in_array($post_type, $this->post_types))
|
177 |
+
return false;
|
178 |
+
|
179 |
+
// Set Default
|
180 |
+
$author_id = get_post_field('post_author', $post_id);
|
181 |
+
$value = $author_id;
|
182 |
+
|
183 |
+
return $value;
|
184 |
+
|
185 |
+
}
|
186 |
+
|
187 |
+
/**
|
188 |
+
* Bypass Metadata Update
|
189 |
+
*/
|
190 |
+
function update_value($return, $value, $post_id, $field){
|
191 |
+
|
192 |
+
if($field['name'] === 'acfe_author')
|
193 |
+
return false;
|
194 |
+
|
195 |
+
return $return;
|
196 |
+
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Field Group Hide on Screen
|
201 |
+
*/
|
202 |
+
function hide_on_screen($style, $field_group){
|
203 |
+
|
204 |
+
$style = str_replace('authordiv', 'acf-group_acfe_author', $style);
|
205 |
+
$style = str_replace('display: none;', 'display: none !important;', $style);
|
206 |
+
|
207 |
+
return $style;
|
208 |
+
|
209 |
+
}
|
210 |
+
|
211 |
+
}
|
212 |
+
|
213 |
+
// initialize
|
214 |
+
acfe()->acfe_author = new acfe_author();
|
215 |
+
|
216 |
+
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/modules/autosync.php
CHANGED
@@ -1,298 +1,321 @@
|
|
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 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
$
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
$
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
}
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
298 |
}
|
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 |
+
|
14 |
+
foreach($acfe_php_load as $path){
|
15 |
+
|
16 |
+
if(!is_readable($path))
|
17 |
+
continue;
|
18 |
+
|
19 |
+
acf_update_setting('acfe/php_found', true);
|
20 |
+
|
21 |
+
$files = glob($path . '/*.php');
|
22 |
+
if(empty($files))
|
23 |
+
continue;
|
24 |
+
|
25 |
+
foreach($files as $file){
|
26 |
+
|
27 |
+
require_once($file);
|
28 |
+
|
29 |
+
}
|
30 |
+
|
31 |
+
}
|
32 |
+
|
33 |
+
}
|
34 |
+
|
35 |
+
$acfe_json = acf_get_setting('json');
|
36 |
+
$acfe_json_load = acf_get_setting('load_json');
|
37 |
+
|
38 |
+
if(!empty($acfe_json) && !empty($acfe_json_load)){
|
39 |
+
|
40 |
+
foreach($acfe_json_load as $path){
|
41 |
+
|
42 |
+
if(!is_dir($path))
|
43 |
+
continue;
|
44 |
+
|
45 |
+
acf_update_setting('acfe/json_found', true);
|
46 |
+
|
47 |
+
break;
|
48 |
+
|
49 |
+
}
|
50 |
+
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Auto Sync: Disable json
|
55 |
+
*/
|
56 |
+
add_action('acf/update_field_group', 'acfe_autosync_json_update_field_group', 9);
|
57 |
+
function acfe_autosync_json_update_field_group($field_group){
|
58 |
+
|
59 |
+
// Validate
|
60 |
+
if(!acf_get_setting('json'))
|
61 |
+
return;
|
62 |
+
|
63 |
+
// Disable json sync for this field group
|
64 |
+
if(!acfe_has_field_group_autosync($field_group, 'json'))
|
65 |
+
add_filter('acf/settings/json', 'acfe_autosync_temp_disable_json');
|
66 |
+
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Auto Sync: Re-enable json
|
71 |
+
*/
|
72 |
+
add_action('acf/update_field_group', 'acfe_autosync_json_after_update_field_group', 11);
|
73 |
+
function acfe_autosync_json_after_update_field_group($field_group){
|
74 |
+
|
75 |
+
// Validate
|
76 |
+
if(!acf_get_setting('json'))
|
77 |
+
return;
|
78 |
+
|
79 |
+
remove_filter('acf/settings/json', 'acfe_autosync_temp_disable_json');
|
80 |
+
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Auto Sync: Disable json (function)
|
85 |
+
*/
|
86 |
+
function acfe_autosync_temp_disable_json(){
|
87 |
+
return false;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Auto Sync: PHP
|
92 |
+
*/
|
93 |
+
add_action('acf/update_field_group', 'acfe_autosync_php_update_field_group');
|
94 |
+
function acfe_autosync_php_update_field_group($field_group){
|
95 |
+
|
96 |
+
// Validate
|
97 |
+
if(!acf_get_setting('acfe/php'))
|
98 |
+
return;
|
99 |
+
|
100 |
+
if(!acfe_has_field_group_autosync($field_group, 'php'))
|
101 |
+
return;
|
102 |
+
|
103 |
+
$field_group['fields'] = acf_get_fields($field_group);
|
104 |
+
acfe_autosync_write_php($field_group);
|
105 |
+
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Auto Sync: Write PHP
|
110 |
+
*/
|
111 |
+
function acfe_autosync_write_php($field_group){
|
112 |
+
|
113 |
+
$path = acf_get_setting('acfe/php_save');
|
114 |
+
if(empty($path))
|
115 |
+
return false;
|
116 |
+
|
117 |
+
// vars
|
118 |
+
$path = untrailingslashit($path);
|
119 |
+
$file = $field_group['key'] . '.php';
|
120 |
+
|
121 |
+
// bail early if dir does not exist
|
122 |
+
if(!is_writable($path))
|
123 |
+
return false;
|
124 |
+
|
125 |
+
// prepare for export
|
126 |
+
$id = acf_extract_var($field_group, 'ID');
|
127 |
+
$field_group = acf_prepare_field_group_for_export($field_group);
|
128 |
+
|
129 |
+
// add modified time
|
130 |
+
$field_group['modified'] = get_post_modified_time('U', true, $id, true);
|
131 |
+
|
132 |
+
|
133 |
+
// Prepare
|
134 |
+
$str_replace = array(
|
135 |
+
" " => "\t",
|
136 |
+
"'!!__(!!\'" => "__('",
|
137 |
+
"!!\', !!\'" => "', '",
|
138 |
+
"!!\')!!'" => "')",
|
139 |
+
"array (" => "array("
|
140 |
+
);
|
141 |
+
|
142 |
+
$preg_replace = array(
|
143 |
+
'/([\t\r\n]+?)array/' => 'array',
|
144 |
+
'/[0-9]+ => array/' => 'array'
|
145 |
+
);
|
146 |
+
|
147 |
+
ob_start();
|
148 |
+
|
149 |
+
echo "<?php " . "\r\n" . "\r\n";
|
150 |
+
echo "if( function_exists('acf_add_local_field_group') ):" . "\r\n" . "\r\n";
|
151 |
+
|
152 |
+
// code
|
153 |
+
$code = var_export($field_group, true);
|
154 |
+
|
155 |
+
|
156 |
+
// change double spaces to tabs
|
157 |
+
$code = str_replace( array_keys($str_replace), array_values($str_replace), $code );
|
158 |
+
|
159 |
+
|
160 |
+
// correctly formats "=> array("
|
161 |
+
$code = preg_replace( array_keys($preg_replace), array_values($preg_replace), $code );
|
162 |
+
|
163 |
+
|
164 |
+
// esc_textarea
|
165 |
+
$code = $code;
|
166 |
+
|
167 |
+
// echo
|
168 |
+
echo "acf_add_local_field_group({$code});" . "\r\n" . "\r\n";
|
169 |
+
|
170 |
+
echo "endif;";
|
171 |
+
|
172 |
+
$output = ob_get_clean();
|
173 |
+
|
174 |
+
// write file
|
175 |
+
$f = fopen("{$path}/{$file}", 'w');
|
176 |
+
fwrite($f, $output);
|
177 |
+
fclose($f);
|
178 |
+
|
179 |
+
// return
|
180 |
+
return true;
|
181 |
+
|
182 |
+
}
|
183 |
+
|
184 |
+
/**
|
185 |
+
* Auto Sync: Helper - is field group json desync
|
186 |
+
*/
|
187 |
+
function acfe_is_field_group_json_desync($field_group){
|
188 |
+
|
189 |
+
acf_enable_filter('local');
|
190 |
+
$group = acf_get_local_field_group($field_group['key']);
|
191 |
+
acf_disable_filter('local');
|
192 |
+
|
193 |
+
$private = acf_maybe_get($group, 'private', false);
|
194 |
+
$local = acf_maybe_get($group, 'local', false);
|
195 |
+
$modified = acf_maybe_get($group, 'modified', 0);
|
196 |
+
|
197 |
+
if($private){
|
198 |
+
return false;
|
199 |
+
}
|
200 |
+
|
201 |
+
elseif($local !== 'json'){
|
202 |
+
return false;
|
203 |
+
}
|
204 |
+
|
205 |
+
elseif($modified && $modified > get_post_modified_time('U', true, $field_group['ID'], true)){
|
206 |
+
return true;
|
207 |
+
}
|
208 |
+
|
209 |
+
return false;
|
210 |
+
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* Auto Sync: Helper - Has field group autosync
|
215 |
+
*/
|
216 |
+
function acfe_has_field_group_autosync($field_group, $type = false){
|
217 |
+
$acfe_autosync = acf_maybe_get($field_group, 'acfe_autosync', array());
|
218 |
+
|
219 |
+
if(!$type)
|
220 |
+
return acf_is_array($acfe_autosync);
|
221 |
+
|
222 |
+
if($type === 'json')
|
223 |
+
return is_array($acfe_autosync) && in_array('json', $acfe_autosync);
|
224 |
+
|
225 |
+
elseif($type === 'php')
|
226 |
+
return is_array($acfe_autosync) && in_array('php', $acfe_autosync);
|
227 |
+
|
228 |
+
return false;
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Auto Sync: Helper - Has field group autosync found register/file
|
233 |
+
*/
|
234 |
+
function acfe_has_field_group_autosync_file($field_group, $type = 'json'){
|
235 |
+
|
236 |
+
if($type === 'json'){
|
237 |
+
|
238 |
+
// acf_is_local_field_group = true if json file found
|
239 |
+
$found = false;
|
240 |
+
|
241 |
+
if(acf_is_local_field_group($field_group['key'])){
|
242 |
+
|
243 |
+
$local_field_group = acf_get_local_field_group($field_group['key']);
|
244 |
+
$get_local = acf_maybe_get($local_field_group, 'local', false);
|
245 |
+
|
246 |
+
if($get_local === 'json'){
|
247 |
+
|
248 |
+
$found = true;
|
249 |
+
|
250 |
+
}else{
|
251 |
+
|
252 |
+
$paths = acf_get_setting('load_json');
|
253 |
+
|
254 |
+
if(!empty($paths)){
|
255 |
+
foreach($paths as $path){
|
256 |
+
|
257 |
+
$path = untrailingslashit($path);
|
258 |
+
$file = $field_group['key'] . '.json';
|
259 |
+
|
260 |
+
if(is_readable("{$path}/{$file}")){
|
261 |
+
|
262 |
+
$found = true;
|
263 |
+
break;
|
264 |
+
|
265 |
+
}
|
266 |
+
|
267 |
+
}
|
268 |
+
}
|
269 |
+
|
270 |
+
}
|
271 |
+
|
272 |
+
}
|
273 |
+
|
274 |
+
else{
|
275 |
+
|
276 |
+
$paths = acf_get_setting('load_json');
|
277 |
+
|
278 |
+
if(!empty($paths)){
|
279 |
+
foreach($paths as $path){
|
280 |
+
|
281 |
+
$path = untrailingslashit($path);
|
282 |
+
$file = $field_group['key'] . '.json';
|
283 |
+
|
284 |
+
if(is_readable("{$path}/{$file}")){
|
285 |
+
|
286 |
+
$found = true;
|
287 |
+
break;
|
288 |
+
|
289 |
+
}
|
290 |
+
|
291 |
+
}
|
292 |
+
}
|
293 |
+
|
294 |
+
}
|
295 |
+
|
296 |
+
return $found;
|
297 |
+
|
298 |
+
}
|
299 |
+
|
300 |
+
elseif($type === 'php'){
|
301 |
+
|
302 |
+
// acf_is_local_field_group = true if php registered
|
303 |
+
$found = false;
|
304 |
+
|
305 |
+
if(acf_is_local_field_group($field_group['key'])){
|
306 |
+
|
307 |
+
$local_field_group = acf_get_local_field_group($field_group['key']);
|
308 |
+
$get_local = acf_maybe_get($local_field_group, 'local', false);
|
309 |
+
|
310 |
+
if($get_local === 'php')
|
311 |
+
$found = true;
|
312 |
+
|
313 |
+
}
|
314 |
+
|
315 |
+
return $found;
|
316 |
+
|
317 |
+
}
|
318 |
+
|
319 |
+
return false;
|
320 |
+
|
321 |
}
|
includes/modules/dev.php
CHANGED
@@ -1,341 +1,341 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
// Check setting
|
7 |
-
if((!acf_get_setting('acfe/dev') && (!defined('ACFE_dev') || !ACFE_dev)) && (!acf_get_setting('acfe/super_dev') && (!defined('ACFE_super_dev') || !ACFE_super_dev)))
|
8 |
-
return;
|
9 |
-
|
10 |
-
if(!class_exists('acfe_dev')):
|
11 |
-
|
12 |
-
class acfe_dev{
|
13 |
-
|
14 |
-
public $wp_meta = array();
|
15 |
-
public $acf_meta = array();
|
16 |
-
|
17 |
-
public $is_super_dev = false;
|
18 |
-
|
19 |
-
function __construct(){
|
20 |
-
|
21 |
-
// Script debug
|
22 |
-
if(!defined('SCRIPT_DEBUG'))
|
23 |
-
define('SCRIPT_DEBUG', true);
|
24 |
-
|
25 |
-
if(acf_get_setting('acfe/super_dev', false) || (defined('ACFE_super_dev') && ACFE_super_dev))
|
26 |
-
$this->is_super_dev = true;
|
27 |
-
|
28 |
-
add_action('load-post.php', array($this, 'load_post'));
|
29 |
-
add_action('load-post-new.php', array($this, 'load_post'));
|
30 |
-
|
31 |
-
add_action('load-term.php', array($this, 'load_term'));
|
32 |
-
|
33 |
-
}
|
34 |
-
|
35 |
-
function load_post(){
|
36 |
-
|
37 |
-
global $typenow;
|
38 |
-
|
39 |
-
$post_type = $typenow;
|
40 |
-
|
41 |
-
// Remove WP post meta box
|
42 |
-
remove_meta_box('postcustom', false, 'normal');
|
43 |
-
|
44 |
-
if(!$this->is_super_dev){
|
45 |
-
|
46 |
-
$restricted = array('acfe-dbt', 'acfe-dop', 'acfe-dpt', 'acfe-dt', 'acfe-form');
|
47 |
-
|
48 |
-
if(in_array($post_type, $restricted))
|
49 |
-
return;
|
50 |
-
|
51 |
-
}
|
52 |
-
|
53 |
-
// actions
|
54 |
-
add_action('add_meta_boxes', array($this, 'add_meta_boxes'), 10, 2);
|
55 |
-
|
56 |
-
}
|
57 |
-
|
58 |
-
function load_term(){
|
59 |
-
|
60 |
-
$screen = get_current_screen();
|
61 |
-
$taxonomy = $screen->taxonomy;
|
62 |
-
|
63 |
-
// actions
|
64 |
-
add_action("{$taxonomy}_edit_form", array($this, 'edit_term'), 20, 2);
|
65 |
-
|
66 |
-
}
|
67 |
-
|
68 |
-
function edit_term($term, $taxonomy){
|
69 |
-
|
70 |
-
$post_id = acf_get_term_post_id($term->taxonomy, $term->term_id);
|
71 |
-
|
72 |
-
$this->get_meta($post_id);
|
73 |
-
|
74 |
-
if(!empty($this->wp_meta)){
|
75 |
-
|
76 |
-
add_meta_box('acfe-wp-custom-fields', 'WP Custom fields', array($this, 'wp_render_meta_box'), 'edit-term', 'normal', 'low');
|
77 |
-
|
78 |
-
}
|
79 |
-
|
80 |
-
if(!empty($this->acf_meta)){
|
81 |
-
|
82 |
-
add_meta_box('acfe-acf-custom-fields', 'ACF Custom fields', array($this, 'acf_render_meta_box'), 'edit-term', 'normal', 'low');
|
83 |
-
|
84 |
-
}
|
85 |
-
|
86 |
-
echo '<div id="poststuff">';
|
87 |
-
|
88 |
-
do_meta_boxes('edit-term', 'normal', array());
|
89 |
-
|
90 |
-
echo '</div>';
|
91 |
-
|
92 |
-
}
|
93 |
-
|
94 |
-
function get_meta($post_id = 0){
|
95 |
-
|
96 |
-
if(!$post_id)
|
97 |
-
$post_id = acf_get_valid_post_id();
|
98 |
-
|
99 |
-
if(empty($post_id))
|
100 |
-
return;
|
101 |
-
|
102 |
-
$info = acf_get_post_id_info($post_id);
|
103 |
-
|
104 |
-
|
105 |
-
global $wpdb;
|
106 |
-
|
107 |
-
// Post
|
108 |
-
if($info['type'] === 'post'){
|
109 |
-
|
110 |
-
$get_meta = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->postmeta WHERE post_id = %d ", $info['id']));
|
111 |
-
|
112 |
-
}
|
113 |
-
|
114 |
-
// Term
|
115 |
-
elseif($info['type'] === 'term'){
|
116 |
-
|
117 |
-
$get_meta = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->termmeta WHERE term_id = %d ", $info['id']));
|
118 |
-
|
119 |
-
}
|
120 |
-
|
121 |
-
usort($get_meta, function($a, $b){
|
122 |
-
return strcmp($a->meta_key, $b->meta_key);
|
123 |
-
});
|
124 |
-
|
125 |
-
if(empty($get_meta))
|
126 |
-
return;
|
127 |
-
|
128 |
-
$wp_meta = array();
|
129 |
-
|
130 |
-
foreach($get_meta as $meta){
|
131 |
-
|
132 |
-
$wp_meta[$meta->meta_key] = $meta->meta_value;
|
133 |
-
|
134 |
-
}
|
135 |
-
|
136 |
-
$acf_meta = array();
|
137 |
-
|
138 |
-
foreach($wp_meta as $key => $value){
|
139 |
-
|
140 |
-
// ACF Meta
|
141 |
-
if(isset($wp_meta["_$key"])){
|
142 |
-
|
143 |
-
$field = false;
|
144 |
-
$field_group = false;
|
145 |
-
|
146 |
-
if(acf_is_field_key($wp_meta["_$key"])){
|
147 |
-
|
148 |
-
$field = acf_get_field($wp_meta["_$key"]);
|
149 |
-
$field_group = acfe_get_field_group_from_field($field);
|
150 |
-
|
151 |
-
}
|
152 |
-
|
153 |
-
$acf_meta[] = array(
|
154 |
-
'key' => "_$key",
|
155 |
-
'value' => $wp_meta["_$key"],
|
156 |
-
'field' => $field,
|
157 |
-
'field_group' => $field_group,
|
158 |
-
);
|
159 |
-
|
160 |
-
$acf_meta[] = array(
|
161 |
-
'key' => $key,
|
162 |
-
'value' => $wp_meta[$key],
|
163 |
-
'field' => $field,
|
164 |
-
'field_group' => $field_group,
|
165 |
-
);
|
166 |
-
|
167 |
-
unset($wp_meta["_$key"]);
|
168 |
-
unset($wp_meta[$key]);
|
169 |
-
|
170 |
-
}
|
171 |
-
|
172 |
-
}
|
173 |
-
|
174 |
-
$this->wp_meta = $wp_meta;
|
175 |
-
$this->acf_meta = $acf_meta;
|
176 |
-
|
177 |
-
}
|
178 |
-
|
179 |
-
function add_meta_boxes($post_type, $post){
|
180 |
-
|
181 |
-
$this->get_meta();
|
182 |
-
|
183 |
-
if(!empty($this->wp_meta)){
|
184 |
-
|
185 |
-
add_meta_box('acfe-wp-custom-fields', 'WP Custom fields', array($this, 'wp_render_meta_box'), $post_type, 'normal', 'low');
|
186 |
-
|
187 |
-
}
|
188 |
-
|
189 |
-
if(!empty($this->acf_meta)){
|
190 |
-
|
191 |
-
add_meta_box('acfe-acf-custom-fields', 'ACF Custom fields', array($this, 'acf_render_meta_box'), $post_type, 'normal', 'low');
|
192 |
-
|
193 |
-
}
|
194 |
-
|
195 |
-
}
|
196 |
-
|
197 |
-
function wp_render_meta_box($post, $metabox){
|
198 |
-
|
199 |
-
?>
|
200 |
-
<table class="wp-list-table widefat fixed striped" style="border:0;">
|
201 |
-
|
202 |
-
<thead>
|
203 |
-
<tr>
|
204 |
-
<th scope="col" style="width:30%;">Name</th>
|
205 |
-
<th scope="col" style="width:auto;">Value</th>
|
206 |
-
</tr>
|
207 |
-
</thead>
|
208 |
-
|
209 |
-
<tbody>
|
210 |
-
|
211 |
-
<?php foreach($this->wp_meta as $meta_key => $meta_value){ ?>
|
212 |
-
|
213 |
-
<?php
|
214 |
-
$value_display = $this->render_meta_value($meta_value);
|
215 |
-
?>
|
216 |
-
|
217 |
-
<tr>
|
218 |
-
<td><strong><?php echo esc_attr($meta_key); ?></strong></td>
|
219 |
-
<td><?php echo $value_display; ?></td>
|
220 |
-
</tr>
|
221 |
-
|
222 |
-
<?php } ?>
|
223 |
-
|
224 |
-
</tbody>
|
225 |
-
|
226 |
-
</table>
|
227 |
-
<?php
|
228 |
-
|
229 |
-
}
|
230 |
-
|
231 |
-
function acf_render_meta_box($post, $metabox){
|
232 |
-
|
233 |
-
?>
|
234 |
-
<table class="wp-list-table widefat fixed striped" style="border:0;">
|
235 |
-
|
236 |
-
<thead>
|
237 |
-
<tr>
|
238 |
-
<th scope="col" style="width:30%;">Name</th>
|
239 |
-
<th scope="col" style="width:auto;">Value</th>
|
240 |
-
<th scope="col" style="width:120px;">Field group</a></th>
|
241 |
-
</tr>
|
242 |
-
</thead>
|
243 |
-
|
244 |
-
<tbody>
|
245 |
-
|
246 |
-
<?php foreach($this->acf_meta as $meta){ ?>
|
247 |
-
|
248 |
-
<?php
|
249 |
-
$meta_key = $meta['key'];
|
250 |
-
$value = $meta['value'];
|
251 |
-
|
252 |
-
$field = $meta['field'];
|
253 |
-
$field_group = $meta['field_group'];
|
254 |
-
$field_group_display = '<span style="color:#aaa;">' . __('Unknown', 'acf') . '</span>';
|
255 |
-
|
256 |
-
if($field_group){
|
257 |
-
|
258 |
-
$field_group_display = $field_group['title'];
|
259 |
-
|
260 |
-
if(!empty($field_group['ID'])){
|
261 |
-
|
262 |
-
$post_status = get_post_status($field_group['ID']);
|
263 |
-
|
264 |
-
if($post_status === 'publish')
|
265 |
-
$field_group_display = '<a href="' . admin_url('post.php?post=' . $field_group['ID'] . '&action=edit') . '">' . $field_group['title'] . '</a>';
|
266 |
-
|
267 |
-
}
|
268 |
-
|
269 |
-
}
|
270 |
-
|
271 |
-
$value_display = $this->render_meta_value($meta['value']);
|
272 |
-
|
273 |
-
?>
|
274 |
-
|
275 |
-
<tr>
|
276 |
-
<td><strong><?php echo esc_attr($meta_key); ?></strong></td>
|
277 |
-
<td><?php echo $value_display; ?></td>
|
278 |
-
<td><?php echo $field_group_display; ?></td>
|
279 |
-
</tr>
|
280 |
-
|
281 |
-
<?php } ?>
|
282 |
-
|
283 |
-
</tbody>
|
284 |
-
|
285 |
-
</table>
|
286 |
-
<?php
|
287 |
-
|
288 |
-
}
|
289 |
-
|
290 |
-
function render_meta_value($value){
|
291 |
-
|
292 |
-
$return = '';
|
293 |
-
|
294 |
-
// Serialized
|
295 |
-
if(is_serialized($value)){
|
296 |
-
|
297 |
-
$return = '<pre style="max-height:200px; overflow:auto; white-space: pre;">' . print_r(maybe_unserialize($value), true) . '</pre>';
|
298 |
-
$return .= '<pre style="max-height:200px; overflow:auto; white-space: pre; margin-top:10px;">' . print_r($value, true) . '</pre>';
|
299 |
-
|
300 |
-
}
|
301 |
-
|
302 |
-
// HTML
|
303 |
-
elseif($value != strip_tags($value)){
|
304 |
-
|
305 |
-
$return = '<pre style="max-height:200px; overflow:auto; white-space: pre;">' . print_r(htmlentities($value), true) . '</pre>';
|
306 |
-
|
307 |
-
}
|
308 |
-
|
309 |
-
// Json
|
310 |
-
elseif(acfe_is_json($value)){
|
311 |
-
|
312 |
-
$return = '<pre style="max-height:200px; overflow:auto; white-space: pre;">' . print_r(json_decode($value), true) . '</pre>';
|
313 |
-
$return .= '<pre style="max-height:200px; overflow:auto; white-space: pre; margin-top:10px;">' . print_r($value, true) . '</pre>';
|
314 |
-
|
315 |
-
}
|
316 |
-
|
317 |
-
// String
|
318 |
-
else{
|
319 |
-
|
320 |
-
$css = '';
|
321 |
-
|
322 |
-
if(empty($value)){
|
323 |
-
|
324 |
-
$css = 'color:#aaa;';
|
325 |
-
$value = '(' . __('empty', 'acf') . ')';
|
326 |
-
|
327 |
-
}
|
328 |
-
|
329 |
-
$return = '<pre style="max-height:200px; overflow:auto; white-space: pre; ' . $css . '">' . print_r($value, true) . '</pre>';
|
330 |
-
|
331 |
-
}
|
332 |
-
|
333 |
-
return $return;
|
334 |
-
|
335 |
-
}
|
336 |
-
|
337 |
-
}
|
338 |
-
|
339 |
-
new acfe_dev();
|
340 |
-
|
341 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
// Check setting
|
7 |
+
if((!acf_get_setting('acfe/dev') && (!defined('ACFE_dev') || !ACFE_dev)) && (!acf_get_setting('acfe/super_dev') && (!defined('ACFE_super_dev') || !ACFE_super_dev)))
|
8 |
+
return;
|
9 |
+
|
10 |
+
if(!class_exists('acfe_dev')):
|
11 |
+
|
12 |
+
class acfe_dev{
|
13 |
+
|
14 |
+
public $wp_meta = array();
|
15 |
+
public $acf_meta = array();
|
16 |
+
|
17 |
+
public $is_super_dev = false;
|
18 |
+
|
19 |
+
function __construct(){
|
20 |
+
|
21 |
+
// Script debug
|
22 |
+
if(!defined('SCRIPT_DEBUG'))
|
23 |
+
define('SCRIPT_DEBUG', true);
|
24 |
+
|
25 |
+
if(acf_get_setting('acfe/super_dev', false) || (defined('ACFE_super_dev') && ACFE_super_dev))
|
26 |
+
$this->is_super_dev = true;
|
27 |
+
|
28 |
+
add_action('load-post.php', array($this, 'load_post'));
|
29 |
+
add_action('load-post-new.php', array($this, 'load_post'));
|
30 |
+
|
31 |
+
add_action('load-term.php', array($this, 'load_term'));
|
32 |
+
|
33 |
+
}
|
34 |
+
|
35 |
+
function load_post(){
|
36 |
+
|
37 |
+
global $typenow;
|
38 |
+
|
39 |
+
$post_type = $typenow;
|
40 |
+
|
41 |
+
// Remove WP post meta box
|
42 |
+
remove_meta_box('postcustom', false, 'normal');
|
43 |
+
|
44 |
+
if(!$this->is_super_dev){
|
45 |
+
|
46 |
+
$restricted = array('acfe-dbt', 'acfe-dop', 'acfe-dpt', 'acfe-dt', 'acfe-form');
|
47 |
+
|
48 |
+
if(in_array($post_type, $restricted))
|
49 |
+
return;
|
50 |
+
|
51 |
+
}
|
52 |
+
|
53 |
+
// actions
|
54 |
+
add_action('add_meta_boxes', array($this, 'add_meta_boxes'), 10, 2);
|
55 |
+
|
56 |
+
}
|
57 |
+
|
58 |
+
function load_term(){
|
59 |
+
|
60 |
+
$screen = get_current_screen();
|
61 |
+
$taxonomy = $screen->taxonomy;
|
62 |
+
|
63 |
+
// actions
|
64 |
+
add_action("{$taxonomy}_edit_form", array($this, 'edit_term'), 20, 2);
|
65 |
+
|
66 |
+
}
|
67 |
+
|
68 |
+
function edit_term($term, $taxonomy){
|
69 |
+
|
70 |
+
$post_id = acf_get_term_post_id($term->taxonomy, $term->term_id);
|
71 |
+
|
72 |
+
$this->get_meta($post_id);
|
73 |
+
|
74 |
+
if(!empty($this->wp_meta)){
|
75 |
+
|
76 |
+
add_meta_box('acfe-wp-custom-fields', 'WP Custom fields', array($this, 'wp_render_meta_box'), 'edit-term', 'normal', 'low');
|
77 |
+
|
78 |
+
}
|
79 |
+
|
80 |
+
if(!empty($this->acf_meta)){
|
81 |
+
|
82 |
+
add_meta_box('acfe-acf-custom-fields', 'ACF Custom fields', array($this, 'acf_render_meta_box'), 'edit-term', 'normal', 'low');
|
83 |
+
|
84 |
+
}
|
85 |
+
|
86 |
+
echo '<div id="poststuff">';
|
87 |
+
|
88 |
+
do_meta_boxes('edit-term', 'normal', array());
|
89 |
+
|
90 |
+
echo '</div>';
|
91 |
+
|
92 |
+
}
|
93 |
+
|
94 |
+
function get_meta($post_id = 0){
|
95 |
+
|
96 |
+
if(!$post_id)
|
97 |
+
$post_id = acf_get_valid_post_id();
|
98 |
+
|
99 |
+
if(empty($post_id))
|
100 |
+
return;
|
101 |
+
|
102 |
+
$info = acf_get_post_id_info($post_id);
|
103 |
+
|
104 |
+
|
105 |
+
global $wpdb;
|
106 |
+
|
107 |
+
// Post
|
108 |
+
if($info['type'] === 'post'){
|
109 |
+
|
110 |
+
$get_meta = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->postmeta WHERE post_id = %d ", $info['id']));
|
111 |
+
|
112 |
+
}
|
113 |
+
|
114 |
+
// Term
|
115 |
+
elseif($info['type'] === 'term'){
|
116 |
+
|
117 |
+
$get_meta = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->termmeta WHERE term_id = %d ", $info['id']));
|
118 |
+
|
119 |
+
}
|
120 |
+
|
121 |
+
usort($get_meta, function($a, $b){
|
122 |
+
return strcmp($a->meta_key, $b->meta_key);
|
123 |
+
});
|
124 |
+
|
125 |
+
if(empty($get_meta))
|
126 |
+
return;
|
127 |
+
|
128 |
+
$wp_meta = array();
|
129 |
+
|
130 |
+
foreach($get_meta as $meta){
|
131 |
+
|
132 |
+
$wp_meta[$meta->meta_key] = $meta->meta_value;
|
133 |
+
|
134 |
+
}
|
135 |
+
|
136 |
+
$acf_meta = array();
|
137 |
+
|
138 |
+
foreach($wp_meta as $key => $value){
|
139 |
+
|
140 |
+
// ACF Meta
|
141 |
+
if(isset($wp_meta["_$key"])){
|
142 |
+
|
143 |
+
$field = false;
|
144 |
+
$field_group = false;
|
145 |
+
|
146 |
+
if(acf_is_field_key($wp_meta["_$key"])){
|
147 |
+
|
148 |
+
$field = acf_get_field($wp_meta["_$key"]);
|
149 |
+
$field_group = acfe_get_field_group_from_field($field);
|
150 |
+
|
151 |
+
}
|
152 |
+
|
153 |
+
$acf_meta[] = array(
|
154 |
+
'key' => "_$key",
|
155 |
+
'value' => $wp_meta["_$key"],
|
156 |
+
'field' => $field,
|
157 |
+
'field_group' => $field_group,
|
158 |
+
);
|
159 |
+
|
160 |
+
$acf_meta[] = array(
|
161 |
+
'key' => $key,
|
162 |
+
'value' => $wp_meta[$key],
|
163 |
+
'field' => $field,
|
164 |
+
'field_group' => $field_group,
|
165 |
+
);
|
166 |
+
|
167 |
+
unset($wp_meta["_$key"]);
|
168 |
+
unset($wp_meta[$key]);
|
169 |
+
|
170 |
+
}
|
171 |
+
|
172 |
+
}
|
173 |
+
|
174 |
+
$this->wp_meta = $wp_meta;
|
175 |
+
$this->acf_meta = $acf_meta;
|
176 |
+
|
177 |
+
}
|
178 |
+
|
179 |
+
function add_meta_boxes($post_type, $post){
|
180 |
+
|
181 |
+
$this->get_meta();
|
182 |
+
|
183 |
+
if(!empty($this->wp_meta)){
|
184 |
+
|
185 |
+
add_meta_box('acfe-wp-custom-fields', 'WP Custom fields <span style="background: #72777c;padding: 1px 5px;border-radius: 4px;color: #fff;margin-left: 3px;font-size: 12px;">'.count($this->wp_meta).'</span>', array($this, 'wp_render_meta_box'), $post_type, 'normal', 'low');
|
186 |
+
|
187 |
+
}
|
188 |
+
|
189 |
+
if(!empty($this->acf_meta)){
|
190 |
+
|
191 |
+
add_meta_box('acfe-acf-custom-fields', 'ACF Custom fields <span style="background: #72777c;padding: 1px 5px;border-radius: 4px;color: #fff;margin-left: 3px;font-size: 12px;">'.count($this->acf_meta).'</span>', array($this, 'acf_render_meta_box'), $post_type, 'normal', 'low');
|
192 |
+
|
193 |
+
}
|
194 |
+
|
195 |
+
}
|
196 |
+
|
197 |
+
function wp_render_meta_box($post, $metabox){
|
198 |
+
|
199 |
+
?>
|
200 |
+
<table class="wp-list-table widefat fixed striped" style="border:0;">
|
201 |
+
|
202 |
+
<thead>
|
203 |
+
<tr>
|
204 |
+
<th scope="col" style="width:30%;">Name</th>
|
205 |
+
<th scope="col" style="width:auto;">Value</th>
|
206 |
+
</tr>
|
207 |
+
</thead>
|
208 |
+
|
209 |
+
<tbody>
|
210 |
+
|
211 |
+
<?php foreach($this->wp_meta as $meta_key => $meta_value){ ?>
|
212 |
+
|
213 |
+
<?php
|
214 |
+
$value_display = $this->render_meta_value($meta_value);
|
215 |
+
?>
|
216 |
+
|
217 |
+
<tr>
|
218 |
+
<td><strong><?php echo esc_attr($meta_key); ?></strong></td>
|
219 |
+
<td><?php echo $value_display; ?></td>
|
220 |
+
</tr>
|
221 |
+
|
222 |
+
<?php } ?>
|
223 |
+
|
224 |
+
</tbody>
|
225 |
+
|
226 |
+
</table>
|
227 |
+
<?php
|
228 |
+
|
229 |
+
}
|
230 |
+
|
231 |
+
function acf_render_meta_box($post, $metabox){
|
232 |
+
|
233 |
+
?>
|
234 |
+
<table class="wp-list-table widefat fixed striped" style="border:0;">
|
235 |
+
|
236 |
+
<thead>
|
237 |
+
<tr>
|
238 |
+
<th scope="col" style="width:30%;">Name</th>
|
239 |
+
<th scope="col" style="width:auto;">Value</th>
|
240 |
+
<th scope="col" style="width:120px;">Field group</a></th>
|
241 |
+
</tr>
|
242 |
+
</thead>
|
243 |
+
|
244 |
+
<tbody>
|
245 |
+
|
246 |
+
<?php foreach($this->acf_meta as $meta){ ?>
|
247 |
+
|
248 |
+
<?php
|
249 |
+
$meta_key = $meta['key'];
|
250 |
+
$value = $meta['value'];
|
251 |
+
|
252 |
+
$field = $meta['field'];
|
253 |
+
$field_group = $meta['field_group'];
|
254 |
+
$field_group_display = '<span style="color:#aaa;">' . __('Unknown', 'acf') . '</span>';
|
255 |
+
|
256 |
+
if($field_group){
|
257 |
+
|
258 |
+
$field_group_display = $field_group['title'];
|
259 |
+
|
260 |
+
if(!empty($field_group['ID'])){
|
261 |
+
|
262 |
+
$post_status = get_post_status($field_group['ID']);
|
263 |
+
|
264 |
+
if($post_status === 'publish')
|
265 |
+
$field_group_display = '<a href="' . admin_url('post.php?post=' . $field_group['ID'] . '&action=edit') . '">' . $field_group['title'] . '</a>';
|
266 |
+
|
267 |
+
}
|
268 |
+
|
269 |
+
}
|
270 |
+
|
271 |
+
$value_display = $this->render_meta_value($meta['value']);
|
272 |
+
|
273 |
+
?>
|
274 |
+
|
275 |
+
<tr>
|
276 |
+
<td><strong><?php echo esc_attr($meta_key); ?></strong></td>
|
277 |
+
<td><?php echo $value_display; ?></td>
|
278 |
+
<td><?php echo $field_group_display; ?></td>
|
279 |
+
</tr>
|
280 |
+
|
281 |
+
<?php } ?>
|
282 |
+
|
283 |
+
</tbody>
|
284 |
+
|
285 |
+
</table>
|
286 |
+
<?php
|
287 |
+
|
288 |
+
}
|
289 |
+
|
290 |
+
function render_meta_value($value){
|
291 |
+
|
292 |
+
$return = '';
|
293 |
+
|
294 |
+
// Serialized
|
295 |
+
if(is_serialized($value)){
|
296 |
+
|
297 |
+
$return = '<pre style="max-height:200px; overflow:auto; white-space: pre;">' . print_r(maybe_unserialize($value), true) . '</pre>';
|
298 |
+
$return .= '<pre style="max-height:200px; overflow:auto; white-space: pre; margin-top:10px;">' . print_r($value, true) . '</pre>';
|
299 |
+
|
300 |
+
}
|
301 |
+
|
302 |
+
// HTML
|
303 |
+
elseif($value != strip_tags($value)){
|
304 |
+
|
305 |
+
$return = '<pre style="max-height:200px; overflow:auto; white-space: pre;">' . print_r(htmlentities($value), true) . '</pre>';
|
306 |
+
|
307 |
+
}
|
308 |
+
|
309 |
+
// Json
|
310 |
+
elseif(acfe_is_json($value)){
|
311 |
+
|
312 |
+
$return = '<pre style="max-height:200px; overflow:auto; white-space: pre;">' . print_r(json_decode($value), true) . '</pre>';
|
313 |
+
$return .= '<pre style="max-height:200px; overflow:auto; white-space: pre; margin-top:10px;">' . print_r($value, true) . '</pre>';
|
314 |
+
|
315 |
+
}
|
316 |
+
|
317 |
+
// String
|
318 |
+
else{
|
319 |
+
|
320 |
+
$css = '';
|
321 |
+
|
322 |
+
if(empty($value)){
|
323 |
+
|
324 |
+
$css = 'color:#aaa;';
|
325 |
+
$value = '(' . __('empty', 'acf') . ')';
|
326 |
+
|
327 |
+
}
|
328 |
+
|
329 |
+
$return = '<pre style="max-height:200px; overflow:auto; white-space: pre; ' . $css . '">' . print_r($value, true) . '</pre>';
|
330 |
+
|
331 |
+
}
|
332 |
+
|
333 |
+
return $return;
|
334 |
+
|
335 |
+
}
|
336 |
+
|
337 |
+
}
|
338 |
+
|
339 |
+
new acfe_dev();
|
340 |
+
|
341 |
endif;
|
includes/modules/dynamic-block-type.php
CHANGED
@@ -1,1327 +1,1344 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
// Check setting
|
7 |
-
if(!acf_get_setting('acfe/modules/dynamic_block_types'))
|
8 |
-
return;
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Require ACF Pro 5.8
|
12 |
-
*/
|
13 |
-
if(version_compare(ACF_VERSION, '5.8', '<'))
|
14 |
-
return;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Register Dynamic Block Type
|
18 |
-
*/
|
19 |
-
add_action('init', 'acfe_dbt_register');
|
20 |
-
function acfe_dbt_register(){
|
21 |
-
|
22 |
-
register_post_type('acfe-dbt', array(
|
23 |
-
'label' => 'Block Type',
|
24 |
-
'description' => 'Block Type',
|
25 |
-
'labels' => array(
|
26 |
-
'name' => 'Block Types',
|
27 |
-
'singular_name' => 'Block Type',
|
28 |
-
'menu_name' => 'Block Types',
|
29 |
-
'edit_item' => 'Edit Block Type',
|
30 |
-
'add_new_item' => 'New Block Type',
|
31 |
-
),
|
32 |
-
'supports' => false,
|
33 |
-
'hierarchical' => false,
|
34 |
-
'public' => false,
|
35 |
-
'show_ui' => true,
|
36 |
-
'show_in_menu' => false,
|
37 |
-
'menu_icon' => 'dashicons-layout',
|
38 |
-
'show_in_admin_bar' => false,
|
39 |
-
'show_in_nav_menus' => false,
|
40 |
-
'can_export' => false,
|
41 |
-
'has_archive' => false,
|
42 |
-
'rewrite' => false,
|
43 |
-
'exclude_from_search' => true,
|
44 |
-
'publicly_queryable' => false,
|
45 |
-
'capabilities' => array(
|
46 |
-
'publish_posts' => acf_get_setting('capability'),
|
47 |
-
'edit_posts' => acf_get_setting('capability'),
|
48 |
-
'edit_others_posts' => acf_get_setting('capability'),
|
49 |
-
'delete_posts' => acf_get_setting('capability'),
|
50 |
-
'delete_others_posts' => acf_get_setting('capability'),
|
51 |
-
'read_private_posts' => acf_get_setting('capability'),
|
52 |
-
'edit_post' => acf_get_setting('capability'),
|
53 |
-
'delete_post' => acf_get_setting('capability'),
|
54 |
-
'read_post' => acf_get_setting('capability'),
|
55 |
-
)
|
56 |
-
));
|
57 |
-
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Dynamic Block Type Menu
|
62 |
-
*/
|
63 |
-
add_action('admin_menu', 'acfe_dbt_menu');
|
64 |
-
function acfe_dbt_menu(){
|
65 |
-
|
66 |
-
if(!acf_get_setting('show_admin'))
|
67 |
-
return;
|
68 |
-
|
69 |
-
add_submenu_page('edit.php?post_type=acf-field-group', __('Block Types'), __('Block Types'), acf_get_setting('capability'), 'edit.php?post_type=acfe-dbt');
|
70 |
-
|
71 |
-
}
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Dynamic Block Type Menu: Parent Highlight
|
75 |
-
*/
|
76 |
-
add_filter('parent_file', 'acfe_dbt_menu_parent_highlight');
|
77 |
-
function acfe_dbt_menu_parent_highlight($parent_file){
|
78 |
-
|
79 |
-
global $pagenow;
|
80 |
-
if($pagenow !== 'post.php' && $pagenow !== 'post-new.php')
|
81 |
-
return $parent_file;
|
82 |
-
|
83 |
-
$post_type = get_post_type();
|
84 |
-
if($post_type != 'acfe-dbt')
|
85 |
-
return $parent_file;
|
86 |
-
|
87 |
-
return 'edit.php?post_type=acf-field-group';
|
88 |
-
|
89 |
-
}
|
90 |
-
|
91 |
-
/**
|
92 |
-
* Dynamic Block Type Menu: Submenu Highlight
|
93 |
-
*/
|
94 |
-
add_filter('submenu_file', 'acfe_dbt_menu_sub_highlight');
|
95 |
-
function acfe_dbt_menu_sub_highlight($submenu_file){
|
96 |
-
|
97 |
-
global $pagenow;
|
98 |
-
if($pagenow != 'post-new.php')
|
99 |
-
return $submenu_file;
|
100 |
-
|
101 |
-
$post_type = get_post_type();
|
102 |
-
if($post_type != 'acfe-dbt')
|
103 |
-
return $submenu_file;
|
104 |
-
|
105 |
-
return 'edit.php?post_type=acfe-dbt';
|
106 |
-
|
107 |
-
}
|
108 |
-
|
109 |
-
/**
|
110 |
-
* ACF Register Block Types
|
111 |
-
*/
|
112 |
-
add_action('init', 'acfe_dbt_registers');
|
113 |
-
function acfe_dbt_registers(){
|
114 |
-
|
115 |
-
$dynamic_block_types = get_option('acfe_dynamic_block_types', array());
|
116 |
-
if(empty($dynamic_block_types))
|
117 |
-
return;
|
118 |
-
|
119 |
-
foreach($dynamic_block_types as $name => $register_args){
|
120 |
-
|
121 |
-
// Register: Execute
|
122 |
-
acf_register_block_type($register_args);
|
123 |
-
|
124 |
-
}
|
125 |
-
|
126 |
-
}
|
127 |
-
|
128 |
-
/**
|
129 |
-
* ACF Exclude Dynamic Options Page from available post types
|
130 |
-
*/
|
131 |
-
add_filter('acf/get_post_types', 'acfe_dbt_exclude', 10, 2);
|
132 |
-
function acfe_dbt_exclude($post_types, $args){
|
133 |
-
|
134 |
-
if(empty($post_types))
|
135 |
-
return $post_types;
|
136 |
-
|
137 |
-
foreach($post_types as $k => $post_type){
|
138 |
-
|
139 |
-
if($post_type !== 'acfe-dbt')
|
140 |
-
continue;
|
141 |
-
|
142 |
-
unset($post_types[$k]);
|
143 |
-
|
144 |
-
}
|
145 |
-
|
146 |
-
return $post_types;
|
147 |
-
|
148 |
-
}
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
$
|
173 |
-
|
174 |
-
|
175 |
-
$
|
176 |
-
$
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
$
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
'
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
'
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
'
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
//
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
}
|
244 |
-
|
245 |
-
//
|
246 |
-
$
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
$register_args['
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
$
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
$
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
$
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
$
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
echo '
|
436 |
-
|
437 |
-
}
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
}
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
$
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
}
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
'
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
array
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
'
|
667 |
-
'
|
668 |
-
|
669 |
-
'
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
'
|
693 |
-
'
|
694 |
-
'
|
695 |
-
'
|
696 |
-
'
|
697 |
-
'
|
698 |
-
|
699 |
-
|
700 |
-
'
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
'
|
705 |
-
'
|
706 |
-
'
|
707 |
-
|
708 |
-
|
709 |
-
'
|
710 |
-
'
|
711 |
-
'
|
712 |
-
|
713 |
-
|
714 |
-
'
|
715 |
-
'
|
716 |
-
'
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
'
|
722 |
-
'
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
'
|
728 |
-
'
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
'
|
734 |
-
'
|
735 |
-
'
|
736 |
-
|
737 |
-
'
|
738 |
-
'
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
'
|
745 |
-
'
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
'
|
754 |
-
'
|
755 |
-
'
|
756 |
-
|
757 |
-
|
758 |
-
'
|
759 |
-
'
|
760 |
-
'
|
761 |
-
|
762 |
-
|
763 |
-
'
|
764 |
-
'
|
765 |
-
'
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
'
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
'
|
776 |
-
'
|
777 |
-
'
|
778 |
-
|
779 |
-
|
780 |
-
'
|
781 |
-
'
|
782 |
-
'
|
783 |
-
|
784 |
-
|
785 |
-
'
|
786 |
-
'
|
787 |
-
'
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
'
|
795 |
-
'
|
796 |
-
'
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
'
|
803 |
-
'
|
804 |
-
'
|
805 |
-
'
|
806 |
-
'
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
'
|
812 |
-
'
|
813 |
-
'
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
'
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
'
|
824 |
-
'
|
825 |
-
'
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
'
|
831 |
-
'
|
832 |
-
'
|
833 |
-
'
|
834 |
-
'
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
'
|
841 |
-
'
|
842 |
-
'
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
'
|
848 |
-
'
|
849 |
-
'
|
850 |
-
'
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
'
|
859 |
-
'
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
'
|
867 |
-
'
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
'
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
'
|
879 |
-
'
|
880 |
-
'
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
'
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
'
|
896 |
-
'
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
'
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
'
|
912 |
-
'
|
913 |
-
'
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
'
|
919 |
-
'
|
920 |
-
'
|
921 |
-
'
|
922 |
-
'
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
'
|
932 |
-
'
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
'
|
939 |
-
|
940 |
-
|
941 |
-
'
|
942 |
-
'
|
943 |
-
'
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
'
|
949 |
-
'
|
950 |
-
'
|
951 |
-
'
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
'
|
969 |
-
'
|
970 |
-
'
|
971 |
-
'
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
'
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
'
|
999 |
-
'
|
1000 |
-
'
|
1001 |
-
'
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
'
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
'
|
1025 |
-
'
|
1026 |
-
'
|
1027 |
-
'
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
'
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
'
|
1051 |
-
'
|
1052 |
-
'
|
1053 |
-
'
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
'
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
'
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
'
|
1073 |
-
'
|
1074 |
-
'
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
'
|
1080 |
-
'
|
1081 |
-
'
|
1082 |
-
'
|
1083 |
-
'
|
1084 |
-
'
|
1085 |
-
|
1086 |
-
|
1087 |
-
'
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
'
|
1092 |
-
'
|
1093 |
-
'
|
1094 |
-
|
1095 |
-
|
1096 |
-
'
|
1097 |
-
'
|
1098 |
-
'
|
1099 |
-
|
1100 |
-
|
1101 |
-
'
|
1102 |
-
'
|
1103 |
-
'
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
'
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
'
|
1114 |
-
'
|
1115 |
-
'
|
1116 |
-
|
1117 |
-
|
1118 |
-
'
|
1119 |
-
'
|
1120 |
-
'
|
1121 |
-
|
1122 |
-
|
1123 |
-
'
|
1124 |
-
'
|
1125 |
-
'
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
'
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
'
|
1136 |
-
'
|
1137 |
-
'
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
'
|
1143 |
-
'
|
1144 |
-
'
|
1145 |
-
'
|
1146 |
-
'
|
1147 |
-
'
|
1148 |
-
|
1149 |
-
|
1150 |
-
'
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
'
|
1155 |
-
'
|
1156 |
-
'
|
1157 |
-
|
1158 |
-
|
1159 |
-
'
|
1160 |
-
'
|
1161 |
-
'
|
1162 |
-
|
1163 |
-
|
1164 |
-
'
|
1165 |
-
'
|
1166 |
-
'
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
'
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
'
|
1177 |
-
'
|
1178 |
-
'
|
1179 |
-
|
1180 |
-
|
1181 |
-
'
|
1182 |
-
'
|
1183 |
-
'
|
1184 |
-
|
1185 |
-
|
1186 |
-
'
|
1187 |
-
'
|
1188 |
-
'
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
'
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
'
|
1199 |
-
'
|
1200 |
-
'
|
1201 |
-
|
1202 |
-
|
1203 |
-
'
|
1204 |
-
'
|
1205 |
-
'
|
1206 |
-
|
1207 |
-
|
1208 |
-
'
|
1209 |
-
'
|
1210 |
-
'
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
'
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
'
|
1221 |
-
'
|
1222 |
-
'
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
'
|
1228 |
-
'
|
1229 |
-
'
|
1230 |
-
'
|
1231 |
-
'
|
1232 |
-
'
|
1233 |
-
|
1234 |
-
|
1235 |
-
'
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
'
|
1240 |
-
'
|
1241 |
-
'
|
1242 |
-
|
1243 |
-
|
1244 |
-
'
|
1245 |
-
'
|
1246 |
-
'
|
1247 |
-
|
1248 |
-
|
1249 |
-
'
|
1250 |
-
'
|
1251 |
-
'
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
'
|
1259 |
-
'
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
'
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
'
|
1276 |
-
'
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
'
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
'
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
'
|
1296 |
-
'
|
1297 |
-
'
|
1298 |
-
|
1299 |
-
|
1300 |
-
'
|
1301 |
-
'
|
1302 |
-
'
|
1303 |
-
|
1304 |
-
|
1305 |
-
'
|
1306 |
-
'
|
1307 |
-
'
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
'
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
'
|
1318 |
-
'
|
1319 |
-
'
|
1320 |
-
|
1321 |
-
|
1322 |
-
'
|
1323 |
-
'
|
1324 |
-
'
|
1325 |
-
|
1326 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1327 |
));
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
// Check setting
|
7 |
+
if(!acf_get_setting('acfe/modules/dynamic_block_types'))
|
8 |
+
return;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Require ACF Pro 5.8
|
12 |
+
*/
|
13 |
+
if(version_compare(ACF_VERSION, '5.8', '<'))
|
14 |
+
return;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Register Dynamic Block Type
|
18 |
+
*/
|
19 |
+
add_action('init', 'acfe_dbt_register');
|
20 |
+
function acfe_dbt_register(){
|
21 |
+
|
22 |
+
register_post_type('acfe-dbt', array(
|
23 |
+
'label' => 'Block Type',
|
24 |
+
'description' => 'Block Type',
|
25 |
+
'labels' => array(
|
26 |
+
'name' => 'Block Types',
|
27 |
+
'singular_name' => 'Block Type',
|
28 |
+
'menu_name' => 'Block Types',
|
29 |
+
'edit_item' => 'Edit Block Type',
|
30 |
+
'add_new_item' => 'New Block Type',
|
31 |
+
),
|
32 |
+
'supports' => false,
|
33 |
+
'hierarchical' => false,
|
34 |
+
'public' => false,
|
35 |
+
'show_ui' => true,
|
36 |
+
'show_in_menu' => false,
|
37 |
+
'menu_icon' => 'dashicons-layout',
|
38 |
+
'show_in_admin_bar' => false,
|
39 |
+
'show_in_nav_menus' => false,
|
40 |
+
'can_export' => false,
|
41 |
+
'has_archive' => false,
|
42 |
+
'rewrite' => false,
|
43 |
+
'exclude_from_search' => true,
|
44 |
+
'publicly_queryable' => false,
|
45 |
+
'capabilities' => array(
|
46 |
+
'publish_posts' => acf_get_setting('capability'),
|
47 |
+
'edit_posts' => acf_get_setting('capability'),
|
48 |
+
'edit_others_posts' => acf_get_setting('capability'),
|
49 |
+
'delete_posts' => acf_get_setting('capability'),
|
50 |
+
'delete_others_posts' => acf_get_setting('capability'),
|
51 |
+
'read_private_posts' => acf_get_setting('capability'),
|
52 |
+
'edit_post' => acf_get_setting('capability'),
|
53 |
+
'delete_post' => acf_get_setting('capability'),
|
54 |
+
'read_post' => acf_get_setting('capability'),
|
55 |
+
)
|
56 |
+
));
|
57 |
+
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Dynamic Block Type Menu
|
62 |
+
*/
|
63 |
+
add_action('admin_menu', 'acfe_dbt_menu');
|
64 |
+
function acfe_dbt_menu(){
|
65 |
+
|
66 |
+
if(!acf_get_setting('show_admin'))
|
67 |
+
return;
|
68 |
+
|
69 |
+
add_submenu_page('edit.php?post_type=acf-field-group', __('Block Types'), __('Block Types'), acf_get_setting('capability'), 'edit.php?post_type=acfe-dbt');
|
70 |
+
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Dynamic Block Type Menu: Parent Highlight
|
75 |
+
*/
|
76 |
+
add_filter('parent_file', 'acfe_dbt_menu_parent_highlight');
|
77 |
+
function acfe_dbt_menu_parent_highlight($parent_file){
|
78 |
+
|
79 |
+
global $pagenow;
|
80 |
+
if($pagenow !== 'post.php' && $pagenow !== 'post-new.php')
|
81 |
+
return $parent_file;
|
82 |
+
|
83 |
+
$post_type = get_post_type();
|
84 |
+
if($post_type != 'acfe-dbt')
|
85 |
+
return $parent_file;
|
86 |
+
|
87 |
+
return 'edit.php?post_type=acf-field-group';
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Dynamic Block Type Menu: Submenu Highlight
|
93 |
+
*/
|
94 |
+
add_filter('submenu_file', 'acfe_dbt_menu_sub_highlight');
|
95 |
+
function acfe_dbt_menu_sub_highlight($submenu_file){
|
96 |
+
|
97 |
+
global $pagenow;
|
98 |
+
if($pagenow != 'post-new.php')
|
99 |
+
return $submenu_file;
|
100 |
+
|
101 |
+
$post_type = get_post_type();
|
102 |
+
if($post_type != 'acfe-dbt')
|
103 |
+
return $submenu_file;
|
104 |
+
|
105 |
+
return 'edit.php?post_type=acfe-dbt';
|
106 |
+
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* ACF Register Block Types
|
111 |
+
*/
|
112 |
+
add_action('init', 'acfe_dbt_registers');
|
113 |
+
function acfe_dbt_registers(){
|
114 |
+
|
115 |
+
$dynamic_block_types = get_option('acfe_dynamic_block_types', array());
|
116 |
+
if(empty($dynamic_block_types))
|
117 |
+
return;
|
118 |
+
|
119 |
+
foreach($dynamic_block_types as $name => $register_args){
|
120 |
+
|
121 |
+
// Register: Execute
|
122 |
+
acf_register_block_type($register_args);
|
123 |
+
|
124 |
+
}
|
125 |
+
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* ACF Exclude Dynamic Options Page from available post types
|
130 |
+
*/
|
131 |
+
add_filter('acf/get_post_types', 'acfe_dbt_exclude', 10, 2);
|
132 |
+
function acfe_dbt_exclude($post_types, $args){
|
133 |
+
|
134 |
+
if(empty($post_types))
|
135 |
+
return $post_types;
|
136 |
+
|
137 |
+
foreach($post_types as $k => $post_type){
|
138 |
+
|
139 |
+
if($post_type !== 'acfe-dbt')
|
140 |
+
continue;
|
141 |
+
|
142 |
+
unset($post_types[$k]);
|
143 |
+
|
144 |
+
}
|
145 |
+
|
146 |
+
return $post_types;
|
147 |
+
|
148 |
+
}
|
149 |
+
|
150 |
+
add_action('post_submitbox_misc_actions', 'acfe_dbt_misc_actions');
|
151 |
+
function acfe_dbt_misc_actions($post){
|
152 |
+
|
153 |
+
if($post->post_type !== 'acfe-dbt')
|
154 |
+
return;
|
155 |
+
|
156 |
+
$name = get_field('name', $post->ID);
|
157 |
+
|
158 |
+
?>
|
159 |
+
<div class="misc-pub-section misc-pub-acfe-field-group-export" style="padding-top:2px;">
|
160 |
+
<span style="font-size:17px;color: #82878c;line-height: 1.3;width: 20px;margin-right: 2px;" class="dashicons dashicons-editor-code"></span> Export: <a href="<?php echo admin_url('edit.php?post_type=acf-field-group&page=acf-tools&tool=acfe_tool_dbt_export&action=php&keys=' . $name); ?>">PHP</a> <a href="<?php echo admin_url('edit.php?post_type=acf-field-group&page=acf-tools&tool=acfe_tool_dbt_export&action=json&keys=' . $name); ?>">Json</a>
|
161 |
+
</div>
|
162 |
+
<?php
|
163 |
+
|
164 |
+
}
|
165 |
+
|
166 |
+
/**
|
167 |
+
* Dynamic Block Types Save
|
168 |
+
*/
|
169 |
+
add_action('acf/save_post', 'acfe_dbt_filter_save', 20);
|
170 |
+
function acfe_dbt_filter_save($post_id){
|
171 |
+
|
172 |
+
if(get_post_type($post_id) != 'acfe-dbt')
|
173 |
+
return;
|
174 |
+
|
175 |
+
$title = get_field('title', $post_id);
|
176 |
+
$name = get_field('name', $post_id);
|
177 |
+
|
178 |
+
// Update post
|
179 |
+
wp_update_post(array(
|
180 |
+
'ID' => $post_id,
|
181 |
+
'post_title' => $title,
|
182 |
+
'post_name' => $name,
|
183 |
+
));
|
184 |
+
|
185 |
+
// Register Args
|
186 |
+
$name = get_field('name', $post_id);
|
187 |
+
$title = get_field('title', $post_id);
|
188 |
+
$description = get_field('description', $post_id);
|
189 |
+
$category = get_field('category', $post_id);
|
190 |
+
$keywords = acf_decode_choices(get_field('keywords', $post_id), true);
|
191 |
+
$post_types = acf_get_array(get_field('post_types', $post_id));
|
192 |
+
$mode = get_field('mode', $post_id);
|
193 |
+
$align = get_field('align', $post_id);
|
194 |
+
$render_template = get_field('render_template', $post_id);
|
195 |
+
$render_callback = get_field('render_callback', $post_id);
|
196 |
+
$enqueue_style = get_field('enqueue_style', $post_id);
|
197 |
+
$enqueue_script = get_field('enqueue_script', $post_id);
|
198 |
+
$enqueue_assets = get_field('enqueue_assets', $post_id);
|
199 |
+
|
200 |
+
// Render Template
|
201 |
+
if(!empty($render_template))
|
202 |
+
$render_template = ACFE_THEME_PATH . '/' . $render_template;
|
203 |
+
|
204 |
+
// Enqueue Style
|
205 |
+
if(!empty($enqueue_style))
|
206 |
+
$enqueue_style = ACFE_THEME_URL . '/' . $enqueue_style;
|
207 |
+
|
208 |
+
// Enqueue Script
|
209 |
+
if(!empty($enqueue_script))
|
210 |
+
$enqueue_script = ACFE_THEME_URL . '/' . $enqueue_script;
|
211 |
+
|
212 |
+
// Register: Args
|
213 |
+
$register_args = array(
|
214 |
+
'name' => $name,
|
215 |
+
'title' => $title,
|
216 |
+
'description' => $description,
|
217 |
+
'category' => $category,
|
218 |
+
'keywords' => $keywords,
|
219 |
+
'post_types' => $post_types,
|
220 |
+
'mode' => $mode,
|
221 |
+
'align' => $align,
|
222 |
+
'render_template' => $render_template,
|
223 |
+
'render_callback' => $render_callback,
|
224 |
+
'enqueue_style' => $enqueue_style,
|
225 |
+
'enqueue_script' => $enqueue_script,
|
226 |
+
'enqueue_assets' => $enqueue_assets
|
227 |
+
);
|
228 |
+
|
229 |
+
// Align
|
230 |
+
if($align == 'none')
|
231 |
+
$register_args['align'] = '';
|
232 |
+
|
233 |
+
// Icon
|
234 |
+
$icon_type = get_field('icon_type', $post_id);
|
235 |
+
|
236 |
+
// Icon: Simple
|
237 |
+
if($icon_type == 'simple'){
|
238 |
+
|
239 |
+
$icon_text = get_field('icon_text', $post_id);
|
240 |
+
|
241 |
+
$register_args['icon'] = $icon_text;
|
242 |
+
|
243 |
+
}
|
244 |
+
|
245 |
+
// Icon: Colors
|
246 |
+
elseif($icon_type == 'colors'){
|
247 |
+
|
248 |
+
$icon_background = get_field('icon_background', $post_id);
|
249 |
+
$icon_foreground = get_field('icon_foreground', $post_id);
|
250 |
+
$icon_src = get_field('icon_src', $post_id);
|
251 |
+
|
252 |
+
$register_args['icon'] = array(
|
253 |
+
'background' => $icon_background,
|
254 |
+
'foreground' => $icon_foreground,
|
255 |
+
'src' => $icon_src,
|
256 |
+
);
|
257 |
+
|
258 |
+
|
259 |
+
}
|
260 |
+
|
261 |
+
// Supports: Align
|
262 |
+
$supports_align = get_field('supports_align', $post_id);
|
263 |
+
$supports_align_args = acf_decode_choices(get_field('supports_align_args', $post_id), true);
|
264 |
+
|
265 |
+
$register_args['supports']['align'] = false;
|
266 |
+
if(!empty($supports_align)){
|
267 |
+
|
268 |
+
$register_args['supports']['align'] = true;
|
269 |
+
|
270 |
+
if(!empty($supports_align_args))
|
271 |
+
$register_args['supports']['align'] = $supports_align_args;
|
272 |
+
|
273 |
+
}
|
274 |
+
|
275 |
+
// Supports: Mode
|
276 |
+
$supports_mode = get_field('supports_mode', $post_id);
|
277 |
+
|
278 |
+
$register_args['supports']['mode'] = false;
|
279 |
+
if(!empty($supports_mode))
|
280 |
+
$register_args['supports']['mode'] = true;
|
281 |
+
|
282 |
+
// Supports: Multiple
|
283 |
+
$supports_multiple = get_field('supports_multiple', $post_id);
|
284 |
+
|
285 |
+
$register_args['supports']['multiple'] = false;
|
286 |
+
if(!empty($supports_multiple))
|
287 |
+
$register_args['supports']['multiple'] = true;
|
288 |
+
|
289 |
+
|
290 |
+
// Get ACFE option
|
291 |
+
$option = get_option('acfe_dynamic_block_types', array());
|
292 |
+
|
293 |
+
// Create ACFE option
|
294 |
+
$option[$name] = $register_args;
|
295 |
+
|
296 |
+
// Sort keys ASC
|
297 |
+
ksort($option);
|
298 |
+
|
299 |
+
// Update ACFE option
|
300 |
+
update_option('acfe_dynamic_block_types', $option);
|
301 |
+
|
302 |
+
}
|
303 |
+
|
304 |
+
/**
|
305 |
+
* Dynamic Block Type Status Publish > Trash
|
306 |
+
*/
|
307 |
+
add_action('publish_to_trash', 'acfe_dbt_filter_status_trash');
|
308 |
+
function acfe_dbt_filter_status_trash($post){
|
309 |
+
|
310 |
+
if(get_post_type($post->ID) != 'acfe-dbt')
|
311 |
+
return;
|
312 |
+
|
313 |
+
$post_id = $post->ID;
|
314 |
+
$name = get_field('name', $post_id);
|
315 |
+
|
316 |
+
// Get ACFE option
|
317 |
+
$option = get_option('acfe_dynamic_block_types', array());
|
318 |
+
|
319 |
+
// Check ACFE option
|
320 |
+
if(isset($option[$name]))
|
321 |
+
unset($option[$name]);
|
322 |
+
|
323 |
+
// Update ACFE option
|
324 |
+
update_option('acfe_dynamic_block_types', $option);
|
325 |
+
|
326 |
+
}
|
327 |
+
|
328 |
+
/**
|
329 |
+
* Dynamic Block Type Status Trash > Publish
|
330 |
+
*/
|
331 |
+
add_action('trash_to_publish', 'acfe_dbt_filter_status_publish');
|
332 |
+
function acfe_dbt_filter_status_publish($post){
|
333 |
+
|
334 |
+
if(get_post_type($post->ID) != 'acfe-dbt')
|
335 |
+
return;
|
336 |
+
|
337 |
+
acfe_dop_filter_save($post->ID);
|
338 |
+
|
339 |
+
}
|
340 |
+
|
341 |
+
/**
|
342 |
+
* Dynamic Block Type Admin: List
|
343 |
+
*/
|
344 |
+
add_action('pre_get_posts', 'acfe_dbt_admin_pre_get_posts');
|
345 |
+
function acfe_dbt_admin_pre_get_posts($query){
|
346 |
+
|
347 |
+
if(!is_admin() || !$query->is_main_query())
|
348 |
+
return;
|
349 |
+
|
350 |
+
global $pagenow;
|
351 |
+
if($pagenow != 'edit.php')
|
352 |
+
return;
|
353 |
+
|
354 |
+
$post_type = $query->get('post_type');
|
355 |
+
if($post_type != 'acfe-dbt')
|
356 |
+
return;
|
357 |
+
|
358 |
+
$query->set('orderby', 'name');
|
359 |
+
$query->set('order', 'ASC');
|
360 |
+
|
361 |
+
}
|
362 |
+
|
363 |
+
/**
|
364 |
+
* Dynamic Block Type Admin: Posts Per Page
|
365 |
+
*/
|
366 |
+
add_filter('edit_posts_per_page', 'acfe_dbt_admin_ppp', 10, 2);
|
367 |
+
function acfe_dbt_admin_ppp($ppp, $post_type){
|
368 |
+
|
369 |
+
if($post_type != 'acfe-dbt')
|
370 |
+
return $ppp;
|
371 |
+
|
372 |
+
global $pagenow;
|
373 |
+
if($pagenow != 'edit.php')
|
374 |
+
return $ppp;
|
375 |
+
|
376 |
+
return 999;
|
377 |
+
|
378 |
+
}
|
379 |
+
|
380 |
+
/**
|
381 |
+
* Admin List Columns
|
382 |
+
*/
|
383 |
+
add_filter('manage_edit-acfe-dbt_columns', 'acfe_dbt_admin_columns');
|
384 |
+
function acfe_dbt_admin_columns($columns){
|
385 |
+
|
386 |
+
if(isset($columns['date']))
|
387 |
+
unset($columns['date']);
|
388 |
+
|
389 |
+
$columns['name'] = __('Name');
|
390 |
+
$columns['category'] = __('Category');
|
391 |
+
$columns['post_types'] = __('Post Types');
|
392 |
+
$columns['render'] = __('Render');
|
393 |
+
|
394 |
+
return $columns;
|
395 |
+
|
396 |
+
}
|
397 |
+
|
398 |
+
/**
|
399 |
+
* Admin List Columns HTML
|
400 |
+
*/
|
401 |
+
add_action('manage_acfe-dbt_posts_custom_column', 'acfe_dbt_admin_columns_html', 10, 2);
|
402 |
+
function acfe_dbt_admin_columns_html($column, $post_id){
|
403 |
+
|
404 |
+
// Name
|
405 |
+
if($column == 'name'){
|
406 |
+
|
407 |
+
echo '<code style="-webkit-user-select: all;-moz-user-select: all;-ms-user-select: all;user-select: all;font-size: 12px;">' . get_field('name', $post_id) . '</code>';
|
408 |
+
|
409 |
+
}
|
410 |
+
|
411 |
+
// Category
|
412 |
+
elseif($column == 'category'){
|
413 |
+
|
414 |
+
echo ucfirst(get_field('category', $post_id));
|
415 |
+
|
416 |
+
}
|
417 |
+
|
418 |
+
// Post Types
|
419 |
+
elseif($column == 'post_types'){
|
420 |
+
|
421 |
+
$post_types = get_field('post_types', $post_id);
|
422 |
+
|
423 |
+
if(empty($post_types)){
|
424 |
+
echo '—';
|
425 |
+
return;
|
426 |
+
}
|
427 |
+
|
428 |
+
$post_types_names = array();
|
429 |
+
foreach($post_types as $post_type_slug){
|
430 |
+
$post_type_obj = get_post_type_object($post_type_slug);
|
431 |
+
$post_types_names[] = $post_type_obj->label;
|
432 |
+
}
|
433 |
+
|
434 |
+
if(empty($post_types_names)){
|
435 |
+
echo '—';
|
436 |
+
return;
|
437 |
+
}
|
438 |
+
|
439 |
+
echo implode(', ', $post_types_names);
|
440 |
+
|
441 |
+
}
|
442 |
+
|
443 |
+
// Render
|
444 |
+
elseif($column == 'render'){
|
445 |
+
|
446 |
+
$render_template = get_field('render_template', $post_id);
|
447 |
+
$render_callback = get_field('render_callback', $post_id);
|
448 |
+
|
449 |
+
if(!empty($render_template)){
|
450 |
+
|
451 |
+
echo '<code style="-webkit-user-select: all;-moz-user-select: all;-ms-user-select: all;user-select: all;font-size: 12px;">/' . $render_template . '</code>';
|
452 |
+
|
453 |
+
}
|
454 |
+
|
455 |
+
elseif(!empty($render_callback)){
|
456 |
+
|
457 |
+
echo '<code style="-webkit-user-select: all;-moz-user-select: all;-ms-user-select: all;user-select: all;font-size: 12px;">' . $render_callback . '</code>';
|
458 |
+
|
459 |
+
}
|
460 |
+
|
461 |
+
else{
|
462 |
+
|
463 |
+
echo '—';
|
464 |
+
|
465 |
+
}
|
466 |
+
|
467 |
+
}
|
468 |
+
|
469 |
+
}
|
470 |
+
|
471 |
+
/**
|
472 |
+
* Admin List Row Actions
|
473 |
+
*/
|
474 |
+
add_filter('post_row_actions','acfe_dbt_admin_row', 10, 2);
|
475 |
+
function acfe_dbt_admin_row($actions, $post){
|
476 |
+
|
477 |
+
if($post->post_type !== 'acfe-dbt' || $post->post_status !== 'publish')
|
478 |
+
return $actions;
|
479 |
+
|
480 |
+
$post_id = $post->ID;
|
481 |
+
$name = get_field('name', $post_id);
|
482 |
+
|
483 |
+
$actions['acfe_dpt_export_php'] = '<a href="' . admin_url('edit.php?post_type=acf-field-group&page=acf-tools&tool=acfe_tool_dbt_export&action=php&keys=' . $name) . '">' . __('PHP') . '</a>';
|
484 |
+
$actions['acfe_dpt_export_json'] = '<a href="' . admin_url('edit.php?post_type=acf-field-group&page=acf-tools&tool=acfe_tool_dbt_export&action=json&keys=' . $name) . '">' . __('Json') . '</a>';
|
485 |
+
|
486 |
+
return $actions;
|
487 |
+
|
488 |
+
}
|
489 |
+
|
490 |
+
/**
|
491 |
+
* Admin Disable Name
|
492 |
+
*/
|
493 |
+
add_filter('acf/prepare_field/key=field_acfe_dbt_name', 'acfe_dbt_admin_disable_name');
|
494 |
+
function acfe_dbt_admin_disable_name($field){
|
495 |
+
|
496 |
+
global $pagenow;
|
497 |
+
if($pagenow !== 'post.php')
|
498 |
+
return $field;
|
499 |
+
|
500 |
+
$field['disabled'] = true;
|
501 |
+
|
502 |
+
return $field;
|
503 |
+
|
504 |
+
}
|
505 |
+
|
506 |
+
add_action('load-post.php', 'acfe_dbt_load');
|
507 |
+
function acfe_dbt_load(){
|
508 |
+
|
509 |
+
// globals
|
510 |
+
global $typenow;
|
511 |
+
|
512 |
+
// Restrict
|
513 |
+
if($typenow !== 'acfe-dbt')
|
514 |
+
return;
|
515 |
+
|
516 |
+
add_action('add_meta_boxes', 'acfe_dbt_load_meta_boxes');
|
517 |
+
|
518 |
+
}
|
519 |
+
|
520 |
+
function acfe_dbt_load_meta_boxes(){
|
521 |
+
|
522 |
+
$name = get_field('name', get_the_ID());
|
523 |
+
|
524 |
+
$data = acf_get_field_groups(array(
|
525 |
+
'block' => 'acf/' . $name
|
526 |
+
));
|
527 |
+
|
528 |
+
if(empty($data))
|
529 |
+
return;
|
530 |
+
|
531 |
+
add_meta_box(
|
532 |
+
|
533 |
+
// ID
|
534 |
+
'acfe-dbt-field-groups',
|
535 |
+
|
536 |
+
// Title
|
537 |
+
__('Field groups', 'acf'),
|
538 |
+
|
539 |
+
// Render
|
540 |
+
'acfe_dbt_load_meta_boxes_render',
|
541 |
+
|
542 |
+
// Screen
|
543 |
+
'acfe-dbt',
|
544 |
+
|
545 |
+
// Position
|
546 |
+
'normal',
|
547 |
+
|
548 |
+
// Priority
|
549 |
+
'default',
|
550 |
+
|
551 |
+
// Data
|
552 |
+
$data
|
553 |
+
|
554 |
+
);
|
555 |
+
|
556 |
+
}
|
557 |
+
|
558 |
+
function acfe_dbt_load_meta_boxes_render($array, $data){
|
559 |
+
|
560 |
+
$data = $data['args'];
|
561 |
+
|
562 |
+
foreach($data as $field_group){ ?>
|
563 |
+
|
564 |
+
<div class="acf-field">
|
565 |
+
|
566 |
+
<div class="acf-label">
|
567 |
+
<label for="acf-_post_title"><a href="<?php echo admin_url('post.php?post=' . $field_group['ID'] . '&action=edit'); ?>"><?php echo $field_group['title']; ?></a></label>
|
568 |
+
<p class="description"><?php echo $field_group['key']; ?></p>
|
569 |
+
</div>
|
570 |
+
|
571 |
+
<div class="acf-input">
|
572 |
+
<?php $fields = acf_get_fields($field_group); ?>
|
573 |
+
|
574 |
+
<?php if(!empty($fields)){ ?>
|
575 |
+
|
576 |
+
<table class="acf-table">
|
577 |
+
<thead>
|
578 |
+
<th class="acf-th" width="25%"><strong>Label</strong></th>
|
579 |
+
<th class="acf-th" width="25%"><strong>Name</strong></th>
|
580 |
+
<th class="acf-th" width="25%"><strong>Key</strong></th>
|
581 |
+
<th class="acf-th" width="25%"><strong>Type</strong></th>
|
582 |
+
</thead>
|
583 |
+
|
584 |
+
<tbody>
|
585 |
+
<?php
|
586 |
+
|
587 |
+
$array = array();
|
588 |
+
foreach($fields as $field){
|
589 |
+
|
590 |
+
acfe_dbt_get_fields_labels_recursive($array, $field);
|
591 |
+
|
592 |
+
}
|
593 |
+
|
594 |
+
foreach($array as $field_key => $field_label){
|
595 |
+
|
596 |
+
$field = acf_get_field($field_key);
|
597 |
+
$type = acf_get_field_type($field['type']);
|
598 |
+
$type_label = '-';
|
599 |
+
if(isset($type->label))
|
600 |
+
$type_label = $type->label;
|
601 |
+
?>
|
602 |
+
|
603 |
+
<tr class="acf-row">
|
604 |
+
<td width="25%"><?php echo $field_label; ?></td>
|
605 |
+
<td width="25%"><?php echo $field['name']; ?></td>
|
606 |
+
<td width="25%"><code><?php echo $field_key; ?></code></td>
|
607 |
+
<td width="25%"><?php echo $type_label; ?></td>
|
608 |
+
</tr>
|
609 |
+
|
610 |
+
<?php } ?>
|
611 |
+
</tbody>
|
612 |
+
</table>
|
613 |
+
|
614 |
+
<?php } ?>
|
615 |
+
</div>
|
616 |
+
|
617 |
+
</div>
|
618 |
+
|
619 |
+
<?php } ?>
|
620 |
+
|
621 |
+
<script type="text/javascript">
|
622 |
+
if(typeof acf !== 'undefined'){
|
623 |
+
|
624 |
+
acf.newPostbox(<?php echo wp_json_encode(array(
|
625 |
+
'id' => 'acfe-dbt-field-groups',
|
626 |
+
'key' => '',
|
627 |
+
'style' => 'default',
|
628 |
+
'label' => 'left',
|
629 |
+
'edit' => false
|
630 |
+
)); ?>);
|
631 |
+
|
632 |
+
}
|
633 |
+
</script>
|
634 |
+
<?php
|
635 |
+
|
636 |
+
}
|
637 |
+
|
638 |
+
function acfe_dbt_get_fields_labels_recursive(&$array, $field){
|
639 |
+
|
640 |
+
$label = '';
|
641 |
+
|
642 |
+
$ancestors = isset($field['ancestors']) ? $field['ancestors'] : count(acf_get_field_ancestors($field));
|
643 |
+
$label = str_repeat('- ', $ancestors) . $label;
|
644 |
+
|
645 |
+
$label .= !empty($field['label']) ? $field['label'] : '(' . __('no label', 'acf') . ')';
|
646 |
+
$label .= $field['required'] ? ' <span class="acf-required">*</span>' : '';
|
647 |
+
|
648 |
+
$array[$field['key']] = $label;
|
649 |
+
|
650 |
+
if(isset($field['sub_fields']) && !empty($field['sub_fields'])){
|
651 |
+
|
652 |
+
foreach($field['sub_fields'] as $s_field){
|
653 |
+
|
654 |
+
acfe_dbt_get_fields_labels_recursive($array, $s_field);
|
655 |
+
|
656 |
+
}
|
657 |
+
|
658 |
+
}
|
659 |
+
|
660 |
+
}
|
661 |
+
|
662 |
+
/**
|
663 |
+
* Add Local Field Group
|
664 |
+
*/
|
665 |
+
acf_add_local_field_group(array(
|
666 |
+
'key' => 'group_acfe_dynamic_block_type',
|
667 |
+
'title' => __('Dynamic Block Type', 'acfe'),
|
668 |
+
|
669 |
+
'location' => array(
|
670 |
+
array(
|
671 |
+
array(
|
672 |
+
'param' => 'post_type',
|
673 |
+
'operator' => '==',
|
674 |
+
'value' => 'acfe-dbt',
|
675 |
+
),
|
676 |
+
),
|
677 |
+
),
|
678 |
+
|
679 |
+
'menu_order' => 0,
|
680 |
+
'position' => 'normal',
|
681 |
+
'style' => 'default',
|
682 |
+
'label_placement' => 'left',
|
683 |
+
'instruction_placement' => 'label',
|
684 |
+
'hide_on_screen' => '',
|
685 |
+
'active' => 1,
|
686 |
+
'description' => '',
|
687 |
+
|
688 |
+
'fields' => array(
|
689 |
+
array(
|
690 |
+
'key' => 'field_acfe_dbt_tab_general',
|
691 |
+
'label' => 'General',
|
692 |
+
'name' => '',
|
693 |
+
'type' => 'tab',
|
694 |
+
'instructions' => '',
|
695 |
+
'required' => 0,
|
696 |
+
'conditional_logic' => 0,
|
697 |
+
'wrapper' => array(
|
698 |
+
'width' => '',
|
699 |
+
'class' => '',
|
700 |
+
'id' => '',
|
701 |
+
),
|
702 |
+
'acfe_validate' => '',
|
703 |
+
'acfe_update' => '',
|
704 |
+
'acfe_permissions' => '',
|
705 |
+
'placement' => 'top',
|
706 |
+
'endpoint' => 0,
|
707 |
+
),
|
708 |
+
array(
|
709 |
+
'key' => 'field_acfe_dbt_title',
|
710 |
+
'label' => 'Title',
|
711 |
+
'name' => 'title',
|
712 |
+
'type' => 'text',
|
713 |
+
'instructions' => '(String) The display title for your block.',
|
714 |
+
'required' => 1,
|
715 |
+
'conditional_logic' => 0,
|
716 |
+
'wrapper' => array(
|
717 |
+
'width' => '',
|
718 |
+
'class' => '',
|
719 |
+
'id' => '',
|
720 |
+
),
|
721 |
+
'acfe_validate' => '',
|
722 |
+
'acfe_update' => '',
|
723 |
+
'acfe_permissions' => '',
|
724 |
+
'default_value' => '',
|
725 |
+
'placeholder' => '',
|
726 |
+
'prepend' => '',
|
727 |
+
'append' => '',
|
728 |
+
'maxlength' => '',
|
729 |
+
),
|
730 |
+
array(
|
731 |
+
'key' => 'field_acfe_dbt_name',
|
732 |
+
'label' => 'Name',
|
733 |
+
'name' => 'name',
|
734 |
+
'type' => 'acfe_slug',
|
735 |
+
'instructions' => '(String) A unique name that identifies the block (without namespace).<br />
|
736 |
+
Note: A block name can only contain lowercase alphanumeric characters and dashes, and must begin with a letter.',
|
737 |
+
'required' => 1,
|
738 |
+
'conditional_logic' => 0,
|
739 |
+
'wrapper' => array(
|
740 |
+
'width' => '',
|
741 |
+
'class' => '',
|
742 |
+
'id' => '',
|
743 |
+
),
|
744 |
+
'acfe_validate' => '',
|
745 |
+
'acfe_update' => array(
|
746 |
+
'5cd2ca4caa18b' => array(
|
747 |
+
'acfe_update_function' => 'sanitize_title',
|
748 |
+
),
|
749 |
+
),
|
750 |
+
'acfe_permissions' => '',
|
751 |
+
'default_value' => '',
|
752 |
+
'placeholder' => '',
|
753 |
+
'prepend' => '',
|
754 |
+
'append' => '',
|
755 |
+
'maxlength' => '',
|
756 |
+
),
|
757 |
+
array(
|
758 |
+
'key' => 'field_acfe_dbt_description',
|
759 |
+
'label' => 'Description',
|
760 |
+
'name' => 'description',
|
761 |
+
'type' => 'textarea',
|
762 |
+
'instructions' => '(String) (Optional) This is a short description for your block.',
|
763 |
+
'required' => 0,
|
764 |
+
'conditional_logic' => 0,
|
765 |
+
'wrapper' => array(
|
766 |
+
'width' => '',
|
767 |
+
'class' => '',
|
768 |
+
'id' => '',
|
769 |
+
),
|
770 |
+
'acfe_validate' => '',
|
771 |
+
'acfe_update' => '',
|
772 |
+
'acfe_permissions' => '',
|
773 |
+
'default_value' => '',
|
774 |
+
'placeholder' => '',
|
775 |
+
'maxlength' => '',
|
776 |
+
'rows' => 3,
|
777 |
+
'new_lines' => '',
|
778 |
+
),
|
779 |
+
array(
|
780 |
+
'key' => 'field_acfe_dbt_category',
|
781 |
+
'label' => 'Category',
|
782 |
+
'name' => 'category',
|
783 |
+
'type' => 'text',
|
784 |
+
'instructions' => '(String) Blocks are grouped into categories to help users browse and discover them. The core provided categories are [ common | formatting | layout | widgets | embed ]. Plugins and Themes can also register custom block categories.',
|
785 |
+
'required' => 0,
|
786 |
+
'conditional_logic' => 0,
|
787 |
+
'wrapper' => array(
|
788 |
+
'width' => '',
|
789 |
+
'class' => '',
|
790 |
+
'id' => '',
|
791 |
+
),
|
792 |
+
'acfe_validate' => '',
|
793 |
+
'acfe_update' => '',
|
794 |
+
'acfe_permissions' => '',
|
795 |
+
'default_value' => 'common',
|
796 |
+
'placeholder' => '',
|
797 |
+
'prepend' => '',
|
798 |
+
'append' => '',
|
799 |
+
'maxlength' => '',
|
800 |
+
),
|
801 |
+
array(
|
802 |
+
'key' => 'field_acfe_dbt_keywords',
|
803 |
+
'label' => 'Keywords',
|
804 |
+
'name' => 'keywords',
|
805 |
+
'type' => 'textarea',
|
806 |
+
'instructions' => '(Array) (Optional) An array of search terms to help user discover the block while searching.<br />
|
807 |
+
One line for each keyword. ie:<br /><br />
|
808 |
+
quote<br />
|
809 |
+
mention<br />
|
810 |
+
cite',
|
811 |
+
'required' => 0,
|
812 |
+
'conditional_logic' => 0,
|
813 |
+
'wrapper' => array(
|
814 |
+
'width' => '',
|
815 |
+
'class' => '',
|
816 |
+
'id' => '',
|
817 |
+
),
|
818 |
+
'acfe_validate' => '',
|
819 |
+
'acfe_update' => '',
|
820 |
+
'acfe_permissions' => '',
|
821 |
+
'default_value' => '',
|
822 |
+
'placeholder' => '',
|
823 |
+
'maxlength' => '',
|
824 |
+
'rows' => '',
|
825 |
+
'new_lines' => '',
|
826 |
+
),
|
827 |
+
array(
|
828 |
+
'key' => 'field_acfe_dbt_post_types',
|
829 |
+
'label' => 'Post types',
|
830 |
+
'name' => 'post_types',
|
831 |
+
'type' => 'acfe_post_types',
|
832 |
+
'instructions' => '(Array) (Optional) An array of post types to restrict this block type to.',
|
833 |
+
'required' => 0,
|
834 |
+
'conditional_logic' => 0,
|
835 |
+
'wrapper' => array(
|
836 |
+
'width' => '',
|
837 |
+
'class' => '',
|
838 |
+
'id' => '',
|
839 |
+
),
|
840 |
+
'acfe_validate' => '',
|
841 |
+
'acfe_update' => '',
|
842 |
+
'acfe_permissions' => '',
|
843 |
+
'field_type' => 'checkbox',
|
844 |
+
'return_format' => 'name',
|
845 |
+
),
|
846 |
+
array(
|
847 |
+
'key' => 'field_acfe_dbt_mode',
|
848 |
+
'label' => 'Mode',
|
849 |
+
'name' => 'mode',
|
850 |
+
'type' => 'select',
|
851 |
+
'instructions' => '(String) (Optional) The display mode for your block. Available settings are “auto”, “preview” and “edit”. Defaults to “auto”.<br /><br />
|
852 |
+
auto: Preview is shown by default but changes to edit form when block is selected.<br />
|
853 |
+
preview: Preview is always shown. Edit form appears in sidebar when block is selected.<br />
|
854 |
+
edit: Edit form is always shown.<br /><br />
|
855 |
+
|
856 |
+
Note. When in “preview” or “edit” modes, an icon will appear in the block toolbar to toggle between modes.',
|
857 |
+
'required' => 0,
|
858 |
+
'conditional_logic' => 0,
|
859 |
+
'wrapper' => array(
|
860 |
+
'width' => '',
|
861 |
+
'class' => '',
|
862 |
+
'id' => '',
|
863 |
+
),
|
864 |
+
'acfe_validate' => '',
|
865 |
+
'acfe_update' => '',
|
866 |
+
'acfe_permissions' => '',
|
867 |
+
'choices' => array(
|
868 |
+
'auto' => 'Auto',
|
869 |
+
'preview' => 'Preview',
|
870 |
+
'edit' => 'Edit',
|
871 |
+
),
|
872 |
+
'default_value' => array(
|
873 |
+
0 => 'auto',
|
874 |
+
),
|
875 |
+
'allow_null' => 0,
|
876 |
+
'multiple' => 0,
|
877 |
+
'ui' => 0,
|
878 |
+
'return_format' => 'value',
|
879 |
+
'ajax' => 0,
|
880 |
+
'placeholder' => '',
|
881 |
+
),
|
882 |
+
array(
|
883 |
+
'key' => 'field_acfe_dbt_align',
|
884 |
+
'label' => 'Align',
|
885 |
+
'name' => 'align',
|
886 |
+
'type' => 'select',
|
887 |
+
'instructions' => '(String) (Optional) The default block alignment. Available settings are “left”, “center”, “right”, “wide” and “full”. Defaults to an empty string.',
|
888 |
+
'required' => 0,
|
889 |
+
'conditional_logic' => 0,
|
890 |
+
'wrapper' => array(
|
891 |
+
'width' => '',
|
892 |
+
'class' => '',
|
893 |
+
'id' => '',
|
894 |
+
),
|
895 |
+
'acfe_validate' => '',
|
896 |
+
'acfe_update' => '',
|
897 |
+
'acfe_permissions' => '',
|
898 |
+
'choices' => array(
|
899 |
+
'none' => 'None',
|
900 |
+
'left' => 'Left',
|
901 |
+
'center' => 'Center',
|
902 |
+
'right' => 'Right',
|
903 |
+
'wide' => 'Wide',
|
904 |
+
'full' => 'Full',
|
905 |
+
),
|
906 |
+
'default_value' => array(
|
907 |
+
),
|
908 |
+
'allow_null' => 0,
|
909 |
+
'multiple' => 0,
|
910 |
+
'ui' => 0,
|
911 |
+
'return_format' => 'value',
|
912 |
+
'ajax' => 0,
|
913 |
+
'placeholder' => '',
|
914 |
+
),
|
915 |
+
array(
|
916 |
+
'key' => 'field_acfe_dbt_tab_icon',
|
917 |
+
'label' => 'Icon',
|
918 |
+
'name' => '',
|
919 |
+
'type' => 'tab',
|
920 |
+
'instructions' => '',
|
921 |
+
'required' => 0,
|
922 |
+
'conditional_logic' => 0,
|
923 |
+
'wrapper' => array(
|
924 |
+
'width' => '',
|
925 |
+
'class' => '',
|
926 |
+
'id' => '',
|
927 |
+
),
|
928 |
+
'acfe_validate' => '',
|
929 |
+
'acfe_update' => '',
|
930 |
+
'acfe_permissions' => '',
|
931 |
+
'placement' => 'top',
|
932 |
+
'endpoint' => 0,
|
933 |
+
),
|
934 |
+
array(
|
935 |
+
'key' => 'field_acfe_dbt_icon_type',
|
936 |
+
'label' => 'Icon Type',
|
937 |
+
'name' => 'icon_type',
|
938 |
+
'type' => 'select',
|
939 |
+
'instructions' => 'Simple: Specify a Dashicons class or SVG path<br />
|
940 |
+
Colors: Specify colors & Dashicons class',
|
941 |
+
'required' => 0,
|
942 |
+
'conditional_logic' => 0,
|
943 |
+
'wrapper' => array(
|
944 |
+
'width' => '',
|
945 |
+
'class' => '',
|
946 |
+
'id' => '',
|
947 |
+
),
|
948 |
+
'acfe_validate' => '',
|
949 |
+
'acfe_update' => '',
|
950 |
+
'acfe_permissions' => '',
|
951 |
+
'choices' => array(
|
952 |
+
'simple' => 'Simple',
|
953 |
+
'colors' => 'Colors',
|
954 |
+
),
|
955 |
+
'default_value' => array(
|
956 |
+
),
|
957 |
+
'allow_null' => 0,
|
958 |
+
'multiple' => 0,
|
959 |
+
'ui' => 0,
|
960 |
+
'return_format' => 'value',
|
961 |
+
'ajax' => 0,
|
962 |
+
'placeholder' => '',
|
963 |
+
),
|
964 |
+
array(
|
965 |
+
'key' => 'field_acfe_dbt_icon_text',
|
966 |
+
'label' => 'Icon',
|
967 |
+
'name' => 'icon_text',
|
968 |
+
'type' => 'text',
|
969 |
+
'instructions' => '(String) (Optional) An icon property can be specified to make it easier to identify a block. These can be any of WordPress’ Dashicons, or a custom svg element.',
|
970 |
+
'required' => 0,
|
971 |
+
'conditional_logic' => array(
|
972 |
+
array(
|
973 |
+
array(
|
974 |
+
'field' => 'field_acfe_dbt_icon_type',
|
975 |
+
'operator' => '==',
|
976 |
+
'value' => 'simple',
|
977 |
+
),
|
978 |
+
),
|
979 |
+
),
|
980 |
+
'wrapper' => array(
|
981 |
+
'width' => '',
|
982 |
+
'class' => '',
|
983 |
+
'id' => '',
|
984 |
+
),
|
985 |
+
'acfe_validate' => '',
|
986 |
+
'acfe_update' => '',
|
987 |
+
'acfe_permissions' => '',
|
988 |
+
'default_value' => '',
|
989 |
+
'placeholder' => '',
|
990 |
+
'prepend' => '',
|
991 |
+
'append' => '',
|
992 |
+
'maxlength' => '',
|
993 |
+
),
|
994 |
+
array(
|
995 |
+
'key' => 'field_acfe_dbt_icon_background',
|
996 |
+
'label' => 'Icon background',
|
997 |
+
'name' => 'icon_background',
|
998 |
+
'type' => 'color_picker',
|
999 |
+
'instructions' => 'Specifying a background color to appear with the icon e.g.: in the inserter.',
|
1000 |
+
'required' => 0,
|
1001 |
+
'conditional_logic' => array(
|
1002 |
+
array(
|
1003 |
+
array(
|
1004 |
+
'field' => 'field_acfe_dbt_icon_type',
|
1005 |
+
'operator' => '==',
|
1006 |
+
'value' => 'colors',
|
1007 |
+
),
|
1008 |
+
),
|
1009 |
+
),
|
1010 |
+
'wrapper' => array(
|
1011 |
+
'width' => '',
|
1012 |
+
'class' => '',
|
1013 |
+
'id' => '',
|
1014 |
+
),
|
1015 |
+
'acfe_validate' => '',
|
1016 |
+
'acfe_update' => '',
|
1017 |
+
'acfe_permissions' => '',
|
1018 |
+
'default_value' => '',
|
1019 |
+
),
|
1020 |
+
array(
|
1021 |
+
'key' => 'field_acfe_dbt_icon_foreground',
|
1022 |
+
'label' => 'Icon foreground',
|
1023 |
+
'name' => 'icon_foreground',
|
1024 |
+
'type' => 'color_picker',
|
1025 |
+
'instructions' => 'Specifying a color for the icon (optional: if not set, a readable color will be automatically defined)',
|
1026 |
+
'required' => 0,
|
1027 |
+
'conditional_logic' => array(
|
1028 |
+
array(
|
1029 |
+
array(
|
1030 |
+
'field' => 'field_acfe_dbt_icon_type',
|
1031 |
+
'operator' => '==',
|
1032 |
+
'value' => 'colors',
|
1033 |
+
),
|
1034 |
+
),
|
1035 |
+
),
|
1036 |
+
'wrapper' => array(
|
1037 |
+
'width' => '',
|
1038 |
+
'class' => '',
|
1039 |
+
'id' => '',
|
1040 |
+
),
|
1041 |
+
'acfe_validate' => '',
|
1042 |
+
'acfe_update' => '',
|
1043 |
+
'acfe_permissions' => '',
|
1044 |
+
'default_value' => '',
|
1045 |
+
),
|
1046 |
+
array(
|
1047 |
+
'key' => 'field_acfe_dbt_icon_src',
|
1048 |
+
'label' => 'Icon src',
|
1049 |
+
'name' => 'icon_src',
|
1050 |
+
'type' => 'text',
|
1051 |
+
'instructions' => 'Specifying a dashicon for the block',
|
1052 |
+
'required' => 0,
|
1053 |
+
'conditional_logic' => array(
|
1054 |
+
array(
|
1055 |
+
array(
|
1056 |
+
'field' => 'field_acfe_dbt_icon_type',
|
1057 |
+
'operator' => '==',
|
1058 |
+
'value' => 'colors',
|
1059 |
+
),
|
1060 |
+
),
|
1061 |
+
),
|
1062 |
+
'wrapper' => array(
|
1063 |
+
'width' => '',
|
1064 |
+
'class' => '',
|
1065 |
+
'id' => '',
|
1066 |
+
),
|
1067 |
+
'acfe_validate' => '',
|
1068 |
+
'acfe_update' => '',
|
1069 |
+
'acfe_permissions' => '',
|
1070 |
+
'default_value' => '',
|
1071 |
+
'placeholder' => '',
|
1072 |
+
'prepend' => '',
|
1073 |
+
'append' => '',
|
1074 |
+
'maxlength' => '',
|
1075 |
+
),
|
1076 |
+
array(
|
1077 |
+
'key' => 'field_acfe_dbt_tab_render',
|
1078 |
+
'label' => 'Render',
|
1079 |
+
'name' => '',
|
1080 |
+
'type' => 'tab',
|
1081 |
+
'instructions' => '',
|
1082 |
+
'required' => 0,
|
1083 |
+
'conditional_logic' => 0,
|
1084 |
+
'wrapper' => array(
|
1085 |
+
'width' => '',
|
1086 |
+
'class' => '',
|
1087 |
+
'id' => '',
|
1088 |
+
),
|
1089 |
+
'acfe_validate' => '',
|
1090 |
+
'acfe_update' => '',
|
1091 |
+
'acfe_permissions' => '',
|
1092 |
+
'placement' => 'top',
|
1093 |
+
'endpoint' => 0,
|
1094 |
+
),
|
1095 |
+
array(
|
1096 |
+
'key' => 'field_acfe_dbt_render_template',
|
1097 |
+
'label' => 'Render template',
|
1098 |
+
'name' => 'render_template',
|
1099 |
+
'type' => 'text',
|
1100 |
+
'instructions' => '(String) The path to a template file used to render the block HTML. This can either be a relative path to a file within the active theme or a full path to any file.',
|
1101 |
+
'required' => 0,
|
1102 |
+
'conditional_logic' => 0,
|
1103 |
+
'wrapper' => array(
|
1104 |
+
'width' => '',
|
1105 |
+
'class' => '',
|
1106 |
+
'id' => '',
|
1107 |
+
),
|
1108 |
+
'acfe_validate' => '',
|
1109 |
+
'acfe_update' => '',
|
1110 |
+
'acfe_permissions' => '',
|
1111 |
+
'default_value' => '',
|
1112 |
+
'placeholder' => '',
|
1113 |
+
'prepend' => str_replace(home_url(), '', ACFE_THEME_URL) . '/',
|
1114 |
+
'append' => '',
|
1115 |
+
'maxlength' => '',
|
1116 |
+
),
|
1117 |
+
array(
|
1118 |
+
'key' => 'field_acfe_dbt_render_callback',
|
1119 |
+
'label' => 'Render callback',
|
1120 |
+
'name' => 'render_callback',
|
1121 |
+
'type' => 'text',
|
1122 |
+
'instructions' => '(Callable) (Optional) Instead of providing a render_template, a callback function name may be specified to output the block’s HTML.',
|
1123 |
+
'required' => 0,
|
1124 |
+
'conditional_logic' => 0,
|
1125 |
+
'wrapper' => array(
|
1126 |
+
'width' => '',
|
1127 |
+
'class' => '',
|
1128 |
+
'id' => '',
|
1129 |
+
),
|
1130 |
+
'acfe_validate' => '',
|
1131 |
+
'acfe_update' => '',
|
1132 |
+
'acfe_permissions' => '',
|
1133 |
+
'default_value' => '',
|
1134 |
+
'placeholder' => '',
|
1135 |
+
'prepend' => '',
|
1136 |
+
'append' => '',
|
1137 |
+
'maxlength' => '',
|
1138 |
+
),
|
1139 |
+
array(
|
1140 |
+
'key' => 'field_acfe_dbt_tab_enqueue',
|
1141 |
+
'label' => 'Enqueue',
|
1142 |
+
'name' => '',
|
1143 |
+
'type' => 'tab',
|
1144 |
+
'instructions' => '',
|
1145 |
+
'required' => 0,
|
1146 |
+
'conditional_logic' => 0,
|
1147 |
+
'wrapper' => array(
|
1148 |
+
'width' => '',
|
1149 |
+
'class' => '',
|
1150 |
+
'id' => '',
|
1151 |
+
),
|
1152 |
+
'acfe_validate' => '',
|
1153 |
+
'acfe_update' => '',
|
1154 |
+
'acfe_permissions' => '',
|
1155 |
+
'placement' => 'top',
|
1156 |
+
'endpoint' => 0,
|
1157 |
+
),
|
1158 |
+
array(
|
1159 |
+
'key' => 'field_acfe_dbt_enqueue_style',
|
1160 |
+
'label' => 'Enqueue style',
|
1161 |
+
'name' => 'enqueue_style',
|
1162 |
+
'type' => 'text',
|
1163 |
+
'instructions' => '(String) (Optional) The url to a .css file to be enqueued whenever your block is displayed (front-end and back-end).',
|
1164 |
+
'required' => 0,
|
1165 |
+
'conditional_logic' => 0,
|
1166 |
+
'wrapper' => array(
|
1167 |
+
'width' => '',
|
1168 |
+
'class' => '',
|
1169 |
+
'id' => '',
|
1170 |
+
),
|
1171 |
+
'acfe_validate' => '',
|
1172 |
+
'acfe_update' => '',
|
1173 |
+
'acfe_permissions' => '',
|
1174 |
+
'default_value' => '',
|
1175 |
+
'placeholder' => '',
|
1176 |
+
'prepend' => str_replace(home_url(), '', ACFE_THEME_URL) . '/',
|
1177 |
+
'append' => '',
|
1178 |
+
'maxlength' => '',
|
1179 |
+
),
|
1180 |
+
array(
|
1181 |
+
'key' => 'field_acfe_dbt_enqueue_script',
|
1182 |
+
'label' => 'Enqueue script',
|
1183 |
+
'name' => 'enqueue_script',
|
1184 |
+
'type' => 'text',
|
1185 |
+
'instructions' => '(String) (Optional) The url to a .js file to be enqueued whenever your block is displayed (front-end and back-end).',
|
1186 |
+
'required' => 0,
|
1187 |
+
'conditional_logic' => 0,
|
1188 |
+
'wrapper' => array(
|
1189 |
+
'width' => '',
|
1190 |
+
'class' => '',
|
1191 |
+
'id' => '',
|
1192 |
+
),
|
1193 |
+
'acfe_validate' => '',
|
1194 |
+
'acfe_update' => '',
|
1195 |
+
'acfe_permissions' => '',
|
1196 |
+
'default_value' => '',
|
1197 |
+
'placeholder' => '',
|
1198 |
+
'prepend' => str_replace(home_url(), '', ACFE_THEME_URL) . '/',
|
1199 |
+
'append' => '',
|
1200 |
+
'maxlength' => '',
|
1201 |
+
),
|
1202 |
+
array(
|
1203 |
+
'key' => 'field_acfe_dbt_enqueue_assets',
|
1204 |
+
'label' => 'Enqueue assets',
|
1205 |
+
'name' => 'enqueue_assets',
|
1206 |
+
'type' => 'text',
|
1207 |
+
'instructions' => '(Callable) (Optional) A callback function that runs whenever your block is displayed (front-end and back-end) and enqueues scripts and/or styles.',
|
1208 |
+
'required' => 0,
|
1209 |
+
'conditional_logic' => 0,
|
1210 |
+
'wrapper' => array(
|
1211 |
+
'width' => '',
|
1212 |
+
'class' => '',
|
1213 |
+
'id' => '',
|
1214 |
+
),
|
1215 |
+
'acfe_validate' => '',
|
1216 |
+
'acfe_update' => '',
|
1217 |
+
'acfe_permissions' => '',
|
1218 |
+
'default_value' => '',
|
1219 |
+
'placeholder' => '',
|
1220 |
+
'prepend' => '',
|
1221 |
+
'append' => '',
|
1222 |
+
'maxlength' => '',
|
1223 |
+
),
|
1224 |
+
array(
|
1225 |
+
'key' => 'field_acfe_dbt_tab_supports',
|
1226 |
+
'label' => 'Supports',
|
1227 |
+
'name' => '',
|
1228 |
+
'type' => 'tab',
|
1229 |
+
'instructions' => '',
|
1230 |
+
'required' => 0,
|
1231 |
+
'conditional_logic' => 0,
|
1232 |
+
'wrapper' => array(
|
1233 |
+
'width' => '',
|
1234 |
+
'class' => '',
|
1235 |
+
'id' => '',
|
1236 |
+
),
|
1237 |
+
'acfe_validate' => '',
|
1238 |
+
'acfe_update' => '',
|
1239 |
+
'acfe_permissions' => '',
|
1240 |
+
'placement' => 'top',
|
1241 |
+
'endpoint' => 0,
|
1242 |
+
),
|
1243 |
+
array(
|
1244 |
+
'key' => 'field_acfe_dbt_supports_align',
|
1245 |
+
'label' => 'Align',
|
1246 |
+
'name' => 'supports_align',
|
1247 |
+
'type' => 'true_false',
|
1248 |
+
'instructions' => 'This property adds block controls which allow the user to change the block’s alignment. Defaults to true. Set to false to hide the alignment toolbar. Set to an array of specific alignment names to customize the toolbar.',
|
1249 |
+
'required' => 0,
|
1250 |
+
'conditional_logic' => 0,
|
1251 |
+
'wrapper' => array(
|
1252 |
+
'width' => '',
|
1253 |
+
'class' => '',
|
1254 |
+
'id' => '',
|
1255 |
+
),
|
1256 |
+
'acfe_validate' => '',
|
1257 |
+
'acfe_update' => '',
|
1258 |
+
'acfe_permissions' => '',
|
1259 |
+
'message' => '',
|
1260 |
+
'default_value' => 1,
|
1261 |
+
'ui' => 1,
|
1262 |
+
'ui_on_text' => 'True',
|
1263 |
+
'ui_off_text' => 'False',
|
1264 |
+
),
|
1265 |
+
array(
|
1266 |
+
'key' => 'field_acfe_dbt_supports_align_args',
|
1267 |
+
'label' => 'Align arguments',
|
1268 |
+
'name' => 'supports_align_args',
|
1269 |
+
'type' => 'textarea',
|
1270 |
+
'instructions' => 'Set to an array of specific alignment names to customize the toolbar.<br />
|
1271 |
+
One line for each name. ie:<br /><br />
|
1272 |
+
left<br />
|
1273 |
+
right<br />
|
1274 |
+
full',
|
1275 |
+
'required' => 0,
|
1276 |
+
'conditional_logic' => array(
|
1277 |
+
array(
|
1278 |
+
array(
|
1279 |
+
'field' => 'field_acfe_dbt_supports_align',
|
1280 |
+
'operator' => '==',
|
1281 |
+
'value' => '1',
|
1282 |
+
),
|
1283 |
+
),
|
1284 |
+
),
|
1285 |
+
'wrapper' => array(
|
1286 |
+
'width' => '',
|
1287 |
+
'class' => '',
|
1288 |
+
'id' => '',
|
1289 |
+
),
|
1290 |
+
'acfe_validate' => '',
|
1291 |
+
'acfe_update' => '',
|
1292 |
+
'acfe_permissions' => '',
|
1293 |
+
'default_value' => '',
|
1294 |
+
'placeholder' => '',
|
1295 |
+
'maxlength' => '',
|
1296 |
+
'rows' => '',
|
1297 |
+
'new_lines' => '',
|
1298 |
+
),
|
1299 |
+
array(
|
1300 |
+
'key' => 'field_acfe_dbt_supports_mode',
|
1301 |
+
'label' => 'Mode',
|
1302 |
+
'name' => 'supports_mode',
|
1303 |
+
'type' => 'true_false',
|
1304 |
+
'instructions' => 'This property allows the user to toggle between edit and preview modes via a button. Defaults to true.',
|
1305 |
+
'required' => 0,
|
1306 |
+
'conditional_logic' => 0,
|
1307 |
+
'wrapper' => array(
|
1308 |
+
'width' => '',
|
1309 |
+
'class' => '',
|
1310 |
+
'id' => '',
|
1311 |
+
),
|
1312 |
+
'acfe_validate' => '',
|
1313 |
+
'acfe_update' => '',
|
1314 |
+
'acfe_permissions' => '',
|
1315 |
+
'message' => '',
|
1316 |
+
'default_value' => 1,
|
1317 |
+
'ui' => 1,
|
1318 |
+
'ui_on_text' => 'True',
|
1319 |
+
'ui_off_text' => 'False',
|
1320 |
+
),
|
1321 |
+
array(
|
1322 |
+
'key' => 'field_acfe_dbt_supports_multiple',
|
1323 |
+
'label' => 'Multiple',
|
1324 |
+
'name' => 'supports_multiple',
|
1325 |
+
'type' => 'true_false',
|
1326 |
+
'instructions' => 'This property allows the block to be added multiple times. Defaults to true.',
|
1327 |
+
'required' => 0,
|
1328 |
+
'conditional_logic' => 0,
|
1329 |
+
'wrapper' => array(
|
1330 |
+
'width' => '',
|
1331 |
+
'class' => '',
|
1332 |
+
'id' => '',
|
1333 |
+
),
|
1334 |
+
'acfe_validate' => '',
|
1335 |
+
'acfe_update' => '',
|
1336 |
+
'acfe_permissions' => '',
|
1337 |
+
'message' => '',
|
1338 |
+
'default_value' => 1,
|
1339 |
+
'ui' => 1,
|
1340 |
+
'ui_on_text' => 'True',
|
1341 |
+
'ui_off_text' => 'False',
|
1342 |
+
),
|
1343 |
+
),
|
1344 |
));
|
includes/modules/dynamic-options-page.php
CHANGED
@@ -1,805 +1,822 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
// Check setting
|
7 |
-
if(!acf_get_setting('acfe/modules/dynamic_options_pages'))
|
8 |
-
return;
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Register Dynamic Options Page
|
12 |
-
*/
|
13 |
-
add_action('init', 'acfe_dop_register');
|
14 |
-
function acfe_dop_register(){
|
15 |
-
|
16 |
-
register_post_type('acfe-dop', array(
|
17 |
-
'label' => 'Options Page',
|
18 |
-
'description' => 'Options Page',
|
19 |
-
'labels' => array(
|
20 |
-
'name' => 'Options Pages',
|
21 |
-
'singular_name' => 'Options Page',
|
22 |
-
'menu_name' => 'Options Pages',
|
23 |
-
'edit_item' => 'Edit Options Page',
|
24 |
-
'add_new_item' => 'New Options Page',
|
25 |
-
),
|
26 |
-
'supports' => false,
|
27 |
-
'hierarchical' => true,
|
28 |
-
'public' => false,
|
29 |
-
'show_ui' => true,
|
30 |
-
'show_in_menu' => false,
|
31 |
-
'menu_icon' => 'dashicons-layout',
|
32 |
-
'show_in_admin_bar' => false,
|
33 |
-
'show_in_nav_menus' => false,
|
34 |
-
'can_export' => false,
|
35 |
-
'has_archive' => false,
|
36 |
-
'rewrite' => false,
|
37 |
-
'exclude_from_search' => true,
|
38 |
-
'publicly_queryable' => false,
|
39 |
-
'capabilities' => array(
|
40 |
-
'publish_posts' => acf_get_setting('capability'),
|
41 |
-
'edit_posts' => acf_get_setting('capability'),
|
42 |
-
'edit_others_posts' => acf_get_setting('capability'),
|
43 |
-
'delete_posts' => acf_get_setting('capability'),
|
44 |
-
'delete_others_posts' => acf_get_setting('capability'),
|
45 |
-
'read_private_posts' => acf_get_setting('capability'),
|
46 |
-
'edit_post' => acf_get_setting('capability'),
|
47 |
-
'delete_post' => acf_get_setting('capability'),
|
48 |
-
'read_post' => acf_get_setting('capability'),
|
49 |
-
)
|
50 |
-
));
|
51 |
-
|
52 |
-
}
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Dynamic Options Page Menu
|
56 |
-
*/
|
57 |
-
add_action('admin_menu', 'acfe_dop_menu');
|
58 |
-
function acfe_dop_menu(){
|
59 |
-
|
60 |
-
if(!acf_get_setting('show_admin'))
|
61 |
-
return;
|
62 |
-
|
63 |
-
add_submenu_page('edit.php?post_type=acf-field-group', __('Options'), __('Options'), acf_get_setting('capability'), 'edit.php?post_type=acfe-dop');
|
64 |
-
|
65 |
-
}
|
66 |
-
|
67 |
-
/**
|
68 |
-
* Dynamic Options Page Menu: Parent Highlight
|
69 |
-
*/
|
70 |
-
add_filter('parent_file', 'acfe_dop_menu_parent_highlight');
|
71 |
-
function acfe_dop_menu_parent_highlight($parent_file){
|
72 |
-
|
73 |
-
global $pagenow;
|
74 |
-
if($pagenow != 'post.php' && $pagenow != 'post-new.php')
|
75 |
-
return $parent_file;
|
76 |
-
|
77 |
-
$post_type = get_post_type();
|
78 |
-
if($post_type != 'acfe-dop')
|
79 |
-
return $parent_file;
|
80 |
-
|
81 |
-
return 'edit.php?post_type=acf-field-group';
|
82 |
-
|
83 |
-
}
|
84 |
-
|
85 |
-
/**
|
86 |
-
* Dynamic Options Page Menu: Submenu Highlight
|
87 |
-
*/
|
88 |
-
add_filter('submenu_file', 'acfe_dop_menu_sub_highlight');
|
89 |
-
function acfe_dop_menu_sub_highlight($submenu_file){
|
90 |
-
|
91 |
-
global $pagenow;
|
92 |
-
if($pagenow != 'post-new.php')
|
93 |
-
return $submenu_file;
|
94 |
-
|
95 |
-
$post_type = get_post_type();
|
96 |
-
if($post_type != 'acfe-dop')
|
97 |
-
return $submenu_file;
|
98 |
-
|
99 |
-
return 'edit.php?post_type=acfe-dop';
|
100 |
-
|
101 |
-
}
|
102 |
-
|
103 |
-
|
104 |
-
/**
|
105 |
-
* ACF Register Options Pages
|
106 |
-
*/
|
107 |
-
add_action('init', 'acfe_dop_registers');
|
108 |
-
function acfe_dop_registers(){
|
109 |
-
|
110 |
-
$dynamic_options_pages = get_option('acfe_dynamic_options_pages', array());
|
111 |
-
if(empty($dynamic_options_pages))
|
112 |
-
return;
|
113 |
-
|
114 |
-
$options_sub_pages = array();
|
115 |
-
|
116 |
-
foreach($dynamic_options_pages as $name => $register_args){
|
117 |
-
|
118 |
-
// Do not register sub pages
|
119 |
-
if(isset($register_args['parent_slug']) && !empty($register_args['parent_slug'])){
|
120 |
-
|
121 |
-
$options_sub_pages[$name] = $register_args;
|
122 |
-
continue;
|
123 |
-
|
124 |
-
}
|
125 |
-
|
126 |
-
// Register: Execute
|
127 |
-
acf_add_options_page($register_args);
|
128 |
-
|
129 |
-
}
|
130 |
-
|
131 |
-
// Register sub pages
|
132 |
-
if(!empty($options_sub_pages)){
|
133 |
-
|
134 |
-
foreach($options_sub_pages as $name => $register_args){
|
135 |
-
|
136 |
-
// Register: Execute
|
137 |
-
acf_add_options_page($register_args);
|
138 |
-
|
139 |
-
}
|
140 |
-
|
141 |
-
}
|
142 |
-
|
143 |
-
}
|
144 |
-
|
145 |
-
/**
|
146 |
-
* ACF Exclude Dynamic Options Page from available post types
|
147 |
-
*/
|
148 |
-
add_filter('acf/get_post_types', 'acfe_dop_exclude', 10, 2);
|
149 |
-
function acfe_dop_exclude($post_types, $args){
|
150 |
-
|
151 |
-
if(empty($post_types))
|
152 |
-
return $post_types;
|
153 |
-
|
154 |
-
foreach($post_types as $k => $post_type){
|
155 |
-
|
156 |
-
if($post_type != 'acfe-dop')
|
157 |
-
continue;
|
158 |
-
|
159 |
-
unset($post_types[$k]);
|
160 |
-
|
161 |
-
}
|
162 |
-
|
163 |
-
return $post_types;
|
164 |
-
|
165 |
-
}
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
);
|
240 |
-
|
241 |
-
//
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
$
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
$
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
$
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
$
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
global $
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
'
|
500 |
-
'
|
501 |
-
|
502 |
-
'
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
'
|
524 |
-
'
|
525 |
-
'
|
526 |
-
|
527 |
-
|
528 |
-
'
|
529 |
-
'
|
530 |
-
'
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
'
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
'
|
541 |
-
'
|
542 |
-
'
|
543 |
-
|
544 |
-
|
545 |
-
'
|
546 |
-
'
|
547 |
-
'
|
548 |
-
|
549 |
-
|
550 |
-
'
|
551 |
-
'
|
552 |
-
'
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
'
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
'
|
563 |
-
'
|
564 |
-
'
|
565 |
-
|
566 |
-
|
567 |
-
'
|
568 |
-
'
|
569 |
-
'
|
570 |
-
|
571 |
-
|
572 |
-
'
|
573 |
-
'
|
574 |
-
'
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
'
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
'
|
585 |
-
'
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
'
|
591 |
-
'
|
592 |
-
'
|
593 |
-
'
|
594 |
-
'
|
595 |
-
'
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
'
|
602 |
-
'
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
'
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
'
|
613 |
-
|
614 |
-
|
615 |
-
'
|
616 |
-
'
|
617 |
-
'
|
618 |
-
'
|
619 |
-
'
|
620 |
-
|
621 |
-
|
622 |
-
'
|
623 |
-
'
|
624 |
-
'
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
'
|
631 |
-
'
|
632 |
-
'
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
'
|
640 |
-
'
|
641 |
-
'
|
642 |
-
'
|
643 |
-
'
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
'
|
648 |
-
'
|
649 |
-
'
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
'
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
'
|
660 |
-
'
|
661 |
-
'
|
662 |
-
|
663 |
-
|
664 |
-
'
|
665 |
-
'
|
666 |
-
'
|
667 |
-
|
668 |
-
|
669 |
-
'
|
670 |
-
'
|
671 |
-
'
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
'
|
677 |
-
'
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
'
|
683 |
-
'
|
684 |
-
|
685 |
-
|
686 |
-
'
|
687 |
-
'
|
688 |
-
'
|
689 |
-
'
|
690 |
-
|
691 |
-
|
692 |
-
'
|
693 |
-
'
|
694 |
-
'
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
'
|
700 |
-
'
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
'
|
706 |
-
'
|
707 |
-
|
708 |
-
|
709 |
-
'
|
710 |
-
'
|
711 |
-
'
|
712 |
-
'
|
713 |
-
|
714 |
-
|
715 |
-
'
|
716 |
-
'
|
717 |
-
'
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
'
|
723 |
-
'
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
'
|
729 |
-
'
|
730 |
-
|
731 |
-
|
732 |
-
'
|
733 |
-
'
|
734 |
-
'
|
735 |
-
'
|
736 |
-
|
737 |
-
|
738 |
-
'
|
739 |
-
'
|
740 |
-
'
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
'
|
746 |
-
'
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
'
|
752 |
-
'
|
753 |
-
|
754 |
-
|
755 |
-
'
|
756 |
-
'
|
757 |
-
'
|
758 |
-
'
|
759 |
-
|
760 |
-
|
761 |
-
'
|
762 |
-
'
|
763 |
-
'
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
'
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
'
|
774 |
-
'
|
775 |
-
'
|
776 |
-
|
777 |
-
|
778 |
-
'
|
779 |
-
'
|
780 |
-
'
|
781 |
-
|
782 |
-
|
783 |
-
'
|
784 |
-
'
|
785 |
-
'
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
'
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
'
|
796 |
-
'
|
797 |
-
'
|
798 |
-
|
799 |
-
|
800 |
-
'
|
801 |
-
'
|
802 |
-
'
|
803 |
-
|
804 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
805 |
));
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
// Check setting
|
7 |
+
if(!acf_get_setting('acfe/modules/dynamic_options_pages'))
|
8 |
+
return;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Register Dynamic Options Page
|
12 |
+
*/
|
13 |
+
add_action('init', 'acfe_dop_register');
|
14 |
+
function acfe_dop_register(){
|
15 |
+
|
16 |
+
register_post_type('acfe-dop', array(
|
17 |
+
'label' => 'Options Page',
|
18 |
+
'description' => 'Options Page',
|
19 |
+
'labels' => array(
|
20 |
+
'name' => 'Options Pages',
|
21 |
+
'singular_name' => 'Options Page',
|
22 |
+
'menu_name' => 'Options Pages',
|
23 |
+
'edit_item' => 'Edit Options Page',
|
24 |
+
'add_new_item' => 'New Options Page',
|
25 |
+
),
|
26 |
+
'supports' => false,
|
27 |
+
'hierarchical' => true,
|
28 |
+
'public' => false,
|
29 |
+
'show_ui' => true,
|
30 |
+
'show_in_menu' => false,
|
31 |
+
'menu_icon' => 'dashicons-layout',
|
32 |
+
'show_in_admin_bar' => false,
|
33 |
+
'show_in_nav_menus' => false,
|
34 |
+
'can_export' => false,
|
35 |
+
'has_archive' => false,
|
36 |
+
'rewrite' => false,
|
37 |
+
'exclude_from_search' => true,
|
38 |
+
'publicly_queryable' => false,
|
39 |
+
'capabilities' => array(
|
40 |
+
'publish_posts' => acf_get_setting('capability'),
|
41 |
+
'edit_posts' => acf_get_setting('capability'),
|
42 |
+
'edit_others_posts' => acf_get_setting('capability'),
|
43 |
+
'delete_posts' => acf_get_setting('capability'),
|
44 |
+
'delete_others_posts' => acf_get_setting('capability'),
|
45 |
+
'read_private_posts' => acf_get_setting('capability'),
|
46 |
+
'edit_post' => acf_get_setting('capability'),
|
47 |
+
'delete_post' => acf_get_setting('capability'),
|
48 |
+
'read_post' => acf_get_setting('capability'),
|
49 |
+
)
|
50 |
+
));
|
51 |
+
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Dynamic Options Page Menu
|
56 |
+
*/
|
57 |
+
add_action('admin_menu', 'acfe_dop_menu');
|
58 |
+
function acfe_dop_menu(){
|
59 |
+
|
60 |
+
if(!acf_get_setting('show_admin'))
|
61 |
+
return;
|
62 |
+
|
63 |
+
add_submenu_page('edit.php?post_type=acf-field-group', __('Options'), __('Options'), acf_get_setting('capability'), 'edit.php?post_type=acfe-dop');
|
64 |
+
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Dynamic Options Page Menu: Parent Highlight
|
69 |
+
*/
|
70 |
+
add_filter('parent_file', 'acfe_dop_menu_parent_highlight');
|
71 |
+
function acfe_dop_menu_parent_highlight($parent_file){
|
72 |
+
|
73 |
+
global $pagenow;
|
74 |
+
if($pagenow != 'post.php' && $pagenow != 'post-new.php')
|
75 |
+
return $parent_file;
|
76 |
+
|
77 |
+
$post_type = get_post_type();
|
78 |
+
if($post_type != 'acfe-dop')
|
79 |
+
return $parent_file;
|
80 |
+
|
81 |
+
return 'edit.php?post_type=acf-field-group';
|
82 |
+
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Dynamic Options Page Menu: Submenu Highlight
|
87 |
+
*/
|
88 |
+
add_filter('submenu_file', 'acfe_dop_menu_sub_highlight');
|
89 |
+
function acfe_dop_menu_sub_highlight($submenu_file){
|
90 |
+
|
91 |
+
global $pagenow;
|
92 |
+
if($pagenow != 'post-new.php')
|
93 |
+
return $submenu_file;
|
94 |
+
|
95 |
+
$post_type = get_post_type();
|
96 |
+
if($post_type != 'acfe-dop')
|
97 |
+
return $submenu_file;
|
98 |
+
|
99 |
+
return 'edit.php?post_type=acfe-dop';
|
100 |
+
|
101 |
+
}
|
102 |
+
|
103 |
+
|
104 |
+
/**
|
105 |
+
* ACF Register Options Pages
|
106 |
+
*/
|
107 |
+
add_action('init', 'acfe_dop_registers');
|
108 |
+
function acfe_dop_registers(){
|
109 |
+
|
110 |
+
$dynamic_options_pages = get_option('acfe_dynamic_options_pages', array());
|
111 |
+
if(empty($dynamic_options_pages))
|
112 |
+
return;
|
113 |
+
|
114 |
+
$options_sub_pages = array();
|
115 |
+
|
116 |
+
foreach($dynamic_options_pages as $name => $register_args){
|
117 |
+
|
118 |
+
// Do not register sub pages
|
119 |
+
if(isset($register_args['parent_slug']) && !empty($register_args['parent_slug'])){
|
120 |
+
|
121 |
+
$options_sub_pages[$name] = $register_args;
|
122 |
+
continue;
|
123 |
+
|
124 |
+
}
|
125 |
+
|
126 |
+
// Register: Execute
|
127 |
+
acf_add_options_page($register_args);
|
128 |
+
|
129 |
+
}
|
130 |
+
|
131 |
+
// Register sub pages
|
132 |
+
if(!empty($options_sub_pages)){
|
133 |
+
|
134 |
+
foreach($options_sub_pages as $name => $register_args){
|
135 |
+
|
136 |
+
// Register: Execute
|
137 |
+
acf_add_options_page($register_args);
|
138 |
+
|
139 |
+
}
|
140 |
+
|
141 |
+
}
|
142 |
+
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* ACF Exclude Dynamic Options Page from available post types
|
147 |
+
*/
|
148 |
+
add_filter('acf/get_post_types', 'acfe_dop_exclude', 10, 2);
|
149 |
+
function acfe_dop_exclude($post_types, $args){
|
150 |
+
|
151 |
+
if(empty($post_types))
|
152 |
+
return $post_types;
|
153 |
+
|
154 |
+
foreach($post_types as $k => $post_type){
|
155 |
+
|
156 |
+
if($post_type != 'acfe-dop')
|
157 |
+
continue;
|
158 |
+
|
159 |
+
unset($post_types[$k]);
|
160 |
+
|
161 |
+
}
|
162 |
+
|
163 |
+
return $post_types;
|
164 |
+
|
165 |
+
}
|
166 |
+
|
167 |
+
add_action('post_submitbox_misc_actions', 'acfe_dop_misc_actions');
|
168 |
+
function acfe_dop_misc_actions($post){
|
169 |
+
|
170 |
+
if($post->post_type !== 'acfe-dop')
|
171 |
+
return;
|
172 |
+
|
173 |
+
$name = get_field('acfe_dop_name', $post->ID);
|
174 |
+
|
175 |
+
?>
|
176 |
+
<div class="misc-pub-section misc-pub-acfe-field-group-export" style="padding-top:2px;">
|
177 |
+
<span style="font-size:17px;color: #82878c;line-height: 1.3;width: 20px;margin-right: 2px;" class="dashicons dashicons-editor-code"></span> Export: <a href="<?php echo admin_url('edit.php?post_type=acf-field-group&page=acf-tools&tool=acfe_tool_dop_export&action=php&keys=' . $name); ?>">PHP</a> <a href="<?php echo admin_url('edit.php?post_type=acf-field-group&page=acf-tools&tool=acfe_tool_dop_export&action=json&keys=' . $name); ?>">Json</a>
|
178 |
+
</div>
|
179 |
+
<?php
|
180 |
+
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* Dynamic Options Page Save
|
185 |
+
*/
|
186 |
+
add_action('acf/save_post', 'acfe_dop_filter_save', 20);
|
187 |
+
function acfe_dop_filter_save($post_id){
|
188 |
+
|
189 |
+
if(get_post_type($post_id) != 'acfe-dop')
|
190 |
+
return;
|
191 |
+
|
192 |
+
$title = get_field('page_title', $post_id);
|
193 |
+
$name = get_field('acfe_dop_name', $post_id);
|
194 |
+
$parent_slug = get_field('parent_slug', $post_id);
|
195 |
+
|
196 |
+
// Force name
|
197 |
+
if(empty($name))
|
198 |
+
$name = sanitize_title($title);
|
199 |
+
|
200 |
+
$parent = 0;
|
201 |
+
if(!empty($parent_slug)){
|
202 |
+
|
203 |
+
$get_dop_parent = get_posts(array(
|
204 |
+
'post_type' => 'acfe-dop',
|
205 |
+
'posts_per_page' => 1,
|
206 |
+
'fields' => 'ids',
|
207 |
+
'meta_query' => array(
|
208 |
+
array(
|
209 |
+
'key' => 'menu_slug',
|
210 |
+
'value' => $parent_slug
|
211 |
+
)
|
212 |
+
)
|
213 |
+
));
|
214 |
+
|
215 |
+
if(!empty($get_dop_parent))
|
216 |
+
$parent = $get_dop_parent[0];
|
217 |
+
|
218 |
+
}
|
219 |
+
|
220 |
+
// Update post
|
221 |
+
wp_update_post(array(
|
222 |
+
'ID' => $post_id,
|
223 |
+
'post_title' => $title,
|
224 |
+
'post_name' => $name,
|
225 |
+
'post_parent' => $parent,
|
226 |
+
));
|
227 |
+
|
228 |
+
// Register Args
|
229 |
+
$page_title = get_field('page_title', $post_id);
|
230 |
+
$menu_title = get_field('menu_title', $post_id);
|
231 |
+
$menu_slug = get_field('menu_slug', $post_id);
|
232 |
+
$capability = get_field('capability', $post_id);
|
233 |
+
$position = get_field('position', $post_id);
|
234 |
+
$icon_url = get_field('icon_url', $post_id);
|
235 |
+
$redirect = get_field('redirect', $post_id);
|
236 |
+
$p_id = get_field('post_id', $post_id);
|
237 |
+
$autoload = get_field('autoload', $post_id);
|
238 |
+
$update_button = get_field('update_button', $post_id);
|
239 |
+
$updated_message = get_field('updated_message', $post_id);
|
240 |
+
|
241 |
+
// Register: Args
|
242 |
+
$register_args = array(
|
243 |
+
'page_title' => $page_title,
|
244 |
+
'menu_title' => $menu_title,
|
245 |
+
'menu_slug' => $menu_slug,
|
246 |
+
'capability' => $capability,
|
247 |
+
'position' => $position,
|
248 |
+
'parent_slug' => $parent_slug,
|
249 |
+
'icon_url' => $icon_url,
|
250 |
+
'redirect' => $redirect,
|
251 |
+
'post_id' => $p_id,
|
252 |
+
'autoload' => $autoload,
|
253 |
+
'update_button' => $update_button,
|
254 |
+
'updated_message' => $updated_message,
|
255 |
+
);
|
256 |
+
|
257 |
+
// Menu title
|
258 |
+
if(empty($menu_title))
|
259 |
+
$register_args['menu_title'] = $page_title;
|
260 |
+
|
261 |
+
// Menu slug
|
262 |
+
if(empty($menu_slug))
|
263 |
+
$register_args['menu_slug'] = sanitize_title($register_args['menu_title']);
|
264 |
+
|
265 |
+
// Redirect
|
266 |
+
$register_args['redirect'] = true;
|
267 |
+
if(empty($redirect))
|
268 |
+
$register_args['redirect'] = false;
|
269 |
+
|
270 |
+
// Post ID
|
271 |
+
if(empty($p_id))
|
272 |
+
$register_args['post_id'] = 'options';
|
273 |
+
|
274 |
+
// Autoload
|
275 |
+
$register_args['autoload'] = true;
|
276 |
+
if(empty($autoload))
|
277 |
+
$register_args['autoload'] = false;
|
278 |
+
|
279 |
+
// Get ACFE option
|
280 |
+
$option = get_option('acfe_dynamic_options_pages', array());
|
281 |
+
|
282 |
+
// Create ACFE option
|
283 |
+
$option[$name] = $register_args;
|
284 |
+
|
285 |
+
// Sort keys ASC
|
286 |
+
ksort($option);
|
287 |
+
|
288 |
+
// Update ACFE option
|
289 |
+
update_option('acfe_dynamic_options_pages', $option);
|
290 |
+
|
291 |
+
}
|
292 |
+
|
293 |
+
/**
|
294 |
+
* Dynamic Options Page Status Publish > Trash
|
295 |
+
*/
|
296 |
+
add_action('publish_to_trash', 'acfe_dop_filter_status_trash');
|
297 |
+
function acfe_dop_filter_status_trash($post){
|
298 |
+
|
299 |
+
if(get_post_type($post->ID) != 'acfe-dop')
|
300 |
+
return;
|
301 |
+
|
302 |
+
$post_id = $post->ID;
|
303 |
+
$title = get_field('page_title', $post_id);
|
304 |
+
$name = get_field('acfe_dop_name', $post_id);
|
305 |
+
|
306 |
+
// Get ACFE option
|
307 |
+
$option = get_option('acfe_dynamic_options_pages', array());
|
308 |
+
|
309 |
+
// Check ACFE option
|
310 |
+
if(isset($option[$name]))
|
311 |
+
unset($option[$name]);
|
312 |
+
|
313 |
+
// Update ACFE option
|
314 |
+
update_option('acfe_dynamic_options_pages', $option);
|
315 |
+
|
316 |
+
}
|
317 |
+
|
318 |
+
/**
|
319 |
+
* Dynamic Options Page Status Trash > Publish
|
320 |
+
*/
|
321 |
+
add_action('trash_to_publish', 'acfe_dop_filter_status_publish');
|
322 |
+
function acfe_dop_filter_status_publish($post){
|
323 |
+
|
324 |
+
if(get_post_type($post->ID) != 'acfe-dop')
|
325 |
+
return;
|
326 |
+
|
327 |
+
acfe_dop_filter_save($post->ID);
|
328 |
+
|
329 |
+
}
|
330 |
+
|
331 |
+
/**
|
332 |
+
* Dynamic Options Page Admin: List
|
333 |
+
*/
|
334 |
+
add_action('pre_get_posts', 'acfe_dop_admin_pre_get_posts');
|
335 |
+
function acfe_dop_admin_pre_get_posts($query){
|
336 |
+
|
337 |
+
if(!is_admin() || !$query->is_main_query())
|
338 |
+
return;
|
339 |
+
|
340 |
+
global $pagenow;
|
341 |
+
if($pagenow != 'edit.php')
|
342 |
+
return;
|
343 |
+
|
344 |
+
$post_type = $query->get('post_type');
|
345 |
+
if($post_type != 'acfe-dop')
|
346 |
+
return;
|
347 |
+
|
348 |
+
$query->set('orderby', 'name');
|
349 |
+
$query->set('order', 'ASC');
|
350 |
+
|
351 |
+
}
|
352 |
+
|
353 |
+
/**
|
354 |
+
* Dynamic Options Page Admin: Posts Per Page
|
355 |
+
*/
|
356 |
+
add_filter('edit_posts_per_page', 'acfe_dop_admin_ppp', 10, 2);
|
357 |
+
function acfe_dop_admin_ppp($ppp, $post_type){
|
358 |
+
|
359 |
+
if($post_type != 'acfe-dop')
|
360 |
+
return $ppp;
|
361 |
+
|
362 |
+
global $pagenow;
|
363 |
+
if($pagenow != 'edit.php')
|
364 |
+
return $ppp;
|
365 |
+
|
366 |
+
return 999;
|
367 |
+
|
368 |
+
}
|
369 |
+
|
370 |
+
/**
|
371 |
+
* Admin List Columns
|
372 |
+
*/
|
373 |
+
add_filter('manage_edit-acfe-dop_columns', 'acfe_dop_admin_columns');
|
374 |
+
function acfe_dop_admin_columns($columns){
|
375 |
+
|
376 |
+
if(isset($columns['date']))
|
377 |
+
unset($columns['date']);
|
378 |
+
|
379 |
+
$columns['name'] = __('Name');
|
380 |
+
$columns['post_id'] = __('Post ID');
|
381 |
+
$columns['autoload'] = __('Autoload');
|
382 |
+
|
383 |
+
return $columns;
|
384 |
+
|
385 |
+
}
|
386 |
+
|
387 |
+
/**
|
388 |
+
* Admin List Columns HTML
|
389 |
+
*/
|
390 |
+
add_action('manage_acfe-dop_posts_custom_column', 'acfe_dop_admin_columns_html', 10, 2);
|
391 |
+
function acfe_dop_admin_columns_html($column, $post_id){
|
392 |
+
|
393 |
+
// Name
|
394 |
+
if($column === 'name'){
|
395 |
+
|
396 |
+
$name = get_field('acfe_dop_name', $post_id);
|
397 |
+
|
398 |
+
echo '<code style="-webkit-user-select: all;-moz-user-select: all;-ms-user-select: all;user-select: all;font-size: 12px;">' . $name . '</code>';
|
399 |
+
|
400 |
+
}
|
401 |
+
|
402 |
+
// Post ID
|
403 |
+
elseif($column === 'post_id'){
|
404 |
+
|
405 |
+
$p_id = get_field('post_id', $post_id);
|
406 |
+
if(empty($p_id))
|
407 |
+
$p_id = 'options';
|
408 |
+
|
409 |
+
echo '<code style="-webkit-user-select: all;-moz-user-select: all;-ms-user-select: all;user-select: all;font-size: 12px;">' . $p_id. '</code>';
|
410 |
+
|
411 |
+
}
|
412 |
+
|
413 |
+
// Autoload
|
414 |
+
elseif($column === 'autoload'){
|
415 |
+
|
416 |
+
$autoload = get_field('autoload', $post_id);
|
417 |
+
|
418 |
+
if(empty($autoload))
|
419 |
+
echo 'No';
|
420 |
+
else
|
421 |
+
echo 'Yes';
|
422 |
+
|
423 |
+
}
|
424 |
+
|
425 |
+
}
|
426 |
+
|
427 |
+
/**
|
428 |
+
* Admin List Row Actions
|
429 |
+
*/
|
430 |
+
add_filter('page_row_actions','acfe_dop_admin_row', 10, 2);
|
431 |
+
function acfe_dop_admin_row($actions, $post){
|
432 |
+
|
433 |
+
if($post->post_type !== 'acfe-dop' || $post->post_status !== 'publish')
|
434 |
+
return $actions;
|
435 |
+
|
436 |
+
$name = get_field('acfe_dop_name', $post->ID);
|
437 |
+
|
438 |
+
$actions['acfe_dop_export_php'] = '<a href="' . admin_url('edit.php?post_type=acf-field-group&page=acf-tools&tool=acfe_tool_dop_export&action=php&keys=' . $name) . '">' . __('PHP') . '</a>';
|
439 |
+
$actions['acfe_dop_export_json'] = '<a href="' . admin_url('edit.php?post_type=acf-field-group&page=acf-tools&tool=acfe_tool_dop_export&action=json&keys=' . $name) . '">' . __('Json') . '</a>';
|
440 |
+
|
441 |
+
return $actions;
|
442 |
+
|
443 |
+
}
|
444 |
+
|
445 |
+
/**
|
446 |
+
* Admin Disable Name
|
447 |
+
*/
|
448 |
+
add_filter('acf/prepare_field/name=acfe_dop_name', 'acfe_dop_admin_disable_name');
|
449 |
+
function acfe_dop_admin_disable_name($field){
|
450 |
+
|
451 |
+
global $pagenow;
|
452 |
+
if($pagenow != 'post.php')
|
453 |
+
return $field;
|
454 |
+
|
455 |
+
$field['disabled'] = true;
|
456 |
+
|
457 |
+
return $field;
|
458 |
+
|
459 |
+
}
|
460 |
+
|
461 |
+
/**
|
462 |
+
* Admin Force Name
|
463 |
+
*/
|
464 |
+
add_action('load-edit.php', 'acfe_dop_admin_name_value');
|
465 |
+
function acfe_dop_admin_name_value(){
|
466 |
+
|
467 |
+
// Get post type
|
468 |
+
global $typenow;
|
469 |
+
|
470 |
+
// Check post type
|
471 |
+
$post_type = $typenow;
|
472 |
+
if(empty($post_type) || $post_type != 'acfe-dop')
|
473 |
+
return;
|
474 |
+
|
475 |
+
$get_options = get_posts(array(
|
476 |
+
'post_type' => 'acfe-dop',
|
477 |
+
'posts_per_page' => -1,
|
478 |
+
'fields' => 'ids'
|
479 |
+
));
|
480 |
+
|
481 |
+
if(empty($get_options))
|
482 |
+
return;
|
483 |
+
|
484 |
+
foreach($get_options as $post_id){
|
485 |
+
|
486 |
+
if(get_field('acfe_dop_name', $post_id))
|
487 |
+
continue;
|
488 |
+
|
489 |
+
update_field('acfe_dop_name', sanitize_title(get_field('page_title', $post_id)), $post_id);
|
490 |
+
|
491 |
+
}
|
492 |
+
|
493 |
+
}
|
494 |
+
|
495 |
+
/**
|
496 |
+
* Add Local Field Group
|
497 |
+
*/
|
498 |
+
acf_add_local_field_group(array(
|
499 |
+
'key' => 'group_acfe_dynamic_options_page',
|
500 |
+
'title' => __('Dynamic Options Page', 'acfe'),
|
501 |
+
|
502 |
+
'location' => array(
|
503 |
+
array(
|
504 |
+
array(
|
505 |
+
'param' => 'post_type',
|
506 |
+
'operator' => '==',
|
507 |
+
'value' => 'acfe-dop',
|
508 |
+
),
|
509 |
+
),
|
510 |
+
),
|
511 |
+
|
512 |
+
'menu_order' => 0,
|
513 |
+
'position' => 'normal',
|
514 |
+
'style' => 'default',
|
515 |
+
'label_placement' => 'left',
|
516 |
+
'instruction_placement' => 'label',
|
517 |
+
'hide_on_screen' => '',
|
518 |
+
'active' => 1,
|
519 |
+
'description' => '',
|
520 |
+
|
521 |
+
'fields' => array(
|
522 |
+
array(
|
523 |
+
'key' => 'field_acfe_dop_page_title',
|
524 |
+
'label' => 'Page title',
|
525 |
+
'name' => 'page_title',
|
526 |
+
'type' => 'text',
|
527 |
+
'instructions' => '(string) The title displayed on the options page. Required.',
|
528 |
+
'required' => 1,
|
529 |
+
'conditional_logic' => 0,
|
530 |
+
'wrapper' => array(
|
531 |
+
'width' => '',
|
532 |
+
'class' => '',
|
533 |
+
'id' => '',
|
534 |
+
),
|
535 |
+
'acfe_validate' => '',
|
536 |
+
'acfe_update' => '',
|
537 |
+
'acfe_permissions' => '',
|
538 |
+
'default_value' => '',
|
539 |
+
'placeholder' => '',
|
540 |
+
'prepend' => '',
|
541 |
+
'append' => '',
|
542 |
+
'maxlength' => '',
|
543 |
+
),
|
544 |
+
array(
|
545 |
+
'key' => 'field_acfe_dop_name',
|
546 |
+
'label' => 'Name',
|
547 |
+
'name' => 'acfe_dop_name',
|
548 |
+
'type' => 'acfe_slug',
|
549 |
+
'instructions' => '(string) Options page slug. Must be unique',
|
550 |
+
'required' => 1,
|
551 |
+
'conditional_logic' => 0,
|
552 |
+
'wrapper' => array(
|
553 |
+
'width' => '',
|
554 |
+
'class' => '',
|
555 |
+
'id' => '',
|
556 |
+
),
|
557 |
+
'acfe_validate' => '',
|
558 |
+
'acfe_update' => '',
|
559 |
+
'acfe_permissions' => '',
|
560 |
+
'default_value' => '',
|
561 |
+
'placeholder' => '',
|
562 |
+
'prepend' => '',
|
563 |
+
'append' => '',
|
564 |
+
'maxlength' => '',
|
565 |
+
),
|
566 |
+
array(
|
567 |
+
'key' => 'field_acfe_dop_menu_title',
|
568 |
+
'label' => 'Menu title',
|
569 |
+
'name' => 'menu_title',
|
570 |
+
'type' => 'text',
|
571 |
+
'instructions' => '(string) The title displayed in the wp-admin sidebar. Defaults to page_title',
|
572 |
+
'required' => 0,
|
573 |
+
'conditional_logic' => 0,
|
574 |
+
'wrapper' => array(
|
575 |
+
'width' => '',
|
576 |
+
'class' => '',
|
577 |
+
'id' => '',
|
578 |
+
),
|
579 |
+
'acfe_validate' => '',
|
580 |
+
'acfe_update' => '',
|
581 |
+
'acfe_permissions' => '',
|
582 |
+
'default_value' => '',
|
583 |
+
'placeholder' => '',
|
584 |
+
'prepend' => '',
|
585 |
+
'append' => '',
|
586 |
+
'maxlength' => '',
|
587 |
+
),
|
588 |
+
array(
|
589 |
+
'key' => 'field_acfe_dop_menu_slug',
|
590 |
+
'label' => 'Menu slug',
|
591 |
+
'name' => 'menu_slug',
|
592 |
+
'type' => 'acfe_slug',
|
593 |
+
'instructions' => '(string) The URL slug used to uniquely identify this options page. Defaults to a url friendly version of menu_title',
|
594 |
+
'required' => 0,
|
595 |
+
'conditional_logic' => 0,
|
596 |
+
'wrapper' => array(
|
597 |
+
'width' => '',
|
598 |
+
'class' => '',
|
599 |
+
'id' => '',
|
600 |
+
),
|
601 |
+
'acfe_validate' => '',
|
602 |
+
'acfe_update' => array(
|
603 |
+
'5cd2a4d60fbf2' => array(
|
604 |
+
'acfe_update_function' => 'sanitize_title',
|
605 |
+
),
|
606 |
+
),
|
607 |
+
'acfe_permissions' => '',
|
608 |
+
'default_value' => '',
|
609 |
+
'placeholder' => '',
|
610 |
+
'prepend' => '',
|
611 |
+
'append' => '',
|
612 |
+
'maxlength' => '',
|
613 |
+
),
|
614 |
+
array(
|
615 |
+
'key' => 'field_acfe_dop_capability',
|
616 |
+
'label' => 'Capability',
|
617 |
+
'name' => 'capability',
|
618 |
+
'type' => 'text',
|
619 |
+
'instructions' => '(string) The capability required for this menu to be displayed to the user. Defaults to edit_posts.<br /><br />
|
620 |
+
|
621 |
+
Read more about capability here: <a href="https://codex.wordpress.org/Roles_and_Capabilities">https://codex.wordpress.org/Roles_and_Capabilities</a>',
|
622 |
+
'required' => 0,
|
623 |
+
'conditional_logic' => 0,
|
624 |
+
'wrapper' => array(
|
625 |
+
'width' => '',
|
626 |
+
'class' => '',
|
627 |
+
'id' => '',
|
628 |
+
),
|
629 |
+
'acfe_validate' => '',
|
630 |
+
'acfe_update' => '',
|
631 |
+
'acfe_permissions' => '',
|
632 |
+
'default_value' => 'edit_posts',
|
633 |
+
'placeholder' => '',
|
634 |
+
'prepend' => '',
|
635 |
+
'append' => '',
|
636 |
+
'maxlength' => '',
|
637 |
+
),
|
638 |
+
array(
|
639 |
+
'key' => 'field_acfe_dop_position',
|
640 |
+
'label' => 'Position',
|
641 |
+
'name' => 'position',
|
642 |
+
'type' => 'text',
|
643 |
+
'instructions' => '(int|string) The position in the menu order this menu should appear. Defaults to bottom of utility menu items.<br /><br />
|
644 |
+
|
645 |
+
WARNING: if two menu items use the same position attribute, one of the items may be overwritten so that only one item displays!<br />
|
646 |
+
Risk of conflict can be reduced by using decimal instead of integer values, e.g. \'63.3\' instead of 63 (must use quotes).',
|
647 |
+
'required' => 0,
|
648 |
+
'conditional_logic' => 0,
|
649 |
+
'wrapper' => array(
|
650 |
+
'width' => '',
|
651 |
+
'class' => '',
|
652 |
+
'id' => '',
|
653 |
+
),
|
654 |
+
'acfe_validate' => '',
|
655 |
+
'acfe_update' => '',
|
656 |
+
'acfe_permissions' => '',
|
657 |
+
'default_value' => '',
|
658 |
+
'placeholder' => '',
|
659 |
+
'prepend' => '',
|
660 |
+
'append' => '',
|
661 |
+
'maxlength' => '',
|
662 |
+
),
|
663 |
+
array(
|
664 |
+
'key' => 'field_acfe_dop_parent_slug',
|
665 |
+
'label' => 'Parent slug',
|
666 |
+
'name' => 'parent_slug',
|
667 |
+
'type' => 'text',
|
668 |
+
'instructions' => '(string) The slug of another WP admin page. if set, this will become a child page.',
|
669 |
+
'required' => 0,
|
670 |
+
'conditional_logic' => 0,
|
671 |
+
'wrapper' => array(
|
672 |
+
'width' => '',
|
673 |
+
'class' => '',
|
674 |
+
'id' => '',
|
675 |
+
),
|
676 |
+
'acfe_validate' => '',
|
677 |
+
'acfe_update' => '',
|
678 |
+
'acfe_permissions' => '',
|
679 |
+
'default_value' => '',
|
680 |
+
'placeholder' => '',
|
681 |
+
'prepend' => '',
|
682 |
+
'append' => '',
|
683 |
+
'maxlength' => '',
|
684 |
+
),
|
685 |
+
array(
|
686 |
+
'key' => 'field_acfe_dop_icon_url',
|
687 |
+
'label' => 'Icon url',
|
688 |
+
'name' => 'icon_url',
|
689 |
+
'type' => 'text',
|
690 |
+
'instructions' => '(string) The icon class for this menu. Defaults to default WordPress gear.<br /><br />
|
691 |
+
Read more about dashicons here: <a href="https://developer.wordpress.org/resource/dashicons/">https://developer.wordpress.org/resource/dashicons/</a>',
|
692 |
+
'required' => 0,
|
693 |
+
'conditional_logic' => 0,
|
694 |
+
'wrapper' => array(
|
695 |
+
'width' => '',
|
696 |
+
'class' => '',
|
697 |
+
'id' => '',
|
698 |
+
),
|
699 |
+
'acfe_validate' => '',
|
700 |
+
'acfe_update' => '',
|
701 |
+
'acfe_permissions' => '',
|
702 |
+
'default_value' => '',
|
703 |
+
'placeholder' => '',
|
704 |
+
'prepend' => '',
|
705 |
+
'append' => '',
|
706 |
+
'maxlength' => '',
|
707 |
+
),
|
708 |
+
array(
|
709 |
+
'key' => 'field_acfe_dop_redirect',
|
710 |
+
'label' => 'Redirect',
|
711 |
+
'name' => 'redirect',
|
712 |
+
'type' => 'true_false',
|
713 |
+
'instructions' => '(boolean) If set to true, this options page will redirect to the first child page (if a child page exists).
|
714 |
+
If set to false, this parent page will appear alongside any child pages. Defaults to true',
|
715 |
+
'required' => 0,
|
716 |
+
'conditional_logic' => 0,
|
717 |
+
'wrapper' => array(
|
718 |
+
'width' => '',
|
719 |
+
'class' => '',
|
720 |
+
'id' => '',
|
721 |
+
),
|
722 |
+
'acfe_validate' => '',
|
723 |
+
'acfe_update' => '',
|
724 |
+
'acfe_permissions' => '',
|
725 |
+
'message' => '',
|
726 |
+
'default_value' => 1,
|
727 |
+
'ui' => 1,
|
728 |
+
'ui_on_text' => 'True',
|
729 |
+
'ui_off_text' => 'False',
|
730 |
+
),
|
731 |
+
array(
|
732 |
+
'key' => 'field_acfe_dop_post_id',
|
733 |
+
'label' => 'Post ID',
|
734 |
+
'name' => 'post_id',
|
735 |
+
'type' => 'text',
|
736 |
+
'instructions' => '(int|string) The \'$post_id\' to save/load data to/from. Can be set to a numeric post ID (123), or a string (\'user_2\').
|
737 |
+
Defaults to \'options\'.',
|
738 |
+
'required' => 0,
|
739 |
+
'conditional_logic' => 0,
|
740 |
+
'wrapper' => array(
|
741 |
+
'width' => '',
|
742 |
+
'class' => '',
|
743 |
+
'id' => '',
|
744 |
+
),
|
745 |
+
'acfe_validate' => '',
|
746 |
+
'acfe_update' => '',
|
747 |
+
'acfe_permissions' => '',
|
748 |
+
'default_value' => 'options',
|
749 |
+
'placeholder' => '',
|
750 |
+
'prepend' => '',
|
751 |
+
'append' => '',
|
752 |
+
'maxlength' => '',
|
753 |
+
),
|
754 |
+
array(
|
755 |
+
'key' => 'field_acfe_dop_autoload',
|
756 |
+
'label' => 'Autoload',
|
757 |
+
'name' => 'autoload',
|
758 |
+
'type' => 'true_false',
|
759 |
+
'instructions' => '(boolean) Whether to load the option (values saved from this options page) when WordPress starts up.
|
760 |
+
Defaults to false.',
|
761 |
+
'required' => 0,
|
762 |
+
'conditional_logic' => 0,
|
763 |
+
'wrapper' => array(
|
764 |
+
'width' => '',
|
765 |
+
'class' => '',
|
766 |
+
'id' => '',
|
767 |
+
),
|
768 |
+
'acfe_validate' => '',
|
769 |
+
'acfe_update' => '',
|
770 |
+
'acfe_permissions' => '',
|
771 |
+
'message' => '',
|
772 |
+
'default_value' => 0,
|
773 |
+
'ui' => 1,
|
774 |
+
'ui_on_text' => 'True',
|
775 |
+
'ui_off_text' => 'False',
|
776 |
+
),
|
777 |
+
array(
|
778 |
+
'key' => 'field_acfe_dop_update_button',
|
779 |
+
'label' => 'Update button',
|
780 |
+
'name' => 'update_button',
|
781 |
+
'type' => 'text',
|
782 |
+
'instructions' => '(string) The update button text.',
|
783 |
+
'required' => 0,
|
784 |
+
'conditional_logic' => 0,
|
785 |
+
'wrapper' => array(
|
786 |
+
'width' => '',
|
787 |
+
'class' => '',
|
788 |
+
'id' => '',
|
789 |
+
),
|
790 |
+
'acfe_validate' => '',
|
791 |
+
'acfe_update' => '',
|
792 |
+
'acfe_permissions' => '',
|
793 |
+
'default_value' => 'Update',
|
794 |
+
'placeholder' => '',
|
795 |
+
'prepend' => '',
|
796 |
+
'append' => '',
|
797 |
+
'maxlength' => '',
|
798 |
+
),
|
799 |
+
array(
|
800 |
+
'key' => 'field_acfe_dop_updated_message',
|
801 |
+
'label' => 'Updated Message',
|
802 |
+
'name' => 'updated_message',
|
803 |
+
'type' => 'text',
|
804 |
+
'instructions' => '(string) The message shown above the form on submit.',
|
805 |
+
'required' => 0,
|
806 |
+
'conditional_logic' => 0,
|
807 |
+
'wrapper' => array(
|
808 |
+
'width' => '',
|
809 |
+
'class' => '',
|
810 |
+
'id' => '',
|
811 |
+
),
|
812 |
+
'acfe_validate' => '',
|
813 |
+
'acfe_update' => '',
|
814 |
+
'acfe_permissions' => '',
|
815 |
+
'default_value' => 'Options Updated',
|
816 |
+
'placeholder' => '',
|
817 |
+
'prepend' => '',
|
818 |
+
'append' => '',
|
819 |
+
'maxlength' => '',
|
820 |
+
),
|
821 |
+
),
|
822 |
));
|
includes/modules/dynamic-post-type.php
CHANGED
@@ -1,2632 +1,2649 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
// Check setting
|
7 |
-
if(!acf_get_setting('acfe/modules/dynamic_post_types'))
|
8 |
-
return;
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Register Dynamic Post Type
|
12 |
-
*/
|
13 |
-
add_action('init', 'acfe_dpt_register');
|
14 |
-
function acfe_dpt_register(){
|
15 |
-
|
16 |
-
register_post_type('acfe-dpt', array(
|
17 |
-
'label' => 'Post Types',
|
18 |
-
'description' => 'Post Types',
|
19 |
-
'labels' => array(
|
20 |
-
'name' => 'Post Types',
|
21 |
-
'singular_name' => 'Post Type',
|
22 |
-
'menu_name' => 'Post Types',
|
23 |
-
'edit_item' => 'Edit Post Type',
|
24 |
-
'add_new_item' => 'New Post Type',
|
25 |
-
),
|
26 |
-
'supports' => false,
|
27 |
-
'hierarchical' => false,
|
28 |
-
'public' => false,
|
29 |
-
'show_ui' => true,
|
30 |
-
'show_in_menu' => 'tools.php',
|
31 |
-
'menu_icon' => 'dashicons-layout',
|
32 |
-
'show_in_admin_bar' => false,
|
33 |
-
'show_in_nav_menus' => false,
|
34 |
-
'can_export' => false,
|
35 |
-
'has_archive' => false,
|
36 |
-
'rewrite' => false,
|
37 |
-
'exclude_from_search' => true,
|
38 |
-
'publicly_queryable' => false,
|
39 |
-
'capabilities' => array(
|
40 |
-
'publish_posts' => acf_get_setting('capability'),
|
41 |
-
'edit_posts' => acf_get_setting('capability'),
|
42 |
-
'edit_others_posts' => acf_get_setting('capability'),
|
43 |
-
'delete_posts' => acf_get_setting('capability'),
|
44 |
-
'delete_others_posts' => acf_get_setting('capability'),
|
45 |
-
'read_private_posts' => acf_get_setting('capability'),
|
46 |
-
'edit_post' => acf_get_setting('capability'),
|
47 |
-
'delete_post' => acf_get_setting('capability'),
|
48 |
-
'read_post' => acf_get_setting('capability'),
|
49 |
-
)
|
50 |
-
));
|
51 |
-
|
52 |
-
}
|
53 |
-
|
54 |
-
/**
|
55 |
-
* WP Register Post Types
|
56 |
-
*/
|
57 |
-
add_action('init', 'acfe_dpt_registers');
|
58 |
-
function acfe_dpt_registers(){
|
59 |
-
|
60 |
-
$dynamic_post_types = get_option('acfe_dynamic_post_types', array());
|
61 |
-
if(empty($dynamic_post_types))
|
62 |
-
return;
|
63 |
-
|
64 |
-
foreach($dynamic_post_types as $name => $register_args){
|
65 |
-
|
66 |
-
// Register: Execute
|
67 |
-
register_post_type($name, $register_args);
|
68 |
-
|
69 |
-
}
|
70 |
-
|
71 |
-
}
|
72 |
-
|
73 |
-
/**
|
74 |
-
* ACF Exclude Dynamic Post Type from available post types
|
75 |
-
*/
|
76 |
-
add_filter('acf/get_post_types', 'acfe_dpt_exclude', 10, 2);
|
77 |
-
function acfe_dpt_exclude($post_types, $args){
|
78 |
-
|
79 |
-
if(empty($post_types))
|
80 |
-
return $post_types;
|
81 |
-
|
82 |
-
foreach($post_types as $k => $post_type){
|
83 |
-
|
84 |
-
if($post_type != 'acfe-dpt')
|
85 |
-
continue;
|
86 |
-
|
87 |
-
unset($post_types[$k]);
|
88 |
-
|
89 |
-
}
|
90 |
-
|
91 |
-
return $post_types;
|
92 |
-
|
93 |
-
}
|
94 |
-
|
95 |
-
/**
|
96 |
-
* Dynamic Post Type Save
|
97 |
-
*/
|
98 |
-
add_action('acf/save_post', 'acfe_dpt_filter_save', 20);
|
99 |
-
function acfe_dpt_filter_save($post_id){
|
100 |
-
|
101 |
-
if(get_post_type($post_id) != 'acfe-dpt')
|
102 |
-
return;
|
103 |
-
|
104 |
-
$title = get_field('label', $post_id);
|
105 |
-
$name = get_field('acfe_dpt_name', $post_id);
|
106 |
-
|
107 |
-
// Update post
|
108 |
-
wp_update_post(array(
|
109 |
-
'ID' => $post_id,
|
110 |
-
'post_title' => $title,
|
111 |
-
'post_name' => $name,
|
112 |
-
));
|
113 |
-
|
114 |
-
// Register Args
|
115 |
-
$label = get_field('label', $post_id);
|
116 |
-
$description = get_field('description', $post_id);
|
117 |
-
$hierarchical = get_field('hierarchical', $post_id);
|
118 |
-
$supports = get_field('supports', $post_id);
|
119 |
-
$taxonomies = acf_get_array(get_field('taxonomies', $post_id));
|
120 |
-
$public = get_field('public', $post_id);
|
121 |
-
$exclude_from_search = get_field('exclude_from_search', $post_id);
|
122 |
-
$publicly_queryable = get_field('publicly_queryable', $post_id);
|
123 |
-
$can_export = get_field('can_export', $post_id);
|
124 |
-
$delete_with_user = get_field('delete_with_user', $post_id);
|
125 |
-
|
126 |
-
// Labels
|
127 |
-
$labels = get_field('labels', $post_id);
|
128 |
-
$labels_args = array();
|
129 |
-
foreach($labels as $k => $l){
|
130 |
-
if(empty($l))
|
131 |
-
continue;
|
132 |
-
|
133 |
-
$labels_args[$k] = $l;
|
134 |
-
}
|
135 |
-
|
136 |
-
// Menu
|
137 |
-
$menu_position = (int) get_field('menu_position', $post_id);
|
138 |
-
$menu_icon = get_field('menu_icon', $post_id);
|
139 |
-
$show_ui = get_field('show_ui', $post_id);
|
140 |
-
$show_in_menu = get_field('show_in_menu', $post_id);
|
141 |
-
$show_in_menu_text = get_field('show_in_menu_text', $post_id);
|
142 |
-
$show_in_nav_menus = get_field('show_in_nav_menus', $post_id);
|
143 |
-
$show_in_admin_bar = get_field('show_in_admin_bar', $post_id);
|
144 |
-
|
145 |
-
// Capability
|
146 |
-
$capability_type = acf_decode_choices(get_field('capability_type', $post_id), true);
|
147 |
-
$capabilities = acf_decode_choices(get_field('capabilities', $post_id), true);
|
148 |
-
$map_meta_cap = get_field('map_meta_cap', $post_id);
|
149 |
-
|
150 |
-
// Archive
|
151 |
-
$archive_template = get_field('acfe_dpt_archive_template', $post_id);
|
152 |
-
$archive_posts_per_page = (int) get_field('acfe_dpt_archive_posts_per_page', $post_id);
|
153 |
-
$archive_orderby = get_field('acfe_dpt_archive_orderby', $post_id);
|
154 |
-
$archive_order = get_field('acfe_dpt_archive_order', $post_id);
|
155 |
-
$has_archive = get_field('has_archive', $post_id);
|
156 |
-
$has_archive_slug = get_field('has_archive_slug', $post_id);
|
157 |
-
|
158 |
-
// Single
|
159 |
-
$single_template = get_field('acfe_dpt_single_template', $post_id);
|
160 |
-
$rewrite = get_field('rewrite', $post_id);
|
161 |
-
$rewrite_args_select = get_field('rewrite_args_select', $post_id);
|
162 |
-
$rewrite_args = get_field('rewrite_args', $post_id);
|
163 |
-
|
164 |
-
// Admin
|
165 |
-
$admin_archive = get_field('acfe_dpt_admin_archive', $post_id);
|
166 |
-
$admin_posts_per_page = (int) get_field('acfe_dpt_admin_posts_per_page', $post_id);
|
167 |
-
$admin_orderby = get_field('acfe_dpt_admin_orderby', $post_id);
|
168 |
-
$admin_order = get_field('acfe_dpt_admin_order', $post_id);
|
169 |
-
|
170 |
-
// REST
|
171 |
-
$show_in_rest = get_field('show_in_rest', $post_id);
|
172 |
-
$rest_base = get_field('rest_base', $post_id);
|
173 |
-
$rest_controller_class = get_field('rest_controller_class', $post_id);
|
174 |
-
|
175 |
-
// Register: Args
|
176 |
-
$register_args = array(
|
177 |
-
'label' => $label,
|
178 |
-
'description' => $description,
|
179 |
-
'hierarchical' => $hierarchical,
|
180 |
-
'supports' => $supports,
|
181 |
-
'taxonomies' => $taxonomies,
|
182 |
-
'public' => $public,
|
183 |
-
'exclude_from_search' => $exclude_from_search,
|
184 |
-
'publicly_queryable' => $publicly_queryable,
|
185 |
-
'can_export' => $can_export,
|
186 |
-
'delete_with_user' => $delete_with_user,
|
187 |
-
|
188 |
-
// Labels
|
189 |
-
'labels' => $labels_args,
|
190 |
-
|
191 |
-
// Menu
|
192 |
-
'menu_position' => $menu_position,
|
193 |
-
'menu_icon' => $menu_icon,
|
194 |
-
'show_ui' => $show_ui,
|
195 |
-
'show_in_menu' => $show_in_menu,
|
196 |
-
'show_in_nav_menus' => $show_in_nav_menus,
|
197 |
-
'show_in_admin_bar' => $show_in_admin_bar,
|
198 |
-
|
199 |
-
// Single
|
200 |
-
'rewrite' => $rewrite,
|
201 |
-
|
202 |
-
// Archive
|
203 |
-
'has_archive' => $has_archive,
|
204 |
-
|
205 |
-
// REST
|
206 |
-
'show_in_rest' => $show_in_rest,
|
207 |
-
'rest_base' => $rest_base,
|
208 |
-
'rest_controller_class' => $rest_controller_class,
|
209 |
-
|
210 |
-
// ACFE: Archive
|
211 |
-
'acfe_archive_template' => $archive_template,
|
212 |
-
'acfe_archive_ppp' => $archive_posts_per_page,
|
213 |
-
'acfe_archive_orderby' => $archive_orderby,
|
214 |
-
'acfe_archive_order' => $archive_order,
|
215 |
-
|
216 |
-
// ACFE: Single
|
217 |
-
'acfe_single_template' => $single_template,
|
218 |
-
|
219 |
-
// ACFE: Admin
|
220 |
-
'acfe_admin_archive' => $admin_archive,
|
221 |
-
'acfe_admin_ppp' => $admin_posts_per_page,
|
222 |
-
'acfe_admin_orderby' => $admin_orderby,
|
223 |
-
'acfe_admin_order' => $admin_order,
|
224 |
-
);
|
225 |
-
|
226 |
-
// Has archive: override
|
227 |
-
if($has_archive && $has_archive_slug)
|
228 |
-
$register_args['has_archive'] = $has_archive_slug;
|
229 |
-
|
230 |
-
// Rewrite: override
|
231 |
-
if($rewrite && $rewrite_args_select){
|
232 |
-
|
233 |
-
$register_args['rewrite'] = array(
|
234 |
-
'slug' => $rewrite_args['acfe_dpt_rewrite_slug'],
|
235 |
-
'with_front' => $rewrite_args['acfe_dpt_rewrite_with_front'],
|
236 |
-
'feeds' => $rewrite_args['feeds'],
|
237 |
-
'pages' => $rewrite_args['pages'],
|
238 |
-
);
|
239 |
-
|
240 |
-
}
|
241 |
-
|
242 |
-
// Show in menu (text)
|
243 |
-
if($show_in_menu && !empty($show_in_menu_text))
|
244 |
-
$register_args['show_in_menu'] = $show_in_menu_text;
|
245 |
-
|
246 |
-
// Capability type
|
247 |
-
$register_args['capability_type'] = $capability_type;
|
248 |
-
if(is_array($capability_type) && count($capability_type) == 1)
|
249 |
-
$register_args['capability_type'] = $capability_type[0];
|
250 |
-
|
251 |
-
// Capabilities
|
252 |
-
$register_args['capabilities'] = $capabilities;
|
253 |
-
|
254 |
-
// Map meta cap
|
255 |
-
$register_args['map_meta_cap'] = null;
|
256 |
-
|
257 |
-
if($map_meta_cap === 'false')
|
258 |
-
$register_args['map_meta_cap'] = false;
|
259 |
-
|
260 |
-
elseif($map_meta_cap === 'true')
|
261 |
-
$register_args['map_meta_cap'] = true;
|
262 |
-
|
263 |
-
// Get ACFE option
|
264 |
-
$option = get_option('acfe_dynamic_post_types', array());
|
265 |
-
|
266 |
-
// Create ACFE option
|
267 |
-
$option[$name] = $register_args;
|
268 |
-
|
269 |
-
// Sort keys ASC
|
270 |
-
ksort($option);
|
271 |
-
|
272 |
-
// Update ACFE option
|
273 |
-
update_option('acfe_dynamic_post_types', $option);
|
274 |
-
|
275 |
-
// Flush permalinks
|
276 |
-
flush_rewrite_rules();
|
277 |
-
|
278 |
-
}
|
279 |
-
|
280 |
-
/**
|
281 |
-
* Dynamic Post Type Status Publish > Trash
|
282 |
-
*/
|
283 |
-
add_action('publish_to_trash', 'acfe_dpt_filter_status_trash');
|
284 |
-
function acfe_dpt_filter_status_trash($post){
|
285 |
-
|
286 |
-
if(get_post_type($post->ID) != 'acfe-dpt')
|
287 |
-
return;
|
288 |
-
|
289 |
-
$post_id = $post->ID;
|
290 |
-
$name = get_field('acfe_dpt_name', $post_id);
|
291 |
-
|
292 |
-
// Get ACFE option
|
293 |
-
$option = get_option('acfe_dynamic_post_types', array());
|
294 |
-
|
295 |
-
// Check ACFE option
|
296 |
-
if(isset($option[$name]))
|
297 |
-
unset($option[$name]);
|
298 |
-
|
299 |
-
// Update ACFE option
|
300 |
-
update_option('acfe_dynamic_post_types', $option);
|
301 |
-
|
302 |
-
// Flush permalinks
|
303 |
-
flush_rewrite_rules();
|
304 |
-
|
305 |
-
}
|
306 |
-
|
307 |
-
/**
|
308 |
-
* Dynamic Post Type Status Trash > Publish
|
309 |
-
*/
|
310 |
-
add_action('trash_to_publish', 'acfe_dpt_filter_status_publish');
|
311 |
-
function acfe_dpt_filter_status_publish($post){
|
312 |
-
|
313 |
-
if(get_post_type($post->ID) != 'acfe-dpt')
|
314 |
-
return;
|
315 |
-
|
316 |
-
acfe_dpt_filter_save($post->ID);
|
317 |
-
|
318 |
-
}
|
319 |
-
|
320 |
-
/**
|
321 |
-
* Dynamic Post Type Admin: List
|
322 |
-
*/
|
323 |
-
add_action('pre_get_posts', 'acfe_dpt_admin_pre_get_posts');
|
324 |
-
function acfe_dpt_admin_pre_get_posts($query){
|
325 |
-
|
326 |
-
if(!is_admin() || !$query->is_main_query())
|
327 |
-
return;
|
328 |
-
|
329 |
-
global $pagenow;
|
330 |
-
if($pagenow != 'edit.php')
|
331 |
-
return;
|
332 |
-
|
333 |
-
$post_type = $query->get('post_type');
|
334 |
-
if($post_type != 'acfe-dpt')
|
335 |
-
return;
|
336 |
-
|
337 |
-
$query->set('orderby', 'name');
|
338 |
-
$query->set('order', 'ASC');
|
339 |
-
|
340 |
-
}
|
341 |
-
|
342 |
-
/**
|
343 |
-
* Dynamic Post Type Admin: Posts Per Page
|
344 |
-
*/
|
345 |
-
add_filter('edit_posts_per_page', 'acfe_dpt_admin_ppp', 10, 2);
|
346 |
-
function acfe_dpt_admin_ppp($ppp, $post_type){
|
347 |
-
|
348 |
-
if($post_type != 'acfe-dpt')
|
349 |
-
return $ppp;
|
350 |
-
|
351 |
-
global $pagenow;
|
352 |
-
if($pagenow != 'edit.php')
|
353 |
-
return $ppp;
|
354 |
-
|
355 |
-
return 999;
|
356 |
-
|
357 |
-
}
|
358 |
-
|
359 |
-
/**
|
360 |
-
* Filter Admin: List
|
361 |
-
*/
|
362 |
-
add_action('pre_get_posts', 'acfe_dpt_filter_admin_list');
|
363 |
-
function acfe_dpt_filter_admin_list($query){
|
364 |
-
|
365 |
-
if(!is_admin() || !$query->is_main_query() || !is_post_type_archive())
|
366 |
-
return;
|
367 |
-
|
368 |
-
$post_type = $query->get('post_type');
|
369 |
-
$post_type_obj = get_post_type_object($post_type);
|
370 |
-
|
371 |
-
$acfe_admin_orderby = (isset($post_type_obj->acfe_admin_orderby) && !empty($post_type_obj->acfe_admin_orderby));
|
372 |
-
$acfe_admin_order = (isset($post_type_obj->acfe_admin_order) && !empty($post_type_obj->acfe_admin_order));
|
373 |
-
|
374 |
-
if($acfe_admin_orderby && (!isset($_REQUEST['orderby']) || empty($_REQUEST['orderby'])))
|
375 |
-
$query->set('orderby', $post_type_obj->acfe_admin_orderby);
|
376 |
-
|
377 |
-
if($acfe_admin_order && (!isset($_REQUEST['order']) || empty($_REQUEST['order'])))
|
378 |
-
$query->set('order', $post_type_obj->acfe_admin_order);
|
379 |
-
|
380 |
-
|
381 |
-
}
|
382 |
-
|
383 |
-
/**
|
384 |
-
* Filter Admin: Posts Per Page
|
385 |
-
*/
|
386 |
-
add_filter('edit_posts_per_page', 'acfe_dpt_filter_admin_ppp', 10, 2);
|
387 |
-
function acfe_dpt_filter_admin_ppp($ppp, $post_type){
|
388 |
-
|
389 |
-
global $pagenow;
|
390 |
-
if($pagenow != 'edit.php')
|
391 |
-
return $ppp;
|
392 |
-
|
393 |
-
$post_type_obj = get_post_type_object($post_type);
|
394 |
-
if(!isset($post_type_obj->acfe_admin_ppp) || empty($post_type_obj->acfe_admin_ppp))
|
395 |
-
return $ppp;
|
396 |
-
|
397 |
-
// Check if user has a screen option
|
398 |
-
if(!empty(get_user_option('edit_' . $post_type . '_per_page')))
|
399 |
-
return $ppp;
|
400 |
-
|
401 |
-
return $post_type_obj->acfe_admin_ppp;
|
402 |
-
|
403 |
-
}
|
404 |
-
|
405 |
-
/**
|
406 |
-
* Filter Front: List + Posts Per Page
|
407 |
-
*/
|
408 |
-
add_action('pre_get_posts', 'acfe_dpt_filter_front_list');
|
409 |
-
function acfe_dpt_filter_front_list($query){
|
410 |
-
|
411 |
-
if(is_admin() || !$query->is_main_query() || !is_post_type_archive())
|
412 |
-
return;
|
413 |
-
|
414 |
-
$post_type = $query->get('post_type');
|
415 |
-
$post_type_obj = get_post_type_object($post_type);
|
416 |
-
|
417 |
-
$acfe_archive_ppp = (isset($post_type_obj->acfe_archive_ppp) && !empty($post_type_obj->acfe_archive_ppp));
|
418 |
-
$acfe_archive_orderby = (isset($post_type_obj->acfe_archive_orderby) && !empty($post_type_obj->acfe_archive_orderby));
|
419 |
-
$acfe_archive_order = (isset($post_type_obj->acfe_archive_order) && !empty($post_type_obj->acfe_archive_order));
|
420 |
-
|
421 |
-
if($acfe_archive_ppp)
|
422 |
-
$query->set('posts_per_page', $post_type_obj->acfe_archive_ppp);
|
423 |
-
|
424 |
-
if($acfe_archive_orderby)
|
425 |
-
$query->set('orderby', $post_type_obj->acfe_archive_orderby);
|
426 |
-
|
427 |
-
if($acfe_archive_order)
|
428 |
-
$query->set('order', $post_type_obj->acfe_archive_order);
|
429 |
-
|
430 |
-
}
|
431 |
-
|
432 |
-
/**
|
433 |
-
* Filter Front: Template
|
434 |
-
*/
|
435 |
-
add_filter('template_include', 'acfe_dpt_filter_template', 999);
|
436 |
-
function acfe_dpt_filter_template($template){
|
437 |
-
|
438 |
-
if(!is_single() && !is_post_type_archive() && !is_home())
|
439 |
-
return $template;
|
440 |
-
|
441 |
-
// Get_query_var
|
442 |
-
$query_var = get_query_var('post_type', false);
|
443 |
-
if(is_array($query_var) && !empty($query_var))
|
444 |
-
$query_var = $query_var[0];
|
445 |
-
|
446 |
-
foreach(get_post_types(array(), 'objects') as $post_type){
|
447 |
-
|
448 |
-
// Get_query_var check
|
449 |
-
$is_query_var = ($query_var && $query_var === $post_type->name);
|
450 |
-
|
451 |
-
// Get_post_type check
|
452 |
-
$get_post_type = (get_post_type() === $post_type->name);
|
453 |
-
|
454 |
-
// Acfe_archive_template
|
455 |
-
$acfe_archive_template = (isset($post_type->acfe_archive_template) && !empty($post_type->acfe_archive_template));
|
456 |
-
|
457 |
-
// Acfe_archive_template
|
458 |
-
$acfe_single_template = (isset($post_type->acfe_single_template) && !empty($post_type->acfe_single_template));
|
459 |
-
|
460 |
-
// Global check
|
461 |
-
if(!$get_post_type || !$is_query_var || (!$acfe_archive_template && !$acfe_single_template))
|
462 |
-
continue;
|
463 |
-
|
464 |
-
$rule = array();
|
465 |
-
$rule['is_archive'] = is_post_type_archive($post_type->name);
|
466 |
-
$rule['has_archive'] = $post_type->has_archive;
|
467 |
-
$rule['is_single'] = is_singular($post_type->name);
|
468 |
-
|
469 |
-
// Post Exception
|
470 |
-
if($post_type->name === 'post'){
|
471 |
-
$rule['is_archive'] = is_home();
|
472 |
-
$rule['has_archive'] = true;
|
473 |
-
}
|
474 |
-
|
475 |
-
// Archive
|
476 |
-
if($rule['has_archive'] && $rule['is_archive'] && $acfe_archive_template && ($locate = locate_template(array($post_type->acfe_archive_template))))
|
477 |
-
return $locate;
|
478 |
-
|
479 |
-
// Single
|
480 |
-
elseif($rule['is_single'] && $acfe_single_template && ($locate = locate_template(array($post_type->acfe_single_template))))
|
481 |
-
return $locate;
|
482 |
-
}
|
483 |
-
|
484 |
-
return $template;
|
485 |
-
|
486 |
-
}
|
487 |
-
|
488 |
-
/**
|
489 |
-
* Admin List Columns
|
490 |
-
*/
|
491 |
-
add_filter('manage_edit-acfe-dpt_columns', 'acfe_dpt_admin_columns');
|
492 |
-
function acfe_dpt_admin_columns($columns){
|
493 |
-
|
494 |
-
if(isset($columns['date']))
|
495 |
-
unset($columns['date']);
|
496 |
-
|
497 |
-
$columns['acfe-name'] = __('Name');
|
498 |
-
$columns['acfe-taxonomies'] = __('Taxonomies');
|
499 |
-
$columns['acfe-posts'] = __('Posts');
|
500 |
-
|
501 |
-
return $columns;
|
502 |
-
|
503 |
-
}
|
504 |
-
|
505 |
-
/**
|
506 |
-
* Admin List Columns HTML
|
507 |
-
*/
|
508 |
-
add_action('manage_acfe-dpt_posts_custom_column', 'acfe_dpt_admin_columns_html', 10, 2);
|
509 |
-
function acfe_dpt_admin_columns_html($column, $post_id){
|
510 |
-
|
511 |
-
// Name
|
512 |
-
if($column === 'acfe-name'){
|
513 |
-
|
514 |
-
echo '<code style="-webkit-user-select: all;-moz-user-select: all;-ms-user-select: all;user-select: all;font-size: 12px;">' . get_field('acfe_dpt_name', $post_id) . '</code>';
|
515 |
-
|
516 |
-
}
|
517 |
-
|
518 |
-
// Taxonomies
|
519 |
-
elseif($column === 'acfe-taxonomies'){
|
520 |
-
|
521 |
-
$taxonomies = acf_get_array(get_field('taxonomies', $post_id));
|
522 |
-
|
523 |
-
if(empty($taxonomies)){
|
524 |
-
|
525 |
-
echo '—';
|
526 |
-
return;
|
527 |
-
|
528 |
-
}
|
529 |
-
|
530 |
-
$taxonomies_names = array();
|
531 |
-
foreach($taxonomies as $taxonomy_slug){
|
532 |
-
|
533 |
-
$taxonomy_obj = get_taxonomy($taxonomy_slug);
|
534 |
-
if(empty($taxonomy_obj))
|
535 |
-
continue;
|
536 |
-
|
537 |
-
$taxonomies_names[] = $taxonomy_obj->label;
|
538 |
-
|
539 |
-
}
|
540 |
-
|
541 |
-
if(empty($taxonomies_names)){
|
542 |
-
|
543 |
-
echo '—';
|
544 |
-
return;
|
545 |
-
|
546 |
-
}
|
547 |
-
|
548 |
-
echo implode(', ', $taxonomies_names);
|
549 |
-
|
550 |
-
}
|
551 |
-
|
552 |
-
// Posts
|
553 |
-
elseif($column === 'acfe-posts'){
|
554 |
-
|
555 |
-
// Name
|
556 |
-
$name = get_field('acfe_dpt_name', $post_id);
|
557 |
-
|
558 |
-
// Count
|
559 |
-
$count = wp_count_posts($name);
|
560 |
-
if(empty($count)){
|
561 |
-
|
562 |
-
echo '—';
|
563 |
-
return;
|
564 |
-
|
565 |
-
}
|
566 |
-
|
567 |
-
$count_publish = $count->publish;
|
568 |
-
|
569 |
-
echo '<a href="' . admin_url('edit.php?post_type=' . $name) . '">' . $count_publish . '</a>';
|
570 |
-
|
571 |
-
}
|
572 |
-
|
573 |
-
}
|
574 |
-
|
575 |
-
/**
|
576 |
-
* Admin List Row Actions
|
577 |
-
*/
|
578 |
-
add_filter('post_row_actions','acfe_dpt_admin_row', 10, 2);
|
579 |
-
function acfe_dpt_admin_row($actions, $post){
|
580 |
-
|
581 |
-
if($post->post_type != 'acfe-dpt' || $post->post_status != 'publish')
|
582 |
-
return $actions;
|
583 |
-
|
584 |
-
$post_id = $post->ID;
|
585 |
-
$name = get_field('acfe_dpt_name', $post_id);
|
586 |
-
|
587 |
-
$actions['acfe_dpt_export_json'] = '<a href="' . admin_url('edit.php?post_type=acf-field-group&page=acf-tools&tool=acfe_tool_dpt_export&keys=' . $name) . '">' . __('Json') . '</a>';
|
588 |
-
|
589 |
-
return $actions;
|
590 |
-
|
591 |
-
}
|
592 |
-
|
593 |
-
/**
|
594 |
-
* Admin Add Config Button
|
595 |
-
*/
|
596 |
-
add_action('admin_footer-edit.php', 'acfe_dpt_admin_footer');
|
597 |
-
function acfe_dpt_admin_footer(){
|
598 |
-
|
599 |
-
if(!current_user_can(acf_get_setting('capability')))
|
600 |
-
return;
|
601 |
-
|
602 |
-
// Get post type
|
603 |
-
global $typenow;
|
604 |
-
|
605 |
-
// Check post type
|
606 |
-
$post_type = $typenow;
|
607 |
-
if(empty($post_type))
|
608 |
-
return;
|
609 |
-
|
610 |
-
// Post type object
|
611 |
-
$post_type_obj = get_post_type_object($post_type);
|
612 |
-
if(!isset($post_type_obj->acfe_admin_ppp))
|
613 |
-
return;
|
614 |
-
|
615 |
-
// Get Dynamic Post Type Post
|
616 |
-
$acfe_dpt_post_type = get_page_by_path($post_type, 'OBJECT', 'acfe-dpt');
|
617 |
-
|
618 |
-
if(empty($acfe_dpt_post_type))
|
619 |
-
return;
|
620 |
-
|
621 |
-
?>
|
622 |
-
<script type="text/html" id="tmpl-acfe-dpt-title-config">
|
623 |
-
<a href="<?php echo admin_url('post.php?post=' . $acfe_dpt_post_type->ID . '&action=edit'); ?>" class="page-title-action acfe-dpt-admin-config"><span class="dashicons dashicons-admin-generic"></span></a>
|
624 |
-
</script>
|
625 |
-
|
626 |
-
<script type="text/javascript">
|
627 |
-
(function($){
|
628 |
-
|
629 |
-
// Add button
|
630 |
-
$('.wrap .page-title-action').before($('#tmpl-acfe-dpt-title-config').html());
|
631 |
-
|
632 |
-
})(jQuery);
|
633 |
-
</script>
|
634 |
-
<?php
|
635 |
-
|
636 |
-
}
|
637 |
-
|
638 |
-
/**
|
639 |
-
* Admin Disable Name
|
640 |
-
*/
|
641 |
-
add_filter('acf/prepare_field/name=acfe_dpt_name', 'acfe_dpt_admin_disable_name');
|
642 |
-
function acfe_dpt_admin_disable_name($field){
|
643 |
-
|
644 |
-
global $pagenow;
|
645 |
-
if($pagenow != 'post.php')
|
646 |
-
return $field;
|
647 |
-
|
648 |
-
$field['disabled'] = true;
|
649 |
-
|
650 |
-
return $field;
|
651 |
-
|
652 |
-
}
|
653 |
-
|
654 |
-
/**
|
655 |
-
* Admin Validate Name
|
656 |
-
*/
|
657 |
-
add_filter('acf/validate_value/name=acfe_dpt_name', 'acfe_dpt_admin_validate_name', 10, 4);
|
658 |
-
function acfe_dpt_admin_validate_name($valid, $value, $field, $input){
|
659 |
-
|
660 |
-
if(!$valid)
|
661 |
-
return $valid;
|
662 |
-
|
663 |
-
$excludes = array(
|
664 |
-
|
665 |
-
// Reserved WP Post types: https://codex.wordpress.org/Function_Reference/register_post_type#Reserved_Post_Types
|
666 |
-
'post',
|
667 |
-
'page',
|
668 |
-
'attachment',
|
669 |
-
'revision',
|
670 |
-
'nav_menu_item',
|
671 |
-
'custom_css',
|
672 |
-
'customize_changeset',
|
673 |
-
'oembed_cache',
|
674 |
-
'user_request',
|
675 |
-
'wp_block',
|
676 |
-
'action',
|
677 |
-
'author',
|
678 |
-
'order',
|
679 |
-
'theme',
|
680 |
-
|
681 |
-
// ACF
|
682 |
-
'acf-field-group',
|
683 |
-
'acf-field',
|
684 |
-
|
685 |
-
// ACF Extended
|
686 |
-
'acfe-dbt',
|
687 |
-
'acfe-dt',
|
688 |
-
'acfe-dop',
|
689 |
-
'acfe-dpt',
|
690 |
-
'acfe-form',
|
691 |
-
|
692 |
-
);
|
693 |
-
|
694 |
-
if(in_array($value, $excludes))
|
695 |
-
return __('This post type name is reserved');
|
696 |
-
|
697 |
-
// Editing Current Dynamic Post Type
|
698 |
-
$current_post_id = $_POST['_acf_post_id'];
|
699 |
-
$current_post_type = false;
|
700 |
-
|
701 |
-
if(!empty($current_post_id))
|
702 |
-
$current_post_type = get_field('acfe_dpt_name', $current_post_id);
|
703 |
-
|
704 |
-
if($value === $current_post_type)
|
705 |
-
return $valid;
|
706 |
-
|
707 |
-
// Listing WP Post Types
|
708 |
-
global $wp_post_types;
|
709 |
-
if(!empty($wp_post_types)){
|
710 |
-
foreach($wp_post_types as $post_type){
|
711 |
-
if($value != $post_type->name)
|
712 |
-
continue;
|
713 |
-
|
714 |
-
$valid = __('This post type name already exists');
|
715 |
-
}
|
716 |
-
}
|
717 |
-
|
718 |
-
return $valid;
|
719 |
-
|
720 |
-
}
|
721 |
-
|
722 |
-
/**
|
723 |
-
* Add Local Field Group
|
724 |
-
*/
|
725 |
-
acf_add_local_field_group(array(
|
726 |
-
'key' => 'group_acfe_dynamic_post_type',
|
727 |
-
'title' => __('Dynamic Post Type', 'acfe'),
|
728 |
-
|
729 |
-
'location' => array(
|
730 |
-
array(
|
731 |
-
array(
|
732 |
-
'param' => 'post_type',
|
733 |
-
'operator' => '==',
|
734 |
-
'value' => 'acfe-dpt',
|
735 |
-
),
|
736 |
-
),
|
737 |
-
),
|
738 |
-
|
739 |
-
'menu_order' => 0,
|
740 |
-
'position' => 'normal',
|
741 |
-
'style' => 'default',
|
742 |
-
'label_placement' => 'left',
|
743 |
-
'instruction_placement' => 'label',
|
744 |
-
'hide_on_screen' => '',
|
745 |
-
'active' => 1,
|
746 |
-
'description' => '',
|
747 |
-
|
748 |
-
'fields' => array(
|
749 |
-
array(
|
750 |
-
'key' => 'field_acfe_dpt_tab_general',
|
751 |
-
'label' => 'General',
|
752 |
-
'name' => '',
|
753 |
-
'type' => 'tab',
|
754 |
-
'instructions' => '',
|
755 |
-
'required' => 0,
|
756 |
-
'conditional_logic' => 0,
|
757 |
-
'wrapper' => array(
|
758 |
-
'width' => '',
|
759 |
-
'class' => '',
|
760 |
-
'id' => '',
|
761 |
-
),
|
762 |
-
'acfe_permissions' => '',
|
763 |
-
'placement' => 'top',
|
764 |
-
'endpoint' => 0,
|
765 |
-
),
|
766 |
-
array(
|
767 |
-
'key' => 'field_acfe_dpt_label',
|
768 |
-
'label' => 'Label',
|
769 |
-
'name' => 'label',
|
770 |
-
'type' => 'text',
|
771 |
-
'instructions' => 'General name for the post type, usually plural. Default is Posts/Pages',
|
772 |
-
'required' => 1,
|
773 |
-
'conditional_logic' => 0,
|
774 |
-
'wrapper' => array(
|
775 |
-
'width' => '',
|
776 |
-
'class' => '',
|
777 |
-
'id' => '',
|
778 |
-
),
|
779 |
-
'acfe_validate' => '',
|
780 |
-
'acfe_update' => '',
|
781 |
-
'acfe_permissions' => '',
|
782 |
-
'user_roles' => array(
|
783 |
-
0 => 'all',
|
784 |
-
),
|
785 |
-
'default_value' => '',
|
786 |
-
'placeholder' => '',
|
787 |
-
'prepend' => '',
|
788 |
-
'append' => '',
|
789 |
-
'maxlength' => '',
|
790 |
-
),
|
791 |
-
array(
|
792 |
-
'key' => 'field_acfe_dpt_name',
|
793 |
-
'label' => 'Name',
|
794 |
-
'name' => 'acfe_dpt_name',
|
795 |
-
'type' => 'acfe_slug',
|
796 |
-
'instructions' => 'Post type name. Max. 20 characters, cannot contain capital letters or spaces',
|
797 |
-
'required' => 1,
|
798 |
-
'conditional_logic' => 0,
|
799 |
-
'wrapper' => array(
|
800 |
-
'width' => '',
|
801 |
-
'class' => '',
|
802 |
-
'id' => '',
|
803 |
-
),
|
804 |
-
'acfe_validate' => '',
|
805 |
-
'acfe_update' => '',
|
806 |
-
'acfe_permissions' => '',
|
807 |
-
'default_value' => '',
|
808 |
-
'placeholder' => '',
|
809 |
-
'prepend' => '',
|
810 |
-
'append' => '',
|
811 |
-
'maxlength' => 20,
|
812 |
-
),
|
813 |
-
array(
|
814 |
-
'key' => 'field_acfe_dpt_description',
|
815 |
-
'label' => 'Description',
|
816 |
-
'name' => 'description',
|
817 |
-
'type' => 'text',
|
818 |
-
'instructions' => 'A short descriptive summary of the post type',
|
819 |
-
'required' => 0,
|
820 |
-
'conditional_logic' => 0,
|
821 |
-
'wrapper' => array(
|
822 |
-
'width' => '',
|
823 |
-
'class' => '',
|
824 |
-
'id' => '',
|
825 |
-
),
|
826 |
-
'acfe_validate' => '',
|
827 |
-
'acfe_update' => '',
|
828 |
-
'acfe_permissions' => '',
|
829 |
-
'default_value' => '',
|
830 |
-
'placeholder' => '',
|
831 |
-
'prepend' => '',
|
832 |
-
'append' => '',
|
833 |
-
'maxlength' => '',
|
834 |
-
),
|
835 |
-
array(
|
836 |
-
'key' => 'field_acfe_dpt_hierarchical',
|
837 |
-
'label' => 'Hierarchical',
|
838 |
-
'name' => 'hierarchical',
|
839 |
-
'type' => 'true_false',
|
840 |
-
'instructions' => 'Whether the post type is hierarchical (e.g. page). Allows Parent to be specified. The \'supports\' parameter should contain \'page-attributes\' to show the parent select box on the editor page.',
|
841 |
-
'required' => 0,
|
842 |
-
'conditional_logic' => 0,
|
843 |
-
'wrapper' => array(
|
844 |
-
'width' => '',
|
845 |
-
'class' => '',
|
846 |
-
'id' => '',
|
847 |
-
),
|
848 |
-
'acfe_validate' => '',
|
849 |
-
'acfe_update' => '',
|
850 |
-
'acfe_permissions' => '',
|
851 |
-
'message' => '',
|
852 |
-
'default_value' => 0,
|
853 |
-
'ui' => 1,
|
854 |
-
'ui_on_text' => '',
|
855 |
-
'ui_off_text' => '',
|
856 |
-
),
|
857 |
-
array(
|
858 |
-
'key' => 'field_acfe_dpt_supports',
|
859 |
-
'label' => 'Supports',
|
860 |
-
'name' => 'supports',
|
861 |
-
'type' => 'checkbox',
|
862 |
-
'instructions' => 'An alias for calling add_post_type_support() directly. As of 3.5, boolean false can be passed as value instead of an array to prevent default (title and editor) behavior.',
|
863 |
-
'required' => 0,
|
864 |
-
'conditional_logic' => 0,
|
865 |
-
'wrapper' => array(
|
866 |
-
'width' => '',
|
867 |
-
'class' => '',
|
868 |
-
'id' => '',
|
869 |
-
),
|
870 |
-
'acfe_validate' => '',
|
871 |
-
'acfe_update' => '',
|
872 |
-
'acfe_permissions' => '',
|
873 |
-
'choices' => array(
|
874 |
-
'title' => 'Title',
|
875 |
-
'editor' => 'Editor',
|
876 |
-
'author' => 'Author',
|
877 |
-
'thumbnail' => 'Thumbnail',
|
878 |
-
'excerpt' => 'Excerpt',
|
879 |
-
'trackbacks' => 'Trackbacks',
|
880 |
-
'custom-fields' => 'Custom fields',
|
881 |
-
'comments' => 'Comments',
|
882 |
-
'revisions' => 'Revisions',
|
883 |
-
'page-attributes' => 'Page attributes',
|
884 |
-
'post-formats' => 'Post formats',
|
885 |
-
),
|
886 |
-
'allow_custom' => 1,
|
887 |
-
'save_custom' => 1,
|
888 |
-
'default_value' => array(
|
889 |
-
0 => 'title',
|
890 |
-
1 => 'thumbnail',
|
891 |
-
2 => 'custom-fields',
|
892 |
-
),
|
893 |
-
'layout' => 'vertical',
|
894 |
-
'toggle' => 0,
|
895 |
-
'return_format' => 'value',
|
896 |
-
),
|
897 |
-
array(
|
898 |
-
'key' => 'field_acfe_dpt_taxonomies',
|
899 |
-
'label' => 'Taxonomies',
|
900 |
-
'name' => 'taxonomies',
|
901 |
-
'type' => 'acfe_taxonomies',
|
902 |
-
'instructions' => 'An array of registered taxonomies like category or post_tag that will be used with this post type. This can be used in lieu of calling register_taxonomy_for_object_type() directly. Custom taxonomies still need to be registered with register_taxonomy()',
|
903 |
-
'required' => 0,
|
904 |
-
'conditional_logic' => 0,
|
905 |
-
'wrapper' => array(
|
906 |
-
'width' => '',
|
907 |
-
'class' => '',
|
908 |
-
'id' => '',
|
909 |
-
),
|
910 |
-
'acfe_validate' => '',
|
911 |
-
'acfe_update' => '',
|
912 |
-
'acfe_permissions' => '',
|
913 |
-
'field_type' => 'checkbox',
|
914 |
-
'return_format' => 'name',
|
915 |
-
'multiple' => 0,
|
916 |
-
'allow_null' => 0,
|
917 |
-
),
|
918 |
-
array(
|
919 |
-
'key' => 'field_acfe_dpt_public',
|
920 |
-
'label' => 'Public',
|
921 |
-
'name' => 'public',
|
922 |
-
'type' => 'true_false',
|
923 |
-
'instructions' => 'Controls how the type is visible to authors (show_in_nav_menus, show_ui) and readers (exclude_from_search, publicly_queryable)',
|
924 |
-
'required' => 0,
|
925 |
-
'conditional_logic' => 0,
|
926 |
-
'wrapper' => array(
|
927 |
-
'width' => '',
|
928 |
-
'class' => '',
|
929 |
-
'id' => '',
|
930 |
-
),
|
931 |
-
'acfe_validate' => '',
|
932 |
-
'acfe_update' => '',
|
933 |
-
'acfe_permissions' => '',
|
934 |
-
'message' => '',
|
935 |
-
'default_value' => 1,
|
936 |
-
'ui' => 1,
|
937 |
-
'ui_on_text' => '',
|
938 |
-
'ui_off_text' => '',
|
939 |
-
),
|
940 |
-
array(
|
941 |
-
'key' => 'field_acfe_dpt_exclude_from_search',
|
942 |
-
'label' => 'Exclude from search',
|
943 |
-
'name' => 'exclude_from_search',
|
944 |
-
'type' => 'true_false',
|
945 |
-
'instructions' => 'Whether to exclude posts with this post type from front end search results',
|
946 |
-
'required' => 0,
|
947 |
-
'conditional_logic' => 0,
|
948 |
-
'wrapper' => array(
|
949 |
-
'width' => '',
|
950 |
-
'class' => '',
|
951 |
-
'id' => '',
|
952 |
-
),
|
953 |
-
'acfe_validate' => '',
|
954 |
-
'acfe_update' => '',
|
955 |
-
'acfe_permissions' => '',
|
956 |
-
'message' => '',
|
957 |
-
'default_value' => 0,
|
958 |
-
'ui' => 1,
|
959 |
-
'ui_on_text' => '',
|
960 |
-
'ui_off_text' => '',
|
961 |
-
),
|
962 |
-
array(
|
963 |
-
'key' => 'field_acfe_dpt_publicly_queryable',
|
964 |
-
'label' => 'Publicly queryable',
|
965 |
-
'name' => 'publicly_queryable',
|
966 |
-
'type' => 'true_false',
|
967 |
-
'instructions' => 'Whether queries can be performed on the front end as part of parse_request()',
|
968 |
-
'required' => 0,
|
969 |
-
'conditional_logic' => 0,
|
970 |
-
'wrapper' => array(
|
971 |
-
'width' => '',
|
972 |
-
'class' => '',
|
973 |
-
'id' => '',
|
974 |
-
),
|
975 |
-
'acfe_validate' => '',
|
976 |
-
'acfe_update' => '',
|
977 |
-
'acfe_permissions' => '',
|
978 |
-
'message' => '',
|
979 |
-
'default_value' => 1,
|
980 |
-
'ui' => 1,
|
981 |
-
'ui_on_text' => '',
|
982 |
-
'ui_off_text' => '',
|
983 |
-
),
|
984 |
-
array(
|
985 |
-
'key' => 'field_acfe_dpt_can_export',
|
986 |
-
'label' => 'Can export',
|
987 |
-
'name' => 'can_export',
|
988 |
-
'type' => 'true_false',
|
989 |
-
'instructions' => 'Can this post type be exported',
|
990 |
-
'required' => 0,
|
991 |
-
'conditional_logic' => 0,
|
992 |
-
'wrapper' => array(
|
993 |
-
'width' => '',
|
994 |
-
'class' => '',
|
995 |
-
'id' => '',
|
996 |
-
),
|
997 |
-
'acfe_validate' => '',
|
998 |
-
'acfe_update' => '',
|
999 |
-
'acfe_permissions' => '',
|
1000 |
-
'message' => '',
|
1001 |
-
'default_value' => 1,
|
1002 |
-
'ui' => 1,
|
1003 |
-
'ui_on_text' => '',
|
1004 |
-
'ui_off_text' => '',
|
1005 |
-
),
|
1006 |
-
array(
|
1007 |
-
'key' => 'field_acfe_dpt_delete_with_user',
|
1008 |
-
'label' => 'Delete with user',
|
1009 |
-
'name' => 'delete_with_user',
|
1010 |
-
'type' => 'select',
|
1011 |
-
'instructions' => 'Whether to delete posts of this type when deleting a user. If true, posts of this type belonging to the user will be moved to trash when then user is deleted.<br /><br />If false, posts of this type belonging to the user will not be trashed or deleted. If not set (the default), posts are trashed if the post type supports author. Otherwise posts are not trashed or deleted',
|
1012 |
-
'required' => 0,
|
1013 |
-
'conditional_logic' => 0,
|
1014 |
-
'wrapper' => array(
|
1015 |
-
'width' => '',
|
1016 |
-
'class' => '',
|
1017 |
-
'id' => '',
|
1018 |
-
),
|
1019 |
-
'acfe_validate' => '',
|
1020 |
-
'acfe_update' => '',
|
1021 |
-
'acfe_permissions' => '',
|
1022 |
-
'choices' => array(
|
1023 |
-
'null' => 'Null (default)',
|
1024 |
-
'false' => 'False',
|
1025 |
-
'true' => 'True',
|
1026 |
-
),
|
1027 |
-
'default_value' => array(
|
1028 |
-
),
|
1029 |
-
'allow_null' => 0,
|
1030 |
-
'multiple' => 0,
|
1031 |
-
'ui' => 0,
|
1032 |
-
'return_format' => 'value',
|
1033 |
-
'ajax' => 0,
|
1034 |
-
'placeholder' => '',
|
1035 |
-
),
|
1036 |
-
array(
|
1037 |
-
'key' => 'field_acfe_dpt_tab_labels',
|
1038 |
-
'label' => 'Labels',
|
1039 |
-
'name' => '',
|
1040 |
-
'type' => 'tab',
|
1041 |
-
'instructions' => '',
|
1042 |
-
'required' => 0,
|
1043 |
-
'conditional_logic' => 0,
|
1044 |
-
'wrapper' => array(
|
1045 |
-
'width' => '',
|
1046 |
-
'class' => '',
|
1047 |
-
'id' => '',
|
1048 |
-
),
|
1049 |
-
'acfe_permissions' => '',
|
1050 |
-
'placement' => 'top',
|
1051 |
-
'endpoint' => 0,
|
1052 |
-
),
|
1053 |
-
array(
|
1054 |
-
'key' => 'field_acfe_dpt_labels',
|
1055 |
-
'label' => 'Labels',
|
1056 |
-
'name' => 'labels',
|
1057 |
-
'type' => 'group',
|
1058 |
-
'instructions' => 'An array of labels for this post type. By default, post labels are used for non-hierarchical post types and page labels for hierarchical ones.<br /><br />
|
1059 |
-
Default: if empty, \'name\' is set to value of \'label\', and \'singular_name\' is set to value of \'name\'.',
|
1060 |
-
'required' => 0,
|
1061 |
-
'conditional_logic' => 0,
|
1062 |
-
'wrapper' => array(
|
1063 |
-
'width' => '',
|
1064 |
-
'class' => '',
|
1065 |
-
'id' => '',
|
1066 |
-
),
|
1067 |
-
'acfe_permissions' => '',
|
1068 |
-
'layout' => 'row',
|
1069 |
-
'sub_fields' => array(
|
1070 |
-
array(
|
1071 |
-
'key' => 'field_acfe_dpt_singular_name',
|
1072 |
-
'label' => 'Singular name',
|
1073 |
-
'name' => 'singular_name',
|
1074 |
-
'type' => 'text',
|
1075 |
-
'instructions' => '',
|
1076 |
-
'required' => 0,
|
1077 |
-
'conditional_logic' => 0,
|
1078 |
-
'wrapper' => array(
|
1079 |
-
'width' => '',
|
1080 |
-
'class' => '',
|
1081 |
-
'id' => '',
|
1082 |
-
),
|
1083 |
-
'acfe_validate' => '',
|
1084 |
-
'acfe_update' => '',
|
1085 |
-
'acfe_permissions' => '',
|
1086 |
-
'default_value' => '',
|
1087 |
-
'placeholder' => '',
|
1088 |
-
'prepend' => '',
|
1089 |
-
'append' => '',
|
1090 |
-
'maxlength' => '',
|
1091 |
-
),
|
1092 |
-
array(
|
1093 |
-
'key' => 'field_acfe_dpt_add_new',
|
1094 |
-
'label' => 'Add new',
|
1095 |
-
'name' => 'add_new',
|
1096 |
-
'type' => 'text',
|
1097 |
-
'instructions' => '',
|
1098 |
-
'required' => 0,
|
1099 |
-
'conditional_logic' => 0,
|
1100 |
-
'wrapper' => array(
|
1101 |
-
'width' => '',
|
1102 |
-
'class' => '',
|
1103 |
-
'id' => '',
|
1104 |
-
),
|
1105 |
-
'acfe_validate' => '',
|
1106 |
-
'acfe_update' => '',
|
1107 |
-
'acfe_permissions' => '',
|
1108 |
-
'default_value' => '',
|
1109 |
-
'placeholder' => '',
|
1110 |
-
'prepend' => '',
|
1111 |
-
'append' => '',
|
1112 |
-
'maxlength' => '',
|
1113 |
-
),
|
1114 |
-
array(
|
1115 |
-
'key' => 'field_acfe_dpt_add_new_item',
|
1116 |
-
'label' => 'Add new item',
|
1117 |
-
'name' => 'add_new_item',
|
1118 |
-
'type' => 'text',
|
1119 |
-
'instructions' => '',
|
1120 |
-
'required' => 0,
|
1121 |
-
'conditional_logic' => 0,
|
1122 |
-
'wrapper' => array(
|
1123 |
-
'width' => '',
|
1124 |
-
'class' => '',
|
1125 |
-
'id' => '',
|
1126 |
-
),
|
1127 |
-
'acfe_validate' => '',
|
1128 |
-
'acfe_update' => '',
|
1129 |
-
'acfe_permissions' => '',
|
1130 |
-
'default_value' => '',
|
1131 |
-
'placeholder' => '',
|
1132 |
-
'prepend' => '',
|
1133 |
-
'append' => '',
|
1134 |
-
'maxlength' => '',
|
1135 |
-
),
|
1136 |
-
array(
|
1137 |
-
'key' => 'field_acfe_dpt_edit_item',
|
1138 |
-
'label' => 'Edit item',
|
1139 |
-
'name' => 'edit_item',
|
1140 |
-
'type' => 'text',
|
1141 |
-
'instructions' => '',
|
1142 |
-
'required' => 0,
|
1143 |
-
'conditional_logic' => 0,
|
1144 |
-
'wrapper' => array(
|
1145 |
-
'width' => '',
|
1146 |
-
'class' => '',
|
1147 |
-
'id' => '',
|
1148 |
-
),
|
1149 |
-
'acfe_validate' => '',
|
1150 |
-
'acfe_update' => '',
|
1151 |
-
'acfe_permissions' => '',
|
1152 |
-
'default_value' => '',
|
1153 |
-
'placeholder' => '',
|
1154 |
-
'prepend' => '',
|
1155 |
-
'append' => '',
|
1156 |
-
'maxlength' => '',
|
1157 |
-
),
|
1158 |
-
array(
|
1159 |
-
'key' => 'field_acfe_dpt_new_item',
|
1160 |
-
'label' => 'New item',
|
1161 |
-
'name' => 'new_item',
|
1162 |
-
'type' => 'text',
|
1163 |
-
'instructions' => '',
|
1164 |
-
'required' => 0,
|
1165 |
-
'conditional_logic' => 0,
|
1166 |
-
'wrapper' => array(
|
1167 |
-
'width' => '',
|
1168 |
-
'class' => '',
|
1169 |
-
'id' => '',
|
1170 |
-
),
|
1171 |
-
'acfe_validate' => '',
|
1172 |
-
'acfe_update' => '',
|
1173 |
-
'acfe_permissions' => '',
|
1174 |
-
'default_value' => '',
|
1175 |
-
'placeholder' => '',
|
1176 |
-
'prepend' => '',
|
1177 |
-
'append' => '',
|
1178 |
-
'maxlength' => '',
|
1179 |
-
),
|
1180 |
-
array(
|
1181 |
-
'key' => 'field_acfe_dpt_view_item',
|
1182 |
-
'label' => 'View item',
|
1183 |
-
'name' => 'view_item',
|
1184 |
-
'type' => 'text',
|
1185 |
-
'instructions' => '',
|
1186 |
-
'required' => 0,
|
1187 |
-
'conditional_logic' => 0,
|
1188 |
-
'wrapper' => array(
|
1189 |
-
'width' => '',
|
1190 |
-
'class' => '',
|
1191 |
-
'id' => '',
|
1192 |
-
),
|
1193 |
-
'acfe_validate' => '',
|
1194 |
-
'acfe_update' => '',
|
1195 |
-
'acfe_permissions' => '',
|
1196 |
-
'default_value' => '',
|
1197 |
-
'placeholder' => '',
|
1198 |
-
'prepend' => '',
|
1199 |
-
'append' => '',
|
1200 |
-
'maxlength' => '',
|
1201 |
-
),
|
1202 |
-
array(
|
1203 |
-
'key' => 'field_acfe_dpt_view_items',
|
1204 |
-
'label' => 'View items',
|
1205 |
-
'name' => 'view_items',
|
1206 |
-
'type' => 'text',
|
1207 |
-
'instructions' => '',
|
1208 |
-
'required' => 0,
|
1209 |
-
'conditional_logic' => 0,
|
1210 |
-
'wrapper' => array(
|
1211 |
-
'width' => '',
|
1212 |
-
'class' => '',
|
1213 |
-
'id' => '',
|
1214 |
-
),
|
1215 |
-
'acfe_validate' => '',
|
1216 |
-
'acfe_update' => '',
|
1217 |
-
'acfe_permissions' => '',
|
1218 |
-
'default_value' => '',
|
1219 |
-
'placeholder' => '',
|
1220 |
-
'prepend' => '',
|
1221 |
-
'append' => '',
|
1222 |
-
'maxlength' => '',
|
1223 |
-
),
|
1224 |
-
array(
|
1225 |
-
'key' => 'field_acfe_dpt_search_items',
|
1226 |
-
'label' => 'Search items',
|
1227 |
-
'name' => 'search_items',
|
1228 |
-
'type' => 'text',
|
1229 |
-
'instructions' => '',
|
1230 |
-
'required' => 0,
|
1231 |
-
'conditional_logic' => 0,
|
1232 |
-
'wrapper' => array(
|
1233 |
-
'width' => '',
|
1234 |
-
'class' => '',
|
1235 |
-
'id' => '',
|
1236 |
-
),
|
1237 |
-
'acfe_validate' => '',
|
1238 |
-
'acfe_update' => '',
|
1239 |
-
'acfe_permissions' => '',
|
1240 |
-
'default_value' => '',
|
1241 |
-
'placeholder' => '',
|
1242 |
-
'prepend' => '',
|
1243 |
-
'append' => '',
|
1244 |
-
'maxlength' => '',
|
1245 |
-
),
|
1246 |
-
array(
|
1247 |
-
'key' => 'field_acfe_dpt_not_found',
|
1248 |
-
'label' => 'Not found',
|
1249 |
-
'name' => 'not_found',
|
1250 |
-
'type' => 'text',
|
1251 |
-
'instructions' => '',
|
1252 |
-
'required' => 0,
|
1253 |
-
'conditional_logic' => 0,
|
1254 |
-
'wrapper' => array(
|
1255 |
-
'width' => '',
|
1256 |
-
'class' => '',
|
1257 |
-
'id' => '',
|
1258 |
-
),
|
1259 |
-
'acfe_validate' => '',
|
1260 |
-
'acfe_update' => '',
|
1261 |
-
'acfe_permissions' => '',
|
1262 |
-
'default_value' => '',
|
1263 |
-
'placeholder' => '',
|
1264 |
-
'prepend' => '',
|
1265 |
-
'append' => '',
|
1266 |
-
'maxlength' => '',
|
1267 |
-
),
|
1268 |
-
array(
|
1269 |
-
'key' => 'field_acfe_dpt_not_found_in_trash',
|
1270 |
-
'label' => 'Not found in trash',
|
1271 |
-
'name' => 'not_found_in_trash',
|
1272 |
-
'type' => 'text',
|
1273 |
-
'instructions' => '',
|
1274 |
-
'required' => 0,
|
1275 |
-
'conditional_logic' => 0,
|
1276 |
-
'wrapper' => array(
|
1277 |
-
'width' => '',
|
1278 |
-
'class' => '',
|
1279 |
-
'id' => '',
|
1280 |
-
),
|
1281 |
-
'acfe_validate' => '',
|
1282 |
-
'acfe_update' => '',
|
1283 |
-
'acfe_permissions' => '',
|
1284 |
-
'default_value' => '',
|
1285 |
-
'placeholder' => '',
|
1286 |
-
'prepend' => '',
|
1287 |
-
'append' => '',
|
1288 |
-
'maxlength' => '',
|
1289 |
-
),
|
1290 |
-
array(
|
1291 |
-
'key' => 'field_acfe_dpt_parent_item_colon',
|
1292 |
-
'label' => 'Parent item colon',
|
1293 |
-
'name' => 'parent_item_colon',
|
1294 |
-
'type' => 'text',
|
1295 |
-
'instructions' => '',
|
1296 |
-
'required' => 0,
|
1297 |
-
'conditional_logic' => 0,
|
1298 |
-
'wrapper' => array(
|
1299 |
-
'width' => '',
|
1300 |
-
'class' => '',
|
1301 |
-
'id' => '',
|
1302 |
-
),
|
1303 |
-
'acfe_validate' => '',
|
1304 |
-
'acfe_update' => '',
|
1305 |
-
'acfe_permissions' => '',
|
1306 |
-
'default_value' => '',
|
1307 |
-
'placeholder' => '',
|
1308 |
-
'prepend' => '',
|
1309 |
-
'append' => '',
|
1310 |
-
'maxlength' => '',
|
1311 |
-
),
|
1312 |
-
array(
|
1313 |
-
'key' => 'field_acfe_dpt_all_items',
|
1314 |
-
'label' => 'All items',
|
1315 |
-
'name' => 'all_items',
|
1316 |
-
'type' => 'text',
|
1317 |
-
'instructions' => '',
|
1318 |
-
'required' => 0,
|
1319 |
-
'conditional_logic' => 0,
|
1320 |
-
'wrapper' => array(
|
1321 |
-
'width' => '',
|
1322 |
-
'class' => '',
|
1323 |
-
'id' => '',
|
1324 |
-
),
|
1325 |
-
'acfe_validate' => '',
|
1326 |
-
'acfe_update' => '',
|
1327 |
-
'acfe_permissions' => '',
|
1328 |
-
'default_value' => '',
|
1329 |
-
'placeholder' => '',
|
1330 |
-
'prepend' => '',
|
1331 |
-
'append' => '',
|
1332 |
-
'maxlength' => '',
|
1333 |
-
),
|
1334 |
-
array(
|
1335 |
-
'key' => 'field_acfe_dpt_archives',
|
1336 |
-
'label' => 'Archives',
|
1337 |
-
'name' => 'archives',
|
1338 |
-
'type' => 'text',
|
1339 |
-
'instructions' => '',
|
1340 |
-
'required' => 0,
|
1341 |
-
'conditional_logic' => 0,
|
1342 |
-
'wrapper' => array(
|
1343 |
-
'width' => '',
|
1344 |
-
'class' => '',
|
1345 |
-
'id' => '',
|
1346 |
-
),
|
1347 |
-
'acfe_validate' => '',
|
1348 |
-
'acfe_update' => '',
|
1349 |
-
'acfe_permissions' => '',
|
1350 |
-
'default_value' => '',
|
1351 |
-
'placeholder' => '',
|
1352 |
-
'prepend' => '',
|
1353 |
-
'append' => '',
|
1354 |
-
'maxlength' => '',
|
1355 |
-
),
|
1356 |
-
array(
|
1357 |
-
'key' => 'field_acfe_dpt_attributes',
|
1358 |
-
'label' => 'Attributes',
|
1359 |
-
'name' => 'attributes',
|
1360 |
-
'type' => 'text',
|
1361 |
-
'instructions' => '',
|
1362 |
-
'required' => 0,
|
1363 |
-
'conditional_logic' => 0,
|
1364 |
-
'wrapper' => array(
|
1365 |
-
'width' => '',
|
1366 |
-
'class' => '',
|
1367 |
-
'id' => '',
|
1368 |
-
),
|
1369 |
-
'acfe_validate' => '',
|
1370 |
-
'acfe_update' => '',
|
1371 |
-
'acfe_permissions' => '',
|
1372 |
-
'default_value' => '',
|
1373 |
-
'placeholder' => '',
|
1374 |
-
'prepend' => '',
|
1375 |
-
'append' => '',
|
1376 |
-
'maxlength' => '',
|
1377 |
-
),
|
1378 |
-
array(
|
1379 |
-
'key' => 'field_acfe_dpt_insert_into_item',
|
1380 |
-
'label' => 'Insert into item',
|
1381 |
-
'name' => 'insert_into_item',
|
1382 |
-
'type' => 'text',
|
1383 |
-
'instructions' => '',
|
1384 |
-
'required' => 0,
|
1385 |
-
'conditional_logic' => 0,
|
1386 |
-
'wrapper' => array(
|
1387 |
-
'width' => '',
|
1388 |
-
'class' => '',
|
1389 |
-
'id' => '',
|
1390 |
-
),
|
1391 |
-
'acfe_validate' => '',
|
1392 |
-
'acfe_update' => '',
|
1393 |
-
'acfe_permissions' => '',
|
1394 |
-
'default_value' => '',
|
1395 |
-
'placeholder' => '',
|
1396 |
-
'prepend' => '',
|
1397 |
-
'append' => '',
|
1398 |
-
'maxlength' => '',
|
1399 |
-
),
|
1400 |
-
array(
|
1401 |
-
'key' => 'field_acfe_dpt_uploaded_to_this_item',
|
1402 |
-
'label' => 'Uploaded to this item',
|
1403 |
-
'name' => 'uploaded_to_this_item',
|
1404 |
-
'type' => 'text',
|
1405 |
-
'instructions' => '',
|
1406 |
-
'required' => 0,
|
1407 |
-
'conditional_logic' => 0,
|
1408 |
-
'wrapper' => array(
|
1409 |
-
'width' => '',
|
1410 |
-
'class' => '',
|
1411 |
-
'id' => '',
|
1412 |
-
),
|
1413 |
-
'acfe_validate' => '',
|
1414 |
-
'acfe_update' => '',
|
1415 |
-
'acfe_permissions' => '',
|
1416 |
-
'default_value' => '',
|
1417 |
-
'placeholder' => '',
|
1418 |
-
'prepend' => '',
|
1419 |
-
'append' => '',
|
1420 |
-
'maxlength' => '',
|
1421 |
-
),
|
1422 |
-
array(
|
1423 |
-
'key' => 'field_acfe_dpt_featured_image',
|
1424 |
-
'label' => 'Featured image',
|
1425 |
-
'name' => 'featured_image',
|
1426 |
-
'type' => 'text',
|
1427 |
-
'instructions' => '',
|
1428 |
-
'required' => 0,
|
1429 |
-
'conditional_logic' => 0,
|
1430 |
-
'wrapper' => array(
|
1431 |
-
'width' => '',
|
1432 |
-
'class' => '',
|
1433 |
-
'id' => '',
|
1434 |
-
),
|
1435 |
-
'acfe_validate' => '',
|
1436 |
-
'acfe_update' => '',
|
1437 |
-
'acfe_permissions' => '',
|
1438 |
-
'default_value' => '',
|
1439 |
-
'placeholder' => '',
|
1440 |
-
'prepend' => '',
|
1441 |
-
'append' => '',
|
1442 |
-
'maxlength' => '',
|
1443 |
-
),
|
1444 |
-
array(
|
1445 |
-
'key' => 'field_acfe_dpt_set_featured_image',
|
1446 |
-
'label' => 'Set featured image',
|
1447 |
-
'name' => 'set_featured_image',
|
1448 |
-
'type' => 'text',
|
1449 |
-
'instructions' => '',
|
1450 |
-
'required' => 0,
|
1451 |
-
'conditional_logic' => 0,
|
1452 |
-
'wrapper' => array(
|
1453 |
-
'width' => '',
|
1454 |
-
'class' => '',
|
1455 |
-
'id' => '',
|
1456 |
-
),
|
1457 |
-
'acfe_validate' => '',
|
1458 |
-
'acfe_update' => '',
|
1459 |
-
'acfe_permissions' => '',
|
1460 |
-
'default_value' => '',
|
1461 |
-
'placeholder' => '',
|
1462 |
-
'prepend' => '',
|
1463 |
-
'append' => '',
|
1464 |
-
'maxlength' => '',
|
1465 |
-
),
|
1466 |
-
array(
|
1467 |
-
'key' => 'field_acfe_dpt_remove_featured_image',
|
1468 |
-
'label' => 'Remove featured image',
|
1469 |
-
'name' => 'remove_featured_image',
|
1470 |
-
'type' => 'text',
|
1471 |
-
'instructions' => '',
|
1472 |
-
'required' => 0,
|
1473 |
-
'conditional_logic' => 0,
|
1474 |
-
'wrapper' => array(
|
1475 |
-
'width' => '',
|
1476 |
-
'class' => '',
|
1477 |
-
'id' => '',
|
1478 |
-
),
|
1479 |
-
'acfe_validate' => '',
|
1480 |
-
'acfe_update' => '',
|
1481 |
-
'acfe_permissions' => '',
|
1482 |
-
'default_value' => '',
|
1483 |
-
'placeholder' => '',
|
1484 |
-
'prepend' => '',
|
1485 |
-
'append' => '',
|
1486 |
-
'maxlength' => '',
|
1487 |
-
),
|
1488 |
-
array(
|
1489 |
-
'key' => 'field_acfe_dpt_use_featured_image',
|
1490 |
-
'label' => 'Use featured image',
|
1491 |
-
'name' => 'use_featured_image',
|
1492 |
-
'type' => 'text',
|
1493 |
-
'instructions' => '',
|
1494 |
-
'required' => 0,
|
1495 |
-
'conditional_logic' => 0,
|
1496 |
-
'wrapper' => array(
|
1497 |
-
'width' => '',
|
1498 |
-
'class' => '',
|
1499 |
-
'id' => '',
|
1500 |
-
),
|
1501 |
-
'acfe_validate' => '',
|
1502 |
-
'acfe_update' => '',
|
1503 |
-
'acfe_permissions' => '',
|
1504 |
-
'default_value' => '',
|
1505 |
-
'placeholder' => '',
|
1506 |
-
'prepend' => '',
|
1507 |
-
'append' => '',
|
1508 |
-
'maxlength' => '',
|
1509 |
-
),
|
1510 |
-
array(
|
1511 |
-
'key' => 'field_acfe_dpt_menu_name',
|
1512 |
-
'label' => 'Menu name',
|
1513 |
-
'name' => 'menu_name',
|
1514 |
-
'type' => 'text',
|
1515 |
-
'instructions' => '',
|
1516 |
-
'required' => 0,
|
1517 |
-
'conditional_logic' => 0,
|
1518 |
-
'wrapper' => array(
|
1519 |
-
'width' => '',
|
1520 |
-
'class' => '',
|
1521 |
-
'id' => '',
|
1522 |
-
),
|
1523 |
-
'acfe_validate' => '',
|
1524 |
-
'acfe_update' => '',
|
1525 |
-
'acfe_permissions' => '',
|
1526 |
-
'default_value' => '',
|
1527 |
-
'placeholder' => '',
|
1528 |
-
'prepend' => '',
|
1529 |
-
'append' => '',
|
1530 |
-
'maxlength' => '',
|
1531 |
-
),
|
1532 |
-
array(
|
1533 |
-
'key' => 'field_acfe_dpt_filter_items_list',
|
1534 |
-
'label' => 'Filter items list',
|
1535 |
-
'name' => 'filter_items_list',
|
1536 |
-
'type' => 'text',
|
1537 |
-
'instructions' => '',
|
1538 |
-
'required' => 0,
|
1539 |
-
'conditional_logic' => 0,
|
1540 |
-
'wrapper' => array(
|
1541 |
-
'width' => '',
|
1542 |
-
'class' => '',
|
1543 |
-
'id' => '',
|
1544 |
-
),
|
1545 |
-
'acfe_validate' => '',
|
1546 |
-
'acfe_update' => '',
|
1547 |
-
'acfe_permissions' => '',
|
1548 |
-
'default_value' => '',
|
1549 |
-
'placeholder' => '',
|
1550 |
-
'prepend' => '',
|
1551 |
-
'append' => '',
|
1552 |
-
'maxlength' => '',
|
1553 |
-
),
|
1554 |
-
array(
|
1555 |
-
'key' => 'field_acfe_dpt_items_list_navigation',
|
1556 |
-
'label' => 'Items list navigation',
|
1557 |
-
'name' => 'items_list_navigation',
|
1558 |
-
'type' => 'text',
|
1559 |
-
'instructions' => '',
|
1560 |
-
'required' => 0,
|
1561 |
-
'conditional_logic' => 0,
|
1562 |
-
'wrapper' => array(
|
1563 |
-
'width' => '',
|
1564 |
-
'class' => '',
|
1565 |
-
'id' => '',
|
1566 |
-
),
|
1567 |
-
'acfe_validate' => '',
|
1568 |
-
'acfe_update' => '',
|
1569 |
-
'acfe_permissions' => '',
|
1570 |
-
'default_value' => '',
|
1571 |
-
'placeholder' => '',
|
1572 |
-
'prepend' => '',
|
1573 |
-
'append' => '',
|
1574 |
-
'maxlength' => '',
|
1575 |
-
),
|
1576 |
-
array(
|
1577 |
-
'key' => 'field_acfe_dpt_items_list',
|
1578 |
-
'label' => 'Items list',
|
1579 |
-
'name' => 'items_list',
|
1580 |
-
'type' => 'text',
|
1581 |
-
'instructions' => '',
|
1582 |
-
'required' => 0,
|
1583 |
-
'conditional_logic' => 0,
|
1584 |
-
'wrapper' => array(
|
1585 |
-
'width' => '',
|
1586 |
-
'class' => '',
|
1587 |
-
'id' => '',
|
1588 |
-
),
|
1589 |
-
'acfe_validate' => '',
|
1590 |
-
'acfe_update' => '',
|
1591 |
-
'acfe_permissions' => '',
|
1592 |
-
'default_value' => '',
|
1593 |
-
'placeholder' => '',
|
1594 |
-
'prepend' => '',
|
1595 |
-
'append' => '',
|
1596 |
-
'maxlength' => '',
|
1597 |
-
),
|
1598 |
-
array(
|
1599 |
-
'key' => 'field_acfe_dpt_name_admin_bar',
|
1600 |
-
'label' => 'Name admin bar',
|
1601 |
-
'name' => 'name_admin_bar',
|
1602 |
-
'type' => 'text',
|
1603 |
-
'instructions' => '',
|
1604 |
-
'required' => 0,
|
1605 |
-
'conditional_logic' => 0,
|
1606 |
-
'wrapper' => array(
|
1607 |
-
'width' => '',
|
1608 |
-
'class' => '',
|
1609 |
-
'id' => '',
|
1610 |
-
),
|
1611 |
-
'acfe_validate' => '',
|
1612 |
-
'acfe_update' => '',
|
1613 |
-
'acfe_permissions' => '',
|
1614 |
-
'default_value' => '',
|
1615 |
-
'placeholder' => '',
|
1616 |
-
'prepend' => '',
|
1617 |
-
'append' => '',
|
1618 |
-
'maxlength' => '',
|
1619 |
-
),
|
1620 |
-
array(
|
1621 |
-
'key' => 'field_acfe_dpt_item_published',
|
1622 |
-
'label' => 'Item published',
|
1623 |
-
'name' => 'item_published',
|
1624 |
-
'type' => 'text',
|
1625 |
-
'instructions' => '',
|
1626 |
-
'required' => 0,
|
1627 |
-
'conditional_logic' => 0,
|
1628 |
-
'wrapper' => array(
|
1629 |
-
'width' => '',
|
1630 |
-
'class' => '',
|
1631 |
-
'id' => '',
|
1632 |
-
),
|
1633 |
-
'acfe_validate' => '',
|
1634 |
-
'acfe_update' => '',
|
1635 |
-
'acfe_permissions' => '',
|
1636 |
-
'default_value' => '',
|
1637 |
-
'placeholder' => '',
|
1638 |
-
'prepend' => '',
|
1639 |
-
'append' => '',
|
1640 |
-
'maxlength' => '',
|
1641 |
-
),
|
1642 |
-
array(
|
1643 |
-
'key' => 'field_acfe_dpt_item_published_privately',
|
1644 |
-
'label' => 'Item published privately',
|
1645 |
-
'name' => 'item_published_privately',
|
1646 |
-
'type' => 'text',
|
1647 |
-
'instructions' => '',
|
1648 |
-
'required' => 0,
|
1649 |
-
'conditional_logic' => 0,
|
1650 |
-
'wrapper' => array(
|
1651 |
-
'width' => '',
|
1652 |
-
'class' => '',
|
1653 |
-
'id' => '',
|
1654 |
-
),
|
1655 |
-
'acfe_validate' => '',
|
1656 |
-
'acfe_update' => '',
|
1657 |
-
'acfe_permissions' => '',
|
1658 |
-
'default_value' => '',
|
1659 |
-
'placeholder' => '',
|
1660 |
-
'prepend' => '',
|
1661 |
-
'append' => '',
|
1662 |
-
'maxlength' => '',
|
1663 |
-
),
|
1664 |
-
array(
|
1665 |
-
'key' => 'field_acfe_dpt_item_reverted_to_draft',
|
1666 |
-
'label' => 'Item reverted to draft',
|
1667 |
-
'name' => 'item_reverted_to_draft',
|
1668 |
-
'type' => 'text',
|
1669 |
-
'instructions' => '',
|
1670 |
-
'required' => 0,
|
1671 |
-
'conditional_logic' => 0,
|
1672 |
-
'wrapper' => array(
|
1673 |
-
'width' => '',
|
1674 |
-
'class' => '',
|
1675 |
-
'id' => '',
|
1676 |
-
),
|
1677 |
-
'acfe_validate' => '',
|
1678 |
-
'acfe_update' => '',
|
1679 |
-
'acfe_permissions' => '',
|
1680 |
-
'default_value' => '',
|
1681 |
-
'placeholder' => '',
|
1682 |
-
'prepend' => '',
|
1683 |
-
'append' => '',
|
1684 |
-
'maxlength' => '',
|
1685 |
-
),
|
1686 |
-
array(
|
1687 |
-
'key' => 'field_acfe_dpt_item_scheduled',
|
1688 |
-
'label' => 'Item scheduled',
|
1689 |
-
'name' => 'item_scheduled',
|
1690 |
-
'type' => 'text',
|
1691 |
-
'instructions' => '',
|
1692 |
-
'required' => 0,
|
1693 |
-
'conditional_logic' => 0,
|
1694 |
-
'wrapper' => array(
|
1695 |
-
'width' => '',
|
1696 |
-
'class' => '',
|
1697 |
-
'id' => '',
|
1698 |
-
),
|
1699 |
-
'acfe_validate' => '',
|
1700 |
-
'acfe_update' => '',
|
1701 |
-
'acfe_permissions' => '',
|
1702 |
-
'default_value' => '',
|
1703 |
-
'placeholder' => '',
|
1704 |
-
'prepend' => '',
|
1705 |
-
'append' => '',
|
1706 |
-
'maxlength' => '',
|
1707 |
-
),
|
1708 |
-
array(
|
1709 |
-
'key' => 'field_acfe_dpt_item_updated',
|
1710 |
-
'label' => 'Item updated',
|
1711 |
-
'name' => 'item_updated',
|
1712 |
-
'type' => 'text',
|
1713 |
-
'instructions' => '',
|
1714 |
-
'required' => 0,
|
1715 |
-
'conditional_logic' => 0,
|
1716 |
-
'wrapper' => array(
|
1717 |
-
'width' => '',
|
1718 |
-
'class' => '',
|
1719 |
-
'id' => '',
|
1720 |
-
),
|
1721 |
-
'acfe_validate' => '',
|
1722 |
-
'acfe_update' => '',
|
1723 |
-
'acfe_permissions' => '',
|
1724 |
-
'default_value' => '',
|
1725 |
-
'placeholder' => '',
|
1726 |
-
'prepend' => '',
|
1727 |
-
'append' => '',
|
1728 |
-
'maxlength' => '',
|
1729 |
-
),
|
1730 |
-
),
|
1731 |
-
),
|
1732 |
-
array(
|
1733 |
-
'key' => 'field_acfe_dpt_tab_menu',
|
1734 |
-
'label' => 'Menu',
|
1735 |
-
'name' => '',
|
1736 |
-
'type' => 'tab',
|
1737 |
-
'instructions' => '',
|
1738 |
-
'required' => 0,
|
1739 |
-
'conditional_logic' => 0,
|
1740 |
-
'wrapper' => array(
|
1741 |
-
'width' => '',
|
1742 |
-
'class' => '',
|
1743 |
-
'id' => '',
|
1744 |
-
),
|
1745 |
-
'acfe_permissions' => '',
|
1746 |
-
'placement' => 'top',
|
1747 |
-
'endpoint' => 0,
|
1748 |
-
),
|
1749 |
-
array(
|
1750 |
-
'key' => 'field_acfe_dpt_menu_position',
|
1751 |
-
'label' => 'Menu position',
|
1752 |
-
'name' => 'menu_position',
|
1753 |
-
'type' => 'number',
|
1754 |
-
'instructions' => 'The position in the menu order the post type should appear. show_in_menu must be true',
|
1755 |
-
'required' => 0,
|
1756 |
-
'conditional_logic' => 0,
|
1757 |
-
'wrapper' => array(
|
1758 |
-
'width' => '',
|
1759 |
-
'class' => '',
|
1760 |
-
'id' => '',
|
1761 |
-
),
|
1762 |
-
'acfe_validate' => '',
|
1763 |
-
'acfe_update' => '',
|
1764 |
-
'acfe_permissions' => '',
|
1765 |
-
'default_value' => 20,
|
1766 |
-
'placeholder' => '',
|
1767 |
-
'prepend' => '',
|
1768 |
-
'append' => '',
|
1769 |
-
'min' => 0,
|
1770 |
-
'max' => '',
|
1771 |
-
'step' => '',
|
1772 |
-
),
|
1773 |
-
array(
|
1774 |
-
'key' => 'field_acfe_dpt_menu_icon',
|
1775 |
-
'label' => 'Menu icon',
|
1776 |
-
'name' => 'menu_icon',
|
1777 |
-
'type' => 'text',
|
1778 |
-
'instructions' => 'The url to the icon to be used for this menu or the name of the icon from the iconfont (<a href="https://developer.wordpress.org/resource/dashicons/" target="_blank">Dashicons</a>)',
|
1779 |
-
'required' => 0,
|
1780 |
-
'conditional_logic' => 0,
|
1781 |
-
'wrapper' => array(
|
1782 |
-
'width' => '',
|
1783 |
-
'class' => '',
|
1784 |
-
'id' => '',
|
1785 |
-
),
|
1786 |
-
'acfe_validate' => '',
|
1787 |
-
'acfe_update' => '',
|
1788 |
-
'acfe_permissions' => '',
|
1789 |
-
'default_value' => 'dashicons-admin-post',
|
1790 |
-
'placeholder' => '',
|
1791 |
-
'prepend' => '',
|
1792 |
-
'append' => '',
|
1793 |
-
'maxlength' => '',
|
1794 |
-
),
|
1795 |
-
array(
|
1796 |
-
'key' => 'field_acfe_dpt_show_ui',
|
1797 |
-
'label' => 'Show UI',
|
1798 |
-
'name' => 'show_ui',
|
1799 |
-
'type' => 'true_false',
|
1800 |
-
'instructions' => 'Whether to generate a default UI for managing this post type in the admin',
|
1801 |
-
'required' => 0,
|
1802 |
-
'conditional_logic' => 0,
|
1803 |
-
'wrapper' => array(
|
1804 |
-
'width' => '',
|
1805 |
-
'class' => '',
|
1806 |
-
'id' => '',
|
1807 |
-
),
|
1808 |
-
'acfe_validate' => '',
|
1809 |
-
'acfe_update' => '',
|
1810 |
-
'acfe_permissions' => '',
|
1811 |
-
'message' => '',
|
1812 |
-
'default_value' => 1,
|
1813 |
-
'ui' => 1,
|
1814 |
-
'ui_on_text' => '',
|
1815 |
-
'ui_off_text' => '',
|
1816 |
-
),
|
1817 |
-
array(
|
1818 |
-
'key' => 'field_acfe_dpt_show_in_menu',
|
1819 |
-
'label' => 'Show in menu',
|
1820 |
-
'name' => 'show_in_menu',
|
1821 |
-
'type' => 'true_false',
|
1822 |
-
'instructions' => 'Where to show the post type in the admin menu. show_ui must be true',
|
1823 |
-
'required' => 0,
|
1824 |
-
'conditional_logic' => 0,
|
1825 |
-
'wrapper' => array(
|
1826 |
-
'width' => '',
|
1827 |
-
'class' => '',
|
1828 |
-
'id' => '',
|
1829 |
-
),
|
1830 |
-
'acfe_validate' => '',
|
1831 |
-
'acfe_update' => '',
|
1832 |
-
'acfe_permissions' => '',
|
1833 |
-
'message' => '',
|
1834 |
-
'default_value' => 1,
|
1835 |
-
'ui' => 1,
|
1836 |
-
'ui_on_text' => '',
|
1837 |
-
'ui_off_text' => '',
|
1838 |
-
),
|
1839 |
-
array(
|
1840 |
-
'key' => 'field_acfe_dpt_show_in_menu_text',
|
1841 |
-
'label' => 'Show in menu (text)',
|
1842 |
-
'name' => 'show_in_menu_text',
|
1843 |
-
'type' => 'text',
|
1844 |
-
'instructions' => 'If an existing top level page such as \'tools.php\' or \'edit.php?post_type=page\', the post type will be placed as a sub menu of that',
|
1845 |
-
'required' => 0,
|
1846 |
-
'conditional_logic' => array(
|
1847 |
-
array(
|
1848 |
-
array(
|
1849 |
-
'field' => 'field_5c9f5dd58d5ee',
|
1850 |
-
'operator' => '==',
|
1851 |
-
'value' => '1',
|
1852 |
-
),
|
1853 |
-
),
|
1854 |
-
),
|
1855 |
-
'wrapper' => array(
|
1856 |
-
'width' => '',
|
1857 |
-
'class' => '',
|
1858 |
-
'id' => '',
|
1859 |
-
),
|
1860 |
-
'acfe_validate' => '',
|
1861 |
-
'acfe_update' => '',
|
1862 |
-
'acfe_permissions' => '',
|
1863 |
-
'default_value' => '',
|
1864 |
-
'placeholder' => '',
|
1865 |
-
'prepend' => '',
|
1866 |
-
'append' => '',
|
1867 |
-
'maxlength' => '',
|
1868 |
-
),
|
1869 |
-
array(
|
1870 |
-
'key' => 'field_acfe_dpt_show_in_nav_menus',
|
1871 |
-
'label' => 'Show in nav menus',
|
1872 |
-
'name' => 'show_in_nav_menus',
|
1873 |
-
'type' => 'true_false',
|
1874 |
-
'instructions' => 'Whether post_type is available for selection in navigation menus',
|
1875 |
-
'required' => 0,
|
1876 |
-
'conditional_logic' => 0,
|
1877 |
-
'wrapper' => array(
|
1878 |
-
'width' => '',
|
1879 |
-
'class' => '',
|
1880 |
-
'id' => '',
|
1881 |
-
),
|
1882 |
-
'acfe_validate' => '',
|
1883 |
-
'acfe_update' => '',
|
1884 |
-
'acfe_permissions' => '',
|
1885 |
-
'message' => '',
|
1886 |
-
'default_value' => 1,
|
1887 |
-
'ui' => 1,
|
1888 |
-
'ui_on_text' => '',
|
1889 |
-
'ui_off_text' => '',
|
1890 |
-
),
|
1891 |
-
array(
|
1892 |
-
'key' => 'field_acfe_dpt_show_in_admin_bar',
|
1893 |
-
'label' => 'Show in admin bar',
|
1894 |
-
'name' => 'show_in_admin_bar',
|
1895 |
-
'type' => 'true_false',
|
1896 |
-
'instructions' => 'Where to show the post type in the admin menu. show_ui must be true',
|
1897 |
-
'required' => 0,
|
1898 |
-
'conditional_logic' => 0,
|
1899 |
-
'wrapper' => array(
|
1900 |
-
'width' => '',
|
1901 |
-
'class' => '',
|
1902 |
-
'id' => '',
|
1903 |
-
),
|
1904 |
-
'acfe_validate' => '',
|
1905 |
-
'acfe_update' => '',
|
1906 |
-
'acfe_permissions' => '',
|
1907 |
-
'message' => '',
|
1908 |
-
'default_value' => 1,
|
1909 |
-
'ui' => 1,
|
1910 |
-
'ui_on_text' => '',
|
1911 |
-
'ui_off_text' => '',
|
1912 |
-
),
|
1913 |
-
array(
|
1914 |
-
'key' => 'field_acfe_dpt_tab_capability',
|
1915 |
-
'label' => 'Capability',
|
1916 |
-
'name' => '',
|
1917 |
-
'type' => 'tab',
|
1918 |
-
'instructions' => '',
|
1919 |
-
'required' => 0,
|
1920 |
-
'conditional_logic' => 0,
|
1921 |
-
'wrapper' => array(
|
1922 |
-
'width' => '',
|
1923 |
-
'class' => '',
|
1924 |
-
'id' => '',
|
1925 |
-
),
|
1926 |
-
'acfe_permissions' => '',
|
1927 |
-
'placement' => 'top',
|
1928 |
-
'endpoint' => 0,
|
1929 |
-
),
|
1930 |
-
array(
|
1931 |
-
'key' => 'field_acfe_dpt_capability_type',
|
1932 |
-
'label' => 'Capability type',
|
1933 |
-
'name' => 'capability_type',
|
1934 |
-
'type' => 'textarea',
|
1935 |
-
'instructions' => 'The string to use to build the read, edit, and delete capabilities.<br />
|
1936 |
-
May be passed as an array to allow for alternative plurals when using this argument as a base to construct the capabilities, like this:<br /><br />
|
1937 |
-
|
1938 |
-
story<br />
|
1939 |
-
stories',
|
1940 |
-
'required' => 0,
|
1941 |
-
'conditional_logic' => 0,
|
1942 |
-
'wrapper' => array(
|
1943 |
-
'width' => '',
|
1944 |
-
'class' => '',
|
1945 |
-
'id' => '',
|
1946 |
-
),
|
1947 |
-
'acfe_validate' => '',
|
1948 |
-
'acfe_update' => '',
|
1949 |
-
'acfe_permissions' => '',
|
1950 |
-
'default_value' => 'post',
|
1951 |
-
'placeholder' => '',
|
1952 |
-
'maxlength' => '',
|
1953 |
-
'rows' => '',
|
1954 |
-
'new_lines' => '',
|
1955 |
-
),
|
1956 |
-
array(
|
1957 |
-
'key' => 'field_acfe_dpt_capabilities',
|
1958 |
-
'label' => 'Capabilities',
|
1959 |
-
'name' => 'capabilities',
|
1960 |
-
'type' => 'textarea',
|
1961 |
-
'instructions' => 'An array of the capabilities for this post type. Specify capabilities like this:<br /><br />
|
1962 |
-
|
1963 |
-
edit_post<br />
|
1964 |
-
read_post<br />
|
1965 |
-
delete_post<br />
|
1966 |
-
edit_posts<br />
|
1967 |
-
etc...',
|
1968 |
-
'required' => 0,
|
1969 |
-
'conditional_logic' => 0,
|
1970 |
-
'wrapper' => array(
|
1971 |
-
'width' => '',
|
1972 |
-
'class' => '',
|
1973 |
-
'id' => '',
|
1974 |
-
),
|
1975 |
-
'acfe_validate' => '',
|
1976 |
-
'acfe_update' => '',
|
1977 |
-
'acfe_permissions' => '',
|
1978 |
-
'default_value' => '',
|
1979 |
-
'placeholder' => '',
|
1980 |
-
'maxlength' => '',
|
1981 |
-
'rows' => '',
|
1982 |
-
'new_lines' => '',
|
1983 |
-
),
|
1984 |
-
array(
|
1985 |
-
'key' => 'field_acfe_dpt_map_meta_cap',
|
1986 |
-
'label' => 'Map meta cap',
|
1987 |
-
'name' => 'map_meta_cap',
|
1988 |
-
'type' => 'select',
|
1989 |
-
'instructions' => '',
|
1990 |
-
'required' => 0,
|
1991 |
-
'conditional_logic' => 0,
|
1992 |
-
'wrapper' => array(
|
1993 |
-
'width' => '',
|
1994 |
-
'class' => '',
|
1995 |
-
'id' => '',
|
1996 |
-
),
|
1997 |
-
'acfe_validate' => '',
|
1998 |
-
'acfe_update' => '',
|
1999 |
-
'acfe_permissions' => '',
|
2000 |
-
'choices' => array(
|
2001 |
-
'null' => 'Null (default)',
|
2002 |
-
'false' => 'False',
|
2003 |
-
'true' => 'True',
|
2004 |
-
),
|
2005 |
-
'default_value' => array(
|
2006 |
-
0 => 'null',
|
2007 |
-
),
|
2008 |
-
'allow_null' => 0,
|
2009 |
-
'multiple' => 0,
|
2010 |
-
'ui' => 0,
|
2011 |
-
'return_format' => 'value',
|
2012 |
-
'ajax' => 0,
|
2013 |
-
'placeholder' => '',
|
2014 |
-
),
|
2015 |
-
array(
|
2016 |
-
'key' => 'field_acfe_dpt_tab_archive',
|
2017 |
-
'label' => 'Archive',
|
2018 |
-
'name' => '',
|
2019 |
-
'type' => 'tab',
|
2020 |
-
'instructions' => '',
|
2021 |
-
'required' => 0,
|
2022 |
-
'conditional_logic' => 0,
|
2023 |
-
'wrapper' => array(
|
2024 |
-
'width' => '',
|
2025 |
-
'class' => '',
|
2026 |
-
'id' => '',
|
2027 |
-
),
|
2028 |
-
'acfe_permissions' => '',
|
2029 |
-
'placement' => 'top',
|
2030 |
-
'endpoint' => 0,
|
2031 |
-
),
|
2032 |
-
array(
|
2033 |
-
'key' => 'field_acfe_dpt_archive_template',
|
2034 |
-
'label' => 'Template',
|
2035 |
-
'name' => 'acfe_dpt_archive_template',
|
2036 |
-
'type' => 'text',
|
2037 |
-
'instructions' => 'ACF Extended: Which template file to load for the archive query. More informations on <a href="https://developer.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|