Version Description
ACF Extended Pro 0.8.7.6: * Field Groups: WP Settings Locations - Added new "General Settings", "Writing", "Reading", "Discussion", "Media" & "Permalinks" locations * Module: Global Field Condition - Fixed compatibility with required fields * Module: Dynamic Templates - Added Polylang/WPML compatibility * Module: Dynamic Templates - Improved code logic & compatibility with Clone fields * Module: Dynamic Forms - Added "Options Page Action". Allowing to Save & Load meta to ACF Options Page * Module: Dynamic Forms - Fixed "Email Action" to correctly use Multiple Upload files * Module: Dynamic Forms - Fixed Multiple Upload files on front-end for not logged users * Module: Dynamic Forms - Fixed Multiple Upload & Dropzone in Basic mode on Firefox * Field: Relationship/Post Object - Fixed Inline Post Creation when only one post type was allowed in the field setting
ACF Extended Basic 0.8.7.6:
* Module: Enhanced UI - Improved logic, compatibility and style. ACF Field Groups can now use any position and any style in Users & Terms views
* Module: Enhanced UI - Fixed Terms WPML widget compatibility
* Module: Dynamic Post Types - "Archive Page" submenu is now correctly translated
* Module: Dynamic Forms - Fixed values loaded from Clones Fields in Seamless display
* Module: Dynamic Forms - Enhanced Image/File format value when using the {field:my_file}
Template Tag
* Module: Multilang - Added "Current Language" text widget in Options Page submit box
* Module: Multilang - Polylang - Added fallback to "Default Language" in Options Page values if a translated option was never saved before
* Module: Multilang - Polylang - Fixed "Dynamic Forms" & "Dynamic Template" post types detection
* Module: PHP AutoSync - Fixed Local Field Group detection when using a custom submenu on the ACF Field Group menu
* Core: Added default acf.data.acfe
in core JS
* Core: Fixed ACF Pro 5.8 JS compatibility
* Core: Fixed Google Map suggestions z-index CSS in modals
Release Info
Developer | hwk-fr |
Plugin | Advanced Custom Fields: Extended |
Version | 0.8.7.6 |
Comparing to | |
See all releases |
Code changes from version 0.8.7.5 to 0.8.7.6
- acf-extended.php +328 -326
- assets/css/acfe-admin.css +9 -1
- assets/css/acfe-admin.min.css +1 -1
- assets/css/acfe-ui.css +426 -195
- assets/css/acfe-ui.min.css +1 -1
- assets/css/acfe.css +5 -0
- assets/css/acfe.min.css +1 -1
- assets/js/acfe-admin.js +524 -524
- assets/js/acfe-field-group.js +329 -417
- assets/js/acfe-field-group.min.js +1 -1
- assets/js/acfe-input.js +3364 -3364
- assets/js/acfe-ui.js +382 -0
- assets/js/acfe-ui.min.js +1 -0
- assets/js/acfe.js +431 -426
- assets/js/acfe.min.js +1 -1
- includes/admin/options.class.php +276 -276
- includes/admin/options.php +578 -578
- includes/admin/plugins.php +41 -41
- includes/admin/settings.php +452 -452
- includes/admin/tools/dbt-export.php +396 -396
- includes/admin/tools/dbt-import.php +208 -208
- includes/admin/tools/dop-export.php +395 -395
- includes/admin/tools/dop-import.php +206 -206
- includes/admin/tools/dpt-export.php +400 -400
- includes/admin/tools/dpt-import.php +241 -241
- includes/admin/tools/dt-export.php +410 -410
- includes/admin/tools/dt-import.php +239 -239
- includes/admin/tools/fg-export.php +64 -64
- includes/admin/tools/fg-local.php +332 -332
- includes/admin/tools/form-export.php +238 -238
- includes/admin/tools/form-import.php +458 -458
- includes/admin/views/html-options-edit.php +60 -60
- includes/admin/views/html-options-list.php +37 -37
- includes/core/compatibility.php +286 -284
- includes/core/enqueue.php +107 -91
- includes/core/helpers.php +1591 -1481
- includes/core/hooks.php +157 -157
- includes/core/menu.php +122 -122
- includes/core/multilang.php +699 -470
- includes/core/settings.php +502 -502
- includes/core/upgrades.php +654 -654
- includes/field-groups/field-group-advanced.php +61 -61
- includes/field-groups/field-group-category.php +260 -260
- includes/field-groups/field-group-display-title.php +34 -34
- includes/field-groups/field-group-hide-on-screen.php +134 -134
- includes/field-groups/field-group-instruction-placement.php +56 -56
- includes/field-groups/field-group-meta.php +90 -183
@@ -1,327 +1,329 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Plugin Name: Advanced Custom Fields: Extended
|
4 |
-
* Description: All-in-one enhancement suite that improves WordPress & Advanced Custom Fields.
|
5 |
-
* Version: 0.8.7.
|
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 |
-
// Vars
|
19 |
-
var $version = '0.8.7.
|
20 |
-
var $acf = false;
|
21 |
-
|
22 |
-
/*
|
23 |
-
* Construct
|
24 |
-
*/
|
25 |
-
function __construct(){
|
26 |
-
// ...
|
27 |
-
}
|
28 |
-
|
29 |
-
/*
|
30 |
-
* Initialize
|
31 |
-
*/
|
32 |
-
function initialize(){
|
33 |
-
|
34 |
-
// Constants
|
35 |
-
$this->constants(array(
|
36 |
-
'ACFE' => true,
|
37 |
-
'ACFE_FILE' => __FILE__,
|
38 |
-
'ACFE_PATH' => plugin_dir_path(__FILE__),
|
39 |
-
'ACFE_VERSION' => $this->version,
|
40 |
-
'ACFE_BASENAME' => plugin_basename(__FILE__),
|
41 |
-
));
|
42 |
-
|
43 |
-
// Init
|
44 |
-
include_once(ACFE_PATH . 'init.php');
|
45 |
-
|
46 |
-
// Load
|
47 |
-
add_action('acf/include_field_types', array($this, 'load'));
|
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 |
-
'modules/
|
90 |
-
'modules/
|
91 |
-
'modules/
|
92 |
-
'modules/
|
93 |
-
'modules/
|
94 |
-
'modules/
|
95 |
-
'modules/
|
96 |
-
'modules/
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
//
|
104 |
-
add_action('acf/
|
105 |
-
|
106 |
-
//
|
107 |
-
add_action('acf/
|
108 |
-
|
109 |
-
//
|
110 |
-
add_action('acf/
|
111 |
-
|
112 |
-
//
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
acfe_include('includes/core/
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
acfe_include('includes/core/
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
acfe_include('includes/admin/
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
acfe_include('includes/fields/field-
|
151 |
-
acfe_include('includes/fields/field-
|
152 |
-
acfe_include('includes/fields/field-
|
153 |
-
acfe_include('includes/fields/field-
|
154 |
-
acfe_include('includes/fields/field-
|
155 |
-
acfe_include('includes/fields/field-
|
156 |
-
acfe_include('includes/fields/field-
|
157 |
-
acfe_include('includes/fields/field-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
acfe_include('includes/fields-settings/
|
165 |
-
acfe_include('includes/fields-settings/
|
166 |
-
acfe_include('includes/fields-settings/
|
167 |
-
acfe_include('includes/fields-settings/
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
acfe_include('includes/field-groups/field-group
|
175 |
-
acfe_include('includes/field-groups/field-group-
|
176 |
-
acfe_include('includes/field-groups/field-group-
|
177 |
-
acfe_include('includes/field-groups/field-group-
|
178 |
-
acfe_include('includes/field-groups/field-group-
|
179 |
-
acfe_include('includes/field-groups/field-group-
|
180 |
-
acfe_include('includes/field-groups/field-
|
181 |
-
acfe_include('includes/field-groups/field-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
acfe_include('includes/locations/post-type-
|
189 |
-
acfe_include('includes/locations/
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
acfe_include('includes/modules/
|
197 |
-
acfe_include('includes/modules/
|
198 |
-
acfe_include('includes/modules/dynamic-
|
199 |
-
acfe_include('includes/modules/dynamic-
|
200 |
-
acfe_include('includes/modules/dynamic-
|
201 |
-
acfe_include('includes/modules/
|
202 |
-
acfe_include('includes/modules/
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
acfe_include('includes/fields/field-
|
223 |
-
acfe_include('includes/fields/field-
|
224 |
-
acfe_include('includes/fields/field-
|
225 |
-
acfe_include('includes/fields/field-
|
226 |
-
acfe_include('includes/fields/field-
|
227 |
-
acfe_include('includes/fields/field-
|
228 |
-
acfe_include('includes/fields/field-
|
229 |
-
acfe_include('includes/fields/field-
|
230 |
-
acfe_include('includes/fields/field-
|
231 |
-
acfe_include('includes/fields/field-
|
232 |
-
acfe_include('includes/fields/field-
|
233 |
-
acfe_include('includes/fields/field-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
acfe_include('includes/admin/tools/
|
245 |
-
acfe_include('includes/admin/tools/
|
246 |
-
acfe_include('includes/admin/tools/
|
247 |
-
acfe_include('includes/admin/tools/
|
248 |
-
acfe_include('includes/admin/tools/
|
249 |
-
acfe_include('includes/admin/tools/
|
250 |
-
|
251 |
-
acfe_include('includes/admin/tools/
|
252 |
-
|
253 |
-
acfe_include('includes/admin/tools/
|
254 |
-
acfe_include('includes/admin/tools/
|
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 |
endif;
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Plugin Name: Advanced Custom Fields: Extended
|
4 |
+
* Description: All-in-one enhancement suite that improves WordPress & Advanced Custom Fields.
|
5 |
+
* Version: 0.8.7.6
|
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 |
+
// Vars
|
19 |
+
var $version = '0.8.7.6';
|
20 |
+
var $acf = false;
|
21 |
+
|
22 |
+
/*
|
23 |
+
* Construct
|
24 |
+
*/
|
25 |
+
function __construct(){
|
26 |
+
// ...
|
27 |
+
}
|
28 |
+
|
29 |
+
/*
|
30 |
+
* Initialize
|
31 |
+
*/
|
32 |
+
function initialize(){
|
33 |
+
|
34 |
+
// Constants
|
35 |
+
$this->constants(array(
|
36 |
+
'ACFE' => true,
|
37 |
+
'ACFE_FILE' => __FILE__,
|
38 |
+
'ACFE_PATH' => plugin_dir_path(__FILE__),
|
39 |
+
'ACFE_VERSION' => $this->version,
|
40 |
+
'ACFE_BASENAME' => plugin_basename(__FILE__),
|
41 |
+
));
|
42 |
+
|
43 |
+
// Init
|
44 |
+
include_once(ACFE_PATH . 'init.php');
|
45 |
+
|
46 |
+
// Load
|
47 |
+
add_action('acf/include_field_types', array($this, 'load'));
|
48 |
+
|
49 |
+
// Compatibility
|
50 |
+
acfe_include('includes/core/compatibility.php');
|
51 |
+
|
52 |
+
}
|
53 |
+
|
54 |
+
/*
|
55 |
+
* Load
|
56 |
+
*/
|
57 |
+
function load(){
|
58 |
+
|
59 |
+
if(!$this->has_acf())
|
60 |
+
return;
|
61 |
+
|
62 |
+
// Vars
|
63 |
+
$theme_path = acf_get_setting('acfe/theme_path', get_stylesheet_directory());
|
64 |
+
$theme_url = acf_get_setting('acfe/theme_url', get_stylesheet_directory_uri());
|
65 |
+
|
66 |
+
// Settings
|
67 |
+
$this->settings(array(
|
68 |
+
|
69 |
+
// General
|
70 |
+
'url' => plugin_dir_url(__FILE__),
|
71 |
+
'theme_path' => $theme_path,
|
72 |
+
'theme_url' => $theme_url,
|
73 |
+
'theme_folder' => parse_url($theme_url, PHP_URL_PATH),
|
74 |
+
|
75 |
+
// Php
|
76 |
+
'php' => true,
|
77 |
+
'php_save' => "{$theme_path}/acfe-php",
|
78 |
+
'php_load' => array("{$theme_path}/acfe-php"),
|
79 |
+
'php_found' => false,
|
80 |
+
|
81 |
+
// Json
|
82 |
+
'json' => acf_get_setting('json'),
|
83 |
+
'json_save' => acf_get_setting('save_json'),
|
84 |
+
'json_load' => acf_get_setting('load_json'),
|
85 |
+
'json_found' => false,
|
86 |
+
|
87 |
+
// Modules
|
88 |
+
'dev' => false,
|
89 |
+
'modules/author' => true,
|
90 |
+
'modules/categories' => true,
|
91 |
+
'modules/dynamic_block_types' => true,
|
92 |
+
'modules/dynamic_forms' => true,
|
93 |
+
'modules/dynamic_options_pages' => true,
|
94 |
+
'modules/dynamic_post_types' => true,
|
95 |
+
'modules/dynamic_taxonomies' => true,
|
96 |
+
'modules/multilang' => true,
|
97 |
+
'modules/options' => true,
|
98 |
+
'modules/single_meta' => false,
|
99 |
+
'modules/ui' => true,
|
100 |
+
|
101 |
+
));
|
102 |
+
|
103 |
+
// Includes
|
104 |
+
add_action('acf/init', array($this, 'includes'), 99);
|
105 |
+
|
106 |
+
// AutoSync
|
107 |
+
add_action('acf/include_fields', array($this, 'autosync'), 5);
|
108 |
+
|
109 |
+
// Fields
|
110 |
+
add_action('acf/include_field_types', array($this, 'fields'), 99);
|
111 |
+
|
112 |
+
// Tools
|
113 |
+
add_action('acf/include_admin_tools', array($this, 'tools'));
|
114 |
+
|
115 |
+
// Additional
|
116 |
+
acfe_include('includes/core/helpers.php');
|
117 |
+
acfe_include('includes/core/multilang.php');
|
118 |
+
acfe_include('includes/core/settings.php');
|
119 |
+
acfe_include('includes/core/upgrades.php');
|
120 |
+
|
121 |
+
}
|
122 |
+
|
123 |
+
/*
|
124 |
+
* Includes
|
125 |
+
*/
|
126 |
+
function includes(){
|
127 |
+
|
128 |
+
/*
|
129 |
+
* Action
|
130 |
+
*/
|
131 |
+
do_action('acfe/init');
|
132 |
+
|
133 |
+
/*
|
134 |
+
* Core
|
135 |
+
*/
|
136 |
+
acfe_include('includes/core/enqueue.php');
|
137 |
+
acfe_include('includes/core/hooks.php');
|
138 |
+
acfe_include('includes/core/menu.php');
|
139 |
+
|
140 |
+
/*
|
141 |
+
* Admin Pages
|
142 |
+
*/
|
143 |
+
acfe_include('includes/admin/options.php');
|
144 |
+
acfe_include('includes/admin/plugins.php');
|
145 |
+
acfe_include('includes/admin/settings.php');
|
146 |
+
|
147 |
+
/*
|
148 |
+
* Fields
|
149 |
+
*/
|
150 |
+
acfe_include('includes/fields/field-checkbox.php');
|
151 |
+
acfe_include('includes/fields/field-clone.php');
|
152 |
+
acfe_include('includes/fields/field-file.php');
|
153 |
+
acfe_include('includes/fields/field-flexible-content.php');
|
154 |
+
acfe_include('includes/fields/field-group.php');
|
155 |
+
acfe_include('includes/fields/field-image.php');
|
156 |
+
acfe_include('includes/fields/field-post-object.php');
|
157 |
+
acfe_include('includes/fields/field-repeater.php');
|
158 |
+
acfe_include('includes/fields/field-select.php');
|
159 |
+
acfe_include('includes/fields/field-textarea.php');
|
160 |
+
|
161 |
+
/*
|
162 |
+
* Fields settings
|
163 |
+
*/
|
164 |
+
acfe_include('includes/fields-settings/bidirectional.php');
|
165 |
+
acfe_include('includes/fields-settings/data.php');
|
166 |
+
acfe_include('includes/fields-settings/instructions.php');
|
167 |
+
acfe_include('includes/fields-settings/permissions.php');
|
168 |
+
acfe_include('includes/fields-settings/settings.php');
|
169 |
+
acfe_include('includes/fields-settings/validation.php');
|
170 |
+
|
171 |
+
/*
|
172 |
+
* Field Groups
|
173 |
+
*/
|
174 |
+
acfe_include('includes/field-groups/field-group.php');
|
175 |
+
acfe_include('includes/field-groups/field-group-advanced.php');
|
176 |
+
acfe_include('includes/field-groups/field-group-category.php');
|
177 |
+
acfe_include('includes/field-groups/field-group-display-title.php');
|
178 |
+
acfe_include('includes/field-groups/field-group-hide-on-screen.php');
|
179 |
+
acfe_include('includes/field-groups/field-group-instruction-placement.php');
|
180 |
+
acfe_include('includes/field-groups/field-group-meta.php');
|
181 |
+
acfe_include('includes/field-groups/field-group-permissions.php');
|
182 |
+
acfe_include('includes/field-groups/field-groups.php');
|
183 |
+
acfe_include('includes/field-groups/field-groups-local.php');
|
184 |
+
|
185 |
+
/*
|
186 |
+
* Locations
|
187 |
+
*/
|
188 |
+
acfe_include('includes/locations/post-type-all.php');
|
189 |
+
acfe_include('includes/locations/post-type-archive.php');
|
190 |
+
acfe_include('includes/locations/post-type-list.php');
|
191 |
+
acfe_include('includes/locations/taxonomy-list.php');
|
192 |
+
|
193 |
+
/*
|
194 |
+
* Modules
|
195 |
+
*/
|
196 |
+
acfe_include('includes/modules/author.php');
|
197 |
+
acfe_include('includes/modules/dev.php');
|
198 |
+
acfe_include('includes/modules/dynamic-block-type.php');
|
199 |
+
acfe_include('includes/modules/dynamic-form.php');
|
200 |
+
acfe_include('includes/modules/dynamic-options-page.php');
|
201 |
+
acfe_include('includes/modules/dynamic-post-type.php');
|
202 |
+
acfe_include('includes/modules/dynamic-taxonomy.php');
|
203 |
+
acfe_include('includes/modules/single-meta.php');
|
204 |
+
acfe_include('includes/modules/ui.php');
|
205 |
+
|
206 |
+
}
|
207 |
+
|
208 |
+
/*
|
209 |
+
* AutoSync
|
210 |
+
*/
|
211 |
+
function autosync(){
|
212 |
+
|
213 |
+
acfe_include('includes/modules/autosync.php');
|
214 |
+
|
215 |
+
}
|
216 |
+
|
217 |
+
/*
|
218 |
+
* Fields
|
219 |
+
*/
|
220 |
+
function fields(){
|
221 |
+
|
222 |
+
acfe_include('includes/fields/field-advanced-link.php');
|
223 |
+
acfe_include('includes/fields/field-button.php');
|
224 |
+
acfe_include('includes/fields/field-code-editor.php');
|
225 |
+
acfe_include('includes/fields/field-column.php');
|
226 |
+
acfe_include('includes/fields/field-dynamic-message.php');
|
227 |
+
acfe_include('includes/fields/field-forms.php');
|
228 |
+
acfe_include('includes/fields/field-hidden.php');
|
229 |
+
acfe_include('includes/fields/field-post-statuses.php');
|
230 |
+
acfe_include('includes/fields/field-post-types.php');
|
231 |
+
acfe_include('includes/fields/field-recaptcha.php');
|
232 |
+
acfe_include('includes/fields/field-slug.php');
|
233 |
+
acfe_include('includes/fields/field-taxonomies.php');
|
234 |
+
acfe_include('includes/fields/field-taxonomy-terms.php');
|
235 |
+
acfe_include('includes/fields/field-user-roles.php');
|
236 |
+
|
237 |
+
}
|
238 |
+
|
239 |
+
/*
|
240 |
+
* Tools
|
241 |
+
*/
|
242 |
+
function tools(){
|
243 |
+
|
244 |
+
acfe_include('includes/admin/tools/dbt-export.php');
|
245 |
+
acfe_include('includes/admin/tools/dbt-import.php');
|
246 |
+
acfe_include('includes/admin/tools/dpt-export.php');
|
247 |
+
acfe_include('includes/admin/tools/dpt-import.php');
|
248 |
+
acfe_include('includes/admin/tools/dt-export.php');
|
249 |
+
acfe_include('includes/admin/tools/dt-import.php');
|
250 |
+
acfe_include('includes/admin/tools/dop-export.php');
|
251 |
+
acfe_include('includes/admin/tools/dop-import.php');
|
252 |
+
|
253 |
+
acfe_include('includes/admin/tools/form-export.php');
|
254 |
+
acfe_include('includes/admin/tools/form-import.php');
|
255 |
+
acfe_include('includes/admin/tools/fg-local.php');
|
256 |
+
acfe_include('includes/admin/tools/fg-export.php');
|
257 |
+
|
258 |
+
}
|
259 |
+
|
260 |
+
/*
|
261 |
+
* Set Constants
|
262 |
+
*/
|
263 |
+
function constants($array = array()){
|
264 |
+
|
265 |
+
foreach($array as $name => $value){
|
266 |
+
|
267 |
+
if(defined($name))
|
268 |
+
continue;
|
269 |
+
|
270 |
+
define($name, $value);
|
271 |
+
|
272 |
+
}
|
273 |
+
|
274 |
+
}
|
275 |
+
|
276 |
+
/*
|
277 |
+
* Set Settings
|
278 |
+
*/
|
279 |
+
function settings($array = array()){
|
280 |
+
|
281 |
+
foreach($array as $name => $value){
|
282 |
+
|
283 |
+
// update
|
284 |
+
acf_update_setting("acfe/{$name}", $value);
|
285 |
+
|
286 |
+
add_filter("acf/settings/acfe/{$name}", function($value) use($name){
|
287 |
+
|
288 |
+
return apply_filters("acfe/settings/{$name}", $value);
|
289 |
+
|
290 |
+
}, 5);
|
291 |
+
|
292 |
+
}
|
293 |
+
|
294 |
+
}
|
295 |
+
|
296 |
+
/*
|
297 |
+
* Has ACF
|
298 |
+
*/
|
299 |
+
function has_acf(){
|
300 |
+
|
301 |
+
if($this->acf)
|
302 |
+
return true;
|
303 |
+
|
304 |
+
$this->acf = class_exists('ACF') && defined('ACF_PRO') && defined('ACF_VERSION') && version_compare(ACF_VERSION, '5.8', '>=');
|
305 |
+
|
306 |
+
return $this->acf;
|
307 |
+
|
308 |
+
}
|
309 |
+
|
310 |
+
}
|
311 |
+
|
312 |
+
function acfe(){
|
313 |
+
|
314 |
+
global $acfe;
|
315 |
+
|
316 |
+
if(!isset($acfe)){
|
317 |
+
|
318 |
+
$acfe = new ACFE();
|
319 |
+
$acfe->initialize();
|
320 |
+
|
321 |
+
}
|
322 |
+
|
323 |
+
return $acfe;
|
324 |
+
|
325 |
+
}
|
326 |
+
|
327 |
+
acfe();
|
328 |
+
|
329 |
endif;
|
@@ -628,12 +628,13 @@ body:not(.acf-admin-5-3) .acf-field .select2-container .select2-search--inline .
|
|
628 |
.postbox .handle-order-higher,
|
629 |
.postbox .handle-order-lower {
|
630 |
vertical-align: bottom;
|
|
|
631 |
}
|
632 |
|
633 |
.postbox .handle-order-higher .order-higher-indicator:before,
|
634 |
.postbox .handle-order-lower .order-lower-indicator:before {
|
635 |
font-size: 15px;
|
636 |
-
top: .
|
637 |
}
|
638 |
|
639 |
.postbox .handlediv {
|
@@ -642,6 +643,13 @@ body:not(.acf-admin-5-3) .acf-field .select2-container .select2-search--inline .
|
|
642 |
|
643 |
.postbox .handlediv .toggle-indicator:before {
|
644 |
text-indent: -7px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
645 |
}
|
646 |
|
647 |
.acf-settings-wrap .acf-box {
|
628 |
.postbox .handle-order-higher,
|
629 |
.postbox .handle-order-lower {
|
630 |
vertical-align: bottom;
|
631 |
+
width: 1.42rem;
|
632 |
}
|
633 |
|
634 |
.postbox .handle-order-higher .order-higher-indicator:before,
|
635 |
.postbox .handle-order-lower .order-lower-indicator:before {
|
636 |
font-size: 15px;
|
637 |
+
top: .23rem;
|
638 |
}
|
639 |
|
640 |
.postbox .handlediv {
|
643 |
|
644 |
.postbox .handlediv .toggle-indicator:before {
|
645 |
text-indent: -7px;
|
646 |
+
top: .1rem;
|
647 |
+
}
|
648 |
+
|
649 |
+
#poststuff .stuffbox > h3,
|
650 |
+
#poststuff h2,
|
651 |
+
#poststuff h3.hndle {
|
652 |
+
line-height: 1.48;
|
653 |
}
|
654 |
|
655 |
.acf-settings-wrap .acf-box {
|
@@ -1 +1 @@
|
|
1 |
-
code,kbd,pre,samp{font-family:Menlo,Monaco,Consolas,Courier New,monospace;font-size:1em}pre{display:block;padding:9.5px;margin:0;line-height:1.42857143;color:#333;word-break:break-all;word-wrap:break-word;background-color:#f9f9f9;border:1px solid #ccc;border-radius:1px;white-space:pre-wrap;overflow:auto}code{-webkit-user-select:all;-moz-user-select:all;user-select:all}pre>code{-webkit-user-select:inherit;-moz-user-select:inherit;-ms-user-select:inherit;user-select:inherit;padding:0;margin:0;background:none;font-size:1em;display:block}.code-codemirror>.CodeMirror,.pre-codemirror>.CodeMirror{border:1px solid #ccc;height:auto;width:auto;background:#f9f9f9;padding:9px 6px}.code-codemirror{display:inline;vertical-align:middle}.code-codemirror>.CodeMirror{display:inline-block;padding:0}.code-codemirror>.CodeMirror .CodeMirror-selected,.pre-codemirror>.CodeMirror .CodeMirror-selected{background:#ddd!important}.code-codemirror>.CodeMirror .CodeMirror-lines,.pre-codemirror>.CodeMirror .CodeMirror-lines{padding:0}.acfe-pre-highlight{display:block;padding:9.5px;margin:0;line-height:1.42857143;color:#333;background-color:#f9f9f9;border:1px solid #ccc;border-radius:1px;overflow:auto;font-family:Menlo,Monaco,Consolas,Courier New,monospace;font-size:1em;white-space:nowrap}.acf-postbox.seamless>.inside>.acf-field{padding:15px 12px}.acf-flexible-content .layout.ui-sortable-helper:first-child+.layout.ui-sortable-placeholder{margin-top:0}.acfe-postbox.acfe-postbox-no-handle h2.hndle{cursor:auto}.acfe-postbox.acfe-postbox-no-handle .handlediv{display:none}.acfe-postbox-top>.inside{position:relative}.acfe-postbox-top>.inside.-border{border:1px solid #ccd0d4;background:#fff}.acfe-postbox-top>.inside>.acf-field{position:relative;margin:0;padding:15px 12px;border-top:1px solid #eee}.acfe-postbox-top>.inside>.acf-field:first-child{border-top:none;margin-top:0}.acfe-postbox-left>.inside{position:relative}.acfe-postbox-left>.inside:after{display:block;clear:both;content:""}.acfe-postbox-left>.inside.-border{border:1px solid #ccd0d4;background:#fff}.acfe-postbox-left>.inside>.acf-field{position:relative;margin:0;padding:15px 12px;border-top:1px solid #eee}.acfe-postbox-left>.inside>.acf-field:first-child{border-top:none;margin-top:0}.acfe-postbox-left>.inside.-clear>.acf-field{border:none;padding:0;margin:15px 0}.acfe-postbox-left>.inside>.acf-field{padding:15px 0}.acfe-postbox-left>.inside>.acf-field:after{display:block;clear:both;content:""}.acfe-postbox-left>.inside>.acf-field:before{content:"";display:block;position:absolute;z-index:0;background:#f9f9f9;border:solid #e1e1e1;border-width:0 1px 0 0;top:0;bottom:0;left:0;width:20%}.acfe-postbox-left>.inside>.acf-field[data-width]{float:none;width:auto!important;border-left-width:0!important;border-right-width:0!important}.acfe-postbox-left>.inside>.acf-field>.acf-label{float:left;width:20%;margin:0;padding:0 12px}.acfe-postbox-left>.inside>.acf-field>.acf-input{float:left;width:80%;margin:0;padding:0 12px}html[dir=rtl] .acfe-postbox-left>.inside>.acf-field:before{border-width:0 0 0 1px;left:auto;right:0}html[dir=rtl] .acfe-postbox-left>.inside>.acf-field>.acf-input,html[dir=rtl] .acfe-postbox-left>.inside>.acf-field>.acf-label{float:right}#side-sortables .acfe-postbox-left>.inside>.acf-field:before{display:none}#side-sortables .acfe-postbox-left>.inside>.acf-field>.acf-label{width:100%;margin-bottom:10px}#side-sortables .acfe-postbox-left>.inside>.acf-field>.acf-input{width:100%}@media screen and (max-width:640px){.acfe-postbox-left>.inside>.acf-field:before{display:none}.acfe-postbox-left>.inside>.acf-field>.acf-label{width:100%;margin-bottom:10px}.acfe-postbox-left>.inside>.acf-field>.acf-input{width:100%}}.wrap .acfe-dop-admin-config,.wrap .acfe-dop-admin-config:active,.wrap .acfe-dpt-admin-config,.wrap .acfe-dpt-admin-config:active,.wrap .acfe-dt-admin-config,.wrap .acfe-dt-admin-config:active{padding-left:4px;padding-right:4px}.wrap .acfe-dop-admin-config span,.wrap .acfe-dpt-admin-config span,.wrap .acfe-dt-admin-config span{font-size:16px;vertical-align:text-top;height:15px;width:19px;line-height:19px}.wrap .acfe-dop-admin-config{display:inline-block}body.post-type-acfe-dpt .misc-pub-post-status,body.post-type-acfe-dpt .misc-pub-visibility,body.post-type-acfe-dpt.post-new-php #minor-publishing-actions,body.post-type-acfe-dpt.post-new-php #misc-publishing-actions{display:none}body.post-type-acfe-dpt.post-new-php #major-publishing-actions{border-top:0}body.post-type-acfe-dt .misc-pub-post-status,body.post-type-acfe-dt .misc-pub-visibility,body.post-type-acfe-dt.post-new-php #minor-publishing-actions,body.post-type-acfe-dt.post-new-php #misc-publishing-actions{display:none}body.post-type-acfe-dt.post-new-php #major-publishing-actions{border-top:0}body.post-type-acfe-dop .misc-pub-post-status,body.post-type-acfe-dop .misc-pub-visibility,body.post-type-acfe-dop.post-new-php #minor-publishing-actions,body.post-type-acfe-dop.post-new-php #misc-publishing-actions{display:none}body.post-type-acfe-dop.post-new-php #major-publishing-actions{border-top:0}body.post-type-acfe-dbt .misc-pub-post-status,body.post-type-acfe-dbt .misc-pub-visibility,body.post-type-acfe-dbt.post-new-php #minor-publishing-actions,body.post-type-acfe-dbt.post-new-php #misc-publishing-actions{display:none}body.post-type-acfe-dbt.post-new-php #major-publishing-actions{border-top:0}body.post-type-acfe-form .misc-pub-post-status,body.post-type-acfe-form .misc-pub-visibility,body.post-type-acfe-form.post-new-php #minor-publishing-actions,body.post-type-acfe-form.post-new-php #misc-publishing-actions{display:none}body.post-type-acfe-form.post-new-php #major-publishing-actions{border-top:0}.acf-field.acf-field-acfe-author>.acf-label{display:none}.edit-post-layout__metaboxes:not(:empty){background:#f3f4f5;padding:10px 10px 0!important}.edit-post-layout__metaboxes .edit-post-meta-boxes-area .postbox{margin-bottom:10px;border:1px solid #e1e1e1}.edit-post-layout__metaboxes .edit-post-meta-boxes-area .postbox>.inside{border-bottom:0}#acf-admin-tool-acfe_tool_dbt_export ul,#acf-admin-tool-acfe_tool_dpt_export ul,#acf-admin-tool-acfe_tool_dt_export ul,#acf-admin-tool-acfe_tool_form_export ul{-webkit-column-width:200px;-moz-column-width:200px;column-width:200px}.acf-meta-box-wrap.-grid #acf-admin-tool-acfe-fg-local{display:none}.settings_page_acfe-options .column-option_id{width:65px}.settings_page_acfe-options .column-option_name{width:435px}.settings_page_acfe-options .column-autoload{width:100px;text-align:center}.acf-field[data-name=acfe_form_post_save_post_content_custom],.acf-field[data-name=acfe_form_post_save_post_name_custom],.acf-field[data-name=acfe_form_post_save_post_title_custom],.acf-field[data-name=acfe_form_term_save_description_custom],.acf-field[data-name=acfe_form_term_save_name_custom],.acf-field[data-name=acfe_form_term_save_slug_custom],.acf-field[data-name=acfe_form_user_save_description_custom],.acf-field[data-name=acfe_form_user_save_display_name_custom],.acf-field[data-name=acfe_form_user_save_email_custom],.acf-field[data-name=acfe_form_user_save_first_name_custom],.acf-field[data-name=acfe_form_user_save_last_name_custom],.acf-field[data-name=acfe_form_user_save_nickname_custom],.acf-field[data-name=acfe_form_user_save_password_custom],.acf-field[data-name=acfe_form_user_save_username_custom],.acf-field[data-name=acfe_form_user_save_website_custom]{border-top:0;padding-top:0}.acf-field.acf-field-acfe-form-attributes>.acf-input>.acf-fields>.acf-field,.acf-field.acf-field-acfe-form-fields-attributes>.acf-input>.acf-fields>.acf-field{border-left-width:0}.acf-field-repeater.acf-field-acfe-form-email-files-static>.acf-input>.acf-repeater>.acf-actions,.acf-field-repeater.acf-field-acfe-form-email-files>.acf-input>.acf-repeater>.acf-actions{text-align:left}.postbox#acfe-acf-custom-fields>.inside,.postbox#acfe-wp-custom-fields>.inside{padding:0;margin:0}.postbox#acfe-acf-custom-fields+.tablenav,.postbox#acfe-wp-custom-fields+.tablenav{padding-top:0;margin-top:-8px}.postbox#acfe-acf-custom-fields em,.postbox#acfe-wp-custom-fields em{color:#aaa}.postbox#acfe-acf-custom-fields .acfe_dev_meta_count,.postbox#acfe-wp-custom-fields .acfe_dev_meta_count{background:#72777c;padding:1px 5px;border-radius:4px;color:#fff;margin-left:7px;font-size:12px;margin-right:auto}@media only screen and (max-width:1100px){.postbox#acfe-acf-custom-fields thead,.postbox#acfe-wp-custom-fields thead{display:none}.postbox#acfe-acf-custom-fields tbody tr,.postbox#acfe-wp-custom-fields tbody tr{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap}.postbox#acfe-acf-custom-fields tbody td,.postbox#acfe-acf-custom-fields tbody th,.postbox#acfe-wp-custom-fields tbody td,.postbox#acfe-wp-custom-fields tbody th{display:block}.postbox#acfe-acf-custom-fields tbody td:first-of-type,.postbox#acfe-wp-custom-fields tbody td:first-of-type{-webkit-box-flex:1;-ms-flex:1;flex:1}@media only screen and (max-width:850px){.postbox#acfe-acf-custom-fields tbody td:first-of-type,.postbox#acfe-wp-custom-fields tbody td:first-of-type{line-height:2.2}}.postbox#acfe-acf-custom-fields tbody td:first-of-type strong,.postbox#acfe-wp-custom-fields tbody td:first-of-type strong{display:inline-block;word-break:break-all}.postbox#acfe-acf-custom-fields tbody td:first-of-type .row-actions,.postbox#acfe-wp-custom-fields tbody td:first-of-type .row-actions{display:inline-block;padding:0;float:right}@media only screen and (max-width:850px){.postbox#acfe-acf-custom-fields tbody td:first-of-type .row-actions,.postbox#acfe-wp-custom-fields tbody td:first-of-type .row-actions{left:auto}}.postbox#acfe-acf-custom-fields tbody td:first-of-type .row-actions .delete,.postbox#acfe-acf-custom-fields tbody td:first-of-type .row-actions a,.postbox#acfe-wp-custom-fields tbody td:first-of-type .row-actions .delete,.postbox#acfe-wp-custom-fields tbody td:first-of-type .row-actions a{padding:0}.postbox#acfe-acf-custom-fields tbody td:nth-child(3),.postbox#acfe-wp-custom-fields tbody td:nth-child(3){-webkit-box-flex:1;-ms-flex:1 1 100%;flex:1 1 100%}}body:not(.acf-admin-5-3) .acf-field .select2-container .select2-selection,body:not(.acf-admin-5-3) .acf-field .select2-container .select2-selection__choice,body:not(.acf-admin-5-3) .acf-field .select2-dropdown{border-color:#dfdfdf!important;border-radius:0!important}body:not(.acf-admin-5-3) .acf-field .select2-container .select2-search--inline .select2-search__field{margin-top:0!important}.acf-field .select2-container .select2-selection--single{border-radius:3px!important;height:30px!important;outline:none}.acf-field .select2-container.select2-container--open .select2-selection--single,.acf-field .select2-container:focus .select2-selection--single{border-color:#007cba!important;color:#016087!important;-webkit-box-shadow:0 0 0 1px #007cba!important;box-shadow:0 0 0 1px #007cba!important}.acf-field .select2-container .select2-selection--single .select2-selection__rendered{font-size:14px;height:28px;line-height:27px!important;padding-right:23px!important}.acf-field .select2-container .select2-selection--single .select2-selection__clear{line-height:26px;height:28px;font-size:16px}.acf-field .select2-container--default .select2-selection--single .select2-selection__arrow{height:28px!important}.acf-field .select2-container--default .select2-selection--single .select2-selection__arrow b{background:url("data:image/svg+xml;charset=US-ASCII, %3Csvg%20width%3D%2220%22%20height%3D%2220%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M5%206l5%205%205-5%202%201-7%207-7-7%202-1z%22%20fill%3D%22%23555%22%2F%3E%3C%2Fsvg%3E") no-repeat;background-size:16px 16px;border:0!important;width:16px!important;height:16px!important;margin-left:-11px!important;margin-top:-7px!important}.acf-field .select2-container .select2-search--inline .select2-search__field{margin-top:4px!important;font-size:14px!important;padding-left:2px!important}.acf-field .select2-container .select2-selection--multiple{min-height:30px!important;line-height:1;border-radius:3px!important}.acf-field .select2-container--default .select2-selection--multiple .select2-selection__rendered{padding:0 2px!important}.acf-field .select2-container--default .select2-selection--multiple .select2-selection__choice{margin-right:2px!important;margin-top:2px!important;line-height:1.6;border-radius:3px!important;font-size:14px}.acf-field .select2-container--default .select2-selection--multiple .select2-selection__choice__remove{line-height:15px;font-size:15px}.acf-field .select2-container--default.select2-container--focus .select2-selection--multiple{border-color:#7e8993!important}.acf-field .select2-container--default .select2-selection--multiple .select2-selection__clear{margin-top:5px!important;margin-right:5px!important;font-size:16px}.acf-field>.acf-input>.select2 .select2-search{width:auto}.select2-container .select2-dropdown .select2-search__field{min-height:30px!important;border:0!important;-webkit-box-shadow:none!important;box-shadow:none!important}.acf-tab-group li a .acfe-tab-badge{border-radius:100px;background:#ddd;width:18px;height:18px;font-size:12px;display:inline-block;vertical-align:text-bottom;padding:0;text-align:center;margin-left:5px;line-height:18px}.acf-tab-group li.active a .acfe-tab-badge,.acf-tab-group li a:hover .acfe-tab-badge{background:#f1f1f1}.menu-item-settings{position:static}@media screen and (min-width:783px){.postbox .handle-order-higher,.postbox .handle-order-lower{visibility:hidden}.postbox:hover .handle-order-higher,.postbox:hover .handle-order-lower{visibility:visible}}.postbox .handle-order-higher,.postbox .handle-order-lower{vertical-align:bottom}.postbox .handle-order-higher .order-higher-indicator:before,.postbox .handle-order-lower .order-lower-indicator:before{font-size:15px;top:.18rem}.postbox .handlediv{width:1.62rem}.postbox .handlediv .toggle-indicator:before{text-indent:-7px}.acf-settings-wrap .acf-box{margin:16px 0}.acf-box .title{padding:8px 15px}.acf-box .title h3{line-height:1.4}.acf-columns-2{margin-right:300px;clear:both}.acf-columns-2:after{display:block;clear:both;content:""}html[dir=rtl] .acf-columns-2{margin-right:0;margin-left:300px}.acf-columns-2 .acf-column-1{float:left;width:100%}html[dir=rtl] .acf-columns-2 .acf-column-1{float:right}.acf-columns-2 .acf-column-2{float:right;margin-right:-300px;width:280px}html[dir=rtl] .acf-columns-2 .acf-column-2{float:left;margin-right:0;margin-left:-300px}@media only screen and (max-width:850px){.acf-columns-2{margin-right:0}.acf-columns-2 .acf-column-1,.acf-columns-2 .acf-column-2{float:none;width:auto;margin:0}}
|
1 |
+
code,kbd,pre,samp{font-family:Menlo,Monaco,Consolas,Courier New,monospace;font-size:1em}pre{display:block;padding:9.5px;margin:0;line-height:1.42857143;color:#333;word-break:break-all;word-wrap:break-word;background-color:#f9f9f9;border:1px solid #ccc;border-radius:1px;white-space:pre-wrap;overflow:auto}code{-webkit-user-select:all;-moz-user-select:all;user-select:all}pre>code{-webkit-user-select:inherit;-moz-user-select:inherit;-ms-user-select:inherit;user-select:inherit;padding:0;margin:0;background:none;font-size:1em;display:block}.code-codemirror>.CodeMirror,.pre-codemirror>.CodeMirror{border:1px solid #ccc;height:auto;width:auto;background:#f9f9f9;padding:9px 6px}.code-codemirror{display:inline;vertical-align:middle}.code-codemirror>.CodeMirror{display:inline-block;padding:0}.code-codemirror>.CodeMirror .CodeMirror-selected,.pre-codemirror>.CodeMirror .CodeMirror-selected{background:#ddd!important}.code-codemirror>.CodeMirror .CodeMirror-lines,.pre-codemirror>.CodeMirror .CodeMirror-lines{padding:0}.acfe-pre-highlight{display:block;padding:9.5px;margin:0;line-height:1.42857143;color:#333;background-color:#f9f9f9;border:1px solid #ccc;border-radius:1px;overflow:auto;font-family:Menlo,Monaco,Consolas,Courier New,monospace;font-size:1em;white-space:nowrap}.acf-postbox.seamless>.inside>.acf-field{padding:15px 12px}.acf-flexible-content .layout.ui-sortable-helper:first-child+.layout.ui-sortable-placeholder{margin-top:0}.acfe-postbox.acfe-postbox-no-handle h2.hndle{cursor:auto}.acfe-postbox.acfe-postbox-no-handle .handlediv{display:none}.acfe-postbox-top>.inside{position:relative}.acfe-postbox-top>.inside.-border{border:1px solid #ccd0d4;background:#fff}.acfe-postbox-top>.inside>.acf-field{position:relative;margin:0;padding:15px 12px;border-top:1px solid #eee}.acfe-postbox-top>.inside>.acf-field:first-child{border-top:none;margin-top:0}.acfe-postbox-left>.inside{position:relative}.acfe-postbox-left>.inside:after{display:block;clear:both;content:""}.acfe-postbox-left>.inside.-border{border:1px solid #ccd0d4;background:#fff}.acfe-postbox-left>.inside>.acf-field{position:relative;margin:0;padding:15px 12px;border-top:1px solid #eee}.acfe-postbox-left>.inside>.acf-field:first-child{border-top:none;margin-top:0}.acfe-postbox-left>.inside.-clear>.acf-field{border:none;padding:0;margin:15px 0}.acfe-postbox-left>.inside>.acf-field{padding:15px 0}.acfe-postbox-left>.inside>.acf-field:after{display:block;clear:both;content:""}.acfe-postbox-left>.inside>.acf-field:before{content:"";display:block;position:absolute;z-index:0;background:#f9f9f9;border:solid #e1e1e1;border-width:0 1px 0 0;top:0;bottom:0;left:0;width:20%}.acfe-postbox-left>.inside>.acf-field[data-width]{float:none;width:auto!important;border-left-width:0!important;border-right-width:0!important}.acfe-postbox-left>.inside>.acf-field>.acf-label{float:left;width:20%;margin:0;padding:0 12px}.acfe-postbox-left>.inside>.acf-field>.acf-input{float:left;width:80%;margin:0;padding:0 12px}html[dir=rtl] .acfe-postbox-left>.inside>.acf-field:before{border-width:0 0 0 1px;left:auto;right:0}html[dir=rtl] .acfe-postbox-left>.inside>.acf-field>.acf-input,html[dir=rtl] .acfe-postbox-left>.inside>.acf-field>.acf-label{float:right}#side-sortables .acfe-postbox-left>.inside>.acf-field:before{display:none}#side-sortables .acfe-postbox-left>.inside>.acf-field>.acf-label{width:100%;margin-bottom:10px}#side-sortables .acfe-postbox-left>.inside>.acf-field>.acf-input{width:100%}@media screen and (max-width:640px){.acfe-postbox-left>.inside>.acf-field:before{display:none}.acfe-postbox-left>.inside>.acf-field>.acf-label{width:100%;margin-bottom:10px}.acfe-postbox-left>.inside>.acf-field>.acf-input{width:100%}}.wrap .acfe-dop-admin-config,.wrap .acfe-dop-admin-config:active,.wrap .acfe-dpt-admin-config,.wrap .acfe-dpt-admin-config:active,.wrap .acfe-dt-admin-config,.wrap .acfe-dt-admin-config:active{padding-left:4px;padding-right:4px}.wrap .acfe-dop-admin-config span,.wrap .acfe-dpt-admin-config span,.wrap .acfe-dt-admin-config span{font-size:16px;vertical-align:text-top;height:15px;width:19px;line-height:19px}.wrap .acfe-dop-admin-config{display:inline-block}body.post-type-acfe-dpt .misc-pub-post-status,body.post-type-acfe-dpt .misc-pub-visibility,body.post-type-acfe-dpt.post-new-php #minor-publishing-actions,body.post-type-acfe-dpt.post-new-php #misc-publishing-actions{display:none}body.post-type-acfe-dpt.post-new-php #major-publishing-actions{border-top:0}body.post-type-acfe-dt .misc-pub-post-status,body.post-type-acfe-dt .misc-pub-visibility,body.post-type-acfe-dt.post-new-php #minor-publishing-actions,body.post-type-acfe-dt.post-new-php #misc-publishing-actions{display:none}body.post-type-acfe-dt.post-new-php #major-publishing-actions{border-top:0}body.post-type-acfe-dop .misc-pub-post-status,body.post-type-acfe-dop .misc-pub-visibility,body.post-type-acfe-dop.post-new-php #minor-publishing-actions,body.post-type-acfe-dop.post-new-php #misc-publishing-actions{display:none}body.post-type-acfe-dop.post-new-php #major-publishing-actions{border-top:0}body.post-type-acfe-dbt .misc-pub-post-status,body.post-type-acfe-dbt .misc-pub-visibility,body.post-type-acfe-dbt.post-new-php #minor-publishing-actions,body.post-type-acfe-dbt.post-new-php #misc-publishing-actions{display:none}body.post-type-acfe-dbt.post-new-php #major-publishing-actions{border-top:0}body.post-type-acfe-form .misc-pub-post-status,body.post-type-acfe-form .misc-pub-visibility,body.post-type-acfe-form.post-new-php #minor-publishing-actions,body.post-type-acfe-form.post-new-php #misc-publishing-actions{display:none}body.post-type-acfe-form.post-new-php #major-publishing-actions{border-top:0}.acf-field.acf-field-acfe-author>.acf-label{display:none}.edit-post-layout__metaboxes:not(:empty){background:#f3f4f5;padding:10px 10px 0!important}.edit-post-layout__metaboxes .edit-post-meta-boxes-area .postbox{margin-bottom:10px;border:1px solid #e1e1e1}.edit-post-layout__metaboxes .edit-post-meta-boxes-area .postbox>.inside{border-bottom:0}#acf-admin-tool-acfe_tool_dbt_export ul,#acf-admin-tool-acfe_tool_dpt_export ul,#acf-admin-tool-acfe_tool_dt_export ul,#acf-admin-tool-acfe_tool_form_export ul{-webkit-column-width:200px;-moz-column-width:200px;column-width:200px}.acf-meta-box-wrap.-grid #acf-admin-tool-acfe-fg-local{display:none}.settings_page_acfe-options .column-option_id{width:65px}.settings_page_acfe-options .column-option_name{width:435px}.settings_page_acfe-options .column-autoload{width:100px;text-align:center}.acf-field[data-name=acfe_form_post_save_post_content_custom],.acf-field[data-name=acfe_form_post_save_post_name_custom],.acf-field[data-name=acfe_form_post_save_post_title_custom],.acf-field[data-name=acfe_form_term_save_description_custom],.acf-field[data-name=acfe_form_term_save_name_custom],.acf-field[data-name=acfe_form_term_save_slug_custom],.acf-field[data-name=acfe_form_user_save_description_custom],.acf-field[data-name=acfe_form_user_save_display_name_custom],.acf-field[data-name=acfe_form_user_save_email_custom],.acf-field[data-name=acfe_form_user_save_first_name_custom],.acf-field[data-name=acfe_form_user_save_last_name_custom],.acf-field[data-name=acfe_form_user_save_nickname_custom],.acf-field[data-name=acfe_form_user_save_password_custom],.acf-field[data-name=acfe_form_user_save_username_custom],.acf-field[data-name=acfe_form_user_save_website_custom]{border-top:0;padding-top:0}.acf-field.acf-field-acfe-form-attributes>.acf-input>.acf-fields>.acf-field,.acf-field.acf-field-acfe-form-fields-attributes>.acf-input>.acf-fields>.acf-field{border-left-width:0}.acf-field-repeater.acf-field-acfe-form-email-files-static>.acf-input>.acf-repeater>.acf-actions,.acf-field-repeater.acf-field-acfe-form-email-files>.acf-input>.acf-repeater>.acf-actions{text-align:left}.postbox#acfe-acf-custom-fields>.inside,.postbox#acfe-wp-custom-fields>.inside{padding:0;margin:0}.postbox#acfe-acf-custom-fields+.tablenav,.postbox#acfe-wp-custom-fields+.tablenav{padding-top:0;margin-top:-8px}.postbox#acfe-acf-custom-fields em,.postbox#acfe-wp-custom-fields em{color:#aaa}.postbox#acfe-acf-custom-fields .acfe_dev_meta_count,.postbox#acfe-wp-custom-fields .acfe_dev_meta_count{background:#72777c;padding:1px 5px;border-radius:4px;color:#fff;margin-left:7px;font-size:12px;margin-right:auto}@media only screen and (max-width:1100px){.postbox#acfe-acf-custom-fields thead,.postbox#acfe-wp-custom-fields thead{display:none}.postbox#acfe-acf-custom-fields tbody tr,.postbox#acfe-wp-custom-fields tbody tr{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap}.postbox#acfe-acf-custom-fields tbody td,.postbox#acfe-acf-custom-fields tbody th,.postbox#acfe-wp-custom-fields tbody td,.postbox#acfe-wp-custom-fields tbody th{display:block}.postbox#acfe-acf-custom-fields tbody td:first-of-type,.postbox#acfe-wp-custom-fields tbody td:first-of-type{-webkit-box-flex:1;-ms-flex:1;flex:1}@media only screen and (max-width:850px){.postbox#acfe-acf-custom-fields tbody td:first-of-type,.postbox#acfe-wp-custom-fields tbody td:first-of-type{line-height:2.2}}.postbox#acfe-acf-custom-fields tbody td:first-of-type strong,.postbox#acfe-wp-custom-fields tbody td:first-of-type strong{display:inline-block;word-break:break-all}.postbox#acfe-acf-custom-fields tbody td:first-of-type .row-actions,.postbox#acfe-wp-custom-fields tbody td:first-of-type .row-actions{display:inline-block;padding:0;float:right}@media only screen and (max-width:850px){.postbox#acfe-acf-custom-fields tbody td:first-of-type .row-actions,.postbox#acfe-wp-custom-fields tbody td:first-of-type .row-actions{left:auto}}.postbox#acfe-acf-custom-fields tbody td:first-of-type .row-actions .delete,.postbox#acfe-acf-custom-fields tbody td:first-of-type .row-actions a,.postbox#acfe-wp-custom-fields tbody td:first-of-type .row-actions .delete,.postbox#acfe-wp-custom-fields tbody td:first-of-type .row-actions a{padding:0}.postbox#acfe-acf-custom-fields tbody td:nth-child(3),.postbox#acfe-wp-custom-fields tbody td:nth-child(3){-webkit-box-flex:1;-ms-flex:1 1 100%;flex:1 1 100%}}body:not(.acf-admin-5-3) .acf-field .select2-container .select2-selection,body:not(.acf-admin-5-3) .acf-field .select2-container .select2-selection__choice,body:not(.acf-admin-5-3) .acf-field .select2-dropdown{border-color:#dfdfdf!important;border-radius:0!important}body:not(.acf-admin-5-3) .acf-field .select2-container .select2-search--inline .select2-search__field{margin-top:0!important}.acf-field .select2-container .select2-selection--single{border-radius:3px!important;height:30px!important;outline:none}.acf-field .select2-container.select2-container--open .select2-selection--single,.acf-field .select2-container:focus .select2-selection--single{border-color:#007cba!important;color:#016087!important;-webkit-box-shadow:0 0 0 1px #007cba!important;box-shadow:0 0 0 1px #007cba!important}.acf-field .select2-container .select2-selection--single .select2-selection__rendered{font-size:14px;height:28px;line-height:27px!important;padding-right:23px!important}.acf-field .select2-container .select2-selection--single .select2-selection__clear{line-height:26px;height:28px;font-size:16px}.acf-field .select2-container--default .select2-selection--single .select2-selection__arrow{height:28px!important}.acf-field .select2-container--default .select2-selection--single .select2-selection__arrow b{background:url("data:image/svg+xml;charset=US-ASCII, %3Csvg%20width%3D%2220%22%20height%3D%2220%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M5%206l5%205%205-5%202%201-7%207-7-7%202-1z%22%20fill%3D%22%23555%22%2F%3E%3C%2Fsvg%3E") no-repeat;background-size:16px 16px;border:0!important;width:16px!important;height:16px!important;margin-left:-11px!important;margin-top:-7px!important}.acf-field .select2-container .select2-search--inline .select2-search__field{margin-top:4px!important;font-size:14px!important;padding-left:2px!important}.acf-field .select2-container .select2-selection--multiple{min-height:30px!important;line-height:1;border-radius:3px!important}.acf-field .select2-container--default .select2-selection--multiple .select2-selection__rendered{padding:0 2px!important}.acf-field .select2-container--default .select2-selection--multiple .select2-selection__choice{margin-right:2px!important;margin-top:2px!important;line-height:1.6;border-radius:3px!important;font-size:14px}.acf-field .select2-container--default .select2-selection--multiple .select2-selection__choice__remove{line-height:15px;font-size:15px}.acf-field .select2-container--default.select2-container--focus .select2-selection--multiple{border-color:#7e8993!important}.acf-field .select2-container--default .select2-selection--multiple .select2-selection__clear{margin-top:5px!important;margin-right:5px!important;font-size:16px}.acf-field>.acf-input>.select2 .select2-search{width:auto}.select2-container .select2-dropdown .select2-search__field{min-height:30px!important;border:0!important;-webkit-box-shadow:none!important;box-shadow:none!important}.acf-tab-group li a .acfe-tab-badge{border-radius:100px;background:#ddd;width:18px;height:18px;font-size:12px;display:inline-block;vertical-align:text-bottom;padding:0;text-align:center;margin-left:5px;line-height:18px}.acf-tab-group li.active a .acfe-tab-badge,.acf-tab-group li a:hover .acfe-tab-badge{background:#f1f1f1}.menu-item-settings{position:static}@media screen and (min-width:783px){.postbox .handle-order-higher,.postbox .handle-order-lower{visibility:hidden}.postbox:hover .handle-order-higher,.postbox:hover .handle-order-lower{visibility:visible}}.postbox .handle-order-higher,.postbox .handle-order-lower{vertical-align:bottom;width:1.42rem}.postbox .handle-order-higher .order-higher-indicator:before,.postbox .handle-order-lower .order-lower-indicator:before{font-size:15px;top:.23rem}.postbox .handlediv{width:1.62rem}.postbox .handlediv .toggle-indicator:before{text-indent:-7px;top:.1rem}#poststuff .stuffbox>h3,#poststuff h2,#poststuff h3.hndle{line-height:1.48}.acf-settings-wrap .acf-box{margin:16px 0}.acf-box .title{padding:8px 15px}.acf-box .title h3{line-height:1.4}.acf-columns-2{margin-right:300px;clear:both}.acf-columns-2:after{display:block;clear:both;content:""}html[dir=rtl] .acf-columns-2{margin-right:0;margin-left:300px}.acf-columns-2 .acf-column-1{float:left;width:100%}html[dir=rtl] .acf-columns-2 .acf-column-1{float:right}.acf-columns-2 .acf-column-2{float:right;margin-right:-300px;width:280px}html[dir=rtl] .acf-columns-2 .acf-column-2{float:left;margin-right:0;margin-left:-300px}@media only screen and (max-width:850px){.acf-columns-2{margin-right:0}.acf-columns-2 .acf-column-1,.acf-columns-2 .acf-column-2{float:none;width:auto;margin:0}}
|
@@ -1,7 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
.wrap > form:not(.search-form) {
|
|
|
2 |
max-width: 100% !important;
|
3 |
-
width: 100%;
|
4 |
-
float: left;
|
5 |
}
|
6 |
|
7 |
.wrap > form > div > div > h2,
|
@@ -70,6 +164,7 @@
|
|
70 |
background: #fff;
|
71 |
border-top: 1px solid #eee;
|
72 |
position: static;
|
|
|
73 |
}
|
74 |
|
75 |
.wrap > form .form-table > tbody > tr > td.td-full {
|
@@ -92,30 +187,26 @@
|
|
92 |
color: #444;
|
93 |
}
|
94 |
|
|
|
|
|
|
|
|
|
|
|
95 |
.wrap > form .form-table > tbody > tr:first-of-type td,
|
96 |
.wrap > form .form-table > tbody > tr:first-of-type th {
|
97 |
border-top: 1px solid #ccd0d4;
|
98 |
}
|
99 |
|
100 |
-
.wrap > form
|
101 |
-
|
102 |
-
}
|
103 |
-
|
104 |
-
.wrap > form #poststuff.acfe-acfe-bt-admin-column {
|
105 |
-
min-width: auto;
|
106 |
-
padding: 0;
|
107 |
-
}
|
108 |
-
|
109 |
-
.wrap > form #poststuff.acfe-acfe-bt-admin-column .inside {
|
110 |
-
margin: 0;
|
111 |
-
padding: 0;
|
112 |
}
|
113 |
|
114 |
-
.wrap > form
|
115 |
-
|
|
|
116 |
}
|
117 |
|
118 |
-
@media only screen and (max-width:
|
119 |
.wrap > form > div > div > h2,
|
120 |
.wrap > form > div > div > h3,
|
121 |
.wrap > form > h2,
|
@@ -149,71 +240,101 @@
|
|
149 |
}
|
150 |
}
|
151 |
|
152 |
-
.wrap
|
153 |
-
|
154 |
-
color: #444;
|
155 |
}
|
156 |
|
157 |
-
.wrap
|
158 |
-
padding
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
}
|
160 |
|
161 |
-
.wrap .
|
162 |
-
|
|
|
|
|
|
|
|
|
163 |
}
|
164 |
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
}
|
169 |
}
|
170 |
|
171 |
-
.wrap .
|
172 |
-
width:
|
173 |
}
|
174 |
|
175 |
-
.wrap
|
176 |
-
|
177 |
-
margin-left: 0;
|
178 |
-
padding: 0 12px;
|
179 |
}
|
180 |
|
181 |
-
.wrap
|
182 |
-
|
|
|
183 |
}
|
184 |
|
185 |
-
.wrap
|
186 |
-
|
187 |
-
-webkit-user-select: auto;
|
188 |
-
-moz-user-select: auto;
|
189 |
-
-ms-user-select: auto;
|
190 |
-
user-select: auto;
|
191 |
}
|
192 |
|
193 |
-
.wrap
|
194 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
}
|
196 |
|
197 |
-
.
|
198 |
-
.
|
199 |
-
.user-new-php .wrap#profile-page .form-table textarea {
|
200 |
width: 100%;
|
201 |
-
max-width: 500px;
|
202 |
}
|
203 |
|
204 |
-
.
|
205 |
-
.
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
.
|
|
|
|
|
|
|
210 |
width: 100% !important;
|
211 |
max-width: 500px !important;
|
212 |
}
|
213 |
|
214 |
-
.
|
215 |
-
.
|
216 |
-
.user-new-php .wrap > form select#ure_select_other_roles + .ms-parent .ms-choice {
|
217 |
-webkit-box-shadow: 0 0 0 transparent;
|
218 |
box-shadow: 0 0 0 transparent;
|
219 |
border-radius: 3px;
|
@@ -231,225 +352,335 @@
|
|
231 |
cursor: pointer;
|
232 |
}
|
233 |
|
234 |
-
.
|
235 |
-
.
|
236 |
-
.user-new-php .wrap > form select#ure_select_other_roles + .ms-parent .ms-choice > span.placeholder {
|
237 |
color: #32373c;
|
238 |
}
|
239 |
|
240 |
-
.
|
241 |
-
.
|
242 |
-
.user-edit-php .wrap > form .form-table > tbody > tr > td > br:first-child,
|
243 |
-
.user-edit-php .wrap > form select#ure_select_other_roles + .ms-parent .ms-choice > div,
|
244 |
-
.user-new-php .wrap > form .form-table > tbody > tr > td > br:first-child,
|
245 |
-
.user-new-php .wrap > form select#ure_select_other_roles + .ms-parent .ms-choice > div {
|
246 |
display: none;
|
247 |
}
|
248 |
|
249 |
-
.
|
250 |
-
.
|
251 |
-
.user-new-php .wrap > form .yoast-settings {
|
252 |
-
border: 1px solid #ccd0d4;
|
253 |
padding: 0;
|
254 |
margin-bottom: 20px;
|
255 |
font-size: 13px;
|
256 |
}
|
257 |
|
258 |
-
.
|
259 |
-
.
|
260 |
-
.user-new-php .wrap > form .yoast-settings h2 {
|
261 |
-
background: #fff;
|
262 |
-
border-bottom: 1px solid #ccd0d4;
|
263 |
margin: 0;
|
264 |
-
color: #23282d;
|
265 |
-
font-size: 14px;
|
266 |
-
padding: 8px 12px;
|
267 |
-
line-height: 1.4;
|
268 |
}
|
269 |
|
270 |
-
.
|
271 |
-
.
|
272 |
-
.user-new-php .wrap > form .yoast-settings label {
|
273 |
margin: 0;
|
274 |
padding: 0;
|
275 |
width: auto;
|
276 |
font-size: 13px;
|
277 |
color: #444;
|
|
|
278 |
}
|
279 |
|
280 |
-
.
|
281 |
-
.
|
282 |
-
.user-new-php .wrap > form .yoast-settings p.description {
|
283 |
font-size: 13px;
|
284 |
margin: 0 0 5px;
|
285 |
color: #666;
|
286 |
}
|
287 |
|
288 |
-
.
|
289 |
-
.
|
290 |
-
.
|
291 |
-
.
|
292 |
-
.user-new-php .wrap > form .yoast-settings input,
|
293 |
-
.user-new-php .wrap > form .yoast-settings textarea {
|
294 |
margin: 0;
|
295 |
}
|
296 |
|
297 |
-
.
|
298 |
-
.
|
299 |
-
|
300 |
-
-webkit-box-sizing: border-box;
|
301 |
-
box-sizing: border-box;
|
302 |
}
|
303 |
|
304 |
-
.
|
305 |
-
.
|
306 |
-
|
307 |
-
|
308 |
-
display: -ms-flexbox;
|
309 |
-
display: flex;
|
310 |
-
border-top: 1px solid #eee;
|
311 |
}
|
312 |
|
313 |
-
.
|
314 |
-
.
|
315 |
-
|
316 |
-
border-top: 0;
|
317 |
}
|
318 |
|
319 |
-
.
|
320 |
-
.
|
321 |
-
|
322 |
-
-webkit-box-flex: 0;
|
323 |
-
-ms-flex: 0 0 20%;
|
324 |
-
flex: 0 0 20%;
|
325 |
-
border-right: 1px solid #e1e1e1;
|
326 |
-
background: #f9f9f9;
|
327 |
-
padding: 15px 12px;
|
328 |
}
|
329 |
|
330 |
-
.
|
331 |
-
.
|
332 |
-
|
333 |
-
-webkit-box-flex: 1;
|
334 |
-
-ms-flex: 1;
|
335 |
-
flex: 1;
|
336 |
-
background: #fff;
|
337 |
-
padding: 15px 12px;
|
338 |
}
|
339 |
|
340 |
-
|
341 |
-
.
|
342 |
-
.
|
343 |
-
|
|
|
344 |
}
|
345 |
|
346 |
-
.
|
347 |
-
.
|
348 |
-
|
349 |
-
height: 3px;
|
350 |
}
|
351 |
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
}
|
364 |
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
-webkit-box-direction: normal;
|
370 |
-
-ms-flex-direction: column;
|
371 |
-
flex-direction: column;
|
372 |
-
padding: 15px 12px;
|
373 |
-
}
|
374 |
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
386 |
|
387 |
-
|
388 |
-
|
389 |
-
.user-new-php .wrap > form .yoast-settings .yoast-settings-table .yoast-settings-row .yoast-settings-input {
|
390 |
-
padding: 0;
|
391 |
-
}
|
392 |
}
|
393 |
|
394 |
-
.
|
395 |
-
|
396 |
-
|
|
|
|
|
397 |
display: none;
|
398 |
}
|
399 |
|
400 |
-
.
|
401 |
-
margin
|
|
|
402 |
}
|
403 |
|
404 |
-
.
|
405 |
-
|
406 |
}
|
407 |
|
408 |
-
.
|
409 |
-
|
410 |
}
|
411 |
|
412 |
-
.
|
413 |
-
|
414 |
}
|
415 |
|
416 |
-
.
|
417 |
-
|
418 |
-
|
419 |
-
border-top: 1px solid #ddd;
|
420 |
}
|
421 |
|
422 |
-
.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
423 |
display: none;
|
424 |
}
|
425 |
|
426 |
-
.
|
427 |
-
|
428 |
-
|
|
|
|
|
429 |
}
|
430 |
|
431 |
-
.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
432 |
padding: 0;
|
433 |
}
|
434 |
|
435 |
-
.edit-tags-php #col-left
|
|
|
436 |
float: none;
|
437 |
width: 100%;
|
438 |
}
|
439 |
|
440 |
-
.edit-tags-php #col-left
|
441 |
padding: 0;
|
442 |
}
|
443 |
|
444 |
-
.edit-tags-php #col-left.
|
445 |
min-width: 100%;
|
446 |
}
|
447 |
|
448 |
-
.edit-tags-php #
|
449 |
-
border-
|
450 |
}
|
451 |
|
452 |
-
.edit-tags-php #
|
453 |
-
|
|
|
|
|
|
|
|
|
454 |
margin: 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
455 |
}
|
1 |
+
.wrap {
|
2 |
+
padding-top: 0 !important;
|
3 |
+
min-width: auto !important;
|
4 |
+
}
|
5 |
+
|
6 |
+
@media only screen and (min-width: 782px) {
|
7 |
+
.wrap:not(#poststuff) form#createuser,
|
8 |
+
.wrap:not(#poststuff) form#edittag,
|
9 |
+
.wrap:not(#poststuff) form#your-profile,
|
10 |
+
.wrap:not(#poststuff) form[action="options-permalink.php"],
|
11 |
+
.wrap:not(#poststuff) form[action="options.php"] {
|
12 |
+
max-width: calc(100% - 300px) !important;
|
13 |
+
position: relative;
|
14 |
+
}
|
15 |
+
|
16 |
+
.wrap:not(#poststuff) form#createuser .edit-tag-actions,
|
17 |
+
.wrap:not(#poststuff) form#createuser p.submit,
|
18 |
+
.wrap:not(#poststuff) form#edittag .edit-tag-actions,
|
19 |
+
.wrap:not(#poststuff) form#edittag p.submit,
|
20 |
+
.wrap:not(#poststuff) form#your-profile .edit-tag-actions,
|
21 |
+
.wrap:not(#poststuff) form#your-profile p.submit,
|
22 |
+
.wrap:not(#poststuff) form[action="options-permalink.php"] .edit-tag-actions,
|
23 |
+
.wrap:not(#poststuff) form[action="options-permalink.php"] p.submit,
|
24 |
+
.wrap:not(#poststuff) form[action="options.php"] .edit-tag-actions,
|
25 |
+
.wrap:not(#poststuff) form[action="options.php"] p.submit {
|
26 |
+
-webkit-box-sizing: border-box;
|
27 |
+
box-sizing: border-box;
|
28 |
+
position: absolute;
|
29 |
+
top: 37px;
|
30 |
+
width: 280px;
|
31 |
+
right: -300px;
|
32 |
+
padding: 10px;
|
33 |
+
margin: 0;
|
34 |
+
background: #f5f5f5;
|
35 |
+
text-align: right;
|
36 |
+
border: 1px solid #ccd0d4;
|
37 |
+
border-radius: 0;
|
38 |
+
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
|
39 |
+
box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
|
40 |
+
}
|
41 |
+
|
42 |
+
.wrap:not(#poststuff) form#createuser .edit-tag-actions:before,
|
43 |
+
.wrap:not(#poststuff) form#createuser p.submit:before,
|
44 |
+
.wrap:not(#poststuff) form#edittag .edit-tag-actions:before,
|
45 |
+
.wrap:not(#poststuff) form#edittag p.submit:before,
|
46 |
+
.wrap:not(#poststuff) form#your-profile .edit-tag-actions:before,
|
47 |
+
.wrap:not(#poststuff) form#your-profile p.submit:before,
|
48 |
+
.wrap:not(#poststuff) form[action="options-permalink.php"] .edit-tag-actions:before,
|
49 |
+
.wrap:not(#poststuff) form[action="options-permalink.php"] p.submit:before,
|
50 |
+
.wrap:not(#poststuff) form[action="options.php"] .edit-tag-actions:before,
|
51 |
+
.wrap:not(#poststuff) form[action="options.php"] p.submit:before {
|
52 |
+
-webkit-box-sizing: border-box;
|
53 |
+
box-sizing: border-box;
|
54 |
+
content: "";
|
55 |
+
background: #fff;
|
56 |
+
border: 1px solid #ccd0d4;
|
57 |
+
border-bottom: 0;
|
58 |
+
position: absolute;
|
59 |
+
width: 280px;
|
60 |
+
top: -38px;
|
61 |
+
height: 37px;
|
62 |
+
left: -1px;
|
63 |
+
}
|
64 |
+
|
65 |
+
.wrap:not(#poststuff) form#createuser .edit-tag-actions .button,
|
66 |
+
.wrap:not(#poststuff) form#createuser p.submit .button,
|
67 |
+
.wrap:not(#poststuff) form#edittag .edit-tag-actions .button,
|
68 |
+
.wrap:not(#poststuff) form#edittag p.submit .button,
|
69 |
+
.wrap:not(#poststuff) form#your-profile .edit-tag-actions .button,
|
70 |
+
.wrap:not(#poststuff) form#your-profile p.submit .button,
|
71 |
+
.wrap:not(#poststuff) form[action="options-permalink.php"] .edit-tag-actions .button,
|
72 |
+
.wrap:not(#poststuff) form[action="options-permalink.php"] p.submit .button,
|
73 |
+
.wrap:not(#poststuff) form[action="options.php"] .edit-tag-actions .button,
|
74 |
+
.wrap:not(#poststuff) form[action="options.php"] p.submit .button {
|
75 |
+
min-height: 32px;
|
76 |
+
line-height: 2.30769231;
|
77 |
+
padding: 0 12px;
|
78 |
+
}
|
79 |
+
|
80 |
+
.wrap:not(#poststuff) form#createuser .edit-tag-actions #delete-link,
|
81 |
+
.wrap:not(#poststuff) form#createuser p.submit #delete-link,
|
82 |
+
.wrap:not(#poststuff) form#edittag .edit-tag-actions #delete-link,
|
83 |
+
.wrap:not(#poststuff) form#edittag p.submit #delete-link,
|
84 |
+
.wrap:not(#poststuff) form#your-profile .edit-tag-actions #delete-link,
|
85 |
+
.wrap:not(#poststuff) form#your-profile p.submit #delete-link,
|
86 |
+
.wrap:not(#poststuff) form[action="options-permalink.php"] .edit-tag-actions #delete-link,
|
87 |
+
.wrap:not(#poststuff) form[action="options-permalink.php"] p.submit #delete-link,
|
88 |
+
.wrap:not(#poststuff) form[action="options.php"] .edit-tag-actions #delete-link,
|
89 |
+
.wrap:not(#poststuff) form[action="options.php"] p.submit #delete-link {
|
90 |
+
float: left;
|
91 |
+
margin: 0;
|
92 |
+
text-decoration: underline;
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
.wrap > form:not(.search-form) {
|
97 |
+
margin-top: 13px;
|
98 |
max-width: 100% !important;
|
|
|
|
|
99 |
}
|
100 |
|
101 |
.wrap > form > div > div > h2,
|
164 |
background: #fff;
|
165 |
border-top: 1px solid #eee;
|
166 |
position: static;
|
167 |
+
padding: 15px 12px;
|
168 |
}
|
169 |
|
170 |
.wrap > form .form-table > tbody > tr > td.td-full {
|
187 |
color: #444;
|
188 |
}
|
189 |
|
190 |
+
.wrap > form .form-table > tbody > tr > td.acf-label label,
|
191 |
+
.wrap > form .form-table > tbody > tr > th label {
|
192 |
+
vertical-align: top;
|
193 |
+
}
|
194 |
+
|
195 |
.wrap > form .form-table > tbody > tr:first-of-type td,
|
196 |
.wrap > form .form-table > tbody > tr:first-of-type th {
|
197 |
border-top: 1px solid #ccd0d4;
|
198 |
}
|
199 |
|
200 |
+
.wrap > form .form-table textarea {
|
201 |
+
width: 100%;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
}
|
203 |
|
204 |
+
.wrap > form .form-table .regular-text {
|
205 |
+
width: 100%;
|
206 |
+
max-width: 25em;
|
207 |
}
|
208 |
|
209 |
+
@media only screen and (max-width: 782px) {
|
210 |
.wrap > form > div > div > h2,
|
211 |
.wrap > form > div > div > h3,
|
212 |
.wrap > form > h2,
|
240 |
}
|
241 |
}
|
242 |
|
243 |
+
.wrap #titlediv {
|
244 |
+
margin-bottom: 10px;
|
|
|
245 |
}
|
246 |
|
247 |
+
.wrap #titlediv input {
|
248 |
+
padding: 3px 8px;
|
249 |
+
font-size: 1.7em;
|
250 |
+
line-height: 100%;
|
251 |
+
height: 1.7em;
|
252 |
+
width: 100%;
|
253 |
+
outline: 0;
|
254 |
+
margin: 0 0 3px;
|
255 |
+
background-color: #fff;
|
256 |
}
|
257 |
|
258 |
+
.wrap .postbox .hndle {
|
259 |
+
cursor: auto;
|
260 |
+
-webkit-user-select: auto;
|
261 |
+
-moz-user-select: auto;
|
262 |
+
-ms-user-select: auto;
|
263 |
+
user-select: auto;
|
264 |
}
|
265 |
|
266 |
+
.wrap .postbox .handle-actions button,
|
267 |
+
.wrap .postbox .handle-actions span {
|
268 |
+
display: none;
|
|
|
269 |
}
|
270 |
|
271 |
+
.wrap .postbox .handle-actions .acf-hndle-cog {
|
272 |
+
width: 2.2rem;
|
273 |
}
|
274 |
|
275 |
+
.wrap #submitdiv #major-publishing-actions {
|
276 |
+
border-top: 0;
|
|
|
|
|
277 |
}
|
278 |
|
279 |
+
.wrap #submitdiv #major-publishing-actions #publishing-action {
|
280 |
+
float: none;
|
281 |
+
margin: 0;
|
282 |
}
|
283 |
|
284 |
+
.wrap #submitdiv #major-publishing-actions #publishing-action .button {
|
285 |
+
float: right;
|
|
|
|
|
|
|
|
|
286 |
}
|
287 |
|
288 |
+
.wrap #submitdiv #major-publishing-actions #publishing-action .spinner {
|
289 |
+
margin: 5px 10px 0;
|
290 |
+
}
|
291 |
+
|
292 |
+
.wrap #submitdiv #major-publishing-actions #publishing-action #delete-link {
|
293 |
+
float: left;
|
294 |
+
margin-left: 0;
|
295 |
+
}
|
296 |
+
|
297 |
+
.wrap #submitdiv #major-publishing-actions #publishing-action #delete-link a {
|
298 |
+
text-decoration: underline;
|
299 |
+
}
|
300 |
+
|
301 |
+
.wrap form#createuser .acf-field input[type=email],
|
302 |
+
.wrap form#createuser .acf-field input[type=number],
|
303 |
+
.wrap form#createuser .acf-field input[type=password],
|
304 |
+
.wrap form#createuser .acf-field input[type=search],
|
305 |
+
.wrap form#createuser .acf-field input[type=text],
|
306 |
+
.wrap form#createuser .acf-field input[type=url],
|
307 |
+
.wrap form#createuser .acf-field select,
|
308 |
+
.wrap form#your-profile .acf-field input[type=email],
|
309 |
+
.wrap form#your-profile .acf-field input[type=number],
|
310 |
+
.wrap form#your-profile .acf-field input[type=password],
|
311 |
+
.wrap form#your-profile .acf-field input[type=search],
|
312 |
+
.wrap form#your-profile .acf-field input[type=text],
|
313 |
+
.wrap form#your-profile .acf-field input[type=url],
|
314 |
+
.wrap form#your-profile .acf-field select {
|
315 |
+
max-width: 100%;
|
316 |
}
|
317 |
|
318 |
+
.wrap form#createuser .acf-field textarea,
|
319 |
+
.wrap form#your-profile .acf-field textarea {
|
|
|
320 |
width: 100%;
|
|
|
321 |
}
|
322 |
|
323 |
+
.wrap form#createuser .acf-tab-wrap,
|
324 |
+
.wrap form#your-profile .acf-tab-wrap {
|
325 |
+
position: relative;
|
326 |
+
}
|
327 |
+
|
328 |
+
.wrap form#createuser select#ure_select_other_roles,
|
329 |
+
.wrap form#createuser select#ure_select_other_roles + .ms-parent,
|
330 |
+
.wrap form#your-profile select#ure_select_other_roles,
|
331 |
+
.wrap form#your-profile select#ure_select_other_roles + .ms-parent {
|
332 |
width: 100% !important;
|
333 |
max-width: 500px !important;
|
334 |
}
|
335 |
|
336 |
+
.wrap form#createuser select#ure_select_other_roles + .ms-parent .ms-choice,
|
337 |
+
.wrap form#your-profile select#ure_select_other_roles + .ms-parent .ms-choice {
|
|
|
338 |
-webkit-box-shadow: 0 0 0 transparent;
|
339 |
box-shadow: 0 0 0 transparent;
|
340 |
border-radius: 3px;
|
352 |
cursor: pointer;
|
353 |
}
|
354 |
|
355 |
+
.wrap form#createuser select#ure_select_other_roles + .ms-parent .ms-choice > span.placeholder,
|
356 |
+
.wrap form#your-profile select#ure_select_other_roles + .ms-parent .ms-choice > span.placeholder {
|
|
|
357 |
color: #32373c;
|
358 |
}
|
359 |
|
360 |
+
.wrap form#createuser select#ure_select_other_roles + .ms-parent .ms-choice > div,
|
361 |
+
.wrap form#your-profile select#ure_select_other_roles + .ms-parent .ms-choice > div {
|
|
|
|
|
|
|
|
|
362 |
display: none;
|
363 |
}
|
364 |
|
365 |
+
.wrap form#createuser .yoast-settings,
|
366 |
+
.wrap form#your-profile .yoast-settings {
|
|
|
|
|
367 |
padding: 0;
|
368 |
margin-bottom: 20px;
|
369 |
font-size: 13px;
|
370 |
}
|
371 |
|
372 |
+
.wrap form#createuser .yoast-settings h2,
|
373 |
+
.wrap form#your-profile .yoast-settings h2 {
|
|
|
|
|
|
|
374 |
margin: 0;
|
|
|
|
|
|
|
|
|
375 |
}
|
376 |
|
377 |
+
.wrap form#createuser .yoast-settings label,
|
378 |
+
.wrap form#your-profile .yoast-settings label {
|
|
|
379 |
margin: 0;
|
380 |
padding: 0;
|
381 |
width: auto;
|
382 |
font-size: 13px;
|
383 |
color: #444;
|
384 |
+
line-height: 1.7;
|
385 |
}
|
386 |
|
387 |
+
.wrap form#createuser .yoast-settings .description,
|
388 |
+
.wrap form#your-profile .yoast-settings .description {
|
|
|
389 |
font-size: 13px;
|
390 |
margin: 0 0 5px;
|
391 |
color: #666;
|
392 |
}
|
393 |
|
394 |
+
.wrap form#createuser .yoast-settings input,
|
395 |
+
.wrap form#createuser .yoast-settings textarea,
|
396 |
+
.wrap form#your-profile .yoast-settings input,
|
397 |
+
.wrap form#your-profile .yoast-settings textarea {
|
|
|
|
|
398 |
margin: 0;
|
399 |
}
|
400 |
|
401 |
+
.wrap form#createuser .yoast-settings textarea,
|
402 |
+
.wrap form#your-profile .yoast-settings textarea {
|
403 |
+
margin-bottom: 10px;
|
|
|
|
|
404 |
}
|
405 |
|
406 |
+
.wrap form#createuser .yoast-settings input[type=checkbox],
|
407 |
+
.wrap form#your-profile .yoast-settings input[type=checkbox] {
|
408 |
+
margin-right: 5px;
|
409 |
+
vertical-align: -6px;
|
|
|
|
|
|
|
410 |
}
|
411 |
|
412 |
+
.wrap form#createuser .form-table[role=presentation] tr.user-language-wrap th[colspan="2"],
|
413 |
+
.wrap form#your-profile .form-table[role=presentation] tr.user-language-wrap th[colspan="2"] {
|
414 |
+
display: none;
|
|
|
415 |
}
|
416 |
|
417 |
+
.wrap form#addtag .acf-fields.-left > .acf-field,
|
418 |
+
.wrap form#edittag .acf-fields.-left > .acf-field {
|
419 |
+
padding-left: 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
420 |
}
|
421 |
|
422 |
+
.wrap form#addtag .acf-fields.-left > .acf-field.acfe-bt-no-label,
|
423 |
+
.wrap form#edittag .acf-fields.-left > .acf-field.acfe-bt-no-label {
|
424 |
+
padding-left: 20%;
|
|
|
|
|
|
|
|
|
|
|
425 |
}
|
426 |
|
427 |
+
@media only screen and (max-width: 640px) {
|
428 |
+
.wrap form#addtag .acf-fields.-left > .acf-field.acfe-bt-no-label,
|
429 |
+
.wrap form#edittag .acf-fields.-left > .acf-field.acfe-bt-no-label {
|
430 |
+
padding-left: 0;
|
431 |
+
}
|
432 |
}
|
433 |
|
434 |
+
.wrap form#addtag .acf-fields.-left > .acf-field:before,
|
435 |
+
.wrap form#edittag .acf-fields.-left > .acf-field:before {
|
436 |
+
width: 20%;
|
|
|
437 |
}
|
438 |
|
439 |
+
.wrap form#addtag .acf-fields.-left > .acf-field > .acf-label,
|
440 |
+
.wrap form#edittag .acf-fields.-left > .acf-field > .acf-label {
|
441 |
+
width: 20%;
|
442 |
+
margin-left: 0;
|
443 |
+
padding: 0 12px;
|
444 |
+
}
|
445 |
|
446 |
+
.wrap form#addtag .acf-fields.-left > .acf-field > .acf-label label,
|
447 |
+
.wrap form#edittag .acf-fields.-left > .acf-field > .acf-label label {
|
448 |
+
color: #444;
|
449 |
+
}
|
|
|
450 |
|
451 |
+
.wrap form#addtag .acf-fields.-left > .acf-field > .acf-input,
|
452 |
+
.wrap form#edittag .acf-fields.-left > .acf-field > .acf-input {
|
453 |
+
padding: 0 12px;
|
454 |
+
}
|
|
|
|
|
|
|
|
|
|
|
455 |
|
456 |
+
.wrap form#addtag .form-field p,
|
457 |
+
.wrap form#addtag .form-field select,
|
458 |
+
.wrap form#edittag .form-field p,
|
459 |
+
.wrap form#edittag .form-field select {
|
460 |
+
max-width: 100%;
|
461 |
+
}
|
462 |
+
|
463 |
+
.wrap form#addtag .form-field input[type=email],
|
464 |
+
.wrap form#addtag .form-field input[type=number],
|
465 |
+
.wrap form#addtag .form-field input[type=password],
|
466 |
+
.wrap form#addtag .form-field input[type=search],
|
467 |
+
.wrap form#addtag .form-field input[type=tel],
|
468 |
+
.wrap form#addtag .form-field input[type=text],
|
469 |
+
.wrap form#addtag .form-field input[type=url],
|
470 |
+
.wrap form#addtag .form-field select,
|
471 |
+
.wrap form#addtag .form-field textarea,
|
472 |
+
.wrap form#edittag .form-field input[type=email],
|
473 |
+
.wrap form#edittag .form-field input[type=number],
|
474 |
+
.wrap form#edittag .form-field input[type=password],
|
475 |
+
.wrap form#edittag .form-field input[type=search],
|
476 |
+
.wrap form#edittag .form-field input[type=tel],
|
477 |
+
.wrap form#edittag .form-field input[type=text],
|
478 |
+
.wrap form#edittag .form-field input[type=url],
|
479 |
+
.wrap form#edittag .form-field select,
|
480 |
+
.wrap form#edittag .form-field textarea {
|
481 |
+
width: 100%;
|
482 |
+
}
|
483 |
|
484 |
+
.wrap form#edittag .acf-column-1 > #wp-description-wrap {
|
485 |
+
display: none;
|
|
|
|
|
|
|
486 |
}
|
487 |
|
488 |
+
.wrap form#edittag .postbox.wpseo-taxonomy-metabox-postbox > h2 {
|
489 |
+
border-bottom: 1px solid #ccd0d4;
|
490 |
+
}
|
491 |
+
|
492 |
+
.wrap form#edittag tr.wpml-term-languages-wrap {
|
493 |
display: none;
|
494 |
}
|
495 |
|
496 |
+
.wrap form#edittag #icl-tax-postbox .inside {
|
497 |
+
margin: 0;
|
498 |
+
padding: 15px 12px;
|
499 |
}
|
500 |
|
501 |
+
.wrap form#edittag #icl-tax-postbox .inside table.icl_translations_table {
|
502 |
+
width: 100%;
|
503 |
}
|
504 |
|
505 |
+
.wrap .rank-math-metabox-frame {
|
506 |
+
max-width: 100%;
|
507 |
}
|
508 |
|
509 |
+
.wrap .rankmath > .acf-fields > .acf-field > .acf-input {
|
510 |
+
padding: 0 0 0 1px !important;
|
511 |
}
|
512 |
|
513 |
+
.wrap .rankmath > .acf-fields > .acf-field > .acf-input > .rank-math-metabox-frame {
|
514 |
+
margin: -15px 0;
|
515 |
+
border: 0;
|
|
|
516 |
}
|
517 |
|
518 |
+
.wrap #add-term-translations,
|
519 |
+
.wrap #edit-term-translations {
|
520 |
+
border: none;
|
521 |
+
width: 100%;
|
522 |
+
}
|
523 |
+
|
524 |
+
.wrap #select-add-term-language select,
|
525 |
+
.wrap #select-edit-term-language select {
|
526 |
+
width: auto !important;
|
527 |
+
padding-right: 25px;
|
528 |
+
}
|
529 |
+
|
530 |
+
.wrap #select-add-term-language + p,
|
531 |
+
.wrap #select-add-term-language p.description,
|
532 |
+
.wrap #select-edit-term-language + p,
|
533 |
+
.wrap #select-edit-term-language p.description {
|
534 |
display: none;
|
535 |
}
|
536 |
|
537 |
+
.wrap #term-translations > p {
|
538 |
+
margin: 0;
|
539 |
+
font-size: 13px;
|
540 |
+
font-weight: 600;
|
541 |
+
color: #444;
|
542 |
}
|
543 |
|
544 |
+
.wrap #term-translations > .icl_subsubsub,
|
545 |
+
.wrap #term-translations > p {
|
546 |
+
position: relative;
|
547 |
+
width: 20%;
|
548 |
+
padding: 0 12px;
|
549 |
+
float: left;
|
550 |
+
-webkit-box-sizing: border-box;
|
551 |
+
box-sizing: border-box;
|
552 |
+
}
|
553 |
+
|
554 |
+
.wrap #term-translations #add-term-translations {
|
555 |
+
width: 80%;
|
556 |
+
position: relative;
|
557 |
+
float: left;
|
558 |
+
clear: none;
|
559 |
+
background: none;
|
560 |
+
padding: 0 12px;
|
561 |
+
}
|
562 |
+
|
563 |
+
.wrap #term-translations #add-term-translations td.pll-translation-column {
|
564 |
+
padding-left: 0;
|
565 |
+
padding-right: 0;
|
566 |
+
}
|
567 |
+
|
568 |
+
.wrap #term-translations #add-term-translations td,
|
569 |
+
.wrap #term-translations #add-term-translations th {
|
570 |
+
padding-top: 4px;
|
571 |
+
padding-bottom: 4px;
|
572 |
+
}
|
573 |
+
|
574 |
+
.wrap #term-translations #add-term-translations tr:first-of-type td,
|
575 |
+
.wrap #term-translations #add-term-translations tr:first-of-type th {
|
576 |
+
padding-top: 0;
|
577 |
+
}
|
578 |
+
|
579 |
+
.wrap #term-translations #add-term-translations tr:last-of-type td,
|
580 |
+
.wrap #term-translations #add-term-translations tr:last-of-type th {
|
581 |
+
padding-bottom: 0;
|
582 |
+
}
|
583 |
+
|
584 |
+
.wrap #term-translations #edit-term-translations td,
|
585 |
+
.wrap #term-translations #edit-term-translations th {
|
586 |
+
padding-top: 2px;
|
587 |
+
padding-bottom: 2px;
|
588 |
+
}
|
589 |
+
|
590 |
+
.wrap #term-translations #edit-term-translations tr:first-of-type td,
|
591 |
+
.wrap #term-translations #edit-term-translations tr:first-of-type th {
|
592 |
+
padding-top: 0;
|
593 |
+
}
|
594 |
+
|
595 |
+
.wrap #term-translations #edit-term-translations tr:last-of-type td,
|
596 |
+
.wrap #term-translations #edit-term-translations tr:last-of-type th {
|
597 |
+
padding-bottom: 0;
|
598 |
+
}
|
599 |
+
|
600 |
+
.wrap #acf-group_term > .acf-fields > .rank-math-metabox-frame.acf-field,
|
601 |
+
.wrap #acf-group_term > .acf-fields > .yoast-settings-table.acf-field,
|
602 |
+
.wrap #acf-group_term > .acf-fields > table.acf-field,
|
603 |
+
.wrap #acf-group_user > .acf-fields > .rank-math-metabox-frame.acf-field,
|
604 |
+
.wrap #acf-group_user > .acf-fields > .yoast-settings-table.acf-field,
|
605 |
+
.wrap #acf-group_user > .acf-fields > table.acf-field,
|
606 |
+
.wrap #acf-group_user_customer > .acf-fields > .rank-math-metabox-frame.acf-field,
|
607 |
+
.wrap #acf-group_user_customer > .acf-fields > .yoast-settings-table.acf-field,
|
608 |
+
.wrap #acf-group_user_customer > .acf-fields > table.acf-field {
|
609 |
+
border: none;
|
610 |
+
margin-bottom: 0;
|
611 |
+
}
|
612 |
+
|
613 |
+
.wrap #acf-group_term > .acf-fields > .rank-math-metabox-frame.acf-field:before,
|
614 |
+
.wrap #acf-group_term > .acf-fields > .yoast-settings-table.acf-field:before,
|
615 |
+
.wrap #acf-group_term > .acf-fields > table.acf-field:before,
|
616 |
+
.wrap #acf-group_user > .acf-fields > .rank-math-metabox-frame.acf-field:before,
|
617 |
+
.wrap #acf-group_user > .acf-fields > .yoast-settings-table.acf-field:before,
|
618 |
+
.wrap #acf-group_user > .acf-fields > table.acf-field:before,
|
619 |
+
.wrap #acf-group_user_customer > .acf-fields > .rank-math-metabox-frame.acf-field:before,
|
620 |
+
.wrap #acf-group_user_customer > .acf-fields > .yoast-settings-table.acf-field:before,
|
621 |
+
.wrap #acf-group_user_customer > .acf-fields > table.acf-field:before {
|
622 |
+
content: unset;
|
623 |
+
}
|
624 |
+
|
625 |
+
.wrap #acf-group_term > .acf-fields > .rank-math-metabox-frame.acf-field > tbody > tr:first-of-type > td,
|
626 |
+
.wrap #acf-group_term > .acf-fields > .rank-math-metabox-frame.acf-field > tbody > tr:first-of-type > th,
|
627 |
+
.wrap #acf-group_term > .acf-fields > .yoast-settings-table.acf-field > tbody > tr:first-of-type > td,
|
628 |
+
.wrap #acf-group_term > .acf-fields > .yoast-settings-table.acf-field > tbody > tr:first-of-type > th,
|
629 |
+
.wrap #acf-group_term > .acf-fields > table.acf-field > tbody > tr:first-of-type > td,
|
630 |
+
.wrap #acf-group_term > .acf-fields > table.acf-field > tbody > tr:first-of-type > th,
|
631 |
+
.wrap #acf-group_user > .acf-fields > .rank-math-metabox-frame.acf-field > tbody > tr:first-of-type > td,
|
632 |
+
.wrap #acf-group_user > .acf-fields > .rank-math-metabox-frame.acf-field > tbody > tr:first-of-type > th,
|
633 |
+
.wrap #acf-group_user > .acf-fields > .yoast-settings-table.acf-field > tbody > tr:first-of-type > td,
|
634 |
+
.wrap #acf-group_user > .acf-fields > .yoast-settings-table.acf-field > tbody > tr:first-of-type > th,
|
635 |
+
.wrap #acf-group_user > .acf-fields > table.acf-field > tbody > tr:first-of-type > td,
|
636 |
+
.wrap #acf-group_user > .acf-fields > table.acf-field > tbody > tr:first-of-type > th,
|
637 |
+
.wrap #acf-group_user_customer > .acf-fields > .rank-math-metabox-frame.acf-field > tbody > tr:first-of-type > td,
|
638 |
+
.wrap #acf-group_user_customer > .acf-fields > .rank-math-metabox-frame.acf-field > tbody > tr:first-of-type > th,
|
639 |
+
.wrap #acf-group_user_customer > .acf-fields > .yoast-settings-table.acf-field > tbody > tr:first-of-type > td,
|
640 |
+
.wrap #acf-group_user_customer > .acf-fields > .yoast-settings-table.acf-field > tbody > tr:first-of-type > th,
|
641 |
+
.wrap #acf-group_user_customer > .acf-fields > table.acf-field > tbody > tr:first-of-type > td,
|
642 |
+
.wrap #acf-group_user_customer > .acf-fields > table.acf-field > tbody > tr:first-of-type > th {
|
643 |
+
border-top: 0;
|
644 |
+
}
|
645 |
+
|
646 |
+
.wrap #acf-group_term > .acf-fields > .rank-math-metabox-frame.acf-field,
|
647 |
+
.wrap #acf-group_user > .acf-fields > .rank-math-metabox-frame.acf-field,
|
648 |
+
.wrap #acf-group_user_customer > .acf-fields > .rank-math-metabox-frame.acf-field {
|
649 |
padding: 0;
|
650 |
}
|
651 |
|
652 |
+
.edit-tags-php #col-left {
|
653 |
+
display: none;
|
654 |
float: none;
|
655 |
width: 100%;
|
656 |
}
|
657 |
|
658 |
+
.edit-tags-php #col-left .col-wrap {
|
659 |
padding: 0;
|
660 |
}
|
661 |
|
662 |
+
.edit-tags-php #col-left .col-wrap #poststuff {
|
663 |
min-width: 100%;
|
664 |
}
|
665 |
|
666 |
+
.edit-tags-php #col-left .col-wrap #poststuff #addtag h2.hndle {
|
667 |
+
border-bottom: 1px solid #ccd0d4;
|
668 |
}
|
669 |
|
670 |
+
.edit-tags-php #col-left .col-wrap #poststuff #addtag .inside .term-name-wrap {
|
671 |
+
border-top: none;
|
672 |
+
}
|
673 |
+
|
674 |
+
.edit-tags-php #col-left .col-wrap #poststuff #addtag .submit {
|
675 |
+
display: block;
|
676 |
margin: 0;
|
677 |
+
}
|
678 |
+
|
679 |
+
.edit-tags-php #col-container #col-right {
|
680 |
+
float: none;
|
681 |
+
width: auto;
|
682 |
+
}
|
683 |
+
|
684 |
+
.edit-tags-php #col-container #col-right .col-wrap {
|
685 |
+
padding: 0;
|
686 |
}
|
@@ -1 +1 @@
|
|
1 |
-
.wrap>form:not(.search-form){max-width:100%!important;width:100%;float:left}.wrap>form>div>div>h2,.wrap>form>div>div>h3,.wrap>form>h2,.wrap>form>h3{background:#fff;border:1px solid #ccd0d4;border-bottom:0;margin:0;color:#23282d;font-size:14px;padding:8px 12px;line-height:1.4}.wrap>form>div>div>h2+p,.wrap>form>div>div>h3+p,.wrap>form>h2+p,.wrap>form>h3+p{margin:0;border:1px solid #ccd0d4;border-bottom:0;padding:15px 12px}.wrap>form>div>div>h2+.form-table,.wrap>form>div>div>h2+p+.form-table,.wrap>form>div>div>h3+.form-table,.wrap>form>div>div>h3+p+.form-table,.wrap>form>h2+.form-table,.wrap>form>h2+p+.form-table,.wrap>form>h3+.form-table,.wrap>form>h3+p+.form-table{margin-top:0}.wrap>form .form-table{background:#fff;width:100%;border:1px solid #ccd0d4;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.04);box-shadow:0 1px 1px rgba(0,0,0,.04);margin-bottom:20px}.wrap>form .form-table>tbody>tr.acf-field{position:static}.wrap>form .form-table>tbody>tr.acf-tab-wrap>td{background:#f9f9f9;padding:15px 0 0}.wrap>form .form-table>tbody>tr.acf-tab-wrap>td ul.acf-tab-group{border-bottom:0;padding:0 0 0 20%}.wrap>form .form-table>tbody>tr.acf-tab-wrap>td ul.acf-tab-group>li.active a{background:#fff}.wrap>form .form-table>tbody>tr>td{background:#fff;border-top:1px solid #eee;position:static}.wrap>form .form-table>tbody>tr>td.td-full{padding:15px 12px}.wrap>form .form-table>tbody>tr>td p{font-size:13px}.wrap>form .form-table>tbody>tr>td.acf-label,.wrap>form .form-table>tbody>tr>th{border-top:1px solid #eee;border-right:1px solid #e1e1e1;background:#f9f9f9;padding:15px 12px;width:20%;font-size:13px;position:static;color:#444}.wrap>form .form-table>tbody>tr:first-of-type td,.wrap>form .form-table>tbody>tr:first-of-type th{border-top:1px solid #ccd0d4}.wrap>form #poststuff{min-width:auto}.wrap>form #poststuff.acfe-acfe-bt-admin-column{min-width:auto;padding:0}.wrap>form #poststuff.acfe-acfe-bt-admin-column .inside{margin:0;padding:0}.wrap>form p.submit{display:none}@media only screen and (max-width:850px){.wrap>form>div>div>h2,.wrap>form>div>div>h3,.wrap>form>h2,.wrap>form>h3{padding:12px}.wrap>form table.form-table>tbody>tr{display:block;padding:15px 12px;border-top:1px solid #eee}.wrap>form table.form-table>tbody>tr>td.acf-label,.wrap>form table.form-table>tbody>tr>th{margin-bottom:10px}.wrap>form table.form-table>tbody>tr>td,.wrap>form table.form-table>tbody>tr>td.acf-label,.wrap>form table.form-table>tbody>tr>th{padding:0;display:block;width:auto;background:none;border:0!important}.wrap>form table.form-table>tbody>tr:first-child{border-top:0}}.wrap .form-table>tbody>.acf-field>.acf-label label{font-size:13px;color:#444}.wrap .acf-fields.-left>.acf-field{padding-left:0}.wrap .acf-fields.-left>.acf-field.acfe-bt-no-label{padding-left:20%}@media only screen and (max-width:640px){.wrap .acf-fields.-left>.acf-field.acfe-bt-no-label{padding-left:0}}.wrap .acf-fields.-left>.acf-field:before{width:20%}.wrap .acf-fields.-left>.acf-field>.acf-label{width:20%;margin-left:0;padding:0 12px}.wrap .acf-fields.-left>.acf-field>.acf-input{padding:0 12px}.wrap .postbox .hndle{cursor:auto;-webkit-user-select:auto;-moz-user-select:auto;-ms-user-select:auto;user-select:auto}.wrap .postbox .handle-actions{display:none}.profile-php .wrap#profile-page .form-table textarea,.user-edit-php .wrap#profile-page .form-table textarea,.user-new-php .wrap#profile-page .form-table textarea{width:100%;max-width:500px}.profile-php .wrap>form select#ure_select_other_roles,.profile-php .wrap>form select#ure_select_other_roles+.ms-parent,.user-edit-php .wrap>form select#ure_select_other_roles,.user-edit-php .wrap>form select#ure_select_other_roles+.ms-parent,.user-new-php .wrap>form select#ure_select_other_roles,.user-new-php .wrap>form select#ure_select_other_roles+.ms-parent{width:100%!important;max-width:500px!important}.profile-php .wrap>form select#ure_select_other_roles+.ms-parent .ms-choice,.user-edit-php .wrap>form select#ure_select_other_roles+.ms-parent .ms-choice,.user-new-php .wrap>form select#ure_select_other_roles+.ms-parent .ms-choice{-webkit-box-shadow:0 0 0 transparent;box-shadow:0 0 0 transparent;border-radius:3px;border:1px solid #7e8993;color:#32373c;padding:4px 8px;margin:0;-webkit-box-sizing:border-box;box-sizing:border-box;font-size:14px;line-height:2.1;min-height:30px;background:#fff url("data:image/svg+xml;charset=US-ASCII, %3Csvg%20width%3D%2220%22%20height%3D%2220%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M5%206l5%205%205-5%202%201-7%207-7-7%202-1z%22%20fill%3D%22%23555%22%2F%3E%3C%2Fsvg%3E") no-repeat right 5px top 55%;background-size:16px 16px;cursor:pointer}.profile-php .wrap>form select#ure_select_other_roles+.ms-parent .ms-choice>span.placeholder,.user-edit-php .wrap>form select#ure_select_other_roles+.ms-parent .ms-choice>span.placeholder,.user-new-php .wrap>form select#ure_select_other_roles+.ms-parent .ms-choice>span.placeholder{color:#32373c}.profile-php .wrap>form .form-table>tbody>tr>td>br:first-child,.profile-php .wrap>form select#ure_select_other_roles+.ms-parent .ms-choice>div,.user-edit-php .wrap>form .form-table>tbody>tr>td>br:first-child,.user-edit-php .wrap>form select#ure_select_other_roles+.ms-parent .ms-choice>div,.user-new-php .wrap>form .form-table>tbody>tr>td>br:first-child,.user-new-php .wrap>form select#ure_select_other_roles+.ms-parent .ms-choice>div{display:none}.profile-php .wrap>form .yoast-settings,.user-edit-php .wrap>form .yoast-settings,.user-new-php .wrap>form .yoast-settings{border:1px solid #ccd0d4;padding:0;margin-bottom:20px;font-size:13px}.profile-php .wrap>form .yoast-settings h2,.user-edit-php .wrap>form .yoast-settings h2,.user-new-php .wrap>form .yoast-settings h2{background:#fff;border-bottom:1px solid #ccd0d4;margin:0;color:#23282d;font-size:14px;padding:8px 12px;line-height:1.4}.profile-php .wrap>form .yoast-settings label,.user-edit-php .wrap>form .yoast-settings label,.user-new-php .wrap>form .yoast-settings label{margin:0;padding:0;width:auto;font-size:13px;color:#444}.profile-php .wrap>form .yoast-settings p.description,.user-edit-php .wrap>form .yoast-settings p.description,.user-new-php .wrap>form .yoast-settings p.description{font-size:13px;margin:0 0 5px;color:#666}.profile-php .wrap>form .yoast-settings input,.profile-php .wrap>form .yoast-settings textarea,.user-edit-php .wrap>form .yoast-settings input,.user-edit-php .wrap>form .yoast-settings textarea,.user-new-php .wrap>form .yoast-settings input,.user-new-php .wrap>form .yoast-settings textarea{margin:0}.profile-php .wrap>form .yoast-settings .yoast-settings-table *,.user-edit-php .wrap>form .yoast-settings .yoast-settings-table *,.user-new-php .wrap>form .yoast-settings .yoast-settings-table *{-webkit-box-sizing:border-box;box-sizing:border-box}.profile-php .wrap>form .yoast-settings .yoast-settings-table .yoast-settings-row,.user-edit-php .wrap>form .yoast-settings .yoast-settings-table .yoast-settings-row,.user-new-php .wrap>form .yoast-settings .yoast-settings-table .yoast-settings-row{display:-webkit-box;display:-ms-flexbox;display:flex;border-top:1px solid #eee}.profile-php .wrap>form .yoast-settings .yoast-settings-table .yoast-settings-row:first-child,.user-edit-php .wrap>form .yoast-settings .yoast-settings-table .yoast-settings-row:first-child,.user-new-php .wrap>form .yoast-settings .yoast-settings-table .yoast-settings-row:first-child{border-top:0}.profile-php .wrap>form .yoast-settings .yoast-settings-table .yoast-settings-row .yoast-settings-label,.user-edit-php .wrap>form .yoast-settings .yoast-settings-table .yoast-settings-row .yoast-settings-label,.user-new-php .wrap>form .yoast-settings .yoast-settings-table .yoast-settings-row .yoast-settings-label{-webkit-box-flex:0;-ms-flex:0 0 20%;flex:0 0 20%;border-right:1px solid #e1e1e1;background:#f9f9f9;padding:15px 12px}.profile-php .wrap>form .yoast-settings .yoast-settings-table .yoast-settings-row .yoast-settings-input,.user-edit-php .wrap>form .yoast-settings .yoast-settings-table .yoast-settings-row .yoast-settings-input,.user-new-php .wrap>form .yoast-settings .yoast-settings-table .yoast-settings-row .yoast-settings-input{-webkit-box-flex:1;-ms-flex:1;flex:1;background:#fff;padding:15px 12px}.profile-php .wrap>form .yoast-settings .yoast-settings-table .yoast-settings-row .yoast-settings-input .yoast-settings__checkbox,.user-edit-php .wrap>form .yoast-settings .yoast-settings-table .yoast-settings-row .yoast-settings-input .yoast-settings__checkbox,.user-new-php .wrap>form .yoast-settings .yoast-settings-table .yoast-settings-row .yoast-settings-input .yoast-settings__checkbox{margin-right:5px}.profile-php .wrap>form .yoast-settings .yoast-settings-table .yoast-settings-row .yoast-settings-input .yoast-settings-spacer,.user-edit-php .wrap>form .yoast-settings .yoast-settings-table .yoast-settings-row .yoast-settings-input .yoast-settings-spacer,.user-new-php .wrap>form .yoast-settings .yoast-settings-table .yoast-settings-row .yoast-settings-input .yoast-settings-spacer{height:3px}@media only screen and (max-width:850px){.profile-php .wrap>form .yoast-settings h2,.user-edit-php .wrap>form .yoast-settings h2,.user-new-php .wrap>form .yoast-settings h2{padding:12px}.profile-php .wrap>form .yoast-settings .yoast-settings-table,.user-edit-php .wrap>form .yoast-settings .yoast-settings-table,.user-new-php .wrap>form .yoast-settings .yoast-settings-table{background:#fff}.profile-php .wrap>form .yoast-settings .yoast-settings-table .yoast-settings-row,.user-edit-php .wrap>form .yoast-settings .yoast-settings-table .yoast-settings-row,.user-new-php .wrap>form .yoast-settings .yoast-settings-table .yoast-settings-row{-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;padding:15px 12px}.profile-php .wrap>form .yoast-settings .yoast-settings-table .yoast-settings-row .yoast-settings-label,.user-edit-php .wrap>form .yoast-settings .yoast-settings-table .yoast-settings-row .yoast-settings-label,.user-new-php .wrap>form .yoast-settings .yoast-settings-table .yoast-settings-row .yoast-settings-label{-webkit-box-flex:1;-ms-flex:1;flex:1;border-right:0;background:#fff;margin-bottom:10px;padding:0}.profile-php .wrap>form .yoast-settings .yoast-settings-table .yoast-settings-row .yoast-settings-input,.user-edit-php .wrap>form .yoast-settings .yoast-settings-table .yoast-settings-row .yoast-settings-input,.user-new-php .wrap>form .yoast-settings .yoast-settings-table .yoast-settings-row .yoast-settings-input{padding:0}}.profile-php .wrap>form .form-table[role=presentation]:first-of-type tr.user-language-wrap th[colspan="2"],.user-edit-php .wrap>form .form-table[role=presentation]:first-of-type tr.user-language-wrap th[colspan="2"],.user-new-php .wrap>form .form-table[role=presentation]:first-of-type tr.user-language-wrap th[colspan="2"]{display:none}.term-php .wrap>form{margin-top:13px}.term-php .acf-column-1>#wp-description-wrap{display:none!important}.term-php .postbox.wpseo-taxonomy-metabox-postbox>h2{border-bottom:1px solid #ccd0d4}.term-php tr.wpml-term-languages-wrap{display:none}.term-php #icl_tax_category_lang .inside{padding:10px;clear:both;border-top:1px solid #ddd}.edit-tags-php #col-left{display:none}.edit-tags-php #col-container #col-right{float:none;width:auto}.edit-tags-php #col-container #col-right .col-wrap{padding:0}.edit-tags-php #col-left.acfe-bt{float:none;width:100%}.edit-tags-php #col-left.acfe-bt .col-wrap{padding:0}.edit-tags-php #col-left.acfe-bt #poststuff{min-width:100%}.edit-tags-php #acfe-bt-form .inside .term-name-wrap{border-top:1px solid #ccd0d4}.edit-tags-php #acfe-bt-form .submit.acf-field{display:block!important;margin:0}
|
1 |
+
.wrap{padding-top:0!important;min-width:auto!important}@media only screen and (min-width:782px){.wrap:not(#poststuff) form#createuser,.wrap:not(#poststuff) form#edittag,.wrap:not(#poststuff) form#your-profile,.wrap:not(#poststuff) form[action="options-permalink.php"],.wrap:not(#poststuff) form[action="options.php"]{max-width:calc(100% - 300px)!important;position:relative}.wrap:not(#poststuff) form#createuser .edit-tag-actions,.wrap:not(#poststuff) form#createuser p.submit,.wrap:not(#poststuff) form#edittag .edit-tag-actions,.wrap:not(#poststuff) form#edittag p.submit,.wrap:not(#poststuff) form#your-profile .edit-tag-actions,.wrap:not(#poststuff) form#your-profile p.submit,.wrap:not(#poststuff) form[action="options-permalink.php"] .edit-tag-actions,.wrap:not(#poststuff) form[action="options-permalink.php"] p.submit,.wrap:not(#poststuff) form[action="options.php"] .edit-tag-actions,.wrap:not(#poststuff) form[action="options.php"] p.submit{-webkit-box-sizing:border-box;box-sizing:border-box;position:absolute;top:37px;width:280px;right:-300px;padding:10px;margin:0;background:#f5f5f5;text-align:right;border:1px solid #ccd0d4;border-radius:0;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.04);box-shadow:0 1px 1px rgba(0,0,0,.04)}.wrap:not(#poststuff) form#createuser .edit-tag-actions:before,.wrap:not(#poststuff) form#createuser p.submit:before,.wrap:not(#poststuff) form#edittag .edit-tag-actions:before,.wrap:not(#poststuff) form#edittag p.submit:before,.wrap:not(#poststuff) form#your-profile .edit-tag-actions:before,.wrap:not(#poststuff) form#your-profile p.submit:before,.wrap:not(#poststuff) form[action="options-permalink.php"] .edit-tag-actions:before,.wrap:not(#poststuff) form[action="options-permalink.php"] p.submit:before,.wrap:not(#poststuff) form[action="options.php"] .edit-tag-actions:before,.wrap:not(#poststuff) form[action="options.php"] p.submit:before{-webkit-box-sizing:border-box;box-sizing:border-box;content:"";background:#fff;border:1px solid #ccd0d4;border-bottom:0;position:absolute;width:280px;top:-38px;height:37px;left:-1px}.wrap:not(#poststuff) form#createuser .edit-tag-actions .button,.wrap:not(#poststuff) form#createuser p.submit .button,.wrap:not(#poststuff) form#edittag .edit-tag-actions .button,.wrap:not(#poststuff) form#edittag p.submit .button,.wrap:not(#poststuff) form#your-profile .edit-tag-actions .button,.wrap:not(#poststuff) form#your-profile p.submit .button,.wrap:not(#poststuff) form[action="options-permalink.php"] .edit-tag-actions .button,.wrap:not(#poststuff) form[action="options-permalink.php"] p.submit .button,.wrap:not(#poststuff) form[action="options.php"] .edit-tag-actions .button,.wrap:not(#poststuff) form[action="options.php"] p.submit .button{min-height:32px;line-height:2.30769231;padding:0 12px}.wrap:not(#poststuff) form#createuser .edit-tag-actions #delete-link,.wrap:not(#poststuff) form#createuser p.submit #delete-link,.wrap:not(#poststuff) form#edittag .edit-tag-actions #delete-link,.wrap:not(#poststuff) form#edittag p.submit #delete-link,.wrap:not(#poststuff) form#your-profile .edit-tag-actions #delete-link,.wrap:not(#poststuff) form#your-profile p.submit #delete-link,.wrap:not(#poststuff) form[action="options-permalink.php"] .edit-tag-actions #delete-link,.wrap:not(#poststuff) form[action="options-permalink.php"] p.submit #delete-link,.wrap:not(#poststuff) form[action="options.php"] .edit-tag-actions #delete-link,.wrap:not(#poststuff) form[action="options.php"] p.submit #delete-link{float:left;margin:0;text-decoration:underline}}.wrap>form:not(.search-form){margin-top:13px;max-width:100%!important}.wrap>form>div>div>h2,.wrap>form>div>div>h3,.wrap>form>h2,.wrap>form>h3{background:#fff;border:1px solid #ccd0d4;border-bottom:0;margin:0;color:#23282d;font-size:14px;padding:8px 12px;line-height:1.4}.wrap>form>div>div>h2+p,.wrap>form>div>div>h3+p,.wrap>form>h2+p,.wrap>form>h3+p{margin:0;border:1px solid #ccd0d4;border-bottom:0;padding:15px 12px}.wrap>form>div>div>h2+.form-table,.wrap>form>div>div>h2+p+.form-table,.wrap>form>div>div>h3+.form-table,.wrap>form>div>div>h3+p+.form-table,.wrap>form>h2+.form-table,.wrap>form>h2+p+.form-table,.wrap>form>h3+.form-table,.wrap>form>h3+p+.form-table{margin-top:0}.wrap>form .form-table{background:#fff;width:100%;border:1px solid #ccd0d4;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.04);box-shadow:0 1px 1px rgba(0,0,0,.04);margin-bottom:20px}.wrap>form .form-table>tbody>tr.acf-field{position:static}.wrap>form .form-table>tbody>tr.acf-tab-wrap>td{background:#f9f9f9;padding:15px 0 0}.wrap>form .form-table>tbody>tr.acf-tab-wrap>td ul.acf-tab-group{border-bottom:0;padding:0 0 0 20%}.wrap>form .form-table>tbody>tr.acf-tab-wrap>td ul.acf-tab-group>li.active a{background:#fff}.wrap>form .form-table>tbody>tr>td{background:#fff;border-top:1px solid #eee;position:static;padding:15px 12px}.wrap>form .form-table>tbody>tr>td.td-full{padding:15px 12px}.wrap>form .form-table>tbody>tr>td p{font-size:13px}.wrap>form .form-table>tbody>tr>td.acf-label,.wrap>form .form-table>tbody>tr>th{border-top:1px solid #eee;border-right:1px solid #e1e1e1;background:#f9f9f9;padding:15px 12px;width:20%;font-size:13px;position:static;color:#444}.wrap>form .form-table>tbody>tr>td.acf-label label,.wrap>form .form-table>tbody>tr>th label{vertical-align:top}.wrap>form .form-table>tbody>tr:first-of-type td,.wrap>form .form-table>tbody>tr:first-of-type th{border-top:1px solid #ccd0d4}.wrap>form .form-table textarea{width:100%}.wrap>form .form-table .regular-text{width:100%;max-width:25em}@media only screen and (max-width:782px){.wrap>form>div>div>h2,.wrap>form>div>div>h3,.wrap>form>h2,.wrap>form>h3{padding:12px}.wrap>form table.form-table>tbody>tr{display:block;padding:15px 12px;border-top:1px solid #eee}.wrap>form table.form-table>tbody>tr>td.acf-label,.wrap>form table.form-table>tbody>tr>th{margin-bottom:10px}.wrap>form table.form-table>tbody>tr>td,.wrap>form table.form-table>tbody>tr>td.acf-label,.wrap>form table.form-table>tbody>tr>th{padding:0;display:block;width:auto;background:none;border:0!important}.wrap>form table.form-table>tbody>tr:first-child{border-top:0}}.wrap #titlediv{margin-bottom:10px}.wrap #titlediv input{padding:3px 8px;font-size:1.7em;line-height:100%;height:1.7em;width:100%;outline:0;margin:0 0 3px;background-color:#fff}.wrap .postbox .hndle{cursor:auto;-webkit-user-select:auto;-moz-user-select:auto;-ms-user-select:auto;user-select:auto}.wrap .postbox .handle-actions button,.wrap .postbox .handle-actions span{display:none}.wrap .postbox .handle-actions .acf-hndle-cog{width:2.2rem}.wrap #submitdiv #major-publishing-actions{border-top:0}.wrap #submitdiv #major-publishing-actions #publishing-action{float:none;margin:0}.wrap #submitdiv #major-publishing-actions #publishing-action .button{float:right}.wrap #submitdiv #major-publishing-actions #publishing-action .spinner{margin:5px 10px 0}.wrap #submitdiv #major-publishing-actions #publishing-action #delete-link{float:left;margin-left:0}.wrap #submitdiv #major-publishing-actions #publishing-action #delete-link a{text-decoration:underline}.wrap form#createuser .acf-field input[type=email],.wrap form#createuser .acf-field input[type=number],.wrap form#createuser .acf-field input[type=password],.wrap form#createuser .acf-field input[type=search],.wrap form#createuser .acf-field input[type=text],.wrap form#createuser .acf-field input[type=url],.wrap form#createuser .acf-field select,.wrap form#your-profile .acf-field input[type=email],.wrap form#your-profile .acf-field input[type=number],.wrap form#your-profile .acf-field input[type=password],.wrap form#your-profile .acf-field input[type=search],.wrap form#your-profile .acf-field input[type=text],.wrap form#your-profile .acf-field input[type=url],.wrap form#your-profile .acf-field select{max-width:100%}.wrap form#createuser .acf-field textarea,.wrap form#your-profile .acf-field textarea{width:100%}.wrap form#createuser .acf-tab-wrap,.wrap form#your-profile .acf-tab-wrap{position:relative}.wrap form#createuser select#ure_select_other_roles,.wrap form#createuser select#ure_select_other_roles+.ms-parent,.wrap form#your-profile select#ure_select_other_roles,.wrap form#your-profile select#ure_select_other_roles+.ms-parent{width:100%!important;max-width:500px!important}.wrap form#createuser select#ure_select_other_roles+.ms-parent .ms-choice,.wrap form#your-profile select#ure_select_other_roles+.ms-parent .ms-choice{-webkit-box-shadow:0 0 0 transparent;box-shadow:0 0 0 transparent;border-radius:3px;border:1px solid #7e8993;color:#32373c;padding:4px 8px;margin:0;-webkit-box-sizing:border-box;box-sizing:border-box;font-size:14px;line-height:2.1;min-height:30px;background:#fff url("data:image/svg+xml;charset=US-ASCII, %3Csvg%20width%3D%2220%22%20height%3D%2220%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M5%206l5%205%205-5%202%201-7%207-7-7%202-1z%22%20fill%3D%22%23555%22%2F%3E%3C%2Fsvg%3E") no-repeat right 5px top 55%;background-size:16px 16px;cursor:pointer}.wrap form#createuser select#ure_select_other_roles+.ms-parent .ms-choice>span.placeholder,.wrap form#your-profile select#ure_select_other_roles+.ms-parent .ms-choice>span.placeholder{color:#32373c}.wrap form#createuser select#ure_select_other_roles+.ms-parent .ms-choice>div,.wrap form#your-profile select#ure_select_other_roles+.ms-parent .ms-choice>div{display:none}.wrap form#createuser .yoast-settings,.wrap form#your-profile .yoast-settings{padding:0;margin-bottom:20px;font-size:13px}.wrap form#createuser .yoast-settings h2,.wrap form#your-profile .yoast-settings h2{margin:0}.wrap form#createuser .yoast-settings label,.wrap form#your-profile .yoast-settings label{margin:0;padding:0;width:auto;font-size:13px;color:#444;line-height:1.7}.wrap form#createuser .yoast-settings .description,.wrap form#your-profile .yoast-settings .description{font-size:13px;margin:0 0 5px;color:#666}.wrap form#createuser .yoast-settings input,.wrap form#createuser .yoast-settings textarea,.wrap form#your-profile .yoast-settings input,.wrap form#your-profile .yoast-settings textarea{margin:0}.wrap form#createuser .yoast-settings textarea,.wrap form#your-profile .yoast-settings textarea{margin-bottom:10px}.wrap form#createuser .yoast-settings input[type=checkbox],.wrap form#your-profile .yoast-settings input[type=checkbox]{margin-right:5px;vertical-align:-6px}.wrap form#createuser .form-table[role=presentation] tr.user-language-wrap th[colspan="2"],.wrap form#your-profile .form-table[role=presentation] tr.user-language-wrap th[colspan="2"]{display:none}.wrap form#addtag .acf-fields.-left>.acf-field,.wrap form#edittag .acf-fields.-left>.acf-field{padding-left:0}.wrap form#addtag .acf-fields.-left>.acf-field.acfe-bt-no-label,.wrap form#edittag .acf-fields.-left>.acf-field.acfe-bt-no-label{padding-left:20%}@media only screen and (max-width:640px){.wrap form#addtag .acf-fields.-left>.acf-field.acfe-bt-no-label,.wrap form#edittag .acf-fields.-left>.acf-field.acfe-bt-no-label{padding-left:0}}.wrap form#addtag .acf-fields.-left>.acf-field:before,.wrap form#edittag .acf-fields.-left>.acf-field:before{width:20%}.wrap form#addtag .acf-fields.-left>.acf-field>.acf-label,.wrap form#edittag .acf-fields.-left>.acf-field>.acf-label{width:20%;margin-left:0;padding:0 12px}.wrap form#addtag .acf-fields.-left>.acf-field>.acf-label label,.wrap form#edittag .acf-fields.-left>.acf-field>.acf-label label{color:#444}.wrap form#addtag .acf-fields.-left>.acf-field>.acf-input,.wrap form#edittag .acf-fields.-left>.acf-field>.acf-input{padding:0 12px}.wrap form#addtag .form-field p,.wrap form#addtag .form-field select,.wrap form#edittag .form-field p,.wrap form#edittag .form-field select{max-width:100%}.wrap form#addtag .form-field input[type=email],.wrap form#addtag .form-field input[type=number],.wrap form#addtag .form-field input[type=password],.wrap form#addtag .form-field input[type=search],.wrap form#addtag .form-field input[type=tel],.wrap form#addtag .form-field input[type=text],.wrap form#addtag .form-field input[type=url],.wrap form#addtag .form-field select,.wrap form#addtag .form-field textarea,.wrap form#edittag .form-field input[type=email],.wrap form#edittag .form-field input[type=number],.wrap form#edittag .form-field input[type=password],.wrap form#edittag .form-field input[type=search],.wrap form#edittag .form-field input[type=tel],.wrap form#edittag .form-field input[type=text],.wrap form#edittag .form-field input[type=url],.wrap form#edittag .form-field select,.wrap form#edittag .form-field textarea{width:100%}.wrap form#edittag .acf-column-1>#wp-description-wrap{display:none}.wrap form#edittag .postbox.wpseo-taxonomy-metabox-postbox>h2{border-bottom:1px solid #ccd0d4}.wrap form#edittag tr.wpml-term-languages-wrap{display:none}.wrap form#edittag #icl-tax-postbox .inside{margin:0;padding:15px 12px}.wrap form#edittag #icl-tax-postbox .inside table.icl_translations_table{width:100%}.wrap .rank-math-metabox-frame{max-width:100%}.wrap .rankmath>.acf-fields>.acf-field>.acf-input{padding:0 0 0 1px!important}.wrap .rankmath>.acf-fields>.acf-field>.acf-input>.rank-math-metabox-frame{margin:-15px 0;border:0}.wrap #add-term-translations,.wrap #edit-term-translations{border:none;width:100%}.wrap #select-add-term-language select,.wrap #select-edit-term-language select{width:auto!important;padding-right:25px}.wrap #select-add-term-language+p,.wrap #select-add-term-language p.description,.wrap #select-edit-term-language+p,.wrap #select-edit-term-language p.description{display:none}.wrap #term-translations>p{margin:0;font-size:13px;font-weight:600;color:#444}.wrap #term-translations>.icl_subsubsub,.wrap #term-translations>p{position:relative;width:20%;padding:0 12px;float:left;-webkit-box-sizing:border-box;box-sizing:border-box}.wrap #term-translations #add-term-translations{width:80%;position:relative;float:left;clear:none;background:none;padding:0 12px}.wrap #term-translations #add-term-translations td.pll-translation-column{padding-left:0;padding-right:0}.wrap #term-translations #add-term-translations td,.wrap #term-translations #add-term-translations th{padding-top:4px;padding-bottom:4px}.wrap #term-translations #add-term-translations tr:first-of-type td,.wrap #term-translations #add-term-translations tr:first-of-type th{padding-top:0}.wrap #term-translations #add-term-translations tr:last-of-type td,.wrap #term-translations #add-term-translations tr:last-of-type th{padding-bottom:0}.wrap #term-translations #edit-term-translations td,.wrap #term-translations #edit-term-translations th{padding-top:2px;padding-bottom:2px}.wrap #term-translations #edit-term-translations tr:first-of-type td,.wrap #term-translations #edit-term-translations tr:first-of-type th{padding-top:0}.wrap #term-translations #edit-term-translations tr:last-of-type td,.wrap #term-translations #edit-term-translations tr:last-of-type th{padding-bottom:0}.wrap #acf-group_term>.acf-fields>.rank-math-metabox-frame.acf-field,.wrap #acf-group_term>.acf-fields>.yoast-settings-table.acf-field,.wrap #acf-group_term>.acf-fields>table.acf-field,.wrap #acf-group_user>.acf-fields>.rank-math-metabox-frame.acf-field,.wrap #acf-group_user>.acf-fields>.yoast-settings-table.acf-field,.wrap #acf-group_user>.acf-fields>table.acf-field,.wrap #acf-group_user_customer>.acf-fields>.rank-math-metabox-frame.acf-field,.wrap #acf-group_user_customer>.acf-fields>.yoast-settings-table.acf-field,.wrap #acf-group_user_customer>.acf-fields>table.acf-field{border:none;margin-bottom:0}.wrap #acf-group_term>.acf-fields>.rank-math-metabox-frame.acf-field:before,.wrap #acf-group_term>.acf-fields>.yoast-settings-table.acf-field:before,.wrap #acf-group_term>.acf-fields>table.acf-field:before,.wrap #acf-group_user>.acf-fields>.rank-math-metabox-frame.acf-field:before,.wrap #acf-group_user>.acf-fields>.yoast-settings-table.acf-field:before,.wrap #acf-group_user>.acf-fields>table.acf-field:before,.wrap #acf-group_user_customer>.acf-fields>.rank-math-metabox-frame.acf-field:before,.wrap #acf-group_user_customer>.acf-fields>.yoast-settings-table.acf-field:before,.wrap #acf-group_user_customer>.acf-fields>table.acf-field:before{content:unset}.wrap #acf-group_term>.acf-fields>.rank-math-metabox-frame.acf-field>tbody>tr:first-of-type>td,.wrap #acf-group_term>.acf-fields>.rank-math-metabox-frame.acf-field>tbody>tr:first-of-type>th,.wrap #acf-group_term>.acf-fields>.yoast-settings-table.acf-field>tbody>tr:first-of-type>td,.wrap #acf-group_term>.acf-fields>.yoast-settings-table.acf-field>tbody>tr:first-of-type>th,.wrap #acf-group_term>.acf-fields>table.acf-field>tbody>tr:first-of-type>td,.wrap #acf-group_term>.acf-fields>table.acf-field>tbody>tr:first-of-type>th,.wrap #acf-group_user>.acf-fields>.rank-math-metabox-frame.acf-field>tbody>tr:first-of-type>td,.wrap #acf-group_user>.acf-fields>.rank-math-metabox-frame.acf-field>tbody>tr:first-of-type>th,.wrap #acf-group_user>.acf-fields>.yoast-settings-table.acf-field>tbody>tr:first-of-type>td,.wrap #acf-group_user>.acf-fields>.yoast-settings-table.acf-field>tbody>tr:first-of-type>th,.wrap #acf-group_user>.acf-fields>table.acf-field>tbody>tr:first-of-type>td,.wrap #acf-group_user>.acf-fields>table.acf-field>tbody>tr:first-of-type>th,.wrap #acf-group_user_customer>.acf-fields>.rank-math-metabox-frame.acf-field>tbody>tr:first-of-type>td,.wrap #acf-group_user_customer>.acf-fields>.rank-math-metabox-frame.acf-field>tbody>tr:first-of-type>th,.wrap #acf-group_user_customer>.acf-fields>.yoast-settings-table.acf-field>tbody>tr:first-of-type>td,.wrap #acf-group_user_customer>.acf-fields>.yoast-settings-table.acf-field>tbody>tr:first-of-type>th,.wrap #acf-group_user_customer>.acf-fields>table.acf-field>tbody>tr:first-of-type>td,.wrap #acf-group_user_customer>.acf-fields>table.acf-field>tbody>tr:first-of-type>th{border-top:0}.wrap #acf-group_term>.acf-fields>.rank-math-metabox-frame.acf-field,.wrap #acf-group_user>.acf-fields>.rank-math-metabox-frame.acf-field,.wrap #acf-group_user_customer>.acf-fields>.rank-math-metabox-frame.acf-field{padding:0}.edit-tags-php #col-left{display:none;float:none;width:100%}.edit-tags-php #col-left .col-wrap{padding:0}.edit-tags-php #col-left .col-wrap #poststuff{min-width:100%}.edit-tags-php #col-left .col-wrap #poststuff #addtag h2.hndle{border-bottom:1px solid #ccd0d4}.edit-tags-php #col-left .col-wrap #poststuff #addtag .inside .term-name-wrap{border-top:none}.edit-tags-php #col-left .col-wrap #poststuff #addtag .submit{display:block;margin:0}.edit-tags-php #col-container #col-right{float:none;width:auto}.edit-tags-php #col-container #col-right .col-wrap{padding:0}
|
@@ -229,6 +229,7 @@ body.acfe-modal-opened {
|
|
229 |
|
230 |
.acfe-modal.-open.-iframe .acfe-modal-content {
|
231 |
overflow: hidden;
|
|
|
232 |
}
|
233 |
|
234 |
.acfe-modal.-open.acfe-modal-sub > .acfe-modal-wrapper > .acfe-modal-content {
|
@@ -575,4 +576,8 @@ body.wp-admin.upload-php.acfe-modal-opened>div:not([style*="display: none;"])>.m
|
|
575 |
width: 100%;
|
576 |
height: 100%;
|
577 |
z-index: 10000;
|
|
|
|
|
|
|
|
|
578 |
}
|
229 |
|
230 |
.acfe-modal.-open.-iframe .acfe-modal-content {
|
231 |
overflow: hidden;
|
232 |
+
line-height: 0;
|
233 |
}
|
234 |
|
235 |
.acfe-modal.-open.acfe-modal-sub > .acfe-modal-wrapper > .acfe-modal-content {
|
576 |
width: 100%;
|
577 |
height: 100%;
|
578 |
z-index: 10000;
|
579 |
+
}
|
580 |
+
|
581 |
+
.pac-container {
|
582 |
+
z-index: 100001;
|
583 |
}
|
@@ -1 +1 @@
|
|
1 |
-
body.acfe-modal-opened{overflow:hidden}.acfe-modal-overlay{background:rgba(0,0,0,.7);position:fixed;top:0;left:0;right:0;bottom:0;height:100%;width:100%;z-index:100000}.acfe-modal{display:none;-webkit-transition:all .3s ease-in-out;-o-transition:all .3s ease-in-out;transition:all .3s ease-in-out}.acfe-modal.-open{position:fixed;z-index:100001;height:100%;width:100%;top:0;left:0;bottom:0;right:0;-webkit-font-smoothing:subpixel-antialiased;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;pointer-events:none}.acfe-modal.-open,.acfe-modal.-open>.acfe-modal-wrapper{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.acfe-modal.-open>.acfe-modal-wrapper{-webkit-box-shadow:0 5px 15px rgba(0,0,0,.7);box-shadow:0 5px 15px rgba(0,0,0,.7);width:calc(100vw - 60px);max-width:1100px;max-height:calc(100vh - 60px);position:relative}.acfe-modal.-open.acfe-modal-sub>.acfe-modal-wrapper>.acfe-modal-wrapper-overlay{position:absolute;z-index:10;background:rgba(0,0,0,.7);height:100%;width:100%;pointer-events:none}.acfe-modal.-open.-small>.acfe-modal-wrapper{max-width:450px}.acfe-modal.-open.-medium>.acfe-modal-wrapper{max-width:700px}.acfe-modal.-open.-large>.acfe-modal-wrapper{max-width:1100px}.acfe-modal.-open.-xlarge>.acfe-modal-wrapper{max-width:1400px}.acfe-modal.-open.-full>.acfe-modal-wrapper{max-width:100%;-webkit-box-flex:1;-ms-flex:1;flex:1}.acfe-modal.-open.-full>.acfe-modal-wrapper>.acfe-modal-content>.acf-fields.-left{height:100%}.acfe-modal.-open.-full>.acfe-modal-wrapper>.acfe-modal-content>.acf-fields.-left:before{content:"";display:block;position:absolute;z-index:0;background:#f9f9f9;border:solid #e1e1e1;border-width:0 1px 0 0;top:0;bottom:0;left:0;width:20%}.acfe-modal.-settings.-open.-full>.acfe-modal-wrapper>.acfe-modal-content>.acf-fields,.acfe-modal.-settings.-open.-full>.acfe-modal-wrapper>.acfe-modal-content>.acf-fields>.acf-field-clone,.acfe-modal.-settings.-open.-full>.acfe-modal-wrapper>.acfe-modal-content>.acf-fields>.acf-field-clone>.acf-input,.acfe-modal.-settings.-open.-full>.acfe-modal-wrapper>.acfe-modal-content>.acf-fields>.acf-field-clone>.acf-input>.acf-clone-fields.acf-fields.-left{height:100%}.acfe-modal.-settings.-open.-full>.acfe-modal-wrapper>.acfe-modal-content>.acf-fields>.acf-field-clone{padding:0}.acfe-modal.-settings.-open.-full>.acfe-modal-wrapper>.acfe-modal-content>.acf-fields>.acf-field-clone>.acf-input{margin:0}.acfe-modal.-settings.-open.-full>.acfe-modal-wrapper>.acfe-modal-content>.acf-fields>.acf-field-clone>.acf-input>.acf-clone-fields.acf-fields.-left:before{content:"";display:block;position:absolute;z-index:0;background:#f9f9f9;border:solid #e1e1e1;border-width:0 1px 0 0;top:0;bottom:0;left:0;width:20%}.acfe-modal.-open .acfe-modal-title *,.acfe-modal.-open>.acfe-modal-title{-webkit-box-sizing:border-box;box-sizing:border-box}.acfe-modal.-open .acfe-modal-title{display:block;height:50px;line-height:50px;font-size:22px;color:#23282d;border-bottom:1px solid #ddd;-o-text-overflow:ellipsis;text-overflow:ellipsis;background:#fcfcfc;padding:0 0 0 16px;position:relative;text-align:left;pointer-events:auto}.acfe-modal.-open.acfe-modal-sub>.acfe-modal-wrapper>.acfe-modal-title{pointer-events:none}.acfe-modal.-open .acfe-modal-title>span.title{line-height:50px;color:#23282d;font-weight:600}.acfe-modal.-open .acfe-modal-title>span.title .acf-fc-layout-order{width:30px;height:30px;border-radius:30px;display:inline-block;text-align:center;line-height:30px;margin:0 2px 0 0;background:#f1f1f1;font-size:14px;color:#666;vertical-align:2px}.acfe-modal.-open .acfe-modal-title>button.close{height:50px;width:50px;color:#666;border:0;border-left:0;margin:0;padding:0;border-radius:0;position:absolute;top:0;right:0;-webkit-transition:color .1s ease-in-out,background .1s ease-in-out;-o-transition:color .1s ease-in-out,background .1s ease-in-out;transition:color .1s ease-in-out,background .1s ease-in-out;background:none;cursor:pointer}.acfe-modal.-open .acfe-modal-title>button.close:hover{color:#00a0d2}.acfe-modal.-open .acfe-modal-title>button.close:before{height:50px;width:50px;line-height:50px!important;font:normal 20px/1 dashicons;content:"\f158";margin:0;padding:0}.acfe-modal.-open .acfe-modal-content{height:100%;background:#fff;display:block;position:relative;pointer-events:auto;overflow:auto}.acfe-modal.-open.-iframe .acfe-modal-content{overflow:hidden}.acfe-modal.-open.acfe-modal-sub>.acfe-modal-wrapper>.acfe-modal-content{pointer-events:none}.acfe-modal.-open .acfe-modal-content .nav-tab-wrapper{padding:0;margin:0;border-bottom:1px solid #ddd}.acfe-modal.-open .acfe-modal-content .nav-tab-wrapper a{margin:0;border-left:0;border-top:0;border-bottom:0;background:#fff;-webkit-transition:color .1s ease-in-out,background .1s ease-in-out;-o-transition:color .1s ease-in-out,background .1s ease-in-out;transition:color .1s ease-in-out,background .1s ease-in-out;padding:7px 15px;border-color:#ddd}.acfe-modal.-open .acfe-modal-content .nav-tab-wrapper a span.dashicons-menu{line-height:27px}.acfe-modal.-open>.acfe-modal-content .nav-tab-wrapper a:hover{background:#f9f9f9;color:#23282d}.acfe-modal.-open .acfe-modal-content .nav-tab-wrapper a.nav-tab-active,.acfe-modal.-open .acfe-modal-content .nav-tab-wrapper a.nav-tab-active:hover{background:#fcfcfc;color:#23282d}.acfe-modal.-open .acfe-modal-content .nav-tab:focus,.acfe-modal.-open .acfe-modal-content .nav-tab:focus:active{border-bottom:0;-webkit-box-shadow:none;box-shadow:none;outline:0}.acfe-modal.-open .acfe-modal-content .acfe-flex-container,.acfe-modal.-open .acfe-modal-content .acfe-flex-container *{-webkit-box-sizing:border-box;box-sizing:border-box}.acfe-modal.-open .acfe-modal-content .acfe-flex-container{width:100%;padding:14px;margin-right:auto;margin-left:auto}.acfe-modal.-open .acfe-modal-content .acfe-flexible-categories~.acfe-flex-container{overflow:auto;height:calc(100% - 39px)}.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul{margin:0 -7px;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap}.acfe-modal.-open>.acfe-modal-content .acfe-flex-container ul:after{content:"";clear:both;display:table}.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li{position:relative;width:100%;padding-right:7px;padding-left:7px;padding-bottom:14px;margin:0;-webkit-box-flex:0;-ms-flex:0 0 25%;flex:0 0 25%;max-width:25%}.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a{border:1px solid #ddd;background:#f9f9f9;padding:15px;color:#333;display:block;text-decoration:none;height:100%}.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-flex-thumbnails ul li a{text-align:center}.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a:hover{background:#007cba;color:#fff}body:not(.acf-admin-5-3) .acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a:hover{background:#0073aa}.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a span{display:inline-block;font-size:16px;font-weight:600}.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a span.badge.acf-js-tooltip{color:#999;font-weight:400;margin-left:2px;line-height:1.2;font-size:0}.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a span.badge.acf-js-tooltip:before{font-size:16px}.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a:hover span.badge.acf-js-tooltip{color:#fff}.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a.disabled{pointer-events:none;opacity:.67}.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a.disabled:hover{cursor:default}.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a.disabled:focus{-webkit-box-shadow:none;box-shadow:none;outline:none}.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-1 ul li{-webkit-box-flex:0;-ms-flex:0 0 100%;flex:0 0 100%;max-width:100%}.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-2 ul li{-webkit-box-flex:0;-ms-flex:0 0 50%;flex:0 0 50%;max-width:50%}.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-3 ul li{-webkit-box-flex:0;-ms-flex:0 0 33.333333%;flex:0 0 33.333333%;max-width:33.333333%}.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-4 ul li{-webkit-box-flex:0;-ms-flex:0 0 25%;flex:0 0 25%;max-width:25%}.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-5 ul li{-webkit-box-flex:0;-ms-flex:0 0 20%;flex:0 0 20%;max-width:20%}.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-6 ul li{-webkit-box-flex:0;-ms-flex:0 0 16.66%;flex:0 0 16.66%;max-width:16.66%}@media only screen and (max-width:960px){.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li{-webkit-box-flex:0!important;-ms-flex:0 0 50%!important;flex:0 0 50%!important;max-width:50%!important}.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-1 ul li{-webkit-box-flex:0!important;-ms-flex:0 0 100%!important;flex:0 0 100%!important;max-width:100%!important}.acfe-modal.-open .acfe-modal-content ul li a{padding:7px}}@media only screen and (max-width:720px){.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-1 ul li,.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li{-webkit-box-flex:0!important;-ms-flex:0 0 100%!important;flex:0 0 100%!important;max-width:100%!important}}.acfe-modal.-open .acfe-modal-footer,.acfe-modal.-open .acfe-modal-footer *{-webkit-box-sizing:border-box;box-sizing:border-box}.acfe-modal.-open .acfe-modal-footer{display:block;height:50px;line-height:50px;color:#23282d;background:#fcfcfc;padding:0 16px;position:relative;text-align:right;border-top:1px solid #ddd;pointer-events:auto}.acfe-modal.-open.acfe-modal-sub>.acfe-modal-wrapper>.acfe-modal-footer{pointer-events:none}.acfe-modal.-open .acfe-modal-footer>button{vertical-align:baseline}body.block-editor-page .edit-post-layout .acfe-modal.-open{-webkit-box-pack:start;-ms-flex-pack:start;justify-content:start;-webkit-box-align:start;-ms-flex-align:start;align-items:start}body.block-editor-page .edit-post-layout .acfe-modal.-open>.acfe-modal-wrapper{margin-top:88px;height:100%;width:100%;max-height:calc(100vh - 88px)}body.block-editor-page .edit-post-layout .acfe-modal.-open>.acfe-modal-wrapper>.acfe-modal-content>.acf-fields.-left{height:100%}body.block-editor-page .edit-post-layout .acfe-modal.-open>.acfe-modal-wrapper>.acfe-modal-content>.acf-fields.-left:before{content:"";display:block;position:absolute;z-index:0;background:#f9f9f9;border:solid #e1e1e1;border-width:0 1px 0 0;top:0;bottom:0;left:0;width:20%}@media only screen and (max-width:1080px){body.block-editor-page .edit-post-layout .acfe-modal.-open>.acfe-modal-wrapper{margin-top:88px}}body.block-editor-page .edit-post-layout .acfe-modal.-open>.acfe-modal-wrapper{max-width:calc(100vw - 160px);margin-left:160px}body.block-editor-page .edit-post-layout.is-sidebar-opened .acfe-modal.-open>.acfe-modal-wrapper{max-width:calc(100vw - 440px)}body.block-editor-page.folded .edit-post-layout .acfe-modal.-open>.acfe-modal-wrapper{max-width:calc(100vw - 36px);margin-left:36px}@media only screen and (max-width:960px){body.block-editor-page.auto-fold .edit-post-layout .acfe-modal.-open>.acfe-modal-wrapper{max-width:calc(100vw - 36px);margin-left:36px}}@media only screen and (max-width:782px){body.block-editor-page.auto-fold .edit-post-layout .acfe-modal.-open>.acfe-modal-wrapper{max-width:100vw;margin-left:0;margin-top:100px}}body.block-editor-page.folded .edit-post-layout.is-sidebar-opened .acfe-modal.-open>.acfe-modal-wrapper{max-width:calc(100vw - 316px)}@media (min-width:600px){body.block-editor-page.acfe-modal-opened .edit-post-layout__content{overflow-y:hidden}}body.block-editor-page .acfe-modal-overlay{display:none}body.wp-admin.upload-php.acfe-modal-opened>div:not([style*="display: none;"])>.media-modal.wp-core-ui:not(.acf-media-modal):before{content:"";display:block;position:absolute;background:rgba(0,0,0,.7);top:0;left:0;width:100%;height:100%;z-index:10000}
|
1 |
+
body.acfe-modal-opened{overflow:hidden}.acfe-modal-overlay{background:rgba(0,0,0,.7);position:fixed;top:0;left:0;right:0;bottom:0;height:100%;width:100%;z-index:100000}.acfe-modal{display:none;-webkit-transition:all .3s ease-in-out;-o-transition:all .3s ease-in-out;transition:all .3s ease-in-out}.acfe-modal.-open{position:fixed;z-index:100001;height:100%;width:100%;top:0;left:0;bottom:0;right:0;-webkit-font-smoothing:subpixel-antialiased;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;pointer-events:none}.acfe-modal.-open,.acfe-modal.-open>.acfe-modal-wrapper{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.acfe-modal.-open>.acfe-modal-wrapper{-webkit-box-shadow:0 5px 15px rgba(0,0,0,.7);box-shadow:0 5px 15px rgba(0,0,0,.7);width:calc(100vw - 60px);max-width:1100px;max-height:calc(100vh - 60px);position:relative}.acfe-modal.-open.acfe-modal-sub>.acfe-modal-wrapper>.acfe-modal-wrapper-overlay{position:absolute;z-index:10;background:rgba(0,0,0,.7);height:100%;width:100%;pointer-events:none}.acfe-modal.-open.-small>.acfe-modal-wrapper{max-width:450px}.acfe-modal.-open.-medium>.acfe-modal-wrapper{max-width:700px}.acfe-modal.-open.-large>.acfe-modal-wrapper{max-width:1100px}.acfe-modal.-open.-xlarge>.acfe-modal-wrapper{max-width:1400px}.acfe-modal.-open.-full>.acfe-modal-wrapper{max-width:100%;-webkit-box-flex:1;-ms-flex:1;flex:1}.acfe-modal.-open.-full>.acfe-modal-wrapper>.acfe-modal-content>.acf-fields.-left{height:100%}.acfe-modal.-open.-full>.acfe-modal-wrapper>.acfe-modal-content>.acf-fields.-left:before{content:"";display:block;position:absolute;z-index:0;background:#f9f9f9;border:solid #e1e1e1;border-width:0 1px 0 0;top:0;bottom:0;left:0;width:20%}.acfe-modal.-settings.-open.-full>.acfe-modal-wrapper>.acfe-modal-content>.acf-fields,.acfe-modal.-settings.-open.-full>.acfe-modal-wrapper>.acfe-modal-content>.acf-fields>.acf-field-clone,.acfe-modal.-settings.-open.-full>.acfe-modal-wrapper>.acfe-modal-content>.acf-fields>.acf-field-clone>.acf-input,.acfe-modal.-settings.-open.-full>.acfe-modal-wrapper>.acfe-modal-content>.acf-fields>.acf-field-clone>.acf-input>.acf-clone-fields.acf-fields.-left{height:100%}.acfe-modal.-settings.-open.-full>.acfe-modal-wrapper>.acfe-modal-content>.acf-fields>.acf-field-clone{padding:0}.acfe-modal.-settings.-open.-full>.acfe-modal-wrapper>.acfe-modal-content>.acf-fields>.acf-field-clone>.acf-input{margin:0}.acfe-modal.-settings.-open.-full>.acfe-modal-wrapper>.acfe-modal-content>.acf-fields>.acf-field-clone>.acf-input>.acf-clone-fields.acf-fields.-left:before{content:"";display:block;position:absolute;z-index:0;background:#f9f9f9;border:solid #e1e1e1;border-width:0 1px 0 0;top:0;bottom:0;left:0;width:20%}.acfe-modal.-open .acfe-modal-title *,.acfe-modal.-open>.acfe-modal-title{-webkit-box-sizing:border-box;box-sizing:border-box}.acfe-modal.-open .acfe-modal-title{display:block;height:50px;line-height:50px;font-size:22px;color:#23282d;border-bottom:1px solid #ddd;-o-text-overflow:ellipsis;text-overflow:ellipsis;background:#fcfcfc;padding:0 0 0 16px;position:relative;text-align:left;pointer-events:auto}.acfe-modal.-open.acfe-modal-sub>.acfe-modal-wrapper>.acfe-modal-title{pointer-events:none}.acfe-modal.-open .acfe-modal-title>span.title{line-height:50px;color:#23282d;font-weight:600}.acfe-modal.-open .acfe-modal-title>span.title .acf-fc-layout-order{width:30px;height:30px;border-radius:30px;display:inline-block;text-align:center;line-height:30px;margin:0 2px 0 0;background:#f1f1f1;font-size:14px;color:#666;vertical-align:2px}.acfe-modal.-open .acfe-modal-title>button.close{height:50px;width:50px;color:#666;border:0;border-left:0;margin:0;padding:0;border-radius:0;position:absolute;top:0;right:0;-webkit-transition:color .1s ease-in-out,background .1s ease-in-out;-o-transition:color .1s ease-in-out,background .1s ease-in-out;transition:color .1s ease-in-out,background .1s ease-in-out;background:none;cursor:pointer}.acfe-modal.-open .acfe-modal-title>button.close:hover{color:#00a0d2}.acfe-modal.-open .acfe-modal-title>button.close:before{height:50px;width:50px;line-height:50px!important;font:normal 20px/1 dashicons;content:"\f158";margin:0;padding:0}.acfe-modal.-open .acfe-modal-content{height:100%;background:#fff;display:block;position:relative;pointer-events:auto;overflow:auto}.acfe-modal.-open.-iframe .acfe-modal-content{overflow:hidden}.acfe-modal.-open.acfe-modal-sub>.acfe-modal-wrapper>.acfe-modal-content{pointer-events:none}.acfe-modal.-open .acfe-modal-content .nav-tab-wrapper{padding:0;margin:0;border-bottom:1px solid #ddd}.acfe-modal.-open .acfe-modal-content .nav-tab-wrapper a{margin:0;border-left:0;border-top:0;border-bottom:0;background:#fff;-webkit-transition:color .1s ease-in-out,background .1s ease-in-out;-o-transition:color .1s ease-in-out,background .1s ease-in-out;transition:color .1s ease-in-out,background .1s ease-in-out;padding:7px 15px;border-color:#ddd}.acfe-modal.-open .acfe-modal-content .nav-tab-wrapper a span.dashicons-menu{line-height:27px}.acfe-modal.-open>.acfe-modal-content .nav-tab-wrapper a:hover{background:#f9f9f9;color:#23282d}.acfe-modal.-open .acfe-modal-content .nav-tab-wrapper a.nav-tab-active,.acfe-modal.-open .acfe-modal-content .nav-tab-wrapper a.nav-tab-active:hover{background:#fcfcfc;color:#23282d}.acfe-modal.-open .acfe-modal-content .nav-tab:focus,.acfe-modal.-open .acfe-modal-content .nav-tab:focus:active{border-bottom:0;-webkit-box-shadow:none;box-shadow:none;outline:0}.acfe-modal.-open .acfe-modal-content .acfe-flex-container,.acfe-modal.-open .acfe-modal-content .acfe-flex-container *{-webkit-box-sizing:border-box;box-sizing:border-box}.acfe-modal.-open .acfe-modal-content .acfe-flex-container{width:100%;padding:14px;margin-right:auto;margin-left:auto}.acfe-modal.-open .acfe-modal-content .acfe-flexible-categories~.acfe-flex-container{overflow:auto;height:calc(100% - 39px)}.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul{margin:0 -7px;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap}.acfe-modal.-open>.acfe-modal-content .acfe-flex-container ul:after{content:"";clear:both;display:table}.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li{position:relative;width:100%;padding-right:7px;padding-left:7px;padding-bottom:14px;margin:0;-webkit-box-flex:0;-ms-flex:0 0 25%;flex:0 0 25%;max-width:25%}.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a{border:1px solid #ddd;background:#f9f9f9;padding:15px;color:#333;display:block;text-decoration:none;height:100%}.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-flex-thumbnails ul li a{text-align:center}.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a:hover{background:#007cba;color:#fff}body:not(.acf-admin-5-3) .acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a:hover{background:#0073aa}.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a span{display:inline-block;font-size:16px;font-weight:600}.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a span.badge.acf-js-tooltip{color:#999;font-weight:400;margin-left:2px;line-height:1.2;font-size:0}.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a span.badge.acf-js-tooltip:before{font-size:16px}.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a:hover span.badge.acf-js-tooltip{color:#fff}.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a.disabled{pointer-events:none;opacity:.67}.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a.disabled:hover{cursor:default}.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li a.disabled:focus{-webkit-box-shadow:none;box-shadow:none;outline:none}.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-1 ul li{-webkit-box-flex:0;-ms-flex:0 0 100%;flex:0 0 100%;max-width:100%}.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-2 ul li{-webkit-box-flex:0;-ms-flex:0 0 50%;flex:0 0 50%;max-width:50%}.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-3 ul li{-webkit-box-flex:0;-ms-flex:0 0 33.333333%;flex:0 0 33.333333%;max-width:33.333333%}.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-4 ul li{-webkit-box-flex:0;-ms-flex:0 0 25%;flex:0 0 25%;max-width:25%}.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-5 ul li{-webkit-box-flex:0;-ms-flex:0 0 20%;flex:0 0 20%;max-width:20%}.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-6 ul li{-webkit-box-flex:0;-ms-flex:0 0 16.66%;flex:0 0 16.66%;max-width:16.66%}@media only screen and (max-width:960px){.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li{-webkit-box-flex:0!important;-ms-flex:0 0 50%!important;flex:0 0 50%!important;max-width:50%!important}.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-1 ul li{-webkit-box-flex:0!important;-ms-flex:0 0 100%!important;flex:0 0 100%!important;max-width:100%!important}.acfe-modal.-open .acfe-modal-content ul li a{padding:7px}}@media only screen and (max-width:720px){.acfe-modal.-open .acfe-modal-content .acfe-flex-container.acfe-col-1 ul li,.acfe-modal.-open .acfe-modal-content .acfe-flex-container ul li{-webkit-box-flex:0!important;-ms-flex:0 0 100%!important;flex:0 0 100%!important;max-width:100%!important}}.acfe-modal.-open .acfe-modal-footer,.acfe-modal.-open .acfe-modal-footer *{-webkit-box-sizing:border-box;box-sizing:border-box}.acfe-modal.-open .acfe-modal-footer{display:block;height:50px;line-height:50px;color:#23282d;background:#fcfcfc;padding:0 16px;position:relative;text-align:right;border-top:1px solid #ddd;pointer-events:auto}.acfe-modal.-open.acfe-modal-sub>.acfe-modal-wrapper>.acfe-modal-footer{pointer-events:none}.acfe-modal.-open .acfe-modal-footer>button{vertical-align:baseline}body.block-editor-page .edit-post-layout .acfe-modal.-open{-webkit-box-pack:start;-ms-flex-pack:start;justify-content:start;-webkit-box-align:start;-ms-flex-align:start;align-items:start}body.block-editor-page .edit-post-layout .acfe-modal.-open>.acfe-modal-wrapper{margin-top:88px;height:100%;width:100%;max-height:calc(100vh - 88px)}body.block-editor-page .edit-post-layout .acfe-modal.-open>.acfe-modal-wrapper>.acfe-modal-content>.acf-fields.-left{height:100%}body.block-editor-page .edit-post-layout .acfe-modal.-open>.acfe-modal-wrapper>.acfe-modal-content>.acf-fields.-left:before{content:"";display:block;position:absolute;z-index:0;background:#f9f9f9;border:solid #e1e1e1;border-width:0 1px 0 0;top:0;bottom:0;left:0;width:20%}@media only screen and (max-width:1080px){body.block-editor-page .edit-post-layout .acfe-modal.-open>.acfe-modal-wrapper{margin-top:88px}}body.block-editor-page .edit-post-layout .acfe-modal.-open>.acfe-modal-wrapper{max-width:calc(100vw - 160px);margin-left:160px}body.block-editor-page .edit-post-layout.is-sidebar-opened .acfe-modal.-open>.acfe-modal-wrapper{max-width:calc(100vw - 440px)}body.block-editor-page.folded .edit-post-layout .acfe-modal.-open>.acfe-modal-wrapper{max-width:calc(100vw - 36px);margin-left:36px}@media only screen and (max-width:960px){body.block-editor-page.auto-fold .edit-post-layout .acfe-modal.-open>.acfe-modal-wrapper{max-width:calc(100vw - 36px);margin-left:36px}}@media only screen and (max-width:782px){body.block-editor-page.auto-fold .edit-post-layout .acfe-modal.-open>.acfe-modal-wrapper{max-width:100vw;margin-left:0;margin-top:100px}}body.block-editor-page.folded .edit-post-layout.is-sidebar-opened .acfe-modal.-open>.acfe-modal-wrapper{max-width:calc(100vw - 316px)}@media (min-width:600px){body.block-editor-page.acfe-modal-opened .edit-post-layout__content{overflow-y:hidden}}body.block-editor-page .acfe-modal-overlay{display:none}body.wp-admin.upload-php.acfe-modal-opened>div:not([style*="display: none;"])>.media-modal.wp-core-ui:not(.acf-media-modal):before{content:"";display:block;position:absolute;background:rgba(0,0,0,.7);top:0;left:0;width:100%;height:100%;z-index:10000}.pac-container{z-index:100001}
|
@@ -1,525 +1,525 @@
|
|
1 |
-
(function($){
|
2 |
-
|
3 |
-
if(typeof acf === 'undefined')
|
4 |
-
return;
|
5 |
-
|
6 |
-
/*
|
7 |
-
* ACFE Form
|
8 |
-
*/
|
9 |
-
new acf.Model({
|
10 |
-
|
11 |
-
actions: {
|
12 |
-
|
13 |
-
// Buttons
|
14 |
-
'new_field/name=acfe_form_actions': 'actionsButton',
|
15 |
-
'new_field/name=acfe_form_email_files': 'filesButton',
|
16 |
-
'new_field/name=acfe_form_email_files_static': 'filesButton',
|
17 |
-
|
18 |
-
// Post
|
19 |
-
'new_field/name=acfe_form_post_map_target': 'mapFields',
|
20 |
-
'new_field/name=acfe_form_post_map_post_type': 'mapFields',
|
21 |
-
'new_field/name=acfe_form_post_map_post_status': 'mapFields',
|
22 |
-
'new_field/name=acfe_form_post_map_post_title': 'mapFields',
|
23 |
-
'new_field/name=acfe_form_post_map_post_name': 'mapFields',
|
24 |
-
'new_field/name=acfe_form_post_map_post_content': 'mapFields',
|
25 |
-
'new_field/name=acfe_form_post_map_post_author': 'mapFields',
|
26 |
-
'new_field/name=acfe_form_post_map_post_parent': 'mapFields',
|
27 |
-
'new_field/name=acfe_form_post_map_post_terms': 'mapFields',
|
28 |
-
|
29 |
-
// User
|
30 |
-
'new_field/name=acfe_form_user_map_email': 'mapFields',
|
31 |
-
'new_field/name=acfe_form_user_map_username': 'mapFields',
|
32 |
-
'new_field/name=acfe_form_user_map_password': 'mapFields',
|
33 |
-
'new_field/name=acfe_form_user_map_first_name': 'mapFields',
|
34 |
-
'new_field/name=acfe_form_user_map_last_name': 'mapFields',
|
35 |
-
'new_field/name=acfe_form_user_map_nickname': 'mapFields',
|
36 |
-
'new_field/name=acfe_form_user_map_display_name': 'mapFields',
|
37 |
-
'new_field/name=acfe_form_user_map_website': 'mapFields',
|
38 |
-
'new_field/name=acfe_form_user_map_description': 'mapFields',
|
39 |
-
'new_field/name=acfe_form_user_map_role': 'mapFields',
|
40 |
-
|
41 |
-
// Term
|
42 |
-
'new_field/name=acfe_form_term_map_name': 'mapFields',
|
43 |
-
'new_field/name=acfe_form_term_map_slug': 'mapFields',
|
44 |
-
'new_field/name=acfe_form_term_map_taxonomy': 'mapFields',
|
45 |
-
'new_field/name=acfe_form_term_map_parent': 'mapFields',
|
46 |
-
'new_field/name=acfe_form_term_map_description': 'mapFields',
|
47 |
-
},
|
48 |
-
|
49 |
-
filters: {
|
50 |
-
'select2_args': 'select2Args'
|
51 |
-
},
|
52 |
-
|
53 |
-
actionsButton: function(field){
|
54 |
-
|
55 |
-
field.on('click', '[data-name="add-layout"]', function(e){
|
56 |
-
|
57 |
-
$('body').find('.acf-fc-popup').addClass('acfe-fc-popup-grey');
|
58 |
-
|
59 |
-
});
|
60 |
-
|
61 |
-
},
|
62 |
-
|
63 |
-
filesButton: function(field){
|
64 |
-
|
65 |
-
field.$('> .acf-input > .acf-repeater > .acf-actions > .acf-button').removeClass('button-primary');
|
66 |
-
|
67 |
-
},
|
68 |
-
|
69 |
-
mapFields: function(field){
|
70 |
-
|
71 |
-
var $layout = field.$el.closest('.layout');
|
72 |
-
var $message = $layout.find('> .acf-fields > .acf-field[data-name="' + field.get('name') + '_message"] > .acf-input');
|
73 |
-
|
74 |
-
var selected = field.$input().find('option:selected').text();
|
75 |
-
|
76 |
-
if(selected.length){
|
77 |
-
$message.html(selected);
|
78 |
-
}
|
79 |
-
|
80 |
-
field.$input().on('change', function(){
|
81 |
-
|
82 |
-
// Message
|
83 |
-
var text = $(this).find('option:selected').text();
|
84 |
-
|
85 |
-
$message.html(text);
|
86 |
-
|
87 |
-
});
|
88 |
-
|
89 |
-
},
|
90 |
-
|
91 |
-
select2Args: function(options, $select, fieldData, field, instance){
|
92 |
-
|
93 |
-
if(field.get('acfeAllowCustom')){
|
94 |
-
|
95 |
-
options.templateSelection = function(state){
|
96 |
-
|
97 |
-
if(!state.id){
|
98 |
-
return state.text;
|
99 |
-
}
|
100 |
-
|
101 |
-
var text = state.text;
|
102 |
-
|
103 |
-
var match_field = /{field:(.*)}/g;
|
104 |
-
var match_fields = /{fields}/g;
|
105 |
-
var match_get_field = /{get_field:(.*)}/g;
|
106 |
-
var match_query_var = /{query_var:(.*)}/g;
|
107 |
-
var match_request = /{request:(.*)}/g;
|
108 |
-
var match_current = /{current:(.*)}/g;
|
109 |
-
var match_form = /{(form|form:.*?)}/g;
|
110 |
-
var match_action = /{action:(.*)}/g;
|
111 |
-
|
112 |
-
text = text.replace(match_field, "<code style='font-size:12px;padding:3px;vertical-align: 1px;line-height: 12px;'>{field:$1}</code>");
|
113 |
-
text = text.replace(match_fields, "<code style='font-size:12px;padding:3px;vertical-align: 1px;line-height: 12px;'>{fields}</code>");
|
114 |
-
text = text.replace(match_current, "<code style='font-size:12px;padding:3px;vertical-align: 1px;line-height: 12px;'>{current:$1}</code>");
|
115 |
-
text = text.replace(match_form, "<code style='font-size:12px;padding:3px;vertical-align: 1px;line-height: 12px;'>{$1}</code>");
|
116 |
-
text = text.replace(match_action, "<code style='font-size:12px;padding:3px;vertical-align: 1px;line-height: 12px;'>{action:$1}</code>");
|
117 |
-
text = text.replace(match_get_field, "<code style='font-size:12px;padding:3px;vertical-align: 1px;line-height: 12px;'>{get_field:$1}</code>");
|
118 |
-
text = text.replace(match_query_var, "<code style='font-size:12px;padding:3px;vertical-align: 1px;line-height: 12px;'>{query_var:$1}</code>");
|
119 |
-
text = text.replace(match_request, "<code style='font-size:12px;padding:3px;vertical-align: 1px;line-height: 12px;'>{request:$1}</code>");
|
120 |
-
|
121 |
-
|
122 |
-
return text;
|
123 |
-
|
124 |
-
};
|
125 |
-
|
126 |
-
options.templateResult = function(state){
|
127 |
-
|
128 |
-
if(!state.id){
|
129 |
-
return state.text;
|
130 |
-
}
|
131 |
-
|
132 |
-
var text = state.text;
|
133 |
-
|
134 |
-
var match_field = /{field:(.*?)}/g;
|
135 |
-
var match_fields = /{fields}/g;
|
136 |
-
var match_get_field = /{get_field:(.*?)}/g;
|
137 |
-
var match_query_var = /{query_var:(.*?)}/g;
|
138 |
-
var match_request = /{request:(.*?)}/g;
|
139 |
-
var match_current = /{current:(.*?)}/g;
|
140 |
-
var match_form = /{(form|form:.*?)}/g;
|
141 |
-
var match_action = /{action:(.*?)}/g;
|
142 |
-
|
143 |
-
text = text.replace(match_field, "<code style='font-size:12px;'>{field:$1}</code>");
|
144 |
-
text = text.replace(match_fields, "<code style='font-size:12px;'>{fields}</code>");
|
145 |
-
text = text.replace(match_get_field, "<code style='font-size:12px;'>{get_field:$1}</code>");
|
146 |
-
text = text.replace(match_query_var, "<code style='font-size:12px;'>{query_var:$1}</code>");
|
147 |
-
text = text.replace(match_request, "<code style='font-size:12px;'>{request:$1}</code>");
|
148 |
-
text = text.replace(match_current, "<code style='font-size:12px;'>{current:$1}</code>");
|
149 |
-
text = text.replace(match_form, "<code style='font-size:12px;'>{$1}</code>");
|
150 |
-
text = text.replace(match_action, "<code style='font-size:12px;'>{action:$1}</code>");
|
151 |
-
|
152 |
-
return text;
|
153 |
-
|
154 |
-
};
|
155 |
-
|
156 |
-
}
|
157 |
-
|
158 |
-
return options;
|
159 |
-
|
160 |
-
}
|
161 |
-
|
162 |
-
});
|
163 |
-
|
164 |
-
/*
|
165 |
-
* Dev Mode
|
166 |
-
*/
|
167 |
-
new acf.Model({
|
168 |
-
|
169 |
-
wait: 'prepare',
|
170 |
-
|
171 |
-
events: {
|
172 |
-
'click .acfe_delete_meta': 'onClickSingle',
|
173 |
-
'click #acfe_bulk_delete_meta_submit': 'onSubmitBulk',
|
174 |
-
'click.postboxes .hide-postbox-tog': 'onClickPostbox',
|
175 |
-
},
|
176 |
-
|
177 |
-
$acfWrap: function(){
|
178 |
-
return $('#acfe-acf-custom-fields');
|
179 |
-
},
|
180 |
-
|
181 |
-
$wpWrap: function(){
|
182 |
-
return $('#acfe-wp-custom-fields');
|
183 |
-
},
|
184 |
-
|
185 |
-
acfCount: function(){
|
186 |
-
return $('#acfe-acf-custom-fields tbody tr').length;
|
187 |
-
},
|
188 |
-
|
189 |
-
wpCount: function(){
|
190 |
-
return $('#acfe-wp-custom-fields tbody tr').length;
|
191 |
-
},
|
192 |
-
|
193 |
-
$bulkActions: function(){
|
194 |
-
return $('.acfe_dev_bulk_actions');
|
195 |
-
},
|
196 |
-
|
197 |
-
initialize: function(){
|
198 |
-
|
199 |
-
var $acfWrap = this.$acfWrap();
|
200 |
-
var $wpWrap = this.$wpWrap();
|
201 |
-
var $bulkActions = this.$bulkActions();
|
202 |
-
|
203 |
-
// Move Bulk Button
|
204 |
-
$acfWrap.find('.tablenav.bottom').insertAfter($acfWrap);
|
205 |
-
$wpWrap.find('.tablenav.bottom').insertAfter($wpWrap);
|
206 |
-
|
207 |
-
if(!$acfWrap.is(':visible') && !$wpWrap.is(':visible')){
|
208 |
-
|
209 |
-
$bulkActions.hide();
|
210 |
-
|
211 |
-
}
|
212 |
-
|
213 |
-
},
|
214 |
-
|
215 |
-
sync: function(){
|
216 |
-
|
217 |
-
var self = this;
|
218 |
-
|
219 |
-
setTimeout(function(){
|
220 |
-
|
221 |
-
var acfCount = self.acfCount();
|
222 |
-
var wpCount = self.wpCount();
|
223 |
-
|
224 |
-
var $acfWrap = self.$acfWrap();
|
225 |
-
var $wpWrap = self.$wpWrap();
|
226 |
-
|
227 |
-
var $bulkActions = self.$bulkActions();
|
228 |
-
|
229 |
-
$acfWrap.find('.acfe_dev_meta_count').text(acfCount);
|
230 |
-
$wpWrap.find('.acfe_dev_meta_count').text(wpCount);
|
231 |
-
|
232 |
-
if(!acfCount){
|
233 |
-
$acfWrap.remove();
|
234 |
-
}
|
235 |
-
|
236 |
-
if(!wpCount){
|
237 |
-
$wpWrap.remove();
|
238 |
-
}
|
239 |
-
|
240 |
-
if(!acfCount && !wpCount){
|
241 |
-
$bulkActions.remove();
|
242 |
-
}
|
243 |
-
|
244 |
-
}, 351);
|
245 |
-
|
246 |
-
},
|
247 |
-
|
248 |
-
onClickSingle: function(e, $el){
|
249 |
-
|
250 |
-
e.preventDefault();
|
251 |
-
|
252 |
-
var self = this;
|
253 |
-
var $tr = $el.closest('tr');
|
254 |
-
|
255 |
-
$.ajax({
|
256 |
-
url: acf.get('ajaxurl'),
|
257 |
-
type: 'post',
|
258 |
-
data: {
|
259 |
-
action: 'acfe/delete_meta',
|
260 |
-
id: $el.attr('data-meta-id'),
|
261 |
-
key: $el.attr('data-meta-key'),
|
262 |
-
type: $el.attr('data-type'),
|
263 |
-
_wpnonce: $el.attr('data-nonce'),
|
264 |
-
},
|
265 |
-
beforeSend: function(){
|
266 |
-
|
267 |
-
$tr.css({backgroundColor:'#faafaa'}).fadeOut(350, function(){
|
268 |
-
$tr.remove();
|
269 |
-
});
|
270 |
-
|
271 |
-
self.sync();
|
272 |
-
|
273 |
-
},
|
274 |
-
success: function(response){
|
275 |
-
|
276 |
-
if(response !== '1'){
|
277 |
-
$tr.css({backgroundColor:''});
|
278 |
-
$tr.show();
|
279 |
-
}
|
280 |
-
|
281 |
-
}
|
282 |
-
});
|
283 |
-
|
284 |
-
},
|
285 |
-
|
286 |
-
onSubmitBulk: function(e, $el){
|
287 |
-
|
288 |
-
e.preventDefault();
|
289 |
-
|
290 |
-
var self = this;
|
291 |
-
var action = $el.prevAll('.acfe_bulk_delete_meta_action').val();
|
292 |
-
var type = $el.prevAll('.acfe_bulk_delete_meta_type').val();
|
293 |
-
var nonce = $el.prevAll('.acfe_bulk_delete_meta_nonce').val();
|
294 |
-
|
295 |
-
if(action === 'delete'){
|
296 |
-
|
297 |
-
var ids = [];
|
298 |
-
var trs = [];
|
299 |
-
|
300 |
-
$('input.acfe_bulk_delete_meta:checked').each(function(){
|
301 |
-
ids.push($(this).val());
|
302 |
-
trs.push($(this).closest('tr'));
|
303 |
-
});
|
304 |
-
|
305 |
-
if(ids.length){
|
306 |
-
|
307 |
-
$.ajax({
|
308 |
-
url: acf.get('ajaxurl'),
|
309 |
-
type: 'post',
|
310 |
-
data: {
|
311 |
-
action: 'acfe/bulk_delete_meta',
|
312 |
-
ids: ids,
|
313 |
-
type: type,
|
314 |
-
_wpnonce: nonce,
|
315 |
-
},
|
316 |
-
beforeSend: function(){
|
317 |
-
|
318 |
-
trs.map(function(tr){
|
319 |
-
$(tr).css({backgroundColor:'#faafaa'}).fadeOut(350, function(){
|
320 |
-
$(tr).remove();
|
321 |
-
});
|
322 |
-
});
|
323 |
-
|
324 |
-
self.sync();
|
325 |
-
|
326 |
-
}
|
327 |
-
});
|
328 |
-
|
329 |
-
}
|
330 |
-
|
331 |
-
}
|
332 |
-
|
333 |
-
},
|
334 |
-
|
335 |
-
onClickPostbox: function(e, $el){
|
336 |
-
|
337 |
-
var val = $el.val();
|
338 |
-
|
339 |
-
var $acfWrap = this.$acfWrap();
|
340 |
-
var $wpWrap = this.$wpWrap();
|
341 |
-
var $bulkActions = this.$bulkActions();
|
342 |
-
|
343 |
-
if(!acfe.inArray(val, ['acfe-wp-custom-fields', 'acfe-acf-custom-fields']))
|
344 |
-
return;
|
345 |
-
|
346 |
-
if($el.prop('checked')){
|
347 |
-
|
348 |
-
if(!$bulkActions.is(':visible'))
|
349 |
-
$bulkActions.show();
|
350 |
-
|
351 |
-
}else if((val === 'acfe-wp-custom-fields' && !$acfWrap.is(':visible')) || (val === 'acfe-acf-custom-fields' && !$wpWrap.is(':visible'))){
|
352 |
-
|
353 |
-
$bulkActions.hide();
|
354 |
-
|
355 |
-
}
|
356 |
-
|
357 |
-
}
|
358 |
-
|
359 |
-
});
|
360 |
-
|
361 |
-
/*
|
362 |
-
* Module: Author
|
363 |
-
*/
|
364 |
-
new acf.Model({
|
365 |
-
|
366 |
-
actions: {
|
367 |
-
'new_field/name=acfe_author': 'newField',
|
368 |
-
},
|
369 |
-
|
370 |
-
newField: function(field){
|
371 |
-
|
372 |
-
field.on('change', function(e){
|
373 |
-
e.stopPropagation();
|
374 |
-
});
|
375 |
-
|
376 |
-
}
|
377 |
-
|
378 |
-
});
|
379 |
-
|
380 |
-
/*
|
381 |
-
* Postbox: ACFE Class
|
382 |
-
*/
|
383 |
-
acf.addAction('show_postbox', function(postbox){
|
384 |
-
postbox.$el.removeClass('acfe-postbox-left acfe-postbox-top');
|
385 |
-
});
|
386 |
-
|
387 |
-
/*
|
388 |
-
* Field: Enable Switch
|
389 |
-
*/
|
390 |
-
new acf.Model({
|
391 |
-
|
392 |
-
actions: {
|
393 |
-
'new_field': 'newField',
|
394 |
-
},
|
395 |
-
|
396 |
-
isRepeater: function(field){
|
397 |
-
return field.get('type') === 'repeater' || field.get('type') === 'flexible_content';
|
398 |
-
},
|
399 |
-
|
400 |
-
getCondition: function(target){
|
401 |
-
return this.isRepeater(target) ? target.val() === 0 : !target.val().length;
|
402 |
-
},
|
403 |
-
|
404 |
-
enableSwitcher: function(field){
|
405 |
-
|
406 |
-
var self = this;
|
407 |
-
var switcher, target;
|
408 |
-
|
409 |
-
if(field.get('switched')){
|
410 |
-
|
411 |
-
switcher = acf.getField(field.$el.prev());
|
412 |
-
target = field;
|
413 |
-
|
414 |
-
}else if(field.get('switcher')){
|
415 |
-
|
416 |
-
switcher = field;
|
417 |
-
target = acf.getField(field.$el.next());
|
418 |
-
|
419 |
-
}
|
420 |
-
|
421 |
-
if(self.getCondition(target)){
|
422 |
-
|
423 |
-
switcher.switchOff();
|
424 |
-
switcher.show('switcher');
|
425 |
-
target.hide('switcher');
|
426 |
-
|
427 |
-
}else{
|
428 |
-
|
429 |
-
switcher.hide('switcher');
|
430 |
-
target.show('switcher');
|
431 |
-
|
432 |
-
}
|
433 |
-
|
434 |
-
if(field.get('switcher')){
|
435 |
-
|
436 |
-
// Switch Action
|
437 |
-
switcher.on('change', function(){
|
438 |
-
|
439 |
-
if(switcher.$input().prop('checked')){
|
440 |
-
|
441 |
-
switcher.hide('switcher');
|
442 |
-
|
443 |
-
target.show('switcher');
|
444 |
-
|
445 |
-
if(self.isRepeater(target)){
|
446 |
-
target.add();
|
447 |
-
}
|
448 |
-
|
449 |
-
}
|
450 |
-
|
451 |
-
});
|
452 |
-
|
453 |
-
// Field Action
|
454 |
-
target.on('change', function(e, $el){
|
455 |
-
|
456 |
-
if(self.getCondition(target)){
|
457 |
-
|
458 |
-
switcher.switchOff();
|
459 |
-
switcher.show('switcher');
|
460 |
-
target.hide('switcher');
|
461 |
-
|
462 |
-
}
|
463 |
-
|
464 |
-
});
|
465 |
-
|
466 |
-
}
|
467 |
-
|
468 |
-
},
|
469 |
-
|
470 |
-
enableSwitch: function(field){
|
471 |
-
|
472 |
-
// Clone
|
473 |
-
var $row = field.$el.clone();
|
474 |
-
|
475 |
-
// Params
|
476 |
-
$row.removeAttr('data-enable-switch');
|
477 |
-
$row.attr('data-switcher', true);
|
478 |
-
$row.attr('data-name', field.get('name') + '_acfe_switch');
|
479 |
-
$row.attr('data-key', field.get('name') + '_acfe_switch');
|
480 |
-
$row.attr('data-type', 'true_false');
|
481 |
-
|
482 |
-
// HTML
|
483 |
-
$row.find('>.acf-input').html('<div class="acf-true-false">\n' +
|
484 |
-
'<input type="hidden" value="0">' +
|
485 |
-
'<label>\n' +
|
486 |
-
'<input type="checkbox" value="1" class="acf-switch-input" autocomplete="off">\n' +
|
487 |
-
'<div class="acf-switch"><span class="acf-switch-on" style="min-width: 18px;">' + acf.__('Yes') + '</span>' +
|
488 |
-
'<span class="acf-switch-off" style="min-width: 18px;">' + acf.__('No') + '</span><div class="acf-switch-slider"></div></div>' +
|
489 |
-
'</label>\n' +
|
490 |
-
'</div>');
|
491 |
-
|
492 |
-
// Insert
|
493 |
-
$row = $row.insertBefore(field.$el);
|
494 |
-
|
495 |
-
// New Switch
|
496 |
-
acf.getField($row);
|
497 |
-
|
498 |
-
// Remove Attribute
|
499 |
-
field.$el.removeAttr('data-enable-switch');
|
500 |
-
field.set('enableSwitch', false);
|
501 |
-
|
502 |
-
field.$el.attr('data-switched', true);
|
503 |
-
field.set('switched', true);
|
504 |
-
|
505 |
-
},
|
506 |
-
|
507 |
-
newField: function(field){
|
508 |
-
|
509 |
-
if(field.get('enableSwitch')){
|
510 |
-
|
511 |
-
this.enableSwitch(field);
|
512 |
-
|
513 |
-
}
|
514 |
-
|
515 |
-
else if(field.get('switched') || field.get('switcher')){
|
516 |
-
|
517 |
-
this.enableSwitcher(field);
|
518 |
-
|
519 |
-
}
|
520 |
-
|
521 |
-
}
|
522 |
-
|
523 |
-
});
|
524 |
-
|
525 |
})(jQuery);
|
1 |
+
(function($){
|
2 |
+
|
3 |
+
if(typeof acf === 'undefined')
|
4 |
+
return;
|
5 |
+
|
6 |
+
/*
|
7 |
+
* ACFE Form
|
8 |
+
*/
|
9 |
+
new acf.Model({
|
10 |
+
|
11 |
+
actions: {
|
12 |
+
|
13 |
+
// Buttons
|
14 |
+
'new_field/name=acfe_form_actions': 'actionsButton',
|
15 |
+
'new_field/name=acfe_form_email_files': 'filesButton',
|
16 |
+
'new_field/name=acfe_form_email_files_static': 'filesButton',
|
17 |
+
|
18 |
+
// Post
|
19 |
+
'new_field/name=acfe_form_post_map_target': 'mapFields',
|
20 |
+
'new_field/name=acfe_form_post_map_post_type': 'mapFields',
|
21 |
+
'new_field/name=acfe_form_post_map_post_status': 'mapFields',
|
22 |
+
'new_field/name=acfe_form_post_map_post_title': 'mapFields',
|
23 |
+
'new_field/name=acfe_form_post_map_post_name': 'mapFields',
|
24 |
+
'new_field/name=acfe_form_post_map_post_content': 'mapFields',
|
25 |
+
'new_field/name=acfe_form_post_map_post_author': 'mapFields',
|
26 |
+
'new_field/name=acfe_form_post_map_post_parent': 'mapFields',
|
27 |
+
'new_field/name=acfe_form_post_map_post_terms': 'mapFields',
|
28 |
+
|
29 |
+
// User
|
30 |
+
'new_field/name=acfe_form_user_map_email': 'mapFields',
|
31 |
+
'new_field/name=acfe_form_user_map_username': 'mapFields',
|
32 |
+
'new_field/name=acfe_form_user_map_password': 'mapFields',
|
33 |
+
'new_field/name=acfe_form_user_map_first_name': 'mapFields',
|
34 |
+
'new_field/name=acfe_form_user_map_last_name': 'mapFields',
|
35 |
+
'new_field/name=acfe_form_user_map_nickname': 'mapFields',
|
36 |
+
'new_field/name=acfe_form_user_map_display_name': 'mapFields',
|
37 |
+
'new_field/name=acfe_form_user_map_website': 'mapFields',
|
38 |
+
'new_field/name=acfe_form_user_map_description': 'mapFields',
|
39 |
+
'new_field/name=acfe_form_user_map_role': 'mapFields',
|
40 |
+
|
41 |
+
// Term
|
42 |
+
'new_field/name=acfe_form_term_map_name': 'mapFields',
|
43 |
+
'new_field/name=acfe_form_term_map_slug': 'mapFields',
|
44 |
+
'new_field/name=acfe_form_term_map_taxonomy': 'mapFields',
|
45 |
+
'new_field/name=acfe_form_term_map_parent': 'mapFields',
|
46 |
+
'new_field/name=acfe_form_term_map_description': 'mapFields',
|
47 |
+
},
|
48 |
+
|
49 |
+
filters: {
|
50 |
+
'select2_args': 'select2Args'
|
51 |
+
},
|
52 |
+
|
53 |
+
actionsButton: function(field){
|
54 |
+
|
55 |
+
field.on('click', '[data-name="add-layout"]', function(e){
|
56 |
+
|
57 |
+
$('body').find('.acf-fc-popup').addClass('acfe-fc-popup-grey');
|
58 |
+
|
59 |
+
});
|
60 |
+
|
61 |
+
},
|
62 |
+
|
63 |
+
filesButton: function(field){
|
64 |
+
|
65 |
+
field.$('> .acf-input > .acf-repeater > .acf-actions > .acf-button').removeClass('button-primary');
|
66 |
+
|
67 |
+
},
|
68 |
+
|
69 |
+
mapFields: function(field){
|
70 |
+
|
71 |
+
var $layout = field.$el.closest('.layout');
|
72 |
+
var $message = $layout.find('> .acf-fields > .acf-field[data-name="' + field.get('name') + '_message"] > .acf-input');
|
73 |
+
|
74 |
+
var selected = field.$input().find('option:selected').text();
|
75 |
+
|
76 |
+
if(selected.length){
|
77 |
+
$message.html(selected);
|
78 |
+
}
|
79 |
+
|
80 |
+
field.$input().on('change', function(){
|
81 |
+
|
82 |
+
// Message
|
83 |
+
var text = $(this).find('option:selected').text();
|
84 |
+
|
85 |
+
$message.html(text);
|
86 |
+
|
87 |
+
});
|
88 |
+
|
89 |
+
},
|
90 |
+
|
91 |
+
select2Args: function(options, $select, fieldData, field, instance){
|
92 |
+
|
93 |
+
if(field.get('acfeAllowCustom')){
|
94 |
+
|
95 |
+
options.templateSelection = function(state){
|
96 |
+
|
97 |
+
if(!state.id){
|
98 |
+
return state.text;
|
99 |
+
}
|
100 |
+
|
101 |
+
var text = state.text;
|
102 |
+
|
103 |
+
var match_field = /{field:(.*)}/g;
|
104 |
+
var match_fields = /{fields}/g;
|
105 |
+
var match_get_field = /{get_field:(.*)}/g;
|
106 |
+
var match_query_var = /{query_var:(.*)}/g;
|
107 |
+
var match_request = /{request:(.*)}/g;
|
108 |
+
var match_current = /{current:(.*)}/g;
|
109 |
+
var match_form = /{(form|form:.*?)}/g;
|
110 |
+
var match_action = /{action:(.*)}/g;
|
111 |
+
|
112 |
+
text = text.replace(match_field, "<code style='font-size:12px;padding:3px;vertical-align: 1px;line-height: 12px;'>{field:$1}</code>");
|
113 |
+
text = text.replace(match_fields, "<code style='font-size:12px;padding:3px;vertical-align: 1px;line-height: 12px;'>{fields}</code>");
|
114 |
+
text = text.replace(match_current, "<code style='font-size:12px;padding:3px;vertical-align: 1px;line-height: 12px;'>{current:$1}</code>");
|
115 |
+
text = text.replace(match_form, "<code style='font-size:12px;padding:3px;vertical-align: 1px;line-height: 12px;'>{$1}</code>");
|
116 |
+
text = text.replace(match_action, "<code style='font-size:12px;padding:3px;vertical-align: 1px;line-height: 12px;'>{action:$1}</code>");
|
117 |
+
text = text.replace(match_get_field, "<code style='font-size:12px;padding:3px;vertical-align: 1px;line-height: 12px;'>{get_field:$1}</code>");
|
118 |
+
text = text.replace(match_query_var, "<code style='font-size:12px;padding:3px;vertical-align: 1px;line-height: 12px;'>{query_var:$1}</code>");
|
119 |
+
text = text.replace(match_request, "<code style='font-size:12px;padding:3px;vertical-align: 1px;line-height: 12px;'>{request:$1}</code>");
|
120 |
+
|
121 |
+
|
122 |
+
return text;
|
123 |
+
|
124 |
+
};
|
125 |
+
|
126 |
+
options.templateResult = function(state){
|
127 |
+
|
128 |
+
if(!state.id){
|
129 |
+
return state.text;
|
130 |
+
}
|
131 |
+
|
132 |
+
var text = state.text;
|
133 |
+
|
134 |
+
var match_field = /{field:(.*?)}/g;
|
135 |
+
var match_fields = /{fields}/g;
|
136 |
+
var match_get_field = /{get_field:(.*?)}/g;
|
137 |
+
var match_query_var = /{query_var:(.*?)}/g;
|
138 |
+
var match_request = /{request:(.*?)}/g;
|
139 |
+
var match_current = /{current:(.*?)}/g;
|
140 |
+
var match_form = /{(form|form:.*?)}/g;
|
141 |
+
var match_action = /{action:(.*?)}/g;
|
142 |
+
|
143 |
+
text = text.replace(match_field, "<code style='font-size:12px;'>{field:$1}</code>");
|
144 |
+
text = text.replace(match_fields, "<code style='font-size:12px;'>{fields}</code>");
|
145 |
+
text = text.replace(match_get_field, "<code style='font-size:12px;'>{get_field:$1}</code>");
|
146 |
+
text = text.replace(match_query_var, "<code style='font-size:12px;'>{query_var:$1}</code>");
|
147 |
+
text = text.replace(match_request, "<code style='font-size:12px;'>{request:$1}</code>");
|
148 |
+
text = text.replace(match_current, "<code style='font-size:12px;'>{current:$1}</code>");
|
149 |
+
text = text.replace(match_form, "<code style='font-size:12px;'>{$1}</code>");
|
150 |
+
text = text.replace(match_action, "<code style='font-size:12px;'>{action:$1}</code>");
|
151 |
+
|
152 |
+
return text;
|
153 |
+
|
154 |
+
};
|
155 |
+
|
156 |
+
}
|
157 |
+
|
158 |
+
return options;
|
159 |
+
|
160 |
+
}
|
161 |
+
|
162 |
+
});
|
163 |
+
|
164 |
+
/*
|
165 |
+
* Dev Mode
|
166 |
+
*/
|
167 |
+
new acf.Model({
|
168 |
+
|
169 |
+
wait: 'prepare',
|
170 |
+
|
171 |
+
events: {
|
172 |
+
'click .acfe_delete_meta': 'onClickSingle',
|
173 |
+
'click #acfe_bulk_delete_meta_submit': 'onSubmitBulk',
|
174 |
+
'click.postboxes .hide-postbox-tog': 'onClickPostbox',
|
175 |
+
},
|
176 |
+
|
177 |
+
$acfWrap: function(){
|
178 |
+
return $('#acfe-acf-custom-fields');
|
179 |
+
},
|
180 |
+
|
181 |
+
$wpWrap: function(){
|
182 |
+
return $('#acfe-wp-custom-fields');
|
183 |
+
},
|
184 |
+
|
185 |
+
acfCount: function(){
|
186 |
+
return $('#acfe-acf-custom-fields tbody tr').length;
|
187 |
+
},
|
188 |
+
|
189 |
+
wpCount: function(){
|
190 |
+
return $('#acfe-wp-custom-fields tbody tr').length;
|
191 |
+
},
|
192 |
+
|
193 |
+
$bulkActions: function(){
|
194 |
+
return $('.acfe_dev_bulk_actions');
|
195 |
+
},
|
196 |
+
|
197 |
+
initialize: function(){
|
198 |
+
|
199 |
+
var $acfWrap = this.$acfWrap();
|
200 |
+
var $wpWrap = this.$wpWrap();
|
201 |
+
var $bulkActions = this.$bulkActions();
|
202 |
+
|
203 |
+
// Move Bulk Button
|
204 |
+
$acfWrap.find('.tablenav.bottom').insertAfter($acfWrap);
|
205 |
+
$wpWrap.find('.tablenav.bottom').insertAfter($wpWrap);
|
206 |
+
|
207 |
+
if(!$acfWrap.is(':visible') && !$wpWrap.is(':visible')){
|
208 |
+
|
209 |
+
$bulkActions.hide();
|
210 |
+
|
211 |
+
}
|
212 |
+
|
213 |
+
},
|
214 |
+
|
215 |
+
sync: function(){
|
216 |
+
|
217 |
+
var self = this;
|
218 |
+
|
219 |
+
setTimeout(function(){
|
220 |
+
|
221 |
+
var acfCount = self.acfCount();
|
222 |
+
var wpCount = self.wpCount();
|
223 |
+
|
224 |
+
var $acfWrap = self.$acfWrap();
|
225 |
+
var $wpWrap = self.$wpWrap();
|
226 |
+
|
227 |
+
var $bulkActions = self.$bulkActions();
|
228 |
+
|
229 |
+
$acfWrap.find('.acfe_dev_meta_count').text(acfCount);
|
230 |
+
$wpWrap.find('.acfe_dev_meta_count').text(wpCount);
|
231 |
+
|
232 |
+
if(!acfCount){
|
233 |
+
$acfWrap.remove();
|
234 |
+
}
|
235 |
+
|
236 |
+
if(!wpCount){
|
237 |
+
$wpWrap.remove();
|
238 |
+
}
|
239 |
+
|
240 |
+
if(!acfCount && !wpCount){
|
241 |
+
$bulkActions.remove();
|
242 |
+
}
|
243 |
+
|
244 |
+
}, 351);
|
245 |
+
|
246 |
+
},
|
247 |
+
|
248 |
+
onClickSingle: function(e, $el){
|
249 |
+
|
250 |
+
e.preventDefault();
|
251 |
+
|
252 |
+
var self = this;
|
253 |
+
var $tr = $el.closest('tr');
|
254 |
+
|
255 |
+
$.ajax({
|
256 |
+
url: acf.get('ajaxurl'),
|
257 |
+
type: 'post',
|
258 |
+
data: {
|
259 |
+
action: 'acfe/delete_meta',
|
260 |
+
id: $el.attr('data-meta-id'),
|
261 |
+
key: $el.attr('data-meta-key'),
|
262 |
+
type: $el.attr('data-type'),
|
263 |
+
_wpnonce: $el.attr('data-nonce'),
|
264 |
+
},
|
265 |
+
beforeSend: function(){
|
266 |
+
|
267 |
+
$tr.css({backgroundColor:'#faafaa'}).fadeOut(350, function(){
|
268 |
+
$tr.remove();
|
269 |
+
});
|
270 |
+
|
271 |
+
self.sync();
|
272 |
+
|
273 |
+
},
|
274 |
+
success: function(response){
|
275 |
+
|
276 |
+
if(response !== '1'){
|
277 |
+
$tr.css({backgroundColor:''});
|
278 |
+
$tr.show();
|
279 |
+
}
|
280 |
+
|
281 |
+
}
|
282 |
+
});
|
283 |
+
|
284 |
+
},
|
285 |
+
|
286 |
+
onSubmitBulk: function(e, $el){
|
287 |
+
|
288 |
+
e.preventDefault();
|
289 |
+
|
290 |
+
var self = this;
|
291 |
+
var action = $el.prevAll('.acfe_bulk_delete_meta_action').val();
|
292 |
+
var type = $el.prevAll('.acfe_bulk_delete_meta_type').val();
|
293 |
+
var nonce = $el.prevAll('.acfe_bulk_delete_meta_nonce').val();
|
294 |
+
|
295 |
+
if(action === 'delete'){
|
296 |
+
|
297 |
+
var ids = [];
|
298 |
+
var trs = [];
|
299 |
+
|
300 |
+
$('input.acfe_bulk_delete_meta:checked').each(function(){
|
301 |
+
ids.push($(this).val());
|
302 |
+
trs.push($(this).closest('tr'));
|
303 |
+
});
|
304 |
+
|
305 |
+
if(ids.length){
|
306 |
+
|
307 |
+
$.ajax({
|
308 |
+
url: acf.get('ajaxurl'),
|
309 |
+
type: 'post',
|
310 |
+
data: {
|
311 |
+
action: 'acfe/bulk_delete_meta',
|
312 |
+
ids: ids,
|
313 |
+
type: type,
|
314 |
+
_wpnonce: nonce,
|
315 |
+
},
|
316 |
+
beforeSend: function(){
|
317 |
+
|
318 |
+
trs.map(function(tr){
|
319 |
+
$(tr).css({backgroundColor:'#faafaa'}).fadeOut(350, function(){
|
320 |
+
$(tr).remove();
|
321 |
+
});
|
322 |
+
});
|
323 |
+
|
324 |
+
self.sync();
|
325 |
+
|
326 |
+
}
|
327 |
+
});
|
328 |
+
|
329 |
+
}
|
330 |
+
|
331 |
+
}
|
332 |
+
|
333 |
+
},
|
334 |
+
|
335 |
+
onClickPostbox: function(e, $el){
|
336 |
+
|
337 |
+
var val = $el.val();
|
338 |
+
|
339 |
+
var $acfWrap = this.$acfWrap();
|
340 |
+
var $wpWrap = this.$wpWrap();
|
341 |
+
var $bulkActions = this.$bulkActions();
|
342 |
+
|
343 |
+
if(!acfe.inArray(val, ['acfe-wp-custom-fields', 'acfe-acf-custom-fields']))
|
344 |
+
return;
|
345 |
+
|
346 |
+
if($el.prop('checked')){
|
347 |
+
|
348 |
+
if(!$bulkActions.is(':visible'))
|
349 |
+
$bulkActions.show();
|
350 |
+
|
351 |
+
}else if((val === 'acfe-wp-custom-fields' && !$acfWrap.is(':visible')) || (val === 'acfe-acf-custom-fields' && !$wpWrap.is(':visible'))){
|
352 |
+
|
353 |
+
$bulkActions.hide();
|
354 |
+
|
355 |
+
}
|
356 |
+
|
357 |
+
}
|
358 |
+
|
359 |
+
});
|
360 |
+
|
361 |
+
/*
|
362 |
+
* Module: Author
|
363 |
+
*/
|
364 |
+
new acf.Model({
|
365 |
+
|
366 |
+
actions: {
|
367 |
+
'new_field/name=acfe_author': 'newField',
|
368 |
+
},
|
369 |
+
|
370 |
+
newField: function(field){
|
371 |
+
|
372 |
+
field.on('change', function(e){
|
373 |
+
e.stopPropagation();
|
374 |
+
});
|
375 |
+
|
376 |
+
}
|
377 |
+
|
378 |
+
});
|
379 |
+
|
380 |
+
/*
|
381 |
+
* Postbox: ACFE Class
|
382 |
+
*/
|
383 |
+
acf.addAction('show_postbox', function(postbox){
|
384 |
+
postbox.$el.removeClass('acfe-postbox-left acfe-postbox-top');
|
385 |
+
});
|
386 |
+
|
387 |
+
/*
|
388 |
+
* Field: Enable Switch
|
389 |
+
*/
|
390 |
+
new acf.Model({
|
391 |
+
|
392 |
+
actions: {
|
393 |
+
'new_field': 'newField',
|
394 |
+
},
|
395 |
+
|
396 |
+
isRepeater: function(field){
|
397 |
+
return field.get('type') === 'repeater' || field.get('type') === 'flexible_content';
|
398 |
+
},
|
399 |
+
|
400 |
+
getCondition: function(target){
|
401 |
+
return this.isRepeater(target) ? target.val() === 0 : !target.val().length;
|
402 |
+
},
|
403 |
+
|
404 |
+
enableSwitcher: function(field){
|
405 |
+
|
406 |
+
var self = this;
|
407 |
+
var switcher, target;
|
408 |
+
|
409 |
+
if(field.get('switched')){
|
410 |
+
|
411 |
+
switcher = acf.getField(field.$el.prev());
|
412 |
+
target = field;
|
413 |
+
|
414 |
+
}else if(field.get('switcher')){
|
415 |
+
|
416 |
+
switcher = field;
|
417 |
+
target = acf.getField(field.$el.next());
|
418 |
+
|
419 |
+
}
|
420 |
+
|
421 |
+
if(self.getCondition(target)){
|
422 |
+
|
423 |
+
switcher.switchOff();
|
424 |
+
switcher.show('switcher');
|
425 |
+
target.hide('switcher');
|
426 |
+
|
427 |
+
}else{
|
428 |
+
|
429 |
+
switcher.hide('switcher');
|
430 |
+
target.show('switcher');
|
431 |
+
|
432 |
+
}
|
433 |
+
|
434 |
+
if(field.get('switcher')){
|
435 |
+
|
436 |
+
// Switch Action
|
437 |
+
switcher.on('change', function(){
|
438 |
+
|
439 |
+
if(switcher.$input().prop('checked')){
|
440 |
+
|
441 |
+
switcher.hide('switcher');
|
442 |
+
|
443 |
+
target.show('switcher');
|
444 |
+
|
445 |
+
if(self.isRepeater(target)){
|
446 |
+
target.add();
|
447 |
+
}
|
448 |
+
|
449 |
+
}
|
450 |
+
|
451 |
+
});
|
452 |
+
|
453 |
+
// Field Action
|
454 |
+
target.on('change', function(e, $el){
|
455 |
+
|
456 |
+
if(self.getCondition(target)){
|
457 |
+
|
458 |
+
switcher.switchOff();
|
459 |
+
switcher.show('switcher');
|
460 |
+
target.hide('switcher');
|
461 |
+
|
462 |
+
}
|
463 |
+
|
464 |
+
});
|
465 |
+
|
466 |
+
}
|
467 |
+
|
468 |
+
},
|
469 |
+
|
470 |
+
enableSwitch: function(field){
|
471 |
+
|
472 |
+
// Clone
|
473 |
+
var $row = field.$el.clone();
|
474 |
+
|
475 |
+
// Params
|
476 |
+
$row.removeAttr('data-enable-switch');
|
477 |
+
$row.attr('data-switcher', true);
|
478 |
+
$row.attr('data-name', field.get('name') + '_acfe_switch');
|
479 |
+
$row.attr('data-key', field.get('name') + '_acfe_switch');
|
480 |
+
$row.attr('data-type', 'true_false');
|
481 |
+
|
482 |
+
// HTML
|
483 |
+
$row.find('>.acf-input').html('<div class="acf-true-false">\n' +
|
484 |
+
'<input type="hidden" value="0">' +
|
485 |
+
'<label>\n' +
|
486 |
+
'<input type="checkbox" value="1" class="acf-switch-input" autocomplete="off">\n' +
|
487 |
+
'<div class="acf-switch"><span class="acf-switch-on" style="min-width: 18px;">' + acf.__('Yes') + '</span>' +
|
488 |
+
'<span class="acf-switch-off" style="min-width: 18px;">' + acf.__('No') + '</span><div class="acf-switch-slider"></div></div>' +
|
489 |
+
'</label>\n' +
|
490 |
+
'</div>');
|
491 |
+
|
492 |
+
// Insert
|
493 |
+
$row = $row.insertBefore(field.$el);
|
494 |
+
|
495 |
+
// New Switch
|
496 |
+
acf.getField($row);
|
497 |
+
|
498 |
+
// Remove Attribute
|
499 |
+
field.$el.removeAttr('data-enable-switch');
|
500 |
+
field.set('enableSwitch', false);
|
501 |
+
|
502 |
+
field.$el.attr('data-switched', true);
|
503 |
+
field.set('switched', true);
|
504 |
+
|
505 |
+
},
|
506 |
+
|
507 |
+
newField: function(field){
|
508 |
+
|
509 |
+
if(field.get('enableSwitch')){
|
510 |
+
|
511 |
+
this.enableSwitch(field);
|
512 |
+
|
513 |
+
}
|
514 |
+
|
515 |
+
else if(field.get('switched') || field.get('switcher')){
|
516 |
+
|
517 |
+
this.enableSwitcher(field);
|
518 |
+
|
519 |
+
}
|
520 |
+
|
521 |
+
}
|
522 |
+
|
523 |
+
});
|
524 |
+
|
525 |
})(jQuery);
|
@@ -1,418 +1,330 @@
|
|
1 |
-
(function($){
|
2 |
-
|
3 |
-
if(typeof acf === 'undefined')
|
4 |
-
return;
|
5 |
-
|
6 |
-
/*
|
7 |
-
* Field: Code Editor
|
8 |
-
*/
|
9 |
-
new acf.Model({
|
10 |
-
|
11 |
-
actions: {
|
12 |
-
'append_field_object': 'appendCodeEditor'
|
13 |
-
},
|
14 |
-
|
15 |
-
// Fix duplicate Code Editor
|
16 |
-
appendCodeEditor: function(field){
|
17 |
-
|
18 |
-
if(field.get('type') !== 'acfe_code_editor')
|
19 |
-
return;
|
20 |
-
|
21 |
-
field.$setting('default_value').find('> .acf-input > .acf-input-wrap > .CodeMirror:last').remove();
|
22 |
-
field.$setting('placeholder').find('> .acf-input > .acf-input-wrap > .CodeMirror:last').remove();
|
23 |
-
|
24 |
-
},
|
25 |
-
|
26 |
-
});
|
27 |
-
|
28 |
-
/*
|
29 |
-
* Field: Column
|
30 |
-
*/
|
31 |
-
new acf.Model({
|
32 |
-
|
33 |
-
actions: {
|
34 |
-
'change_field_label/type=acfe_column': 'renderTitle',
|
35 |
-
'change_field_type/type=acfe_column': 'renderTitle',
|
36 |
-
'render_field_settings/type=acfe_column': 'renderField',
|
37 |
-
},
|
38 |
-
|
39 |
-
renderTitle: function($el){
|
40 |
-
|
41 |
-
var field = acf.getInstance($el);
|
42 |
-
|
43 |
-
var $columns = field.$setting('columns');
|
44 |
-
var columns = acf.getInstance($columns).getValue();
|
45 |
-
|
46 |
-
var $endpoint = field.$setting('endpoint');
|
47 |
-
var endpoint = acf.getInstance($endpoint).getValue();
|
48 |
-
|
49 |
-
if(endpoint){
|
50 |
-
|
51 |
-
field.set('label', '(Column endpoint)');
|
52 |
-
|
53 |
-
}else{
|
54 |
-
|
55 |
-
field.set('label', '(Column ' + columns + ')');
|
56 |
-
|
57 |
-
}
|
58 |
-
|
59 |
-
},
|
60 |
-
|
61 |
-
renderField: function($el){
|
62 |
-
|
63 |
-
var field = acf.getFieldObject($el);
|
64 |
-
|
65 |
-
var setLabel = function(){
|
66 |
-
field.set('label', true);
|
67 |
-
}
|
68 |
-
|
69 |
-
field.on('change', '.acfe-field-columns', setLabel);
|
70 |
-
field.on('change', '.acfe-field-columns-endpoint', setLabel);
|
71 |
-
|
72 |
-
}
|
73 |
-
|
74 |
-
});
|
75 |
-
|
76 |
-
/*
|
77 |
-
* Field: Taxonomy Terms
|
78 |
-
*/
|
79 |
-
new acf.Model({
|
80 |
-
|
81 |
-
filters: {
|
82 |
-
'select2_ajax_data/action=acfe/fields/taxonomy_terms/allow_query': 'taxonomyTermsAjax',
|
83 |
-
},
|
84 |
-
|
85 |
-
taxonomyTermsAjax: function(ajaxData, data, $el, field, select){
|
86 |
-
|
87 |
-
// Taxonomies
|
88 |
-
var $taxonomies = $el.closest('.acf-field-settings').find('> .acf-field-setting-taxonomy > .acf-input > select > option:selected');
|
89 |
-
|
90 |
-
var tax = [];
|
91 |
-
|
92 |
-
$taxonomies.each(function(){
|
93 |
-
tax.push($(this).val());
|
94 |
-
});
|
95 |
-
|
96 |
-
ajaxData.taxonomies = tax;
|
97 |
-
|
98 |
-
// Terms level
|
99 |
-
var $level = $el.closest('.acf-field-settings').find('> .acf-field-setting-allow_terms > .acf-input input[type="number"]');
|
100 |
-
|
101 |
-
ajaxData.level = $level.val();
|
102 |
-
|
103 |
-
return ajaxData;
|
104 |
-
|
105 |
-
}
|
106 |
-
|
107 |
-
});
|
108 |
-
|
109 |
-
/*
|
110 |
-
* Field: Data
|
111 |
-
*/
|
112 |
-
new acf.Model({
|
113 |
-
|
114 |
-
wait: 'prepare',
|
115 |
-
|
116 |
-
events: {
|
117 |
-
'click .acfe_modal_open': 'onClickOpen'
|
118 |
-
},
|
119 |
-
|
120 |
-
onClickOpen: function(e, $el){
|
121 |
-
|
122 |
-
new acfe.Popup($('.acfe-modal[data-modal-key=' + $el.attr('data-modal-key') + ']'), {
|
123 |
-
title: 'Data',
|
124 |
-
size: 'medium',
|
125 |
-
footer: acf.__('Close')
|
126 |
-
});
|
127 |
-
|
128 |
-
},
|
129 |
-
|
130 |
-
initialize: function(){
|
131 |
-
|
132 |
-
$('.button.edit-field').each(function(){
|
133 |
-
|
134 |
-
var tbody = $(this).closest('tbody');
|
135 |
-
$(tbody).find('.acfe_modal_open:first').insertAfter($(this));
|
136 |
-
$(tbody).find('.acfe-modal:first').appendTo($('body'));
|
137 |
-
$(tbody).find('tr.acf-field-setting-acfe_field_data:first').remove();
|
138 |
-
|
139 |
-
});
|
140 |
-
|
141 |
-
}
|
142 |
-
|
143 |
-
});
|
144 |
-
|
145 |
-
/*
|
146 |
-
* Field Attribute: Before/After
|
147 |
-
*/
|
148 |
-
new acf.Model({
|
149 |
-
|
150 |
-
actions: {
|
151 |
-
'new_field' : 'onNewField'
|
152 |
-
},
|
153 |
-
|
154 |
-
onNewField: function(field){
|
155 |
-
|
156 |
-
if(field.get('type') === 'tab')
|
157 |
-
return;
|
158 |
-
|
159 |
-
var $sibling;
|
160 |
-
|
161 |
-
if(field.has('before')){
|
162 |
-
|
163 |
-
// vars
|
164 |
-
$sibling = field.$el.siblings('[data-name="' + field.get('before') + '"]').first();
|
165 |
-
|
166 |
-
if($sibling.length)
|
167 |
-
$sibling.before(field.$el);
|
168 |
-
|
169 |
-
}else if(field.has('after')){
|
170 |
-
|
171 |
-
// vars
|
172 |
-
$sibling = field.$el.siblings('[data-name="' + field.get('after') + '"]').first();
|
173 |
-
|
174 |
-
if($sibling.length)
|
175 |
-
$sibling.after(field.$el);
|
176 |
-
|
177 |
-
}
|
178 |
-
|
179 |
-
}
|
180 |
-
});
|
181 |
-
|
182 |
-
/*
|
183 |
-
* Tab Attribute: Before/After
|
184 |
-
*/
|
185 |
-
var Tab = acf.models.TabField;
|
186 |
-
|
187 |
-
acf.models.TabField = Tab.extend({
|
188 |
-
|
189 |
-
initialize: function(){
|
190 |
-
|
191 |
-
if(this.has('before')){
|
192 |
-
|
193 |
-
// vars
|
194 |
-
$sibling = this.$el.siblings('[data-name="' + this.get('before') + '"]').first();
|
195 |
-
|
196 |
-
if($sibling.length)
|
197 |
-
$sibling.before(this.$el);
|
198 |
-
|
199 |
-
}else if(this.has('after')){
|
200 |
-
|
201 |
-
// vars
|
202 |
-
$sibling = this.$el.siblings('[data-name="' + this.get('after') + '"]').first();
|
203 |
-
|
204 |
-
if($sibling.length)
|
205 |
-
$sibling.after(this.$el);
|
206 |
-
|
207 |
-
}
|
208 |
-
|
209 |
-
// Setup
|
210 |
-
Tab.prototype.initialize.apply(this, arguments);
|
211 |
-
|
212 |
-
}
|
213 |
-
|
214 |
-
});
|
215 |
-
|
216 |
-
/*
|
217 |
-
* Field Group: Locations - Date/Time Picker
|
218 |
-
*/
|
219 |
-
new acf.Model({
|
220 |
-
|
221 |
-
wait: 'ready',
|
222 |
-
|
223 |
-
actions:{
|
224 |
-
'append': 'onAppend',
|
225 |
-
'acfe/field_group/rule_refresh': 'refreshFields'
|
226 |
-
},
|
227 |
-
|
228 |
-
initialize: function(){
|
229 |
-
this.$el = $('#acf-field-group-locations');
|
230 |
-
},
|
231 |
-
|
232 |
-
onAppend: function($el){
|
233 |
-
|
234 |
-
if(!$el.is('.rule-group') && !$el.parent().parent().parent().is('.rule-group'))
|
235 |
-
return;
|
236 |
-
|
237 |
-
this.refreshFields();
|
238 |
-
|
239 |
-
},
|
240 |
-
|
241 |
-
refreshFields: function(){
|
242 |
-
|
243 |
-
var fields = acf.getFields({
|
244 |
-
parent: this.$('td.value')
|
245 |
-
});
|
246 |
-
|
247 |
-
fields.map(function(field){
|
248 |
-
|
249 |
-
if(!acfe.inArray(field.get('type'), ['date_picker', 'date_time_picker', 'time_picker']))
|
250 |
-
return;
|
251 |
-
|
252 |
-
field.$inputText().removeClass('hasDatepicker').removeAttr('id');
|
253 |
-
|
254 |
-
field.initialize();
|
255 |
-
|
256 |
-
});
|
257 |
-
|
258 |
-
}
|
259 |
-
|
260 |
-
});
|
261 |
-
|
262 |
-
/*
|
263 |
-
* Field Group: Meta
|
264 |
-
*/
|
265 |
-
new acf.Model({
|
266 |
-
|
267 |
-
actions: {
|
268 |
-
'new_field/name=acfe_meta': 'renderClass',
|
269 |
-
'new_field/name=acfe_settings': 'renderClass',
|
270 |
-
'new_field/name=acfe_validate': 'renderClass',
|
271 |
-
},
|
272 |
-
|
273 |
-
renderClass: function(field){
|
274 |
-
|
275 |
-
field.$('.acf-button').removeClass('button-primary');
|
276 |
-
|
277 |
-
}
|
278 |
-
|
279 |
-
});
|
280 |
-
|
281 |
-
/*
|
282 |
-
* Field Group
|
283 |
-
*/
|
284 |
-
new acf.Model({
|
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 |
-
field.
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
},
|
332 |
-
|
333 |
-
meta: function(field){
|
334 |
-
|
335 |
-
var $tab = this.getTab(field, 'advanced');
|
336 |
-
var tabTitle = $tab.text();
|
337 |
-
|
338 |
-
var val = field.val();
|
339 |
-
$tab.html(tabTitle + (val ? ' <span class="acfe-tab-badge">' + val + '</span>' : ''));
|
340 |
-
|
341 |
-
field.on('change', function(){
|
342 |
-
|
343 |
-
var val = field.val();
|
344 |
-
$tab.html(tabTitle + (val ? ' <span class="acfe-tab-badge">' + val + '</span>' : ''));
|
345 |
-
|
346 |
-
});
|
347 |
-
|
348 |
-
},
|
349 |
-
|
350 |
-
note: function(field){
|
351 |
-
|
352 |
-
var $tab = this.getTab(field, 'note');
|
353 |
-
var tabTitle = $tab.text();
|
354 |
-
|
355 |
-
var val = field.val();
|
356 |
-
$tab.html(tabTitle + (val.length ? ' <span class="acfe-tab-badge">1</span>' : ''));
|
357 |
-
|
358 |
-
field.on('change', function(){
|
359 |
-
|
360 |
-
var val = field.val();
|
361 |
-
$tab.html(tabTitle + (val.length ? ' <span class="acfe-tab-badge">1</span>' : ''));
|
362 |
-
|
363 |
-
});
|
364 |
-
|
365 |
-
},
|
366 |
-
|
367 |
-
});
|
368 |
-
|
369 |
-
/*
|
370 |
-
* Field Group Custom Slug
|
371 |
-
*/
|
372 |
-
new acf.Model({
|
373 |
-
|
374 |
-
events: {
|
375 |
-
'keyup #post_name': 'onInput'
|
376 |
-
},
|
377 |
-
|
378 |
-
onInput: function(e, $el){
|
379 |
-
|
380 |
-
var val = $el.val();
|
381 |
-
|
382 |
-
if(!val.startsWith('group_')){
|
383 |
-
|
384 |
-
val = 'group_' + val;
|
385 |
-
$el.val(val);
|
386 |
-
|
387 |
-
}
|
388 |
-
|
389 |
-
$('[name="acf_field_group[key]"]').val(val);
|
390 |
-
$('.misc-pub-acfe-field-group-key code').html(val);
|
391 |
-
|
392 |
-
},
|
393 |
-
|
394 |
-
});
|
395 |
-
|
396 |
-
/*
|
397 |
-
* Compatibility
|
398 |
-
*/
|
399 |
-
new acf.Model({
|
400 |
-
|
401 |
-
actions: {
|
402 |
-
'ready_field_object': 'flexibleContent'
|
403 |
-
},
|
404 |
-
|
405 |
-
// 0.8.4.5 Flexible Content: Fix duplicated "layout_settings" & "layout_title"
|
406 |
-
flexibleContent: function(field){
|
407 |
-
|
408 |
-
// field_acfe_layout_abc123456_settings + field_acfe_layout_abc123456_title
|
409 |
-
if(!field.get('key').startsWith('field_acfe_layout_'))
|
410 |
-
return;
|
411 |
-
|
412 |
-
field.delete();
|
413 |
-
|
414 |
-
},
|
415 |
-
|
416 |
-
});
|
417 |
-
|
418 |
})(jQuery);
|
1 |
+
(function($){
|
2 |
+
|
3 |
+
if(typeof acf === 'undefined')
|
4 |
+
return;
|
5 |
+
|
6 |
+
/*
|
7 |
+
* Field: Code Editor
|
8 |
+
*/
|
9 |
+
new acf.Model({
|
10 |
+
|
11 |
+
actions: {
|
12 |
+
'append_field_object': 'appendCodeEditor'
|
13 |
+
},
|
14 |
+
|
15 |
+
// Fix duplicate Code Editor
|
16 |
+
appendCodeEditor: function(field){
|
17 |
+
|
18 |
+
if(field.get('type') !== 'acfe_code_editor')
|
19 |
+
return;
|
20 |
+
|
21 |
+
field.$setting('default_value').find('> .acf-input > .acf-input-wrap > .CodeMirror:last').remove();
|
22 |
+
field.$setting('placeholder').find('> .acf-input > .acf-input-wrap > .CodeMirror:last').remove();
|
23 |
+
|
24 |
+
},
|
25 |
+
|
26 |
+
});
|
27 |
+
|
28 |
+
/*
|
29 |
+
* Field: Column
|
30 |
+
*/
|
31 |
+
new acf.Model({
|
32 |
+
|
33 |
+
actions: {
|
34 |
+
'change_field_label/type=acfe_column': 'renderTitle',
|
35 |
+
'change_field_type/type=acfe_column': 'renderTitle',
|
36 |
+
'render_field_settings/type=acfe_column': 'renderField',
|
37 |
+
},
|
38 |
+
|
39 |
+
renderTitle: function($el){
|
40 |
+
|
41 |
+
var field = acf.getInstance($el);
|
42 |
+
|
43 |
+
var $columns = field.$setting('columns');
|
44 |
+
var columns = acf.getInstance($columns).getValue();
|
45 |
+
|
46 |
+
var $endpoint = field.$setting('endpoint');
|
47 |
+
var endpoint = acf.getInstance($endpoint).getValue();
|
48 |
+
|
49 |
+
if(endpoint){
|
50 |
+
|
51 |
+
field.set('label', '(Column endpoint)');
|
52 |
+
|
53 |
+
}else{
|
54 |
+
|
55 |
+
field.set('label', '(Column ' + columns + ')');
|
56 |
+
|
57 |
+
}
|
58 |
+
|
59 |
+
},
|
60 |
+
|
61 |
+
renderField: function($el){
|
62 |
+
|
63 |
+
var field = acf.getFieldObject($el);
|
64 |
+
|
65 |
+
var setLabel = function(){
|
66 |
+
field.set('label', true);
|
67 |
+
}
|
68 |
+
|
69 |
+
field.on('change', '.acfe-field-columns', setLabel);
|
70 |
+
field.on('change', '.acfe-field-columns-endpoint', setLabel);
|
71 |
+
|
72 |
+
}
|
73 |
+
|
74 |
+
});
|
75 |
+
|
76 |
+
/*
|
77 |
+
* Field: Taxonomy Terms
|
78 |
+
*/
|
79 |
+
new acf.Model({
|
80 |
+
|
81 |
+
filters: {
|
82 |
+
'select2_ajax_data/action=acfe/fields/taxonomy_terms/allow_query': 'taxonomyTermsAjax',
|
83 |
+
},
|
84 |
+
|
85 |
+
taxonomyTermsAjax: function(ajaxData, data, $el, field, select){
|
86 |
+
|
87 |
+
// Taxonomies
|
88 |
+
var $taxonomies = $el.closest('.acf-field-settings').find('> .acf-field-setting-taxonomy > .acf-input > select > option:selected');
|
89 |
+
|
90 |
+
var tax = [];
|
91 |
+
|
92 |
+
$taxonomies.each(function(){
|
93 |
+
tax.push($(this).val());
|
94 |
+
});
|
95 |
+
|
96 |
+
ajaxData.taxonomies = tax;
|
97 |
+
|
98 |
+
// Terms level
|
99 |
+
var $level = $el.closest('.acf-field-settings').find('> .acf-field-setting-allow_terms > .acf-input input[type="number"]');
|
100 |
+
|
101 |
+
ajaxData.level = $level.val();
|
102 |
+
|
103 |
+
return ajaxData;
|
104 |
+
|
105 |
+
}
|
106 |
+
|
107 |
+
});
|
108 |
+
|
109 |
+
/*
|
110 |
+
* Field: Data
|
111 |
+
*/
|
112 |
+
new acf.Model({
|
113 |
+
|
114 |
+
wait: 'prepare',
|
115 |
+
|
116 |
+
events: {
|
117 |
+
'click .acfe_modal_open': 'onClickOpen'
|
118 |
+
},
|
119 |
+
|
120 |
+
onClickOpen: function(e, $el){
|
121 |
+
|
122 |
+
new acfe.Popup($('.acfe-modal[data-modal-key=' + $el.attr('data-modal-key') + ']'), {
|
123 |
+
title: 'Data',
|
124 |
+
size: 'medium',
|
125 |
+
footer: acf.__('Close')
|
126 |
+
});
|
127 |
+
|
128 |
+
},
|
129 |
+
|
130 |
+
initialize: function(){
|
131 |
+
|
132 |
+
$('.button.edit-field').each(function(){
|
133 |
+
|
134 |
+
var tbody = $(this).closest('tbody');
|
135 |
+
$(tbody).find('.acfe_modal_open:first').insertAfter($(this));
|
136 |
+
$(tbody).find('.acfe-modal:first').appendTo($('body'));
|
137 |
+
$(tbody).find('tr.acf-field-setting-acfe_field_data:first').remove();
|
138 |
+
|
139 |
+
});
|
140 |
+
|
141 |
+
}
|
142 |
+
|
143 |
+
});
|
144 |
+
|
145 |
+
/*
|
146 |
+
* Field Attribute: Before/After
|
147 |
+
*/
|
148 |
+
new acf.Model({
|
149 |
+
|
150 |
+
actions: {
|
151 |
+
'new_field' : 'onNewField'
|
152 |
+
},
|
153 |
+
|
154 |
+
onNewField: function(field){
|
155 |
+
|
156 |
+
if(field.get('type') === 'tab')
|
157 |
+
return;
|
158 |
+
|
159 |
+
var $sibling;
|
160 |
+
|
161 |
+
if(field.has('before')){
|
162 |
+
|
163 |
+
// vars
|
164 |
+
$sibling = field.$el.siblings('[data-name="' + field.get('before') + '"]').first();
|
165 |
+
|
166 |
+
if($sibling.length)
|
167 |
+
$sibling.before(field.$el);
|
168 |
+
|
169 |
+
}else if(field.has('after')){
|
170 |
+
|
171 |
+
// vars
|
172 |
+
$sibling = field.$el.siblings('[data-name="' + field.get('after') + '"]').first();
|
173 |
+
|
174 |
+
if($sibling.length)
|
175 |
+
$sibling.after(field.$el);
|
176 |
+
|
177 |
+
}
|
178 |
+
|
179 |
+
}
|
180 |
+
});
|
181 |
+
|
182 |
+
/*
|
183 |
+
* Tab Attribute: Before/After
|
184 |
+
*/
|
185 |
+
var Tab = acf.models.TabField;
|
186 |
+
|
187 |
+
acf.models.TabField = Tab.extend({
|
188 |
+
|
189 |
+
initialize: function(){
|
190 |
+
|
191 |
+
if(this.has('before')){
|
192 |
+
|
193 |
+
// vars
|
194 |
+
$sibling = this.$el.siblings('[data-name="' + this.get('before') + '"]').first();
|
195 |
+
|
196 |
+
if($sibling.length)
|
197 |
+
$sibling.before(this.$el);
|
198 |
+
|
199 |
+
}else if(this.has('after')){
|
200 |
+
|
201 |
+
// vars
|
202 |
+
$sibling = this.$el.siblings('[data-name="' + this.get('after') + '"]').first();
|
203 |
+
|
204 |
+
if($sibling.length)
|
205 |
+
$sibling.after(this.$el);
|
206 |
+
|
207 |
+
}
|
208 |
+
|
209 |
+
// Setup
|
210 |
+
Tab.prototype.initialize.apply(this, arguments);
|
211 |
+
|
212 |
+
}
|
213 |
+
|
214 |
+
});
|
215 |
+
|
216 |
+
/*
|
217 |
+
* Field Group: Locations - Date/Time Picker
|
218 |
+
*/
|
219 |
+
new acf.Model({
|
220 |
+
|
221 |
+
wait: 'ready',
|
222 |
+
|
223 |
+
actions:{
|
224 |
+
'append': 'onAppend',
|
225 |
+
'acfe/field_group/rule_refresh': 'refreshFields'
|
226 |
+
},
|
227 |
+
|
228 |
+
initialize: function(){
|
229 |
+
this.$el = $('#acf-field-group-locations');
|
230 |
+
},
|
231 |
+
|
232 |
+
onAppend: function($el){
|
233 |
+
|
234 |
+
if(!$el.is('.rule-group') && !$el.parent().parent().parent().is('.rule-group'))
|
235 |
+
return;
|
236 |
+
|
237 |
+
this.refreshFields();
|
238 |
+
|
239 |
+
},
|
240 |
+
|
241 |
+
refreshFields: function(){
|
242 |
+
|
243 |
+
var fields = acf.getFields({
|
244 |
+
parent: this.$('td.value')
|
245 |
+
});
|
246 |
+
|
247 |
+
fields.map(function(field){
|
248 |
+
|
249 |
+
if(!acfe.inArray(field.get('type'), ['date_picker', 'date_time_picker', 'time_picker']))
|
250 |
+
return;
|
251 |
+
|
252 |
+
field.$inputText().removeClass('hasDatepicker').removeAttr('id');
|
253 |
+
|
254 |
+
field.initialize();
|
255 |
+
|
256 |
+
});
|
257 |
+
|
258 |
+
}
|
259 |
+
|
260 |
+
});
|
261 |
+
|
262 |
+
/*
|
263 |
+
* Field Group: Meta
|
264 |
+
*/
|
265 |
+
new acf.Model({
|
266 |
+
|
267 |
+
actions: {
|
268 |
+
'new_field/name=acfe_meta': 'renderClass',
|
269 |
+
'new_field/name=acfe_settings': 'renderClass',
|
270 |
+
'new_field/name=acfe_validate': 'renderClass',
|
271 |
+
},
|
272 |
+
|
273 |
+
renderClass: function(field){
|
274 |
+
|
275 |
+
field.$('.acf-button').removeClass('button-primary');
|
276 |
+
|
277 |
+
}
|
278 |
+
|
279 |
+
});
|
280 |
+
|
281 |
+
/*
|
282 |
+
* Field Group Custom Slug
|
283 |
+
*/
|
284 |
+
new acf.Model({
|
285 |
+
|
286 |
+
events: {
|
287 |
+
'keyup #post_name': 'onInput'
|
288 |
+
},
|
289 |
+
|
290 |
+
onInput: function(e, $el){
|
291 |
+
|
292 |
+
var val = $el.val();
|
293 |
+
|
294 |
+
if(!val.startsWith('group_')){
|
295 |
+
|
296 |
+
val = 'group_' + val;
|
297 |
+
$el.val(val);
|
298 |
+
|
299 |
+
}
|
300 |
+
|
301 |
+
$('[name="acf_field_group[key]"]').val(val);
|
302 |
+
$('.misc-pub-acfe-field-group-key code').html(val);
|
303 |
+
|
304 |
+
},
|
305 |
+
|
306 |
+
});
|
307 |
+
|
308 |
+
/*
|
309 |
+
* Compatibility
|
310 |
+
*/
|
311 |
+
new acf.Model({
|
312 |
+
|
313 |
+
actions: {
|
314 |
+
'ready_field_object': 'flexibleContent'
|
315 |
+
},
|
316 |
+
|
317 |
+
// 0.8.4.5 Flexible Content: Fix duplicated "layout_settings" & "layout_title"
|
318 |
+
flexibleContent: function(field){
|
319 |
+
|
320 |
+
// field_acfe_layout_abc123456_settings + field_acfe_layout_abc123456_title
|
321 |
+
if(!field.get('key').startsWith('field_acfe_layout_'))
|
322 |
+
return;
|
323 |
+
|
324 |
+
field.delete();
|
325 |
+
|
326 |
+
},
|
327 |
+
|
328 |
+
});
|
329 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
330 |
})(jQuery);
|
@@ -1 +1 @@
|
|
1 |
-
!function(
|
1 |
+
!function(f){var e;"undefined"!=typeof acf&&(new acf.Model({actions:{append_field_object:"appendCodeEditor"},appendCodeEditor:function(e){"acfe_code_editor"===e.get("type")&&(e.$setting("default_value").find("> .acf-input > .acf-input-wrap > .CodeMirror:last").remove(),e.$setting("placeholder").find("> .acf-input > .acf-input-wrap > .CodeMirror:last").remove())}}),new acf.Model({actions:{"change_field_label/type=acfe_column":"renderTitle","change_field_type/type=acfe_column":"renderTitle","render_field_settings/type=acfe_column":"renderField"},renderTitle:function(e){var t=acf.getInstance(e),n=t.$setting("columns"),e=acf.getInstance(n).getValue(),n=t.$setting("endpoint");acf.getInstance(n).getValue()?t.set("label","(Column endpoint)"):t.set("label","(Column "+e+")")},renderField:function(e){var t=acf.getFieldObject(e),e=function(){t.set("label",!0)};t.on("change",".acfe-field-columns",e),t.on("change",".acfe-field-columns-endpoint",e)}}),new acf.Model({filters:{"select2_ajax_data/action=acfe/fields/taxonomy_terms/allow_query":"taxonomyTermsAjax"},taxonomyTermsAjax:function(e,t,n,a,i){var l=n.closest(".acf-field-settings").find("> .acf-field-setting-taxonomy > .acf-input > select > option:selected"),o=[];l.each(function(){o.push(f(this).val())}),e.taxonomies=o;n=n.closest(".acf-field-settings").find('> .acf-field-setting-allow_terms > .acf-input input[type="number"]');return e.level=n.val(),e}}),new acf.Model({wait:"prepare",events:{"click .acfe_modal_open":"onClickOpen"},onClickOpen:function(e,t){new acfe.Popup(f(".acfe-modal[data-modal-key="+t.attr("data-modal-key")+"]"),{title:"Data",size:"medium",footer:acf.__("Close")})},initialize:function(){f(".button.edit-field").each(function(){var e=f(this).closest("tbody");f(e).find(".acfe_modal_open:first").insertAfter(f(this)),f(e).find(".acfe-modal:first").appendTo(f("body")),f(e).find("tr.acf-field-setting-acfe_field_data:first").remove()})}}),new acf.Model({actions:{new_field:"onNewField"},onNewField:function(e){var t;"tab"!==e.get("type")&&(e.has("before")?(t=e.$el.siblings('[data-name="'+e.get("before")+'"]').first()).length&&t.before(e.$el):e.has("after")&&(t=e.$el.siblings('[data-name="'+e.get("after")+'"]').first()).length&&t.after(e.$el))}}),e=acf.models.TabField,acf.models.TabField=e.extend({initialize:function(){this.has("before")?($sibling=this.$el.siblings('[data-name="'+this.get("before")+'"]').first(),$sibling.length&&$sibling.before(this.$el)):this.has("after")&&($sibling=this.$el.siblings('[data-name="'+this.get("after")+'"]').first(),$sibling.length&&$sibling.after(this.$el)),e.prototype.initialize.apply(this,arguments)}}),new acf.Model({wait:"ready",actions:{append:"onAppend","acfe/field_group/rule_refresh":"refreshFields"},initialize:function(){this.$el=f("#acf-field-group-locations")},onAppend:function(e){(e.is(".rule-group")||e.parent().parent().parent().is(".rule-group"))&&this.refreshFields()},refreshFields:function(){acf.getFields({parent:this.$("td.value")}).map(function(e){acfe.inArray(e.get("type"),["date_picker","date_time_picker","time_picker"])&&(e.$inputText().removeClass("hasDatepicker").removeAttr("id"),e.initialize())})}}),new acf.Model({actions:{"new_field/name=acfe_meta":"renderClass","new_field/name=acfe_settings":"renderClass","new_field/name=acfe_validate":"renderClass"},renderClass:function(e){e.$(".acf-button").removeClass("button-primary")}}),new acf.Model({events:{"keyup #post_name":"onInput"},onInput:function(e,t){var n=t.val();n.startsWith("group_")||(n="group_"+n,t.val(n)),f('[name="acf_field_group[key]"]').val(n),f(".misc-pub-acfe-field-group-key code").html(n)}}),new acf.Model({actions:{ready_field_object:"flexibleContent"},flexibleContent:function(e){e.get("key").startsWith("field_acfe_layout_")&&e.delete()}}))}(jQuery);
|
@@ -1,3372 +1,3372 @@
|
|
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 |
-
* Drag & Drop
|
14 |
-
*/
|
15 |
-
model.addSortable = function(self){
|
16 |
-
|
17 |
-
// bail early if max 1 row
|
18 |
-
if(this.get('max') == 1){
|
19 |
-
return;
|
20 |
-
}
|
21 |
-
|
22 |
-
// add sortable
|
23 |
-
this.$layoutsWrap().sortable({
|
24 |
-
items: ' > .layout',
|
25 |
-
handle: '> .acf-fc-layout-handle',
|
26 |
-
forceHelperSize: false, // Changed to false
|
27 |
-
forcePlaceholderSize: true,
|
28 |
-
revert: 50,
|
29 |
-
tolerance: "pointer", // Changed to pointer
|
30 |
-
scroll: true,
|
31 |
-
stop: function(event, ui) {
|
32 |
-
self.render();
|
33 |
-
},
|
34 |
-
update: function(event, ui) {
|
35 |
-
self.$input().trigger('change');
|
36 |
-
}
|
37 |
-
});
|
38 |
-
|
39 |
-
};
|
40 |
-
|
41 |
-
/*
|
42 |
-
* Actions
|
43 |
-
*/
|
44 |
-
model.acfeOneClick = function(e, $el){
|
45 |
-
|
46 |
-
// Get Flexible
|
47 |
-
var flexible = this;
|
48 |
-
|
49 |
-
// Vars
|
50 |
-
var $clones = flexible.$clones();
|
51 |
-
var $layout_name = $($clones[0]).data('layout');
|
52 |
-
|
53 |
-
// Source
|
54 |
-
var $layout_source = null;
|
55 |
-
if($el.hasClass('acf-icon'))
|
56 |
-
$layout_source = $el.closest('.layout');
|
57 |
-
|
58 |
-
// Add
|
59 |
-
var $layout_added = flexible.add({
|
60 |
-
layout: $layout_name,
|
61 |
-
before: $layout_source
|
62 |
-
});
|
63 |
-
|
64 |
-
// Hide native tooltip
|
65 |
-
var acfPopup = $('.acf-fc-popup');
|
66 |
-
|
67 |
-
if(acfPopup.length){
|
68 |
-
acfPopup.hide();
|
69 |
-
}
|
70 |
-
|
71 |
-
|
72 |
-
};
|
73 |
-
|
74 |
-
model.acfeLayoutInit = function($layout){
|
75 |
-
|
76 |
-
// Get Flexible
|
77 |
-
var flexible = this;
|
78 |
-
|
79 |
-
// Vars
|
80 |
-
var $controls = $layout.find('> .acf-fc-layout-controls');
|
81 |
-
var $handle = $layout.find('> .acf-fc-layout-handle');
|
82 |
-
|
83 |
-
// Placeholder
|
84 |
-
var $placeholder = $layout.find('> .acfe-fc-placeholder');
|
85 |
-
|
86 |
-
// Placeholder: Show
|
87 |
-
$placeholder.removeClass('acf-hidden');
|
88 |
-
|
89 |
-
// If no modal edition & opened: Hide Placeholder
|
90 |
-
if(!flexible.has('acfeFlexibleModalEdition') && !flexible.isLayoutClosed($layout)){
|
91 |
-
|
92 |
-
$placeholder.addClass('acf-hidden');
|
93 |
-
|
94 |
-
}
|
95 |
-
|
96 |
-
// Flexible has Preview
|
97 |
-
if(flexible.isLayoutClosed($layout) && flexible.has('acfeFlexiblePreview') && !$placeholder.hasClass('-loading')){
|
98 |
-
|
99 |
-
$placeholder.addClass('acfe-fc-preview -loading').find('> .acfe-flexible-placeholder').prepend('<span class="spinner"></span>');
|
100 |
-
$placeholder.find('> .acfe-fc-overlay').addClass('-hover');
|
101 |
-
|
102 |
-
// vars
|
103 |
-
var $input = $layout.children('input');
|
104 |
-
var prefix = $input.attr('name').replace('[acf_fc_layout]', '');
|
105 |
-
|
106 |
-
// ajax data
|
107 |
-
var ajaxData = {
|
108 |
-
action: 'acfe/flexible/layout_preview',
|
109 |
-
field_key: flexible.get('key'),
|
110 |
-
i: $layout.index(),
|
111 |
-
layout: $layout.data('layout'),
|
112 |
-
value: acf.serialize($layout, prefix)
|
113 |
-
};
|
114 |
-
|
115 |
-
acf.doAction('acfe/fields/flexible_content/before_preview', flexible.$el, $layout, ajaxData);
|
116 |
-
acf.doAction('acfe/fields/flexible_content/before_preview/name=' + flexible.get('name'), flexible.$el, $layout, ajaxData);
|
117 |
-
acf.doAction('acfe/fields/flexible_content/before_preview/key=' + flexible.get('key'), flexible.$el, $layout, ajaxData);
|
118 |
-
acf.doAction('acfe/fields/flexible_content/before_preview/name=' + flexible.get('name') + '&layout=' + $layout.data('layout'), flexible.$el, $layout, ajaxData);
|
119 |
-
acf.doAction('acfe/fields/flexible_content/before_preview/key=' + flexible.get('key') + '&layout=' + $layout.data('layout'), flexible.$el, $layout, ajaxData);
|
120 |
-
|
121 |
-
// ajax
|
122 |
-
$.ajax({
|
123 |
-
url: acf.get('ajaxurl'),
|
124 |
-
data: acf.prepareForAjax(ajaxData),
|
125 |
-
dataType: 'html',
|
126 |
-
type: 'post',
|
127 |
-
success: function(response){
|
128 |
-
|
129 |
-
if(response){
|
130 |
-
|
131 |
-
$placeholder.find('> .acfe-flexible-placeholder').html(response);
|
132 |
-
|
133 |
-
}else{
|
134 |
-
|
135 |
-
$placeholder.removeClass('acfe-fc-preview');
|
136 |
-
|
137 |
-
}
|
138 |
-
|
139 |
-
acf.doAction('acfe/fields/flexible_content/preview', response, flexible.$el, $layout, ajaxData);
|
140 |
-
acf.doAction('acfe/fields/flexible_content/preview/name=' + flexible.get('name'), response, flexible.$el, $layout, ajaxData);
|
141 |
-
acf.doAction('acfe/fields/flexible_content/preview/key=' + flexible.get('key'), response, flexible.$el, $layout, ajaxData);
|
142 |
-
acf.doAction('acfe/fields/flexible_content/preview/name=' + flexible.get('name') + '&layout=' + $layout.data('layout'), response, flexible.$el, $layout, ajaxData);
|
143 |
-
acf.doAction('acfe/fields/flexible_content/preview/key=' + flexible.get('key') + '&layout=' + $layout.data('layout'), response, flexible.$el, $layout, ajaxData);
|
144 |
-
|
145 |
-
},
|
146 |
-
complete: function(){
|
147 |
-
|
148 |
-
$placeholder.find('> .acfe-fc-overlay').removeClass('-hover');
|
149 |
-
$placeholder.removeClass('-loading').find('> .acfe-flexible-placeholder > .spinner').remove();
|
150 |
-
|
151 |
-
}
|
152 |
-
});
|
153 |
-
|
154 |
-
}
|
155 |
-
|
156 |
-
};
|
157 |
-
|
158 |
-
/*
|
159 |
-
* WYSIWYG
|
160 |
-
*/
|
161 |
-
var wysiwyg = acf.getFieldType('wysiwyg').prototype;
|
162 |
-
wysiwyg.initialize = function(){
|
163 |
-
|
164 |
-
// initializeEditor if no delay
|
165 |
-
if( !this.has('id') && !this.$control().hasClass('delay') ) {
|
166 |
-
this.initializeEditor();
|
167 |
-
}
|
168 |
-
|
169 |
-
};
|
170 |
-
|
171 |
-
var acfeFlexibleDelayInit = function(editor){
|
172 |
-
|
173 |
-
if(editor.has('id') || !editor.$el.is(':visible') || acfe.isFilterEnabled('acfeForceOpen'))
|
174 |
-
return;
|
175 |
-
|
176 |
-
var $wrap = editor.$control();
|
177 |
-
|
178 |
-
if($wrap.hasClass('delay')){
|
179 |
-
|
180 |
-
$wrap.removeClass('delay');
|
181 |
-
$wrap.find('.acf-editor-toolbar').remove();
|
182 |
-
|
183 |
-
// initialize
|
184 |
-
editor.initializeEditor();
|
185 |
-
|
186 |
-
}
|
187 |
-
|
188 |
-
};
|
189 |
-
|
190 |
-
acf.addAction('show_field/type=wysiwyg', acfeFlexibleDelayInit);
|
191 |
-
acf.addAction('ready_field/type=wysiwyg', acfeFlexibleDelayInit);
|
192 |
-
|
193 |
-
/*
|
194 |
-
* Spawn
|
195 |
-
*/
|
196 |
-
acf.addAction('new_field/type=flexible_content', function(flexible){
|
197 |
-
|
198 |
-
// Vars
|
199 |
-
var $clones = flexible.$clones();
|
200 |
-
var $layouts = flexible.$layouts();
|
201 |
-
|
202 |
-
// Merge
|
203 |
-
var $all_layouts = $.merge($layouts, $clones);
|
204 |
-
|
205 |
-
// Do Actions
|
206 |
-
$layouts.each(function(){
|
207 |
-
|
208 |
-
var $layout = $(this);
|
209 |
-
var $name = $layout.data('layout');
|
210 |
-
|
211 |
-
acf.doAction('acfe/flexible/layouts', $layout, flexible);
|
212 |
-
acf.doAction('acfe/flexible/layout/name=' + $name, $layout, flexible);
|
213 |
-
|
214 |
-
});
|
215 |
-
|
216 |
-
// ACFE: 1 layout available - OneClick
|
217 |
-
if($clones.length === 1){
|
218 |
-
|
219 |
-
// Remove native ACF Tooltip action
|
220 |
-
flexible.removeEvents({'click [data-name="add-layout"]': 'onClickAdd'});
|
221 |
-
|
222 |
-
// Add ACF Extended Modal action
|
223 |
-
flexible.addEvents({'click [data-name="add-layout"]': 'acfeOneClick'});
|
224 |
-
|
225 |
-
}
|
226 |
-
|
227 |
-
flexible.addEvents({'click .acfe-fc-placeholder': 'onClickCollapse'});
|
228 |
-
|
229 |
-
flexible.addEvents({'click .acfe-flexible-opened-actions > a': 'onClickCollapse'});
|
230 |
-
|
231 |
-
// Flexible: Ajax
|
232 |
-
if(flexible.has('acfeFlexibleAjax')){
|
233 |
-
|
234 |
-
flexible.add = function(args){
|
235 |
-
|
236 |
-
// Get Flexible
|
237 |
-
var flexible = this;
|
238 |
-
|
239 |
-
// defaults
|
240 |
-
args = acf.parseArgs(args, {
|
241 |
-
layout: '',
|
242 |
-
before: false
|
243 |
-
});
|
244 |
-
|
245 |
-
// validate
|
246 |
-
if( !this.allowAdd() ) {
|
247 |
-
return false;
|
248 |
-
}
|
249 |
-
|
250 |
-
// ajax
|
251 |
-
$.ajax({
|
252 |
-
url: acf.get('ajaxurl'),
|
253 |
-
data: acf.prepareForAjax({
|
254 |
-
action: 'acfe/flexible/models',
|
255 |
-
field_key: this.get('key'),
|
256 |
-
layout: args.layout,
|
257 |
-
}),
|
258 |
-
dataType: 'html',
|
259 |
-
type: 'post',
|
260 |
-
beforeSend: function(){
|
261 |
-
$('body').addClass('-loading');
|
262 |
-
},
|
263 |
-
success: function(html){
|
264 |
-
if(html){
|
265 |
-
|
266 |
-
var $layout = $(html);
|
267 |
-
var uniqid = acf.uniqid();
|
268 |
-
|
269 |
-
var search = 'acf[' + flexible.get('key') + '][acfcloneindex]';
|
270 |
-
var replace = flexible.$control().find('> input[type=hidden]').attr('name') + '[' + uniqid + ']';
|
271 |
-
|
272 |
-
// add row
|
273 |
-
var $el = acf.duplicate({
|
274 |
-
target: $layout,
|
275 |
-
search: search,
|
276 |
-
replace: replace,
|
277 |
-
append: flexible.proxy(function( $el, $el2 ){
|
278 |
-
|
279 |
-
// append
|
280 |
-
if( args.before ) {
|
281 |
-
args.before.before( $el2 );
|
282 |
-
} else {
|
283 |
-
flexible.$layoutsWrap().append( $el2 );
|
284 |
-
}
|
285 |
-
|
286 |
-
// enable
|
287 |
-
acf.enable( $el2, flexible.cid );
|
288 |
-
|
289 |
-
// render
|
290 |
-
flexible.render();
|
291 |
-
})
|
292 |
-
});
|
293 |
-
|
294 |
-
// Fix data-id
|
295 |
-
$el.attr('data-id', uniqid);
|
296 |
-
|
297 |
-
// trigger change for validation errors
|
298 |
-
flexible.$input().trigger('change');
|
299 |
-
|
300 |
-
// return
|
301 |
-
return $el;
|
302 |
-
|
303 |
-
}
|
304 |
-
},
|
305 |
-
'complete': function(){
|
306 |
-
$('body').removeClass('-loading');
|
307 |
-
}
|
308 |
-
});
|
309 |
-
|
310 |
-
};
|
311 |
-
|
312 |
-
}
|
313 |
-
|
314 |
-
});
|
315 |
-
|
316 |
-
acf.addAction('acfe/flexible/layouts', function($layout, flexible){
|
317 |
-
|
318 |
-
// Layout Closed
|
319 |
-
if(flexible.isLayoutClosed($layout)){
|
320 |
-
|
321 |
-
// Placeholder
|
322 |
-
$layout.find('> .acfe-fc-placeholder').removeClass('acf-hidden');
|
323 |
-
|
324 |
-
if(flexible.has('acfeFlexibleOpen')){
|
325 |
-
|
326 |
-
acfe.enableFilter('acfeForceOpen');
|
327 |
-
|
328 |
-
flexible.openLayout($layout);
|
329 |
-
|
330 |
-
acfe.disableFilter('acfeForceOpen');
|
331 |
-
|
332 |
-
}
|
333 |
-
|
334 |
-
}
|
335 |
-
|
336 |
-
});
|
337 |
-
|
338 |
-
acf.addAction('show', function($layout, type){
|
339 |
-
|
340 |
-
if(type !== 'collapse' || !$layout.is('.layout'))
|
341 |
-
return;
|
342 |
-
|
343 |
-
var flexible = acf.getInstance($layout.closest('.acf-field-flexible-content'));
|
344 |
-
|
345 |
-
// Hide Placeholder
|
346 |
-
if(!flexible.has('acfeFlexibleModalEdition')){
|
347 |
-
|
348 |
-
// Placeholder
|
349 |
-
$layout.find('> .acfe-fc-placeholder').addClass('acf-hidden');
|
350 |
-
|
351 |
-
}
|
352 |
-
|
353 |
-
});
|
354 |
-
|
355 |
-
acf.addAction('hide', function($layout, type){
|
356 |
-
|
357 |
-
if(type !== 'collapse' || !$layout.is('.layout') || $layout.is('.acf-clone'))
|
358 |
-
return;
|
359 |
-
|
360 |
-
// Get Flexible
|
361 |
-
var flexible = acf.getInstance($layout.closest('.acf-field-flexible-content'));
|
362 |
-
|
363 |
-
// Remove Ajax Title
|
364 |
-
if(flexible.has('acfeFlexibleRemoveAjaxTitle')){
|
365 |
-
|
366 |
-
flexible.renderLayout = function($layout){};
|
367 |
-
|
368 |
-
}
|
369 |
-
|
370 |
-
// Preview Ajax
|
371 |
-
flexible.acfeLayoutInit($layout);
|
372 |
-
|
373 |
-
});
|
374 |
-
|
375 |
-
acf.addAction('append', function($el){
|
376 |
-
|
377 |
-
// Bail early if layout is not layout
|
378 |
-
if(!$el.is('.layout'))
|
379 |
-
return;
|
380 |
-
|
381 |
-
// Get Flexible
|
382 |
-
var flexible = acf.getInstance($el.closest('.acf-field-flexible-content'));
|
383 |
-
|
384 |
-
// Open Layout
|
385 |
-
if(!$el.is('.acfe-layout-duplicated')){
|
386 |
-
|
387 |
-
// Modal Edition: Open
|
388 |
-
if(flexible.has('acfeFlexibleModalEdition')){
|
389 |
-
|
390 |
-
$el.find('> [data-action="acfe-flexible-modal-edit"]:first').trigger('click');
|
391 |
-
|
392 |
-
}
|
393 |
-
|
394 |
-
// Normal Edition: Open
|
395 |
-
else{
|
396 |
-
|
397 |
-
flexible.openLayout($el);
|
398 |
-
|
399 |
-
}
|
400 |
-
|
401 |
-
}
|
402 |
-
|
403 |
-
flexible.acfeLayoutInit($el);
|
404 |
-
|
405 |
-
var $modal = flexible.$el.closest('.acfe-modal.-open');
|
406 |
-
|
407 |
-
if($modal.length){
|
408 |
-
|
409 |
-
// Scroll to new layout
|
410 |
-
$modal.find('> .acfe-modal-wrapper > .acfe-modal-content').animate({
|
411 |
-
scrollTop: parseInt($el.offset().top) - 200
|
412 |
-
}, 200);
|
413 |
-
|
414 |
-
}else{
|
415 |
-
|
416 |
-
var acfVersion = parseFloat(acf.get('acf_version'));
|
417 |
-
|
418 |
-
if(acfVersion < 5.9){
|
419 |
-
|
420 |
-
// Scroll to new layout
|
421 |
-
$('html, body').animate({
|
422 |
-
scrollTop: parseInt($el.offset().top) - 200
|
423 |
-
}, 200);
|
424 |
-
|
425 |
-
}else{
|
426 |
-
|
427 |
-
// Avoid native ACF duplicate
|
428 |
-
if(!$el.hasClass('-focused')){
|
429 |
-
|
430 |
-
// Scroll to new layout
|
431 |
-
$('html, body').animate({
|
432 |
-
scrollTop: parseInt($el.offset().top) - 200
|
433 |
-
}, 200);
|
434 |
-
|
435 |
-
}
|
436 |
-
|
437 |
-
}
|
438 |
-
|
439 |
-
}
|
440 |
-
|
441 |
-
});
|
442 |
-
|
443 |
-
/*
|
444 |
-
* Field Error
|
445 |
-
*/
|
446 |
-
acf.addAction('invalid_field', function(field){
|
447 |
-
|
448 |
-
field.$el.parents('.layout').addClass('acfe-flexible-modal-edit-error');
|
449 |
-
|
450 |
-
});
|
451 |
-
|
452 |
-
/*
|
453 |
-
* Field Valid
|
454 |
-
*/
|
455 |
-
acf.addAction('valid_field', function(field){
|
456 |
-
|
457 |
-
field.$el.parents('.layout').each(function(){
|
458 |
-
|
459 |
-
var $layout = $(this);
|
460 |
-
|
461 |
-
if(!$layout.find('.acf-error').length)
|
462 |
-
$layout.removeClass('acfe-flexible-modal-edit-error');
|
463 |
-
|
464 |
-
});
|
465 |
-
|
466 |
-
});
|
467 |
-
|
468 |
})(jQuery);
|
469 |
-
(function($){
|
470 |
-
|
471 |
-
if(typeof acf === 'undefined')
|
472 |
-
return;
|
473 |
-
|
474 |
-
/*
|
475 |
-
* Init
|
476 |
-
*/
|
477 |
-
var flexible = acf.getFieldType('flexible_content');
|
478 |
-
var model = flexible.prototype;
|
479 |
-
|
480 |
-
/*
|
481 |
-
* Actions
|
482 |
-
*/
|
483 |
-
model.events['click .acf-fc-layout-handle'] = 'acfeEditLayoutTitleToggleHandle';
|
484 |
-
model.acfeEditLayoutTitleToggleHandle = function(e, $el){
|
485 |
-
|
486 |
-
var flexible = this;
|
487 |
-
|
488 |
-
// Title Edition
|
489 |
-
if(!flexible.has('acfeFlexibleTitleEdition'))
|
490 |
-
return;
|
491 |
-
|
492 |
-
// Vars
|
493 |
-
var $layout = $el.closest('.layout');
|
494 |
-
|
495 |
-
if($layout.hasClass('acfe-flexible-title-edition')){
|
496 |
-
|
497 |
-
$layout.find('> .acf-fc-layout-handle > .acfe-layout-title > input.acfe-flexible-control-title').trigger('blur');
|
498 |
-
|
499 |
-
}
|
500 |
-
|
501 |
-
}
|
502 |
-
|
503 |
-
model.events['click .acfe-layout-title-text'] = 'acfeEditLayoutTitle';
|
504 |
-
model.acfeEditLayoutTitle = function(e, $el){
|
505 |
-
|
506 |
-
// Get Flexible
|
507 |
-
var flexible = this;
|
508 |
-
|
509 |
-
// Title Edition
|
510 |
-
if(!flexible.has('acfeFlexibleTitleEdition'))
|
511 |
-
return;
|
512 |
-
|
513 |
-
// Stop propagation
|
514 |
-
e.stopPropagation();
|
515 |
-
|
516 |
-
// Toggle
|
517 |
-
flexible.acfeEditLayoutTitleToggle(e, $el);
|
518 |
-
|
519 |
-
}
|
520 |
-
|
521 |
-
model.events['blur input.acfe-flexible-control-title'] = 'acfeEditLayoutTitleToggle';
|
522 |
-
model.acfeEditLayoutTitleToggle = function(e, $el){
|
523 |
-
|
524 |
-
var flexible = this;
|
525 |
-
|
526 |
-
// Vars
|
527 |
-
var $layout = $el.closest('.layout');
|
528 |
-
var $handle = $layout.find('> .acf-fc-layout-handle');
|
529 |
-
var $title = $handle.find('.acfe-layout-title');
|
530 |
-
|
531 |
-
if($layout.hasClass('acfe-flexible-title-edition')){
|
532 |
-
|
533 |
-
var $input = $title.find('> input[data-acfe-flexible-control-title-input]');
|
534 |
-
|
535 |
-
if($input.val() === '')
|
536 |
-
$input.val($input.attr('placeholder')).trigger('input');
|
537 |
-
|
538 |
-
$layout.removeClass('acfe-flexible-title-edition');
|
539 |
-
|
540 |
-
$input.insertAfter($handle);
|
541 |
-
|
542 |
-
}
|
543 |
-
|
544 |
-
else{
|
545 |
-
|
546 |
-
var $input = $layout.find('> input[data-acfe-flexible-control-title-input]');
|
547 |
-
|
548 |
-
var $input = $input.appendTo($title);
|
549 |
-
|
550 |
-
$layout.addClass('acfe-flexible-title-edition');
|
551 |
-
$input.focus().attr('size', $input.val().length);
|
552 |
-
|
553 |
-
}
|
554 |
-
|
555 |
-
}
|
556 |
-
|
557 |
-
// Layout: Edit Title
|
558 |
-
model.events['click input.acfe-flexible-control-title'] = 'acfeEditLayoutTitlePropagation';
|
559 |
-
model.acfeEditLayoutTitlePropagation = function(e, $el){
|
560 |
-
|
561 |
-
e.stopPropagation();
|
562 |
-
|
563 |
-
}
|
564 |
-
|
565 |
-
// Layout: Edit Title Input
|
566 |
-
model.events['input [data-acfe-flexible-control-title-input]'] = 'acfeEditLayoutTitleInput';
|
567 |
-
model.acfeEditLayoutTitleInput = function(e, $el){
|
568 |
-
|
569 |
-
// Vars
|
570 |
-
var $layout = $el.closest('.layout');
|
571 |
-
var $title = $layout.find('> .acf-fc-layout-handle .acfe-layout-title .acfe-layout-title-text');
|
572 |
-
|
573 |
-
var val = $el.val();
|
574 |
-
|
575 |
-
$el.attr('size', val.length);
|
576 |
-
|
577 |
-
$title.html(val);
|
578 |
-
|
579 |
-
}
|
580 |
-
|
581 |
-
// Layout: Edit Title Input Enter
|
582 |
-
model.events['keypress [data-acfe-flexible-control-title-input]'] = 'acfeEditLayoutTitleInputEnter';
|
583 |
-
model.acfeEditLayoutTitleInputEnter = function(e, $el){
|
584 |
-
|
585 |
-
// Enter Key
|
586 |
-
if(e.keyCode !== 13)
|
587 |
-
return;
|
588 |
-
|
589 |
-
e.preventDefault();
|
590 |
-
$el.blur();
|
591 |
-
|
592 |
-
}
|
593 |
-
|
594 |
-
// Layout: Settings
|
595 |
-
model.events['click [data-acfe-flexible-settings]'] = 'acfeLayoutSettings';
|
596 |
-
model.acfeLayoutSettings = function(e, $el){
|
597 |
-
|
598 |
-
// Get Flexible
|
599 |
-
var flexible = this;
|
600 |
-
|
601 |
-
// Vars
|
602 |
-
var $layout = $el.closest('.layout');
|
603 |
-
|
604 |
-
// Modal data
|
605 |
-
var $modal = $layout.find('> .acfe-modal.-settings');
|
606 |
-
var $handle = $layout.find('> .acf-fc-layout-handle');
|
607 |
-
|
608 |
-
var $layout_order = $handle.find('> .acf-fc-layout-order').outerHTML();
|
609 |
-
var $layout_title = $handle.find('.acfe-layout-title-text').text();
|
610 |
-
|
611 |
-
// Open modal
|
612 |
-
new acfe.Popup($modal, {
|
613 |
-
title: $layout_order + ' ' + $layout_title,
|
614 |
-
footer: acf.__('Close'),
|
615 |
-
onClose: function(){
|
616 |
-
|
617 |
-
if(!flexible.has('acfeFlexiblePreview'))
|
618 |
-
return;
|
619 |
-
|
620 |
-
flexible.closeLayout($layout);
|
621 |
-
|
622 |
-
}
|
623 |
-
});
|
624 |
-
|
625 |
-
}
|
626 |
-
|
627 |
-
/*
|
628 |
-
* Layout: Toggle Action
|
629 |
-
*/
|
630 |
-
model.events['click [data-acfe-flexible-control-toggle]'] = 'acfeLayoutToggle';
|
631 |
-
model.acfeLayoutToggle = function(e, $el){
|
632 |
-
|
633 |
-
// Get Flexible
|
634 |
-
var flexible = this;
|
635 |
-
|
636 |
-
// Vars
|
637 |
-
var $layout = $el.closest('.layout');
|
638 |
-
|
639 |
-
var $field = $layout.find('> .acfe-flexible-layout-toggle');
|
640 |
-
|
641 |
-
if(!$field.length)
|
642 |
-
return;
|
643 |
-
|
644 |
-
if($field.val() === '1'){
|
645 |
-
|
646 |
-
$layout.removeClass('acfe-flexible-layout-hidden');
|
647 |
-
$field.val('');
|
648 |
-
|
649 |
-
}else{
|
650 |
-
|
651 |
-
$layout.addClass('acfe-flexible-layout-hidden');
|
652 |
-
$field.val('1');
|
653 |
-
|
654 |
-
}
|
655 |
-
|
656 |
-
}
|
657 |
-
|
658 |
-
/*
|
659 |
-
* Layout: Toggle Spawn
|
660 |
-
*/
|
661 |
-
acf.addAction('acfe/flexible/layouts', function($layout, flexible){
|
662 |
-
|
663 |
-
if(!flexible.has('acfeFlexibleToggle'))
|
664 |
-
return;
|
665 |
-
|
666 |
-
// Layout Closed
|
667 |
-
var $field = $layout.find('> .acfe-flexible-layout-toggle');
|
668 |
-
|
669 |
-
if(!$field.length)
|
670 |
-
return;
|
671 |
-
|
672 |
-
if($field.val() === '1'){
|
673 |
-
|
674 |
-
$layout.addClass('acfe-flexible-layout-hidden');
|
675 |
-
|
676 |
-
}else{
|
677 |
-
|
678 |
-
$layout.removeClass('acfe-flexible-layout-hidden');
|
679 |
-
|
680 |
-
}
|
681 |
-
|
682 |
-
});
|
683 |
-
|
684 |
-
// Layout: Clone
|
685 |
-
model.events['click [data-acfe-flexible-control-clone]'] = 'acfeCloneLayout';
|
686 |
-
model.acfeCloneLayout = function(e, $el){
|
687 |
-
|
688 |
-
// Get Flexible
|
689 |
-
var flexible = this;
|
690 |
-
|
691 |
-
// Vars
|
692 |
-
var $layout = $el.closest('.layout');
|
693 |
-
var layout_name = $layout.data('layout');
|
694 |
-
|
695 |
-
// Popup min/max
|
696 |
-
var $popup = $(flexible.$popup().html());
|
697 |
-
var $layouts = flexible.$layouts();
|
698 |
-
|
699 |
-
var countLayouts = function(name){
|
700 |
-
return $layouts.filter(function(){
|
701 |
-
return $(this).data('layout') === name;
|
702 |
-
}).length;
|
703 |
-
};
|
704 |
-
|
705 |
-
// vars
|
706 |
-
var $a = $popup.find('[data-layout="' + layout_name + '"]');
|
707 |
-
var min = $a.data('min') || 0;
|
708 |
-
var max = $a.data('max') || 0;
|
709 |
-
var count = countLayouts(layout_name);
|
710 |
-
|
711 |
-
// max
|
712 |
-
if(max && count >= max){
|
713 |
-
|
714 |
-
$el.addClass('disabled');
|
715 |
-
return false;
|
716 |
-
|
717 |
-
}else{
|
718 |
-
|
719 |
-
$el.removeClass('disabled');
|
720 |
-
|
721 |
-
}
|
722 |
-
|
723 |
-
// Fix inputs
|
724 |
-
flexible.acfeFixInputs($layout);
|
725 |
-
|
726 |
-
var $_layout = $layout.clone();
|
727 |
-
|
728 |
-
// Clean Layout
|
729 |
-
flexible.acfeCleanLayouts($_layout);
|
730 |
-
|
731 |
-
var parent = $el.closest('.acf-flexible-content').find('> input[type=hidden]').attr('name');
|
732 |
-
|
733 |
-
// Clone
|
734 |
-
var $layout_added = flexible.acfeDuplicate({
|
735 |
-
layout: $_layout,
|
736 |
-
before: $layout,
|
737 |
-
parent: parent
|
738 |
-
});
|
739 |
-
|
740 |
-
}
|
741 |
-
|
742 |
-
// Layout: Copy
|
743 |
-
model.events['click [data-acfe-flexible-control-copy]'] = 'acfeCopyLayout';
|
744 |
-
model.acfeCopyLayout = function(e, $el){
|
745 |
-
|
746 |
-
// Get Flexible
|
747 |
-
var flexible = this;
|
748 |
-
|
749 |
-
// Vars
|
750 |
-
var $layout = $el.closest('.layout').clone();
|
751 |
-
var source = flexible.$control().find('> input[type=hidden]').attr('name');
|
752 |
-
|
753 |
-
// Fix inputs
|
754 |
-
flexible.acfeFixInputs($layout);
|
755 |
-
|
756 |
-
// Clean layout
|
757 |
-
flexible.acfeCleanLayouts($layout);
|
758 |
-
|
759 |
-
// Get layout data
|
760 |
-
var data = JSON.stringify({
|
761 |
-
source: source,
|
762 |
-
layouts: $layout[0].outerHTML
|
763 |
-
});
|
764 |
-
|
765 |
-
// Append Temp Input
|
766 |
-
var $input = $('<input type="text" style="clip:rect(0,0,0,0);clip-path:rect(0,0,0,0);position:absolute;" value="" />').appendTo($('body'));
|
767 |
-
$input.attr('value', data).select();
|
768 |
-
|
769 |
-
// Command: Copy
|
770 |
-
if(document.execCommand('copy'))
|
771 |
-
alert('Layout has been transferred to your clipboard');
|
772 |
-
|
773 |
-
// Prompt
|
774 |
-
else
|
775 |
-
prompt('Copy the following layout data to your clipboard', data);
|
776 |
-
|
777 |
-
// Remove the temp input
|
778 |
-
$input.remove();
|
779 |
-
|
780 |
-
}
|
781 |
-
|
782 |
-
// Flexible: Copy Layouts
|
783 |
-
model.acfeCopyLayouts = function(){
|
784 |
-
|
785 |
-
// Get Flexible
|
786 |
-
var flexible = this;
|
787 |
-
|
788 |
-
// Get layouts
|
789 |
-
var $layouts = flexible.$layoutsWrap().clone();
|
790 |
-
var source = flexible.$control().find('> input[type=hidden]').attr('name');
|
791 |
-
|
792 |
-
// Fix inputs
|
793 |
-
flexible.acfeFixInputs($layouts);
|
794 |
-
|
795 |
-
// Clean layout
|
796 |
-
flexible.acfeCleanLayouts($layouts);
|
797 |
-
|
798 |
-
// Get layouts data
|
799 |
-
var data = JSON.stringify({
|
800 |
-
source: source,
|
801 |
-
layouts: $layouts.html()
|
802 |
-
});
|
803 |
-
|
804 |
-
// Append Temp Input
|
805 |
-
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);
|
806 |
-
$input.attr('value', data).select();
|
807 |
-
|
808 |
-
// Command: Copy
|
809 |
-
if(document.execCommand('copy'))
|
810 |
-
alert('Layouts have been transferred to your clipboard');
|
811 |
-
|
812 |
-
// Prompt
|
813 |
-
else
|
814 |
-
prompt('Copy the following layouts data to your clipboard', data);
|
815 |
-
|
816 |
-
$input.remove();
|
817 |
-
|
818 |
-
}
|
819 |
-
|
820 |
-
// Flexible: Paste Layouts
|
821 |
-
model.acfePasteLayouts = function(){
|
822 |
-
|
823 |
-
// Get Flexible
|
824 |
-
var flexible = this;
|
825 |
-
|
826 |
-
var paste = prompt('Paste layouts data in the following field');
|
827 |
-
|
828 |
-
// No input
|
829 |
-
if(paste == null || paste === '')
|
830 |
-
return;
|
831 |
-
|
832 |
-
try{
|
833 |
-
|
834 |
-
// Paste HTML
|
835 |
-
var data = JSON.parse(paste);
|
836 |
-
var source = data.source;
|
837 |
-
var $html = $(data.layouts);
|
838 |
-
|
839 |
-
// Parsed layouts
|
840 |
-
var $html_layouts = $html.closest('[data-layout]');
|
841 |
-
|
842 |
-
if(!$html_layouts.length)
|
843 |
-
return alert('No layouts data available');
|
844 |
-
|
845 |
-
// Popup min/max
|
846 |
-
var $popup = $(flexible.$popup().html());
|
847 |
-
var $layouts = flexible.$layouts();
|
848 |
-
|
849 |
-
var countLayouts = function(name){
|
850 |
-
return $layouts.filter(function(){
|
851 |
-
return $(this).data('layout') === name;
|
852 |
-
}).length;
|
853 |
-
};
|
854 |
-
|
855 |
-
// init
|
856 |
-
var validated_layouts = [];
|
857 |
-
|
858 |
-
// Each first level layouts
|
859 |
-
$html_layouts.each(function(){
|
860 |
-
|
861 |
-
var $this = $(this);
|
862 |
-
var layout_name = $this.data('layout');
|
863 |
-
|
864 |
-
// vars
|
865 |
-
var $a = $popup.find('[data-layout="' + layout_name + '"]');
|
866 |
-
var min = $a.data('min') || 0;
|
867 |
-
var max = $a.data('max') || 0;
|
868 |
-
var count = countLayouts(layout_name);
|
869 |
-
|
870 |
-
// max
|
871 |
-
if(max && count >= max)
|
872 |
-
return;
|
873 |
-
|
874 |
-
// Validate layout against available layouts
|
875 |
-
var get_clone_layout = flexible.$clone($this.attr('data-layout'));
|
876 |
-
|
877 |
-
// Layout is invalid
|
878 |
-
if(!get_clone_layout.length)
|
879 |
-
return;
|
880 |
-
|
881 |
-
// Add validated layout
|
882 |
-
validated_layouts.push($this);
|
883 |
-
|
884 |
-
});
|
885 |
-
|
886 |
-
// Nothing to add
|
887 |
-
if(!validated_layouts.length)
|
888 |
-
return alert('No layouts could be pasted');
|
889 |
-
|
890 |
-
// Add layouts
|
891 |
-
$.each(validated_layouts, function(){
|
892 |
-
|
893 |
-
var $layout = $(this);
|
894 |
-
var search = source + '[' + $layout.attr('data-id') + ']';
|
895 |
-
var target = flexible.$control().find('> input[type=hidden]').attr('name');
|
896 |
-
|
897 |
-
flexible.acfeDuplicate({
|
898 |
-
layout: $layout,
|
899 |
-
before: false,
|
900 |
-
search: search,
|
901 |
-
parent: target
|
902 |
-
});
|
903 |
-
|
904 |
-
});
|
905 |
-
|
906 |
-
}catch(e){
|
907 |
-
|
908 |
-
console.log(e);
|
909 |
-
alert('Invalid data');
|
910 |
-
|
911 |
-
}
|
912 |
-
|
913 |
-
}
|
914 |
-
|
915 |
-
// Flexible: Dropdown
|
916 |
-
model.events['click [data-name="acfe-flexible-control-button"]'] = 'acfeControl';
|
917 |
-
model.acfeControl = function(e, $el){
|
918 |
-
|
919 |
-
// Get Flexible
|
920 |
-
var flexible = this;
|
921 |
-
|
922 |
-
// Vars
|
923 |
-
var $dropdown = $el.next('.tmpl-acfe-flexible-control-popup').html();
|
924 |
-
|
925 |
-
// Init Popup
|
926 |
-
var Popup = acf.models.TooltipConfirm.extend({
|
927 |
-
render: function(){
|
928 |
-
this.html(this.get('text'));
|
929 |
-
this.$el.addClass('acf-fc-popup');
|
930 |
-
}
|
931 |
-
});
|
932 |
-
|
933 |
-
// New Popup
|
934 |
-
var popup = new Popup({
|
935 |
-
target: $el,
|
936 |
-
targetConfirm: false,
|
937 |
-
text: $dropdown,
|
938 |
-
context: flexible,
|
939 |
-
confirm: function(e, $el){
|
940 |
-
|
941 |
-
if($el.attr('data-acfe-flexible-control-action') === 'paste')
|
942 |
-
flexible.acfePasteLayouts();
|
943 |
-
|
944 |
-
else if($el.attr('data-acfe-flexible-control-action') === 'copy')
|
945 |
-
flexible.acfeCopyLayouts();
|
946 |
-
|
947 |
-
}
|
948 |
-
});
|
949 |
-
|
950 |
-
popup.on('click', 'a', 'onConfirm');
|
951 |
-
|
952 |
-
}
|
953 |
-
|
954 |
-
// Flexible: Duplicate
|
955 |
-
model.acfeDuplicate = function(args){
|
956 |
-
|
957 |
-
// Arguments
|
958 |
-
args = acf.parseArgs(args, {
|
959 |
-
layout: '',
|
960 |
-
before: false,
|
961 |
-
parent: false,
|
962 |
-
search: '',
|
963 |
-
replace: '',
|
964 |
-
});
|
965 |
-
|
966 |
-
// Validate
|
967 |
-
if(!this.allowAdd())
|
968 |
-
return false;
|
969 |
-
|
970 |
-
var uniqid = acf.uniqid();
|
971 |
-
|
972 |
-
if(args.parent){
|
973 |
-
|
974 |
-
if(!args.search){
|
975 |
-
|
976 |
-
args.search = args.parent + '[' + args.layout.attr('data-id') + ']';
|
977 |
-
|
978 |
-
}
|
979 |
-
|
980 |
-
args.replace = args.parent + '[' + uniqid + ']';
|
981 |
-
|
982 |
-
}
|
983 |
-
|
984 |
-
var duplicate_args = {
|
985 |
-
target: args.layout,
|
986 |
-
search: args.search,
|
987 |
-
replace: args.replace,
|
988 |
-
append: this.proxy(function($el, $el2){
|
989 |
-
|
990 |
-
// Add class to duplicated layout
|
991 |
-
$el2.addClass('acfe-layout-duplicated');
|
992 |
-
|
993 |
-
// Reset UniqID
|
994 |
-
$el2.attr('data-id', uniqid);
|
995 |
-
|
996 |
-
// append before
|
997 |
-
if(args.before){
|
998 |
-
|
999 |
-
// Fix clone: Use after() instead of native before()
|
1000 |
-
args.before.after($el2);
|
1001 |
-
|
1002 |
-
}
|
1003 |
-
|
1004 |
-
// append end
|
1005 |
-
else{
|
1006 |
-
|
1007 |
-
this.$layoutsWrap().append($el2);
|
1008 |
-
|
1009 |
-
}
|
1010 |
-
|
1011 |
-
// enable
|
1012 |
-
acf.enable($el2, this.cid);
|
1013 |
-
|
1014 |
-
// render
|
1015 |
-
this.render();
|
1016 |
-
|
1017 |
-
})
|
1018 |
-
}
|
1019 |
-
|
1020 |
-
var acfVersion = parseFloat(acf.get('acf_version'));
|
1021 |
-
|
1022 |
-
if(acfVersion < 5.9){
|
1023 |
-
|
1024 |
-
// Add row
|
1025 |
-
var $el = acf.duplicate(duplicate_args);
|
1026 |
-
|
1027 |
-
// Hotfix for ACF Pro 5.9
|
1028 |
-
}else{
|
1029 |
-
|
1030 |
-
// Add row
|
1031 |
-
var $el = model.acfeNewAcfDuplicate(duplicate_args);
|
1032 |
-
|
1033 |
-
}
|
1034 |
-
|
1035 |
-
// trigger change for validation errors
|
1036 |
-
this.$input().trigger('change');
|
1037 |
-
|
1038 |
-
// Fix tabs conditionally hidden
|
1039 |
-
var tabs = acf.getFields({
|
1040 |
-
type: 'tab',
|
1041 |
-
parent: $el,
|
1042 |
-
});
|
1043 |
-
|
1044 |
-
if(tabs.length){
|
1045 |
-
|
1046 |
-
$.each(tabs, function(){
|
1047 |
-
|
1048 |
-
if(this.$el.hasClass('acf-hidden')){
|
1049 |
-
|
1050 |
-
this.tab.$el.addClass('acf-hidden');
|
1051 |
-
|
1052 |
-
}
|
1053 |
-
|
1054 |
-
});
|
1055 |
-
|
1056 |
-
}
|
1057 |
-
|
1058 |
-
|
1059 |
-
// return
|
1060 |
-
return $el;
|
1061 |
-
|
1062 |
-
}
|
1063 |
-
|
1064 |
-
/*
|
1065 |
-
* Based on acf.duplicate (5.9)
|
1066 |
-
*
|
1067 |
-
* doAction('duplicate) has been commented out
|
1068 |
-
* This fix an issue with the WYSIWYG editor field during copy/paste since ACF 5.9
|
1069 |
-
*/
|
1070 |
-
model.acfeNewAcfDuplicate = function( args ){
|
1071 |
-
|
1072 |
-
// allow jQuery
|
1073 |
-
if( args instanceof jQuery ) {
|
1074 |
-
args = {
|
1075 |
-
target: args
|
1076 |
-
};
|
1077 |
-
}
|
1078 |
-
|
1079 |
-
// defaults
|
1080 |
-
args = acf.parseArgs(args, {
|
1081 |
-
target: false,
|
1082 |
-
search: '',
|
1083 |
-
replace: '',
|
1084 |
-
rename: true,
|
1085 |
-
before: function( $el ){},
|
1086 |
-
after: function( $el, $el2 ){},
|
1087 |
-
append: function( $el, $el2 ){
|
1088 |
-
$el.after( $el2 );
|
1089 |
-
}
|
1090 |
-
});
|
1091 |
-
|
1092 |
-
// compatibility
|
1093 |
-
args.target = args.target || args.$el;
|
1094 |
-
|
1095 |
-
// vars
|
1096 |
-
var $el = args.target;
|
1097 |
-
|
1098 |
-
// search
|
1099 |
-
args.search = args.search || $el.attr('data-id');
|
1100 |
-
args.replace = args.replace || acf.uniqid();
|
1101 |
-
|
1102 |
-
// before
|
1103 |
-
// - allow acf to modify DOM
|
1104 |
-
// - fixes bug where select field option is not selected
|
1105 |
-
args.before( $el );
|
1106 |
-
acf.doAction('before_duplicate', $el);
|
1107 |
-
|
1108 |
-
// clone
|
1109 |
-
var $el2 = $el.clone();
|
1110 |
-
|
1111 |
-
// rename
|
1112 |
-
if( args.rename ) {
|
1113 |
-
acf.rename({
|
1114 |
-
target: $el2,
|
1115 |
-
search: args.search,
|
1116 |
-
replace: args.replace,
|
1117 |
-
replacer: ( typeof args.rename === 'function' ? args.rename : null )
|
1118 |
-
});
|
1119 |
-
}
|
1120 |
-
|
1121 |
-
// remove classes
|
1122 |
-
$el2.removeClass('acf-clone');
|
1123 |
-
$el2.find('.ui-sortable').removeClass('ui-sortable');
|
1124 |
-
|
1125 |
-
// after
|
1126 |
-
// - allow acf to modify DOM
|
1127 |
-
args.after( $el, $el2 );
|
1128 |
-
acf.doAction('after_duplicate', $el, $el2 );
|
1129 |
-
|
1130 |
-
// append
|
1131 |
-
args.append( $el, $el2 );
|
1132 |
-
|
1133 |
-
/**
|
1134 |
-
* Fires after an element has been duplicated and appended to the DOM.
|
1135 |
-
*
|
1136 |
-
* @date 30/10/19
|
1137 |
-
* @since 5.8.7
|
1138 |
-
*
|
1139 |
-
* @param jQuery $el The original element.
|
1140 |
-
* @param jQuery $el2 The duplicated element.
|
1141 |
-
*/
|
1142 |
-
//acf.doAction('duplicate', $el, $el2 );
|
1143 |
-
|
1144 |
-
// append
|
1145 |
-
acf.doAction('append', $el2);
|
1146 |
-
|
1147 |
-
// return
|
1148 |
-
return $el2;
|
1149 |
-
};
|
1150 |
-
|
1151 |
-
// Flexible: Fix Inputs
|
1152 |
-
model.acfeFixInputs = function($layout){
|
1153 |
-
|
1154 |
-
$layout.find('input').each(function(){
|
1155 |
-
|
1156 |
-
$(this).attr('value', this.value);
|
1157 |
-
|
1158 |
-
});
|
1159 |
-
|
1160 |
-
$layout.find('textarea').each(function(){
|
1161 |
-
|
1162 |
-
$(this).html(this.value);
|
1163 |
-
|
1164 |
-
});
|
1165 |
-
|
1166 |
-
$layout.find('input:radio,input:checkbox').each(function() {
|
1167 |
-
|
1168 |
-
if(this.checked)
|
1169 |
-
$(this).attr('checked', 'checked');
|
1170 |
-
|
1171 |
-
else
|
1172 |
-
$(this).attr('checked', false);
|
1173 |
-
|
1174 |
-
});
|
1175 |
-
|
1176 |
-
$layout.find('option').each(function(){
|
1177 |
-
|
1178 |
-
if(this.selected)
|
1179 |
-
$(this).attr('selected', 'selected');
|
1180 |
-
|
1181 |
-
else
|
1182 |
-
$(this).attr('selected', false);
|
1183 |
-
|
1184 |
-
});
|
1185 |
-
|
1186 |
-
}
|
1187 |
-
|
1188 |
-
// Flexible: Clean Layout
|
1189 |
-
model.acfeCleanLayouts = function($layout){
|
1190 |
-
|
1191 |
-
// Clean WP Editor
|
1192 |
-
$layout.find('.acf-editor-wrap').each(function(){
|
1193 |
-
|
1194 |
-
var $input = $(this);
|
1195 |
-
|
1196 |
-
$input.find('.wp-editor-container div').remove();
|
1197 |
-
$input.find('.wp-editor-container textarea').css('display', '');
|
1198 |
-
|
1199 |
-
});
|
1200 |
-
|
1201 |
-
// Clean Date
|
1202 |
-
$layout.find('.acf-date-picker').each(function(){
|
1203 |
-
|
1204 |
-
var $input = $(this);
|
1205 |
-
|
1206 |
-
$input.find('input.input').removeClass('hasDatepicker').removeAttr('id');
|
1207 |
-
|
1208 |
-
});
|
1209 |
-
|
1210 |
-
// Clean Time
|
1211 |
-
$layout.find('.acf-time-picker').each(function(){
|
1212 |
-
|
1213 |
-
var $input = $(this);
|
1214 |
-
|
1215 |
-
$input.find('input.input').removeClass('hasDatepicker').removeAttr('id');
|
1216 |
-
|
1217 |
-
});
|
1218 |
-
|
1219 |
-
// Clean DateTime
|
1220 |
-
$layout.find('.acf-date-time-picker').each(function(){
|
1221 |
-
|
1222 |
-
var $input = $(this);
|
1223 |
-
|
1224 |
-
$input.find('input.input').removeClass('hasDatepicker').removeAttr('id');
|
1225 |
-
|
1226 |
-
});
|
1227 |
-
|
1228 |
-
// Clean Code Editor
|
1229 |
-
$layout.find('.acfe-field-code-editor').each(function(){
|
1230 |
-
|
1231 |
-
var $input = $(this);
|
1232 |
-
|
1233 |
-
$input.find('.CodeMirror').remove();
|
1234 |
-
|
1235 |
-
});
|
1236 |
-
|
1237 |
-
// Clean Color Picker
|
1238 |
-
$layout.find('.acf-color-picker').each(function(){
|
1239 |
-
|
1240 |
-
var $input = $(this);
|
1241 |
-
|
1242 |
-
var $color_picker = $input.find('> input');
|
1243 |
-
var $color_picker_proxy = $input.find('.wp-picker-container input.wp-color-picker').clone();
|
1244 |
-
|
1245 |
-
$color_picker.after($color_picker_proxy);
|
1246 |
-
|
1247 |
-
$input.find('.wp-picker-container').remove();
|
1248 |
-
|
1249 |
-
});
|
1250 |
-
|
1251 |
-
// Clean Post Object
|
1252 |
-
$layout.find('.acf-field-post-object').each(function(){
|
1253 |
-
|
1254 |
-
var $input = $(this);
|
1255 |
-
|
1256 |
-
$input.find('> .acf-input span').remove();
|
1257 |
-
|
1258 |
-
$input.find('> .acf-input select').removeAttr('tabindex aria-hidden').removeClass();
|
1259 |
-
|
1260 |
-
});
|
1261 |
-
|
1262 |
-
// Clean Page Link
|
1263 |
-
$layout.find('.acf-field-page-link').each(function(){
|
1264 |
-
|
1265 |
-
var $input = $(this);
|
1266 |
-
|
1267 |
-
$input.find('> .acf-input span').remove();
|
1268 |
-
|
1269 |
-
$input.find('> .acf-input select').removeAttr('tabindex aria-hidden').removeClass();
|
1270 |
-
|
1271 |
-
});
|
1272 |
-
|
1273 |
-
// Clean Select2
|
1274 |
-
$layout.find('.acf-field-select').each(function(){
|
1275 |
-
|
1276 |
-
var $input = $(this);
|
1277 |
-
|
1278 |
-
$input.find('> .acf-input span').remove();
|
1279 |
-
|
1280 |
-
$input.find('> .acf-input select').removeAttr('tabindex aria-hidden').removeClass();
|
1281 |
-
|
1282 |
-
});
|
1283 |
-
|
1284 |
-
// Clean FontAwesome
|
1285 |
-
$layout.find('.acf-field-font-awesome').each(function(){
|
1286 |
-
|
1287 |
-
var $input = $(this);
|
1288 |
-
|
1289 |
-
$input.find('> .acf-input span').remove();
|
1290 |
-
|
1291 |
-
$input.find('> .acf-input select').removeAttr('tabindex aria-hidden');
|
1292 |
-
|
1293 |
-
});
|
1294 |
-
|
1295 |
-
|
1296 |
-
// Clean Tab
|
1297 |
-
$layout.find('.acf-tab-wrap').each(function(){
|
1298 |
-
|
1299 |
-
var $wrap = $(this);
|
1300 |
-
|
1301 |
-
var $content = $wrap.closest('.acf-fields');
|
1302 |
-
|
1303 |
-
var tabs = [];
|
1304 |
-
$.each($wrap.find('li a'), function(){
|
1305 |
-
|
1306 |
-
tabs.push($(this));
|
1307 |
-
|
1308 |
-
});
|
1309 |
-
|
1310 |
-
$content.find('> .acf-field-tab').each(function(){
|
1311 |
-
|
1312 |
-
$current_tab = $(this);
|
1313 |
-
|
1314 |
-
$.each(tabs, function(){
|
1315 |
-
|
1316 |
-
var $this = $(this);
|
1317 |
-
|
1318 |
-
if($this.attr('data-key') !== $current_tab.attr('data-key'))
|
1319 |
-
return;
|
1320 |
-
|
1321 |
-
$current_tab.find('> .acf-input').append($this);
|
1322 |
-
|
1323 |
-
});
|
1324 |
-
|
1325 |
-
});
|
1326 |
-
|
1327 |
-
$wrap.remove();
|
1328 |
-
|
1329 |
-
});
|
1330 |
-
|
1331 |
-
// Clean Accordion
|
1332 |
-
$layout.find('.acf-field-accordion').each(function(){
|
1333 |
-
|
1334 |
-
var $input = $(this);
|
1335 |
-
|
1336 |
-
$input.find('> .acf-accordion-title > .acf-accordion-icon').remove();
|
1337 |
-
|
1338 |
-
// Append virtual endpoint after each accordion
|
1339 |
-
$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>');
|
1340 |
-
|
1341 |
-
});
|
1342 |
-
|
1343 |
-
}
|
1344 |
-
|
1345 |
-
/*
|
1346 |
-
* Spawn
|
1347 |
-
*/
|
1348 |
-
acf.addAction('new_field/type=flexible_content', function(flexible){
|
1349 |
-
|
1350 |
-
// ACFE: Lock
|
1351 |
-
if(flexible.has('acfeFlexibleLock')){
|
1352 |
-
|
1353 |
-
flexible.removeEvents({'mouseover': 'onHover'});
|
1354 |
-
|
1355 |
-
}
|
1356 |
-
|
1357 |
-
});
|
1358 |
-
|
1359 |
})(jQuery);
|
1360 |
-
(function($){
|
1361 |
-
|
1362 |
-
if(typeof acf === 'undefined')
|
1363 |
-
return;
|
1364 |
-
|
1365 |
-
/*
|
1366 |
-
* Init
|
1367 |
-
*/
|
1368 |
-
var flexible = acf.getFieldType('flexible_content');
|
1369 |
-
var model = flexible.prototype;
|
1370 |
-
|
1371 |
-
/*
|
1372 |
-
* Actions
|
1373 |
-
*/
|
1374 |
-
model.acfeModalSelect = function(e, $el){
|
1375 |
-
|
1376 |
-
// Get Flexible
|
1377 |
-
var flexible = this;
|
1378 |
-
|
1379 |
-
// Validate
|
1380 |
-
if(!flexible.validateAdd())
|
1381 |
-
return false;
|
1382 |
-
|
1383 |
-
// Layout
|
1384 |
-
var $layout_source = null;
|
1385 |
-
|
1386 |
-
if($el.hasClass('acf-icon'))
|
1387 |
-
$layout_source = $el.closest('.layout');
|
1388 |
-
|
1389 |
-
// Get Available Layouts
|
1390 |
-
var layouts = flexible.getPopupHTML();
|
1391 |
-
|
1392 |
-
// Init Categories
|
1393 |
-
var categories = {
|
1394 |
-
array: [],
|
1395 |
-
html: ''
|
1396 |
-
};
|
1397 |
-
|
1398 |
-
function SearchArray(element, array){
|
1399 |
-
|
1400 |
-
var len = array.length,
|
1401 |
-
str = element.toString().toLowerCase();
|
1402 |
-
|
1403 |
-
for(var i = 0; i < len; i++){
|
1404 |
-
if(array[i].toLowerCase() === str){
|
1405 |
-
return i;
|
1406 |
-
}
|
1407 |
-
}
|
1408 |
-
|
1409 |
-
return -1;
|
1410 |
-
|
1411 |
-
}
|
1412 |
-
|
1413 |
-
// Get Categories
|
1414 |
-
$(layouts).find('li a span[data-acfe-flexible-category]').each(function(){
|
1415 |
-
|
1416 |
-
var spanCats = $(this).data('acfe-flexible-category');
|
1417 |
-
|
1418 |
-
$.each(spanCats, function(){
|
1419 |
-
|
1420 |
-
if(SearchArray(this, categories.array) !== -1)
|
1421 |
-
return;
|
1422 |
-
|
1423 |
-
categories.array.push(this);
|
1424 |
-
|
1425 |
-
});
|
1426 |
-
|
1427 |
-
});
|
1428 |
-
|
1429 |
-
// Categories HTML
|
1430 |
-
if(categories.array.length){
|
1431 |
-
|
1432 |
-
categories.array.sort();
|
1433 |
-
|
1434 |
-
categories.html += '<h2 class="acfe-flexible-categories nav-tab-wrapper">';
|
1435 |
-
|
1436 |
-
categories.html += '<a href="#" data-acfe-flexible-category="acfe-all" class="nav-tab nav-tab-active"><span class="dashicons dashicons-menu"></span></a>';
|
1437 |
-
|
1438 |
-
$(categories.array).each(function(k, category){
|
1439 |
-
|
1440 |
-
categories.html += '<a href="#" data-acfe-flexible-category="' + category + '" class="nav-tab">' + category + '</a>';
|
1441 |
-
|
1442 |
-
});
|
1443 |
-
|
1444 |
-
categories.html += '</h2>';
|
1445 |
-
|
1446 |
-
}
|
1447 |
-
|
1448 |
-
// Modal Title
|
1449 |
-
var modalTitle = acf.__('Add Row');
|
1450 |
-
|
1451 |
-
if(flexible.has('acfeFlexibleModalTitle')){
|
1452 |
-
modalTitle = flexible.get('acfeFlexibleModalTitle');
|
1453 |
-
}
|
1454 |
-
|
1455 |
-
// Create Modal
|
1456 |
-
var $modal = $('' +
|
1457 |
-
'<div class="acfe-modal">' +
|
1458 |
-
|
1459 |
-
categories.html +
|
1460 |
-
'<div class="acfe-flex-container">' +
|
1461 |
-
layouts +
|
1462 |
-
'</div>' +
|
1463 |
-
|
1464 |
-
'</div>'
|
1465 |
-
|
1466 |
-
).appendTo('body');
|
1467 |
-
|
1468 |
-
// Open Modal
|
1469 |
-
new acfe.Popup($modal, {
|
1470 |
-
title: modalTitle,
|
1471 |
-
size: 'full',
|
1472 |
-
destroy: true
|
1473 |
-
});
|
1474 |
-
|
1475 |
-
// Modal: Columns
|
1476 |
-
if(flexible.has('acfeFlexibleModalCol')){
|
1477 |
-
|
1478 |
-
$modal.find('.acfe-modal-content .acfe-flex-container').addClass('acfe-col-' + flexible.get('acfeFlexibleModalCol'));
|
1479 |
-
|
1480 |
-
}
|
1481 |
-
|
1482 |
-
// Modal: Columns
|
1483 |
-
if(flexible.has('acfeFlexibleThumbnails')){
|
1484 |
-
|
1485 |
-
$modal.find('.acfe-modal-content .acfe-flex-container').addClass('acfe-flex-thumbnails');
|
1486 |
-
|
1487 |
-
}
|
1488 |
-
|
1489 |
-
// Modal: ACF autofocus fix
|
1490 |
-
$modal.find('li:first-of-type a').blur();
|
1491 |
-
|
1492 |
-
// Modal: Layouts Badges
|
1493 |
-
$modal.find('li a span.badge').each(function(){
|
1494 |
-
|
1495 |
-
$(this).addClass('acf-js-tooltip dashicons dashicons-info');
|
1496 |
-
|
1497 |
-
});
|
1498 |
-
|
1499 |
-
// Modal: Categories Click
|
1500 |
-
$modal.find('.acfe-flexible-categories a').click(function(e){
|
1501 |
-
|
1502 |
-
e.preventDefault();
|
1503 |
-
|
1504 |
-
var $link = $(this);
|
1505 |
-
|
1506 |
-
$link.closest('.acfe-flexible-categories').find('a').removeClass('nav-tab-active');
|
1507 |
-
$link.addClass('nav-tab-active');
|
1508 |
-
|
1509 |
-
var selected_category = $link.data('acfe-flexible-category');
|
1510 |
-
|
1511 |
-
$modal.find('a[data-layout] span[data-acfe-flexible-category]').each(function(){
|
1512 |
-
|
1513 |
-
// Get span
|
1514 |
-
var $span = $(this);
|
1515 |
-
|
1516 |
-
// Show All
|
1517 |
-
$span.closest('li').show();
|
1518 |
-
|
1519 |
-
var category = $span.data('acfe-flexible-category');
|
1520 |
-
|
1521 |
-
// Specific category
|
1522 |
-
if(selected_category !== 'acfe-all'){
|
1523 |
-
|
1524 |
-
// Hide All
|
1525 |
-
$span.closest('li').hide();
|
1526 |
-
|
1527 |
-
$.each(category, function(i, c){
|
1528 |
-
|
1529 |
-
if(selected_category.toLowerCase() === c.toLowerCase()){
|
1530 |
-
|
1531 |
-
$span.closest('li').show();
|
1532 |
-
|
1533 |
-
return false;
|
1534 |
-
|
1535 |
-
}
|
1536 |
-
|
1537 |
-
});
|
1538 |
-
|
1539 |
-
}
|
1540 |
-
|
1541 |
-
});
|
1542 |
-
|
1543 |
-
});
|
1544 |
-
|
1545 |
-
// Modal: Click Add Layout
|
1546 |
-
$modal.on('click', 'a[data-layout]', function(e){
|
1547 |
-
|
1548 |
-
e.preventDefault();
|
1549 |
-
|
1550 |
-
// Close modal
|
1551 |
-
acfe.closePopup();
|
1552 |
-
|
1553 |
-
// Add layout
|
1554 |
-
flexible.add({
|
1555 |
-
layout: $(this).data('layout'),
|
1556 |
-
before: $layout_source
|
1557 |
-
});
|
1558 |
-
|
1559 |
-
});
|
1560 |
-
|
1561 |
-
}
|
1562 |
-
|
1563 |
-
/*
|
1564 |
-
* Spawn
|
1565 |
-
*/
|
1566 |
-
acf.addAction('new_field/type=flexible_content', function(flexible){
|
1567 |
-
|
1568 |
-
if(!flexible.has('acfeFlexibleModal'))
|
1569 |
-
return;
|
1570 |
-
|
1571 |
-
// Vars
|
1572 |
-
var $clones = flexible.$clones();
|
1573 |
-
|
1574 |
-
if($clones.length <= 1)
|
1575 |
-
return;
|
1576 |
-
|
1577 |
-
// Remove native ACF Tooltip action
|
1578 |
-
flexible.removeEvents({'click [data-name="add-layout"]': 'onClickAdd'});
|
1579 |
-
|
1580 |
-
// Add ACF Extended Modal action
|
1581 |
-
flexible.addEvents({'click [data-name="add-layout"]': 'acfeModalSelect'});
|
1582 |
-
|
1583 |
-
});
|
1584 |
-
|
1585 |
})(jQuery);
|
1586 |
-
(function($){
|
1587 |
-
|
1588 |
-
if(typeof acf === 'undefined')
|
1589 |
-
return;
|
1590 |
-
|
1591 |
-
/*
|
1592 |
-
* Init
|
1593 |
-
*/
|
1594 |
-
var flexible = acf.getFieldType('flexible_content');
|
1595 |
-
var model = flexible.prototype;
|
1596 |
-
|
1597 |
-
/*
|
1598 |
-
* Actions
|
1599 |
-
*/
|
1600 |
-
model.events['click [data-action="acfe-flexible-modal-edit"]'] = 'acfeModalEdit';
|
1601 |
-
model.acfeModalEdit = function(e, $el){
|
1602 |
-
|
1603 |
-
var flexible = this;
|
1604 |
-
|
1605 |
-
// Layout
|
1606 |
-
var $layout = $el.closest('.layout');
|
1607 |
-
|
1608 |
-
// Modal data
|
1609 |
-
var $modal = $layout.find('> .acfe-modal.-fields');
|
1610 |
-
var $handle = $layout.find('> .acf-fc-layout-handle');
|
1611 |
-
|
1612 |
-
var $layout_order = $handle.find('> .acf-fc-layout-order').outerHTML();
|
1613 |
-
var $layout_title = $handle.find('.acfe-layout-title-text').text();
|
1614 |
-
|
1615 |
-
var close = false;
|
1616 |
-
if(flexible.has('acfeFlexibleCloseButton')){
|
1617 |
-
|
1618 |
-
close = acf.__('Close');
|
1619 |
-
|
1620 |
-
}
|
1621 |
-
|
1622 |
-
// Open modal
|
1623 |
-
new acfe.Popup($modal, {
|
1624 |
-
title: $layout_order + ' ' + $layout_title,
|
1625 |
-
footer: close,
|
1626 |
-
onOpen: function(){
|
1627 |
-
|
1628 |
-
flexible.openLayout($layout);
|
1629 |
-
|
1630 |
-
},
|
1631 |
-
onClose: function(){
|
1632 |
-
|
1633 |
-
flexible.closeLayout($layout);
|
1634 |
-
|
1635 |
-
}
|
1636 |
-
});
|
1637 |
-
|
1638 |
-
};
|
1639 |
-
|
1640 |
-
/*
|
1641 |
-
* Spawn
|
1642 |
-
*/
|
1643 |
-
acf.addAction('new_field/type=flexible_content', function(flexible){
|
1644 |
-
|
1645 |
-
if(flexible.has('acfeFlexibleModalEdition') && (flexible.has('acfeFlexiblePlaceholder') || flexible.has('acfeFlexiblePreview'))){
|
1646 |
-
|
1647 |
-
// Remove Collapse Action
|
1648 |
-
flexible.removeEvents({'click [data-name="collapse-layout"]': 'onClickCollapse'});
|
1649 |
-
|
1650 |
-
// Remove placeholder Collapse Action
|
1651 |
-
flexible.removeEvents({'click .acfe-fc-placeholder': 'onClickCollapse'});
|
1652 |
-
|
1653 |
-
}
|
1654 |
-
|
1655 |
-
});
|
1656 |
-
|
1657 |
})(jQuery);
|
1658 |
-
/*
|
1659 |
-
* Field: reCaptcha Callback
|
1660 |
-
*/
|
1661 |
-
function acfe_recaptcha(){
|
1662 |
-
|
1663 |
-
(function($){
|
1664 |
-
|
1665 |
-
if(typeof acf === 'undefined')
|
1666 |
-
return;
|
1667 |
-
|
1668 |
-
$.each(acf.getFields({type: 'acfe_recaptcha'}), function(){
|
1669 |
-
this.render();
|
1670 |
-
});
|
1671 |
-
|
1672 |
-
})(jQuery);
|
1673 |
-
|
1674 |
-
}
|
1675 |
-
|
1676 |
-
(function($){
|
1677 |
-
|
1678 |
-
if(typeof acf === 'undefined')
|
1679 |
-
return;
|
1680 |
-
|
1681 |
-
/*
|
1682 |
-
* Field: reCaptcha
|
1683 |
-
*/
|
1684 |
-
var reCaptcha = acf.Field.extend({
|
1685 |
-
|
1686 |
-
type: 'acfe_recaptcha',
|
1687 |
-
|
1688 |
-
actions: {
|
1689 |
-
'validation_failure' : 'validationFailure'
|
1690 |
-
},
|
1691 |
-
|
1692 |
-
$control: function(){
|
1693 |
-
return this.$('.acfe-field-recaptcha');
|
1694 |
-
},
|
1695 |
-
|
1696 |
-
$input: function(){
|
1697 |
-
return this.$('input[type="hidden"]');
|
1698 |
-
},
|
1699 |
-
|
1700 |
-
$selector: function(){
|
1701 |
-
return this.$control().find('> div');
|
1702 |
-
},
|
1703 |
-
|
1704 |
-
selector: function(){
|
1705 |
-
return this.$selector()[0];
|
1706 |
-
},
|
1707 |
-
|
1708 |
-
version: function(){
|
1709 |
-
return this.get('version');
|
1710 |
-
},
|
1711 |
-
|
1712 |
-
render: function(){
|
1713 |
-
|
1714 |
-
var field = this;
|
1715 |
-
|
1716 |
-
if(this.version() === 'v2'){
|
1717 |
-
|
1718 |
-
this.recaptcha = grecaptcha.render(field.selector(), {
|
1719 |
-
'sitekey': field.$control().data('site-key'),
|
1720 |
-
'theme': field.$control().data('theme'),
|
1721 |
-
'size': field.$control().data('size'),
|
1722 |
-
|
1723 |
-
|
1724 |
-
'callback': function(response){
|
1725 |
-
|
1726 |
-
field.$input().val(response).change();
|
1727 |
-
field.$input().closest('.acf-input').find('> .acf-notice.-error').hide();
|
1728 |
-
|
1729 |
-
},
|
1730 |
-
|
1731 |
-
'error-callback': function(){
|
1732 |
-
|
1733 |
-
field.$input().val('error').change();
|
1734 |
-
|
1735 |
-
},
|
1736 |
-
|
1737 |
-
'expired-callback': function(){
|
1738 |
-
|
1739 |
-
field.$input().val('expired').change();
|
1740 |
-
|
1741 |
-
}
|
1742 |
-
});
|
1743 |
-
|
1744 |
-
}
|
1745 |
-
|
1746 |
-
else if(this.version() === 'v3'){
|
1747 |
-
|
1748 |
-
grecaptcha.ready(function(){
|
1749 |
-
grecaptcha.execute(field.$control().data('site-key'), {action: 'homepage'}).then(function(response){
|
1750 |
-
|
1751 |
-
field.$input().val(response).change();
|
1752 |
-
field.$input().closest('.acf-input').find('> .acf-notice.-error').hide();
|
1753 |
-
|
1754 |
-
});
|
1755 |
-
});
|
1756 |
-
|
1757 |
-
}
|
1758 |
-
|
1759 |
-
},
|
1760 |
-
|
1761 |
-
validationFailure: function($form){
|
1762 |
-
|
1763 |
-
if(this.version() === 'v2'){
|
1764 |
-
|
1765 |
-
grecaptcha.reset(this.recaptcha);
|
1766 |
-
|
1767 |
-
}
|
1768 |
-
|
1769 |
-
}
|
1770 |
-
|
1771 |
-
});
|
1772 |
-
|
1773 |
-
acf.registerFieldType(reCaptcha);
|
1774 |
-
|
1775 |
-
/*
|
1776 |
-
* Field: Code Editor
|
1777 |
-
*/
|
1778 |
-
var CodeEditor = acf.Field.extend({
|
1779 |
-
|
1780 |
-
wait: 'ready',
|
1781 |
-
|
1782 |
-
type: 'acfe_code_editor',
|
1783 |
-
|
1784 |
-
events: {
|
1785 |
-
'showField': 'onShow',
|
1786 |
-
},
|
1787 |
-
|
1788 |
-
$control: function(){
|
1789 |
-
|
1790 |
-
return this.$el.find('> .acf-input > .acf-input-wrap');
|
1791 |
-
|
1792 |
-
},
|
1793 |
-
|
1794 |
-
$input: function(){
|
1795 |
-
|
1796 |
-
return this.$el.find('> .acf-input > .acf-input-wrap > textarea');
|
1797 |
-
|
1798 |
-
},
|
1799 |
-
|
1800 |
-
input: function(){
|
1801 |
-
|
1802 |
-
return this.$input()[0];
|
1803 |
-
|
1804 |
-
},
|
1805 |
-
|
1806 |
-
rows: function(){
|
1807 |
-
|
1808 |
-
return this.$input().attr('rows');
|
1809 |
-
|
1810 |
-
},
|
1811 |
-
|
1812 |
-
initialize: function(){
|
1813 |
-
|
1814 |
-
this.rows = this.$control().data('rows');
|
1815 |
-
this.max_rows = this.$control().data('max-rows');
|
1816 |
-
|
1817 |
-
this.mode = this.$control().data('mode');
|
1818 |
-
this.lines = this.$control().data('lines');
|
1819 |
-
this.indentUnit = this.$control().data('indent-unit');
|
1820 |
-
|
1821 |
-
var codeEditor = [];
|
1822 |
-
|
1823 |
-
// Default WP settings
|
1824 |
-
var wpCodeMirror = wp.codeEditor.defaultSettings.codemirror;
|
1825 |
-
|
1826 |
-
// Field settings
|
1827 |
-
var CodeMirror = {
|
1828 |
-
lineNumbers: this.lines,
|
1829 |
-
lineWrapping: true,
|
1830 |
-
styleActiveLine: false,
|
1831 |
-
continueComments: true,
|
1832 |
-
indentUnit: this.indentUnit,
|
1833 |
-
tabSize: 1,
|
1834 |
-
indentWithTabs: true,
|
1835 |
-
mode: this.mode,
|
1836 |
-
extraKeys: {
|
1837 |
-
Tab: function(cm){
|
1838 |
-
cm.execCommand("indentMore")
|
1839 |
-
},
|
1840 |
-
"Shift-Tab": function(cm){
|
1841 |
-
cm.execCommand("indentLess")
|
1842 |
-
},
|
1843 |
-
},
|
1844 |
-
};
|
1845 |
-
|
1846 |
-
// Merge settings
|
1847 |
-
var codeMirror = jQuery.extend(wpCodeMirror, CodeMirror);
|
1848 |
-
|
1849 |
-
// Push CodeMirror settings to codemirror property
|
1850 |
-
codeEditor.codemirror = codeMirror;
|
1851 |
-
|
1852 |
-
// Init WP Code Editor
|
1853 |
-
this.editor = wp.codeEditor.initialize(this.input(), codeEditor);
|
1854 |
-
|
1855 |
-
if(this.rows || this.max_rows){
|
1856 |
-
|
1857 |
-
if(this.rows){
|
1858 |
-
|
1859 |
-
this.editor.codemirror.getScrollerElement().style.minHeight = this.rows * 18.5 + 'px';
|
1860 |
-
|
1861 |
-
}
|
1862 |
-
|
1863 |
-
if(this.max_rows){
|
1864 |
-
|
1865 |
-
this.editor.codemirror.getScrollerElement().style.maxHeight = this.max_rows * 18.5 + 'px';
|
1866 |
-
|
1867 |
-
}
|
1868 |
-
|
1869 |
-
this.editor.codemirror.refresh();
|
1870 |
-
|
1871 |
-
}
|
1872 |
-
|
1873 |
-
field = this;
|
1874 |
-
|
1875 |
-
this.editor.codemirror.on('change', function(){
|
1876 |
-
|
1877 |
-
field.editor.codemirror.save();
|
1878 |
-
field.$input().change();
|
1879 |
-
|
1880 |
-
});
|
1881 |
-
|
1882 |
-
},
|
1883 |
-
|
1884 |
-
onShow: function(){
|
1885 |
-
|
1886 |
-
if(this.editor.codemirror){
|
1887 |
-
|
1888 |
-
this.editor.codemirror.refresh();
|
1889 |
-
|
1890 |
-
}
|
1891 |
-
|
1892 |
-
},
|
1893 |
-
|
1894 |
-
});
|
1895 |
-
|
1896 |
-
acf.registerFieldType(CodeEditor);
|
1897 |
-
|
1898 |
-
/*
|
1899 |
-
* Field: Textarea
|
1900 |
-
*/
|
1901 |
-
var Textarea = acf.Field.extend({
|
1902 |
-
|
1903 |
-
type: 'textarea',
|
1904 |
-
|
1905 |
-
events: {
|
1906 |
-
'keydown textarea': 'onInput',
|
1907 |
-
},
|
1908 |
-
|
1909 |
-
onInput: function(e, $el){
|
1910 |
-
|
1911 |
-
if(!this.has('acfeTextareaCode'))
|
1912 |
-
return;
|
1913 |
-
|
1914 |
-
if(e.keyCode !== 9)
|
1915 |
-
return;
|
1916 |
-
|
1917 |
-
e.preventDefault();
|
1918 |
-
|
1919 |
-
var input = this.$el.find('textarea')[0];
|
1920 |
-
|
1921 |
-
var s = input.selectionStart;
|
1922 |
-
|
1923 |
-
this.$el.find('textarea').val(function(i, v){
|
1924 |
-
|
1925 |
-
return v.substring(0, s) + " " + v.substring(input.selectionEnd)
|
1926 |
-
|
1927 |
-
});
|
1928 |
-
|
1929 |
-
input.selectionEnd = s + 4;
|
1930 |
-
|
1931 |
-
},
|
1932 |
-
|
1933 |
-
});
|
1934 |
-
|
1935 |
-
acf.registerFieldType(Textarea);
|
1936 |
-
|
1937 |
-
/*
|
1938 |
-
* Field: Slug
|
1939 |
-
*/
|
1940 |
-
var ACFE_Slug = acf.Field.extend({
|
1941 |
-
|
1942 |
-
type: 'acfe_slug',
|
1943 |
-
|
1944 |
-
events: {
|
1945 |
-
'input input': 'onInput',
|
1946 |
-
'focusout input': 'onFocusOut',
|
1947 |
-
},
|
1948 |
-
|
1949 |
-
onInput: function(e, $el){
|
1950 |
-
|
1951 |
-
$el.val($el.val().toLowerCase()
|
1952 |
-
.replace(/\s+/g, '-') // Replace spaces with -
|
1953 |
-
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
|
1954 |
-
.replace(/\-\-+/g, '-') // Replace multiple - with single -
|
1955 |
-
.replace(/\_\_+/g, '_') // Replace multiple _ with single _
|
1956 |
-
.replace(/^-+/, '')); // Trim - from start of text
|
1957 |
-
|
1958 |
-
},
|
1959 |
-
|
1960 |
-
onFocusOut: function(e, $el){
|
1961 |
-
|
1962 |
-
$el.val($el.val().toLowerCase()
|
1963 |
-
.replace(/-+$/, '') // Trim - from end of text
|
1964 |
-
.replace(/_+$/, '')); // Trim _ from end of text
|
1965 |
-
|
1966 |
-
},
|
1967 |
-
|
1968 |
-
});
|
1969 |
-
|
1970 |
-
acf.registerFieldType(ACFE_Slug);
|
1971 |
-
|
1972 |
-
/*
|
1973 |
-
* Field: Button
|
1974 |
-
*/
|
1975 |
-
var ACFE_Button = acf.Field.extend({
|
1976 |
-
|
1977 |
-
type: 'acfe_button',
|
1978 |
-
|
1979 |
-
events: {
|
1980 |
-
'click input': 'onClick',
|
1981 |
-
'click button': 'onClick',
|
1982 |
-
},
|
1983 |
-
|
1984 |
-
$input: function(){
|
1985 |
-
|
1986 |
-
if(this.$('input').length){
|
1987 |
-
|
1988 |
-
return this.$('input');
|
1989 |
-
|
1990 |
-
}else if(this.$('button').length){
|
1991 |
-
|
1992 |
-
return this.$('button');
|
1993 |
-
|
1994 |
-
}
|
1995 |
-
|
1996 |
-
},
|
1997 |
-
|
1998 |
-
initialize: function(){
|
1999 |
-
|
2000 |
-
// vars
|
2001 |
-
var $button = this.$input();
|
2002 |
-
|
2003 |
-
// inherit data
|
2004 |
-
this.inherit($button);
|
2005 |
-
|
2006 |
-
},
|
2007 |
-
|
2008 |
-
onClick: function(e, $el){
|
2009 |
-
|
2010 |
-
if(this.get('ajax')){
|
2011 |
-
|
2012 |
-
e.preventDefault();
|
2013 |
-
|
2014 |
-
// serialize form data
|
2015 |
-
var data = {
|
2016 |
-
action: 'acfe/fields/button',
|
2017 |
-
field_name: this.get('name'),
|
2018 |
-
field_key: this.get('key')
|
2019 |
-
};
|
2020 |
-
|
2021 |
-
// Deprecated
|
2022 |
-
acf.doAction('acfe/fields/button/before_ajax', this.$el, data);
|
2023 |
-
|
2024 |
-
// Actions
|
2025 |
-
acf.doAction('acfe/fields/button/before', this.$el, data);
|
2026 |
-
acf.doAction('acfe/fields/button/before/key=' + this.get('key'), this.$el, data);
|
2027 |
-
acf.doAction('acfe/fields/button/before/name=' + this.get('name'), this.$el, data);
|
2028 |
-
|
2029 |
-
// ajax
|
2030 |
-
$.ajax({
|
2031 |
-
url: acf.get('ajaxurl'),
|
2032 |
-
data: acf.prepareForAjax(data),
|
2033 |
-
type: 'post',
|
2034 |
-
dataType: 'json',
|
2035 |
-
context: this,
|
2036 |
-
|
2037 |
-
// Success
|
2038 |
-
success: function(response){
|
2039 |
-
|
2040 |
-
// Deprecated
|
2041 |
-
acf.doAction('acfe/fields/button/ajax_success', response, this.$el, data);
|
2042 |
-
|
2043 |
-
// Actions
|
2044 |
-
acf.doAction('acfe/fields/button/success', response, this.$el, data);
|
2045 |
-
acf.doAction('acfe/fields/button/success/key=' + this.get('key'), response, this.$el, data);
|
2046 |
-
acf.doAction('acfe/fields/button/success/name=' + this.get('name'), response, this.$el, data);
|
2047 |
-
|
2048 |
-
},
|
2049 |
-
|
2050 |
-
// Complete
|
2051 |
-
complete: function(xhr){
|
2052 |
-
|
2053 |
-
var response = xhr.responseText;
|
2054 |
-
|
2055 |
-
// Actions
|
2056 |
-
acf.doAction('acfe/fields/button/complete', response, this.$el, data);
|
2057 |
-
acf.doAction('acfe/fields/button/complete/key=' + this.get('key'), response, this.$el, data);
|
2058 |
-
acf.doAction('acfe/fields/button/complete/name=' + this.get('name'), response, this.$el, data);
|
2059 |
-
|
2060 |
-
}
|
2061 |
-
|
2062 |
-
|
2063 |
-
});
|
2064 |
-
|
2065 |
-
}
|
2066 |
-
|
2067 |
-
}
|
2068 |
-
|
2069 |
-
});
|
2070 |
-
|
2071 |
-
acf.registerFieldType(ACFE_Button);
|
2072 |
-
|
2073 |
-
/*
|
2074 |
-
* Field: Advanced Link
|
2075 |
-
*/
|
2076 |
-
var ACFE_Advanced_Link = acf.Field.extend({
|
2077 |
-
|
2078 |
-
type: 'acfe_advanced_link',
|
2079 |
-
|
2080 |
-
events: {
|
2081 |
-
'click a[data-name="add"]': 'onClickEdit',
|
2082 |
-
'click a[data-name="edit"]': 'onClickEdit',
|
2083 |
-
'click a[data-name="remove"]': 'onClickRemove',
|
2084 |
-
},
|
2085 |
-
|
2086 |
-
$control: function(){
|
2087 |
-
return this.$('.acf-link');
|
2088 |
-
},
|
2089 |
-
|
2090 |
-
initialize: function(){
|
2091 |
-
// ...
|
2092 |
-
},
|
2093 |
-
|
2094 |
-
getValue: function(){
|
2095 |
-
|
2096 |
-
// return
|
2097 |
-
var data = {
|
2098 |
-
type: this.$('.input-type :checked').val(),
|
2099 |
-
title: this.$('.input-title').val(),
|
2100 |
-
url: this.$('.input-url').val(),
|
2101 |
-
post: this.$('.input-post :selected').text(),
|
2102 |
-
term: this.$('.input-term :selected').text(),
|
2103 |
-
target: this.$('.input-target').is(':checked')
|
2104 |
-
};
|
2105 |
-
|
2106 |
-
if(data.type === 'post'){
|
2107 |
-
|
2108 |
-
data.url = data.post;
|
2109 |
-
|
2110 |
-
}else if(data.type === 'term'){
|
2111 |
-
|
2112 |
-
data.url = data.term;
|
2113 |
-
|
2114 |
-
}
|
2115 |
-
|
2116 |
-
return data;
|
2117 |
-
|
2118 |
-
},
|
2119 |
-
|
2120 |
-
setValue: function( val ){
|
2121 |
-
|
2122 |
-
// default
|
2123 |
-
val = acf.parseArgs(val, {
|
2124 |
-
remove: false,
|
2125 |
-
title: '',
|
2126 |
-
url: '',
|
2127 |
-
target: false
|
2128 |
-
});
|
2129 |
-
|
2130 |
-
// vars
|
2131 |
-
var $div = this.$control();
|
2132 |
-
|
2133 |
-
// remove class
|
2134 |
-
$div.removeClass('-value -external');
|
2135 |
-
|
2136 |
-
// add class
|
2137 |
-
if(val.url)
|
2138 |
-
$div.addClass('-value');
|
2139 |
-
|
2140 |
-
if(val.target)
|
2141 |
-
$div.addClass('-external');
|
2142 |
-
|
2143 |
-
// update text
|
2144 |
-
this.$('.link-title').html( val.title );
|
2145 |
-
this.$('.link-url').attr('href', val.url).html( val.url );
|
2146 |
-
|
2147 |
-
// remove inputs data
|
2148 |
-
if(val.remove){
|
2149 |
-
|
2150 |
-
this.$('.input-type :checked').prop('checked', false);
|
2151 |
-
this.$('.input-type [value="url"]').prop('checked', true).trigger('change');
|
2152 |
-
this.$('.input-title').val('');
|
2153 |
-
this.$('.input-target').prop('checked', false);
|
2154 |
-
this.$('.input-url').val('').trigger('change');
|
2155 |
-
this.$('.input-post').val('').trigger('change');
|
2156 |
-
this.$('.input-term').val('').trigger('change');
|
2157 |
-
|
2158 |
-
}
|
2159 |
-
|
2160 |
-
},
|
2161 |
-
|
2162 |
-
onClickEdit: function(e, $el){
|
2163 |
-
|
2164 |
-
var $modal = $el.closest('.acf-input').find('.acfe-modal');
|
2165 |
-
|
2166 |
-
var title = $modal.attr('data-modal-title');
|
2167 |
-
|
2168 |
-
var model = this;
|
2169 |
-
|
2170 |
-
new acfe.Popup($modal, {
|
2171 |
-
title: title,
|
2172 |
-
size: 'medium',
|
2173 |
-
footer: acf.__('Close'),
|
2174 |
-
onClose: function(){
|
2175 |
-
model.onChange();
|
2176 |
-
}
|
2177 |
-
});
|
2178 |
-
|
2179 |
-
},
|
2180 |
-
|
2181 |
-
onClickRemove: function( e, $el ){
|
2182 |
-
|
2183 |
-
this.setValue({
|
2184 |
-
remove: true
|
2185 |
-
});
|
2186 |
-
|
2187 |
-
},
|
2188 |
-
|
2189 |
-
onChange: function( e, $el ){
|
2190 |
-
|
2191 |
-
// get the changed value
|
2192 |
-
var val = this.getValue();
|
2193 |
-
|
2194 |
-
// update inputs
|
2195 |
-
this.setValue(val);
|
2196 |
-
|
2197 |
-
},
|
2198 |
-
|
2199 |
-
});
|
2200 |
-
|
2201 |
-
acf.registerFieldType(ACFE_Advanced_Link);
|
2202 |
-
|
2203 |
-
/*
|
2204 |
-
* Field: Advanced Link Manager
|
2205 |
-
*/
|
2206 |
-
new acf.Model({
|
2207 |
-
|
2208 |
-
actions: {
|
2209 |
-
'invalid_field': 'invalidField',
|
2210 |
-
},
|
2211 |
-
|
2212 |
-
filters: {
|
2213 |
-
'select2_ajax_data/type=post_object': 'ajaxField',
|
2214 |
-
},
|
2215 |
-
|
2216 |
-
invalidField: function(field){
|
2217 |
-
|
2218 |
-
var $advanced_link = field.$el.closest('.acf-field-acfe-advanced-link').not('.acf-error');
|
2219 |
-
|
2220 |
-
if($advanced_link.length){
|
2221 |
-
|
2222 |
-
var advanced_link_field = acf.getInstance($advanced_link);
|
2223 |
-
|
2224 |
-
advanced_link_field.showError(field.notice.get('text'));
|
2225 |
-
|
2226 |
-
}
|
2227 |
-
|
2228 |
-
},
|
2229 |
-
|
2230 |
-
ajaxField: function(ajaxData, data, $el, field, select){
|
2231 |
-
|
2232 |
-
if(field.get('key') !== 'post')
|
2233 |
-
return ajaxData;
|
2234 |
-
|
2235 |
-
var advanced_link = acf.getInstance($el.closest('.acf-field-acfe-advanced-link'));
|
2236 |
-
|
2237 |
-
if(advanced_link){
|
2238 |
-
|
2239 |
-
ajaxData.field_key = advanced_link.get('key');
|
2240 |
-
|
2241 |
-
}
|
2242 |
-
|
2243 |
-
return ajaxData;
|
2244 |
-
|
2245 |
-
},
|
2246 |
-
|
2247 |
-
});
|
2248 |
-
|
2249 |
-
/*
|
2250 |
-
* Field: Group
|
2251 |
-
*/
|
2252 |
-
var Group = acf.Field.extend({
|
2253 |
-
|
2254 |
-
wait: false,
|
2255 |
-
|
2256 |
-
type: 'group',
|
2257 |
-
|
2258 |
-
events: {
|
2259 |
-
'click [data-name="edit"]': 'onClick',
|
2260 |
-
'duplicateField': 'onDuplicate'
|
2261 |
-
},
|
2262 |
-
|
2263 |
-
initialize: function(){
|
2264 |
-
|
2265 |
-
if(this.has('acfeGroupModal')){
|
2266 |
-
|
2267 |
-
var edit = this.get('acfeGroupModalButton');
|
2268 |
-
|
2269 |
-
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>');
|
2270 |
-
this.$el.find('> .acf-input').append('<a data-name="edit" class="acf-button button" href="#">' + edit + '</a>');
|
2271 |
-
|
2272 |
-
}
|
2273 |
-
|
2274 |
-
},
|
2275 |
-
|
2276 |
-
onClick: function(e, $el){
|
2277 |
-
|
2278 |
-
var title = this.$el.find('> .acf-label').text().trim();
|
2279 |
-
var $modal = this.$el.find('> .acf-input > .acfe-modal');
|
2280 |
-
|
2281 |
-
// Title
|
2282 |
-
if(!title.length){
|
2283 |
-
|
2284 |
-
title = this.get('acfeGroupModalButton');
|
2285 |
-
|
2286 |
-
}
|
2287 |
-
|
2288 |
-
// Close
|
2289 |
-
var close = false;
|
2290 |
-
|
2291 |
-
if(this.has('acfeGroupModalClose')){
|
2292 |
-
|
2293 |
-
close = acf.__('Close');
|
2294 |
-
|
2295 |
-
}
|
2296 |
-
|
2297 |
-
// Size
|
2298 |
-
var size = 'large';
|
2299 |
-
|
2300 |
-
if(this.has('acfeGroupModalSize')){
|
2301 |
-
|
2302 |
-
size = this.get('acfeGroupModalSize');
|
2303 |
-
|
2304 |
-
}
|
2305 |
-
|
2306 |
-
// Open modal
|
2307 |
-
new acfe.Popup($modal, {
|
2308 |
-
title: title,
|
2309 |
-
size: size,
|
2310 |
-
footer: close
|
2311 |
-
});
|
2312 |
-
|
2313 |
-
},
|
2314 |
-
|
2315 |
-
onDuplicate: function(e, $el, $duplicate){
|
2316 |
-
$duplicate.find('a[data-name="edit"]').remove();
|
2317 |
-
}
|
2318 |
-
|
2319 |
-
});
|
2320 |
-
|
2321 |
-
acf.registerFieldType(Group);
|
2322 |
-
|
2323 |
-
/*
|
2324 |
-
* Field: Clone
|
2325 |
-
*/
|
2326 |
-
var Clone = acf.Field.extend({
|
2327 |
-
|
2328 |
-
wait: false,
|
2329 |
-
|
2330 |
-
type: 'clone',
|
2331 |
-
|
2332 |
-
events: {
|
2333 |
-
'click [data-name="edit"]': 'onClick',
|
2334 |
-
'duplicateField': 'onDuplicate'
|
2335 |
-
},
|
2336 |
-
|
2337 |
-
initialize: function(){
|
2338 |
-
|
2339 |
-
if(this.has('acfeCloneModal')){
|
2340 |
-
|
2341 |
-
var edit = this.get('acfeCloneModalButton');
|
2342 |
-
|
2343 |
-
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>');
|
2344 |
-
this.$el.find('> .acf-input').append('<a data-name="edit" class="acf-button button" href="#">' + edit + '</a>');
|
2345 |
-
|
2346 |
-
}
|
2347 |
-
|
2348 |
-
},
|
2349 |
-
|
2350 |
-
onClick: function(e, $el){
|
2351 |
-
|
2352 |
-
var title = this.$el.find('> .acf-label').text().trim();
|
2353 |
-
var $modal = this.$el.find('> .acf-input > .acfe-modal');
|
2354 |
-
|
2355 |
-
|
2356 |
-
// Title
|
2357 |
-
if(!title.length){
|
2358 |
-
|
2359 |
-
title = this.get('acfeCloneModalButton');
|
2360 |
-
|
2361 |
-
}
|
2362 |
-
|
2363 |
-
// Close
|
2364 |
-
var close = false;
|
2365 |
-
|
2366 |
-
if(this.has('acfeCloneModalClose')){
|
2367 |
-
|
2368 |
-
close = acf.__('Close');
|
2369 |
-
|
2370 |
-
}
|
2371 |
-
|
2372 |
-
// Size
|
2373 |
-
var size = 'large';
|
2374 |
-
|
2375 |
-
if(this.has('acfeCloneModalSize')){
|
2376 |
-
|
2377 |
-
size = this.get('acfeCloneModalSize');
|
2378 |
-
|
2379 |
-
}
|
2380 |
-
|
2381 |
-
// Open modal
|
2382 |
-
new acfe.Popup($modal, {
|
2383 |
-
title: title,
|
2384 |
-
size: size,
|
2385 |
-
footer: close
|
2386 |
-
});
|
2387 |
-
|
2388 |
-
},
|
2389 |
-
|
2390 |
-
onDuplicate: function(e, $el, $duplicate){
|
2391 |
-
$duplicate.find('a[data-name="edit"]').remove();
|
2392 |
-
}
|
2393 |
-
|
2394 |
-
});
|
2395 |
-
|
2396 |
-
acf.registerFieldType(Clone);
|
2397 |
-
|
2398 |
-
/*
|
2399 |
-
* Field: Column
|
2400 |
-
*/
|
2401 |
-
var Column = acf.Field.extend({
|
2402 |
-
|
2403 |
-
wait: 'new_field',
|
2404 |
-
|
2405 |
-
type: 'acfe_column',
|
2406 |
-
|
2407 |
-
$control: function(){
|
2408 |
-
return this.$('.acf-fields:first');
|
2409 |
-
},
|
2410 |
-
|
2411 |
-
initialize: function(){
|
2412 |
-
|
2413 |
-
if(this.$el.is('td')){
|
2414 |
-
|
2415 |
-
var $table = this.$el.closest('.acf-table').find('th[data-type="acfe_column"]').remove();
|
2416 |
-
this.remove();
|
2417 |
-
|
2418 |
-
}
|
2419 |
-
|
2420 |
-
if(this.get('endpoint')){
|
2421 |
-
|
2422 |
-
this.$el.find('> .acf-label').remove();
|
2423 |
-
this.$el.find('> .acf-input').remove();
|
2424 |
-
|
2425 |
-
return;
|
2426 |
-
|
2427 |
-
}
|
2428 |
-
|
2429 |
-
var $field = this.$el;
|
2430 |
-
var $label = this.$el.find('> .acf-label');
|
2431 |
-
var $input = this.$inputWrap();
|
2432 |
-
var $wrap = this.$control();
|
2433 |
-
|
2434 |
-
$label.remove();
|
2435 |
-
|
2436 |
-
var $parent = $field.parent();
|
2437 |
-
$wrap.addClass($parent.hasClass('-left') ? '-left' : '');
|
2438 |
-
$wrap.addClass($parent.hasClass('-clear') ? '-clear' : '');
|
2439 |
-
|
2440 |
-
$wrap.append($field.nextUntil('.acf-field-acfe-column', '.acf-field'));
|
2441 |
-
|
2442 |
-
}
|
2443 |
-
|
2444 |
-
});
|
2445 |
-
|
2446 |
-
acf.registerFieldType(Column);
|
2447 |
-
|
2448 |
-
/*
|
2449 |
-
* Field: Select
|
2450 |
-
*/
|
2451 |
-
new acf.Model({
|
2452 |
-
|
2453 |
-
actions: {
|
2454 |
-
'new_field/type=select': 'newField',
|
2455 |
-
},
|
2456 |
-
|
2457 |
-
newField: function(field){
|
2458 |
-
|
2459 |
-
field.inherit(field.$input());
|
2460 |
-
|
2461 |
-
// Remove "- -" characters from placeholder
|
2462 |
-
if(!field.get('ui') && field.get('allow_null')){
|
2463 |
-
|
2464 |
-
field.$input().find('option').each(function(i, option){
|
2465 |
-
|
2466 |
-
if(option.value)
|
2467 |
-
return;
|
2468 |
-
|
2469 |
-
if(!option.text.startsWith('- ') || !option.text.endsWith(' -'))
|
2470 |
-
return;
|
2471 |
-
|
2472 |
-
option.text = option.text.substring(2);
|
2473 |
-
option.text = option.text.substring(0, option.text.length - 2);
|
2474 |
-
|
2475 |
-
});
|
2476 |
-
|
2477 |
-
}
|
2478 |
-
|
2479 |
-
if(field.has('acfePrepend') || field.has('acfeAppend')){
|
2480 |
-
|
2481 |
-
if(!field.$input().parent('.acf-input-wrap').length){
|
2482 |
-
|
2483 |
-
field.$input().wrapAll('<div class="acf-input-wrap"></div>');
|
2484 |
-
|
2485 |
-
if(field.get('ui')){
|
2486 |
-
|
2487 |
-
field.$('.acf-input-wrap:first').append(field.$('.select2'));
|
2488 |
-
|
2489 |
-
}
|
2490 |
-
|
2491 |
-
if(field.has('acfePrepend')){
|
2492 |
-
|
2493 |
-
field.$('.acf-input-wrap:first').before('<div class="acf-input-prepend">' + field.get('acfePrepend') + '</div>');
|
2494 |
-
field.$input().addClass('acf-is-prepended');
|
2495 |
-
|
2496 |
-
}
|
2497 |
-
|
2498 |
-
if(field.has('acfeAppend')){
|
2499 |
-
|
2500 |
-
field.$('.acf-input-wrap:first').before('<div class="acf-input-append">' + field.get('acfeAppend') + '</div>');
|
2501 |
-
field.$input().addClass('acf-is-appended');
|
2502 |
-
|
2503 |
-
}
|
2504 |
-
|
2505 |
-
}
|
2506 |
-
|
2507 |
-
}
|
2508 |
-
|
2509 |
-
}
|
2510 |
-
|
2511 |
-
});
|
2512 |
-
|
2513 |
-
/*
|
2514 |
-
* Field: Select2
|
2515 |
-
*/
|
2516 |
-
new acf.Model({
|
2517 |
-
|
2518 |
-
actions:{
|
2519 |
-
'select2_init': 'select2Init',
|
2520 |
-
},
|
2521 |
-
|
2522 |
-
filters: {
|
2523 |
-
'select2_args': 'select2Args',
|
2524 |
-
'select2_ajax_data': 'select2Ajax',
|
2525 |
-
},
|
2526 |
-
|
2527 |
-
select2Init: function($select, options, data, field, instance){
|
2528 |
-
|
2529 |
-
// Search Placeholder
|
2530 |
-
if(field.get('acfeSearchPlaceholder')){
|
2531 |
-
|
2532 |
-
var search_placeholder = field.get('acfeSearchPlaceholder');
|
2533 |
-
|
2534 |
-
$select.on('select2:open', function(e){
|
2535 |
-
|
2536 |
-
if(field.get('multiple')){
|
2537 |
-
|
2538 |
-
if(!$select.val()){
|
2539 |
-
|
2540 |
-
field.$('.select2-search__field').attr('placeholder', search_placeholder);
|
2541 |
-
|
2542 |
-
}
|
2543 |
-
|
2544 |
-
}else{
|
2545 |
-
|
2546 |
-
$('.select2-search.select2-search--dropdown > .select2-search__field').attr('placeholder', search_placeholder);
|
2547 |
-
|
2548 |
-
}
|
2549 |
-
|
2550 |
-
});
|
2551 |
-
|
2552 |
-
if(field.get('multiple')){
|
2553 |
-
|
2554 |
-
$select.on('select2:close', function(e){
|
2555 |
-
|
2556 |
-
if(!$select.val()){
|
2557 |
-
|
2558 |
-
field.$('.select2-search__field').attr('placeholder', field.get('placeholder'));
|
2559 |
-
|
2560 |
-
}
|
2561 |
-
|
2562 |
-
});
|
2563 |
-
|
2564 |
-
}
|
2565 |
-
|
2566 |
-
}
|
2567 |
-
|
2568 |
-
acf.doAction('select2_init/type=' + field.get('type'), $select, options, data, field, instance);
|
2569 |
-
acf.doAction('select2_init/name=' + field.get('name'), $select, options, data, field, instance);
|
2570 |
-
acf.doAction('select2_init/key=' + field.get('key'), $select, options, data, field, instance);
|
2571 |
-
|
2572 |
-
},
|
2573 |
-
|
2574 |
-
select2Args: function(options, $select, data, field, instance){
|
2575 |
-
|
2576 |
-
// Allow Custom tags
|
2577 |
-
if(field.get('acfeAllowCustom')){
|
2578 |
-
|
2579 |
-
options.tags = true;
|
2580 |
-
|
2581 |
-
options.createTag = function(params){
|
2582 |
-
|
2583 |
-
var term = $.trim(params.term);
|
2584 |
-
|
2585 |
-
if(term === '')
|
2586 |
-
return null;
|
2587 |
-
|
2588 |
-
var optionsMatch = false;
|
2589 |
-
|
2590 |
-
this.$element.find('option').each(function(){
|
2591 |
-
|
2592 |
-
if(this.value.toLowerCase() !== term.toLowerCase())
|
2593 |
-
return;
|
2594 |
-
|
2595 |
-
optionsMatch = true;
|
2596 |
-
return false;
|
2597 |
-
|
2598 |
-
});
|
2599 |
-
|
2600 |
-
if(optionsMatch)
|
2601 |
-
return null;
|
2602 |
-
|
2603 |
-
return {
|
2604 |
-
id: term,
|
2605 |
-
text: term
|
2606 |
-
};
|
2607 |
-
|
2608 |
-
};
|
2609 |
-
|
2610 |
-
|
2611 |
-
options.insertTag = function(data, tag){
|
2612 |
-
|
2613 |
-
var found = false;
|
2614 |
-
|
2615 |
-
$.each(data, function(){
|
2616 |
-
|
2617 |
-
if($.trim(tag.text).toUpperCase() !== $.trim(this.text).toUpperCase())
|
2618 |
-
return;
|
2619 |
-
|
2620 |
-
found = true;
|
2621 |
-
return false;
|
2622 |
-
|
2623 |
-
});
|
2624 |
-
|
2625 |
-
if(!found)
|
2626 |
-
data.unshift(tag);
|
2627 |
-
|
2628 |
-
};
|
2629 |
-
|
2630 |
-
}
|
2631 |
-
|
2632 |
-
options = acf.applyFilters('select2_args/type=' + field.get('type'), options, $select, data, field, instance);
|
2633 |
-
options = acf.applyFilters('select2_args/name=' + field.get('name'), options, $select, data, field, instance);
|
2634 |
-
options = acf.applyFilters('select2_args/key=' + field.get('key'), options, $select, data, field, instance);
|
2635 |
-
|
2636 |
-
return options;
|
2637 |
-
|
2638 |
-
},
|
2639 |
-
|
2640 |
-
select2Ajax: function(ajaxData, data, $el, field, instance){
|
2641 |
-
|
2642 |
-
ajaxData = acf.applyFilters('select2_ajax_data/type=' + field.get('type'), ajaxData, data, $el, field, instance);
|
2643 |
-
ajaxData = acf.applyFilters('select2_ajax_data/name=' + field.get('name'), ajaxData, data, $el, field, instance);
|
2644 |
-
ajaxData = acf.applyFilters('select2_ajax_data/key=' + field.get('key'), ajaxData, data, $el, field, instance);
|
2645 |
-
|
2646 |
-
if(ajaxData.action){
|
2647 |
-
|
2648 |
-
ajaxData = acf.applyFilters('select2_ajax_data/action=' + ajaxData.action, ajaxData, data, $el, field, instance);
|
2649 |
-
|
2650 |
-
}
|
2651 |
-
|
2652 |
-
return ajaxData;
|
2653 |
-
|
2654 |
-
}
|
2655 |
-
|
2656 |
-
});
|
2657 |
-
|
2658 |
-
/*
|
2659 |
-
* Field: Tab
|
2660 |
-
*/
|
2661 |
-
new acf.Model({
|
2662 |
-
|
2663 |
-
actions: {
|
2664 |
-
'prepare_field/type=tab': 'prepareField',
|
2665 |
-
},
|
2666 |
-
|
2667 |
-
prepareField: function(field){
|
2668 |
-
|
2669 |
-
if(!field.has('noPreference'))
|
2670 |
-
return;
|
2671 |
-
|
2672 |
-
var $tabs = field.findTabs();
|
2673 |
-
var tabs = acf.getInstances($tabs);
|
2674 |
-
var key = field.get('key');
|
2675 |
-
|
2676 |
-
if(tabs.length){
|
2677 |
-
|
2678 |
-
var preference = acf.getPreference('this.tabs');
|
2679 |
-
|
2680 |
-
if(!preference)
|
2681 |
-
return;
|
2682 |
-
|
2683 |
-
$.each(tabs, function(i, group){
|
2684 |
-
|
2685 |
-
var groupIndex = group.get('index');
|
2686 |
-
|
2687 |
-
if(group.data.key !== key)
|
2688 |
-
return;
|
2689 |
-
|
2690 |
-
preference[groupIndex] = 0;
|
2691 |
-
|
2692 |
-
});
|
2693 |
-
|
2694 |
-
// update
|
2695 |
-
acf.setPreference('this.tabs', preference);
|
2696 |
-
|
2697 |
-
}
|
2698 |
-
|
2699 |
-
}
|
2700 |
-
|
2701 |
-
});
|
2702 |
-
|
2703 |
-
/*
|
2704 |
-
* Field: Checkbox
|
2705 |
-
*/
|
2706 |
-
new acf.Model({
|
2707 |
-
|
2708 |
-
actions: {
|
2709 |
-
'new_field/type=checkbox': 'newField',
|
2710 |
-
},
|
2711 |
-
|
2712 |
-
newField: function(field){
|
2713 |
-
|
2714 |
-
if(!field.has('acfeLabels'))
|
2715 |
-
return;
|
2716 |
-
|
2717 |
-
$.each(field.get('acfeLabels'), function(group, key){
|
2718 |
-
|
2719 |
-
field.$control().find('input[type=checkbox][value="' + key + '"]').closest('ul').before('<strong>' + group + '</strong>');
|
2720 |
-
|
2721 |
-
});
|
2722 |
-
|
2723 |
-
}
|
2724 |
-
|
2725 |
-
});
|
2726 |
-
|
2727 |
-
/*
|
2728 |
-
* Field: Radio
|
2729 |
-
*/
|
2730 |
-
new acf.Model({
|
2731 |
-
|
2732 |
-
actions: {
|
2733 |
-
'new_field/type=radio': 'newField',
|
2734 |
-
},
|
2735 |
-
|
2736 |
-
newField: function(field){
|
2737 |
-
|
2738 |
-
if(!field.has('acfeLabels'))
|
2739 |
-
return;
|
2740 |
-
|
2741 |
-
$.each(field.get('acfeLabels'), function(group, key){
|
2742 |
-
|
2743 |
-
field.$control().find('input[type=radio][value="' + key + '"]').closest('li').addClass('parent').prepend('<strong>' + group + '</strong>');
|
2744 |
-
|
2745 |
-
});
|
2746 |
-
|
2747 |
-
if(field.$control().hasClass('acf-hl')){
|
2748 |
-
|
2749 |
-
field.$control().find('li.parent').each(function(){
|
2750 |
-
|
2751 |
-
$(this).nextUntil('li.parent').addBack().wrapAll('<li><ul></ul></li>');
|
2752 |
-
|
2753 |
-
});
|
2754 |
-
|
2755 |
-
}
|
2756 |
-
|
2757 |
-
}
|
2758 |
-
|
2759 |
-
});
|
2760 |
-
|
2761 |
-
/*
|
2762 |
-
* Field: Instructions
|
2763 |
-
*/
|
2764 |
-
new acf.Model({
|
2765 |
-
|
2766 |
-
field: false,
|
2767 |
-
placement: false,
|
2768 |
-
|
2769 |
-
actions: {
|
2770 |
-
'new_field': 'newField',
|
2771 |
-
},
|
2772 |
-
|
2773 |
-
newField: function(field){
|
2774 |
-
|
2775 |
-
this.field = field;
|
2776 |
-
|
2777 |
-
if(field.has('instructionTooltip')){
|
2778 |
-
this.setTooltip();
|
2779 |
-
}
|
2780 |
-
|
2781 |
-
if(field.has('instructionAboveField')){
|
2782 |
-
this.setAboveField();
|
2783 |
-
}
|
2784 |
-
|
2785 |
-
if(field.has('instructionPlacement')){
|
2786 |
-
this.overridePlacement(field.get('instructionPlacement'));
|
2787 |
-
}
|
2788 |
-
|
2789 |
-
},
|
2790 |
-
|
2791 |
-
setTooltip: function(){
|
2792 |
-
|
2793 |
-
this.field.$labelWrap().prepend('<span class="acfe-field-tooltip acf-js-tooltip dashicons dashicons-info" title="' + _.escape(this.field.get('instructionTooltip')) + '"></span>');
|
2794 |
-
this.field.$labelWrap().find('.description').remove();
|
2795 |
-
|
2796 |
-
},
|
2797 |
-
|
2798 |
-
setAboveField: function(){
|
2799 |
-
|
2800 |
-
this.field.$inputWrap().prepend('<p class="description">' + this.field.get('instructionAboveField') + '</p>');
|
2801 |
-
this.field.$labelWrap().find('.description').remove();
|
2802 |
-
|
2803 |
-
},
|
2804 |
-
|
2805 |
-
overridePlacement: function(target){
|
2806 |
-
|
2807 |
-
var current = this.getPlacement();
|
2808 |
-
|
2809 |
-
// No instruction
|
2810 |
-
if(!current)
|
2811 |
-
return;
|
2812 |
-
|
2813 |
-
// Placement is correct
|
2814 |
-
if(current === target)
|
2815 |
-
return;
|
2816 |
-
|
2817 |
-
this.setPlacement(target);
|
2818 |
-
|
2819 |
-
},
|
2820 |
-
|
2821 |
-
getPlacement: function(){
|
2822 |
-
|
2823 |
-
var placement = false;
|
2824 |
-
|
2825 |
-
if(this.field.$labelWrap().find('>.description').length)
|
2826 |
-
placement = 'label';
|
2827 |
-
|
2828 |
-
else if(this.field.$inputWrap().find('>.description:first-child').length)
|
2829 |
-
placement = 'above_field';
|
2830 |
-
|
2831 |
-
else if(this.field.$inputWrap().find('>.description:last-child').length)
|
2832 |
-
placement = 'field';
|
2833 |
-
|
2834 |
-
else if(this.field.$labelWrap().find('>.acfe-field-tooltip').length)
|
2835 |
-
placement = 'tooltip';
|
2836 |
-
|
2837 |
-
this.placement = placement;
|
2838 |
-
|
2839 |
-
return this.placement;
|
2840 |
-
|
2841 |
-
},
|
2842 |
-
|
2843 |
-
$getInstruction: function(){
|
2844 |
-
|
2845 |
-
var placement = this.getPlacement();
|
2846 |
-
|
2847 |
-
if(placement === 'label'){
|
2848 |
-
|
2849 |
-
return this.field.$labelWrap().find('>.description');
|
2850 |
-
|
2851 |
-
}else if(placement === 'above_field'){
|
2852 |
-
|
2853 |
-
return this.field.$inputWrap().find('>.description:first-child');
|
2854 |
-
|
2855 |
-
}else if(placement === 'field'){
|
2856 |
-
|
2857 |
-
return this.field.$inputWrap().find('>.description:last-child');
|
2858 |
-
|
2859 |
-
}else if(placement === 'tooltip'){
|
2860 |
-
|
2861 |
-
return this.field.$labelWrap().find('>.acfe-field-tooltip');
|
2862 |
-
|
2863 |
-
}
|
2864 |
-
|
2865 |
-
return false;
|
2866 |
-
|
2867 |
-
},
|
2868 |
-
|
2869 |
-
setPlacement: function(target){
|
2870 |
-
|
2871 |
-
var $instruction = this.$getInstruction();
|
2872 |
-
|
2873 |
-
if(this.placement === 'tooltip'){
|
2874 |
-
|
2875 |
-
var text = $instruction.attr('title');
|
2876 |
-
|
2877 |
-
$instruction.remove();
|
2878 |
-
$instruction = $('<p class="description">' + text + '</p>');
|
2879 |
-
|
2880 |
-
}
|
2881 |
-
|
2882 |
-
if(target === 'label'){
|
2883 |
-
|
2884 |
-
this.field.$labelWrap().append($instruction);
|
2885 |
-
|
2886 |
-
}else if(target === 'above_field'){
|
2887 |
-
|
2888 |
-
this.field.$inputWrap().prepend($instruction);
|
2889 |
-
|
2890 |
-
}else if(target === 'field'){
|
2891 |
-
|
2892 |
-
this.field.$inputWrap().append($instruction);
|
2893 |
-
|
2894 |
-
}else if(target === 'tooltip'){
|
2895 |
-
|
2896 |
-
this.field.$labelWrap().prepend($('<span class="acfe-field-tooltip acf-js-tooltip dashicons dashicons-info" title="' + _.escape($instruction.html()) + '"></span>'));
|
2897 |
-
$instruction.remove();
|
2898 |
-
|
2899 |
-
}
|
2900 |
-
|
2901 |
-
}
|
2902 |
-
|
2903 |
-
});
|
2904 |
-
|
2905 |
})(jQuery);
|
2906 |
-
(function($){
|
2907 |
-
|
2908 |
-
if(typeof acf === 'undefined')
|
2909 |
-
return;
|
2910 |
-
|
2911 |
-
/*
|
2912 |
-
* Field Conditions: Code Editor
|
2913 |
-
*/
|
2914 |
-
acf.registerConditionForFieldType('equalTo', 'acfe_code_editor');
|
2915 |
-
acf.registerConditionForFieldType('notEqualTo', 'acfe_code_editor');
|
2916 |
-
acf.registerConditionForFieldType('patternMatch', 'acfe_code_editor');
|
2917 |
-
acf.registerConditionForFieldType('contains', 'acfe_code_editor');
|
2918 |
-
acf.registerConditionForFieldType('hasValue', 'acfe_code_editor');
|
2919 |
-
acf.registerConditionForFieldType('hasNoValue', 'acfe_code_editor');
|
2920 |
-
|
2921 |
-
/*
|
2922 |
-
* Field Conditions: Datepicker
|
2923 |
-
*/
|
2924 |
-
acf.registerConditionForFieldType('equalTo', 'date_picker');
|
2925 |
-
acf.registerConditionForFieldType('notEqualTo', 'date_picker');
|
2926 |
-
acf.registerConditionForFieldType('patternMatch', 'date_picker');
|
2927 |
-
acf.registerConditionForFieldType('contains', 'date_picker');
|
2928 |
-
acf.registerConditionForFieldType('greaterThan', 'date_picker');
|
2929 |
-
acf.registerConditionForFieldType('lessThan', 'date_picker');
|
2930 |
-
|
2931 |
-
/*
|
2932 |
-
* Field Conditions: Datetime picker
|
2933 |
-
*/
|
2934 |
-
acf.registerConditionForFieldType('equalTo', 'date_time_picker');
|
2935 |
-
acf.registerConditionForFieldType('notEqualTo', 'date_time_picker');
|
2936 |
-
acf.registerConditionForFieldType('patternMatch', 'date_time_picker');
|
2937 |
-
acf.registerConditionForFieldType('contains', 'date_time_picker');
|
2938 |
-
|
2939 |
-
/*
|
2940 |
-
* Field Conditions: Timepicker
|
2941 |
-
*/
|
2942 |
-
acf.registerConditionForFieldType('equalTo', 'time_picker');
|
2943 |
-
acf.registerConditionForFieldType('notEqualTo', 'time_picker');
|
2944 |
-
acf.registerConditionForFieldType('patternMatch', 'time_picker');
|
2945 |
-
acf.registerConditionForFieldType('contains', 'time_picker');
|
2946 |
-
|
2947 |
-
/*
|
2948 |
-
* Field Conditions: Taxonomy
|
2949 |
-
*/
|
2950 |
-
acf.registerConditionForFieldType('equalTo', 'taxonomy');
|
2951 |
-
acf.registerConditionForFieldType('notEqualTo', 'taxonomy');
|
2952 |
-
acf.registerConditionForFieldType('patternMatch', 'taxonomy');
|
2953 |
-
acf.registerConditionForFieldType('contains', 'taxonomy');
|
2954 |
-
acf.registerConditionForFieldType('hasValue', 'taxonomy');
|
2955 |
-
acf.registerConditionForFieldType('hasNoValue', 'taxonomy');
|
2956 |
-
|
2957 |
-
/*
|
2958 |
-
* Field Conditions: Forms
|
2959 |
-
*/
|
2960 |
-
acf.registerConditionForFieldType('equalTo', 'acfe_forms');
|
2961 |
-
acf.registerConditionForFieldType('notEqualTo', 'acfe_forms');
|
2962 |
-
acf.registerConditionForFieldType('patternMatch', 'acfe_forms');
|
2963 |
-
acf.registerConditionForFieldType('contains', 'acfe_forms');
|
2964 |
-
acf.registerConditionForFieldType('hasValue', 'acfe_forms');
|
2965 |
-
acf.registerConditionForFieldType('hasNoValue', 'acfe_forms');
|
2966 |
-
|
2967 |
-
/*
|
2968 |
-
* Field Conditions: Hidden
|
2969 |
-
*/
|
2970 |
-
acf.registerConditionForFieldType('equalTo', 'acfe_hidden');
|
2971 |
-
acf.registerConditionForFieldType('notEqualTo', 'acfe_hidden');
|
2972 |
-
acf.registerConditionForFieldType('patternMatch', 'acfe_hidden');
|
2973 |
-
acf.registerConditionForFieldType('contains', 'acfe_hidden');
|
2974 |
-
acf.registerConditionForFieldType('hasValue', 'acfe_hidden');
|
2975 |
-
acf.registerConditionForFieldType('hasNoValue', 'acfe_hidden');
|
2976 |
-
|
2977 |
-
/*
|
2978 |
-
* Field Conditions: Post Status
|
2979 |
-
*/
|
2980 |
-
acf.registerConditionForFieldType('equalTo', 'acfe_post_statuses');
|
2981 |
-
acf.registerConditionForFieldType('notEqualTo', 'acfe_post_statuses');
|
2982 |
-
acf.registerConditionForFieldType('patternMatch', 'acfe_post_statuses');
|
2983 |
-
acf.registerConditionForFieldType('contains', 'acfe_post_statuses');
|
2984 |
-
acf.registerConditionForFieldType('hasValue', 'acfe_post_statuses');
|
2985 |
-
acf.registerConditionForFieldType('hasNoValue', 'acfe_post_statuses');
|
2986 |
-
|
2987 |
-
/*
|
2988 |
-
* Field Conditions: Post Types
|
2989 |
-
*/
|
2990 |
-
acf.registerConditionForFieldType('equalTo', 'acfe_post_types');
|
2991 |
-
acf.registerConditionForFieldType('notEqualTo', 'acfe_post_types');
|
2992 |
-
acf.registerConditionForFieldType('patternMatch', 'acfe_post_types');
|
2993 |
-
acf.registerConditionForFieldType('contains', 'acfe_post_types');
|
2994 |
-
acf.registerConditionForFieldType('hasValue', 'acfe_post_types');
|
2995 |
-
acf.registerConditionForFieldType('hasNoValue', 'acfe_post_types');
|
2996 |
-
|
2997 |
-
/*
|
2998 |
-
* Field Conditions: Slug
|
2999 |
-
*/
|
3000 |
-
acf.registerConditionForFieldType('equalTo', 'acfe_slug');
|
3001 |
-
acf.registerConditionForFieldType('notEqualTo', 'acfe_slug');
|
3002 |
-
acf.registerConditionForFieldType('patternMatch', 'acfe_slug');
|
3003 |
-
acf.registerConditionForFieldType('contains', 'acfe_slug');
|
3004 |
-
acf.registerConditionForFieldType('hasValue', 'acfe_slug');
|
3005 |
-
acf.registerConditionForFieldType('hasNoValue', 'acfe_slug');
|
3006 |
-
|
3007 |
-
/*
|
3008 |
-
* Field Conditions: Taxonomies
|
3009 |
-
*/
|
3010 |
-
acf.registerConditionForFieldType('equalTo', 'acfe_taxonomies');
|
3011 |
-
acf.registerConditionForFieldType('notEqualTo', 'acfe_taxonomies');
|
3012 |
-
acf.registerConditionForFieldType('patternMatch', 'acfe_taxonomies');
|
3013 |
-
acf.registerConditionForFieldType('contains', 'acfe_taxonomies');
|
3014 |
-
acf.registerConditionForFieldType('hasValue', 'acfe_taxonomies');
|
3015 |
-
acf.registerConditionForFieldType('hasNoValue', 'acfe_taxonomies');
|
3016 |
-
|
3017 |
-
/*
|
3018 |
-
* Field Conditions: Taxonomy Terms
|
3019 |
-
*/
|
3020 |
-
acf.registerConditionForFieldType('equalTo', 'acfe_taxonomy_terms');
|
3021 |
-
acf.registerConditionForFieldType('notEqualTo', 'acfe_taxonomy_terms');
|
3022 |
-
acf.registerConditionForFieldType('patternMatch', 'acfe_taxonomy_terms');
|
3023 |
-
acf.registerConditionForFieldType('contains', 'acfe_taxonomy_terms');
|
3024 |
-
acf.registerConditionForFieldType('hasValue', 'acfe_taxonomy_terms');
|
3025 |
-
acf.registerConditionForFieldType('hasNoValue', 'acfe_taxonomy_terms');
|
3026 |
-
|
3027 |
-
/*
|
3028 |
-
* Field Conditions: User Roles
|
3029 |
-
*/
|
3030 |
-
acf.registerConditionForFieldType('equalTo', 'acfe_user_roles');
|
3031 |
-
acf.registerConditionForFieldType('notEqualTo', 'acfe_user_roles');
|
3032 |
-
acf.registerConditionForFieldType('patternMatch', 'acfe_user_roles');
|
3033 |
-
acf.registerConditionForFieldType('contains', 'acfe_user_roles');
|
3034 |
-
acf.registerConditionForFieldType('hasValue', 'acfe_user_roles');
|
3035 |
-
acf.registerConditionForFieldType('hasNoValue', 'acfe_user_roles');
|
3036 |
-
|
3037 |
})(jQuery);
|
3038 |
-
(function($){
|
3039 |
-
|
3040 |
-
if(typeof acf === 'undefined')
|
3041 |
-
return;
|
3042 |
-
|
3043 |
-
/*
|
3044 |
-
* ACFE Form
|
3045 |
-
*/
|
3046 |
-
new acf.Model({
|
3047 |
-
|
3048 |
-
actions: {
|
3049 |
-
'prepare': 'prepare',
|
3050 |
-
'new_field/type=date_picker': 'datePicker',
|
3051 |
-
'new_field/type=date_time_picker': 'datePicker',
|
3052 |
-
'new_field/type=time_picker': 'datePicker',
|
3053 |
-
'new_field/type=google_map': 'googleMap',
|
3054 |
-
'invalid_field': 'invalidField',
|
3055 |
-
'validation_begin': 'validationBegin',
|
3056 |
-
},
|
3057 |
-
|
3058 |
-
prepare: function(){
|
3059 |
-
|
3060 |
-
if(acfe.get('is_admin'))
|
3061 |
-
return;
|
3062 |
-
|
3063 |
-
// Fix Image/File WP Media upload
|
3064 |
-
if(acf.isset(window, 'wp', 'media', 'view', 'settings', 'post')){
|
3065 |
-
|
3066 |
-
// Unset Post ID
|
3067 |
-
wp.media.view.settings.post = false;
|
3068 |
-
|
3069 |
-
}
|
3070 |
-
|
3071 |
-
if($('.acfe-form[data-hide-unload="1"]').length){
|
3072 |
-
|
3073 |
-
acf.unload.disable();
|
3074 |
-
|
3075 |
-
}
|
3076 |
-
|
3077 |
-
var $form_success = $('.acfe-form-success');
|
3078 |
-
|
3079 |
-
if($form_success.length){
|
3080 |
-
|
3081 |
-
// Prevent refresh sending post fields again
|
3082 |
-
if(window.history.replaceState){
|
3083 |
-
window.history.replaceState(null, null, window.location.href);
|
3084 |
-
}
|
3085 |
-
|
3086 |
-
$form_success.each(function(){
|
3087 |
-
|
3088 |
-
var form_name = $(this).data('form-name');
|
3089 |
-
var form_id = $(this).data('form-id');
|
3090 |
-
|
3091 |
-
acf.doAction('acfe/form/submit/success');
|
3092 |
-
acf.doAction('acfe/form/submit/success/id=' + form_id);
|
3093 |
-
acf.doAction('acfe/form/submit/success/name=' + form_name);
|
3094 |
-
|
3095 |
-
});
|
3096 |
-
|
3097 |
-
}
|
3098 |
-
|
3099 |
-
// Prevent form submission click spam
|
3100 |
-
$('.acf-form .button, .acf-form [type="submit"], .acfe-form .button, .acfe-form [type="submit"]').click(function(e){
|
3101 |
-
|
3102 |
-
if(!$(this).hasClass('disabled'))
|
3103 |
-
return;
|
3104 |
-
|
3105 |
-
e.preventDefault();
|
3106 |
-
|
3107 |
-
});
|
3108 |
-
|
3109 |
-
},
|
3110 |
-
|
3111 |
-
// Datepicker: Add field class
|
3112 |
-
datePicker: function(field){
|
3113 |
-
|
3114 |
-
if(acfe.get('is_admin'))
|
3115 |
-
return;
|
3116 |
-
|
3117 |
-
var $form = field.$el.closest('.acfe-form');
|
3118 |
-
|
3119 |
-
if(!$form.length)
|
3120 |
-
return;
|
3121 |
-
|
3122 |
-
var field_class = $form.data('fields-class');
|
3123 |
-
|
3124 |
-
if(field_class)
|
3125 |
-
field.$inputText().addClass(field_class);
|
3126 |
-
|
3127 |
-
},
|
3128 |
-
|
3129 |
-
// Google Maps: Add field class
|
3130 |
-
googleMap: function(field){
|
3131 |
-
|
3132 |
-
if(acfe.get('is_admin'))
|
3133 |
-
return;
|
3134 |
-
|
3135 |
-
var $form = field.$el.closest('.acfe-form');
|
3136 |
-
|
3137 |
-
if(!$form.length)
|
3138 |
-
return;
|
3139 |
-
|
3140 |
-
var field_class = $form.data('fields-class');
|
3141 |
-
|
3142 |
-
if(field_class)
|
3143 |
-
field.$search().addClass(field_class);
|
3144 |
-
|
3145 |
-
},
|
3146 |
-
|
3147 |
-
// Error: Move error
|
3148 |
-
invalidField: function(field){
|
3149 |
-
|
3150 |
-
if(acfe.get('is_admin'))
|
3151 |
-
return;
|
3152 |
-
|
3153 |
-
var $form = field.$el.closest('.acfe-form');
|
3154 |
-
|
3155 |
-
if(!$form.length)
|
3156 |
-
return;
|
3157 |
-
|
3158 |
-
var errors_position = $form.data('errors-position');
|
3159 |
-
var errors_class = $form.data('errors-class');
|
3160 |
-
|
3161 |
-
// Class
|
3162 |
-
if(errors_class && errors_class.length){
|
3163 |
-
|
3164 |
-
field.$el.find('.acf-notice.-error').addClass(errors_class);
|
3165 |
-
|
3166 |
-
}
|
3167 |
-
|
3168 |
-
// Move below
|
3169 |
-
if(errors_position && errors_position === 'below'){
|
3170 |
-
|
3171 |
-
if(field.$control().length){
|
3172 |
-
|
3173 |
-
field.$el.find('.acf-notice.-error').insertAfter(field.$control());
|
3174 |
-
|
3175 |
-
}else if(field.$input().length){
|
3176 |
-
|
3177 |
-
field.$el.find('.acf-notice.-error').insertAfter(field.$input());
|
3178 |
-
|
3179 |
-
}
|
3180 |
-
|
3181 |
-
var $selector = false;
|
3182 |
-
|
3183 |
-
if(field.$control().length){
|
3184 |
-
|
3185 |
-
$selector = field.$control();
|
3186 |
-
|
3187 |
-
}else if(field.$input().length){
|
3188 |
-
|
3189 |
-
$selector = field.$input();
|
3190 |
-
|
3191 |
-
}
|
3192 |
-
|
3193 |
-
if($selector)
|
3194 |
-
field.$el.find('.acf-notice.-error').insertAfter($selector);
|
3195 |
-
|
3196 |
-
}
|
3197 |
-
|
3198 |
-
// Group errors
|
3199 |
-
else if(errors_position && errors_position === 'group'){
|
3200 |
-
|
3201 |
-
var label = field.$el.find('.acf-label label').text().trim();
|
3202 |
-
var placeholder = field.$el.find('.acf-input-wrap [placeholder!=""]').attr('placeholder');
|
3203 |
-
var message = field.$el.find('.acf-notice.-error').text().trim();
|
3204 |
-
|
3205 |
-
field.$el.find('.acf-notice.-error').remove();
|
3206 |
-
|
3207 |
-
// Try label
|
3208 |
-
if(label && label.length && label !== '*'){
|
3209 |
-
|
3210 |
-
message = label + ': ' + message;
|
3211 |
-
|
3212 |
-
}
|
3213 |
-
|
3214 |
-
// Try placeholder
|
3215 |
-
else if(placeholder && placeholder.length && placeholder !== ''){
|
3216 |
-
|
3217 |
-
message = placeholder + ': ' + message;
|
3218 |
-
|
3219 |
-
}
|
3220 |
-
|
3221 |
-
// If everything fails, use field name
|
3222 |
-
else{
|
3223 |
-
|
3224 |
-
message = field.get('name') + ': ' + message;
|
3225 |
-
|
3226 |
-
}
|
3227 |
-
|
3228 |
-
var $form_error = $form.find('> .acfe-form-error')
|
3229 |
-
|
3230 |
-
if(!$form_error.length)
|
3231 |
-
$form_error = $('<div class="acf-notice -error acf-error-message acfe-form-error" />').prependTo($form);
|
3232 |
-
|
3233 |
-
$form_error.append('<p>' + message + '</p>');
|
3234 |
-
|
3235 |
-
}
|
3236 |
-
|
3237 |
-
// Hide errors
|
3238 |
-
else if(errors_position && errors_position === 'hide'){
|
3239 |
-
|
3240 |
-
field.$el.find('.acf-notice.-error').remove();
|
3241 |
-
|
3242 |
-
}
|
3243 |
-
|
3244 |
-
},
|
3245 |
-
|
3246 |
-
// Ajax Validation
|
3247 |
-
validationBegin: function($form){
|
3248 |
-
|
3249 |
-
if(acfe.get('is_admin'))
|
3250 |
-
return;
|
3251 |
-
|
3252 |
-
if(typeof $form === 'undefined')
|
3253 |
-
return;
|
3254 |
-
|
3255 |
-
$form.find('.acf-error-message').remove();
|
3256 |
-
|
3257 |
-
}
|
3258 |
-
|
3259 |
-
});
|
3260 |
-
|
3261 |
-
// Rewrite ACF New Condition
|
3262 |
-
// Allow conditions to work within wrapped div
|
3263 |
-
acf.newCondition = function(rule, conditions){
|
3264 |
-
|
3265 |
-
// currently setting up conditions for fieldX, this field is the 'target'
|
3266 |
-
var target = conditions.get('field');
|
3267 |
-
|
3268 |
-
// use the 'target' to find the 'trigger' field.
|
3269 |
-
// - this field is used to setup the conditional logic events
|
3270 |
-
var field = target.getField( rule.field );
|
3271 |
-
|
3272 |
-
// ACF Extended: Check in all form if targeted field not found
|
3273 |
-
if( target && !field ) {
|
3274 |
-
|
3275 |
-
field = acf.getField( rule.field );
|
3276 |
-
|
3277 |
-
}
|
3278 |
-
|
3279 |
-
// bail ealry if no target or no field (possible if field doesn't exist due to HTML error)
|
3280 |
-
if( !target || !field ) {
|
3281 |
-
return false;
|
3282 |
-
}
|
3283 |
-
|
3284 |
-
// vars
|
3285 |
-
var args = {
|
3286 |
-
rule: rule,
|
3287 |
-
target: target,
|
3288 |
-
conditions: conditions,
|
3289 |
-
field: field
|
3290 |
-
};
|
3291 |
-
|
3292 |
-
// vars
|
3293 |
-
var fieldType = field.get('type');
|
3294 |
-
var operator = rule.operator;
|
3295 |
-
|
3296 |
-
// get avaibale conditions
|
3297 |
-
var conditionTypes = acf.getConditionTypes({
|
3298 |
-
fieldType: fieldType,
|
3299 |
-
operator: operator,
|
3300 |
-
});
|
3301 |
-
|
3302 |
-
// instantiate
|
3303 |
-
var model = conditionTypes[0] || acf.Condition;
|
3304 |
-
|
3305 |
-
// instantiate
|
3306 |
-
var condition = new model( args );
|
3307 |
-
|
3308 |
-
// return
|
3309 |
-
return condition;
|
3310 |
-
|
3311 |
-
};
|
3312 |
-
|
3313 |
})(jQuery);
|
3314 |
-
(function($){
|
3315 |
-
|
3316 |
-
if(typeof acf === 'undefined')
|
3317 |
-
return;
|
3318 |
-
|
3319 |
-
/*
|
3320 |
-
* Init
|
3321 |
-
*/
|
3322 |
-
var repeater = acf.getFieldType('repeater');
|
3323 |
-
var model = repeater.prototype;
|
3324 |
-
|
3325 |
-
// Repeater: Lock Layouts
|
3326 |
-
model.acfeOnHover = function(){
|
3327 |
-
|
3328 |
-
var repeater = this;
|
3329 |
-
|
3330 |
-
// remove event
|
3331 |
-
repeater.off('mouseover');
|
3332 |
-
|
3333 |
-
}
|
3334 |
-
|
3335 |
-
/*
|
3336 |
-
* Spawn
|
3337 |
-
*/
|
3338 |
-
acf.addAction('new_field/type=repeater', function(repeater){
|
3339 |
-
|
3340 |
-
// ACFE: Lock
|
3341 |
-
if(repeater.has('acfeRepeaterLock')){
|
3342 |
-
|
3343 |
-
repeater.removeEvents({'mouseover': 'onHover'});
|
3344 |
-
|
3345 |
-
repeater.addEvents({'mouseover': 'acfeOnHover'});
|
3346 |
-
|
3347 |
-
}
|
3348 |
-
|
3349 |
-
// ACFE: Remove Actions
|
3350 |
-
if(repeater.has('acfeRepeaterRemoveActions')){
|
3351 |
-
|
3352 |
-
repeater.$actions().remove();
|
3353 |
-
|
3354 |
-
repeater.$el.find('thead:first > tr > th.acf-row-handle:last').remove();
|
3355 |
-
repeater.$rows().find('> .acf-row-handle:last').remove();
|
3356 |
-
|
3357 |
-
repeater.$control().find('> .acfe-repeater-stylised-button').remove();
|
3358 |
-
|
3359 |
-
|
3360 |
-
}
|
3361 |
-
|
3362 |
-
// ACFE: Stylised button
|
3363 |
-
if(repeater.has('acfeRepeaterStylisedButton')){
|
3364 |
-
|
3365 |
-
repeater.$button().removeClass('button-primary');
|
3366 |
-
repeater.$actions().wrap('<div class="acfe-repeater-stylised-button" />');
|
3367 |
-
|
3368 |
-
}
|
3369 |
-
|
3370 |
-
});
|
3371 |
-
|
3372 |
})(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 |
+
* Drag & Drop
|
14 |
+
*/
|
15 |
+
model.addSortable = function(self){
|
16 |
+
|
17 |
+
// bail early if max 1 row
|
18 |
+
if(this.get('max') == 1){
|
19 |
+
return;
|
20 |
+
}
|
21 |
+
|
22 |
+
// add sortable
|
23 |
+
this.$layoutsWrap().sortable({
|
24 |
+
items: ' > .layout',
|
25 |
+
handle: '> .acf-fc-layout-handle',
|
26 |
+
forceHelperSize: false, // Changed to false
|
27 |
+
forcePlaceholderSize: true,
|
28 |
+
revert: 50,
|
29 |
+
tolerance: "pointer", // Changed to pointer
|
30 |
+
scroll: true,
|
31 |
+
stop: function(event, ui) {
|
32 |
+
self.render();
|
33 |
+
},
|
34 |
+
update: function(event, ui) {
|
35 |
+
self.$input().trigger('change');
|
36 |
+
}
|
37 |
+
});
|
38 |
+
|
39 |
+
};
|
40 |
+
|
41 |
+
/*
|
42 |
+
* Actions
|
43 |
+
*/
|
44 |
+
model.acfeOneClick = function(e, $el){
|
45 |
+
|
46 |
+
// Get Flexible
|
47 |
+
var flexible = this;
|
48 |
+
|
49 |
+
// Vars
|
50 |
+
var $clones = flexible.$clones();
|
51 |
+
var $layout_name = $($clones[0]).data('layout');
|
52 |
+
|
53 |
+
// Source
|
54 |
+
var $layout_source = null;
|
55 |
+
if($el.hasClass('acf-icon'))
|
56 |
+
$layout_source = $el.closest('.layout');
|
57 |
+
|
58 |
+
// Add
|
59 |
+
var $layout_added = flexible.add({
|
60 |
+
layout: $layout_name,
|
61 |
+
before: $layout_source
|
62 |
+
});
|
63 |
+
|
64 |
+
// Hide native tooltip
|
65 |
+
var acfPopup = $('.acf-fc-popup');
|
66 |
+
|
67 |
+
if(acfPopup.length){
|
68 |
+
acfPopup.hide();
|
69 |
+
}
|
70 |
+
|
71 |
+
|
72 |
+
};
|
73 |
+
|
74 |
+
model.acfeLayoutInit = function($layout){
|
75 |
+
|
76 |
+
// Get Flexible
|
77 |
+
var flexible = this;
|
78 |
+
|
79 |
+
// Vars
|
80 |
+
var $controls = $layout.find('> .acf-fc-layout-controls');
|
81 |
+
var $handle = $layout.find('> .acf-fc-layout-handle');
|
82 |
+
|
83 |
+
// Placeholder
|
84 |
+
var $placeholder = $layout.find('> .acfe-fc-placeholder');
|
85 |
+
|
86 |
+
// Placeholder: Show
|
87 |
+
$placeholder.removeClass('acf-hidden');
|
88 |
+
|
89 |
+
// If no modal edition & opened: Hide Placeholder
|
90 |
+
if(!flexible.has('acfeFlexibleModalEdition') && !flexible.isLayoutClosed($layout)){
|
91 |
+
|
92 |
+
$placeholder.addClass('acf-hidden');
|
93 |
+
|
94 |
+
}
|
95 |
+
|
96 |
+
// Flexible has Preview
|
97 |
+
if(flexible.isLayoutClosed($layout) && flexible.has('acfeFlexiblePreview') && !$placeholder.hasClass('-loading')){
|
98 |
+
|
99 |
+
$placeholder.addClass('acfe-fc-preview -loading').find('> .acfe-flexible-placeholder').prepend('<span class="spinner"></span>');
|
100 |
+
$placeholder.find('> .acfe-fc-overlay').addClass('-hover');
|
101 |
+
|
102 |
+
// vars
|
103 |
+
var $input = $layout.children('input');
|
104 |
+
var prefix = $input.attr('name').replace('[acf_fc_layout]', '');
|
105 |
+
|
106 |
+
// ajax data
|
107 |
+
var ajaxData = {
|
108 |
+
action: 'acfe/flexible/layout_preview',
|
109 |
+
field_key: flexible.get('key'),
|
110 |
+
i: $layout.index(),
|
111 |
+
layout: $layout.data('layout'),
|
112 |
+
value: acf.serialize($layout, prefix)
|
113 |
+
};
|
114 |
+
|
115 |
+
acf.doAction('acfe/fields/flexible_content/before_preview', flexible.$el, $layout, ajaxData);
|
116 |
+
acf.doAction('acfe/fields/flexible_content/before_preview/name=' + flexible.get('name'), flexible.$el, $layout, ajaxData);
|
117 |
+
acf.doAction('acfe/fields/flexible_content/before_preview/key=' + flexible.get('key'), flexible.$el, $layout, ajaxData);
|
118 |
+
acf.doAction('acfe/fields/flexible_content/before_preview/name=' + flexible.get('name') + '&layout=' + $layout.data('layout'), flexible.$el, $layout, ajaxData);
|
119 |
+
acf.doAction('acfe/fields/flexible_content/before_preview/key=' + flexible.get('key') + '&layout=' + $layout.data('layout'), flexible.$el, $layout, ajaxData);
|
120 |
+
|
121 |
+
// ajax
|
122 |
+
$.ajax({
|
123 |
+
url: acf.get('ajaxurl'),
|
124 |
+
data: acf.prepareForAjax(ajaxData),
|
125 |
+
dataType: 'html',
|
126 |
+
type: 'post',
|
127 |
+
success: function(response){
|
128 |
+
|
129 |
+
if(response){
|
130 |
+
|
131 |
+
$placeholder.find('> .acfe-flexible-placeholder').html(response);
|
132 |
+
|
133 |
+
}else{
|
134 |
+
|
135 |
+
$placeholder.removeClass('acfe-fc-preview');
|
136 |
+
|
137 |
+
}
|
138 |
+
|
139 |
+
acf.doAction('acfe/fields/flexible_content/preview', response, flexible.$el, $layout, ajaxData);
|
140 |
+
acf.doAction('acfe/fields/flexible_content/preview/name=' + flexible.get('name'), response, flexible.$el, $layout, ajaxData);
|
141 |
+
acf.doAction('acfe/fields/flexible_content/preview/key=' + flexible.get('key'), response, flexible.$el, $layout, ajaxData);
|
142 |
+
acf.doAction('acfe/fields/flexible_content/preview/name=' + flexible.get('name') + '&layout=' + $layout.data('layout'), response, flexible.$el, $layout, ajaxData);
|
143 |
+
acf.doAction('acfe/fields/flexible_content/preview/key=' + flexible.get('key') + '&layout=' + $layout.data('layout'), response, flexible.$el, $layout, ajaxData);
|
144 |
+
|
145 |
+
},
|
146 |
+
complete: function(){
|
147 |
+
|
148 |
+
$placeholder.find('> .acfe-fc-overlay').removeClass('-hover');
|
149 |
+
$placeholder.removeClass('-loading').find('> .acfe-flexible-placeholder > .spinner').remove();
|
150 |
+
|
151 |
+
}
|
152 |
+
});
|
153 |
+
|
154 |
+
}
|
155 |
+
|
156 |
+
};
|
157 |
+
|
158 |
+
/*
|
159 |
+
* WYSIWYG
|
160 |
+
*/
|
161 |
+
var wysiwyg = acf.getFieldType('wysiwyg').prototype;
|
162 |
+
wysiwyg.initialize = function(){
|
163 |
+
|
164 |
+
// initializeEditor if no delay
|
165 |
+
if( !this.has('id') && !this.$control().hasClass('delay') ) {
|
166 |
+
this.initializeEditor();
|
167 |
+
}
|
168 |
+
|
169 |
+
};
|
170 |
+
|
171 |
+
var acfeFlexibleDelayInit = function(editor){
|
172 |
+
|
173 |
+
if(editor.has('id') || !editor.$el.is(':visible') || acfe.isFilterEnabled('acfeForceOpen'))
|
174 |
+
return;
|
175 |
+
|
176 |
+
var $wrap = editor.$control();
|
177 |
+
|
178 |
+
if($wrap.hasClass('delay')){
|
179 |
+
|
180 |
+
$wrap.removeClass('delay');
|
181 |
+
$wrap.find('.acf-editor-toolbar').remove();
|
182 |
+
|
183 |
+
// initialize
|
184 |
+
editor.initializeEditor();
|
185 |
+
|
186 |
+
}
|
187 |
+
|
188 |
+
};
|
189 |
+
|
190 |
+
acf.addAction('show_field/type=wysiwyg', acfeFlexibleDelayInit);
|
191 |
+
acf.addAction('ready_field/type=wysiwyg', acfeFlexibleDelayInit);
|
192 |
+
|
193 |
+
/*
|
194 |
+
* Spawn
|
195 |
+
*/
|
196 |
+
acf.addAction('new_field/type=flexible_content', function(flexible){
|
197 |
+
|
198 |
+
// Vars
|
199 |
+
var $clones = flexible.$clones();
|
200 |
+
var $layouts = flexible.$layouts();
|
201 |
+
|
202 |
+
// Merge
|
203 |
+
var $all_layouts = $.merge($layouts, $clones);
|
204 |
+
|
205 |
+
// Do Actions
|
206 |
+
$layouts.each(function(){
|
207 |
+
|
208 |
+
var $layout = $(this);
|
209 |
+
var $name = $layout.data('layout');
|
210 |
+
|
211 |
+
acf.doAction('acfe/flexible/layouts', $layout, flexible);
|
212 |
+
acf.doAction('acfe/flexible/layout/name=' + $name, $layout, flexible);
|
213 |
+
|
214 |
+
});
|
215 |
+
|
216 |
+
// ACFE: 1 layout available - OneClick
|
217 |
+
if($clones.length === 1){
|
218 |
+
|
219 |
+
// Remove native ACF Tooltip action
|
220 |
+
flexible.removeEvents({'click [data-name="add-layout"]': 'onClickAdd'});
|
221 |
+
|
222 |
+
// Add ACF Extended Modal action
|
223 |
+
flexible.addEvents({'click [data-name="add-layout"]': 'acfeOneClick'});
|
224 |
+
|
225 |
+
}
|
226 |
+
|
227 |
+
flexible.addEvents({'click .acfe-fc-placeholder': 'onClickCollapse'});
|
228 |
+
|
229 |
+
flexible.addEvents({'click .acfe-flexible-opened-actions > a': 'onClickCollapse'});
|
230 |
+
|
231 |
+
// Flexible: Ajax
|
232 |
+
if(flexible.has('acfeFlexibleAjax')){
|
233 |
+
|
234 |
+
flexible.add = function(args){
|
235 |
+
|
236 |
+
// Get Flexible
|
237 |
+
var flexible = this;
|
238 |
+
|
239 |
+
// defaults
|
240 |
+
args = acf.parseArgs(args, {
|
241 |
+
layout: '',
|
242 |
+
before: false
|
243 |
+
});
|
244 |
+
|
245 |
+
// validate
|
246 |
+
if( !this.allowAdd() ) {
|
247 |
+
return false;
|
248 |
+
}
|
249 |
+
|
250 |
+
// ajax
|
251 |
+
$.ajax({
|
252 |
+
url: acf.get('ajaxurl'),
|
253 |
+
data: acf.prepareForAjax({
|
254 |
+
action: 'acfe/flexible/models',
|
255 |
+
field_key: this.get('key'),
|
256 |
+
layout: args.layout,
|
257 |
+
}),
|
258 |
+
dataType: 'html',
|
259 |
+
type: 'post',
|
260 |
+
beforeSend: function(){
|
261 |
+
$('body').addClass('-loading');
|
262 |
+
},
|
263 |
+
success: function(html){
|
264 |
+
if(html){
|
265 |
+
|
266 |
+
var $layout = $(html);
|
267 |
+
var uniqid = acf.uniqid();
|
268 |
+
|
269 |
+
var search = 'acf[' + flexible.get('key') + '][acfcloneindex]';
|
270 |
+
var replace = flexible.$control().find('> input[type=hidden]').attr('name') + '[' + uniqid + ']';
|
271 |
+
|
272 |
+
// add row
|
273 |
+
var $el = acf.duplicate({
|
274 |
+
target: $layout,
|
275 |
+
search: search,
|
276 |
+
replace: replace,
|
277 |
+
append: flexible.proxy(function( $el, $el2 ){
|
278 |
+
|
279 |
+
// append
|
280 |
+
if( args.before ) {
|
281 |
+
args.before.before( $el2 );
|
282 |
+
} else {
|
283 |
+
flexible.$layoutsWrap().append( $el2 );
|
284 |
+
}
|
285 |
+
|
286 |
+
// enable
|
287 |
+
acf.enable( $el2, flexible.cid );
|
288 |
+
|
289 |
+
// render
|
290 |
+
flexible.render();
|
291 |
+
})
|
292 |
+
});
|
293 |
+
|
294 |
+
// Fix data-id
|
295 |
+
$el.attr('data-id', uniqid);
|
296 |
+
|
297 |
+
// trigger change for validation errors
|
298 |
+
flexible.$input().trigger('change');
|
299 |
+
|
300 |
+
// return
|
301 |
+
return $el;
|
302 |
+
|
303 |
+
}
|
304 |
+
},
|
305 |
+
'complete': function(){
|
306 |
+
$('body').removeClass('-loading');
|
307 |
+
}
|
308 |
+
});
|
309 |
+
|
310 |
+
};
|
311 |
+
|
312 |
+
}
|
313 |
+
|
314 |
+
});
|
315 |
+
|
316 |
+
acf.addAction('acfe/flexible/layouts', function($layout, flexible){
|
317 |
+
|
318 |
+
// Layout Closed
|
319 |
+
if(flexible.isLayoutClosed($layout)){
|
320 |
+
|
321 |
+
// Placeholder
|
322 |
+
$layout.find('> .acfe-fc-placeholder').removeClass('acf-hidden');
|
323 |
+
|
324 |
+
if(flexible.has('acfeFlexibleOpen')){
|
325 |
+
|
326 |
+
acfe.enableFilter('acfeForceOpen');
|
327 |
+
|
328 |
+
flexible.openLayout($layout);
|
329 |
+
|
330 |
+
acfe.disableFilter('acfeForceOpen');
|
331 |
+
|
332 |
+
}
|
333 |
+
|
334 |
+
}
|
335 |
+
|
336 |
+
});
|
337 |
+
|
338 |
+
acf.addAction('show', function($layout, type){
|
339 |
+
|
340 |
+
if(type !== 'collapse' || !$layout.is('.layout'))
|
341 |
+
return;
|
342 |
+
|
343 |
+
var flexible = acf.getInstance($layout.closest('.acf-field-flexible-content'));
|
344 |
+
|
345 |
+
// Hide Placeholder
|
346 |
+
if(!flexible.has('acfeFlexibleModalEdition')){
|
347 |
+
|
348 |
+
// Placeholder
|
349 |
+
$layout.find('> .acfe-fc-placeholder').addClass('acf-hidden');
|
350 |
+
|
351 |
+
}
|
352 |
+
|
353 |
+
});
|
354 |
+
|
355 |
+
acf.addAction('hide', function($layout, type){
|
356 |
+
|
357 |
+
if(type !== 'collapse' || !$layout.is('.layout') || $layout.is('.acf-clone'))
|
358 |
+
return;
|
359 |
+
|
360 |
+
// Get Flexible
|
361 |
+
var flexible = acf.getInstance($layout.closest('.acf-field-flexible-content'));
|
362 |
+
|
363 |
+
// Remove Ajax Title
|
364 |
+
if(flexible.has('acfeFlexibleRemoveAjaxTitle')){
|
365 |
+
|
366 |
+
flexible.renderLayout = function($layout){};
|
367 |
+
|
368 |
+
}
|
369 |
+
|
370 |
+
// Preview Ajax
|
371 |
+
flexible.acfeLayoutInit($layout);
|
372 |
+
|
373 |
+
});
|
374 |
+
|
375 |
+
acf.addAction('append', function($el){
|
376 |
+
|
377 |
+
// Bail early if layout is not layout
|
378 |
+
if(!$el.is('.layout'))
|
379 |
+
return;
|
380 |
+
|
381 |
+
// Get Flexible
|
382 |
+
var flexible = acf.getInstance($el.closest('.acf-field-flexible-content'));
|
383 |
+
|
384 |
+
// Open Layout
|
385 |
+
if(!$el.is('.acfe-layout-duplicated')){
|
386 |
+
|
387 |
+
// Modal Edition: Open
|
388 |
+
if(flexible.has('acfeFlexibleModalEdition')){
|
389 |
+
|
390 |
+
$el.find('> [data-action="acfe-flexible-modal-edit"]:first').trigger('click');
|
391 |
+
|
392 |
+
}
|
393 |
+
|
394 |
+
// Normal Edition: Open
|
395 |
+
else{
|
396 |
+
|
397 |
+
flexible.openLayout($el);
|
398 |
+
|
399 |
+
}
|
400 |
+
|
401 |
+
}
|
402 |
+
|
403 |
+
flexible.acfeLayoutInit($el);
|
404 |
+
|
405 |
+
var $modal = flexible.$el.closest('.acfe-modal.-open');
|
406 |
+
|
407 |
+
if($modal.length){
|
408 |
+
|
409 |
+
// Scroll to new layout
|
410 |
+
$modal.find('> .acfe-modal-wrapper > .acfe-modal-content').animate({
|
411 |
+
scrollTop: parseInt($el.offset().top) - 200
|
412 |
+
}, 200);
|
413 |
+
|
414 |
+
}else{
|
415 |
+
|
416 |
+
var acfVersion = parseFloat(acf.get('acf_version'));
|
417 |
+
|
418 |
+
if(acfVersion < 5.9){
|
419 |
+
|
420 |
+
// Scroll to new layout
|
421 |
+
$('html, body').animate({
|
422 |
+
scrollTop: parseInt($el.offset().top) - 200
|
423 |
+
}, 200);
|
424 |
+
|
425 |
+
}else{
|
426 |
+
|
427 |
+
// Avoid native ACF duplicate
|
428 |
+
if(!$el.hasClass('-focused')){
|
429 |
+
|
430 |
+
// Scroll to new layout
|
431 |
+
$('html, body').animate({
|
432 |
+
scrollTop: parseInt($el.offset().top) - 200
|
433 |
+
}, 200);
|
434 |
+
|
435 |
+
}
|
436 |
+
|
437 |
+
}
|
438 |
+
|
439 |
+
}
|
440 |
+
|
441 |
+
});
|
442 |
+
|
443 |
+
/*
|
444 |
+
* Field Error
|
445 |
+
*/
|
446 |
+
acf.addAction('invalid_field', function(field){
|
447 |
+
|
448 |
+
field.$el.parents('.layout').addClass('acfe-flexible-modal-edit-error');
|
449 |
+
|
450 |
+
});
|
451 |
+
|
452 |
+
/*
|
453 |
+
* Field Valid
|
454 |
+
*/
|
455 |
+
acf.addAction('valid_field', function(field){
|
456 |
+
|
457 |
+
field.$el.parents('.layout').each(function(){
|
458 |
+
|
459 |
+
var $layout = $(this);
|
460 |
+
|
461 |
+
if(!$layout.find('.acf-error').length)
|
462 |
+
$layout.removeClass('acfe-flexible-modal-edit-error');
|
463 |
+
|
464 |
+
});
|
465 |
+
|
466 |
+
});
|
467 |
+
|
468 |
})(jQuery);
|
469 |
+
(function($){
|
470 |
+
|
471 |
+
if(typeof acf === 'undefined')
|
472 |
+
return;
|
473 |
+
|
474 |
+
/*
|
475 |
+
* Init
|
476 |
+
*/
|
477 |
+
var flexible = acf.getFieldType('flexible_content');
|
478 |
+
var model = flexible.prototype;
|
479 |
+
|
480 |
+
/*
|
481 |
+
* Actions
|
482 |
+
*/
|
483 |
+
model.events['click .acf-fc-layout-handle'] = 'acfeEditLayoutTitleToggleHandle';
|
484 |
+
model.acfeEditLayoutTitleToggleHandle = function(e, $el){
|
485 |
+
|
486 |
+
var flexible = this;
|
487 |
+
|
488 |
+
// Title Edition
|
489 |
+
if(!flexible.has('acfeFlexibleTitleEdition'))
|
490 |
+
return;
|
491 |
+
|
492 |
+
// Vars
|
493 |
+
var $layout = $el.closest('.layout');
|
494 |
+
|
495 |
+
if($layout.hasClass('acfe-flexible-title-edition')){
|
496 |
+
|
497 |
+
$layout.find('> .acf-fc-layout-handle > .acfe-layout-title > input.acfe-flexible-control-title').trigger('blur');
|
498 |
+
|
499 |
+
}
|
500 |
+
|
501 |
+
}
|
502 |
+
|
503 |
+
model.events['click .acfe-layout-title-text'] = 'acfeEditLayoutTitle';
|
504 |
+
model.acfeEditLayoutTitle = function(e, $el){
|
505 |
+
|
506 |
+
// Get Flexible
|
507 |
+
var flexible = this;
|
508 |
+
|
509 |
+
// Title Edition
|
510 |
+
if(!flexible.has('acfeFlexibleTitleEdition'))
|
511 |
+
return;
|
512 |
+
|
513 |
+
// Stop propagation
|
514 |
+
e.stopPropagation();
|
515 |
+
|
516 |
+
// Toggle
|
517 |
+
flexible.acfeEditLayoutTitleToggle(e, $el);
|
518 |
+
|
519 |
+
}
|
520 |
+
|
521 |
+
model.events['blur input.acfe-flexible-control-title'] = 'acfeEditLayoutTitleToggle';
|
522 |
+
model.acfeEditLayoutTitleToggle = function(e, $el){
|
523 |
+
|
524 |
+
var flexible = this;
|
525 |
+
|
526 |
+
// Vars
|
527 |
+
var $layout = $el.closest('.layout');
|
528 |
+
var $handle = $layout.find('> .acf-fc-layout-handle');
|
529 |
+
var $title = $handle.find('.acfe-layout-title');
|
530 |
+
|
531 |
+
if($layout.hasClass('acfe-flexible-title-edition')){
|
532 |
+
|
533 |
+
var $input = $title.find('> input[data-acfe-flexible-control-title-input]');
|
534 |
+
|
535 |
+
if($input.val() === '')
|
536 |
+
$input.val($input.attr('placeholder')).trigger('input');
|
537 |
+
|
538 |
+
$layout.removeClass('acfe-flexible-title-edition');
|
539 |
+
|
540 |
+
$input.insertAfter($handle);
|
541 |
+
|
542 |
+
}
|
543 |
+
|
544 |
+
else{
|
545 |
+
|
546 |
+
var $input = $layout.find('> input[data-acfe-flexible-control-title-input]');
|
547 |
+
|
548 |
+
var $input = $input.appendTo($title);
|
549 |
+
|
550 |
+
$layout.addClass('acfe-flexible-title-edition');
|
551 |
+
$input.focus().attr('size', $input.val().length);
|
552 |
+
|
553 |
+
}
|
554 |
+
|
555 |
+
}
|
556 |
+
|
557 |
+
// Layout: Edit Title
|
558 |
+
model.events['click input.acfe-flexible-control-title'] = 'acfeEditLayoutTitlePropagation';
|
559 |
+
model.acfeEditLayoutTitlePropagation = function(e, $el){
|
560 |
+
|
561 |
+
e.stopPropagation();
|
562 |
+
|
563 |
+
}
|
564 |
+
|
565 |
+
// Layout: Edit Title Input
|
566 |
+
model.events['input [data-acfe-flexible-control-title-input]'] = 'acfeEditLayoutTitleInput';
|
567 |
+
model.acfeEditLayoutTitleInput = function(e, $el){
|
568 |
+
|
569 |
+
// Vars
|
570 |
+
var $layout = $el.closest('.layout');
|
571 |
+
var $title = $layout.find('> .acf-fc-layout-handle .acfe-layout-title .acfe-layout-title-text');
|
572 |
+
|
573 |
+
var val = $el.val();
|
574 |
+
|
575 |
+
$el.attr('size', val.length);
|
576 |
+
|
577 |
+
$title.html(val);
|
578 |
+
|
579 |
+
}
|
580 |
+
|
581 |
+
// Layout: Edit Title Input Enter
|
582 |
+
model.events['keypress [data-acfe-flexible-control-title-input]'] = 'acfeEditLayoutTitleInputEnter';
|
583 |
+
model.acfeEditLayoutTitleInputEnter = function(e, $el){
|
584 |
+
|
585 |
+
// Enter Key
|
586 |
+
if(e.keyCode !== 13)
|
587 |
+
return;
|
588 |
+
|
589 |
+
e.preventDefault();
|
590 |
+
$el.blur();
|
591 |
+
|
592 |
+
}
|
593 |
+
|
594 |
+
// Layout: Settings
|
595 |
+
model.events['click [data-acfe-flexible-settings]'] = 'acfeLayoutSettings';
|
596 |
+
model.acfeLayoutSettings = function(e, $el){
|
597 |
+
|
598 |
+
// Get Flexible
|
599 |
+
var flexible = this;
|
600 |
+
|
601 |
+
// Vars
|
602 |
+
var $layout = $el.closest('.layout');
|
603 |
+
|
604 |
+
// Modal data
|
605 |
+
var $modal = $layout.find('> .acfe-modal.-settings');
|
606 |
+
var $handle = $layout.find('> .acf-fc-layout-handle');
|
607 |
+
|
608 |
+
var $layout_order = $handle.find('> .acf-fc-layout-order').outerHTML();
|
609 |
+
var $layout_title = $handle.find('.acfe-layout-title-text').text();
|
610 |
+
|
611 |
+
// Open modal
|
612 |
+
new acfe.Popup($modal, {
|
613 |
+
title: $layout_order + ' ' + $layout_title,
|
614 |
+
footer: acf.__('Close'),
|
615 |
+
onClose: function(){
|
616 |
+
|
617 |
+
if(!flexible.has('acfeFlexiblePreview'))
|
618 |
+
return;
|
619 |
+
|
620 |
+
flexible.closeLayout($layout);
|
621 |
+
|
622 |
+
}
|
623 |
+
});
|
624 |
+
|
625 |
+
}
|
626 |
+
|
627 |
+
/*
|
628 |
+
* Layout: Toggle Action
|
629 |
+
*/
|
630 |
+
model.events['click [data-acfe-flexible-control-toggle]'] = 'acfeLayoutToggle';
|
631 |
+
model.acfeLayoutToggle = function(e, $el){
|
632 |
+
|
633 |
+
// Get Flexible
|
634 |
+
var flexible = this;
|
635 |
+
|
636 |
+
// Vars
|
637 |
+
var $layout = $el.closest('.layout');
|
638 |
+
|
639 |
+
var $field = $layout.find('> .acfe-flexible-layout-toggle');
|
640 |
+
|
641 |
+
if(!$field.length)
|
642 |
+
return;
|
643 |
+
|
644 |
+
if($field.val() === '1'){
|
645 |
+
|
646 |
+
$layout.removeClass('acfe-flexible-layout-hidden');
|
647 |
+
$field.val('');
|
648 |
+
|
649 |
+
}else{
|
650 |
+
|
651 |
+
$layout.addClass('acfe-flexible-layout-hidden');
|
652 |
+
$field.val('1');
|
653 |
+
|
654 |
+
}
|
655 |
+
|
656 |
+
}
|
657 |
+
|
658 |
+
/*
|
659 |
+
* Layout: Toggle Spawn
|
660 |
+
*/
|
661 |
+
acf.addAction('acfe/flexible/layouts', function($layout, flexible){
|
662 |
+
|
663 |
+
if(!flexible.has('acfeFlexibleToggle'))
|
664 |
+
return;
|
665 |
+
|
666 |
+
// Layout Closed
|
667 |
+
var $field = $layout.find('> .acfe-flexible-layout-toggle');
|
668 |
+
|
669 |
+
if(!$field.length)
|
670 |
+
return;
|
671 |
+
|
672 |
+
if($field.val() === '1'){
|
673 |
+
|
674 |
+
$layout.addClass('acfe-flexible-layout-hidden');
|
675 |
+
|
676 |
+
}else{
|
677 |
+
|
678 |
+
$layout.removeClass('acfe-flexible-layout-hidden');
|
679 |
+
|
680 |
+
}
|
681 |
+
|
682 |
+
});
|
683 |
+
|
684 |
+
// Layout: Clone
|
685 |
+
model.events['click [data-acfe-flexible-control-clone]'] = 'acfeCloneLayout';
|
686 |
+
model.acfeCloneLayout = function(e, $el){
|
687 |
+
|
688 |
+
// Get Flexible
|
689 |
+
var flexible = this;
|
690 |
+
|
691 |
+
// Vars
|
692 |
+
var $layout = $el.closest('.layout');
|
693 |
+
var layout_name = $layout.data('layout');
|
694 |
+
|
695 |
+
// Popup min/max
|
696 |
+
var $popup = $(flexible.$popup().html());
|
697 |
+
var $layouts = flexible.$layouts();
|
698 |
+
|
699 |
+
var countLayouts = function(name){
|
700 |
+
return $layouts.filter(function(){
|
701 |
+
return $(this).data('layout') === name;
|
702 |
+
}).length;
|
703 |
+
};
|
704 |
+
|
705 |
+
// vars
|
706 |
+
var $a = $popup.find('[data-layout="' + layout_name + '"]');
|
707 |
+
var min = $a.data('min') || 0;
|
708 |
+
var max = $a.data('max') || 0;
|
709 |
+
var count = countLayouts(layout_name);
|
710 |
+
|
711 |
+
// max
|
712 |
+
if(max && count >= max){
|
713 |
+
|
714 |
+
$el.addClass('disabled');
|
715 |
+
return false;
|
716 |
+
|
717 |
+
}else{
|
718 |
+
|
719 |
+
$el.removeClass('disabled');
|
720 |
+
|
721 |
+
}
|
722 |
+
|
723 |
+
// Fix inputs
|
724 |
+
flexible.acfeFixInputs($layout);
|
725 |
+
|
726 |
+
var $_layout = $layout.clone();
|
727 |
+
|
728 |
+
// Clean Layout
|
729 |
+
flexible.acfeCleanLayouts($_layout);
|
730 |
+
|
731 |
+
var parent = $el.closest('.acf-flexible-content').find('> input[type=hidden]').attr('name');
|
732 |
+
|
733 |
+
// Clone
|
734 |
+
var $layout_added = flexible.acfeDuplicate({
|
735 |
+
layout: $_layout,
|
736 |
+
before: $layout,
|
737 |
+
parent: parent
|
738 |
+
});
|
739 |
+
|
740 |
+
}
|
741 |
+
|
742 |
+
// Layout: Copy
|
743 |
+
model.events['click [data-acfe-flexible-control-copy]'] = 'acfeCopyLayout';
|
744 |
+
model.acfeCopyLayout = function(e, $el){
|
745 |
+
|
746 |
+
// Get Flexible
|
747 |
+
var flexible = this;
|
748 |
+
|
749 |
+
// Vars
|
750 |
+
var $layout = $el.closest('.layout').clone();
|
751 |
+
var source = flexible.$control().find('> input[type=hidden]').attr('name');
|
752 |
+
|
753 |
+
// Fix inputs
|
754 |
+
flexible.acfeFixInputs($layout);
|
755 |
+
|
756 |
+
// Clean layout
|
757 |
+
flexible.acfeCleanLayouts($layout);
|
758 |
+
|
759 |
+
// Get layout data
|
760 |
+
var data = JSON.stringify({
|
761 |
+
source: source,
|
762 |
+
layouts: $layout[0].outerHTML
|
763 |
+
});
|
764 |
+
|
765 |
+
// Append Temp Input
|
766 |
+
var $input = $('<input type="text" style="clip:rect(0,0,0,0);clip-path:rect(0,0,0,0);position:absolute;" value="" />').appendTo($('body'));
|
767 |
+
$input.attr('value', data).select();
|
768 |
+
|
769 |
+
// Command: Copy
|
770 |
+
if(document.execCommand('copy'))
|
771 |
+
alert('Layout has been transferred to your clipboard');
|
772 |
+
|
773 |
+
// Prompt
|
774 |
+
else
|
775 |
+
prompt('Copy the following layout data to your clipboard', data);
|
776 |
+
|
777 |
+
// Remove the temp input
|
778 |
+
$input.remove();
|
779 |
+
|
780 |
+
}
|
781 |
+
|
782 |
+
// Flexible: Copy Layouts
|
783 |
+
model.acfeCopyLayouts = function(){
|
784 |
+
|
785 |
+
// Get Flexible
|
786 |
+
var flexible = this;
|
787 |
+
|
788 |
+
// Get layouts
|
789 |
+
var $layouts = flexible.$layoutsWrap().clone();
|
790 |
+
var source = flexible.$control().find('> input[type=hidden]').attr('name');
|
791 |
+
|
792 |
+
// Fix inputs
|
793 |
+
flexible.acfeFixInputs($layouts);
|
794 |
+
|
795 |
+
// Clean layout
|
796 |
+
flexible.acfeCleanLayouts($layouts);
|
797 |
+
|
798 |
+
// Get layouts data
|
799 |
+
var data = JSON.stringify({
|
800 |
+
source: source,
|
801 |
+
layouts: $layouts.html()
|
802 |
+
});
|
803 |
+
|
804 |
+
// Append Temp Input
|
805 |
+
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);
|
806 |
+
$input.attr('value', data).select();
|
807 |
+
|
808 |
+
// Command: Copy
|
809 |
+
if(document.execCommand('copy'))
|
810 |
+
alert('Layouts have been transferred to your clipboard');
|
811 |
+
|
812 |
+
// Prompt
|
813 |
+
else
|
814 |
+
prompt('Copy the following layouts data to your clipboard', data);
|
815 |
+
|
816 |
+
$input.remove();
|
817 |
+
|
818 |
+
}
|
819 |
+
|
820 |
+
// Flexible: Paste Layouts
|
821 |
+
model.acfePasteLayouts = function(){
|
822 |
+
|
823 |
+
// Get Flexible
|
824 |
+
var flexible = this;
|
825 |
+
|
826 |
+
var paste = prompt('Paste layouts data in the following field');
|
827 |
+
|
828 |
+
// No input
|
829 |
+
if(paste == null || paste === '')
|
830 |
+
return;
|
831 |
+
|
832 |
+
try{
|
833 |
+
|
834 |
+
// Paste HTML
|
835 |
+
var data = JSON.parse(paste);
|
836 |
+
var source = data.source;
|
837 |
+
var $html = $(data.layouts);
|
838 |
+
|
839 |
+
// Parsed layouts
|
840 |
+
var $html_layouts = $html.closest('[data-layout]');
|
841 |
+
|
842 |
+
if(!$html_layouts.length)
|
843 |
+
return alert('No layouts data available');
|
844 |
+
|
845 |
+
// Popup min/max
|
846 |
+
var $popup = $(flexible.$popup().html());
|
847 |
+
var $layouts = flexible.$layouts();
|
848 |
+
|
849 |
+
var countLayouts = function(name){
|
850 |
+
return $layouts.filter(function(){
|
851 |
+
return $(this).data('layout') === name;
|
852 |
+
}).length;
|
853 |
+
};
|
854 |
+
|
855 |
+
// init
|
856 |
+
var validated_layouts = [];
|
857 |
+
|
858 |
+
// Each first level layouts
|
859 |
+
$html_layouts.each(function(){
|
860 |
+
|
861 |
+
var $this = $(this);
|
862 |
+
var layout_name = $this.data('layout');
|
863 |
+
|
864 |
+
// vars
|
865 |
+
var $a = $popup.find('[data-layout="' + layout_name + '"]');
|
866 |
+
var min = $a.data('min') || 0;
|
867 |
+
var max = $a.data('max') || 0;
|
868 |
+
var count = countLayouts(layout_name);
|
869 |
+
|
870 |
+
// max
|
871 |
+
if(max && count >= max)
|
872 |
+
return;
|
873 |
+
|
874 |
+
// Validate layout against available layouts
|
875 |
+
var get_clone_layout = flexible.$clone($this.attr('data-layout'));
|
876 |
+
|
877 |
+
// Layout is invalid
|
878 |
+
if(!get_clone_layout.length)
|
879 |
+
return;
|
880 |
+
|
881 |
+
// Add validated layout
|
882 |
+
validated_layouts.push($this);
|
883 |
+
|
884 |
+
});
|
885 |
+
|
886 |
+
// Nothing to add
|
887 |
+
if(!validated_layouts.length)
|
888 |
+
return alert('No layouts could be pasted');
|
889 |
+
|
890 |
+
// Add layouts
|
891 |
+
$.each(validated_layouts, function(){
|
892 |
+
|
893 |
+
var $layout = $(this);
|
894 |
+
var search = source + '[' + $layout.attr('data-id') + ']';
|
895 |
+
var target = flexible.$control().find('> input[type=hidden]').attr('name');
|
896 |
+
|
897 |
+
flexible.acfeDuplicate({
|
898 |
+
layout: $layout,
|
899 |
+
before: false,
|
900 |
+
search: search,
|
901 |
+
parent: target
|
902 |
+
});
|
903 |
+
|
904 |
+
});
|
905 |
+
|
906 |
+
}catch(e){
|
907 |
+
|
908 |
+
console.log(e);
|
909 |
+
alert('Invalid data');
|
910 |
+
|
911 |
+
}
|
912 |
+
|
913 |
+
}
|
914 |
+
|
915 |
+
// Flexible: Dropdown
|
916 |
+
model.events['click [data-name="acfe-flexible-control-button"]'] = 'acfeControl';
|
917 |
+
model.acfeControl = function(e, $el){
|
918 |
+
|
919 |
+
// Get Flexible
|
920 |
+
var flexible = this;
|
921 |
+
|
922 |
+
// Vars
|
923 |
+
var $dropdown = $el.next('.tmpl-acfe-flexible-control-popup').html();
|
924 |
+
|
925 |
+
// Init Popup
|
926 |
+
var Popup = acf.models.TooltipConfirm.extend({
|
927 |
+
render: function(){
|
928 |
+
this.html(this.get('text'));
|
929 |
+
this.$el.addClass('acf-fc-popup');
|
930 |
+
}
|
931 |
+
});
|
932 |
+
|
933 |
+
// New Popup
|
934 |
+
var popup = new Popup({
|
935 |
+
target: $el,
|
936 |
+
targetConfirm: false,
|
937 |
+
text: $dropdown,
|
938 |
+
context: flexible,
|
939 |
+
confirm: function(e, $el){
|
940 |
+
|
941 |
+
if($el.attr('data-acfe-flexible-control-action') === 'paste')
|
942 |
+
flexible.acfePasteLayouts();
|
943 |
+
|
944 |
+
else if($el.attr('data-acfe-flexible-control-action') === 'copy')
|
945 |
+
flexible.acfeCopyLayouts();
|
946 |
+
|
947 |
+
}
|
948 |
+
});
|
949 |
+
|
950 |
+
popup.on('click', 'a', 'onConfirm');
|
951 |
+
|
952 |
+
}
|
953 |
+
|
954 |
+
// Flexible: Duplicate
|
955 |
+
model.acfeDuplicate = function(args){
|
956 |
+
|
957 |
+
// Arguments
|
958 |
+
args = acf.parseArgs(args, {
|
959 |
+
layout: '',
|
960 |
+
before: false,
|
961 |
+
parent: false,
|
962 |
+
search: '',
|
963 |
+
replace: '',
|
964 |
+
});
|
965 |
+
|
966 |
+
// Validate
|
967 |
+
if(!this.allowAdd())
|
968 |
+
return false;
|
969 |
+
|
970 |
+
var uniqid = acf.uniqid();
|
971 |
+
|
972 |
+
if(args.parent){
|
973 |
+
|
974 |
+
if(!args.search){
|
975 |
+
|
976 |
+
args.search = args.parent + '[' + args.layout.attr('data-id') + ']';
|
977 |
+
|
978 |
+
}
|
979 |
+
|
980 |
+
args.replace = args.parent + '[' + uniqid + ']';
|
981 |
+
|
982 |
+
}
|
983 |
+
|
984 |
+
var duplicate_args = {
|
985 |
+
target: args.layout,
|
986 |
+
search: args.search,
|
987 |
+
replace: args.replace,
|
988 |
+
append: this.proxy(function($el, $el2){
|
989 |
+
|
990 |
+
// Add class to duplicated layout
|
991 |
+
$el2.addClass('acfe-layout-duplicated');
|
992 |
+
|
993 |
+
// Reset UniqID
|
994 |
+
$el2.attr('data-id', uniqid);
|
995 |
+
|
996 |
+
// append before
|
997 |
+
if(args.before){
|
998 |
+
|
999 |
+
// Fix clone: Use after() instead of native before()
|
1000 |
+
args.before.after($el2);
|
1001 |
+
|
1002 |
+
}
|
1003 |
+
|
1004 |
+
// append end
|
1005 |
+
else{
|
1006 |
+
|
1007 |
+
this.$layoutsWrap().append($el2);
|
1008 |
+
|
1009 |
+
}
|
1010 |
+
|
1011 |
+
// enable
|
1012 |
+
acf.enable($el2, this.cid);
|
1013 |
+
|
1014 |
+
// render
|
1015 |
+
this.render();
|
1016 |
+
|
1017 |
+
})
|
1018 |
+
}
|
1019 |
+
|
1020 |
+
var acfVersion = parseFloat(acf.get('acf_version'));
|
1021 |
+
|
1022 |
+
if(acfVersion < 5.9){
|
1023 |
+
|
1024 |
+
// Add row
|
1025 |
+
var $el = acf.duplicate(duplicate_args);
|
1026 |
+
|
1027 |
+
// Hotfix for ACF Pro 5.9
|
1028 |
+
}else{
|
1029 |
+
|
1030 |
+
// Add row
|
1031 |
+
var $el = model.acfeNewAcfDuplicate(duplicate_args);
|
1032 |
+
|
1033 |
+
}
|
1034 |
+
|
1035 |
+
// trigger change for validation errors
|
1036 |
+
this.$input().trigger('change');
|
1037 |
+
|
1038 |
+
// Fix tabs conditionally hidden
|
1039 |
+
var tabs = acf.getFields({
|
1040 |
+
type: 'tab',
|
1041 |
+
parent: $el,
|
1042 |
+
});
|
1043 |
+
|
1044 |
+
if(tabs.length){
|
1045 |
+
|
1046 |
+
$.each(tabs, function(){
|
1047 |
+
|
1048 |
+
if(this.$el.hasClass('acf-hidden')){
|
1049 |
+
|
1050 |
+
this.tab.$el.addClass('acf-hidden');
|
1051 |
+
|
1052 |
+
}
|
1053 |
+
|
1054 |
+
});
|
1055 |
+
|
1056 |
+
}
|
1057 |
+
|
1058 |
+
|
1059 |
+
// return
|
1060 |
+
return $el;
|
1061 |
+
|
1062 |
+
}
|
1063 |
+
|
1064 |
+
/*
|
1065 |
+
* Based on acf.duplicate (5.9)
|
1066 |
+
*
|
1067 |
+
* doAction('duplicate) has been commented out
|
1068 |
+
* This fix an issue with the WYSIWYG editor field during copy/paste since ACF 5.9
|
1069 |
+
*/
|
1070 |
+
model.acfeNewAcfDuplicate = function( args ){
|
1071 |
+
|
1072 |
+
// allow jQuery
|
1073 |
+
if( args instanceof jQuery ) {
|
1074 |
+
args = {
|
1075 |
+
target: args
|
1076 |
+
};
|
1077 |
+
}
|
1078 |
+
|
1079 |
+
// defaults
|
1080 |
+
args = acf.parseArgs(args, {
|
1081 |
+
target: false,
|
1082 |
+
search: '',
|
1083 |
+
replace: '',
|
1084 |
+
rename: true,
|
1085 |
+
before: function( $el ){},
|
1086 |
+
after: function( $el, $el2 ){},
|
1087 |
+
append: function( $el, $el2 ){
|
1088 |
+
$el.after( $el2 );
|
1089 |
+
}
|
1090 |
+
});
|
1091 |
+
|
1092 |
+
// compatibility
|
1093 |
+
args.target = args.target || args.$el;
|
1094 |
+
|
1095 |
+
// vars
|
1096 |
+
var $el = args.target;
|
1097 |
+
|
1098 |
+
// search
|
1099 |
+
args.search = args.search || $el.attr('data-id');
|
1100 |
+
args.replace = args.replace || acf.uniqid();
|
1101 |
+
|
1102 |
+
// before
|
1103 |
+
// - allow acf to modify DOM
|
1104 |
+
// - fixes bug where select field option is not selected
|
1105 |
+
args.before( $el );
|
1106 |
+
acf.doAction('before_duplicate', $el);
|
1107 |
+
|
1108 |
+
// clone
|
1109 |
+
var $el2 = $el.clone();
|
1110 |
+
|
1111 |
+
// rename
|
1112 |
+
if( args.rename ) {
|
1113 |
+
acf.rename({
|
1114 |
+
target: $el2,
|
1115 |
+
search: args.search,
|
1116 |
+
replace: args.replace,
|
1117 |
+
replacer: ( typeof args.rename === 'function' ? args.rename : null )
|
1118 |
+
});
|
1119 |
+
}
|
1120 |
+
|
1121 |
+
// remove classes
|
1122 |
+
$el2.removeClass('acf-clone');
|
1123 |
+
$el2.find('.ui-sortable').removeClass('ui-sortable');
|
1124 |
+
|
1125 |
+
// after
|
1126 |
+
// - allow acf to modify DOM
|
1127 |
+
args.after( $el, $el2 );
|
1128 |
+
acf.doAction('after_duplicate', $el, $el2 );
|
1129 |
+
|
1130 |
+
// append
|
1131 |
+
args.append( $el, $el2 );
|
1132 |
+
|
1133 |
+
/**
|
1134 |
+
* Fires after an element has been duplicated and appended to the DOM.
|
1135 |
+
*
|
1136 |
+
* @date 30/10/19
|
1137 |
+
* @since 5.8.7
|
1138 |
+
*
|
1139 |
+
* @param jQuery $el The original element.
|
1140 |
+
* @param jQuery $el2 The duplicated element.
|
1141 |
+
*/
|
1142 |
+
//acf.doAction('duplicate', $el, $el2 );
|
1143 |
+
|
1144 |
+
// append
|
1145 |
+
acf.doAction('append', $el2);
|
1146 |
+
|
1147 |
+
// return
|
1148 |
+
return $el2;
|
1149 |
+
};
|
1150 |
+
|
1151 |
+
// Flexible: Fix Inputs
|
1152 |
+
model.acfeFixInputs = function($layout){
|
1153 |
+
|
1154 |
+
$layout.find('input').each(function(){
|
1155 |
+
|
1156 |
+
$(this).attr('value', this.value);
|
1157 |
+
|
1158 |
+
});
|
1159 |
+
|
1160 |
+
$layout.find('textarea').each(function(){
|
1161 |
+
|
1162 |
+
$(this).html(this.value);
|
1163 |
+
|
1164 |
+
});
|
1165 |
+
|
1166 |
+
$layout.find('input:radio,input:checkbox').each(function() {
|
1167 |
+
|
1168 |
+
if(this.checked)
|
1169 |
+
$(this).attr('checked', 'checked');
|
1170 |
+
|
1171 |
+
else
|
1172 |
+
$(this).attr('checked', false);
|
1173 |
+
|
1174 |
+
});
|
1175 |
+
|
1176 |
+
$layout.find('option').each(function(){
|
1177 |
+
|
1178 |
+
if(this.selected)
|
1179 |
+
$(this).attr('selected', 'selected');
|
1180 |
+
|
1181 |
+
else
|
1182 |
+
$(this).attr('selected', false);
|
1183 |
+
|
1184 |
+
});
|
1185 |
+
|
1186 |
+
}
|
1187 |
+
|
1188 |
+
// Flexible: Clean Layout
|
1189 |
+
model.acfeCleanLayouts = function($layout){
|
1190 |
+
|
1191 |
+
// Clean WP Editor
|
1192 |
+
$layout.find('.acf-editor-wrap').each(function(){
|
1193 |
+
|
1194 |
+
var $input = $(this);
|
1195 |
+
|
1196 |
+
$input.find('.wp-editor-container div').remove();
|
1197 |
+
$input.find('.wp-editor-container textarea').css('display', '');
|
1198 |
+
|
1199 |
+
});
|
1200 |
+
|
1201 |
+
// Clean Date
|
1202 |
+
$layout.find('.acf-date-picker').each(function(){
|
1203 |
+
|
1204 |
+
var $input = $(this);
|
1205 |
+
|
1206 |
+
$input.find('input.input').removeClass('hasDatepicker').removeAttr('id');
|
1207 |
+
|
1208 |
+
});
|
1209 |
+
|
1210 |
+
// Clean Time
|
1211 |
+
$layout.find('.acf-time-picker').each(function(){
|
1212 |
+
|
1213 |
+
var $input = $(this);
|
1214 |
+
|
1215 |
+
$input.find('input.input').removeClass('hasDatepicker').removeAttr('id');
|
1216 |
+
|
1217 |
+
});
|
1218 |
+
|
1219 |
+
// Clean DateTime
|
1220 |
+
$layout.find('.acf-date-time-picker').each(function(){
|
1221 |
+
|
1222 |
+
var $input = $(this);
|
1223 |
+
|
1224 |
+
$input.find('input.input').removeClass('hasDatepicker').removeAttr('id');
|
1225 |
+
|
1226 |
+
});
|
1227 |
+
|
1228 |
+
// Clean Code Editor
|
1229 |
+
$layout.find('.acfe-field-code-editor').each(function(){
|
1230 |
+
|
1231 |
+
var $input = $(this);
|
1232 |
+
|
1233 |
+
$input.find('.CodeMirror').remove();
|
1234 |
+
|
1235 |
+
});
|
1236 |
+
|
1237 |
+
// Clean Color Picker
|
1238 |
+
$layout.find('.acf-color-picker').each(function(){
|
1239 |
+
|
1240 |
+
var $input = $(this);
|
1241 |
+
|
1242 |
+
var $color_picker = $input.find('> input');
|
1243 |
+
var $color_picker_proxy = $input.find('.wp-picker-container input.wp-color-picker').clone();
|
1244 |
+
|
1245 |
+
$color_picker.after($color_picker_proxy);
|
1246 |
+
|
1247 |
+
$input.find('.wp-picker-container').remove();
|
1248 |
+
|
1249 |
+
});
|
1250 |
+
|
1251 |
+
// Clean Post Object
|
1252 |
+
$layout.find('.acf-field-post-object').each(function(){
|
1253 |
+
|
1254 |
+
var $input = $(this);
|
1255 |
+
|
1256 |
+
$input.find('> .acf-input span').remove();
|
1257 |
+
|
1258 |
+
$input.find('> .acf-input select').removeAttr('tabindex aria-hidden').removeClass();
|
1259 |
+
|
1260 |
+
});
|
1261 |
+
|
1262 |
+
// Clean Page Link
|
1263 |
+
$layout.find('.acf-field-page-link').each(function(){
|
1264 |
+
|
1265 |
+
var $input = $(this);
|
1266 |
+
|
1267 |
+
$input.find('> .acf-input span').remove();
|
1268 |
+
|
1269 |
+
$input.find('> .acf-input select').removeAttr('tabindex aria-hidden').removeClass();
|
1270 |
+
|
1271 |
+
});
|
1272 |
+
|
1273 |
+
// Clean Select2
|
1274 |
+
$layout.find('.acf-field-select').each(function(){
|
1275 |
+
|
1276 |
+
var $input = $(this);
|
1277 |
+
|
1278 |
+
$input.find('> .acf-input span').remove();
|
1279 |
+
|
1280 |
+
$input.find('> .acf-input select').removeAttr('tabindex aria-hidden').removeClass();
|
1281 |
+
|
1282 |
+
});
|
1283 |
+
|
1284 |
+
// Clean FontAwesome
|
1285 |
+
$layout.find('.acf-field-font-awesome').each(function(){
|
1286 |
+
|
1287 |
+
var $input = $(this);
|
1288 |
+
|
1289 |
+
$input.find('> .acf-input span').remove();
|
1290 |
+
|
1291 |
+
$input.find('> .acf-input select').removeAttr('tabindex aria-hidden');
|
1292 |
+
|
1293 |
+
});
|
1294 |
+
|
1295 |
+
|
1296 |
+
// Clean Tab
|
1297 |
+
$layout.find('.acf-tab-wrap').each(function(){
|
1298 |
+
|
1299 |
+
var $wrap = $(this);
|
1300 |
+
|
1301 |
+
var $content = $wrap.closest('.acf-fields');
|
1302 |
+
|
1303 |
+
var tabs = [];
|
1304 |
+
$.each($wrap.find('li a'), function(){
|
1305 |
+
|
1306 |
+
tabs.push($(this));
|
1307 |
+
|
1308 |
+
});
|
1309 |
+
|
1310 |
+
$content.find('> .acf-field-tab').each(function(){
|
1311 |
+
|
1312 |
+
$current_tab = $(this);
|
1313 |
+
|
1314 |
+
$.each(tabs, function(){
|
1315 |
+
|
1316 |
+
var $this = $(this);
|
1317 |
+
|
1318 |
+
if($this.attr('data-key') !== $current_tab.attr('data-key'))
|
1319 |
+
return;
|
1320 |
+
|
1321 |
+
$current_tab.find('> .acf-input').append($this);
|
1322 |
+
|
1323 |
+
});
|
1324 |
+
|
1325 |
+
});
|
1326 |
+
|
1327 |
+
$wrap.remove();
|
1328 |
+
|
1329 |
+
});
|
1330 |
+
|
1331 |
+
// Clean Accordion
|
1332 |
+
$layout.find('.acf-field-accordion').each(function(){
|
1333 |
+
|
1334 |
+
var $input = $(this);
|
1335 |
+
|
1336 |
+
$input.find('> .acf-accordion-title > .acf-accordion-icon').remove();
|
1337 |
+
|
1338 |
+
// Append virtual endpoint after each accordion
|
1339 |
+
$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>');
|
1340 |
+
|
1341 |
+
});
|
1342 |
+
|
1343 |
+
}
|
1344 |
+
|
1345 |
+
/*
|
1346 |
+
* Spawn
|
1347 |
+
*/
|
1348 |
+
acf.addAction('new_field/type=flexible_content', function(flexible){
|
1349 |
+
|
1350 |
+
// ACFE: Lock
|
1351 |
+
if(flexible.has('acfeFlexibleLock')){
|
1352 |
+
|
1353 |
+
flexible.removeEvents({'mouseover': 'onHover'});
|
1354 |
+
|
1355 |
+
}
|
1356 |
+
|
1357 |
+
});
|
1358 |
+
|
1359 |
})(jQuery);
|
1360 |
+
(function($){
|
1361 |
+
|
1362 |
+
if(typeof acf === 'undefined')
|
1363 |
+
return;
|
1364 |
+
|
1365 |
+
/*
|
1366 |
+
* Init
|
1367 |
+
*/
|
1368 |
+
var flexible = acf.getFieldType('flexible_content');
|
1369 |
+
var model = flexible.prototype;
|
1370 |
+
|
1371 |
+
/*
|
1372 |
+
* Actions
|
1373 |
+
*/
|
1374 |
+
model.acfeModalSelect = function(e, $el){
|
1375 |
+
|
1376 |
+
// Get Flexible
|
1377 |
+
var flexible = this;
|
1378 |
+
|
1379 |
+
// Validate
|
1380 |
+
if(!flexible.validateAdd())
|
1381 |
+
return false;
|
1382 |
+
|
1383 |
+
// Layout
|
1384 |
+
var $layout_source = null;
|
1385 |
+
|
1386 |
+
if($el.hasClass('acf-icon'))
|
1387 |
+
$layout_source = $el.closest('.layout');
|
1388 |
+
|
1389 |
+
// Get Available Layouts
|
1390 |
+
var layouts = flexible.getPopupHTML();
|
1391 |
+
|
1392 |
+
// Init Categories
|
1393 |
+
var categories = {
|
1394 |
+
array: [],
|
1395 |
+
html: ''
|
1396 |
+
};
|
1397 |
+
|
1398 |
+
function SearchArray(element, array){
|
1399 |
+
|
1400 |
+
var len = array.length,
|
1401 |
+
str = element.toString().toLowerCase();
|
1402 |
+
|
1403 |
+
for(var i = 0; i < len; i++){
|
1404 |
+
if(array[i].toLowerCase() === str){
|
1405 |
+
return i;
|
1406 |
+
}
|
1407 |
+
}
|
1408 |
+
|
1409 |
+
return -1;
|
1410 |
+
|
1411 |
+
}
|
1412 |
+
|
1413 |
+
// Get Categories
|
1414 |
+
$(layouts).find('li a span[data-acfe-flexible-category]').each(function(){
|
1415 |
+
|
1416 |
+
var spanCats = $(this).data('acfe-flexible-category');
|
1417 |
+
|
1418 |
+
$.each(spanCats, function(){
|
1419 |
+
|
1420 |
+
if(SearchArray(this, categories.array) !== -1)
|
1421 |
+
return;
|
1422 |
+
|
1423 |
+
categories.array.push(this);
|
1424 |
+
|
1425 |
+
});
|
1426 |
+
|
1427 |
+
});
|
1428 |
+
|
1429 |
+
// Categories HTML
|
1430 |
+
if(categories.array.length){
|
1431 |
+
|
1432 |
+
categories.array.sort();
|
1433 |
+
|
1434 |
+
categories.html += '<h2 class="acfe-flexible-categories nav-tab-wrapper">';
|
1435 |
+
|
1436 |
+
categories.html += '<a href="#" data-acfe-flexible-category="acfe-all" class="nav-tab nav-tab-active"><span class="dashicons dashicons-menu"></span></a>';
|
1437 |
+
|
1438 |
+
$(categories.array).each(function(k, category){
|
1439 |
+
|
1440 |
+
categories.html += '<a href="#" data-acfe-flexible-category="' + category + '" class="nav-tab">' + category + '</a>';
|
1441 |
+
|
1442 |
+
});
|
1443 |
+
|
1444 |
+
categories.html += '</h2>';
|
1445 |
+
|
1446 |
+
}
|
1447 |
+
|
1448 |
+
// Modal Title
|
1449 |
+
var modalTitle = acf.__('Add Row');
|
1450 |
+
|
1451 |
+
if(flexible.has('acfeFlexibleModalTitle')){
|
1452 |
+
modalTitle = flexible.get('acfeFlexibleModalTitle');
|
1453 |
+
}
|
1454 |
+
|
1455 |
+
// Create Modal
|
1456 |
+
var $modal = $('' +
|
1457 |
+
'<div class="acfe-modal">' +
|
1458 |
+
|
1459 |
+
categories.html +
|
1460 |
+
'<div class="acfe-flex-container">' +
|
1461 |
+
layouts +
|
1462 |
+
'</div>' +
|
1463 |
+
|
1464 |
+
'</div>'
|
1465 |
+
|
1466 |
+
).appendTo('body');
|
1467 |
+
|
1468 |
+
// Open Modal
|
1469 |
+
new acfe.Popup($modal, {
|
1470 |
+
title: modalTitle,
|
1471 |
+
size: 'full',
|
1472 |
+
destroy: true
|
1473 |
+
});
|
1474 |
+
|
1475 |
+
// Modal: Columns
|
1476 |
+
if(flexible.has('acfeFlexibleModalCol')){
|
1477 |
+
|
1478 |
+
$modal.find('.acfe-modal-content .acfe-flex-container').addClass('acfe-col-' + flexible.get('acfeFlexibleModalCol'));
|
1479 |
+
|
1480 |
+
}
|
1481 |
+
|
1482 |
+
// Modal: Columns
|
1483 |
+
if(flexible.has('acfeFlexibleThumbnails')){
|
1484 |
+
|
1485 |
+
$modal.find('.acfe-modal-content .acfe-flex-container').addClass('acfe-flex-thumbnails');
|
1486 |
+
|
1487 |
+
}
|
1488 |
+
|
1489 |
+
// Modal: ACF autofocus fix
|
1490 |
+
$modal.find('li:first-of-type a').blur();
|
1491 |
+
|
1492 |
+
// Modal: Layouts Badges
|
1493 |
+
$modal.find('li a span.badge').each(function(){
|
1494 |
+
|
1495 |
+
$(this).addClass('acf-js-tooltip dashicons dashicons-info');
|
1496 |
+
|
1497 |
+
});
|
1498 |
+
|
1499 |
+
// Modal: Categories Click
|
1500 |
+
$modal.find('.acfe-flexible-categories a').click(function(e){
|
1501 |
+
|
1502 |
+
e.preventDefault();
|
1503 |
+
|
1504 |
+
var $link = $(this);
|
1505 |
+
|
1506 |
+
$link.closest('.acfe-flexible-categories').find('a').removeClass('nav-tab-active');
|
1507 |
+
$link.addClass('nav-tab-active');
|
1508 |
+
|
1509 |
+
var selected_category = $link.data('acfe-flexible-category');
|
1510 |
+
|
1511 |
+
$modal.find('a[data-layout] span[data-acfe-flexible-category]').each(function(){
|
1512 |
+
|
1513 |
+
// Get span
|
1514 |
+
var $span = $(this);
|
1515 |
+
|
1516 |
+
// Show All
|
1517 |
+
$span.closest('li').show();
|
1518 |
+
|
1519 |
+
var category = $span.data('acfe-flexible-category');
|
1520 |
+
|
1521 |
+
// Specific category
|
1522 |
+
if(selected_category !== 'acfe-all'){
|
1523 |
+
|
1524 |
+
// Hide All
|
1525 |
+
$span.closest('li').hide();
|
1526 |
+
|
1527 |
+
$.each(category, function(i, c){
|
1528 |
+
|
1529 |
+
if(selected_category.toLowerCase() === c.toLowerCase()){
|
1530 |
+
|
1531 |
+
$span.closest('li').show();
|
1532 |
+
|
1533 |
+
return false;
|
1534 |
+
|
1535 |
+
}
|
1536 |
+
|
1537 |
+
});
|
1538 |
+
|
1539 |
+
}
|
1540 |
+
|
1541 |
+
});
|
1542 |
+
|
1543 |
+
});
|
1544 |
+
|
1545 |
+
// Modal: Click Add Layout
|
1546 |
+
$modal.on('click', 'a[data-layout]', function(e){
|
1547 |
+
|
1548 |
+
e.preventDefault();
|
1549 |
+
|
1550 |
+
// Close modal
|
1551 |
+
acfe.closePopup();
|
1552 |
+
|
1553 |
+
// Add layout
|
1554 |
+
flexible.add({
|
1555 |
+
layout: $(this).data('layout'),
|
1556 |
+
before: $layout_source
|
1557 |
+
});
|
1558 |
+
|
1559 |
+
});
|
1560 |
+
|
1561 |
+
}
|
1562 |
+
|
1563 |
+
/*
|
1564 |
+
* Spawn
|
1565 |
+
*/
|
1566 |
+
acf.addAction('new_field/type=flexible_content', function(flexible){
|
1567 |
+
|
1568 |
+
if(!flexible.has('acfeFlexibleModal'))
|
1569 |
+
return;
|
1570 |
+
|
1571 |
+
// Vars
|
1572 |
+
var $clones = flexible.$clones();
|
1573 |
+
|
1574 |
+
if($clones.length <= 1)
|
1575 |
+
return;
|
1576 |
+
|
1577 |
+
// Remove native ACF Tooltip action
|
1578 |
+
flexible.removeEvents({'click [data-name="add-layout"]': 'onClickAdd'});
|
1579 |
+
|
1580 |
+
// Add ACF Extended Modal action
|
1581 |
+
flexible.addEvents({'click [data-name="add-layout"]': 'acfeModalSelect'});
|
1582 |
+
|
1583 |
+
});
|
1584 |
+
|
1585 |
})(jQuery);
|
1586 |
+
(function($){
|
1587 |
+
|
1588 |
+
if(typeof acf === 'undefined')
|
1589 |
+
return;
|
1590 |
+
|
1591 |
+
/*
|
1592 |
+
* Init
|
1593 |
+
*/
|
1594 |
+
var flexible = acf.getFieldType('flexible_content');
|
1595 |
+
var model = flexible.prototype;
|
1596 |
+
|
1597 |
+
/*
|
1598 |
+
* Actions
|
1599 |
+
*/
|
1600 |
+
model.events['click [data-action="acfe-flexible-modal-edit"]'] = 'acfeModalEdit';
|
1601 |
+
model.acfeModalEdit = function(e, $el){
|
1602 |
+
|
1603 |
+
var flexible = this;
|
1604 |
+
|
1605 |
+
// Layout
|
1606 |
+
var $layout = $el.closest('.layout');
|
1607 |
+
|
1608 |
+
// Modal data
|
1609 |
+
var $modal = $layout.find('> .acfe-modal.-fields');
|
1610 |
+
var $handle = $layout.find('> .acf-fc-layout-handle');
|
1611 |
+
|
1612 |
+
var $layout_order = $handle.find('> .acf-fc-layout-order').outerHTML();
|
1613 |
+
var $layout_title = $handle.find('.acfe-layout-title-text').text();
|
1614 |
+
|
1615 |
+
var close = false;
|
1616 |
+
if(flexible.has('acfeFlexibleCloseButton')){
|
1617 |
+
|
1618 |
+
close = acf.__('Close');
|
1619 |
+
|
1620 |
+
}
|
1621 |
+
|
1622 |
+
// Open modal
|
1623 |
+
new acfe.Popup($modal, {
|
1624 |
+
title: $layout_order + ' ' + $layout_title,
|
1625 |
+
footer: close,
|
1626 |
+
onOpen: function(){
|
1627 |
+
|
1628 |
+
flexible.openLayout($layout);
|
1629 |
+
|
1630 |
+
},
|
1631 |
+
onClose: function(){
|
1632 |
+
|
1633 |
+
flexible.closeLayout($layout);
|
1634 |
+
|
1635 |
+
}
|
1636 |
+
});
|
1637 |
+
|
1638 |
+
};
|
1639 |
+
|
1640 |
+
/*
|
1641 |
+
* Spawn
|
1642 |
+
*/
|
1643 |
+
acf.addAction('new_field/type=flexible_content', function(flexible){
|
1644 |
+
|
1645 |
+
if(flexible.has('acfeFlexibleModalEdition') && (flexible.has('acfeFlexiblePlaceholder') || flexible.has('acfeFlexiblePreview'))){
|
1646 |
+
|
1647 |
+
// Remove Collapse Action
|
1648 |
+
flexible.removeEvents({'click [data-name="collapse-layout"]': 'onClickCollapse'});
|
1649 |
+
|
1650 |
+
// Remove placeholder Collapse Action
|
1651 |
+
flexible.removeEvents({'click .acfe-fc-placeholder': 'onClickCollapse'});
|
1652 |
+
|
1653 |
+
}
|
1654 |
+
|
1655 |
+
});
|
1656 |
+
|
1657 |
})(jQuery);
|
1658 |
+
/*
|
1659 |
+
* Field: reCaptcha Callback
|
1660 |
+
*/
|
1661 |
+
function acfe_recaptcha(){
|
1662 |
+
|
1663 |
+
(function($){
|
1664 |
+
|
1665 |
+
if(typeof acf === 'undefined')
|
1666 |
+
return;
|
1667 |
+
|
1668 |
+
$.each(acf.getFields({type: 'acfe_recaptcha'}), function(){
|
1669 |
+
this.render();
|
1670 |
+
});
|
1671 |
+
|
1672 |
+
})(jQuery);
|
1673 |
+
|
1674 |
+
}
|
1675 |
+
|
1676 |
+
(function($){
|
1677 |
+
|
1678 |
+
if(typeof acf === 'undefined')
|
1679 |
+
return;
|
1680 |
+
|
1681 |
+
/*
|
1682 |
+
* Field: reCaptcha
|
1683 |
+
*/
|
1684 |
+
var reCaptcha = acf.Field.extend({
|
1685 |
+
|
1686 |
+
type: 'acfe_recaptcha',
|
1687 |
+
|
1688 |
+
actions: {
|
1689 |
+
'validation_failure' : 'validationFailure'
|
1690 |
+
},
|
1691 |
+
|
1692 |
+
$control: function(){
|
1693 |
+
return this.$('.acfe-field-recaptcha');
|
1694 |
+
},
|
1695 |
+
|
1696 |
+
$input: function(){
|
1697 |
+
return this.$('input[type="hidden"]');
|
1698 |
+
},
|
1699 |
+
|
1700 |
+
$selector: function(){
|
1701 |
+
return this.$control().find('> div');
|
1702 |
+
},
|
1703 |
+
|
1704 |
+
selector: function(){
|
1705 |
+
return this.$selector()[0];
|
1706 |
+
},
|
1707 |
+
|
1708 |
+
version: function(){
|
1709 |
+
return this.get('version');
|
1710 |
+
},
|
1711 |
+
|
1712 |
+
render: function(){
|
1713 |
+
|
1714 |
+
var field = this;
|
1715 |
+
|
1716 |
+
if(this.version() === 'v2'){
|
1717 |
+
|
1718 |
+
this.recaptcha = grecaptcha.render(field.selector(), {
|
1719 |
+
'sitekey': field.$control().data('site-key'),
|
1720 |
+
'theme': field.$control().data('theme'),
|
1721 |
+
'size': field.$control().data('size'),
|
1722 |
+
|
1723 |
+
|
1724 |
+
'callback': function(response){
|
1725 |
+
|
1726 |
+
field.$input().val(response).change();
|
1727 |
+
field.$input().closest('.acf-input').find('> .acf-notice.-error').hide();
|
1728 |
+
|
1729 |
+
},
|
1730 |
+
|
1731 |
+
'error-callback': function(){
|
1732 |
+
|
1733 |
+
field.$input().val('error').change();
|
1734 |
+
|
1735 |
+
},
|
1736 |
+
|
1737 |
+
'expired-callback': function(){
|
1738 |
+
|
1739 |
+
field.$input().val('expired').change();
|
1740 |
+
|
1741 |
+
}
|
1742 |
+
});
|
1743 |
+
|
1744 |
+
}
|
1745 |
+
|
1746 |
+
else if(this.version() === 'v3'){
|
1747 |
+
|
1748 |
+
grecaptcha.ready(function(){
|
1749 |
+
grecaptcha.execute(field.$control().data('site-key'), {action: 'homepage'}).then(function(response){
|
1750 |
+
|
1751 |
+
field.$input().val(response).change();
|
1752 |
+
field.$input().closest('.acf-input').find('> .acf-notice.-error').hide();
|
1753 |
+
|
1754 |
+
});
|
1755 |
+
});
|
1756 |
+
|
1757 |
+
}
|
1758 |
+
|
1759 |
+
},
|
1760 |
+
|
1761 |
+
validationFailure: function($form){
|
1762 |
+
|
1763 |
+
if(this.version() === 'v2'){
|
1764 |
+
|
1765 |
+
grecaptcha.reset(this.recaptcha);
|
1766 |
+
|
1767 |
+
}
|
1768 |
+
|
1769 |
+
}
|
1770 |
+
|
1771 |
+
});
|
1772 |
+
|
1773 |
+
acf.registerFieldType(reCaptcha);
|
1774 |
+
|
1775 |
+
/*
|
1776 |
+
* Field: Code Editor
|
1777 |
+
*/
|
1778 |
+
var CodeEditor = acf.Field.extend({
|
1779 |
+
|
1780 |
+
wait: 'ready',
|
1781 |
+
|
1782 |
+
type: 'acfe_code_editor',
|
1783 |
+
|
1784 |
+
events: {
|
1785 |
+
'showField': 'onShow',
|
1786 |
+
},
|
1787 |
+
|
1788 |
+
$control: function(){
|
1789 |
+
|
1790 |
+
return this.$el.find('> .acf-input > .acf-input-wrap');
|
1791 |
+
|
1792 |
+
},
|
1793 |
+
|
1794 |
+
$input: function(){
|
1795 |
+
|
1796 |
+
return this.$el.find('> .acf-input > .acf-input-wrap > textarea');
|
1797 |
+
|
1798 |
+
},
|
1799 |
+
|
1800 |
+
input: function(){
|
1801 |
+
|
1802 |
+
return this.$input()[0];
|
1803 |
+
|
1804 |
+
},
|
1805 |
+
|
1806 |
+
rows: function(){
|
1807 |
+
|
1808 |
+
return this.$input().attr('rows');
|
1809 |
+
|
1810 |
+
},
|
1811 |
+
|
1812 |
+
initialize: function(){
|
1813 |
+
|
1814 |
+
this.rows = this.$control().data('rows');
|
1815 |
+
this.max_rows = this.$control().data('max-rows');
|
1816 |
+
|
1817 |
+
this.mode = this.$control().data('mode');
|
1818 |
+
this.lines = this.$control().data('lines');
|
1819 |
+
this.indentUnit = this.$control().data('indent-unit');
|
1820 |
+
|
1821 |
+
var codeEditor = [];
|
1822 |
+
|
1823 |
+
// Default WP settings
|
1824 |
+
var wpCodeMirror = wp.codeEditor.defaultSettings.codemirror;
|
1825 |
+
|
1826 |
+
// Field settings
|
1827 |
+
var CodeMirror = {
|
1828 |
+
lineNumbers: this.lines,
|
1829 |
+
lineWrapping: true,
|
1830 |
+
styleActiveLine: false,
|
1831 |
+
continueComments: true,
|
1832 |
+
indentUnit: this.indentUnit,
|
1833 |
+
tabSize: 1,
|
1834 |
+
indentWithTabs: true,
|
1835 |
+
mode: this.mode,
|
1836 |
+
extraKeys: {
|
1837 |
+
Tab: function(cm){
|
1838 |
+
cm.execCommand("indentMore")
|
1839 |
+
},
|
1840 |
+
"Shift-Tab": function(cm){
|
1841 |
+
cm.execCommand("indentLess")
|
1842 |
+
},
|
1843 |
+
},
|
1844 |
+
};
|
1845 |
+
|
1846 |
+
// Merge settings
|
1847 |
+
var codeMirror = jQuery.extend(wpCodeMirror, CodeMirror);
|
1848 |
+
|
1849 |
+
// Push CodeMirror settings to codemirror property
|
1850 |
+
codeEditor.codemirror = codeMirror;
|
1851 |
+
|
1852 |
+
// Init WP Code Editor
|
1853 |
+
this.editor = wp.codeEditor.initialize(this.input(), codeEditor);
|
1854 |
+
|
1855 |
+
if(this.rows || this.max_rows){
|
1856 |
+
|
1857 |
+
if(this.rows){
|
1858 |
+
|
1859 |
+
this.editor.codemirror.getScrollerElement().style.minHeight = this.rows * 18.5 + 'px';
|
1860 |
+
|
1861 |
+
}
|
1862 |
+
|
1863 |
+
if(this.max_rows){
|
1864 |
+
|
1865 |
+
this.editor.codemirror.getScrollerElement().style.maxHeight = this.max_rows * 18.5 + 'px';
|
1866 |
+
|
1867 |
+
}
|
1868 |
+
|
1869 |
+
this.editor.codemirror.refresh();
|
1870 |
+
|
1871 |
+
}
|
1872 |
+
|
1873 |
+
field = this;
|
1874 |
+
|
1875 |
+
this.editor.codemirror.on('change', function(){
|
1876 |
+
|
1877 |
+
field.editor.codemirror.save();
|
1878 |
+
field.$input().change();
|
1879 |
+
|
1880 |
+
});
|
1881 |
+
|
1882 |
+
},
|
1883 |
+
|
1884 |
+
onShow: function(){
|
1885 |
+
|
1886 |
+
if(this.editor.codemirror){
|
1887 |
+
|
1888 |
+
this.editor.codemirror.refresh();
|
1889 |
+
|
1890 |
+
}
|
1891 |
+
|
1892 |
+
},
|
1893 |
+
|
1894 |
+
});
|
1895 |
+
|
1896 |
+
acf.registerFieldType(CodeEditor);
|
1897 |
+
|
1898 |
+
/*
|
1899 |
+
* Field: Textarea
|
1900 |
+
*/
|
1901 |
+
var Textarea = acf.Field.extend({
|
1902 |
+
|
1903 |
+
type: 'textarea',
|
1904 |
+
|
1905 |
+
events: {
|
1906 |
+
'keydown textarea': 'onInput',
|
1907 |
+
},
|
1908 |
+
|
1909 |
+
onInput: function(e, $el){
|
1910 |
+
|
1911 |
+
if(!this.has('acfeTextareaCode'))
|
1912 |
+
return;
|
1913 |
+
|
1914 |
+
if(e.keyCode !== 9)
|
1915 |
+
return;
|
1916 |
+
|
1917 |
+
e.preventDefault();
|
1918 |
+
|
1919 |
+
var input = this.$el.find('textarea')[0];
|
1920 |
+
|
1921 |
+
var s = input.selectionStart;
|
1922 |
+
|
1923 |
+
this.$el.find('textarea').val(function(i, v){
|
1924 |
+
|
1925 |
+
return v.substring(0, s) + " " + v.substring(input.selectionEnd)
|
1926 |
+
|
1927 |
+
});
|
1928 |
+
|
1929 |
+
input.selectionEnd = s + 4;
|
1930 |
+
|
1931 |
+
},
|
1932 |
+
|
1933 |
+
});
|
1934 |
+
|
1935 |
+
acf.registerFieldType(Textarea);
|
1936 |
+
|
1937 |
+
/*
|
1938 |
+
* Field: Slug
|
1939 |
+
*/
|
1940 |
+
var ACFE_Slug = acf.Field.extend({
|
1941 |
+
|
1942 |
+
type: 'acfe_slug',
|
1943 |
+
|
1944 |
+
events: {
|
1945 |
+
'input input': 'onInput',
|
1946 |
+
'focusout input': 'onFocusOut',
|
1947 |
+
},
|
1948 |
+
|
1949 |
+
onInput: function(e, $el){
|
1950 |
+
|
1951 |
+
$el.val($el.val().toLowerCase()
|
1952 |
+
.replace(/\s+/g, '-') // Replace spaces with -
|
1953 |
+
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
|
1954 |
+
.replace(/\-\-+/g, '-') // Replace multiple - with single -
|
1955 |
+
.replace(/\_\_+/g, '_') // Replace multiple _ with single _
|
1956 |
+
.replace(/^-+/, '')); // Trim - from start of text
|
1957 |
+
|
1958 |
+
},
|
1959 |
+
|
1960 |
+
onFocusOut: function(e, $el){
|
1961 |
+
|
1962 |
+
$el.val($el.val().toLowerCase()
|
1963 |
+
.replace(/-+$/, '') // Trim - from end of text
|
1964 |
+
.replace(/_+$/, '')); // Trim _ from end of text
|
1965 |
+
|
1966 |
+
},
|
1967 |
+
|
1968 |
+
});
|
1969 |
+
|
1970 |
+
acf.registerFieldType(ACFE_Slug);
|
1971 |
+
|
1972 |
+
/*
|
1973 |
+
* Field: Button
|
1974 |
+
*/
|
1975 |
+
var ACFE_Button = acf.Field.extend({
|
1976 |
+
|
1977 |
+
type: 'acfe_button',
|
1978 |
+
|
1979 |
+
events: {
|
1980 |
+
'click input': 'onClick',
|
1981 |
+
'click button': 'onClick',
|
1982 |
+
},
|
1983 |
+
|
1984 |
+
$input: function(){
|
1985 |
+
|
1986 |
+
if(this.$('input').length){
|
1987 |
+
|
1988 |
+
return this.$('input');
|
1989 |
+
|
1990 |
+
}else if(this.$('button').length){
|
1991 |
+
|
1992 |
+
return this.$('button');
|
1993 |
+
|
1994 |
+
}
|
1995 |
+
|
1996 |
+
},
|
1997 |
+
|
1998 |
+
initialize: function(){
|
1999 |
+
|
2000 |
+
// vars
|
2001 |
+
var $button = this.$input();
|
2002 |
+
|
2003 |
+
// inherit data
|
2004 |
+
this.inherit($button);
|
2005 |
+
|
2006 |
+
},
|
2007 |
+
|
2008 |
+
onClick: function(e, $el){
|
2009 |
+
|
2010 |
+
if(this.get('ajax')){
|
2011 |
+
|
2012 |
+
e.preventDefault();
|
2013 |
+
|
2014 |
+
// serialize form data
|
2015 |
+
var data = {
|
2016 |
+
action: 'acfe/fields/button',
|
2017 |
+
field_name: this.get('name'),
|
2018 |
+
field_key: this.get('key')
|
2019 |
+
};
|
2020 |
+
|
2021 |
+
// Deprecated
|
2022 |
+
acf.doAction('acfe/fields/button/before_ajax', this.$el, data);
|
2023 |
+
|
2024 |
+
// Actions
|
2025 |
+
acf.doAction('acfe/fields/button/before', this.$el, data);
|
2026 |
+
acf.doAction('acfe/fields/button/before/key=' + this.get('key'), this.$el, data);
|
2027 |
+
acf.doAction('acfe/fields/button/before/name=' + this.get('name'), this.$el, data);
|
2028 |
+
|
2029 |
+
// ajax
|
2030 |
+
$.ajax({
|
2031 |
+
url: acf.get('ajaxurl'),
|
2032 |
+
data: acf.prepareForAjax(data),
|
2033 |
+
type: 'post',
|
2034 |
+
dataType: 'json',
|
2035 |
+
context: this,
|
2036 |
+
|
2037 |
+
// Success
|
2038 |
+
success: function(response){
|
2039 |
+
|
2040 |
+
// Deprecated
|
2041 |
+
acf.doAction('acfe/fields/button/ajax_success', response, this.$el, data);
|
2042 |
+
|
2043 |
+
// Actions
|
2044 |
+
acf.doAction('acfe/fields/button/success', response, this.$el, data);
|
2045 |
+
acf.doAction('acfe/fields/button/success/key=' + this.get('key'), response, this.$el, data);
|
2046 |
+
acf.doAction('acfe/fields/button/success/name=' + this.get('name'), response, this.$el, data);
|
2047 |
+
|
2048 |
+
},
|
2049 |
+
|
2050 |
+
// Complete
|
2051 |
+
complete: function(xhr){
|
2052 |
+
|
2053 |
+
var response = xhr.responseText;
|
2054 |
+
|
2055 |
+
// Actions
|
2056 |
+
acf.doAction('acfe/fields/button/complete', response, this.$el, data);
|
2057 |
+
acf.doAction('acfe/fields/button/complete/key=' + this.get('key'), response, this.$el, data);
|
2058 |
+
acf.doAction('acfe/fields/button/complete/name=' + this.get('name'), response, this.$el, data);
|
2059 |
+
|
2060 |
+
}
|
2061 |
+
|
2062 |
+
|
2063 |
+
});
|
2064 |
+
|
2065 |
+
}
|
2066 |
+
|
2067 |
+
}
|
2068 |
+
|
2069 |
+
});
|
2070 |
+
|
2071 |
+
acf.registerFieldType(ACFE_Button);
|
2072 |
+
|
2073 |
+
/*
|
2074 |
+
* Field: Advanced Link
|
2075 |
+
*/
|
2076 |
+
var ACFE_Advanced_Link = acf.Field.extend({
|
2077 |
+
|
2078 |
+
type: 'acfe_advanced_link',
|
2079 |
+
|
2080 |
+
events: {
|
2081 |
+
'click a[data-name="add"]': 'onClickEdit',
|
2082 |
+
'click a[data-name="edit"]': 'onClickEdit',
|
2083 |
+
'click a[data-name="remove"]': 'onClickRemove',
|
2084 |
+
},
|
2085 |
+
|
2086 |
+
$control: function(){
|
2087 |
+
return this.$('.acf-link');
|
2088 |
+
},
|
2089 |
+
|
2090 |
+
initialize: function(){
|
2091 |
+
// ...
|
2092 |
+
},
|
2093 |
+
|
2094 |
+
getValue: function(){
|
2095 |
+
|
2096 |
+
// return
|
2097 |
+
var data = {
|
2098 |
+
type: this.$('.input-type :checked').val(),
|
2099 |
+
title: this.$('.input-title').val(),
|
2100 |
+
url: this.$('.input-url').val(),
|
2101 |
+
post: this.$('.input-post :selected').text(),
|
2102 |
+
term: this.$('.input-term :selected').text(),
|
2103 |
+
target: this.$('.input-target').is(':checked')
|
2104 |
+
};
|
2105 |
+
|
2106 |
+
if(data.type === 'post'){
|
2107 |
+
|
2108 |
+
data.url = data.post;
|
2109 |
+
|
2110 |
+
}else if(data.type === 'term'){
|
2111 |
+
|
2112 |
+
data.url = data.term;
|
2113 |
+
|
2114 |
+
}
|
2115 |
+
|
2116 |
+
return data;
|
2117 |
+
|
2118 |
+
},
|
2119 |
+
|
2120 |
+
setValue: function( val ){
|
2121 |
+
|
2122 |
+
// default
|
2123 |
+
val = acf.parseArgs(val, {
|
2124 |
+
remove: false,
|
2125 |
+
title: '',
|
2126 |
+
url: '',
|
2127 |
+
target: false
|
2128 |
+
});
|
2129 |
+
|
2130 |
+
// vars
|
2131 |
+
var $div = this.$control();
|
2132 |
+
|
2133 |
+
// remove class
|
2134 |
+
$div.removeClass('-value -external');
|
2135 |
+
|
2136 |
+
// add class
|
2137 |
+
if(val.url)
|
2138 |
+
$div.addClass('-value');
|
2139 |
+
|
2140 |
+
if(val.target)
|
2141 |
+
$div.addClass('-external');
|
2142 |
+
|
2143 |
+
// update text
|
2144 |
+
this.$('.link-title').html( val.title );
|
2145 |
+
this.$('.link-url').attr('href', val.url).html( val.url );
|
2146 |
+
|
2147 |
+
// remove inputs data
|
2148 |
+
if(val.remove){
|
2149 |
+
|
2150 |
+
this.$('.input-type :checked').prop('checked', false);
|
2151 |
+
this.$('.input-type [value="url"]').prop('checked', true).trigger('change');
|
2152 |
+
this.$('.input-title').val('');
|
2153 |
+
this.$('.input-target').prop('checked', false);
|
2154 |
+
this.$('.input-url').val('').trigger('change');
|
2155 |
+
this.$('.input-post').val('').trigger('change');
|
2156 |
+
this.$('.input-term').val('').trigger('change');
|
2157 |
+
|
2158 |
+
}
|
2159 |
+
|
2160 |
+
},
|
2161 |
+
|
2162 |
+
onClickEdit: function(e, $el){
|
2163 |
+
|
2164 |
+
var $modal = $el.closest('.acf-input').find('.acfe-modal');
|
2165 |
+
|
2166 |
+
var title = $modal.attr('data-modal-title');
|
2167 |
+
|
2168 |
+
var model = this;
|
2169 |
+
|
2170 |
+
new acfe.Popup($modal, {
|
2171 |
+
title: title,
|
2172 |
+
size: 'medium',
|
2173 |
+
footer: acf.__('Close'),
|
2174 |
+
onClose: function(){
|
2175 |
+
model.onChange();
|
2176 |
+
}
|
2177 |
+
});
|
2178 |
+
|
2179 |
+
},
|
2180 |
+
|
2181 |
+
onClickRemove: function( e, $el ){
|
2182 |
+
|
2183 |
+
this.setValue({
|
2184 |
+
remove: true
|
2185 |
+
});
|
2186 |
+
|
2187 |
+
},
|
2188 |
+
|
2189 |
+
onChange: function( e, $el ){
|
2190 |
+
|
2191 |
+
// get the changed value
|
2192 |
+
var val = this.getValue();
|
2193 |
+
|
2194 |
+
// update inputs
|
2195 |
+
this.setValue(val);
|
2196 |
+
|
2197 |
+
},
|
2198 |
+
|
2199 |
+
});
|
2200 |
+
|
2201 |
+
acf.registerFieldType(ACFE_Advanced_Link);
|
2202 |
+
|
2203 |
+
/*
|
2204 |
+
* Field: Advanced Link Manager
|
2205 |
+
*/
|
2206 |
+
new acf.Model({
|
2207 |
+
|
2208 |
+
actions: {
|
2209 |
+
'invalid_field': 'invalidField',
|
2210 |
+
},
|
2211 |
+
|
2212 |
+
filters: {
|
2213 |
+
'select2_ajax_data/type=post_object': 'ajaxField',
|
2214 |
+
},
|
2215 |
+
|
2216 |
+
invalidField: function(field){
|
2217 |
+
|
2218 |
+
var $advanced_link = field.$el.closest('.acf-field-acfe-advanced-link').not('.acf-error');
|
2219 |
+
|
2220 |
+
if($advanced_link.length){
|
2221 |
+
|
2222 |
+
var advanced_link_field = acf.getInstance($advanced_link);
|
2223 |
+
|
2224 |
+
advanced_link_field.showError(field.notice.get('text'));
|
2225 |
+
|
2226 |
+
}
|
2227 |
+
|
2228 |
+
},
|
2229 |
+
|
2230 |
+
ajaxField: function(ajaxData, data, $el, field, select){
|
2231 |
+
|
2232 |
+
if(field.get('key') !== 'post')
|
2233 |
+
return ajaxData;
|
2234 |
+
|
2235 |
+
var advanced_link = acf.getInstance($el.closest('.acf-field-acfe-advanced-link'));
|
2236 |
+
|
2237 |
+
if(advanced_link){
|
2238 |
+
|
2239 |
+
ajaxData.field_key = advanced_link.get('key');
|
2240 |
+
|
2241 |
+
}
|
2242 |
+
|
2243 |
+
return ajaxData;
|
2244 |
+
|
2245 |
+
},
|
2246 |
+
|
2247 |
+
});
|
2248 |
+
|
2249 |
+
/*
|
2250 |
+
* Field: Group
|
2251 |
+
*/
|
2252 |
+
var Group = acf.Field.extend({
|
2253 |
+
|
2254 |
+
wait: false,
|
2255 |
+
|
2256 |
+
type: 'group',
|
2257 |
+
|
2258 |
+
events: {
|
2259 |
+
'click [data-name="edit"]': 'onClick',
|
2260 |
+
'duplicateField': 'onDuplicate'
|
2261 |
+
},
|
2262 |
+
|
2263 |
+
initialize: function(){
|
2264 |
+
|
2265 |
+
if(this.has('acfeGroupModal')){
|
2266 |
+
|
2267 |
+
var edit = this.get('acfeGroupModalButton');
|
2268 |
+
|
2269 |
+
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>');
|
2270 |
+
this.$el.find('> .acf-input').append('<a data-name="edit" class="acf-button button" href="#">' + edit + '</a>');
|
2271 |
+
|
2272 |
+
}
|
2273 |
+
|
2274 |
+
},
|
2275 |
+
|
2276 |
+
onClick: function(e, $el){
|
2277 |
+
|
2278 |
+
var title = this.$el.find('> .acf-label').text().trim();
|
2279 |
+
var $modal = this.$el.find('> .acf-input > .acfe-modal');
|
2280 |
+
|
2281 |
+
// Title
|
2282 |
+
if(!title.length){
|
2283 |
+
|
2284 |
+
title = this.get('acfeGroupModalButton');
|
2285 |
+
|
2286 |
+
}
|
2287 |
+
|
2288 |
+
// Close
|
2289 |
+
var close = false;
|
2290 |
+
|
2291 |
+
if(this.has('acfeGroupModalClose')){
|
2292 |
+
|
2293 |
+
close = acf.__('Close');
|
2294 |
+
|
2295 |
+
}
|
2296 |
+
|
2297 |
+
// Size
|
2298 |
+
var size = 'large';
|
2299 |
+
|
2300 |
+
if(this.has('acfeGroupModalSize')){
|
2301 |
+
|
2302 |
+
size = this.get('acfeGroupModalSize');
|
2303 |
+
|
2304 |
+
}
|
2305 |
+
|
2306 |
+
// Open modal
|
2307 |
+
new acfe.Popup($modal, {
|
2308 |
+
title: title,
|
2309 |
+
size: size,
|
2310 |
+
footer: close
|
2311 |
+
});
|
2312 |
+
|
2313 |
+
},
|
2314 |
+
|
2315 |
+
onDuplicate: function(e, $el, $duplicate){
|
2316 |
+
$duplicate.find('a[data-name="edit"]').remove();
|
2317 |
+
}
|
2318 |
+
|
2319 |
+
});
|
2320 |
+
|
2321 |
+
acf.registerFieldType(Group);
|
2322 |
+
|
2323 |
+
/*
|
2324 |
+
* Field: Clone
|
2325 |
+
*/
|
2326 |
+
var Clone = acf.Field.extend({
|
2327 |
+
|
2328 |
+
wait: false,
|
2329 |
+
|
2330 |
+
type: 'clone',
|
2331 |
+
|
2332 |
+
events: {
|
2333 |
+
'click [data-name="edit"]': 'onClick',
|
2334 |
+
'duplicateField': 'onDuplicate'
|
2335 |
+
},
|
2336 |
+
|
2337 |
+
initialize: function(){
|
2338 |
+
|
2339 |
+
if(this.has('acfeCloneModal')){
|
2340 |
+
|
2341 |
+
var edit = this.get('acfeCloneModalButton');
|
2342 |
+
|
2343 |
+
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>');
|
2344 |
+
this.$el.find('> .acf-input').append('<a data-name="edit" class="acf-button button" href="#">' + edit + '</a>');
|
2345 |
+
|
2346 |
+
}
|
2347 |
+
|
2348 |
+
},
|
2349 |
+
|
2350 |
+
onClick: function(e, $el){
|
2351 |
+
|
2352 |
+
var title = this.$el.find('> .acf-label').text().trim();
|
2353 |
+
var $modal = this.$el.find('> .acf-input > .acfe-modal');
|
2354 |
+
|
2355 |
+
|
2356 |
+
// Title
|
2357 |
+
if(!title.length){
|
2358 |
+
|
2359 |
+
title = this.get('acfeCloneModalButton');
|
2360 |
+
|
2361 |
+
}
|
2362 |
+
|
2363 |
+
// Close
|
2364 |
+
var close = false;
|
2365 |
+
|
2366 |
+
if(this.has('acfeCloneModalClose')){
|
2367 |
+
|
2368 |
+
close = acf.__('Close');
|
2369 |
+
|
2370 |
+
}
|
2371 |
+
|
2372 |
+
// Size
|
2373 |
+
var size = 'large';
|
2374 |
+
|
2375 |
+
if(this.has('acfeCloneModalSize')){
|
2376 |
+
|
2377 |
+
size = this.get('acfeCloneModalSize');
|
2378 |
+
|
2379 |
+
}
|
2380 |
+
|
2381 |
+
// Open modal
|
2382 |
+
new acfe.Popup($modal, {
|
2383 |
+
title: title,
|
2384 |
+
size: size,
|
2385 |
+
footer: close
|
2386 |
+
});
|
2387 |
+
|
2388 |
+
},
|
2389 |
+
|
2390 |
+
onDuplicate: function(e, $el, $duplicate){
|
2391 |
+
$duplicate.find('a[data-name="edit"]').remove();
|
2392 |
+
}
|
2393 |
+
|
2394 |
+
});
|
2395 |
+
|
2396 |
+
acf.registerFieldType(Clone);
|
2397 |
+
|
2398 |
+
/*
|
2399 |
+
* Field: Column
|
2400 |
+
*/
|
2401 |
+
var Column = acf.Field.extend({
|
2402 |
+
|
2403 |
+
wait: 'new_field',
|
2404 |
+
|
2405 |
+
type: 'acfe_column',
|
2406 |
+
|
2407 |
+
$control: function(){
|
2408 |
+
return this.$('.acf-fields:first');
|
2409 |
+
},
|
2410 |
+
|
2411 |
+
initialize: function(){
|
2412 |
+
|
2413 |
+
if(this.$el.is('td')){
|
2414 |
+
|
2415 |
+
var $table = this.$el.closest('.acf-table').find('th[data-type="acfe_column"]').remove();
|
2416 |
+
this.remove();
|
2417 |
+
|
2418 |
+
}
|
2419 |
+
|
2420 |
+
if(this.get('endpoint')){
|
2421 |
+
|
2422 |
+
this.$el.find('> .acf-label').remove();
|
2423 |
+
this.$el.find('> .acf-input').remove();
|
2424 |
+
|
2425 |
+
return;
|
2426 |
+
|
2427 |
+
}
|
2428 |
+
|
2429 |
+
var $field = this.$el;
|
2430 |
+
var $label = this.$el.find('> .acf-label');
|
2431 |
+
var $input = this.$inputWrap();
|
2432 |
+
var $wrap = this.$control();
|
2433 |
+
|
2434 |
+
$label.remove();
|
2435 |
+
|
2436 |
+
var $parent = $field.parent();
|
2437 |
+
$wrap.addClass($parent.hasClass('-left') ? '-left' : '');
|
2438 |
+
$wrap.addClass($parent.hasClass('-clear') ? '-clear' : '');
|
2439 |
+
|
2440 |
+
$wrap.append($field.nextUntil('.acf-field-acfe-column', '.acf-field'));
|
2441 |
+
|
2442 |
+
}
|
2443 |
+
|
2444 |
+
});
|
2445 |
+
|
2446 |
+
acf.registerFieldType(Column);
|
2447 |
+
|
2448 |
+
/*
|
2449 |
+
* Field: Select
|
2450 |
+
*/
|
2451 |
+
new acf.Model({
|
2452 |
+
|
2453 |
+
actions: {
|
2454 |
+
'new_field/type=select': 'newField',
|
2455 |
+
},
|
2456 |
+
|
2457 |
+
newField: function(field){
|
2458 |
+
|
2459 |
+
field.inherit(field.$input());
|
2460 |
+
|
2461 |
+
// Remove "- -" characters from placeholder
|
2462 |
+
if(!field.get('ui') && field.get('allow_null')){
|
2463 |
+
|
2464 |
+
field.$input().find('option').each(function(i, option){
|
2465 |
+
|
2466 |
+
if(option.value)
|
2467 |
+
return;
|
2468 |
+
|
2469 |
+
if(!option.text.startsWith('- ') || !option.text.endsWith(' -'))
|
2470 |
+
return;
|
2471 |
+
|
2472 |
+
option.text = option.text.substring(2);
|
2473 |
+
option.text = option.text.substring(0, option.text.length - 2);
|
2474 |
+
|
2475 |
+
});
|
2476 |
+
|
2477 |
+
}
|
2478 |
+
|
2479 |
+
if(field.has('acfePrepend') || field.has('acfeAppend')){
|
2480 |
+
|
2481 |
+
if(!field.$input().parent('.acf-input-wrap').length){
|
2482 |
+
|
2483 |
+
field.$input().wrapAll('<div class="acf-input-wrap"></div>');
|
2484 |
+
|
2485 |
+
if(field.get('ui')){
|
2486 |
+
|
2487 |
+
field.$('.acf-input-wrap:first').append(field.$('.select2'));
|
2488 |
+
|
2489 |
+
}
|
2490 |
+
|
2491 |
+
if(field.has('acfePrepend')){
|
2492 |
+
|
2493 |
+
field.$('.acf-input-wrap:first').before('<div class="acf-input-prepend">' + field.get('acfePrepend') + '</div>');
|
2494 |
+
field.$input().addClass('acf-is-prepended');
|
2495 |
+
|
2496 |
+
}
|
2497 |
+
|
2498 |
+
if(field.has('acfeAppend')){
|
2499 |
+
|
2500 |
+
field.$('.acf-input-wrap:first').before('<div class="acf-input-append">' + field.get('acfeAppend') + '</div>');
|
2501 |
+
field.$input().addClass('acf-is-appended');
|
2502 |
+
|
2503 |
+
}
|
2504 |
+
|
2505 |
+
}
|
2506 |
+
|
2507 |
+
}
|
2508 |
+
|
2509 |
+
}
|
2510 |
+
|
2511 |
+
});
|
2512 |
+
|
2513 |
+
/*
|
2514 |
+
* Field: Select2
|
2515 |
+
*/
|
2516 |
+
new acf.Model({
|
2517 |
+
|
2518 |
+
actions:{
|
2519 |
+
'select2_init': 'select2Init',
|
2520 |
+
},
|
2521 |
+
|
2522 |
+
filters: {
|
2523 |
+
'select2_args': 'select2Args',
|
2524 |
+
'select2_ajax_data': 'select2Ajax',
|
2525 |
+
},
|
2526 |
+
|
2527 |
+
select2Init: function($select, options, data, field, instance){
|
2528 |
+
|
2529 |
+
// Search Placeholder
|
2530 |
+
if(field.get('acfeSearchPlaceholder')){
|
2531 |
+
|
2532 |
+
var search_placeholder = field.get('acfeSearchPlaceholder');
|
2533 |
+
|
2534 |
+
$select.on('select2:open', function(e){
|
2535 |
+
|
2536 |
+
if(field.get('multiple')){
|
2537 |
+
|
2538 |
+
if(!$select.val()){
|
2539 |
+
|
2540 |
+
field.$('.select2-search__field').attr('placeholder', search_placeholder);
|
2541 |
+
|
2542 |
+
}
|
2543 |
+
|
2544 |
+
}else{
|
2545 |
+
|
2546 |
+
$('.select2-search.select2-search--dropdown > .select2-search__field').attr('placeholder', search_placeholder);
|
2547 |
+
|
2548 |
+
}
|
2549 |
+
|
2550 |
+
});
|
2551 |
+
|
2552 |
+
if(field.get('multiple')){
|
2553 |
+
|
2554 |
+
$select.on('select2:close', function(e){
|
2555 |
+
|
2556 |
+
if(!$select.val()){
|
2557 |
+
|
2558 |
+
field.$('.select2-search__field').attr('placeholder', field.get('placeholder'));
|
2559 |
+
|
2560 |
+
}
|
2561 |
+
|
2562 |
+
});
|
2563 |
+
|
2564 |
+
}
|
2565 |
+
|
2566 |
+
}
|
2567 |
+
|
2568 |
+
acf.doAction('select2_init/type=' + field.get('type'), $select, options, data, field, instance);
|
2569 |
+
acf.doAction('select2_init/name=' + field.get('name'), $select, options, data, field, instance);
|
2570 |
+
acf.doAction('select2_init/key=' + field.get('key'), $select, options, data, field, instance);
|
2571 |
+
|
2572 |
+
},
|
2573 |
+
|
2574 |
+
select2Args: function(options, $select, data, field, instance){
|
2575 |
+
|
2576 |
+
// Allow Custom tags
|
2577 |
+
if(field.get('acfeAllowCustom')){
|
2578 |
+
|
2579 |
+
options.tags = true;
|
2580 |
+
|
2581 |
+
options.createTag = function(params){
|
2582 |
+
|
2583 |
+
var term = $.trim(params.term);
|
2584 |
+
|
2585 |
+
if(term === '')
|
2586 |
+
return null;
|
2587 |
+
|
2588 |
+
var optionsMatch = false;
|
2589 |
+
|
2590 |
+
this.$element.find('option').each(function(){
|
2591 |
+
|
2592 |
+
if(this.value.toLowerCase() !== term.toLowerCase())
|
2593 |
+
return;
|
2594 |
+
|
2595 |
+
optionsMatch = true;
|
2596 |
+
return false;
|
2597 |
+
|
2598 |
+
});
|
2599 |
+
|
2600 |
+
if(optionsMatch)
|
2601 |
+
return null;
|
2602 |
+
|
2603 |
+
return {
|
2604 |
+
id: term,
|
2605 |
+
text: term
|
2606 |
+
};
|
2607 |
+
|
2608 |
+
};
|
2609 |
+
|
2610 |
+
|
2611 |
+
options.insertTag = function(data, tag){
|
2612 |
+
|
2613 |
+
var found = false;
|
2614 |
+
|
2615 |
+
$.each(data, function(){
|
2616 |
+
|
2617 |
+
if($.trim(tag.text).toUpperCase() !== $.trim(this.text).toUpperCase())
|
2618 |
+
return;
|
2619 |
+
|
2620 |
+
found = true;
|
2621 |
+
return false;
|
2622 |
+
|
2623 |
+
});
|
2624 |
+
|
2625 |
+
if(!found)
|
2626 |
+
data.unshift(tag);
|
2627 |
+
|
2628 |
+
};
|
2629 |
+
|
2630 |
+
}
|
2631 |
+
|
2632 |
+
options = acf.applyFilters('select2_args/type=' + field.get('type'), options, $select, data, field, instance);
|
2633 |
+
options = acf.applyFilters('select2_args/name=' + field.get('name'), options, $select, data, field, instance);
|
2634 |
+
options = acf.applyFilters('select2_args/key=' + field.get('key'), options, $select, data, field, instance);
|
2635 |
+
|
2636 |
+
return options;
|
2637 |
+
|
2638 |
+
},
|
2639 |
+
|
2640 |
+
select2Ajax: function(ajaxData, data, $el, field, instance){
|
2641 |
+
|
2642 |
+
ajaxData = acf.applyFilters('select2_ajax_data/type=' + field.get('type'), ajaxData, data, $el, field, instance);
|
2643 |
+
ajaxData = acf.applyFilters('select2_ajax_data/name=' + field.get('name'), ajaxData, data, $el, field, instance);
|
2644 |
+
ajaxData = acf.applyFilters('select2_ajax_data/key=' + field.get('key'), ajaxData, data, $el, field, instance);
|
2645 |
+
|
2646 |
+
if(ajaxData.action){
|
2647 |
+
|
2648 |
+
ajaxData = acf.applyFilters('select2_ajax_data/action=' + ajaxData.action, ajaxData, data, $el, field, instance);
|
2649 |
+
|
2650 |
+
}
|
2651 |
+
|
2652 |
+
return ajaxData;
|
2653 |
+
|
2654 |
+
}
|
2655 |
+
|
2656 |
+
});
|
2657 |
+
|
2658 |
+
/*
|
2659 |
+
* Field: Tab
|
2660 |
+
*/
|
2661 |
+
new acf.Model({
|
2662 |
+
|
2663 |
+
actions: {
|
2664 |
+
'prepare_field/type=tab': 'prepareField',
|
2665 |
+
},
|
2666 |
+
|
2667 |
+
prepareField: function(field){
|
2668 |
+
|
2669 |
+
if(!field.has('noPreference'))
|
2670 |
+
return;
|
2671 |
+
|
2672 |
+
var $tabs = field.findTabs();
|
2673 |
+
var tabs = acf.getInstances($tabs);
|
2674 |
+
var key = field.get('key');
|
2675 |
+
|
2676 |
+
if(tabs.length){
|
2677 |
+
|
2678 |
+
var preference = acf.getPreference('this.tabs');
|
2679 |
+
|
2680 |
+
if(!preference)
|
2681 |
+
return;
|
2682 |
+
|
2683 |
+
$.each(tabs, function(i, group){
|
2684 |
+
|
2685 |
+
var groupIndex = group.get('index');
|
2686 |
+
|
2687 |
+
if(group.data.key !== key)
|
2688 |
+
return;
|
2689 |
+
|
2690 |
+
preference[groupIndex] = 0;
|
2691 |
+
|
2692 |
+
});
|
2693 |
+
|
2694 |
+
// update
|
2695 |
+
acf.setPreference('this.tabs', preference);
|
2696 |
+
|
2697 |
+
}
|
2698 |
+
|
2699 |
+
}
|
2700 |
+
|
2701 |
+
});
|
2702 |
+
|
2703 |
+
/*
|
2704 |
+
* Field: Checkbox
|
2705 |
+
*/
|
2706 |
+
new acf.Model({
|
2707 |
+
|
2708 |
+
actions: {
|
2709 |
+
'new_field/type=checkbox': 'newField',
|
2710 |
+
},
|
2711 |
+
|
2712 |
+
newField: function(field){
|
2713 |
+
|
2714 |
+
if(!field.has('acfeLabels'))
|
2715 |
+
return;
|
2716 |
+
|
2717 |
+
$.each(field.get('acfeLabels'), function(group, key){
|
2718 |
+
|
2719 |
+
field.$control().find('input[type=checkbox][value="' + key + '"]').closest('ul').before('<strong>' + group + '</strong>');
|
2720 |
+
|
2721 |
+
});
|
2722 |
+
|
2723 |
+
}
|
2724 |
+
|
2725 |
+
});
|
2726 |
+
|
2727 |
+
/*
|
2728 |
+
* Field: Radio
|
2729 |
+
*/
|
2730 |
+
new acf.Model({
|
2731 |
+
|
2732 |
+
actions: {
|
2733 |
+
'new_field/type=radio': 'newField',
|
2734 |
+
},
|
2735 |
+
|
2736 |
+
newField: function(field){
|
2737 |
+
|
2738 |
+
if(!field.has('acfeLabels'))
|
2739 |
+
return;
|
2740 |
+
|
2741 |
+
$.each(field.get('acfeLabels'), function(group, key){
|
2742 |
+
|
2743 |
+
field.$control().find('input[type=radio][value="' + key + '"]').closest('li').addClass('parent').prepend('<strong>' + group + '</strong>');
|
2744 |
+
|
2745 |
+
});
|
2746 |
+
|
2747 |
+
if(field.$control().hasClass('acf-hl')){
|
2748 |
+
|
2749 |
+
field.$control().find('li.parent').each(function(){
|
2750 |
+
|
2751 |
+
$(this).nextUntil('li.parent').addBack().wrapAll('<li><ul></ul></li>');
|
2752 |
+
|
2753 |
+
});
|
2754 |
+
|
2755 |
+
}
|
2756 |
+
|
2757 |
+
}
|
2758 |
+
|
2759 |
+
});
|
2760 |
+
|
2761 |
+
/*
|
2762 |
+
* Field: Instructions
|
2763 |
+
*/
|
2764 |
+
new acf.Model({
|
2765 |
+
|
2766 |
+
field: false,
|
2767 |
+
placement: false,
|
2768 |
+
|
2769 |
+
actions: {
|
2770 |
+
'new_field': 'newField',
|
2771 |
+
},
|
2772 |
+
|
2773 |
+
newField: function(field){
|
2774 |
+
|
2775 |
+
this.field = field;
|
2776 |
+
|
2777 |
+
if(field.has('instructionTooltip')){
|
2778 |
+
this.setTooltip();
|
2779 |
+
}
|
2780 |
+
|
2781 |
+
if(field.has('instructionAboveField')){
|
2782 |
+
this.setAboveField();
|
2783 |
+
}
|
2784 |
+
|
2785 |
+
if(field.has('instructionPlacement')){
|
2786 |
+
this.overridePlacement(field.get('instructionPlacement'));
|
2787 |
+
}
|
2788 |
+
|
2789 |
+
},
|
2790 |
+
|
2791 |
+
setTooltip: function(){
|
2792 |
+
|
2793 |
+
this.field.$labelWrap().prepend('<span class="acfe-field-tooltip acf-js-tooltip dashicons dashicons-info" title="' + _.escape(this.field.get('instructionTooltip')) + '"></span>');
|
2794 |
+
this.field.$labelWrap().find('.description').remove();
|
2795 |
+
|
2796 |
+
},
|
2797 |
+
|
2798 |
+
setAboveField: function(){
|
2799 |
+
|
2800 |
+
this.field.$inputWrap().prepend('<p class="description">' + this.field.get('instructionAboveField') + '</p>');
|
2801 |
+
this.field.$labelWrap().find('.description').remove();
|
2802 |
+
|
2803 |
+
},
|
2804 |
+
|
2805 |
+
overridePlacement: function(target){
|
2806 |
+
|
2807 |
+
var current = this.getPlacement();
|
2808 |
+
|
2809 |
+
// No instruction
|
2810 |
+
if(!current)
|
2811 |
+
return;
|
2812 |
+
|
2813 |
+
// Placement is correct
|
2814 |
+
if(current === target)
|
2815 |
+
return;
|
2816 |
+
|
2817 |
+
this.setPlacement(target);
|
2818 |
+
|
2819 |
+
},
|
2820 |
+
|
2821 |
+
getPlacement: function(){
|
2822 |
+
|
2823 |
+
var placement = false;
|
2824 |
+
|
2825 |
+
if(this.field.$labelWrap().find('>.description').length)
|
2826 |
+
placement = 'label';
|
2827 |
+
|
2828 |
+
else if(this.field.$inputWrap().find('>.description:first-child').length)
|
2829 |
+
placement = 'above_field';
|
2830 |
+
|
2831 |
+
else if(this.field.$inputWrap().find('>.description:last-child').length)
|
2832 |
+
placement = 'field';
|
2833 |
+
|
2834 |
+
else if(this.field.$labelWrap().find('>.acfe-field-tooltip').length)
|
2835 |
+
placement = 'tooltip';
|
2836 |
+
|
2837 |
+
this.placement = placement;
|
2838 |
+
|
2839 |
+
return this.placement;
|
2840 |
+
|
2841 |
+
},
|
2842 |
+
|
2843 |
+
$getInstruction: function(){
|
2844 |
+
|
2845 |
+
var placement = this.getPlacement();
|
2846 |
+
|
2847 |
+
if(placement === 'label'){
|
2848 |
+
|
2849 |
+
return this.field.$labelWrap().find('>.description');
|
2850 |
+
|
2851 |
+
}else if(placement === 'above_field'){
|
2852 |
+
|
2853 |
+
return this.field.$inputWrap().find('>.description:first-child');
|
2854 |
+
|
2855 |
+
}else if(placement === 'field'){
|
2856 |
+
|
2857 |
+
return this.field.$inputWrap().find('>.description:last-child');
|
2858 |
+
|
2859 |
+
}else if(placement === 'tooltip'){
|
2860 |
+
|
2861 |
+
return this.field.$labelWrap().find('>.acfe-field-tooltip');
|
2862 |
+
|
2863 |
+
}
|
2864 |
+
|
2865 |
+
return false;
|
2866 |
+
|
2867 |
+
},
|
2868 |
+
|
2869 |
+
setPlacement: function(target){
|
2870 |
+
|
2871 |
+
var $instruction = this.$getInstruction();
|
2872 |
+
|
2873 |
+
if(this.placement === 'tooltip'){
|
2874 |
+
|
2875 |
+
var text = $instruction.attr('title');
|
2876 |
+
|
2877 |
+
$instruction.remove();
|
2878 |
+
$instruction = $('<p class="description">' + text + '</p>');
|
2879 |
+
|
2880 |
+
}
|
2881 |
+
|
2882 |
+
if(target === 'label'){
|
2883 |
+
|
2884 |
+
this.field.$labelWrap().append($instruction);
|
2885 |
+
|
2886 |
+
}else if(target === 'above_field'){
|
2887 |
+
|
2888 |
+
this.field.$inputWrap().prepend($instruction);
|
2889 |
+
|
2890 |
+
}else if(target === 'field'){
|
2891 |
+
|
2892 |
+
this.field.$inputWrap().append($instruction);
|
2893 |
+
|
2894 |
+
}else if(target === 'tooltip'){
|
2895 |
+
|
2896 |
+
this.field.$labelWrap().prepend($('<span class="acfe-field-tooltip acf-js-tooltip dashicons dashicons-info" title="' + _.escape($instruction.html()) + '"></span>'));
|
2897 |
+
$instruction.remove();
|
2898 |
+
|
2899 |
+
}
|
2900 |
+
|
2901 |
+
}
|
2902 |
+
|
2903 |
+
});
|
2904 |
+
|
2905 |
})(jQuery);
|
2906 |
+
(function($){
|
2907 |
+
|
2908 |
+
if(typeof acf === 'undefined')
|
2909 |
+
return;
|
2910 |
+
|
2911 |
+
/*
|
2912 |
+
* Field Conditions: Code Editor
|
2913 |
+
*/
|
2914 |
+
acf.registerConditionForFieldType('equalTo', 'acfe_code_editor');
|
2915 |
+
acf.registerConditionForFieldType('notEqualTo', 'acfe_code_editor');
|
2916 |
+
acf.registerConditionForFieldType('patternMatch', 'acfe_code_editor');
|
2917 |
+
acf.registerConditionForFieldType('contains', 'acfe_code_editor');
|
2918 |
+
acf.registerConditionForFieldType('hasValue', 'acfe_code_editor');
|
2919 |
+
acf.registerConditionForFieldType('hasNoValue', 'acfe_code_editor');
|
2920 |
+
|
2921 |
+
/*
|
2922 |
+
* Field Conditions: Datepicker
|
2923 |
+
*/
|
2924 |
+
acf.registerConditionForFieldType('equalTo', 'date_picker');
|
2925 |
+
acf.registerConditionForFieldType('notEqualTo', 'date_picker');
|
2926 |
+
acf.registerConditionForFieldType('patternMatch', 'date_picker');
|
2927 |
+
acf.registerConditionForFieldType('contains', 'date_picker');
|
2928 |
+
acf.registerConditionForFieldType('greaterThan', 'date_picker');
|
2929 |
+
acf.registerConditionForFieldType('lessThan', 'date_picker');
|
2930 |
+
|
2931 |
+
/*
|
2932 |
+
* Field Conditions: Datetime picker
|
2933 |
+
*/
|
2934 |
+
acf.registerConditionForFieldType('equalTo', 'date_time_picker');
|
2935 |
+
acf.registerConditionForFieldType('notEqualTo', 'date_time_picker');
|
2936 |
+
acf.registerConditionForFieldType('patternMatch', 'date_time_picker');
|
2937 |
+
acf.registerConditionForFieldType('contains', 'date_time_picker');
|
2938 |
+
|
2939 |
+
/*
|
2940 |
+
* Field Conditions: Timepicker
|
2941 |
+
*/
|
2942 |
+
acf.registerConditionForFieldType('equalTo', 'time_picker');
|
2943 |
+
acf.registerConditionForFieldType('notEqualTo', 'time_picker');
|
2944 |
+
acf.registerConditionForFieldType('patternMatch', 'time_picker');
|
2945 |
+
acf.registerConditionForFieldType('contains', 'time_picker');
|
2946 |
+
|
2947 |
+
/*
|
2948 |
+
* Field Conditions: Taxonomy
|
2949 |
+
*/
|
2950 |
+
acf.registerConditionForFieldType('equalTo', 'taxonomy');
|
2951 |
+
acf.registerConditionForFieldType('notEqualTo', 'taxonomy');
|
2952 |
+
acf.registerConditionForFieldType('patternMatch', 'taxonomy');
|
2953 |
+
acf.registerConditionForFieldType('contains', 'taxonomy');
|
2954 |
+
acf.registerConditionForFieldType('hasValue', 'taxonomy');
|
2955 |
+
acf.registerConditionForFieldType('hasNoValue', 'taxonomy');
|
2956 |
+
|
2957 |
+
/*
|
2958 |
+
* Field Conditions: Forms
|
2959 |
+
*/
|
2960 |
+
acf.registerConditionForFieldType('equalTo', 'acfe_forms');
|
2961 |
+
acf.registerConditionForFieldType('notEqualTo', 'acfe_forms');
|
2962 |
+
acf.registerConditionForFieldType('patternMatch', 'acfe_forms');
|
2963 |
+
acf.registerConditionForFieldType('contains', 'acfe_forms');
|
2964 |
+
acf.registerConditionForFieldType('hasValue', 'acfe_forms');
|
2965 |
+
acf.registerConditionForFieldType('hasNoValue', 'acfe_forms');
|
2966 |
+
|
2967 |
+
/*
|
2968 |
+
* Field Conditions: Hidden
|
2969 |
+
*/
|
2970 |
+
acf.registerConditionForFieldType('equalTo', 'acfe_hidden');
|
2971 |
+
acf.registerConditionForFieldType('notEqualTo', 'acfe_hidden');
|
2972 |
+
acf.registerConditionForFieldType('patternMatch', 'acfe_hidden');
|
2973 |
+
acf.registerConditionForFieldType('contains', 'acfe_hidden');
|
2974 |
+
acf.registerConditionForFieldType('hasValue', 'acfe_hidden');
|
2975 |
+
acf.registerConditionForFieldType('hasNoValue', 'acfe_hidden');
|
2976 |
+
|
2977 |
+
/*
|
2978 |
+
* Field Conditions: Post Status
|
2979 |
+
*/
|
2980 |
+
acf.registerConditionForFieldType('equalTo', 'acfe_post_statuses');
|
2981 |
+
acf.registerConditionForFieldType('notEqualTo', 'acfe_post_statuses');
|
2982 |
+
acf.registerConditionForFieldType('patternMatch', 'acfe_post_statuses');
|
2983 |
+
acf.registerConditionForFieldType('contains', 'acfe_post_statuses');
|
2984 |
+
acf.registerConditionForFieldType('hasValue', 'acfe_post_statuses');
|
2985 |
+
acf.registerConditionForFieldType('hasNoValue', 'acfe_post_statuses');
|
2986 |
+
|
2987 |
+
/*
|
2988 |
+
* Field Conditions: Post Types
|
2989 |
+
*/
|
2990 |
+
acf.registerConditionForFieldType('equalTo', 'acfe_post_types');
|
2991 |
+
acf.registerConditionForFieldType('notEqualTo', 'acfe_post_types');
|
2992 |
+
acf.registerConditionForFieldType('patternMatch', 'acfe_post_types');
|
2993 |
+
acf.registerConditionForFieldType('contains', 'acfe_post_types');
|
2994 |
+
acf.registerConditionForFieldType('hasValue', 'acfe_post_types');
|
2995 |
+
acf.registerConditionForFieldType('hasNoValue', 'acfe_post_types');
|
2996 |
+
|
2997 |
+
/*
|
2998 |
+
* Field Conditions: Slug
|
2999 |
+
*/
|
3000 |
+
acf.registerConditionForFieldType('equalTo', 'acfe_slug');
|
3001 |
+
acf.registerConditionForFieldType('notEqualTo', 'acfe_slug');
|
3002 |
+
acf.registerConditionForFieldType('patternMatch', 'acfe_slug');
|
3003 |
+
acf.registerConditionForFieldType('contains', 'acfe_slug');
|
3004 |
+
acf.registerConditionForFieldType('hasValue', 'acfe_slug');
|
3005 |
+
acf.registerConditionForFieldType('hasNoValue', 'acfe_slug');
|
3006 |
+
|
3007 |
+
/*
|
3008 |
+
* Field Conditions: Taxonomies
|
3009 |
+
*/
|
3010 |
+
acf.registerConditionForFieldType('equalTo', 'acfe_taxonomies');
|
3011 |
+
acf.registerConditionForFieldType('notEqualTo', 'acfe_taxonomies');
|
3012 |
+
acf.registerConditionForFieldType('patternMatch', 'acfe_taxonomies');
|
3013 |
+
acf.registerConditionForFieldType('contains', 'acfe_taxonomies');
|
3014 |
+
acf.registerConditionForFieldType('hasValue', 'acfe_taxonomies');
|
3015 |
+
acf.registerConditionForFieldType('hasNoValue', 'acfe_taxonomies');
|
3016 |
+
|
3017 |
+
/*
|
3018 |
+
* Field Conditions: Taxonomy Terms
|
3019 |
+
*/
|
3020 |
+
acf.registerConditionForFieldType('equalTo', 'acfe_taxonomy_terms');
|
3021 |
+
acf.registerConditionForFieldType('notEqualTo', 'acfe_taxonomy_terms');
|
3022 |
+
acf.registerConditionForFieldType('patternMatch', 'acfe_taxonomy_terms');
|
3023 |
+
acf.registerConditionForFieldType('contains', 'acfe_taxonomy_terms');
|
3024 |
+
acf.registerConditionForFieldType('hasValue', 'acfe_taxonomy_terms');
|
3025 |
+
acf.registerConditionForFieldType('hasNoValue', 'acfe_taxonomy_terms');
|
3026 |
+
|
3027 |
+
/*
|
3028 |
+
* Field Conditions: User Roles
|
3029 |
+
*/
|
3030 |
+
acf.registerConditionForFieldType('equalTo', 'acfe_user_roles');
|
3031 |
+
acf.registerConditionForFieldType('notEqualTo', 'acfe_user_roles');
|
3032 |
+
acf.registerConditionForFieldType('patternMatch', 'acfe_user_roles');
|
3033 |
+
acf.registerConditionForFieldType('contains', 'acfe_user_roles');
|
3034 |
+
acf.registerConditionForFieldType('hasValue', 'acfe_user_roles');
|
3035 |
+
acf.registerConditionForFieldType('hasNoValue', 'acfe_user_roles');
|
3036 |
+
|
3037 |
})(jQuery);
|
3038 |
+
(function($){
|
3039 |
+
|
3040 |
+
if(typeof acf === 'undefined')
|
3041 |
+
return;
|
3042 |
+
|
3043 |
+
/*
|
3044 |
+
* ACFE Form
|
3045 |
+
*/
|
3046 |
+
new acf.Model({
|
3047 |
+
|
3048 |
+
actions: {
|
3049 |
+
'prepare': 'prepare',
|
3050 |
+
'new_field/type=date_picker': 'datePicker',
|
3051 |
+
'new_field/type=date_time_picker': 'datePicker',
|
3052 |
+
'new_field/type=time_picker': 'datePicker',
|
3053 |
+
'new_field/type=google_map': 'googleMap',
|
3054 |
+
'invalid_field': 'invalidField',
|
3055 |
+
'validation_begin': 'validationBegin',
|
3056 |
+
},
|
3057 |
+
|
3058 |
+
prepare: function(){
|
3059 |
+
|
3060 |
+
if(acfe.get('is_admin'))
|
3061 |
+
return;
|
3062 |
+
|
3063 |
+
// Fix Image/File WP Media upload
|
3064 |
+
if(acf.isset(window, 'wp', 'media', 'view', 'settings', 'post')){
|
3065 |
+
|
3066 |
+
// Unset Post ID
|
3067 |
+
wp.media.view.settings.post = false;
|
3068 |
+
|
3069 |
+
}
|
3070 |
+
|
3071 |
+
if($('.acfe-form[data-hide-unload="1"]').length){
|
3072 |
+
|
3073 |
+
acf.unload.disable();
|
3074 |
+
|
3075 |
+
}
|
3076 |
+
|
3077 |
+
var $form_success = $('.acfe-form-success');
|
3078 |
+
|
3079 |
+
if($form_success.length){
|
3080 |
+
|
3081 |
+
// Prevent refresh sending post fields again
|
3082 |
+
if(window.history.replaceState){
|
3083 |
+
window.history.replaceState(null, null, window.location.href);
|
3084 |
+
}
|
3085 |
+
|
3086 |
+
$form_success.each(function(){
|
3087 |
+
|
3088 |
+
var form_name = $(this).data('form-name');
|
3089 |
+
var form_id = $(this).data('form-id');
|
3090 |
+
|
3091 |
+
acf.doAction('acfe/form/submit/success');
|
3092 |
+
acf.doAction('acfe/form/submit/success/id=' + form_id);
|
3093 |
+
acf.doAction('acfe/form/submit/success/name=' + form_name);
|
3094 |
+
|
3095 |
+
});
|
3096 |
+
|
3097 |
+
}
|
3098 |
+
|
3099 |
+
// Prevent form submission click spam
|
3100 |
+
$('.acf-form .button, .acf-form [type="submit"], .acfe-form .button, .acfe-form [type="submit"]').click(function(e){
|
3101 |
+
|
3102 |
+
if(!$(this).hasClass('disabled'))
|
3103 |
+
return;
|
3104 |
+
|
3105 |
+
e.preventDefault();
|
3106 |
+
|
3107 |
+
});
|
3108 |
+
|
3109 |
+
},
|
3110 |
+
|
3111 |
+
// Datepicker: Add field class
|
3112 |
+
datePicker: function(field){
|
3113 |
+
|
3114 |
+
if(acfe.get('is_admin'))
|
3115 |
+
return;
|
3116 |
+
|
3117 |
+
var $form = field.$el.closest('.acfe-form');
|
3118 |
+
|
3119 |
+
if(!$form.length)
|
3120 |
+
return;
|
3121 |
+
|
3122 |
+
var field_class = $form.data('fields-class');
|
3123 |
+
|
3124 |
+
if(field_class)
|
3125 |
+
field.$inputText().addClass(field_class);
|
3126 |
+
|
3127 |
+
},
|
3128 |
+
|
3129 |
+
// Google Maps: Add field class
|
3130 |
+
googleMap: function(field){
|
3131 |
+
|
3132 |
+
if(acfe.get('is_admin'))
|
3133 |
+
return;
|
3134 |
+
|
3135 |
+
var $form = field.$el.closest('.acfe-form');
|
3136 |
+
|
3137 |
+
if(!$form.length)
|
3138 |
+
return;
|
3139 |
+
|
3140 |
+
var field_class = $form.data('fields-class');
|
3141 |
+
|
3142 |
+
if(field_class)
|
3143 |
+
field.$search().addClass(field_class);
|
3144 |
+
|
3145 |
+
},
|
3146 |
+
|
3147 |
+
// Error: Move error
|
3148 |
+
invalidField: function(field){
|
3149 |
+
|
3150 |
+
if(acfe.get('is_admin'))
|
3151 |
+
return;
|
3152 |
+
|
3153 |
+
var $form = field.$el.closest('.acfe-form');
|
3154 |
+
|
3155 |
+
if(!$form.length)
|
3156 |
+
return;
|
3157 |
+
|
3158 |
+
var errors_position = $form.data('errors-position');
|
3159 |
+
var errors_class = $form.data('errors-class');
|
3160 |
+
|
3161 |
+
// Class
|
3162 |
+
if(errors_class && errors_class.length){
|
3163 |
+
|
3164 |
+
field.$el.find('.acf-notice.-error').addClass(errors_class);
|
3165 |
+
|
3166 |
+
}
|
3167 |
+
|
3168 |
+
// Move below
|
3169 |
+
if(errors_position && errors_position === 'below'){
|
3170 |
+
|
3171 |
+
if(field.$control().length){
|
3172 |
+
|
3173 |
+
field.$el.find('.acf-notice.-error').insertAfter(field.$control());
|
3174 |
+
|
3175 |
+
}else if(field.$input().length){
|
3176 |
+
|
3177 |
+
field.$el.find('.acf-notice.-error').insertAfter(field.$input());
|
3178 |
+
|
3179 |
+
}
|
3180 |
+
|
3181 |
+
var $selector = false;
|
3182 |
+
|
3183 |
+
if(field.$control().length){
|
3184 |
+
|
3185 |
+
$selector = field.$control();
|
3186 |
+
|
3187 |
+
}else if(field.$input().length){
|
3188 |
+
|
3189 |
+
$selector = field.$input();
|
3190 |
+
|
3191 |
+
}
|
3192 |
+
|
3193 |
+
if($selector)
|
3194 |
+
field.$el.find('.acf-notice.-error').insertAfter($selector);
|
3195 |
+
|
3196 |
+
}
|
3197 |
+
|
3198 |
+
// Group errors
|
3199 |
+
else if(errors_position && errors_position === 'group'){
|
3200 |
+
|
3201 |
+
var label = field.$el.find('.acf-label label').text().trim();
|
3202 |
+
var placeholder = field.$el.find('.acf-input-wrap [placeholder!=""]').attr('placeholder');
|
3203 |
+
var message = field.$el.find('.acf-notice.-error').text().trim();
|
3204 |
+
|
3205 |
+
field.$el.find('.acf-notice.-error').remove();
|
3206 |
+
|
3207 |
+
// Try label
|
3208 |
+
if(label && label.length && label !== '*'){
|
3209 |
+
|
3210 |
+
message = label + ': ' + message;
|
3211 |
+
|
3212 |
+
}
|
3213 |
+
|
3214 |
+
// Try placeholder
|
3215 |
+
else if(placeholder && placeholder.length && placeholder !== ''){
|
3216 |
+
|
3217 |
+
message = placeholder + ': ' + message;
|
3218 |
+
|
3219 |
+
}
|
3220 |
+
|
3221 |
+
// If everything fails, use field name
|
3222 |
+
else{
|
3223 |
+
|
3224 |
+
message = field.get('name') + ': ' + message;
|
3225 |
+
|
3226 |
+
}
|
3227 |
+
|
3228 |
+
var $form_error = $form.find('> .acfe-form-error')
|
3229 |
+
|
3230 |
+
if(!$form_error.length)
|
3231 |
+
$form_error = $('<div class="acf-notice -error acf-error-message acfe-form-error" />').prependTo($form);
|
3232 |
+
|
3233 |
+
$form_error.append('<p>' + message + '</p>');
|
3234 |
+
|
3235 |
+
}
|
3236 |
+
|
3237 |
+
// Hide errors
|
3238 |
+
else if(errors_position && errors_position === 'hide'){
|
3239 |
+
|
3240 |
+
field.$el.find('.acf-notice.-error').remove();
|
3241 |
+
|
3242 |
+
}
|
3243 |
+
|
3244 |
+
},
|
3245 |
+
|
3246 |
+
// Ajax Validation
|
3247 |
+
validationBegin: function($form){
|
3248 |
+
|
3249 |
+
if(acfe.get('is_admin'))
|
3250 |
+
return;
|
3251 |
+
|
3252 |
+
if(typeof $form === 'undefined')
|
3253 |
+
return;
|
3254 |
+
|
3255 |
+
$form.find('.acf-error-message').remove();
|
3256 |
+
|
3257 |
+
}
|
3258 |
+
|
3259 |
+
});
|
3260 |
+
|
3261 |
+
// Rewrite ACF New Condition
|
3262 |
+
// Allow conditions to work within wrapped div
|
3263 |
+
acf.newCondition = function(rule, conditions){
|
3264 |
+
|
3265 |
+
// currently setting up conditions for fieldX, this field is the 'target'
|
3266 |
+
var target = conditions.get('field');
|
3267 |
+
|
3268 |
+
// use the 'target' to find the 'trigger' field.
|
3269 |
+
// - this field is used to setup the conditional logic events
|
3270 |
+
var field = target.getField( rule.field );
|
3271 |
+
|
3272 |
+
// ACF Extended: Check in all form if targeted field not found
|
3273 |
+
if( target && !field ) {
|
3274 |
+
|
3275 |
+
field = acf.getField( rule.field );
|
3276 |
+
|
3277 |
+
}
|
3278 |
+
|
3279 |
+
// bail ealry if no target or no field (possible if field doesn't exist due to HTML error)
|
3280 |
+
if( !target || !field ) {
|
3281 |
+
return false;
|
3282 |
+
}
|
3283 |
+
|
3284 |
+
// vars
|
3285 |
+
var args = {
|
3286 |
+
rule: rule,
|
3287 |
+
target: target,
|
3288 |
+
conditions: conditions,
|
3289 |
+
field: field
|
3290 |
+
};
|
3291 |
+
|
3292 |
+
// vars
|
3293 |
+
var fieldType = field.get('type');
|
3294 |
+
var operator = rule.operator;
|
3295 |
+
|
3296 |
+
// get avaibale conditions
|
3297 |
+
var conditionTypes = acf.getConditionTypes({
|
3298 |
+
fieldType: fieldType,
|
3299 |
+
operator: operator,
|
3300 |
+
});
|
3301 |
+
|
3302 |
+
// instantiate
|
3303 |
+
var model = conditionTypes[0] || acf.Condition;
|
3304 |
+
|
3305 |
+
// instantiate
|
3306 |
+
var condition = new model( args );
|
3307 |
+
|
3308 |
+
// return
|
3309 |
+
return condition;
|
3310 |
+
|
3311 |
+
};
|
3312 |
+
|
3313 |
})(jQuery);
|
3314 |
+
(function($){
|
3315 |
+
|
3316 |
+
if(typeof acf === 'undefined')
|
3317 |
+
return;
|
3318 |
+
|
3319 |
+
/*
|
3320 |
+
* Init
|
3321 |
+
*/
|
3322 |
+
var repeater = acf.getFieldType('repeater');
|
3323 |
+
var model = repeater.prototype;
|
3324 |
+
|
3325 |
+
// Repeater: Lock Layouts
|
3326 |
+
model.acfeOnHover = function(){
|
3327 |
+
|
3328 |
+
var repeater = this;
|
3329 |
+
|
3330 |
+
// remove event
|
3331 |
+
repeater.off('mouseover');
|
3332 |
+
|
3333 |
+
}
|
3334 |
+
|
3335 |
+
/*
|
3336 |
+
* Spawn
|
3337 |
+
*/
|
3338 |
+
acf.addAction('new_field/type=repeater', function(repeater){
|
3339 |
+
|
3340 |
+
// ACFE: Lock
|
3341 |
+
if(repeater.has('acfeRepeaterLock')){
|
3342 |
+
|
3343 |
+
repeater.removeEvents({'mouseover': 'onHover'});
|
3344 |
+
|
3345 |
+
repeater.addEvents({'mouseover': 'acfeOnHover'});
|
3346 |
+
|
3347 |
+
}
|
3348 |
+
|
3349 |
+
// ACFE: Remove Actions
|
3350 |
+
if(repeater.has('acfeRepeaterRemoveActions')){
|
3351 |
+
|
3352 |
+
repeater.$actions().remove();
|
3353 |
+
|
3354 |
+
repeater.$el.find('thead:first > tr > th.acf-row-handle:last').remove();
|
3355 |
+
repeater.$rows().find('> .acf-row-handle:last').remove();
|
3356 |
+
|
3357 |
+
repeater.$control().find('> .acfe-repeater-stylised-button').remove();
|
3358 |
+
|
3359 |
+
|
3360 |
+
}
|
3361 |
+
|
3362 |
+
// ACFE: Stylised button
|
3363 |
+
if(repeater.has('acfeRepeaterStylisedButton')){
|
3364 |
+
|
3365 |
+
repeater.$button().removeClass('button-primary');
|
3366 |
+
repeater.$actions().wrap('<div class="acfe-repeater-stylised-button" />');
|
3367 |
+
|
3368 |
+
}
|
3369 |
+
|
3370 |
+
});
|
3371 |
+
|
3372 |
})(jQuery);
|
@@ -0,0 +1,382 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function($){
|
2 |
+
|
3 |
+
if(typeof acf === 'undefined')
|
4 |
+
return;
|
5 |
+
|
6 |
+
acfe.enhancedEditUI = function(props){
|
7 |
+
return new enhancedEditUI(props);
|
8 |
+
};
|
9 |
+
|
10 |
+
var enhancedEditUI = acf.Model.extend({
|
11 |
+
|
12 |
+
data: {
|
13 |
+
screen: false,
|
14 |
+
submit: '> p.submit',
|
15 |
+
pageTitle: false
|
16 |
+
},
|
17 |
+
|
18 |
+
title: false,
|
19 |
+
$form: false,
|
20 |
+
$main: false,
|
21 |
+
$sidebar: false,
|
22 |
+
|
23 |
+
setup: function(props){
|
24 |
+
|
25 |
+
// Extend data
|
26 |
+
$.extend(this.data, props);
|
27 |
+
|
28 |
+
// $el
|
29 |
+
this.$el = $('.wrap');
|
30 |
+
this.$el.attr('id', 'poststuff');
|
31 |
+
|
32 |
+
// Init
|
33 |
+
this.$('> form').wrapInner('<div class="acf-columns-2"><div class="acf-column-1"></div></div>');
|
34 |
+
$('#side-sortables').appendTo('.acf-columns-2').wrapAll('<div class="acf-column-2"></div>');
|
35 |
+
|
36 |
+
// Vars
|
37 |
+
this.title = this.$('> h1').text();
|
38 |
+
this.$form = this.$('> form');
|
39 |
+
this.$main = this.$('.acf-column-1');
|
40 |
+
this.$sidebar = this.$('.acf-column-2');
|
41 |
+
|
42 |
+
// Fake Page Title
|
43 |
+
if(this.get('pageTitle')){
|
44 |
+
this.$main.find('> table:first').before('<h2>' + this.title + '</h2>');
|
45 |
+
}
|
46 |
+
|
47 |
+
// Sidebar Title
|
48 |
+
$('#submitdiv > .postbox-header > h2.hndle').text(this.title);
|
49 |
+
|
50 |
+
// Submit: Move to Sidebar
|
51 |
+
this.$main.find(this.get('submit')).contents().appendTo('#publishing-action');
|
52 |
+
this.$main.find(this.get('submit')).remove();
|
53 |
+
|
54 |
+
// Submit: Button
|
55 |
+
$('#submitdiv #publishing-action .button').addClass('button-large').after('<span class="spinner"></span>');
|
56 |
+
|
57 |
+
},
|
58 |
+
|
59 |
+
events:{
|
60 |
+
'submit form': 'onSubmit'
|
61 |
+
},
|
62 |
+
|
63 |
+
initialize: function(){
|
64 |
+
|
65 |
+
this.addActions({
|
66 |
+
'acfe/ui/user-edit': 'userEdit',
|
67 |
+
'acfe/ui/user-new': 'userNew',
|
68 |
+
'acfe/ui/term-edit': 'termEdit',
|
69 |
+
'acfe/ui/settings': 'settings',
|
70 |
+
});
|
71 |
+
|
72 |
+
acf.doAction('acfe/ui/' + this.get('screen'), this);
|
73 |
+
|
74 |
+
},
|
75 |
+
|
76 |
+
onSubmit: function(e, $el){
|
77 |
+
|
78 |
+
acf.lockForm($el);
|
79 |
+
|
80 |
+
},
|
81 |
+
|
82 |
+
userEdit: function(){
|
83 |
+
|
84 |
+
// Vars
|
85 |
+
var $main = this.$main;
|
86 |
+
|
87 |
+
// Metabox: After Title
|
88 |
+
$main.prepend($('#acf_after_title-sortables'));
|
89 |
+
|
90 |
+
// Yoast Settings
|
91 |
+
var $yoastSettings = this.$('> form .yoast.yoast-settings');
|
92 |
+
|
93 |
+
if($yoastSettings.length){
|
94 |
+
|
95 |
+
$yoastSettings.addClass('postbox');
|
96 |
+
$yoastSettings.find('> h2').wrapAll('<div class="postbox-header"></div>');
|
97 |
+
$yoastSettings.find('> .postbox-header ~ *').wrapAll('<div class="acf-fields -left"></div>');
|
98 |
+
$yoastSettings.find('.acf-fields > label:nth-of-type(1), .acf-fields > input:nth-of-type(1)').wrapAll('<div class="acf-field"></div>');
|
99 |
+
$yoastSettings.find('.acf-fields > label:nth-of-type(1), .acf-fields > label:nth-of-type(1) ~ *').wrapAll('<div class="acf-field"></div>');
|
100 |
+
$yoastSettings.find('.acf-fields > br').remove();
|
101 |
+
|
102 |
+
$yoastSettings.find('.acf-field').each(function(){
|
103 |
+
|
104 |
+
var $this = $(this);
|
105 |
+
$this.find('label:nth-of-type(1)').wrapAll('<div class="acf-label"></div>');
|
106 |
+
$this.find('.acf-label ~ *').wrapAll('<div class="acf-input"></div>');
|
107 |
+
|
108 |
+
});
|
109 |
+
|
110 |
+
}
|
111 |
+
|
112 |
+
// RankMath
|
113 |
+
var $rankMath = this.$('> form .rank-math-metabox-frame');
|
114 |
+
|
115 |
+
if($rankMath.length){
|
116 |
+
|
117 |
+
var rankMathTitle = $rankMath.find('h2').text();
|
118 |
+
|
119 |
+
$rankMath.find('h2').remove();
|
120 |
+
$rankMath.wrapAll('<div class="postbox acf-postbox rankmath"><div class="acf-fields -left"><div class="acf-field"><div class="acf-input"></div></div></div></div>');
|
121 |
+
$rankMath.closest('.acf-field').prepend('<div class="acf-label"><label>' + rankMathTitle + '</label></div>');
|
122 |
+
$rankMath.closest('.postbox').prepend('<div class="postbox-header"><h2>' + rankMathTitle + '</h2></div>');
|
123 |
+
|
124 |
+
}
|
125 |
+
|
126 |
+
// User Role Editor
|
127 |
+
var $userRoleEditor = this.$('#ure_select_other_roles');
|
128 |
+
|
129 |
+
if($userRoleEditor.length){
|
130 |
+
$userRoleEditor.closest('table').find('tr:eq(1) > td > br').remove();
|
131 |
+
}
|
132 |
+
|
133 |
+
// Application Passwords
|
134 |
+
var $applicationPasswords = $('#application-passwords-section');
|
135 |
+
|
136 |
+
if($applicationPasswords.length){
|
137 |
+
|
138 |
+
var title = $applicationPasswords.find('> h2').text();
|
139 |
+
|
140 |
+
$applicationPasswords.addClass('postbox');
|
141 |
+
$applicationPasswords.wrapInner('<div class="acf-fields -left"><div class="acf-field"><div class="acf-input"></div></div></div>');
|
142 |
+
$applicationPasswords.find('.acf-input > h2').insertBefore($applicationPasswords.find('.acf-fields')).wrapAll('<div class="postbox-header"></div>');
|
143 |
+
$applicationPasswords.find('.acf-input').before('<div class="acf-label"><label>' + title + '</label></div>');
|
144 |
+
$applicationPasswords.find('.acf-input > p:first').css('margin-top', 15).insertBefore($applicationPasswords.find('p.submit'));
|
145 |
+
|
146 |
+
$applicationPasswords.find('.acf-input > .create-application-password > .form-field').removeClass('form-field');
|
147 |
+
$applicationPasswords.find('.acf-input > .create-application-password > div > label').remove();
|
148 |
+
|
149 |
+
}
|
150 |
+
|
151 |
+
// Nickname Field
|
152 |
+
var $userNickname = $('input#nickname');
|
153 |
+
|
154 |
+
if($userNickname.length){
|
155 |
+
|
156 |
+
$userNickname.wrapAll('<div id="titlediv"><div id="titlewrap"></div></div>');
|
157 |
+
$('#titlediv').append($('#edit-slug-box')).prependTo($main);
|
158 |
+
$main.find('tr.user-nickname-wrap').remove();
|
159 |
+
|
160 |
+
}
|
161 |
+
|
162 |
+
// Reorder Name to first metabox
|
163 |
+
$main.find('> h2:eq(1), > h2:eq(1) + table').insertBefore($main.find('> h2:first'));
|
164 |
+
|
165 |
+
},
|
166 |
+
|
167 |
+
userNew: function(){
|
168 |
+
|
169 |
+
// Vars
|
170 |
+
var $main = this.$main;
|
171 |
+
this.$('> p:first').insertAfter($main.find('>h2:first'));
|
172 |
+
$main.prepend($('#acf_after_title-sortables'));
|
173 |
+
|
174 |
+
},
|
175 |
+
|
176 |
+
termEdit: function(){
|
177 |
+
|
178 |
+
// Vars
|
179 |
+
var $main = this.$main;
|
180 |
+
|
181 |
+
// Term Name Field
|
182 |
+
var $termName = $('input#name');
|
183 |
+
|
184 |
+
if($termName.length){
|
185 |
+
|
186 |
+
$termName.wrapAll('<div id="titlediv"><div id="titlewrap"></div></div>');
|
187 |
+
$('#titlediv').append($('.permalink')).prependTo($main);
|
188 |
+
$main.find('tr.term-name-wrap').remove();
|
189 |
+
|
190 |
+
}
|
191 |
+
|
192 |
+
// WPML Widget
|
193 |
+
var $wpml = $('#icl_tax_menu');
|
194 |
+
|
195 |
+
if($wpml.length){
|
196 |
+
|
197 |
+
var widgetTitle = $wpml.find('h3.hndle').text();
|
198 |
+
$wpml.find('.inside').addClass('icl-tax-postbox-content').attr('style', '').insertAfter('#submitdiv');
|
199 |
+
this.$sidebar.find('.icl-tax-postbox-content').wrapAll('<div id="icl-tax-postbox" class="postbox"></div>').parent().prepend('<div class="postbox-header"><h2 class="hdnle">' + widgetTitle + '</h2></div>');
|
200 |
+
|
201 |
+
}
|
202 |
+
|
203 |
+
// Yoast
|
204 |
+
var $yoast = $('.wpseo-taxonomy-metabox-postbox');
|
205 |
+
|
206 |
+
if($yoast.length){
|
207 |
+
|
208 |
+
var metaboxTitle = $yoast.find('> h2').text();
|
209 |
+
$yoast.find('> .inside').removeClass('inside').wrapAll('<div class="acf-fields -left"><div class="acf-field"><div class="acf-input"></div></div></div>');
|
210 |
+
$('<div class="acf-label"><label>' + metaboxTitle + '</label></div>').insertBefore($yoast.find('.acf-input'));
|
211 |
+
|
212 |
+
}
|
213 |
+
|
214 |
+
// RankMath
|
215 |
+
var $rankMath = this.$('> form .rank-math-metabox-frame');
|
216 |
+
|
217 |
+
if($rankMath.length){
|
218 |
+
|
219 |
+
var rankMathTitle = $rankMath.find('h2').text();
|
220 |
+
|
221 |
+
$rankMath.find('h2').remove();
|
222 |
+
$rankMath.wrapAll('<div class="postbox acf-postbox rankmath"><div class="acf-fields -left"><div class="acf-field"><div class="acf-input"></div></div></div></div>');
|
223 |
+
$rankMath.closest('.acf-field').prepend('<div class="acf-label"><label>' + rankMathTitle + '</label></div>');
|
224 |
+
$rankMath.closest('.postbox').prepend('<div class="postbox-header"><h2>' + rankMathTitle + '</h2></div>');
|
225 |
+
|
226 |
+
}
|
227 |
+
|
228 |
+
},
|
229 |
+
|
230 |
+
settings: function(){
|
231 |
+
|
232 |
+
// Fix potential empty locale causing error
|
233 |
+
if(!acf.get('locale'))
|
234 |
+
acf.set('locale', 'en_US');
|
235 |
+
|
236 |
+
// Form Data
|
237 |
+
$('#acf-form-data').prependTo(this.$form);
|
238 |
+
|
239 |
+
// Metabox: After title
|
240 |
+
$('#acf_after_title-sortables').prependTo(this.$main);
|
241 |
+
|
242 |
+
// Metabox: Normal
|
243 |
+
$('#normal-sortables').appendTo(this.$main);
|
244 |
+
|
245 |
+
// Writing: Ping
|
246 |
+
var $pingSites = this.$('#ping_sites');
|
247 |
+
|
248 |
+
if($pingSites.length){
|
249 |
+
$pingSites.wrap('<table class="form-table"><tbody><td class="td-full"></td></tbody></table>');
|
250 |
+
$pingSites.css('width', '100%');
|
251 |
+
}
|
252 |
+
|
253 |
+
// Permlalinks
|
254 |
+
var $permalinks = this.$('.permalink-structure');
|
255 |
+
|
256 |
+
if($permalinks.length){
|
257 |
+
$permalinks.prev().prev('p').insertBefore($permalinks);
|
258 |
+
}
|
259 |
+
|
260 |
+
},
|
261 |
+
|
262 |
+
});
|
263 |
+
|
264 |
+
acfe.enhancedListUI = function(props){
|
265 |
+
return new enhancedListUI(props);
|
266 |
+
};
|
267 |
+
|
268 |
+
var enhancedListUI = acf.Model.extend({
|
269 |
+
|
270 |
+
setup: function(props){
|
271 |
+
|
272 |
+
// Extend data
|
273 |
+
$.extend(this.data, props);
|
274 |
+
|
275 |
+
},
|
276 |
+
|
277 |
+
initialize: function(){
|
278 |
+
|
279 |
+
// Add button
|
280 |
+
$('.wrap .wp-heading-inline').after($('#tmpl-button-add-term').html());
|
281 |
+
|
282 |
+
// Move form
|
283 |
+
$('#ajax-response').after($('#col-container #col-left').addClass('acfe-bt'));
|
284 |
+
|
285 |
+
// Hide form
|
286 |
+
$('.acfe-bt').hide();
|
287 |
+
|
288 |
+
// Create wrapper
|
289 |
+
$('.acfe-bt .form-wrap').append('<div id="poststuff"></div>');
|
290 |
+
|
291 |
+
// Append form inside wrapper
|
292 |
+
var $newForm = $('.acfe-bt .form-wrap form');
|
293 |
+
|
294 |
+
$('.acfe-bt #poststuff').append($newForm);
|
295 |
+
$newForm.wrapInner('<div class="postbox" id="acfe-bt-form"><div class="inside"></div></div>');
|
296 |
+
|
297 |
+
// Append new title
|
298 |
+
var $nativeTitle = $('.acfe-bt .form-wrap > h2');
|
299 |
+
|
300 |
+
$('.acfe-bt .postbox').prepend('<h2 class="hndle">' + $nativeTitle.text() + '</h2>');
|
301 |
+
$nativeTitle.remove();
|
302 |
+
|
303 |
+
// ACF class
|
304 |
+
var $fields = $('.acfe-bt .inside .form-field, .acfe-bt .inside .submit');
|
305 |
+
$fields.addClass('acf-field');
|
306 |
+
|
307 |
+
$fields.each(function(){
|
308 |
+
|
309 |
+
var $this = $(this);
|
310 |
+
|
311 |
+
// Polylang Exception
|
312 |
+
if($this.is('#term-translations'))
|
313 |
+
return;
|
314 |
+
|
315 |
+
$this.append('<div class="acf-input"></div>');
|
316 |
+
$this.find('.acf-input').append($this.find('> :not("label")'));
|
317 |
+
|
318 |
+
// Add spacing when a meta field has no label
|
319 |
+
var $label = $this.find('> label');
|
320 |
+
if($label.length){
|
321 |
+
|
322 |
+
$label.wrap('<div class="acf-label"></div>');
|
323 |
+
|
324 |
+
}else{
|
325 |
+
|
326 |
+
$this.addClass('acfe-bt-no-label');
|
327 |
+
|
328 |
+
}
|
329 |
+
|
330 |
+
});
|
331 |
+
|
332 |
+
// Remove ACF Fields id
|
333 |
+
$('#acf-term-fields').contents().unwrap();
|
334 |
+
|
335 |
+
// Button
|
336 |
+
var $newButton = $('.acfe-bt-admin-button-add');
|
337 |
+
|
338 |
+
$newButton.click(function(e){
|
339 |
+
|
340 |
+
e.preventDefault();
|
341 |
+
var $wrap = $('.acfe-bt');
|
342 |
+
|
343 |
+
if($wrap.is(':visible'))
|
344 |
+
$wrap.hide();
|
345 |
+
else
|
346 |
+
$wrap.show();
|
347 |
+
|
348 |
+
});
|
349 |
+
|
350 |
+
// Label to left
|
351 |
+
if(typeof acf !== 'undefined'){
|
352 |
+
acf.postbox.render({
|
353 |
+
'id': 'acfe-bt-form',
|
354 |
+
'label': 'left'
|
355 |
+
});
|
356 |
+
}
|
357 |
+
|
358 |
+
$('#acfe-bt-form .acf-tab-wrap.-left').removeClass('-left').addClass('-top');
|
359 |
+
|
360 |
+
// WPML Widget
|
361 |
+
var $wpml = $('#icl_tax_menu');
|
362 |
+
|
363 |
+
if($wpml.length){
|
364 |
+
|
365 |
+
var $wpmlWidget = $wpml.find('.postbox').removeClass('postbox');
|
366 |
+
$wpmlWidget.find('.inside').removeClass('inside').css('padding', 0);
|
367 |
+
$wpmlWidget.insertBefore('.acfe-bt .inside .submit');
|
368 |
+
|
369 |
+
var wpmlTitle = $wpmlWidget.find('h3.hndle').text();
|
370 |
+
|
371 |
+
$wpmlWidget.find('.hndle').remove();
|
372 |
+
|
373 |
+
$wpmlWidget.wrapAll('<div class="form-field acf-field"><div class="acf-input"></div></div>').parent().parent().prepend('<div class="acf-label"><label>' + wpmlTitle + '</label></div>');
|
374 |
+
|
375 |
+
|
376 |
+
}
|
377 |
+
|
378 |
+
}
|
379 |
+
|
380 |
+
});
|
381 |
+
|
382 |
+
})(jQuery);
|
@@ -0,0 +1 @@
|
|
|
1 |
+
!function(s){var i,t;"undefined"!=typeof acf&&(acfe.enhancedEditUI=function(e){return new i(e)},i=acf.Model.extend({data:{screen:!1,submit:"> p.submit",pageTitle:!1},title:!1,$form:!1,$main:!1,$sidebar:!1,setup:function(e){s.extend(this.data,e),this.$el=s(".wrap"),this.$el.attr("id","poststuff"),this.$("> form").wrapInner('<div class="acf-columns-2"><div class="acf-column-1"></div></div>'),s("#side-sortables").appendTo(".acf-columns-2").wrapAll('<div class="acf-column-2"></div>'),this.title=this.$("> h1").text(),this.$form=this.$("> form"),this.$main=this.$(".acf-column-1"),this.$sidebar=this.$(".acf-column-2"),this.get("pageTitle")&&this.$main.find("> table:first").before("<h2>"+this.title+"</h2>"),s("#submitdiv > .postbox-header > h2.hndle").text(this.title),this.$main.find(this.get("submit")).contents().appendTo("#publishing-action"),this.$main.find(this.get("submit")).remove(),s("#submitdiv #publishing-action .button").addClass("button-large").after('<span class="spinner"></span>')},events:{"submit form":"onSubmit"},initialize:function(){this.addActions({"acfe/ui/user-edit":"userEdit","acfe/ui/user-new":"userNew","acfe/ui/term-edit":"termEdit","acfe/ui/settings":"settings"}),acf.doAction("acfe/ui/"+this.get("screen"),this)},onSubmit:function(e,i){acf.lockForm(i)},userEdit:function(){var e=this.$main;e.prepend(s("#acf_after_title-sortables"));var i=this.$("> form .yoast.yoast-settings");i.length&&(i.addClass("postbox"),i.find("> h2").wrapAll('<div class="postbox-header"></div>'),i.find("> .postbox-header ~ *").wrapAll('<div class="acf-fields -left"></div>'),i.find(".acf-fields > label:nth-of-type(1), .acf-fields > input:nth-of-type(1)").wrapAll('<div class="acf-field"></div>'),i.find(".acf-fields > label:nth-of-type(1), .acf-fields > label:nth-of-type(1) ~ *").wrapAll('<div class="acf-field"></div>'),i.find(".acf-fields > br").remove(),i.find(".acf-field").each(function(){var e=s(this);e.find("label:nth-of-type(1)").wrapAll('<div class="acf-label"></div>'),e.find(".acf-label ~ *").wrapAll('<div class="acf-input"></div>')}));i=this.$("> form .rank-math-metabox-frame");i.length&&(t=i.find("h2").text(),i.find("h2").remove(),i.wrapAll('<div class="postbox acf-postbox rankmath"><div class="acf-fields -left"><div class="acf-field"><div class="acf-input"></div></div></div></div>'),i.closest(".acf-field").prepend('<div class="acf-label"><label>'+t+"</label></div>"),i.closest(".postbox").prepend('<div class="postbox-header"><h2>'+t+"</h2></div>"));i=this.$("#ure_select_other_roles");i.length&&i.closest("table").find("tr:eq(1) > td > br").remove();var t=s("#application-passwords-section");t.length&&(i=t.find("> h2").text(),t.addClass("postbox"),t.wrapInner('<div class="acf-fields -left"><div class="acf-field"><div class="acf-input"></div></div></div>'),t.find(".acf-input > h2").insertBefore(t.find(".acf-fields")).wrapAll('<div class="postbox-header"></div>'),t.find(".acf-input").before('<div class="acf-label"><label>'+i+"</label></div>"),t.find(".acf-input > p:first").css("margin-top",15).insertBefore(t.find("p.submit")),t.find(".acf-input > .create-application-password > .form-field").removeClass("form-field"),t.find(".acf-input > .create-application-password > div > label").remove());t=s("input#nickname");t.length&&(t.wrapAll('<div id="titlediv"><div id="titlewrap"></div></div>'),s("#titlediv").append(s("#edit-slug-box")).prependTo(e),e.find("tr.user-nickname-wrap").remove()),e.find("> h2:eq(1), > h2:eq(1) + table").insertBefore(e.find("> h2:first"))},userNew:function(){var e=this.$main;this.$("> p:first").insertAfter(e.find(">h2:first")),e.prepend(s("#acf_after_title-sortables"))},termEdit:function(){var e=this.$main,i=s("input#name");i.length&&(i.wrapAll('<div id="titlediv"><div id="titlewrap"></div></div>'),s("#titlediv").append(s(".permalink")).prependTo(e),e.find("tr.term-name-wrap").remove());e=s("#icl_tax_menu");e.length&&(t=e.find("h3.hndle").text(),e.find(".inside").addClass("icl-tax-postbox-content").attr("style","").insertAfter("#submitdiv"),this.$sidebar.find(".icl-tax-postbox-content").wrapAll('<div id="icl-tax-postbox" class="postbox"></div>').parent().prepend('<div class="postbox-header"><h2 class="hdnle">'+t+"</h2></div>"));var t=s(".wpseo-taxonomy-metabox-postbox");t.length&&(a=t.find("> h2").text(),t.find("> .inside").removeClass("inside").wrapAll('<div class="acf-fields -left"><div class="acf-field"><div class="acf-input"></div></div></div>'),s('<div class="acf-label"><label>'+a+"</label></div>").insertBefore(t.find(".acf-input")));var a=this.$("> form .rank-math-metabox-frame");a.length&&(t=a.find("h2").text(),a.find("h2").remove(),a.wrapAll('<div class="postbox acf-postbox rankmath"><div class="acf-fields -left"><div class="acf-field"><div class="acf-input"></div></div></div></div>'),a.closest(".acf-field").prepend('<div class="acf-label"><label>'+t+"</label></div>"),a.closest(".postbox").prepend('<div class="postbox-header"><h2>'+t+"</h2></div>"))},settings:function(){acf.get("locale")||acf.set("locale","en_US"),s("#acf-form-data").prependTo(this.$form),s("#acf_after_title-sortables").prependTo(this.$main),s("#normal-sortables").appendTo(this.$main);var e=this.$("#ping_sites");e.length&&(e.wrap('<table class="form-table"><tbody><td class="td-full"></td></tbody></table>'),e.css("width","100%"));e=this.$(".permalink-structure");e.length&&e.prev().prev("p").insertBefore(e)}}),acfe.enhancedListUI=function(e){return new t(e)},t=acf.Model.extend({setup:function(e){s.extend(this.data,e)},initialize:function(){s(".wrap .wp-heading-inline").after(s("#tmpl-button-add-term").html()),s("#ajax-response").after(s("#col-container #col-left").addClass("acfe-bt")),s(".acfe-bt").hide(),s(".acfe-bt .form-wrap").append('<div id="poststuff"></div>');var e=s(".acfe-bt .form-wrap form");s(".acfe-bt #poststuff").append(e),e.wrapInner('<div class="postbox" id="acfe-bt-form"><div class="inside"></div></div>');var i=s(".acfe-bt .form-wrap > h2");s(".acfe-bt .postbox").prepend('<h2 class="hndle">'+i.text()+"</h2>"),i.remove();e=s(".acfe-bt .inside .form-field, .acfe-bt .inside .submit");e.addClass("acf-field"),e.each(function(){var e,i=s(this);i.is("#term-translations")||(i.append('<div class="acf-input"></div>'),i.find(".acf-input").append(i.find('> :not("label")')),(e=i.find("> label")).length?e.wrap('<div class="acf-label"></div>'):i.addClass("acfe-bt-no-label"))}),s("#acf-term-fields").contents().unwrap(),s(".acfe-bt-admin-button-add").click(function(e){e.preventDefault();e=s(".acfe-bt");e.is(":visible")?e.hide():e.show()}),"undefined"!=typeof acf&&acf.postbox.render({id:"acfe-bt-form",label:"left"}),s("#acfe-bt-form .acf-tab-wrap.-left").removeClass("-left").addClass("-top");i=s("#icl_tax_menu");i.length&&((e=i.find(".postbox").removeClass("postbox")).find(".inside").removeClass("inside").css("padding",0),e.insertBefore(".acfe-bt .inside .submit"),i=e.find("h3.hndle").text(),e.find(".hndle").remove(),e.wrapAll('<div class="form-field acf-field"><div class="acf-input"></div></div>').parent().parent().prepend('<div class="acf-label"><label>'+i+"</label></div>"))}}))}(jQuery);
|
@@ -1,427 +1,432 @@
|
|
1 |
-
(function($){
|
2 |
-
|
3 |
-
if(typeof acf === 'undefined')
|
4 |
-
return;
|
5 |
-
|
6 |
-
/*
|
7 |
-
*
|
8 |
-
*/
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
acfe
|
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 |
-
this.$
|
137 |
-
|
138 |
-
acfe.
|
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 |
-
var
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
var
|
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 |
})(jQuery);
|
1 |
+
(function($){
|
2 |
+
|
3 |
+
if(typeof acf === 'undefined')
|
4 |
+
return;
|
5 |
+
|
6 |
+
/*
|
7 |
+
* ACF Data
|
8 |
+
*/
|
9 |
+
acf.data.acfe = {};
|
10 |
+
|
11 |
+
/*
|
12 |
+
* ACFE
|
13 |
+
*/
|
14 |
+
var acfe = {};
|
15 |
+
|
16 |
+
window.acfe = acfe;
|
17 |
+
|
18 |
+
/*
|
19 |
+
* Get
|
20 |
+
*/
|
21 |
+
acfe.get = function(name){
|
22 |
+
return acf.data.acfe[name] || null;
|
23 |
+
};
|
24 |
+
|
25 |
+
/*
|
26 |
+
* Has
|
27 |
+
*/
|
28 |
+
acfe.has = function(name){
|
29 |
+
return this.get(name) !== null;
|
30 |
+
};
|
31 |
+
|
32 |
+
/*
|
33 |
+
* Set
|
34 |
+
*/
|
35 |
+
acfe.set = function(name, value){
|
36 |
+
acf.data.acfe[name] = value;
|
37 |
+
return this;
|
38 |
+
};
|
39 |
+
|
40 |
+
/*
|
41 |
+
* Popup
|
42 |
+
*/
|
43 |
+
var popups = [];
|
44 |
+
|
45 |
+
acfe.Popup = acf.Model.extend({
|
46 |
+
|
47 |
+
data: {
|
48 |
+
title: false,
|
49 |
+
footer: false,
|
50 |
+
size: false,
|
51 |
+
destroy: false,
|
52 |
+
onOpen: function(){},
|
53 |
+
onClose: function(){},
|
54 |
+
},
|
55 |
+
|
56 |
+
events: {
|
57 |
+
'click .acfe-modal-title>.close': 'onClickClose',
|
58 |
+
'click .acfe-modal-footer>button': 'onClickClose',
|
59 |
+
},
|
60 |
+
|
61 |
+
setup: function($content, args){
|
62 |
+
|
63 |
+
$.extend(this.data, args);
|
64 |
+
|
65 |
+
this.$el = $content;
|
66 |
+
this.render();
|
67 |
+
|
68 |
+
},
|
69 |
+
|
70 |
+
initialize: function(){
|
71 |
+
|
72 |
+
this.open();
|
73 |
+
|
74 |
+
},
|
75 |
+
|
76 |
+
render: function(){
|
77 |
+
|
78 |
+
// Size
|
79 |
+
if(this.get('size')){
|
80 |
+
|
81 |
+
this.$el.addClass('-' + this.get('size'));
|
82 |
+
|
83 |
+
}
|
84 |
+
|
85 |
+
// Wrapper
|
86 |
+
if(!this.$('> .acfe-modal-wrapper').length){
|
87 |
+
|
88 |
+
this.$el.wrapInner('<div class="acfe-modal-wrapper" />');
|
89 |
+
|
90 |
+
}
|
91 |
+
|
92 |
+
var $wrapper = this.$('> .acfe-modal-wrapper');
|
93 |
+
|
94 |
+
// Content
|
95 |
+
if(!$wrapper.find('> .acfe-modal-content').length){
|
96 |
+
|
97 |
+
$wrapper.wrapInner('<div class="acfe-modal-content" />');
|
98 |
+
|
99 |
+
}
|
100 |
+
|
101 |
+
// Title
|
102 |
+
if(this.get('title')){
|
103 |
+
|
104 |
+
$wrapper.prepend('<div class="acfe-modal-title"><span class="title">' + this.get('title') + '</span><button class="close"></button></div>');
|
105 |
+
|
106 |
+
}
|
107 |
+
|
108 |
+
// Overlay
|
109 |
+
$wrapper.prepend('<div class="acfe-modal-wrapper-overlay"></div>');
|
110 |
+
|
111 |
+
// Footer
|
112 |
+
if(this.get('footer')){
|
113 |
+
|
114 |
+
$wrapper.append('<div class="acfe-modal-footer"><button class="button button-primary">' + this.get('footer') + '</button></div>');
|
115 |
+
|
116 |
+
}
|
117 |
+
|
118 |
+
},
|
119 |
+
|
120 |
+
open: function(){
|
121 |
+
|
122 |
+
this.$el.addClass('-open');
|
123 |
+
|
124 |
+
popups.push(this);
|
125 |
+
|
126 |
+
acfe.syncPopup();
|
127 |
+
|
128 |
+
acf.doAction('acfe/modal/open', this.$el, this.data);
|
129 |
+
|
130 |
+
this.get('onOpen').apply(this.$el);
|
131 |
+
|
132 |
+
},
|
133 |
+
|
134 |
+
close: function(){
|
135 |
+
|
136 |
+
this.$('.acfe-modal-wrapper-overlay').remove();
|
137 |
+
this.$('.acfe-modal-title').remove();
|
138 |
+
this.$('.acfe-modal-footer').remove();
|
139 |
+
|
140 |
+
this.$el.removeAttr('style');
|
141 |
+
this.$el.removeClass('-open');
|
142 |
+
|
143 |
+
acfe.syncPopup();
|
144 |
+
|
145 |
+
acf.doAction('acfe/modal/close', this.$el, this.data);
|
146 |
+
|
147 |
+
this.get('onClose').apply(this.$el);
|
148 |
+
|
149 |
+
this.remove();
|
150 |
+
|
151 |
+
if(this.get('destroy')){
|
152 |
+
|
153 |
+
this.$el.remove();
|
154 |
+
|
155 |
+
}
|
156 |
+
|
157 |
+
},
|
158 |
+
|
159 |
+
remove: function(){
|
160 |
+
|
161 |
+
this.removeEvents();
|
162 |
+
this.removeActions();
|
163 |
+
this.removeFilters();
|
164 |
+
|
165 |
+
},
|
166 |
+
|
167 |
+
onClickClose: function(e){
|
168 |
+
|
169 |
+
e.preventDefault();
|
170 |
+
|
171 |
+
if(!popups.length)
|
172 |
+
return false;
|
173 |
+
|
174 |
+
popups.pop().close();
|
175 |
+
|
176 |
+
}
|
177 |
+
|
178 |
+
});
|
179 |
+
|
180 |
+
/*
|
181 |
+
* Popup: Close
|
182 |
+
*/
|
183 |
+
acfe.closePopup = function(){
|
184 |
+
|
185 |
+
if(!popups.length)
|
186 |
+
return false;
|
187 |
+
|
188 |
+
popups.pop().close();
|
189 |
+
|
190 |
+
};
|
191 |
+
|
192 |
+
/*
|
193 |
+
* Popup: Sync
|
194 |
+
*/
|
195 |
+
acfe.syncPopup = function(){
|
196 |
+
|
197 |
+
var $body = $('body');
|
198 |
+
|
199 |
+
if(popups.length){
|
200 |
+
|
201 |
+
// Prepare Body
|
202 |
+
if(!$body.hasClass('acfe-modal-opened')){
|
203 |
+
|
204 |
+
$body.addClass('acfe-modal-opened').append($('<div class="acfe-modal-overlay" />'));
|
205 |
+
|
206 |
+
$('.acfe-modal-overlay').on('click', function(e){
|
207 |
+
|
208 |
+
e.preventDefault();
|
209 |
+
acfe.closePopup();
|
210 |
+
|
211 |
+
});
|
212 |
+
|
213 |
+
}
|
214 |
+
|
215 |
+
// Prepare Multiple
|
216 |
+
popups.map(function(self, i){
|
217 |
+
|
218 |
+
if(i === popups.length - 1){
|
219 |
+
return self.$el.removeClass('acfe-modal-sub').css('margin-left', '');
|
220 |
+
}
|
221 |
+
|
222 |
+
self.$el.addClass('acfe-modal-sub').css('margin-left', - (500 / (i+1)));
|
223 |
+
|
224 |
+
});
|
225 |
+
|
226 |
+
}else{
|
227 |
+
|
228 |
+
$('.acfe-modal-overlay').remove();
|
229 |
+
$body.removeClass('acfe-modal-opened');
|
230 |
+
|
231 |
+
}
|
232 |
+
|
233 |
+
};
|
234 |
+
|
235 |
+
$(window).on('keydown', function(e){
|
236 |
+
|
237 |
+
if(e.keyCode !== 27 || !$('body').hasClass('acfe-modal-opened'))
|
238 |
+
return;
|
239 |
+
|
240 |
+
e.preventDefault();
|
241 |
+
acfe.closePopup();
|
242 |
+
|
243 |
+
});
|
244 |
+
|
245 |
+
// Compatibility
|
246 |
+
acfe.modal = {
|
247 |
+
|
248 |
+
open: function($modal, args){
|
249 |
+
|
250 |
+
new acfe.Popup($modal, args);
|
251 |
+
|
252 |
+
},
|
253 |
+
|
254 |
+
close: function(){
|
255 |
+
|
256 |
+
acfe.closePopup();
|
257 |
+
|
258 |
+
}
|
259 |
+
|
260 |
+
};
|
261 |
+
|
262 |
+
/*
|
263 |
+
* Filters
|
264 |
+
*/
|
265 |
+
var filters = [];
|
266 |
+
|
267 |
+
acfe.disableFilters = function(){
|
268 |
+
filters = [];
|
269 |
+
};
|
270 |
+
|
271 |
+
acfe.getFilters = function(){
|
272 |
+
return filters;
|
273 |
+
};
|
274 |
+
|
275 |
+
acfe.isFilterEnabled = function(name){
|
276 |
+
return filters.indexOf(name) > -1;
|
277 |
+
};
|
278 |
+
|
279 |
+
acfe.enableFilter = function(name){
|
280 |
+
|
281 |
+
if(filters.indexOf(name) === -1)
|
282 |
+
filters.push(name);
|
283 |
+
|
284 |
+
};
|
285 |
+
|
286 |
+
acfe.disableFilter = function(name){
|
287 |
+
|
288 |
+
for(var i = filters.length; i--;){
|
289 |
+
|
290 |
+
if(filters[i] !== name)
|
291 |
+
continue;
|
292 |
+
|
293 |
+
filters.splice(i, 1);
|
294 |
+
|
295 |
+
}
|
296 |
+
|
297 |
+
};
|
298 |
+
|
299 |
+
/*
|
300 |
+
* Parse String
|
301 |
+
*/
|
302 |
+
acfe.parseString = function(val){
|
303 |
+
return val ? '' + val : '';
|
304 |
+
};
|
305 |
+
|
306 |
+
/*
|
307 |
+
* In Array
|
308 |
+
*/
|
309 |
+
acfe.inArray = function(v1, array){
|
310 |
+
|
311 |
+
array = array.map(function(v2){
|
312 |
+
return acfe.parseString(v2);
|
313 |
+
});
|
314 |
+
|
315 |
+
return (array.indexOf(v1) > -1);
|
316 |
+
|
317 |
+
}
|
318 |
+
|
319 |
+
/*
|
320 |
+
* Parse URL
|
321 |
+
*/
|
322 |
+
acfe.parseURL = function(url){
|
323 |
+
|
324 |
+
url = url || acfe.currentURL;
|
325 |
+
|
326 |
+
var params = {};
|
327 |
+
|
328 |
+
var queryString = url.replace(/^[^\?]+\??/, '');
|
329 |
+
|
330 |
+
if (!queryString)
|
331 |
+
return params;
|
332 |
+
|
333 |
+
var Pairs = queryString.split(/[;&]/);
|
334 |
+
|
335 |
+
for(var i = 0; i < Pairs.length; i++){
|
336 |
+
|
337 |
+
var KeyVal = Pairs[i].split('=');
|
338 |
+
|
339 |
+
if (!KeyVal || KeyVal.length !== 2)
|
340 |
+
continue;
|
341 |
+
|
342 |
+
var key = decodeURI(KeyVal[0]);
|
343 |
+
var val = decodeURI(KeyVal[1]);
|
344 |
+
|
345 |
+
val = val.replace(/\+/g, ' ');
|
346 |
+
|
347 |
+
params[key] = val;
|
348 |
+
|
349 |
+
}
|
350 |
+
|
351 |
+
return params;
|
352 |
+
|
353 |
+
};
|
354 |
+
|
355 |
+
/*
|
356 |
+
* Current URL
|
357 |
+
*/
|
358 |
+
acfe.currentURL = function(){
|
359 |
+
|
360 |
+
return self.location.href;
|
361 |
+
|
362 |
+
};
|
363 |
+
|
364 |
+
/*
|
365 |
+
* Current Path
|
366 |
+
*/
|
367 |
+
acfe.currentPath = function(){
|
368 |
+
|
369 |
+
return self.location.pathname;
|
370 |
+
|
371 |
+
};
|
372 |
+
|
373 |
+
/*
|
374 |
+
* Current Filename
|
375 |
+
*/
|
376 |
+
acfe.currentFilename = function(){
|
377 |
+
|
378 |
+
return acfe.currentPath().split('/').pop();
|
379 |
+
|
380 |
+
};
|
381 |
+
|
382 |
+
/*
|
383 |
+
* Parent Object
|
384 |
+
*/
|
385 |
+
acfe.parentObject = function(obj){
|
386 |
+
return Object.getPrototypeOf(Object.getPrototypeOf(obj));
|
387 |
+
}
|
388 |
+
|
389 |
+
/*
|
390 |
+
* Tooltip
|
391 |
+
*/
|
392 |
+
new acf.Model({
|
393 |
+
|
394 |
+
tooltip: false,
|
395 |
+
|
396 |
+
events: {
|
397 |
+
'click .acfe-field-tooltip': 'showTitle',
|
398 |
+
},
|
399 |
+
|
400 |
+
showTitle: function(e, $el){
|
401 |
+
|
402 |
+
// vars
|
403 |
+
var title = $el.attr('title');
|
404 |
+
|
405 |
+
// bail ealry if no title
|
406 |
+
if( !title ) {
|
407 |
+
return;
|
408 |
+
}
|
409 |
+
|
410 |
+
// clear title to avoid default browser tooltip
|
411 |
+
$el.attr('title', '');
|
412 |
+
|
413 |
+
// create
|
414 |
+
if( !this.tooltip ) {
|
415 |
+
this.tooltip = acf.newTooltip({
|
416 |
+
text: title,
|
417 |
+
target: $el
|
418 |
+
});
|
419 |
+
|
420 |
+
// update
|
421 |
+
} else {
|
422 |
+
this.tooltip.update({
|
423 |
+
text: title,
|
424 |
+
target: $el
|
425 |
+
});
|
426 |
+
}
|
427 |
+
|
428 |
+
}
|
429 |
+
|
430 |
+
});
|
431 |
+
|
432 |
})(jQuery);
|
@@ -1 +1 @@
|
|
1 |
-
!function(o){var l,n,a;"undefined"!=typeof acf&&(l={},(window.acfe=l).get=function(e){return acf.data.acfe[e]||null},l.has=function(e){return null!==this.get(e)},l.set=function(e,t){return acf.data.acfe[e]=t,this},n=[],l.Popup=acf.Model.extend({data:{title:!1,footer:!1,size:!1,destroy:!1,onOpen:function(){},onClose:function(){}},events:{"click .acfe-modal-title>.close":"onClickClose","click .acfe-modal-footer>button":"onClickClose"},setup:function(e,t){o.extend(this.data,t),this.$el=e,this.render()},initialize:function(){this.open()},render:function(){this.get("size")&&this.$el.addClass("-"+this.get("size")),this.$("> .acfe-modal-wrapper").length||this.$el.wrapInner('<div class="acfe-modal-wrapper" />');var e=this.$("> .acfe-modal-wrapper");e.find("> .acfe-modal-content").length||e.wrapInner('<div class="acfe-modal-content" />'),this.get("title")&&e.prepend('<div class="acfe-modal-title"><span class="title">'+this.get("title")+'</span><button class="close"></button></div>'),e.prepend('<div class="acfe-modal-wrapper-overlay"></div>'),this.get("footer")&&e.append('<div class="acfe-modal-footer"><button class="button button-primary">'+this.get("footer")+"</button></div>")},open:function(){this.$el.addClass("-open"),n.push(this),l.syncPopup(),acf.doAction("acfe/modal/open",this.$el,this.data),this.get("onOpen").apply(this.$el)},close:function(){this.$(".acfe-modal-wrapper-overlay").remove(),this.$(".acfe-modal-title").remove(),this.$(".acfe-modal-footer").remove(),this.$el.removeAttr("style"),this.$el.removeClass("-open"),l.syncPopup(),acf.doAction("acfe/modal/close",this.$el,this.data),this.get("onClose").apply(this.$el),this.remove(),this.get("destroy")&&this.$el.remove()},remove:function(){this.removeEvents(),this.removeActions(),this.removeFilters()},onClickClose:function(e){if(e.preventDefault(),!n.length)return!1;n.pop().close()}}),l.closePopup=function(){if(!n.length)return!1;n.pop().close()},l.syncPopup=function(){var e=o("body");n.length?(e.hasClass("acfe-modal-opened")||(e.addClass("acfe-modal-opened").append(o('<div class="acfe-modal-overlay" />')),o(".acfe-modal-overlay").on("click",function(e){e.preventDefault(),l.closePopup()})),n.map(function(e,t){return t===n.length-1?e.$el.removeClass("acfe-modal-sub").css("margin-left",""):void e.$el.addClass("acfe-modal-sub").css("margin-left",-500/(t+1))})):(o(".acfe-modal-overlay").remove(),e.removeClass("acfe-modal-opened"))},o(window).on("keydown",function(e){27===e.keyCode&&o("body").hasClass("acfe-modal-opened")&&(e.preventDefault(),l.closePopup())}),l.modal={open:function(e,t){new l.Popup(e,t)},close:function(){l.closePopup()}},a=[],l.disableFilters=function(){a=[]},l.getFilters=function(){return a},l.isFilterEnabled=function(e){return-1<a.indexOf(e)},l.enableFilter=function(e){-1===a.indexOf(e)&&a.push(e)},l.disableFilter=function(e){for(var t=a.length;t--;)a[t]===e&&a.splice(t,1)},l.parseString=function(e){return e?""+e:""},l.inArray=function(e,t){return-1<(t=t.map(function(e){return l.parseString(e)})).indexOf(e)},l.parseURL=function(e){var t={},e=(e=e||l.currentURL).replace(/^[^\?]+\??/,"");if(!e)return t;for(var o=e.split(/[;&]/),n=0;n<o.length;n++){var a,i=o[n].split("=");i&&2===i.length&&(a=decodeURI(i[0]),i=(i=decodeURI(i[1])).replace(/\+/g," "),t[a]=i)}return t},l.currentURL=function(){return self.location.href},l.currentPath=function(){return self.location.pathname},l.currentFilename=function(){return l.currentPath().split("/").pop()},l.parentObject=function(e){return Object.getPrototypeOf(Object.getPrototypeOf(e))},new acf.Model({tooltip:!1,events:{"click .acfe-field-tooltip":"showTitle"},showTitle:function(e,t){var o=t.attr("title");o&&(t.attr("title",""),this.tooltip?this.tooltip.update({text:o,target:t}):this.tooltip=acf.newTooltip({text:o,target:t}))}}))}(jQuery);
|
1 |
+
!function(o){var l,n,a;"undefined"!=typeof acf&&(acf.data.acfe={},l={},(window.acfe=l).get=function(e){return acf.data.acfe[e]||null},l.has=function(e){return null!==this.get(e)},l.set=function(e,t){return acf.data.acfe[e]=t,this},n=[],l.Popup=acf.Model.extend({data:{title:!1,footer:!1,size:!1,destroy:!1,onOpen:function(){},onClose:function(){}},events:{"click .acfe-modal-title>.close":"onClickClose","click .acfe-modal-footer>button":"onClickClose"},setup:function(e,t){o.extend(this.data,t),this.$el=e,this.render()},initialize:function(){this.open()},render:function(){this.get("size")&&this.$el.addClass("-"+this.get("size")),this.$("> .acfe-modal-wrapper").length||this.$el.wrapInner('<div class="acfe-modal-wrapper" />');var e=this.$("> .acfe-modal-wrapper");e.find("> .acfe-modal-content").length||e.wrapInner('<div class="acfe-modal-content" />'),this.get("title")&&e.prepend('<div class="acfe-modal-title"><span class="title">'+this.get("title")+'</span><button class="close"></button></div>'),e.prepend('<div class="acfe-modal-wrapper-overlay"></div>'),this.get("footer")&&e.append('<div class="acfe-modal-footer"><button class="button button-primary">'+this.get("footer")+"</button></div>")},open:function(){this.$el.addClass("-open"),n.push(this),l.syncPopup(),acf.doAction("acfe/modal/open",this.$el,this.data),this.get("onOpen").apply(this.$el)},close:function(){this.$(".acfe-modal-wrapper-overlay").remove(),this.$(".acfe-modal-title").remove(),this.$(".acfe-modal-footer").remove(),this.$el.removeAttr("style"),this.$el.removeClass("-open"),l.syncPopup(),acf.doAction("acfe/modal/close",this.$el,this.data),this.get("onClose").apply(this.$el),this.remove(),this.get("destroy")&&this.$el.remove()},remove:function(){this.removeEvents(),this.removeActions(),this.removeFilters()},onClickClose:function(e){if(e.preventDefault(),!n.length)return!1;n.pop().close()}}),l.closePopup=function(){if(!n.length)return!1;n.pop().close()},l.syncPopup=function(){var e=o("body");n.length?(e.hasClass("acfe-modal-opened")||(e.addClass("acfe-modal-opened").append(o('<div class="acfe-modal-overlay" />')),o(".acfe-modal-overlay").on("click",function(e){e.preventDefault(),l.closePopup()})),n.map(function(e,t){return t===n.length-1?e.$el.removeClass("acfe-modal-sub").css("margin-left",""):void e.$el.addClass("acfe-modal-sub").css("margin-left",-500/(t+1))})):(o(".acfe-modal-overlay").remove(),e.removeClass("acfe-modal-opened"))},o(window).on("keydown",function(e){27===e.keyCode&&o("body").hasClass("acfe-modal-opened")&&(e.preventDefault(),l.closePopup())}),l.modal={open:function(e,t){new l.Popup(e,t)},close:function(){l.closePopup()}},a=[],l.disableFilters=function(){a=[]},l.getFilters=function(){return a},l.isFilterEnabled=function(e){return-1<a.indexOf(e)},l.enableFilter=function(e){-1===a.indexOf(e)&&a.push(e)},l.disableFilter=function(e){for(var t=a.length;t--;)a[t]===e&&a.splice(t,1)},l.parseString=function(e){return e?""+e:""},l.inArray=function(e,t){return-1<(t=t.map(function(e){return l.parseString(e)})).indexOf(e)},l.parseURL=function(e){var t={},e=(e=e||l.currentURL).replace(/^[^\?]+\??/,"");if(!e)return t;for(var o=e.split(/[;&]/),n=0;n<o.length;n++){var a,i=o[n].split("=");i&&2===i.length&&(a=decodeURI(i[0]),i=(i=decodeURI(i[1])).replace(/\+/g," "),t[a]=i)}return t},l.currentURL=function(){return self.location.href},l.currentPath=function(){return self.location.pathname},l.currentFilename=function(){return l.currentPath().split("/").pop()},l.parentObject=function(e){return Object.getPrototypeOf(Object.getPrototypeOf(e))},new acf.Model({tooltip:!1,events:{"click .acfe-field-tooltip":"showTitle"},showTitle:function(e,t){var o=t.attr("title");o&&(t.attr("title",""),this.tooltip?this.tooltip.update({text:o,target:t}):this.tooltip=acf.newTooltip({text:o,target:t}))}}))}(jQuery);
|
@@ -1,277 +1,277 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
if(!class_exists('WP_List_Table'))
|
7 |
-
require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
|
8 |
-
|
9 |
-
class ACFE_Admin_Options_List extends WP_List_Table{
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Constructor
|
13 |
-
*
|
14 |
-
*/
|
15 |
-
public function __construct(){
|
16 |
-
|
17 |
-
parent::__construct(array(
|
18 |
-
'singular' => __('Option', 'acfe'),
|
19 |
-
'plural' => __('Options', 'acfe'),
|
20 |
-
'ajax' => false
|
21 |
-
));
|
22 |
-
|
23 |
-
}
|
24 |
-
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Retrieve data from the database
|
28 |
-
*
|
29 |
-
* @param int $per_page
|
30 |
-
* @param int $page_number
|
31 |
-
*
|
32 |
-
* @return mixed
|
33 |
-
*/
|
34 |
-
public static function get_options($per_page = 100, $page_number = 1, $search = ''){
|
35 |
-
|
36 |
-
global $wpdb;
|
37 |
-
|
38 |
-
$sql = "SELECT * FROM {$wpdb->options}";
|
39 |
-
|
40 |
-
if(!empty($search)){
|
41 |
-
|
42 |
-
$sql .= ' WHERE option_name LIKE \'%' . $search . '%\'';
|
43 |
-
|
44 |
-
}
|
45 |
-
|
46 |
-
if(empty($_REQUEST['orderby'])){
|
47 |
-
|
48 |
-
$sql .= ' ORDER BY option_id ASC';
|
49 |
-
|
50 |
-
}
|
51 |
-
|
52 |
-
else{
|
53 |
-
|
54 |
-
$sql .= ' ORDER BY ' . esc_sql($_REQUEST['orderby']);
|
55 |
-
$sql .= !empty($_REQUEST['order']) ? ' ' . esc_sql($_REQUEST['order']) : ' ASC';
|
56 |
-
|
57 |
-
}
|
58 |
-
|
59 |
-
if(empty($search)){
|
60 |
-
|
61 |
-
$sql .= " LIMIT $per_page";
|
62 |
-
$sql .= ' OFFSET ' . ($page_number - 1) * $per_page;
|
63 |
-
|
64 |
-
}
|
65 |
-
|
66 |
-
|
67 |
-
$result = $wpdb->get_results($sql, 'ARRAY_A');
|
68 |
-
|
69 |
-
return $result;
|
70 |
-
|
71 |
-
}
|
72 |
-
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Returns the count of records in the database.
|
76 |
-
*
|
77 |
-
* @return null|string
|
78 |
-
*/
|
79 |
-
public static function record_count($search = ''){
|
80 |
-
|
81 |
-
global $wpdb;
|
82 |
-
|
83 |
-
$sql = "SELECT COUNT(*) FROM {$wpdb->options}";
|
84 |
-
|
85 |
-
if(!empty($search)){
|
86 |
-
|
87 |
-
$sql .= ' WHERE option_name LIKE \'%' . $search . '%\'';
|
88 |
-
|
89 |
-
}
|
90 |
-
|
91 |
-
return $wpdb->get_var($sql);
|
92 |
-
|
93 |
-
}
|
94 |
-
|
95 |
-
|
96 |
-
/** Text displayed when no data is available */
|
97 |
-
public function no_items(){
|
98 |
-
|
99 |
-
_e('No options avaliable.', 'acfe');
|
100 |
-
|
101 |
-
}
|
102 |
-
|
103 |
-
|
104 |
-
/**
|
105 |
-
* Render a column when no column specific method exist.
|
106 |
-
*
|
107 |
-
* @param array $item
|
108 |
-
* @param string $column_name
|
109 |
-
*
|
110 |
-
* @return mixed
|
111 |
-
*/
|
112 |
-
public function column_default($item, $column_name){
|
113 |
-
|
114 |
-
if($column_name === 'option_id'){
|
115 |
-
|
116 |
-
return $item['option_id'];
|
117 |
-
|
118 |
-
}
|
119 |
-
|
120 |
-
elseif($column_name === 'option_value'){
|
121 |
-
|
122 |
-
if(is_serialized($item['option_value']) || $item['option_value'] != strip_tags($item['option_value'])){
|
123 |
-
|
124 |
-
return '<pre style="max-height:200px; overflow:auto; white-space: pre;">' . print_r(maybe_unserialize($item['option_value']), true) . '</pre>';
|
125 |
-
|
126 |
-
}elseif(acfe_is_json($item['option_value'])){
|
127 |
-
|
128 |
-
return '<pre style="max-height:200px; overflow:auto; white-space: pre;">' . print_r(json_decode($item['option_value']), true) . '</pre>';
|
129 |
-
|
130 |
-
}
|
131 |
-
|
132 |
-
|
133 |
-
return $item['option_value'];
|
134 |
-
|
135 |
-
}
|
136 |
-
|
137 |
-
elseif($column_name === 'autoload'){
|
138 |
-
|
139 |
-
return $item['autoload'];
|
140 |
-
|
141 |
-
}else{
|
142 |
-
|
143 |
-
return print_r($item, true);
|
144 |
-
|
145 |
-
}
|
146 |
-
|
147 |
-
}
|
148 |
-
|
149 |
-
/**
|
150 |
-
* Render the bulk edit checkbox
|
151 |
-
*
|
152 |
-
* @param array $item
|
153 |
-
*
|
154 |
-
* @return string
|
155 |
-
*/
|
156 |
-
public function column_cb($item){
|
157 |
-
|
158 |
-
return sprintf(
|
159 |
-
'<input type="checkbox" name="bulk-delete[]" value="%s" />', $item['option_id']
|
160 |
-
);
|
161 |
-
|
162 |
-
}
|
163 |
-
|
164 |
-
|
165 |
-
/**
|
166 |
-
* Method for name column
|
167 |
-
*
|
168 |
-
* @param array $item an array of DB data
|
169 |
-
*
|
170 |
-
* @return string
|
171 |
-
*/
|
172 |
-
public function column_option_name($item){
|
173 |
-
|
174 |
-
$delete_nonce = wp_create_nonce('acfe_options_delete_option');
|
175 |
-
|
176 |
-
$title = '<strong>' . $item['option_name'] . '</strong>';
|
177 |
-
|
178 |
-
$actions = array(
|
179 |
-
'edit' => sprintf('<a href="?page=%s&action=edit&option=%s">' . __('Edit') . '</a>', esc_attr($_REQUEST['page']), absint($item['option_id'])),
|
180 |
-
'delete' => sprintf('<a href="?page=%s&action=delete&option=%s&_wpnonce=%s">' . __('Delete') . '</a>', esc_attr($_REQUEST['page']), absint($item['option_id']), $delete_nonce),
|
181 |
-
);
|
182 |
-
|
183 |
-
return $title . $this->row_actions($actions);
|
184 |
-
|
185 |
-
}
|
186 |
-
|
187 |
-
|
188 |
-
/**
|
189 |
-
* Associative array of columns
|
190 |
-
*
|
191 |
-
* @return array
|
192 |
-
*/
|
193 |
-
public function get_columns(){
|
194 |
-
|
195 |
-
$columns = array(
|
196 |
-
'cb' => '<input type="checkbox" />',
|
197 |
-
'option_id' => __('ID', 'acfe'),
|
198 |
-
'option_name' => __('Name', 'acfe'),
|
199 |
-
'option_value' => __('Value', 'acfe'),
|
200 |
-
'autoload' => __('Autoload', 'acfe'),
|
201 |
-
);
|
202 |
-
|
203 |
-
return $columns;
|
204 |
-
|
205 |
-
}
|
206 |
-
|
207 |
-
|
208 |
-
/**
|
209 |
-
* Columns to make sortable.
|
210 |
-
*
|
211 |
-
* @return array
|
212 |
-
*/
|
213 |
-
public function get_sortable_columns(){
|
214 |
-
|
215 |
-
$sortable_columns = array(
|
216 |
-
'option_id' => array('option_id', true),
|
217 |
-
'option_name' => array('option_name', true),
|
218 |
-
'option_value' => array('option_value', true),
|
219 |
-
'autoload' => array('autoload', true),
|
220 |
-
);
|
221 |
-
|
222 |
-
return $sortable_columns;
|
223 |
-
|
224 |
-
}
|
225 |
-
|
226 |
-
/**
|
227 |
-
* Returns an associative array containing the bulk action
|
228 |
-
*
|
229 |
-
* @return array
|
230 |
-
*/
|
231 |
-
public function get_bulk_actions(){
|
232 |
-
|
233 |
-
$actions = array(
|
234 |
-
'bulk-delete' => __('Delete')
|
235 |
-
);
|
236 |
-
|
237 |
-
return $actions;
|
238 |
-
|
239 |
-
}
|
240 |
-
|
241 |
-
|
242 |
-
/**
|
243 |
-
* Handles data query and filter, sorting, and pagination.
|
244 |
-
*/
|
245 |
-
public function prepare_items(){
|
246 |
-
|
247 |
-
// Get columns
|
248 |
-
$this->_column_headers = array($this->get_columns(), array(), $this->get_sortable_columns());
|
249 |
-
|
250 |
-
// Vars
|
251 |
-
$per_page = $this->get_items_per_page('options_per_page', 100);
|
252 |
-
$current_page = $this->get_pagenum();
|
253 |
-
|
254 |
-
// Search
|
255 |
-
$search = (isset( $_REQUEST['s'])) ? $_REQUEST['s'] : false;
|
256 |
-
|
257 |
-
// Get items
|
258 |
-
$this->items = self::get_options($per_page, $current_page, $search);
|
259 |
-
/*
|
260 |
-
foreach($this->items as &$item){
|
261 |
-
$item = json_encode($item);
|
262 |
-
}*/
|
263 |
-
|
264 |
-
// Get total
|
265 |
-
$total_items = self::record_count($search);
|
266 |
-
|
267 |
-
if(!empty($search))
|
268 |
-
$per_page = $total_items;
|
269 |
-
|
270 |
-
$this->set_pagination_args(array(
|
271 |
-
'total_items' => $total_items,
|
272 |
-
'per_page' => $per_page
|
273 |
-
));
|
274 |
-
|
275 |
-
}
|
276 |
-
|
277 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
if(!class_exists('WP_List_Table'))
|
7 |
+
require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
|
8 |
+
|
9 |
+
class ACFE_Admin_Options_List extends WP_List_Table{
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Constructor
|
13 |
+
*
|
14 |
+
*/
|
15 |
+
public function __construct(){
|
16 |
+
|
17 |
+
parent::__construct(array(
|
18 |
+
'singular' => __('Option', 'acfe'),
|
19 |
+
'plural' => __('Options', 'acfe'),
|
20 |
+
'ajax' => false
|
21 |
+
));
|
22 |
+
|
23 |
+
}
|
24 |
+
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Retrieve data from the database
|
28 |
+
*
|
29 |
+
* @param int $per_page
|
30 |
+
* @param int $page_number
|
31 |
+
*
|
32 |
+
* @return mixed
|
33 |
+
*/
|
34 |
+
public static function get_options($per_page = 100, $page_number = 1, $search = ''){
|
35 |
+
|
36 |
+
global $wpdb;
|
37 |
+
|
38 |
+
$sql = "SELECT * FROM {$wpdb->options}";
|
39 |
+
|
40 |
+
if(!empty($search)){
|
41 |
+
|
42 |
+
$sql .= ' WHERE option_name LIKE \'%' . $search . '%\'';
|
43 |
+
|
44 |
+
}
|
45 |
+
|
46 |
+
if(empty($_REQUEST['orderby'])){
|
47 |
+
|
48 |
+
$sql .= ' ORDER BY option_id ASC';
|
49 |
+
|
50 |
+
}
|
51 |
+
|
52 |
+
else{
|
53 |
+
|
54 |
+
$sql .= ' ORDER BY ' . esc_sql($_REQUEST['orderby']);
|
55 |
+
$sql .= !empty($_REQUEST['order']) ? ' ' . esc_sql($_REQUEST['order']) : ' ASC';
|
56 |
+
|
57 |
+
}
|
58 |
+
|
59 |
+
if(empty($search)){
|
60 |
+
|
61 |
+
$sql .= " LIMIT $per_page";
|
62 |
+
$sql .= ' OFFSET ' . ($page_number - 1) * $per_page;
|
63 |
+
|
64 |
+
}
|
65 |
+
|
66 |
+
|
67 |
+
$result = $wpdb->get_results($sql, 'ARRAY_A');
|
68 |
+
|
69 |
+
return $result;
|
70 |
+
|
71 |
+
}
|
72 |
+
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Returns the count of records in the database.
|
76 |
+
*
|
77 |
+
* @return null|string
|
78 |
+
*/
|
79 |
+
public static function record_count($search = ''){
|
80 |
+
|
81 |
+
global $wpdb;
|
82 |
+
|
83 |
+
$sql = "SELECT COUNT(*) FROM {$wpdb->options}";
|
84 |
+
|
85 |
+
if(!empty($search)){
|
86 |
+
|
87 |
+
$sql .= ' WHERE option_name LIKE \'%' . $search . '%\'';
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
return $wpdb->get_var($sql);
|
92 |
+
|
93 |
+
}
|
94 |
+
|
95 |
+
|
96 |
+
/** Text displayed when no data is available */
|
97 |
+
public function no_items(){
|
98 |
+
|
99 |
+
_e('No options avaliable.', 'acfe');
|
100 |
+
|
101 |
+
}
|
102 |
+
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Render a column when no column specific method exist.
|
106 |
+
*
|
107 |
+
* @param array $item
|
108 |
+
* @param string $column_name
|
109 |
+
*
|
110 |
+
* @return mixed
|
111 |
+
*/
|
112 |
+
public function column_default($item, $column_name){
|
113 |
+
|
114 |
+
if($column_name === 'option_id'){
|
115 |
+
|
116 |
+
return $item['option_id'];
|
117 |
+
|
118 |
+
}
|
119 |
+
|
120 |
+
elseif($column_name === 'option_value'){
|
121 |
+
|
122 |
+
if(is_serialized($item['option_value']) || $item['option_value'] != strip_tags($item['option_value'])){
|
123 |
+
|
124 |
+
return '<pre style="max-height:200px; overflow:auto; white-space: pre;">' . print_r(maybe_unserialize($item['option_value']), true) . '</pre>';
|
125 |
+
|
126 |
+
}elseif(acfe_is_json($item['option_value'])){
|
127 |
+
|
128 |
+
return '<pre style="max-height:200px; overflow:auto; white-space: pre;">' . print_r(json_decode($item['option_value']), true) . '</pre>';
|
129 |
+
|
130 |
+
}
|
131 |
+
|
132 |
+
|
133 |
+
return $item['option_value'];
|
134 |
+
|
135 |
+
}
|
136 |
+
|
137 |
+
elseif($column_name === 'autoload'){
|
138 |
+
|
139 |
+
return $item['autoload'];
|
140 |
+
|
141 |
+
}else{
|
142 |
+
|
143 |
+
return print_r($item, true);
|
144 |
+
|
145 |
+
}
|
146 |
+
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Render the bulk edit checkbox
|
151 |
+
*
|
152 |
+
* @param array $item
|
153 |
+
*
|
154 |
+
* @return string
|
155 |
+
*/
|
156 |
+
public function column_cb($item){
|
157 |
+
|
158 |
+
return sprintf(
|
159 |
+
'<input type="checkbox" name="bulk-delete[]" value="%s" />', $item['option_id']
|
160 |
+
);
|
161 |
+
|
162 |
+
}
|
163 |
+
|
164 |
+
|
165 |
+
/**
|
166 |
+
* Method for name column
|
167 |
+
*
|
168 |
+
* @param array $item an array of DB data
|
169 |
+
*
|
170 |
+
* @return string
|
171 |
+
*/
|
172 |
+
public function column_option_name($item){
|
173 |
+
|
174 |
+
$delete_nonce = wp_create_nonce('acfe_options_delete_option');
|
175 |
+
|
176 |
+
$title = '<strong>' . $item['option_name'] . '</strong>';
|
177 |
+
|
178 |
+
$actions = array(
|
179 |
+
'edit' => sprintf('<a href="?page=%s&action=edit&option=%s">' . __('Edit') . '</a>', esc_attr($_REQUEST['page']), absint($item['option_id'])),
|
180 |
+
'delete' => sprintf('<a href="?page=%s&action=delete&option=%s&_wpnonce=%s">' . __('Delete') . '</a>', esc_attr($_REQUEST['page']), absint($item['option_id']), $delete_nonce),
|
181 |
+
);
|
182 |
+
|
183 |
+
return $title . $this->row_actions($actions);
|
184 |
+
|
185 |
+
}
|
186 |
+
|
187 |
+
|
188 |
+
/**
|
189 |
+
* Associative array of columns
|
190 |
+
*
|
191 |
+
* @return array
|
192 |
+
*/
|
193 |
+
public function get_columns(){
|
194 |
+
|
195 |
+
$columns = array(
|
196 |
+
'cb' => '<input type="checkbox" />',
|
197 |
+
'option_id' => __('ID', 'acfe'),
|
198 |
+
'option_name' => __('Name', 'acfe'),
|
199 |
+
'option_value' => __('Value', 'acfe'),
|
200 |
+
'autoload' => __('Autoload', 'acfe'),
|
201 |
+
);
|
202 |
+
|
203 |
+
return $columns;
|
204 |
+
|
205 |
+
}
|
206 |
+
|
207 |
+
|
208 |
+
/**
|
209 |
+
* Columns to make sortable.
|
210 |
+
*
|
211 |
+
* @return array
|
212 |
+
*/
|
213 |
+
public function get_sortable_columns(){
|
214 |
+
|
215 |
+
$sortable_columns = array(
|
216 |
+
'option_id' => array('option_id', true),
|
217 |
+
'option_name' => array('option_name', true),
|
218 |
+
'option_value' => array('option_value', true),
|
219 |
+
'autoload' => array('autoload', true),
|
220 |
+
);
|
221 |
+
|
222 |
+
return $sortable_columns;
|
223 |
+
|
224 |
+
}
|
225 |
+
|
226 |
+
/**
|
227 |
+
* Returns an associative array containing the bulk action
|
228 |
+
*
|
229 |
+
* @return array
|
230 |
+
*/
|
231 |
+
public function get_bulk_actions(){
|
232 |
+
|
233 |
+
$actions = array(
|
234 |
+
'bulk-delete' => __('Delete')
|
235 |
+
);
|
236 |
+
|
237 |
+
return $actions;
|
238 |
+
|
239 |
+
}
|
240 |
+
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Handles data query and filter, sorting, and pagination.
|
244 |
+
*/
|
245 |
+
public function prepare_items(){
|
246 |
+
|
247 |
+
// Get columns
|
248 |
+
$this->_column_headers = array($this->get_columns(), array(), $this->get_sortable_columns());
|
249 |
+
|
250 |
+
// Vars
|
251 |
+
$per_page = $this->get_items_per_page('options_per_page', 100);
|
252 |
+
$current_page = $this->get_pagenum();
|
253 |
+
|
254 |
+
// Search
|
255 |
+
$search = (isset( $_REQUEST['s'])) ? $_REQUEST['s'] : false;
|
256 |
+
|
257 |
+
// Get items
|
258 |
+
$this->items = self::get_options($per_page, $current_page, $search);
|
259 |
+
/*
|
260 |
+
foreach($this->items as &$item){
|
261 |
+
$item = json_encode($item);
|
262 |
+
}*/
|
263 |
+
|
264 |
+
// Get total
|
265 |
+
$total_items = self::record_count($search);
|
266 |
+
|
267 |
+
if(!empty($search))
|
268 |
+
$per_page = $total_items;
|
269 |
+
|
270 |
+
$this->set_pagination_args(array(
|
271 |
+
'total_items' => $total_items,
|
272 |
+
'per_page' => $per_page
|
273 |
+
));
|
274 |
+
|
275 |
+
}
|
276 |
+
|
277 |
}
|
@@ -1,579 +1,579 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
// Check setting
|
7 |
-
if(!acf_get_setting('acfe/modules/options'))
|
8 |
-
return;
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Options WP List Table
|
12 |
-
*
|
13 |
-
*/
|
14 |
-
require_once(ACFE_PATH . 'includes/admin/options.class.php');
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Options Menu
|
18 |
-
*
|
19 |
-
*/
|
20 |
-
add_action('admin_menu', 'acfe_options_menu');
|
21 |
-
function acfe_options_menu(){
|
22 |
-
|
23 |
-
$hook = add_submenu_page(
|
24 |
-
'options-general.php',
|
25 |
-
__('Options'),
|
26 |
-
__('Options'),
|
27 |
-
acf_get_setting('capability'),
|
28 |
-
'acfe-options'
|
29 |
-
);
|
30 |
-
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Options Screen
|
35 |
-
*
|
36 |
-
*/
|
37 |
-
add_filter('set-screen-option', 'acfe_options_screen', 10, 3);
|
38 |
-
function acfe_options_screen($status, $option, $value){
|
39 |
-
|
40 |
-
return $value;
|
41 |
-
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Options Enqueue
|
46 |
-
*
|
47 |
-
*/
|
48 |
-
add_action('admin_print_scripts-settings_page_acfe-options', 'acfe_options_enqueue');
|
49 |
-
function acfe_options_enqueue(){
|
50 |
-
|
51 |
-
wp_enqueue_style('acf-input');
|
52 |
-
wp_enqueue_script('acf-input');
|
53 |
-
wp_enqueue_style('acf-extended', plugins_url('assets/acf-extended.css', ACFE_FILE), false, null);
|
54 |
-
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Options Load
|
59 |
-
*
|
60 |
-
*/
|
61 |
-
add_action('load-settings_page_acfe-options', 'acfe_options_load');
|
62 |
-
function acfe_options_load(){
|
63 |
-
|
64 |
-
// Messages
|
65 |
-
if(isset($_REQUEST['message']) && !empty($_REQUEST['message']))
|
66 |
-
do_action('acfe/options/load/message=' . $_REQUEST['message']);
|
67 |
-
|
68 |
-
// Default Action
|
69 |
-
$action = 'list';
|
70 |
-
|
71 |
-
// Request Action
|
72 |
-
if(isset($_REQUEST['action']) && !empty($_REQUEST['action']) && $_REQUEST['action'] != '-1')
|
73 |
-
$action = $_REQUEST['action'];
|
74 |
-
|
75 |
-
// Request Action2
|
76 |
-
elseif(isset($_REQUEST['action2']) && !empty($_REQUEST['action2']) && $_REQUEST['action2'] != '-1')
|
77 |
-
$action = $_REQUEST['action2'];
|
78 |
-
|
79 |
-
// Do Action: Specific
|
80 |
-
do_action('acfe/options/load/action=' . $action, $action);
|
81 |
-
|
82 |
-
// Do Action
|
83 |
-
do_action('acfe/options/load', $action);
|
84 |
-
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Options HTML
|
89 |
-
*
|
90 |
-
*/
|
91 |
-
add_action('settings_page_acfe-options', 'acfe_options_html');
|
92 |
-
function acfe_options_html(){
|
93 |
-
|
94 |
-
// Default Action
|
95 |
-
$action = 'list';
|
96 |
-
|
97 |
-
// Request Action
|
98 |
-
if(isset($_REQUEST['action']) && !empty($_REQUEST['action']) && $_REQUEST['action'] != '-1')
|
99 |
-
$action = $_REQUEST['action'];
|
100 |
-
|
101 |
-
// Do Action: Specific
|
102 |
-
do_action('acfe/options/html/action=' . $action, $action);
|
103 |
-
|
104 |
-
// Do Action
|
105 |
-
do_action('acfe/options/html', $action);
|
106 |
-
|
107 |
-
}
|
108 |
-
|
109 |
-
/**
|
110 |
-
* Options List: Load
|
111 |
-
*
|
112 |
-
*/
|
113 |
-
add_action('acfe/options/load/action=list', 'acfe_options_load_list');
|
114 |
-
function acfe_options_load_list(){
|
115 |
-
|
116 |
-
add_screen_option('per_page', array(
|
117 |
-
'label' => 'Options',
|
118 |
-
'default' => 100,
|
119 |
-
'option' => 'options_per_page'
|
120 |
-
));
|
121 |
-
|
122 |
-
}
|
123 |
-
|
124 |
-
/**
|
125 |
-
* Options List: HTML
|
126 |
-
*
|
127 |
-
*/
|
128 |
-
add_filter('acfe/options/html/action=list', 'acfe_options_html_list');
|
129 |
-
function acfe_options_html_list(){
|
130 |
-
|
131 |
-
acf_get_view(ACFE_PATH . '/includes/admin/views/html-options-list.php');
|
132 |
-
|
133 |
-
}
|
134 |
-
|
135 |
-
/**
|
136 |
-
* Options Delete: Load
|
137 |
-
*
|
138 |
-
*/
|
139 |
-
add_action('acfe/options/load/action=delete', 'acfe_options_load_delete');
|
140 |
-
function acfe_options_load_delete(){
|
141 |
-
|
142 |
-
$nonce = esc_attr($_REQUEST['_wpnonce']);
|
143 |
-
|
144 |
-
if(!wp_verify_nonce($nonce, 'acfe_options_delete_option'))
|
145 |
-
wp_die('Cheatin’, huh?');
|
146 |
-
|
147 |
-
acfe_options_delete_option(absint($_GET['option']));
|
148 |
-
|
149 |
-
wp_redirect(sprintf('?page=%s&message=deleted', esc_attr($_REQUEST['page'])));
|
150 |
-
exit;
|
151 |
-
|
152 |
-
}
|
153 |
-
|
154 |
-
/**
|
155 |
-
* Options Delete: Message
|
156 |
-
*
|
157 |
-
*/
|
158 |
-
add_action('acfe/options/load/message=deleted', 'acfe_options_load_delete_message');
|
159 |
-
function acfe_options_load_delete_message(){
|
160 |
-
|
161 |
-
acf_add_admin_notice(__('Option has been deleted'), 'success');
|
162 |
-
|
163 |
-
}
|
164 |
-
|
165 |
-
/**
|
166 |
-
* Options Bulk Delete: Load
|
167 |
-
*
|
168 |
-
*/
|
169 |
-
add_action('acfe/options/load/action=bulk-delete', 'acfe_options_load_bulk_delete');
|
170 |
-
function acfe_options_load_bulk_delete(){
|
171 |
-
|
172 |
-
$nonce = esc_attr($_REQUEST['_wpnonce']);
|
173 |
-
|
174 |
-
if(!wp_verify_nonce($nonce, 'bulk-options'))
|
175 |
-
wp_die('Cheatin’, huh?');
|
176 |
-
|
177 |
-
$delete_ids = esc_sql($_REQUEST['bulk-delete']);
|
178 |
-
|
179 |
-
foreach($delete_ids as $id){
|
180 |
-
|
181 |
-
acfe_options_delete_option($id);
|
182 |
-
|
183 |
-
}
|
184 |
-
|
185 |
-
wp_redirect(sprintf('?page=%s&message=bulk-deleted', esc_attr($_REQUEST['page'])));
|
186 |
-
exit;
|
187 |
-
|
188 |
-
}
|
189 |
-
|
190 |
-
/**
|
191 |
-
* Options Bulk Delete: Message
|
192 |
-
*
|
193 |
-
*/
|
194 |
-
add_action('acfe/options/load/message=bulk-deleted', 'acfe_options_load_bulk_delete_message');
|
195 |
-
function acfe_options_load_bulk_delete_message(){
|
196 |
-
|
197 |
-
acf_add_admin_notice(__('Options have been deleted'), 'success');
|
198 |
-
|
199 |
-
}
|
200 |
-
|
201 |
-
/**
|
202 |
-
* Options Delete: Function
|
203 |
-
*
|
204 |
-
*/
|
205 |
-
function acfe_options_delete_option($id){
|
206 |
-
|
207 |
-
global $wpdb;
|
208 |
-
|
209 |
-
$wpdb->delete(
|
210 |
-
"{$wpdb->options}",
|
211 |
-
array('option_id' => $id),
|
212 |
-
array('%d')
|
213 |
-
);
|
214 |
-
|
215 |
-
}
|
216 |
-
|
217 |
-
/**
|
218 |
-
* Options Edit: Load
|
219 |
-
*
|
220 |
-
*/
|
221 |
-
add_action('acfe/options/load/action=edit', 'acfe_options_load_edit');
|
222 |
-
add_action('acfe/options/load/action=add', 'acfe_options_load_edit');
|
223 |
-
function acfe_options_load_edit($action){
|
224 |
-
|
225 |
-
// Nonce
|
226 |
-
if(acf_verify_nonce('acfe-options-edit')){
|
227 |
-
|
228 |
-
// Save data
|
229 |
-
if(acf_validate_save_post(true)){
|
230 |
-
|
231 |
-
acf_save_post('acfe_options_edit');
|
232 |
-
|
233 |
-
$redirect = add_query_arg(array('message' => 'updated'));
|
234 |
-
|
235 |
-
if($action === 'add')
|
236 |
-
$redirect = sprintf('?page=%s&message=added', esc_attr($_REQUEST['page']));
|
237 |
-
|
238 |
-
wp_redirect($redirect);
|
239 |
-
exit;
|
240 |
-
|
241 |
-
}
|
242 |
-
|
243 |
-
}
|
244 |
-
|
245 |
-
// Load acf scripts
|
246 |
-
acf_enqueue_scripts();
|
247 |
-
|
248 |
-
// Actions
|
249 |
-
add_action('acf/input/admin_head', 'acfe_options_edit_metabox');
|
250 |
-
|
251 |
-
// Add columns support
|
252 |
-
add_screen_option('layout_columns', array(
|
253 |
-
'max' => 2,
|
254 |
-
'default' => 2
|
255 |
-
));
|
256 |
-
|
257 |
-
}
|
258 |
-
|
259 |
-
/**
|
260 |
-
* Options Edit: HTML
|
261 |
-
*
|
262 |
-
*/
|
263 |
-
add_filter('acfe/options/html/action=edit', 'acfe_options_html_edit');
|
264 |
-
add_filter('acfe/options/html/action=add', 'acfe_options_html_edit');
|
265 |
-
function acfe_options_html_edit(){
|
266 |
-
|
267 |
-
acf_get_view(ACFE_PATH . '/includes/admin/views/html-options-edit.php');
|
268 |
-
|
269 |
-
}
|
270 |
-
|
271 |
-
/**
|
272 |
-
* Options Edit: Metabox
|
273 |
-
*
|
274 |
-
*/
|
275 |
-
function acfe_options_edit_metabox(){
|
276 |
-
|
277 |
-
$option = array(
|
278 |
-
'option_id' => 0,
|
279 |
-
'option_name' => '',
|
280 |
-
'option_value' => '',
|
281 |
-
'autoload' => 'no',
|
282 |
-
);
|
283 |
-
|
284 |
-
if(isset($_REQUEST['option']) && !empty($_REQUEST['option'])){
|
285 |
-
|
286 |
-
$option_id = absint($_REQUEST['option']);
|
287 |
-
|
288 |
-
global $wpdb;
|
289 |
-
|
290 |
-
$get_option = $wpdb->get_row("SELECT * FROM {$wpdb->options} WHERE option_id = '$option_id'", 'ARRAY_A');
|
291 |
-
if(!empty($get_option))
|
292 |
-
$option = $get_option;
|
293 |
-
|
294 |
-
}
|
295 |
-
|
296 |
-
$field_group = array(
|
297 |
-
'ID' => 0,
|
298 |
-
'key' => 'group_acfe_options_edit',
|
299 |
-
'style' => 'default',
|
300 |
-
'label_placement' => 'left',
|
301 |
-
'instruction_placement' => 'label',
|
302 |
-
'fields' => array()
|
303 |
-
);
|
304 |
-
|
305 |
-
$fields = array();
|
306 |
-
|
307 |
-
$fields[] = array(
|
308 |
-
'label' => __('Name'),
|
309 |
-
'key' => 'field_acfe_options_edit_name',
|
310 |
-
'name' => 'field_acfe_options_edit_name',
|
311 |
-
'type' => 'text',
|
312 |
-
'prefix' => 'acf',
|
313 |
-
'instructions' => '',
|
314 |
-
'required' => true,
|
315 |
-
'conditional_logic' => false,
|
316 |
-
'default_value' => '',
|
317 |
-
'placeholder' => '',
|
318 |
-
'prepend' => '',
|
319 |
-
'append' => '',
|
320 |
-
'maxlength' => '',
|
321 |
-
'value' => $option['option_name'],
|
322 |
-
'wrapper' => array(
|
323 |
-
'width' => '',
|
324 |
-
'class' => '',
|
325 |
-
'id' => '',
|
326 |
-
),
|
327 |
-
);
|
328 |
-
|
329 |
-
// Serialized || HTML
|
330 |
-
if(is_serialized($option['option_value']) || $option['option_value'] != strip_tags($option['option_value'])){
|
331 |
-
|
332 |
-
$type = 'serialized';
|
333 |
-
$instructions = 'Use this <a href="https://duzun.me/playground/serialize" target="_blank">online tool</a> to unserialize/seriliaze data.';
|
334 |
-
|
335 |
-
if($option['option_value'] != strip_tags($option['option_value'])){
|
336 |
-
|
337 |
-
$type = 'HTML';
|
338 |
-
$instructions = '';
|
339 |
-
|
340 |
-
}
|
341 |
-
|
342 |
-
$fields[] = array(
|
343 |
-
'label' => __('Value <code style="font-size:11px;float:right; line-height:1.2; margin-top:1px;">' . $type . '</code>'),
|
344 |
-
'key' => 'field_acfe_options_edit_value',
|
345 |
-
'name' => 'field_acfe_options_edit_value',
|
346 |
-
'type' => 'textarea',
|
347 |
-
'prefix' => 'acf',
|
348 |
-
'instructions' => $instructions,
|
349 |
-
'required' => false,
|
350 |
-
'conditional_logic' => false,
|
351 |
-
'default_value' => '',
|
352 |
-
'placeholder' => '',
|
353 |
-
'prepend' => '',
|
354 |
-
'append' => '',
|
355 |
-
'maxlength' => '',
|
356 |
-
'value' => $option['option_value'],
|
357 |
-
'class' => 'code',
|
358 |
-
'wrapper' => array(
|
359 |
-
'width' => '',
|
360 |
-
'class' => '',
|
361 |
-
'id' => '',
|
362 |
-
),
|
363 |
-
);
|
364 |
-
|
365 |
-
}
|
366 |
-
|
367 |
-
// Serialized || HTML
|
368 |
-
elseif(acfe_is_json($option['option_value'])){
|
369 |
-
|
370 |
-
$type = 'json';
|
371 |
-
$instructions = 'Use this <a href="http://solutions.weblite.ca/php2json/" target="_blank">online tool</a> to decode/encode json.';
|
372 |
-
|
373 |
-
$fields[] = array(
|
374 |
-
'label' => __('Value <code style="font-size:11px;float:right; line-height:1.2; margin-top:1px;">' . $type . '</code>'),
|
375 |
-
'key' => 'field_acfe_options_edit_value',
|
376 |
-
'name' => 'field_acfe_options_edit_value',
|
377 |
-
'type' => 'textarea',
|
378 |
-
'prefix' => 'acf',
|
379 |
-
'instructions' => $instructions,
|
380 |
-
'required' => false,
|
381 |
-
'conditional_logic' => false,
|
382 |
-
'default_value' => '',
|
383 |
-
'placeholder' => '',
|
384 |
-
'prepend' => '',
|
385 |
-
'append' => '',
|
386 |
-
'maxlength' => '',
|
387 |
-
'value' => $option['option_value'],
|
388 |
-
'class' => 'code',
|
389 |
-
'wrapper' => array(
|
390 |
-
'width' => '',
|
391 |
-
'class' => '',
|
392 |
-
'id' => '',
|
393 |
-
),
|
394 |
-
);
|
395 |
-
|
396 |
-
}
|
397 |
-
|
398 |
-
// String
|
399 |
-
else{
|
400 |
-
|
401 |
-
$type = '';
|
402 |
-
if(!empty($option['option_value']))
|
403 |
-
$type = '<code style="font-size:11px;float:right; line-height:1.2; margin-top:1px;">string</code>';
|
404 |
-
|
405 |
-
$fields[] = array(
|
406 |
-
'label' => __('Value ' . $type),
|
407 |
-
'key' => 'field_acfe_options_edit_value',
|
408 |
-
'name' => 'field_acfe_options_edit_value',
|
409 |
-
'type' => 'textarea',
|
410 |
-
'prefix' => 'acf',
|
411 |
-
'instructions' => '',
|
412 |
-
'required' => false,
|
413 |
-
'conditional_logic' => false,
|
414 |
-
'default_value' => '',
|
415 |
-
'placeholder' => '',
|
416 |
-
'prepend' => '',
|
417 |
-
'append' => '',
|
418 |
-
'maxlength' => '',
|
419 |
-
'value' => $option['option_value'],
|
420 |
-
'wrapper' => array(
|
421 |
-
'width' => '',
|
422 |
-
'class' => '',
|
423 |
-
'id' => '',
|
424 |
-
),
|
425 |
-
);
|
426 |
-
|
427 |
-
}
|
428 |
-
|
429 |
-
$fields[] = array(
|
430 |
-
'label' => __('Autoload'),
|
431 |
-
'key' => 'field_acfe_options_edit_autoload',
|
432 |
-
'name' => 'field_acfe_options_edit_autoload',
|
433 |
-
'type' => 'select',
|
434 |
-
'prefix' => 'acf',
|
435 |
-
'instructions' => '',
|
436 |
-
'required' => true,
|
437 |
-
'conditional_logic' => false,
|
438 |
-
'default_value' => '',
|
439 |
-
'placeholder' => '',
|
440 |
-
'prepend' => '',
|
441 |
-
'append' => '',
|
442 |
-
'maxlength' => '',
|
443 |
-
'value' => $option['autoload'],
|
444 |
-
'choices' => array(
|
445 |
-
'no' => __('No'),
|
446 |
-
'yes' => __('Yes'),
|
447 |
-
),
|
448 |
-
'wrapper' => array(
|
449 |
-
'width' => '',
|
450 |
-
'class' => '',
|
451 |
-
'id' => '',
|
452 |
-
),
|
453 |
-
);
|
454 |
-
|
455 |
-
$field_group['fields'] = $fields;
|
456 |
-
|
457 |
-
$metabox_submit_title = __('Submit','acf');
|
458 |
-
$metabox_main_title = __('Add Option');
|
459 |
-
|
460 |
-
if(!empty($option['option_id'])){
|
461 |
-
|
462 |
-
$metabox_submit_title = __('Edit','acf');
|
463 |
-
$metabox_main_title = __('Edit Option');
|
464 |
-
|
465 |
-
}
|
466 |
-
|
467 |
-
// Submit Metabox
|
468 |
-
add_meta_box('submitdiv', $metabox_submit_title, function($post, $args) use($option){
|
469 |
-
|
470 |
-
$delete_nonce = wp_create_nonce('acfe_options_delete_option');
|
471 |
-
|
472 |
-
?>
|
473 |
-
<div id="major-publishing-actions">
|
474 |
-
|
475 |
-
<?php if(!empty($option['option_id'])){ ?>
|
476 |
-
|
477 |
-
<div id="delete-action">
|
478 |
-
<a class="submitdelete deletion" style="color:#a00;" href="<?php echo sprintf('?page=%s&action=%s&option=%s&_wpnonce=%s', esc_attr($_REQUEST['page']), 'delete', $option['option_id'], $delete_nonce); ?>"><?php _e('Delete'); ?></a>
|
479 |
-
</div>
|
480 |
-
|
481 |
-
<?php } ?>
|
482 |
-
|
483 |
-
<div id="publishing-action">
|
484 |
-
<span class="spinner"></span>
|
485 |
-
<input type="submit" accesskey="p" value="<?php _e('Update'); ?>" class="button button-primary button-large" id="publish" name="publish">
|
486 |
-
</div>
|
487 |
-
|
488 |
-
<div class="clear"></div>
|
489 |
-
|
490 |
-
</div>
|
491 |
-
<?php
|
492 |
-
}, 'acf_options_page', 'side', 'high');
|
493 |
-
|
494 |
-
// Main Metabox
|
495 |
-
add_meta_box('acf-group_acfe_options_edit', $metabox_main_title, function($post, $args){
|
496 |
-
|
497 |
-
// extract args
|
498 |
-
extract($args); // all variables from the add_meta_box function
|
499 |
-
extract($args); // all variables from the args argument
|
500 |
-
|
501 |
-
// vars
|
502 |
-
$o = array(
|
503 |
-
'id' => $id,
|
504 |
-
'key' => $field_group['key'],
|
505 |
-
'style' => $field_group['style'],
|
506 |
-
'label' => $field_group['label_placement'],
|
507 |
-
'editLink' => '',
|
508 |
-
'editTitle' => __('Edit field group', 'acf'),
|
509 |
-
'visibility' => true
|
510 |
-
);
|
511 |
-
|
512 |
-
// load fields
|
513 |
-
$fields = $field_group['fields'];
|
514 |
-
|
515 |
-
// render
|
516 |
-
acf_render_fields($fields, 'acfe-options-edit', 'div', $field_group['instruction_placement']);
|
517 |
-
|
518 |
-
?>
|
519 |
-
<script type="text/javascript">
|
520 |
-
if(typeof acf !== 'undefined'){
|
521 |
-
|
522 |
-
acf.newPostbox(<?php echo json_encode($o); ?>);
|
523 |
-
|
524 |
-
}
|
525 |
-
</script>
|
526 |
-
<?php
|
527 |
-
|
528 |
-
}, 'acf_options_page', 'normal', 'high', array('field_group' => $field_group));
|
529 |
-
|
530 |
-
}
|
531 |
-
|
532 |
-
/**
|
533 |
-
* Options Edit: Save
|
534 |
-
*
|
535 |
-
*/
|
536 |
-
add_action('acf/save_post', 'acfe_options_edit_save_post', 5);
|
537 |
-
function acfe_options_edit_save_post($post_id){
|
538 |
-
|
539 |
-
// Validate
|
540 |
-
if($post_id !== 'acfe_options_edit')
|
541 |
-
return;
|
542 |
-
|
543 |
-
// Vars
|
544 |
-
$option_name = wp_unslash($_POST['acf']['field_acfe_options_edit_name']);
|
545 |
-
$option_value = wp_unslash($_POST['acf']['field_acfe_options_edit_value']);
|
546 |
-
$autoload = $_POST['acf']['field_acfe_options_edit_autoload'];
|
547 |
-
|
548 |
-
// Value serialized?
|
549 |
-
$option_value = maybe_unserialize($option_value);
|
550 |
-
|
551 |
-
// Update
|
552 |
-
update_option($option_name, $option_value, $autoload);
|
553 |
-
|
554 |
-
// Flush ACF
|
555 |
-
$_POST['acf'] = array();
|
556 |
-
|
557 |
-
}
|
558 |
-
|
559 |
-
/**
|
560 |
-
* Options Edit: Message
|
561 |
-
*
|
562 |
-
*/
|
563 |
-
add_action('acfe/options/load/message=updated', 'acfe_options_load_edit_message');
|
564 |
-
function acfe_options_load_edit_message(){
|
565 |
-
|
566 |
-
acf_add_admin_notice(__('Option has been updated'), 'success');
|
567 |
-
|
568 |
-
}
|
569 |
-
|
570 |
-
/**
|
571 |
-
* Options Add: Message
|
572 |
-
*
|
573 |
-
*/
|
574 |
-
add_action('acfe/options/load/message=added', 'acfe_options_load_add_message');
|
575 |
-
function acfe_options_load_add_message(){
|
576 |
-
|
577 |
-
acf_add_admin_notice(__('Option has been added'), 'success');
|
578 |
-
|
579 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
// Check setting
|
7 |
+
if(!acf_get_setting('acfe/modules/options'))
|
8 |
+
return;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Options WP List Table
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
require_once(ACFE_PATH . 'includes/admin/options.class.php');
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Options Menu
|
18 |
+
*
|
19 |
+
*/
|
20 |
+
add_action('admin_menu', 'acfe_options_menu');
|
21 |
+
function acfe_options_menu(){
|
22 |
+
|
23 |
+
$hook = add_submenu_page(
|
24 |
+
'options-general.php',
|
25 |
+
__('Options'),
|
26 |
+
__('Options'),
|
27 |
+
acf_get_setting('capability'),
|
28 |
+
'acfe-options'
|
29 |
+
);
|
30 |
+
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Options Screen
|
35 |
+
*
|
36 |
+
*/
|
37 |
+
add_filter('set-screen-option', 'acfe_options_screen', 10, 3);
|
38 |
+
function acfe_options_screen($status, $option, $value){
|
39 |
+
|
40 |
+
return $value;
|
41 |
+
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Options Enqueue
|
46 |
+
*
|
47 |
+
*/
|
48 |
+
add_action('admin_print_scripts-settings_page_acfe-options', 'acfe_options_enqueue');
|
49 |
+
function acfe_options_enqueue(){
|
50 |
+
|
51 |
+
wp_enqueue_style('acf-input');
|
52 |
+
wp_enqueue_script('acf-input');
|
53 |
+
wp_enqueue_style('acf-extended', plugins_url('assets/acf-extended.css', ACFE_FILE), false, null);
|
54 |
+
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Options Load
|
59 |
+
*
|
60 |
+
*/
|
61 |
+
add_action('load-settings_page_acfe-options', 'acfe_options_load');
|
62 |
+
function acfe_options_load(){
|
63 |
+
|
64 |
+
// Messages
|
65 |
+
if(isset($_REQUEST['message']) && !empty($_REQUEST['message']))
|
66 |
+
do_action('acfe/options/load/message=' . $_REQUEST['message']);
|
67 |
+
|
68 |
+
// Default Action
|
69 |
+
$action = 'list';
|
70 |
+
|
71 |
+
// Request Action
|
72 |
+
if(isset($_REQUEST['action']) && !empty($_REQUEST['action']) && $_REQUEST['action'] != '-1')
|
73 |
+
$action = $_REQUEST['action'];
|
74 |
+
|
75 |
+
// Request Action2
|
76 |
+
elseif(isset($_REQUEST['action2']) && !empty($_REQUEST['action2']) && $_REQUEST['action2'] != '-1')
|
77 |
+
$action = $_REQUEST['action2'];
|
78 |
+
|
79 |
+
// Do Action: Specific
|
80 |
+
do_action('acfe/options/load/action=' . $action, $action);
|
81 |
+
|
82 |
+
// Do Action
|
83 |
+
do_action('acfe/options/load', $action);
|
84 |
+
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Options HTML
|
89 |
+
*
|
90 |
+
*/
|
91 |
+
add_action('settings_page_acfe-options', 'acfe_options_html');
|
92 |
+
function acfe_options_html(){
|
93 |
+
|
94 |
+
// Default Action
|
95 |
+
$action = 'list';
|
96 |
+
|
97 |
+
// Request Action
|
98 |
+
if(isset($_REQUEST['action']) && !empty($_REQUEST['action']) && $_REQUEST['action'] != '-1')
|
99 |
+
$action = $_REQUEST['action'];
|
100 |
+
|
101 |
+
// Do Action: Specific
|
102 |
+
do_action('acfe/options/html/action=' . $action, $action);
|
103 |
+
|
104 |
+
// Do Action
|
105 |
+
do_action('acfe/options/html', $action);
|
106 |
+
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Options List: Load
|
111 |
+
*
|
112 |
+
*/
|
113 |
+
add_action('acfe/options/load/action=list', 'acfe_options_load_list');
|
114 |
+
function acfe_options_load_list(){
|
115 |
+
|
116 |
+
add_screen_option('per_page', array(
|
117 |
+
'label' => 'Options',
|
118 |
+
'default' => 100,
|
119 |
+
'option' => 'options_per_page'
|
120 |
+
));
|
121 |
+
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Options List: HTML
|
126 |
+
*
|
127 |
+
*/
|
128 |
+
add_filter('acfe/options/html/action=list', 'acfe_options_html_list');
|
129 |
+
function acfe_options_html_list(){
|
130 |
+
|
131 |
+
acf_get_view(ACFE_PATH . '/includes/admin/views/html-options-list.php');
|
132 |
+
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Options Delete: Load
|
137 |
+
*
|
138 |
+
*/
|
139 |
+
add_action('acfe/options/load/action=delete', 'acfe_options_load_delete');
|
140 |
+
function acfe_options_load_delete(){
|
141 |
+
|
142 |
+
$nonce = esc_attr($_REQUEST['_wpnonce']);
|
143 |
+
|
144 |
+
if(!wp_verify_nonce($nonce, 'acfe_options_delete_option'))
|
145 |
+
wp_die('Cheatin’, huh?');
|
146 |
+
|
147 |
+
acfe_options_delete_option(absint($_GET['option']));
|
148 |
+
|
149 |
+
wp_redirect(sprintf('?page=%s&message=deleted', esc_attr($_REQUEST['page'])));
|
150 |
+
exit;
|
151 |
+
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Options Delete: Message
|
156 |
+
*
|
157 |
+
*/
|
158 |
+
add_action('acfe/options/load/message=deleted', 'acfe_options_load_delete_message');
|
159 |
+
function acfe_options_load_delete_message(){
|
160 |
+
|
161 |
+
acf_add_admin_notice(__('Option has been deleted'), 'success');
|
162 |
+
|
163 |
+
}
|
164 |
+
|
165 |
+
/**
|
166 |
+
* Options Bulk Delete: Load
|
167 |
+
*
|
168 |
+
*/
|
169 |
+
add_action('acfe/options/load/action=bulk-delete', 'acfe_options_load_bulk_delete');
|
170 |
+
function acfe_options_load_bulk_delete(){
|
171 |
+
|
172 |
+
$nonce = esc_attr($_REQUEST['_wpnonce']);
|
173 |
+
|
174 |
+
if(!wp_verify_nonce($nonce, 'bulk-options'))
|
175 |
+
wp_die('Cheatin’, huh?');
|
176 |
+
|
177 |
+
$delete_ids = esc_sql($_REQUEST['bulk-delete']);
|
178 |
+
|
179 |
+
foreach($delete_ids as $id){
|
180 |
+
|
181 |
+
acfe_options_delete_option($id);
|
182 |
+
|
183 |
+
}
|
184 |
+
|
185 |
+
wp_redirect(sprintf('?page=%s&message=bulk-deleted', esc_attr($_REQUEST['page'])));
|
186 |
+
exit;
|
187 |
+
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Options Bulk Delete: Message
|
192 |
+
*
|
193 |
+
*/
|
194 |
+
add_action('acfe/options/load/message=bulk-deleted', 'acfe_options_load_bulk_delete_message');
|
195 |
+
function acfe_options_load_bulk_delete_message(){
|
196 |
+
|
197 |
+
acf_add_admin_notice(__('Options have been deleted'), 'success');
|
198 |
+
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Options Delete: Function
|
203 |
+
*
|
204 |
+
*/
|
205 |
+
function acfe_options_delete_option($id){
|
206 |
+
|
207 |
+
global $wpdb;
|
208 |
+
|
209 |
+
$wpdb->delete(
|
210 |
+
"{$wpdb->options}",
|
211 |
+
array('option_id' => $id),
|
212 |
+
array('%d')
|
213 |
+
);
|
214 |
+
|
215 |
+
}
|
216 |
+
|
217 |
+
/**
|
218 |
+
* Options Edit: Load
|
219 |
+
*
|
220 |
+
*/
|
221 |
+
add_action('acfe/options/load/action=edit', 'acfe_options_load_edit');
|
222 |
+
add_action('acfe/options/load/action=add', 'acfe_options_load_edit');
|
223 |
+
function acfe_options_load_edit($action){
|
224 |
+
|
225 |
+
// Nonce
|
226 |
+
if(acf_verify_nonce('acfe-options-edit')){
|
227 |
+
|
228 |
+
// Save data
|
229 |
+
if(acf_validate_save_post(true)){
|
230 |
+
|
231 |
+
acf_save_post('acfe_options_edit');
|
232 |
+
|
233 |
+
$redirect = add_query_arg(array('message' => 'updated'));
|
234 |
+
|
235 |
+
if($action === 'add')
|
236 |
+
$redirect = sprintf('?page=%s&message=added', esc_attr($_REQUEST['page']));
|
237 |
+
|
238 |
+
wp_redirect($redirect);
|
239 |
+
exit;
|
240 |
+
|
241 |
+
}
|
242 |
+
|
243 |
+
}
|
244 |
+
|
245 |
+
// Load acf scripts
|
246 |
+
acf_enqueue_scripts();
|
247 |
+
|
248 |
+
// Actions
|
249 |
+
add_action('acf/input/admin_head', 'acfe_options_edit_metabox');
|
250 |
+
|
251 |
+
// Add columns support
|
252 |
+
add_screen_option('layout_columns', array(
|
253 |
+
'max' => 2,
|
254 |
+
'default' => 2
|
255 |
+
));
|
256 |
+
|
257 |
+
}
|
258 |
+
|
259 |
+
/**
|
260 |
+
* Options Edit: HTML
|
261 |
+
*
|
262 |
+
*/
|
263 |
+
add_filter('acfe/options/html/action=edit', 'acfe_options_html_edit');
|
264 |
+
add_filter('acfe/options/html/action=add', 'acfe_options_html_edit');
|
265 |
+
function acfe_options_html_edit(){
|
266 |
+
|
267 |
+
acf_get_view(ACFE_PATH . '/includes/admin/views/html-options-edit.php');
|
268 |
+
|
269 |
+
}
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Options Edit: Metabox
|
273 |
+
*
|
274 |
+
*/
|
275 |
+
function acfe_options_edit_metabox(){
|
276 |
+
|
277 |
+
$option = array(
|
278 |
+
'option_id' => 0,
|
279 |
+
'option_name' => '',
|
280 |
+
'option_value' => '',
|
281 |
+
'autoload' => 'no',
|
282 |
+
);
|
283 |
+
|
284 |
+
if(isset($_REQUEST['option']) && !empty($_REQUEST['option'])){
|
285 |
+
|
286 |
+
$option_id = absint($_REQUEST['option']);
|
287 |
+
|
288 |
+
global $wpdb;
|
289 |
+
|
290 |
+
$get_option = $wpdb->get_row("SELECT * FROM {$wpdb->options} WHERE option_id = '$option_id'", 'ARRAY_A');
|
291 |
+
if(!empty($get_option))
|
292 |
+
$option = $get_option;
|
293 |
+
|
294 |
+
}
|
295 |
+
|
296 |
+
$field_group = array(
|
297 |
+
'ID' => 0,
|
298 |
+
'key' => 'group_acfe_options_edit',
|
299 |
+
'style' => 'default',
|
300 |
+
'label_placement' => 'left',
|
301 |
+
'instruction_placement' => 'label',
|
302 |
+
'fields' => array()
|
303 |
+
);
|
304 |
+
|
305 |
+
$fields = array();
|
306 |
+
|
307 |
+
$fields[] = array(
|
308 |
+
'label' => __('Name'),
|
309 |
+
'key' => 'field_acfe_options_edit_name',
|
310 |
+
'name' => 'field_acfe_options_edit_name',
|
311 |
+
'type' => 'text',
|
312 |
+
'prefix' => 'acf',
|
313 |
+
'instructions' => '',
|
314 |
+
'required' => true,
|
315 |
+
'conditional_logic' => false,
|
316 |
+
'default_value' => '',
|
317 |
+
'placeholder' => '',
|
318 |
+
'prepend' => '',
|
319 |
+
'append' => '',
|
320 |
+
'maxlength' => '',
|
321 |
+
'value' => $option['option_name'],
|
322 |
+
'wrapper' => array(
|
323 |
+
'width' => '',
|
324 |
+
'class' => '',
|
325 |
+
'id' => '',
|
326 |
+
),
|
327 |
+
);
|
328 |
+
|
329 |
+
// Serialized || HTML
|
330 |
+
if(is_serialized($option['option_value']) || $option['option_value'] != strip_tags($option['option_value'])){
|
331 |
+
|
332 |
+
$type = 'serialized';
|
333 |
+
$instructions = 'Use this <a href="https://duzun.me/playground/serialize" target="_blank">online tool</a> to unserialize/seriliaze data.';
|
334 |
+
|
335 |
+
if($option['option_value'] != strip_tags($option['option_value'])){
|
336 |
+
|
337 |
+
$type = 'HTML';
|
338 |
+
$instructions = '';
|
339 |
+
|
340 |
+
}
|
341 |
+
|
342 |
+
$fields[] = array(
|
343 |
+
'label' => __('Value <code style="font-size:11px;float:right; line-height:1.2; margin-top:1px;">' . $type . '</code>'),
|
344 |
+
'key' => 'field_acfe_options_edit_value',
|
345 |
+
'name' => 'field_acfe_options_edit_value',
|
346 |
+
'type' => 'textarea',
|
347 |
+
'prefix' => 'acf',
|
348 |
+
'instructions' => $instructions,
|
349 |
+
'required' => false,
|
350 |
+
'conditional_logic' => false,
|
351 |
+
'default_value' => '',
|
352 |
+
'placeholder' => '',
|
353 |
+
'prepend' => '',
|
354 |
+
'append' => '',
|
355 |
+
'maxlength' => '',
|
356 |
+
'value' => $option['option_value'],
|
357 |
+
'class' => 'code',
|
358 |
+
'wrapper' => array(
|
359 |
+
'width' => '',
|
360 |
+
'class' => '',
|
361 |
+
'id' => '',
|
362 |
+
),
|
363 |
+
);
|
364 |
+
|
365 |
+
}
|
366 |
+
|
367 |
+
// Serialized || HTML
|
368 |
+
elseif(acfe_is_json($option['option_value'])){
|
369 |
+
|
370 |
+
$type = 'json';
|
371 |
+
$instructions = 'Use this <a href="http://solutions.weblite.ca/php2json/" target="_blank">online tool</a> to decode/encode json.';
|
372 |
+
|
373 |
+
$fields[] = array(
|
374 |
+
'label' => __('Value <code style="font-size:11px;float:right; line-height:1.2; margin-top:1px;">' . $type . '</code>'),
|
375 |
+
'key' => 'field_acfe_options_edit_value',
|
376 |
+
'name' => 'field_acfe_options_edit_value',
|
377 |
+
'type' => 'textarea',
|
378 |
+
'prefix' => 'acf',
|
379 |
+
'instructions' => $instructions,
|
380 |
+
'required' => false,
|
381 |
+
'conditional_logic' => false,
|
382 |
+
'default_value' => '',
|
383 |
+
'placeholder' => '',
|
384 |
+
'prepend' => '',
|
385 |
+
'append' => '',
|
386 |
+
'maxlength' => '',
|
387 |
+
'value' => $option['option_value'],
|
388 |
+
'class' => 'code',
|
389 |
+
'wrapper' => array(
|
390 |
+
'width' => '',
|
391 |
+
'class' => '',
|
392 |
+
'id' => '',
|
393 |
+
),
|
394 |
+
);
|
395 |
+
|
396 |
+
}
|
397 |
+
|
398 |
+
// String
|
399 |
+
else{
|
400 |
+
|
401 |
+
$type = '';
|
402 |
+
if(!empty($option['option_value']))
|
403 |
+
$type = '<code style="font-size:11px;float:right; line-height:1.2; margin-top:1px;">string</code>';
|
404 |
+
|
405 |
+
$fields[] = array(
|
406 |
+
'label' => __('Value ' . $type),
|
407 |
+
'key' => 'field_acfe_options_edit_value',
|
408 |
+
'name' => 'field_acfe_options_edit_value',
|
409 |
+
'type' => 'textarea',
|
410 |
+
'prefix' => 'acf',
|
411 |
+
'instructions' => '',
|
412 |
+
'required' => false,
|
413 |
+
'conditional_logic' => false,
|
414 |
+
'default_value' => '',
|
415 |
+
'placeholder' => '',
|
416 |
+
'prepend' => '',
|
417 |
+
'append' => '',
|
418 |
+
'maxlength' => '',
|
419 |
+
'value' => $option['option_value'],
|
420 |
+
'wrapper' => array(
|
421 |
+
'width' => '',
|
422 |
+
'class' => '',
|
423 |
+
'id' => '',
|
424 |
+
),
|
425 |
+
);
|
426 |
+
|
427 |
+
}
|
428 |
+
|
429 |
+
$fields[] = array(
|
430 |
+
'label' => __('Autoload'),
|
431 |
+
'key' => 'field_acfe_options_edit_autoload',
|
432 |
+
'name' => 'field_acfe_options_edit_autoload',
|
433 |
+
'type' => 'select',
|
434 |
+
'prefix' => 'acf',
|
435 |
+
'instructions' => '',
|
436 |
+
'required' => true,
|
437 |
+
'conditional_logic' => false,
|
438 |
+
'default_value' => '',
|
439 |
+
'placeholder' => '',
|
440 |
+
'prepend' => '',
|
441 |
+
'append' => '',
|
442 |
+
'maxlength' => '',
|
443 |
+
'value' => $option['autoload'],
|
444 |
+
'choices' => array(
|
445 |
+
'no' => __('No'),
|
446 |
+
'yes' => __('Yes'),
|
447 |
+
),
|
448 |
+
'wrapper' => array(
|
449 |
+
'width' => '',
|
450 |
+
'class' => '',
|
451 |
+
'id' => '',
|
452 |
+
),
|
453 |
+
);
|
454 |
+
|
455 |
+
$field_group['fields'] = $fields;
|
456 |
+
|
457 |
+
$metabox_submit_title = __('Submit','acf');
|
458 |
+
$metabox_main_title = __('Add Option');
|
459 |
+
|
460 |
+
if(!empty($option['option_id'])){
|
461 |
+
|
462 |
+
$metabox_submit_title = __('Edit','acf');
|
463 |
+
$metabox_main_title = __('Edit Option');
|
464 |
+
|
465 |
+
}
|
466 |
+
|
467 |
+
// Submit Metabox
|
468 |
+
add_meta_box('submitdiv', $metabox_submit_title, function($post, $args) use($option){
|
469 |
+
|
470 |
+
$delete_nonce = wp_create_nonce('acfe_options_delete_option');
|
471 |
+
|
472 |
+
?>
|
473 |
+
<div id="major-publishing-actions">
|
474 |
+
|
475 |
+
<?php if(!empty($option['option_id'])){ ?>
|
476 |
+
|
477 |
+
<div id="delete-action">
|
478 |
+
<a class="submitdelete deletion" style="color:#a00;" href="<?php echo sprintf('?page=%s&action=%s&option=%s&_wpnonce=%s', esc_attr($_REQUEST['page']), 'delete', $option['option_id'], $delete_nonce); ?>"><?php _e('Delete'); ?></a>
|
479 |
+
</div>
|
480 |
+
|
481 |
+
<?php } ?>
|
482 |
+
|
483 |
+
<div id="publishing-action">
|
484 |
+
<span class="spinner"></span>
|
485 |
+
<input type="submit" accesskey="p" value="<?php _e('Update'); ?>" class="button button-primary button-large" id="publish" name="publish">
|
486 |
+
</div>
|
487 |
+
|
488 |
+
<div class="clear"></div>
|
489 |
+
|
490 |
+
</div>
|
491 |
+
<?php
|
492 |
+
}, 'acf_options_page', 'side', 'high');
|
493 |
+
|
494 |
+
// Main Metabox
|
495 |
+
add_meta_box('acf-group_acfe_options_edit', $metabox_main_title, function($post, $args){
|
496 |
+
|
497 |
+
// extract args
|
498 |
+
extract($args); // all variables from the add_meta_box function
|
499 |
+
extract($args); // all variables from the args argument
|
500 |
+
|
501 |
+
// vars
|
502 |
+
$o = array(
|
503 |
+
'id' => $id,
|
504 |
+
'key' => $field_group['key'],
|
505 |
+
'style' => $field_group['style'],
|
506 |
+
'label' => $field_group['label_placement'],
|
507 |
+
'editLink' => '',
|
508 |
+
'editTitle' => __('Edit field group', 'acf'),
|
509 |
+
'visibility' => true
|
510 |
+
);
|
511 |
+
|
512 |
+
// load fields
|
513 |
+
$fields = $field_group['fields'];
|
514 |
+
|
515 |
+
// render
|
516 |
+
acf_render_fields($fields, 'acfe-options-edit', 'div', $field_group['instruction_placement']);
|
517 |
+
|
518 |
+
?>
|
519 |
+
<script type="text/javascript">
|
520 |
+
if(typeof acf !== 'undefined'){
|
521 |
+
|
522 |
+
acf.newPostbox(<?php echo json_encode($o); ?>);
|
523 |
+
|
524 |
+
}
|
525 |
+
</script>
|
526 |
+
<?php
|
527 |
+
|
528 |
+
}, 'acf_options_page', 'normal', 'high', array('field_group' => $field_group));
|
529 |
+
|
530 |
+
}
|
531 |
+
|
532 |
+
/**
|
533 |
+
* Options Edit: Save
|
534 |
+
*
|
535 |
+
*/
|
536 |
+
add_action('acf/save_post', 'acfe_options_edit_save_post', 5);
|
537 |
+
function acfe_options_edit_save_post($post_id){
|
538 |
+
|
539 |
+
// Validate
|
540 |
+
if($post_id !== 'acfe_options_edit')
|
541 |
+
return;
|
542 |
+
|
543 |
+
// Vars
|
544 |
+
$option_name = wp_unslash($_POST['acf']['field_acfe_options_edit_name']);
|
545 |
+
$option_value = wp_unslash($_POST['acf']['field_acfe_options_edit_value']);
|
546 |
+
$autoload = $_POST['acf']['field_acfe_options_edit_autoload'];
|
547 |
+
|
548 |
+
// Value serialized?
|
549 |
+
$option_value = maybe_unserialize($option_value);
|
550 |
+
|
551 |
+
// Update
|
552 |
+
update_option($option_name, $option_value, $autoload);
|
553 |
+
|
554 |
+
// Flush ACF
|
555 |
+
$_POST['acf'] = array();
|
556 |
+
|
557 |
+
}
|
558 |
+
|
559 |
+
/**
|
560 |
+
* Options Edit: Message
|
561 |
+
*
|
562 |
+
*/
|
563 |
+
add_action('acfe/options/load/message=updated', 'acfe_options_load_edit_message');
|
564 |
+
function acfe_options_load_edit_message(){
|
565 |
+
|
566 |
+
acf_add_admin_notice(__('Option has been updated'), 'success');
|
567 |
+
|
568 |
+
}
|
569 |
+
|
570 |
+
/**
|
571 |
+
* Options Add: Message
|
572 |
+
*
|
573 |
+
*/
|
574 |
+
add_action('acfe/options/load/message=added', 'acfe_options_load_add_message');
|
575 |
+
function acfe_options_load_add_message(){
|
576 |
+
|
577 |
+
acf_add_admin_notice(__('Option has been added'), 'success');
|
578 |
+
|
579 |
}
|
@@ -1,42 +1,42 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Admin: Plugins Tab
|
8 |
-
*/
|
9 |
-
add_filter('install_plugins_tabs', 'acfe_admin_plugins_tabs');
|
10 |
-
function acfe_admin_plugins_tabs($tabs){
|
11 |
-
|
12 |
-
$tabs['acf'] = __('Advanced Custom Fields');
|
13 |
-
|
14 |
-
return $tabs;
|
15 |
-
|
16 |
-
}
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Admin: Plugins Args
|
20 |
-
*/
|
21 |
-
add_filter('install_plugins_table_api_args_acf', 'acfe_admin_plugins_args');
|
22 |
-
function acfe_admin_plugins_args($args){
|
23 |
-
|
24 |
-
global $paged;
|
25 |
-
|
26 |
-
$args['search'] = 'acf';
|
27 |
-
$args['page'] = $paged;
|
28 |
-
$args['per_page'] = 12;
|
29 |
-
|
30 |
-
return $args;
|
31 |
-
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Admin: Plugins HTML
|
36 |
-
*/
|
37 |
-
add_action('install_plugins_acf', 'acfe_admin_plugins_html');
|
38 |
-
function acfe_admin_plugins_html(){
|
39 |
-
|
40 |
-
display_plugins_table();
|
41 |
-
|
42 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Admin: Plugins Tab
|
8 |
+
*/
|
9 |
+
add_filter('install_plugins_tabs', 'acfe_admin_plugins_tabs');
|
10 |
+
function acfe_admin_plugins_tabs($tabs){
|
11 |
+
|
12 |
+
$tabs['acf'] = __('Advanced Custom Fields');
|
13 |
+
|
14 |
+
return $tabs;
|
15 |
+
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Admin: Plugins Args
|
20 |
+
*/
|
21 |
+
add_filter('install_plugins_table_api_args_acf', 'acfe_admin_plugins_args');
|
22 |
+
function acfe_admin_plugins_args($args){
|
23 |
+
|
24 |
+
global $paged;
|
25 |
+
|
26 |
+
$args['search'] = 'acf';
|
27 |
+
$args['page'] = $paged;
|
28 |
+
$args['per_page'] = 12;
|
29 |
+
|
30 |
+
return $args;
|
31 |
+
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Admin: Plugins HTML
|
36 |
+
*/
|
37 |
+
add_action('install_plugins_acf', 'acfe_admin_plugins_html');
|
38 |
+
function acfe_admin_plugins_html(){
|
39 |
+
|
40 |
+
display_plugins_table();
|
41 |
+
|
42 |
}
|
@@ -1,453 +1,453 @@
|
|
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 |
-
<div class="postbox-header">
|
30 |
-
<h2 class="hndle ui-sortable-handle"><span><?php _e('Settings'); ?></span></h2>
|
31 |
-
</div>
|
32 |
-
<div class="inside acf-fields -left">
|
33 |
-
|
34 |
-
<?php
|
35 |
-
acf_render_field_wrap(array(
|
36 |
-
'type' => 'tab',
|
37 |
-
'label' => 'ACF',
|
38 |
-
));
|
39 |
-
?>
|
40 |
-
|
41 |
-
<?php
|
42 |
-
|
43 |
-
$settings = array(
|
44 |
-
array(
|
45 |
-
'name' => 'path',
|
46 |
-
'label' => 'Path',
|
47 |
-
'value' => '<code>' . acf_get_setting('path') . '</code>',
|
48 |
-
'description' => 'Absolute path to ACF plugin folder including trailing slash.<br />Defaults to plugin_dir_path'
|
49 |
-
),
|
50 |
-
array(
|
51 |
-
'name' => 'dir',
|
52 |
-
'label' => 'Directory',
|
53 |
-
'value' => '<code>' . acf_get_setting('dir') . '</code>',
|
54 |
-
'description' => 'URL to ACF plugin folder including trailing slash. Defaults to plugin_dir_url'
|
55 |
-
),
|
56 |
-
array(
|
57 |
-
'name' => 'show_admin',
|
58 |
-
'label' => 'Show menu',
|
59 |
-
'value' => '<code>' . (acf_get_setting('show_admin') ? __('True'): __('False')) . '</code>',
|
60 |
-
'description' => 'Show/hide ACF menu item. Defaults to true'
|
61 |
-
),
|
62 |
-
array(
|
63 |
-
'name' => 'stripslashes',
|
64 |
-
'label' => 'Strip slashes',
|
65 |
-
'value' => '<code>' . (acf_get_setting('stripslashes') ? __('True'): __('False')) . '</code>',
|
66 |
-
'description' => 'Runs the function stripslashes on all $_POST data. Some servers / WP instals may require this extra functioanlity. Defaults to false'
|
67 |
-
),
|
68 |
-
array(
|
69 |
-
'name' => 'local',
|
70 |
-
'label' => 'PHP/Json',
|
71 |
-
'value' => '<code>' . (acf_get_setting('local') ? __('True'): __('False')) . '</code>',
|
72 |
-
'description' => 'Enable/Disable local (PHP/json) fields. Defaults to true'
|
73 |
-
),
|
74 |
-
array(
|
75 |
-
'name' => 'json',
|
76 |
-
'label' => 'Json',
|
77 |
-
'value' => '<code>' . (acf_get_setting('json') ? __('True'): __('False')) . '</code>',
|
78 |
-
'description' => 'Enable/Disable json fields. Defaults to true'
|
79 |
-
),
|
80 |
-
array(
|
81 |
-
'name' => 'save_json',
|
82 |
-
'label' => 'Json folder (save)',
|
83 |
-
'value' => '<code>' . acf_get_setting('save_json') . '</code>',
|
84 |
-
'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'
|
85 |
-
),
|
86 |
-
array(
|
87 |
-
'name' => 'load_json',
|
88 |
-
'label' => 'Json folder (load)',
|
89 |
-
'value' => '<code>' . implode("<br />", (array) acf_get_setting('load_json')) . '</code>',
|
90 |
-
'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'
|
91 |
-
),
|
92 |
-
array(
|
93 |
-
'name' => 'default_language',
|
94 |
-
'label' => 'Default language',
|
95 |
-
'value' => '<code>' . acf_get_setting('default_language') . '</code>',
|
96 |
-
'description' => 'Language code of the default language. Defaults to ”.<br />If WPML is active, ACF will default this to the WPML default language setting'
|
97 |
-
),
|
98 |
-
array(
|
99 |
-
'name' => 'current_language',
|
100 |
-
'label' => 'Current language',
|
101 |
-
'value' => '<code>' . acf_get_setting('current_language') . '</code>',
|
102 |
-
'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'
|
103 |
-
),
|
104 |
-
array(
|
105 |
-
'name' => 'capability',
|
106 |
-
'label' => 'Capability',
|
107 |
-
'value' => '<code>' . acf_get_setting('capability') . '</code>',
|
108 |
-
'description' => 'Capability used for ACF post types and if the current user can see the ACF menu item.<br />Defaults to ‘manage_options’.'
|
109 |
-
),
|
110 |
-
array(
|
111 |
-
'name' => 'show_updates',
|
112 |
-
'label' => 'Show updates',
|
113 |
-
'value' => '<code>' . (acf_get_setting('show_updates') ? __('True'): __('False')) . '</code>',
|
114 |
-
'description' => 'Enable/Disable updates to appear in plugin list and show/hide the ACF updates admin page.<br />Defaults to true.'
|
115 |
-
),
|
116 |
-
array(
|
117 |
-
'name' => 'export_textdomain',
|
118 |
-
'label' => 'Export textdomain',
|
119 |
-
'value' => '<code>' . (acf_get_setting('export_textdomain') ? __('True'): __('False')) . '</code>',
|
120 |
-
'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'
|
121 |
-
),
|
122 |
-
array(
|
123 |
-
'name' => 'export_translate',
|
124 |
-
'label' => 'Export translate',
|
125 |
-
'value' => '<code>' . print_r(acf_get_setting('export_translate'), true) . '</code>',
|
126 |
-
'description' => 'Used during the ‘Export to PHP’ feature to wrap strings within the __() function.<br />Depreciated in v5.4.4 – please see l10n_textdomain'
|
127 |
-
),
|
128 |
-
array(
|
129 |
-
'name' => 'autoload',
|
130 |
-
'label' => 'Auto load',
|
131 |
-
'value' => '<code>' . (acf_get_setting('autoload') ? __('True'): __('False')) . '</code>',
|
132 |
-
'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'
|
133 |
-
),
|
134 |
-
array(
|
135 |
-
'name' => 'l10n',
|
136 |
-
'label' => 'l10n',
|
137 |
-
'value' => '<code>' . (acf_get_setting('l10n') ? __('True'): __('False')) . '</code>',
|
138 |
-
'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'
|
139 |
-
),
|
140 |
-
array(
|
141 |
-
'name' => 'l10n_textdomain',
|
142 |
-
'label' => 'l10n Textdomain',
|
143 |
-
'value' => '<code>' . print_r(acf_get_setting('l10n_textdomain'), true) . '</code>',
|
144 |
-
'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'
|
145 |
-
),
|
146 |
-
array(
|
147 |
-
'name' => 'l10n_field',
|
148 |
-
'label' => 'l10n Field',
|
149 |
-
'value' => '<code>' . print_r(acf_get_setting('l10n_field'), true) . '</code>',
|
150 |
-
'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'
|
151 |
-
),
|
152 |
-
array(
|
153 |
-
'name' => 'l10n_field_group',
|
154 |
-
'label' => 'l10n Field group',
|
155 |
-
'value' => '<code>' . print_r(acf_get_setting('l10n_field_group'), true) . '</code>',
|
156 |
-
'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'
|
157 |
-
),
|
158 |
-
array(
|
159 |
-
'name' => 'google_api_key',
|
160 |
-
'label' => 'Google API Key',
|
161 |
-
'value' => '<code>' . acf_get_setting('google_api_key') . '</code>',
|
162 |
-
'description' => 'Specify a Google Maps API authentication key to prevent usage limits.<br />Defaults to ”'
|
163 |
-
),
|
164 |
-
array(
|
165 |
-
'name' => 'google_api_client',
|
166 |
-
'label' => 'Google API Key',
|
167 |
-
'value' => '<code>' . acf_get_setting('google_api_client') . '</code>',
|
168 |
-
'description' => 'Specify a Google Maps API Client ID to prevent usage limits.<br />Not needed if using <code>google_api_key</code>. Defaults to ”'
|
169 |
-
),
|
170 |
-
array(
|
171 |
-
'name' => 'enqueue_google_maps',
|
172 |
-
'label' => 'Enqueue Google Maps',
|
173 |
-
'value' => '<code>' . (acf_get_setting('enqueue_google_maps') ? __('True'): __('False')) . '</code>',
|
174 |
-
'description' => 'Allows ACF to enqueue and load the Google Maps API JS library.<br />Defaults to true'
|
175 |
-
),
|
176 |
-
array(
|
177 |
-
'name' => 'enqueue_select2',
|
178 |
-
'label' => 'Enqueue Select2',
|
179 |
-
'value' => '<code>' . (acf_get_setting('enqueue_select2') ? __('True'): __('False')) . '</code>',
|
180 |
-
'description' => 'Allows ACF to enqueue and load the Select2 JS/CSS library.<br />Defaults to true'
|
181 |
-
),
|
182 |
-
array(
|
183 |
-
'name' => 'select2_version',
|
184 |
-
'label' => 'Select2 version',
|
185 |
-
'value' => '<code>' . acf_get_setting('select2_version') . '</code>',
|
186 |
-
'description' => 'Defines which version of Select2 library to enqueue. Either 3 or 4.<br />Defaults to 4 since ACF 5.6.0'
|
187 |
-
),
|
188 |
-
array(
|
189 |
-
'name' => 'enqueue_datepicker',
|
190 |
-
'label' => 'Enqueue Datepicker',
|
191 |
-
'value' => '<code>' . (acf_get_setting('enqueue_datepicker') ? __('True'): __('False')) . '</code>',
|
192 |
-
'description' => 'Allows ACF to enqueue and load the WP datepicker JS/CSS library.<br />Defaults to true'
|
193 |
-
),
|
194 |
-
array(
|
195 |
-
'name' => 'enqueue_datetimepicker',
|
196 |
-
'label' => 'Enqueue Date/timepicker',
|
197 |
-
'value' => '<code>' . (acf_get_setting('enqueue_datetimepicker') ? __('True'): __('False')) . '</code>',
|
198 |
-
'description' => 'Allows ACF to enqueue and load the datetimepicker JS/CSS library.<br />Defaults to true'
|
199 |
-
),
|
200 |
-
array(
|
201 |
-
'name' => 'row_index_offset',
|
202 |
-
'label' => 'Row index offset',
|
203 |
-
'value' => '<code>' . acf_get_setting('row_index_offset') . '</code>',
|
204 |
-
'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)'
|
205 |
-
),
|
206 |
-
array(
|
207 |
-
'name' => 'remove_wp_meta_box',
|
208 |
-
'label' => 'Remove WP meta box',
|
209 |
-
'value' => '<code>' . (acf_get_setting('remove_wp_meta_box') ? __('True'): __('False')) . '</code>',
|
210 |
-
'description' => 'Allows ACF to remove the default WP custom fields metabox. Defaults to true'
|
211 |
-
),
|
212 |
-
);
|
213 |
-
|
214 |
-
?>
|
215 |
-
|
216 |
-
<?php foreach($settings as $setting){ ?>
|
217 |
-
<div class="acf-field">
|
218 |
-
<div class="acf-label">
|
219 |
-
<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>
|
220 |
-
<p class="description"><code><?php echo $setting['name']; ?></code></p>
|
221 |
-
</div>
|
222 |
-
<div class="acf-input">
|
223 |
-
<?php echo $setting['value']; ?>
|
224 |
-
</div>
|
225 |
-
</div>
|
226 |
-
<?php } ?>
|
227 |
-
|
228 |
-
<?php
|
229 |
-
acf_render_field_wrap(array(
|
230 |
-
'type' => 'tab',
|
231 |
-
'label' => 'ACF: Extended',
|
232 |
-
));
|
233 |
-
?>
|
234 |
-
|
235 |
-
<?php
|
236 |
-
|
237 |
-
$settings = array(
|
238 |
-
|
239 |
-
// Modules
|
240 |
-
array(
|
241 |
-
'name' => 'acfe/modules/author',
|
242 |
-
'label' => 'Module: Author',
|
243 |
-
'value' => '<code>' . (acf_get_setting('acfe/modules/author', true) ? __('True'): __('False')) . '</code>',
|
244 |
-
'description' => 'Show/hide the Author module. Defaults to true'
|
245 |
-
),
|
246 |
-
array(
|
247 |
-
'name' => 'acfe/modules/categories',
|
248 |
-
'label' => 'Module: Categories',
|
249 |
-
'value' => '<code>' . (acf_get_setting('acfe/modules/categories', true) ? __('True'): __('False')) . '</code>',
|
250 |
-
'description' => 'Enable/disable the Field Group Categories taxonomy. Defaults to true'
|
251 |
-
),
|
252 |
-
array(
|
253 |
-
'name' => 'acfe/modules/dynamic_block_types',
|
254 |
-
'label' => 'Module: Dynamic Block Types',
|
255 |
-
'value' => '<code>' . (acf_get_setting('acfe/modules/dynamic_block_types', true) ? __('True'): __('False')) . '</code>',
|
256 |
-
'description' => 'Show/hide the Block Types module. Defaults to true'
|
257 |
-
),
|
258 |
-
array(
|
259 |
-
'name' => 'acfe/modules/dynamic_forms',
|
260 |
-
'label' => 'Module: Dynamic Forms',
|
261 |
-
'value' => '<code>' . (acf_get_setting('acfe/modules/dynamic_forms', true) ? __('True'): __('False')) . '</code>',
|
262 |
-
'description' => 'Show/hide the Forms module. Defaults to true'
|
263 |
-
),
|
264 |
-
array(
|
265 |
-
'name' => 'acfe/modules/dynamic_post_types',
|
266 |
-
'label' => 'Module: Dynamic Post Types',
|
267 |
-
'value' => '<code>' . (acf_get_setting('acfe/modules/dynamic_post_types', true) ? __('True'): __('False')) . '</code>',
|
268 |
-
'description' => 'Show/hide the Post Types module. Defaults to true'
|
269 |
-
),
|
270 |
-
array(
|
271 |
-
'name' => 'acfe/modules/dynamic_taxonomies',
|
272 |
-
'label' => 'Module: Dynamic Taxonomies',
|
273 |
-
'value' => '<code>' . (acf_get_setting('acfe/modules/dynamic_taxonomies', true) ? __('True'): __('False')) . '</code>',
|
274 |
-
'description' => 'Show/hide the Taxonomies module. Defaults to true'
|
275 |
-
),
|
276 |
-
array(
|
277 |
-
'name' => 'acfe/modules/dynamic_options_pages',
|
278 |
-
'label' => 'Module: Dynamic Options Pages',
|
279 |
-
'value' => '<code>' . (acf_get_setting('acfe/modules/dynamic_options_pages', true) ? __('True'): __('False')) . '</code>',
|
280 |
-
'description' => 'Show/hide the Options Pages module. Defaults to true'
|
281 |
-
),
|
282 |
-
array(
|
283 |
-
'name' => 'acfe/modules/multilang',
|
284 |
-
'label' => 'Module: Multilang',
|
285 |
-
'value' => '<code>' . (acf_get_setting('acfe/modules/multilang', true) ? __('True'): __('False')) . '</code>',
|
286 |
-
'description' => 'Enable/disable Multilang compatibility module for WPML & Polylang. Defaults to true'
|
287 |
-
),
|
288 |
-
array(
|
289 |
-
'name' => 'acfe/modules/options',
|
290 |
-
'label' => 'Module: Options',
|
291 |
-
'value' => '<code>' . (acf_get_setting('acfe/modules/options', true) ? __('True'): __('False')) . '</code>',
|
292 |
-
'description' => 'Show/hide the Options module. Defaults to true'
|
293 |
-
),
|
294 |
-
array(
|
295 |
-
'name' => 'acfe/modules/single_meta',
|
296 |
-
'label' => 'Module: Single Meta',
|
297 |
-
'value' => '<code>' . (acf_get_setting('acfe/modules/single_meta', true) ? __('True'): __('False')) . '</code>',
|
298 |
-
'description' => 'Enable/disable Single Meta Save module. Defaults to false'
|
299 |
-
),
|
300 |
-
array(
|
301 |
-
'name' => 'acfe/modules/ui',
|
302 |
-
'label' => 'Module: UI Enhancements',
|
303 |
-
'value' => '<code>' . (acf_get_setting('acfe/modules/ui', true) ? __('True'): __('False')) . '</code>',
|
304 |
-
'description' => 'Show/hide the UI enhancements module. Defaults to true'
|
305 |
-
),
|
306 |
-
|
307 |
-
// Recaptcha
|
308 |
-
array(
|
309 |
-
'name' => 'acfe/field/recaptcha/site_key',
|
310 |
-
'label' => 'Field: reCaptcha site key',
|
311 |
-
'value' => '<code>' . acf_get_setting('acfe/field/recaptcha/site_key') . '</code>',
|
312 |
-
'description' => 'The default reCaptcha site key'
|
313 |
-
),
|
314 |
-
array(
|
315 |
-
'name' => 'acfe/field/recaptcha/secret_key',
|
316 |
-
'label' => 'Field: reCaptcha secret key',
|
317 |
-
'value' => '<code>' . acf_get_setting('acfe/field/recaptcha/secret_key') . '</code>',
|
318 |
-
'description' => 'The default reCaptcha secret key'
|
319 |
-
),
|
320 |
-
array(
|
321 |
-
'name' => 'acfe/field/recaptcha/version',
|
322 |
-
'label' => 'Field: reCaptcha version',
|
323 |
-
'value' => '<code>' . acf_get_setting('acfe/field/recaptcha/version', 'v2') . '</code>',
|
324 |
-
'description' => 'The default reCaptcha version'
|
325 |
-
),
|
326 |
-
array(
|
327 |
-
'name' => 'acfe/field/recaptcha/v2/theme',
|
328 |
-
'label' => 'Field: reCaptcha v2 theme',
|
329 |
-
'value' => '<code>' . acf_get_setting('acfe/field/recaptcha/v2/theme', 'light') . '</code>',
|
330 |
-
'description' => 'The default reCaptcha v2 theme'
|
331 |
-
),
|
332 |
-
array(
|
333 |
-
'name' => 'acfe/field/recaptcha/v2/size',
|
334 |
-
'label' => 'Field: reCaptcha v2 size',
|
335 |
-
'value' => '<code>' . acf_get_setting('acfe/field/recaptcha/v2/size', 'normal') . '</code>',
|
336 |
-
'description' => 'The default reCaptcha v2 size'
|
337 |
-
),
|
338 |
-
array(
|
339 |
-
'name' => 'acfe/field/recaptcha/v3/hide_logo',
|
340 |
-
'label' => 'Field: reCaptcha v3 hide logo',
|
341 |
-
'value' => '<code>' . acf_get_setting('acfe/field/recaptcha/v3/hide_logo') . '</code>',
|
342 |
-
'description' => 'Show/hide reCaptcha v3 logo'
|
343 |
-
),
|
344 |
-
array(
|
345 |
-
'name' => 'acfe/dev',
|
346 |
-
'label' => 'Dev mode',
|
347 |
-
'value' => '<code>' . (acf_get_setting('acfe/dev') ? __('True'): __('False')) . '</code>',
|
348 |
-
'description' => 'Show/hide the advanced WP post meta box. Defaults to false'
|
349 |
-
),
|
350 |
-
|
351 |
-
// PHP
|
352 |
-
array(
|
353 |
-
'name' => 'acfe/php',
|
354 |
-
'label' => 'PHP',
|
355 |
-
'value' => '<code>' . (acf_get_setting('acfe/php') ? __('True'): __('False')) . '</code>',
|
356 |
-
'description' => 'Whenever PHP AutoSync is enabled'
|
357 |
-
),
|
358 |
-
array(
|
359 |
-
'name' => 'acfe/php_found',
|
360 |
-
'label' => 'PHP: Found',
|
361 |
-
'value' => '<code>' . (acf_get_setting('acfe/php_found') ? __('True'): __('False')) . '</code>',
|
362 |
-
'description' => 'Whenever PHP AutoSync folder has been found, based on acfe/php_load setting'
|
363 |
-
),
|
364 |
-
array(
|
365 |
-
'name' => 'acfe/php_save',
|
366 |
-
'label' => 'PHP: Save',
|
367 |
-
'value' => '<code>' . acf_get_setting('acfe/php_save') . '</code>',
|
368 |
-
'description' => 'PHP AutoSync saving path'
|
369 |
-
),
|
370 |
-
array(
|
371 |
-
'name' => 'acfe/php_load',
|
372 |
-
'label' => 'PHP: Load',
|
373 |
-
'value' => '<code>' . implode("<br />", (array) acf_get_setting('acfe/php_load')) . '</code>',
|
374 |
-
'description' => 'PHP AutoSync loading path'
|
375 |
-
),
|
376 |
-
|
377 |
-
// Json
|
378 |
-
array(
|
379 |
-
'name' => 'acfe/json',
|
380 |
-
'label' => 'Json',
|
381 |
-
'value' => '<code>' . (acf_get_setting('acfe/json') ? __('True'): __('False')) . '</code>',
|
382 |
-
'description' => 'Whenever Json AutoSync is enabled'
|
383 |
-
),
|
384 |
-
array(
|
385 |
-
'name' => 'acfe/json_found',
|
386 |
-
'label' => 'Json: Found',
|
387 |
-
'value' => '<code>' . (acf_get_setting('acfe/json_found') ? __('True'): __('False')) . '</code>',
|
388 |
-
'description' => 'Whenever Json AutoSync folder has been found, based on acfe/json_load setting'
|
389 |
-
),
|
390 |
-
array(
|
391 |
-
'name' => 'acfe/json_save',
|
392 |
-
'label' => 'Json: Save',
|
393 |
-
'value' => '<code>' . acf_get_setting('acfe/json_save') . '</code>',
|
394 |
-
'description' => 'Json AutoSync saving path'
|
395 |
-
),
|
396 |
-
array(
|
397 |
-
'name' => 'acfe/json_load',
|
398 |
-
'label' => 'Json: Load',
|
399 |
-
'value' => '<code>' . implode("<br />", (array) acf_get_setting('acfe/json_load')) . '</code>',
|
400 |
-
'description' => 'Json AutoSync loading paths'
|
401 |
-
),
|
402 |
-
|
403 |
-
// Theme
|
404 |
-
array(
|
405 |
-
'name' => 'acfe/theme_path',
|
406 |
-
'label' => 'Theme: Path',
|
407 |
-
'value' => '<code>' . acf_get_setting('acfe/theme_path') . '</code>',
|
408 |
-
'description' => 'Detected Theme Path'
|
409 |
-
),
|
410 |
-
array(
|
411 |
-
'name' => 'acfe/theme_url',
|
412 |
-
'label' => 'Theme: URL',
|
413 |
-
'value' => '<code>' . acf_get_setting('acfe/theme_url') . '</code>',
|
414 |
-
'description' => 'Detected Theme URL'
|
415 |
-
),
|
416 |
-
array(
|
417 |
-
'name' => 'acfe/theme_folder',
|
418 |
-
'label' => 'Theme: Folder',
|
419 |
-
'value' => '<code>' . acf_get_setting('acfe/theme_folder') . '</code>',
|
420 |
-
'description' => 'Detected Theme Folder'
|
421 |
-
),
|
422 |
-
);
|
423 |
-
?>
|
424 |
-
|
425 |
-
<?php foreach($settings as $setting){ ?>
|
426 |
-
<div class="acf-field">
|
427 |
-
<div class="acf-label">
|
428 |
-
<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>
|
429 |
-
<p class="description"><code><?php echo $setting['name']; ?></code></p>
|
430 |
-
</div>
|
431 |
-
<div class="acf-input">
|
432 |
-
<?php echo $setting['value']; ?>
|
433 |
-
</div>
|
434 |
-
</div>
|
435 |
-
<?php } ?>
|
436 |
-
|
437 |
-
<script type="text/javascript">
|
438 |
-
if( typeof acf !== 'undefined' ) {
|
439 |
-
|
440 |
-
acf.newPostbox({
|
441 |
-
'id': 'acfe-settings',
|
442 |
-
'label': 'left'
|
443 |
-
});
|
444 |
-
|
445 |
-
}
|
446 |
-
</script>
|
447 |
-
</div>
|
448 |
-
</div>
|
449 |
-
</div>
|
450 |
-
|
451 |
-
</div>
|
452 |
-
<?php
|
453 |
}
|
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 |
+
<div class="postbox-header">
|
30 |
+
<h2 class="hndle ui-sortable-handle"><span><?php _e('Settings'); ?></span></h2>
|
31 |
+
</div>
|
32 |
+
<div class="inside acf-fields -left">
|
33 |
+
|
34 |
+
<?php
|
35 |
+
acf_render_field_wrap(array(
|
36 |
+
'type' => 'tab',
|
37 |
+
'label' => 'ACF',
|
38 |
+
));
|
39 |
+
?>
|
40 |
+
|
41 |
+
<?php
|
42 |
+
|
43 |
+
$settings = array(
|
44 |
+
array(
|
45 |
+
'name' => 'path',
|
46 |
+
'label' => 'Path',
|
47 |
+
'value' => '<code>' . acf_get_setting('path') . '</code>',
|
48 |
+
'description' => 'Absolute path to ACF plugin folder including trailing slash.<br />Defaults to plugin_dir_path'
|
49 |
+
),
|
50 |
+
array(
|
51 |
+
'name' => 'dir',
|
52 |
+
'label' => 'Directory',
|
53 |
+
'value' => '<code>' . acf_get_setting('dir') . '</code>',
|
54 |
+
'description' => 'URL to ACF plugin folder including trailing slash. Defaults to plugin_dir_url'
|
55 |
+
),
|
56 |
+
array(
|
57 |
+
'name' => 'show_admin',
|
58 |
+
'label' => 'Show menu',
|
59 |
+
'value' => '<code>' . (acf_get_setting('show_admin') ? __('True'): __('False')) . '</code>',
|
60 |
+
'description' => 'Show/hide ACF menu item. Defaults to true'
|
61 |
+
),
|
62 |
+
array(
|
63 |
+
'name' => 'stripslashes',
|
64 |
+
'label' => 'Strip slashes',
|
65 |
+
'value' => '<code>' . (acf_get_setting('stripslashes') ? __('True'): __('False')) . '</code>',
|
66 |
+
'description' => 'Runs the function stripslashes on all $_POST data. Some servers / WP instals may require this extra functioanlity. Defaults to false'
|
67 |
+
),
|
68 |
+
array(
|
69 |
+
'name' => 'local',
|
70 |
+
'label' => 'PHP/Json',
|
71 |
+
'value' => '<code>' . (acf_get_setting('local') ? __('True'): __('False')) . '</code>',
|
72 |
+
'description' => 'Enable/Disable local (PHP/json) fields. Defaults to true'
|
73 |
+
),
|
74 |
+
array(
|
75 |
+
'name' => 'json',
|
76 |
+
'label' => 'Json',
|
77 |
+
'value' => '<code>' . (acf_get_setting('json') ? __('True'): __('False')) . '</code>',
|
78 |
+
'description' => 'Enable/Disable json fields. Defaults to true'
|
79 |
+
),
|
80 |
+
array(
|
81 |
+
'name' => 'save_json',
|
82 |
+
'label' => 'Json folder (save)',
|
83 |
+
'value' => '<code>' . acf_get_setting('save_json') . '</code>',
|
84 |
+
'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'
|
85 |
+
),
|
86 |
+
array(
|
87 |
+
'name' => 'load_json',
|
88 |
+
'label' => 'Json folder (load)',
|
89 |
+
'value' => '<code>' . implode("<br />", (array) acf_get_setting('load_json')) . '</code>',
|
90 |
+
'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'
|
91 |
+
),
|
92 |
+
array(
|
93 |
+
'name' => 'default_language',
|
94 |
+
'label' => 'Default language',
|
95 |
+
'value' => '<code>' . acf_get_setting('default_language') . '</code>',
|
96 |
+
'description' => 'Language code of the default language. Defaults to ”.<br />If WPML is active, ACF will default this to the WPML default language setting'
|
97 |
+
),
|
98 |
+
array(
|
99 |
+
'name' => 'current_language',
|
100 |
+
'label' => 'Current language',
|
101 |
+
'value' => '<code>' . acf_get_setting('current_language') . '</code>',
|
102 |
+
'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'
|
103 |
+
),
|
104 |
+
array(
|
105 |
+
'name' => 'capability',
|
106 |
+
'label' => 'Capability',
|
107 |
+
'value' => '<code>' . acf_get_setting('capability') . '</code>',
|
108 |
+
'description' => 'Capability used for ACF post types and if the current user can see the ACF menu item.<br />Defaults to ‘manage_options’.'
|
109 |
+
),
|
110 |
+
array(
|
111 |
+
'name' => 'show_updates',
|
112 |
+
'label' => 'Show updates',
|
113 |
+
'value' => '<code>' . (acf_get_setting('show_updates') ? __('True'): __('False')) . '</code>',
|
114 |
+
'description' => 'Enable/Disable updates to appear in plugin list and show/hide the ACF updates admin page.<br />Defaults to true.'
|
115 |
+
),
|
116 |
+
array(
|
117 |
+
'name' => 'export_textdomain',
|
118 |
+
'label' => 'Export textdomain',
|
119 |
+
'value' => '<code>' . (acf_get_setting('export_textdomain') ? __('True'): __('False')) . '</code>',
|
120 |
+
'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'
|
121 |
+
),
|
122 |
+
array(
|
123 |
+
'name' => 'export_translate',
|
124 |
+
'label' => 'Export translate',
|
125 |
+
'value' => '<code>' . print_r(acf_get_setting('export_translate'), true) . '</code>',
|
126 |
+
'description' => 'Used during the ‘Export to PHP’ feature to wrap strings within the __() function.<br />Depreciated in v5.4.4 – please see l10n_textdomain'
|
127 |
+
),
|
128 |
+
array(
|
129 |
+
'name' => 'autoload',
|
130 |
+
'label' => 'Auto load',
|
131 |
+
'value' => '<code>' . (acf_get_setting('autoload') ? __('True'): __('False')) . '</code>',
|
132 |
+
'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'
|
133 |
+
),
|
134 |
+
array(
|
135 |
+
'name' => 'l10n',
|
136 |
+
'label' => 'l10n',
|
137 |
+
'value' => '<code>' . (acf_get_setting('l10n') ? __('True'): __('False')) . '</code>',
|
138 |
+
'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'
|
139 |
+
),
|
140 |
+
array(
|
141 |
+
'name' => 'l10n_textdomain',
|
142 |
+
'label' => 'l10n Textdomain',
|
143 |
+
'value' => '<code>' . print_r(acf_get_setting('l10n_textdomain'), true) . '</code>',
|
144 |
+
'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'
|
145 |
+
),
|
146 |
+
array(
|
147 |
+
'name' => 'l10n_field',
|
148 |
+
'label' => 'l10n Field',
|
149 |
+
'value' => '<code>' . print_r(acf_get_setting('l10n_field'), true) . '</code>',
|
150 |
+
'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'
|
151 |
+
),
|
152 |
+
array(
|
153 |
+
'name' => 'l10n_field_group',
|
154 |
+
'label' => 'l10n Field group',
|
155 |
+
'value' => '<code>' . print_r(acf_get_setting('l10n_field_group'), true) . '</code>',
|
156 |
+
'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'
|
157 |
+
),
|
158 |
+
array(
|
159 |
+
'name' => 'google_api_key',
|
160 |
+
'label' => 'Google API Key',
|
161 |
+
'value' => '<code>' . acf_get_setting('google_api_key') . '</code>',
|
162 |
+
'description' => 'Specify a Google Maps API authentication key to prevent usage limits.<br />Defaults to ”'
|
163 |
+
),
|
164 |
+
array(
|
165 |
+
'name' => 'google_api_client',
|
166 |
+
'label' => 'Google API Key',
|
167 |
+
'value' => '<code>' . acf_get_setting('google_api_client') . '</code>',
|
168 |
+
'description' => 'Specify a Google Maps API Client ID to prevent usage limits.<br />Not needed if using <code>google_api_key</code>. Defaults to ”'
|
169 |
+
),
|
170 |
+
array(
|
171 |
+
'name' => 'enqueue_google_maps',
|
172 |
+
'label' => 'Enqueue Google Maps',
|
173 |
+
'value' => '<code>' . (acf_get_setting('enqueue_google_maps') ? __('True'): __('False')) . '</code>',
|
174 |
+
'description' => 'Allows ACF to enqueue and load the Google Maps API JS library.<br />Defaults to true'
|
175 |
+
),
|
176 |
+
array(
|
177 |
+
'name' => 'enqueue_select2',
|
178 |
+
'label' => 'Enqueue Select2',
|
179 |
+
'value' => '<code>' . (acf_get_setting('enqueue_select2') ? __('True'): __('False')) . '</code>',
|
180 |
+
'description' => 'Allows ACF to enqueue and load the Select2 JS/CSS library.<br />Defaults to true'
|
181 |
+
),
|
182 |
+
array(
|
183 |
+
'name' => 'select2_version',
|
184 |
+
'label' => 'Select2 version',
|
185 |
+
'value' => '<code>' . acf_get_setting('select2_version') . '</code>',
|
186 |
+
'description' => 'Defines which version of Select2 library to enqueue. Either 3 or 4.<br />Defaults to 4 since ACF 5.6.0'
|
187 |
+
),
|
188 |
+
array(
|
189 |
+
'name' => 'enqueue_datepicker',
|
190 |
+
'label' => 'Enqueue Datepicker',
|
191 |
+
'value' => '<code>' . (acf_get_setting('enqueue_datepicker') ? __('True'): __('False')) . '</code>',
|
192 |
+
'description' => 'Allows ACF to enqueue and load the WP datepicker JS/CSS library.<br />Defaults to true'
|
193 |
+
),
|
194 |
+
array(
|
195 |
+
'name' => 'enqueue_datetimepicker',
|
196 |
+
'label' => 'Enqueue Date/timepicker',
|
197 |
+
'value' => '<code>' . (acf_get_setting('enqueue_datetimepicker') ? __('True'): __('False')) . '</code>',
|
198 |
+
'description' => 'Allows ACF to enqueue and load the datetimepicker JS/CSS library.<br />Defaults to true'
|
199 |
+
),
|
200 |
+
array(
|
201 |
+
'name' => 'row_index_offset',
|
202 |
+
'label' => 'Row index offset',
|
203 |
+
'value' => '<code>' . acf_get_setting('row_index_offset') . '</code>',
|
204 |
+
'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)'
|
205 |
+
),
|
206 |
+
array(
|
207 |
+
'name' => 'remove_wp_meta_box',
|
208 |
+
'label' => 'Remove WP meta box',
|
209 |
+
'value' => '<code>' . (acf_get_setting('remove_wp_meta_box') ? __('True'): __('False')) . '</code>',
|
210 |
+
'description' => 'Allows ACF to remove the default WP custom fields metabox. Defaults to true'
|
211 |
+
),
|
212 |
+
);
|
213 |
+
|
214 |
+
?>
|
215 |
+
|
216 |
+
<?php foreach($settings as $setting){ ?>
|
217 |
+
<div class="acf-field">
|
218 |
+
<div class="acf-label">
|
219 |
+
<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>
|
220 |
+
<p class="description"><code><?php echo $setting['name']; ?></code></p>
|
221 |
+
</div>
|
222 |
+
<div class="acf-input">
|
223 |
+
<?php echo $setting['value']; ?>
|
224 |
+
</div>
|
225 |
+
</div>
|
226 |
+
<?php } ?>
|
227 |
+
|
228 |
+
<?php
|
229 |
+
acf_render_field_wrap(array(
|
230 |
+
'type' => 'tab',
|
231 |
+
'label' => 'ACF: Extended',
|
232 |
+
));
|
233 |
+
?>
|
234 |
+
|
235 |
+
<?php
|
236 |
+
|
237 |
+
$settings = array(
|
238 |
+
|
239 |
+
// Modules
|
240 |
+
array(
|
241 |
+
'name' => 'acfe/modules/author',
|
242 |
+
'label' => 'Module: Author',
|
243 |
+
'value' => '<code>' . (acf_get_setting('acfe/modules/author', true) ? __('True'): __('False')) . '</code>',
|
244 |
+
'description' => 'Show/hide the Author module. Defaults to true'
|
245 |
+
),
|
246 |
+
array(
|
247 |
+
'name' => 'acfe/modules/categories',
|
248 |
+
'label' => 'Module: Categories',
|
249 |
+
'value' => '<code>' . (acf_get_setting('acfe/modules/categories', true) ? __('True'): __('False')) . '</code>',
|
250 |
+
'description' => 'Enable/disable the Field Group Categories taxonomy. Defaults to true'
|
251 |
+
),
|
252 |
+
array(
|
253 |
+
'name' => 'acfe/modules/dynamic_block_types',
|
254 |
+
'label' => 'Module: Dynamic Block Types',
|
255 |
+
'value' => '<code>' . (acf_get_setting('acfe/modules/dynamic_block_types', true) ? __('True'): __('False')) . '</code>',
|
256 |
+
'description' => 'Show/hide the Block Types module. Defaults to true'
|
257 |
+
),
|
258 |
+
array(
|
259 |
+
'name' => 'acfe/modules/dynamic_forms',
|
260 |
+
'label' => 'Module: Dynamic Forms',
|
261 |
+
'value' => '<code>' . (acf_get_setting('acfe/modules/dynamic_forms', true) ? __('True'): __('False')) . '</code>',
|
262 |
+
'description' => 'Show/hide the Forms module. Defaults to true'
|
263 |
+
),
|
264 |
+
array(
|
265 |
+
'name' => 'acfe/modules/dynamic_post_types',
|
266 |
+
'label' => 'Module: Dynamic Post Types',
|
267 |
+
'value' => '<code>' . (acf_get_setting('acfe/modules/dynamic_post_types', true) ? __('True'): __('False')) . '</code>',
|
268 |
+
'description' => 'Show/hide the Post Types module. Defaults to true'
|
269 |
+
),
|
270 |
+
array(
|
271 |
+
'name' => 'acfe/modules/dynamic_taxonomies',
|
272 |
+
'label' => 'Module: Dynamic Taxonomies',
|
273 |
+
'value' => '<code>' . (acf_get_setting('acfe/modules/dynamic_taxonomies', true) ? __('True'): __('False')) . '</code>',
|
274 |
+
'description' => 'Show/hide the Taxonomies module. Defaults to true'
|
275 |
+
),
|
276 |
+
array(
|
277 |
+
'name' => 'acfe/modules/dynamic_options_pages',
|
278 |
+
'label' => 'Module: Dynamic Options Pages',
|
279 |
+
'value' => '<code>' . (acf_get_setting('acfe/modules/dynamic_options_pages', true) ? __('True'): __('False')) . '</code>',
|
280 |
+
'description' => 'Show/hide the Options Pages module. Defaults to true'
|
281 |
+
),
|
282 |
+
array(
|
283 |
+
'name' => 'acfe/modules/multilang',
|
284 |
+
'label' => 'Module: Multilang',
|
285 |
+
'value' => '<code>' . (acf_get_setting('acfe/modules/multilang', true) ? __('True'): __('False')) . '</code>',
|
286 |
+
'description' => 'Enable/disable Multilang compatibility module for WPML & Polylang. Defaults to true'
|
287 |
+
),
|
288 |
+
array(
|
289 |
+
'name' => 'acfe/modules/options',
|
290 |
+
'label' => 'Module: Options',
|
291 |
+
'value' => '<code>' . (acf_get_setting('acfe/modules/options', true) ? __('True'): __('False')) . '</code>',
|
292 |
+
'description' => 'Show/hide the Options module. Defaults to true'
|
293 |
+
),
|
294 |
+
array(
|
295 |
+
'name' => 'acfe/modules/single_meta',
|
296 |
+
'label' => 'Module: Single Meta',
|
297 |
+
'value' => '<code>' . (acf_get_setting('acfe/modules/single_meta', true) ? __('True'): __('False')) . '</code>',
|
298 |
+
'description' => 'Enable/disable Single Meta Save module. Defaults to false'
|
299 |
+
),
|
300 |
+
array(
|
301 |
+
'name' => 'acfe/modules/ui',
|
302 |
+
'label' => 'Module: UI Enhancements',
|
303 |
+
'value' => '<code>' . (acf_get_setting('acfe/modules/ui', true) ? __('True'): __('False')) . '</code>',
|
304 |
+
'description' => 'Show/hide the UI enhancements module. Defaults to true'
|
305 |
+
),
|
306 |
+
|
307 |
+
// Recaptcha
|
308 |
+
array(
|
309 |
+
'name' => 'acfe/field/recaptcha/site_key',
|
310 |
+
'label' => 'Field: reCaptcha site key',
|
311 |
+
'value' => '<code>' . acf_get_setting('acfe/field/recaptcha/site_key') . '</code>',
|
312 |
+
'description' => 'The default reCaptcha site key'
|
313 |
+
),
|
314 |
+
array(
|
315 |
+
'name' => 'acfe/field/recaptcha/secret_key',
|
316 |
+
'label' => 'Field: reCaptcha secret key',
|
317 |
+
'value' => '<code>' . acf_get_setting('acfe/field/recaptcha/secret_key') . '</code>',
|
318 |
+
'description' => 'The default reCaptcha secret key'
|
319 |
+
),
|
320 |
+
array(
|
321 |
+
'name' => 'acfe/field/recaptcha/version',
|
322 |
+
'label' => 'Field: reCaptcha version',
|
323 |
+
'value' => '<code>' . acf_get_setting('acfe/field/recaptcha/version', 'v2') . '</code>',
|
324 |
+
'description' => 'The default reCaptcha version'
|
325 |
+
),
|
326 |
+
array(
|
327 |
+
'name' => 'acfe/field/recaptcha/v2/theme',
|
328 |
+
'label' => 'Field: reCaptcha v2 theme',
|
329 |
+
'value' => '<code>' . acf_get_setting('acfe/field/recaptcha/v2/theme', 'light') . '</code>',
|
330 |
+
'description' => 'The default reCaptcha v2 theme'
|
331 |
+
),
|
332 |
+
array(
|
333 |
+
'name' => 'acfe/field/recaptcha/v2/size',
|
334 |
+
'label' => 'Field: reCaptcha v2 size',
|
335 |
+
'value' => '<code>' . acf_get_setting('acfe/field/recaptcha/v2/size', 'normal') . '</code>',
|
336 |
+
'description' => 'The default reCaptcha v2 size'
|
337 |
+
),
|
338 |
+
array(
|
339 |
+
'name' => 'acfe/field/recaptcha/v3/hide_logo',
|
340 |
+
'label' => 'Field: reCaptcha v3 hide logo',
|
341 |
+
'value' => '<code>' . acf_get_setting('acfe/field/recaptcha/v3/hide_logo') . '</code>',
|
342 |
+
'description' => 'Show/hide reCaptcha v3 logo'
|
343 |
+
),
|
344 |
+
array(
|
345 |
+
'name' => 'acfe/dev',
|
346 |
+
'label' => 'Dev mode',
|
347 |
+
'value' => '<code>' . (acf_get_setting('acfe/dev') ? __('True'): __('False')) . '</code>',
|
348 |
+
'description' => 'Show/hide the advanced WP post meta box. Defaults to false'
|
349 |
+
),
|
350 |
+
|
351 |
+
// PHP
|
352 |
+
array(
|
353 |
+
'name' => 'acfe/php',
|
354 |
+
'label' => 'PHP',
|
355 |
+
'value' => '<code>' . (acf_get_setting('acfe/php') ? __('True'): __('False')) . '</code>',
|
356 |
+
'description' => 'Whenever PHP AutoSync is enabled'
|
357 |
+
),
|
358 |
+
array(
|
359 |
+
'name' => 'acfe/php_found',
|
360 |
+
'label' => 'PHP: Found',
|
361 |
+
'value' => '<code>' . (acf_get_setting('acfe/php_found') ? __('True'): __('False')) . '</code>',
|
362 |
+
'description' => 'Whenever PHP AutoSync folder has been found, based on acfe/php_load setting'
|
363 |
+
),
|
364 |
+
array(
|
365 |
+
'name' => 'acfe/php_save',
|
366 |
+
'label' => 'PHP: Save',
|
367 |
+
'value' => '<code>' . acf_get_setting('acfe/php_save') . '</code>',
|
368 |
+
'description' => 'PHP AutoSync saving path'
|
369 |
+
),
|
370 |
+
array(
|
371 |
+
'name' => 'acfe/php_load',
|
372 |
+
'label' => 'PHP: Load',
|
373 |
+
'value' => '<code>' . implode("<br />", (array) acf_get_setting('acfe/php_load')) . '</code>',
|
374 |
+
'description' => 'PHP AutoSync loading path'
|
375 |
+
),
|
376 |
+
|
377 |
+
// Json
|
378 |
+
array(
|
379 |
+
'name' => 'acfe/json',
|
380 |
+
'label' => 'Json',
|
381 |
+
'value' => '<code>' . (acf_get_setting('acfe/json') ? __('True'): __('False')) . '</code>',
|
382 |
+
'description' => 'Whenever Json AutoSync is enabled'
|
383 |
+
),
|
384 |
+
array(
|
385 |
+
'name' => 'acfe/json_found',
|
386 |
+
'label' => 'Json: Found',
|
387 |
+
'value' => '<code>' . (acf_get_setting('acfe/json_found') ? __('True'): __('False')) . '</code>',
|
388 |
+
'description' => 'Whenever Json AutoSync folder has been found, based on acfe/json_load setting'
|
389 |
+
),
|
390 |
+
array(
|
391 |
+
'name' => 'acfe/json_save',
|
392 |
+
'label' => 'Json: Save',
|
393 |
+
'value' => '<code>' . acf_get_setting('acfe/json_save') . '</code>',
|
394 |
+
'description' => 'Json AutoSync saving path'
|
395 |
+
),
|
396 |
+
array(
|
397 |
+
'name' => 'acfe/json_load',
|
398 |
+
'label' => 'Json: Load',
|
399 |
+
'value' => '<code>' . implode("<br />", (array) acf_get_setting('acfe/json_load')) . '</code>',
|
400 |
+
'description' => 'Json AutoSync loading paths'
|
401 |
+
),
|
402 |
+
|
403 |
+
// Theme
|
404 |
+
array(
|
405 |
+
'name' => 'acfe/theme_path',
|
406 |
+
'label' => 'Theme: Path',
|
407 |
+
'value' => '<code>' . acf_get_setting('acfe/theme_path') . '</code>',
|
408 |
+
'description' => 'Detected Theme Path'
|
409 |
+
),
|
410 |
+
array(
|
411 |
+
'name' => 'acfe/theme_url',
|
412 |
+
'label' => 'Theme: URL',
|
413 |
+
'value' => '<code>' . acf_get_setting('acfe/theme_url') . '</code>',
|
414 |
+
'description' => 'Detected Theme URL'
|
415 |
+
),
|
416 |
+
array(
|
417 |
+
'name' => 'acfe/theme_folder',
|
418 |
+
'label' => 'Theme: Folder',
|
419 |
+
'value' => '<code>' . acf_get_setting('acfe/theme_folder') . '</code>',
|
420 |
+
'description' => 'Detected Theme Folder'
|
421 |
+
),
|
422 |
+
);
|
423 |
+
?>
|
424 |
+
|
425 |
+
<?php foreach($settings as $setting){ ?>
|
426 |
+
<div class="acf-field">
|
427 |
+
<div class="acf-label">
|
428 |
+
<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>
|
429 |
+
<p class="description"><code><?php echo $setting['name']; ?></code></p>
|
430 |
+
</div>
|
431 |
+
<div class="acf-input">
|
432 |
+
<?php echo $setting['value']; ?>
|
433 |
+
</div>
|
434 |
+
</div>
|
435 |
+
<?php } ?>
|
436 |
+
|
437 |
+
<script type="text/javascript">
|
438 |
+
if( typeof acf !== 'undefined' ) {
|
439 |
+
|
440 |
+
acf.newPostbox({
|
441 |
+
'id': 'acfe-settings',
|
442 |
+
'label': 'left'
|
443 |
+
});
|
444 |
+
|
445 |
+
}
|
446 |
+
</script>
|
447 |
+
</div>
|
448 |
+
</div>
|
449 |
+
</div>
|
450 |
+
|
451 |
+
</div>
|
452 |
+
<?php
|
453 |
}
|
@@ -1,397 +1,397 @@
|
|
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 = acfe_settings('modules.dynamic_block_type.data');
|
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 |
-
// Get settings.
|
132 |
-
$l10n = acf_get_setting('l10n');
|
133 |
-
$l10n_textdomain = acf_get_setting('l10n_textdomain');
|
134 |
-
|
135 |
-
?>
|
136 |
-
<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>
|
137 |
-
|
138 |
-
<div id="acf-admin-tool-export">
|
139 |
-
|
140 |
-
<textarea id="acf-export-textarea" readonly="true"><?php
|
141 |
-
|
142 |
-
echo "if( function_exists('acf_register_block_type') ):" . "\r\n" . "\r\n";
|
143 |
-
|
144 |
-
foreach($this->data as $args){
|
145 |
-
|
146 |
-
// Translate settings if textdomain is set.
|
147 |
-
if($l10n && $l10n_textdomain){
|
148 |
-
|
149 |
-
$args['title'] = acf_translate($args['title']);
|
150 |
-
$args['description'] = acf_translate($args['description']);
|
151 |
-
|
152 |
-
}
|
153 |
-
|
154 |
-
// code
|
155 |
-
$code = var_export($args, true);
|
156 |
-
|
157 |
-
|
158 |
-
// change double spaces to tabs
|
159 |
-
$code = str_replace( array_keys($str_replace), array_values($str_replace), $code );
|
160 |
-
|
161 |
-
|
162 |
-
// correctly formats "=> array("
|
163 |
-
$code = preg_replace( array_keys($preg_replace), array_values($preg_replace), $code );
|
164 |
-
|
165 |
-
|
166 |
-
// esc_textarea
|
167 |
-
$code = esc_textarea( $code );
|
168 |
-
|
169 |
-
|
170 |
-
// echo
|
171 |
-
echo "acf_register_block_type({$code});" . "\r\n" . "\r\n";
|
172 |
-
|
173 |
-
}
|
174 |
-
|
175 |
-
echo "endif;";
|
176 |
-
|
177 |
-
?></textarea>
|
178 |
-
|
179 |
-
</div>
|
180 |
-
|
181 |
-
<p class="acf-submit">
|
182 |
-
<a class="button" id="acf-export-copy"><?php _e( 'Copy to clipboard', 'acf' ); ?></a>
|
183 |
-
</p>
|
184 |
-
<script type="text/javascript">
|
185 |
-
(function($){
|
186 |
-
|
187 |
-
// vars
|
188 |
-
var $a = $('#acf-export-copy');
|
189 |
-
var $textarea = $('#acf-export-textarea');
|
190 |
-
|
191 |
-
|
192 |
-
// remove $a if 'copy' is not supported
|
193 |
-
if( !document.queryCommandSupported('copy') ) {
|
194 |
-
return $a.remove();
|
195 |
-
}
|
196 |
-
|
197 |
-
|
198 |
-
// event
|
199 |
-
$a.on('click', function( e ){
|
200 |
-
|
201 |
-
// prevent default
|
202 |
-
e.preventDefault();
|
203 |
-
|
204 |
-
|
205 |
-
// select
|
206 |
-
$textarea.get(0).select();
|
207 |
-
|
208 |
-
|
209 |
-
// try
|
210 |
-
try {
|
211 |
-
|
212 |
-
// copy
|
213 |
-
var copy = document.execCommand('copy');
|
214 |
-
if( !copy ) return;
|
215 |
-
|
216 |
-
|
217 |
-
// tooltip
|
218 |
-
acf.newTooltip({
|
219 |
-
text: "<?php _e('Copied', 'acf' ); ?>",
|
220 |
-
timeout: 250,
|
221 |
-
target: $(this),
|
222 |
-
});
|
223 |
-
|
224 |
-
} catch (err) {
|
225 |
-
|
226 |
-
// do nothing
|
227 |
-
|
228 |
-
}
|
229 |
-
|
230 |
-
});
|
231 |
-
|
232 |
-
})(jQuery);
|
233 |
-
</script>
|
234 |
-
</div>
|
235 |
-
</div>
|
236 |
-
<?php
|
237 |
-
|
238 |
-
}
|
239 |
-
|
240 |
-
function load(){
|
241 |
-
|
242 |
-
if($this->is_active()){
|
243 |
-
|
244 |
-
$this->action = $this->get_action();
|
245 |
-
$this->data = $this->get_selected();
|
246 |
-
|
247 |
-
// Json submit
|
248 |
-
if($this->action === 'json')
|
249 |
-
$this->submit();
|
250 |
-
|
251 |
-
// add notice
|
252 |
-
if(!empty($this->data)){
|
253 |
-
|
254 |
-
$count = count($this->data);
|
255 |
-
$text = sprintf(_n( 'Exported 1 block type.', 'Exported %s block types.', $count, 'acf' ), $count);
|
256 |
-
|
257 |
-
acf_add_admin_notice($text, 'success');
|
258 |
-
|
259 |
-
}
|
260 |
-
|
261 |
-
}
|
262 |
-
|
263 |
-
}
|
264 |
-
|
265 |
-
function submit(){
|
266 |
-
|
267 |
-
$this->action = $this->get_action();
|
268 |
-
$this->data = $this->get_selected();
|
269 |
-
|
270 |
-
// validate
|
271 |
-
if($this->data === false)
|
272 |
-
return acf_add_admin_notice(__('No block types selected'), 'warning');
|
273 |
-
|
274 |
-
$keys = array();
|
275 |
-
foreach($this->data as $key => $args){
|
276 |
-
|
277 |
-
$keys[] = $key;
|
278 |
-
|
279 |
-
}
|
280 |
-
|
281 |
-
if($this->action === 'json'){
|
282 |
-
|
283 |
-
// Prefix
|
284 |
-
$prefix = (count($keys) > 1) ? 'block-types' : 'block-type';
|
285 |
-
|
286 |
-
// Slugs
|
287 |
-
$slugs = implode('-', $keys);
|
288 |
-
|
289 |
-
// Date
|
290 |
-
$date = date('Y-m-d');
|
291 |
-
|
292 |
-
// file
|
293 |
-
$file_name = 'acfe-export-' . $prefix . '-' . $slugs . '-' . $date . '.json';
|
294 |
-
|
295 |
-
// headers
|
296 |
-
header("Content-Description: File Transfer");
|
297 |
-
header("Content-Disposition: attachment; filename={$file_name}");
|
298 |
-
header("Content-Type: application/json; charset=utf-8");
|
299 |
-
|
300 |
-
// return
|
301 |
-
echo acf_json_encode($this->data);
|
302 |
-
die;
|
303 |
-
|
304 |
-
}
|
305 |
-
|
306 |
-
elseif($this->action === 'php'){
|
307 |
-
|
308 |
-
// url
|
309 |
-
$url = add_query_arg(array(
|
310 |
-
'keys' => implode('+', $keys),
|
311 |
-
'action' => 'php'
|
312 |
-
), $this->get_url());
|
313 |
-
|
314 |
-
// redirect
|
315 |
-
wp_redirect($url);
|
316 |
-
exit;
|
317 |
-
|
318 |
-
}
|
319 |
-
|
320 |
-
}
|
321 |
-
|
322 |
-
function get_selected(){
|
323 |
-
|
324 |
-
// vars
|
325 |
-
$selected = $this->get_selected_keys();
|
326 |
-
|
327 |
-
if(!$selected)
|
328 |
-
return false;
|
329 |
-
|
330 |
-
$dynamic_block_types = acfe_settings('modules.dynamic_block_type.data');
|
331 |
-
|
332 |
-
if(empty($dynamic_block_types))
|
333 |
-
return false;
|
334 |
-
|
335 |
-
$data = array();
|
336 |
-
|
337 |
-
// construct data
|
338 |
-
foreach($selected as $key){
|
339 |
-
|
340 |
-
if(!isset($dynamic_block_types[$key]))
|
341 |
-
continue;
|
342 |
-
|
343 |
-
// add to data array
|
344 |
-
$data[$key] = $dynamic_block_types[$key];
|
345 |
-
|
346 |
-
}
|
347 |
-
|
348 |
-
// return
|
349 |
-
return $data;
|
350 |
-
|
351 |
-
}
|
352 |
-
|
353 |
-
function get_selected_keys(){
|
354 |
-
|
355 |
-
// check $_POST
|
356 |
-
if($keys = acf_maybe_get_POST('keys')){
|
357 |
-
|
358 |
-
return (array) $keys;
|
359 |
-
|
360 |
-
}
|
361 |
-
|
362 |
-
// check $_GET
|
363 |
-
if($keys = acf_maybe_get_GET('keys')){
|
364 |
-
|
365 |
-
$keys = str_replace(' ', '+', $keys);
|
366 |
-
return explode('+', $keys);
|
367 |
-
|
368 |
-
}
|
369 |
-
|
370 |
-
// return
|
371 |
-
return false;
|
372 |
-
|
373 |
-
}
|
374 |
-
|
375 |
-
function get_action(){
|
376 |
-
|
377 |
-
// init
|
378 |
-
$type = 'json';
|
379 |
-
|
380 |
-
// check GET / POST
|
381 |
-
if(($action = acf_maybe_get_GET('action')) || ($action = acf_maybe_get_POST('action'))){
|
382 |
-
|
383 |
-
if(in_array($action, array('json', 'php')))
|
384 |
-
$type = $action;
|
385 |
-
|
386 |
-
}
|
387 |
-
|
388 |
-
// return
|
389 |
-
return $type;
|
390 |
-
|
391 |
-
}
|
392 |
-
|
393 |
-
}
|
394 |
-
|
395 |
-
acf_register_admin_tool('ACFE_Admin_Tool_Export_DBT');
|
396 |
-
|
397 |
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 = acfe_settings('modules.dynamic_block_type.data');
|
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 |
+
// Get settings.
|
132 |
+
$l10n = acf_get_setting('l10n');
|
133 |
+
$l10n_textdomain = acf_get_setting('l10n_textdomain');
|
134 |
+
|
135 |
+
?>
|
136 |
+
<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>
|
137 |
+
|
138 |
+
<div id="acf-admin-tool-export">
|
139 |
+
|
140 |
+
<textarea id="acf-export-textarea" readonly="true"><?php
|
141 |
+
|
142 |
+
echo "if( function_exists('acf_register_block_type') ):" . "\r\n" . "\r\n";
|
143 |
+
|
144 |
+
foreach($this->data as $args){
|
145 |
+
|
146 |
+
// Translate settings if textdomain is set.
|
147 |
+
if($l10n && $l10n_textdomain){
|
148 |
+
|
149 |
+
$args['title'] = acf_translate($args['title']);
|
150 |
+
$args['description'] = acf_translate($args['description']);
|
151 |
+
|
152 |
+
}
|
153 |
+
|
154 |
+
// code
|
155 |
+
$code = var_export($args, true);
|
156 |
+
|
157 |
+
|
158 |
+
// change double spaces to tabs
|
159 |
+
$code = str_replace( array_keys($str_replace), array_values($str_replace), $code );
|
160 |
+
|
161 |
+
|
162 |
+
// correctly formats "=> array("
|
163 |
+
$code = preg_replace( array_keys($preg_replace), array_values($preg_replace), $code );
|
164 |
+
|
165 |
+
|
166 |
+
// esc_textarea
|
167 |
+
$code = esc_textarea( $code );
|
168 |
+
|
169 |
+
|
170 |
+
// echo
|
171 |
+
echo "acf_register_block_type({$code});" . "\r\n" . "\r\n";
|
172 |
+
|
173 |
+
}
|
174 |
+
|
175 |
+
echo "endif;";
|
176 |
+
|
177 |
+
?></textarea>
|
178 |
+
|
179 |
+
</div>
|
180 |
+
|
181 |
+
<p class="acf-submit">
|
182 |
+
<a class="button" id="acf-export-copy"><?php _e( 'Copy to clipboard', 'acf' ); ?></a>
|
183 |
+
</p>
|
184 |
+
<script type="text/javascript">
|
185 |
+
(function($){
|
186 |
+
|
187 |
+
// vars
|
188 |
+
var $a = $('#acf-export-copy');
|
189 |
+
var $textarea = $('#acf-export-textarea');
|
190 |
+
|
191 |
+
|
192 |
+
// remove $a if 'copy' is not supported
|
193 |
+
if( !document.queryCommandSupported('copy') ) {
|
194 |
+
return $a.remove();
|
195 |
+
}
|
196 |
+
|
197 |
+
|
198 |
+
// event
|
199 |
+
$a.on('click', function( e ){
|
200 |
+
|
201 |
+
// prevent default
|
202 |
+
e.preventDefault();
|
203 |
+
|
204 |
+
|
205 |
+
// select
|
206 |
+
$textarea.get(0).select();
|
207 |
+
|
208 |
+
|
209 |
+
// try
|
210 |
+
try {
|
211 |
+
|
212 |
+
// copy
|
213 |
+
var copy = document.execCommand('copy');
|
214 |
+
if( !copy ) return;
|
215 |
+
|
216 |
+
|
217 |
+
// tooltip
|
218 |
+
acf.newTooltip({
|
219 |
+
text: "<?php _e('Copied', 'acf' ); ?>",
|
220 |
+
timeout: 250,
|
221 |
+
target: $(this),
|
222 |
+
});
|
223 |
+
|
224 |
+
} catch (err) {
|
225 |
+
|
226 |
+
// do nothing
|
227 |
+
|
228 |
+
}
|
229 |
+
|
230 |
+
});
|
231 |
+
|
232 |
+
})(jQuery);
|
233 |
+
</script>
|
234 |
+
</div>
|
235 |
+
</div>
|
236 |
+
<?php
|
237 |
+
|
238 |
+
}
|
239 |
+
|
240 |
+
function load(){
|
241 |
+
|
242 |
+
if($this->is_active()){
|
243 |
+
|
244 |
+
$this->action = $this->get_action();
|
245 |
+
$this->data = $this->get_selected();
|
246 |
+
|
247 |
+
// Json submit
|
248 |
+
if($this->action === 'json')
|
249 |
+
$this->submit();
|
250 |
+
|
251 |
+
// add notice
|
252 |
+
if(!empty($this->data)){
|
253 |
+
|
254 |
+
$count = count($this->data);
|
255 |
+
$text = sprintf(_n( 'Exported 1 block type.', 'Exported %s block types.', $count, 'acf' ), $count);
|
256 |
+
|
257 |
+
acf_add_admin_notice($text, 'success');
|
258 |
+
|
259 |
+
}
|
260 |
+
|
261 |
+
}
|
262 |
+
|
263 |
+
}
|
264 |
+
|
265 |
+
function submit(){
|
266 |
+
|
267 |
+
$this->action = $this->get_action();
|
268 |
+
$this->data = $this->get_selected();
|
269 |
+
|
270 |
+
// validate
|
271 |
+
if($this->data === false)
|
272 |
+
return acf_add_admin_notice(__('No block types selected'), 'warning');
|
273 |
+
|
274 |
+
$keys = array();
|
275 |
+
foreach($this->data as $key => $args){
|
276 |
+
|
277 |
+
$keys[] = $key;
|
278 |
+
|
279 |
+
}
|
280 |
+
|
281 |
+
if($this->action === 'json'){
|
282 |
+
|
283 |
+
// Prefix
|
284 |
+
$prefix = (count($keys) > 1) ? 'block-types' : 'block-type';
|
285 |
+
|
286 |
+
// Slugs
|
287 |
+
$slugs = implode('-', $keys);
|
288 |
+
|
289 |
+
// Date
|
290 |
+
$date = date('Y-m-d');
|
291 |
+
|
292 |
+
// file
|
293 |
+
$file_name = 'acfe-export-' . $prefix . '-' . $slugs . '-' . $date . '.json';
|
294 |
+
|
295 |
+
// headers
|
296 |
+
header("Content-Description: File Transfer");
|
297 |
+
header("Content-Disposition: attachment; filename={$file_name}");
|
298 |
+
header("Content-Type: application/json; charset=utf-8");
|
299 |
+
|
300 |
+
// return
|
301 |
+
echo acf_json_encode($this->data);
|
302 |
+
die;
|
303 |
+
|
304 |
+
}
|
305 |
+
|
306 |
+
elseif($this->action === 'php'){
|
307 |
+
|
308 |
+
// url
|
309 |
+
$url = add_query_arg(array(
|
310 |
+
'keys' => implode('+', $keys),
|
311 |
+
'action' => 'php'
|
312 |
+
), $this->get_url());
|
313 |
+
|
314 |
+
// redirect
|
315 |
+
wp_redirect($url);
|
316 |
+
exit;
|
317 |
+
|
318 |
+
}
|
319 |
+
|
320 |
+
}
|
321 |
+
|
322 |
+
function get_selected(){
|
323 |
+
|
324 |
+
// vars
|
325 |
+
$selected = $this->get_selected_keys();
|
326 |
+
|
327 |
+
if(!$selected)
|
328 |
+
return false;
|
329 |
+
|
330 |
+
$dynamic_block_types = acfe_settings('modules.dynamic_block_type.data');
|
331 |
+
|
332 |
+
if(empty($dynamic_block_types))
|
333 |
+
return false;
|
334 |
+
|
335 |
+
$data = array();
|
336 |
+
|
337 |
+
// construct data
|
338 |
+
foreach($selected as $key){
|
339 |
+
|
340 |
+
if(!isset($dynamic_block_types[$key]))
|
341 |
+
continue;
|
342 |
+
|
343 |
+
// add to data array
|
344 |
+
$data[$key] = $dynamic_block_types[$key];
|
345 |
+
|
346 |
+
}
|
347 |
+
|
348 |
+
// return
|
349 |
+
return $data;
|
350 |
+
|
351 |
+
}
|
352 |
+
|
353 |
+
function get_selected_keys(){
|
354 |
+
|
355 |
+
// check $_POST
|
356 |
+
if($keys = acf_maybe_get_POST('keys')){
|
357 |
+
|
358 |
+
return (array) $keys;
|
359 |
+
|
360 |
+
}
|
361 |
+
|
362 |
+
// check $_GET
|
363 |
+
if($keys = acf_maybe_get_GET('keys')){
|
364 |
+
|
365 |
+
$keys = str_replace(' ', '+', $keys);
|
366 |
+
return explode('+', $keys);
|
367 |
+
|
368 |
+
}
|
369 |
+
|
370 |
+
// return
|
371 |
+
return false;
|
372 |
+
|
373 |
+
}
|
374 |
+
|
375 |
+
function get_action(){
|
376 |
+
|
377 |
+
// init
|
378 |
+
$type = 'json';
|
379 |
+
|
380 |
+
// check GET / POST
|
381 |
+
if(($action = acf_maybe_get_GET('action')) || ($action = acf_maybe_get_POST('action'))){
|
382 |
+
|
383 |
+
if(in_array($action, array('json', 'php')))
|
384 |
+
$type = $action;
|
385 |
+
|
386 |
+
}
|
387 |
+
|
388 |
+
// return
|
389 |
+
return $type;
|
390 |
+
|
391 |
+
}
|
392 |
+
|
393 |
+
}
|
394 |
+
|
395 |
+
acf_register_admin_tool('ACFE_Admin_Tool_Export_DBT');
|
396 |
+
|
397 |
endif;
|
@@ -1,209 +1,209 @@
|
|
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_Import_DBT')):
|
11 |
-
|
12 |
-
class ACFE_Admin_Tool_Import_DBT extends ACF_Admin_Tool{
|
13 |
-
|
14 |
-
function initialize(){
|
15 |
-
|
16 |
-
// vars
|
17 |
-
$this->name = 'acfe_tool_dbt_import';
|
18 |
-
$this->title = __('Import Block Types');
|
19 |
-
$this->icon = 'dashicons-upload';
|
20 |
-
|
21 |
-
}
|
22 |
-
|
23 |
-
function html(){
|
24 |
-
|
25 |
-
?>
|
26 |
-
<p><?php _e('Import Block Types', '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 |
-
$dynamic_block_types = acfe_settings('modules.dynamic_block_type.data');
|
77 |
-
|
78 |
-
// Loop over json
|
79 |
-
foreach($json as $block_type_name => $args){
|
80 |
-
|
81 |
-
// Check if already exists
|
82 |
-
if(isset($dynamic_block_types[$block_type_name])){
|
83 |
-
|
84 |
-
acf_add_admin_notice(__("Block type {$dynamic_block_types[$block_type_name]['title']} already exists. Import aborted."), 'warning');
|
85 |
-
continue;
|
86 |
-
|
87 |
-
}
|
88 |
-
|
89 |
-
// Vars
|
90 |
-
$title = $args['title'];
|
91 |
-
$name = $block_type_name;
|
92 |
-
|
93 |
-
// Insert post
|
94 |
-
$post_id = wp_insert_post(array(
|
95 |
-
'post_title' => $title,
|
96 |
-
'post_name' => $name,
|
97 |
-
'post_type' => 'acfe-dbt',
|
98 |
-
'post_status' => 'publish'
|
99 |
-
));
|
100 |
-
|
101 |
-
// Insert error
|
102 |
-
if(is_wp_error($post_id)){
|
103 |
-
|
104 |
-
acf_add_admin_notice(__("Something went wrong with the block type {$title}. Import aborted."), 'warning');
|
105 |
-
continue;
|
106 |
-
|
107 |
-
}
|
108 |
-
|
109 |
-
// Register Args
|
110 |
-
update_field('name', $name, $post_id);
|
111 |
-
update_field('description', $args['description'], $post_id);
|
112 |
-
update_field('category', $args['category'], $post_id);
|
113 |
-
update_field('keywords', acf_encode_choices($args['keywords'], false), $post_id);
|
114 |
-
update_field('post_types', $args['post_types'], $post_id);
|
115 |
-
update_field('mode', $args['mode'], $post_id);
|
116 |
-
update_field('align', $args['align'], $post_id);
|
117 |
-
update_field('render_callback', $args['render_callback'], $post_id);
|
118 |
-
update_field('enqueue_assets', $args['enqueue_assets'], $post_id);
|
119 |
-
update_field('render_template', $args['render_template'], $post_id);
|
120 |
-
update_field('enqueue_style', $args['enqueue_style'], $post_id);
|
121 |
-
update_field('enqueue_script', $args['enqueue_script'], $post_id);
|
122 |
-
|
123 |
-
// Align
|
124 |
-
if(empty($args['align']))
|
125 |
-
update_field('align', 'none', $post_id);
|
126 |
-
|
127 |
-
// Icon
|
128 |
-
if(!empty($args['icon'])){
|
129 |
-
|
130 |
-
// Simple
|
131 |
-
if(is_string($args['icon'])){
|
132 |
-
|
133 |
-
update_field('icon_type', 'simple', $post_id);
|
134 |
-
|
135 |
-
update_field('icon_text', $args['icon'], $post_id);
|
136 |
-
|
137 |
-
}
|
138 |
-
|
139 |
-
// Colors
|
140 |
-
elseif(is_array($args['icon'])){
|
141 |
-
|
142 |
-
update_field('icon_type', 'colors', $post_id);
|
143 |
-
|
144 |
-
update_field('icon_background', $args['icon']['background'], $post_id);
|
145 |
-
update_field('icon_foreground', $args['icon']['foreground'], $post_id);
|
146 |
-
update_field('icon_src', $args['icon']['src'], $post_id);
|
147 |
-
|
148 |
-
}
|
149 |
-
|
150 |
-
}
|
151 |
-
|
152 |
-
// Supports: Align
|
153 |
-
update_field('supports_align', $args['supports']['align'], $post_id);
|
154 |
-
|
155 |
-
if(is_array($args['supports']['align'])){
|
156 |
-
|
157 |
-
update_field('supports_align_args', acf_encode_choices($args['supports']['align'], false), $post_id);
|
158 |
-
|
159 |
-
}
|
160 |
-
|
161 |
-
// Supports: Mode
|
162 |
-
update_field('supports_mode', $args['supports']['mode'], $post_id);
|
163 |
-
|
164 |
-
// Supports: Multiple
|
165 |
-
update_field('supports_multiple', $args['supports']['multiple'], $post_id);
|
166 |
-
|
167 |
-
// Create ACFE option
|
168 |
-
$dynamic_block_types[$block_type_name] = $args;
|
169 |
-
|
170 |
-
// Sort keys ASC
|
171 |
-
ksort($dynamic_block_types);
|
172 |
-
|
173 |
-
// Update ACFE option
|
174 |
-
acfe_settings('modules.dynamic_block_type.data', $dynamic_block_types, true);
|
175 |
-
|
176 |
-
// append message
|
177 |
-
$ids[] = $post_id;
|
178 |
-
|
179 |
-
}
|
180 |
-
|
181 |
-
if(empty($ids))
|
182 |
-
return;
|
183 |
-
|
184 |
-
// Count total
|
185 |
-
$total = count($ids);
|
186 |
-
|
187 |
-
// Generate text
|
188 |
-
$text = sprintf(_n('1 block type imported', '%s block types imported', $total, 'acf'), $total);
|
189 |
-
|
190 |
-
// Add links to text
|
191 |
-
$links = array();
|
192 |
-
foreach($ids as $id){
|
193 |
-
|
194 |
-
$links[] = '<a href="' . get_edit_post_link($id) . '">' . get_the_title($id) . '</a>';
|
195 |
-
|
196 |
-
}
|
197 |
-
|
198 |
-
$text .= ': ' . implode(', ', $links);
|
199 |
-
|
200 |
-
// Add notice
|
201 |
-
acf_add_admin_notice($text, 'success');
|
202 |
-
|
203 |
-
}
|
204 |
-
|
205 |
-
}
|
206 |
-
|
207 |
-
acf_register_admin_tool('ACFE_Admin_Tool_Import_DBT');
|
208 |
-
|
209 |
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_Import_DBT')):
|
11 |
+
|
12 |
+
class ACFE_Admin_Tool_Import_DBT extends ACF_Admin_Tool{
|
13 |
+
|
14 |
+
function initialize(){
|
15 |
+
|
16 |
+
// vars
|
17 |
+
$this->name = 'acfe_tool_dbt_import';
|
18 |
+
$this->title = __('Import Block Types');
|
19 |
+
$this->icon = 'dashicons-upload';
|
20 |
+
|
21 |
+
}
|
22 |
+
|
23 |
+
function html(){
|
24 |
+
|
25 |
+
?>
|
26 |
+
<p><?php _e('Import Block Types', '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 |
+
$dynamic_block_types = acfe_settings('modules.dynamic_block_type.data');
|
77 |
+
|
78 |
+
// Loop over json
|
79 |
+
foreach($json as $block_type_name => $args){
|
80 |
+
|
81 |
+
// Check if already exists
|
82 |
+
if(isset($dynamic_block_types[$block_type_name])){
|
83 |
+
|
84 |
+
acf_add_admin_notice(__("Block type {$dynamic_block_types[$block_type_name]['title']} already exists. Import aborted."), 'warning');
|
85 |
+
continue;
|
86 |
+
|
87 |
+
}
|
88 |
+
|
89 |
+
// Vars
|
90 |
+
$title = $args['title'];
|
91 |
+
$name = $block_type_name;
|
92 |
+
|
93 |
+
// Insert post
|
94 |
+
$post_id = wp_insert_post(array(
|
95 |
+
'post_title' => $title,
|
96 |
+
'post_name' => $name,
|
97 |
+
'post_type' => 'acfe-dbt',
|
98 |
+
'post_status' => 'publish'
|
99 |
+
));
|
100 |
+
|
101 |
+
// Insert error
|
102 |
+
if(is_wp_error($post_id)){
|
103 |
+
|
104 |
+
acf_add_admin_notice(__("Something went wrong with the block type {$title}. Import aborted."), 'warning');
|
105 |
+
continue;
|
106 |
+
|
107 |
+
}
|
108 |
+
|
109 |
+
// Register Args
|
110 |
+
update_field('name', $name, $post_id);
|
111 |
+
update_field('description', $args['description'], $post_id);
|
112 |
+
update_field('category', $args['category'], $post_id);
|
113 |
+
update_field('keywords', acf_encode_choices($args['keywords'], false), $post_id);
|
114 |
+
update_field('post_types', $args['post_types'], $post_id);
|
115 |
+
update_field('mode', $args['mode'], $post_id);
|
116 |
+
update_field('align', $args['align'], $post_id);
|
117 |
+
update_field('render_callback', $args['render_callback'], $post_id);
|
118 |
+
update_field('enqueue_assets', $args['enqueue_assets'], $post_id);
|
119 |
+
update_field('render_template', $args['render_template'], $post_id);
|
120 |
+
update_field('enqueue_style', $args['enqueue_style'], $post_id);
|
121 |
+
update_field('enqueue_script', $args['enqueue_script'], $post_id);
|
122 |
+
|
123 |
+
// Align
|
124 |
+
if(empty($args['align']))
|
125 |
+
update_field('align', 'none', $post_id);
|
126 |
+
|
127 |
+
// Icon
|
128 |
+
if(!empty($args['icon'])){
|
129 |
+
|
130 |
+
// Simple
|
131 |
+
if(is_string($args['icon'])){
|
132 |
+
|
133 |
+
update_field('icon_type', 'simple', $post_id);
|
134 |
+
|
135 |
+
update_field('icon_text', $args['icon'], $post_id);
|
136 |
+
|
137 |
+
}
|
138 |
+
|
139 |
+
// Colors
|
140 |
+
elseif(is_array($args['icon'])){
|
141 |
+
|
142 |
+
update_field('icon_type', 'colors', $post_id);
|
143 |
+
|
144 |
+
update_field('icon_background', $args['icon']['background'], $post_id);
|
145 |
+
update_field('icon_foreground', $args['icon']['foreground'], $post_id);
|
146 |
+
update_field('icon_src', $args['icon']['src'], $post_id);
|
147 |
+
|
148 |
+
}
|
149 |
+
|
150 |
+
}
|
151 |
+
|
152 |
+
// Supports: Align
|
153 |
+
update_field('supports_align', $args['supports']['align'], $post_id);
|
154 |
+
|
155 |
+
if(is_array($args['supports']['align'])){
|
156 |
+
|
157 |
+
update_field('supports_align_args', acf_encode_choices($args['supports']['align'], false), $post_id);
|
158 |
+
|
159 |
+
}
|
160 |
+
|
161 |
+
// Supports: Mode
|
162 |
+
update_field('supports_mode', $args['supports']['mode'], $post_id);
|
163 |
+
|
164 |
+
// Supports: Multiple
|
165 |
+
update_field('supports_multiple', $args['supports']['multiple'], $post_id);
|
166 |
+
|
167 |
+
// Create ACFE option
|
168 |
+
$dynamic_block_types[$block_type_name] = $args;
|
169 |
+
|
170 |
+
// Sort keys ASC
|
171 |
+
ksort($dynamic_block_types);
|
172 |
+
|
173 |
+
// Update ACFE option
|
174 |
+
acfe_settings('modules.dynamic_block_type.data', $dynamic_block_types, true);
|
175 |
+
|
176 |
+
// append message
|
177 |
+
$ids[] = $post_id;
|
178 |
+
|
179 |
+
}
|
180 |
+
|
181 |
+
if(empty($ids))
|
182 |
+
return;
|
183 |
+
|
184 |
+
// Count total
|
185 |
+
$total = count($ids);
|
186 |
+
|
187 |
+
// Generate text
|
188 |
+
$text = sprintf(_n('1 block type imported', '%s block types imported', $total, 'acf'), $total);
|
189 |
+
|
190 |
+
// Add links to text
|
191 |
+
$links = array();
|
192 |
+
foreach($ids as $id){
|
193 |
+
|
194 |
+
$links[] = '<a href="' . get_edit_post_link($id) . '">' . get_the_title($id) . '</a>';
|
195 |
+
|
196 |
+
}
|
197 |
+
|
198 |
+
$text .= ': ' . implode(', ', $links);
|
199 |
+
|
200 |
+
// Add notice
|
201 |
+
acf_add_admin_notice($text, 'success');
|
202 |
+
|
203 |
+
}
|
204 |
+
|
205 |
+
}
|
206 |
+
|
207 |
+
acf_register_admin_tool('ACFE_Admin_Tool_Import_DBT');
|
208 |
+
|
209 |
endif;
|
@@ -1,395 +1,395 @@
|
|
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 = acfe_settings('modules.dynamic_option.data');
|
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 |
-
// Get settings.
|
130 |
-
$l10n = acf_get_setting('l10n');
|
131 |
-
$l10n_textdomain = acf_get_setting('l10n_textdomain');
|
132 |
-
|
133 |
-
?>
|
134 |
-
<p><?php _e("The following code can be used to register an options page. Simply copy and paste the following code to your theme's functions.php file or include it within an external file.", 'acf'); ?></p>
|
135 |
-
|
136 |
-
<div id="acf-admin-tool-export">
|
137 |
-
|
138 |
-
<textarea id="acf-export-textarea" readonly="true"><?php
|
139 |
-
|
140 |
-
echo "if( function_exists('acf_add_options_page') ):" . "\r\n" . "\r\n";
|
141 |
-
|
142 |
-
foreach($this->data as $args){
|
143 |
-
|
144 |
-
// Translate settings if textdomain is set.
|
145 |
-
if($l10n && $l10n_textdomain){
|
146 |
-
|
147 |
-
$args['page_title'] = acf_translate($args['page_title']);
|
148 |
-
$args['menu_title'] = acf_translate($args['menu_title']);
|
149 |
-
$args['update_button'] = acf_translate($args['update_button']);
|
150 |
-
$args['updated_message'] = acf_translate($args['updated_message']);
|
151 |
-
|
152 |
-
}
|
153 |
-
|
154 |
-
// code
|
155 |
-
$code = var_export($args, true);
|
156 |
-
|
157 |
-
|
158 |
-
// change double spaces to tabs
|
159 |
-
$code = str_replace( array_keys($str_replace), array_values($str_replace), $code );
|
160 |
-
|
161 |
-
|
162 |
-
// correctly formats "=> array("
|
163 |
-
$code = preg_replace( array_keys($preg_replace), array_values($preg_replace), $code );
|
164 |
-
|
165 |
-
|
166 |
-
// esc_textarea
|
167 |
-
$code = esc_textarea( $code );
|
168 |
-
|
169 |
-
|
170 |
-
// echo
|
171 |
-
echo "acf_add_options_page({$code});" . "\r\n" . "\r\n";
|
172 |
-
|
173 |
-
}
|
174 |
-
|
175 |
-
echo "endif;";
|
176 |
-
|
177 |
-
?></textarea>
|
178 |
-
|
179 |
-
</div>
|
180 |
-
|
181 |
-
<p class="acf-submit">
|
182 |
-
<a class="button" id="acf-export-copy"><?php _e( 'Copy to clipboard', 'acf' ); ?></a>
|
183 |
-
</p>
|
184 |
-
<script type="text/javascript">
|
185 |
-
(function($){
|
186 |
-
|
187 |
-
// vars
|
188 |
-
var $a = $('#acf-export-copy');
|
189 |
-
var $textarea = $('#acf-export-textarea');
|
190 |
-
|
191 |
-
|
192 |
-
// remove $a if 'copy' is not supported
|
193 |
-
if( !document.queryCommandSupported('copy') ) {
|
194 |
-
return $a.remove();
|
195 |
-
}
|
196 |
-
|
197 |
-
|
198 |
-
// event
|
199 |
-
$a.on('click', function( e ){
|
200 |
-
|
201 |
-
// prevent default
|
202 |
-
e.preventDefault();
|
203 |
-
|
204 |
-
|
205 |
-
// select
|
206 |
-
$textarea.get(0).select();
|
207 |
-
|
208 |
-
|
209 |
-
// try
|
210 |
-
try {
|
211 |
-
|
212 |
-
// copy
|
213 |
-
var copy = document.execCommand('copy');
|
214 |
-
if( !copy ) return;
|
215 |
-
|
216 |
-
|
217 |
-
// tooltip
|
218 |
-
acf.newTooltip({
|
219 |
-
text: "<?php _e('Copied', 'acf' ); ?>",
|
220 |
-
timeout: 250,
|
221 |
-
target: $(this),
|
222 |
-
});
|
223 |
-
|
224 |
-
} catch (err) {
|
225 |
-
|
226 |
-
// do nothing
|
227 |
-
|
228 |
-
}
|
229 |
-
|
230 |
-
});
|
231 |
-
|
232 |
-
})(jQuery);
|
233 |
-
</script>
|
234 |
-
</div>
|
235 |
-
</div>
|
236 |
-
<?php
|
237 |
-
|
238 |
-
}
|
239 |
-
|
240 |
-
function load(){
|
241 |
-
|
242 |
-
if($this->is_active()){
|
243 |
-
|
244 |
-
$this->action = $this->get_action();
|
245 |
-
$this->data = $this->get_selected();
|
246 |
-
|
247 |
-
// Json submit
|
248 |
-
if($this->action === 'json')
|
249 |
-
$this->submit();
|
250 |
-
|
251 |
-
// add notice
|
252 |
-
if(!empty($this->data)){
|
253 |
-
|
254 |
-
$count = count($this->data);
|
255 |
-
$text = sprintf(_n( 'Exported 1 option page.', 'Exported %s option pages.', $count, 'acf' ), $count);
|
256 |
-
|
257 |
-
acf_add_admin_notice($text, 'success');
|
258 |
-
|
259 |
-
}
|
260 |
-
|
261 |
-
}
|
262 |
-
|
263 |
-
}
|
264 |
-
|
265 |
-
function submit(){
|
266 |
-
|
267 |
-
$this->action = $this->get_action();
|
268 |
-
$this->data = $this->get_selected();
|
269 |
-
|
270 |
-
// validate
|
271 |
-
if($this->data === false)
|
272 |
-
return acf_add_admin_notice(__('No options page selected'), 'warning');
|
273 |
-
|
274 |
-
$keys = array();
|
275 |
-
foreach($this->data as $key => $args){
|
276 |
-
|
277 |
-
$keys[] = $key;
|
278 |
-
|
279 |
-
}
|
280 |
-
|
281 |
-
if($this->action === 'json'){
|
282 |
-
|
283 |
-
// Prefix
|
284 |
-
$prefix = (count($keys) > 1) ? 'options-pages' : 'options-page';
|
285 |
-
|
286 |
-
// Slugs
|
287 |
-
$slugs = implode('-', $keys);
|
288 |
-
|
289 |
-
// Date
|
290 |
-
$date = date('Y-m-d');
|
291 |
-
|
292 |
-
// file
|
293 |
-
$file_name = 'acfe-export-' . $prefix . '-' . $slugs . '-' . $date . '.json';
|
294 |
-
|
295 |
-
// headers
|
296 |
-
header("Content-Description: File Transfer");
|
297 |
-
header("Content-Disposition: attachment; filename={$file_name}");
|
298 |
-
header("Content-Type: application/json; charset=utf-8");
|
299 |
-
|
300 |
-
// return
|
301 |
-
echo acf_json_encode($this->data);
|
302 |
-
die;
|
303 |
-
|
304 |
-
}
|
305 |
-
|
306 |
-
elseif($this->action === 'php'){
|
307 |
-
|
308 |
-
// url
|
309 |
-
$url = add_query_arg(array(
|
310 |
-
'keys' => implode('+', $keys),
|
311 |
-
'action' => 'php'
|
312 |
-
), $this->get_url());
|
313 |
-
|
314 |
-
// redirect
|
315 |
-
wp_redirect($url);
|
316 |
-
exit;
|
317 |
-
|
318 |
-
}
|
319 |
-
|
320 |
-
}
|
321 |
-
|
322 |
-
function get_selected(){
|
323 |
-
|
324 |
-
// vars
|
325 |
-
$selected = $this->get_selected_keys();
|
326 |
-
$data = array();
|
327 |
-
|
328 |
-
if(!$selected)
|
329 |
-
return false;
|
330 |
-
$dynamic_options_pages = acfe_settings('modules.dynamic_option.data');
|
331 |
-
|
332 |
-
if(empty($dynamic_options_pages))
|
333 |
-
return false;
|
334 |
-
|
335 |
-
// construct data
|
336 |
-
foreach($selected as $key){
|
337 |
-
|
338 |
-
if(!isset($dynamic_options_pages[$key]))
|
339 |
-
continue;
|
340 |
-
|
341 |
-
// add to data array
|
342 |
-
$data[$key] = $dynamic_options_pages[$key];
|
343 |
-
|
344 |
-
}
|
345 |
-
|
346 |
-
// return
|
347 |
-
return $data;
|
348 |
-
|
349 |
-
}
|
350 |
-
|
351 |
-
function get_selected_keys(){
|
352 |
-
|
353 |
-
// check $_POST
|
354 |
-
if($keys = acf_maybe_get_POST('keys')){
|
355 |
-
|
356 |
-
return (array) $keys;
|
357 |
-
|
358 |
-
}
|
359 |
-
|
360 |
-
// check $_GET
|
361 |
-
if($keys = acf_maybe_get_GET('keys')){
|
362 |
-
|
363 |
-
$keys = str_replace(' ', '+', $keys);
|
364 |
-
return explode('+', $keys);
|
365 |
-
|
366 |
-
}
|
367 |
-
|
368 |
-
// return
|
369 |
-
return false;
|
370 |
-
|
371 |
-
}
|
372 |
-
|
373 |
-
function get_action(){
|
374 |
-
|
375 |
-
// init
|
376 |
-
$type = 'json';
|
377 |
-
|
378 |
-
// check GET / POST
|
379 |
-
if(($action = acf_maybe_get_GET('action')) || ($action = acf_maybe_get_POST('action'))){
|
380 |
-
|
381 |
-
if(in_array($action, array('json', 'php')))
|
382 |
-
$type = $action;
|
383 |
-
|
384 |
-
}
|
385 |
-
|
386 |
-
// return
|
387 |
-
return $type;
|
388 |
-
|
389 |
-
}
|
390 |
-
|
391 |
-
}
|
392 |
-
|
393 |
-
acf_register_admin_tool('ACFE_Admin_Tool_Export_DOP');
|
394 |
-
|
395 |
-
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 = acfe_settings('modules.dynamic_option.data');
|
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 |
+
// Get settings.
|
130 |
+
$l10n = acf_get_setting('l10n');
|
131 |
+
$l10n_textdomain = acf_get_setting('l10n_textdomain');
|
132 |
+
|
133 |
+
?>
|
134 |
+
<p><?php _e("The following code can be used to register an options page. Simply copy and paste the following code to your theme's functions.php file or include it within an external file.", 'acf'); ?></p>
|
135 |
+
|
136 |
+
<div id="acf-admin-tool-export">
|
137 |
+
|
138 |
+
<textarea id="acf-export-textarea" readonly="true"><?php
|
139 |
+
|
140 |
+
echo "if( function_exists('acf_add_options_page') ):" . "\r\n" . "\r\n";
|
141 |
+
|
142 |
+
foreach($this->data as $args){
|
143 |
+
|
144 |
+
// Translate settings if textdomain is set.
|
145 |
+
if($l10n && $l10n_textdomain){
|
146 |
+
|
147 |
+
$args['page_title'] = acf_translate($args['page_title']);
|
148 |
+
$args['menu_title'] = acf_translate($args['menu_title']);
|
149 |
+
$args['update_button'] = acf_translate($args['update_button']);
|
150 |
+
$args['updated_message'] = acf_translate($args['updated_message']);
|
151 |
+
|
152 |
+
}
|
153 |
+
|
154 |
+
// code
|
155 |
+
$code = var_export($args, true);
|
156 |
+
|
157 |
+
|
158 |
+
// change double spaces to tabs
|
159 |
+
$code = str_replace( array_keys($str_replace), array_values($str_replace), $code );
|
160 |
+
|
161 |
+
|
162 |
+
// correctly formats "=> array("
|
163 |
+
$code = preg_replace( array_keys($preg_replace), array_values($preg_replace), $code );
|
164 |
+
|
165 |
+
|
166 |
+
// esc_textarea
|
167 |
+
$code = esc_textarea( $code );
|
168 |
+
|
169 |
+
|
170 |
+
// echo
|
171 |
+
echo "acf_add_options_page({$code});" . "\r\n" . "\r\n";
|
172 |
+
|
173 |
+
}
|
174 |
+
|
175 |
+
echo "endif;";
|
176 |
+
|
177 |
+
?></textarea>
|
178 |
+
|
179 |
+
</div>
|
180 |
+
|
181 |
+
<p class="acf-submit">
|
182 |
+
<a class="button" id="acf-export-copy"><?php _e( 'Copy to clipboard', 'acf' ); ?></a>
|
183 |
+
</p>
|
184 |
+
<script type="text/javascript">
|
185 |
+
(function($){
|
186 |
+
|
187 |
+
// vars
|
188 |
+
var $a = $('#acf-export-copy');
|
189 |
+
var $textarea = $('#acf-export-textarea');
|
190 |
+
|
191 |
+
|
192 |
+
// remove $a if 'copy' is not supported
|
193 |
+
if( !document.queryCommandSupported('copy') ) {
|
194 |
+
return $a.remove();
|
195 |
+
}
|
196 |
+
|
197 |
+
|
198 |
+
// event
|
199 |
+
$a.on('click', function( e ){
|
200 |
+
|
201 |
+
// prevent default
|
202 |
+
e.preventDefault();
|
203 |
+
|
204 |
+
|
205 |
+
// select
|
206 |
+
$textarea.get(0).select();
|
207 |
+
|
208 |
+
|
209 |
+
// try
|
210 |
+
try {
|
211 |
+
|
212 |
+
// copy
|
213 |
+
var copy = document.execCommand('copy');
|
214 |
+
if( !copy ) return;
|
215 |
+
|
216 |
+
|
217 |
+
// tooltip
|
218 |
+
acf.newTooltip({
|
219 |
+
text: "<?php _e('Copied', 'acf' ); ?>",
|
220 |
+
timeout: 250,
|
221 |
+
target: $(this),
|
222 |
+
});
|
223 |
+
|
224 |
+
} catch (err) {
|
225 |
+
|
226 |
+
// do nothing
|
227 |
+
|
228 |
+
}
|
229 |
+
|
230 |
+
});
|
231 |
+
|
232 |
+
})(jQuery);
|
233 |
+
</script>
|
234 |
+
</div>
|
235 |
+
</div>
|
236 |
+
<?php
|
237 |
+
|
238 |
+
}
|
239 |
+
|
240 |
+
function load(){
|
241 |
+
|
242 |
+
if($this->is_active()){
|
243 |
+
|
244 |
+
$this->action = $this->get_action();
|
245 |
+
$this->data = $this->get_selected();
|
246 |
+
|
247 |
+
// Json submit
|
248 |
+
if($this->action === 'json')
|
249 |
+
$this->submit();
|
250 |
+
|
251 |
+
// add notice
|
252 |
+
if(!empty($this->data)){
|
253 |
+
|
254 |
+
$count = count($this->data);
|
255 |
+
$text = sprintf(_n( 'Exported 1 option page.', 'Exported %s option pages.', $count, 'acf' ), $count);
|
256 |
+
|
257 |
+
acf_add_admin_notice($text, 'success');
|
258 |
+
|
259 |
+
}
|
260 |
+
|
261 |
+
}
|
262 |
+
|
263 |
+
}
|
264 |
+
|
265 |
+
function submit(){
|
266 |
+
|
267 |
+
$this->action = $this->get_action();
|
268 |
+
$this->data = $this->get_selected();
|
269 |
+
|
270 |
+
// validate
|
271 |
+
if($this->data === false)
|
272 |
+
return acf_add_admin_notice(__('No options page selected'), 'warning');
|
273 |
+
|
274 |
+
$keys = array();
|
275 |
+
foreach($this->data as $key => $args){
|
276 |
+
|
277 |
+
$keys[] = $key;
|
278 |
+
|
279 |
+
}
|
280 |
+
|
281 |
+
if($this->action === 'json'){
|
282 |
+
|
283 |
+
// Prefix
|
284 |
+
$prefix = (count($keys) > 1) ? 'options-pages' : 'options-page';
|
285 |
+
|
286 |
+
// Slugs
|
287 |
+
$slugs = implode('-', $keys);
|
288 |
+
|
289 |
+
// Date
|
290 |
+
$date = date('Y-m-d');
|
291 |
+
|
292 |
+
// file
|
293 |
+
$file_name = 'acfe-export-' . $prefix . '-' . $slugs . '-' . $date . '.json';
|
294 |
+
|
295 |
+
// headers
|
296 |
+
header("Content-Description: File Transfer");
|
297 |
+
header("Content-Disposition: attachment; filename={$file_name}");
|
298 |
+
header("Content-Type: application/json; charset=utf-8");
|
299 |
+
|
300 |
+
// return
|
301 |
+
echo acf_json_encode($this->data);
|
302 |
+
die;
|
303 |
+
|
304 |
+
}
|
305 |
+
|
306 |
+
elseif($this->action === 'php'){
|
307 |
+
|
308 |
+
// url
|
309 |
+
$url = add_query_arg(array(
|
310 |
+
'keys' => implode('+', $keys),
|
311 |
+
'action' => 'php'
|
312 |
+
), $this->get_url());
|
313 |
+
|
314 |
+
// redirect
|
315 |
+
wp_redirect($url);
|
316 |
+
exit;
|
317 |
+
|
318 |
+
}
|
319 |
+
|
320 |
+
}
|
321 |
+
|
322 |
+
function get_selected(){
|
323 |
+
|
324 |
+
// vars
|
325 |
+
$selected = $this->get_selected_keys();
|
326 |
+
$data = array();
|
327 |
+
|
328 |
+
if(!$selected)
|
329 |
+
return false;
|
330 |
+
$dynamic_options_pages = acfe_settings('modules.dynamic_option.data');
|
331 |
+
|
332 |
+
if(empty($dynamic_options_pages))
|
333 |
+
return false;
|
334 |
+
|
335 |
+
// construct data
|
336 |
+
foreach($selected as $key){
|
337 |
+
|
338 |
+
if(!isset($dynamic_options_pages[$key]))
|
339 |
+
continue;
|
340 |
+
|
341 |
+
// add to data array
|
342 |
+
$data[$key] = $dynamic_options_pages[$key];
|
343 |
+
|
344 |
+
}
|
345 |
+
|
346 |
+
// return
|
347 |
+
return $data;
|
348 |
+
|
349 |
+
}
|
350 |
+
|
351 |
+
function get_selected_keys(){
|
352 |
+
|
353 |
+
// check $_POST
|
354 |
+
if($keys = acf_maybe_get_POST('keys')){
|
355 |
+
|
356 |
+
return (array) $keys;
|
357 |
+
|
358 |
+
}
|
359 |
+
|
360 |
+
// check $_GET
|
361 |
+
if($keys = acf_maybe_get_GET('keys')){
|
362 |
+
|
363 |
+
$keys = str_replace(' ', '+', $keys);
|
364 |
+
return explode('+', $keys);
|
365 |
+
|
366 |
+
}
|
367 |
+
|
368 |
+
// return
|
369 |
+
return false;
|
370 |
+
|
371 |
+
}
|
372 |
+
|
373 |
+
function get_action(){
|
374 |
+
|
375 |
+
// init
|
376 |
+
$type = 'json';
|
377 |
+
|
378 |
+
// check GET / POST
|
379 |
+
if(($action = acf_maybe_get_GET('action')) || ($action = acf_maybe_get_POST('action'))){
|
380 |
+
|
381 |
+
if(in_array($action, array('json', 'php')))
|
382 |
+
$type = $action;
|
383 |
+
|
384 |
+
}
|
385 |
+
|
386 |
+
// return
|
387 |
+
return $type;
|
388 |
+
|
389 |
+
}
|
390 |
+
|
391 |
+
}
|
392 |
+
|
393 |
+
acf_register_admin_tool('ACFE_Admin_Tool_Export_DOP');
|
394 |
+
|
395 |
+
endif;
|
@@ -1,207 +1,207 @@
|
|
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_Import_DOP')):
|
11 |
-
|
12 |
-
class ACFE_Admin_Tool_Import_DOP extends ACF_Admin_Tool{
|
13 |
-
|
14 |
-
function initialize(){
|
15 |
-
|
16 |
-
// vars
|
17 |
-
$this->name = 'acfe_tool_dop_import';
|
18 |
-
$this->title = __('Import Options Pages');
|
19 |
-
$this->icon = 'dashicons-upload';
|
20 |
-
|
21 |
-
}
|
22 |
-
|
23 |
-
function html(){
|
24 |
-
|
25 |
-
?>
|
26 |
-
<p><?php _e('Import Options Pages', '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 |
-
$dynamic_options_pages = acfe_settings('modules.dynamic_option.data');
|
77 |
-
|
78 |
-
$dynamic_options_sub_pages = array();
|
79 |
-
|
80 |
-
// Loop over json
|
81 |
-
foreach($json as $options_page_name => $args){
|
82 |
-
|
83 |
-
// Check if already exists
|
84 |
-
if(isset($dynamic_options_pages[$options_page_name])){
|
85 |
-
|
86 |
-
acf_add_admin_notice(__("Options page {$dynamic_options_pages[$options_page_name]['page_title']} already exists. Import aborted."), 'warning');
|
87 |
-
continue;
|
88 |
-
|
89 |
-
}
|
90 |
-
|
91 |
-
// Vars
|
92 |
-
$page_title = $args['page_title'];
|
93 |
-
$menu_slug = $args['menu_slug'];
|
94 |
-
|
95 |
-
// Insert post
|
96 |
-
$post_id = wp_insert_post(array(
|
97 |
-
'post_title' => $page_title,
|
98 |
-
'post_name' => $menu_slug,
|
99 |
-
'post_type' => 'acfe-dop',
|
100 |
-
'post_status' => 'publish'
|
101 |
-
));
|
102 |
-
|
103 |
-
// Insert error
|
104 |
-
if(is_wp_error($post_id)){
|
105 |
-
|
106 |
-
acf_add_admin_notice(__("Something went wrong with the options page {$page_title}. Import aborted."), 'warning');
|
107 |
-
continue;
|
108 |
-
|
109 |
-
}
|
110 |
-
|
111 |
-
// Register Args
|
112 |
-
update_field('menu_title', $args['menu_title'], $post_id);
|
113 |
-
update_field('menu_slug', $args['menu_slug'], $post_id);
|
114 |
-
update_field('capability', $args['capability'], $post_id);
|
115 |
-
update_field('position', $args['position'], $post_id);
|
116 |
-
update_field('parent_slug', $args['parent_slug'], $post_id);
|
117 |
-
update_field('icon_url', $args['icon_url'], $post_id);
|
118 |
-
update_field('redirect', $args['redirect'], $post_id);
|
119 |
-
update_field('post_id', $args['post_id'], $post_id);
|
120 |
-
update_field('autoload', $args['autoload'], $post_id);
|
121 |
-
update_field('update_button', $args['update_button'], $post_id);
|
122 |
-
update_field('updated_message', $args['updated_message'], $post_id);
|
123 |
-
|
124 |
-
// Create ACFE option
|
125 |
-
$dynamic_options_pages[$options_page_name] = $args;
|
126 |
-
|
127 |
-
// Sort keys ASC
|
128 |
-
ksort($dynamic_options_pages);
|
129 |
-
|
130 |
-
// Update ACFE option
|
131 |
-
acfe_settings('modules.dynamic_option.data', $dynamic_options_pages, true);
|
132 |
-
|
133 |
-
// Append message
|
134 |
-
$ids[] = $post_id;
|
135 |
-
|
136 |
-
// Add Sub Page
|
137 |
-
if(isset($args['parent_slug']) && !empty($args['parent_slug']))
|
138 |
-
$dynamic_options_sub_pages[$post_id] = $args;
|
139 |
-
|
140 |
-
}
|
141 |
-
|
142 |
-
// Check if pages have been added
|
143 |
-
if(empty($ids))
|
144 |
-
return;
|
145 |
-
|
146 |
-
// Update Options Sub Pages
|
147 |
-
if(!empty($dynamic_options_sub_pages)){
|
148 |
-
|
149 |
-
foreach($dynamic_options_sub_pages as $post_id => $args){
|
150 |
-
|
151 |
-
// Get possible parent options pages
|
152 |
-
$get_dop_parent = get_posts(array(
|
153 |
-
'post_type' => 'acfe-dop',
|
154 |
-
'posts_per_page' => 1,
|
155 |
-
'fields' => 'ids',
|
156 |
-
'meta_query' => array(
|
157 |
-
array(
|
158 |
-
'key' => 'menu_slug',
|
159 |
-
'value' => $args['parent_slug']
|
160 |
-
)
|
161 |
-
)
|
162 |
-
));
|
163 |
-
|
164 |
-
if(empty($get_dop_parent))
|
165 |
-
continue;
|
166 |
-
|
167 |
-
$parent = $get_dop_parent[0];
|
168 |
-
|
169 |
-
// Update sub page post
|
170 |
-
wp_update_post(array(
|
171 |
-
'ID' => $post_id,
|
172 |
-
'post_parent' => $parent,
|
173 |
-
));
|
174 |
-
|
175 |
-
}
|
176 |
-
|
177 |
-
}
|
178 |
-
|
179 |
-
// Count total
|
180 |
-
$total = count($ids);
|
181 |
-
|
182 |
-
// Generate text
|
183 |
-
$text = sprintf(_n('1 options page imported', '%s options pages imported', $total, 'acf'), $total);
|
184 |
-
|
185 |
-
// Add links to text
|
186 |
-
$links = array();
|
187 |
-
foreach($ids as $id){
|
188 |
-
|
189 |
-
$links[] = '<a href="' . get_edit_post_link($id) . '">' . get_the_title($id) . '</a>';
|
190 |
-
|
191 |
-
}
|
192 |
-
|
193 |
-
$text .= ': ' . implode(', ', $links);
|
194 |
-
|
195 |
-
// Add notice
|
196 |
-
acf_add_admin_notice($text, 'success');
|
197 |
-
|
198 |
-
// Flush permalinks
|
199 |
-
flush_rewrite_rules();
|
200 |
-
|
201 |
-
}
|
202 |
-
|
203 |
-
}
|
204 |
-
|
205 |
-
acf_register_admin_tool('ACFE_Admin_Tool_Import_DOP');
|
206 |
-
|
207 |
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_Import_DOP')):
|
11 |
+
|
12 |
+
class ACFE_Admin_Tool_Import_DOP extends ACF_Admin_Tool{
|
13 |
+
|
14 |
+
function initialize(){
|
15 |
+
|
16 |
+
// vars
|
17 |
+
$this->name = 'acfe_tool_dop_import';
|
18 |
+
$this->title = __('Import Options Pages');
|
19 |
+
$this->icon = 'dashicons-upload';
|
20 |
+
|
21 |
+
}
|
22 |
+
|
23 |
+
function html(){
|
24 |
+
|
25 |
+
?>
|
26 |
+
<p><?php _e('Import Options Pages', '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 |
+
$dynamic_options_pages = acfe_settings('modules.dynamic_option.data');
|
77 |
+
|
78 |
+
$dynamic_options_sub_pages = array();
|
79 |
+
|
80 |
+
// Loop over json
|
81 |
+
foreach($json as $options_page_name => $args){
|
82 |
+
|
83 |
+
// Check if already exists
|
84 |
+
if(isset($dynamic_options_pages[$options_page_name])){
|
85 |
+
|
86 |
+
acf_add_admin_notice(__("Options page {$dynamic_options_pages[$options_page_name]['page_title']} already exists. Import aborted."), 'warning');
|
87 |
+
continue;
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
// Vars
|
92 |
+
$page_title = $args['page_title'];
|
93 |
+
$menu_slug = $args['menu_slug'];
|
94 |
+
|
95 |
+
// Insert post
|
96 |
+
$post_id = wp_insert_post(array(
|
97 |
+
'post_title' => $page_title,
|
98 |
+
'post_name' => $menu_slug,
|
99 |
+
'post_type' => 'acfe-dop',
|
100 |
+
'post_status' => 'publish'
|
101 |
+
));
|
102 |
+
|
103 |
+
// Insert error
|
104 |
+
if(is_wp_error($post_id)){
|
105 |
+
|
106 |
+
acf_add_admin_notice(__("Something went wrong with the options page {$page_title}. Import aborted."), 'warning');
|
107 |
+
continue;
|
108 |
+
|
109 |
+
}
|
110 |
+
|
111 |
+
// Register Args
|
112 |
+
update_field('menu_title', $args['menu_title'], $post_id);
|
113 |
+
update_field('menu_slug', $args['menu_slug'], $post_id);
|
114 |
+
update_field('capability', $args['capability'], $post_id);
|
115 |
+
update_field('position', $args['position'], $post_id);
|
116 |
+
update_field('parent_slug', $args['parent_slug'], $post_id);
|
117 |
+
update_field('icon_url', $args['icon_url'], $post_id);
|
118 |
+
update_field('redirect', $args['redirect'], $post_id);
|
119 |
+
update_field('post_id', $args['post_id'], $post_id);
|
120 |
+
update_field('autoload', $args['autoload'], $post_id);
|
121 |
+
update_field('update_button', $args['update_button'], $post_id);
|
122 |
+
update_field('updated_message', $args['updated_message'], $post_id);
|
123 |
+
|
124 |
+
// Create ACFE option
|
125 |
+
$dynamic_options_pages[$options_page_name] = $args;
|
126 |
+
|
127 |
+
// Sort keys ASC
|
128 |
+
ksort($dynamic_options_pages);
|
129 |
+
|
130 |
+
// Update ACFE option
|
131 |
+
acfe_settings('modules.dynamic_option.data', $dynamic_options_pages, true);
|
132 |
+
|
133 |
+
// Append message
|
134 |
+
$ids[] = $post_id;
|
135 |
+
|
136 |
+
// Add Sub Page
|
137 |
+
if(isset($args['parent_slug']) && !empty($args['parent_slug']))
|
138 |
+
$dynamic_options_sub_pages[$post_id] = $args;
|
139 |
+
|
140 |
+
}
|
141 |
+
|
142 |
+
// Check if pages have been added
|
143 |
+
if(empty($ids))
|
144 |
+
return;
|
145 |
+
|
146 |
+
// Update Options Sub Pages
|
147 |
+
if(!empty($dynamic_options_sub_pages)){
|
148 |
+
|
149 |
+
foreach($dynamic_options_sub_pages as $post_id => $args){
|
150 |
+
|
151 |
+
// Get possible parent options pages
|
152 |
+
$get_dop_parent = get_posts(array(
|
153 |
+
'post_type' => 'acfe-dop',
|
154 |
+
'posts_per_page' => 1,
|
155 |
+
'fields' => 'ids',
|
156 |
+
'meta_query' => array(
|
157 |
+
array(
|
158 |
+
'key' => 'menu_slug',
|
159 |
+
'value' => $args['parent_slug']
|
160 |
+
)
|
161 |
+
)
|
162 |
+
));
|
163 |
+
|
164 |
+
if(empty($get_dop_parent))
|
165 |
+
continue;
|
166 |
+
|
167 |
+
$parent = $get_dop_parent[0];
|
168 |
+
|
169 |
+
// Update sub page post
|
170 |
+
wp_update_post(array(
|
171 |
+
'ID' => $post_id,
|
172 |
+
'post_parent' => $parent,
|
173 |
+
));
|
174 |
+
|
175 |
+
}
|
176 |
+
|
177 |
+
}
|
178 |
+
|
179 |
+
// Count total
|
180 |
+
$total = count($ids);
|
181 |
+
|
182 |
+
// Generate text
|
183 |
+
$text = sprintf(_n('1 options page imported', '%s options pages imported', $total, 'acf'), $total);
|
184 |
+
|
185 |
+
// Add links to text
|
186 |
+
$links = array();
|
187 |
+
foreach($ids as $id){
|
188 |
+
|
189 |
+
$links[] = '<a href="' . get_edit_post_link($id) . '">' . get_the_title($id) . '</a>';
|
190 |
+
|
191 |
+
}
|
192 |
+
|
193 |
+
$text .= ': ' . implode(', ', $links);
|
194 |
+
|
195 |
+
// Add notice
|
196 |
+
acf_add_admin_notice($text, 'success');
|
197 |
+
|
198 |
+
// Flush permalinks
|
199 |
+
flush_rewrite_rules();
|
200 |
+
|
201 |
+
}
|
202 |
+
|
203 |
+
}
|
204 |
+
|
205 |
+
acf_register_admin_tool('ACFE_Admin_Tool_Import_DOP');
|
206 |
+
|
207 |
endif;
|
@@ -1,401 +1,401 @@
|
|
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 = acfe_settings('modules.dynamic_post_type.data');
|
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 |
-
// Get settings.
|
130 |
-
$l10n = acf_get_setting('l10n');
|
131 |
-
$l10n_textdomain = acf_get_setting('l10n_textdomain');
|
132 |
-
|
133 |
-
?>
|
134 |
-
<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>
|
135 |
-
|
136 |
-
<div id="acf-admin-tool-export">
|
137 |
-
|
138 |
-
<textarea id="acf-export-textarea" readonly="true"><?php
|
139 |
-
|
140 |
-
foreach($this->data as $post_type => $args){
|
141 |
-
|
142 |
-
// Translate settings if textdomain is set.
|
143 |
-
if($l10n && $l10n_textdomain){
|
144 |
-
|
145 |
-
$args['label'] = acf_translate($args['label']);
|
146 |
-
$args['description'] = acf_translate($args['description']);
|
147 |
-
|
148 |
-
if(!empty($args['labels'])){
|
149 |
-
|
150 |
-
foreach($args['labels'] as $key => &$label){
|
151 |
-
|
152 |
-
$args['labels'][$key] = acf_translate($label);
|
153 |
-
|
154 |
-
}
|
155 |
-
|
156 |
-
}
|
157 |
-
|
158 |
-
}
|
159 |
-
|
160 |
-
// code
|
161 |
-
$code = var_export($args, true);
|
162 |
-
|
163 |
-
|
164 |
-
// change double spaces to tabs
|
165 |
-
$code = str_replace( array_keys($str_replace), array_values($str_replace), $code );
|
166 |
-
|
167 |
-
|
168 |
-
// correctly formats "=> array("
|
169 |
-
$code = preg_replace( array_keys($preg_replace), array_values($preg_replace), $code );
|
170 |
-
|
171 |
-
|
172 |
-
// esc_textarea
|
173 |
-
$code = esc_textarea( $code );
|
174 |
-
|
175 |
-
|
176 |
-
// echo
|
177 |
-
echo "register_post_type('{$post_type}', {$code});" . "\r\n" . "\r\n";
|
178 |
-
|
179 |
-
}
|
180 |
-
|
181 |
-
?></textarea>
|
182 |
-
|
183 |
-
</div>
|
184 |
-
|
185 |
-
<p class="acf-submit">
|
186 |
-
<a class="button" id="acf-export-copy"><?php _e( 'Copy to clipboard', 'acf' ); ?></a>
|
187 |
-
</p>
|
188 |
-
<script type="text/javascript">
|
189 |
-
(function($){
|
190 |
-
|
191 |
-
// vars
|
192 |
-
var $a = $('#acf-export-copy');
|
193 |
-
var $textarea = $('#acf-export-textarea');
|
194 |
-
|
195 |
-
|
196 |
-
// remove $a if 'copy' is not supported
|
197 |
-
if( !document.queryCommandSupported('copy') ) {
|
198 |
-
return $a.remove();
|
199 |
-
}
|
200 |
-
|
201 |
-
|
202 |
-
// event
|
203 |
-
$a.on('click', function( e ){
|
204 |
-
|
205 |
-
// prevent default
|
206 |
-
e.preventDefault();
|
207 |
-
|
208 |
-
|
209 |
-
// select
|
210 |
-
$textarea.get(0).select();
|
211 |
-
|
212 |
-
|
213 |
-
// try
|
214 |
-
try {
|
215 |
-
|
216 |
-
// copy
|
217 |
-
var copy = document.execCommand('copy');
|
218 |
-
if( !copy ) return;
|
219 |
-
|
220 |
-
|
221 |
-
// tooltip
|
222 |
-
acf.newTooltip({
|
223 |
-
text: "<?php _e('Copied', 'acf' ); ?>",
|
224 |
-
timeout: 250,
|
225 |
-
target: $(this),
|
226 |
-
});
|
227 |
-
|
228 |
-
} catch (err) {
|
229 |
-
|
230 |
-
// do nothing
|
231 |
-
|
232 |
-
}
|
233 |
-
|
234 |
-
});
|
235 |
-
|
236 |
-
})(jQuery);
|
237 |
-
</script>
|
238 |
-
</div>
|
239 |
-
</div>
|
240 |
-
<?php
|
241 |
-
|
242 |
-
}
|
243 |
-
|
244 |
-
function load(){
|
245 |
-
|
246 |
-
if($this->is_active()){
|
247 |
-
|
248 |
-
$this->action = $this->get_action();
|
249 |
-
$this->data = $this->get_selected();
|
250 |
-
|
251 |
-
// Json submit
|
252 |
-
if($this->action === 'json')
|
253 |
-
$this->submit();
|
254 |
-
|
255 |
-
// add notice
|
256 |
-
if(!empty($this->data)){
|
257 |
-
|
258 |
-
$count = count($this->data);
|
259 |
-
$text = sprintf(_n( 'Exported 1 post type.', 'Exported %s post types.', $count, 'acf' ), $count);
|
260 |
-
|
261 |
-
acf_add_admin_notice($text, 'success');
|
262 |
-
|
263 |
-
}
|
264 |
-
|
265 |
-
}
|
266 |
-
|
267 |
-
}
|
268 |
-
|
269 |
-
function submit(){
|
270 |
-
|
271 |
-
$this->action = $this->get_action();
|
272 |
-
$this->data = $this->get_selected();
|
273 |
-
|
274 |
-
// validate
|
275 |
-
if($this->data === false)
|
276 |
-
return acf_add_admin_notice(__('No post types selected'), 'warning');
|
277 |
-
|
278 |
-
$keys = array();
|
279 |
-
foreach($this->data as $key => $args){
|
280 |
-
|
281 |
-
$keys[] = $key;
|
282 |
-
|
283 |
-
}
|
284 |
-
|
285 |
-
if($this->action === 'json'){
|
286 |
-
|
287 |
-
// Prefix
|
288 |
-
$prefix = (count($keys) > 1) ? 'post-types' : 'post-type';
|
289 |
-
|
290 |
-
// Slugs
|
291 |
-
$slugs = implode('-', $keys);
|
292 |
-
|
293 |
-
// Date
|
294 |
-
$date = date('Y-m-d');
|
295 |
-
|
296 |
-
// file
|
297 |
-
$file_name = 'acfe-export-' . $prefix . '-' . $slugs . '-' . $date . '.json';
|
298 |
-
|
299 |
-
// headers
|
300 |
-
header("Content-Description: File Transfer");
|
301 |
-
header("Content-Disposition: attachment; filename={$file_name}");
|
302 |
-
header("Content-Type: application/json; charset=utf-8");
|
303 |
-
|
304 |
-
// return
|
305 |
-
echo acf_json_encode($this->data);
|
306 |
-
die;
|
307 |
-
|
308 |
-
}
|
309 |
-
|
310 |
-
elseif($this->action === 'php'){
|
311 |
-
|
312 |
-
// url
|
313 |
-
$url = add_query_arg(array(
|
314 |
-
'keys' => implode('+', $keys),
|
315 |
-
'action' => 'php'
|
316 |
-
), $this->get_url());
|
317 |
-
|
318 |
-
// redirect
|
319 |
-
wp_redirect($url);
|
320 |
-
exit;
|
321 |
-
|
322 |
-
}
|
323 |
-
|
324 |
-
}
|
325 |
-
|
326 |
-
function get_selected(){
|
327 |
-
|
328 |
-
// vars
|
329 |
-
$selected = $this->get_selected_keys();
|
330 |
-
|
331 |
-
if(!$selected)
|
332 |
-
return false;
|
333 |
-
|
334 |
-
$dynamic_post_types = acfe_settings('modules.dynamic_post_type.data');
|
335 |
-
|
336 |
-
if(empty($dynamic_post_types))
|
337 |
-
return false;
|
338 |
-
|
339 |
-
$data = array();
|
340 |
-
|
341 |
-
// construct Data
|
342 |
-
foreach($selected as $key){
|
343 |
-
|
344 |
-
if(!isset($dynamic_post_types[$key]))
|
345 |
-
continue;
|
346 |
-
|
347 |
-
// add to data array
|
348 |
-
$data[$key] = $dynamic_post_types[$key];
|
349 |
-
|
350 |
-
}
|
351 |
-
|
352 |
-
// return
|
353 |
-
return $data;
|
354 |
-
|
355 |
-
}
|
356 |
-
|
357 |
-
function get_selected_keys(){
|
358 |
-
|
359 |
-
// check $_POST
|
360 |
-
if($keys = acf_maybe_get_POST('keys')){
|
361 |
-
|
362 |
-
return (array) $keys;
|
363 |
-
|
364 |
-
}
|
365 |
-
|
366 |
-
// check $_GET
|
367 |
-
if($keys = acf_maybe_get_GET('keys')){
|
368 |
-
|
369 |
-
$keys = str_replace(' ', '+', $keys);
|
370 |
-
return explode('+', $keys);
|
371 |
-
|
372 |
-
}
|
373 |
-
|
374 |
-
// return
|
375 |
-
return false;
|
376 |
-
|
377 |
-
}
|
378 |
-
|
379 |
-
function get_action(){
|
380 |
-
|
381 |
-
// init
|
382 |
-
$type = 'json';
|
383 |
-
|
384 |
-
// check GET / POST
|
385 |
-
if(($action = acf_maybe_get_GET('action')) || ($action = acf_maybe_get_POST('action'))){
|
386 |
-
|
387 |
-
if(in_array($action, array('json', 'php')))
|
388 |
-
$type = $action;
|
389 |
-
|
390 |
-
}
|
391 |
-
|
392 |
-
// return
|
393 |
-
return $type;
|
394 |
-
|
395 |
-
}
|
396 |
-
|
397 |
-
}
|
398 |
-
|
399 |
-
acf_register_admin_tool('ACFE_Admin_Tool_Export_DPT');
|
400 |
-
|
401 |
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 = acfe_settings('modules.dynamic_post_type.data');
|
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 |
+
// Get settings.
|
130 |
+
$l10n = acf_get_setting('l10n');
|
131 |
+
$l10n_textdomain = acf_get_setting('l10n_textdomain');
|
132 |
+
|
133 |
+
?>
|
134 |
+
<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>
|
135 |
+
|
136 |
+
<div id="acf-admin-tool-export">
|
137 |
+
|
138 |
+
<textarea id="acf-export-textarea" readonly="true"><?php
|
139 |
+
|
140 |
+
foreach($this->data as $post_type => $args){
|
141 |
+
|
142 |
+
// Translate settings if textdomain is set.
|
143 |
+
if($l10n && $l10n_textdomain){
|
144 |
+
|
145 |
+
$args['label'] = acf_translate($args['label']);
|
146 |
+
$args['description'] = acf_translate($args['description']);
|
147 |
+
|
148 |
+
if(!empty($args['labels'])){
|
149 |
+
|
150 |
+
foreach($args['labels'] as $key => &$label){
|
151 |
+
|
152 |
+
$args['labels'][$key] = acf_translate($label);
|
153 |
+
|
154 |
+
}
|
155 |
+
|
156 |
+
}
|
157 |
+
|
158 |
+
}
|
159 |
+
|
160 |
+
// code
|
161 |
+
$code = var_export($args, true);
|
162 |
+
|
163 |
+
|
164 |
+
// change double spaces to tabs
|
165 |
+
$code = str_replace( array_keys($str_replace), array_values($str_replace), $code );
|
166 |
+
|
167 |
+
|
168 |
+
// correctly formats "=> array("
|
169 |
+
$code = preg_replace( array_keys($preg_replace), array_values($preg_replace), $code );
|
170 |
+
|
171 |
+
|
172 |
+
// esc_textarea
|
173 |
+
$code = esc_textarea( $code );
|
174 |
+
|
175 |
+
|
176 |
+
// echo
|
177 |
+
echo "register_post_type('{$post_type}', {$code});" . "\r\n" . "\r\n";
|
178 |
+
|
179 |
+
}
|
180 |
+
|
181 |
+
?></textarea>
|
182 |
+
|
183 |
+
</div>
|
184 |
+
|
185 |
+
<p class="acf-submit">
|
186 |
+
<a class="button" id="acf-export-copy"><?php _e( 'Copy to clipboard', 'acf' ); ?></a>
|
187 |
+
</p>
|
188 |
+
<script type="text/javascript">
|
189 |
+
(function($){
|
190 |
+
|
191 |
+
// vars
|
192 |
+
var $a = $('#acf-export-copy');
|
193 |
+
var $textarea = $('#acf-export-textarea');
|
194 |
+
|
195 |
+
|
196 |
+
// remove $a if 'copy' is not supported
|
197 |
+
if( !document.queryCommandSupported('copy') ) {
|
198 |
+
return $a.remove();
|
199 |
+
}
|
200 |
+
|
201 |
+
|
202 |
+
// event
|
203 |
+
$a.on('click', function( e ){
|
204 |
+
|
205 |
+
// prevent default
|
206 |
+
e.preventDefault();
|
207 |
+
|
208 |
+
|
209 |
+
// select
|
210 |
+
$textarea.get(0).select();
|
211 |
+
|
212 |
+
|
213 |
+
// try
|
214 |
+
try {
|
215 |
+
|
216 |
+
// copy
|
217 |
+
var copy = document.execCommand('copy');
|
218 |
+
if( !copy ) return;
|
219 |
+
|
220 |
+
|
221 |
+
// tooltip
|
222 |
+
acf.newTooltip({
|
223 |
+
text: "<?php _e('Copied', 'acf' ); ?>",
|
224 |
+
timeout: 250,
|
225 |
+
target: $(this),
|
226 |
+
});
|
227 |
+
|
228 |
+
} catch (err) {
|
229 |
+
|
230 |
+
// do nothing
|
231 |
+
|
232 |
+
}
|
233 |
+
|
234 |
+
});
|
235 |
+
|
236 |
+
})(jQuery);
|
237 |
+
</script>
|
238 |
+
</div>
|
239 |
+
</div>
|
240 |
+
<?php
|
241 |
+
|
242 |
+
}
|
243 |
+
|
244 |
+
function load(){
|
245 |
+
|
246 |
+
if($this->is_active()){
|
247 |
+
|
248 |
+
$this->action = $this->get_action();
|
249 |
+
$this->data = $this->get_selected();
|
250 |
+
|
251 |
+
// Json submit
|
252 |
+
if($this->action === 'json')
|
253 |
+
$this->submit();
|
254 |
+
|
255 |
+
// add notice
|
256 |
+
if(!empty($this->data)){
|
257 |
+
|
258 |
+
$count = count($this->data);
|
259 |
+
$text = sprintf(_n( 'Exported 1 post type.', 'Exported %s post types.', $count, 'acf' ), $count);
|
260 |
+
|
261 |
+
acf_add_admin_notice($text, 'success');
|
262 |
+
|
263 |
+
}
|
264 |
+
|
265 |
+
}
|
266 |
+
|
267 |
+
}
|
268 |
+
|
269 |
+
function submit(){
|
270 |
+
|
271 |
+
$this->action = $this->get_action();
|
272 |
+
$this->data = $this->get_selected();
|
273 |
+
|
274 |
+
// validate
|
275 |
+
if($this->data === false)
|
276 |
+
return acf_add_admin_notice(__('No post types selected'), 'warning');
|
277 |
+
|
278 |
+
$keys = array();
|
279 |
+
foreach($this->data as $key => $args){
|
280 |
+
|
281 |
+
$keys[] = $key;
|
282 |
+
|
283 |
+
}
|
284 |
+
|
285 |
+
if($this->action === 'json'){
|
286 |
+
|
287 |
+
// Prefix
|
288 |
+
$prefix = (count($keys) > 1) ? 'post-types' : 'post-type';
|
289 |
+
|
290 |
+
// Slugs
|
291 |
+
$slugs = implode('-', $keys);
|
292 |
+
|
293 |
+
// Date
|
294 |
+
$date = date('Y-m-d');
|
295 |
+
|
296 |
+
// file
|
297 |
+
$file_name = 'acfe-export-' . $prefix . '-' . $slugs . '-' . $date . '.json';
|
298 |
+
|
299 |
+
// headers
|
300 |
+
header("Content-Description: File Transfer");
|
301 |
+
header("Content-Disposition: attachment; filename={$file_name}");
|
302 |
+
header("Content-Type: application/json; charset=utf-8");
|
303 |
+
|
304 |
+
// return
|
305 |
+
echo acf_json_encode($this->data);
|
306 |
+
die;
|
307 |
+
|
308 |
+
}
|
309 |
+
|
310 |
+
elseif($this->action === 'php'){
|
311 |
+
|
312 |
+
// url
|
313 |
+
$url = add_query_arg(array(
|
314 |
+
'keys' => implode('+', $keys),
|
315 |
+
'action' => 'php'
|
316 |
+
), $this->get_url());
|
317 |
+
|
318 |
+
// redirect
|
319 |
+
wp_redirect($url);
|
320 |
+
exit;
|
321 |
+
|
322 |
+
}
|
323 |
+
|
324 |
+
}
|
325 |
+
|
326 |
+
function get_selected(){
|
327 |
+
|
328 |
+
// vars
|
329 |
+
$selected = $this->get_selected_keys();
|
330 |
+
|
331 |
+
if(!$selected)
|
332 |
+
return false;
|
333 |
+
|
334 |
+
$dynamic_post_types = acfe_settings('modules.dynamic_post_type.data');
|
335 |
+
|
336 |
+
if(empty($dynamic_post_types))
|
337 |
+
return false;
|
338 |
+
|
339 |
+
$data = array();
|
340 |
+
|
341 |
+
// construct Data
|
342 |
+
foreach($selected as $key){
|
343 |
+
|
344 |
+
if(!isset($dynamic_post_types[$key]))
|
345 |
+
continue;
|
346 |
+
|
347 |
+
// add to data array
|
348 |
+
$data[$key] = $dynamic_post_types[$key];
|
349 |
+
|
350 |
+
}
|
351 |
+
|
352 |
+
// return
|
353 |
+
return $data;
|
354 |
+
|
355 |
+
}
|
356 |
+
|
357 |
+
function get_selected_keys(){
|
358 |
+
|
359 |
+
// check $_POST
|
360 |
+
if($keys = acf_maybe_get_POST('keys')){
|
361 |
+
|
362 |
+
return (array) $keys;
|
363 |
+
|
364 |
+
}
|
365 |
+
|
366 |
+
// check $_GET
|
367 |
+
if($keys = acf_maybe_get_GET('keys')){
|
368 |
+
|
369 |
+
$keys = str_replace(' ', '+', $keys);
|
370 |
+
return explode('+', $keys);
|
371 |
+
|
372 |
+
}
|
373 |
+
|
374 |
+
// return
|
375 |
+
return false;
|
376 |
+
|
377 |
+
}
|
378 |
+
|
379 |
+
function get_action(){
|
380 |
+
|
381 |
+
// init
|
382 |
+
$type = 'json';
|
383 |
+
|
384 |
+
// check GET / POST
|
385 |
+
if(($action = acf_maybe_get_GET('action')) || ($action = acf_maybe_get_POST('action'))){
|
386 |
+
|
387 |
+
if(in_array($action, array('json', 'php')))
|
388 |
+
$type = $action;
|
389 |
+
|
390 |
+
}
|
391 |
+
|
392 |
+
// return
|
393 |
+
return $type;
|
394 |
+
|
395 |
+
}
|
396 |
+
|
397 |
+
}
|
398 |
+
|
399 |
+
acf_register_admin_tool('ACFE_Admin_Tool_Export_DPT');
|
400 |
+
|
401 |
endif;
|
@@ -1,242 +1,242 @@
|
|
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_Import_DPT')):
|
11 |
-
|
12 |
-
class ACFE_Admin_Tool_Import_DPT extends ACF_Admin_Tool{
|
13 |
-
|
14 |
-
function initialize(){
|
15 |
-
|
16 |
-
// vars
|
17 |
-
$this->name = 'acfe_tool_dpt_import';
|
18 |
-
$this->title = __('Import Post Types');
|
19 |
-
$this->icon = 'dashicons-upload';
|
20 |
-
|
21 |
-
}
|
22 |
-
|
23 |
-
function html(){
|
24 |
-
|
25 |
-
?>
|
26 |
-
<p><?php _e('Import Post Types', '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 |
-
$dynamic_post_types = acfe_settings('modules.dynamic_post_type.data');
|
77 |
-
|
78 |
-
// Loop over json
|
79 |
-
foreach($json as $post_type_name => $args){
|
80 |
-
|
81 |
-
// Check if already exists
|
82 |
-
if(isset($dynamic_post_types[$post_type_name])){
|
83 |
-
|
84 |
-
acf_add_admin_notice(__("Post type {$dynamic_post_types[$post_type_name]['label']} already exists. Import aborted."), 'warning');
|
85 |
-
continue;
|
86 |
-
|
87 |
-
}
|
88 |
-
|
89 |
-
// Vars
|
90 |
-
$title = $args['label'];
|
91 |
-
$name = $post_type_name;
|
92 |
-
|
93 |
-
// Insert post
|
94 |
-
$post_id = wp_insert_post(array(
|
95 |
-
'post_title' => $title,
|
96 |
-
'post_name' => $name,
|
97 |
-
'post_type' => 'acfe-dpt',
|
98 |
-
'post_status' => 'publish'
|
99 |
-
));
|
100 |
-
|
101 |
-
// Insert error
|
102 |
-
if(is_wp_error($post_id)){
|
103 |
-
|
104 |
-
acf_add_admin_notice(__("Something went wrong with the post type {$title}. Import aborted."), 'warning');
|
105 |
-
continue;
|
106 |
-
|
107 |
-
}
|
108 |
-
|
109 |
-
// Register Args
|
110 |
-
update_field('acfe_dpt_name', $post_type_name, $post_id);
|
111 |
-
update_field('description', $args['description'], $post_id);
|
112 |
-
update_field('hierarchical', $args['hierarchical'], $post_id);
|
113 |
-
update_field('supports', $args['supports'], $post_id);
|
114 |
-
update_field('taxonomies', $args['taxonomies'], $post_id);
|
115 |
-
update_field('public', $args['public'], $post_id);
|
116 |
-
update_field('exclude_from_search', $args['exclude_from_search'], $post_id);
|
117 |
-
update_field('publicly_queryable', $args['publicly_queryable'], $post_id);
|
118 |
-
update_field('can_export', $args['can_export'], $post_id);
|
119 |
-
update_field('delete_with_user', $args['delete_with_user'], $post_id);
|
120 |
-
|
121 |
-
// Labels
|
122 |
-
if(!empty($args['labels'])){
|
123 |
-
|
124 |
-
foreach($args['labels'] as $label_key => $label_value){
|
125 |
-
|
126 |
-
update_field('labels_' . $label_key, $label_value, $post_id);
|
127 |
-
|
128 |
-
}
|
129 |
-
|
130 |
-
}
|
131 |
-
|
132 |
-
// Menu
|
133 |
-
update_field('menu_position', $args['menu_position'], $post_id);
|
134 |
-
update_field('menu_icon', $args['menu_icon'], $post_id);
|
135 |
-
update_field('show_ui', $args['show_ui'], $post_id);
|
136 |
-
update_field('show_in_menu', $args['show_in_menu'], $post_id);
|
137 |
-
update_field('show_in_nav_menus', $args['show_in_nav_menus'], $post_id);
|
138 |
-
update_field('show_in_admin_bar', $args['show_in_admin_bar'], $post_id);
|
139 |
-
|
140 |
-
// Capability
|
141 |
-
update_field('capability_type', acf_encode_choices($args['capability_type'], false), $post_id);
|
142 |
-
update_field('map_meta_cap', $args['map_meta_cap'], $post_id);
|
143 |
-
|
144 |
-
if(isset($args['capabilities']))
|
145 |
-
update_field('capabilities', acf_encode_choices($args['capabilities'], false), $post_id);
|
146 |
-
|
147 |
-
// Archive
|
148 |
-
update_field('acfe_dpt_archive_template', $args['acfe_archive_template'], $post_id);
|
149 |
-
update_field('acfe_dpt_archive_posts_per_page', $args['acfe_archive_ppp'], $post_id);
|
150 |
-
update_field('acfe_dpt_archive_orderby', $args['acfe_archive_orderby'], $post_id);
|
151 |
-
update_field('acfe_dpt_archive_order', $args['acfe_archive_order'], $post_id);
|
152 |
-
update_field('has_archive', $args['has_archive'], $post_id);
|
153 |
-
|
154 |
-
// Single
|
155 |
-
update_field('acfe_dpt_single_template', $args['acfe_single_template'], $post_id);
|
156 |
-
update_field('rewrite', $args['rewrite'], $post_id);
|
157 |
-
|
158 |
-
// Admin
|
159 |
-
update_field('acfe_dpt_admin_posts_per_page', $args['acfe_admin_ppp'], $post_id);
|
160 |
-
update_field('acfe_dpt_admin_orderby', $args['acfe_admin_orderby'], $post_id);
|
161 |
-
update_field('acfe_dpt_admin_order', $args['acfe_admin_order'], $post_id);
|
162 |
-
|
163 |
-
// REST
|
164 |
-
update_field('show_in_rest', $args['show_in_rest'], $post_id);
|
165 |
-
update_field('rest_base', $args['rest_base'], $post_id);
|
166 |
-
update_field('rest_controller_class', $args['rest_controller_class'], $post_id);
|
167 |
-
|
168 |
-
// Has archive: override
|
169 |
-
if($args['has_archive'] && is_string($args['has_archive']))
|
170 |
-
update_field('has_archive_slug', $args['has_archive'], $post_id);
|
171 |
-
|
172 |
-
// Rewrite: override
|
173 |
-
if($args['rewrite'] && is_array($args['rewrite'])){
|
174 |
-
|
175 |
-
update_field('rewrite', true, $post_id);
|
176 |
-
|
177 |
-
update_field('rewrite_args_select', true, $post_id);
|
178 |
-
|
179 |
-
update_field('rewrite_args_acfe_dpt_rewrite_slug', $args['rewrite']['slug'], $post_id);
|
180 |
-
update_field('rewrite_args_acfe_dpt_rewrite_with_front', $args['rewrite']['with_front'], $post_id);
|
181 |
-
update_field('rewrite_args_feeds', $args['rewrite']['feeds'], $post_id);
|
182 |
-
update_field('rewrite_args_pages', $args['rewrite']['pages'], $post_id);
|
183 |
-
|
184 |
-
}
|
185 |
-
|
186 |
-
// Show in menu (text)
|
187 |
-
if($args['show_in_menu'] && is_string($args['show_in_menu']))
|
188 |
-
update_field('show_in_menu_text', $args['show_in_menu'], $post_id);
|
189 |
-
|
190 |
-
// Map meta cap
|
191 |
-
if($args['map_meta_cap'] === false)
|
192 |
-
update_field('map_meta_cap', 'false', $post_id);
|
193 |
-
|
194 |
-
elseif($args['map_meta_cap'] === true)
|
195 |
-
update_field('map_meta_cap', 'true', $post_id);
|
196 |
-
|
197 |
-
// Create ACFE option
|
198 |
-
$dynamic_post_types[$post_type_name] = $args;
|
199 |
-
|
200 |
-
// Sort keys ASC
|
201 |
-
ksort($dynamic_post_types);
|
202 |
-
|
203 |
-
// Update ACFE option
|
204 |
-
acfe_settings('modules.dynamic_post_type.data', $dynamic_post_types, true);
|
205 |
-
|
206 |
-
// append message
|
207 |
-
$ids[] = $post_id;
|
208 |
-
|
209 |
-
}
|
210 |
-
|
211 |
-
if(empty($ids))
|
212 |
-
return;
|
213 |
-
|
214 |
-
// Count total
|
215 |
-
$total = count($ids);
|
216 |
-
|
217 |
-
// Generate text
|
218 |
-
$text = sprintf(_n('1 post type imported', '%s post types imported', $total, 'acf'), $total);
|
219 |
-
|
220 |
-
// Add links to text
|
221 |
-
$links = array();
|
222 |
-
foreach($ids as $id){
|
223 |
-
|
224 |
-
$links[] = '<a href="' . get_edit_post_link($id) . '">' . get_the_title($id) . '</a>';
|
225 |
-
|
226 |
-
}
|
227 |
-
|
228 |
-
$text .= ': ' . implode(', ', $links);
|
229 |
-
|
230 |
-
// Add notice
|
231 |
-
acf_add_admin_notice($text, 'success');
|
232 |
-
|
233 |
-
// Flush permalinks
|
234 |
-
flush_rewrite_rules();
|
235 |
-
|
236 |
-
}
|
237 |
-
|
238 |
-
}
|
239 |
-
|
240 |
-
acf_register_admin_tool('ACFE_Admin_Tool_Import_DPT');
|
241 |
-
|
242 |
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_Import_DPT')):
|
11 |
+
|
12 |
+
class ACFE_Admin_Tool_Import_DPT extends ACF_Admin_Tool{
|
13 |
+
|
14 |
+
function initialize(){
|
15 |
+
|
16 |
+
// vars
|
17 |
+
$this->name = 'acfe_tool_dpt_import';
|
18 |
+
$this->title = __('Import Post Types');
|
19 |
+
$this->icon = 'dashicons-upload';
|
20 |
+
|
21 |
+
}
|
22 |
+
|
23 |
+
function html(){
|
24 |
+
|
25 |
+
?>
|
26 |
+
<p><?php _e('Import Post Types', '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 |
+
$dynamic_post_types = acfe_settings('modules.dynamic_post_type.data');
|
77 |
+
|
78 |
+
// Loop over json
|
79 |
+
foreach($json as $post_type_name => $args){
|
80 |
+
|
81 |
+
// Check if already exists
|
82 |
+
if(isset($dynamic_post_types[$post_type_name])){
|
83 |
+
|
84 |
+
acf_add_admin_notice(__("Post type {$dynamic_post_types[$post_type_name]['label']} already exists. Import aborted."), 'warning');
|
85 |
+
continue;
|
86 |
+
|
87 |
+
}
|
88 |
+
|
89 |
+
// Vars
|
90 |
+
$title = $args['label'];
|
91 |
+
$name = $post_type_name;
|
92 |
+
|
93 |
+
// Insert post
|
94 |
+
$post_id = wp_insert_post(array(
|
95 |
+
'post_title' => $title,
|
96 |
+
'post_name' => $name,
|
97 |
+
'post_type' => 'acfe-dpt',
|
98 |
+
'post_status' => 'publish'
|
99 |
+
));
|
100 |
+
|
101 |
+
// Insert error
|
102 |
+
if(is_wp_error($post_id)){
|
103 |
+
|
104 |
+
acf_add_admin_notice(__("Something went wrong with the post type {$title}. Import aborted."), 'warning');
|
105 |
+
continue;
|
106 |
+
|
107 |
+
}
|
108 |
+
|
109 |
+
// Register Args
|
110 |
+
update_field('acfe_dpt_name', $post_type_name, $post_id);
|
111 |
+
update_field('description', $args['description'], $post_id);
|
112 |
+
update_field('hierarchical', $args['hierarchical'], $post_id);
|
113 |
+
update_field('supports', $args['supports'], $post_id);
|
114 |
+
update_field('taxonomies', $args['taxonomies'], $post_id);
|
115 |
+
update_field('public', $args['public'], $post_id);
|
116 |
+
update_field('exclude_from_search', $args['exclude_from_search'], $post_id);
|
117 |
+
update_field('publicly_queryable', $args['publicly_queryable'], $post_id);
|
118 |
+
update_field('can_export', $args['can_export'], $post_id);
|
119 |
+
update_field('delete_with_user', $args['delete_with_user'], $post_id);
|
120 |
+
|
121 |
+
// Labels
|
122 |
+
if(!empty($args['labels'])){
|
123 |
+
|
124 |
+
foreach($args['labels'] as $label_key => $label_value){
|
125 |
+
|
126 |
+
update_field('labels_' . $label_key, $label_value, $post_id);
|
127 |
+
|
128 |
+
}
|
129 |
+
|
130 |
+
}
|
131 |
+
|
132 |
+
// Menu
|
133 |
+
update_field('menu_position', $args['menu_position'], $post_id);
|
134 |
+
update_field('menu_icon', $args['menu_icon'], $post_id);
|
135 |
+
update_field('show_ui', $args['show_ui'], $post_id);
|
136 |
+
update_field('show_in_menu', $args['show_in_menu'], $post_id);
|
137 |
+
update_field('show_in_nav_menus', $args['show_in_nav_menus'], $post_id);
|
138 |
+
update_field('show_in_admin_bar', $args['show_in_admin_bar'], $post_id);
|
139 |
+
|
140 |
+
// Capability
|
141 |
+
update_field('capability_type', acf_encode_choices($args['capability_type'], false), $post_id);
|
142 |
+
update_field('map_meta_cap', $args['map_meta_cap'], $post_id);
|
143 |
+
|
144 |
+
if(isset($args['capabilities']))
|
145 |
+
update_field('capabilities', acf_encode_choices($args['capabilities'], false), $post_id);
|
146 |
+
|
147 |
+
// Archive
|
148 |
+
update_field('acfe_dpt_archive_template', $args['acfe_archive_template'], $post_id);
|
149 |
+
update_field('acfe_dpt_archive_posts_per_page', $args['acfe_archive_ppp'], $post_id);
|
150 |
+
update_field('acfe_dpt_archive_orderby', $args['acfe_archive_orderby'], $post_id);
|
151 |
+
update_field('acfe_dpt_archive_order', $args['acfe_archive_order'], $post_id);
|
152 |
+
update_field('has_archive', $args['has_archive'], $post_id);
|
153 |
+
|
154 |
+
// Single
|
155 |
+
update_field('acfe_dpt_single_template', $args['acfe_single_template'], $post_id);
|
156 |
+
update_field('rewrite', $args['rewrite'], $post_id);
|
157 |
+
|
158 |
+
// Admin
|
159 |
+
update_field('acfe_dpt_admin_posts_per_page', $args['acfe_admin_ppp'], $post_id);
|
160 |
+
update_field('acfe_dpt_admin_orderby', $args['acfe_admin_orderby'], $post_id);
|
161 |
+
update_field('acfe_dpt_admin_order', $args['acfe_admin_order'], $post_id);
|
162 |
+
|
163 |
+
// REST
|
164 |
+
update_field('show_in_rest', $args['show_in_rest'], $post_id);
|
165 |
+
update_field('rest_base', $args['rest_base'], $post_id);
|
166 |
+
update_field('rest_controller_class', $args['rest_controller_class'], $post_id);
|
167 |
+
|
168 |
+
// Has archive: override
|
169 |
+
if($args['has_archive'] && is_string($args['has_archive']))
|
170 |
+
update_field('has_archive_slug', $args['has_archive'], $post_id);
|
171 |
+
|
172 |
+
// Rewrite: override
|
173 |
+
if($args['rewrite'] && is_array($args['rewrite'])){
|
174 |
+
|
175 |
+
update_field('rewrite', true, $post_id);
|
176 |
+
|
177 |
+
update_field('rewrite_args_select', true, $post_id);
|
178 |
+
|
179 |
+
update_field('rewrite_args_acfe_dpt_rewrite_slug', $args['rewrite']['slug'], $post_id);
|
180 |
+
update_field('rewrite_args_acfe_dpt_rewrite_with_front', $args['rewrite']['with_front'], $post_id);
|
181 |
+
update_field('rewrite_args_feeds', $args['rewrite']['feeds'], $post_id);
|
182 |
+
update_field('rewrite_args_pages', $args['rewrite']['pages'], $post_id);
|
183 |
+
|
184 |
+
}
|
185 |
+
|
186 |
+
// Show in menu (text)
|
187 |
+
if($args['show_in_menu'] && is_string($args['show_in_menu']))
|
188 |
+
update_field('show_in_menu_text', $args['show_in_menu'], $post_id);
|
189 |
+
|
190 |
+
// Map meta cap
|
191 |
+
if($args['map_meta_cap'] === false)
|
192 |
+
update_field('map_meta_cap', 'false', $post_id);
|
193 |
+
|
194 |
+
elseif($args['map_meta_cap'] === true)
|
195 |
+
update_field('map_meta_cap', 'true', $post_id);
|
196 |
+
|
197 |
+
// Create ACFE option
|
198 |
+
$dynamic_post_types[$post_type_name] = $args;
|
199 |
+
|
200 |
+
// Sort keys ASC
|
201 |
+
ksort($dynamic_post_types);
|
202 |
+
|
203 |
+
// Update ACFE option
|
204 |
+
acfe_settings('modules.dynamic_post_type.data', $dynamic_post_types, true);
|
205 |
+
|
206 |
+
// append message
|
207 |
+
$ids[] = $post_id;
|
208 |
+
|
209 |
+
}
|
210 |
+
|
211 |
+
if(empty($ids))
|
212 |
+
return;
|
213 |
+
|
214 |
+
// Count total
|
215 |
+
$total = count($ids);
|
216 |
+
|
217 |
+
// Generate text
|
218 |
+
$text = sprintf(_n('1 post type imported', '%s post types imported', $total, 'acf'), $total);
|
219 |
+
|
220 |
+
// Add links to text
|
221 |
+
$links = array();
|
222 |
+
foreach($ids as $id){
|
223 |
+
|
224 |
+
$links[] = '<a href="' . get_edit_post_link($id) . '">' . get_the_title($id) . '</a>';
|
225 |
+
|
226 |
+
}
|
227 |
+
|
228 |
+
$text .= ': ' . implode(', ', $links);
|
229 |
+
|
230 |
+
// Add notice
|
231 |
+
acf_add_admin_notice($text, 'success');
|
232 |
+
|
233 |
+
// Flush permalinks
|
234 |
+
flush_rewrite_rules();
|
235 |
+
|
236 |
+
}
|
237 |
+
|
238 |
+
}
|
239 |
+
|
240 |
+
acf_register_admin_tool('ACFE_Admin_Tool_Import_DPT');
|
241 |
+
|
242 |
endif;
|
@@ -1,411 +1,411 @@
|
|
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 = acfe_settings('modules.dynamic_taxonomy.data');
|
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 |
-
// Get settings.
|
130 |
-
$l10n = acf_get_setting('l10n');
|
131 |
-
$l10n_textdomain = acf_get_setting('l10n_textdomain');
|
132 |
-
|
133 |
-
?>
|
134 |
-
<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>
|
135 |
-
|
136 |
-
<div id="acf-admin-tool-export">
|
137 |
-
|
138 |
-
<textarea id="acf-export-textarea" readonly="true"><?php
|
139 |
-
|
140 |
-
foreach($this->data as $taxonomy => $args){
|
141 |
-
|
142 |
-
// Translate settings if textdomain is set.
|
143 |
-
if($l10n && $l10n_textdomain){
|
144 |
-
|
145 |
-
$args['label'] = acf_translate($args['label']);
|
146 |
-
$args['description'] = acf_translate($args['description']);
|
147 |
-
|
148 |
-
if(!empty($args['labels'])){
|
149 |
-
|
150 |
-
foreach($args['labels'] as $key => &$label){
|
151 |
-
|
152 |
-
$args['labels'][$key] = acf_translate($label);
|
153 |
-
|
154 |
-
}
|
155 |
-
|
156 |
-
}
|
157 |
-
|
158 |
-
}
|
159 |
-
|
160 |
-
$post_types = array();
|
161 |
-
if(acf_maybe_get($args, 'post_types')){
|
162 |
-
|
163 |
-
$post_types = $args['post_types'];
|
164 |
-
|
165 |
-
}
|
166 |
-
|
167 |
-
$post_types = var_export($post_types, true);
|
168 |
-
$post_types = str_replace( array_keys($str_replace), array_values($str_replace), $post_types );
|
169 |
-
$post_types = preg_replace( array_keys($preg_replace), array_values($preg_replace), $post_types );
|
170 |
-
|
171 |
-
|
172 |
-
// code
|
173 |
-
$code = var_export($args, true);
|
174 |
-
|
175 |
-
|
176 |
-
// change double spaces to tabs
|
177 |
-
$code = str_replace( array_keys($str_replace), array_values($str_replace), $code );
|
178 |
-
|
179 |
-
|
180 |
-
// correctly formats "=> array("
|
181 |
-
$code = preg_replace( array_keys($preg_replace), array_values($preg_replace), $code );
|
182 |
-
|
183 |
-
|
184 |
-
// esc_textarea
|
185 |
-
$code = esc_textarea( $code );
|
186 |
-
|
187 |
-
// echo
|
188 |
-
echo "register_taxonomy('{$taxonomy}', {$post_types}, {$code});" . "\r\n" . "\r\n";
|
189 |
-
|
190 |
-
}
|
191 |
-
|
192 |
-
?></textarea>
|
193 |
-
|
194 |
-
</div>
|
195 |
-
|
196 |
-
<p class="acf-submit">
|
197 |
-
<a class="button" id="acf-export-copy"><?php _e( 'Copy to clipboard', 'acf' ); ?></a>
|
198 |
-
</p>
|
199 |
-
<script type="text/javascript">
|
200 |
-
(function($){
|
201 |
-
|
202 |
-
// vars
|
203 |
-
var $a = $('#acf-export-copy');
|
204 |
-
var $textarea = $('#acf-export-textarea');
|
205 |
-
|
206 |
-
|
207 |
-
// remove $a if 'copy' is not supported
|
208 |
-
if( !document.queryCommandSupported('copy') ) {
|
209 |
-
return $a.remove();
|
210 |
-
}
|
211 |
-
|
212 |
-
|
213 |
-
// event
|
214 |
-
$a.on('click', function( e ){
|
215 |
-
|
216 |
-
// prevent default
|
217 |
-
e.preventDefault();
|
218 |
-
|
219 |
-
|
220 |
-
// select
|
221 |
-
$textarea.get(0).select();
|
222 |
-
|
223 |
-
|
224 |
-
// try
|
225 |
-
try {
|
226 |
-
|
227 |
-
// copy
|
228 |
-
var copy = document.execCommand('copy');
|
229 |
-
if( !copy ) return;
|
230 |
-
|
231 |
-
|
232 |
-
// tooltip
|
233 |
-
acf.newTooltip({
|
234 |
-
text: "<?php _e('Copied', 'acf' ); ?>",
|
235 |
-
timeout: 250,
|
236 |
-
target: $(this),
|
237 |
-
});
|
238 |
-
|
239 |
-
} catch (err) {
|
240 |
-
|
241 |
-
// do nothing
|
242 |
-
|
243 |
-
}
|
244 |
-
|
245 |
-
});
|
246 |
-
|
247 |
-
})(jQuery);
|
248 |
-
</script>
|
249 |
-
</div>
|
250 |
-
</div>
|
251 |
-
<?php
|
252 |
-
|
253 |
-
}
|
254 |
-
|
255 |
-
function load(){
|
256 |
-
|
257 |
-
if($this->is_active()){
|
258 |
-
|
259 |
-
$this->action = $this->get_action();
|
260 |
-
$this->data = $this->get_selected();
|
261 |
-
|
262 |
-
// Json submit
|
263 |
-
if($this->action === 'json')
|
264 |
-
$this->submit();
|
265 |
-
|
266 |
-
// add notice
|
267 |
-
if(!empty($this->data)){
|
268 |
-
|
269 |
-
$count = count($this->data);
|
270 |
-
$text = sprintf(_n( 'Exported 1 taxonomy.', 'Exported %s taxonomies.', $count, 'acf' ), $count);
|
271 |
-
|
272 |
-
acf_add_admin_notice($text, 'success');
|
273 |
-
|
274 |
-
}
|
275 |
-
|
276 |
-
}
|
277 |
-
|
278 |
-
}
|
279 |
-
|
280 |
-
function submit(){
|
281 |
-
|
282 |
-
$this->action = $this->get_action();
|
283 |
-
$this->data = $this->get_selected();
|
284 |
-
|
285 |
-
// validate
|
286 |
-
if($this->data === false)
|
287 |
-
return acf_add_admin_notice(__('No taxonomies selected'), 'warning');
|
288 |
-
|
289 |
-
$keys = array();
|
290 |
-
foreach($this->data as $key => $args){
|
291 |
-
|
292 |
-
$keys[] = $key;
|
293 |
-
|
294 |
-
}
|
295 |
-
|
296 |
-
if($this->action === 'json'){
|
297 |
-
|
298 |
-
// Prefix
|
299 |
-
$prefix = (count($keys) > 1) ? 'taxonomies' : 'taxonomy';
|
300 |
-
|
301 |
-
// Slugs
|
302 |
-
$slugs = implode('-', $keys);
|
303 |
-
|
304 |
-
// Date
|
305 |
-
$date = date('Y-m-d');
|
306 |
-
|
307 |
-
// file
|
308 |
-
$file_name = 'acfe-export-' . $prefix . '-' . $slugs . '-' . $date . '.json';
|
309 |
-
|
310 |
-
// headers
|
311 |
-
header("Content-Description: File Transfer");
|
312 |
-
header("Content-Disposition: attachment; filename={$file_name}");
|
313 |
-
header("Content-Type: application/json; charset=utf-8");
|
314 |
-
|
315 |
-
// return
|
316 |
-
echo acf_json_encode($this->data);
|
317 |
-
die;
|
318 |
-
|
319 |
-
}
|
320 |
-
|
321 |
-
elseif($this->action === 'php'){
|
322 |
-
|
323 |
-
// url
|
324 |
-
$url = add_query_arg(array(
|
325 |
-
'keys' => implode('+', $keys),
|
326 |
-
'action' => 'php'
|
327 |
-
), $this->get_url());
|
328 |
-
|
329 |
-
// redirect
|
330 |
-
wp_redirect($url);
|
331 |
-
exit;
|
332 |
-
|
333 |
-
}
|
334 |
-
|
335 |
-
}
|
336 |
-
|
337 |
-
function get_selected(){
|
338 |
-
|
339 |
-
// vars
|
340 |
-
$selected = $this->get_selected_keys();
|
341 |
-
$json = array();
|
342 |
-
|
343 |
-
if(!$selected)
|
344 |
-
return false;
|
345 |
-
|
346 |
-
$dynamic_taxonomies = acfe_settings('modules.dynamic_taxonomy.data');
|
347 |
-
|
348 |
-
if(empty($dynamic_taxonomies))
|
349 |
-
return false;
|
350 |
-
|
351 |
-
// construct JSON
|
352 |
-
foreach($selected as $key){
|
353 |
-
|
354 |
-
if(!isset($dynamic_taxonomies[$key]))
|
355 |
-
continue;
|
356 |
-
|
357 |
-
// add to json array
|
358 |
-
$json[$key] = $dynamic_taxonomies[$key];
|
359 |
-
|
360 |
-
}
|
361 |
-
|
362 |
-
// return
|
363 |
-
return $json;
|
364 |
-
|
365 |
-
}
|
366 |
-
|
367 |
-
function get_selected_keys(){
|
368 |
-
|
369 |
-
// check $_POST
|
370 |
-
if($keys = acf_maybe_get_POST('keys')){
|
371 |
-
|
372 |
-
return (array) $keys;
|
373 |
-
|
374 |
-
}
|
375 |
-
|
376 |
-
// check $_GET
|
377 |
-
if($keys = acf_maybe_get_GET('keys')){
|
378 |
-
|
379 |
-
$keys = str_replace(' ', '+', $keys);
|
380 |
-
return explode('+', $keys);
|
381 |
-
|
382 |
-
}
|
383 |
-
|
384 |
-
// return
|
385 |
-
return false;
|
386 |
-
|
387 |
-
}
|
388 |
-
|
389 |
-
function get_action(){
|
390 |
-
|
391 |
-
// init
|
392 |
-
$type = 'json';
|
393 |
-
|
394 |
-
// check GET / POST
|
395 |
-
if(($action = acf_maybe_get_GET('action')) || ($action = acf_maybe_get_POST('action'))){
|
396 |
-
|
397 |
-
if(in_array($action, array('json', 'php')))
|
398 |
-
$type = $action;
|
399 |
-
|
400 |
-
}
|
401 |
-
|
402 |
-
// return
|
403 |
-
return $type;
|
404 |
-
|
405 |
-
}
|
406 |
-
|
407 |
-
}
|
408 |
-
|
409 |
-
acf_register_admin_tool('ACFE_Admin_Tool_Export_DT');
|
410 |
-
|
411 |
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 = acfe_settings('modules.dynamic_taxonomy.data');
|
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 |
+
// Get settings.
|
130 |
+
$l10n = acf_get_setting('l10n');
|
131 |
+
$l10n_textdomain = acf_get_setting('l10n_textdomain');
|
132 |
+
|
133 |
+
?>
|
134 |
+
<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>
|
135 |
+
|
136 |
+
<div id="acf-admin-tool-export">
|
137 |
+
|
138 |
+
<textarea id="acf-export-textarea" readonly="true"><?php
|
139 |
+
|
140 |
+
foreach($this->data as $taxonomy => $args){
|
141 |
+
|
142 |
+
// Translate settings if textdomain is set.
|
143 |
+
if($l10n && $l10n_textdomain){
|
144 |
+
|
145 |
+
$args['label'] = acf_translate($args['label']);
|
146 |
+
$args['description'] = acf_translate($args['description']);
|
147 |
+
|
148 |
+
if(!empty($args['labels'])){
|
149 |
+
|
150 |
+
foreach($args['labels'] as $key => &$label){
|
151 |
+
|
152 |
+
$args['labels'][$key] = acf_translate($label);
|
153 |
+
|
154 |
+
}
|
155 |
+
|
156 |
+
}
|
157 |
+
|
158 |
+
}
|
159 |
+
|
160 |
+
$post_types = array();
|
161 |
+
if(acf_maybe_get($args, 'post_types')){
|
162 |
+
|
163 |
+
$post_types = $args['post_types'];
|
164 |
+
|
165 |
+
}
|
166 |
+
|
167 |
+
$post_types = var_export($post_types, true);
|
168 |
+
$post_types = str_replace( array_keys($str_replace), array_values($str_replace), $post_types );
|
169 |
+
$post_types = preg_replace( array_keys($preg_replace), array_values($preg_replace), $post_types );
|
170 |
+
|
171 |
+
|
172 |
+
// code
|
173 |
+
$code = var_export($args, true);
|
174 |
+
|
175 |
+
|
176 |
+
// change double spaces to tabs
|
177 |
+
$code = str_replace( array_keys($str_replace), array_values($str_replace), $code );
|
178 |
+
|
179 |
+
|
180 |
+
// correctly formats "=> array("
|
181 |
+
$code = preg_replace( array_keys($preg_replace), array_values($preg_replace), $code );
|
182 |
+
|
183 |
+
|
184 |
+
// esc_textarea
|
185 |
+
$code = esc_textarea( $code );
|
186 |
+
|
187 |
+
// echo
|
188 |
+
echo "register_taxonomy('{$taxonomy}', {$post_types}, {$code});" . "\r\n" . "\r\n";
|
189 |
+
|
190 |
+
}
|
191 |
+
|
192 |
+
?></textarea>
|
193 |
+
|
194 |
+
</div>
|
195 |
+
|
196 |
+
<p class="acf-submit">
|
197 |
+
<a class="button" id="acf-export-copy"><?php _e( 'Copy to clipboard', 'acf' ); ?></a>
|
198 |
+
</p>
|
199 |
+
<script type="text/javascript">
|
200 |
+
(function($){
|
201 |
+
|
202 |
+
// vars
|
203 |
+
var $a = $('#acf-export-copy');
|
204 |
+
var $textarea = $('#acf-export-textarea');
|
205 |
+
|
206 |
+
|
207 |
+
// remove $a if 'copy' is not supported
|
208 |
+
if( !document.queryCommandSupported('copy') ) {
|
209 |
+
return $a.remove();
|
210 |
+
}
|
211 |
+
|
212 |
+
|
213 |
+
// event
|
214 |
+
$a.on('click', function( e ){
|
215 |
+
|
216 |
+
// prevent default
|
217 |
+
e.preventDefault();
|
218 |
+
|
219 |
+
|
220 |
+
// select
|
221 |
+
$textarea.get(0).select();
|
222 |
+
|
223 |
+
|
224 |
+
// try
|
225 |
+
try {
|
226 |
+
|
227 |
+
// copy
|
228 |
+
var copy = document.execCommand('copy');
|
229 |
+
if( !copy ) return;
|
230 |
+
|
231 |
+
|
232 |
+
// tooltip
|
233 |
+
acf.newTooltip({
|
234 |
+
text: "<?php _e('Copied', 'acf' ); ?>",
|
235 |
+
timeout: 250,
|
236 |
+
target: $(this),
|
237 |
+
});
|
238 |
+
|
239 |
+
} catch (err) {
|
240 |
+
|
241 |
+
// do nothing
|
242 |
+
|
243 |
+
}
|
244 |
+
|
245 |
+
});
|
246 |
+
|
247 |
+
})(jQuery);
|
248 |
+
</script>
|
249 |
+
</div>
|
250 |
+
</div>
|
251 |
+
<?php
|
252 |
+
|
253 |
+
}
|
254 |
+
|
255 |
+
function load(){
|
256 |
+
|
257 |
+
if($this->is_active()){
|
258 |
+
|
259 |
+
$this->action = $this->get_action();
|
260 |
+
$this->data = $this->get_selected();
|
261 |
+
|
262 |
+
// Json submit
|
263 |
+
if($this->action === 'json')
|
264 |
+
$this->submit();
|
265 |
+
|
266 |
+
// add notice
|
267 |
+
if(!empty($this->data)){
|
268 |
+
|
269 |
+
$count = count($this->data);
|
270 |
+
$text = sprintf(_n( 'Exported 1 taxonomy.', 'Exported %s taxonomies.', $count, 'acf' ), $count);
|
271 |
+
|
272 |
+
acf_add_admin_notice($text, 'success');
|
273 |
+
|
274 |
+
}
|
275 |
+
|
276 |
+
}
|
277 |
+
|
278 |
+
}
|
279 |
+
|
280 |
+
function submit(){
|
281 |
+
|
282 |
+
$this->action = $this->get_action();
|
283 |
+
$this->data = $this->get_selected();
|
284 |
+
|
285 |
+
// validate
|
286 |
+
if($this->data === false)
|
287 |
+
return acf_add_admin_notice(__('No taxonomies selected'), 'warning');
|
288 |
+
|
289 |
+
$keys = array();
|
290 |
+
foreach($this->data as $key => $args){
|
291 |
+
|
292 |
+
$keys[] = $key;
|
293 |
+
|
294 |
+
}
|
295 |
+
|
296 |
+
if($this->action === 'json'){
|
297 |
+
|
298 |
+
// Prefix
|
299 |
+
$prefix = (count($keys) > 1) ? 'taxonomies' : 'taxonomy';
|
300 |
+
|
301 |
+
// Slugs
|
302 |
+
$slugs = implode('-', $keys);
|
303 |
+
|
304 |
+
// Date
|
305 |
+
$date = date('Y-m-d');
|
306 |
+
|
307 |
+
// file
|
308 |
+
$file_name = 'acfe-export-' . $prefix . '-' . $slugs . '-' . $date . '.json';
|
309 |
+
|
310 |
+
// headers
|
311 |
+
header("Content-Description: File Transfer");
|
312 |
+
header("Content-Disposition: attachment; filename={$file_name}");
|
313 |
+
header("Content-Type: application/json; charset=utf-8");
|
314 |
+
|
315 |
+
// return
|
316 |
+
echo acf_json_encode($this->data);
|
317 |
+
die;
|
318 |
+
|
319 |
+
}
|
320 |
+
|
321 |
+
elseif($this->action === 'php'){
|
322 |
+
|
323 |
+
// url
|
324 |
+
$url = add_query_arg(array(
|
325 |
+
'keys' => implode('+', $keys),
|
326 |
+
'action' => 'php'
|
327 |
+
), $this->get_url());
|
328 |
+
|
329 |
+
// redirect
|
330 |
+
wp_redirect($url);
|
331 |
+
exit;
|
332 |
+
|
333 |
+
}
|
334 |
+
|
335 |
+
}
|
336 |
+
|
337 |
+
function get_selected(){
|
338 |
+
|
339 |
+
// vars
|
340 |
+
$selected = $this->get_selected_keys();
|
341 |
+
$json = array();
|
342 |
+
|
343 |
+
if(!$selected)
|
344 |
+
return false;
|
345 |
+
|
346 |
+
$dynamic_taxonomies = acfe_settings('modules.dynamic_taxonomy.data');
|
347 |
+
|
348 |
+
if(empty($dynamic_taxonomies))
|
349 |
+
return false;
|
350 |
+
|
351 |
+
// construct JSON
|
352 |
+
foreach($selected as $key){
|
353 |
+
|
354 |
+
if(!isset($dynamic_taxonomies[$key]))
|
355 |
+
continue;
|
356 |
+
|
357 |
+
// add to json array
|
358 |
+
$json[$key] = $dynamic_taxonomies[$key];
|
359 |
+
|
360 |
+
}
|
361 |
+
|
362 |
+
// return
|
363 |
+
return $json;
|
364 |
+
|
365 |
+
}
|
366 |
+
|
367 |
+
function get_selected_keys(){
|
368 |
+
|
369 |
+
// check $_POST
|
370 |
+
if($keys = acf_maybe_get_POST('keys')){
|
371 |
+
|
372 |
+
return (array) $keys;
|
373 |
+
|
374 |
+
}
|
375 |
+
|
376 |
+
// check $_GET
|
377 |
+
if($keys = acf_maybe_get_GET('keys')){
|
378 |
+
|
379 |
+
$keys = str_replace(' ', '+', $keys);
|
380 |
+
return explode('+', $keys);
|
381 |
+
|
382 |
+
}
|
383 |
+
|
384 |
+
// return
|
385 |
+
return false;
|
386 |
+
|
387 |
+
}
|
388 |
+
|
389 |
+
function get_action(){
|
390 |
+
|
391 |
+
// init
|
392 |
+
$type = 'json';
|
393 |
+
|
394 |
+
// check GET / POST
|
395 |
+
if(($action = acf_maybe_get_GET('action')) || ($action = acf_maybe_get_POST('action'))){
|
396 |
+
|
397 |
+
if(in_array($action, array('json', 'php')))
|
398 |
+
$type = $action;
|
399 |
+
|
400 |
+
}
|
401 |
+
|
402 |
+
// return
|
403 |
+
return $type;
|
404 |
+
|
405 |
+
}
|
406 |
+
|
407 |
+
}
|
408 |
+
|
409 |
+
acf_register_admin_tool('ACFE_Admin_Tool_Export_DT');
|
410 |
+
|
411 |
endif;
|
@@ -1,240 +1,240 @@
|
|
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_Import_DT')):
|
11 |
-
|
12 |
-
class ACFE_Admin_Tool_Import_DT extends ACF_Admin_Tool{
|
13 |
-
|
14 |
-
function initialize(){
|
15 |
-
|
16 |
-
// vars
|
17 |
-
$this->name = 'acfe_tool_dt_import';
|
18 |
-
$this->title = __('Import Taxonomies');
|
19 |
-
$this->icon = 'dashicons-upload';
|
20 |
-
|
21 |
-
}
|
22 |
-
|
23 |
-
function html(){
|
24 |
-
|
25 |
-
?>
|
26 |
-
<p><?php _e('Import Taxonomies', '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 |
-
$dynamic_taxonomies = acfe_settings('modules.dynamic_taxonomy.data');
|
77 |
-
|
78 |
-
// Loop over json
|
79 |
-
foreach($json as $taxonomy_name => $args){
|
80 |
-
|
81 |
-
// Check if already exists
|
82 |
-
if(isset($dynamic_taxonomies[$taxonomy_name])){
|
83 |
-
|
84 |
-
acf_add_admin_notice(__("Taxonomy {$dynamic_taxonomies[$taxonomy_name]['label']} already exists. Import aborted."), 'warning');
|
85 |
-
continue;
|
86 |
-
|
87 |
-
}
|
88 |
-
|
89 |
-
// Vars
|
90 |
-
$title = $args['label'];
|
91 |
-
$name = $taxonomy_name;
|
92 |
-
|
93 |
-
// Insert post
|
94 |
-
$post_id = wp_insert_post(array(
|
95 |
-
'post_title' => $title,
|
96 |
-
'post_name' => $name,
|
97 |
-
'post_type' => 'acfe-dt',
|
98 |
-
'post_status' => 'publish'
|
99 |
-
));
|
100 |
-
|
101 |
-
// Insert error
|
102 |
-
if(is_wp_error($post_id)){
|
103 |
-
|
104 |
-
acf_add_admin_notice(__("Something went wrong with the taxonomy {$title}. Import aborted."), 'warning');
|
105 |
-
continue;
|
106 |
-
|
107 |
-
}
|
108 |
-
|
109 |
-
|
110 |
-
// Register Args
|
111 |
-
update_field('acfe_dt_name', $taxonomy_name, $post_id);
|
112 |
-
update_field('description', $args['description'], $post_id);
|
113 |
-
update_field('hierarchical', $args['hierarchical'], $post_id);
|
114 |
-
update_field('post_types', $args['post_types'], $post_id);
|
115 |
-
update_field('public', $args['public'], $post_id);
|
116 |
-
update_field('publicly_queryable', $args['publicly_queryable'], $post_id);
|
117 |
-
update_field('update_count_callback', $args['update_count_callback'], $post_id);
|
118 |
-
update_field('sort', $args['sort'], $post_id);
|
119 |
-
|
120 |
-
// Meta box callback
|
121 |
-
if(!isset($args['meta_box_cb']) || $args['meta_box_cb'] === null){
|
122 |
-
|
123 |
-
update_field('meta_box_cb', 'null', $post_id);
|
124 |
-
update_field('meta_box_cb_custom', '', $post_id);
|
125 |
-
|
126 |
-
}
|
127 |
-
|
128 |
-
elseif($args['meta_box_cb'] === false){
|
129 |
-
|
130 |
-
update_field('meta_box_cb', 'false', $post_id);
|
131 |
-
update_field('meta_box_cb_custom', '', $post_id);
|
132 |
-
|
133 |
-
}
|
134 |
-
|
135 |
-
elseif(empty($args['meta_box_cb']) || is_string($args['meta_box_cb'])){
|
136 |
-
|
137 |
-
update_field('meta_box_cb', 'custom', $post_id);
|
138 |
-
update_field('meta_box_cb_custom', $args['meta_box_cb'], $post_id);
|
139 |
-
|
140 |
-
}
|
141 |
-
|
142 |
-
// Labels
|
143 |
-
if(!empty($args['labels'])){
|
144 |
-
|
145 |
-
foreach($args['labels'] as $label_key => $label_value){
|
146 |
-
|
147 |
-
update_field('labels_' . $label_key, $label_value, $post_id);
|
148 |
-
|
149 |
-
}
|
150 |
-
|
151 |
-
}
|
152 |
-
|
153 |
-
// Menu
|
154 |
-
update_field('show_ui', $args['show_ui'], $post_id);
|
155 |
-
update_field('show_in_menu', $args['show_in_menu'], $post_id);
|
156 |
-
update_field('show_in_nav_menus', $args['show_in_nav_menus'], $post_id);
|
157 |
-
update_field('show_tagcloud', $args['show_tagcloud'], $post_id);
|
158 |
-
update_field('show_in_quick_edit', $args['show_in_quick_edit'], $post_id);
|
159 |
-
update_field('show_admin_column', $args['show_admin_column'], $post_id);
|
160 |
-
|
161 |
-
// Capability
|
162 |
-
if(isset($args['capabilities']))
|
163 |
-
update_field('capabilities', acf_encode_choices($args['capabilities'], false), $post_id);
|
164 |
-
|
165 |
-
// Single
|
166 |
-
update_field('acfe_dt_single_template', $args['acfe_single_template'], $post_id);
|
167 |
-
update_field('acfe_dt_single_posts_per_page', $args['acfe_single_ppp'], $post_id);
|
168 |
-
update_field('acfe_dt_single_orderby', $args['acfe_single_orderby'], $post_id);
|
169 |
-
update_field('acfe_dt_single_order', $args['acfe_single_order'], $post_id);
|
170 |
-
update_field('rewrite', $args['rewrite'], $post_id);
|
171 |
-
|
172 |
-
// Admin
|
173 |
-
update_field('acfe_dt_admin_terms_per_page', $args['acfe_admin_ppp'], $post_id);
|
174 |
-
update_field('acfe_dt_admin_orderby', $args['acfe_admin_orderby'], $post_id);
|
175 |
-
update_field('acfe_dt_admin_order', $args['acfe_admin_order'], $post_id);
|
176 |
-
|
177 |
-
// REST
|
178 |
-
update_field('show_in_rest', $args['show_in_rest'], $post_id);
|
179 |
-
update_field('rest_base', $args['rest_base'], $post_id);
|
180 |
-
update_field('rest_controller_class', $args['rest_controller_class'], $post_id);
|
181 |
-
|
182 |
-
// Rewrite: override
|
183 |
-
if($args['rewrite'] && is_array($args['rewrite'])){
|
184 |
-
|
185 |
-
update_field('rewrite', true, $post_id);
|
186 |
-
|
187 |
-
update_field('rewrite_args_select', true, $post_id);
|
188 |
-
|
189 |
-
update_field('rewrite_args_acfe_dt_rewrite_slug', $args['rewrite']['slug'], $post_id);
|
190 |
-
update_field('rewrite_args_acfe_dt_rewrite_with_front', $args['rewrite']['with_front'], $post_id);
|
191 |
-
update_field('rewrite_args_hierarchical', $args['rewrite']['hierarchical'], $post_id);
|
192 |
-
|
193 |
-
}
|
194 |
-
|
195 |
-
// Create ACFE option
|
196 |
-
$dynamic_taxonomies[$taxonomy_name] = $args;
|
197 |
-
|
198 |
-
// Sort keys ASC
|
199 |
-
ksort($dynamic_taxonomies);
|
200 |
-
|
201 |
-
// Update ACFE option
|
202 |
-
acfe_settings('modules.dynamic_taxonomy.data', $dynamic_taxonomies, true);
|
203 |
-
|
204 |
-
// append message
|
205 |
-
$ids[] = $post_id;
|
206 |
-
|
207 |
-
}
|
208 |
-
|
209 |
-
if(empty($ids))
|
210 |
-
return;
|
211 |
-
|
212 |
-
// Count total
|
213 |
-
$total = count($ids);
|
214 |
-
|
215 |
-
// Generate text
|
216 |
-
$text = sprintf(_n('1 taxonomy imported', '%s taxonomies imported', $total, 'acf'), $total);
|
217 |
-
|
218 |
-
// Add links to text
|
219 |
-
$links = array();
|
220 |
-
foreach($ids as $id){
|
221 |
-
|
222 |
-
$links[] = '<a href="' . get_edit_post_link($id) . '">' . get_the_title($id) . '</a>';
|
223 |
-
|
224 |
-
}
|
225 |
-
|
226 |
-
$text .= ': ' . implode(', ', $links);
|
227 |
-
|
228 |
-
// Add notice
|
229 |
-
acf_add_admin_notice($text, 'success');
|
230 |
-
|
231 |
-
// Flush permalinks
|
232 |
-
flush_rewrite_rules();
|
233 |
-
|
234 |
-
}
|
235 |
-
|
236 |
-
}
|
237 |
-
|
238 |
-
acf_register_admin_tool('ACFE_Admin_Tool_Import_DT');
|
239 |
-
|
240 |
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_Import_DT')):
|
11 |
+
|
12 |
+
class ACFE_Admin_Tool_Import_DT extends ACF_Admin_Tool{
|
13 |
+
|
14 |
+
function initialize(){
|
15 |
+
|
16 |
+
// vars
|
17 |
+
$this->name = 'acfe_tool_dt_import';
|
18 |
+
$this->title = __('Import Taxonomies');
|
19 |
+
$this->icon = 'dashicons-upload';
|
20 |
+
|
21 |
+
}
|
22 |
+
|
23 |
+
function html(){
|
24 |
+
|
25 |
+
?>
|
26 |
+
<p><?php _e('Import Taxonomies', '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 |
+
$dynamic_taxonomies = acfe_settings('modules.dynamic_taxonomy.data');
|
77 |
+
|
78 |
+
// Loop over json
|
79 |
+
foreach($json as $taxonomy_name => $args){
|
80 |
+
|
81 |
+
// Check if already exists
|
82 |
+
if(isset($dynamic_taxonomies[$taxonomy_name])){
|
83 |
+
|
84 |
+
acf_add_admin_notice(__("Taxonomy {$dynamic_taxonomies[$taxonomy_name]['label']} already exists. Import aborted."), 'warning');
|
85 |
+
continue;
|
86 |
+
|
87 |
+
}
|
88 |
+
|
89 |
+
// Vars
|
90 |
+
$title = $args['label'];
|
91 |
+
$name = $taxonomy_name;
|
92 |
+
|
93 |
+
// Insert post
|
94 |
+
$post_id = wp_insert_post(array(
|
95 |
+
'post_title' => $title,
|
96 |
+
'post_name' => $name,
|
97 |
+
'post_type' => 'acfe-dt',
|
98 |
+
'post_status' => 'publish'
|
99 |
+
));
|
100 |
+
|
101 |
+
// Insert error
|
102 |
+
if(is_wp_error($post_id)){
|
103 |
+
|
104 |
+
acf_add_admin_notice(__("Something went wrong with the taxonomy {$title}. Import aborted."), 'warning');
|
105 |
+
continue;
|
106 |
+
|
107 |
+
}
|
108 |
+
|
109 |
+
|
110 |
+
// Register Args
|
111 |
+
update_field('acfe_dt_name', $taxonomy_name, $post_id);
|
112 |
+
update_field('description', $args['description'], $post_id);
|
113 |
+
update_field('hierarchical', $args['hierarchical'], $post_id);
|
114 |
+
update_field('post_types', $args['post_types'], $post_id);
|
115 |
+
update_field('public', $args['public'], $post_id);
|
116 |
+
update_field('publicly_queryable', $args['publicly_queryable'], $post_id);
|
117 |
+
update_field('update_count_callback', $args['update_count_callback'], $post_id);
|
118 |
+
update_field('sort', $args['sort'], $post_id);
|
119 |
+
|
120 |
+
// Meta box callback
|
121 |
+
if(!isset($args['meta_box_cb']) || $args['meta_box_cb'] === null){
|
122 |
+
|
123 |
+
update_field('meta_box_cb', 'null', $post_id);
|
124 |
+
update_field('meta_box_cb_custom', '', $post_id);
|
125 |
+
|
126 |
+
}
|
127 |
+
|
128 |
+
elseif($args['meta_box_cb'] === false){
|
129 |
+
|
130 |
+
update_field('meta_box_cb', 'false', $post_id);
|
131 |
+
update_field('meta_box_cb_custom', '', $post_id);
|
132 |
+
|
133 |
+
}
|
134 |
+
|
135 |
+
elseif(empty($args['meta_box_cb']) || is_string($args['meta_box_cb'])){
|
136 |
+
|
137 |
+
update_field('meta_box_cb', 'custom', $post_id);
|
138 |
+
update_field('meta_box_cb_custom', $args['meta_box_cb'], $post_id);
|
139 |
+
|
140 |
+
}
|
141 |
+
|
142 |
+
// Labels
|
143 |
+
if(!empty($args['labels'])){
|
144 |
+
|
145 |
+
foreach($args['labels'] as $label_key => $label_value){
|
146 |
+
|
147 |
+
update_field('labels_' . $label_key, $label_value, $post_id);
|
148 |
+
|
149 |
+
}
|
150 |
+
|
151 |
+
}
|
152 |
+
|
153 |
+
// Menu
|
154 |
+
update_field('show_ui', $args['show_ui'], $post_id);
|
155 |
+
update_field('show_in_menu', $args['show_in_menu'], $post_id);
|
156 |
+
update_field('show_in_nav_menus', $args['show_in_nav_menus'], $post_id);
|
157 |
+
update_field('show_tagcloud', $args['show_tagcloud'], $post_id);
|
158 |
+
update_field('show_in_quick_edit', $args['show_in_quick_edit'], $post_id);
|
159 |
+
update_field('show_admin_column', $args['show_admin_column'], $post_id);
|
160 |
+
|
161 |
+
// Capability
|
162 |
+
if(isset($args['capabilities']))
|
163 |
+
update_field('capabilities', acf_encode_choices($args['capabilities'], false), $post_id);
|
164 |
+
|
165 |
+
// Single
|
166 |
+
update_field('acfe_dt_single_template', $args['acfe_single_template'], $post_id);
|
167 |
+
update_field('acfe_dt_single_posts_per_page', $args['acfe_single_ppp'], $post_id);
|
168 |
+
update_field('acfe_dt_single_orderby', $args['acfe_single_orderby'], $post_id);
|
169 |
+
update_field('acfe_dt_single_order', $args['acfe_single_order'], $post_id);
|
170 |
+
update_field('rewrite', $args['rewrite'], $post_id);
|
171 |
+
|
172 |
+
// Admin
|
173 |
+
update_field('acfe_dt_admin_terms_per_page', $args['acfe_admin_ppp'], $post_id);
|
174 |
+
update_field('acfe_dt_admin_orderby', $args['acfe_admin_orderby'], $post_id);
|
175 |
+
update_field('acfe_dt_admin_order', $args['acfe_admin_order'], $post_id);
|
176 |
+
|
177 |
+
// REST
|
178 |
+
update_field('show_in_rest', $args['show_in_rest'], $post_id);
|
179 |
+
update_field('rest_base', $args['rest_base'], $post_id);
|
180 |
+
update_field('rest_controller_class', $args['rest_controller_class'], $post_id);
|
181 |
+
|
182 |
+
// Rewrite: override
|
183 |
+
if($args['rewrite'] && is_array($args['rewrite'])){
|
184 |
+
|
185 |
+
update_field('rewrite', true, $post_id);
|
186 |
+
|
187 |
+
update_field('rewrite_args_select', true, $post_id);
|
188 |
+
|
189 |
+
update_field('rewrite_args_acfe_dt_rewrite_slug', $args['rewrite']['slug'], $post_id);
|
190 |
+
update_field('rewrite_args_acfe_dt_rewrite_with_front', $args['rewrite']['with_front'], $post_id);
|
191 |
+
update_field('rewrite_args_hierarchical', $args['rewrite']['hierarchical'], $post_id);
|
192 |
+
|
193 |
+
}
|
194 |
+
|
195 |
+
// Create ACFE option
|
196 |
+
$dynamic_taxonomies[$taxonomy_name] = $args;
|
197 |
+
|
198 |
+
// Sort keys ASC
|
199 |
+
ksort($dynamic_taxonomies);
|
200 |
+
|
201 |
+
// Update ACFE option
|
202 |
+
acfe_settings('modules.dynamic_taxonomy.data', $dynamic_taxonomies, true);
|
203 |
+
|
204 |
+
// append message
|
205 |
+
$ids[] = $post_id;
|
206 |
+
|
207 |
+
}
|
208 |
+
|
209 |
+
if(empty($ids))
|
210 |
+
return;
|
211 |
+
|
212 |
+
// Count total
|
213 |
+
$total = count($ids);
|
214 |
+
|
215 |
+
// Generate text
|
216 |
+
$text = sprintf(_n('1 taxonomy imported', '%s taxonomies imported', $total, 'acf'), $total);
|
217 |
+
|
218 |
+
// Add links to text
|
219 |
+
$links = array();
|
220 |
+
foreach($ids as $id){
|
221 |
+
|
222 |
+
$links[] = '<a href="' . get_edit_post_link($id) . '">' . get_the_title($id) . '</a>';
|
223 |
+
|
224 |
+
}
|
225 |
+
|
226 |
+
$text .= ': ' . implode(', ', $links);
|
227 |
+
|
228 |
+
// Add notice
|
229 |
+
acf_add_admin_notice($text, 'success');
|
230 |
+
|
231 |
+
// Flush permalinks
|
232 |
+
flush_rewrite_rules();
|
233 |
+
|
234 |
+
}
|
235 |
+
|
236 |
+
}
|
237 |
+
|
238 |
+
acf_register_admin_tool('ACFE_Admin_Tool_Import_DT');
|
239 |
+
|
240 |
endif;
|
@@ -1,65 +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;
|
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;
|
@@ -1,333 +1,333 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
if(!class_exists('ACFE_Admin_Tool_FG_Local_Export')):
|
7 |
-
|
8 |
-
class ACFE_Admin_Tool_FG_Local extends ACF_Admin_Tool{
|
9 |
-
|
10 |
-
function initialize(){
|
11 |
-
|
12 |
-
// vars
|
13 |
-
$this->title = __('Export Local Field Groups');
|
14 |
-
$this->name = 'acfe-fg-local';
|
15 |
-
$this->icon = 'dashicons-upload';
|
16 |
-
|
17 |
-
}
|
18 |
-
|
19 |
-
function load(){
|
20 |
-
|
21 |
-
if($ids = acf_maybe_get_GET('acfe-fg-local-sync')){
|
22 |
-
|
23 |
-
$ids = explode(' ', $ids);
|
24 |
-
|
25 |
-
// Count number of imported field groups.
|
26 |
-
$total = count($ids);
|
27 |
-
|
28 |
-
// Generate text.
|
29 |
-
$text = sprintf( _n( 'Imported 1 field group', 'Imported %s field groups', $total, 'acf' ), $total );
|
30 |
-
|
31 |
-
// Add links to text.
|
32 |
-
$links = array();
|
33 |
-
foreach( $ids as $id ) {
|
34 |
-
$links[] = '<a href="' . get_edit_post_link( $id ) . '">' . get_the_title( $id ) . '</a>';
|
35 |
-
}
|
36 |
-
$text .= ' ' . implode( ', ', $links );
|
37 |
-
|
38 |
-
// Add notice
|
39 |
-
acf_add_admin_notice($text, 'success');
|
40 |
-
|
41 |
-
}
|
42 |
-
|
43 |
-
if($this->is_active()){
|
44 |
-
|
45 |
-
$array = $this->get_selected();
|
46 |
-
$keys = $this->get_selected_keys();
|
47 |
-
$action = $this->get_action();
|
48 |
-
|
49 |
-
// validate
|
50 |
-
if($array === false)
|
51 |
-
return acf_add_admin_notice(__('No field group selected'), 'warning');
|
52 |
-
|
53 |
-
// Json
|
54 |
-
if($action === 'json'){
|
55 |
-
|
56 |
-
// Slugs
|
57 |
-
$slugs = implode('-', $keys);
|
58 |
-
|
59 |
-
// Date
|
60 |
-
$date = date('Y-m-d');
|
61 |
-
|
62 |
-
// file
|
63 |
-
$file_name = 'acfe-export-local-' . $slugs . '-' . $date . '.json';
|
64 |
-
|
65 |
-
// headers
|
66 |
-
header("Content-Description: File Transfer");
|
67 |
-
header("Content-Disposition: attachment; filename={$file_name}");
|
68 |
-
header("Content-Type: application/json; charset=utf-8");
|
69 |
-
|
70 |
-
// return
|
71 |
-
echo acf_json_encode($array);
|
72 |
-
die;
|
73 |
-
|
74 |
-
}
|
75 |
-
|
76 |
-
// Sync
|
77 |
-
elseif($action === 'sync'){
|
78 |
-
|
79 |
-
// Force array
|
80 |
-
$array = acf_array($array);
|
81 |
-
|
82 |
-
// Remeber imported field group ids.
|
83 |
-
$ids = array();
|
84 |
-
|
85 |
-
// Loop over json
|
86 |
-
foreach($array as $field_group){
|
87 |
-
|
88 |
-
// Search database for existing field group.
|
89 |
-
$post = acf_get_field_group_post($field_group['key']);
|
90 |
-
|
91 |
-
if($post)
|
92 |
-
$field_group['ID'] = $post->ID;
|
93 |
-
|
94 |
-
// Import field group.
|
95 |
-
$field_group = acf_import_field_group($field_group);
|
96 |
-
|
97 |
-
// append message
|
98 |
-
$ids[] = $field_group['ID'];
|
99 |
-
|
100 |
-
}
|
101 |
-
|
102 |
-
// url
|
103 |
-
$url = add_query_arg('acfe-fg-local-sync', implode('+', $ids), acf_get_admin_tools_url());
|
104 |
-
|
105 |
-
// redirect
|
106 |
-
wp_redirect($url);
|
107 |
-
exit;
|
108 |
-
|
109 |
-
}
|
110 |
-
|
111 |
-
}
|
112 |
-
|
113 |
-
}
|
114 |
-
|
115 |
-
function html(){
|
116 |
-
|
117 |
-
if($this->is_active()){
|
118 |
-
|
119 |
-
$array = $this->get_selected();
|
120 |
-
$action = $this->get_action();
|
121 |
-
|
122 |
-
?>
|
123 |
-
<div class="acf-postbox-columns">
|
124 |
-
<div class="acf-postbox-main">
|
125 |
-
|
126 |
-
<?php
|
127 |
-
// prevent default translation and fake __() within string
|
128 |
-
acf_update_setting('l10n_var_export', true);
|
129 |
-
|
130 |
-
// vars
|
131 |
-
$json = $array;
|
132 |
-
|
133 |
-
$str_replace = array(
|
134 |
-
" " => "\t",
|
135 |
-
"'!!__(!!\'" => "__('",
|
136 |
-
"!!\', !!\'" => "', '",
|
137 |
-
"!!\')!!'" => "')",
|
138 |
-
"array (" => "array("
|
139 |
-
);
|
140 |
-
|
141 |
-
$preg_replace = array(
|
142 |
-
'/([\t\r\n]+?)array/' => 'array',
|
143 |
-
'/[0-9]+ => array/' => 'array'
|
144 |
-
);
|
145 |
-
|
146 |
-
|
147 |
-
?>
|
148 |
-
<p><?php _e("The following code can be used to register a local version of the selected field group(s). A local field group can provide many benefits such as faster load times, version control & dynamic fields/settings. Simply copy and paste the following code to your theme's functions.php file or include it within an external file.", 'acf'); ?></p>
|
149 |
-
|
150 |
-
<div id="acf-admin-tool-export">
|
151 |
-
|
152 |
-
<textarea id="acf-export-textarea" readonly="true"><?php
|
153 |
-
|
154 |
-
echo "if( function_exists('acf_add_local_field_group') ):" . "\r\n" . "\r\n";
|
155 |
-
|
156 |
-
foreach( $json as $field_group ) {
|
157 |
-
|
158 |
-
// code
|
159 |
-
$code = var_export($field_group, true);
|
160 |
-
|
161 |
-
|
162 |
-
// change double spaces to tabs
|
163 |
-
$code = str_replace( array_keys($str_replace), array_values($str_replace), $code );
|
164 |
-
|
165 |
-
|
166 |
-
// correctly formats "=> array("
|
167 |
-
$code = preg_replace( array_keys($preg_replace), array_values($preg_replace), $code );
|
168 |
-
|
169 |
-
|
170 |
-
// esc_textarea
|
171 |
-
$code = esc_textarea( $code );
|
172 |
-
|
173 |
-
|
174 |
-
// echo
|
175 |
-
echo "acf_add_local_field_group({$code});" . "\r\n" . "\r\n";
|
176 |
-
|
177 |
-
}
|
178 |
-
|
179 |
-
echo "endif;";
|
180 |
-
|
181 |
-
?></textarea>
|
182 |
-
|
183 |
-
</div>
|
184 |
-
|
185 |
-
<p class="acf-submit">
|
186 |
-
<a class="button" id="acf-export-copy"><?php _e( 'Copy to clipboard', 'acf' ); ?></a>
|
187 |
-
</p>
|
188 |
-
<script type="text/javascript">
|
189 |
-
(function($){
|
190 |
-
|
191 |
-
// vars
|
192 |
-
var $a = $('#acf-export-copy');
|
193 |
-
var $textarea = $('#acf-export-textarea');
|
194 |
-
|
195 |
-
|
196 |
-
// remove $a if 'copy' is not supported
|
197 |
-
if( !document.queryCommandSupported('copy') ) {
|
198 |
-
return $a.remove();
|
199 |
-
}
|
200 |
-
|
201 |
-
|
202 |
-
// event
|
203 |
-
$a.on('click', function( e ){
|
204 |
-
|
205 |
-
// prevent default
|
206 |
-
e.preventDefault();
|
207 |
-
|
208 |
-
|
209 |
-
// select
|
210 |
-
$textarea.get(0).select();
|
211 |
-
|
212 |
-
|
213 |
-
// try
|
214 |
-
try {
|
215 |
-
|
216 |
-
// copy
|
217 |
-
var copy = document.execCommand('copy');
|
218 |
-
if( !copy ) return;
|
219 |
-
|
220 |
-
|
221 |
-
// tooltip
|
222 |
-
acf.newTooltip({
|
223 |
-
text: "<?php _e('Copied', 'acf' ); ?>",
|
224 |
-
timeout: 250,
|
225 |
-
target: $(this),
|
226 |
-
});
|
227 |
-
|
228 |
-
} catch (err) {
|
229 |
-
|
230 |
-
// do nothing
|
231 |
-
|
232 |
-
}
|
233 |
-
|
234 |
-
});
|
235 |
-
|
236 |
-
})(jQuery);
|
237 |
-
</script>
|
238 |
-
</div>
|
239 |
-
</div>
|
240 |
-
<?php
|
241 |
-
|
242 |
-
}
|
243 |
-
|
244 |
-
}
|
245 |
-
|
246 |
-
function get_selected(){
|
247 |
-
|
248 |
-
// vars
|
249 |
-
$selected = $this->get_selected_keys();
|
250 |
-
|
251 |
-
if(!$selected)
|
252 |
-
return false;
|
253 |
-
|
254 |
-
// Return
|
255 |
-
$array = array();
|
256 |
-
|
257 |
-
// Enable filters
|
258 |
-
acf_enable_filters();
|
259 |
-
|
260 |
-
// Disable fitler: clone
|
261 |
-
acf_disable_filter('clone');
|
262 |
-
|
263 |
-
// Get desync PHP Field Groups
|
264 |
-
$desync_php_field_groups = acfe_get_desync_php_field_groups();
|
265 |
-
|
266 |
-
foreach($desync_php_field_groups as $file_key => $file_path){
|
267 |
-
|
268 |
-
require_once($file_path);
|
269 |
-
|
270 |
-
}
|
271 |
-
|
272 |
-
foreach($selected as $field_group_key){
|
273 |
-
|
274 |
-
$field_group = acf_get_field_group($field_group_key);
|
275 |
-
|
276 |
-
// validate field group
|
277 |
-
if(empty($field_group))
|
278 |
-
continue;
|
279 |
-
|
280 |
-
// load fields
|
281 |
-
$field_group['fields'] = acf_get_fields($field_group);
|
282 |
-
|
283 |
-
// prepare for export
|
284 |
-
$field_group = acf_prepare_field_group_for_export($field_group);
|
285 |
-
|
286 |
-
$array[] = $field_group;
|
287 |
-
|
288 |
-
}
|
289 |
-
|
290 |
-
// return
|
291 |
-
return $array;
|
292 |
-
|
293 |
-
}
|
294 |
-
|
295 |
-
function get_selected_keys(){
|
296 |
-
|
297 |
-
// check $_POST
|
298 |
-
if($keys = acf_maybe_get_POST('keys'))
|
299 |
-
return (array) $keys;
|
300 |
-
|
301 |
-
// check $_GET
|
302 |
-
if($keys = acf_maybe_get_GET('keys')){
|
303 |
-
|
304 |
-
$keys = str_replace(' ', '+', $keys);
|
305 |
-
return explode('+', $keys);
|
306 |
-
|
307 |
-
}
|
308 |
-
|
309 |
-
// return
|
310 |
-
return false;
|
311 |
-
|
312 |
-
}
|
313 |
-
|
314 |
-
function get_action(){
|
315 |
-
|
316 |
-
// check $_POST
|
317 |
-
if($action = acf_maybe_get_POST('action'))
|
318 |
-
return $action;
|
319 |
-
|
320 |
-
// check $_GET
|
321 |
-
if($action = acf_maybe_get_GET('action'))
|
322 |
-
return $action;
|
323 |
-
|
324 |
-
// return
|
325 |
-
return 'json';
|
326 |
-
|
327 |
-
}
|
328 |
-
|
329 |
-
}
|
330 |
-
|
331 |
-
acf_register_admin_tool('ACFE_Admin_Tool_FG_Local');
|
332 |
-
|
333 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
if(!class_exists('ACFE_Admin_Tool_FG_Local_Export')):
|
7 |
+
|
8 |
+
class ACFE_Admin_Tool_FG_Local extends ACF_Admin_Tool{
|
9 |
+
|
10 |
+
function initialize(){
|
11 |
+
|
12 |
+
// vars
|
13 |
+
$this->title = __('Export Local Field Groups');
|
14 |
+
$this->name = 'acfe-fg-local';
|
15 |
+
$this->icon = 'dashicons-upload';
|
16 |
+
|
17 |
+
}
|
18 |
+
|
19 |
+
function load(){
|
20 |
+
|
21 |
+
if($ids = acf_maybe_get_GET('acfe-fg-local-sync')){
|
22 |
+
|
23 |
+
$ids = explode(' ', $ids);
|
24 |
+
|
25 |
+
// Count number of imported field groups.
|
26 |
+
$total = count($ids);
|
27 |
+
|
28 |
+
// Generate text.
|
29 |
+
$text = sprintf( _n( 'Imported 1 field group', 'Imported %s field groups', $total, 'acf' ), $total );
|
30 |
+
|
31 |
+
// Add links to text.
|
32 |
+
$links = array();
|
33 |
+
foreach( $ids as $id ) {
|
34 |
+
$links[] = '<a href="' . get_edit_post_link( $id ) . '">' . get_the_title( $id ) . '</a>';
|
35 |
+
}
|
36 |
+
$text .= ' ' . implode( ', ', $links );
|
37 |
+
|
38 |
+
// Add notice
|
39 |
+
acf_add_admin_notice($text, 'success');
|
40 |
+
|
41 |
+
}
|
42 |
+
|
43 |
+
if($this->is_active()){
|
44 |
+
|
45 |
+
$array = $this->get_selected();
|
46 |
+
$keys = $this->get_selected_keys();
|
47 |
+
$action = $this->get_action();
|
48 |
+
|
49 |
+
// validate
|
50 |
+
if($array === false)
|
51 |
+
return acf_add_admin_notice(__('No field group selected'), 'warning');
|
52 |
+
|
53 |
+
// Json
|
54 |
+
if($action === 'json'){
|
55 |
+
|
56 |
+
// Slugs
|
57 |
+
$slugs = implode('-', $keys);
|
58 |
+
|
59 |
+
// Date
|
60 |
+
$date = date('Y-m-d');
|
61 |
+
|
62 |
+
// file
|
63 |
+
$file_name = 'acfe-export-local-' . $slugs . '-' . $date . '.json';
|
64 |
+
|
65 |
+
// headers
|
66 |
+
header("Content-Description: File Transfer");
|
67 |
+
header("Content-Disposition: attachment; filename={$file_name}");
|
68 |
+
header("Content-Type: application/json; charset=utf-8");
|
69 |
+
|
70 |
+
// return
|
71 |
+
echo acf_json_encode($array);
|
72 |
+
die;
|
73 |
+
|
74 |
+
}
|
75 |
+
|
76 |
+
// Sync
|
77 |
+
elseif($action === 'sync'){
|
78 |
+
|
79 |
+
// Force array
|
80 |
+
$array = acf_array($array);
|
81 |
+
|
82 |
+
// Remeber imported field group ids.
|
83 |
+
$ids = array();
|
84 |
+
|
85 |
+
// Loop over json
|
86 |
+
foreach($array as $field_group){
|
87 |
+
|
88 |
+
// Search database for existing field group.
|
89 |
+
$post = acf_get_field_group_post($field_group['key']);
|
90 |
+
|
91 |
+
if($post)
|
92 |
+
$field_group['ID'] = $post->ID;
|
93 |
+
|
94 |
+
// Import field group.
|
95 |
+
$field_group = acf_import_field_group($field_group);
|
96 |
+
|
97 |
+
// append message
|
98 |
+
$ids[] = $field_group['ID'];
|
99 |
+
|
100 |
+
}
|
101 |
+
|
102 |
+
// url
|
103 |
+
$url = add_query_arg('acfe-fg-local-sync', implode('+', $ids), acf_get_admin_tools_url());
|
104 |
+
|
105 |
+
// redirect
|
106 |
+
wp_redirect($url);
|
107 |
+
exit;
|
108 |
+
|
109 |
+
}
|
110 |
+
|
111 |
+
}
|
112 |
+
|
113 |
+
}
|
114 |
+
|
115 |
+
function html(){
|
116 |
+
|
117 |
+
if($this->is_active()){
|
118 |
+
|
119 |
+
$array = $this->get_selected();
|
120 |
+
$action = $this->get_action();
|
121 |
+
|
122 |
+
?>
|
123 |
+
<div class="acf-postbox-columns">
|
124 |
+
<div class="acf-postbox-main">
|
125 |
+
|
126 |
+
<?php
|
127 |
+
// prevent default translation and fake __() within string
|
128 |
+
acf_update_setting('l10n_var_export', true);
|
129 |
+
|
130 |
+
// vars
|
131 |
+
$json = $array;
|
132 |
+
|
133 |
+
$str_replace = array(
|
134 |
+
" " => "\t",
|
135 |
+
"'!!__(!!\'" => "__('",
|
136 |
+
"!!\', !!\'" => "', '",
|
137 |
+
"!!\')!!'" => "')",
|
138 |
+
"array (" => "array("
|
139 |
+
);
|
140 |
+
|
141 |
+
$preg_replace = array(
|
142 |
+
'/([\t\r\n]+?)array/' => 'array',
|
143 |
+
'/[0-9]+ => array/' => 'array'
|
144 |
+
);
|
145 |
+
|
146 |
+
|
147 |
+
?>
|
148 |
+
<p><?php _e("The following code can be used to register a local version of the selected field group(s). A local field group can provide many benefits such as faster load times, version control & dynamic fields/settings. Simply copy and paste the following code to your theme's functions.php file or include it within an external file.", 'acf'); ?></p>
|
149 |
+
|
150 |
+
<div id="acf-admin-tool-export">
|
151 |
+
|
152 |
+
<textarea id="acf-export-textarea" readonly="true"><?php
|
153 |
+
|
154 |
+
echo "if( function_exists('acf_add_local_field_group') ):" . "\r\n" . "\r\n";
|
155 |
+
|
156 |
+
foreach( $json as $field_group ) {
|
157 |
+
|
158 |
+
// code
|
159 |
+
$code = var_export($field_group, true);
|
160 |
+
|
161 |
+
|
162 |
+
// change double spaces to tabs
|
163 |
+
$code = str_replace( array_keys($str_replace), array_values($str_replace), $code );
|
164 |
+
|
165 |
+
|
166 |
+
// correctly formats "=> array("
|
167 |
+
$code = preg_replace( array_keys($preg_replace), array_values($preg_replace), $code );
|
168 |
+
|
169 |
+
|
170 |
+
// esc_textarea
|
171 |
+
$code = esc_textarea( $code );
|
172 |
+
|
173 |
+
|
174 |
+
// echo
|
175 |
+
echo "acf_add_local_field_group({$code});" . "\r\n" . "\r\n";
|
176 |
+
|
177 |
+
}
|
178 |
+
|
179 |
+
echo "endif;";
|
180 |
+
|
181 |
+
?></textarea>
|
182 |
+
|
183 |
+
</div>
|
184 |
+
|
185 |
+
<p class="acf-submit">
|
186 |
+
<a class="button" id="acf-export-copy"><?php _e( 'Copy to clipboard', 'acf' ); ?></a>
|
187 |
+
</p>
|
188 |
+
<script type="text/javascript">
|
189 |
+
(function($){
|
190 |
+
|
191 |
+
// vars
|
192 |
+
var $a = $('#acf-export-copy');
|
193 |
+
var $textarea = $('#acf-export-textarea');
|
194 |
+
|
195 |
+
|
196 |
+
// remove $a if 'copy' is not supported
|
197 |
+
if( !document.queryCommandSupported('copy') ) {
|
198 |
+
return $a.remove();
|
199 |
+
}
|
200 |
+
|
201 |
+
|
202 |
+
// event
|
203 |
+
$a.on('click', function( e ){
|
204 |
+
|
205 |
+
// prevent default
|
206 |
+
e.preventDefault();
|
207 |
+
|
208 |
+
|
209 |
+
// select
|
210 |
+
$textarea.get(0).select();
|
211 |
+
|
212 |
+
|
213 |
+
// try
|
214 |
+
try {
|
215 |
+
|
216 |
+
// copy
|
217 |
+
var copy = document.execCommand('copy');
|
218 |
+
if( !copy ) return;
|
219 |
+
|
220 |
+
|
221 |
+
// tooltip
|
222 |
+
acf.newTooltip({
|
223 |
+
text: "<?php _e('Copied', 'acf' ); ?>",
|
224 |
+
timeout: 250,
|
225 |
+
target: $(this),
|
226 |
+
});
|
227 |
+
|
228 |
+
} catch (err) {
|
229 |
+
|
230 |
+
// do nothing
|
231 |
+
|
232 |
+
}
|
233 |
+
|
234 |
+
});
|
235 |
+
|
236 |
+
})(jQuery);
|
237 |
+
</script>
|
238 |
+
</div>
|
239 |
+
</div>
|
240 |
+
<?php
|
241 |
+
|
242 |
+
}
|
243 |
+
|
244 |
+
}
|
245 |
+
|
246 |
+
function get_selected(){
|
247 |
+
|
248 |
+
// vars
|
249 |
+
$selected = $this->get_selected_keys();
|
250 |
+
|
251 |
+
if(!$selected)
|
252 |
+
return false;
|
253 |
+
|
254 |
+
// Return
|
255 |
+
$array = array();
|
256 |
+
|
257 |
+
// Enable filters
|
258 |
+
acf_enable_filters();
|
259 |
+
|
260 |
+
// Disable fitler: clone
|
261 |
+
acf_disable_filter('clone');
|
262 |
+
|
263 |
+
// Get desync PHP Field Groups
|
264 |
+
$desync_php_field_groups = acfe_get_desync_php_field_groups();
|
265 |
+
|
266 |
+
foreach($desync_php_field_groups as $file_key => $file_path){
|
267 |
+
|
268 |
+
require_once($file_path);
|
269 |
+
|
270 |
+
}
|
271 |
+
|
272 |
+
foreach($selected as $field_group_key){
|
273 |
+
|
274 |
+
$field_group = acf_get_field_group($field_group_key);
|
275 |
+
|
276 |
+
// validate field group
|
277 |
+
if(empty($field_group))
|
278 |
+
continue;
|
279 |
+
|
280 |
+
// load fields
|
281 |
+
$field_group['fields'] = acf_get_fields($field_group);
|
282 |
+
|
283 |
+
// prepare for export
|
284 |
+
$field_group = acf_prepare_field_group_for_export($field_group);
|
285 |
+
|
286 |
+
$array[] = $field_group;
|
287 |
+
|
288 |
+
}
|
289 |
+
|
290 |
+
// return
|
291 |
+
return $array;
|
292 |
+
|
293 |
+
}
|
294 |
+
|
295 |
+
function get_selected_keys(){
|
296 |
+
|
297 |
+
// check $_POST
|
298 |
+
if($keys = acf_maybe_get_POST('keys'))
|
299 |
+
return (array) $keys;
|
300 |
+
|
301 |
+
// check $_GET
|
302 |
+
if($keys = acf_maybe_get_GET('keys')){
|
303 |
+
|
304 |
+
$keys = str_replace(' ', '+', $keys);
|
305 |
+
return explode('+', $keys);
|
306 |
+
|
307 |
+
}
|
308 |
+
|
309 |
+
// return
|
310 |
+
return false;
|
311 |
+
|
312 |
+
}
|
313 |
+
|
314 |
+
function get_action(){
|
315 |
+
|
316 |
+
// check $_POST
|
317 |
+
if($action = acf_maybe_get_POST('action'))
|
318 |
+
return $action;
|
319 |
+
|
320 |
+
// check $_GET
|
321 |
+
if($action = acf_maybe_get_GET('action'))
|
322 |
+
return $action;
|
323 |
+
|
324 |
+
// return
|
325 |
+
return 'json';
|
326 |
+
|
327 |
+
}
|
328 |
+
|
329 |
+
}
|
330 |
+
|
331 |
+
acf_register_admin_tool('ACFE_Admin_Tool_FG_Local');
|
332 |
+
|
333 |
endif;
|
@@ -1,239 +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 $args){
|
141 |
-
|
142 |
-
$keys[] = $args['acfe_form_name'];
|
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[] = 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;
|
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 $args){
|
141 |
+
|
142 |
+
$keys[] = $args['acfe_form_name'];
|
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[] = 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;
|
@@ -1,459 +1,459 @@
|
|
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 $args){
|
78 |
-
|
79 |
-
// Check if already exists
|
80 |
-
if(get_page_by_path($args['acfe_form_name'], OBJECT, 'acfe-form')){
|
81 |
-
|
82 |
-
acf_add_admin_notice(__("Form {$args['title']} already exists. Import aborted."), 'warning');
|
83 |
-
|
84 |
-
continue;
|
85 |
-
|
86 |
-
}
|
87 |
-
|
88 |
-
// Import
|
89 |
-
$post_id = $this->import($args);
|
90 |
-
|
91 |
-
// Insert error
|
92 |
-
if(!$post_id){
|
93 |
-
|
94 |
-
acf_add_admin_notice(__("Something went wrong with the form {$args['title']}. Import aborted."), 'warning');
|
95 |
-
|
96 |
-
continue;
|
97 |
-
|
98 |
-
}
|
99 |
-
|
100 |
-
// append message
|
101 |
-
$ids[] = $post_id;
|
102 |
-
|
103 |
-
}
|
104 |
-
|
105 |
-
if(empty($ids))
|
106 |
-
return false;
|
107 |
-
|
108 |
-
// Count total
|
109 |
-
$total = count($ids);
|
110 |
-
|
111 |
-
// Generate text
|
112 |
-
$text = sprintf(_n('1 form imported', '%s forms imported', $total, 'acf'), $total);
|
113 |
-
|
114 |
-
// Add links to text
|
115 |
-
$links = array();
|
116 |
-
foreach($ids as $id){
|
117 |
-
|
118 |
-
$links[] = '<a href="' . get_edit_post_link($id) . '">' . get_the_title($id) . '</a>';
|
119 |
-
|
120 |
-
}
|
121 |
-
|
122 |
-
$text .= ': ' . implode(', ', $links);
|
123 |
-
|
124 |
-
// Add notice
|
125 |
-
acf_add_admin_notice($text, 'success');
|
126 |
-
|
127 |
-
}
|
128 |
-
|
129 |
-
function import($args){
|
130 |
-
|
131 |
-
// Vars
|
132 |
-
$title = acf_extract_var($args, 'title');
|
133 |
-
$name = $args['acfe_form_name'];
|
134 |
-
|
135 |
-
// Insert post
|
136 |
-
$post_id = wp_insert_post(array(
|
137 |
-
'post_title' => $title,
|
138 |
-
'post_name' => $name,
|
139 |
-
'post_type' => 'acfe-form',
|
140 |
-
'post_status' => 'publish'
|
141 |
-
));
|
142 |
-
|
143 |
-
// Insert error
|
144 |
-
if(is_wp_error($post_id))
|
145 |
-
return false;
|
146 |
-
|
147 |
-
acf_enable_filter('local');
|
148 |
-
|
149 |
-
// Import Compatibility
|
150 |
-
$args = $this->import_compatibility($args);
|
151 |
-
|
152 |
-
// Update Values
|
153 |
-
acf_update_values($args, $post_id);
|
154 |
-
|
155 |
-
acf_disable_filter('local');
|
156 |
-
|
157 |
-
return $post_id;
|
158 |
-
|
159 |
-
}
|
160 |
-
|
161 |
-
function import_compatibility($args){
|
162 |
-
|
163 |
-
// ACF Extended: 0.8.5 Compatibility - Step 1
|
164 |
-
// Groups upgrade
|
165 |
-
$has_upgraded = false;
|
166 |
-
|
167 |
-
$rules = array(
|
168 |
-
|
169 |
-
// Post: title
|
170 |
-
array(
|
171 |
-
'group' => 'field_acfe_form_post_save_post_title_group',
|
172 |
-
'sub_field' => 'field_acfe_form_post_save_post_title',
|
173 |
-
'sub_field_custom' => 'field_acfe_form_post_save_post_title_custom',
|
174 |
-
),
|
175 |
-
|
176 |
-
// Post: name
|
177 |
-
array(
|
178 |
-
'group' => 'field_acfe_form_post_save_post_name_group',
|
179 |
-
'sub_field' => 'field_acfe_form_post_save_post_name',
|
180 |
-
'sub_field_custom' => 'field_acfe_form_post_save_post_name_custom',
|
181 |
-
),
|
182 |
-
|
183 |
-
// Term: name
|
184 |
-
array(
|
185 |
-
'group' => 'field_acfe_form_term_save_name_group',
|
186 |
-
'sub_field' => 'field_acfe_form_term_save_name',
|
187 |
-
'sub_field_custom' => 'field_acfe_form_term_save_name_custom',
|
188 |
-
),
|
189 |
-
|
190 |
-
// Term: slug
|
191 |
-
array(
|
192 |
-
'group' => 'field_acfe_form_term_save_slug_group',
|
193 |
-
'sub_field' => 'field_acfe_form_term_save_slug',
|
194 |
-
'sub_field_custom' => 'field_acfe_form_term_save_slug_custom',
|
195 |
-
),
|
196 |
-
|
197 |
-
// User: e-mail
|
198 |
-
array(
|
199 |
-
'group' => 'field_acfe_form_user_save_email_group',
|
200 |
-
'sub_field' => 'field_acfe_form_user_save_email',
|
201 |
-
'sub_field_custom' => 'field_acfe_form_user_save_email_custom',
|
202 |
-
),
|
203 |
-
|
204 |
-
// User: username
|
205 |
-
array(
|
206 |
-
'group' => 'field_acfe_form_user_save_username_group',
|
207 |
-
'sub_field' => 'field_acfe_form_user_save_username',
|
208 |
-
'sub_field_custom' => 'field_acfe_form_user_save_username_custom',
|
209 |
-
),
|
210 |
-
|
211 |
-
// User: password
|
212 |
-
array(
|
213 |
-
'group' => 'field_acfe_form_user_save_password_group',
|
214 |
-
'sub_field' => 'field_acfe_form_user_save_password',
|
215 |
-
'sub_field_custom' => 'field_acfe_form_user_save_password_custom',
|
216 |
-
),
|
217 |
-
|
218 |
-
// User: first name
|
219 |
-
array(
|
220 |
-
'group' => 'field_acfe_form_user_save_first_name_group',
|
221 |
-
'sub_field' => 'field_acfe_form_user_save_first_name',
|
222 |
-
'sub_field_custom' => 'field_acfe_form_user_save_first_name_custom',
|
223 |
-
),
|
224 |
-
|
225 |
-
// User: last name
|
226 |
-
array(
|
227 |
-
'group' => 'field_acfe_form_user_save_last_name_group',
|
228 |
-
'sub_field' => 'field_acfe_form_user_save_last_name',
|
229 |
-
'sub_field_custom' => 'field_acfe_form_user_save_last_name_custom',
|
230 |
-
),
|
231 |
-
|
232 |
-
// User: nickname
|
233 |
-
array(
|
234 |
-
'group' => 'field_acfe_form_user_save_nickname_group',
|
235 |
-
'sub_field' => 'field_acfe_form_user_save_nickname',
|
236 |
-
'sub_field_custom' => 'field_acfe_form_user_save_nickname_custom',
|
237 |
-
),
|
238 |
-
|
239 |
-
// User: display name
|
240 |
-
array(
|
241 |
-
'group' => 'field_acfe_form_user_save_display_name_group',
|
242 |
-
'sub_field' => 'field_acfe_form_user_save_display_name',
|
243 |
-
'sub_field_custom' => 'field_acfe_form_user_save_display_name_custom',
|
244 |
-
),
|
245 |
-
|
246 |
-
// User: website
|
247 |
-
array(
|
248 |
-
'group' => 'field_acfe_form_user_save_website_group',
|
249 |
-
'sub_field' => 'field_acfe_form_user_save_website',
|
250 |
-
'sub_field_custom' => 'field_acfe_form_user_save_website_custom',
|
251 |
-
),
|
252 |
-
|
253 |
-
);
|
254 |
-
|
255 |
-
foreach($args['acfe_form_actions'] as &$row){
|
256 |
-
|
257 |
-
foreach($rules as $rule){
|
258 |
-
|
259 |
-
if(!acf_maybe_get($row, $rule['group']))
|
260 |
-
continue;
|
261 |
-
|
262 |
-
$value = null;
|
263 |
-
$group = $row[$rule['group']];
|
264 |
-
|
265 |
-
if(acf_maybe_get($group, $rule['sub_field']) === 'custom'){
|
266 |
-
|
267 |
-
$value = acf_maybe_get($group, $rule['sub_field_custom']);
|
268 |
-
|
269 |
-
}else{
|
270 |
-
|
271 |
-
$value = acf_maybe_get($group, $rule['sub_field']);
|
272 |
-
|
273 |
-
}
|
274 |
-
|
275 |
-
unset($row[$rule['group']]);
|
276 |
-
|
277 |
-
$row[$rule['sub_field']] = $value;
|
278 |
-
|
279 |
-
$has_upgraded = true;
|
280 |
-
|
281 |
-
}
|
282 |
-
|
283 |
-
}
|
284 |
-
|
285 |
-
// ACF Extended: 0.8.5 Compatibility - Step 2
|
286 |
-
// Field mapping upgrade
|
287 |
-
if($has_upgraded){
|
288 |
-
|
289 |
-
// Rules
|
290 |
-
$rules = array(
|
291 |
-
|
292 |
-
array(
|
293 |
-
'load_values' => 'field_acfe_form_post_load_values',
|
294 |
-
'fields' => array(
|
295 |
-
'field_acfe_form_post_map_post_type' => 'field_acfe_form_post_save_post_type',
|
296 |
-
'field_acfe_form_post_map_post_status' => 'field_acfe_form_post_save_post_status',
|
297 |
-
'field_acfe_form_post_map_post_title' => 'field_acfe_form_post_save_post_title',
|
298 |
-
'field_acfe_form_post_map_post_name' => 'field_acfe_form_post_save_post_name',
|
299 |
-
'field_acfe_form_post_map_post_content' => 'field_acfe_form_post_save_post_content',
|
300 |
-
'field_acfe_form_post_map_post_author' => 'field_acfe_form_post_save_post_author',
|
301 |
-
'field_acfe_form_post_map_post_parent' => 'field_acfe_form_post_save_post_parent',
|
302 |
-
'field_acfe_form_post_map_post_terms' => 'field_acfe_form_post_save_post_terms',
|
303 |
-
)
|
304 |
-
),
|
305 |
-
|
306 |
-
array(
|
307 |
-
'load_values' => 'field_acfe_form_term_load_values',
|
308 |
-
'fields' => array(
|
309 |
-
'field_acfe_form_term_map_name' => 'field_acfe_form_term_save_name',
|
310 |
-
'field_acfe_form_term_map_slug' => 'field_acfe_form_term_save_slug',
|
311 |
-
'field_acfe_form_term_map_taxonomy' => 'field_acfe_form_term_save_taxonomy',
|
312 |
-
'field_acfe_form_term_map_parent' => 'field_acfe_form_term_save_parent',
|
313 |
-
'field_acfe_form_term_map_description' => 'field_acfe_form_term_save_description',
|
314 |
-
)
|
315 |
-
),
|
316 |
-
|
317 |
-
array(
|
318 |
-
'load_values' => 'field_acfe_form_user_load_values',
|
319 |
-
'fields' => array(
|
320 |
-
'field_acfe_form_user_map_email' => 'field_acfe_form_user_save_email',
|
321 |
-
'field_acfe_form_user_map_username' => 'field_acfe_form_user_save_username',
|
322 |
-
'field_acfe_form_user_map_password' => 'field_acfe_form_user_save_password',
|
323 |
-
'field_acfe_form_user_map_first_name' => 'field_acfe_form_user_save_first_name',
|
324 |
-
'field_acfe_form_user_map_last_name' => 'field_acfe_form_user_save_last_name',
|
325 |
-
'field_acfe_form_user_map_nickname' => 'field_acfe_form_user_save_nickname',
|
326 |
-
'field_acfe_form_user_map_display_name' => 'field_acfe_form_user_save_display_name',
|
327 |
-
'field_acfe_form_user_map_website' => 'field_acfe_form_user_save_website',
|
328 |
-
'field_acfe_form_user_map_description' => 'field_acfe_form_user_save_description',
|
329 |
-
'field_acfe_form_user_map_role' => 'field_acfe_form_user_save_role',
|
330 |
-
)
|
331 |
-
),
|
332 |
-
|
333 |
-
);
|
334 |
-
|
335 |
-
foreach($args['acfe_form_actions'] as &$row){
|
336 |
-
|
337 |
-
foreach($rules as $rule){
|
338 |
-
|
339 |
-
$load_values = acf_maybe_get($row, $rule['load_values']);
|
340 |
-
$fields = $rule['fields'];
|
341 |
-
|
342 |
-
if(!empty($load_values))
|
343 |
-
continue;
|
344 |
-
|
345 |
-
foreach($fields as $map => $save){
|
346 |
-
|
347 |
-
$map_value = acf_maybe_get($row, $map);
|
348 |
-
|
349 |
-
if(empty($map_value))
|
350 |
-
continue;
|
351 |
-
|
352 |
-
if($save === 'field_acfe_form_post_save_post_content'){
|
353 |
-
|
354 |
-
$row['field_acfe_form_post_save_post_content_group'][$save] = $map_value;
|
355 |
-
|
356 |
-
}
|
357 |
-
|
358 |
-
elseif($save === 'field_acfe_form_term_save_description'){
|
359 |
-
|
360 |
-
$row['field_acfe_form_term_save_description_group'][$save] = $map_value;
|
361 |
-
|
362 |
-
}
|
363 |
-
|
364 |
-
elseif($save === 'field_acfe_form_user_save_description'){
|
365 |
-
|
366 |
-
$row['field_acfe_form_user_save_description_group'][$save] = $map_value;
|
367 |
-
|
368 |
-
}
|
369 |
-
|
370 |
-
else{
|
371 |
-
|
372 |
-
$row[$save] = $map_value;
|
373 |
-
|
374 |
-
}
|
375 |
-
|
376 |
-
}
|
377 |
-
|
378 |
-
}
|
379 |
-
|
380 |
-
}
|
381 |
-
|
382 |
-
}
|
383 |
-
|
384 |
-
return $args;
|
385 |
-
|
386 |
-
}
|
387 |
-
|
388 |
-
function import_external($data){
|
389 |
-
|
390 |
-
$ids = array();
|
391 |
-
|
392 |
-
// Loop over args
|
393 |
-
foreach($data as $args){
|
394 |
-
|
395 |
-
// Check if already exists
|
396 |
-
$form_exists = get_page_by_path($args['acfe_form_name'], OBJECT, 'acfe-form');
|
397 |
-
|
398 |
-
if($form_exists)
|
399 |
-
continue;
|
400 |
-
|
401 |
-
// Import
|
402 |
-
$post_id = $this->import($args);
|
403 |
-
|
404 |
-
// Insert error
|
405 |
-
if(!$post_id)
|
406 |
-
continue;
|
407 |
-
|
408 |
-
$name = get_field('acfe_form_name', $post_id);
|
409 |
-
|
410 |
-
$return = array(
|
411 |
-
'id' => $post_id,
|
412 |
-
'name' => $name,
|
413 |
-
);
|
414 |
-
|
415 |
-
// append message
|
416 |
-
$ids[] = $return;
|
417 |
-
|
418 |
-
}
|
419 |
-
|
420 |
-
if(empty($ids))
|
421 |
-
return false;
|
422 |
-
|
423 |
-
return $ids;
|
424 |
-
|
425 |
-
}
|
426 |
-
|
427 |
-
}
|
428 |
-
|
429 |
-
acf_register_admin_tool('ACFE_Admin_Tool_Import_Form');
|
430 |
-
|
431 |
-
endif;
|
432 |
-
|
433 |
-
/*
|
434 |
-
* ACFE: Import Dynamic Form
|
435 |
-
*
|
436 |
-
* $args: Accepts array() or json
|
437 |
-
* return: A list of form_id & form_name
|
438 |
-
*/
|
439 |
-
function acfe_import_dynamic_form($args = false){
|
440 |
-
|
441 |
-
if(!$args)
|
442 |
-
return false;
|
443 |
-
|
444 |
-
// json
|
445 |
-
if(is_string($args)){
|
446 |
-
|
447 |
-
$args = json_decode($args, true);
|
448 |
-
|
449 |
-
}
|
450 |
-
|
451 |
-
if(!is_array($args) || empty($args))
|
452 |
-
return false;
|
453 |
-
|
454 |
-
// Tool
|
455 |
-
$tool = acf()->admin_tools->get_tool('ACFE_Admin_Tool_Import_Form');
|
456 |
-
|
457 |
-
return $tool->import_external($args);
|
458 |
-
|
459 |
}
|
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 $args){
|
78 |
+
|
79 |
+
// Check if already exists
|
80 |
+
if(get_page_by_path($args['acfe_form_name'], OBJECT, 'acfe-form')){
|
81 |
+
|
82 |
+
acf_add_admin_notice(__("Form {$args['title']} already exists. Import aborted."), 'warning');
|
83 |
+
|
84 |
+
continue;
|
85 |
+
|
86 |
+
}
|
87 |
+
|
88 |
+
// Import
|
89 |
+
$post_id = $this->import($args);
|
90 |
+
|
91 |
+
// Insert error
|
92 |
+
if(!$post_id){
|
93 |
+
|
94 |
+
acf_add_admin_notice(__("Something went wrong with the form {$args['title']}. Import aborted."), 'warning');
|
95 |
+
|
96 |
+
continue;
|
97 |
+
|
98 |
+
}
|
99 |
+
|
100 |
+
// append message
|
101 |
+
$ids[] = $post_id;
|
102 |
+
|
103 |
+
}
|
104 |
+
|
105 |
+
if(empty($ids))
|
106 |
+
return false;
|
107 |
+
|
108 |
+
// Count total
|
109 |
+
$total = count($ids);
|
110 |
+
|
111 |
+
// Generate text
|
112 |
+
$text = sprintf(_n('1 form imported', '%s forms imported', $total, 'acf'), $total);
|
113 |
+
|
114 |
+
// Add links to text
|
115 |
+
$links = array();
|
116 |
+
foreach($ids as $id){
|
117 |
+
|
118 |
+
$links[] = '<a href="' . get_edit_post_link($id) . '">' . get_the_title($id) . '</a>';
|
119 |
+
|
120 |
+
}
|
121 |
+
|
122 |
+
$text .= ': ' . implode(', ', $links);
|
123 |
+
|
124 |
+
// Add notice
|
125 |
+
acf_add_admin_notice($text, 'success');
|
126 |
+
|
127 |
+
}
|
128 |
+
|
129 |
+
function import($args){
|
130 |
+
|
131 |
+
// Vars
|
132 |
+
$title = acf_extract_var($args, 'title');
|
133 |
+
$name = $args['acfe_form_name'];
|
134 |
+
|
135 |
+
// Insert post
|
136 |
+
$post_id = wp_insert_post(array(
|
137 |
+
'post_title' => $title,
|
138 |
+
'post_name' => $name,
|
139 |
+
'post_type' => 'acfe-form',
|
140 |
+
'post_status' => 'publish'
|
141 |
+
));
|
142 |
+
|
143 |
+
// Insert error
|
144 |
+
if(is_wp_error($post_id))
|
145 |
+
return false;
|
146 |
+
|
147 |
+
acf_enable_filter('local');
|
148 |
+
|
149 |
+
// Import Compatibility
|
150 |
+
$args = $this->import_compatibility($args);
|
151 |
+
|
152 |
+
// Update Values
|
153 |
+
acf_update_values($args, $post_id);
|
154 |
+
|
155 |
+
acf_disable_filter('local');
|
156 |
+
|
157 |
+
return $post_id;
|
158 |
+
|
159 |
+
}
|
160 |
+
|
161 |
+
function import_compatibility($args){
|
162 |
+
|
163 |
+
// ACF Extended: 0.8.5 Compatibility - Step 1
|
164 |
+
// Groups upgrade
|
165 |
+
$has_upgraded = false;
|
166 |
+
|
167 |
+
$rules = array(
|
168 |
+
|
169 |
+
// Post: title
|
170 |
+
array(
|
171 |
+
'group' => 'field_acfe_form_post_save_post_title_group',
|
172 |
+
'sub_field' => 'field_acfe_form_post_save_post_title',
|
173 |
+
'sub_field_custom' => 'field_acfe_form_post_save_post_title_custom',
|
174 |
+
),
|
175 |
+
|
176 |
+
// Post: name
|
177 |
+
array(
|
178 |
+
'group' => 'field_acfe_form_post_save_post_name_group',
|
179 |
+
'sub_field' => 'field_acfe_form_post_save_post_name',
|
180 |
+
'sub_field_custom' => 'field_acfe_form_post_save_post_name_custom',
|
181 |
+
),
|
182 |
+
|
183 |
+
// Term: name
|
184 |
+
array(
|
185 |
+
'group' => 'field_acfe_form_term_save_name_group',
|
186 |
+
'sub_field' => 'field_acfe_form_term_save_name',
|
187 |
+
'sub_field_custom' => 'field_acfe_form_term_save_name_custom',
|
188 |
+
),
|
189 |
+
|
190 |
+
// Term: slug
|
191 |
+
array(
|
192 |
+
'group' => 'field_acfe_form_term_save_slug_group',
|
193 |
+
'sub_field' => 'field_acfe_form_term_save_slug',
|
194 |
+
'sub_field_custom' => 'field_acfe_form_term_save_slug_custom',
|
195 |
+
),
|
196 |
+
|
197 |
+
// User: e-mail
|
198 |
+
array(
|
199 |
+
'group' => 'field_acfe_form_user_save_email_group',
|
200 |
+
'sub_field' => 'field_acfe_form_user_save_email',
|
201 |
+
'sub_field_custom' => 'field_acfe_form_user_save_email_custom',
|
202 |
+
),
|
203 |
+
|
204 |
+
// User: username
|
205 |
+
array(
|
206 |
+
'group' => 'field_acfe_form_user_save_username_group',
|
207 |
+
'sub_field' => 'field_acfe_form_user_save_username',
|
208 |
+
'sub_field_custom' => 'field_acfe_form_user_save_username_custom',
|
209 |
+
),
|
210 |
+
|
211 |
+
// User: password
|
212 |
+
array(
|
213 |
+
'group' => 'field_acfe_form_user_save_password_group',
|
214 |
+
'sub_field' => 'field_acfe_form_user_save_password',
|
215 |
+
'sub_field_custom' => 'field_acfe_form_user_save_password_custom',
|
216 |
+
),
|
217 |
+
|
218 |
+
// User: first name
|
219 |
+
array(
|
220 |
+
'group' => 'field_acfe_form_user_save_first_name_group',
|
221 |
+
'sub_field' => 'field_acfe_form_user_save_first_name',
|
222 |
+
'sub_field_custom' => 'field_acfe_form_user_save_first_name_custom',
|
223 |
+
),
|
224 |
+
|
225 |
+
// User: last name
|
226 |
+
array(
|
227 |
+
'group' => 'field_acfe_form_user_save_last_name_group',
|
228 |
+
'sub_field' => 'field_acfe_form_user_save_last_name',
|
229 |
+
'sub_field_custom' => 'field_acfe_form_user_save_last_name_custom',
|
230 |
+
),
|
231 |
+
|
232 |
+
// User: nickname
|
233 |
+
array(
|
234 |
+
'group' => 'field_acfe_form_user_save_nickname_group',
|
235 |
+
'sub_field' => 'field_acfe_form_user_save_nickname',
|
236 |
+
'sub_field_custom' => 'field_acfe_form_user_save_nickname_custom',
|
237 |
+
),
|
238 |
+
|
239 |
+
// User: display name
|
240 |
+
array(
|
241 |
+
'group' => 'field_acfe_form_user_save_display_name_group',
|
242 |
+
'sub_field' => 'field_acfe_form_user_save_display_name',
|
243 |
+
'sub_field_custom' => 'field_acfe_form_user_save_display_name_custom',
|
244 |
+
),
|
245 |
+
|
246 |
+
// User: website
|
247 |
+
array(
|
248 |
+
'group' => 'field_acfe_form_user_save_website_group',
|
249 |
+
'sub_field' => 'field_acfe_form_user_save_website',
|
250 |
+
'sub_field_custom' => 'field_acfe_form_user_save_website_custom',
|
251 |
+
),
|
252 |
+
|
253 |
+
);
|
254 |
+
|
255 |
+
foreach($args['acfe_form_actions'] as &$row){
|
256 |
+
|
257 |
+
foreach($rules as $rule){
|
258 |
+
|
259 |
+
if(!acf_maybe_get($row, $rule['group']))
|
260 |
+
continue;
|
261 |
+
|
262 |
+
$value = null;
|
263 |
+
$group = $row[$rule['group']];
|
264 |
+
|
265 |
+
if(acf_maybe_get($group, $rule['sub_field']) === 'custom'){
|
266 |
+
|
267 |
+
$value = acf_maybe_get($group, $rule['sub_field_custom']);
|
268 |
+
|
269 |
+
}else{
|
270 |
+
|
271 |
+
$value = acf_maybe_get($group, $rule['sub_field']);
|
272 |
+
|
273 |
+
}
|
274 |
+
|
275 |
+
unset($row[$rule['group']]);
|
276 |
+
|
277 |
+
$row[$rule['sub_field']] = $value;
|
278 |
+
|
279 |
+
$has_upgraded = true;
|
280 |
+
|
281 |
+
}
|
282 |
+
|
283 |
+
}
|
284 |
+
|
285 |
+
// ACF Extended: 0.8.5 Compatibility - Step 2
|
286 |
+
// Field mapping upgrade
|
287 |
+
if($has_upgraded){
|
288 |
+
|
289 |
+
// Rules
|
290 |
+
$rules = array(
|
291 |
+
|
292 |
+
array(
|
293 |
+
'load_values' => 'field_acfe_form_post_load_values',
|
294 |
+
'fields' => array(
|
295 |
+
'field_acfe_form_post_map_post_type' => 'field_acfe_form_post_save_post_type',
|
296 |
+
'field_acfe_form_post_map_post_status' => 'field_acfe_form_post_save_post_status',
|
297 |
+
'field_acfe_form_post_map_post_title' => 'field_acfe_form_post_save_post_title',
|
298 |
+
'field_acfe_form_post_map_post_name' => 'field_acfe_form_post_save_post_name',
|
299 |
+
'field_acfe_form_post_map_post_content' => 'field_acfe_form_post_save_post_content',
|
300 |
+
'field_acfe_form_post_map_post_author' => 'field_acfe_form_post_save_post_author',
|
301 |
+
'field_acfe_form_post_map_post_parent' => 'field_acfe_form_post_save_post_parent',
|
302 |
+
'field_acfe_form_post_map_post_terms' => 'field_acfe_form_post_save_post_terms',
|
303 |
+
)
|
304 |
+
),
|
305 |
+
|
306 |
+
array(
|
307 |
+
'load_values' => 'field_acfe_form_term_load_values',
|
308 |
+
'fields' => array(
|
309 |
+
'field_acfe_form_term_map_name' => 'field_acfe_form_term_save_name',
|
310 |
+
'field_acfe_form_term_map_slug' => 'field_acfe_form_term_save_slug',
|
311 |
+
'field_acfe_form_term_map_taxonomy' => 'field_acfe_form_term_save_taxonomy',
|
312 |
+
'field_acfe_form_term_map_parent' => 'field_acfe_form_term_save_parent',
|
313 |
+
'field_acfe_form_term_map_description' => 'field_acfe_form_term_save_description',
|
314 |
+
)
|
315 |
+
),
|
316 |
+
|
317 |
+
array(
|
318 |
+
'load_values' => 'field_acfe_form_user_load_values',
|
319 |
+
'fields' => array(
|
320 |
+
'field_acfe_form_user_map_email' => 'field_acfe_form_user_save_email',
|
321 |
+
'field_acfe_form_user_map_username' => 'field_acfe_form_user_save_username',
|
322 |
+
'field_acfe_form_user_map_password' => 'field_acfe_form_user_save_password',
|
323 |
+
'field_acfe_form_user_map_first_name' => 'field_acfe_form_user_save_first_name',
|
324 |
+
'field_acfe_form_user_map_last_name' => 'field_acfe_form_user_save_last_name',
|
325 |
+
'field_acfe_form_user_map_nickname' => 'field_acfe_form_user_save_nickname',
|
326 |
+
'field_acfe_form_user_map_display_name' => 'field_acfe_form_user_save_display_name',
|
327 |
+
'field_acfe_form_user_map_website' => 'field_acfe_form_user_save_website',
|
328 |
+
'field_acfe_form_user_map_description' => 'field_acfe_form_user_save_description',
|
329 |
+
'field_acfe_form_user_map_role' => 'field_acfe_form_user_save_role',
|
330 |
+
)
|
331 |
+
),
|
332 |
+
|
333 |
+
);
|
334 |
+
|
335 |
+
foreach($args['acfe_form_actions'] as &$row){
|
336 |
+
|
337 |
+
foreach($rules as $rule){
|
338 |
+
|
339 |
+
$load_values = acf_maybe_get($row, $rule['load_values']);
|
340 |
+
$fields = $rule['fields'];
|
341 |
+
|
342 |
+
if(!empty($load_values))
|
343 |
+
continue;
|
344 |
+
|
345 |
+
foreach($fields as $map => $save){
|
346 |
+
|
347 |
+
$map_value = acf_maybe_get($row, $map);
|
348 |
+
|
349 |
+
if(empty($map_value))
|
350 |
+
continue;
|
351 |
+
|
352 |
+
if($save === 'field_acfe_form_post_save_post_content'){
|
353 |
+
|
354 |
+
$row['field_acfe_form_post_save_post_content_group'][$save] = $map_value;
|
355 |
+
|
356 |
+
}
|
357 |
+
|
358 |
+
elseif($save === 'field_acfe_form_term_save_description'){
|
359 |
+
|
360 |
+
$row['field_acfe_form_term_save_description_group'][$save] = $map_value;
|
361 |
+
|
362 |
+
}
|
363 |
+
|
364 |
+
elseif($save === 'field_acfe_form_user_save_description'){
|
365 |
+
|
366 |
+
$row['field_acfe_form_user_save_description_group'][$save] = $map_value;
|
367 |
+
|
368 |
+
}
|
369 |
+
|
370 |
+
else{
|
371 |
+
|
372 |
+
$row[$save] = $map_value;
|
373 |
+
|
374 |
+
}
|
375 |
+
|
376 |
+
}
|
377 |
+
|
378 |
+
}
|
379 |
+
|
380 |
+
}
|
381 |
+
|
382 |
+
}
|
383 |
+
|
384 |
+
return $args;
|
385 |
+
|
386 |
+
}
|
387 |
+
|
388 |
+
function import_external($data){
|
389 |
+
|
390 |
+
$ids = array();
|
391 |
+
|
392 |
+
// Loop over args
|
393 |
+
foreach($data as $args){
|
394 |
+
|
395 |
+
// Check if already exists
|
396 |
+
$form_exists = get_page_by_path($args['acfe_form_name'], OBJECT, 'acfe-form');
|
397 |
+
|
398 |
+
if($form_exists)
|
399 |
+
continue;
|
400 |
+
|
401 |
+
// Import
|
402 |
+
$post_id = $this->import($args);
|
403 |
+
|
404 |
+
// Insert error
|
405 |
+
if(!$post_id)
|
406 |
+
continue;
|
407 |
+
|
408 |
+
$name = get_field('acfe_form_name', $post_id);
|
409 |
+
|
410 |
+
$return = array(
|
411 |
+
'id' => $post_id,
|
412 |
+
'name' => $name,
|
413 |
+
);
|
414 |
+
|
415 |
+
// append message
|
416 |
+
$ids[] = $return;
|
417 |
+
|
418 |
+
}
|
419 |
+
|
420 |
+
if(empty($ids))
|
421 |
+
return false;
|
422 |
+
|
423 |
+
return $ids;
|
424 |
+
|
425 |
+
}
|
426 |
+
|
427 |
+
}
|
428 |
+
|
429 |
+
acf_register_admin_tool('ACFE_Admin_Tool_Import_Form');
|
430 |
+
|
431 |
+
endif;
|
432 |
+
|
433 |
+
/*
|
434 |
+
* ACFE: Import Dynamic Form
|
435 |
+
*
|
436 |
+
* $args: Accepts array() or json
|
437 |
+
* return: A list of form_id & form_name
|
438 |
+
*/
|
439 |
+
function acfe_import_dynamic_form($args = false){
|
440 |
+
|
441 |
+
if(!$args)
|
442 |
+
return false;
|
443 |
+
|
444 |
+
// json
|
445 |
+
if(is_string($args)){
|
446 |
+
|
447 |
+
$args = json_decode($args, true);
|
448 |
+
|
449 |
+
}
|
450 |
+
|
451 |
+
if(!is_array($args) || empty($args))
|
452 |
+
return false;
|
453 |
+
|
454 |
+
// Tool
|
455 |
+
$tool = acf()->admin_tools->get_tool('ACFE_Admin_Tool_Import_Form');
|
456 |
+
|
457 |
+
return $tool->import_external($args);
|
458 |
+
|
459 |
}
|
@@ -1,61 +1,61 @@
|
|
1 |
-
<div class="wrap acf-settings-wrap">
|
2 |
-
|
3 |
-
<?php
|
4 |
-
$title = __('Edit Option');
|
5 |
-
if($_REQUEST['action'] === 'add')
|
6 |
-
$title = __('Add Option');
|
7 |
-
?>
|
8 |
-
<h1 class="wp-heading-inline"><?php echo $title; ?></h1>
|
9 |
-
|
10 |
-
<hr class="wp-header-end" />
|
11 |
-
|
12 |
-
<form id="post" method="post" name="post">
|
13 |
-
|
14 |
-
<?php
|
15 |
-
|
16 |
-
// render post data
|
17 |
-
acf_form_data(array(
|
18 |
-
'screen' => 'acfe-options-edit',
|
19 |
-
'post_id' => 'acfe_options_edit',
|
20 |
-
));
|
21 |
-
|
22 |
-
wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
|
23 |
-
wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
|
24 |
-
|
25 |
-
?>
|
26 |
-
|
27 |
-
<div id="poststuff">
|
28 |
-
|
29 |
-
<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
|
30 |
-
|
31 |
-
<!--
|
32 |
-
<div id="post-body-content">
|
33 |
-
<div id="titlediv">
|
34 |
-
<div id="titlewrap">
|
35 |
-
<input type="text" name="post_title" size="30" value="Post 4" id="title" spellcheck="true" autocomplete="off" />
|
36 |
-
</div>
|
37 |
-
</div>
|
38 |
-
</div>
|
39 |
-
-->
|
40 |
-
|
41 |
-
<div id="postbox-container-1" class="postbox-container">
|
42 |
-
|
43 |
-
<?php do_meta_boxes('acf_options_page', 'side', null); ?>
|
44 |
-
|
45 |
-
</div>
|
46 |
-
|
47 |
-
<div id="postbox-container-2" class="postbox-container">
|
48 |
-
|
49 |
-
<?php do_meta_boxes('acf_options_page', 'normal', null); ?>
|
50 |
-
|
51 |
-
</div>
|
52 |
-
|
53 |
-
</div>
|
54 |
-
|
55 |
-
<br class="clear" />
|
56 |
-
|
57 |
-
</div>
|
58 |
-
|
59 |
-
</form>
|
60 |
-
|
61 |
</div>
|
1 |
+
<div class="wrap acf-settings-wrap">
|
2 |
+
|
3 |
+
<?php
|
4 |
+
$title = __('Edit Option');
|
5 |
+
if($_REQUEST['action'] === 'add')
|
6 |
+
$title = __('Add Option');
|
7 |
+
?>
|
8 |
+
<h1 class="wp-heading-inline"><?php echo $title; ?></h1>
|
9 |
+
|
10 |
+
<hr class="wp-header-end" />
|
11 |
+
|
12 |
+
<form id="post" method="post" name="post">
|
13 |
+
|
14 |
+
<?php
|
15 |
+
|
16 |
+
// render post data
|
17 |
+
acf_form_data(array(
|
18 |
+
'screen' => 'acfe-options-edit',
|
19 |
+
'post_id' => 'acfe_options_edit',
|
20 |
+
));
|
21 |
+
|
22 |
+
wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
|
23 |
+
wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
|
24 |
+
|
25 |
+
?>
|
26 |
+
|
27 |
+
<div id="poststuff">
|
28 |
+
|
29 |
+
<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
|
30 |
+
|
31 |
+
<!--
|
32 |
+
<div id="post-body-content">
|
33 |
+
<div id="titlediv">
|
34 |
+
<div id="titlewrap">
|
35 |
+
<input type="text" name="post_title" size="30" value="Post 4" id="title" spellcheck="true" autocomplete="off" />
|
36 |
+
</div>
|
37 |
+
</div>
|
38 |
+
</div>
|
39 |
+
-->
|
40 |
+
|
41 |
+
<div id="postbox-container-1" class="postbox-container">
|
42 |
+
|
43 |
+
<?php do_meta_boxes('acf_options_page', 'side', null); ?>
|
44 |
+
|
45 |
+
</div>
|
46 |
+
|
47 |
+
<div id="postbox-container-2" class="postbox-container">
|
48 |
+
|
49 |
+
<?php do_meta_boxes('acf_options_page', 'normal', null); ?>
|
50 |
+
|
51 |
+
</div>
|
52 |
+
|
53 |
+
</div>
|
54 |
+
|
55 |
+
<br class="clear" />
|
56 |
+
|
57 |
+
</div>
|
58 |
+
|
59 |
+
</form>
|
60 |
+
|
61 |
</div>
|
@@ -1,38 +1,38 @@
|
|
1 |
-
<div class="wrap" id="acfe-admin-options">
|
2 |
-
|
3 |
-
<h1 class="wp-heading-inline"><?php _e('Options'); ?></h1>
|
4 |
-
<a href="<?php echo sprintf('?page=%s&action=add', esc_attr($_REQUEST['page'])); ?>" class="page-title-action"><?php _e('Add New'); ?></a>
|
5 |
-
|
6 |
-
<hr class="wp-header-end" />
|
7 |
-
|
8 |
-
<div id="poststuff">
|
9 |
-
|
10 |
-
<div id="post-body" class="metabox-holder">
|
11 |
-
<div id="post-body-content">
|
12 |
-
<div class="meta-box-sortables ui-sortable">
|
13 |
-
<form method="post">
|
14 |
-
|
15 |
-
<?php
|
16 |
-
|
17 |
-
// WP List
|
18 |
-
$acfe_options_list = new ACFE_Admin_Options_List();
|
19 |
-
|
20 |
-
// Prepare items
|
21 |
-
$acfe_options_list->prepare_items();
|
22 |
-
|
23 |
-
$acfe_options_list->search_box('Search', 'search');
|
24 |
-
|
25 |
-
$acfe_options_list->display();
|
26 |
-
|
27 |
-
?>
|
28 |
-
|
29 |
-
</form>
|
30 |
-
</div>
|
31 |
-
</div>
|
32 |
-
</div>
|
33 |
-
|
34 |
-
<br class="clear" />
|
35 |
-
|
36 |
-
</div>
|
37 |
-
|
38 |
</div>
|
1 |
+
<div class="wrap" id="acfe-admin-options">
|
2 |
+
|
3 |
+
<h1 class="wp-heading-inline"><?php _e('Options'); ?></h1>
|
4 |
+
<a href="<?php echo sprintf('?page=%s&action=add', esc_attr($_REQUEST['page'])); ?>" class="page-title-action"><?php _e('Add New'); ?></a>
|
5 |
+
|
6 |
+
<hr class="wp-header-end" />
|
7 |
+
|
8 |
+
<div id="poststuff">
|
9 |
+
|
10 |
+
<div id="post-body" class="metabox-holder">
|
11 |
+
<div id="post-body-content">
|
12 |
+
<div class="meta-box-sortables ui-sortable">
|
13 |
+
<form method="post">
|
14 |
+
|
15 |
+
<?php
|
16 |
+
|
17 |
+
// WP List
|
18 |
+
$acfe_options_list = new ACFE_Admin_Options_List();
|
19 |
+
|
20 |
+
// Prepare items
|
21 |
+
$acfe_options_list->prepare_items();
|
22 |
+
|
23 |
+
$acfe_options_list->search_box('Search', 'search');
|
24 |
+
|
25 |
+
$acfe_options_list->display();
|
26 |
+
|
27 |
+
?>
|
28 |
+
|
29 |
+
</form>
|
30 |
+
</div>
|
31 |
+
</div>
|
32 |
+
</div>
|
33 |
+
|
34 |
+
<br class="clear" />
|
35 |
+
|
36 |
+
</div>
|
37 |
+
|
38 |
</div>
|
@@ -1,285 +1,287 @@
|
|
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'), 98);
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
$this
|
19 |
-
|
20 |
-
add_filter('
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
add_filter('
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
add_filter('
|
34 |
-
|
35 |
-
add_filter('
|
36 |
-
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* ACF Extended: Settings
|
41 |
-
*/
|
42 |
-
function update_settings(){
|
43 |
-
|
44 |
-
// ACF Extended: 0.8.6.3 - Renamed 'acfe/modules/taxonomies' to 'acfe/modules/ui'
|
45 |
-
if(acf_get_setting('acfe/modules/taxonomies') !== null){
|
46 |
-
acf_update_setting('acfe/modules/ui', acf_get_setting('acfe/modules/taxonomies'));
|
47 |
-
}
|
48 |
-
|
49 |
-
// ACF Extended: 0.8 - Renamed 'acfe_php*' to 'acfe/php*'
|
50 |
-
if(acf_get_setting('acfe_php') !== null){
|
51 |
-
acf_update_setting('acfe/php', acf_get_setting('acfe_php'));
|
52 |
-
}
|
53 |
-
|
54 |
-
if(acf_get_setting('php_save') !== null){
|
55 |
-
acf_update_setting('acfe/php_save', acf_get_setting('php_save'));
|
56 |
-
}
|
57 |
-
|
58 |
-
if(acf_get_setting('php_load') !== null){
|
59 |
-
acf_update_setting('acfe/php_load', acf_get_setting('php_load'));
|
60 |
-
}
|
61 |
-
|
62 |
-
if(acf_get_setting('php_found') !== null){
|
63 |
-
acf_update_setting('acfe/php_found', acf_get_setting('php_found'));
|
64 |
-
}
|
65 |
-
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* ACF Extended: 0.8
|
70 |
-
* Field Group Location: Archive renamed to List
|
71 |
-
*/
|
72 |
-
function field_group_location_list($field_group){
|
73 |
-
|
74 |
-
if(!acf_maybe_get($field_group, 'location'))
|
75 |
-
return $field_group;
|
76 |
-
|
77 |
-
foreach($field_group['location'] as &$or){
|
78 |
-
|
79 |
-
foreach($or as &$and){
|
80 |
-
|
81 |
-
if(!isset($and['value']))
|
82 |
-
continue;
|
83 |
-
|
84 |
-
// Post Type List
|
85 |
-
if($and['param'] === 'post_type' && acfe_ends_with($and['value'], '_archive')){
|
86 |
-
|
87 |
-
$and['param'] = 'post_type_list';
|
88 |
-
$and['value'] = substr_replace($and['value'], '', -8);
|
89 |
-
|
90 |
-
}
|
91 |
-
|
92 |
-
// Taxonomy List
|
93 |
-
elseif($and['param'] === 'taxonomy' && acfe_ends_with($and['value'], '_archive')){
|
94 |
-
|
95 |
-
$and['param'] = 'taxonomy_list';
|
96 |
-
$and['value'] = substr_replace($and['value'], '', -8);
|
97 |
-
|
98 |
-
}
|
99 |
-
|
100 |
-
}
|
101 |
-
|
102 |
-
}
|
103 |
-
|
104 |
-
return $field_group;
|
105 |
-
|
106 |
-
}
|
107 |
-
|
108 |
-
/**
|
109 |
-
* ACF Extended: 0.8
|
110 |
-
* Field Filter Value: Removed from this version
|
111 |
-
*/
|
112 |
-
function field_acfe_update($field){
|
113 |
-
|
114 |
-
if(!acf_maybe_get($field, 'acfe_update'))
|
115 |
-
return $field;
|
116 |
-
|
117 |
-
unset($field['acfe_update']);
|
118 |
-
|
119 |
-
return $field;
|
120 |
-
|
121 |
-
}
|
122 |
-
|
123 |
-
/**
|
124 |
-
* ACF Extended: 0.8.5
|
125 |
-
* Field Group/Clone: Fixed typo "Seamless"
|
126 |
-
*/
|
127 |
-
function field_seamless_style($field){
|
128 |
-
|
129 |
-
if($seamless = acf_maybe_get($field, 'acfe_seemless_style', false)){
|
130 |
-
|
131 |
-
$field['acfe_seamless_style'] = $seamless;
|
132 |
-
|
133 |
-
}
|
134 |
-
|
135 |
-
return $field;
|
136 |
-
|
137 |
-
}
|
138 |
-
|
139 |
-
/**
|
140 |
-
* ACF Extended: 0.8.4.5
|
141 |
-
* Field Flexible Content: Fix duplicated "layout_settings" & "layout_title"
|
142 |
-
*/
|
143 |
-
function field_flexible_settings_title($fields, $parent){
|
144 |
-
|
145 |
-
// Check if is tool screen
|
146 |
-
if(!acf_is_screen(acfe_get_acf_screen_id('acf-tools')))
|
147 |
-
return $fields;
|
148 |
-
|
149 |
-
foreach($fields as $_k => $_field){
|
150 |
-
|
151 |
-
// field name
|
152 |
-
$_field_name = acf_maybe_get($_field, 'name');
|
153 |
-
|
154 |
-
// check 'acfe_flexible_layout_title' & 'layout_settings'
|
155 |
-
if($_field_name !== 'acfe_flexible_layout_title' && $_field_name !== 'layout_settings')
|
156 |
-
continue;
|
157 |
-
|
158 |
-
// unset
|
159 |
-
unset($fields[$_k]);
|
160 |
-
|
161 |
-
}
|
162 |
-
|
163 |
-
return $fields;
|
164 |
-
|
165 |
-
}
|
166 |
-
|
167 |
-
/**
|
168 |
-
* ACF Extended: 0.8.6.7
|
169 |
-
* Field Flexible Content: Compatibility for Layout Categories
|
170 |
-
*/
|
171 |
-
function field_flexible_layout_categories($field){
|
172 |
-
|
173 |
-
$value = acf_maybe_get($field, 'value');
|
174 |
-
|
175 |
-
if(empty($value))
|
176 |
-
return $field;
|
177 |
-
|
178 |
-
if(is_string($value)){
|
179 |
-
|
180 |
-
$explode = explode('|', $value);
|
181 |
-
|
182 |
-
$choices = array();
|
183 |
-
|
184 |
-
foreach($explode as $v){
|
185 |
-
|
186 |
-
$v = trim($v);
|
187 |
-
$choices[$v] = $v;
|
188 |
-
|
189 |
-
}
|
190 |
-
|
191 |
-
$field['choices'] = $choices;
|
192 |
-
$field['value'] = $choices;
|
193 |
-
|
194 |
-
}
|
195 |
-
|
196 |
-
return $field;
|
197 |
-
|
198 |
-
}
|
199 |
-
|
200 |
-
/**
|
201 |
-
* Plugin: Post Types Order
|
202 |
-
* https://wordpress.org/plugins/post-types-order/
|
203 |
-
* The plugin apply custom order to ACF Field Group Post Type. We have to fix this
|
204 |
-
*/
|
205 |
-
function pto_acf_field_group($ignore, $orderby, $query){
|
206 |
-
|
207 |
-
if(is_admin() && $query->is_main_query() && $query->get('post_type') === 'acf-field-group')
|
208 |
-
$ignore = true;
|
209 |
-
|
210 |
-
return $ignore;
|
211 |
-
|
212 |
-
}
|
213 |
-
|
214 |
-
/**
|
215 |
-
* Plugin: Post Types Order
|
216 |
-
* https://wordpress.org/plugins/post-types-order/
|
217 |
-
* The plugin apply a drag & drop UI on ACF Field Group UI. We have to fix this
|
218 |
-
*/
|
219 |
-
function pto_options_acf_field_group($options){
|
220 |
-
|
221 |
-
$options['show_reorder_interfaces']['acf-field-group'] = 'hide';
|
222 |
-
|
223 |
-
return $options;
|
224 |
-
|
225 |
-
}
|
226 |
-
|
227 |
-
/**
|
228 |
-
* Plugin: Category Order and Taxonomy Terms Order
|
229 |
-
* https://wordpress.org/plugins/taxonomy-terms-order/
|
230 |
-
* The plugin add a submenu to 'Custom Fields' to order Field Group Categories. It's unecessary
|
231 |
-
*/
|
232 |
-
function cotto_submenu(){
|
233 |
-
|
234 |
-
remove_submenu_page('edit.php?post_type=acf-field-group', 'to-interface-acf-field-group');
|
235 |
-
|
236 |
-
}
|
237 |
-
|
238 |
-
/**
|
239 |
-
* Plugin: Rank Math SEO
|
240 |
-
* https://wordpress.org/plugins/seo-by-rank-math/
|
241 |
-
* Fix the plugin post metabox which is always above ACF metaboxes
|
242 |
-
*/
|
243 |
-
function rankmath_metaboxes_priority(){
|
244 |
-
|
245 |
-
return 'default';
|
246 |
-
|
247 |
-
}
|
248 |
-
|
249 |
-
/**
|
250 |
-
* Plugin: YOAST SEO
|
251 |
-
* https://wordpress.org/plugins/wordpress-seo/
|
252 |
-
* Fix the plugin post metabox which is always above ACF metaboxes
|
253 |
-
*/
|
254 |
-
function yoast_metaboxes_priority(){
|
255 |
-
|
256 |
-
return 'default';
|
257 |
-
|
258 |
-
}
|
259 |
-
|
260 |
-
/**
|
261 |
-
* ACF Extended: 0.8.3
|
262 |
-
* Modules: Enable PolyLang Translation for ACFE Form Module
|
263 |
-
* https://polylang.pro/doc/filter-reference/
|
264 |
-
*/
|
265 |
-
function polylang($post_types, $is_settings){
|
266 |
-
|
267 |
-
if($is_settings){
|
268 |
-
|
269 |
-
unset($post_types['acfe-form']);
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
}
|
282 |
-
|
283 |
-
|
284 |
-
|
|
|
|
|
285 |
endif;
|
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'), 98);
|
13 |
+
|
14 |
+
add_filter('pto/posts_orderby/ignore', array($this, 'pto_acf_field_group'), 10, 3);
|
15 |
+
add_filter('pto/get_options', array($this, 'pto_options_acf_field_group'));
|
16 |
+
|
17 |
+
add_action('admin_menu', array($this, 'cotto_submenu'), 999);
|
18 |
+
add_filter('rank_math/metabox/priority', array($this, 'rankmath_metaboxes_priority'));
|
19 |
+
add_filter('wpseo_metabox_prio', array($this, 'yoast_metaboxes_priority'));
|
20 |
+
add_filter('pll_get_post_types', array($this, 'polylang'), 10, 2 );
|
21 |
+
|
22 |
+
}
|
23 |
+
|
24 |
+
function init(){
|
25 |
+
|
26 |
+
$this->update_settings();
|
27 |
+
|
28 |
+
add_filter('acf/validate_field_group', array($this, 'field_group_location_list'), 20);
|
29 |
+
add_filter('acf/validate_field', array($this, 'field_acfe_update'), 20);
|
30 |
+
|
31 |
+
add_filter('acf/validate_field/type=group', array($this, 'field_seamless_style'), 20);
|
32 |
+
add_filter('acf/validate_field/type=clone', array($this, 'field_seamless_style'), 20);
|
33 |
+
add_filter('acfe/load_fields/type=flexible_content', array($this, 'field_flexible_settings_title'), 20, 2);
|
34 |
+
|
35 |
+
add_filter('acf/prepare_field/name=acfe_flexible_category', array($this, 'field_flexible_layout_categories'), 10, 2);
|
36 |
+
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* ACF Extended: Settings
|
41 |
+
*/
|
42 |
+
function update_settings(){
|
43 |
+
|
44 |
+
// ACF Extended: 0.8.6.3 - Renamed 'acfe/modules/taxonomies' to 'acfe/modules/ui'
|
45 |
+
if(acf_get_setting('acfe/modules/taxonomies') !== null){
|
46 |
+
acf_update_setting('acfe/modules/ui', acf_get_setting('acfe/modules/taxonomies'));
|
47 |
+
}
|
48 |
+
|
49 |
+
// ACF Extended: 0.8 - Renamed 'acfe_php*' to 'acfe/php*'
|
50 |
+
if(acf_get_setting('acfe_php') !== null){
|
51 |
+
acf_update_setting('acfe/php', acf_get_setting('acfe_php'));
|
52 |
+
}
|
53 |
+
|
54 |
+
if(acf_get_setting('php_save') !== null){
|
55 |
+
acf_update_setting('acfe/php_save', acf_get_setting('php_save'));
|
56 |
+
}
|
57 |
+
|
58 |
+
if(acf_get_setting('php_load') !== null){
|
59 |
+
acf_update_setting('acfe/php_load', acf_get_setting('php_load'));
|
60 |
+
}
|
61 |
+
|
62 |
+
if(acf_get_setting('php_found') !== null){
|
63 |
+
acf_update_setting('acfe/php_found', acf_get_setting('php_found'));
|
64 |
+
}
|
65 |
+
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* ACF Extended: 0.8
|
70 |
+
* Field Group Location: Archive renamed to List
|
71 |
+
*/
|
72 |
+
function field_group_location_list($field_group){
|
73 |
+
|
74 |
+
if(!acf_maybe_get($field_group, 'location'))
|
75 |
+
return $field_group;
|
76 |
+
|
77 |
+
foreach($field_group['location'] as &$or){
|
78 |
+
|
79 |
+
foreach($or as &$and){
|
80 |
+
|
81 |
+
if(!isset($and['value']))
|
82 |
+
continue;
|
83 |
+
|
84 |
+
// Post Type List
|
85 |
+
if($and['param'] === 'post_type' && acfe_ends_with($and['value'], '_archive')){
|
86 |
+
|
87 |
+
$and['param'] = 'post_type_list';
|
88 |
+
$and['value'] = substr_replace($and['value'], '', -8);
|
89 |
+
|
90 |
+
}
|
91 |
+
|
92 |
+
// Taxonomy List
|
93 |
+
elseif($and['param'] === 'taxonomy' && acfe_ends_with($and['value'], '_archive')){
|
94 |
+
|
95 |
+
$and['param'] = 'taxonomy_list';
|
96 |
+
$and['value'] = substr_replace($and['value'], '', -8);
|
97 |
+
|
98 |
+
}
|
99 |
+
|
100 |
+
}
|
101 |
+
|
102 |
+
}
|
103 |
+
|
104 |
+
return $field_group;
|
105 |
+
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* ACF Extended: 0.8
|
110 |
+
* Field Filter Value: Removed from this version
|
111 |
+
*/
|
112 |
+
function field_acfe_update($field){
|
113 |
+
|
114 |
+
if(!acf_maybe_get($field, 'acfe_update'))
|
115 |
+
return $field;
|
116 |
+
|
117 |
+
unset($field['acfe_update']);
|
118 |
+
|
119 |
+
return $field;
|
120 |
+
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* ACF Extended: 0.8.5
|
125 |
+
* Field Group/Clone: Fixed typo "Seamless"
|
126 |
+
*/
|
127 |
+
function field_seamless_style($field){
|
128 |
+
|
129 |
+
if($seamless = acf_maybe_get($field, 'acfe_seemless_style', false)){
|
130 |
+
|
131 |
+
$field['acfe_seamless_style'] = $seamless;
|
132 |
+
|
133 |
+
}
|
134 |
+
|
135 |
+
return $field;
|
136 |
+
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* ACF Extended: 0.8.4.5
|
141 |
+
* Field Flexible Content: Fix duplicated "layout_settings" & "layout_title"
|
142 |
+
*/
|
143 |
+
function field_flexible_settings_title($fields, $parent){
|
144 |
+
|
145 |
+
// Check if is tool screen
|
146 |
+
if(!acf_is_screen(acfe_get_acf_screen_id('acf-tools')))
|
147 |
+
return $fields;
|
148 |
+
|
149 |
+
foreach($fields as $_k => $_field){
|
150 |
+
|
151 |
+
// field name
|
152 |
+
$_field_name = acf_maybe_get($_field, 'name');
|
153 |
+
|
154 |
+
// check 'acfe_flexible_layout_title' & 'layout_settings'
|
155 |
+
if($_field_name !== 'acfe_flexible_layout_title' && $_field_name !== 'layout_settings')
|
156 |
+
continue;
|
157 |
+
|
158 |
+
// unset
|
159 |
+
unset($fields[$_k]);
|
160 |
+
|
161 |
+
}
|
162 |
+
|
163 |
+
return $fields;
|
164 |
+
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* ACF Extended: 0.8.6.7
|
169 |
+
* Field Flexible Content: Compatibility for Layout Categories
|
170 |
+
*/
|
171 |
+
function field_flexible_layout_categories($field){
|
172 |
+
|
173 |
+
$value = acf_maybe_get($field, 'value');
|
174 |
+
|
175 |
+
if(empty($value))
|
176 |
+
return $field;
|
177 |
+
|
178 |
+
if(is_string($value)){
|
179 |
+
|
180 |
+
$explode = explode('|', $value);
|
181 |
+
|
182 |
+
$choices = array();
|
183 |
+
|
184 |
+
foreach($explode as $v){
|
185 |
+
|
186 |
+
$v = trim($v);
|
187 |
+
$choices[$v] = $v;
|
188 |
+
|
189 |
+
}
|
190 |
+
|
191 |
+
$field['choices'] = $choices;
|
192 |
+
$field['value'] = $choices;
|
193 |
+
|
194 |
+
}
|
195 |
+
|
196 |
+
return $field;
|
197 |
+
|
198 |
+
}
|
199 |
+
|
200 |
+
/**
|
201 |
+
* Plugin: Post Types Order
|
202 |
+
* https://wordpress.org/plugins/post-types-order/
|
203 |
+
* The plugin apply custom order to ACF Field Group Post Type. We have to fix this
|
204 |
+
*/
|
205 |
+
function pto_acf_field_group($ignore, $orderby, $query){
|
206 |
+
|
207 |
+
if(is_admin() && $query->is_main_query() && $query->get('post_type') === 'acf-field-group')
|
208 |
+
$ignore = true;
|
209 |
+
|
210 |
+
return $ignore;
|
211 |
+
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* Plugin: Post Types Order
|
216 |
+
* https://wordpress.org/plugins/post-types-order/
|
217 |
+
* The plugin apply a drag & drop UI on ACF Field Group UI. We have to fix this
|
218 |
+
*/
|
219 |
+
function pto_options_acf_field_group($options){
|
220 |
+
|
221 |
+
$options['show_reorder_interfaces']['acf-field-group'] = 'hide';
|
222 |
+
|
223 |
+
return $options;
|
224 |
+
|
225 |
+
}
|
226 |
+
|
227 |
+
/**
|
228 |
+
* Plugin: Category Order and Taxonomy Terms Order
|
229 |
+
* https://wordpress.org/plugins/taxonomy-terms-order/
|
230 |
+
* The plugin add a submenu to 'Custom Fields' to order Field Group Categories. It's unecessary
|
231 |
+
*/
|
232 |
+
function cotto_submenu(){
|
233 |
+
|
234 |
+
remove_submenu_page('edit.php?post_type=acf-field-group', 'to-interface-acf-field-group');
|
235 |
+
|
236 |
+
}
|
237 |
+
|
238 |
+
/**
|
239 |
+
* Plugin: Rank Math SEO
|
240 |
+
* https://wordpress.org/plugins/seo-by-rank-math/
|
241 |
+
* Fix the plugin post metabox which is always above ACF metaboxes
|
242 |
+
*/
|
243 |
+
function rankmath_metaboxes_priority(){
|
244 |
+
|
245 |
+
return 'default';
|
246 |
+
|
247 |
+
}
|
248 |
+
|
249 |
+
/**
|
250 |
+
* Plugin: YOAST SEO
|
251 |
+
* https://wordpress.org/plugins/wordpress-seo/
|
252 |
+
* Fix the plugin post metabox which is always above ACF metaboxes
|
253 |
+
*/
|
254 |
+
function yoast_metaboxes_priority(){
|
255 |
+
|
256 |
+
return 'default';
|
257 |
+
|
258 |
+
}
|
259 |
+
|
260 |
+
/**
|
261 |
+
* ACF Extended: 0.8.3
|
262 |
+
* Modules: Enable PolyLang Translation for ACFE Form Module
|
263 |
+
* https://polylang.pro/doc/filter-reference/
|
264 |
+
*/
|
265 |
+
function polylang($post_types, $is_settings){
|
266 |
+
|
267 |
+
if($is_settings){
|
268 |
+
|
269 |
+
unset($post_types['acfe-form']);
|
270 |
+
unset($post_types['acfe-template']);
|
271 |
+
|
272 |
+
}else{
|
273 |
+
|
274 |
+
$post_types['acfe-form'] = 'acfe-form';
|
275 |
+
$post_types['acfe-template'] = 'acfe-template';
|
276 |
+
|
277 |
+
}
|
278 |
+
|
279 |
+
return $post_types;
|
280 |
+
|
281 |
+
}
|
282 |
+
|
283 |
+
}
|
284 |
+
|
285 |
+
new acfe_compatibility();
|
286 |
+
|
287 |
endif;
|
@@ -1,92 +1,108 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
if(!class_exists('acfe_enqueue')):
|
7 |
-
|
8 |
-
class acfe_enqueue{
|
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 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
if(!class_exists('acfe_enqueue')):
|
7 |
+
|
8 |
+
class acfe_enqueue{
|
9 |
+
|
10 |
+
function __construct(){
|
11 |
+
|
12 |
+
// Hooks
|
13 |
+
add_action('init', array($this, 'register_assets'));
|
14 |
+
add_action('admin_enqueue_scripts', array($this, 'admin_enqueue'));
|
15 |
+
add_action('acf/input/admin_enqueue_scripts', array($this, 'acf_enqueue'));
|
16 |
+
|
17 |
+
}
|
18 |
+
|
19 |
+
function register_assets(){
|
20 |
+
|
21 |
+
$version = ACFE_VERSION;
|
22 |
+
$min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
|
23 |
+
|
24 |
+
// register scripts
|
25 |
+
wp_register_script('acf-extended', acfe_get_url("assets/js/acfe{$min}.js"), array('acf-input'), $version);
|
26 |
+
wp_register_script('acf-extended-input', acfe_get_url("assets/js/acfe-input{$min}.js"), array('acf-extended'), $version);
|
27 |
+
wp_register_script('acf-extended-admin', acfe_get_url("assets/js/acfe-admin{$min}.js"), array('acf-extended'), $version);
|
28 |
+
wp_register_script('acf-extended-field-group', acfe_get_url("assets/js/acfe-field-group{$min}.js"), array('acf-field-group'), $version);
|
29 |
+
wp_register_script('acf-extended-ui', acfe_get_url("assets/js/acfe-ui{$min}.js"), array('acf-extended'), $version);
|
30 |
+
|
31 |
+
// register styles
|
32 |
+
wp_register_style('acf-extended', acfe_get_url("assets/css/acfe{$min}.css"), array(), $version);
|
33 |
+
wp_register_style('acf-extended-input', acfe_get_url("assets/css/acfe-input{$min}.css"), array(), $version);
|
34 |
+
wp_register_style('acf-extended-admin', acfe_get_url("assets/css/acfe-admin{$min}.css"), array(), $version);
|
35 |
+
wp_register_style('acf-extended-field-group', acfe_get_url("assets/css/acfe-field-group{$min}.css"), array(), $version);
|
36 |
+
wp_register_style('acf-extended-ui', acfe_get_url("assets/css/acfe-ui{$min}.css"), array(), $version);
|
37 |
+
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Admin Enqueue
|
42 |
+
*/
|
43 |
+
function admin_enqueue(){
|
44 |
+
|
45 |
+
// Admin
|
46 |
+
wp_enqueue_style('acf-extended-admin');
|
47 |
+
|
48 |
+
// Field Group
|
49 |
+
if(acf_is_screen(array('edit-acf-field-group', 'acf-field-group'))){
|
50 |
+
|
51 |
+
wp_enqueue_style('acf-extended-field-group');
|
52 |
+
|
53 |
+
}
|
54 |
+
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* ACF (Front + Back) Enqueue
|
59 |
+
*/
|
60 |
+
function acf_enqueue(){
|
61 |
+
|
62 |
+
// Global
|
63 |
+
wp_enqueue_style('acf-extended');
|
64 |
+
wp_enqueue_script('acf-extended');
|
65 |
+
|
66 |
+
// Input
|
67 |
+
wp_enqueue_style('acf-extended-input');
|
68 |
+
wp_enqueue_script('acf-extended-input');
|
69 |
+
|
70 |
+
// Admin
|
71 |
+
if(is_admin()){
|
72 |
+
|
73 |
+
wp_enqueue_script('acf-extended-admin');
|
74 |
+
|
75 |
+
}
|
76 |
+
|
77 |
+
// Field Group
|
78 |
+
if(acf_is_screen(array('acf-field-group'))){
|
79 |
+
|
80 |
+
wp_enqueue_script('acf-extended-field-group');
|
81 |
+
|
82 |
+
}
|
83 |
+
|
84 |
+
acf_localize_data(array(
|
85 |
+
'acfe_version' => ACFE_VERSION,
|
86 |
+
'acfe' => array(
|
87 |
+
'home_url' => home_url(),
|
88 |
+
'is_admin' => is_admin(),
|
89 |
+
'is_user_logged_in' => is_user_logged_in(),
|
90 |
+
)
|
91 |
+
));
|
92 |
+
|
93 |
+
$read_more = __('Read more...');
|
94 |
+
$read_more = str_replace('…', '', $read_more);
|
95 |
+
$read_more = str_replace('...', '', $read_more);
|
96 |
+
|
97 |
+
acf_localize_text(array(
|
98 |
+
'Close' => __('Close', 'acf'),
|
99 |
+
'Read more' => $read_more,
|
100 |
+
));
|
101 |
+
|
102 |
+
}
|
103 |
+
|
104 |
+
}
|
105 |
+
|
106 |
+
new acfe_enqueue();
|
107 |
+
|
108 |
endif;
|
@@ -1,1482 +1,1592 @@
|
|
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 false;
|
15 |
-
|
16 |
-
// Vars
|
17 |
-
$flexible = acf_get_field_type('flexible_content');
|
18 |
-
|
19 |
-
ob_start();
|
20 |
-
|
21 |
-
while(have_rows($selector, $post_id)): the_row();
|
22 |
-
|
23 |
-
// Vars
|
24 |
-
$loop = acf_get_loop('active');
|
25 |
-
$field = $loop['field'];
|
26 |
-
|
27 |
-
// Bail early if not Flexible Content
|
28 |
-
if($field['type'] !== 'flexible_content')
|
29 |
-
break;
|
30 |
-
|
31 |
-
$loop_i = acf_get_loop('active', 'i');
|
32 |
-
$layout = $flexible->get_layout(get_row_layout(), $field);
|
33 |
-
|
34 |
-
// First row
|
35 |
-
if($loop_i === 0){
|
36 |
-
|
37 |
-
// Global
|
38 |
-
global $is_preview;
|
39 |
-
|
40 |
-
// Vars
|
41 |
-
if(!isset($is_preview))
|
42 |
-
$is_preview = false;
|
43 |
-
|
44 |
-
$name = $field['_name'];
|
45 |
-
$key = $field['key'];
|
46 |
-
|
47 |
-
// Actions
|
48 |
-
do_action("acfe/flexible/enqueue", $field, $is_preview);
|
49 |
-
do_action("acfe/flexible/enqueue/name={$name}", $field, $is_preview);
|
50 |
-
do_action("acfe/flexible/enqueue/key={$key}", $field, $is_preview);
|
51 |
-
|
52 |
-
}
|
53 |
-
|
54 |
-
// Render: HTML Comment
|
55 |
-
echo "\n" . '<!-- ' . $layout['label'] . ' -->' . "\n";
|
56 |
-
|
57 |
-
// Render: Enqueue
|
58 |
-
acfe_flexible_render_layout_enqueue($layout, $field);
|
59 |
-
|
60 |
-
// Render: Template
|
61 |
-
acfe_flexible_render_layout_template($layout, $field);
|
62 |
-
|
63 |
-
endwhile;
|
64 |
-
|
65 |
-
return ob_get_clean();
|
66 |
-
|
67 |
-
}
|
68 |
-
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* The Flexible
|
73 |
-
*/
|
74 |
-
if(!function_exists('the_flexible')){
|
75 |
-
|
76 |
-
function the_flexible($selector, $post_id = false){
|
77 |
-
|
78 |
-
echo get_flexible($selector, $post_id);
|
79 |
-
|
80 |
-
}
|
81 |
-
|
82 |
-
}
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Has Flexible
|
86 |
-
*/
|
87 |
-
if(!function_exists('has_flexible')){
|
88 |
-
|
89 |
-
function has_flexible($selector, $post_id = false){
|
90 |
-
|
91 |
-
return have_rows($selector, $post_id);
|
92 |
-
|
93 |
-
}
|
94 |
-
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* Flexible: have_settings()
|
99 |
-
*/
|
100 |
-
if(!function_exists('have_settings')){
|
101 |
-
|
102 |
-
function have_settings(){
|
103 |
-
|
104 |
-
return have_rows('layout_settings');
|
105 |
-
|
106 |
-
}
|
107 |
-
|
108 |
-
}
|
109 |
-
|
110 |
-
/**
|
111 |
-
* Flexible: the_settings()
|
112 |
-
*/
|
113 |
-
if(!function_exists('the_setting')){
|
114 |
-
|
115 |
-
function the_setting(){
|
116 |
-
|
117 |
-
return the_row();
|
118 |
-
|
119 |
-
}
|
120 |
-
|
121 |
-
}
|
122 |
-
|
123 |
-
/**
|
124 |
-
* have_archive()
|
125 |
-
*/
|
126 |
-
if(!function_exists('have_archive')){
|
127 |
-
|
128 |
-
function have_archive($_post_type = false){
|
129 |
-
|
130 |
-
global $acfe_archive_i, $acfe_archive_post_type;
|
131 |
-
|
132 |
-
$acfe_archive_post_type = false;
|
133 |
-
|
134 |
-
if(!isset($acfe_archive_i) || $acfe_archive_i === 0){
|
135 |
-
|
136 |
-
$acfe_archive_i = 0;
|
137 |
-
|
138 |
-
$post_type = get_post_type();
|
139 |
-
|
140 |
-
if(!empty($_post_type))
|
141 |
-
$post_type = $_post_type;
|
142 |
-
|
143 |
-
if(!post_type_exists($post_type))
|
144 |
-
return false;
|
145 |
-
|
146 |
-
$post_type_object = get_post_type_object($post_type);
|
147 |
-
|
148 |
-
if(empty($post_type_object))
|
149 |
-
return false;
|
150 |
-
|
151 |
-
if(!isset($post_type_object->acfe_admin_archive) || empty($post_type_object->acfe_admin_archive))
|
152 |
-
return false;
|
153 |
-
|
154 |
-
$acfe_archive_post_type = $post_type;
|
155 |
-
|
156 |
-
return true;
|
157 |
-
|
158 |
-
}
|
159 |
-
|
160 |
-
remove_filter('acf/pre_load_post_id', 'acfe_the_archive_post_id');
|
161 |
-
|
162 |
-
return false;
|
163 |
-
|
164 |
-
}
|
165 |
-
|
166 |
-
}
|
167 |
-
|
168 |
-
/**
|
169 |
-
* the_archive()
|
170 |
-
*/
|
171 |
-
if(!function_exists('the_archive')){
|
172 |
-
|
173 |
-
function the_archive(){
|
174 |
-
|
175 |
-
global $acfe_archive_i;
|
176 |
-
|
177 |
-
add_filter('acf/pre_load_post_id', 'acfe_the_archive_post_id', 10, 2);
|
178 |
-
|
179 |
-
$acfe_archive_i++;
|
180 |
-
|
181 |
-
}
|
182 |
-
|
183 |
-
}
|
184 |
-
|
185 |
-
function acfe_the_archive_post_id($null, $post_id){
|
186 |
-
|
187 |
-
if($post_id !== false)
|
188 |
-
return $null;
|
189 |
-
|
190 |
-
global $acfe_archive_post_type;
|
191 |
-
|
192 |
-
if(empty($acfe_archive_post_type))
|
193 |
-
return $null;
|
194 |
-
|
195 |
-
$return = acf_get_valid_post_id($acfe_archive_post_type . '_archive');
|
196 |
-
|
197 |
-
return $return;
|
198 |
-
|
199 |
-
}
|
200 |
-
|
201 |
-
/**
|
202 |
-
* ACFE Flexible: Render Template
|
203 |
-
*/
|
204 |
-
function acfe_flexible_render_layout_template($layout, $field){
|
205 |
-
|
206 |
-
// Global
|
207 |
-
global $is_preview;
|
208 |
-
|
209 |
-
// Vars
|
210 |
-
$name = $field['_name'];
|
211 |
-
$key = $field['key'];
|
212 |
-
$l_name = $layout['name'];
|
213 |
-
|
214 |
-
// File
|
215 |
-
$file = acf_maybe_get($layout, 'acfe_flexible_render_template');
|
216 |
-
|
217 |
-
// Filters
|
218 |
-
$file = apply_filters("acfe/flexible/render/template", $file, $field, $layout, $is_preview);
|
219 |
-
$file = apply_filters("acfe/flexible/render/template/name={$name}", $file, $field, $layout, $is_preview);
|
220 |
-
$file = apply_filters("acfe/flexible/render/template/key={$key}", $file, $field, $layout, $is_preview);
|
221 |
-
$file = apply_filters("acfe/flexible/render/template/layout={$l_name}", $file, $field, $layout, $is_preview);
|
222 |
-
$file = apply_filters("acfe/flexible/render/template/name={$name}&layout={$l_name}", $file, $field, $layout, $is_preview);
|
223 |
-
$file = apply_filters("acfe/flexible/render/template/key={$key}&layout={$l_name}", $file, $field, $layout, $is_preview);
|
224 |
-
|
225 |
-
// Deprecated
|
226 |
-
$file = apply_filters_deprecated("acfe/flexible/layout/render/template/layout={$l_name}", array($file, $field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/template/layout={$l_name}");
|
227 |
-
$file = apply_filters_deprecated("acfe/flexible/layout/render/template/name={$name}&layout={$l_name}", array($file, $field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/template/name={$name}&layout={$l_name}");
|
228 |
-
$file = apply_filters_deprecated("acfe/flexible/layout/render/template/key={$key}&layout={$l_name}", array($file, $field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/template/key={$key}&layout={$l_name}");
|
229 |
-
|
230 |
-
// Before Template
|
231 |
-
do_action("acfe/flexible/render/before_template", $field, $layout, $is_preview);
|
232 |
-
do_action("acfe/flexible/render/before_template/name={$name}", $field, $layout, $is_preview);
|
233 |
-
do_action("acfe/flexible/render/before_template/key={$key}", $field, $layout, $is_preview);
|
234 |
-
do_action("acfe/flexible/render/before_template/layout={$l_name}", $field, $layout, $is_preview);
|
235 |
-
do_action("acfe/flexible/render/before_template/name={$name}&layout={$l_name}", $field, $layout, $is_preview);
|
236 |
-
do_action("acfe/flexible/render/before_template/key={$key}&layout={$l_name}", $field, $layout, $is_preview);
|
237 |
-
|
238 |
-
// Deprecated
|
239 |
-
do_action_deprecated("acfe/flexible/layout/render/before_template/layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/before_template/layout={$l_name}");
|
240 |
-
do_action_deprecated("acfe/flexible/layout/render/before_template/name={$name}&layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/before_template/name={$name}&layout={$l_name}");
|
241 |
-
do_action_deprecated("acfe/flexible/layout/render/before_template/key={$key}&layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/before_template/key={$key}&layout={$l_name}");
|
242 |
-
|
243 |
-
// Check file
|
244 |
-
if(!empty($file)){
|
245 |
-
|
246 |
-
$file_found = acfe_locate_file_path($file);
|
247 |
-
|
248 |
-
if(!empty($file_found)){
|
249 |
-
|
250 |
-
// Front-end
|
251 |
-
if(!$is_preview){
|
252 |
-
|
253 |
-
// Include
|
254 |
-
include($file_found);
|
255 |
-
|
256 |
-
// Preview
|
257 |
-
}else{
|
258 |
-
|
259 |
-
$path = pathinfo($file);
|
260 |
-
$extension = $path['extension'];
|
261 |
-
|
262 |
-
$file_preview = substr($file,0, -strlen($extension)-1);
|
263 |
-
$file_preview .= '-preview.' . $extension;
|
264 |
-
|
265 |
-
$file_preview = acfe_locate_file_path($file_preview);
|
266 |
-
|
267 |
-
// Include
|
268 |
-
if(!empty($file_preview)){
|
269 |
-
|
270 |
-
include($file_preview);
|
271 |
-
|
272 |
-
}else{
|
273 |
-
|
274 |
-
include($file_found);
|
275 |
-
|
276 |
-
}
|
277 |
-
|
278 |
-
}
|
279 |
-
|
280 |
-
}
|
281 |
-
|
282 |
-
}
|
283 |
-
|
284 |
-
// After Template
|
285 |
-
do_action("acfe/flexible/render/after_template", $field, $layout, $is_preview);
|
286 |
-
do_action("acfe/flexible/render/after_template/name={$name}", $field, $layout, $is_preview);
|
287 |
-
do_action("acfe/flexible/render/after_template/key={$key}", $field, $layout, $is_preview);
|
288 |
-
do_action("acfe/flexible/render/after_template/layout={$l_name}", $field, $layout, $is_preview);
|
289 |
-
do_action("acfe/flexible/render/after_template/name={$name}&layout={$l_name}", $field, $layout, $is_preview);
|
290 |
-
do_action("acfe/flexible/render/after_template/key={$key}&layout={$l_name}", $field, $layout, $is_preview);
|
291 |
-
|
292 |
-
// Deprecated
|
293 |
-
do_action_deprecated("acfe/flexible/layout/render/after_template/layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/after_template/layout={$l_name}");
|
294 |
-
do_action_deprecated("acfe/flexible/layout/render/after_template/name={$name}&layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/after_template/name={$name}&layout={$l_name}");
|
295 |
-
do_action_deprecated("acfe/flexible/layout/render/after_template/key={$key}&layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/after_template/key={$key}&layout={$l_name}");
|
296 |
-
|
297 |
-
}
|
298 |
-
|
299 |
-
/**
|
300 |
-
* ACFE Flexible: Render Enqueue
|
301 |
-
*
|
302 |
-
* @param $layout
|
303 |
-
* @param $field
|
304 |
-
*/
|
305 |
-
function acfe_flexible_render_layout_enqueue($layout, $field){
|
306 |
-
|
307 |
-
// Global
|
308 |
-
global $is_preview;
|
309 |
-
|
310 |
-
// Vars
|
311 |
-
$name = $field['_name'];
|
312 |
-
$key = $field['key'];
|
313 |
-
$l_name = $layout['name'];
|
314 |
-
$handle = acf_slugify($name) . '-layout-' . acf_slugify($l_name);
|
315 |
-
|
316 |
-
// Files
|
317 |
-
$style = acf_maybe_get($layout, 'acfe_flexible_render_style');
|
318 |
-
$script = acf_maybe_get($layout, 'acfe_flexible_render_script');
|
319 |
-
|
320 |
-
/**
|
321 |
-
* Actions
|
322 |
-
*/
|
323 |
-
do_action("acfe/flexible/enqueue/layout={$l_name}", $field, $layout, $is_preview);
|
324 |
-
do_action("acfe/flexible/enqueue/name={$name}&layout={$l_name}", $field, $layout, $is_preview);
|
325 |
-
do_action("acfe/flexible/enqueue/key={$key}&layout={$l_name}", $field, $layout, $is_preview);
|
326 |
-
|
327 |
-
// Deprecated
|
328 |
-
do_action_deprecated("acfe/flexible/layout/enqueue/layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/enqueue/layout={$l_name}");
|
329 |
-
do_action_deprecated("acfe/flexible/layout/enqueue/name={$name}&layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/enqueue/name={$name}&layout={$l_name}");
|
330 |
-
do_action_deprecated("acfe/flexible/layout/enqueue/key={$key}&layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/enqueue/key={$key}&layout={$l_name}");
|
331 |
-
|
332 |
-
/**
|
333 |
-
* Style
|
334 |
-
*/
|
335 |
-
$style = apply_filters("acfe/flexible/render/style", $style, $field, $layout, $is_preview);
|
336 |
-
$style = apply_filters("acfe/flexible/render/style/name={$name}", $style, $field, $layout, $is_preview);
|
337 |
-
$style = apply_filters("acfe/flexible/render/style/key={$key}", $style, $field, $layout, $is_preview);
|
338 |
-
$style = apply_filters("acfe/flexible/render/style/layout={$l_name}", $style, $field, $layout, $is_preview);
|
339 |
-
$style = apply_filters("acfe/flexible/render/style/name={$name}&layout={$l_name}", $style, $field, $layout, $is_preview);
|
340 |
-
$style = apply_filters("acfe/flexible/render/style/key={$key}&layout={$l_name}", $style, $field, $layout, $is_preview);
|
341 |
-
|
342 |
-
// Deprecated
|
343 |
-
$style = apply_filters_deprecated("acfe/flexible/layout/render/style/layout={$l_name}", array($style, $field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/style/layout={$l_name}");
|
344 |
-
$style = apply_filters_deprecated("acfe/flexible/layout/render/style/name={$name}&layout={$l_name}", array($style, $field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/style/name={$name}&layout={$l_name}");
|
345 |
-
$style = apply_filters_deprecated("acfe/flexible/layout/render/style/key={$key}&layout={$l_name}", array($style, $field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/style/key={$key}&layout={$l_name}");
|
346 |
-
|
347 |
-
// Check
|
348 |
-
if(!empty($style)){
|
349 |
-
|
350 |
-
// URL starting with current domain
|
351 |
-
if(stripos($style, home_url()) === 0){
|
352 |
-
|
353 |
-
$style = str_replace(home_url(), '', $style);
|
354 |
-
|
355 |
-
}
|
356 |
-
|
357 |
-
// Locate
|
358 |
-
$style_file = acfe_locate_file_url($style);
|
359 |
-
|
360 |
-
// Front-end
|
361 |
-
if(!empty($style_file)){
|
362 |
-
|
363 |
-
wp_enqueue_style($handle, $style_file, array(), false, 'all');
|
364 |
-
|
365 |
-
}
|
366 |
-
|
367 |
-
// Preview
|
368 |
-
if($is_preview && stripos($style, 'http://') !== 0 && stripos($style, 'https://') !== 0 && stripos($style, '//') !== 0){
|
369 |
-
|
370 |
-
$path = pathinfo($style);
|
371 |
-
$extension = $path['extension'];
|
372 |
-
|
373 |
-
$style_preview = substr($style,0, -strlen($extension)-1);
|
374 |
-
$style_preview .= '-preview.' . $extension;
|
375 |
-
|
376 |
-
$style_preview = acfe_locate_file_url($style_preview);
|
377 |
-
|
378 |
-
// Enqueue
|
379 |
-
if(!empty($style_preview)){
|
380 |
-
|
381 |
-
wp_enqueue_style($handle . '-preview', $style_preview, array(), false, 'all');
|
382 |
-
|
383 |
-
}
|
384 |
-
|
385 |
-
}
|
386 |
-
|
387 |
-
}
|
388 |
-
|
389 |
-
/**
|
390 |
-
* Script
|
391 |
-
*/
|
392 |
-
$script = apply_filters("acfe/flexible/render/script", $script, $field, $layout, $is_preview);
|
393 |
-
$script = apply_filters("acfe/flexible/render/script/name={$name}", $script, $field, $layout, $is_preview);
|
394 |
-
$script = apply_filters("acfe/flexible/render/script/key={$key}", $script, $field, $layout, $is_preview);
|
395 |
-
$script = apply_filters("acfe/flexible/render/script/layout={$l_name}", $script, $field, $layout, $is_preview);
|
396 |
-
$script = apply_filters("acfe/flexible/render/script/name={$name}&layout={$l_name}", $script, $field, $layout, $is_preview);
|
397 |
-
$script = apply_filters("acfe/flexible/render/script/key={$key}&layout={$l_name}", $script, $field, $layout, $is_preview);
|
398 |
-
|
399 |
-
// Deprecated
|
400 |
-
$script = apply_filters_deprecated("acfe/flexible/layout/render/script/layout={$l_name}", array($script, $field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/script/layout={$l_name}");
|
401 |
-
$script = apply_filters_deprecated("acfe/flexible/layout/render/script/name={$name}&layout={$l_name}", array($script, $field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/script/name={$name}&layout={$l_name}");
|
402 |
-
$script = apply_filters_deprecated("acfe/flexible/layout/render/script/key={$key}&layout={$l_name}", array($script, $field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/script/key={$key}&layout={$l_name}");
|
403 |
-
|
404 |
-
// Check
|
405 |
-
if(!empty($script)){
|
406 |
-
|
407 |
-
// URL starting with current domain
|
408 |
-
if(stripos($script, home_url()) === 0){
|
409 |
-
|
410 |
-
$script = str_replace(home_url(), '', $script);
|
411 |
-
|
412 |
-
}
|
413 |
-
|
414 |
-
// Locate
|
415 |
-
$script_file = acfe_locate_file_url($script);
|
416 |
-
|
417 |
-
// Front-end
|
418 |
-
if(!$is_preview || (stripos($script, 'http://') === 0 || stripos($script, 'https://') === 0 || stripos($script, '//') === 0)){
|
419 |
-
|
420 |
-
if(!empty($script_file)){
|
421 |
-
|
422 |
-
wp_enqueue_script($handle, $script_file, array(), false, true);
|
423 |
-
|
424 |
-
}
|
425 |
-
|
426 |
-
}else{
|
427 |
-
|
428 |
-
$path = pathinfo($script);
|
429 |
-
$extension = $path['extension'];
|
430 |
-
|
431 |
-
$script_preview = substr($script,0, -strlen($extension)-1);
|
432 |
-
$script_preview .= '-preview.' . $extension;
|
433 |
-
|
434 |
-
$script_preview = acfe_locate_file_url($script_preview);
|
435 |
-
|
436 |
-
// Enqueue
|
437 |
-
if(!empty($script_preview)){
|
438 |
-
|
439 |
-
wp_enqueue_script($handle . '-preview', $script_preview, array(), false, true);
|
440 |
-
|
441 |
-
}elseif(!empty($script_file)){
|
442 |
-
|
443 |
-
wp_enqueue_script($handle, $script_file, array(), false, true);
|
444 |
-
|
445 |
-
}
|
446 |
-
|
447 |
-
}
|
448 |
-
|
449 |
-
}
|
450 |
-
|
451 |
-
}
|
452 |
-
|
453 |
-
/**
|
454 |
-
* Get Field Group from Field
|
455 |
-
*/
|
456 |
-
function acfe_get_field_group_from_field($field){
|
457 |
-
|
458 |
-
if(!acf_maybe_get($field, 'parent'))
|
459 |
-
return false;
|
460 |
-
|
461 |
-
$field_parent = $field['parent'];
|
462 |
-
|
463 |
-
if(!$field_ancestors = acf_get_field_ancestors($field))
|
464 |
-
return acf_get_field_group($field_parent);
|
465 |
-
|
466 |
-
// Reverse for DESC order (Top field first)
|
467 |
-
$field_ancestors = array_reverse($field_ancestors);
|
468 |
-
|
469 |
-
$field_top_ancestor = $field_ancestors[0];
|
470 |
-
$field_top_ancestor = acf_get_field($field_top_ancestor);
|
471 |
-
|
472 |
-
return acf_get_field_group($field_top_ancestor['parent']);
|
473 |
-
|
474 |
-
}
|
475 |
-
|
476 |
-
/**
|
477 |
-
* Is Json
|
478 |
-
* Source: https://stackoverflow.com/a/6041773
|
479 |
-
*/
|
480 |
-
function acfe_is_json($string){
|
481 |
-
|
482 |
-
// in case string = 1
|
483 |
-
if(is_numeric($string))
|
484 |
-
return false;
|
485 |
-
|
486 |
-
json_decode($string);
|
487 |
-
|
488 |
-
return (json_last_error() == JSON_ERROR_NONE);
|
489 |
-
|
490 |
-
}
|
491 |
-
|
492 |
-
/*
|
493 |
-
* Array Keys Recursive
|
494 |
-
*/
|
495 |
-
function acfe_array_keys_r($array){
|
496 |
-
|
497 |
-
$keys = array_keys($array);
|
498 |
-
|
499 |
-
foreach($array as $i){
|
500 |
-
|
501 |
-
if(!is_array($i))
|
502 |
-
continue;
|
503 |
-
|
504 |
-
$keys = array_merge($keys, acfe_array_keys_r($i));
|
505 |
-
|
506 |
-
}
|
507 |
-
|
508 |
-
return $keys;
|
509 |
-
|
510 |
-
}
|
511 |
-
|
512 |
-
/*
|
513 |
-
* Locate File URL
|
514 |
-
* Check if file exists locally and return URL (supports parent/child theme)
|
515 |
-
*/
|
516 |
-
function acfe_locate_file_url($filenames){
|
517 |
-
|
518 |
-
$located = '';
|
519 |
-
|
520 |
-
foreach((array) $filenames as $filename){
|
521 |
-
|
522 |
-
if(!$filename)
|
523 |
-
continue;
|
524 |
-
|
525 |
-
// Direct URL: https://www.domain.com/folder/file.js
|
526 |
-
if(stripos($filename, 'http://') === 0 || stripos($filename, 'https://') === 0 || stripos($filename, '//') === 0){
|
527 |
-
|
528 |
-
$located = $filename;
|
529 |
-
break;
|
530 |
-
|
531 |
-
}else{
|
532 |
-
|
533 |
-
$_filename = ltrim($filename, '/\\');
|
534 |
-
$abspath = untrailingslashit(ABSPATH);
|
535 |
-
|
536 |
-
// Child Theme
|
537 |
-
if(file_exists(STYLESHEETPATH . '/' . $_filename)){
|
538 |
-
|
539 |
-
$located = get_stylesheet_directory_uri() . '/' . $_filename;
|
540 |
-
break;
|
541 |
-
|
542 |
-
}
|
543 |
-
|
544 |
-
// Parent Theme
|
545 |
-
elseif(file_exists(TEMPLATEPATH . '/' . $_filename)){
|
546 |
-
|
547 |
-
$located = get_template_directory_uri() . '/' . $_filename;
|
548 |
-
break;
|
549 |
-
|
550 |
-
}
|
551 |
-
|
552 |
-
// Direct file path
|
553 |
-
elseif(file_exists($filename)){
|
554 |
-
|
555 |
-
$located = acfe_get_abs_path_to_url($filename);
|
556 |
-
break;
|
557 |
-
|
558 |
-
}
|
559 |
-
|
560 |
-
// ABSPATH file path
|
561 |
-
elseif(file_exists($abspath . '/' . $_filename)){
|
562 |
-
|
563 |
-
$located = acfe_get_abs_path_to_url($abspath . '/' . $_filename);
|
564 |
-
break;
|
565 |
-
|
566 |
-
}
|
567 |
-
|
568 |
-
// WP Content Dir
|
569 |
-
elseif(file_exists(WP_CONTENT_DIR . '/' . $_filename)){
|
570 |
-
|
571 |
-
$located = WP_CONTENT_URL . '/' . $_filename;
|
572 |
-
break;
|
573 |
-
|
574 |
-
}
|
575 |
-
|
576 |
-
}
|
577 |
-
|
578 |
-
}
|
579 |
-
|
580 |
-
return $located;
|
581 |
-
|
582 |
-
}
|
583 |
-
|
584 |
-
/*
|
585 |
-
* Locate File Path
|
586 |
-
* Based on wp-includes\template.php:653
|
587 |
-
*/
|
588 |
-
function acfe_locate_file_path($filenames){
|
589 |
-
|
590 |
-
$located = '';
|
591 |
-
|
592 |
-
foreach((array) $filenames as $filename){
|
593 |
-
|
594 |
-
if(!$filename)
|
595 |
-
continue;
|
596 |
-
|
597 |
-
$_filename = ltrim($filename, '/\\');
|
598 |
-
$abspath = untrailingslashit(ABSPATH);
|
599 |
-
|
600 |
-
// Stylesheet file path
|
601 |
-
if(file_exists(STYLESHEETPATH . '/' . $_filename)){
|
602 |
-
|
603 |
-
$located = STYLESHEETPATH . '/' . $_filename;
|
604 |
-
break;
|
605 |
-
|
606 |
-
}
|
607 |
-
|
608 |
-
// Template file path
|
609 |
-
elseif(file_exists(TEMPLATEPATH . '/' . $_filename)){
|
610 |
-
|
611 |
-
$located = TEMPLATEPATH . '/' . $_filename;
|
612 |
-
break;
|
613 |
-
|
614 |
-
}
|
615 |
-
|
616 |
-
// Direct file path
|
617 |
-
elseif(file_exists($filename)){
|
618 |
-
|
619 |
-
$located = $filename;
|
620 |
-
break;
|
621 |
-
|
622 |
-
}
|
623 |
-
|
624 |
-
// ABSPATH file path
|
625 |
-
elseif(file_exists($abspath . '/' . $_filename)){
|
626 |
-
|
627 |
-
$located = $abspath . '/' . $_filename;
|
628 |
-
break;
|
629 |
-
|
630 |
-
}
|
631 |
-
|
632 |
-
// WP Content Dir
|
633 |
-
elseif(file_exists(WP_CONTENT_DIR . '/' . $_filename)){
|
634 |
-
|
635 |
-
$located = WP_CONTENT_DIR . '/' . $_filename;
|
636 |
-
break;
|
637 |
-
|
638 |
-
}
|
639 |
-
|
640 |
-
}
|
641 |
-
|
642 |
-
return $located;
|
643 |
-
|
644 |
-
}
|
645 |
-
|
646 |
-
/**
|
647 |
-
* Convert ABSPATH . '/url' to https://www.domain.com/url
|
648 |
-
*/
|
649 |
-
function acfe_get_abs_path_to_url($path = ''){
|
650 |
-
|
651 |
-
$abspath = untrailingslashit(ABSPATH);
|
652 |
-
|
653 |
-
$url = str_replace($abspath, site_url(), $path);
|
654 |
-
$url = wp_normalize_path($url);
|
655 |
-
|
656 |
-
return esc_url_raw($url);
|
657 |
-
|
658 |
-
}
|
659 |
-
|
660 |
-
/**
|
661 |
-
* Get Roles
|
662 |
-
*/
|
663 |
-
function acfe_get_roles($filtered_user_roles = array()){
|
664 |
-
|
665 |
-
$list = array();
|
666 |
-
|
667 |
-
global $wp_roles;
|
668 |
-
|
669 |
-
if(is_multisite())
|
670 |
-
$list['super_admin'] = __('Super Admin');
|
671 |
-
|
672 |
-
foreach($wp_roles->roles as $role => $settings){
|
673 |
-
|
674 |
-
$list[$role] = $settings['name'];
|
675 |
-
|
676 |
-
}
|
677 |
-
|
678 |
-
$user_roles = $list;
|
679 |
-
|
680 |
-
if(!empty($filtered_user_roles)){
|
681 |
-
|
682 |
-
$user_roles = array();
|
683 |
-
|
684 |
-
foreach($list as $role => $role_label){
|
685 |
-
|
686 |
-
if(!in_array($role, $filtered_user_roles))
|
687 |
-
continue;
|
688 |
-
|
689 |
-
$user_roles[$role] = $role_label;
|
690 |
-
|
691 |
-
}
|
692 |
-
|
693 |
-
}
|
694 |
-
|
695 |
-
return $user_roles;
|
696 |
-
|
697 |
-
}
|
698 |
-
|
699 |
-
/**
|
700 |
-
* Get Current Roles
|
701 |
-
*/
|
702 |
-
function acfe_get_current_user_roles(){
|
703 |
-
|
704 |
-
global $current_user;
|
705 |
-
|
706 |
-
if(!is_object($current_user) || !isset($current_user->roles))
|
707 |
-
return false;
|
708 |
-
|
709 |
-
$roles = $current_user->roles;
|
710 |
-
|
711 |
-
if(is_multisite() && current_user_can('setup_network'))
|
712 |
-
$roles[] = 'super_admin';
|
713 |
-
|
714 |
-
return $roles;
|
715 |
-
|
716 |
-
}
|
717 |
-
|
718 |
-
/**
|
719 |
-
* Get post types objects
|
720 |
-
*/
|
721 |
-
function acfe_get_post_type_objects($args = array()){
|
722 |
-
|
723 |
-
// vars
|
724 |
-
$return = array();
|
725 |
-
|
726 |
-
// Post Types
|
727 |
-
$posts_types = acf_get_post_types($args);
|
728 |
-
|
729 |
-
// Choices
|
730 |
-
if(!empty($posts_types)){
|
731 |
-
|
732 |
-
foreach($posts_types as $post_type){
|
733 |
-
|
734 |
-
$post_type_object = get_post_type_object($post_type);
|
735 |
-
|
736 |
-
$return[$post_type_object->name] = $post_type_object;
|
737 |
-
|
738 |
-
}
|
739 |
-
|
740 |
-
}
|
741 |
-
|
742 |
-
return $return;
|
743 |
-
|
744 |
-
}
|
745 |
-
|
746 |
-
/**
|
747 |
-
* Get taxonomy objects
|
748 |
-
*/
|
749 |
-
function acfe_get_taxonomy_objects($args = array()){
|
750 |
-
|
751 |
-
// vars
|
752 |
-
$return = array();
|
753 |
-
|
754 |
-
// Post Types
|
755 |
-
$taxonomies = acf_get_taxonomies($args);
|
756 |
-
|
757 |
-
// Choices
|
758 |
-
if(!empty($taxonomies)){
|
759 |
-
|
760 |
-
foreach($taxonomies as $taxonomy){
|
761 |
-
|
762 |
-
$taxonomy_object = get_taxonomy($taxonomy);
|
763 |
-
|
764 |
-
$return[$taxonomy_object->name] = $taxonomy_object;
|
765 |
-
|
766 |
-
}
|
767 |
-
|
768 |
-
}
|
769 |
-
|
770 |
-
return $return;
|
771 |
-
|
772 |
-
}
|
773 |
-
|
774 |
-
/**
|
775 |
-
* Get post statuses
|
776 |
-
*/
|
777 |
-
function acfe_get_pretty_post_statuses($posts_statuses = array()){
|
778 |
-
|
779 |
-
if(empty($posts_statuses)){
|
780 |
-
|
781 |
-
$posts_statuses = get_post_stati(array(), 'names');
|
782 |
-
|
783 |
-
}
|
784 |
-
|
785 |
-
$return = array();
|
786 |
-
|
787 |
-
// Choices
|
788 |
-
if(!empty($posts_statuses)){
|
789 |
-
|
790 |
-
foreach($posts_statuses as $post_status){
|
791 |
-
|
792 |
-
$post_status_object = get_post_status_object($post_status);
|
793 |
-
|
794 |
-
$return[$post_status_object->name] = $post_status_object->label . ' (' . $post_status_object->name . ')';
|
795 |
-
|
796 |
-
}
|
797 |
-
|
798 |
-
}
|
799 |
-
|
800 |
-
return $return;
|
801 |
-
|
802 |
-
}
|
803 |
-
|
804 |
-
/**
|
805 |
-
* Get forms
|
806 |
-
*/
|
807 |
-
function acfe_get_pretty_forms($forms = array()){
|
808 |
-
|
809 |
-
if(empty($forms)){
|
810 |
-
|
811 |
-
$forms = get_posts(array(
|
812 |
-
'post_type' => 'acfe-form',
|
813 |
-
'posts_per_page' => -1,
|
814 |
-
'fields' => 'ids',
|
815 |
-
'orderby' => 'title',
|
816 |
-
'order' => 'ASC',
|
817 |
-
));
|
818 |
-
|
819 |
-
}
|
820 |
-
|
821 |
-
$return = array();
|
822 |
-
|
823 |
-
// Choices
|
824 |
-
if(!empty($forms)){
|
825 |
-
|
826 |
-
foreach($forms as $form_id){
|
827 |
-
|
828 |
-
$form_name = get_the_title($form_id);
|
829 |
-
|
830 |
-
$return[$form_id] = $form_name;
|
831 |
-
|
832 |
-
}
|
833 |
-
|
834 |
-
}
|
835 |
-
|
836 |
-
return $return;
|
837 |
-
|
838 |
-
}
|
839 |
-
|
840 |
-
/**
|
841 |
-
* Starts with
|
842 |
-
*/
|
843 |
-
function acfe_starts_with($haystack, $needle){
|
844 |
-
|
845 |
-
$length = strlen($needle);
|
846 |
-
return (substr($haystack, 0, $length) === $needle);
|
847 |
-
|
848 |
-
}
|
849 |
-
|
850 |
-
/**
|
851 |
-
* Ends with
|
852 |
-
*/
|
853 |
-
function acfe_ends_with($haystack, $needle){
|
854 |
-
|
855 |
-
$length = strlen($needle);
|
856 |
-
|
857 |
-
if($length == 0)
|
858 |
-
return true;
|
859 |
-
|
860 |
-
return (substr($haystack, -$length) === $needle);
|
861 |
-
|
862 |
-
}
|
863 |
-
|
864 |
-
function acfe_form_is_admin(){
|
865 |
-
|
866 |
-
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'))
|
867 |
-
return true;
|
868 |
-
|
869 |
-
return false;
|
870 |
-
|
871 |
-
}
|
872 |
-
|
873 |
-
function acfe_form_is_front(){
|
874 |
-
|
875 |
-
if(!is_admin() || (is_admin() && wp_doing_ajax() && (acf_maybe_get_POST('_acf_screen') === 'acfe_form' || acf_maybe_get_POST('_acf_screen') === 'acf_form')))
|
876 |
-
return true;
|
877 |
-
|
878 |
-
return false;
|
879 |
-
|
880 |
-
}
|
881 |
-
|
882 |
-
function acfe_form_decrypt_args(){
|
883 |
-
|
884 |
-
if(!acf_maybe_get_POST('_acf_form'))
|
885 |
-
return false;
|
886 |
-
|
887 |
-
$form = json_decode(acf_decrypt($_POST['_acf_form']), true);
|
888 |
-
|
889 |
-
if(empty($form))
|
890 |
-
return false;
|
891 |
-
|
892 |
-
return $form;
|
893 |
-
|
894 |
-
}
|
895 |
-
|
896 |
-
function acfe_is_form_success($form_name = false){
|
897 |
-
|
898 |
-
if(!acf_maybe_get_POST('_acf_form'))
|
899 |
-
return false;
|
900 |
-
|
901 |
-
$form = acfe_form_decrypt_args();
|
902 |
-
|
903 |
-
if(empty($form))
|
904 |
-
return false;
|
905 |
-
|
906 |
-
if(!empty($form_name) && acf_maybe_get($form, 'name') !== $form_name)
|
907 |
-
return false;
|
908 |
-
|
909 |
-
return true;
|
910 |
-
|
911 |
-
}
|
912 |
-
|
913 |
-
function acfe_form_is_submitted($form_name = false){
|
914 |
-
|
915 |
-
_deprecated_function('ACF Extended - Dynamic Forms: "acfe_form_is_submitted()" function', '0.8.7.5', "acfe_is_form_success()");
|
916 |
-
|
917 |
-
return acfe_is_form_success($form_name);
|
918 |
-
|
919 |
-
}
|
920 |
-
|
921 |
-
function acfe_form_unique_action_id($form, $type){
|
922 |
-
|
923 |
-
$name = $form['name'] . '-' . $type;
|
924 |
-
|
925 |
-
global $acfe_form_uniqid;
|
926 |
-
|
927 |
-
$acfe_form_uniqid = acf_get_array($acfe_form_uniqid);
|
928 |
-
|
929 |
-
if(!isset($acfe_form_uniqid[$type])){
|
930 |
-
|
931 |
-
$acfe_form_uniqid[$type] = 1;
|
932 |
-
|
933 |
-
}
|
934 |
-
|
935 |
-
if($acfe_form_uniqid[$type] > 1)
|
936 |
-
$name = $name . '-' . $acfe_form_uniqid[$type];
|
937 |
-
|
938 |
-
$acfe_form_uniqid[$type]++;
|
939 |
-
|
940 |
-
return $name;
|
941 |
-
|
942 |
-
}
|
943 |
-
|
944 |
-
function acfe_form_get_actions(){
|
945 |
-
|
946 |
-
return get_query_var('acfe_form_actions', array());
|
947 |
-
|
948 |
-
}
|
949 |
-
|
950 |
-
function acfe_form_get_action($name = false){
|
951 |
-
|
952 |
-
$actions = acfe_form_get_actions();
|
953 |
-
|
954 |
-
// No Action
|
955 |
-
if(empty($actions))
|
956 |
-
return false;
|
957 |
-
|
958 |
-
// Last Action
|
959 |
-
if(empty($name))
|
960 |
-
return end($actions);
|
961 |
-
|
962 |
-
if(isset($actions[$name]))
|
963 |
-
return $actions[$name];
|
964 |
-
|
965 |
-
return false;
|
966 |
-
|
967 |
-
}
|
968 |
-
|
969 |
-
function acfe_array_insert_before($key, array &$array, $new_key, $new_value){
|
970 |
-
|
971 |
-
if(!array_key_exists($key, $array))
|
972 |
-
return $array;
|
973 |
-
|
974 |
-
$new = array();
|
975 |
-
|
976 |
-
foreach($array as $k => $value){
|
977 |
-
|
978 |
-
if($k === $key)
|
979 |
-
$new[$new_key] = $new_value;
|
980 |
-
|
981 |
-
$new[$k] = $value;
|
982 |
-
|
983 |
-
}
|
984 |
-
|
985 |
-
return $new;
|
986 |
-
|
987 |
-
}
|
988 |
-
|
989 |
-
function acfe_array_insert_after($key, array &$array, $new_key, $new_value){
|
990 |
-
|
991 |
-
if(!array_key_exists($key, $array))
|
992 |
-
return $array;
|
993 |
-
|
994 |
-
$new = array();
|
995 |
-
|
996 |
-
foreach($array as $k => $value){
|
997 |
-
|
998 |
-
$new[$k] = $value;
|
999 |
-
|
1000 |
-
if($k === $key)
|
1001 |
-
$new[$new_key] = $new_value;
|
1002 |
-
|
1003 |
-
}
|
1004 |
-
|
1005 |
-
return $new;
|
1006 |
-
|
1007 |
-
}
|
1008 |
-
|
1009 |
-
function acfe_array_move(&$array, $a, $b){
|
1010 |
-
|
1011 |
-
$out = array_splice($array, $a, 1);
|
1012 |
-
array_splice($array, $b, 0, $out);
|
1013 |
-
|
1014 |
-
}
|
1015 |
-
|
1016 |
-
function acfe_add_validation_error($selector = '', $message = ''){
|
1017 |
-
|
1018 |
-
// General error
|
1019 |
-
if(empty($selector))
|
1020 |
-
return acf_add_validation_error('', $message);
|
1021 |
-
|
1022 |
-
$row = acf_get_loop('active');
|
1023 |
-
|
1024 |
-
if($row){
|
1025 |
-
|
1026 |
-
$field = acf_get_sub_field($selector, $row['field']);
|
1027 |
-
|
1028 |
-
}
|
1029 |
-
|
1030 |
-
else{
|
1031 |
-
|
1032 |
-
$field = acf_get_field($selector);
|
1033 |
-
|
1034 |
-
}
|
1035 |
-
|
1036 |
-
// Field not found: General error
|
1037 |
-
if(!$field)
|
1038 |
-
return acf_add_validation_error('', $message);
|
1039 |
-
|
1040 |
-
// Specific field error
|
1041 |
-
add_filter('acf/validate_value/key=' . $field['key'], function($valid) use($message){
|
1042 |
-
|
1043 |
-
return $message;
|
1044 |
-
|
1045 |
-
});
|
1046 |
-
|
1047 |
-
}
|
1048 |
-
|
1049 |
-
/*
|
1050 |
-
* Similar to acf_get_taxonomy_terms() but returns array('256' => 'Category name') instead of array('category:category_name' => 'Category name')
|
1051 |
-
*/
|
1052 |
-
function acfe_get_taxonomy_terms_ids($taxonomies = array()){
|
1053 |
-
|
1054 |
-
// force array
|
1055 |
-
$taxonomies = acf_get_array($taxonomies);
|
1056 |
-
|
1057 |
-
// get pretty taxonomy names
|
1058 |
-
$taxonomies = acf_get_pretty_taxonomies( $taxonomies );
|
1059 |
-
|
1060 |
-
// vars
|
1061 |
-
$r = array();
|
1062 |
-
|
1063 |
-
// populate $r
|
1064 |
-
foreach( array_keys($taxonomies) as $taxonomy ) {
|
1065 |
-
|
1066 |
-
// vars
|
1067 |
-
$label = $taxonomies[$taxonomy];
|
1068 |
-
$is_hierarchical = is_taxonomy_hierarchical( $taxonomy );
|
1069 |
-
|
1070 |
-
$terms = acf_get_terms(array(
|
1071 |
-
'taxonomy' => $taxonomy,
|
1072 |
-
'hide_empty' => false
|
1073 |
-
));
|
1074 |
-
|
1075 |
-
// bail early if no terms
|
1076 |
-
if(empty($terms))
|
1077 |
-
continue;
|
1078 |
-
|
1079 |
-
// sort into hierachial order!
|
1080 |
-
if($is_hierarchical){
|
1081 |
-
|
1082 |
-
$terms = _get_term_children( 0, $terms, $taxonomy );
|
1083 |
-
|
1084 |
-
}
|
1085 |
-
|
1086 |
-
// add placeholder
|
1087 |
-
$r[ $label ] = array();
|
1088 |
-
|
1089 |
-
// add choices
|
1090 |
-
foreach($terms as $term){
|
1091 |
-
|
1092 |
-
$k = "{$term->term_id}";
|
1093 |
-
$r[$label][$k] = acf_get_term_title($term);
|
1094 |
-
|
1095 |
-
}
|
1096 |
-
|
1097 |
-
}
|
1098 |
-
|
1099 |
-
// return
|
1100 |
-
return $r;
|
1101 |
-
|
1102 |
-
}
|
1103 |
-
|
1104 |
-
function acfe_get_term_level($term, $taxonomy){
|
1105 |
-
|
1106 |
-
$ancestors = get_ancestors($term, $taxonomy);
|
1107 |
-
|
1108 |
-
return count($ancestors) + 1;
|
1109 |
-
|
1110 |
-
}
|
1111 |
-
|
1112 |
-
function acfe_number_suffix($num){
|
1113 |
-
|
1114 |
-
if(!in_array(($num % 100), array(11,12,13))){
|
1115 |
-
|
1116 |
-
switch($num % 10){
|
1117 |
-
case 1: return $num . 'st';
|
1118 |
-
case 2: return $num . 'nd';
|
1119 |
-
case 3: return $num . 'rd';
|
1120 |
-
}
|
1121 |
-
|
1122 |
-
}
|
1123 |
-
|
1124 |
-
return $num . 'th';
|
1125 |
-
|
1126 |
-
}
|
1127 |
-
|
1128 |
-
function acfe_array_to_string($array = array()){
|
1129 |
-
|
1130 |
-
if(!is_array($array))
|
1131 |
-
return $array;
|
1132 |
-
|
1133 |
-
if(empty($array))
|
1134 |
-
return false;
|
1135 |
-
|
1136 |
-
if(acf_is_sequential_array($array)){
|
1137 |
-
|
1138 |
-
foreach($array as $k => $v){
|
1139 |
-
|
1140 |
-
if(!is_string($v))
|
1141 |
-
continue;
|
1142 |
-
|
1143 |
-
return $v;
|
1144 |
-
|
1145 |
-
}
|
1146 |
-
|
1147 |
-
}elseif(acf_is_associative_array($array)){
|
1148 |
-
|
1149 |
-
foreach($array as $k => $v){
|
1150 |
-
|
1151 |
-
if(!is_string($v))
|
1152 |
-
continue;
|
1153 |
-
|
1154 |
-
return $v;
|
1155 |
-
|
1156 |
-
}
|
1157 |
-
|
1158 |
-
}
|
1159 |
-
|
1160 |
-
return false;
|
1161 |
-
|
1162 |
-
}
|
1163 |
-
|
1164 |
-
function acfe_get_acf_screen_id($page = ''){
|
1165 |
-
|
1166 |
-
$prefix = sanitize_title( __("Custom Fields", 'acf') );
|
1167 |
-
|
1168 |
-
if(empty($page))
|
1169 |
-
return $prefix;
|
1170 |
-
|
1171 |
-
return $prefix . '_page_' . $page;
|
1172 |
-
|
1173 |
-
}
|
1174 |
-
|
1175 |
-
function acfe_is_admin_screen($modules = false){
|
1176 |
-
|
1177 |
-
// bail early if not defined
|
1178 |
-
if(!function_exists('get_current_screen'))
|
1179 |
-
return false;
|
1180 |
-
|
1181 |
-
// vars
|
1182 |
-
$screen = get_current_screen();
|
1183 |
-
|
1184 |
-
// no screen
|
1185 |
-
if(!$screen)
|
1186 |
-
return false;
|
1187 |
-
|
1188 |
-
$post_types = array(
|
1189 |
-
'acf-field-group', // ACF
|
1190 |
-
);
|
1191 |
-
|
1192 |
-
$field_group_category = false;
|
1193 |
-
|
1194 |
-
// include ACF Extended Modules?
|
1195 |
-
if($modules){
|
1196 |
-
|
1197 |
-
$post_types[] = 'acfe-dbt'; // Dynamic Block Type
|
1198 |
-
$post_types[] = 'acfe-dop'; // Dynamic Option Page
|
1199 |
-
$post_types[] = 'acfe-dpt'; // Dynamic Post Type
|
1200 |
-
$post_types[] = 'acfe-dt'; // Dynamic Taxonomy
|
1201 |
-
$post_types[] = 'acfe-form'; // Dynamic Form
|
1202 |
-
|
1203 |
-
// Field Group Category
|
1204 |
-
$field_group_category = $screen->post_type === 'post' && $screen->taxonomy === 'acf-field-group-category';
|
1205 |
-
|
1206 |
-
}
|
1207 |
-
|
1208 |
-
if(in_array($screen->post_type, $post_types) || $field_group_category)
|
1209 |
-
return true;
|
1210 |
-
|
1211 |
-
return false;
|
1212 |
-
|
1213 |
-
}
|
1214 |
-
|
1215 |
-
function acfe_is_dev(){
|
1216 |
-
|
1217 |
-
return acf_get_setting('acfe/dev', false) || (defined('ACFE_dev') && ACFE_dev);
|
1218 |
-
|
1219 |
-
}
|
1220 |
-
|
1221 |
-
function acfe_is_super_dev(){
|
1222 |
-
|
1223 |
-
return acf_get_setting('acfe/super_dev', false) || (defined('ACFE_super_dev') && ACFE_super_dev);
|
1224 |
-
|
1225 |
-
}
|
1226 |
-
|
1227 |
-
function acfe_update_setting($name, $value){
|
1228 |
-
|
1229 |
-
return acf_update_setting("acfe/{$name}", $value);
|
1230 |
-
|
1231 |
-
}
|
1232 |
-
|
1233 |
-
function acfe_append_setting($name, $value){
|
1234 |
-
|
1235 |
-
return acf_append_setting("acfe/{$name}", $value);
|
1236 |
-
|
1237 |
-
}
|
1238 |
-
|
1239 |
-
function acfe_get_setting($name, $value = null){
|
1240 |
-
|
1241 |
-
return acf_get_setting("acfe/{$name}", $value);
|
1242 |
-
|
1243 |
-
}
|
1244 |
-
|
1245 |
-
function acfe_get_locations_array($locations){
|
1246 |
-
|
1247 |
-
$return = array();
|
1248 |
-
$types = acf_get_location_rule_types();
|
1249 |
-
|
1250 |
-
if(!$locations || !$types)
|
1251 |
-
return $return;
|
1252 |
-
|
1253 |
-
$icon_default = 'admin-generic';
|
1254 |
-
|
1255 |
-
$icons = array(
|
1256 |
-
'edit' => array(
|
1257 |
-
'post_type',
|
1258 |
-
'post_template',
|
1259 |
-
'post_status',
|
1260 |
-
'post_format',
|
1261 |
-
'post',
|
1262 |
-
),
|
1263 |
-
'media-default' => array(
|
1264 |
-
'page_template',
|
1265 |
-
'page_type',
|
1266 |
-
'page_parent',
|
1267 |
-
'page',
|
1268 |
-
),
|
1269 |
-
'admin-users' => array(
|
1270 |
-
'current_user',
|
1271 |
-
'user_form',
|
1272 |
-
),
|
1273 |
-
'welcome-widgets-menus' => array(
|
1274 |
-
'widget',
|
1275 |
-
'nav_menu',
|
1276 |
-
'nav_menu_item',
|
1277 |
-
),
|
1278 |
-
'category' => array(
|
1279 |
-
'taxonomy',
|
1280 |
-
'post_category',
|
1281 |
-
'post_taxonomy',
|
1282 |
-
),
|
1283 |
-
'admin-comments' => array(
|
1284 |
-
'comment',
|
1285 |
-
),
|
1286 |
-
'paperclip' => array(
|
1287 |
-
'attachment',
|
1288 |
-
),
|
1289 |
-
'admin-settings' => array(
|
1290 |
-
'options_page',
|
1291 |
-
),
|
1292 |
-
'businessman' => array(
|
1293 |
-
'current_user_role',
|
1294 |
-
'user_role',
|
1295 |
-
),
|
1296 |
-
'admin-appearance' => array(
|
1297 |
-
'acfe_template'
|
1298 |
-
)
|
1299 |
-
);
|
1300 |
-
|
1301 |
-
$rules = array();
|
1302 |
-
|
1303 |
-
foreach($types as $key => $type){
|
1304 |
-
|
1305 |
-
foreach($type as $slug => $name){
|
1306 |
-
|
1307 |
-
$icon = $icon_default;
|
1308 |
-
|
1309 |
-
foreach($icons as $_icon => $icon_slugs){
|
1310 |
-
|
1311 |
-
if(!in_array($slug, $icon_slugs))
|
1312 |
-
continue;
|
1313 |
-
|
1314 |
-
$icon = $_icon;
|
1315 |
-
break;
|
1316 |
-
|
1317 |
-
}
|
1318 |
-
|
1319 |
-
$rules[$slug] = array(
|
1320 |
-
'name' => $slug,
|
1321 |
-
'label' => $name,
|
1322 |
-
'icon' => $icon
|
1323 |
-
);
|
1324 |
-
|
1325 |
-
}
|
1326 |
-
|
1327 |
-
}
|
1328 |
-
|
1329 |
-
foreach($locations as $group){
|
1330 |
-
|
1331 |
-
if(!acf_maybe_get($rules, $group['param']) || !acf_maybe_get($group, 'value'))
|
1332 |
-
continue;
|
1333 |
-
|
1334 |
-
// init
|
1335 |
-
$rule = $rules[$group['param']];
|
1336 |
-
|
1337 |
-
// vars
|
1338 |
-
$icon = $rule['icon'];
|
1339 |
-
$name = $rule['name'];
|
1340 |
-
$label = $rule['label'];
|
1341 |
-
$operator = $group['operator'] === '==' ? '=' : $group['operator'];
|
1342 |
-
$value = $group['value'];
|
1343 |
-
|
1344 |
-
// Exception for Post/Page/page Parent ID
|
1345 |
-
if(in_array($group['param'], array('post', 'page', 'page_parent'))){
|
1346 |
-
|
1347 |
-
$value = get_the_title((int) $value);
|
1348 |
-
|
1349 |
-
}else{
|
1350 |
-
|
1351 |
-
// Validate value
|
1352 |
-
$values = acf_get_location_rule_values($group);
|
1353 |
-
|
1354 |
-
if(!empty($values) && is_array($values)){
|
1355 |
-
|
1356 |
-
foreach($values as $value_slug => $value_name){
|
1357 |
-
|
1358 |
-
if($value != $value_slug)
|
1359 |
-
continue;
|
1360 |
-
|
1361 |
-
$value = $value_name;
|
1362 |
-
|
1363 |
-
if(is_array($value_name) && isset($value_name[$value_slug])){
|
1364 |
-
|
1365 |
-
$value = $value_name[$value_slug];
|
1366 |
-
|
1367 |
-
}
|
1368 |
-
|
1369 |
-
break;
|
1370 |
-
|
1371 |
-
}
|
1372 |
-
|
1373 |
-
}
|
1374 |
-
|
1375 |
-
}
|
1376 |
-
|
1377 |
-
// html
|
1378 |
-
$title = $label . ' ' . $operator . ' ' . $value;
|
1379 |
-
|
1380 |
-
$atts = array(
|
1381 |
-
'class' => 'acf-js-tooltip dashicons dashicons-' . $icon,
|
1382 |
-
'title' => $title
|
1383 |
-
);
|
1384 |
-
|
1385 |
-
if($operator === '!='){
|
1386 |
-
|
1387 |
-
$atts['style'] = 'color: #ccc;';
|
1388 |
-
|
1389 |
-
}
|
1390 |
-
|
1391 |
-
$html = '<span ' . acf_esc_attr($atts) . '></span>';
|
1392 |
-
|
1393 |
-
$return[] = array(
|
1394 |
-
'html' => $html,
|
1395 |
-
'icon' => $icon,
|
1396 |
-
'title' => $title,
|
1397 |
-
'name' => $name,
|
1398 |
-
'label' => $label,
|
1399 |
-
'operator' => $operator,
|
1400 |
-
'value' => $value,
|
1401 |
-
);
|
1402 |
-
|
1403 |
-
}
|
1404 |
-
|
1405 |
-
return $return;
|
1406 |
-
|
1407 |
-
}
|
1408 |
-
|
1409 |
-
function acfe_render_field_group_locations_html($field_group){
|
1410 |
-
|
1411 |
-
foreach($field_group['location'] as $groups){
|
1412 |
-
|
1413 |
-
$html = acfe_get_locations_array($groups);
|
1414 |
-
|
1415 |
-
if($html){
|
1416 |
-
|
1417 |
-
$array = array();
|
1418 |
-
|
1419 |
-
foreach($html as $location){
|
1420 |
-
|
1421 |
-
$array[] = $location['html'];
|
1422 |
-
|
1423 |
-
}
|
1424 |
-
|
1425 |
-
echo implode(' ', $array);
|
1426 |
-
|
1427 |
-
}
|
1428 |
-
|
1429 |
-
}
|
1430 |
-
|
1431 |
-
}
|
1432 |
-
|
1433 |
-
function acfe_unset(&$array, $key){
|
1434 |
-
|
1435 |
-
if(isset($array[$key]))
|
1436 |
-
unset($array[$key]);
|
1437 |
-
|
1438 |
-
}
|
1439 |
-
|
1440 |
-
function acfe_unarray($val){
|
1441 |
-
|
1442 |
-
if(is_array($val)){
|
1443 |
-
return reset($val);
|
1444 |
-
}
|
1445 |
-
|
1446 |
-
return $val;
|
1447 |
-
}
|
1448 |
-
|
1449 |
-
function acfe_get_post_id(){
|
1450 |
-
|
1451 |
-
return acf_get_valid_post_id();
|
1452 |
-
|
1453 |
-
}
|
1454 |
-
|
1455 |
-
function acfe_highlight(){
|
1456 |
-
|
1457 |
-
ini_set("highlight.comment", "#555");
|
1458 |
-
/*
|
1459 |
-
ini_set("highlight.keyword", "#0000BB"); // #4B2AFF
|
1460 |
-
ini_set("highlight.default", "#222222");
|
1461 |
-
ini_set("highlight.string", "#777777");
|
1462 |
-
*/
|
1463 |
-
|
1464 |
-
static $on = false;
|
1465 |
-
|
1466 |
-
if ( !$on ) {
|
1467 |
-
ob_start();
|
1468 |
-
} else {
|
1469 |
-
$buffer = "<?php\n" . ob_get_contents();
|
1470 |
-
ob_end_clean();
|
1471 |
-
$code = highlight_string($buffer, true);
|
1472 |
-
|
1473 |
-
$code = str_replace("<?php<br />", '', $code);
|
1474 |
-
$code = str_replace("<code>", '', $code);
|
1475 |
-
$code = str_replace("</code>", '', $code);
|
1476 |
-
|
1477 |
-
echo '<div class="acfe-pre-highlight">' . $code . '</div>';
|
1478 |
-
}
|
1479 |
-
|
1480 |
-
$on = !$on;
|
1481 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1482 |
}
|
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 false;
|
15 |
+
|
16 |
+
// Vars
|
17 |
+
$flexible = acf_get_field_type('flexible_content');
|
18 |
+
|
19 |
+
ob_start();
|
20 |
+
|
21 |
+
while(have_rows($selector, $post_id)): the_row();
|
22 |
+
|
23 |
+
// Vars
|
24 |
+
$loop = acf_get_loop('active');
|
25 |
+
$field = $loop['field'];
|
26 |
+
|
27 |
+
// Bail early if not Flexible Content
|
28 |
+
if($field['type'] !== 'flexible_content')
|
29 |
+
break;
|
30 |
+
|
31 |
+
$loop_i = acf_get_loop('active', 'i');
|
32 |
+
$layout = $flexible->get_layout(get_row_layout(), $field);
|
33 |
+
|
34 |
+
// First row
|
35 |
+
if($loop_i === 0){
|
36 |
+
|
37 |
+
// Global
|
38 |
+
global $is_preview;
|
39 |
+
|
40 |
+
// Vars
|
41 |
+
if(!isset($is_preview))
|
42 |
+
$is_preview = false;
|
43 |
+
|
44 |
+
$name = $field['_name'];
|
45 |
+
$key = $field['key'];
|
46 |
+
|
47 |
+
// Actions
|
48 |
+
do_action("acfe/flexible/enqueue", $field, $is_preview);
|
49 |
+
do_action("acfe/flexible/enqueue/name={$name}", $field, $is_preview);
|
50 |
+
do_action("acfe/flexible/enqueue/key={$key}", $field, $is_preview);
|
51 |
+
|
52 |
+
}
|
53 |
+
|
54 |
+
// Render: HTML Comment
|
55 |
+
echo "\n" . '<!-- ' . $layout['label'] . ' -->' . "\n";
|
56 |
+
|
57 |
+
// Render: Enqueue
|
58 |
+
acfe_flexible_render_layout_enqueue($layout, $field);
|
59 |
+
|
60 |
+
// Render: Template
|
61 |
+
acfe_flexible_render_layout_template($layout, $field);
|
62 |
+
|
63 |
+
endwhile;
|
64 |
+
|
65 |
+
return ob_get_clean();
|
66 |
+
|
67 |
+
}
|
68 |
+
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* The Flexible
|
73 |
+
*/
|
74 |
+
if(!function_exists('the_flexible')){
|
75 |
+
|
76 |
+
function the_flexible($selector, $post_id = false){
|
77 |
+
|
78 |
+
echo get_flexible($selector, $post_id);
|
79 |
+
|
80 |
+
}
|
81 |
+
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Has Flexible
|
86 |
+
*/
|
87 |
+
if(!function_exists('has_flexible')){
|
88 |
+
|
89 |
+
function has_flexible($selector, $post_id = false){
|
90 |
+
|
91 |
+
return have_rows($selector, $post_id);
|
92 |
+
|
93 |
+
}
|
94 |
+
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Flexible: have_settings()
|
99 |
+
*/
|
100 |
+
if(!function_exists('have_settings')){
|
101 |
+
|
102 |
+
function have_settings(){
|
103 |
+
|
104 |
+
return have_rows('layout_settings');
|
105 |
+
|
106 |
+
}
|
107 |
+
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Flexible: the_settings()
|
112 |
+
*/
|
113 |
+
if(!function_exists('the_setting')){
|
114 |
+
|
115 |
+
function the_setting(){
|
116 |
+
|
117 |
+
return the_row();
|
118 |
+
|
119 |
+
}
|
120 |
+
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* have_archive()
|
125 |
+
*/
|
126 |
+
if(!function_exists('have_archive')){
|
127 |
+
|
128 |
+
function have_archive($_post_type = false){
|
129 |
+
|
130 |
+
global $acfe_archive_i, $acfe_archive_post_type;
|
131 |
+
|
132 |
+
$acfe_archive_post_type = false;
|
133 |
+
|
134 |
+
if(!isset($acfe_archive_i) || $acfe_archive_i === 0){
|
135 |
+
|
136 |
+
$acfe_archive_i = 0;
|
137 |
+
|
138 |
+
$post_type = get_post_type();
|
139 |
+
|
140 |
+
if(!empty($_post_type))
|
141 |
+
$post_type = $_post_type;
|
142 |
+
|
143 |
+
if(!post_type_exists($post_type))
|
144 |
+
return false;
|
145 |
+
|
146 |
+
$post_type_object = get_post_type_object($post_type);
|
147 |
+
|
148 |
+
if(empty($post_type_object))
|
149 |
+
return false;
|
150 |
+
|
151 |
+
if(!isset($post_type_object->acfe_admin_archive) || empty($post_type_object->acfe_admin_archive))
|
152 |
+
return false;
|
153 |
+
|
154 |
+
$acfe_archive_post_type = $post_type;
|
155 |
+
|
156 |
+
return true;
|
157 |
+
|
158 |
+
}
|
159 |
+
|
160 |
+
remove_filter('acf/pre_load_post_id', 'acfe_the_archive_post_id');
|
161 |
+
|
162 |
+
return false;
|
163 |
+
|
164 |
+
}
|
165 |
+
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* the_archive()
|
170 |
+
*/
|
171 |
+
if(!function_exists('the_archive')){
|
172 |
+
|
173 |
+
function the_archive(){
|
174 |
+
|
175 |
+
global $acfe_archive_i;
|
176 |
+
|
177 |
+
add_filter('acf/pre_load_post_id', 'acfe_the_archive_post_id', 10, 2);
|
178 |
+
|
179 |
+
$acfe_archive_i++;
|
180 |
+
|
181 |
+
}
|
182 |
+
|
183 |
+
}
|
184 |
+
|
185 |
+
function acfe_the_archive_post_id($null, $post_id){
|
186 |
+
|
187 |
+
if($post_id !== false)
|
188 |
+
return $null;
|
189 |
+
|
190 |
+
global $acfe_archive_post_type;
|
191 |
+
|
192 |
+
if(empty($acfe_archive_post_type))
|
193 |
+
return $null;
|
194 |
+
|
195 |
+
$return = acf_get_valid_post_id($acfe_archive_post_type . '_archive');
|
196 |
+
|
197 |
+
return $return;
|
198 |
+
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* ACFE Flexible: Render Template
|
203 |
+
*/
|
204 |
+
function acfe_flexible_render_layout_template($layout, $field){
|
205 |
+
|
206 |
+
// Global
|
207 |
+
global $is_preview;
|
208 |
+
|
209 |
+
// Vars
|
210 |
+
$name = $field['_name'];
|
211 |
+
$key = $field['key'];
|
212 |
+
$l_name = $layout['name'];
|
213 |
+
|
214 |
+
// File
|
215 |
+
$file = acf_maybe_get($layout, 'acfe_flexible_render_template');
|
216 |
+
|
217 |
+
// Filters
|
218 |
+
$file = apply_filters("acfe/flexible/render/template", $file, $field, $layout, $is_preview);
|
219 |
+
$file = apply_filters("acfe/flexible/render/template/name={$name}", $file, $field, $layout, $is_preview);
|
220 |
+
$file = apply_filters("acfe/flexible/render/template/key={$key}", $file, $field, $layout, $is_preview);
|
221 |
+
$file = apply_filters("acfe/flexible/render/template/layout={$l_name}", $file, $field, $layout, $is_preview);
|
222 |
+
$file = apply_filters("acfe/flexible/render/template/name={$name}&layout={$l_name}", $file, $field, $layout, $is_preview);
|
223 |
+
$file = apply_filters("acfe/flexible/render/template/key={$key}&layout={$l_name}", $file, $field, $layout, $is_preview);
|
224 |
+
|
225 |
+
// Deprecated
|
226 |
+
$file = apply_filters_deprecated("acfe/flexible/layout/render/template/layout={$l_name}", array($file, $field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/template/layout={$l_name}");
|
227 |
+
$file = apply_filters_deprecated("acfe/flexible/layout/render/template/name={$name}&layout={$l_name}", array($file, $field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/template/name={$name}&layout={$l_name}");
|
228 |
+
$file = apply_filters_deprecated("acfe/flexible/layout/render/template/key={$key}&layout={$l_name}", array($file, $field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/template/key={$key}&layout={$l_name}");
|
229 |
+
|
230 |
+
// Before Template
|
231 |
+
do_action("acfe/flexible/render/before_template", $field, $layout, $is_preview);
|
232 |
+
do_action("acfe/flexible/render/before_template/name={$name}", $field, $layout, $is_preview);
|
233 |
+
do_action("acfe/flexible/render/before_template/key={$key}", $field, $layout, $is_preview);
|
234 |
+
do_action("acfe/flexible/render/before_template/layout={$l_name}", $field, $layout, $is_preview);
|
235 |
+
do_action("acfe/flexible/render/before_template/name={$name}&layout={$l_name}", $field, $layout, $is_preview);
|
236 |
+
do_action("acfe/flexible/render/before_template/key={$key}&layout={$l_name}", $field, $layout, $is_preview);
|
237 |
+
|
238 |
+
// Deprecated
|
239 |
+
do_action_deprecated("acfe/flexible/layout/render/before_template/layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/before_template/layout={$l_name}");
|
240 |
+
do_action_deprecated("acfe/flexible/layout/render/before_template/name={$name}&layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/before_template/name={$name}&layout={$l_name}");
|
241 |
+
do_action_deprecated("acfe/flexible/layout/render/before_template/key={$key}&layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/before_template/key={$key}&layout={$l_name}");
|
242 |
+
|
243 |
+
// Check file
|
244 |
+
if(!empty($file)){
|
245 |
+
|
246 |
+
$file_found = acfe_locate_file_path($file);
|
247 |
+
|
248 |
+
if(!empty($file_found)){
|
249 |
+
|
250 |
+
// Front-end
|
251 |
+
if(!$is_preview){
|
252 |
+
|
253 |
+
// Include
|
254 |
+
include($file_found);
|
255 |
+
|
256 |
+
// Preview
|
257 |
+
}else{
|
258 |
+
|
259 |
+
$path = pathinfo($file);
|
260 |
+
$extension = $path['extension'];
|
261 |
+
|
262 |
+
$file_preview = substr($file,0, -strlen($extension)-1);
|
263 |
+
$file_preview .= '-preview.' . $extension;
|
264 |
+
|
265 |
+
$file_preview = acfe_locate_file_path($file_preview);
|
266 |
+
|
267 |
+
// Include
|
268 |
+
if(!empty($file_preview)){
|
269 |
+
|
270 |
+
include($file_preview);
|
271 |
+
|
272 |
+
}else{
|
273 |
+
|
274 |
+
include($file_found);
|
275 |
+
|
276 |
+
}
|
277 |
+
|
278 |
+
}
|
279 |
+
|
280 |
+
}
|
281 |
+
|
282 |
+
}
|
283 |
+
|
284 |
+
// After Template
|
285 |
+
do_action("acfe/flexible/render/after_template", $field, $layout, $is_preview);
|
286 |
+
do_action("acfe/flexible/render/after_template/name={$name}", $field, $layout, $is_preview);
|
287 |
+
do_action("acfe/flexible/render/after_template/key={$key}", $field, $layout, $is_preview);
|
288 |
+
do_action("acfe/flexible/render/after_template/layout={$l_name}", $field, $layout, $is_preview);
|
289 |
+
do_action("acfe/flexible/render/after_template/name={$name}&layout={$l_name}", $field, $layout, $is_preview);
|
290 |
+
do_action("acfe/flexible/render/after_template/key={$key}&layout={$l_name}", $field, $layout, $is_preview);
|
291 |
+
|
292 |
+
// Deprecated
|
293 |
+
do_action_deprecated("acfe/flexible/layout/render/after_template/layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/after_template/layout={$l_name}");
|
294 |
+
do_action_deprecated("acfe/flexible/layout/render/after_template/name={$name}&layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/after_template/name={$name}&layout={$l_name}");
|
295 |
+
do_action_deprecated("acfe/flexible/layout/render/after_template/key={$key}&layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/after_template/key={$key}&layout={$l_name}");
|
296 |
+
|
297 |
+
}
|
298 |
+
|
299 |
+
/**
|
300 |
+
* ACFE Flexible: Render Enqueue
|
301 |
+
*
|
302 |
+
* @param $layout
|
303 |
+
* @param $field
|
304 |
+
*/
|
305 |
+
function acfe_flexible_render_layout_enqueue($layout, $field){
|
306 |
+
|
307 |
+
// Global
|
308 |
+
global $is_preview;
|
309 |
+
|
310 |
+
// Vars
|
311 |
+
$name = $field['_name'];
|
312 |
+
$key = $field['key'];
|
313 |
+
$l_name = $layout['name'];
|
314 |
+
$handle = acf_slugify($name) . '-layout-' . acf_slugify($l_name);
|
315 |
+
|
316 |
+
// Files
|
317 |
+
$style = acf_maybe_get($layout, 'acfe_flexible_render_style');
|
318 |
+
$script = acf_maybe_get($layout, 'acfe_flexible_render_script');
|
319 |
+
|
320 |
+
/**
|
321 |
+
* Actions
|
322 |
+
*/
|
323 |
+
do_action("acfe/flexible/enqueue/layout={$l_name}", $field, $layout, $is_preview);
|
324 |
+
do_action("acfe/flexible/enqueue/name={$name}&layout={$l_name}", $field, $layout, $is_preview);
|
325 |
+
do_action("acfe/flexible/enqueue/key={$key}&layout={$l_name}", $field, $layout, $is_preview);
|
326 |
+
|
327 |
+
// Deprecated
|
328 |
+
do_action_deprecated("acfe/flexible/layout/enqueue/layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/enqueue/layout={$l_name}");
|
329 |
+
do_action_deprecated("acfe/flexible/layout/enqueue/name={$name}&layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/enqueue/name={$name}&layout={$l_name}");
|
330 |
+
do_action_deprecated("acfe/flexible/layout/enqueue/key={$key}&layout={$l_name}", array($field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/enqueue/key={$key}&layout={$l_name}");
|
331 |
+
|
332 |
+
/**
|
333 |
+
* Style
|
334 |
+
*/
|
335 |
+
$style = apply_filters("acfe/flexible/render/style", $style, $field, $layout, $is_preview);
|
336 |
+
$style = apply_filters("acfe/flexible/render/style/name={$name}", $style, $field, $layout, $is_preview);
|
337 |
+
$style = apply_filters("acfe/flexible/render/style/key={$key}", $style, $field, $layout, $is_preview);
|
338 |
+
$style = apply_filters("acfe/flexible/render/style/layout={$l_name}", $style, $field, $layout, $is_preview);
|
339 |
+
$style = apply_filters("acfe/flexible/render/style/name={$name}&layout={$l_name}", $style, $field, $layout, $is_preview);
|
340 |
+
$style = apply_filters("acfe/flexible/render/style/key={$key}&layout={$l_name}", $style, $field, $layout, $is_preview);
|
341 |
+
|
342 |
+
// Deprecated
|
343 |
+
$style = apply_filters_deprecated("acfe/flexible/layout/render/style/layout={$l_name}", array($style, $field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/style/layout={$l_name}");
|
344 |
+
$style = apply_filters_deprecated("acfe/flexible/layout/render/style/name={$name}&layout={$l_name}", array($style, $field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/style/name={$name}&layout={$l_name}");
|
345 |
+
$style = apply_filters_deprecated("acfe/flexible/layout/render/style/key={$key}&layout={$l_name}", array($style, $field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/style/key={$key}&layout={$l_name}");
|
346 |
+
|
347 |
+
// Check
|
348 |
+
if(!empty($style)){
|
349 |
+
|
350 |
+
// URL starting with current domain
|
351 |
+
if(stripos($style, home_url()) === 0){
|
352 |
+
|
353 |
+
$style = str_replace(home_url(), '', $style);
|
354 |
+
|
355 |
+
}
|
356 |
+
|
357 |
+
// Locate
|
358 |
+
$style_file = acfe_locate_file_url($style);
|
359 |
+
|
360 |
+
// Front-end
|
361 |
+
if(!empty($style_file)){
|
362 |
+
|
363 |
+
wp_enqueue_style($handle, $style_file, array(), false, 'all');
|
364 |
+
|
365 |
+
}
|
366 |
+
|
367 |
+
// Preview
|
368 |
+
if($is_preview && stripos($style, 'http://') !== 0 && stripos($style, 'https://') !== 0 && stripos($style, '//') !== 0){
|
369 |
+
|
370 |
+
$path = pathinfo($style);
|
371 |
+
$extension = $path['extension'];
|
372 |
+
|
373 |
+
$style_preview = substr($style,0, -strlen($extension)-1);
|
374 |
+
$style_preview .= '-preview.' . $extension;
|
375 |
+
|
376 |
+
$style_preview = acfe_locate_file_url($style_preview);
|
377 |
+
|
378 |
+
// Enqueue
|
379 |
+
if(!empty($style_preview)){
|
380 |
+
|
381 |
+
wp_enqueue_style($handle . '-preview', $style_preview, array(), false, 'all');
|
382 |
+
|
383 |
+
}
|
384 |
+
|
385 |
+
}
|
386 |
+
|
387 |
+
}
|
388 |
+
|
389 |
+
/**
|
390 |
+
* Script
|
391 |
+
*/
|
392 |
+
$script = apply_filters("acfe/flexible/render/script", $script, $field, $layout, $is_preview);
|
393 |
+
$script = apply_filters("acfe/flexible/render/script/name={$name}", $script, $field, $layout, $is_preview);
|
394 |
+
$script = apply_filters("acfe/flexible/render/script/key={$key}", $script, $field, $layout, $is_preview);
|
395 |
+
$script = apply_filters("acfe/flexible/render/script/layout={$l_name}", $script, $field, $layout, $is_preview);
|
396 |
+
$script = apply_filters("acfe/flexible/render/script/name={$name}&layout={$l_name}", $script, $field, $layout, $is_preview);
|
397 |
+
$script = apply_filters("acfe/flexible/render/script/key={$key}&layout={$l_name}", $script, $field, $layout, $is_preview);
|
398 |
+
|
399 |
+
// Deprecated
|
400 |
+
$script = apply_filters_deprecated("acfe/flexible/layout/render/script/layout={$l_name}", array($script, $field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/script/layout={$l_name}");
|
401 |
+
$script = apply_filters_deprecated("acfe/flexible/layout/render/script/name={$name}&layout={$l_name}", array($script, $field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/script/name={$name}&layout={$l_name}");
|
402 |
+
$script = apply_filters_deprecated("acfe/flexible/layout/render/script/key={$key}&layout={$l_name}", array($script, $field, $layout, $is_preview), '0.8.6.7', "acfe/flexible/render/script/key={$key}&layout={$l_name}");
|
403 |
+
|
404 |
+
// Check
|
405 |
+
if(!empty($script)){
|
406 |
+
|
407 |
+
// URL starting with current domain
|
408 |
+
if(stripos($script, home_url()) === 0){
|
409 |
+
|
410 |
+
$script = str_replace(home_url(), '', $script);
|
411 |
+
|
412 |
+
}
|
413 |
+
|
414 |
+
// Locate
|
415 |
+
$script_file = acfe_locate_file_url($script);
|
416 |
+
|
417 |
+
// Front-end
|
418 |
+
if(!$is_preview || (stripos($script, 'http://') === 0 || stripos($script, 'https://') === 0 || stripos($script, '//') === 0)){
|
419 |
+
|
420 |
+
if(!empty($script_file)){
|
421 |
+
|
422 |
+
wp_enqueue_script($handle, $script_file, array(), false, true);
|
423 |
+
|
424 |
+
}
|
425 |
+
|
426 |
+
}else{
|
427 |
+
|
428 |
+
$path = pathinfo($script);
|
429 |
+
$extension = $path['extension'];
|
430 |
+
|
431 |
+
$script_preview = substr($script,0, -strlen($extension)-1);
|
432 |
+
$script_preview .= '-preview.' . $extension;
|
433 |
+
|
434 |
+
$script_preview = acfe_locate_file_url($script_preview);
|
435 |
+
|
436 |
+
// Enqueue
|
437 |
+
if(!empty($script_preview)){
|
438 |
+
|
439 |
+
wp_enqueue_script($handle . '-preview', $script_preview, array(), false, true);
|
440 |
+
|
441 |
+
}elseif(!empty($script_file)){
|
442 |
+
|
443 |
+
wp_enqueue_script($handle, $script_file, array(), false, true);
|
444 |
+
|
445 |
+
}
|
446 |
+
|
447 |
+
}
|
448 |
+
|
449 |
+
}
|
450 |
+
|
451 |
+
}
|
452 |
+
|
453 |
+
/**
|
454 |
+
* Get Field Group from Field
|
455 |
+
*/
|
456 |
+
function acfe_get_field_group_from_field($field){
|
457 |
+
|
458 |
+
if(!acf_maybe_get($field, 'parent'))
|
459 |
+
return false;
|
460 |
+
|
461 |
+
$field_parent = $field['parent'];
|
462 |
+
|
463 |
+
if(!$field_ancestors = acf_get_field_ancestors($field))
|
464 |
+
return acf_get_field_group($field_parent);
|
465 |
+
|
466 |
+
// Reverse for DESC order (Top field first)
|
467 |
+
$field_ancestors = array_reverse($field_ancestors);
|
468 |
+
|
469 |
+
$field_top_ancestor = $field_ancestors[0];
|
470 |
+
$field_top_ancestor = acf_get_field($field_top_ancestor);
|
471 |
+
|
472 |
+
return acf_get_field_group($field_top_ancestor['parent']);
|
473 |
+
|
474 |
+
}
|
475 |
+
|
476 |
+
/**
|
477 |
+
* Is Json
|
478 |
+
* Source: https://stackoverflow.com/a/6041773
|
479 |
+
*/
|
480 |
+
function acfe_is_json($string){
|
481 |
+
|
482 |
+
// in case string = 1
|
483 |
+
if(is_numeric($string))
|
484 |
+
return false;
|
485 |
+
|
486 |
+
json_decode($string);
|
487 |
+
|
488 |
+
return (json_last_error() == JSON_ERROR_NONE);
|
489 |
+
|
490 |
+
}
|
491 |
+
|
492 |
+
/*
|
493 |
+
* Array Keys Recursive
|
494 |
+
*/
|
495 |
+
function acfe_array_keys_r($array){
|
496 |
+
|
497 |
+
$keys = array_keys($array);
|
498 |
+
|
499 |
+
foreach($array as $i){
|
500 |
+
|
501 |
+
if(!is_array($i))
|
502 |
+
continue;
|
503 |
+
|
504 |
+
$keys = array_merge($keys, acfe_array_keys_r($i));
|
505 |
+
|
506 |
+
}
|
507 |
+
|
508 |
+
return $keys;
|
509 |
+
|
510 |
+
}
|
511 |
+
|
512 |
+
/*
|
513 |
+
* Locate File URL
|
514 |
+
* Check if file exists locally and return URL (supports parent/child theme)
|
515 |
+
*/
|
516 |
+
function acfe_locate_file_url($filenames){
|
517 |
+
|
518 |
+
$located = '';
|
519 |
+
|
520 |
+
foreach((array) $filenames as $filename){
|
521 |
+
|
522 |
+
if(!$filename)
|
523 |
+
continue;
|
524 |
+
|
525 |
+
// Direct URL: https://www.domain.com/folder/file.js
|
526 |
+
if(stripos($filename, 'http://') === 0 || stripos($filename, 'https://') === 0 || stripos($filename, '//') === 0){
|
527 |
+
|
528 |
+
$located = $filename;
|
529 |
+
break;
|
530 |
+
|
531 |
+
}else{
|
532 |
+
|
533 |
+
$_filename = ltrim($filename, '/\\');
|
534 |
+
$abspath = untrailingslashit(ABSPATH);
|
535 |
+
|
536 |
+
// Child Theme
|
537 |
+
if(file_exists(STYLESHEETPATH . '/' . $_filename)){
|
538 |
+
|
539 |
+
$located = get_stylesheet_directory_uri() . '/' . $_filename;
|
540 |
+
break;
|
541 |
+
|
542 |
+
}
|
543 |
+
|
544 |
+
// Parent Theme
|
545 |
+
elseif(file_exists(TEMPLATEPATH . '/' . $_filename)){
|
546 |
+
|
547 |
+
$located = get_template_directory_uri() . '/' . $_filename;
|
548 |
+
break;
|
549 |
+
|
550 |
+
}
|
551 |
+
|
552 |
+
// Direct file path
|
553 |
+
elseif(file_exists($filename)){
|
554 |
+
|
555 |
+
$located = acfe_get_abs_path_to_url($filename);
|
556 |
+
break;
|
557 |
+
|
558 |
+
}
|
559 |
+
|
560 |
+
// ABSPATH file path
|
561 |
+
elseif(file_exists($abspath . '/' . $_filename)){
|
562 |
+
|
563 |
+
$located = acfe_get_abs_path_to_url($abspath . '/' . $_filename);
|
564 |
+
break;
|
565 |
+
|
566 |
+
}
|
567 |
+
|
568 |
+
// WP Content Dir
|
569 |
+
elseif(file_exists(WP_CONTENT_DIR . '/' . $_filename)){
|
570 |
+
|
571 |
+
$located = WP_CONTENT_URL . '/' . $_filename;
|
572 |
+
break;
|
573 |
+
|
574 |
+
}
|
575 |
+
|
576 |
+
}
|
577 |
+
|
578 |
+
}
|
579 |
+
|
580 |
+
return $located;
|
581 |
+
|
582 |
+
}
|
583 |
+
|
584 |
+
/*
|
585 |
+
* Locate File Path
|
586 |
+
* Based on wp-includes\template.php:653
|
587 |
+
*/
|
588 |
+
function acfe_locate_file_path($filenames){
|
589 |
+
|
590 |
+
$located = '';
|
591 |
+
|
592 |
+
foreach((array) $filenames as $filename){
|
593 |
+
|
594 |
+
if(!$filename)
|
595 |
+
continue;
|
596 |
+
|
597 |
+
$_filename = ltrim($filename, '/\\');
|
598 |
+
$abspath = untrailingslashit(ABSPATH);
|
599 |
+
|
600 |
+
// Stylesheet file path
|
601 |
+
if(file_exists(STYLESHEETPATH . '/' . $_filename)){
|
602 |
+
|
603 |
+
$located = STYLESHEETPATH . '/' . $_filename;
|
604 |
+
break;
|
605 |
+
|
606 |
+
}
|
607 |
+
|
608 |
+
// Template file path
|
609 |
+
elseif(file_exists(TEMPLATEPATH . '/' . $_filename)){
|
610 |
+
|
611 |
+
$located = TEMPLATEPATH . '/' . $_filename;
|
612 |
+
break;
|
613 |
+
|
614 |
+
}
|
615 |
+
|
616 |
+
// Direct file path
|
617 |
+
elseif(file_exists($filename)){
|
618 |
+
|
619 |
+
$located = $filename;
|
620 |
+
break;
|
621 |
+
|
622 |
+
}
|
623 |
+
|
624 |
+
// ABSPATH file path
|
625 |
+
elseif(file_exists($abspath . '/' . $_filename)){
|
626 |
+
|
627 |
+
$located = $abspath . '/' . $_filename;
|
628 |
+
break;
|
629 |
+
|
630 |
+
}
|
631 |
+
|
632 |
+
// WP Content Dir
|
633 |
+
elseif(file_exists(WP_CONTENT_DIR . '/' . $_filename)){
|
634 |
+
|
635 |
+
$located = WP_CONTENT_DIR . '/' . $_filename;
|
636 |
+
break;
|
637 |
+
|
638 |
+
}
|
639 |
+
|
640 |
+
}
|
641 |
+
|
642 |
+
return $located;
|
643 |
+
|
644 |
+
}
|
645 |
+
|
646 |
+
/**
|
647 |
+
* Convert ABSPATH . '/url' to https://www.domain.com/url
|
648 |
+
*/
|
649 |
+
function acfe_get_abs_path_to_url($path = ''){
|
650 |
+
|
651 |
+
$abspath = untrailingslashit(ABSPATH);
|
652 |
+
|
653 |
+
$url = str_replace($abspath, site_url(), $path);
|
654 |
+
$url = wp_normalize_path($url);
|
655 |
+
|
656 |
+
return esc_url_raw($url);
|
657 |
+
|
658 |
+
}
|
659 |
+
|
660 |
+
/**
|
661 |
+
* Get Roles
|
662 |
+
*/
|
663 |
+
function acfe_get_roles($filtered_user_roles = array()){
|
664 |
+
|
665 |
+
$list = array();
|
666 |
+
|
667 |
+
global $wp_roles;
|
668 |
+
|
669 |
+
if(is_multisite())
|
670 |
+
$list['super_admin'] = __('Super Admin');
|
671 |
+
|
672 |
+
foreach($wp_roles->roles as $role => $settings){
|
673 |
+
|
674 |
+
$list[$role] = $settings['name'];
|
675 |
+
|
676 |
+
}
|
677 |
+
|
678 |
+
$user_roles = $list;
|
679 |
+
|
680 |
+
if(!empty($filtered_user_roles)){
|
681 |
+
|
682 |
+
$user_roles = array();
|
683 |
+
|
684 |
+
foreach($list as $role => $role_label){
|
685 |
+
|
686 |
+
if(!in_array($role, $filtered_user_roles))
|
687 |
+
continue;
|
688 |
+
|
689 |
+
$user_roles[$role] = $role_label;
|
690 |
+
|
691 |
+
}
|
692 |
+
|
693 |
+
}
|
694 |
+
|
695 |
+
return $user_roles;
|
696 |
+
|
697 |
+
}
|
698 |
+
|
699 |
+
/**
|
700 |
+
* Get Current Roles
|
701 |
+
*/
|
702 |
+
function acfe_get_current_user_roles(){
|
703 |
+
|
704 |
+
global $current_user;
|
705 |
+
|
706 |
+
if(!is_object($current_user) || !isset($current_user->roles))
|
707 |
+
return false;
|
708 |
+
|
709 |
+
$roles = $current_user->roles;
|
710 |
+
|
711 |
+
if(is_multisite() && current_user_can('setup_network'))
|
712 |
+
$roles[] = 'super_admin';
|
713 |
+
|
714 |
+
return $roles;
|
715 |
+
|
716 |
+
}
|
717 |
+
|
718 |
+
/**
|
719 |
+
* Get post types objects
|
720 |
+
*/
|
721 |
+
function acfe_get_post_type_objects($args = array()){
|
722 |
+
|
723 |
+
// vars
|
724 |
+
$return = array();
|
725 |
+
|
726 |
+
// Post Types
|
727 |
+
$posts_types = acf_get_post_types($args);
|
728 |
+
|
729 |
+
// Choices
|
730 |
+
if(!empty($posts_types)){
|
731 |
+
|
732 |
+
foreach($posts_types as $post_type){
|
733 |
+
|
734 |
+
$post_type_object = get_post_type_object($post_type);
|
735 |
+
|
736 |
+
$return[$post_type_object->name] = $post_type_object;
|
737 |
+
|
738 |
+
}
|
739 |
+
|
740 |
+
}
|
741 |
+
|
742 |
+
return $return;
|
743 |
+
|
744 |
+
}
|
745 |
+
|
746 |
+
/**
|
747 |
+
* Get taxonomy objects
|
748 |
+
*/
|
749 |
+
function acfe_get_taxonomy_objects($args = array()){
|
750 |
+
|
751 |
+
// vars
|
752 |
+
$return = array();
|
753 |
+
|
754 |
+
// Post Types
|
755 |
+
$taxonomies = acf_get_taxonomies($args);
|
756 |
+
|
757 |
+
// Choices
|
758 |
+
if(!empty($taxonomies)){
|
759 |
+
|
760 |
+
foreach($taxonomies as $taxonomy){
|
761 |
+
|
762 |
+
$taxonomy_object = get_taxonomy($taxonomy);
|
763 |
+
|
764 |
+
$return[$taxonomy_object->name] = $taxonomy_object;
|
765 |
+
|
766 |
+
}
|
767 |
+
|
768 |
+
}
|
769 |
+
|
770 |
+
return $return;
|
771 |
+
|
772 |
+
}
|
773 |
+
|
774 |
+
/**
|
775 |
+
* Get post statuses
|
776 |
+
*/
|
777 |
+
function acfe_get_pretty_post_statuses($posts_statuses = array()){
|
778 |
+
|
779 |
+
if(empty($posts_statuses)){
|
780 |
+
|
781 |
+
$posts_statuses = get_post_stati(array(), 'names');
|
782 |
+
|
783 |
+
}
|
784 |
+
|
785 |
+
$return = array();
|
786 |
+
|
787 |
+
// Choices
|
788 |
+
if(!empty($posts_statuses)){
|
789 |
+
|
790 |
+
foreach($posts_statuses as $post_status){
|
791 |
+
|
792 |
+
$post_status_object = get_post_status_object($post_status);
|
793 |
+
|
794 |
+
$return[$post_status_object->name] = $post_status_object->label . ' (' . $post_status_object->name . ')';
|
795 |
+
|
796 |
+
}
|
797 |
+
|
798 |
+
}
|
799 |
+
|
800 |
+
return $return;
|
801 |
+
|
802 |
+
}
|
803 |
+
|
804 |
+
/**
|
805 |
+
* Get forms
|
806 |
+
*/
|
807 |
+
function acfe_get_pretty_forms($forms = array()){
|
808 |
+
|
809 |
+
if(empty($forms)){
|
810 |
+
|
811 |
+
$forms = get_posts(array(
|
812 |
+
'post_type' => 'acfe-form',
|
813 |
+
'posts_per_page' => -1,
|
814 |
+
'fields' => 'ids',
|
815 |
+
'orderby' => 'title',
|
816 |
+
'order' => 'ASC',
|
817 |
+
));
|
818 |
+
|
819 |
+
}
|
820 |
+
|
821 |
+
$return = array();
|
822 |
+
|
823 |
+
// Choices
|
824 |
+
if(!empty($forms)){
|
825 |
+
|
826 |
+
foreach($forms as $form_id){
|
827 |
+
|
828 |
+
$form_name = get_the_title($form_id);
|
829 |
+
|
830 |
+
$return[$form_id] = $form_name;
|
831 |
+
|
832 |
+
}
|
833 |
+
|
834 |
+
}
|
835 |
+
|
836 |
+
return $return;
|
837 |
+
|
838 |
+
}
|
839 |
+
|
840 |
+
/**
|
841 |
+
* Starts with
|
842 |
+
*/
|
843 |
+
function acfe_starts_with($haystack, $needle){
|
844 |
+
|
845 |
+
$length = strlen($needle);
|
846 |
+
return (substr($haystack, 0, $length) === $needle);
|
847 |
+
|
848 |
+
}
|
849 |
+
|
850 |
+
/**
|
851 |
+
* Ends with
|
852 |
+
*/
|
853 |
+
function acfe_ends_with($haystack, $needle){
|
854 |
+
|
855 |
+
$length = strlen($needle);
|
856 |
+
|
857 |
+
if($length == 0)
|
858 |
+
return true;
|
859 |
+
|
860 |
+
return (substr($haystack, -$length) === $needle);
|
861 |
+
|
862 |
+
}
|
863 |
+
|
864 |
+
function acfe_form_is_admin(){
|
865 |
+
|
866 |
+
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'))
|
867 |
+
return true;
|
868 |
+
|
869 |
+
return false;
|
870 |
+
|
871 |
+
}
|
872 |
+
|
873 |
+
function acfe_form_is_front(){
|
874 |
+
|
875 |
+
if(!is_admin() || (is_admin() && wp_doing_ajax() && (acf_maybe_get_POST('_acf_screen') === 'acfe_form' || acf_maybe_get_POST('_acf_screen') === 'acf_form')))
|
876 |
+
return true;
|
877 |
+
|
878 |
+
return false;
|
879 |
+
|
880 |
+
}
|
881 |
+
|
882 |
+
function acfe_form_decrypt_args(){
|
883 |
+
|
884 |
+
if(!acf_maybe_get_POST('_acf_form'))
|
885 |
+
return false;
|
886 |
+
|
887 |
+
$form = json_decode(acf_decrypt($_POST['_acf_form']), true);
|
888 |
+
|
889 |
+
if(empty($form))
|
890 |
+
return false;
|
891 |
+
|
892 |
+
return $form;
|
893 |
+
|
894 |
+
}
|
895 |
+
|
896 |
+
function acfe_is_form_success($form_name = false){
|
897 |
+
|
898 |
+
if(!acf_maybe_get_POST('_acf_form'))
|
899 |
+
return false;
|
900 |
+
|
901 |
+
$form = acfe_form_decrypt_args();
|
902 |
+
|
903 |
+
if(empty($form))
|
904 |
+
return false;
|
905 |
+
|
906 |
+
if(!empty($form_name) && acf_maybe_get($form, 'name') !== $form_name)
|
907 |
+
return false;
|
908 |
+
|
909 |
+
return true;
|
910 |
+
|
911 |
+
}
|
912 |
+
|
913 |
+
function acfe_form_is_submitted($form_name = false){
|
914 |
+
|
915 |
+
_deprecated_function('ACF Extended - Dynamic Forms: "acfe_form_is_submitted()" function', '0.8.7.5', "acfe_is_form_success()");
|
916 |
+
|
917 |
+
return acfe_is_form_success($form_name);
|
918 |
+
|
919 |
+
}
|
920 |
+
|
921 |
+
function acfe_form_unique_action_id($form, $type){
|
922 |
+
|
923 |
+
$name = $form['name'] . '-' . $type;
|
924 |
+
|
925 |
+
global $acfe_form_uniqid;
|
926 |
+
|
927 |
+
$acfe_form_uniqid = acf_get_array($acfe_form_uniqid);
|
928 |
+
|
929 |
+
if(!isset($acfe_form_uniqid[$type])){
|
930 |
+
|
931 |
+
$acfe_form_uniqid[$type] = 1;
|
932 |
+
|
933 |
+
}
|
934 |
+
|
935 |
+
if($acfe_form_uniqid[$type] > 1)
|
936 |
+
$name = $name . '-' . $acfe_form_uniqid[$type];
|
937 |
+
|
938 |
+
$acfe_form_uniqid[$type]++;
|
939 |
+
|
940 |
+
return $name;
|
941 |
+
|
942 |
+
}
|
943 |
+
|
944 |
+
function acfe_form_get_actions(){
|
945 |
+
|
946 |
+
return get_query_var('acfe_form_actions', array());
|
947 |
+
|
948 |
+
}
|
949 |
+
|
950 |
+
function acfe_form_get_action($name = false){
|
951 |
+
|
952 |
+
$actions = acfe_form_get_actions();
|
953 |
+
|
954 |
+
// No Action
|
955 |
+
if(empty($actions))
|
956 |
+
return false;
|
957 |
+
|
958 |
+
// Last Action
|
959 |
+
if(empty($name))
|
960 |
+
return end($actions);
|
961 |
+
|
962 |
+
if(isset($actions[$name]))
|
963 |
+
return $actions[$name];
|
964 |
+
|
965 |
+
return false;
|
966 |
+
|
967 |
+
}
|
968 |
+
|
969 |
+
function acfe_array_insert_before($key, array &$array, $new_key, $new_value){
|
970 |
+
|
971 |
+
if(!array_key_exists($key, $array))
|
972 |
+
return $array;
|
973 |
+
|
974 |
+
$new = array();
|
975 |
+
|
976 |
+
foreach($array as $k => $value){
|
977 |
+
|
978 |
+
if($k === $key)
|
979 |
+
$new[$new_key] = $new_value;
|
980 |
+
|
981 |
+
$new[$k] = $value;
|
982 |
+
|
983 |
+
}
|
984 |
+
|
985 |
+
return $new;
|
986 |
+
|
987 |
+
}
|
988 |
+
|
989 |
+
function acfe_array_insert_after($key, array &$array, $new_key, $new_value){
|
990 |
+
|
991 |
+
if(!array_key_exists($key, $array))
|
992 |
+
return $array;
|
993 |
+
|
994 |
+
$new = array();
|
995 |
+
|
996 |
+
foreach($array as $k => $value){
|
997 |
+
|
998 |
+
$new[$k] = $value;
|
999 |
+
|
1000 |
+
if($k === $key)
|
1001 |
+
$new[$new_key] = $new_value;
|
1002 |
+
|
1003 |
+
}
|
1004 |
+
|
1005 |
+
return $new;
|
1006 |
+
|
1007 |
+
}
|
1008 |
+
|
1009 |
+
function acfe_array_move(&$array, $a, $b){
|
1010 |
+
|
1011 |
+
$out = array_splice($array, $a, 1);
|
1012 |
+
array_splice($array, $b, 0, $out);
|
1013 |
+
|
1014 |
+
}
|
1015 |
+
|
1016 |
+
function acfe_add_validation_error($selector = '', $message = ''){
|
1017 |
+
|
1018 |
+
// General error
|
1019 |
+
if(empty($selector))
|
1020 |
+
return acf_add_validation_error('', $message);
|
1021 |
+
|
1022 |
+
$row = acf_get_loop('active');
|
1023 |
+
|
1024 |
+
if($row){
|
1025 |
+
|
1026 |
+
$field = acf_get_sub_field($selector, $row['field']);
|
1027 |
+
|
1028 |
+
}
|
1029 |
+
|
1030 |
+
else{
|
1031 |
+
|
1032 |
+
$field = acf_get_field($selector);
|
1033 |
+
|
1034 |
+
}
|
1035 |
+
|
1036 |
+
// Field not found: General error
|
1037 |
+
if(!$field)
|
1038 |
+
return acf_add_validation_error('', $message);
|
1039 |
+
|
1040 |
+
// Specific field error
|
1041 |
+
add_filter('acf/validate_value/key=' . $field['key'], function($valid) use($message){
|
1042 |
+
|
1043 |
+
return $message;
|
1044 |
+
|
1045 |
+
});
|
1046 |
+
|
1047 |
+
}
|
1048 |
+
|
1049 |
+
/*
|
1050 |
+
* Similar to acf_get_taxonomy_terms() but returns array('256' => 'Category name') instead of array('category:category_name' => 'Category name')
|
1051 |
+
*/
|
1052 |
+
function acfe_get_taxonomy_terms_ids($taxonomies = array()){
|
1053 |
+
|
1054 |
+
// force array
|
1055 |
+
$taxonomies = acf_get_array($taxonomies);
|
1056 |
+
|
1057 |
+
// get pretty taxonomy names
|
1058 |
+
$taxonomies = acf_get_pretty_taxonomies( $taxonomies );
|
1059 |
+
|
1060 |
+
// vars
|
1061 |
+
$r = array();
|
1062 |
+
|
1063 |
+
// populate $r
|
1064 |
+
foreach( array_keys($taxonomies) as $taxonomy ) {
|
1065 |
+
|
1066 |
+
// vars
|
1067 |
+
$label = $taxonomies[$taxonomy];
|
1068 |
+
$is_hierarchical = is_taxonomy_hierarchical( $taxonomy );
|
1069 |
+
|
1070 |
+
$terms = acf_get_terms(array(
|
1071 |
+
'taxonomy' => $taxonomy,
|
1072 |
+
'hide_empty' => false
|
1073 |
+
));
|
1074 |
+
|
1075 |
+
// bail early if no terms
|
1076 |
+
if(empty($terms))
|
1077 |
+
continue;
|
1078 |
+
|
1079 |
+
// sort into hierachial order!
|
1080 |
+
if($is_hierarchical){
|
1081 |
+
|
1082 |
+
$terms = _get_term_children( 0, $terms, $taxonomy );
|
1083 |
+
|
1084 |
+
}
|
1085 |
+
|
1086 |
+
// add placeholder
|
1087 |
+
$r[ $label ] = array();
|
1088 |
+
|
1089 |
+
// add choices
|
1090 |
+
foreach($terms as $term){
|
1091 |
+
|
1092 |
+
$k = "{$term->term_id}";
|
1093 |
+
$r[$label][$k] = acf_get_term_title($term);
|
1094 |
+
|
1095 |
+
}
|
1096 |
+
|
1097 |
+
}
|
1098 |
+
|
1099 |
+
// return
|
1100 |
+
return $r;
|
1101 |
+
|
1102 |
+
}
|
1103 |
+
|
1104 |
+
function acfe_get_term_level($term, $taxonomy){
|
1105 |
+
|
1106 |
+
$ancestors = get_ancestors($term, $taxonomy);
|
1107 |
+
|
1108 |
+
return count($ancestors) + 1;
|
1109 |
+
|
1110 |
+
}
|
1111 |
+
|
1112 |
+
function acfe_number_suffix($num){
|
1113 |
+
|
1114 |
+
if(!in_array(($num % 100), array(11,12,13))){
|
1115 |
+
|
1116 |
+
switch($num % 10){
|
1117 |
+
case 1: return $num . 'st';
|
1118 |
+
case 2: return $num . 'nd';
|
1119 |
+
case 3: return $num . 'rd';
|
1120 |
+
}
|
1121 |
+
|
1122 |
+
}
|
1123 |
+
|
1124 |
+
return $num . 'th';
|
1125 |
+
|
1126 |
+
}
|
1127 |
+
|
1128 |
+
function acfe_array_to_string($array = array()){
|
1129 |
+
|
1130 |
+
if(!is_array($array))
|
1131 |
+
return $array;
|
1132 |
+
|
1133 |
+
if(empty($array))
|
1134 |
+
return false;
|
1135 |
+
|
1136 |
+
if(acf_is_sequential_array($array)){
|
1137 |
+
|
1138 |
+
foreach($array as $k => $v){
|
1139 |
+
|
1140 |
+
if(!is_string($v))
|
1141 |
+
continue;
|
1142 |
+
|
1143 |
+
return $v;
|
1144 |
+
|
1145 |
+
}
|
1146 |
+
|
1147 |
+
}elseif(acf_is_associative_array($array)){
|
1148 |
+
|
1149 |
+
foreach($array as $k => $v){
|
1150 |
+
|
1151 |
+
if(!is_string($v))
|
1152 |
+
continue;
|
1153 |
+
|
1154 |
+
return $v;
|
1155 |
+
|
1156 |
+
}
|
1157 |
+
|
1158 |
+
}
|
1159 |
+
|
1160 |
+
return false;
|
1161 |
+
|
1162 |
+
}
|
1163 |
+
|
1164 |
+
function acfe_get_acf_screen_id($page = ''){
|
1165 |
+
|
1166 |
+
$prefix = sanitize_title( __("Custom Fields", 'acf') );
|
1167 |
+
|
1168 |
+
if(empty($page))
|
1169 |
+
return $prefix;
|
1170 |
+
|
1171 |
+
return $prefix . '_page_' . $page;
|
1172 |
+
|
1173 |
+
}
|
1174 |
+
|
1175 |
+
function acfe_is_admin_screen($modules = false){
|
1176 |
+
|
1177 |
+
// bail early if not defined
|
1178 |
+
if(!function_exists('get_current_screen'))
|
1179 |
+
return false;
|
1180 |
+
|
1181 |
+
// vars
|
1182 |
+
$screen = get_current_screen();
|
1183 |
+
|
1184 |
+
// no screen
|
1185 |
+
if(!$screen)
|
1186 |
+
return false;
|
1187 |
+
|
1188 |
+
$post_types = array(
|
1189 |
+
'acf-field-group', // ACF
|
1190 |
+
);
|
1191 |
+
|
1192 |
+
$field_group_category = false;
|
1193 |
+
|
1194 |
+
// include ACF Extended Modules?
|
1195 |
+
if($modules){
|
1196 |
+
|
1197 |
+
$post_types[] = 'acfe-dbt'; // Dynamic Block Type
|
1198 |
+
$post_types[] = 'acfe-dop'; // Dynamic Option Page
|
1199 |
+
$post_types[] = 'acfe-dpt'; // Dynamic Post Type
|
1200 |
+
$post_types[] = 'acfe-dt'; // Dynamic Taxonomy
|
1201 |
+
$post_types[] = 'acfe-form'; // Dynamic Form
|
1202 |
+
|
1203 |
+
// Field Group Category
|
1204 |
+
$field_group_category = $screen->post_type === 'post' && $screen->taxonomy === 'acf-field-group-category';
|
1205 |
+
|
1206 |
+
}
|
1207 |
+
|
1208 |
+
if(in_array($screen->post_type, $post_types) || $field_group_category)
|
1209 |
+
return true;
|
1210 |
+
|
1211 |
+
return false;
|
1212 |
+
|
1213 |
+
}
|
1214 |
+
|
1215 |
+
function acfe_is_dev(){
|
1216 |
+
|
1217 |
+
return acf_get_setting('acfe/dev', false) || (defined('ACFE_dev') && ACFE_dev);
|
1218 |
+
|
1219 |
+
}
|
1220 |
+
|
1221 |
+
function acfe_is_super_dev(){
|
1222 |
+
|
1223 |
+
return acf_get_setting('acfe/super_dev', false) || (defined('ACFE_super_dev') && ACFE_super_dev);
|
1224 |
+
|
1225 |
+
}
|
1226 |
+
|
1227 |
+
function acfe_update_setting($name, $value){
|
1228 |
+
|
1229 |
+
return acf_update_setting("acfe/{$name}", $value);
|
1230 |
+
|
1231 |
+
}
|
1232 |
+
|
1233 |
+
function acfe_append_setting($name, $value){
|
1234 |
+
|
1235 |
+
return acf_append_setting("acfe/{$name}", $value);
|
1236 |
+
|
1237 |
+
}
|
1238 |
+
|
1239 |
+
function acfe_get_setting($name, $value = null){
|
1240 |
+
|
1241 |
+
return acf_get_setting("acfe/{$name}", $value);
|
1242 |
+
|
1243 |
+
}
|
1244 |
+
|
1245 |
+
function acfe_get_locations_array($locations){
|
1246 |
+
|
1247 |
+
$return = array();
|
1248 |
+
$types = acf_get_location_rule_types();
|
1249 |
+
|
1250 |
+
if(!$locations || !$types)
|
1251 |
+
return $return;
|
1252 |
+
|
1253 |
+
$icon_default = 'admin-generic';
|
1254 |
+
|
1255 |
+
$icons = array(
|
1256 |
+
'edit' => array(
|
1257 |
+
'post_type',
|
1258 |
+
'post_template',
|
1259 |
+
'post_status',
|
1260 |
+
'post_format',
|
1261 |
+
'post',
|
1262 |
+
),
|
1263 |
+
'media-default' => array(
|
1264 |
+
'page_template',
|
1265 |
+
'page_type',
|
1266 |
+
'page_parent',
|
1267 |
+
'page',
|
1268 |
+
),
|
1269 |
+
'admin-users' => array(
|
1270 |
+
'current_user',
|
1271 |
+
'user_form',
|
1272 |
+
),
|
1273 |
+
'welcome-widgets-menus' => array(
|
1274 |
+
'widget',
|
1275 |
+
'nav_menu',
|
1276 |
+
'nav_menu_item',
|
1277 |
+
),
|
1278 |
+
'category' => array(
|
1279 |
+
'taxonomy',
|
1280 |
+
'post_category',
|
1281 |
+
'post_taxonomy',
|
1282 |
+
),
|
1283 |
+
'admin-comments' => array(
|
1284 |
+
'comment',
|
1285 |
+
),
|
1286 |
+
'paperclip' => array(
|
1287 |
+
'attachment',
|
1288 |
+
),
|
1289 |
+
'admin-settings' => array(
|
1290 |
+
'options_page',
|
1291 |
+
),
|
1292 |
+
'businessman' => array(
|
1293 |
+
'current_user_role',
|
1294 |
+
'user_role',
|
1295 |
+
),
|
1296 |
+
'admin-appearance' => array(
|
1297 |
+
'acfe_template'
|
1298 |
+
)
|
1299 |
+
);
|
1300 |
+
|
1301 |
+
$rules = array();
|
1302 |
+
|
1303 |
+
foreach($types as $key => $type){
|
1304 |
+
|
1305 |
+
foreach($type as $slug => $name){
|
1306 |
+
|
1307 |
+
$icon = $icon_default;
|
1308 |
+
|
1309 |
+
foreach($icons as $_icon => $icon_slugs){
|
1310 |
+
|
1311 |
+
if(!in_array($slug, $icon_slugs))
|
1312 |
+
continue;
|
1313 |
+
|
1314 |
+
$icon = $_icon;
|
1315 |
+
break;
|
1316 |
+
|
1317 |
+
}
|
1318 |
+
|
1319 |
+
$rules[$slug] = array(
|
1320 |
+
'name' => $slug,
|
1321 |
+
'label' => $name,
|
1322 |
+
'icon' => $icon
|
1323 |
+
);
|
1324 |
+
|
1325 |
+
}
|
1326 |
+
|
1327 |
+
}
|
1328 |
+
|
1329 |
+
foreach($locations as $group){
|
1330 |
+
|
1331 |
+
if(!acf_maybe_get($rules, $group['param']) || !acf_maybe_get($group, 'value'))
|
1332 |
+
continue;
|
1333 |
+
|
1334 |
+
// init
|
1335 |
+
$rule = $rules[$group['param']];
|
1336 |
+
|
1337 |
+
// vars
|
1338 |
+
$icon = $rule['icon'];
|
1339 |
+
$name = $rule['name'];
|
1340 |
+
$label = $rule['label'];
|
1341 |
+
$operator = $group['operator'] === '==' ? '=' : $group['operator'];
|
1342 |
+
$value = $group['value'];
|
1343 |
+
|
1344 |
+
// Exception for Post/Page/page Parent ID
|
1345 |
+
if(in_array($group['param'], array('post', 'page', 'page_parent'))){
|
1346 |
+
|
1347 |
+
$value = get_the_title((int) $value);
|
1348 |
+
|
1349 |
+
}else{
|
1350 |
+
|
1351 |
+
// Validate value
|
1352 |
+
$values = acf_get_location_rule_values($group);
|
1353 |
+
|
1354 |
+
if(!empty($values) && is_array($values)){
|
1355 |
+
|
1356 |
+
foreach($values as $value_slug => $value_name){
|
1357 |
+
|
1358 |
+
if($value != $value_slug)
|
1359 |
+
continue;
|
1360 |
+
|
1361 |
+
$value = $value_name;
|
1362 |
+
|
1363 |
+
if(is_array($value_name) && isset($value_name[$value_slug])){
|
1364 |
+
|
1365 |
+
$value = $value_name[$value_slug];
|
1366 |
+
|
1367 |
+
}
|
1368 |
+
|
1369 |
+
break;
|
1370 |
+
|
1371 |
+
}
|
1372 |
+
|
1373 |
+
}
|
1374 |
+
|
1375 |
+
}
|
1376 |
+
|
1377 |
+
// html
|
1378 |
+
$title = $label . ' ' . $operator . ' ' . $value;
|
1379 |
+
|
1380 |
+
$atts = array(
|
1381 |
+
'class' => 'acf-js-tooltip dashicons dashicons-' . $icon,
|
1382 |
+
'title' => $title
|
1383 |
+
);
|
1384 |
+
|
1385 |
+
if($operator === '!='){
|
1386 |
+
|
1387 |
+
$atts['style'] = 'color: #ccc;';
|
1388 |
+
|
1389 |
+
}
|
1390 |
+
|
1391 |
+
$html = '<span ' . acf_esc_attr($atts) . '></span>';
|
1392 |
+
|
1393 |
+
$return[] = array(
|
1394 |
+
'html' => $html,
|
1395 |
+
'icon' => $icon,
|
1396 |
+
'title' => $title,
|
1397 |
+
'name' => $name,
|
1398 |
+
'label' => $label,
|
1399 |
+
'operator' => $operator,
|
1400 |
+
'value' => $value,
|
1401 |
+
);
|
1402 |
+
|
1403 |
+
}
|
1404 |
+
|
1405 |
+
return $return;
|
1406 |
+
|
1407 |
+
}
|
1408 |
+
|
1409 |
+
function acfe_render_field_group_locations_html($field_group){
|
1410 |
+
|
1411 |
+
foreach($field_group['location'] as $groups){
|
1412 |
+
|
1413 |
+
$html = acfe_get_locations_array($groups);
|
1414 |
+
|
1415 |
+
if($html){
|
1416 |
+
|
1417 |
+
$array = array();
|
1418 |
+
|
1419 |
+
foreach($html as $location){
|
1420 |
+
|
1421 |
+
$array[] = $location['html'];
|
1422 |
+
|
1423 |
+
}
|
1424 |
+
|
1425 |
+
echo implode(' ', $array);
|
1426 |
+
|
1427 |
+
}
|
1428 |
+
|
1429 |
+
}
|
1430 |
+
|
1431 |
+
}
|
1432 |
+
|
1433 |
+
function acfe_unset(&$array, $key){
|
1434 |
+
|
1435 |
+
if(isset($array[$key]))
|
1436 |
+
unset($array[$key]);
|
1437 |
+
|
1438 |
+
}
|
1439 |
+
|
1440 |
+
function acfe_unarray($val){
|
1441 |
+
|
1442 |
+
if(is_array($val)){
|
1443 |
+
return reset($val);
|
1444 |
+
}
|
1445 |
+
|
1446 |
+
return $val;
|
1447 |
+
}
|
1448 |
+
|
1449 |
+
function acfe_get_post_id(){
|
1450 |
+
|
1451 |
+
return acf_get_valid_post_id();
|
1452 |
+
|
1453 |
+
}
|
1454 |
+
|
1455 |
+
function acfe_highlight(){
|
1456 |
+
|
1457 |
+
ini_set("highlight.comment", "#555");
|
1458 |
+
/*
|
1459 |
+
ini_set("highlight.keyword", "#0000BB"); // #4B2AFF
|
1460 |
+
ini_set("highlight.default", "#222222");
|
1461 |
+
ini_set("highlight.string", "#777777");
|
1462 |
+
*/
|
1463 |
+
|
1464 |
+
static $on = false;
|
1465 |
+
|
1466 |
+
if ( !$on ) {
|
1467 |
+
ob_start();
|
1468 |
+
} else {
|
1469 |
+
$buffer = "<?php\n" . ob_get_contents();
|
1470 |
+
ob_end_clean();
|
1471 |
+
$code = highlight_string($buffer, true);
|
1472 |
+
|
1473 |
+
$code = str_replace("<?php<br />", '', $code);
|
1474 |
+
$code = str_replace("<code>", '', $code);
|
1475 |
+
$code = str_replace("</code>", '', $code);
|
1476 |
+
|
1477 |
+
echo '<div class="acfe-pre-highlight">' . $code . '</div>';
|
1478 |
+
}
|
1479 |
+
|
1480 |
+
$on = !$on;
|
1481 |
+
|
1482 |
+
}
|
1483 |
+
|
1484 |
+
/*
|
1485 |
+
* https://gist.github.com/tripflex/c6518efc1753cf2392559866b4bd1a53
|
1486 |
+
*/
|
1487 |
+
function acfe_remove_class_filter( $tag, $class_name = '', $method_name = '', $priority = 10 ) {
|
1488 |
+
|
1489 |
+
global $wp_filter;
|
1490 |
+
|
1491 |
+
// Check that filter actually exists first
|
1492 |
+
if ( ! isset( $wp_filter[ $tag ] ) ) {
|
1493 |
+
return FALSE;
|
1494 |
+
}
|
1495 |
+
|
1496 |
+
/**
|
1497 |
+
* If filter config is an object, means we're using WordPress 4.7+ and the config is no longer
|
1498 |
+
* a simple array, rather it is an object that implements the ArrayAccess interface.
|
1499 |
+
*
|
1500 |
+
* To be backwards compatible, we set $callbacks equal to the correct array as a reference (so $wp_filter is updated)
|
1501 |
+
*
|
1502 |
+
* @see https://make.wordpress.org/core/2016/09/08/wp_hook-next-generation-actions-and-filters/
|
1503 |
+
*/
|
1504 |
+
if ( is_object( $wp_filter[ $tag ] ) && isset( $wp_filter[ $tag ]->callbacks ) ) {
|
1505 |
+
// Create $fob object from filter tag, to use below
|
1506 |
+
$fob = $wp_filter[ $tag ];
|
1507 |
+
$callbacks = &$wp_filter[ $tag ]->callbacks;
|
1508 |
+
} else {
|
1509 |
+
$callbacks = &$wp_filter[ $tag ];
|
1510 |
+
}
|
1511 |
+
|
1512 |
+
// Exit if there aren't any callbacks for specified priority
|
1513 |
+
if ( ! isset( $callbacks[ $priority ] ) || empty( $callbacks[ $priority ] ) ) {
|
1514 |
+
return FALSE;
|
1515 |
+
}
|
1516 |
+
|
1517 |
+
// Loop through each filter for the specified priority, looking for our class & method
|
1518 |
+
foreach ( (array) $callbacks[ $priority ] as $filter_id => $filter ) {
|
1519 |
+
|
1520 |
+
// Filter should always be an array - array( $this, 'method' ), if not goto next
|
1521 |
+
if ( ! isset( $filter['function'] ) || ! is_array( $filter['function'] ) ) {
|
1522 |
+
continue;
|
1523 |
+
}
|
1524 |
+
|
1525 |
+
// If first value in array is not an object, it can't be a class
|
1526 |
+
if ( ! is_object( $filter['function'][0] ) ) {
|
1527 |
+
continue;
|
1528 |
+
}
|
1529 |
+
|
1530 |
+
// Method doesn't match the one we're looking for, goto next
|
1531 |
+
if ( $filter['function'][1] !== $method_name ) {
|
1532 |
+
continue;
|
1533 |
+
}
|
1534 |
+
|
1535 |
+
// Method matched, now let's check the Class
|
1536 |
+
if ( get_class( $filter['function'][0] ) === $class_name ) {
|
1537 |
+
|
1538 |
+
// WordPress 4.7+ use core remove_filter() since we found the class object
|
1539 |
+
if ( isset( $fob ) ) {
|
1540 |
+
// Handles removing filter, reseting callback priority keys mid-iteration, etc.
|
1541 |
+
$fob->remove_filter( $tag, $filter['function'], $priority );
|
1542 |
+
|
1543 |
+
} else {
|
1544 |
+
// Use legacy removal process (pre 4.7)
|
1545 |
+
unset( $callbacks[ $priority ][ $filter_id ] );
|
1546 |
+
// and if it was the only filter in that priority, unset that priority
|
1547 |
+
if ( empty( $callbacks[ $priority ] ) ) {
|
1548 |
+
unset( $callbacks[ $priority ] );
|
1549 |
+
}
|
1550 |
+
// and if the only filter for that tag, set the tag to an empty array
|
1551 |
+
if ( empty( $callbacks ) ) {
|
1552 |
+
$callbacks = array();
|
1553 |
+
}
|
1554 |
+
// Remove this filter from merged_filters, which specifies if filters have been sorted
|
1555 |
+
unset( $GLOBALS['merged_filters'][ $tag ] );
|
1556 |
+
}
|
1557 |
+
|
1558 |
+
return TRUE;
|
1559 |
+
}
|
1560 |
+
}
|
1561 |
+
|
1562 |
+
return FALSE;
|
1563 |
+
}
|
1564 |
+
|
1565 |
+
function acfe_remove_class_action( $tag, $class_name = '', $method_name = '', $priority = 10 ) {
|
1566 |
+
return acfe_remove_class_filter( $tag, $class_name, $method_name, $priority );
|
1567 |
+
}
|
1568 |
+
|
1569 |
+
/*
|
1570 |
+
* Similar to get_fields() but with field keys
|
1571 |
+
*/
|
1572 |
+
function acfe_get_fields($post_id = false, $format_value = true){
|
1573 |
+
|
1574 |
+
// vars
|
1575 |
+
$fields = get_field_objects($post_id, $format_value);
|
1576 |
+
$meta = array();
|
1577 |
+
|
1578 |
+
// bail early
|
1579 |
+
if(!$fields)
|
1580 |
+
return false;
|
1581 |
+
|
1582 |
+
// populate
|
1583 |
+
foreach($fields as $k => $field){
|
1584 |
+
|
1585 |
+
$meta[ $field['key'] ] = $field['value'];
|
1586 |
+
|
1587 |
+
}
|
1588 |
+
|
1589 |
+
// return
|
1590 |
+
return $meta;
|
1591 |
+
|
1592 |
}
|
@@ -1,158 +1,158 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
if(!class_exists('acfe_hooks')):
|
7 |
-
|
8 |
-
class acfe_hooks{
|
9 |
-
|
10 |
-
public $field_group;
|
11 |
-
|
12 |
-
function __construct(){
|
13 |
-
|
14 |
-
// Field Groups
|
15 |
-
add_filter('acf/load_field_groups', array($this, 'load_field_groups'), 100);
|
16 |
-
add_filter('acf/pre_render_fields', array($this, 'pre_render_fields'), 10, 2);
|
17 |
-
add_action('acf/render_fields', array($this, 'render_fields'), 10, 2);
|
18 |
-
|
19 |
-
acf_add_filter_variations('acfe/prepare_field_group', array('ID', 'key'), 0);
|
20 |
-
acf_add_action_variations('acfe/pre_render_field_group', array('ID', 'key'), 0);
|
21 |
-
acf_add_action_variations('acfe/render_field_group', array('ID', 'key'), 0);
|
22 |
-
|
23 |
-
// Fields
|
24 |
-
add_filter('acf/field_wrapper_attributes', array($this, 'field_wrapper_attributes'), 10, 2);
|
25 |
-
add_filter('acf/load_fields', array($this, 'load_fields'), 10, 2);
|
26 |
-
add_filter('acf/load_field', array($this, 'load_field'));
|
27 |
-
|
28 |
-
acf_add_filter_variations('acfe/field_wrapper_attributes', array('type', 'name', 'key'), 1);
|
29 |
-
acf_add_filter_variations('acfe/load_fields', array('type', 'name', 'key'), 1);
|
30 |
-
acf_add_filter_variations('acfe/load_field', array('type', 'name', 'key'), 0);
|
31 |
-
acf_add_filter_variations('acfe/load_field_front', array('type', 'name', 'key'), 0);
|
32 |
-
acf_add_filter_variations('acfe/load_field_admin', array('type', 'name', 'key'), 0);
|
33 |
-
|
34 |
-
}
|
35 |
-
|
36 |
-
/*
|
37 |
-
* Load Field Groups
|
38 |
-
*/
|
39 |
-
function load_field_groups($field_groups){
|
40 |
-
|
41 |
-
if(acfe_is_admin_screen())
|
42 |
-
return $field_groups;
|
43 |
-
|
44 |
-
foreach($field_groups as $i => &$field_group){
|
45 |
-
|
46 |
-
$field_group = apply_filters('acfe/prepare_field_group', $field_group);
|
47 |
-
|
48 |
-
// Do not render if false
|
49 |
-
if($field_group === false){
|
50 |
-
|
51 |
-
unset($field_groups[$i]);
|
52 |
-
|
53 |
-
}
|
54 |
-
|
55 |
-
}
|
56 |
-
|
57 |
-
return $field_groups;
|
58 |
-
|
59 |
-
}
|
60 |
-
|
61 |
-
/*
|
62 |
-
* Pre Render Fields
|
63 |
-
*/
|
64 |
-
function pre_render_fields($fields, $post_id){
|
65 |
-
|
66 |
-
$this->field_group = array();
|
67 |
-
|
68 |
-
if(!isset($fields[0]))
|
69 |
-
return $fields;
|
70 |
-
|
71 |
-
if(!acf_maybe_get($fields[0], 'parent'))
|
72 |
-
return $fields;
|
73 |
-
|
74 |
-
$field_group = acf_get_field_group($fields[0]['parent']);
|
75 |
-
|
76 |
-
if(!$field_group)
|
77 |
-
return $fields;
|
78 |
-
|
79 |
-
$this->field_group = $field_group;
|
80 |
-
|
81 |
-
do_action('acfe/pre_render_field_group', $field_group, $fields, $post_id);
|
82 |
-
|
83 |
-
return $fields;
|
84 |
-
|
85 |
-
}
|
86 |
-
|
87 |
-
/*
|
88 |
-
* Pre Render Fields
|
89 |
-
*/
|
90 |
-
function render_fields($fields, $post_id){
|
91 |
-
|
92 |
-
if(empty($this->field_group))
|
93 |
-
return;
|
94 |
-
|
95 |
-
do_action('acfe/render_field_group', $this->field_group, $fields, $post_id);
|
96 |
-
|
97 |
-
}
|
98 |
-
|
99 |
-
/*
|
100 |
-
* Field Wrapper Attributes
|
101 |
-
*/
|
102 |
-
function field_wrapper_attributes($wrapper, $field){
|
103 |
-
|
104 |
-
$wrapper = apply_filters('acfe/field_wrapper_attributes', $wrapper, $field);
|
105 |
-
|
106 |
-
return $wrapper;
|
107 |
-
|
108 |
-
}
|
109 |
-
|
110 |
-
/*
|
111 |
-
* Load Fields
|
112 |
-
*/
|
113 |
-
function load_fields($fields, $parent){
|
114 |
-
|
115 |
-
// check if field (fitler is also called on field groups)
|
116 |
-
if(!acf_maybe_get($parent, 'type'))
|
117 |
-
return $fields;
|
118 |
-
|
119 |
-
$fields = apply_filters('acfe/load_fields', $fields, $parent);
|
120 |
-
|
121 |
-
return $fields;
|
122 |
-
|
123 |
-
}
|
124 |
-
|
125 |
-
/*
|
126 |
-
* Load Field
|
127 |
-
*/
|
128 |
-
function load_field($field){
|
129 |
-
|
130 |
-
if(acfe_is_admin_screen())
|
131 |
-
return $field;
|
132 |
-
|
133 |
-
// Everywhere
|
134 |
-
$field = apply_filters('acfe/load_field', $field);
|
135 |
-
|
136 |
-
// Admin
|
137 |
-
if(acfe_form_is_admin()){
|
138 |
-
|
139 |
-
$field = apply_filters('acfe/load_field_admin', $field);
|
140 |
-
|
141 |
-
}
|
142 |
-
|
143 |
-
// Front
|
144 |
-
elseif(acfe_form_is_front()){
|
145 |
-
|
146 |
-
$field = apply_filters('acfe/load_field_front', $field);
|
147 |
-
|
148 |
-
}
|
149 |
-
|
150 |
-
return $field;
|
151 |
-
|
152 |
-
}
|
153 |
-
|
154 |
-
}
|
155 |
-
|
156 |
-
new acfe_hooks();
|
157 |
-
|
158 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
if(!class_exists('acfe_hooks')):
|
7 |
+
|
8 |
+
class acfe_hooks{
|
9 |
+
|
10 |
+
public $field_group;
|
11 |
+
|
12 |
+
function __construct(){
|
13 |
+
|
14 |
+
// Field Groups
|
15 |
+
add_filter('acf/load_field_groups', array($this, 'load_field_groups'), 100);
|
16 |
+
add_filter('acf/pre_render_fields', array($this, 'pre_render_fields'), 10, 2);
|
17 |
+
add_action('acf/render_fields', array($this, 'render_fields'), 10, 2);
|
18 |
+
|
19 |
+
acf_add_filter_variations('acfe/prepare_field_group', array('ID', 'key'), 0);
|
20 |
+
acf_add_action_variations('acfe/pre_render_field_group', array('ID', 'key'), 0);
|
21 |
+
acf_add_action_variations('acfe/render_field_group', array('ID', 'key'), 0);
|
22 |
+
|
23 |
+
// Fields
|
24 |
+
add_filter('acf/field_wrapper_attributes', array($this, 'field_wrapper_attributes'), 10, 2);
|
25 |
+
add_filter('acf/load_fields', array($this, 'load_fields'), 10, 2);
|
26 |
+
add_filter('acf/load_field', array($this, 'load_field'));
|
27 |
+
|
28 |
+
acf_add_filter_variations('acfe/field_wrapper_attributes', array('type', 'name', 'key'), 1);
|
29 |
+
acf_add_filter_variations('acfe/load_fields', array('type', 'name', 'key'), 1);
|
30 |
+
acf_add_filter_variations('acfe/load_field', array('type', 'name', 'key'), 0);
|
31 |
+
acf_add_filter_variations('acfe/load_field_front', array('type', 'name', 'key'), 0);
|
32 |
+
acf_add_filter_variations('acfe/load_field_admin', array('type', 'name', 'key'), 0);
|
33 |
+
|
34 |
+
}
|
35 |
+
|
36 |
+
/*
|
37 |
+
* Load Field Groups
|
38 |
+
*/
|
39 |
+
function load_field_groups($field_groups){
|
40 |
+
|
41 |
+
if(acfe_is_admin_screen())
|
42 |
+
return $field_groups;
|
43 |
+
|
44 |
+
foreach($field_groups as $i => &$field_group){
|
45 |
+
|
46 |
+
$field_group = apply_filters('acfe/prepare_field_group', $field_group);
|
47 |
+
|
48 |
+
// Do not render if false
|
49 |
+
if($field_group === false){
|
50 |
+
|
51 |
+
unset($field_groups[$i]);
|
52 |
+
|
53 |
+
}
|
54 |
+
|
55 |
+
}
|
56 |
+
|
57 |
+
return $field_groups;
|
58 |
+
|
59 |
+
}
|
60 |
+
|
61 |
+
/*
|
62 |
+
* Pre Render Fields
|
63 |
+
*/
|
64 |
+
function pre_render_fields($fields, $post_id){
|
65 |
+
|
66 |
+
$this->field_group = array();
|
67 |
+
|
68 |
+
if(!isset($fields[0]))
|
69 |
+
return $fields;
|
70 |
+
|
71 |
+
if(!acf_maybe_get($fields[0], 'parent'))
|
72 |
+
return $fields;
|
73 |
+
|
74 |
+
$field_group = acf_get_field_group($fields[0]['parent']);
|
75 |
+
|
76 |
+
if(!$field_group)
|
77 |
+
return $fields;
|
78 |
+
|
79 |
+
$this->field_group = $field_group;
|
80 |
+
|
81 |
+
do_action('acfe/pre_render_field_group', $field_group, $fields, $post_id);
|
82 |
+
|
83 |
+
return $fields;
|
84 |
+
|
85 |
+
}
|
86 |
+
|
87 |
+
/*
|
88 |
+
* Pre Render Fields
|
89 |
+
*/
|
90 |
+
function render_fields($fields, $post_id){
|
91 |
+
|
92 |
+
if(empty($this->field_group))
|
93 |
+
return;
|
94 |
+
|
95 |
+
do_action('acfe/render_field_group', $this->field_group, $fields, $post_id);
|
96 |
+
|
97 |
+
}
|
98 |
+
|
99 |
+
/*
|
100 |
+
* Field Wrapper Attributes
|
101 |
+
*/
|
102 |
+
function field_wrapper_attributes($wrapper, $field){
|
103 |
+
|
104 |
+
$wrapper = apply_filters('acfe/field_wrapper_attributes', $wrapper, $field);
|
105 |
+
|
106 |
+
return $wrapper;
|
107 |
+
|
108 |
+
}
|
109 |
+
|
110 |
+
/*
|
111 |
+
* Load Fields
|
112 |
+
*/
|
113 |
+
function load_fields($fields, $parent){
|
114 |
+
|
115 |
+
// check if field (fitler is also called on field groups)
|
116 |
+
if(!acf_maybe_get($parent, 'type'))
|
117 |
+
return $fields;
|
118 |
+
|
119 |
+
$fields = apply_filters('acfe/load_fields', $fields, $parent);
|
120 |
+
|
121 |
+
return $fields;
|
122 |
+
|
123 |
+
}
|
124 |
+
|
125 |
+
/*
|
126 |
+
* Load Field
|
127 |
+
*/
|
128 |
+
function load_field($field){
|
129 |
+
|
130 |
+
if(acfe_is_admin_screen())
|
131 |
+
return $field;
|
132 |
+
|
133 |
+
// Everywhere
|
134 |
+
$field = apply_filters('acfe/load_field', $field);
|
135 |
+
|
136 |
+
// Admin
|
137 |
+
if(acfe_form_is_admin()){
|
138 |
+
|
139 |
+
$field = apply_filters('acfe/load_field_admin', $field);
|
140 |
+
|
141 |
+
}
|
142 |
+
|
143 |
+
// Front
|
144 |
+
elseif(acfe_form_is_front()){
|
145 |
+
|
146 |
+
$field = apply_filters('acfe/load_field_front', $field);
|
147 |
+
|
148 |
+
}
|
149 |
+
|
150 |
+
return $field;
|
151 |
+
|
152 |
+
}
|
153 |
+
|
154 |
+
}
|
155 |
+
|
156 |
+
new acfe_hooks();
|
157 |
+
|
158 |
endif;
|
@@ -1,123 +1,123 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
add_action('current_screen', 'acfe_screen_header');
|
7 |
-
function acfe_screen_header($screen){
|
8 |
-
|
9 |
-
if(acf_version_compare(acf_get_setting('version'), '<', '5.9'))
|
10 |
-
return;
|
11 |
-
|
12 |
-
if(!acf_is_screen(array('edit-acf-field-group-category', 'edit-acfe-dbt', 'acfe-dbt', 'edit-acfe-dop', 'acfe-dop', 'edit-acfe-template', 'acfe-template', 'edit-acfe-form', 'acfe-form')))
|
13 |
-
return;
|
14 |
-
|
15 |
-
add_action('in_admin_header', function(){
|
16 |
-
|
17 |
-
acf_get_view('html-admin-navigation');
|
18 |
-
|
19 |
-
});
|
20 |
-
|
21 |
-
}
|
22 |
-
|
23 |
-
add_action('admin_menu', 'acfe_admin_settings_submenu_swap', 999);
|
24 |
-
function acfe_admin_settings_submenu_swap(){
|
25 |
-
|
26 |
-
global $submenu;
|
27 |
-
|
28 |
-
if(!acf_maybe_get($submenu, 'edit.php?post_type=acf-field-group'))
|
29 |
-
return;
|
30 |
-
|
31 |
-
$_submenu = $submenu['edit.php?post_type=acf-field-group'];
|
32 |
-
$array = array();
|
33 |
-
|
34 |
-
foreach($submenu['edit.php?post_type=acf-field-group'] as $k => $item){
|
35 |
-
|
36 |
-
// Field Groups
|
37 |
-
if($item[2] === 'edit.php?post_type=acf-field-group'){
|
38 |
-
|
39 |
-
$array[0] = $item;
|
40 |
-
unset($_submenu[$k]);
|
41 |
-
|
42 |
-
}
|
43 |
-
|
44 |
-
// Add New
|
45 |
-
elseif($item[2] === 'post-new.php?post_type=acf-field-group'){
|
46 |
-
|
47 |
-
$array[1] = $item;
|
48 |
-
unset($_submenu[$k]);
|
49 |
-
|
50 |
-
}
|
51 |
-
|
52 |
-
// Categories
|
53 |
-
elseif($item[2] === 'edit-tags.php?taxonomy=acf-field-group-category'){
|
54 |
-
|
55 |
-
$array[2] = $item;
|
56 |
-
unset($_submenu[$k]);
|
57 |
-
|
58 |
-
}
|
59 |
-
|
60 |
-
// Block Types
|
61 |
-
elseif($item[2] === 'edit.php?post_type=acfe-dbt'){
|
62 |
-
|
63 |
-
$array[3] = $item;
|
64 |
-
unset($_submenu[$k]);
|
65 |
-
|
66 |
-
}
|
67 |
-
|
68 |
-
// Forms
|
69 |
-
elseif($item[2] === 'edit.php?post_type=acfe-form'){
|
70 |
-
|
71 |
-
$array[4] = $item;
|
72 |
-
unset($_submenu[$k]);
|
73 |
-
|
74 |
-
}
|
75 |
-
|
76 |
-
// Options
|
77 |
-
elseif($item[2] === 'edit.php?post_type=acfe-dop'){
|
78 |
-
|
79 |
-
$array[5] = $item;
|
80 |
-
unset($_submenu[$k]);
|
81 |
-
|
82 |
-
}
|
83 |
-
|
84 |
-
// Settings
|
85 |
-
elseif($item[2] === 'acfe-settings'){
|
86 |
-
|
87 |
-
$array[6] = $item;
|
88 |
-
unset($_submenu[$k]);
|
89 |
-
|
90 |
-
}
|
91 |
-
|
92 |
-
// Tools
|
93 |
-
elseif($item[2] === 'acf-tools'){
|
94 |
-
|
95 |
-
$array[7] = $item;
|
96 |
-
unset($_submenu[$k]);
|
97 |
-
|
98 |
-
}
|
99 |
-
|
100 |
-
// Updates
|
101 |
-
elseif($item[2] === 'acf-settings-updates'){
|
102 |
-
|
103 |
-
$array[8] = $item;
|
104 |
-
unset($_submenu[$k]);
|
105 |
-
|
106 |
-
}
|
107 |
-
|
108 |
-
}
|
109 |
-
|
110 |
-
// Sort
|
111 |
-
ksort($array);
|
112 |
-
|
113 |
-
// Default submenu
|
114 |
-
$submenu['edit.php?post_type=acf-field-group'] = $array;
|
115 |
-
|
116 |
-
// Add items left
|
117 |
-
if(!empty($_submenu)){
|
118 |
-
|
119 |
-
$submenu['edit.php?post_type=acf-field-group'] = array_merge($array, $_submenu);
|
120 |
-
|
121 |
-
}
|
122 |
-
|
123 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
add_action('current_screen', 'acfe_screen_header');
|
7 |
+
function acfe_screen_header($screen){
|
8 |
+
|
9 |
+
if(acf_version_compare(acf_get_setting('version'), '<', '5.9'))
|
10 |
+
return;
|
11 |
+
|
12 |
+
if(!acf_is_screen(array('edit-acf-field-group-category', 'edit-acfe-dbt', 'acfe-dbt', 'edit-acfe-dop', 'acfe-dop', 'edit-acfe-template', 'acfe-template', 'edit-acfe-form', 'acfe-form')))
|
13 |
+
return;
|
14 |
+
|
15 |
+
add_action('in_admin_header', function(){
|
16 |
+
|
17 |
+
acf_get_view('html-admin-navigation');
|
18 |
+
|
19 |
+
});
|
20 |
+
|
21 |
+
}
|
22 |
+
|
23 |
+
add_action('admin_menu', 'acfe_admin_settings_submenu_swap', 999);
|
24 |
+
function acfe_admin_settings_submenu_swap(){
|
25 |
+
|
26 |
+
global $submenu;
|
27 |
+
|
28 |
+
if(!acf_maybe_get($submenu, 'edit.php?post_type=acf-field-group'))
|
29 |
+
return;
|
30 |
+
|
31 |
+
$_submenu = $submenu['edit.php?post_type=acf-field-group'];
|
32 |
+
$array = array();
|
33 |
+
|
34 |
+
foreach($submenu['edit.php?post_type=acf-field-group'] as $k => $item){
|
35 |
+
|
36 |
+
// Field Groups
|
37 |
+
if($item[2] === 'edit.php?post_type=acf-field-group'){
|
38 |
+
|
39 |
+
$array[0] = $item;
|
40 |
+
unset($_submenu[$k]);
|
41 |
+
|
42 |
+
}
|
43 |
+
|
44 |
+
// Add New
|
45 |
+
elseif($item[2] === 'post-new.php?post_type=acf-field-group'){
|
46 |
+
|
47 |
+
$array[1] = $item;
|
48 |
+
unset($_submenu[$k]);
|
49 |
+
|
50 |
+
}
|
51 |
+
|
52 |
+
// Categories
|
53 |
+
elseif($item[2] === 'edit-tags.php?taxonomy=acf-field-group-category'){
|
54 |
+
|
55 |
+
$array[2] = $item;
|
56 |
+
unset($_submenu[$k]);
|
57 |
+
|
58 |
+
}
|
59 |
+
|
60 |
+
// Block Types
|
61 |
+
elseif($item[2] === 'edit.php?post_type=acfe-dbt'){
|
62 |
+
|
63 |
+
$array[3] = $item;
|
64 |
+
unset($_submenu[$k]);
|
65 |
+
|
66 |
+
}
|
67 |
+
|
68 |
+
// Forms
|
69 |
+
elseif($item[2] === 'edit.php?post_type=acfe-form'){
|
70 |
+
|
71 |
+
$array[4] = $item;
|
72 |
+
unset($_submenu[$k]);
|
73 |
+
|
74 |
+
}
|
75 |
+
|
76 |
+
// Options
|
77 |
+
elseif($item[2] === 'edit.php?post_type=acfe-dop'){
|
78 |
+
|
79 |
+
$array[5] = $item;
|
80 |
+
unset($_submenu[$k]);
|
81 |
+
|
82 |
+
}
|
83 |
+
|
84 |
+
// Settings
|
85 |
+
elseif($item[2] === 'acfe-settings'){
|
86 |
+
|
87 |
+
$array[6] = $item;
|
88 |
+
unset($_submenu[$k]);
|
89 |
+
|
90 |
+
}
|
91 |
+
|
92 |
+
// Tools
|
93 |
+
elseif($item[2] === 'acf-tools'){
|
94 |
+
|
95 |
+
$array[7] = $item;
|
96 |
+
unset($_submenu[$k]);
|
97 |
+
|
98 |
+
}
|
99 |
+
|
100 |
+
// Updates
|
101 |
+
elseif($item[2] === 'acf-settings-updates'){
|
102 |
+
|
103 |
+
$array[8] = $item;
|
104 |
+
unset($_submenu[$k]);
|
105 |
+
|
106 |
+
}
|
107 |
+
|
108 |
+
}
|
109 |
+
|
110 |
+
// Sort
|
111 |
+
ksort($array);
|
112 |
+
|
113 |
+
// Default submenu
|
114 |
+
$submenu['edit.php?post_type=acf-field-group'] = $array;
|
115 |
+
|
116 |
+
// Add items left
|
117 |
+
if(!empty($_submenu)){
|
118 |
+
|
119 |
+
$submenu['edit.php?post_type=acf-field-group'] = array_merge($array, $_submenu);
|
120 |
+
|
121 |
+
}
|
122 |
+
|
123 |
}
|
@@ -1,471 +1,700 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
if(!class_exists('acfe_multilang')):
|
7 |
-
|
8 |
-
class acfe_multilang{
|
9 |
-
|
10 |
-
var $is_wpml = false;
|
11 |
-
var $is_polylang = false;
|
12 |
-
var $is_multilang = false;
|
13 |
-
var $options_pages = false;
|
14 |
-
|
15 |
-
function __construct(){
|
16 |
-
|
17 |
-
// WPML
|
18 |
-
if(defined('ICL_SITEPRESS_VERSION')){
|
19 |
-
|
20 |
-
$this->is_wpml = true;
|
21 |
-
$this->is_multilang = true;
|
22 |
-
|
23 |
-
}
|
24 |
-
|
25 |
-
// PolyLang
|
26 |
-
if(defined('POLYLANG_VERSION') && function_exists('pll_default_language')){
|
27 |
-
|
28 |
-
$this->is_polylang = true;
|
29 |
-
$this->is_multilang = true;
|
30 |
-
|
31 |
-
}
|
32 |
-
|
33 |
-
if($this->is_multilang){
|
34 |
-
|
35 |
-
add_action('acf/init', array($this, 'init'), 99);
|
36 |
-
|
37 |
-
}
|
38 |
-
|
39 |
-
}
|
40 |
-
|
41 |
-
function init(){
|
42 |
-
|
43 |
-
// Check setting
|
44 |
-
if(!acf_get_setting('acfe/modules/multilang'))
|
45 |
-
return;
|
46 |
-
|
47 |
-
// Polylang specific
|
48 |
-
if($this->is_polylang){
|
49 |
-
|
50 |
-
// Default/Current Language
|
51 |
-
$dl = pll_default_language('locale');
|
52 |
-
$cl = pll_current_language('locale');
|
53 |
-
|
54 |
-
// Update settings
|
55 |
-
acf_update_setting('default_language', $dl);
|
56 |
-
acf_update_setting('current_language', $cl);
|
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 |
-
|
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 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
}
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
471 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
if(!class_exists('acfe_multilang')):
|
7 |
+
|
8 |
+
class acfe_multilang{
|
9 |
+
|
10 |
+
var $is_wpml = false;
|
11 |
+
var $is_polylang = false;
|
12 |
+
var $is_multilang = false;
|
13 |
+
var $options_pages = false;
|
14 |
+
|
15 |
+
function __construct(){
|
16 |
+
|
17 |
+
// WPML
|
18 |
+
if(defined('ICL_SITEPRESS_VERSION')){
|
19 |
+
|
20 |
+
$this->is_wpml = true;
|
21 |
+
$this->is_multilang = true;
|
22 |
+
|
23 |
+
}
|
24 |
+
|
25 |
+
// PolyLang
|
26 |
+
if(defined('POLYLANG_VERSION') && function_exists('pll_default_language')){
|
27 |
+
|
28 |
+
$this->is_polylang = true;
|
29 |
+
$this->is_multilang = true;
|
30 |
+
|
31 |
+
}
|
32 |
+
|
33 |
+
if($this->is_multilang){
|
34 |
+
|
35 |
+
add_action('acf/init', array($this, 'init'), 99);
|
36 |
+
|
37 |
+
}
|
38 |
+
|
39 |
+
}
|
40 |
+
|
41 |
+
function init(){
|
42 |
+
|
43 |
+
// Check setting
|
44 |
+
if(!acf_get_setting('acfe/modules/multilang'))
|
45 |
+
return;
|
46 |
+
|
47 |
+
// Polylang specific
|
48 |
+
if($this->is_polylang){
|
49 |
+
|
50 |
+
// Default/Current Language
|
51 |
+
$dl = pll_default_language('locale');
|
52 |
+
$cl = pll_current_language('locale');
|
53 |
+
|
54 |
+
// Update settings
|
55 |
+
acf_update_setting('default_language', $dl);
|
56 |
+
acf_update_setting('current_language', $cl);
|
57 |
+
|
58 |
+
add_filter('acf/pre_load_reference', array($this, 'polylang_preload_reference'), 10, 3);
|
59 |
+
add_filter('acf/pre_load_value', array($this, 'polylang_preload_value'), 10, 3);
|
60 |
+
|
61 |
+
}
|
62 |
+
|
63 |
+
// Options Page Message
|
64 |
+
add_filter('acf/options_page/submitbox_before_major_actions', array($this, 'options_page_message'));
|
65 |
+
|
66 |
+
// ACF Options Post ID
|
67 |
+
add_filter('acf/validate_post_id', array($this, 'set_options_post_id'), 99, 2);
|
68 |
+
|
69 |
+
}
|
70 |
+
|
71 |
+
function polylang_preload_reference($null, $field_name, $post_id){
|
72 |
+
|
73 |
+
// Validate post id
|
74 |
+
$original_post_id = $this->polylang_validate_preload_post_id($post_id);
|
75 |
+
|
76 |
+
if(!$original_post_id)
|
77 |
+
return $null;
|
78 |
+
|
79 |
+
$reference = acf_get_metadata($post_id, $field_name, true);
|
80 |
+
|
81 |
+
if($reference !== null)
|
82 |
+
return $null;
|
83 |
+
|
84 |
+
return acf_get_metadata($original_post_id, $field_name, true);
|
85 |
+
|
86 |
+
}
|
87 |
+
|
88 |
+
function polylang_preload_value($null, $post_id, $field){
|
89 |
+
|
90 |
+
// Validate post id
|
91 |
+
$original_post_id = $this->polylang_validate_preload_post_id($post_id);
|
92 |
+
|
93 |
+
if(!$original_post_id)
|
94 |
+
return $null;
|
95 |
+
|
96 |
+
// Get field name.
|
97 |
+
$field_name = $field['name'];
|
98 |
+
|
99 |
+
// Check store.
|
100 |
+
$store = acf_get_store('values');
|
101 |
+
|
102 |
+
if($store->has("$post_id:$field_name"))
|
103 |
+
return $null;
|
104 |
+
|
105 |
+
// Load value from database.
|
106 |
+
$value = acf_get_metadata($post_id, $field_name);
|
107 |
+
|
108 |
+
// Use field's default_value if no meta was found.
|
109 |
+
if($value !== null)
|
110 |
+
return $null;
|
111 |
+
|
112 |
+
return acf_get_value($original_post_id, $field);
|
113 |
+
|
114 |
+
}
|
115 |
+
|
116 |
+
function polylang_validate_preload_post_id($post_id){
|
117 |
+
|
118 |
+
// Bail early if admin screen
|
119 |
+
if(is_admin() || !is_string($post_id))
|
120 |
+
return false;
|
121 |
+
|
122 |
+
// Get post id info
|
123 |
+
$data = acf_get_post_id_info($post_id);
|
124 |
+
|
125 |
+
// Bail early if post id isn't an option type
|
126 |
+
if($data['type'] !== 'option')
|
127 |
+
return false;
|
128 |
+
|
129 |
+
// Bail early if not localized
|
130 |
+
if(!$this->is_localized($post_id))
|
131 |
+
return false;
|
132 |
+
|
133 |
+
$original_post_id = preg_replace( '/([_\-][A-Za-z]{2}_[A-Za-z]{2})$/', '', $post_id);
|
134 |
+
|
135 |
+
// Check the regex
|
136 |
+
if($original_post_id === $post_id)
|
137 |
+
return false;
|
138 |
+
|
139 |
+
// Bail early if no Options Page found with that post id
|
140 |
+
if(!$this->is_options_page($original_post_id))
|
141 |
+
return false;
|
142 |
+
|
143 |
+
return $original_post_id;
|
144 |
+
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* WPML
|
149 |
+
* https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/
|
150 |
+
*/
|
151 |
+
function wpml_get_languages($pluck, $type = 'all'){
|
152 |
+
|
153 |
+
// Pluck
|
154 |
+
$pluck_filter = $pluck;
|
155 |
+
|
156 |
+
if($pluck === 'locale')
|
157 |
+
$pluck_filter = 'default_locale';
|
158 |
+
|
159 |
+
// Vars
|
160 |
+
$languages = array();
|
161 |
+
|
162 |
+
switch($type){
|
163 |
+
|
164 |
+
// Active
|
165 |
+
case 'active':
|
166 |
+
|
167 |
+
// Active Languages
|
168 |
+
// https://wpml.org/wpml-hook/wpml_active_languages/
|
169 |
+
$languages = apply_filters('wpml_active_languages', null, array('skip_missing' => 0));
|
170 |
+
|
171 |
+
$languages = wp_list_pluck($languages, $pluck_filter, true);
|
172 |
+
|
173 |
+
return $languages;
|
174 |
+
|
175 |
+
// All
|
176 |
+
case 'all':
|
177 |
+
|
178 |
+
// Active Languages
|
179 |
+
// https://wpml.org/wpml-hook/wpml_active_languages/
|
180 |
+
$languages = apply_filters('wpml_active_languages', null, array('skip_missing' => 0));
|
181 |
+
|
182 |
+
$languages = wp_list_pluck($languages, $pluck_filter, true);
|
183 |
+
|
184 |
+
// Plugin Languages
|
185 |
+
$plugin_languages = icl_get_languages_locales();
|
186 |
+
|
187 |
+
if(!empty($plugin_languages)){
|
188 |
+
|
189 |
+
if($pluck === 'code'){
|
190 |
+
|
191 |
+
$plugin_languages = array_keys($plugin_languages);
|
192 |
+
|
193 |
+
}elseif($pluck === 'locale'){
|
194 |
+
|
195 |
+
$plugin_languages = array_values($plugin_languages);
|
196 |
+
|
197 |
+
}
|
198 |
+
|
199 |
+
// Merge
|
200 |
+
$languages = array_merge($languages, $plugin_languages);
|
201 |
+
$languages = array_unique($languages);
|
202 |
+
|
203 |
+
}
|
204 |
+
|
205 |
+
return $languages;
|
206 |
+
|
207 |
+
}
|
208 |
+
|
209 |
+
return $languages;
|
210 |
+
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* PolyLang
|
215 |
+
* https://polylang.pro/doc/filter-reference/
|
216 |
+
* https://polylang.pro/doc/developpers-how-to/
|
217 |
+
* https://polylang.wordpress.com/documentation/documentation-for-developers/general/
|
218 |
+
* https://polylang.wordpress.com/documentation/documentation-for-developers/functions-reference/
|
219 |
+
*/
|
220 |
+
function polylang_get_languages($pluck, $type = 'all'){
|
221 |
+
|
222 |
+
// Vars
|
223 |
+
$languages = array();
|
224 |
+
|
225 |
+
switch($type){
|
226 |
+
|
227 |
+
// Active
|
228 |
+
case 'active':
|
229 |
+
|
230 |
+
$pluck_filter = $pluck;
|
231 |
+
if($pluck === 'code')
|
232 |
+
$pluck_filter = 'slug';
|
233 |
+
|
234 |
+
// https://polylang.wordpress.com/documentation/documentation-for-developers/functions-reference/
|
235 |
+
$languages = pll_languages_list(array(
|
236 |
+
'hide_empty' => false,
|
237 |
+
'fields' => $pluck_filter
|
238 |
+
));
|
239 |
+
|
240 |
+
return $languages;
|
241 |
+
|
242 |
+
// All
|
243 |
+
case 'all':
|
244 |
+
|
245 |
+
// Copy from wp-content/plugins/polylang-pro/settings/settings.php:363
|
246 |
+
require_once ABSPATH . 'wp-admin/includes/translation-install.php';
|
247 |
+
|
248 |
+
$languages = include POLYLANG_DIR . '/settings/languages.php';
|
249 |
+
$translations = wp_get_available_translations();
|
250 |
+
|
251 |
+
if (!empty($translations)){
|
252 |
+
|
253 |
+
$translations['en_US'] = '';
|
254 |
+
$languages = array_intersect_key($languages, $translations);
|
255 |
+
|
256 |
+
}
|
257 |
+
|
258 |
+
$languages = apply_filters('pll_predefined_languages', $languages);
|
259 |
+
|
260 |
+
foreach($languages as $k => $lang){
|
261 |
+
|
262 |
+
if(isset($lang['code'], $lang['locale'], $lang['name'], $lang['dir'], $lang['flag']))
|
263 |
+
continue;
|
264 |
+
|
265 |
+
unset($languages[$k]);
|
266 |
+
|
267 |
+
}
|
268 |
+
|
269 |
+
$languages = wp_list_pluck($languages, $pluck, true);
|
270 |
+
|
271 |
+
return $languages;
|
272 |
+
|
273 |
+
}
|
274 |
+
|
275 |
+
return $languages;
|
276 |
+
|
277 |
+
}
|
278 |
+
|
279 |
+
/**
|
280 |
+
* ACF Options Post ID
|
281 |
+
*/
|
282 |
+
function set_options_post_id($post_id, $original_post_id){
|
283 |
+
|
284 |
+
// Bail early if original post id is 'options' ||'option'
|
285 |
+
if(!is_string($post_id) || in_array($original_post_id, array('options', 'option')))
|
286 |
+
return $post_id;
|
287 |
+
|
288 |
+
$data = acf_get_post_id_info($post_id);
|
289 |
+
|
290 |
+
// Bail early if post id isn't an option type
|
291 |
+
if($data['type'] !== 'option')
|
292 |
+
return $post_id;
|
293 |
+
|
294 |
+
// Bail early if no Options Page found with that post id
|
295 |
+
if(!$this->is_options_page($post_id))
|
296 |
+
return $post_id;
|
297 |
+
|
298 |
+
// Bail early if already localized: 'my-options_en_US'
|
299 |
+
if($this->is_localized($post_id))
|
300 |
+
return $post_id;
|
301 |
+
|
302 |
+
// Append current language to post id
|
303 |
+
$dl = acf_get_setting('default_language');
|
304 |
+
$cl = acf_get_setting('current_language');
|
305 |
+
|
306 |
+
// Add Language
|
307 |
+
if($cl && $cl !== $dl){
|
308 |
+
|
309 |
+
$post_id .= '_' . $cl;
|
310 |
+
|
311 |
+
}
|
312 |
+
|
313 |
+
return $post_id;
|
314 |
+
|
315 |
+
}
|
316 |
+
|
317 |
+
function is_localized($post_id){
|
318 |
+
|
319 |
+
// Check if post id ends with '-en_US' || '_en_US' || '-en' || '_en'
|
320 |
+
// https://regex101.com/r/oMsyeL/4
|
321 |
+
preg_match('/(?P<locale>[_\-][A-Za-z]{2}_[A-Za-z]{2})$|(?P<code>[_\-][A-Za-z]{2})$/', $post_id, $matches);
|
322 |
+
|
323 |
+
if(empty($matches))
|
324 |
+
return false;
|
325 |
+
|
326 |
+
// Cleanup matches
|
327 |
+
$lang = array();
|
328 |
+
|
329 |
+
foreach($matches as $key => $val){
|
330 |
+
|
331 |
+
if(is_int($key) || empty($val))
|
332 |
+
continue;
|
333 |
+
|
334 |
+
$lang = array(
|
335 |
+
'type' => $key,
|
336 |
+
'lang' => strtolower(substr($val, 1)), // Lowercase + Remove the first '_'
|
337 |
+
);
|
338 |
+
|
339 |
+
}
|
340 |
+
|
341 |
+
if(empty($lang))
|
342 |
+
return false;
|
343 |
+
|
344 |
+
// Get WPML/Polylang Languages List
|
345 |
+
$languages = $this->get_languages($lang['type']);
|
346 |
+
$languages = array_map('strtolower', $languages);
|
347 |
+
|
348 |
+
// Compare Matches vs WPML/Polylang Languages List
|
349 |
+
return in_array($lang['lang'], $languages);
|
350 |
+
|
351 |
+
}
|
352 |
+
|
353 |
+
function is_options_page($post_id){
|
354 |
+
|
355 |
+
// Get Options Pages
|
356 |
+
if($this->options_pages === false){
|
357 |
+
|
358 |
+
// Get ACF Options Pages
|
359 |
+
$options_pages = acf_get_array(acf_get_options_pages());
|
360 |
+
$list = wp_list_pluck($options_pages, 'post_id', true);
|
361 |
+
|
362 |
+
// Add 'Post Types List' location
|
363 |
+
$post_types = acf_get_post_types(array(
|
364 |
+
'show_ui' => 1,
|
365 |
+
'exclude' => array('attachment')
|
366 |
+
));
|
367 |
+
|
368 |
+
if(!empty($post_types)){
|
369 |
+
|
370 |
+
foreach($post_types as $post_type){
|
371 |
+
|
372 |
+
$list[] = $post_type . '_options';
|
373 |
+
|
374 |
+
}
|
375 |
+
|
376 |
+
}
|
377 |
+
|
378 |
+
// Add 'Taxonomy List' location
|
379 |
+
$taxonomies = acf_get_taxonomies();
|
380 |
+
|
381 |
+
if(!empty($taxonomies)){
|
382 |
+
|
383 |
+
foreach($taxonomies as $taxonomy){
|
384 |
+
|
385 |
+
$list[] = 'tax_' . $taxonomy . '_options';
|
386 |
+
|
387 |
+
}
|
388 |
+
|
389 |
+
}
|
390 |
+
|
391 |
+
$list = apply_filters('acfe/modules/multilang/options', $list);
|
392 |
+
|
393 |
+
$this->options_pages = $list;
|
394 |
+
|
395 |
+
}
|
396 |
+
|
397 |
+
if(is_array($this->options_pages) && !empty($this->options_pages)){
|
398 |
+
|
399 |
+
return in_array($post_id, $this->options_pages);
|
400 |
+
|
401 |
+
}
|
402 |
+
|
403 |
+
return false;
|
404 |
+
|
405 |
+
}
|
406 |
+
|
407 |
+
function get_languages($pluck = 'code', $type = 'all', $plugin = false){
|
408 |
+
|
409 |
+
// Polylang
|
410 |
+
if($this->is_polylang || $plugin === 'polylang'){
|
411 |
+
|
412 |
+
return $this->polylang_get_languages($pluck, $type);
|
413 |
+
|
414 |
+
// WPML
|
415 |
+
}elseif($this->is_wpml || $plugin === 'wpml'){
|
416 |
+
|
417 |
+
return $this->wpml_get_languages($pluck, $type);
|
418 |
+
|
419 |
+
}
|
420 |
+
|
421 |
+
return array();
|
422 |
+
|
423 |
+
}
|
424 |
+
|
425 |
+
function options_page_message(){
|
426 |
+
|
427 |
+
$default_language = acf_get_setting('default_language');
|
428 |
+
$current_language = acf_get_setting('current_language');
|
429 |
+
|
430 |
+
$message = false;
|
431 |
+
|
432 |
+
// Polylang
|
433 |
+
if($this->is_polylang){
|
434 |
+
|
435 |
+
if(!$current_language)
|
436 |
+
$current_language = $default_language;
|
437 |
+
|
438 |
+
$message = "Language: {$current_language}";
|
439 |
+
|
440 |
+
$nice_language = false;
|
441 |
+
$nice_flag = false;
|
442 |
+
|
443 |
+
$languages = pll_languages_list(array(
|
444 |
+
'hide_empty' => false,
|
445 |
+
'fields' => false
|
446 |
+
));
|
447 |
+
|
448 |
+
if($languages){
|
449 |
+
|
450 |
+
foreach($languages as $language){
|
451 |
+
|
452 |
+
if($language->locale !== $current_language)
|
453 |
+
continue;
|
454 |
+
|
455 |
+
$nice_language = $language->name;
|
456 |
+
$nice_flag = $language->flag_url;
|
457 |
+
break;
|
458 |
+
|
459 |
+
}
|
460 |
+
|
461 |
+
}
|
462 |
+
|
463 |
+
if($nice_language){
|
464 |
+
|
465 |
+
$message = "<img src='{$nice_flag}' style='margin-right:5px;vertical-align:-1px;' /> Language: {$nice_language}";
|
466 |
+
|
467 |
+
}
|
468 |
+
|
469 |
+
if($default_language === $current_language){
|
470 |
+
|
471 |
+
$message .= ' (Default)';
|
472 |
+
|
473 |
+
}
|
474 |
+
|
475 |
+
}
|
476 |
+
|
477 |
+
// WPML
|
478 |
+
elseif($this->is_wpml){
|
479 |
+
|
480 |
+
if($current_language === 'all')
|
481 |
+
$current_language = 'All';
|
482 |
+
|
483 |
+
$message = "Language: {$current_language}";
|
484 |
+
|
485 |
+
if($current_language !== 'All'){
|
486 |
+
|
487 |
+
$nice_language = false;
|
488 |
+
$nice_flag = false;
|
489 |
+
|
490 |
+
$languages = apply_filters('wpml_active_languages', null, array('skip_missing' => 0));
|
491 |
+
|
492 |
+
if($languages){
|
493 |
+
|
494 |
+
foreach($languages as $language){
|
495 |
+
|
496 |
+
if($language['language_code'] !== $current_language)
|
497 |
+
continue;
|
498 |
+
|
499 |
+
$nice_language = $language['native_name'];
|
500 |
+
$nice_flag = $language['country_flag_url'];
|
501 |
+
break;
|
502 |
+
|
503 |
+
}
|
504 |
+
|
505 |
+
}
|
506 |
+
|
507 |
+
if($nice_language){
|
508 |
+
|
509 |
+
$message = "<img src='{$nice_flag}' style='margin-right:5px;vertical-align:-1px; width:16px; height:11px;' /> Language: {$nice_language}";
|
510 |
+
|
511 |
+
}
|
512 |
+
|
513 |
+
}
|
514 |
+
|
515 |
+
}
|
516 |
+
|
517 |
+
if(empty($message))
|
518 |
+
return;
|
519 |
+
|
520 |
+
echo "<div class='misc-pub-section' style='padding-top:15px; padding-bottom:15px;'>{$message}</div>";
|
521 |
+
|
522 |
+
|
523 |
+
}
|
524 |
+
|
525 |
+
}
|
526 |
+
|
527 |
+
acf_new_instance('acfe_multilang');
|
528 |
+
|
529 |
+
endif;
|
530 |
+
|
531 |
+
function acfe_is_multilang(){
|
532 |
+
|
533 |
+
return acf_get_instance('acfe_multilang')->is_multilang;
|
534 |
+
|
535 |
+
}
|
536 |
+
|
537 |
+
function acfe_get_multilang(){
|
538 |
+
|
539 |
+
$wpml = acf_get_instance('acfe_multilang')->is_wpml;
|
540 |
+
$polylang = acf_get_instance('acfe_multilang')->is_polylang;
|
541 |
+
|
542 |
+
$data = array(
|
543 |
+
'dl' => acf_get_setting('default_language'),
|
544 |
+
'cl' => acf_get_setting('current_language'),
|
545 |
+
'wpml' => $wpml,
|
546 |
+
'polylang' => $polylang,
|
547 |
+
);
|
548 |
+
|
549 |
+
return $data;
|
550 |
+
|
551 |
+
}
|
552 |
+
|
553 |
+
function acfe_get_languages($pluck = 'code', $type = 'all', $plugin = false){
|
554 |
+
|
555 |
+
return acf_get_instance('acfe_multilang')->get_languages($pluck, $type, $plugin);
|
556 |
+
|
557 |
+
}
|
558 |
+
|
559 |
+
function acfe_is_polylang(){
|
560 |
+
|
561 |
+
return acf_get_instance('acfe_multilang')->is_polylang;
|
562 |
+
|
563 |
+
}
|
564 |
+
|
565 |
+
function acfe_is_wpml(){
|
566 |
+
|
567 |
+
return acf_get_instance('acfe_multilang')->is_wpml;
|
568 |
+
|
569 |
+
}
|
570 |
+
|
571 |
+
function acfe_get_post_lang($post_id, $field = false){
|
572 |
+
|
573 |
+
// Bail early if not multilang
|
574 |
+
if(!acfe_is_multilang())
|
575 |
+
return false;
|
576 |
+
|
577 |
+
// Polylang
|
578 |
+
if(acfe_is_polylang()){
|
579 |
+
|
580 |
+
// Default field
|
581 |
+
if(!$field)
|
582 |
+
$field = 'locale';
|
583 |
+
|
584 |
+
return pll_get_post_language($post_id, $field);
|
585 |
+
|
586 |
+
// WPML
|
587 |
+
}elseif(acfe_is_wpml()){
|
588 |
+
|
589 |
+
$post_lang = apply_filters('wpml_post_language_details', NULL, $post_id);
|
590 |
+
|
591 |
+
// Default field
|
592 |
+
if(!$field)
|
593 |
+
$field = 'slug';
|
594 |
+
|
595 |
+
if($field === 'locale'){
|
596 |
+
|
597 |
+
return $post_lang['locale'];
|
598 |
+
|
599 |
+
}elseif($field === 'slug'){
|
600 |
+
|
601 |
+
return $post_lang['language_code'];
|
602 |
+
|
603 |
+
}elseif($field === 'name'){
|
604 |
+
|
605 |
+
return $post_lang['display_name'];
|
606 |
+
|
607 |
+
}
|
608 |
+
|
609 |
+
return false;
|
610 |
+
|
611 |
+
}
|
612 |
+
|
613 |
+
return false;
|
614 |
+
|
615 |
+
}
|
616 |
+
|
617 |
+
function acfe_get_post_translated($post_id, $lang = false){
|
618 |
+
|
619 |
+
// Bail early if not multilang
|
620 |
+
if(!acfe_is_multilang())
|
621 |
+
return $post_id;
|
622 |
+
|
623 |
+
// Default
|
624 |
+
$translated_post_id = $post_id;
|
625 |
+
|
626 |
+
// Polylang
|
627 |
+
if(acfe_is_polylang()){
|
628 |
+
|
629 |
+
$translated_post_id = pll_get_post($post_id, $lang);
|
630 |
+
|
631 |
+
// WPML
|
632 |
+
}elseif(acfe_is_wpml()){
|
633 |
+
|
634 |
+
$translated_post_id = apply_filters('wpml_object_id', $post_id, 'post', false, $lang);
|
635 |
+
|
636 |
+
}
|
637 |
+
|
638 |
+
/*
|
639 |
+
if(empty($translated_post_id))
|
640 |
+
return $post_id;
|
641 |
+
*/
|
642 |
+
|
643 |
+
return $translated_post_id;
|
644 |
+
|
645 |
+
}
|
646 |
+
|
647 |
+
function acfe_get_post_translated_default($post_id){
|
648 |
+
|
649 |
+
// Get translated post id
|
650 |
+
$translated_post_id = acfe_get_post_translated($post_id, acf_get_setting('default_language'));
|
651 |
+
|
652 |
+
// Fallback to current
|
653 |
+
if(empty($translated_post_id))
|
654 |
+
return $post_id;
|
655 |
+
|
656 |
+
return $translated_post_id;
|
657 |
+
|
658 |
+
}
|
659 |
+
|
660 |
+
function acfe__(&$string, $name = false, $textdomain = 'acfe'){
|
661 |
+
|
662 |
+
if(!acfe_is_multilang() || empty($string))
|
663 |
+
return __($string, $textdomain);
|
664 |
+
|
665 |
+
if(empty($name))
|
666 |
+
$name = $string;
|
667 |
+
|
668 |
+
// WPML
|
669 |
+
if(acfe_is_wpml()){
|
670 |
+
|
671 |
+
do_action( 'wpml_register_single_string', $textdomain, $name, $string);
|
672 |
+
|
673 |
+
$string = __($string, $textdomain);
|
674 |
+
|
675 |
+
return $string;
|
676 |
+
|
677 |
+
}
|
678 |
+
|
679 |
+
// PolyLang
|
680 |
+
if(acfe_is_polylang()){
|
681 |
+
|
682 |
+
pll_register_string($name, $string, $textdomain);
|
683 |
+
|
684 |
+
$string = pll__($string);
|
685 |
+
|
686 |
+
return $string;
|
687 |
+
|
688 |
+
}
|
689 |
+
|
690 |
+
$string = __($string, $textdomain);
|
691 |
+
|
692 |
+
return $string;
|
693 |
+
|
694 |
+
}
|
695 |
+
|
696 |
+
function acfe__e($string, $name = false, $textdomain = 'acfe'){
|
697 |
+
|
698 |
+
echo acfe__($string, $name, $textdomain);
|
699 |
+
|
700 |
}
|
@@ -1,503 +1,503 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
acf_register_store('acfe/settings');
|
4 |
-
|
5 |
-
if(!class_exists('acfe_settings')):
|
6 |
-
|
7 |
-
class acfe_settings{
|
8 |
-
|
9 |
-
public $settings = array();
|
10 |
-
|
11 |
-
public $upgrades = array(
|
12 |
-
'0_8_5' => '0.8.5',
|
13 |
-
'0_8_6' => '0.8.6',
|
14 |
-
);
|
15 |
-
|
16 |
-
public $model = array(
|
17 |
-
|
18 |
-
// Version
|
19 |
-
'version' => ACFE_VERSION,
|
20 |
-
|
21 |
-
// Modules
|
22 |
-
'modules' => array(
|
23 |
-
|
24 |
-
'author' => array(
|
25 |
-
'active' => true,
|
26 |
-
),
|
27 |
-
|
28 |
-
'dev' => array(
|
29 |
-
'active' => false,
|
30 |
-
),
|
31 |
-
|
32 |
-
'meta' => array(
|
33 |
-
'active' => false,
|
34 |
-
),
|
35 |
-
|
36 |
-
'option' => array(
|
37 |
-
'active' => true,
|
38 |
-
),
|
39 |
-
|
40 |
-
'ui' => array(
|
41 |
-
'active' => true,
|
42 |
-
),
|
43 |
-
|
44 |
-
'dynamic_block_type' => array(
|
45 |
-
'active' => true,
|
46 |
-
'settings' => array(),
|
47 |
-
'data' => array()
|
48 |
-
),
|
49 |
-
|
50 |
-
'dynamic_form' => array(
|
51 |
-
'active' => true,
|
52 |
-
'settings' => array(),
|
53 |
-
'data' => array()
|
54 |
-
),
|
55 |
-
|
56 |
-
'dynamic_option' => array(
|
57 |
-
'active' => true,
|
58 |
-
'settings' => array(),
|
59 |
-
'data' => array()
|
60 |
-
),
|
61 |
-
|
62 |
-
'dynamic_post_type' => array(
|
63 |
-
'active' => true,
|
64 |
-
'settings' => array(),
|
65 |
-
'data' => array()
|
66 |
-
),
|
67 |
-
|
68 |
-
'dynamic_taxonomy' => array(
|
69 |
-
'active' => true,
|
70 |
-
'settings' => array(),
|
71 |
-
'data' => array()
|
72 |
-
),
|
73 |
-
|
74 |
-
),
|
75 |
-
|
76 |
-
// Upgrades
|
77 |
-
'upgrades' => array(),
|
78 |
-
);
|
79 |
-
|
80 |
-
function __construct(){
|
81 |
-
|
82 |
-
$this->settings = acf_get_store('acfe/settings');
|
83 |
-
|
84 |
-
if(empty($this->settings->get_data())){
|
85 |
-
|
86 |
-
$option = get_option('acfe', array());
|
87 |
-
|
88 |
-
if(!empty($option)){
|
89 |
-
|
90 |
-
$this->settings->set($option);
|
91 |
-
|
92 |
-
$this->version();
|
93 |
-
|
94 |
-
}else{
|
95 |
-
|
96 |
-
$this->reset();
|
97 |
-
|
98 |
-
}
|
99 |
-
|
100 |
-
}
|
101 |
-
|
102 |
-
}
|
103 |
-
|
104 |
-
function get($selector = false){
|
105 |
-
|
106 |
-
return $this->array_get($this->settings->get(), $selector);
|
107 |
-
|
108 |
-
}
|
109 |
-
|
110 |
-
function set($selector = false, $value = null, $update = true, $append = false){
|
111 |
-
|
112 |
-
if($value === null)
|
113 |
-
return false;
|
114 |
-
|
115 |
-
$rows = $this->settings->get();
|
116 |
-
|
117 |
-
if($append){
|
118 |
-
|
119 |
-
$this->array_append($rows, $selector, $value);
|
120 |
-
|
121 |
-
}else{
|
122 |
-
|
123 |
-
$this->array_set($rows, $selector, $value);
|
124 |
-
|
125 |
-
}
|
126 |
-
|
127 |
-
$this->settings->set($rows);
|
128 |
-
|
129 |
-
if($update)
|
130 |
-
$this->update();
|
131 |
-
|
132 |
-
return $this;
|
133 |
-
|
134 |
-
}
|
135 |
-
|
136 |
-
function clear($selector = false, $update = true){
|
137 |
-
|
138 |
-
$rows = $this->settings->get();
|
139 |
-
|
140 |
-
$this->array_clear($rows, $selector);
|
141 |
-
|
142 |
-
$this->settings->set($rows);
|
143 |
-
|
144 |
-
if($update)
|
145 |
-
$this->update();
|
146 |
-
|
147 |
-
return $this;
|
148 |
-
|
149 |
-
}
|
150 |
-
|
151 |
-
function delete($selector = false, $update = true){
|
152 |
-
|
153 |
-
// Single
|
154 |
-
if(strpos($selector, '.') === false){
|
155 |
-
|
156 |
-
$this->settings->remove($selector);
|
157 |
-
|
158 |
-
// Array
|
159 |
-
}else{
|
160 |
-
|
161 |
-
$rows = $this->settings->get();
|
162 |
-
|
163 |
-
$this->array_remove($rows, $selector);
|
164 |
-
|
165 |
-
$this->settings->set($rows);
|
166 |
-
|
167 |
-
}
|
168 |
-
|
169 |
-
if($update)
|
170 |
-
$this->update();
|
171 |
-
|
172 |
-
return $this;
|
173 |
-
|
174 |
-
}
|
175 |
-
|
176 |
-
function append($selector = false, $value = null, $update = true){
|
177 |
-
|
178 |
-
if($selector === false && $value === null)
|
179 |
-
return false;
|
180 |
-
|
181 |
-
// Allow simple append without selector
|
182 |
-
if($value === null){
|
183 |
-
|
184 |
-
$value = $selector;
|
185 |
-
$selector = false;
|
186 |
-
|
187 |
-
}
|
188 |
-
|
189 |
-
return $this->set($selector, $value, $update, true);
|
190 |
-
|
191 |
-
}
|
192 |
-
|
193 |
-
function array_get($array, $key, $default = null) {
|
194 |
-
|
195 |
-
if(empty($key))
|
196 |
-
return $array;
|
197 |
-
|
198 |
-
if(!is_array($key))
|
199 |
-
$key = explode('.', $key);
|
200 |
-
|
201 |
-
$count = count($key);
|
202 |
-
$i=-1;
|
203 |
-
|
204 |
-
foreach($key as $segment){
|
205 |
-
|
206 |
-
$i++;
|
207 |
-
|
208 |
-
if(!isset($array[$segment]))
|
209 |
-
continue;
|
210 |
-
|
211 |
-
if($i+1 === $count){
|
212 |
-
|
213 |
-
return $array[$segment];
|
214 |
-
|
215 |
-
}
|
216 |
-
|
217 |
-
unset($key[$i]);
|
218 |
-
|
219 |
-
return $this->array_get($array[$segment], $key, $default);
|
220 |
-
|
221 |
-
|
222 |
-
}
|
223 |
-
|
224 |
-
return $default;
|
225 |
-
|
226 |
-
}
|
227 |
-
|
228 |
-
function array_set(&$array, $key, $value){
|
229 |
-
|
230 |
-
if(empty($key))
|
231 |
-
return $array = $value;
|
232 |
-
|
233 |
-
$keys = explode('.', $key);
|
234 |
-
|
235 |
-
while(count($keys) > 1){
|
236 |
-
|
237 |
-
$key = array_shift($keys);
|
238 |
-
|
239 |
-
if(!isset($array[$key]) || !is_array($array[$key])){
|
240 |
-
|
241 |
-
$array[$key] = array();
|
242 |
-
|
243 |
-
}
|
244 |
-
|
245 |
-
$array =& $array[$key];
|
246 |
-
|
247 |
-
}
|
248 |
-
|
249 |
-
$array[array_shift($keys)] = $value;
|
250 |
-
|
251 |
-
return $array;
|
252 |
-
|
253 |
-
}
|
254 |
-
|
255 |
-
function array_append(&$array, $key, $value){
|
256 |
-
|
257 |
-
$get = $this->array_get($array, $key);
|
258 |
-
|
259 |
-
$old = acf_get_array($get);
|
260 |
-
$value = acf_get_array($value);
|
261 |
-
|
262 |
-
$value = array_merge($old, $value);
|
263 |
-
|
264 |
-
$this->array_set($array, $key, $value);
|
265 |
-
|
266 |
-
return $array;
|
267 |
-
|
268 |
-
}
|
269 |
-
|
270 |
-
function array_clear(&$array, $key){
|
271 |
-
|
272 |
-
$get = $this->array_get($array, $key);
|
273 |
-
|
274 |
-
if($get === null)
|
275 |
-
return $array;
|
276 |
-
|
277 |
-
$value = null;
|
278 |
-
|
279 |
-
if(is_array($get))
|
280 |
-
$value = array();
|
281 |
-
|
282 |
-
$this->array_set($array, $key, $value);
|
283 |
-
|
284 |
-
return $array;
|
285 |
-
|
286 |
-
}
|
287 |
-
|
288 |
-
function array_remove(&$array, $keys){
|
289 |
-
|
290 |
-
$original =& $array;
|
291 |
-
|
292 |
-
foreach((array)$keys as $key){
|
293 |
-
|
294 |
-
$parts = explode('.', $key);
|
295 |
-
|
296 |
-
while(count($parts) > 1){
|
297 |
-
|
298 |
-
$part = array_shift($parts);
|
299 |
-
|
300 |
-
if(isset($array[$part]) && is_array($array[$part])){
|
301 |
-
|
302 |
-
$array =& $array[$part];
|
303 |
-
|
304 |
-
}
|
305 |
-
|
306 |
-
}
|
307 |
-
|
308 |
-
unset($array[array_shift($parts)]);
|
309 |
-
|
310 |
-
// clean up after each pass
|
311 |
-
$array =& $original;
|
312 |
-
|
313 |
-
}
|
314 |
-
|
315 |
-
}
|
316 |
-
|
317 |
-
function reset(){
|
318 |
-
|
319 |
-
$this->model['upgrades'] = $this->upgrades;
|
320 |
-
|
321 |
-
$this->set('', $this->model, true);
|
322 |
-
|
323 |
-
new acfe_upgrades();
|
324 |
-
|
325 |
-
add_action('init', array($this, 'reset_modules'));
|
326 |
-
|
327 |
-
}
|
328 |
-
|
329 |
-
function reset_modules(){
|
330 |
-
|
331 |
-
// Reset Post Types
|
332 |
-
$post_types = get_posts(array(
|
333 |
-
'post_type' => 'acfe-dpt',
|
334 |
-
'posts_per_page' => -1,
|
335 |
-
'fields' => 'ids'
|
336 |
-
));
|
337 |
-
|
338 |
-
if(!empty($post_types)){
|
339 |
-
|
340 |
-
foreach($post_types as $post_id){
|
341 |
-
|
342 |
-
acfe_dpt_filter_save($post_id);
|
343 |
-
|
344 |
-
acf_log('[ACF Extended] Reset: Dynamic Post Type "' . get_post_field('post_title', $post_id) . '"');
|
345 |
-
|
346 |
-
}
|
347 |
-
|
348 |
-
}
|
349 |
-
|
350 |
-
// Reset Taxonomies
|
351 |
-
$taxonomies = get_posts(array(
|
352 |
-
'post_type' => 'acfe-dt',
|
353 |
-
'posts_per_page' => -1,
|
354 |
-
'fields' => 'ids'
|
355 |
-
));
|
356 |
-
|
357 |
-
if(!empty($taxonomies)){
|
358 |
-
|
359 |
-
foreach($taxonomies as $post_id){
|
360 |
-
|
361 |
-
acfe_dt_filter_save($post_id);
|
362 |
-
|
363 |
-
acf_log('[ACF Extended] Reset: Dynamic Taxonomy "' . get_post_field('post_title', $post_id) . '"');
|
364 |
-
|
365 |
-
}
|
366 |
-
|
367 |
-
}
|
368 |
-
|
369 |
-
// Reset Block Types
|
370 |
-
$block_types = get_posts(array(
|
371 |
-
'post_type' => 'acfe-dbt',
|
372 |
-
'posts_per_page' => -1,
|
373 |
-
'fields' => 'ids'
|
374 |
-
));
|
375 |
-
|
376 |
-
if(!empty($block_types)){
|
377 |
-
|
378 |
-
foreach($block_types as $post_id){
|
379 |
-
|
380 |
-
acfe_dbt_filter_save($post_id);
|
381 |
-
|
382 |
-
acf_log('[ACF Extended] Reset: Dynamic Block Type "' . get_post_field('post_title', $post_id) . '"');
|
383 |
-
|
384 |
-
}
|
385 |
-
|
386 |
-
}
|
387 |
-
|
388 |
-
// Reset Options Pages
|
389 |
-
$options_pages = get_posts(array(
|
390 |
-
'post_type' => 'acfe-dop',
|
391 |
-
'posts_per_page' => -1,
|
392 |
-
'fields' => 'ids'
|
393 |
-
));
|
394 |
-
|
395 |
-
if(!empty($options_pages)){
|
396 |
-
|
397 |
-
foreach($options_pages as $post_id){
|
398 |
-
|
399 |
-
acfe_dop_filter_save($post_id);
|
400 |
-
|
401 |
-
acf_log('[ACF Extended] Reset: Dynamic Options Page "' . get_post_field('post_title', $post_id) . '"');
|
402 |
-
|
403 |
-
}
|
404 |
-
|
405 |
-
}
|
406 |
-
|
407 |
-
}
|
408 |
-
|
409 |
-
function version(){
|
410 |
-
|
411 |
-
$version = $this->get('version');
|
412 |
-
|
413 |
-
if(acf_version_compare($version, '<', ACFE_VERSION)){
|
414 |
-
|
415 |
-
if(!empty($this->upgrades)){
|
416 |
-
|
417 |
-
$do_upgrades = false;
|
418 |
-
|
419 |
-
foreach($this->upgrades as $function => $v){
|
420 |
-
|
421 |
-
if(acf_version_compare($v, '<=', $version))
|
422 |
-
continue;
|
423 |
-
|
424 |
-
$do_upgrades = true;
|
425 |
-
|
426 |
-
$this->model['upgrades'][$function] = true;
|
427 |
-
|
428 |
-
}
|
429 |
-
|
430 |
-
}
|
431 |
-
|
432 |
-
$data = $this->get();
|
433 |
-
$model = $this->model;
|
434 |
-
|
435 |
-
$new_model = $this->parse_args_r($data, $model);
|
436 |
-
|
437 |
-
$new_model['version'] = ACFE_VERSION;
|
438 |
-
|
439 |
-
$this->set('', $new_model, true);
|
440 |
-
|
441 |
-
if($do_upgrades){
|
442 |
-
|
443 |
-
new acfe_upgrades();
|
444 |
-
|
445 |
-
}
|
446 |
-
|
447 |
-
}
|
448 |
-
|
449 |
-
}
|
450 |
-
|
451 |
-
function update(){
|
452 |
-
|
453 |
-
$settings = $this->settings->get();
|
454 |
-
|
455 |
-
update_option('acfe', $settings, 'true');
|
456 |
-
|
457 |
-
}
|
458 |
-
|
459 |
-
function parse_args_r(&$a, $b){
|
460 |
-
|
461 |
-
$a = (array) $a;
|
462 |
-
$b = (array) $b;
|
463 |
-
$r = $b;
|
464 |
-
|
465 |
-
foreach($a as $k => &$v){
|
466 |
-
|
467 |
-
if(is_array($v) && isset($r[ $k ])){
|
468 |
-
$r[$k] = $this->parse_args_r($v, $r[ $k ]);
|
469 |
-
}else{
|
470 |
-
$r[$k] = $v;
|
471 |
-
}
|
472 |
-
|
473 |
-
}
|
474 |
-
|
475 |
-
return $r;
|
476 |
-
|
477 |
-
}
|
478 |
-
|
479 |
-
}
|
480 |
-
|
481 |
-
endif;
|
482 |
-
|
483 |
-
function acfe_settings($selector = null, $value = null, $update = true){
|
484 |
-
|
485 |
-
$instance = acf_get_instance('acfe_settings');
|
486 |
-
|
487 |
-
// Set
|
488 |
-
if($selector !== null && $value !== null){
|
489 |
-
|
490 |
-
return $instance->set($selector, $value, $update);
|
491 |
-
|
492 |
-
}
|
493 |
-
|
494 |
-
// Get
|
495 |
-
elseif($selector !== null && $value === null){
|
496 |
-
|
497 |
-
return $instance->get($selector);
|
498 |
-
|
499 |
-
}
|
500 |
-
|
501 |
-
return $instance;
|
502 |
-
|
503 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
acf_register_store('acfe/settings');
|
4 |
+
|
5 |
+
if(!class_exists('acfe_settings')):
|
6 |
+
|
7 |
+
class acfe_settings{
|
8 |
+
|
9 |
+
public $settings = array();
|
10 |
+
|
11 |
+
public $upgrades = array(
|
12 |
+
'0_8_5' => '0.8.5',
|
13 |
+
'0_8_6' => '0.8.6',
|
14 |
+
);
|
15 |
+
|
16 |
+
public $model = array(
|
17 |
+
|
18 |
+
// Version
|
19 |
+
'version' => ACFE_VERSION,
|
20 |
+
|
21 |
+
// Modules
|
22 |
+
'modules' => array(
|
23 |
+
|
24 |
+
'author' => array(
|
25 |
+
'active' => true,
|
26 |
+
),
|
27 |
+
|
28 |
+
'dev' => array(
|
29 |
+
'active' => false,
|
30 |
+
),
|
31 |
+
|
32 |
+
'meta' => array(
|
33 |
+
'active' => false,
|
34 |
+
),
|
35 |
+
|
36 |
+
'option' => array(
|
37 |
+
'active' => true,
|
38 |
+
),
|
39 |
+
|
40 |
+
'ui' => array(
|
41 |
+
'active' => true,
|
42 |
+
),
|
43 |
+
|
44 |
+
'dynamic_block_type' => array(
|
45 |
+
'active' => true,
|
46 |
+
'settings' => array(),
|
47 |
+
'data' => array()
|
48 |
+
),
|
49 |
+
|
50 |
+
'dynamic_form' => array(
|
51 |
+
'active' => true,
|
52 |
+
'settings' => array(),
|
53 |
+
'data' => array()
|
54 |
+
),
|
55 |
+
|
56 |
+
'dynamic_option' => array(
|
57 |
+
'active' => true,
|
58 |
+
'settings' => array(),
|
59 |
+
'data' => array()
|
60 |
+
),
|
61 |
+
|
62 |
+
'dynamic_post_type' => array(
|
63 |
+
'active' => true,
|
64 |
+
'settings' => array(),
|
65 |
+
'data' => array()
|
66 |
+
),
|
67 |
+
|
68 |
+
'dynamic_taxonomy' => array(
|
69 |
+
'active' => true,
|
70 |
+
'settings' => array(),
|
71 |
+
'data' => array()
|
72 |
+
),
|
73 |
+
|
74 |
+
),
|
75 |
+
|
76 |
+
// Upgrades
|
77 |
+
'upgrades' => array(),
|
78 |
+
);
|
79 |
+
|
80 |
+
function __construct(){
|
81 |
+
|
82 |
+
$this->settings = acf_get_store('acfe/settings');
|
83 |
+
|
84 |
+
if(empty($this->settings->get_data())){
|
85 |
+
|
86 |
+
$option = get_option('acfe', array());
|
87 |
+
|
88 |
+
if(!empty($option)){
|
89 |
+
|
90 |
+
$this->settings->set($option);
|
91 |
+
|
92 |
+
$this->version();
|
93 |
+
|
94 |
+
}else{
|
95 |
+
|
96 |
+
$this->reset();
|
97 |
+
|
98 |
+
}
|
99 |
+
|
100 |
+
}
|
101 |
+
|
102 |
+
}
|
103 |
+
|
104 |
+
function get($selector = false){
|
105 |
+
|
106 |
+
return $this->array_get($this->settings->get(), $selector);
|
107 |
+
|
108 |
+
}
|
109 |
+
|
110 |
+
function set($selector = false, $value = null, $update = true, $append = false){
|
111 |
+
|
112 |
+
if($value === null)
|
113 |
+
return false;
|
114 |
+
|
115 |
+
$rows = $this->settings->get();
|
116 |
+
|
117 |
+
if($append){
|
118 |
+
|
119 |
+
$this->array_append($rows, $selector, $value);
|
120 |
+
|
121 |
+
}else{
|
122 |
+
|
123 |
+
$this->array_set($rows, $selector, $value);
|
124 |
+
|
125 |
+
}
|
126 |
+
|
127 |
+
$this->settings->set($rows);
|
128 |
+
|
129 |
+
if($update)
|
130 |
+
$this->update();
|
131 |
+
|
132 |
+
return $this;
|
133 |
+
|
134 |
+
}
|
135 |
+
|
136 |
+
function clear($selector = false, $update = true){
|
137 |
+
|
138 |
+
$rows = $this->settings->get();
|
139 |
+
|
140 |
+
$this->array_clear($rows, $selector);
|
141 |
+
|
142 |
+
$this->settings->set($rows);
|
143 |
+
|
144 |
+
if($update)
|
145 |
+
$this->update();
|
146 |
+
|
147 |
+
return $this;
|
148 |
+
|
149 |
+
}
|
150 |
+
|
151 |
+
function delete($selector = false, $update = true){
|
152 |
+
|
153 |
+
// Single
|
154 |
+
if(strpos($selector, '.') === false){
|
155 |
+
|
156 |
+
$this->settings->remove($selector);
|
157 |
+
|
158 |
+
// Array
|
159 |
+
}else{
|
160 |
+
|
161 |
+
$rows = $this->settings->get();
|
162 |
+
|
163 |
+
$this->array_remove($rows, $selector);
|
164 |
+
|
165 |
+
$this->settings->set($rows);
|
166 |
+
|
167 |
+
}
|
168 |
+
|
169 |
+
if($update)
|
170 |
+
$this->update();
|
171 |
+
|
172 |
+
return $this;
|
173 |
+
|
174 |
+
}
|
175 |
+
|
176 |
+
function append($selector = false, $value = null, $update = true){
|
177 |
+
|
178 |
+
if($selector === false && $value === null)
|
179 |
+
return false;
|
180 |
+
|
181 |
+
// Allow simple append without selector
|
182 |
+
if($value === null){
|
183 |
+
|
184 |
+
$value = $selector;
|
185 |
+
$selector = false;
|
186 |
+
|
187 |
+
}
|
188 |
+
|
189 |
+
return $this->set($selector, $value, $update, true);
|
190 |
+
|
191 |
+
}
|
192 |
+
|
193 |
+
function array_get($array, $key, $default = null) {
|
194 |
+
|
195 |
+
if(empty($key))
|
196 |
+
return $array;
|
197 |
+
|
198 |
+
if(!is_array($key))
|
199 |
+
$key = explode('.', $key);
|
200 |
+
|
201 |
+
$count = count($key);
|
202 |
+
$i=-1;
|
203 |
+
|
204 |
+
foreach($key as $segment){
|
205 |
+
|
206 |
+
$i++;
|
207 |
+
|
208 |
+
if(!isset($array[$segment]))
|
209 |
+
continue;
|
210 |
+
|
211 |
+
if($i+1 === $count){
|
212 |
+
|
213 |
+
return $array[$segment];
|
214 |
+
|
215 |
+
}
|
216 |
+
|
217 |
+
unset($key[$i]);
|
218 |
+
|
219 |
+
return $this->array_get($array[$segment], $key, $default);
|
220 |
+
|
221 |
+
|
222 |
+
}
|
223 |
+
|
224 |
+
return $default;
|
225 |
+
|
226 |
+
}
|
227 |
+
|
228 |
+
function array_set(&$array, $key, $value){
|
229 |
+
|
230 |
+
if(empty($key))
|
231 |
+
return $array = $value;
|
232 |
+
|
233 |
+
$keys = explode('.', $key);
|
234 |
+
|
235 |
+
while(count($keys) > 1){
|
236 |
+
|
237 |
+
$key = array_shift($keys);
|
238 |
+
|
239 |
+
if(!isset($array[$key]) || !is_array($array[$key])){
|
240 |
+
|
241 |
+
$array[$key] = array();
|
242 |
+
|
243 |
+
}
|
244 |
+
|
245 |
+
$array =& $array[$key];
|
246 |
+
|
247 |
+
}
|
248 |
+
|
249 |
+
$array[array_shift($keys)] = $value;
|
250 |
+
|
251 |
+
return $array;
|
252 |
+
|
253 |
+
}
|
254 |
+
|
255 |
+
function array_append(&$array, $key, $value){
|
256 |
+
|
257 |
+
$get = $this->array_get($array, $key);
|
258 |
+
|
259 |
+
$old = acf_get_array($get);
|
260 |
+
$value = acf_get_array($value);
|
261 |
+
|
262 |
+
$value = array_merge($old, $value);
|
263 |
+
|
264 |
+
$this->array_set($array, $key, $value);
|
265 |
+
|
266 |
+
return $array;
|
267 |
+
|
268 |
+
}
|
269 |
+
|
270 |
+
function array_clear(&$array, $key){
|
271 |
+
|
272 |
+
$get = $this->array_get($array, $key);
|
273 |
+
|
274 |
+
if($get === null)
|
275 |
+
return $array;
|
276 |
+
|
277 |
+
$value = null;
|
278 |
+
|
279 |
+
if(is_array($get))
|
280 |
+
$value = array();
|
281 |
+
|
282 |
+
$this->array_set($array, $key, $value);
|
283 |
+
|
284 |
+
return $array;
|
285 |
+
|
286 |
+
}
|
287 |
+
|
288 |
+
function array_remove(&$array, $keys){
|
289 |
+
|
290 |
+
$original =& $array;
|
291 |
+
|
292 |
+
foreach((array)$keys as $key){
|
293 |
+
|
294 |
+
$parts = explode('.', $key);
|
295 |
+
|
296 |
+
while(count($parts) > 1){
|
297 |
+
|
298 |
+
$part = array_shift($parts);
|
299 |
+
|
300 |
+
if(isset($array[$part]) && is_array($array[$part])){
|
301 |
+
|
302 |
+
$array =& $array[$part];
|
303 |
+
|
304 |
+
}
|
305 |
+
|
306 |
+
}
|
307 |
+
|
308 |
+
unset($array[array_shift($parts)]);
|
309 |
+
|
310 |
+
// clean up after each pass
|
311 |
+
$array =& $original;
|
312 |
+
|
313 |
+
}
|
314 |
+
|
315 |
+
}
|
316 |
+
|
317 |
+
function reset(){
|
318 |
+
|
319 |
+
$this->model['upgrades'] = $this->upgrades;
|
320 |
+
|
321 |
+
$this->set('', $this->model, true);
|
322 |
+
|
323 |
+
new acfe_upgrades();
|
324 |
+
|
325 |
+
add_action('init', array($this, 'reset_modules'));
|
326 |
+
|
327 |
+
}
|
328 |
+
|
329 |
+
function reset_modules(){
|
330 |
+
|
331 |
+
// Reset Post Types
|
332 |
+
$post_types = get_posts(array(
|
333 |
+
'post_type' => 'acfe-dpt',
|
334 |
+
'posts_per_page' => -1,
|
335 |
+
'fields' => 'ids'
|
336 |
+
));
|
337 |
+
|
338 |
+
if(!empty($post_types)){
|
339 |
+
|
340 |
+
foreach($post_types as $post_id){
|
341 |
+
|
342 |
+
acfe_dpt_filter_save($post_id);
|
343 |
+
|
344 |
+
acf_log('[ACF Extended] Reset: Dynamic Post Type "' . get_post_field('post_title', $post_id) . '"');
|
345 |
+
|
346 |
+
}
|
347 |
+
|
348 |
+
}
|
349 |
+
|
350 |
+
// Reset Taxonomies
|
351 |
+
$taxonomies = get_posts(array(
|
352 |
+
'post_type' => 'acfe-dt',
|
353 |
+
'posts_per_page' => -1,
|
354 |
+
'fields' => 'ids'
|
355 |
+
));
|
356 |
+
|
357 |
+
if(!empty($taxonomies)){
|
358 |
+
|
359 |
+
foreach($taxonomies as $post_id){
|
360 |
+
|
361 |
+
acfe_dt_filter_save($post_id);
|
362 |
+
|
363 |
+
acf_log('[ACF Extended] Reset: Dynamic Taxonomy "' . get_post_field('post_title', $post_id) . '"');
|
364 |
+
|
365 |
+
}
|
366 |
+
|
367 |
+
}
|
368 |
+
|
369 |
+
// Reset Block Types
|
370 |
+
$block_types = get_posts(array(
|
371 |
+
'post_type' => 'acfe-dbt',
|
372 |
+
'posts_per_page' => -1,
|
373 |
+
'fields' => 'ids'
|
374 |
+
));
|
375 |
+
|
376 |
+
if(!empty($block_types)){
|
377 |
+
|
378 |
+
foreach($block_types as $post_id){
|
379 |
+
|
380 |
+
acfe_dbt_filter_save($post_id);
|
381 |
+
|
382 |
+
acf_log('[ACF Extended] Reset: Dynamic Block Type "' . get_post_field('post_title', $post_id) . '"');
|
383 |
+
|
384 |
+
}
|
385 |
+
|
386 |
+
}
|
387 |
+
|
388 |
+
// Reset Options Pages
|
389 |
+
$options_pages = get_posts(array(
|
390 |
+
'post_type' => 'acfe-dop',
|
391 |
+
'posts_per_page' => -1,
|
392 |
+
'fields' => 'ids'
|
393 |
+
));
|
394 |
+
|
395 |
+
if(!empty($options_pages)){
|
396 |
+
|
397 |
+
foreach($options_pages as $post_id){
|
398 |
+
|
399 |
+
acfe_dop_filter_save($post_id);
|
400 |
+
|
401 |
+
acf_log('[ACF Extended] Reset: Dynamic Options Page "' . get_post_field('post_title', $post_id) . '"');
|
402 |
+
|
403 |
+
}
|
404 |
+
|
405 |
+
}
|
406 |
+
|
407 |
+
}
|
408 |
+
|
409 |
+
function version(){
|
410 |
+
|
411 |
+
$version = $this->get('version');
|
412 |
+
|
413 |
+
if(acf_version_compare($version, '<', ACFE_VERSION)){
|
414 |
+
|
415 |
+
if(!empty($this->upgrades)){
|
416 |
+
|
417 |
+
$do_upgrades = false;
|
418 |
+
|
419 |
+
foreach($this->upgrades as $function => $v){
|
420 |
+
|
421 |
+
if(acf_version_compare($v, '<=', $version))
|
422 |
+
continue;
|
423 |
+
|
424 |
+
$do_upgrades = true;
|
425 |
+
|
426 |
+
$this->model['upgrades'][$function] = true;
|
427 |
+
|
428 |
+
}
|
429 |
+
|
430 |
+
}
|
431 |
+
|
432 |
+
$data = $this->get();
|
433 |
+
$model = $this->model;
|
434 |
+
|
435 |
+
$new_model = $this->parse_args_r($data, $model);
|
436 |
+
|
437 |
+
$new_model['version'] = ACFE_VERSION;
|
438 |
+
|
439 |
+
$this->set('', $new_model, true);
|
440 |
+
|
441 |
+
if($do_upgrades){
|
442 |
+
|
443 |
+
new acfe_upgrades();
|
444 |
+
|
445 |
+
}
|
446 |
+
|
447 |
+
}
|
448 |
+
|
449 |
+
}
|
450 |
+
|
451 |
+
function update(){
|
452 |
+
|
453 |
+
$settings = $this->settings->get();
|
454 |
+
|
455 |
+
update_option('acfe', $settings, 'true');
|
456 |
+
|
457 |
+
}
|
458 |
+
|
459 |
+
function parse_args_r(&$a, $b){
|
460 |
+
|
461 |
+
$a = (array) $a;
|
462 |
+
$b = (array) $b;
|
463 |
+
$r = $b;
|
464 |
+
|
465 |
+
foreach($a as $k => &$v){
|
466 |
+
|
467 |
+
if(is_array($v) && isset($r[ $k ])){
|
468 |
+
$r[$k] = $this->parse_args_r($v, $r[ $k ]);
|
469 |
+
}else{
|
470 |
+
$r[$k] = $v;
|
471 |
+
}
|
472 |
+
|
473 |
+
}
|
474 |
+
|
475 |
+
return $r;
|
476 |
+
|
477 |
+
}
|
478 |
+
|
479 |
+
}
|
480 |
+
|
481 |
+
endif;
|
482 |
+
|
483 |
+
function acfe_settings($selector = null, $value = null, $update = true){
|
484 |
+
|
485 |
+
$instance = acf_get_instance('acfe_settings');
|
486 |
+
|
487 |
+
// Set
|
488 |
+
if($selector !== null && $value !== null){
|
489 |
+
|
490 |
+
return $instance->set($selector, $value, $update);
|
491 |
+
|
492 |
+
}
|
493 |
+
|
494 |
+
// Get
|
495 |
+
elseif($selector !== null && $value === null){
|
496 |
+
|
497 |
+
return $instance->get($selector);
|
498 |
+
|
499 |
+
}
|
500 |
+
|
501 |
+
return $instance;
|
502 |
+
|
503 |
}
|
@@ -1,655 +1,655 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!class_exists('acfe_upgrades')):
|
4 |
-
|
5 |
-
class acfe_upgrades{
|
6 |
-
|
7 |
-
function __construct(){
|
8 |
-
|
9 |
-
$upgrades = acfe_settings('upgrades');
|
10 |
-
|
11 |
-
if(empty($upgrades))
|
12 |
-
return;
|
13 |
-
|
14 |
-
// ACF Extended: 0.8.5
|
15 |
-
add_action('acf/init', array($this, 'upgrade_0_8_5'), 999);
|
16 |
-
|
17 |
-
// ACF Extended: 0.8.6
|
18 |
-
add_action('acf/init', array($this, 'upgrade_0_8_6'), 999);
|
19 |
-
|
20 |
-
}
|
21 |
-
|
22 |
-
function upgrade_0_8_6(){
|
23 |
-
|
24 |
-
$todo = acfe_settings('upgrades.0_8_6');
|
25 |
-
|
26 |
-
if(!$todo)
|
27 |
-
return;
|
28 |
-
|
29 |
-
acf_log('[ACF Extended] 0.8.6 Upgrade: Dynamic Options Pages');
|
30 |
-
|
31 |
-
$get_options = get_posts(array(
|
32 |
-
'post_type' => 'acfe-dop',
|
33 |
-
'posts_per_page' => -1,
|
34 |
-
'fields' => 'ids'
|
35 |
-
));
|
36 |
-
|
37 |
-
if(!empty($get_options)){
|
38 |
-
|
39 |
-
foreach($get_options as $post_id){
|
40 |
-
|
41 |
-
$menu_slug = get_field('menu_slug', $post_id);
|
42 |
-
$acfe_dop_name = get_field('acfe_dop_name', $post_id);
|
43 |
-
$post_name = get_post_field('post_name', $post_id);
|
44 |
-
|
45 |
-
// Update empty 'menu_slug' fields in options pages
|
46 |
-
if(empty($menu_slug)){
|
47 |
-
|
48 |
-
// Page Title
|
49 |
-
$page_title = get_post_field('post_title', $post_id);
|
50 |
-
|
51 |
-
// Menu Title
|
52 |
-
$menu_title = get_field('menu_title', $post_id);
|
53 |
-
|
54 |
-
if(empty($menu_title)){
|
55 |
-
|
56 |
-
$menu_title = $page_title;
|
57 |
-
|
58 |
-
}
|
59 |
-
|
60 |
-
// Menu Slug
|
61 |
-
$menu_slug = sanitize_title($menu_title);
|
62 |
-
|
63 |
-
// Update field
|
64 |
-
update_field('menu_slug', $menu_slug, $post_id);
|
65 |
-
|
66 |
-
}
|
67 |
-
|
68 |
-
// Upgrade old name to menu_slug
|
69 |
-
if($acfe_dop_name === $post_name){
|
70 |
-
|
71 |
-
// Get ACFE option
|
72 |
-
$option = acfe_settings('modules.dynamic_option.data');
|
73 |
-
|
74 |
-
// Check ACFE option
|
75 |
-
if(isset($option[$acfe_dop_name])){
|
76 |
-
|
77 |
-
$register_args = $option[$acfe_dop_name];
|
78 |
-
|
79 |
-
// Delete old option page slug
|
80 |
-
unset($option[$acfe_dop_name]);
|
81 |
-
|
82 |
-
// Re-assign to menu_slug
|
83 |
-
$option[$menu_slug] = $register_args;
|
84 |
-
|
85 |
-
// Sort keys ASC
|
86 |
-
ksort($option);
|
87 |
-
|
88 |
-
// Update ACFE option
|
89 |
-
acfe_settings('modules.dynamic_option.data', $option, true);
|
90 |
-
|
91 |
-
// Update post: force menu slug as name
|
92 |
-
wp_update_post(array(
|
93 |
-
'ID' => $post_id,
|
94 |
-
'post_name' => $menu_slug,
|
95 |
-
));
|
96 |
-
|
97 |
-
}
|
98 |
-
|
99 |
-
}
|
100 |
-
|
101 |
-
}
|
102 |
-
|
103 |
-
}
|
104 |
-
|
105 |
-
// Done
|
106 |
-
acfe_settings()->delete('upgrades.0_8_6');
|
107 |
-
|
108 |
-
acf_log('[ACF Extended] 0.8.6 Upgrade: Done');
|
109 |
-
|
110 |
-
}
|
111 |
-
|
112 |
-
function upgrade_0_8_5(){
|
113 |
-
|
114 |
-
$todo = acfe_settings('upgrades.0_8_5');
|
115 |
-
|
116 |
-
if(!$todo)
|
117 |
-
return;
|
118 |
-
|
119 |
-
$tasks = array(
|
120 |
-
'dynamic_form',
|
121 |
-
'dynamic_post_type',
|
122 |
-
'dynamic_taxonomy',
|
123 |
-
'dynamic_block_type',
|
124 |
-
'dynamic_option',
|
125 |
-
);
|
126 |
-
|
127 |
-
foreach($tasks as $task){
|
128 |
-
|
129 |
-
/*
|
130 |
-
* Forms
|
131 |
-
*/
|
132 |
-
if($task === 'dynamic_form'){
|
133 |
-
|
134 |
-
acf_log('[ACF Extended] 0.8.5 Upgrade: Dynamic Forms');
|
135 |
-
|
136 |
-
// Retrieve all forms posts
|
137 |
-
$get_forms = get_posts(array(
|
138 |
-
'post_type' => 'acfe-form',
|
139 |
-
'posts_per_page' => -1,
|
140 |
-
'fields' => 'ids',
|
141 |
-
'post_status' => 'any'
|
142 |
-
));
|
143 |
-
|
144 |
-
// Bail early if no form found
|
145 |
-
if(empty($get_forms)){
|
146 |
-
|
147 |
-
// Upgrade done
|
148 |
-
continue;
|
149 |
-
|
150 |
-
}
|
151 |
-
|
152 |
-
$flexible = acf_get_field_type('flexible_content');
|
153 |
-
$field = acf_get_field('acfe_form_actions');
|
154 |
-
|
155 |
-
global $wpdb;
|
156 |
-
|
157 |
-
foreach($get_forms as $post_id){
|
158 |
-
|
159 |
-
// init
|
160 |
-
$wp_meta = array();
|
161 |
-
$acf_meta = array();
|
162 |
-
|
163 |
-
// Retrieve meta
|
164 |
-
$get_meta = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->postmeta WHERE post_id = %d ", $post_id));
|
165 |
-
|
166 |
-
// Sort
|
167 |
-
usort($get_meta, function($a, $b){
|
168 |
-
return strcmp($a->meta_key, $b->meta_key);
|
169 |
-
});
|
170 |
-
|
171 |
-
// Store
|
172 |
-
foreach($get_meta as $meta){
|
173 |
-
|
174 |
-
$wp_meta[$meta->meta_key] = $meta->meta_value;
|
175 |
-
|
176 |
-
}
|
177 |
-
|
178 |
-
// Check if is acf meta
|
179 |
-
foreach($wp_meta as $key => $value){
|
180 |
-
|
181 |
-
// ACF Meta
|
182 |
-
if(isset($wp_meta["_$key"])){
|
183 |
-
|
184 |
-
$acf_meta[] = array(
|
185 |
-
'key' => $key,
|
186 |
-
'value' => $wp_meta[$key],
|
187 |
-
);
|
188 |
-
|
189 |
-
}
|
190 |
-
|
191 |
-
}
|
192 |
-
|
193 |
-
/*
|
194 |
-
* Step 1: Upgrade old group fields
|
195 |
-
*/
|
196 |
-
$prefix = 'acfe_form_actions';
|
197 |
-
|
198 |
-
// Define script rules
|
199 |
-
$rules = array(
|
200 |
-
|
201 |
-
// Post: title
|
202 |
-
array(
|
203 |
-
'group' => 'acfe_form_post_save_post_title_group',
|
204 |
-
'sub_field' => 'acfe_form_post_save_post_title_group_acfe_form_post_save_post_title',
|
205 |
-
'sub_field_custom' => 'acfe_form_post_save_post_title_group_acfe_form_post_save_post_title_custom',
|
206 |
-
'new_field' => 'acfe_form_post_save_post_title',
|
207 |
-
),
|
208 |
-
|
209 |
-
// Post: name
|
210 |
-
array(
|
211 |
-
'group' => 'acfe_form_post_save_post_name_group',
|
212 |
-
'sub_field' => 'acfe_form_post_save_post_name_group_acfe_form_post_save_post_name',
|
213 |
-
'sub_field_custom' => 'acfe_form_post_save_post_name_group_acfe_form_post_save_post_name_custom',
|
214 |
-
'new_field' => 'acfe_form_post_save_post_name',
|
215 |
-
),
|
216 |
-
|
217 |
-
// Term: name
|
218 |
-
array(
|
219 |
-
'group' => 'acfe_form_term_save_name_group',
|
220 |
-
'sub_field' => 'acfe_form_term_save_name_group_acfe_form_term_save_name',
|
221 |
-
'sub_field_custom' => 'acfe_form_term_save_name_group_acfe_form_term_save_name_custom',
|
222 |
-
'new_field' => 'acfe_form_term_save_name',
|
223 |
-
),
|
224 |
-
|
225 |
-
// Term: slug
|
226 |
-
array(
|
227 |
-
'group' => 'acfe_form_term_save_slug_group',
|
228 |
-
'sub_field' => 'acfe_form_term_save_slug_group_acfe_form_term_save_slug',
|
229 |
-
'sub_field_custom' => 'acfe_form_term_save_slug_group_acfe_form_term_save_slug_custom',
|
230 |
-
'new_field' => 'acfe_form_term_save_slug',
|
231 |
-
),
|
232 |
-
|
233 |
-
// User: e-mail
|
234 |
-
array(
|
235 |
-
'group' => 'acfe_form_user_save_email_group',
|
236 |
-
'sub_field' => 'acfe_form_user_save_email_group_acfe_form_user_save_email',
|
237 |
-
'sub_field_custom' => 'acfe_form_user_save_email_group_acfe_form_user_save_email_custom',
|
238 |
-
'new_field' => 'acfe_form_user_save_email',
|
239 |
-
),
|
240 |
-
|
241 |
-
// User: username
|
242 |
-
array(
|
243 |
-
'group' => 'acfe_form_user_save_username_group',
|
244 |
-
'sub_field' => 'acfe_form_user_save_username_group_acfe_form_user_save_username',
|
245 |
-
'sub_field_custom' => 'acfe_form_user_save_username_group_acfe_form_user_save_username_custom',
|
246 |
-
'new_field' => 'acfe_form_user_save_username',
|
247 |
-
),
|
248 |
-
|
249 |
-
// User: password
|
250 |
-
array(
|
251 |
-
'group' => 'acfe_form_user_save_password_group',
|
252 |
-
'sub_field' => 'acfe_form_user_save_password_group_acfe_form_user_save_password',
|
253 |
-
'sub_field_custom' => 'acfe_form_user_save_password_group_acfe_form_user_save_password_custom',
|
254 |
-
'new_field' => 'acfe_form_user_save_password',
|
255 |
-
),
|
256 |
-
|
257 |
-
// User: first name
|
258 |
-
array(
|
259 |
-
'group' => 'acfe_form_user_save_first_name_group',
|
260 |
-
'sub_field' => 'acfe_form_user_save_first_name_group_acfe_form_user_save_first_name',
|
261 |
-
'sub_field_custom' => 'acfe_form_user_save_first_name_group_acfe_form_user_save_first_name_custom',
|
262 |
-
'new_field' => 'acfe_form_user_save_first_name',
|
263 |
-
),
|
264 |
-
|
265 |
-
// User: last name
|
266 |
-
array(
|
267 |
-
'group' => 'acfe_form_user_save_last_name_group',
|
268 |
-
'sub_field' => 'acfe_form_user_save_last_name_group_acfe_form_user_save_last_name',
|
269 |
-
'sub_field_custom' => 'acfe_form_user_save_last_name_group_acfe_form_user_save_last_name_custom',
|
270 |
-
'new_field' => 'acfe_form_user_save_last_name',
|
271 |
-
),
|
272 |
-
|
273 |
-
// User: nickname
|
274 |
-
array(
|
275 |
-
'group' => 'acfe_form_user_save_nickname_group',
|
276 |
-
'sub_field' => 'acfe_form_user_save_nickname_group_acfe_form_user_save_nickname',
|
277 |
-
'sub_field_custom' => 'acfe_form_user_save_nickname_group_acfe_form_user_save_nickname_custom',
|
278 |
-
'new_field' => 'acfe_form_user_save_nickname',
|
279 |
-
),
|
280 |
-
|
281 |
-
// User: display name
|
282 |
-
array(
|
283 |
-
'group' => 'acfe_form_user_save_display_name_group',
|
284 |
-
'sub_field' => 'acfe_form_user_save_display_name_group_acfe_form_user_save_display_name',
|
285 |
-
'sub_field_custom' => 'acfe_form_user_save_display_name_group_acfe_form_user_save_display_name_custom',
|
286 |
-
'new_field' => 'acfe_form_user_save_display_name',
|
287 |
-
),
|
288 |
-
|
289 |
-
// User: website
|
290 |
-
array(
|
291 |
-
'group' => 'acfe_form_user_save_website_group',
|
292 |
-
'sub_field' => 'acfe_form_user_save_website_group_acfe_form_user_save_website',
|
293 |
-
'sub_field_custom' => 'acfe_form_user_save_website_group_acfe_form_user_save_website_custom',
|
294 |
-
'new_field' => 'acfe_form_user_save_website',
|
295 |
-
),
|
296 |
-
|
297 |
-
);
|
298 |
-
|
299 |
-
// Process rules
|
300 |
-
foreach($rules as $rule){
|
301 |
-
|
302 |
-
$updates = array();
|
303 |
-
|
304 |
-
foreach($acf_meta as $acf){
|
305 |
-
|
306 |
-
// Bail early if doesn't starts with 'acfe_form_actions'
|
307 |
-
if(strpos($acf['key'], $prefix) !== 0)
|
308 |
-
continue;
|
309 |
-
|
310 |
-
// Regex: 'acfe_form_actions_2_acfe_form_post_save_post_title_group'
|
311 |
-
// Match: '2'
|
312 |
-
if(preg_match('/^' . $prefix . '_([0-9]+)_' . $rule['group'] . '$/', $acf['key'], $match)){
|
313 |
-
|
314 |
-
$updates[$rule['new_field']][$match[1]]['group'] = array(
|
315 |
-
'key' => $acf['key'],
|
316 |
-
'value' => $acf['value'],
|
317 |
-
);
|
318 |
-
|
319 |
-
// Regex: 'acfe_form_post_2_save_post_title_group_acfe_form_post_save_post_title'
|
320 |
-
// Match: '2'
|
321 |
-
}elseif(preg_match('/^' . $prefix . '_([0-9]+)_' . $rule['sub_field'] . '$/', $acf['key'], $match)){
|
322 |
-
|
323 |
-
$updates[$rule['new_field']][$match[1]]['sub_field'] = array(
|
324 |
-
'key' => $acf['key'],
|
325 |
-
'value' => $acf['value'],
|
326 |
-
);
|
327 |
-
|
328 |
-
// Regex: 'acfe_form_post_2_save_post_title_group_acfe_form_post_save_post_title_custom'
|
329 |
-
// Match: '2'
|
330 |
-
}elseif(preg_match('/^' . $prefix . '_([0-9]+)_' . $rule['sub_field_custom'] . '$/', $acf['key'], $match)){
|
331 |
-
|
332 |
-
// Generate: array[acfe_form_post_save_post_title][2]['sub_field_custom']
|
333 |
-
$updates[$rule['new_field']][$match[1]]['sub_field_custom'] = array(
|
334 |
-
'key' => $acf['key'],
|
335 |
-
'value' => $acf['value'],
|
336 |
-
);
|
337 |
-
|
338 |
-
}
|
339 |
-
|
340 |
-
}
|
341 |
-
|
342 |
-
if(!empty($updates)){
|
343 |
-
|
344 |
-
// Update meta
|
345 |
-
foreach($updates as $new_field => $data){
|
346 |
-
|
347 |
-
foreach($data as $i => $row){
|
348 |
-
|
349 |
-
$group = acf_maybe_get($row, 'group');
|
350 |
-
$sub_field = acf_maybe_get($row, 'sub_field');
|
351 |
-
$sub_field_custom = acf_maybe_get($row, 'sub_field_custom');
|
352 |
-
|
353 |
-
if($sub_field){
|
354 |
-
|
355 |
-
$new_field_name = "{$prefix}_{$i}_{$new_field}";
|
356 |
-
|
357 |
-
// update field
|
358 |
-
if($sub_field['value'] === 'custom'){
|
359 |
-
|
360 |
-
update_post_meta($post_id, $new_field_name, $sub_field_custom['value']);
|
361 |
-
|
362 |
-
}else{
|
363 |
-
|
364 |
-
update_post_meta($post_id, $new_field_name, $sub_field['value']);
|
365 |
-
|
366 |
-
}
|
367 |
-
|
368 |
-
// update reference
|
369 |
-
update_post_meta($post_id, '_' . $new_field_name, 'field_' . $new_field);
|
370 |
-
|
371 |
-
}
|
372 |
-
|
373 |
-
// Delete old group
|
374 |
-
delete_post_meta($post_id, $group['key']);
|
375 |
-
delete_post_meta($post_id, $sub_field['key']);
|
376 |
-
delete_post_meta($post_id, $sub_field_custom['key']);
|
377 |
-
|
378 |
-
}
|
379 |
-
|
380 |
-
}
|
381 |
-
|
382 |
-
}
|
383 |
-
|
384 |
-
}
|
385 |
-
|
386 |
-
/*
|
387 |
-
* Step 2: Upgrade map fields which now require "Load values" to be enabled
|
388 |
-
*/
|
389 |
-
if(have_rows('acfe_form_actions', $post_id)):
|
390 |
-
while(have_rows('acfe_form_actions', $post_id)): the_row();
|
391 |
-
|
392 |
-
$layout = get_row_layout();
|
393 |
-
$row = get_row_index();
|
394 |
-
$i = $row-1;
|
395 |
-
|
396 |
-
// Post Action
|
397 |
-
if($layout === 'post'){
|
398 |
-
|
399 |
-
$load_values = get_sub_field('acfe_form_post_load_values');
|
400 |
-
|
401 |
-
$fields = array(
|
402 |
-
'field_acfe_form_post_save_post_type' => get_sub_field('acfe_form_post_map_post_type', false),
|
403 |
-
'field_acfe_form_post_save_post_status' => get_sub_field('acfe_form_post_map_post_status', false),
|
404 |
-
'field_acfe_form_post_save_post_title' => get_sub_field('acfe_form_post_map_post_title', false),
|
405 |
-
'field_acfe_form_post_save_post_name' => get_sub_field('acfe_form_post_map_post_name', false),
|
406 |
-
'field_acfe_form_post_save_post_content' => get_sub_field('acfe_form_post_map_post_content', false),
|
407 |
-
'field_acfe_form_post_save_post_author' => get_sub_field('acfe_form_post_map_post_author', false),
|
408 |
-
'field_acfe_form_post_save_post_parent' => get_sub_field('acfe_form_post_map_post_parent', false),
|
409 |
-
'field_acfe_form_post_save_post_terms' => get_sub_field('acfe_form_post_map_post_terms', false),
|
410 |
-
);
|
411 |
-
|
412 |
-
if(!$load_values){
|
413 |
-
|
414 |
-
foreach($fields as $field_key => $field_value){
|
415 |
-
|
416 |
-
// Bail early if map field has no value
|
417 |
-
if(empty($field_value))
|
418 |
-
continue;
|
419 |
-
|
420 |
-
// args
|
421 |
-
$update = array();
|
422 |
-
$update['acf_fc_layout'] = $layout;
|
423 |
-
|
424 |
-
// Post content inside group
|
425 |
-
if($field_key === 'field_acfe_form_post_save_post_content'){
|
426 |
-
|
427 |
-
$update['field_acfe_form_post_save_post_content_group'] = array(
|
428 |
-
'field_acfe_form_post_save_post_content' => $field_value
|
429 |
-
);
|
430 |
-
|
431 |
-
}else{
|
432 |
-
|
433 |
-
$update[$field_key] = $field_value;
|
434 |
-
|
435 |
-
}
|
436 |
-
|
437 |
-
// update
|
438 |
-
$flexible->update_row($update, $i, $field, $post_id);
|
439 |
-
|
440 |
-
}
|
441 |
-
|
442 |
-
}
|
443 |
-
|
444 |
-
}
|
445 |
-
|
446 |
-
// Term Action
|
447 |
-
elseif($layout === 'term'){
|
448 |
-
|
449 |
-
$load_values = get_sub_field('acfe_form_term_load_values');
|
450 |
-
|
451 |
-
$fields = array(
|
452 |
-
'field_acfe_form_term_save_name' => get_sub_field('acfe_form_term_map_name', false),
|
453 |
-
'field_acfe_form_term_save_slug' => get_sub_field('acfe_form_term_map_slug', false),
|
454 |
-
'field_acfe_form_term_save_taxonomy' => get_sub_field('acfe_form_term_map_taxonomy', false),
|
455 |
-
'field_acfe_form_term_save_parent' => get_sub_field('acfe_form_term_map_parent', false),
|
456 |
-
'field_acfe_form_term_save_description' => get_sub_field('acfe_form_term_map_description', false),
|
457 |
-
);
|
458 |
-
|
459 |
-
if(!$load_values){
|
460 |
-
|
461 |
-
foreach($fields as $field_key => $field_value){
|
462 |
-
|
463 |
-
// Bail early if map field has no value
|
464 |
-
if(empty($field_value))
|
465 |
-
continue;
|
466 |
-
|
467 |
-
// args
|
468 |
-
$update = array();
|
469 |
-
$update['acf_fc_layout'] = $layout;
|
470 |
-
|
471 |
-
// Post content inside group
|
472 |
-
if($field_key === 'field_acfe_form_term_save_description'){
|
473 |
-
|
474 |
-
$update['field_acfe_form_term_save_description_group'] = array(
|
475 |
-
'field_acfe_form_term_save_description' => $field_value
|
476 |
-
);
|
477 |
-
|
478 |
-
}else{
|
479 |
-
|
480 |
-
$update[$field_key] = $field_value;
|
481 |
-
|
482 |
-
}
|
483 |
-
|
484 |
-
// update
|
485 |
-
$flexible->update_row($update, $i, $field, $post_id);
|
486 |
-
|
487 |
-
}
|
488 |
-
|
489 |
-
}
|
490 |
-
|
491 |
-
}
|
492 |
-
|
493 |
-
// User Action
|
494 |
-
elseif($layout === 'user'){
|
495 |
-
|
496 |
-
$load_values = get_sub_field('acfe_form_user_load_values');
|
497 |
-
|
498 |
-
$fields = array(
|
499 |
-
'field_acfe_form_user_save_email' => get_sub_field('acfe_form_user_map_email', false),
|
500 |
-
'field_acfe_form_user_save_username' => get_sub_field('acfe_form_user_map_username', false),
|
501 |
-
'field_acfe_form_user_save_password' => get_sub_field('acfe_form_user_map_password', false),
|
502 |
-
'field_acfe_form_user_save_first_name' => get_sub_field('acfe_form_user_map_first_name', false),
|
503 |
-
'field_acfe_form_user_save_last_name' => get_sub_field('acfe_form_user_map_last_name', false),
|
504 |
-
'field_acfe_form_user_save_nickname' => get_sub_field('acfe_form_user_map_nickname', false),
|
505 |
-
'field_acfe_form_user_save_display_name' => get_sub_field('acfe_form_user_map_display_name', false),
|
506 |
-
'field_acfe_form_user_save_website' => get_sub_field('acfe_form_user_map_website', false),
|
507 |
-
'field_acfe_form_user_save_description' => get_sub_field('acfe_form_user_map_description', false),
|
508 |
-
'field_acfe_form_user_save_role' => get_sub_field('acfe_form_user_map_role', false),
|
509 |
-
);
|
510 |
-
|
511 |
-
if(!$load_values){
|
512 |
-
|
513 |
-
foreach($fields as $field_key => $field_value){
|
514 |
-
|
515 |
-
// Bail early if map field has no value
|
516 |
-
if(empty($field_value))
|
517 |
-
continue;
|
518 |
-
|
519 |
-
// args
|
520 |
-
$update = array();
|
521 |
-
$update['acf_fc_layout'] = $layout;
|
522 |
-
|
523 |
-
// Post content inside group
|
524 |
-
if($field_key === 'field_acfe_form_user_save_description'){
|
525 |
-
|
526 |
-
$update['field_acfe_form_user_save_description_group'] = array(
|
527 |
-
'field_acfe_form_user_save_description' => $field_value
|
528 |
-
);
|
529 |
-
|
530 |
-
}else{
|
531 |
-
|
532 |
-
$update[$field_key] = $field_value;
|
533 |
-
|
534 |
-
}
|
535 |
-
|
536 |
-
// update
|
537 |
-
$flexible->update_row($update, $i, $field, $post_id);
|
538 |
-
|
539 |
-
}
|
540 |
-
|
541 |
-
}
|
542 |
-
|
543 |
-
}
|
544 |
-
|
545 |
-
endwhile;
|
546 |
-
endif;
|
547 |
-
|
548 |
-
}
|
549 |
-
|
550 |
-
}
|
551 |
-
|
552 |
-
/*
|
553 |
-
* Post Types
|
554 |
-
*/
|
555 |
-
elseif($task === 'dynamic_post_type'){
|
556 |
-
|
557 |
-
acf_log('[ACF Extended] 0.8.5 Upgrade: Dynamic Post Types');
|
558 |
-
|
559 |
-
// Old Post Types
|
560 |
-
$old_post_types = get_option('acfe_dynamic_post_types', array());
|
561 |
-
|
562 |
-
// New Post Types
|
563 |
-
$new_post_types = acfe_settings('modules.dynamic_post_type.data');
|
564 |
-
|
565 |
-
$merged_post_types = array_merge($old_post_types, $new_post_types);
|
566 |
-
|
567 |
-
// Update Post Types
|
568 |
-
acfe_settings('modules.dynamic_post_type.data', $merged_post_types, true);
|
569 |
-
|
570 |
-
// Delete Old Post Types
|
571 |
-
delete_option('acfe_dynamic_post_types');
|
572 |
-
|
573 |
-
}
|
574 |
-
|
575 |
-
/*
|
576 |
-
* Taxonomies
|
577 |
-
*/
|
578 |
-
elseif($task === 'dynamic_taxonomy'){
|
579 |
-
|
580 |
-
acf_log('[ACF Extended] 0.8.5 Upgrade: Dynamic Taxonomies');
|
581 |
-
|
582 |
-
// Old Taxonomies
|
583 |
-
$old_taxonomies = get_option('acfe_dynamic_taxonomies', array());
|
584 |
-
|
585 |
-
// New Taxonomies
|
586 |
-
$new_taxonomies = acfe_settings('modules.dynamic_taxonomy.data');
|
587 |
-
|
588 |
-
$merged_taxonomies = array_merge($old_taxonomies, $new_taxonomies);
|
589 |
-
|
590 |
-
// Update Taxonomies
|
591 |
-
acfe_settings('modules.dynamic_taxonomy.data', $merged_taxonomies, true);
|
592 |
-
|
593 |
-
// Delete Old Taxonomies
|
594 |
-
delete_option('acfe_dynamic_taxonomies');
|
595 |
-
|
596 |
-
}
|
597 |
-
|
598 |
-
/*
|
599 |
-
* Block Types
|
600 |
-
*/
|
601 |
-
elseif($task === 'dynamic_block_type'){
|
602 |
-
|
603 |
-
acf_log('[ACF Extended] 0.8.5 Upgrade: Dynamic Block Types');
|
604 |
-
|
605 |
-
// Old Block Types
|
606 |
-
$old_block_types = get_option('acfe_dynamic_block_types', array());
|
607 |
-
|
608 |
-
// New Block Types
|
609 |
-
$new_block_types = acfe_settings('modules.dynamic_block_type.data');
|
610 |
-
|
611 |
-
$merged_block_types = array_merge($old_block_types, $new_block_types);
|
612 |
-
|
613 |
-
// Update Block Types
|
614 |
-
acfe_settings('modules.dynamic_block_type.data', $merged_block_types, true);
|
615 |
-
|
616 |
-
// Delete Old Block Types
|
617 |
-
delete_option('acfe_dynamic_block_types');
|
618 |
-
|
619 |
-
}
|
620 |
-
|
621 |
-
/*
|
622 |
-
* Option Pages
|
623 |
-
*/
|
624 |
-
elseif($task === 'dynamic_option'){
|
625 |
-
|
626 |
-
acf_log('[ACF Extended] 0.8.5 Upgrade: Dynamic Options Pages');
|
627 |
-
|
628 |
-
// Old Options
|
629 |
-
$old_options = get_option('acfe_dynamic_options_pages', array());
|
630 |
-
|
631 |
-
// New Options
|
632 |
-
$new_options = acfe_settings('modules.dynamic_option.data');
|
633 |
-
|
634 |
-
$merged_options = array_merge($old_options, $new_options);
|
635 |
-
|
636 |
-
// Update Options
|
637 |
-
acfe_settings('modules.dynamic_option.data', $merged_options, true);
|
638 |
-
|
639 |
-
// Delete Old Options
|
640 |
-
delete_option('acfe_dynamic_options_pages');
|
641 |
-
|
642 |
-
}
|
643 |
-
|
644 |
-
}
|
645 |
-
|
646 |
-
// Done
|
647 |
-
acfe_settings()->delete('upgrades.0_8_5');
|
648 |
-
|
649 |
-
acf_log('[ACF Extended] 0.8.5 Upgrade: Done');
|
650 |
-
|
651 |
-
}
|
652 |
-
|
653 |
-
}
|
654 |
-
|
655 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!class_exists('acfe_upgrades')):
|
4 |
+
|
5 |
+
class acfe_upgrades{
|
6 |
+
|
7 |
+
function __construct(){
|
8 |
+
|
9 |
+
$upgrades = acfe_settings('upgrades');
|
10 |
+
|
11 |
+
if(empty($upgrades))
|
12 |
+
return;
|
13 |
+
|
14 |
+
// ACF Extended: 0.8.5
|
15 |
+
add_action('acf/init', array($this, 'upgrade_0_8_5'), 999);
|
16 |
+
|
17 |
+
// ACF Extended: 0.8.6
|
18 |
+
add_action('acf/init', array($this, 'upgrade_0_8_6'), 999);
|
19 |
+
|
20 |
+
}
|
21 |
+
|
22 |
+
function upgrade_0_8_6(){
|
23 |
+
|
24 |
+
$todo = acfe_settings('upgrades.0_8_6');
|
25 |
+
|
26 |
+
if(!$todo)
|
27 |
+
return;
|
28 |
+
|
29 |
+
acf_log('[ACF Extended] 0.8.6 Upgrade: Dynamic Options Pages');
|
30 |
+
|
31 |
+
$get_options = get_posts(array(
|
32 |
+
'post_type' => 'acfe-dop',
|
33 |
+
'posts_per_page' => -1,
|
34 |
+
'fields' => 'ids'
|
35 |
+
));
|
36 |
+
|
37 |
+
if(!empty($get_options)){
|
38 |
+
|
39 |
+
foreach($get_options as $post_id){
|
40 |
+
|
41 |
+
$menu_slug = get_field('menu_slug', $post_id);
|
42 |
+
$acfe_dop_name = get_field('acfe_dop_name', $post_id);
|
43 |
+
$post_name = get_post_field('post_name', $post_id);
|
44 |
+
|
45 |
+
// Update empty 'menu_slug' fields in options pages
|
46 |
+
if(empty($menu_slug)){
|
47 |
+
|
48 |
+
// Page Title
|
49 |
+
$page_title = get_post_field('post_title', $post_id);
|
50 |
+
|
51 |
+
// Menu Title
|
52 |
+
$menu_title = get_field('menu_title', $post_id);
|
53 |
+
|
54 |
+
if(empty($menu_title)){
|
55 |
+
|
56 |
+
$menu_title = $page_title;
|
57 |
+
|
58 |
+
}
|
59 |
+
|
60 |
+
// Menu Slug
|
61 |
+
$menu_slug = sanitize_title($menu_title);
|
62 |
+
|
63 |
+
// Update field
|
64 |
+
update_field('menu_slug', $menu_slug, $post_id);
|
65 |
+
|
66 |
+
}
|
67 |
+
|
68 |
+
// Upgrade old name to menu_slug
|
69 |
+
if($acfe_dop_name === $post_name){
|
70 |
+
|
71 |
+
// Get ACFE option
|
72 |
+
$option = acfe_settings('modules.dynamic_option.data');
|
73 |
+
|
74 |
+
// Check ACFE option
|
75 |
+
if(isset($option[$acfe_dop_name])){
|
76 |
+
|
77 |
+
$register_args = $option[$acfe_dop_name];
|
78 |
+
|
79 |
+
// Delete old option page slug
|
80 |
+
unset($option[$acfe_dop_name]);
|
81 |
+
|
82 |
+
// Re-assign to menu_slug
|
83 |
+
$option[$menu_slug] = $register_args;
|
84 |
+
|
85 |
+
// Sort keys ASC
|
86 |
+
ksort($option);
|
87 |
+
|
88 |
+
// Update ACFE option
|
89 |
+
acfe_settings('modules.dynamic_option.data', $option, true);
|
90 |
+
|
91 |
+
// Update post: force menu slug as name
|
92 |
+
wp_update_post(array(
|
93 |
+
'ID' => $post_id,
|
94 |
+
'post_name' => $menu_slug,
|
95 |
+
));
|
96 |
+
|
97 |
+
}
|
98 |
+
|
99 |
+
}
|
100 |
+
|
101 |
+
}
|
102 |
+
|
103 |
+
}
|
104 |
+
|
105 |
+
// Done
|
106 |
+
acfe_settings()->delete('upgrades.0_8_6');
|
107 |
+
|
108 |
+
acf_log('[ACF Extended] 0.8.6 Upgrade: Done');
|
109 |
+
|
110 |
+
}
|
111 |
+
|
112 |
+
function upgrade_0_8_5(){
|
113 |
+
|
114 |
+
$todo = acfe_settings('upgrades.0_8_5');
|
115 |
+
|
116 |
+
if(!$todo)
|
117 |
+
return;
|
118 |
+
|
119 |
+
$tasks = array(
|
120 |
+
'dynamic_form',
|
121 |
+
'dynamic_post_type',
|
122 |
+
'dynamic_taxonomy',
|
123 |
+
'dynamic_block_type',
|
124 |
+
'dynamic_option',
|
125 |
+
);
|
126 |
+
|
127 |
+
foreach($tasks as $task){
|
128 |
+
|
129 |
+
/*
|
130 |
+
* Forms
|
131 |
+
*/
|
132 |
+
if($task === 'dynamic_form'){
|
133 |
+
|
134 |
+
acf_log('[ACF Extended] 0.8.5 Upgrade: Dynamic Forms');
|
135 |
+
|
136 |
+
// Retrieve all forms posts
|
137 |
+
$get_forms = get_posts(array(
|
138 |
+
'post_type' => 'acfe-form',
|
139 |
+
'posts_per_page' => -1,
|
140 |
+
'fields' => 'ids',
|
141 |
+
'post_status' => 'any'
|
142 |
+
));
|
143 |
+
|
144 |
+
// Bail early if no form found
|
145 |
+
if(empty($get_forms)){
|
146 |
+
|
147 |
+
// Upgrade done
|
148 |
+
continue;
|
149 |
+
|
150 |
+
}
|
151 |
+
|
152 |
+
$flexible = acf_get_field_type('flexible_content');
|
153 |
+
$field = acf_get_field('acfe_form_actions');
|
154 |
+
|
155 |
+
global $wpdb;
|
156 |
+
|
157 |
+
foreach($get_forms as $post_id){
|
158 |
+
|
159 |
+
// init
|
160 |
+
$wp_meta = array();
|
161 |
+
$acf_meta = array();
|
162 |
+
|
163 |
+
// Retrieve meta
|
164 |
+
$get_meta = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->postmeta WHERE post_id = %d ", $post_id));
|
165 |
+
|
166 |
+
// Sort
|
167 |
+
usort($get_meta, function($a, $b){
|
168 |
+
return strcmp($a->meta_key, $b->meta_key);
|
169 |
+
});
|
170 |
+
|
171 |
+
// Store
|
172 |
+
foreach($get_meta as $meta){
|
173 |
+
|
174 |
+
$wp_meta[$meta->meta_key] = $meta->meta_value;
|
175 |
+
|
176 |
+
}
|
177 |
+
|
178 |
+
// Check if is acf meta
|
179 |
+
foreach($wp_meta as $key => $value){
|
180 |
+
|
181 |
+
// ACF Meta
|
182 |
+
if(isset($wp_meta["_$key"])){
|
183 |
+
|
184 |
+
$acf_meta[] = array(
|
185 |
+
'key' => $key,
|
186 |
+
'value' => $wp_meta[$key],
|
187 |
+
);
|
188 |
+
|
189 |
+
}
|
190 |
+
|
191 |
+
}
|
192 |
+
|
193 |
+
/*
|
194 |
+
* Step 1: Upgrade old group fields
|
195 |
+
*/
|
196 |
+
$prefix = 'acfe_form_actions';
|
197 |
+
|
198 |
+
// Define script rules
|
199 |
+
$rules = array(
|
200 |
+
|
201 |
+
// Post: title
|
202 |
+
array(
|
203 |
+
'group' => 'acfe_form_post_save_post_title_group',
|
204 |
+
'sub_field' => 'acfe_form_post_save_post_title_group_acfe_form_post_save_post_title',
|
205 |
+
'sub_field_custom' => 'acfe_form_post_save_post_title_group_acfe_form_post_save_post_title_custom',
|
206 |
+
'new_field' => 'acfe_form_post_save_post_title',
|
207 |
+
),
|
208 |
+
|
209 |
+
// Post: name
|
210 |
+
array(
|
211 |
+
'group' => 'acfe_form_post_save_post_name_group',
|
212 |
+
'sub_field' => 'acfe_form_post_save_post_name_group_acfe_form_post_save_post_name',
|
213 |
+
'sub_field_custom' => 'acfe_form_post_save_post_name_group_acfe_form_post_save_post_name_custom',
|
214 |
+
'new_field' => 'acfe_form_post_save_post_name',
|
215 |
+
),
|
216 |
+
|
217 |
+
// Term: name
|
218 |
+
array(
|
219 |
+
'group' => 'acfe_form_term_save_name_group',
|
220 |
+
'sub_field' => 'acfe_form_term_save_name_group_acfe_form_term_save_name',
|
221 |
+
'sub_field_custom' => 'acfe_form_term_save_name_group_acfe_form_term_save_name_custom',
|
222 |
+
'new_field' => 'acfe_form_term_save_name',
|
223 |
+
),
|
224 |
+
|
225 |
+
// Term: slug
|
226 |
+
array(
|
227 |
+
'group' => 'acfe_form_term_save_slug_group',
|
228 |
+
'sub_field' => 'acfe_form_term_save_slug_group_acfe_form_term_save_slug',
|
229 |
+
'sub_field_custom' => 'acfe_form_term_save_slug_group_acfe_form_term_save_slug_custom',
|
230 |
+
'new_field' => 'acfe_form_term_save_slug',
|
231 |
+
),
|
232 |
+
|
233 |
+
// User: e-mail
|
234 |
+
array(
|
235 |
+
'group' => 'acfe_form_user_save_email_group',
|
236 |
+
'sub_field' => 'acfe_form_user_save_email_group_acfe_form_user_save_email',
|
237 |
+
'sub_field_custom' => 'acfe_form_user_save_email_group_acfe_form_user_save_email_custom',
|
238 |
+
'new_field' => 'acfe_form_user_save_email',
|
239 |
+
),
|
240 |
+
|
241 |
+
// User: username
|
242 |
+
array(
|
243 |
+
'group' => 'acfe_form_user_save_username_group',
|
244 |
+
'sub_field' => 'acfe_form_user_save_username_group_acfe_form_user_save_username',
|
245 |
+
'sub_field_custom' => 'acfe_form_user_save_username_group_acfe_form_user_save_username_custom',
|
246 |
+
'new_field' => 'acfe_form_user_save_username',
|
247 |
+
),
|
248 |
+
|
249 |
+
// User: password
|
250 |
+
array(
|
251 |
+
'group' => 'acfe_form_user_save_password_group',
|
252 |
+
'sub_field' => 'acfe_form_user_save_password_group_acfe_form_user_save_password',
|
253 |
+
'sub_field_custom' => 'acfe_form_user_save_password_group_acfe_form_user_save_password_custom',
|
254 |
+
'new_field' => 'acfe_form_user_save_password',
|
255 |
+
),
|
256 |
+
|
257 |
+
// User: first name
|
258 |
+
array(
|
259 |
+
'group' => 'acfe_form_user_save_first_name_group',
|
260 |
+
'sub_field' => 'acfe_form_user_save_first_name_group_acfe_form_user_save_first_name',
|
261 |
+
'sub_field_custom' => 'acfe_form_user_save_first_name_group_acfe_form_user_save_first_name_custom',
|
262 |
+
'new_field' => 'acfe_form_user_save_first_name',
|
263 |
+
),
|
264 |
+
|
265 |
+
// User: last name
|
266 |
+
array(
|
267 |
+
'group' => 'acfe_form_user_save_last_name_group',
|
268 |
+
'sub_field' => 'acfe_form_user_save_last_name_group_acfe_form_user_save_last_name',
|
269 |
+
'sub_field_custom' => 'acfe_form_user_save_last_name_group_acfe_form_user_save_last_name_custom',
|
270 |
+
'new_field' => 'acfe_form_user_save_last_name',
|
271 |
+
),
|
272 |
+
|
273 |
+
// User: nickname
|
274 |
+
array(
|
275 |
+
'group' => 'acfe_form_user_save_nickname_group',
|
276 |
+
'sub_field' => 'acfe_form_user_save_nickname_group_acfe_form_user_save_nickname',
|
277 |
+
'sub_field_custom' => 'acfe_form_user_save_nickname_group_acfe_form_user_save_nickname_custom',
|
278 |
+
'new_field' => 'acfe_form_user_save_nickname',
|
279 |
+
),
|
280 |
+
|
281 |
+
// User: display name
|
282 |
+
array(
|
283 |
+
'group' => 'acfe_form_user_save_display_name_group',
|
284 |
+
'sub_field' => 'acfe_form_user_save_display_name_group_acfe_form_user_save_display_name',
|
285 |
+
'sub_field_custom' => 'acfe_form_user_save_display_name_group_acfe_form_user_save_display_name_custom',
|
286 |
+
'new_field' => 'acfe_form_user_save_display_name',
|
287 |
+
),
|
288 |
+
|
289 |
+
// User: website
|
290 |
+
array(
|
291 |
+
'group' => 'acfe_form_user_save_website_group',
|
292 |
+
'sub_field' => 'acfe_form_user_save_website_group_acfe_form_user_save_website',
|
293 |
+
'sub_field_custom' => 'acfe_form_user_save_website_group_acfe_form_user_save_website_custom',
|
294 |
+
'new_field' => 'acfe_form_user_save_website',
|
295 |
+
),
|
296 |
+
|
297 |
+
);
|
298 |
+
|
299 |
+
// Process rules
|
300 |
+
foreach($rules as $rule){
|
301 |
+
|
302 |
+
$updates = array();
|
303 |
+
|
304 |
+
foreach($acf_meta as $acf){
|
305 |
+
|
306 |
+
// Bail early if doesn't starts with 'acfe_form_actions'
|
307 |
+
if(strpos($acf['key'], $prefix) !== 0)
|
308 |
+
continue;
|
309 |
+
|
310 |
+
// Regex: 'acfe_form_actions_2_acfe_form_post_save_post_title_group'
|
311 |
+
// Match: '2'
|
312 |
+
if(preg_match('/^' . $prefix . '_([0-9]+)_' . $rule['group'] . '$/', $acf['key'], $match)){
|
313 |
+
|
314 |
+
$updates[$rule['new_field']][$match[1]]['group'] = array(
|
315 |
+
'key' => $acf['key'],
|
316 |
+
'value' => $acf['value'],
|
317 |
+
);
|
318 |
+
|
319 |
+
// Regex: 'acfe_form_post_2_save_post_title_group_acfe_form_post_save_post_title'
|
320 |
+
// Match: '2'
|
321 |
+
}elseif(preg_match('/^' . $prefix . '_([0-9]+)_' . $rule['sub_field'] . '$/', $acf['key'], $match)){
|
322 |
+
|
323 |
+
$updates[$rule['new_field']][$match[1]]['sub_field'] = array(
|
324 |
+
'key' => $acf['key'],
|
325 |
+
'value' => $acf['value'],
|
326 |
+
);
|
327 |
+
|
328 |
+
// Regex: 'acfe_form_post_2_save_post_title_group_acfe_form_post_save_post_title_custom'
|
329 |
+
// Match: '2'
|
330 |
+
}elseif(preg_match('/^' . $prefix . '_([0-9]+)_' . $rule['sub_field_custom'] . '$/', $acf['key'], $match)){
|
331 |
+
|
332 |
+
// Generate: array[acfe_form_post_save_post_title][2]['sub_field_custom']
|
333 |
+
$updates[$rule['new_field']][$match[1]]['sub_field_custom'] = array(
|
334 |
+
'key' => $acf['key'],
|
335 |
+
'value' => $acf['value'],
|
336 |
+
);
|
337 |
+
|
338 |
+
}
|
339 |
+
|
340 |
+
}
|
341 |
+
|
342 |
+
if(!empty($updates)){
|
343 |
+
|
344 |
+
// Update meta
|
345 |
+
foreach($updates as $new_field => $data){
|
346 |
+
|
347 |
+
foreach($data as $i => $row){
|
348 |
+
|
349 |
+
$group = acf_maybe_get($row, 'group');
|
350 |
+
$sub_field = acf_maybe_get($row, 'sub_field');
|
351 |
+
$sub_field_custom = acf_maybe_get($row, 'sub_field_custom');
|
352 |
+
|
353 |
+
if($sub_field){
|
354 |
+
|
355 |
+
$new_field_name = "{$prefix}_{$i}_{$new_field}";
|
356 |
+
|
357 |
+
// update field
|
358 |
+
if($sub_field['value'] === 'custom'){
|
359 |
+
|
360 |
+
update_post_meta($post_id, $new_field_name, $sub_field_custom['value']);
|
361 |
+
|
362 |
+
}else{
|
363 |
+
|
364 |
+
update_post_meta($post_id, $new_field_name, $sub_field['value']);
|
365 |
+
|
366 |
+
}
|
367 |
+
|
368 |
+
// update reference
|
369 |
+
update_post_meta($post_id, '_' . $new_field_name, 'field_' . $new_field);
|
370 |
+
|
371 |
+
}
|
372 |
+
|
373 |
+
// Delete old group
|
374 |
+
delete_post_meta($post_id, $group['key']);
|
375 |
+
delete_post_meta($post_id, $sub_field['key']);
|
376 |
+
delete_post_meta($post_id, $sub_field_custom['key']);
|
377 |
+
|
378 |
+
}
|
379 |
+
|
380 |
+
}
|
381 |
+
|
382 |
+
}
|
383 |
+
|
384 |
+
}
|
385 |
+
|
386 |
+
/*
|
387 |
+
* Step 2: Upgrade map fields which now require "Load values" to be enabled
|
388 |
+
*/
|
389 |
+
if(have_rows('acfe_form_actions', $post_id)):
|
390 |
+
while(have_rows('acfe_form_actions', $post_id)): the_row();
|
391 |
+
|
392 |
+
$layout = get_row_layout();
|
393 |
+
$row = get_row_index();
|
394 |
+
$i = $row-1;
|
395 |
+
|
396 |
+
// Post Action
|
397 |
+
if($layout === 'post'){
|
398 |
+
|
399 |
+
$load_values = get_sub_field('acfe_form_post_load_values');
|
400 |
+
|
401 |
+
$fields = array(
|
402 |
+
'field_acfe_form_post_save_post_type' => get_sub_field('acfe_form_post_map_post_type', false),
|
403 |
+
'field_acfe_form_post_save_post_status' => get_sub_field('acfe_form_post_map_post_status', false),
|
404 |
+
'field_acfe_form_post_save_post_title' => get_sub_field('acfe_form_post_map_post_title', false),
|
405 |
+
'field_acfe_form_post_save_post_name' => get_sub_field('acfe_form_post_map_post_name', false),
|
406 |
+
'field_acfe_form_post_save_post_content' => get_sub_field('acfe_form_post_map_post_content', false),
|
407 |
+
'field_acfe_form_post_save_post_author' => get_sub_field('acfe_form_post_map_post_author', false),
|
408 |
+
'field_acfe_form_post_save_post_parent' => get_sub_field('acfe_form_post_map_post_parent', false),
|
409 |
+
'field_acfe_form_post_save_post_terms' => get_sub_field('acfe_form_post_map_post_terms', false),
|
410 |
+
);
|
411 |
+
|
412 |
+
if(!$load_values){
|
413 |
+
|
414 |
+
foreach($fields as $field_key => $field_value){
|
415 |
+
|
416 |
+
// Bail early if map field has no value
|
417 |
+
if(empty($field_value))
|
418 |
+
continue;
|
419 |
+
|
420 |
+
// args
|
421 |
+
$update = array();
|
422 |
+
$update['acf_fc_layout'] = $layout;
|
423 |
+
|
424 |
+
// Post content inside group
|
425 |
+
if($field_key === 'field_acfe_form_post_save_post_content'){
|
426 |
+
|
427 |
+
$update['field_acfe_form_post_save_post_content_group'] = array(
|
428 |
+
'field_acfe_form_post_save_post_content' => $field_value
|
429 |
+
);
|
430 |
+
|
431 |
+
}else{
|
432 |
+
|
433 |
+
$update[$field_key] = $field_value;
|
434 |
+
|
435 |
+
}
|
436 |
+
|
437 |
+
// update
|
438 |
+
$flexible->update_row($update, $i, $field, $post_id);
|
439 |
+
|
440 |
+
}
|
441 |
+
|
442 |
+
}
|
443 |
+
|
444 |
+
}
|
445 |
+
|
446 |
+
// Term Action
|
447 |
+
elseif($layout === 'term'){
|
448 |
+
|
449 |
+
$load_values = get_sub_field('acfe_form_term_load_values');
|
450 |
+
|
451 |
+
$fields = array(
|
452 |
+
'field_acfe_form_term_save_name' => get_sub_field('acfe_form_term_map_name', false),
|
453 |
+
'field_acfe_form_term_save_slug' => get_sub_field('acfe_form_term_map_slug', false),
|
454 |
+
'field_acfe_form_term_save_taxonomy' => get_sub_field('acfe_form_term_map_taxonomy', false),
|
455 |
+
'field_acfe_form_term_save_parent' => get_sub_field('acfe_form_term_map_parent', false),
|
456 |
+
'field_acfe_form_term_save_description' => get_sub_field('acfe_form_term_map_description', false),
|
457 |
+
);
|
458 |
+
|
459 |
+
if(!$load_values){
|
460 |
+
|
461 |
+
foreach($fields as $field_key => $field_value){
|
462 |
+
|
463 |
+
// Bail early if map field has no value
|
464 |
+
if(empty($field_value))
|
465 |
+
continue;
|
466 |
+
|
467 |
+
// args
|
468 |
+
$update = array();
|
469 |
+
$update['acf_fc_layout'] = $layout;
|
470 |
+
|
471 |
+
// Post content inside group
|
472 |
+
if($field_key === 'field_acfe_form_term_save_description'){
|
473 |
+
|
474 |
+
$update['field_acfe_form_term_save_description_group'] = array(
|
475 |
+
'field_acfe_form_term_save_description' => $field_value
|
476 |
+
);
|
477 |
+
|
478 |
+
}else{
|
479 |
+
|
480 |
+
$update[$field_key] = $field_value;
|
481 |
+
|
482 |
+
}
|
483 |
+
|
484 |
+
// update
|
485 |
+
$flexible->update_row($update, $i, $field, $post_id);
|
486 |
+
|
487 |
+
}
|
488 |
+
|
489 |
+
}
|
490 |
+
|
491 |
+
}
|
492 |
+
|
493 |
+
// User Action
|
494 |
+
elseif($layout === 'user'){
|
495 |
+
|
496 |
+
$load_values = get_sub_field('acfe_form_user_load_values');
|
497 |
+
|
498 |
+
$fields = array(
|
499 |
+
'field_acfe_form_user_save_email' => get_sub_field('acfe_form_user_map_email', false),
|
500 |
+
'field_acfe_form_user_save_username' => get_sub_field('acfe_form_user_map_username', false),
|
501 |
+
'field_acfe_form_user_save_password' => get_sub_field('acfe_form_user_map_password', false),
|
502 |
+
'field_acfe_form_user_save_first_name' => get_sub_field('acfe_form_user_map_first_name', false),
|
503 |
+
'field_acfe_form_user_save_last_name' => get_sub_field('acfe_form_user_map_last_name', false),
|
504 |
+
'field_acfe_form_user_save_nickname' => get_sub_field('acfe_form_user_map_nickname', false),
|
505 |
+
'field_acfe_form_user_save_display_name' => get_sub_field('acfe_form_user_map_display_name', false),
|
506 |
+
'field_acfe_form_user_save_website' => get_sub_field('acfe_form_user_map_website', false),
|
507 |
+
'field_acfe_form_user_save_description' => get_sub_field('acfe_form_user_map_description', false),
|
508 |
+
'field_acfe_form_user_save_role' => get_sub_field('acfe_form_user_map_role', false),
|
509 |
+
);
|
510 |
+
|
511 |
+
if(!$load_values){
|
512 |
+
|
513 |
+
foreach($fields as $field_key => $field_value){
|
514 |
+
|
515 |
+
// Bail early if map field has no value
|
516 |
+
if(empty($field_value))
|
517 |
+
continue;
|
518 |
+
|
519 |
+
// args
|
520 |
+
$update = array();
|
521 |
+
$update['acf_fc_layout'] = $layout;
|
522 |
+
|
523 |
+
// Post content inside group
|
524 |
+
if($field_key === 'field_acfe_form_user_save_description'){
|
525 |
+
|
526 |
+
$update['field_acfe_form_user_save_description_group'] = array(
|
527 |
+
'field_acfe_form_user_save_description' => $field_value
|
528 |
+
);
|
529 |
+
|
530 |
+
}else{
|
531 |
+
|
532 |
+
$update[$field_key] = $field_value;
|
533 |
+
|
534 |
+
}
|
535 |
+
|
536 |
+
// update
|
537 |
+
$flexible->update_row($update, $i, $field, $post_id);
|
538 |
+
|
539 |
+
}
|
540 |
+
|
541 |
+
}
|
542 |
+
|
543 |
+
}
|
544 |
+
|
545 |
+
endwhile;
|
546 |
+
endif;
|
547 |
+
|
548 |
+
}
|
549 |
+
|
550 |
+
}
|
551 |
+
|
552 |
+
/*
|
553 |
+
* Post Types
|
554 |
+
*/
|
555 |
+
elseif($task === 'dynamic_post_type'){
|
556 |
+
|
557 |
+
acf_log('[ACF Extended] 0.8.5 Upgrade: Dynamic Post Types');
|
558 |
+
|
559 |
+
// Old Post Types
|
560 |
+
$old_post_types = get_option('acfe_dynamic_post_types', array());
|
561 |
+
|
562 |
+
// New Post Types
|
563 |
+
$new_post_types = acfe_settings('modules.dynamic_post_type.data');
|
564 |
+
|
565 |
+
$merged_post_types = array_merge($old_post_types, $new_post_types);
|
566 |
+
|
567 |
+
// Update Post Types
|
568 |
+
acfe_settings('modules.dynamic_post_type.data', $merged_post_types, true);
|
569 |
+
|
570 |
+
// Delete Old Post Types
|
571 |
+
delete_option('acfe_dynamic_post_types');
|
572 |
+
|
573 |
+
}
|
574 |
+
|
575 |
+
/*
|
576 |
+
* Taxonomies
|
577 |
+
*/
|
578 |
+
elseif($task === 'dynamic_taxonomy'){
|
579 |
+
|
580 |
+
acf_log('[ACF Extended] 0.8.5 Upgrade: Dynamic Taxonomies');
|
581 |
+
|
582 |
+
// Old Taxonomies
|
583 |
+
$old_taxonomies = get_option('acfe_dynamic_taxonomies', array());
|
584 |
+
|
585 |
+
// New Taxonomies
|
586 |
+
$new_taxonomies = acfe_settings('modules.dynamic_taxonomy.data');
|
587 |
+
|
588 |
+
$merged_taxonomies = array_merge($old_taxonomies, $new_taxonomies);
|
589 |
+
|
590 |
+
// Update Taxonomies
|
591 |
+
acfe_settings('modules.dynamic_taxonomy.data', $merged_taxonomies, true);
|
592 |
+
|
593 |
+
// Delete Old Taxonomies
|
594 |
+
delete_option('acfe_dynamic_taxonomies');
|
595 |
+
|
596 |
+
}
|
597 |
+
|
598 |
+
/*
|
599 |
+
* Block Types
|
600 |
+
*/
|
601 |
+
elseif($task === 'dynamic_block_type'){
|
602 |
+
|
603 |
+
acf_log('[ACF Extended] 0.8.5 Upgrade: Dynamic Block Types');
|
604 |
+
|
605 |
+
// Old Block Types
|
606 |
+
$old_block_types = get_option('acfe_dynamic_block_types', array());
|
607 |
+
|
608 |
+
// New Block Types
|
609 |
+
$new_block_types = acfe_settings('modules.dynamic_block_type.data');
|
610 |
+
|
611 |
+
$merged_block_types = array_merge($old_block_types, $new_block_types);
|
612 |
+
|
613 |
+
// Update Block Types
|
614 |
+
acfe_settings('modules.dynamic_block_type.data', $merged_block_types, true);
|
615 |
+
|
616 |
+
// Delete Old Block Types
|
617 |
+
delete_option('acfe_dynamic_block_types');
|
618 |
+
|
619 |
+
}
|
620 |
+
|
621 |
+
/*
|
622 |
+
* Option Pages
|
623 |
+
*/
|
624 |
+
elseif($task === 'dynamic_option'){
|
625 |
+
|
626 |
+
acf_log('[ACF Extended] 0.8.5 Upgrade: Dynamic Options Pages');
|
627 |
+
|
628 |
+
// Old Options
|
629 |
+
$old_options = get_option('acfe_dynamic_options_pages', array());
|
630 |
+
|
631 |
+
// New Options
|
632 |
+
$new_options = acfe_settings('modules.dynamic_option.data');
|
633 |
+
|
634 |
+
$merged_options = array_merge($old_options, $new_options);
|
635 |
+
|
636 |
+
// Update Options
|
637 |
+
acfe_settings('modules.dynamic_option.data', $merged_options, true);
|
638 |
+
|
639 |
+
// Delete Old Options
|
640 |
+
delete_option('acfe_dynamic_options_pages');
|
641 |
+
|
642 |
+
}
|
643 |
+
|
644 |
+
}
|
645 |
+
|
646 |
+
// Done
|
647 |
+
acfe_settings()->delete('upgrades.0_8_5');
|
648 |
+
|
649 |
+
acf_log('[ACF Extended] 0.8.5 Upgrade: Done');
|
650 |
+
|
651 |
+
}
|
652 |
+
|
653 |
+
}
|
654 |
+
|
655 |
endif;
|
@@ -1,62 +1,62 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
// Check setting
|
7 |
-
if(acfe_get_setting('modules/field_group_ui'))
|
8 |
-
return;
|
9 |
-
|
10 |
-
if(!class_exists('acfe_field_group_advanced')):
|
11 |
-
|
12 |
-
class acfe_field_group_advanced{
|
13 |
-
|
14 |
-
function __construct(){
|
15 |
-
|
16 |
-
add_action('acf/field_group/admin_head', array($this, 'admin_head'), 5);
|
17 |
-
add_action('acf/render_field_group_settings', array($this, 'render_settings'));
|
18 |
-
|
19 |
-
}
|
20 |
-
|
21 |
-
/*
|
22 |
-
* Admin Head
|
23 |
-
*/
|
24 |
-
function admin_head(){
|
25 |
-
|
26 |
-
global $field_group;
|
27 |
-
|
28 |
-
if(!acf_maybe_get($field_group, 'acfe_form'))
|
29 |
-
return;
|
30 |
-
|
31 |
-
acf_enable_filter('acfe/field_group/advanced');
|
32 |
-
|
33 |
-
}
|
34 |
-
|
35 |
-
/*
|
36 |
-
* Advanced Settings
|
37 |
-
*/
|
38 |
-
function render_settings($field_group){
|
39 |
-
|
40 |
-
// Form settings
|
41 |
-
acf_render_field_wrap(array(
|
42 |
-
'label' => __('Advanced settings'),
|
43 |
-
'name' => 'acfe_form',
|
44 |
-
'prefix' => 'acf_field_group',
|
45 |
-
'type' => 'true_false',
|
46 |
-
'ui' => 1,
|
47 |
-
'instructions' => __('Enable advanced fields settings & validation'),
|
48 |
-
'value' => (isset($field_group['acfe_form'])) ? $field_group['acfe_form'] : '',
|
49 |
-
'required' => false,
|
50 |
-
'wrapper' => array(
|
51 |
-
'data-after' => 'active'
|
52 |
-
)
|
53 |
-
));
|
54 |
-
|
55 |
-
}
|
56 |
-
|
57 |
-
}
|
58 |
-
|
59 |
-
// initialize
|
60 |
-
new acfe_field_group_advanced();
|
61 |
-
|
62 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
// Check setting
|
7 |
+
if(acfe_get_setting('modules/field_group_ui'))
|
8 |
+
return;
|
9 |
+
|
10 |
+
if(!class_exists('acfe_field_group_advanced')):
|
11 |
+
|
12 |
+
class acfe_field_group_advanced{
|
13 |
+
|
14 |
+
function __construct(){
|
15 |
+
|
16 |
+
add_action('acf/field_group/admin_head', array($this, 'admin_head'), 5);
|
17 |
+
add_action('acf/render_field_group_settings', array($this, 'render_settings'));
|
18 |
+
|
19 |
+
}
|
20 |
+
|
21 |
+
/*
|
22 |
+
* Admin Head
|
23 |
+
*/
|
24 |
+
function admin_head(){
|
25 |
+
|
26 |
+
global $field_group;
|
27 |
+
|
28 |
+
if(!acf_maybe_get($field_group, 'acfe_form'))
|
29 |
+
return;
|
30 |
+
|
31 |
+
acf_enable_filter('acfe/field_group/advanced');
|
32 |
+
|
33 |
+
}
|
34 |
+
|
35 |
+
/*
|
36 |
+
* Advanced Settings
|
37 |
+
*/
|
38 |
+
function render_settings($field_group){
|
39 |
+
|
40 |
+
// Form settings
|
41 |
+
acf_render_field_wrap(array(
|
42 |
+
'label' => __('Advanced settings'),
|
43 |
+
'name' => 'acfe_form',
|
44 |
+
'prefix' => 'acf_field_group',
|
45 |
+
'type' => 'true_false',
|
46 |
+
'ui' => 1,
|
47 |
+
'instructions' => __('Enable advanced fields settings & validation'),
|
48 |
+
'value' => (isset($field_group['acfe_form'])) ? $field_group['acfe_form'] : '',
|
49 |
+
'required' => false,
|
50 |
+
'wrapper' => array(
|
51 |
+
'data-after' => 'active'
|
52 |
+
)
|
53 |
+
));
|
54 |
+
|
55 |
+
}
|
56 |
+
|
57 |
+
}
|
58 |
+
|
59 |
+
// initialize
|
60 |
+
new acfe_field_group_advanced();
|
61 |
+
|
62 |
endif;
|
@@ -1,261 +1,261 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
// Check setting
|
7 |
-
if(!acf_get_setting('acfe/modules/categories'))
|
8 |
-
return;
|
9 |
-
|
10 |
-
if(!class_exists('acfe_field_group_category')):
|
11 |
-
|
12 |
-
class acfe_field_group_category{
|
13 |
-
|
14 |
-
function __construct(){
|
15 |
-
|
16 |
-
add_action('init', array($this, 'init'), 9);
|
17 |
-
add_action('admin_menu', array($this, 'admin_menu'));
|
18 |
-
add_filter('parent_file', array($this, 'parent_file'));
|
19 |
-
add_filter('manage_edit-acf-field-group_columns', array($this, 'columns'), 11);
|
20 |
-
add_action('manage_acf-field-group_posts_custom_column' , array($this, 'column_html'), 10, 2);
|
21 |
-
add_filter('views_edit-acf-field-group', array($this, 'views'), 9);
|
22 |
-
add_filter('acf/get_taxonomies', array($this, 'acf_get_taxonomies'), 10, 2);
|
23 |
-
|
24 |
-
add_filter('acf/prepare_field_group_for_export', array($this, 'prepare_for_export'));
|
25 |
-
add_action('acf/import_field_group', array($this, 'prepare_for_import'));
|
26 |
-
|
27 |
-
}
|
28 |
-
|
29 |
-
/*
|
30 |
-
* Register Taxonomy
|
31 |
-
*/
|
32 |
-
function init(){
|
33 |
-
|
34 |
-
register_taxonomy('acf-field-group-category', array('acf-field-group'), array(
|
35 |
-
'hierarchical' => true,
|
36 |
-
'public' => false,
|
37 |
-
'show_ui' => 'ACFE',
|
38 |
-
'show_admin_column' => true,
|
39 |
-
'show_in_menu' => true,
|
40 |
-
'show_in_nav_menus' => true,
|
41 |
-
'show_tagcloud' => false,
|
42 |
-
'rewrite' => false,
|
43 |
-
'labels' => array(
|
44 |
-
'name' => _x('Categories', 'Category'),
|
45 |
-
'singular_name' => _x('Categories', 'Category'),
|
46 |
-
'search_items' => __('Search categories', 'acfe'),
|
47 |
-
'all_items' => __('All categories', 'acfe'),
|
48 |
-
'parent_item' => __('Parent category', 'acfe'),
|
49 |
-
'parent_item_colon' => __('Parent category:', 'acfe'),
|
50 |
-
'edit_item' => __('Edit category', 'acfe'),
|
51 |
-
'update_item' => __('Update category', 'acfe'),
|
52 |
-
'add_new_item' => __('Add New category', 'acfe'),
|
53 |
-
'new_item_name' => __('New category name', 'acfe'),
|
54 |
-
'menu_name' => __('category', 'acfe'),
|
55 |
-
),
|
56 |
-
));
|
57 |
-
|
58 |
-
}
|
59 |
-
|
60 |
-
/*
|
61 |
-
* Admin Menu
|
62 |
-
*/
|
63 |
-
function admin_menu(){
|
64 |
-
|
65 |
-
if(!acf_get_setting('show_admin'))
|
66 |
-
return;
|
67 |
-
|
68 |
-
add_submenu_page('edit.php?post_type=acf-field-group', __('Categories'), __('Categories'), acf_get_setting('capability'), 'edit-tags.php?taxonomy=acf-field-group-category');
|
69 |
-
|
70 |
-
}
|
71 |
-
|
72 |
-
/*
|
73 |
-
* Menu Parent File
|
74 |
-
*/
|
75 |
-
function parent_file($parent_file){
|
76 |
-
|
77 |
-
global $submenu_file, $current_screen, $pagenow;
|
78 |
-
|
79 |
-
if($current_screen->taxonomy === 'acf-field-group-category' && ($pagenow === 'edit-tags.php' || $pagenow === 'term.php'))
|
80 |
-
$parent_file = 'edit.php?post_type=acf-field-group';
|
81 |
-
|
82 |
-
return $parent_file;
|
83 |
-
|
84 |
-
}
|
85 |
-
|
86 |
-
/*
|
87 |
-
* ACF Field Group: Columns
|
88 |
-
*/
|
89 |
-
function columns($columns){
|
90 |
-
|
91 |
-
$new_columns = array();
|
92 |
-
foreach($columns as $key => $value) {
|
93 |
-
if($key === 'title')
|
94 |
-
$new_columns['acf-field-group-category'] = __('Categories');
|
95 |
-
|
96 |
-
$new_columns[$key] = $value;
|
97 |
-
}
|
98 |
-
|
99 |
-
return $new_columns;
|
100 |
-
|
101 |
-
}
|
102 |
-
|
103 |
-
/*
|
104 |
-
* ACF Field Group: Column HTML
|
105 |
-
*/
|
106 |
-
function column_html($column, $post_id){
|
107 |
-
|
108 |
-
if($column === 'acf-field-group-category'){
|
109 |
-
if(!$terms = get_the_terms($post_id, 'acf-field-group-category')){
|
110 |
-
echo '—';
|
111 |
-
return;
|
112 |
-
}
|
113 |
-
|
114 |
-
$categories = array();
|
115 |
-
foreach($terms as $term){
|
116 |
-
$categories[] = '<a href="' . admin_url('edit.php?acf-field-group-category='.$term->slug.'&post_type=acf-field-group') . '">' . $term->name . '</a>';
|
117 |
-
}
|
118 |
-
|
119 |
-
echo implode(' ', $categories);
|
120 |
-
}
|
121 |
-
|
122 |
-
}
|
123 |
-
|
124 |
-
/*
|
125 |
-
* ACF Field Group: Views
|
126 |
-
*/
|
127 |
-
function views($views){
|
128 |
-
|
129 |
-
if(!$terms = get_terms('acf-field-group-category', array('hide_empty' => false)))
|
130 |
-
return $views;
|
131 |
-
|
132 |
-
foreach($terms as $term){
|
133 |
-
|
134 |
-
$groups = get_posts( array(
|
135 |
-
'post_type' => 'acf-field-group',
|
136 |
-
'posts_per_page' => -1,
|
137 |
-
'suppress_filters' => false,
|
138 |
-
'post_status' => array('publish', 'acf-disabled'),
|
139 |
-
'taxonomy' => 'acf-field-group-category',
|
140 |
-
'term' => $term->slug,
|
141 |
-
'fields' => 'ids'
|
142 |
-
));
|
143 |
-
|
144 |
-
$count = count($groups);
|
145 |
-
|
146 |
-
$html = '';
|
147 |
-
if($count > 0)
|
148 |
-
$html = ' <span class="count">(' . $count . ')</span>';
|
149 |
-
|
150 |
-
global $wp_query;
|
151 |
-
$class = '';
|
152 |
-
if(isset($wp_query->query_vars['acf-field-group-category']) && $wp_query->query_vars['acf-field-group-category'] === $term->slug)
|
153 |
-
$class = ' class="current"';
|
154 |
-
|
155 |
-
$views['category-' . $term->slug] = '<a href="' . admin_url('edit.php?acf-field-group-category=' . $term->slug . '&post_type=acf-field-group') . '"' . $class . '>' . $term->name . $html . '</a>';
|
156 |
-
}
|
157 |
-
|
158 |
-
return $views;
|
159 |
-
|
160 |
-
}
|
161 |
-
|
162 |
-
/*
|
163 |
-
* ACF Exclude Field Group Category from available taxonomies
|
164 |
-
*/
|
165 |
-
function acf_get_taxonomies($taxonomies, $args){
|
166 |
-
|
167 |
-
if(empty($taxonomies))
|
168 |
-
return $taxonomies;
|
169 |
-
|
170 |
-
foreach($taxonomies as $k => $taxonomy){
|
171 |
-
|
172 |
-
if($taxonomy != 'acf-field-group-category')
|
173 |
-
continue;
|
174 |
-
|
175 |
-
unset($taxonomies[$k]);
|
176 |
-
|
177 |
-
}
|
178 |
-
|
179 |
-
return $taxonomies;
|
180 |
-
|
181 |
-
}
|
182 |
-
|
183 |
-
/*
|
184 |
-
* Prepare Export
|
185 |
-
*/
|
186 |
-
function prepare_for_export($field_group){
|
187 |
-
|
188 |
-
$_field_group = acf_get_field_group($field_group['key']);
|
189 |
-
|
190 |
-
if(empty($_field_group))
|
191 |
-
return $field_group;
|
192 |
-
|
193 |
-
if(!acf_maybe_get($_field_group, 'ID'))
|
194 |
-
return $field_group;
|
195 |
-
|
196 |
-
$categories = get_the_terms($_field_group['ID'], 'acf-field-group-category');
|
197 |
-
|
198 |
-
if(empty($categories) || is_wp_error($categories))
|
199 |
-
return $field_group;
|
200 |
-
|
201 |
-
$field_group['acfe_categories'] = array();
|
202 |
-
|
203 |
-
foreach($categories as $term){
|
204 |
-
|
205 |
-
$field_group['acfe_categories'][$term->slug] = $term->name;
|
206 |
-
|
207 |
-
}
|
208 |
-
|
209 |
-
return $field_group;
|
210 |
-
|
211 |
-
}
|
212 |
-
|
213 |
-
/*
|
214 |
-
* Prepare Import
|
215 |
-
*/
|
216 |
-
function prepare_for_import($field_group){
|
217 |
-
|
218 |
-
if(!$categories = acf_maybe_get($field_group, 'acfe_categories'))
|
219 |
-
return;
|
220 |
-
|
221 |
-
foreach($categories as $term_slug => $term_name){
|
222 |
-
|
223 |
-
$new_term_id = false;
|
224 |
-
$get_term = get_term_by('slug', $term_slug, 'acf-field-group-category');
|
225 |
-
|
226 |
-
// Term doesn't exists
|
227 |
-
if(empty($get_term)){
|
228 |
-
|
229 |
-
$new_term = wp_insert_term($term_name, 'acf-field-group-category', array(
|
230 |
-
'slug' => $term_slug
|
231 |
-
));
|
232 |
-
|
233 |
-
if(!is_wp_error($new_term)){
|
234 |
-
|
235 |
-
$new_term_id = $new_term['term_id'];
|
236 |
-
|
237 |
-
}
|
238 |
-
|
239 |
-
// Term already exists
|
240 |
-
}else{
|
241 |
-
|
242 |
-
$new_term_id = $get_term->term_id;
|
243 |
-
|
244 |
-
}
|
245 |
-
|
246 |
-
if($new_term_id){
|
247 |
-
|
248 |
-
wp_set_post_terms($field_group['ID'], array($new_term_id), 'acf-field-group-category', true);
|
249 |
-
|
250 |
-
}
|
251 |
-
|
252 |
-
}
|
253 |
-
|
254 |
-
}
|
255 |
-
|
256 |
-
}
|
257 |
-
|
258 |
-
// initialize
|
259 |
-
new acfe_field_group_category();
|
260 |
-
|
261 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
// Check setting
|
7 |
+
if(!acf_get_setting('acfe/modules/categories'))
|
8 |
+
return;
|
9 |
+
|
10 |
+
if(!class_exists('acfe_field_group_category')):
|
11 |
+
|
12 |
+
class acfe_field_group_category{
|
13 |
+
|
14 |
+
function __construct(){
|
15 |
+
|
16 |
+
add_action('init', array($this, 'init'), 9);
|
17 |
+
add_action('admin_menu', array($this, 'admin_menu'));
|
18 |
+
add_filter('parent_file', array($this, 'parent_file'));
|
19 |
+
add_filter('manage_edit-acf-field-group_columns', array($this, 'columns'), 11);
|
20 |
+
add_action('manage_acf-field-group_posts_custom_column' , array($this, 'column_html'), 10, 2);
|
21 |
+
add_filter('views_edit-acf-field-group', array($this, 'views'), 9);
|
22 |
+
add_filter('acf/get_taxonomies', array($this, 'acf_get_taxonomies'), 10, 2);
|
23 |
+
|
24 |
+
add_filter('acf/prepare_field_group_for_export', array($this, 'prepare_for_export'));
|
25 |
+
add_action('acf/import_field_group', array($this, 'prepare_for_import'));
|
26 |
+
|
27 |
+
}
|
28 |
+
|
29 |
+
/*
|
30 |
+
* Register Taxonomy
|
31 |
+
*/
|
32 |
+
function init(){
|
33 |
+
|
34 |
+
register_taxonomy('acf-field-group-category', array('acf-field-group'), array(
|
35 |
+
'hierarchical' => true,
|
36 |
+
'public' => false,
|
37 |
+
'show_ui' => 'ACFE',
|
38 |
+
'show_admin_column' => true,
|
39 |
+
'show_in_menu' => true,
|
40 |
+
'show_in_nav_menus' => true,
|
41 |
+
'show_tagcloud' => false,
|
42 |
+
'rewrite' => false,
|
43 |
+
'labels' => array(
|
44 |
+
'name' => _x('Categories', 'Category'),
|
45 |
+
'singular_name' => _x('Categories', 'Category'),
|
46 |
+
'search_items' => __('Search categories', 'acfe'),
|
47 |
+
'all_items' => __('All categories', 'acfe'),
|
48 |
+
'parent_item' => __('Parent category', 'acfe'),
|
49 |
+
'parent_item_colon' => __('Parent category:', 'acfe'),
|
50 |
+
'edit_item' => __('Edit category', 'acfe'),
|
51 |
+
'update_item' => __('Update category', 'acfe'),
|
52 |
+
'add_new_item' => __('Add New category', 'acfe'),
|
53 |
+
'new_item_name' => __('New category name', 'acfe'),
|
54 |
+
'menu_name' => __('category', 'acfe'),
|
55 |
+
),
|
56 |
+
));
|
57 |
+
|
58 |
+
}
|
59 |
+
|
60 |
+
/*
|
61 |
+
* Admin Menu
|
62 |
+
*/
|
63 |
+
function admin_menu(){
|
64 |
+
|
65 |
+
if(!acf_get_setting('show_admin'))
|
66 |
+
return;
|
67 |
+
|
68 |
+
add_submenu_page('edit.php?post_type=acf-field-group', __('Categories'), __('Categories'), acf_get_setting('capability'), 'edit-tags.php?taxonomy=acf-field-group-category');
|
69 |
+
|
70 |
+
}
|
71 |
+
|
72 |
+
/*
|
73 |
+
* Menu Parent File
|
74 |
+
*/
|
75 |
+
function parent_file($parent_file){
|
76 |
+
|
77 |
+
global $submenu_file, $current_screen, $pagenow;
|
78 |
+
|
79 |
+
if($current_screen->taxonomy === 'acf-field-group-category' && ($pagenow === 'edit-tags.php' || $pagenow === 'term.php'))
|
80 |
+
$parent_file = 'edit.php?post_type=acf-field-group';
|
81 |
+
|
82 |
+
return $parent_file;
|
83 |
+
|
84 |
+
}
|
85 |
+
|
86 |
+
/*
|
87 |
+
* ACF Field Group: Columns
|
88 |
+
*/
|
89 |
+
function columns($columns){
|
90 |
+
|
91 |
+
$new_columns = array();
|
92 |
+
foreach($columns as $key => $value) {
|
93 |
+
if($key === 'title')
|
94 |
+
$new_columns['acf-field-group-category'] = __('Categories');
|
95 |
+
|
96 |
+
$new_columns[$key] = $value;
|
97 |
+
}
|
98 |
+
|
99 |
+
return $new_columns;
|
100 |
+
|
101 |
+
}
|
102 |
+
|
103 |
+
/*
|
104 |
+
* ACF Field Group: Column HTML
|
105 |
+
*/
|
106 |
+
function column_html($column, $post_id){
|
107 |
+
|
108 |
+
if($column === 'acf-field-group-category'){
|
109 |
+
if(!$terms = get_the_terms($post_id, 'acf-field-group-category')){
|
110 |
+
echo '—';
|
111 |
+
return;
|
112 |
+
}
|
113 |
+
|
114 |
+
$categories = array();
|
115 |
+
foreach($terms as $term){
|
116 |
+
$categories[] = '<a href="' . admin_url('edit.php?acf-field-group-category='.$term->slug.'&post_type=acf-field-group') . '">' . $term->name . '</a>';
|
117 |
+
}
|
118 |
+
|
119 |
+
echo implode(' ', $categories);
|
120 |
+
}
|
121 |
+
|
122 |
+
}
|
123 |
+
|
124 |
+
/*
|
125 |
+
* ACF Field Group: Views
|
126 |
+
*/
|
127 |
+
function views($views){
|
128 |
+
|
129 |
+
if(!$terms = get_terms('acf-field-group-category', array('hide_empty' => false)))
|
130 |
+
return $views;
|
131 |
+
|
132 |
+
foreach($terms as $term){
|
133 |
+
|
134 |
+
$groups = get_posts( array(
|
135 |
+
'post_type' => 'acf-field-group',
|
136 |
+
'posts_per_page' => -1,
|
137 |
+
'suppress_filters' => false,
|
138 |
+
'post_status' => array('publish', 'acf-disabled'),
|
139 |
+
'taxonomy' => 'acf-field-group-category',
|
140 |
+
'term' => $term->slug,
|
141 |
+
'fields' => 'ids'
|
142 |
+
));
|
143 |
+
|
144 |
+
$count = count($groups);
|
145 |
+
|
146 |
+
$html = '';
|
147 |
+
if($count > 0)
|
148 |
+
$html = ' <span class="count">(' . $count . ')</span>';
|
149 |
+
|
150 |
+
global $wp_query;
|
151 |
+
$class = '';
|
152 |
+
if(isset($wp_query->query_vars['acf-field-group-category']) && $wp_query->query_vars['acf-field-group-category'] === $term->slug)
|
153 |
+
$class = ' class="current"';
|
154 |
+
|
155 |
+
$views['category-' . $term->slug] = '<a href="' . admin_url('edit.php?acf-field-group-category=' . $term->slug . '&post_type=acf-field-group') . '"' . $class . '>' . $term->name . $html . '</a>';
|
156 |
+
}
|
157 |
+
|
158 |
+
return $views;
|
159 |
+
|
160 |
+
}
|
161 |
+
|
162 |
+
/*
|
163 |
+
* ACF Exclude Field Group Category from available taxonomies
|
164 |
+
*/
|
165 |
+
function acf_get_taxonomies($taxonomies, $args){
|
166 |
+
|
167 |
+
if(empty($taxonomies))
|
168 |
+
return $taxonomies;
|
169 |
+
|
170 |
+
foreach($taxonomies as $k => $taxonomy){
|
171 |
+
|
172 |
+
if($taxonomy != 'acf-field-group-category')
|
173 |
+
continue;
|
174 |
+
|
175 |
+
unset($taxonomies[$k]);
|
176 |
+
|
177 |
+
}
|
178 |
+
|
179 |
+
return $taxonomies;
|
180 |
+
|
181 |
+
}
|
182 |
+
|
183 |
+
/*
|
184 |
+
* Prepare Export
|
185 |
+
*/
|
186 |
+
function prepare_for_export($field_group){
|
187 |
+
|
188 |
+
$_field_group = acf_get_field_group($field_group['key']);
|
189 |
+
|
190 |
+
if(empty($_field_group))
|
191 |
+
return $field_group;
|
192 |
+
|
193 |
+
if(!acf_maybe_get($_field_group, 'ID'))
|
194 |
+
return $field_group;
|
195 |
+
|
196 |
+
$categories = get_the_terms($_field_group['ID'], 'acf-field-group-category');
|
197 |
+
|
198 |
+
if(empty($categories) || is_wp_error($categories))
|
199 |
+
return $field_group;
|
200 |
+
|
201 |
+
$field_group['acfe_categories'] = array();
|
202 |
+
|
203 |
+
foreach($categories as $term){
|
204 |
+
|
205 |
+
$field_group['acfe_categories'][$term->slug] = $term->name;
|
206 |
+
|
207 |
+
}
|
208 |
+
|
209 |
+
return $field_group;
|
210 |
+
|
211 |
+
}
|
212 |
+
|
213 |
+
/*
|
214 |
+
* Prepare Import
|
215 |
+
*/
|
216 |
+
function prepare_for_import($field_group){
|
217 |
+
|
218 |
+
if(!$categories = acf_maybe_get($field_group, 'acfe_categories'))
|
219 |
+
return;
|
220 |
+
|
221 |
+
foreach($categories as $term_slug => $term_name){
|
222 |
+
|
223 |
+
$new_term_id = false;
|
224 |
+
$get_term = get_term_by('slug', $term_slug, 'acf-field-group-category');
|
225 |
+
|
226 |
+
// Term doesn't exists
|
227 |
+
if(empty($get_term)){
|
228 |
+
|
229 |
+
$new_term = wp_insert_term($term_name, 'acf-field-group-category', array(
|
230 |
+
'slug' => $term_slug
|
231 |
+
));
|
232 |
+
|
233 |
+
if(!is_wp_error($new_term)){
|
234 |
+
|
235 |
+
$new_term_id = $new_term['term_id'];
|
236 |
+
|
237 |
+
}
|
238 |
+
|
239 |
+
// Term already exists
|
240 |
+
}else{
|
241 |
+
|
242 |
+
$new_term_id = $get_term->term_id;
|
243 |
+
|
244 |
+
}
|
245 |
+
|
246 |
+
if($new_term_id){
|
247 |
+
|
248 |
+
wp_set_post_terms($field_group['ID'], array($new_term_id), 'acf-field-group-category', true);
|
249 |
+
|
250 |
+
}
|
251 |
+
|
252 |
+
}
|
253 |
+
|
254 |
+
}
|
255 |
+
|
256 |
+
}
|
257 |
+
|
258 |
+
// initialize
|
259 |
+
new acfe_field_group_category();
|
260 |
+
|
261 |
endif;
|
@@ -1,35 +1,35 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
if(!class_exists('acfe_field_group_display_title')):
|
7 |
-
|
8 |
-
class acfe_field_group_display_title{
|
9 |
-
|
10 |
-
function __construct(){
|
11 |
-
|
12 |
-
add_filter('acfe/prepare_field_group', array($this, 'prepare_field_group'));
|
13 |
-
|
14 |
-
}
|
15 |
-
|
16 |
-
/*
|
17 |
-
* Prepare Field Group
|
18 |
-
*/
|
19 |
-
function prepare_field_group($field_group){
|
20 |
-
|
21 |
-
if(!acf_maybe_get($field_group, 'acfe_display_title'))
|
22 |
-
return $field_group;
|
23 |
-
|
24 |
-
$field_group['title'] = $field_group['acfe_display_title'];
|
25 |
-
|
26 |
-
return $field_group;
|
27 |
-
|
28 |
-
}
|
29 |
-
|
30 |
-
}
|
31 |
-
|
32 |
-
// initialize
|
33 |
-
new acfe_field_group_display_title();
|
34 |
-
|
35 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
if(!class_exists('acfe_field_group_display_title')):
|
7 |
+
|
8 |
+
class acfe_field_group_display_title{
|
9 |
+
|
10 |
+
function __construct(){
|
11 |
+
|
12 |
+
add_filter('acfe/prepare_field_group', array($this, 'prepare_field_group'));
|
13 |
+
|
14 |
+
}
|
15 |
+
|
16 |
+
/*
|
17 |
+
* Prepare Field Group
|
18 |
+
*/
|
19 |
+
function prepare_field_group($field_group){
|
20 |
+
|
21 |
+
if(!acf_maybe_get($field_group, 'acfe_display_title'))
|
22 |
+
return $field_group;
|
23 |
+
|
24 |
+
$field_group['title'] = $field_group['acfe_display_title'];
|
25 |
+
|
26 |
+
return $field_group;
|
27 |
+
|
28 |
+
}
|
29 |
+
|
30 |
+
}
|
31 |
+
|
32 |
+
// initialize
|
33 |
+
new acfe_field_group_display_title();
|
34 |
+
|
35 |
endif;
|
@@ -1,135 +1,135 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
if(!class_exists('acfe_field_group_hide_on_screen')):
|
7 |
-
|
8 |
-
class acfe_field_group_hide_on_screen{
|
9 |
-
|
10 |
-
function __construct(){
|
11 |
-
|
12 |
-
// Field Group
|
13 |
-
add_action('acf/field_group/admin_head', array($this, 'admin_head'));
|
14 |
-
|
15 |
-
// Post Metaboxes
|
16 |
-
add_action('acf/add_meta_boxes', array($this, 'acf_add_meta_boxes'), 10, 3);
|
17 |
-
|
18 |
-
// Hide Block Editor
|
19 |
-
add_action('load-post.php', array($this, 'hide_block_editor'));
|
20 |
-
add_action('load-post-new.php', array($this, 'hide_block_editor'));
|
21 |
-
|
22 |
-
}
|
23 |
-
|
24 |
-
function admin_head(){
|
25 |
-
|
26 |
-
add_filter('acf/prepare_field/name=hide_on_screen', array($this, 'prepare_hide_on_screen'));
|
27 |
-
|
28 |
-
}
|
29 |
-
|
30 |
-
/*
|
31 |
-
* Hide on screen: Settings
|
32 |
-
*/
|
33 |
-
function prepare_hide_on_screen($field){
|
34 |
-
|
35 |
-
$choices = array();
|
36 |
-
|
37 |
-
foreach($field['choices'] as $key => $value){
|
38 |
-
|
39 |
-
if($key === 'the_content'){
|
40 |
-
|
41 |
-
$choices['block_editor'] = __('Block Editor');
|
42 |
-
|
43 |
-
}
|
44 |
-
|
45 |
-
|
46 |
-
$choices[$key] = $value;
|
47 |
-
|
48 |
-
}
|
49 |
-
|
50 |
-
$field['choices'] = $choices;
|
51 |
-
|
52 |
-
return $field;
|
53 |
-
|
54 |
-
}
|
55 |
-
|
56 |
-
/*
|
57 |
-
* Add Metaboxes: Apply all Field Groups styles
|
58 |
-
* Fix ACF only which only use the first Field Group style
|
59 |
-
*/
|
60 |
-
function acf_add_meta_boxes($post_type, $post, $field_groups){
|
61 |
-
|
62 |
-
$instance = acf_get_instance('ACF_Form_Post');
|
63 |
-
|
64 |
-
$styles = '';
|
65 |
-
|
66 |
-
foreach($field_groups as $field_group){
|
67 |
-
|
68 |
-
$styles .= acf_get_field_group_style($field_group);
|
69 |
-
|
70 |
-
}
|
71 |
-
|
72 |
-
$instance->style = $styles;
|
73 |
-
|
74 |
-
}
|
75 |
-
|
76 |
-
/*
|
77 |
-
* Hide Block Editor
|
78 |
-
*/
|
79 |
-
function hide_block_editor(){
|
80 |
-
|
81 |
-
// globals
|
82 |
-
global $typenow;
|
83 |
-
|
84 |
-
// Restrict
|
85 |
-
$restricted = array('acf-field-group', 'attachment');
|
86 |
-
|
87 |
-
if(in_array($typenow, $restricted))
|
88 |
-
return;
|
89 |
-
|
90 |
-
$post_type = $typenow;
|
91 |
-
$post_id = 0;
|
92 |
-
|
93 |
-
if(isset( $_GET['post'])){
|
94 |
-
|
95 |
-
$post_id = (int) $_GET['post'];
|
96 |
-
|
97 |
-
}elseif(isset($_POST['post_ID'])){
|
98 |
-
|
99 |
-
$post_id = (int) $_POST['post_ID'];
|
100 |
-
|
101 |
-
}
|
102 |
-
|
103 |
-
$field_groups = acf_get_field_groups(array(
|
104 |
-
'post_id' => $post_id,
|
105 |
-
'post_type' => $post_type
|
106 |
-
));
|
107 |
-
|
108 |
-
$hide_block_editor = false;
|
109 |
-
|
110 |
-
foreach($field_groups as $field_group){
|
111 |
-
|
112 |
-
$hide_on_screen = acf_get_array($field_group['hide_on_screen']);
|
113 |
-
|
114 |
-
if(!in_array('block_editor', $hide_on_screen))
|
115 |
-
continue;
|
116 |
-
|
117 |
-
$hide_block_editor = true;
|
118 |
-
break;
|
119 |
-
|
120 |
-
}
|
121 |
-
|
122 |
-
if($hide_block_editor){
|
123 |
-
|
124 |
-
add_filter('use_block_editor_for_post_type', '__return_false');
|
125 |
-
|
126 |
-
}
|
127 |
-
|
128 |
-
}
|
129 |
-
|
130 |
-
}
|
131 |
-
|
132 |
-
// initialize
|
133 |
-
new acfe_field_group_hide_on_screen();
|
134 |
-
|
135 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
if(!class_exists('acfe_field_group_hide_on_screen')):
|
7 |
+
|
8 |
+
class acfe_field_group_hide_on_screen{
|
9 |
+
|
10 |
+
function __construct(){
|
11 |
+
|
12 |
+
// Field Group
|
13 |
+
add_action('acf/field_group/admin_head', array($this, 'admin_head'));
|
14 |
+
|
15 |
+
// Post Metaboxes
|
16 |
+
add_action('acf/add_meta_boxes', array($this, 'acf_add_meta_boxes'), 10, 3);
|
17 |
+
|
18 |
+
// Hide Block Editor
|
19 |
+
add_action('load-post.php', array($this, 'hide_block_editor'));
|
20 |
+
add_action('load-post-new.php', array($this, 'hide_block_editor'));
|
21 |
+
|
22 |
+
}
|
23 |
+
|
24 |
+
function admin_head(){
|
25 |
+
|
26 |
+
add_filter('acf/prepare_field/name=hide_on_screen', array($this, 'prepare_hide_on_screen'));
|
27 |
+
|
28 |
+
}
|
29 |
+
|
30 |
+
/*
|
31 |
+
* Hide on screen: Settings
|
32 |
+
*/
|
33 |
+
function prepare_hide_on_screen($field){
|
34 |
+
|
35 |
+
$choices = array();
|
36 |
+
|
37 |
+
foreach($field['choices'] as $key => $value){
|
38 |
+
|
39 |
+
if($key === 'the_content'){
|
40 |
+
|
41 |
+
$choices['block_editor'] = __('Block Editor');
|
42 |
+
|
43 |
+
}
|
44 |
+
|
45 |
+
|
46 |
+
$choices[$key] = $value;
|
47 |
+
|
48 |
+
}
|
49 |
+
|
50 |
+
$field['choices'] = $choices;
|
51 |
+
|
52 |
+
return $field;
|
53 |
+
|
54 |
+
}
|
55 |
+
|
56 |
+
/*
|
57 |
+
* Add Metaboxes: Apply all Field Groups styles
|
58 |
+
* Fix ACF only which only use the first Field Group style
|
59 |
+
*/
|
60 |
+
function acf_add_meta_boxes($post_type, $post, $field_groups){
|
61 |
+
|
62 |
+
$instance = acf_get_instance('ACF_Form_Post');
|
63 |
+
|
64 |
+
$styles = '';
|
65 |
+
|
66 |
+
foreach($field_groups as $field_group){
|
67 |
+
|
68 |
+
$styles .= acf_get_field_group_style($field_group);
|
69 |
+
|
70 |
+
}
|
71 |
+
|
72 |
+
$instance->style = $styles;
|
73 |
+
|
74 |
+
}
|
75 |
+
|
76 |
+
/*
|
77 |
+
* Hide Block Editor
|
78 |
+
*/
|
79 |
+
function hide_block_editor(){
|
80 |
+
|
81 |
+
// globals
|
82 |
+
global $typenow;
|
83 |
+
|
84 |
+
// Restrict
|
85 |
+
$restricted = array('acf-field-group', 'attachment');
|
86 |
+
|
87 |
+
if(in_array($typenow, $restricted))
|
88 |
+
return;
|
89 |
+
|
90 |
+
$post_type = $typenow;
|
91 |
+
$post_id = 0;
|
92 |
+
|
93 |
+
if(isset( $_GET['post'])){
|
94 |
+
|
95 |
+
$post_id = (int) $_GET['post'];
|
96 |
+
|
97 |
+
}elseif(isset($_POST['post_ID'])){
|
98 |
+
|
99 |
+
$post_id = (int) $_POST['post_ID'];
|
100 |
+
|
101 |
+
}
|
102 |
+
|
103 |
+
$field_groups = acf_get_field_groups(array(
|
104 |
+
'post_id' => $post_id,
|
105 |
+
'post_type' => $post_type
|
106 |
+
));
|
107 |
+
|
108 |
+
$hide_block_editor = false;
|
109 |
+
|
110 |
+
foreach($field_groups as $field_group){
|
111 |
+
|
112 |
+
$hide_on_screen = acf_get_array($field_group['hide_on_screen']);
|
113 |
+
|
114 |
+
if(!in_array('block_editor', $hide_on_screen))
|
115 |
+
continue;
|
116 |
+
|
117 |
+
$hide_block_editor = true;
|
118 |
+
break;
|
119 |
+
|
120 |
+
}
|
121 |
+
|
122 |
+
if($hide_block_editor){
|
123 |
+
|
124 |
+
add_filter('use_block_editor_for_post_type', '__return_false');
|
125 |
+
|
126 |
+
}
|
127 |
+
|
128 |
+
}
|
129 |
+
|
130 |
+
}
|
131 |
+
|
132 |
+
// initialize
|
133 |
+
new acfe_field_group_hide_on_screen();
|
134 |
+
|
135 |
endif;
|
@@ -1,57 +1,57 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
if(!class_exists('acfe_field_group_instruction_placement')):
|
7 |
-
|
8 |
-
class acfe_field_group_instruction_placement{
|
9 |
-
|
10 |
-
function __construct(){
|
11 |
-
|
12 |
-
// Field Group
|
13 |
-
add_action('acf/field_group/admin_head', array($this, 'admin_head'));
|
14 |
-
add_filter('acf/validate_field_group', array($this, 'validate_tooltip_compatibility'), 20);
|
15 |
-
|
16 |
-
}
|
17 |
-
|
18 |
-
function admin_head(){
|
19 |
-
|
20 |
-
add_filter('acf/prepare_field/name=instruction_placement', array($this, 'prepare_instruction_placement'));
|
21 |
-
|
22 |
-
}
|
23 |
-
|
24 |
-
/*
|
25 |
-
* Instruction Placement: Settings
|
26 |
-
*/
|
27 |
-
function prepare_instruction_placement($field){
|
28 |
-
|
29 |
-
$field['choices'] = array_merge($field['choices'], array(
|
30 |
-
'above_field' => 'Above fields',
|
31 |
-
'tooltip' => 'Tooltip'
|
32 |
-
));
|
33 |
-
|
34 |
-
return $field;
|
35 |
-
|
36 |
-
}
|
37 |
-
|
38 |
-
/*
|
39 |
-
* Instruction Placement: Tooltip 0.8.7.5 Compatibility
|
40 |
-
*/
|
41 |
-
function validate_tooltip_compatibility($field_group){
|
42 |
-
|
43 |
-
if(acf_maybe_get($field_group, 'instruction_placement') !== 'acfe_instructions_tooltip')
|
44 |
-
return $field_group;
|
45 |
-
|
46 |
-
$field_group['instruction_placement'] = 'tooltip';
|
47 |
-
|
48 |
-
return $field_group;
|
49 |
-
|
50 |
-
}
|
51 |
-
|
52 |
-
}
|
53 |
-
|
54 |
-
// initialize
|
55 |
-
new acfe_field_group_instruction_placement();
|
56 |
-
|
57 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
if(!class_exists('acfe_field_group_instruction_placement')):
|
7 |
+
|
8 |
+
class acfe_field_group_instruction_placement{
|
9 |
+
|
10 |
+
function __construct(){
|
11 |
+
|
12 |
+
// Field Group
|
13 |
+
add_action('acf/field_group/admin_head', array($this, 'admin_head'));
|
14 |
+
add_filter('acf/validate_field_group', array($this, 'validate_tooltip_compatibility'), 20);
|
15 |
+
|
16 |
+
}
|
17 |
+
|
18 |
+
function admin_head(){
|
19 |
+
|
20 |
+
add_filter('acf/prepare_field/name=instruction_placement', array($this, 'prepare_instruction_placement'));
|
21 |
+
|
22 |
+
}
|
23 |
+
|
24 |
+
/*
|
25 |
+
* Instruction Placement: Settings
|
26 |
+
*/
|
27 |
+
function prepare_instruction_placement($field){
|
28 |
+
|
29 |
+
$field['choices'] = array_merge($field['choices'], array(
|
30 |
+
'above_field' => 'Above fields',
|
31 |
+
'tooltip' => 'Tooltip'
|
32 |
+
));
|
33 |
+
|
34 |
+
return $field;
|
35 |
+
|
36 |
+
}
|
37 |
+
|
38 |
+
/*
|
39 |
+
* Instruction Placement: Tooltip 0.8.7.5 Compatibility
|
40 |
+
*/
|
41 |
+
function validate_tooltip_compatibility($field_group){
|
42 |
+
|
43 |
+
if(acf_maybe_get($field_group, 'instruction_placement') !== 'acfe_instructions_tooltip')
|
44 |
+
return $field_group;
|
45 |
+
|
46 |
+
$field_group['instruction_placement'] = 'tooltip';
|
47 |
+
|
48 |
+
return $field_group;
|
49 |
+
|
50 |
+
}
|
51 |
+
|
52 |
+
}
|
53 |
+
|
54 |
+
// initialize
|
55 |
+
new acfe_field_group_instruction_placement();
|
56 |
+
|
57 |
endif;
|
@@ -1,184 +1,184 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if(!defined('ABSPATH'))
|
4 |
-
exit;
|
5 |
-
|
6 |
-
// Check setting
|
7 |
-
if(acfe_get_setting('modules/field_group_ui'))
|
8 |
-
return;
|
9 |
-
|
10 |
-
if(!class_exists('acfe_field_group_meta')):
|
11 |
-
|
12 |
-
class acfe_field_group_meta{
|
13 |
-
|
14 |
-
function __construct(){
|
15 |
-
|
16 |
-
add_action('acf/field_group/admin_head', array($this, 'admin_head'));
|
17 |
-
add_action('acf/field_group/admin_head', array($this, 'prepare_meta'));
|
18 |
-
|
19 |
-
}
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Admin Head
|
23 |
-
*/
|
24 |
-
function admin_head(){
|
25 |
-
|
26 |
-
add_action('acf/render_field/name=acfe_data', array($this, 'render_data'));
|
27 |
-
|
28 |
-
add_meta_box('acf-field-group-acfe', __('Field group', 'acf'), array($this, 'render_metabox'), 'acf-field-group', 'normal');
|
29 |
-
|
30 |
-
}
|
31 |
-
|
32 |
-
/*
|
33 |
-
* Render Metabox
|
34 |
-
*/
|
35 |
-
function render_metabox(){
|
36 |
-
|
37 |
-
global $field_group;
|
38 |
-
|
39 |
-
// Meta
|
40 |
-
acf_render_field_wrap(array(
|
41 |
-
'label' => __('Custom meta data'),
|
42 |
-
'name' => 'acfe_meta',
|
43 |
-
'key' => 'acfe_meta',
|
44 |
-
'instructions' => __('Add custom meta data to the field group.'),
|
45 |
-
'prefix' => 'acf_field_group',
|
46 |
-
'type' => 'repeater',
|
47 |
-
'button_label' => __('+ Meta'),
|
48 |
-
'required' => false,
|
49 |
-
'layout' => 'table',
|
50 |
-
'value' => (isset($field_group['acfe_meta'])) ? $field_group['acfe_meta'] : array(),
|
51 |
-
'wrapper' => array(
|
52 |
-
'data-enable-switch' => true
|
53 |
-
),
|
54 |
-
'sub_fields' => array(
|
55 |
-
array(
|
56 |
-
'ID' => false,
|
57 |
-
'label' => __('Key'),
|
58 |
-
'name' => 'acfe_meta_key',
|
59 |
-
'key' => 'acfe_meta_key',
|
60 |
-
'prefix' => '',
|
61 |
-
'_name' => '',
|
62 |
-
'_prepare' => '',
|
63 |
-
'type' => 'text',
|
64 |
-
'instructions' => false,
|
65 |
-
'required' => false,
|
66 |
-
'wrapper' => array(
|
67 |
-
'width' => '',
|
68 |
-
'class' => '',
|
69 |
-
'id' => '',
|
70 |
-
),
|
71 |
-
),
|
72 |
-
array(
|
73 |
-
'ID' => false,
|
74 |
-
'label' => __('Value'),
|
75 |
-
'name' => 'acfe_meta_value',
|
76 |
-
'key' => 'acfe_meta_value',
|
77 |
-
'prefix' => '',
|
78 |
-
'_name' => '',
|
79 |
-
'_prepare' => '',
|
80 |
-
'type' => 'text',
|
81 |
-
'instructions' => false,
|
82 |
-
'required' => false,
|
83 |
-
'wrapper' => array(
|
84 |
-
'width' => '',
|
85 |
-
'class' => '',
|
86 |
-
'id' => '',
|
87 |
-
),
|
88 |
-
),
|
89 |
-
)
|
90 |
-
|
91 |
-
|
92 |
-
// Note
|
93 |
-
acf_render_field_wrap(array(
|
94 |
-
'label' => __('Note'),
|
95 |
-
'name' => 'acfe_note',
|
96 |
-
'prefix' => 'acf_field_group',
|
97 |
-
'type' => 'textarea',
|
98 |
-
'instructions' => __('Add personal note. Only visible to administrators'),
|
99 |
-
'value' => (isset($field_group['acfe_note'])) ? $field_group['acfe_note'] : '',
|
100 |
-
'required' => false,
|
101 |
-
'wrapper' => array(
|
102 |
-
'data-enable-switch' => true
|
103 |
-
),
|
104 |
-
));
|
105 |
-
|
106 |
-
// Data
|
107 |
-
acf_render_field_wrap(array(
|
108 |
-
'label' => __('Field group data'),
|
109 |
-
'instructions' => __('View raw field group data, for development use'),
|
110 |
-
'type' => 'acfe_dynamic_message',
|
111 |
-
'name' => 'acfe_data',
|
112 |
-
'prefix' => 'acf_field_group',
|
113 |
-
'value' => $field_group['key'],
|
114 |
-
));
|
115 |
-
|
116 |
-
?>
|
117 |
-
<script type="text/javascript">
|
118 |
-
if(typeof acf !== 'undefined'){
|
119 |
-
acf.postbox.render({
|
120 |
-
'id': 'acf-field-group-acfe',
|
121 |
-
'label': 'left'
|
122 |
-
});
|
123 |
-
}
|
124 |
-
</script>
|
125 |
-
<?php
|
126 |
-
}
|
127 |
-
|
128 |
-
/*
|
129 |
-
* Render: Data button
|
130 |
-
*/
|
131 |
-
function render_data($field){
|
132 |
-
|
133 |
-
$field_group = acf_get_field_group($field['value']);
|
134 |
-
|
135 |
-
if(!$field_group){
|
136 |
-
|
137 |
-
echo '<a href="#" class="button disabled" disabled>' . __('Data') . '</a>';
|
138 |
-
return;
|
139 |
-
|
140 |
-
}
|
141 |
-
|
142 |
-
$field_group_key = $field_group['key'];
|
143 |
-
$raw_field_group = get_post($field_group['ID']);
|
144 |
-
|
145 |
-
?>
|
146 |
-
<a href="#" class="acf-button button acfe_modal_open" data-modal-key="<?php echo $field_group_key; ?>"><?php _e('Data'); ?></a>
|
147 |
-
<div class="acfe-modal" data-modal-key="<?php echo $field_group_key; ?>">
|
148 |
-
<div style="padding:15px;">
|
149 |
-
<pre style="margin-bottom:15px;"><?php print_r($field_group); ?></pre>
|
150 |
-
<pre><?php print_r($raw_field_group); ?></pre>
|
151 |
-
</div>
|
152 |
-
</div>
|
153 |
-
<?php
|
154 |
-
|
155 |
-
}
|
156 |
-
|
157 |
-
/*
|
158 |
-
* Prepare Meta
|
159 |
-
*/
|
160 |
-
function prepare_meta(){
|
161 |
-
|
162 |
-
$names = array('acfe_meta', 'acfe_meta_key', 'acfe_meta_value');
|
163 |
-
|
164 |
-
foreach($names as $name){
|
165 |
-
|
166 |
-
add_filter("acf/prepare_field/name={$name}", function($field){
|
167 |
-
|
168 |
-
$field['prefix'] = str_replace('row-', '', $field['prefix']);
|
169 |
-
$field['name'] = str_replace('row-', '', $field['name']);
|
170 |
-
|
171 |
-
return $field;
|
172 |
-
|
173 |
-
});
|
174 |
-
|
175 |
-
}
|
176 |
-
|
177 |
-
}
|
178 |
-
|
179 |
-
}
|
180 |
-
|
181 |
-
// initialize
|
182 |
-
new acfe_field_group_meta();
|
183 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
// Check setting
|
7 |
+
if(acfe_get_setting('modules/field_group_ui'))
|
8 |
+
return;
|
9 |
+
|
10 |
+
if(!class_exists('acfe_field_group_meta')):
|
11 |
+
|
12 |
+
class acfe_field_group_meta{
|
13 |
+
|
14 |
+
function __construct(){
|
15 |
+
|
16 |
+
add_action('acf/field_group/admin_head', array($this, 'admin_head'));
|
17 |
+
add_action('acf/field_group/admin_head', array($this, 'prepare_meta'));
|
18 |
+
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Admin Head
|
23 |
+
*/
|
24 |
+
function admin_head(){
|
25 |
+
|
26 |
+
add_action('acf/render_field/name=acfe_data', array($this, 'render_data'));
|
27 |
+
|
28 |
+
add_meta_box('acf-field-group-acfe', __('Field group', 'acf'), array($this, 'render_metabox'), 'acf-field-group', 'normal');
|
29 |
+
|
30 |
+
}
|
31 |
+
|
32 |
+
/*
|
33 |
+
* Render Metabox
|
34 |
+
*/
|
35 |
+
function render_metabox(){
|
36 |
+
|
37 |
+
global $field_group;
|
38 |
+
|
39 |
+
// Meta
|
40 |
+
acf_render_field_wrap(array(
|
41 |
+
'label' => __('Custom meta data'),
|
42 |
+
'name' => 'acfe_meta',
|
43 |
+
'key' => 'acfe_meta',
|
44 |
+
'instructions' => __('Add custom meta data to the field group.'),
|
45 |
+
'prefix' => 'acf_field_group',
|
46 |
+
'type' => 'repeater',
|
47 |
+
'button_label' => __('+ Meta'),
|
48 |
+
'required' => false,
|
49 |
+
'layout' => 'table',
|
50 |
+
'value' => (isset($field_group['acfe_meta'])) ? $field_group['acfe_meta'] : array(),
|
51 |
+
'wrapper' => array(
|
52 |
+
'data-enable-switch' => true
|
53 |
+
),
|
54 |
+
'sub_fields' => array(
|
55 |
+
array(
|
56 |
+
'ID' => false,
|
57 |
+
'label' => __('Key'),
|
58 |
+
'name' => 'acfe_meta_key',
|
59 |
+
'key' => 'acfe_meta_key',
|
60 |
+
'prefix' => '',
|
61 |
+
'_name' => '',
|
62 |
+
'_prepare' => '',
|
63 |
+
'type' => 'text',
|
64 |
+
'instructions' => false,
|
65 |
+
'required' => false,
|
66 |
+
'wrapper' => array(
|
67 |
+
'width' => '',
|
68 |
+
'class' => '',
|
69 |
+
'id' => '',
|
70 |
+
),
|
71 |
+
),
|
72 |
+
array(
|
73 |
+
'ID' => false,
|
74 |
+
'label' => __('Value'),
|
75 |
+
'name' => 'acfe_meta_value',
|
76 |
+
'key' => 'acfe_meta_value',
|
77 |
+
'prefix' => '',
|
78 |
+
'_name' => '',
|
79 |
+
'_prepare' => '',
|
80 |
+
'type' => 'text',
|
81 |
+
'instructions' => false,
|
82 |
+
'required' => false,
|
83 |
+
'wrapper' => array(
|
84 |
+
'width' => '',
|
85 |
+
'class' => '',
|
86 |
+
'id' => '',
|
87 |
+
),
|
88 |
+
),
|
89 |
+
)
|
90 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|