Version Description
- Maintenance work on ACF repeater fields inside of nested content
Download this release
Release Info
Developer | adbox |
Plugin | WordPress Landing Pages |
Version | 2.6.5 |
Comparing to | |
See all releases |
Code changes from version 2.6.4 to 2.6.5
- classes/class.acf-integration.php +38 -3
- classes/class.landing-pages.php +3 -0
- landing-pages.php +2 -2
- readme.txt +4 -1
- shared/assets/plugins/advanced-custom-fields/FETCH_HEAD +1 -0
- shared/assets/plugins/advanced-custom-fields/HEAD +1 -0
- shared/assets/plugins/advanced-custom-fields/README.md +11 -0
- shared/assets/plugins/advanced-custom-fields/acf.php +983 -963
- shared/assets/plugins/advanced-custom-fields/composer.json +16 -0
- shared/assets/plugins/advanced-custom-fields/config +6 -0
- shared/assets/plugins/advanced-custom-fields/config.codekit +1929 -0
- shared/assets/plugins/advanced-custom-fields/core/actions/export.php +275 -275
- shared/assets/plugins/advanced-custom-fields/core/api.php +1668 -1668
- shared/assets/plugins/advanced-custom-fields/core/controllers/addons.php +286 -286
- shared/assets/plugins/advanced-custom-fields/core/controllers/everything_fields.php +881 -881
- shared/assets/plugins/advanced-custom-fields/core/controllers/export.php +508 -508
- shared/assets/plugins/advanced-custom-fields/core/controllers/field_group.php +987 -987
- shared/assets/plugins/advanced-custom-fields/core/controllers/field_groups.php +529 -529
- shared/assets/plugins/advanced-custom-fields/core/controllers/input.php +169 -169
- shared/assets/plugins/advanced-custom-fields/core/controllers/location.php +986 -986
- shared/assets/plugins/advanced-custom-fields/core/controllers/post.php +570 -570
- shared/assets/plugins/advanced-custom-fields/core/controllers/revisions.php +305 -316
- shared/assets/plugins/advanced-custom-fields/core/controllers/third_party.php +233 -233
- shared/assets/plugins/advanced-custom-fields/core/controllers/upgrade.php +828 -828
- shared/assets/plugins/advanced-custom-fields/core/early-access.php +351 -0
- shared/assets/plugins/advanced-custom-fields/core/fields/_base.php +190 -190
- shared/assets/plugins/advanced-custom-fields/core/fields/_functions.php +597 -597
- shared/assets/plugins/advanced-custom-fields/core/fields/checkbox.php +209 -209
- shared/assets/plugins/advanced-custom-fields/core/fields/color_picker.php +109 -109
- shared/assets/plugins/advanced-custom-fields/core/fields/date_picker/date_picker.php +182 -182
- shared/assets/plugins/advanced-custom-fields/core/fields/date_picker/jquery.ui.datepicker.js +1814 -1814
- shared/assets/plugins/advanced-custom-fields/core/fields/date_picker/style.date_picker.css +409 -409
- shared/assets/plugins/advanced-custom-fields/core/fields/dummy.php +278 -278
- shared/assets/plugins/advanced-custom-fields/core/fields/email.php +172 -172
- shared/assets/plugins/advanced-custom-fields/core/fields/file.php +398 -398
- shared/assets/plugins/advanced-custom-fields/core/fields/google-map.php +318 -317
- shared/assets/plugins/advanced-custom-fields/core/fields/image.php +457 -457
- shared/assets/plugins/advanced-custom-fields/core/fields/message.php +92 -92
- shared/assets/plugins/advanced-custom-fields/core/fields/number.php +273 -273
- shared/assets/plugins/advanced-custom-fields/core/fields/page_link.php +218 -218
- shared/assets/plugins/advanced-custom-fields/core/fields/password.php +154 -154
- shared/assets/plugins/advanced-custom-fields/core/fields/post_object.php +544 -544
- shared/assets/plugins/advanced-custom-fields/core/fields/radio.php +279 -279
- shared/assets/plugins/advanced-custom-fields/core/fields/relationship.php +904 -904
- shared/assets/plugins/advanced-custom-fields/core/fields/select.php +357 -357
- shared/assets/plugins/advanced-custom-fields/core/fields/tab.php +80 -80
- shared/assets/plugins/advanced-custom-fields/core/fields/taxonomy.php +630 -630
- shared/assets/plugins/advanced-custom-fields/core/fields/text.php +278 -278
- shared/assets/plugins/advanced-custom-fields/core/fields/textarea.php +234 -234
- shared/assets/plugins/advanced-custom-fields/core/fields/true_false.php +139 -139
- shared/assets/plugins/advanced-custom-fields/core/fields/user.php +381 -381
- shared/assets/plugins/advanced-custom-fields/core/fields/wysiwyg.php +0 -364
classes/class.acf-integration.php
CHANGED
@@ -397,28 +397,63 @@ class Landing_Pages_ACF {
|
|
397 |
public static function get_repeater_values( $array , $field , $needle ) {
|
398 |
|
399 |
/* Discover correct repeater pointer by parsing field name */
|
400 |
-
|
401 |
|
402 |
/* if not a repeater subfield then bail */
|
403 |
-
if (!$matches) {
|
404 |
return false;
|
405 |
}
|
406 |
|
407 |
-
$pointer = str_replace('_' , '' , $matches[0]);
|
408 |
$repeater_key = self::key_search($array, $field , true ); /* returns parent flexible content field key using sub field key */
|
409 |
|
410 |
|
411 |
/* */
|
412 |
if ( $repeater_key && $repeater_key !== '0' && isset($array[$repeater_key][$pointer][$field['key']])){
|
|
|
|
|
|
|
413 |
return $array[$repeater_key][$pointer][$field['key']];
|
414 |
}
|
415 |
|
416 |
/* repeater field comes after the pointer???? */
|
417 |
if (isset($array[$pointer][$needle])){
|
|
|
|
|
418 |
return $array[$pointer][$needle];
|
419 |
}
|
420 |
|
421 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
422 |
|
423 |
return '';
|
424 |
|
397 |
public static function get_repeater_values( $array , $field , $needle ) {
|
398 |
|
399 |
/* Discover correct repeater pointer by parsing field name */
|
400 |
+
preg_match_all('/(_\d_)/', $field['name'], $matches, PREG_PATTERN_ORDER, 0);
|
401 |
|
402 |
/* if not a repeater subfield then bail */
|
403 |
+
if (!$matches || !$matches[0]) {
|
404 |
return false;
|
405 |
}
|
406 |
|
407 |
+
$pointer = str_replace('_' , '' , $matches[0][0]);
|
408 |
$repeater_key = self::key_search($array, $field , true ); /* returns parent flexible content field key using sub field key */
|
409 |
|
410 |
|
411 |
/* */
|
412 |
if ( $repeater_key && $repeater_key !== '0' && isset($array[$repeater_key][$pointer][$field['key']])){
|
413 |
+
/* if the value is empty, mark as empty */
|
414 |
+
if($array[$repeater_key][$pointer][$field['key']] === ''){$array[$repeater_key][$pointer][$field['key']] = '_empty';}
|
415 |
+
|
416 |
return $array[$repeater_key][$pointer][$field['key']];
|
417 |
}
|
418 |
|
419 |
/* repeater field comes after the pointer???? */
|
420 |
if (isset($array[$pointer][$needle])){
|
421 |
+
if($array[$pointer][$needle] === ''){$array[$pointer][$needle] = '_empty';}
|
422 |
+
|
423 |
return $array[$pointer][$needle];
|
424 |
}
|
425 |
|
426 |
|
427 |
+
|
428 |
+
/* if the repeater is nested in a flexible content field */
|
429 |
+
if(isset($matches[0][1])){
|
430 |
+
$nested_value = null;
|
431 |
+
$parent_field = $field['parent'];
|
432 |
+
$sub_pointer = str_replace('_' , '' , $matches[0][1]);
|
433 |
+
|
434 |
+
if(isset($array[$pointer][$parent_field][$sub_pointer][$field['key']])){
|
435 |
+
$nested_value = $array[$pointer][$parent_field][$sub_pointer][$field['key']];
|
436 |
+
}
|
437 |
+
|
438 |
+
/* if the nested repeater's indexes are field keys instead of numbers */
|
439 |
+
if( isset($array[$repeater_key][$parent_field]) &&
|
440 |
+
is_array($array[$repeater_key][$parent_field]) &&
|
441 |
+
!isset($array[$repeater_key][$parent_field][0]))
|
442 |
+
{
|
443 |
+
/* get the numerical indexes of the keys */
|
444 |
+
$keys = array_keys($array[$repeater_key][$parent_field]);
|
445 |
+
|
446 |
+
$nested_value = $array[$repeater_key][$parent_field][$keys[$sub_pointer]][$field['key']];
|
447 |
+
|
448 |
+
}
|
449 |
+
|
450 |
+
/* if the value is empty, mark it as empty */
|
451 |
+
if($nested_value === ''){$nested_value = '_empty';}
|
452 |
+
|
453 |
+
if(isset($nested_value)){
|
454 |
+
return $nested_value;
|
455 |
+
}
|
456 |
+
}
|
457 |
|
458 |
return '';
|
459 |
|
classes/class.landing-pages.php
CHANGED
@@ -320,6 +320,9 @@ class Landing_Pages_Template_Switcher {
|
|
320 |
$wpfl = new WP_Featherlight_Scripts(plugin_dir_url( 'wp-featherlight' ) , '');
|
321 |
$wpfl->load_css();
|
322 |
}
|
|
|
|
|
|
|
323 |
}
|
324 |
|
325 |
/**
|
320 |
$wpfl = new WP_Featherlight_Scripts(plugin_dir_url( 'wp-featherlight' ) , '');
|
321 |
$wpfl->load_css();
|
322 |
}
|
323 |
+
|
324 |
+
/* easy way for 3rd parties to hook into */
|
325 |
+
do_action('load_misc_plugin_support');
|
326 |
}
|
327 |
|
328 |
/**
|
landing-pages.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Landing Pages
|
4 |
Plugin URI: http://www.inboundnow.com/landing-pages/
|
5 |
Description: Landing page template framework with variant testing and lead capturing through cooperation with Inbound Now's Leads plugin. This is the stand alone version served through WordPress.org.
|
6 |
-
Version: 2.6.
|
7 |
Author: Inbound Now
|
8 |
Author URI: http://www.inboundnow.com/
|
9 |
|
@@ -41,7 +41,7 @@ if (!class_exists('Inbound_Landing_Pages_Plugin')) {
|
|
41 |
*/
|
42 |
private static function load_constants() {
|
43 |
|
44 |
-
define('LANDINGPAGES_CURRENT_VERSION', '2.6.
|
45 |
define('LANDINGPAGES_URLPATH', plugins_url( '/' , __FILE__ ) );
|
46 |
define('LANDINGPAGES_PATH', WP_PLUGIN_DIR.'/'.plugin_basename( dirname(__FILE__) ).'/' );
|
47 |
define('LANDINGPAGES_PLUGIN_SLUG', 'landing-pages' );
|
3 |
Plugin Name: Landing Pages
|
4 |
Plugin URI: http://www.inboundnow.com/landing-pages/
|
5 |
Description: Landing page template framework with variant testing and lead capturing through cooperation with Inbound Now's Leads plugin. This is the stand alone version served through WordPress.org.
|
6 |
+
Version: 2.6.5
|
7 |
Author: Inbound Now
|
8 |
Author URI: http://www.inboundnow.com/
|
9 |
|
41 |
*/
|
42 |
private static function load_constants() {
|
43 |
|
44 |
+
define('LANDINGPAGES_CURRENT_VERSION', '2.6.5' );
|
45 |
define('LANDINGPAGES_URLPATH', plugins_url( '/' , __FILE__ ) );
|
46 |
define('LANDINGPAGES_PATH', WP_PLUGIN_DIR.'/'.plugin_basename( dirname(__FILE__) ).'/' );
|
47 |
define('LANDINGPAGES_PLUGIN_SLUG', 'landing-pages' );
|
readme.txt
CHANGED
@@ -7,7 +7,7 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
|
7 |
Tags: landing pages, inbound marketing, conversion pages, split testing, a b test, a b testing, a/b test, a/b testing, coming soon page, email list, landing page, list building, maintenance page, squeeze page, inbound now, landing-pages, splash pages, cpa, click tracking, goal tracking, analytics, free landing page templates
|
8 |
Requires at least: 3.8
|
9 |
Tested up to: 4.8.1
|
10 |
-
Stable Tag: 2.6.
|
11 |
|
12 |
|
13 |
Create landing pages for your WordPress site. Monitor and improve conversion rates, run A/B split tests, customize your own templates and more.
|
@@ -85,6 +85,9 @@ We also offer a guide for using <a href="https://github.com/inboundnow/inbound-p
|
|
85 |
|
86 |
== Changelog ==
|
87 |
|
|
|
|
|
|
|
88 |
= 2.6.4 =
|
89 |
* Updating readme links
|
90 |
|
7 |
Tags: landing pages, inbound marketing, conversion pages, split testing, a b test, a b testing, a/b test, a/b testing, coming soon page, email list, landing page, list building, maintenance page, squeeze page, inbound now, landing-pages, splash pages, cpa, click tracking, goal tracking, analytics, free landing page templates
|
8 |
Requires at least: 3.8
|
9 |
Tested up to: 4.8.1
|
10 |
+
Stable Tag: 2.6.5
|
11 |
|
12 |
|
13 |
Create landing pages for your WordPress site. Monitor and improve conversion rates, run A/B split tests, customize your own templates and more.
|
85 |
|
86 |
== Changelog ==
|
87 |
|
88 |
+
= 2.6.5 =
|
89 |
+
* Maintenance work on ACF repeater fields inside of nested content
|
90 |
+
|
91 |
= 2.6.4 =
|
92 |
* Updating readme links
|
93 |
|
shared/assets/plugins/advanced-custom-fields/FETCH_HEAD
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
b65534f71d0efff916a133609aee3d98a8b1c7de branch 'master' of https://github.com/elliotcondon/acf
|
shared/assets/plugins/advanced-custom-fields/HEAD
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
ref: refs/heads/master
|
shared/assets/plugins/advanced-custom-fields/README.md
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Advanced Custom Fields
|
2 |
+
|
3 |
+
Welcome to the official repository for Advanced Custom Fields WordPress plugin.
|
4 |
+
|
5 |
+
-----------------------
|
6 |
+
|
7 |
+
* Readme : https://github.com/elliotcondon/acf/blob/master/readme.txt
|
8 |
+
* WordPress repository: https://wordpress.org/plugins/advanced-custom-fields/
|
9 |
+
* Website : http://www.advancedcustomfields.com/
|
10 |
+
* Documentation: http://www.advancedcustomfields.com/resources/
|
11 |
+
* Support: http://support.advancedcustomfields.com/
|
shared/assets/plugins/advanced-custom-fields/acf.php
CHANGED
@@ -1,963 +1,983 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Plugin Name: Advanced Custom Fields
|
4 |
-
Plugin URI: http://www.advancedcustomfields.com/
|
5 |
-
Description: Customise WordPress with powerful, professional and intuitive fields
|
6 |
-
Version: 4.4.
|
7 |
-
Author: Elliot Condon
|
8 |
-
Author URI: http://www.elliotcondon.com/
|
9 |
-
License: GPL
|
10 |
-
Copyright: Elliot Condon
|
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 |
-
$this
|
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 |
-
if
|
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 |
-
if(
|
186 |
-
|
187 |
-
$post_id =
|
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 |
-
include_once('core/fields/
|
404 |
-
include_once('core/fields/
|
405 |
-
|
406 |
-
include_once('core/fields/
|
407 |
-
|
408 |
-
include_once('core/fields/
|
409 |
-
include_once('core/fields/
|
410 |
-
include_once('core/fields/
|
411 |
-
|
412 |
-
include_once('core/fields/
|
413 |
-
|
414 |
-
include_once('core/fields/
|
415 |
-
|
416 |
-
include_once('core/fields/
|
417 |
-
|
418 |
-
include_once('core/fields/
|
419 |
-
include_once('core/fields/
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
'
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
'
|
545 |
-
'
|
546 |
-
'
|
547 |
-
|
548 |
-
|
549 |
-
'
|
550 |
-
'
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
// register acf
|
562 |
-
$
|
563 |
-
|
564 |
-
'
|
565 |
-
'
|
566 |
-
'
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
*
|
662 |
-
*
|
663 |
-
*
|
664 |
-
*
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
*
|
866 |
-
*
|
867 |
-
* This
|
868 |
-
*
|
869 |
-
*
|
870 |
-
* @
|
871 |
-
*
|
872 |
-
*
|
873 |
-
* @
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
*
|
887 |
-
*
|
888 |
-
*
|
889 |
-
*
|
890 |
-
* @
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
{
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Advanced Custom Fields
|
4 |
+
Plugin URI: http://www.advancedcustomfields.com/
|
5 |
+
Description: Customise WordPress with powerful, professional and intuitive fields
|
6 |
+
Version: 4.4.12
|
7 |
+
Author: Elliot Condon
|
8 |
+
Author URI: http://www.elliotcondon.com/
|
9 |
+
License: GPL
|
10 |
+
Copyright: Elliot Condon
|
11 |
+
Text Domain: acf
|
12 |
+
Domain Path: /lang
|
13 |
+
*/
|
14 |
+
|
15 |
+
if( !class_exists('acf') ):
|
16 |
+
|
17 |
+
class acf {
|
18 |
+
|
19 |
+
/** @var string The plugin version number */
|
20 |
+
var $version = '4.4.12';
|
21 |
+
|
22 |
+
|
23 |
+
/** @var array The plugin settings array */
|
24 |
+
var $settings = array();
|
25 |
+
|
26 |
+
|
27 |
+
/*
|
28 |
+
* Constructor
|
29 |
+
*
|
30 |
+
* This function will construct all the neccessary actions, filters and functions for the ACF plugin to work
|
31 |
+
*
|
32 |
+
* @type function
|
33 |
+
* @date 23/06/12
|
34 |
+
* @since 1.0.0
|
35 |
+
*
|
36 |
+
* @param N/A
|
37 |
+
* @return N/A
|
38 |
+
*/
|
39 |
+
|
40 |
+
function __construct() {
|
41 |
+
|
42 |
+
// helpers
|
43 |
+
add_filter('acf/helpers/get_path', array($this, 'helpers_get_path'), 1, 1);
|
44 |
+
add_filter('acf/helpers/get_dir', array($this, 'helpers_get_dir'), 1, 1);
|
45 |
+
|
46 |
+
|
47 |
+
// vars
|
48 |
+
$this->settings = array(
|
49 |
+
|
50 |
+
// basic
|
51 |
+
'name' => __('Advanced Custom Fields', 'acf'),
|
52 |
+
'version' => $this->version,
|
53 |
+
|
54 |
+
// urls
|
55 |
+
'file' => __FILE__,
|
56 |
+
'path' => apply_filters('acf/helpers/get_path', __FILE__),
|
57 |
+
'dir' => apply_filters('acf/helpers/get_dir', __FILE__),
|
58 |
+
'basename' => plugin_basename( __FILE__ ),
|
59 |
+
|
60 |
+
// options
|
61 |
+
'include_3rd_party' => false
|
62 |
+
);
|
63 |
+
|
64 |
+
|
65 |
+
// set text domain
|
66 |
+
load_textdomain('acf', $this->settings['path'] . 'lang/acf-' . get_locale() . '.mo');
|
67 |
+
|
68 |
+
|
69 |
+
// actions
|
70 |
+
add_action('init', array($this, 'init'), 1);
|
71 |
+
add_action('acf/pre_save_post', array($this, 'save_post_lock'), 0);
|
72 |
+
add_action('acf/pre_save_post', array($this, 'save_post_unlock'), 999);
|
73 |
+
add_action('acf/save_post', array($this, 'save_post_lock'), 0);
|
74 |
+
add_action('acf/save_post', array($this, 'save_post'), 10);
|
75 |
+
add_action('acf/save_post', array($this, 'save_post_unlock'), 999);
|
76 |
+
add_action('acf/create_fields', array($this, 'create_fields'), 1, 2);
|
77 |
+
|
78 |
+
|
79 |
+
// filters
|
80 |
+
add_filter('acf/get_info', array($this, 'get_info'), 1, 1);
|
81 |
+
add_filter('acf/parse_types', array($this, 'parse_types'), 1, 1);
|
82 |
+
add_filter('acf/get_post_types', array($this, 'get_post_types'), 1, 3);
|
83 |
+
add_filter('acf/get_taxonomies_for_select', array($this, 'get_taxonomies_for_select'), 1, 2);
|
84 |
+
add_filter('acf/get_image_sizes', array($this, 'get_image_sizes'), 1, 1);
|
85 |
+
add_filter('acf/get_post_id', array($this, 'get_post_id'), 1, 1);
|
86 |
+
|
87 |
+
|
88 |
+
// includes
|
89 |
+
$this->include_before_theme();
|
90 |
+
add_action('after_setup_theme', array($this, 'include_after_theme'), 1);
|
91 |
+
add_action('after_setup_theme', array($this, 'include_3rd_party'), 1);
|
92 |
+
|
93 |
+
}
|
94 |
+
|
95 |
+
|
96 |
+
/*
|
97 |
+
* helpers_get_path
|
98 |
+
*
|
99 |
+
* This function will calculate the path to a file
|
100 |
+
*
|
101 |
+
* @type function
|
102 |
+
* @date 30/01/13
|
103 |
+
* @since 3.6.0
|
104 |
+
*
|
105 |
+
* @param $file (file) a reference to the file
|
106 |
+
* @return (string)
|
107 |
+
*/
|
108 |
+
|
109 |
+
function helpers_get_path( $file )
|
110 |
+
{
|
111 |
+
return trailingslashit(dirname($file));
|
112 |
+
}
|
113 |
+
|
114 |
+
|
115 |
+
/*
|
116 |
+
* helpers_get_dir
|
117 |
+
*
|
118 |
+
* This function will calculate the directory (URL) to a file
|
119 |
+
*
|
120 |
+
* @type function
|
121 |
+
* @date 30/01/13
|
122 |
+
* @since 3.6.0
|
123 |
+
*
|
124 |
+
* @param $file (file) a reference to the file
|
125 |
+
* @return (string)
|
126 |
+
*/
|
127 |
+
|
128 |
+
function helpers_get_dir( $file )
|
129 |
+
{
|
130 |
+
$dir = trailingslashit(dirname($file));
|
131 |
+
$count = 0;
|
132 |
+
|
133 |
+
|
134 |
+
// sanitize for Win32 installs
|
135 |
+
$dir = str_replace('\\' ,'/', $dir);
|
136 |
+
|
137 |
+
|
138 |
+
// if file is in plugins folder
|
139 |
+
$wp_plugin_dir = str_replace('\\' ,'/', WP_PLUGIN_DIR);
|
140 |
+
$dir = str_replace($wp_plugin_dir, plugins_url(), $dir, $count);
|
141 |
+
|
142 |
+
|
143 |
+
if( $count < 1 )
|
144 |
+
{
|
145 |
+
// if file is in wp-content folder
|
146 |
+
$wp_content_dir = str_replace('\\' ,'/', WP_CONTENT_DIR);
|
147 |
+
$dir = str_replace($wp_content_dir, content_url(), $dir, $count);
|
148 |
+
}
|
149 |
+
|
150 |
+
|
151 |
+
if( $count < 1 )
|
152 |
+
{
|
153 |
+
// if file is in ??? folder
|
154 |
+
$wp_dir = str_replace('\\' ,'/', ABSPATH);
|
155 |
+
$dir = str_replace($wp_dir, site_url('/'), $dir);
|
156 |
+
}
|
157 |
+
|
158 |
+
|
159 |
+
return $dir;
|
160 |
+
}
|
161 |
+
|
162 |
+
|
163 |
+
/*
|
164 |
+
* acf/get_post_id
|
165 |
+
*
|
166 |
+
* A helper function to filter the post_id variable.
|
167 |
+
*
|
168 |
+
* @type filter
|
169 |
+
* @date 27/05/13
|
170 |
+
*
|
171 |
+
* @param {mixed} $post_id
|
172 |
+
* @return {mixed} $post_id
|
173 |
+
*/
|
174 |
+
|
175 |
+
function get_post_id( $post_id ) {
|
176 |
+
|
177 |
+
// if not $post_id, load queried object
|
178 |
+
if( !$post_id ) {
|
179 |
+
|
180 |
+
// try for global post (needed for setup_postdata)
|
181 |
+
$post_id = (int) get_the_ID();
|
182 |
+
|
183 |
+
|
184 |
+
// try for current screen
|
185 |
+
if( !$post_id ) {
|
186 |
+
|
187 |
+
$post_id = get_queried_object();
|
188 |
+
|
189 |
+
}
|
190 |
+
|
191 |
+
}
|
192 |
+
|
193 |
+
|
194 |
+
// $post_id may be an object
|
195 |
+
if( is_object($post_id) ) {
|
196 |
+
|
197 |
+
// user
|
198 |
+
if( isset($post_id->roles, $post_id->ID) ) {
|
199 |
+
|
200 |
+
$post_id = 'user_' . $post_id->ID;
|
201 |
+
|
202 |
+
// term
|
203 |
+
} elseif( isset($post_id->taxonomy, $post_id->term_id) ) {
|
204 |
+
|
205 |
+
$post_id = $post_id->taxonomy . '_' . $post_id->term_id;
|
206 |
+
|
207 |
+
// comment
|
208 |
+
} elseif( isset($post_id->comment_ID) ) {
|
209 |
+
|
210 |
+
$post_id = 'comment_' . $post_id->comment_ID;
|
211 |
+
|
212 |
+
// post
|
213 |
+
} elseif( isset($post_id->ID) ) {
|
214 |
+
|
215 |
+
$post_id = $post_id->ID;
|
216 |
+
|
217 |
+
// default
|
218 |
+
} else {
|
219 |
+
|
220 |
+
$post_id = 0;
|
221 |
+
|
222 |
+
}
|
223 |
+
|
224 |
+
}
|
225 |
+
|
226 |
+
|
227 |
+
// allow for option == options
|
228 |
+
if( $post_id === 'option' ) {
|
229 |
+
|
230 |
+
$post_id = 'options';
|
231 |
+
|
232 |
+
}
|
233 |
+
|
234 |
+
|
235 |
+
/*
|
236 |
+
* Override for preview
|
237 |
+
*
|
238 |
+
* If the $_GET['preview_id'] is set, then the user wants to see the preview data.
|
239 |
+
* There is also the case of previewing a page with post_id = 1, but using get_field
|
240 |
+
* to load data from another post_id.
|
241 |
+
* In this case, we need to make sure that the autosave revision is actually related
|
242 |
+
* to the $post_id variable. If they match, then the autosave data will be used, otherwise,
|
243 |
+
* the user wants to load data from a completely different post_id
|
244 |
+
*/
|
245 |
+
|
246 |
+
if( isset($_GET['preview_id']) ) {
|
247 |
+
|
248 |
+
$autosave = wp_get_post_autosave( $_GET['preview_id'] );
|
249 |
+
|
250 |
+
if( $autosave && $autosave->post_parent == $post_id ) {
|
251 |
+
|
252 |
+
$post_id = (int) $autosave->ID;
|
253 |
+
|
254 |
+
}
|
255 |
+
|
256 |
+
}
|
257 |
+
|
258 |
+
|
259 |
+
// return
|
260 |
+
return $post_id;
|
261 |
+
}
|
262 |
+
|
263 |
+
|
264 |
+
/*
|
265 |
+
* get_info
|
266 |
+
*
|
267 |
+
* This function will return a setting from the settings array
|
268 |
+
*
|
269 |
+
* @type function
|
270 |
+
* @date 24/01/13
|
271 |
+
* @since 3.6.0
|
272 |
+
*
|
273 |
+
* @param $i (string) the setting to get
|
274 |
+
* @return (mixed)
|
275 |
+
*/
|
276 |
+
|
277 |
+
function get_info( $i )
|
278 |
+
{
|
279 |
+
// vars
|
280 |
+
$return = false;
|
281 |
+
|
282 |
+
|
283 |
+
// specific
|
284 |
+
if( isset($this->settings[ $i ]) )
|
285 |
+
{
|
286 |
+
$return = $this->settings[ $i ];
|
287 |
+
}
|
288 |
+
|
289 |
+
|
290 |
+
// all
|
291 |
+
if( $i == 'all' )
|
292 |
+
{
|
293 |
+
$return = $this->settings;
|
294 |
+
}
|
295 |
+
|
296 |
+
|
297 |
+
// return
|
298 |
+
return $return;
|
299 |
+
}
|
300 |
+
|
301 |
+
|
302 |
+
/*
|
303 |
+
* parse_types
|
304 |
+
*
|
305 |
+
* @description: helper function to set the 'types' of variables
|
306 |
+
* @since: 2.0.4
|
307 |
+
* @created: 9/12/12
|
308 |
+
*/
|
309 |
+
|
310 |
+
function parse_types( $value )
|
311 |
+
{
|
312 |
+
// vars
|
313 |
+
$restricted = array(
|
314 |
+
'label',
|
315 |
+
'name',
|
316 |
+
'_name',
|
317 |
+
'value',
|
318 |
+
'instructions'
|
319 |
+
);
|
320 |
+
|
321 |
+
|
322 |
+
// is value another array?
|
323 |
+
if( is_array($value) )
|
324 |
+
{
|
325 |
+
foreach( $value as $k => $v )
|
326 |
+
{
|
327 |
+
// bail early for restricted pieces
|
328 |
+
if( in_array($k, $restricted, true) )
|
329 |
+
{
|
330 |
+
continue;
|
331 |
+
}
|
332 |
+
|
333 |
+
|
334 |
+
// filter piece
|
335 |
+
$value[ $k ] = apply_filters( 'acf/parse_types', $v );
|
336 |
+
}
|
337 |
+
}
|
338 |
+
else
|
339 |
+
{
|
340 |
+
// string
|
341 |
+
if( is_string($value) )
|
342 |
+
{
|
343 |
+
$value = trim( $value );
|
344 |
+
}
|
345 |
+
|
346 |
+
|
347 |
+
// numbers
|
348 |
+
if( is_numeric($value) )
|
349 |
+
{
|
350 |
+
// check for non numeric characters
|
351 |
+
if( preg_match('/[^0-9]/', $value) )
|
352 |
+
{
|
353 |
+
// leave value if it contains such characters: . + - e
|
354 |
+
//$value = floatval( $value );
|
355 |
+
}
|
356 |
+
else
|
357 |
+
{
|
358 |
+
$value = intval( $value );
|
359 |
+
}
|
360 |
+
}
|
361 |
+
}
|
362 |
+
|
363 |
+
|
364 |
+
// return
|
365 |
+
return $value;
|
366 |
+
}
|
367 |
+
|
368 |
+
|
369 |
+
/*
|
370 |
+
* include_before_theme
|
371 |
+
*
|
372 |
+
* This function will include core files before the theme's functions.php file has been excecuted.
|
373 |
+
*
|
374 |
+
* @type action (plugins_loaded)
|
375 |
+
* @date 3/09/13
|
376 |
+
* @since 4.3.0
|
377 |
+
*
|
378 |
+
* @param N/A
|
379 |
+
* @return N/A
|
380 |
+
*/
|
381 |
+
|
382 |
+
function include_before_theme()
|
383 |
+
{
|
384 |
+
// incudes
|
385 |
+
include_once('core/api.php');
|
386 |
+
|
387 |
+
include_once('core/controllers/input.php');
|
388 |
+
include_once('core/controllers/location.php');
|
389 |
+
include_once('core/controllers/field_group.php');
|
390 |
+
|
391 |
+
|
392 |
+
// admin only includes
|
393 |
+
if( is_admin() )
|
394 |
+
{
|
395 |
+
include_once('core/controllers/post.php');
|
396 |
+
include_once('core/controllers/revisions.php');
|
397 |
+
include_once('core/controllers/everything_fields.php');
|
398 |
+
include_once('core/controllers/field_groups.php');
|
399 |
+
}
|
400 |
+
|
401 |
+
|
402 |
+
// register fields
|
403 |
+
include_once('core/fields/_functions.php');
|
404 |
+
include_once('core/fields/_base.php');
|
405 |
+
|
406 |
+
include_once('core/fields/text.php');
|
407 |
+
include_once('core/fields/textarea.php');
|
408 |
+
include_once('core/fields/number.php');
|
409 |
+
include_once('core/fields/email.php');
|
410 |
+
include_once('core/fields/password.php');
|
411 |
+
|
412 |
+
include_once('core/fields/wysiwyg.php');
|
413 |
+
include_once('core/fields/image.php');
|
414 |
+
include_once('core/fields/file.php');
|
415 |
+
|
416 |
+
include_once('core/fields/select.php');
|
417 |
+
include_once('core/fields/checkbox.php');
|
418 |
+
include_once('core/fields/radio.php');
|
419 |
+
include_once('core/fields/true_false.php');
|
420 |
+
|
421 |
+
include_once('core/fields/page_link.php');
|
422 |
+
include_once('core/fields/post_object.php');
|
423 |
+
include_once('core/fields/relationship.php');
|
424 |
+
include_once('core/fields/taxonomy.php');
|
425 |
+
include_once('core/fields/user.php');
|
426 |
+
|
427 |
+
include_once('core/fields/google-map.php');
|
428 |
+
include_once('core/fields/date_picker/date_picker.php');
|
429 |
+
include_once('core/fields/color_picker.php');
|
430 |
+
|
431 |
+
include_once('core/fields/message.php');
|
432 |
+
include_once('core/fields/tab.php');
|
433 |
+
|
434 |
+
}
|
435 |
+
|
436 |
+
|
437 |
+
/*
|
438 |
+
* include_3rd_party
|
439 |
+
*
|
440 |
+
* This function will include 3rd party add-ons
|
441 |
+
*
|
442 |
+
* @type function
|
443 |
+
* @date 29/01/2014
|
444 |
+
* @since 5.0.0
|
445 |
+
*
|
446 |
+
* @param N/A
|
447 |
+
* @return N/A
|
448 |
+
*/
|
449 |
+
|
450 |
+
function include_3rd_party() {
|
451 |
+
|
452 |
+
// run only once
|
453 |
+
if( $this->settings['include_3rd_party'] )
|
454 |
+
{
|
455 |
+
return false;
|
456 |
+
}
|
457 |
+
|
458 |
+
|
459 |
+
// update setting
|
460 |
+
$this->settings['include_3rd_party'] = true;
|
461 |
+
|
462 |
+
|
463 |
+
// include 3rd party fields
|
464 |
+
do_action('acf/register_fields');
|
465 |
+
|
466 |
+
}
|
467 |
+
|
468 |
+
|
469 |
+
/*
|
470 |
+
* include_after_theme
|
471 |
+
*
|
472 |
+
* This function will include core files after the theme's functions.php file has been excecuted.
|
473 |
+
*
|
474 |
+
* @type action (after_setup_theme)
|
475 |
+
* @date 3/09/13
|
476 |
+
* @since 4.3.0
|
477 |
+
*
|
478 |
+
* @param N/A
|
479 |
+
* @return N/A
|
480 |
+
*/
|
481 |
+
|
482 |
+
function include_after_theme() {
|
483 |
+
|
484 |
+
// early access
|
485 |
+
if( defined('ACF_EARLY_ACCESS') ) {
|
486 |
+
include_once('core/early-access.php');
|
487 |
+
}
|
488 |
+
|
489 |
+
|
490 |
+
|
491 |
+
// bail early if user has defined LITE_MODE as true
|
492 |
+
if( defined('ACF_LITE') && ACF_LITE )
|
493 |
+
{
|
494 |
+
return;
|
495 |
+
}
|
496 |
+
|
497 |
+
|
498 |
+
// admin only includes
|
499 |
+
if( is_admin() )
|
500 |
+
{
|
501 |
+
include_once('core/controllers/export.php');
|
502 |
+
include_once('core/controllers/addons.php');
|
503 |
+
include_once('core/controllers/third_party.php');
|
504 |
+
include_once('core/controllers/upgrade.php');
|
505 |
+
}
|
506 |
+
|
507 |
+
}
|
508 |
+
|
509 |
+
|
510 |
+
/*
|
511 |
+
* init
|
512 |
+
*
|
513 |
+
* This function is called during the 'init' action and will do things such as:
|
514 |
+
* create post_type, register scripts, add actions / filters
|
515 |
+
*
|
516 |
+
* @type action (init)
|
517 |
+
* @date 23/06/12
|
518 |
+
* @since 1.0.0
|
519 |
+
*
|
520 |
+
* @param N/A
|
521 |
+
* @return N/A
|
522 |
+
*/
|
523 |
+
|
524 |
+
function init()
|
525 |
+
{
|
526 |
+
|
527 |
+
// Create ACF post type
|
528 |
+
$labels = array(
|
529 |
+
'name' => __( 'Field Groups', 'acf' ),
|
530 |
+
'singular_name' => __( 'Advanced Custom Fields', 'acf' ),
|
531 |
+
'add_new' => __( 'Add New' , 'acf' ),
|
532 |
+
'add_new_item' => __( 'Add New Field Group' , 'acf' ),
|
533 |
+
'edit_item' => __( 'Edit Field Group' , 'acf' ),
|
534 |
+
'new_item' => __( 'New Field Group' , 'acf' ),
|
535 |
+
'view_item' => __('View Field Group', 'acf'),
|
536 |
+
'search_items' => __('Search Field Groups', 'acf'),
|
537 |
+
'not_found' => __('No Field Groups found', 'acf'),
|
538 |
+
'not_found_in_trash' => __('No Field Groups found in Trash', 'acf'),
|
539 |
+
);
|
540 |
+
|
541 |
+
register_post_type('acf', array(
|
542 |
+
'labels' => $labels,
|
543 |
+
'public' => false,
|
544 |
+
'show_ui' => true,
|
545 |
+
'_builtin' => false,
|
546 |
+
'capability_type' => 'page',
|
547 |
+
'hierarchical' => true,
|
548 |
+
'rewrite' => false,
|
549 |
+
'query_var' => "acf",
|
550 |
+
'supports' => array(
|
551 |
+
'title',
|
552 |
+
),
|
553 |
+
'show_in_menu' => false,
|
554 |
+
));
|
555 |
+
|
556 |
+
|
557 |
+
// min
|
558 |
+
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
559 |
+
|
560 |
+
|
561 |
+
// register acf scripts
|
562 |
+
$scripts = array();
|
563 |
+
$scripts[] = array(
|
564 |
+
'handle' => 'acf-field-group',
|
565 |
+
'src' => $this->settings['dir'] . "js/field-group{$min}.js",
|
566 |
+
'deps' => array('jquery')
|
567 |
+
);
|
568 |
+
$scripts[] = array(
|
569 |
+
'handle' => 'acf-input',
|
570 |
+
'src' => $this->settings['dir'] . "js/input{$min}.js",
|
571 |
+
'deps' => array('jquery', 'jquery-ui-core', 'jquery-ui-datepicker')
|
572 |
+
);
|
573 |
+
|
574 |
+
|
575 |
+
foreach( $scripts as $script )
|
576 |
+
{
|
577 |
+
wp_register_script( $script['handle'], $script['src'], $script['deps'], $this->settings['version'] );
|
578 |
+
}
|
579 |
+
|
580 |
+
|
581 |
+
// register acf styles
|
582 |
+
$styles = array(
|
583 |
+
'acf' => $this->settings['dir'] . 'css/acf.css',
|
584 |
+
'acf-field-group' => $this->settings['dir'] . 'css/field-group.css',
|
585 |
+
'acf-global' => $this->settings['dir'] . 'css/global.css',
|
586 |
+
'acf-input' => $this->settings['dir'] . 'css/input.css',
|
587 |
+
'acf-datepicker' => $this->settings['dir'] . 'core/fields/date_picker/style.date_picker.css',
|
588 |
+
);
|
589 |
+
|
590 |
+
foreach( $styles as $k => $v )
|
591 |
+
{
|
592 |
+
wp_register_style( $k, $v, false, $this->settings['version'] );
|
593 |
+
}
|
594 |
+
|
595 |
+
|
596 |
+
// bail early if user has defined LITE_MODE as true
|
597 |
+
if( defined('ACF_LITE') && ACF_LITE )
|
598 |
+
{
|
599 |
+
return;
|
600 |
+
}
|
601 |
+
|
602 |
+
|
603 |
+
// admin only
|
604 |
+
if( is_admin() )
|
605 |
+
{
|
606 |
+
add_action('admin_menu', array($this,'admin_menu'));
|
607 |
+
add_action('admin_head', array($this,'admin_head'));
|
608 |
+
add_filter('post_updated_messages', array($this, 'post_updated_messages'));
|
609 |
+
}
|
610 |
+
}
|
611 |
+
|
612 |
+
|
613 |
+
/*
|
614 |
+
* admin_menu
|
615 |
+
*
|
616 |
+
* @description:
|
617 |
+
* @since 1.0.0
|
618 |
+
* @created: 23/06/12
|
619 |
+
*/
|
620 |
+
|
621 |
+
function admin_menu()
|
622 |
+
{
|
623 |
+
add_menu_page(__("Custom Fields",'acf'), __("Custom Fields",'acf'), 'manage_options', 'edit.php?post_type=acf', false, false, '80.025');
|
624 |
+
}
|
625 |
+
|
626 |
+
|
627 |
+
/*
|
628 |
+
* post_updated_messages
|
629 |
+
*
|
630 |
+
* @description: messages for saving a field group
|
631 |
+
* @since 1.0.0
|
632 |
+
* @created: 23/06/12
|
633 |
+
*/
|
634 |
+
|
635 |
+
function post_updated_messages( $messages )
|
636 |
+
{
|
637 |
+
global $post, $post_ID;
|
638 |
+
|
639 |
+
$messages['acf'] = array(
|
640 |
+
0 => '', // Unused. Messages start at index 1.
|
641 |
+
1 => __('Field group updated.', 'acf'),
|
642 |
+
2 => __('Custom field updated.', 'acf'),
|
643 |
+
3 => __('Custom field deleted.', 'acf'),
|
644 |
+
4 => __('Field group updated.', 'acf'),
|
645 |
+
/* translators: %s: date and time of the revision */
|
646 |
+
5 => isset($_GET['revision']) ? sprintf( __('Field group restored to revision from %s', 'acf'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
|
647 |
+
6 => __('Field group published.', 'acf'),
|
648 |
+
7 => __('Field group saved.', 'acf'),
|
649 |
+
8 => __('Field group submitted.', 'acf'),
|
650 |
+
9 => __('Field group scheduled for.', 'acf'),
|
651 |
+
10 => __('Field group draft updated.', 'acf'),
|
652 |
+
);
|
653 |
+
|
654 |
+
return $messages;
|
655 |
+
}
|
656 |
+
|
657 |
+
|
658 |
+
/*--------------------------------------------------------------------------------------
|
659 |
+
*
|
660 |
+
* admin_head
|
661 |
+
*
|
662 |
+
* @author Elliot Condon
|
663 |
+
* @since 1.0.0
|
664 |
+
*
|
665 |
+
*-------------------------------------------------------------------------------------*/
|
666 |
+
|
667 |
+
function admin_head()
|
668 |
+
{
|
669 |
+
?>
|
670 |
+
<style type="text/css">
|
671 |
+
#adminmenu #toplevel_page_edit-post_type-acf a[href="edit.php?post_type=acf&page=acf-upgrade"]{ display: none; }
|
672 |
+
#adminmenu #toplevel_page_edit-post_type-acf .wp-menu-image { background-position: 1px -33px; }
|
673 |
+
#adminmenu #toplevel_page_edit-post_type-acf:hover .wp-menu-image,
|
674 |
+
#adminmenu #toplevel_page_edit-post_type-acf.wp-menu-open .wp-menu-image { background-position: 1px -1px; }
|
675 |
+
</style>
|
676 |
+
<?php
|
677 |
+
}
|
678 |
+
|
679 |
+
|
680 |
+
/*
|
681 |
+
* get_taxonomies_for_select
|
682 |
+
*
|
683 |
+
* @description:
|
684 |
+
* @since: 3.6
|
685 |
+
* @created: 27/01/13
|
686 |
+
*/
|
687 |
+
|
688 |
+
function get_taxonomies_for_select( $choices, $simple_value = false )
|
689 |
+
{
|
690 |
+
// vars
|
691 |
+
$post_types = get_post_types();
|
692 |
+
|
693 |
+
|
694 |
+
if($post_types)
|
695 |
+
{
|
696 |
+
foreach($post_types as $post_type)
|
697 |
+
{
|
698 |
+
$post_type_object = get_post_type_object($post_type);
|
699 |
+
$taxonomies = get_object_taxonomies($post_type);
|
700 |
+
if($taxonomies)
|
701 |
+
{
|
702 |
+
foreach($taxonomies as $taxonomy)
|
703 |
+
{
|
704 |
+
if(!is_taxonomy_hierarchical($taxonomy)) continue;
|
705 |
+
$terms = get_terms($taxonomy, array('hide_empty' => false));
|
706 |
+
if($terms)
|
707 |
+
{
|
708 |
+
foreach($terms as $term)
|
709 |
+
{
|
710 |
+
$value = $taxonomy . ':' . $term->term_id;
|
711 |
+
|
712 |
+
if( $simple_value )
|
713 |
+
{
|
714 |
+
$value = $term->term_id;
|
715 |
+
}
|
716 |
+
|
717 |
+
$choices[$post_type_object->label . ': ' . $taxonomy][$value] = $term->name;
|
718 |
+
}
|
719 |
+
}
|
720 |
+
}
|
721 |
+
}
|
722 |
+
}
|
723 |
+
}
|
724 |
+
|
725 |
+
return $choices;
|
726 |
+
}
|
727 |
+
|
728 |
+
|
729 |
+
/*
|
730 |
+
* get_post_types
|
731 |
+
*
|
732 |
+
* @description:
|
733 |
+
* @since: 3.5.5
|
734 |
+
* @created: 16/12/12
|
735 |
+
*/
|
736 |
+
|
737 |
+
function get_post_types( $post_types, $exclude = array(), $include = array() )
|
738 |
+
{
|
739 |
+
// get all custom post types
|
740 |
+
$post_types = array_merge($post_types, get_post_types());
|
741 |
+
|
742 |
+
|
743 |
+
// core include / exclude
|
744 |
+
$acf_includes = array_merge( array(), $include );
|
745 |
+
$acf_excludes = array_merge( array( 'acf', 'revision', 'nav_menu_item' ), $exclude );
|
746 |
+
|
747 |
+
|
748 |
+
// include
|
749 |
+
foreach( $acf_includes as $p )
|
750 |
+
{
|
751 |
+
if( post_type_exists($p) )
|
752 |
+
{
|
753 |
+
$post_types[ $p ] = $p;
|
754 |
+
}
|
755 |
+
}
|
756 |
+
|
757 |
+
|
758 |
+
// exclude
|
759 |
+
foreach( $acf_excludes as $p )
|
760 |
+
{
|
761 |
+
unset( $post_types[ $p ] );
|
762 |
+
}
|
763 |
+
|
764 |
+
|
765 |
+
return $post_types;
|
766 |
+
|
767 |
+
}
|
768 |
+
|
769 |
+
|
770 |
+
/*
|
771 |
+
* get_image_sizes
|
772 |
+
*
|
773 |
+
* @description: returns an array holding all the image sizes
|
774 |
+
* @since 3.2.8
|
775 |
+
* @created: 6/07/12
|
776 |
+
*/
|
777 |
+
|
778 |
+
function get_image_sizes( $sizes )
|
779 |
+
{
|
780 |
+
// find all sizes
|
781 |
+
$all_sizes = get_intermediate_image_sizes();
|
782 |
+
|
783 |
+
|
784 |
+
// define default sizes
|
785 |
+
$sizes = array_merge($sizes, array(
|
786 |
+
'thumbnail' => __("Thumbnail",'acf'),
|
787 |
+
'medium' => __("Medium",'acf'),
|
788 |
+
'large' => __("Large",'acf'),
|
789 |
+
'full' => __("Full",'acf')
|
790 |
+
));
|
791 |
+
|
792 |
+
|
793 |
+
// add extra registered sizes
|
794 |
+
foreach( $all_sizes as $size )
|
795 |
+
{
|
796 |
+
if( !isset($sizes[ $size ]) )
|
797 |
+
{
|
798 |
+
$sizes[ $size ] = ucwords( str_replace('-', ' ', $size) );
|
799 |
+
}
|
800 |
+
}
|
801 |
+
|
802 |
+
|
803 |
+
// return array
|
804 |
+
return $sizes;
|
805 |
+
}
|
806 |
+
|
807 |
+
|
808 |
+
/*
|
809 |
+
* render_fields_for_input
|
810 |
+
*
|
811 |
+
* @description:
|
812 |
+
* @since 3.1.6
|
813 |
+
* @created: 23/06/12
|
814 |
+
*/
|
815 |
+
|
816 |
+
function create_fields( $fields, $post_id )
|
817 |
+
{
|
818 |
+
if( is_array($fields) ){ foreach( $fields as $field ){
|
819 |
+
|
820 |
+
// if they didn't select a type, skip this field
|
821 |
+
if( !$field || !$field['type'] || $field['type'] == 'null' )
|
822 |
+
{
|
823 |
+
continue;
|
824 |
+
}
|
825 |
+
|
826 |
+
|
827 |
+
// set value
|
828 |
+
if( !isset($field['value']) )
|
829 |
+
{
|
830 |
+
$field['value'] = apply_filters('acf/load_value', false, $post_id, $field);
|
831 |
+
$field['value'] = apply_filters('acf/format_value', $field['value'], $post_id, $field);
|
832 |
+
}
|
833 |
+
|
834 |
+
|
835 |
+
// required
|
836 |
+
$required_class = "";
|
837 |
+
$required_label = "";
|
838 |
+
|
839 |
+
if( $field['required'] )
|
840 |
+
{
|
841 |
+
$required_class = ' required';
|
842 |
+
$required_label = ' <span class="required">*</span>';
|
843 |
+
}
|
844 |
+
|
845 |
+
|
846 |
+
echo '<div id="acf-' . $field['name'] . '" class="field field_type-' . $field['type'] . ' field_key-' . $field['key'] . $required_class . '" data-field_name="' . $field['name'] . '" data-field_key="' . $field['key'] . '" data-field_type="' . $field['type'] . '">';
|
847 |
+
|
848 |
+
echo '<p class="label">';
|
849 |
+
echo '<label for="' . $field['id'] . '">' . $field['label'] . $required_label . '</label>';
|
850 |
+
echo $field['instructions'];
|
851 |
+
echo '</p>';
|
852 |
+
|
853 |
+
$field['name'] = 'fields[' . $field['key'] . ']';
|
854 |
+
do_action('acf/create_field', $field, $post_id);
|
855 |
+
|
856 |
+
echo '</div>';
|
857 |
+
|
858 |
+
}}
|
859 |
+
|
860 |
+
}
|
861 |
+
|
862 |
+
|
863 |
+
/*
|
864 |
+
* save_post_lock
|
865 |
+
*
|
866 |
+
* This action sets a global variable which locks the ACF save functions to this ID.
|
867 |
+
* This prevents an inifinite loop if a user was to hook into the save and create a new post
|
868 |
+
*
|
869 |
+
* @type function
|
870 |
+
* @date 16/07/13
|
871 |
+
*
|
872 |
+
* @param {int} $post_id
|
873 |
+
* @return {int} $post_id
|
874 |
+
*/
|
875 |
+
|
876 |
+
function save_post_lock( $post_id )
|
877 |
+
{
|
878 |
+
$GLOBALS['acf_save_lock'] = $post_id;
|
879 |
+
|
880 |
+
return $post_id;
|
881 |
+
}
|
882 |
+
|
883 |
+
|
884 |
+
/*
|
885 |
+
* save_post_unlock
|
886 |
+
*
|
887 |
+
* This action sets a global variable which unlocks the ACF save functions to this ID.
|
888 |
+
* This prevents an inifinite loop if a user was to hook into the save and create a new post
|
889 |
+
*
|
890 |
+
* @type function
|
891 |
+
* @date 16/07/13
|
892 |
+
*
|
893 |
+
* @param {int} $post_id
|
894 |
+
* @return {int} $post_id
|
895 |
+
*/
|
896 |
+
|
897 |
+
function save_post_unlock( $post_id )
|
898 |
+
{
|
899 |
+
$GLOBALS['acf_save_lock'] = false;
|
900 |
+
|
901 |
+
return $post_id;
|
902 |
+
}
|
903 |
+
|
904 |
+
|
905 |
+
/*
|
906 |
+
* save_post
|
907 |
+
*
|
908 |
+
* @description:
|
909 |
+
* @since: 3.6
|
910 |
+
* @created: 28/01/13
|
911 |
+
*/
|
912 |
+
|
913 |
+
function save_post( $post_id )
|
914 |
+
{
|
915 |
+
|
916 |
+
// load from post
|
917 |
+
if( !isset($_POST['fields']) )
|
918 |
+
{
|
919 |
+
return $post_id;
|
920 |
+
}
|
921 |
+
|
922 |
+
|
923 |
+
// loop through and save
|
924 |
+
if( !empty($_POST['fields']) )
|
925 |
+
{
|
926 |
+
// loop through and save $_POST data
|
927 |
+
foreach( $_POST['fields'] as $k => $v )
|
928 |
+
{
|
929 |
+
// get field
|
930 |
+
$f = apply_filters('acf/load_field', false, $k );
|
931 |
+
|
932 |
+
// update field
|
933 |
+
do_action('acf/update_value', $v, $post_id, $f );
|
934 |
+
|
935 |
+
}
|
936 |
+
// foreach($fields as $key => $value)
|
937 |
+
}
|
938 |
+
// if($fields)
|
939 |
+
|
940 |
+
|
941 |
+
return $post_id;
|
942 |
+
}
|
943 |
+
|
944 |
+
|
945 |
+
}
|
946 |
+
|
947 |
+
|
948 |
+
/*
|
949 |
+
* acf
|
950 |
+
*
|
951 |
+
* The main function responsible for returning the one true acf Instance to functions everywhere.
|
952 |
+
* Use this function like you would a global variable, except without needing to declare the global.
|
953 |
+
*
|
954 |
+
* Example: <?php $acf = acf(); ?>
|
955 |
+
*
|
956 |
+
* @type function
|
957 |
+
* @date 4/09/13
|
958 |
+
* @since 4.3.0
|
959 |
+
*
|
960 |
+
* @param N/A
|
961 |
+
* @return (object)
|
962 |
+
*/
|
963 |
+
|
964 |
+
function acf()
|
965 |
+
{
|
966 |
+
global $acf;
|
967 |
+
|
968 |
+
if( !isset($acf) )
|
969 |
+
{
|
970 |
+
$acf = new acf();
|
971 |
+
}
|
972 |
+
|
973 |
+
return $acf;
|
974 |
+
}
|
975 |
+
|
976 |
+
|
977 |
+
// initialize
|
978 |
+
acf();
|
979 |
+
|
980 |
+
|
981 |
+
endif; // class_exists check
|
982 |
+
|
983 |
+
?>
|
shared/assets/plugins/advanced-custom-fields/composer.json
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name" : "elliotcondon/acf",
|
3 |
+
"description": "Fully customise WordPress edit screens with powerful fields.",
|
4 |
+
"homepage" : "http://www.advancedcustomfields.com/",
|
5 |
+
"type" : "wordpress-plugin",
|
6 |
+
"license" : "GPL-2.0+",
|
7 |
+
"authors" : [
|
8 |
+
{
|
9 |
+
"name" : "Elliot Condon",
|
10 |
+
"homepage": "http://www.elliotcondon.com/"
|
11 |
+
}
|
12 |
+
],
|
13 |
+
"require": {
|
14 |
+
"composer/installers": "~1.0"
|
15 |
+
}
|
16 |
+
}
|
shared/assets/plugins/advanced-custom-fields/config
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[core]
|
2 |
+
bare = true
|
3 |
+
repositoryformatversion = 0
|
4 |
+
filemode = false
|
5 |
+
symlinks = false
|
6 |
+
ignorecase = true
|
shared/assets/plugins/advanced-custom-fields/config.codekit
ADDED
@@ -0,0 +1,1929 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"CodeKitInfo": "This is a CodeKit 2.x project configuration file. It is designed to sync project settings across multiple machines. MODIFYING THE CONTENTS OF THIS FILE IS A POOR LIFE DECISION. If you do so, you will likely cause CodeKit to crash. This file is not useful unless accompanied by the project that created it in CodeKit 2. This file is not backwards-compatible with CodeKit 1.x. For more information, see: http:\/\/incident57.com\/codekit",
|
3 |
+
"creatorBuild": "19142",
|
4 |
+
"files": {
|
5 |
+
"\/acf.php": {
|
6 |
+
"fileType": 8192,
|
7 |
+
"ignore": 0,
|
8 |
+
"ignoreWasSetByUser": 0,
|
9 |
+
"inputAbbreviatedPath": "\/acf.php",
|
10 |
+
"outputAbbreviatedPath": "No Output Path",
|
11 |
+
"outputPathIsOutsideProject": 0,
|
12 |
+
"outputPathIsSetByUser": 0
|
13 |
+
},
|
14 |
+
"\/composer.json": {
|
15 |
+
"fileType": 524288,
|
16 |
+
"ignore": 1,
|
17 |
+
"ignoreWasSetByUser": 0,
|
18 |
+
"inputAbbreviatedPath": "\/composer.json",
|
19 |
+
"orderOutput": 0,
|
20 |
+
"outputAbbreviatedPath": "\/composer-min.json",
|
21 |
+
"outputPathIsOutsideProject": 0,
|
22 |
+
"outputPathIsSetByUser": 0,
|
23 |
+
"outputStyle": 1
|
24 |
+
},
|
25 |
+
"\/core\/actions\/export.php": {
|
26 |
+
"fileType": 8192,
|
27 |
+
"ignore": 0,
|
28 |
+
"ignoreWasSetByUser": 0,
|
29 |
+
"inputAbbreviatedPath": "\/core\/actions\/export.php",
|
30 |
+
"outputAbbreviatedPath": "No Output Path",
|
31 |
+
"outputPathIsOutsideProject": 0,
|
32 |
+
"outputPathIsSetByUser": 0
|
33 |
+
},
|
34 |
+
"\/core\/api.php": {
|
35 |
+
"fileType": 8192,
|
36 |
+
"ignore": 0,
|
37 |
+
"ignoreWasSetByUser": 0,
|
38 |
+
"inputAbbreviatedPath": "\/core\/api.php",
|
39 |
+
"outputAbbreviatedPath": "No Output Path",
|
40 |
+
"outputPathIsOutsideProject": 0,
|
41 |
+
"outputPathIsSetByUser": 0
|
42 |
+
},
|
43 |
+
"\/core\/controllers\/addons.php": {
|
44 |
+
"fileType": 8192,
|
45 |
+
"ignore": 0,
|
46 |
+
"ignoreWasSetByUser": 0,
|
47 |
+
"inputAbbreviatedPath": "\/core\/controllers\/addons.php",
|
48 |
+
"outputAbbreviatedPath": "No Output Path",
|
49 |
+
"outputPathIsOutsideProject": 0,
|
50 |
+
"outputPathIsSetByUser": 0
|
51 |
+
},
|
52 |
+
"\/core\/controllers\/everything_fields.php": {
|
53 |
+
"fileType": 8192,
|
54 |
+
"ignore": 0,
|
55 |
+
"ignoreWasSetByUser": 0,
|
56 |
+
"inputAbbreviatedPath": "\/core\/controllers\/everything_fields.php",
|
57 |
+
"outputAbbreviatedPath": "No Output Path",
|
58 |
+
"outputPathIsOutsideProject": 0,
|
59 |
+
"outputPathIsSetByUser": 0
|
60 |
+
},
|
61 |
+
"\/core\/controllers\/export.php": {
|
62 |
+
"fileType": 8192,
|
63 |
+
"ignore": 0,
|
64 |
+
"ignoreWasSetByUser": 0,
|
65 |
+
"inputAbbreviatedPath": "\/core\/controllers\/export.php",
|
66 |
+
"outputAbbreviatedPath": "No Output Path",
|
67 |
+
"outputPathIsOutsideProject": 0,
|
68 |
+
"outputPathIsSetByUser": 0
|
69 |
+
},
|
70 |
+
"\/core\/controllers\/field_group.php": {
|
71 |
+
"fileType": 8192,
|
72 |
+
"ignore": 0,
|
73 |
+
"ignoreWasSetByUser": 0,
|
74 |
+
"inputAbbreviatedPath": "\/core\/controllers\/field_group.php",
|
75 |
+
"outputAbbreviatedPath": "No Output Path",
|
76 |
+
"outputPathIsOutsideProject": 0,
|
77 |
+
"outputPathIsSetByUser": 0
|
78 |
+
},
|
79 |
+
"\/core\/controllers\/field_groups.php": {
|
80 |
+
"fileType": 8192,
|
81 |
+
"ignore": 0,
|
82 |
+
"ignoreWasSetByUser": 0,
|
83 |
+
"inputAbbreviatedPath": "\/core\/controllers\/field_groups.php",
|
84 |
+
"outputAbbreviatedPath": "No Output Path",
|
85 |
+
"outputPathIsOutsideProject": 0,
|
86 |
+
"outputPathIsSetByUser": 0
|
87 |
+
},
|
88 |
+
"\/core\/controllers\/input.php": {
|
89 |
+
"fileType": 8192,
|
90 |
+
"ignore": 0,
|
91 |
+
"ignoreWasSetByUser": 0,
|
92 |
+
"inputAbbreviatedPath": "\/core\/controllers\/input.php",
|
93 |
+
"outputAbbreviatedPath": "No Output Path",
|
94 |
+
"outputPathIsOutsideProject": 0,
|
95 |
+
"outputPathIsSetByUser": 0
|
96 |
+
},
|
97 |
+
"\/core\/controllers\/location.php": {
|
98 |
+
"fileType": 8192,
|
99 |
+
"ignore": 0,
|
100 |
+
"ignoreWasSetByUser": 0,
|
101 |
+
"inputAbbreviatedPath": "\/core\/controllers\/location.php",
|
102 |
+
"outputAbbreviatedPath": "No Output Path",
|
103 |
+
"outputPathIsOutsideProject": 0,
|
104 |
+
"outputPathIsSetByUser": 0
|
105 |
+
},
|
106 |
+
"\/core\/controllers\/post.php": {
|
107 |
+
"fileType": 8192,
|
108 |
+
"ignore": 0,
|
109 |
+
"ignoreWasSetByUser": 0,
|
110 |
+
"inputAbbreviatedPath": "\/core\/controllers\/post.php",
|
111 |
+
"outputAbbreviatedPath": "No Output Path",
|
112 |
+
"outputPathIsOutsideProject": 0,
|
113 |
+
"outputPathIsSetByUser": 0
|
114 |
+
},
|
115 |
+
"\/core\/controllers\/revisions.php": {
|
116 |
+
"fileType": 8192,
|
117 |
+
"ignore": 0,
|
118 |
+
"ignoreWasSetByUser": 0,
|
119 |
+
"inputAbbreviatedPath": "\/core\/controllers\/revisions.php",
|
120 |
+
"outputAbbreviatedPath": "No Output Path",
|
121 |
+
"outputPathIsOutsideProject": 0,
|
122 |
+
"outputPathIsSetByUser": 0
|
123 |
+
},
|
124 |
+
"\/core\/controllers\/third_party.php": {
|
125 |
+
"fileType": 8192,
|
126 |
+
"ignore": 0,
|
127 |
+
"ignoreWasSetByUser": 0,
|
128 |
+
"inputAbbreviatedPath": "\/core\/controllers\/third_party.php",
|
129 |
+
"outputAbbreviatedPath": "No Output Path",
|
130 |
+
"outputPathIsOutsideProject": 0,
|
131 |
+
"outputPathIsSetByUser": 0
|
132 |
+
},
|
133 |
+
"\/core\/controllers\/upgrade.php": {
|
134 |
+
"fileType": 8192,
|
135 |
+
"ignore": 0,
|
136 |
+
"ignoreWasSetByUser": 0,
|
137 |
+
"inputAbbreviatedPath": "\/core\/controllers\/upgrade.php",
|
138 |
+
"outputAbbreviatedPath": "No Output Path",
|
139 |
+
"outputPathIsOutsideProject": 0,
|
140 |
+
"outputPathIsSetByUser": 0
|
141 |
+
},
|
142 |
+
"\/core\/early-access.php": {
|
143 |
+
"fileType": 8192,
|
144 |
+
"ignore": 0,
|
145 |
+
"ignoreWasSetByUser": 0,
|
146 |
+
"inputAbbreviatedPath": "\/core\/early-access.php",
|
147 |
+
"outputAbbreviatedPath": "No Output Path",
|
148 |
+
"outputPathIsOutsideProject": 0,
|
149 |
+
"outputPathIsSetByUser": 0
|
150 |
+
},
|
151 |
+
"\/core\/fields\/_base.php": {
|
152 |
+
"fileType": 8192,
|
153 |
+
"ignore": 1,
|
154 |
+
"ignoreWasSetByUser": 0,
|
155 |
+
"inputAbbreviatedPath": "\/core\/fields\/_base.php",
|
156 |
+
"outputAbbreviatedPath": "No Output Path",
|
157 |
+
"outputPathIsOutsideProject": 0,
|
158 |
+
"outputPathIsSetByUser": 0
|
159 |
+
},
|
160 |
+
"\/core\/fields\/_functions.php": {
|
161 |
+
"fileType": 8192,
|
162 |
+
"ignore": 0,
|
163 |
+
"ignoreWasSetByUser": 0,
|
164 |
+
"inputAbbreviatedPath": "\/core\/fields\/_functions.php",
|
165 |
+
"outputAbbreviatedPath": "No Output Path",
|
166 |
+
"outputPathIsOutsideProject": 0,
|
167 |
+
"outputPathIsSetByUser": 0
|
168 |
+
},
|
169 |
+
"\/core\/fields\/checkbox.php": {
|
170 |
+
"fileType": 8192,
|
171 |
+
"ignore": 0,
|
172 |
+
"ignoreWasSetByUser": 0,
|
173 |
+
"inputAbbreviatedPath": "\/core\/fields\/checkbox.php",
|
174 |
+
"outputAbbreviatedPath": "No Output Path",
|
175 |
+
"outputPathIsOutsideProject": 0,
|
176 |
+
"outputPathIsSetByUser": 0
|
177 |
+
},
|
178 |
+
"\/core\/fields\/color_picker.php": {
|
179 |
+
"fileType": 8192,
|
180 |
+
"ignore": 0,
|
181 |
+
"ignoreWasSetByUser": 0,
|
182 |
+
"inputAbbreviatedPath": "\/core\/fields\/color_picker.php",
|
183 |
+
"outputAbbreviatedPath": "No Output Path",
|
184 |
+
"outputPathIsOutsideProject": 0,
|
185 |
+
"outputPathIsSetByUser": 0
|
186 |
+
},
|
187 |
+
"\/core\/fields\/date_picker\/date_picker.php": {
|
188 |
+
"fileType": 8192,
|
189 |
+
"ignore": 0,
|
190 |
+
"ignoreWasSetByUser": 0,
|
191 |
+
"inputAbbreviatedPath": "\/core\/fields\/date_picker\/date_picker.php",
|
192 |
+
"outputAbbreviatedPath": "No Output Path",
|
193 |
+
"outputPathIsOutsideProject": 0,
|
194 |
+
"outputPathIsSetByUser": 0
|
195 |
+
},
|
196 |
+
"\/core\/fields\/date_picker\/images\/ui-bg_flat_0_aaaaaa_40x100.png": {
|
197 |
+
"fileType": 32768,
|
198 |
+
"ignore": 0,
|
199 |
+
"ignoreWasSetByUser": 0,
|
200 |
+
"initialSize": 180,
|
201 |
+
"inputAbbreviatedPath": "\/core\/fields\/date_picker\/images\/ui-bg_flat_0_aaaaaa_40x100.png",
|
202 |
+
"outputAbbreviatedPath": "\/core\/fields\/date_picker\/images\/ui-bg_flat_0_aaaaaa_40x100.png",
|
203 |
+
"outputPathIsOutsideProject": 0,
|
204 |
+
"outputPathIsSetByUser": 0,
|
205 |
+
"processed": 0
|
206 |
+
},
|
207 |
+
"\/core\/fields\/date_picker\/images\/ui-bg_flat_55_5bc6f5_40x100.png": {
|
208 |
+
"fileType": 32768,
|
209 |
+
"ignore": 0,
|
210 |
+
"ignoreWasSetByUser": 0,
|
211 |
+
"initialSize": 213,
|
212 |
+
"inputAbbreviatedPath": "\/core\/fields\/date_picker\/images\/ui-bg_flat_55_5bc6f5_40x100.png",
|
213 |
+
"outputAbbreviatedPath": "\/core\/fields\/date_picker\/images\/ui-bg_flat_55_5bc6f5_40x100.png",
|
214 |
+
"outputPathIsOutsideProject": 0,
|
215 |
+
"outputPathIsSetByUser": 0,
|
216 |
+
"processed": 0
|
217 |
+
},
|
218 |
+
"\/core\/fields\/date_picker\/images\/ui-bg_flat_75_ffffff_40x100.png": {
|
219 |
+
"fileType": 32768,
|
220 |
+
"ignore": 0,
|
221 |
+
"ignoreWasSetByUser": 0,
|
222 |
+
"initialSize": 178,
|
223 |
+
"inputAbbreviatedPath": "\/core\/fields\/date_picker\/images\/ui-bg_flat_75_ffffff_40x100.png",
|
224 |
+
"outputAbbreviatedPath": "\/core\/fields\/date_picker\/images\/ui-bg_flat_75_ffffff_40x100.png",
|
225 |
+
"outputPathIsOutsideProject": 0,
|
226 |
+
"outputPathIsSetByUser": 0,
|
227 |
+
"processed": 0
|
228 |
+
},
|
229 |
+
"\/core\/fields\/date_picker\/images\/ui-bg_glass_65_ffffff_1x400.png": {
|
230 |
+
"fileType": 32768,
|
231 |
+
"ignore": 0,
|
232 |
+
"ignoreWasSetByUser": 0,
|
233 |
+
"initialSize": 105,
|
234 |
+
"inputAbbreviatedPath": "\/core\/fields\/date_picker\/images\/ui-bg_glass_65_ffffff_1x400.png",
|
235 |
+
"outputAbbreviatedPath": "\/core\/fields\/date_picker\/images\/ui-bg_glass_65_ffffff_1x400.png",
|
236 |
+
"outputPathIsOutsideProject": 0,
|
237 |
+
"outputPathIsSetByUser": 0,
|
238 |
+
"processed": 0
|
239 |
+
},
|
240 |
+
"\/core\/fields\/date_picker\/images\/ui-bg_glass_75_dadada_1x400.png": {
|
241 |
+
"fileType": 32768,
|
242 |
+
"ignore": 0,
|
243 |
+
"ignoreWasSetByUser": 0,
|
244 |
+
"initialSize": 111,
|
245 |
+
"inputAbbreviatedPath": "\/core\/fields\/date_picker\/images\/ui-bg_glass_75_dadada_1x400.png",
|
246 |
+
"outputAbbreviatedPath": "\/core\/fields\/date_picker\/images\/ui-bg_glass_75_dadada_1x400.png",
|
247 |
+
"outputPathIsOutsideProject": 0,
|
248 |
+
"outputPathIsSetByUser": 0,
|
249 |
+
"processed": 0
|
250 |
+
},
|
251 |
+
"\/core\/fields\/date_picker\/images\/ui-bg_glass_75_e6e6e6_1x400.png": {
|
252 |
+
"fileType": 32768,
|
253 |
+
"ignore": 0,
|
254 |
+
"ignoreWasSetByUser": 0,
|
255 |
+
"initialSize": 110,
|
256 |
+
"inputAbbreviatedPath": "\/core\/fields\/date_picker\/images\/ui-bg_glass_75_e6e6e6_1x400.png",
|
257 |
+
"outputAbbreviatedPath": "\/core\/fields\/date_picker\/images\/ui-bg_glass_75_e6e6e6_1x400.png",
|
258 |
+
"outputPathIsOutsideProject": 0,
|
259 |
+
"outputPathIsSetByUser": 0,
|
260 |
+
"processed": 0
|
261 |
+
},
|
262 |
+
"\/core\/fields\/date_picker\/images\/ui-bg_glass_95_fef1ec_1x400.png": {
|
263 |
+
"fileType": 32768,
|
264 |
+
"ignore": 0,
|
265 |
+
"ignoreWasSetByUser": 0,
|
266 |
+
"initialSize": 119,
|
267 |
+
"inputAbbreviatedPath": "\/core\/fields\/date_picker\/images\/ui-bg_glass_95_fef1ec_1x400.png",
|
268 |
+
"outputAbbreviatedPath": "\/core\/fields\/date_picker\/images\/ui-bg_glass_95_fef1ec_1x400.png",
|
269 |
+
"outputPathIsOutsideProject": 0,
|
270 |
+
"outputPathIsSetByUser": 0,
|
271 |
+
"processed": 0
|
272 |
+
},
|
273 |
+
"\/core\/fields\/date_picker\/images\/ui-bg_highlight-soft_0_444444_1x100.png": {
|
274 |
+
"fileType": 32768,
|
275 |
+
"ignore": 0,
|
276 |
+
"ignoreWasSetByUser": 0,
|
277 |
+
"initialSize": 79,
|
278 |
+
"inputAbbreviatedPath": "\/core\/fields\/date_picker\/images\/ui-bg_highlight-soft_0_444444_1x100.png",
|
279 |
+
"outputAbbreviatedPath": "\/core\/fields\/date_picker\/images\/ui-bg_highlight-soft_0_444444_1x100.png",
|
280 |
+
"outputPathIsOutsideProject": 0,
|
281 |
+
"outputPathIsSetByUser": 0,
|
282 |
+
"processed": 0
|
283 |
+
},
|
284 |
+
"\/core\/fields\/date_picker\/images\/ui-icons_222222_256x240.png": {
|
285 |
+
"fileType": 32768,
|
286 |
+
"ignore": 0,
|
287 |
+
"ignoreWasSetByUser": 0,
|
288 |
+
"initialSize": 4369,
|
289 |
+
"inputAbbreviatedPath": "\/core\/fields\/date_picker\/images\/ui-icons_222222_256x240.png",
|
290 |
+
"outputAbbreviatedPath": "\/core\/fields\/date_picker\/images\/ui-icons_222222_256x240.png",
|
291 |
+
"outputPathIsOutsideProject": 0,
|
292 |
+
"outputPathIsSetByUser": 0,
|
293 |
+
"processed": 0
|
294 |
+
},
|
295 |
+
"\/core\/fields\/date_picker\/images\/ui-icons_2e83ff_256x240.png": {
|
296 |
+
"fileType": 32768,
|
297 |
+
"ignore": 0,
|
298 |
+
"ignoreWasSetByUser": 0,
|
299 |
+
"initialSize": 4369,
|
300 |
+
"inputAbbreviatedPath": "\/core\/fields\/date_picker\/images\/ui-icons_2e83ff_256x240.png",
|
301 |
+
"outputAbbreviatedPath": "\/core\/fields\/date_picker\/images\/ui-icons_2e83ff_256x240.png",
|
302 |
+
"outputPathIsOutsideProject": 0,
|
303 |
+
"outputPathIsSetByUser": 0,
|
304 |
+
"processed": 0
|
305 |
+
},
|
306 |
+
"\/core\/fields\/date_picker\/images\/ui-icons_454545_256x240.png": {
|
307 |
+
"fileType": 32768,
|
308 |
+
"ignore": 0,
|
309 |
+
"ignoreWasSetByUser": 0,
|
310 |
+
"initialSize": 4369,
|
311 |
+
"inputAbbreviatedPath": "\/core\/fields\/date_picker\/images\/ui-icons_454545_256x240.png",
|
312 |
+
"outputAbbreviatedPath": "\/core\/fields\/date_picker\/images\/ui-icons_454545_256x240.png",
|
313 |
+
"outputPathIsOutsideProject": 0,
|
314 |
+
"outputPathIsSetByUser": 0,
|
315 |
+
"processed": 0
|
316 |
+
},
|
317 |
+
"\/core\/fields\/date_picker\/images\/ui-icons_888888_256x240.png": {
|
318 |
+
"fileType": 32768,
|
319 |
+
"ignore": 0,
|
320 |
+
"ignoreWasSetByUser": 0,
|
321 |
+
"initialSize": 4369,
|
322 |
+
"inputAbbreviatedPath": "\/core\/fields\/date_picker\/images\/ui-icons_888888_256x240.png",
|
323 |
+
"outputAbbreviatedPath": "\/core\/fields\/date_picker\/images\/ui-icons_888888_256x240.png",
|
324 |
+
"outputPathIsOutsideProject": 0,
|
325 |
+
"outputPathIsSetByUser": 0,
|
326 |
+
"processed": 0
|
327 |
+
},
|
328 |
+
"\/core\/fields\/date_picker\/images\/ui-icons_cd0a0a_256x240.png": {
|
329 |
+
"fileType": 32768,
|
330 |
+
"ignore": 0,
|
331 |
+
"ignoreWasSetByUser": 0,
|
332 |
+
"initialSize": 4369,
|
333 |
+
"inputAbbreviatedPath": "\/core\/fields\/date_picker\/images\/ui-icons_cd0a0a_256x240.png",
|
334 |
+
"outputAbbreviatedPath": "\/core\/fields\/date_picker\/images\/ui-icons_cd0a0a_256x240.png",
|
335 |
+
"outputPathIsOutsideProject": 0,
|
336 |
+
"outputPathIsSetByUser": 0,
|
337 |
+
"processed": 0
|
338 |
+
},
|
339 |
+
"\/core\/fields\/date_picker\/jquery.ui.datepicker.js": {
|
340 |
+
"fileType": 64,
|
341 |
+
"ignore": 0,
|
342 |
+
"ignoreWasSetByUser": 0,
|
343 |
+
"inputAbbreviatedPath": "\/core\/fields\/date_picker\/jquery.ui.datepicker.js",
|
344 |
+
"outputAbbreviatedPath": "\/core\/fields\/date_picker\/min\/jquery.ui.datepicker-ck.js",
|
345 |
+
"outputPathIsOutsideProject": 0,
|
346 |
+
"outputPathIsSetByUser": 0,
|
347 |
+
"outputStyle": 1,
|
348 |
+
"syntaxCheckerStyle": 1
|
349 |
+
},
|
350 |
+
"\/core\/fields\/date_picker\/style.date_picker.css": {
|
351 |
+
"fileType": 16,
|
352 |
+
"ignore": 0,
|
353 |
+
"ignoreWasSetByUser": 0,
|
354 |
+
"inputAbbreviatedPath": "\/core\/fields\/date_picker\/style.date_picker.css",
|
355 |
+
"outputAbbreviatedPath": "No Output Path",
|
356 |
+
"outputPathIsOutsideProject": 0,
|
357 |
+
"outputPathIsSetByUser": 0
|
358 |
+
},
|
359 |
+
"\/core\/fields\/dummy.php": {
|
360 |
+
"fileType": 8192,
|
361 |
+
"ignore": 0,
|
362 |
+
"ignoreWasSetByUser": 0,
|
363 |
+
"inputAbbreviatedPath": "\/core\/fields\/dummy.php",
|
364 |
+
"outputAbbreviatedPath": "No Output Path",
|
365 |
+
"outputPathIsOutsideProject": 0,
|
366 |
+
"outputPathIsSetByUser": 0
|
367 |
+
},
|
368 |
+
"\/core\/fields\/email.php": {
|
369 |
+
"fileType": 8192,
|
370 |
+
"ignore": 0,
|
371 |
+
"ignoreWasSetByUser": 0,
|
372 |
+
"inputAbbreviatedPath": "\/core\/fields\/email.php",
|
373 |
+
"outputAbbreviatedPath": "No Output Path",
|
374 |
+
"outputPathIsOutsideProject": 0,
|
375 |
+
"outputPathIsSetByUser": 0
|
376 |
+
},
|
377 |
+
"\/core\/fields\/file.php": {
|
378 |
+
"fileType": 8192,
|
379 |
+
"ignore": 0,
|
380 |
+
"ignoreWasSetByUser": 0,
|
381 |
+
"inputAbbreviatedPath": "\/core\/fields\/file.php",
|
382 |
+
"outputAbbreviatedPath": "No Output Path",
|
383 |
+
"outputPathIsOutsideProject": 0,
|
384 |
+
"outputPathIsSetByUser": 0
|
385 |
+
},
|
386 |
+
"\/core\/fields\/google-map.php": {
|
387 |
+
"fileType": 8192,
|
388 |
+
"ignore": 0,
|
389 |
+
"ignoreWasSetByUser": 0,
|
390 |
+
"inputAbbreviatedPath": "\/core\/fields\/google-map.php",
|
391 |
+
"outputAbbreviatedPath": "No Output Path",
|
392 |
+
"outputPathIsOutsideProject": 0,
|
393 |
+
"outputPathIsSetByUser": 0
|
394 |
+
},
|
395 |
+
"\/core\/fields\/image.php": {
|
396 |
+
"fileType": 8192,
|
397 |
+
"ignore": 0,
|
398 |
+
"ignoreWasSetByUser": 0,
|
399 |
+
"inputAbbreviatedPath": "\/core\/fields\/image.php",
|
400 |
+
"outputAbbreviatedPath": "No Output Path",
|
401 |
+
"outputPathIsOutsideProject": 0,
|
402 |
+
"outputPathIsSetByUser": 0
|
403 |
+
},
|
404 |
+
"\/core\/fields\/message.php": {
|
405 |
+
"fileType": 8192,
|
406 |
+
"ignore": 0,
|
407 |
+
"ignoreWasSetByUser": 0,
|
408 |
+
"inputAbbreviatedPath": "\/core\/fields\/message.php",
|
409 |
+
"outputAbbreviatedPath": "No Output Path",
|
410 |
+
"outputPathIsOutsideProject": 0,
|
411 |
+
"outputPathIsSetByUser": 0
|
412 |
+
},
|
413 |
+
"\/core\/fields\/number.php": {
|
414 |
+
"fileType": 8192,
|
415 |
+
"ignore": 0,
|
416 |
+
"ignoreWasSetByUser": 0,
|
417 |
+
"inputAbbreviatedPath": "\/core\/fields\/number.php",
|
418 |
+
"outputAbbreviatedPath": "No Output Path",
|
419 |
+
"outputPathIsOutsideProject": 0,
|
420 |
+
"outputPathIsSetByUser": 0
|
421 |
+
},
|
422 |
+
"\/core\/fields\/page_link.php": {
|
423 |
+
"fileType": 8192,
|
424 |
+
"ignore": 0,
|
425 |
+
"ignoreWasSetByUser": 0,
|
426 |
+
"inputAbbreviatedPath": "\/core\/fields\/page_link.php",
|
427 |
+
"outputAbbreviatedPath": "No Output Path",
|
428 |
+
"outputPathIsOutsideProject": 0,
|
429 |
+
"outputPathIsSetByUser": 0
|
430 |
+
},
|
431 |
+
"\/core\/fields\/password.php": {
|
432 |
+
"fileType": 8192,
|
433 |
+
"ignore": 0,
|
434 |
+
"ignoreWasSetByUser": 0,
|
435 |
+
"inputAbbreviatedPath": "\/core\/fields\/password.php",
|
436 |
+
"outputAbbreviatedPath": "No Output Path",
|
437 |
+
"outputPathIsOutsideProject": 0,
|
438 |
+
"outputPathIsSetByUser": 0
|
439 |
+
},
|
440 |
+
"\/core\/fields\/post_object.php": {
|
441 |
+
"fileType": 8192,
|
442 |
+
"ignore": 0,
|
443 |
+
"ignoreWasSetByUser": 0,
|
444 |
+
"inputAbbreviatedPath": "\/core\/fields\/post_object.php",
|
445 |
+
"outputAbbreviatedPath": "No Output Path",
|
446 |
+
"outputPathIsOutsideProject": 0,
|
447 |
+
"outputPathIsSetByUser": 0
|
448 |
+
},
|
449 |
+
"\/core\/fields\/radio.php": {
|
450 |
+
"fileType": 8192,
|
451 |
+
"ignore": 0,
|
452 |
+
"ignoreWasSetByUser": 0,
|
453 |
+
"inputAbbreviatedPath": "\/core\/fields\/radio.php",
|
454 |
+
"outputAbbreviatedPath": "No Output Path",
|
455 |
+
"outputPathIsOutsideProject": 0,
|
456 |
+
"outputPathIsSetByUser": 0
|
457 |
+
},
|
458 |
+
"\/core\/fields\/relationship.php": {
|
459 |
+
"fileType": 8192,
|
460 |
+
"ignore": 0,
|
461 |
+
"ignoreWasSetByUser": 0,
|
462 |
+
"inputAbbreviatedPath": "\/core\/fields\/relationship.php",
|
463 |
+
"outputAbbreviatedPath": "No Output Path",
|
464 |
+
"outputPathIsOutsideProject": 0,
|
465 |
+
"outputPathIsSetByUser": 0
|
466 |
+
},
|
467 |
+
"\/core\/fields\/select.php": {
|
468 |
+
"fileType": 8192,
|
469 |
+
"ignore": 0,
|
470 |
+
"ignoreWasSetByUser": 0,
|
471 |
+
"inputAbbreviatedPath": "\/core\/fields\/select.php",
|
472 |
+
"outputAbbreviatedPath": "No Output Path",
|
473 |
+
"outputPathIsOutsideProject": 0,
|
474 |
+
"outputPathIsSetByUser": 0
|
475 |
+
},
|
476 |
+
"\/core\/fields\/tab.php": {
|
477 |
+
"fileType": 8192,
|
478 |
+
"ignore": 0,
|
479 |
+
"ignoreWasSetByUser": 0,
|
480 |
+
"inputAbbreviatedPath": "\/core\/fields\/tab.php",
|
481 |
+
"outputAbbreviatedPath": "No Output Path",
|
482 |
+
"outputPathIsOutsideProject": 0,
|
483 |
+
"outputPathIsSetByUser": 0
|
484 |
+
},
|
485 |
+
"\/core\/fields\/taxonomy.php": {
|
486 |
+
"fileType": 8192,
|
487 |
+
"ignore": 0,
|
488 |
+
"ignoreWasSetByUser": 0,
|
489 |
+
"inputAbbreviatedPath": "\/core\/fields\/taxonomy.php",
|
490 |
+
"outputAbbreviatedPath": "No Output Path",
|
491 |
+
"outputPathIsOutsideProject": 0,
|
492 |
+
"outputPathIsSetByUser": 0
|
493 |
+
},
|
494 |
+
"\/core\/fields\/text.php": {
|
495 |
+
"fileType": 8192,
|
496 |
+
"ignore": 0,
|
497 |
+
"ignoreWasSetByUser": 0,
|
498 |
+
"inputAbbreviatedPath": "\/core\/fields\/text.php",
|
499 |
+
"outputAbbreviatedPath": "No Output Path",
|
500 |
+
"outputPathIsOutsideProject": 0,
|
501 |
+
"outputPathIsSetByUser": 0
|
502 |
+
},
|
503 |
+
"\/core\/fields\/textarea.php": {
|
504 |
+
"fileType": 8192,
|
505 |
+
"ignore": 0,
|
506 |
+
"ignoreWasSetByUser": 0,
|
507 |
+
"inputAbbreviatedPath": "\/core\/fields\/textarea.php",
|
508 |
+
"outputAbbreviatedPath": "No Output Path",
|
509 |
+
"outputPathIsOutsideProject": 0,
|
510 |
+
"outputPathIsSetByUser": 0
|
511 |
+
},
|
512 |
+
"\/core\/fields\/true_false.php": {
|
513 |
+
"fileType": 8192,
|
514 |
+
"ignore": 0,
|
515 |
+
"ignoreWasSetByUser": 0,
|
516 |
+
"inputAbbreviatedPath": "\/core\/fields\/true_false.php",
|
517 |
+
"outputAbbreviatedPath": "No Output Path",
|
518 |
+
"outputPathIsOutsideProject": 0,
|
519 |
+
"outputPathIsSetByUser": 0
|
520 |
+
},
|
521 |
+
"\/core\/fields\/user.php": {
|
522 |
+
"fileType": 8192,
|
523 |
+
"ignore": 0,
|
524 |
+
"ignoreWasSetByUser": 0,
|
525 |
+
"inputAbbreviatedPath": "\/core\/fields\/user.php",
|
526 |
+
"outputAbbreviatedPath": "No Output Path",
|
527 |
+
"outputPathIsOutsideProject": 0,
|
528 |
+
"outputPathIsSetByUser": 0
|
529 |
+
},
|
530 |
+
"\/core\/fields\/wysiwyg.php": {
|
531 |
+
"fileType": 8192,
|
532 |
+
"ignore": 0,
|
533 |
+
"ignoreWasSetByUser": 0,
|
534 |
+
"inputAbbreviatedPath": "\/core\/fields\/wysiwyg.php",
|
535 |
+
"outputAbbreviatedPath": "No Output Path",
|
536 |
+
"outputPathIsOutsideProject": 0,
|
537 |
+
"outputPathIsSetByUser": 0
|
538 |
+
},
|
539 |
+
"\/core\/views\/meta_box_fields.php": {
|
540 |
+
"fileType": 8192,
|
541 |
+
"ignore": 0,
|
542 |
+
"ignoreWasSetByUser": 0,
|
543 |
+
"inputAbbreviatedPath": "\/core\/views\/meta_box_fields.php",
|
544 |
+
"outputAbbreviatedPath": "No Output Path",
|
545 |
+
"outputPathIsOutsideProject": 0,
|
546 |
+
"outputPathIsSetByUser": 0
|
547 |
+
},
|
548 |
+
"\/core\/views\/meta_box_location.php": {
|
549 |
+
"fileType": 8192,
|
550 |
+
"ignore": 0,
|
551 |
+
"ignoreWasSetByUser": 0,
|
552 |
+
"inputAbbreviatedPath": "\/core\/views\/meta_box_location.php",
|
553 |
+
"outputAbbreviatedPath": "No Output Path",
|
554 |
+
"outputPathIsOutsideProject": 0,
|
555 |
+
"outputPathIsSetByUser": 0
|
556 |
+
},
|
557 |
+
"\/core\/views\/meta_box_options.php": {
|
558 |
+
"fileType": 8192,
|
559 |
+
"ignore": 0,
|
560 |
+
"ignoreWasSetByUser": 0,
|
561 |
+
"inputAbbreviatedPath": "\/core\/views\/meta_box_options.php",
|
562 |
+
"outputAbbreviatedPath": "No Output Path",
|
563 |
+
"outputPathIsOutsideProject": 0,
|
564 |
+
"outputPathIsSetByUser": 0
|
565 |
+
},
|
566 |
+
"\/css\/acf.css": {
|
567 |
+
"fileType": 16,
|
568 |
+
"ignore": 0,
|
569 |
+
"ignoreWasSetByUser": 0,
|
570 |
+
"inputAbbreviatedPath": "\/css\/acf.css",
|
571 |
+
"outputAbbreviatedPath": "No Output Path",
|
572 |
+
"outputPathIsOutsideProject": 0,
|
573 |
+
"outputPathIsSetByUser": 0
|
574 |
+
},
|
575 |
+
"\/css\/field-group.css": {
|
576 |
+
"fileType": 16,
|
577 |
+
"ignore": 0,
|
578 |
+
"ignoreWasSetByUser": 0,
|
579 |
+
"inputAbbreviatedPath": "\/css\/field-group.css",
|
580 |
+
"outputAbbreviatedPath": "No Output Path",
|
581 |
+
"outputPathIsOutsideProject": 0,
|
582 |
+
"outputPathIsSetByUser": 0
|
583 |
+
},
|
584 |
+
"\/css\/global.css": {
|
585 |
+
"fileType": 16,
|
586 |
+
"ignore": 0,
|
587 |
+
"ignoreWasSetByUser": 0,
|
588 |
+
"inputAbbreviatedPath": "\/css\/global.css",
|
589 |
+
"outputAbbreviatedPath": "No Output Path",
|
590 |
+
"outputPathIsOutsideProject": 0,
|
591 |
+
"outputPathIsSetByUser": 0
|
592 |
+
},
|
593 |
+
"\/css\/input.css": {
|
594 |
+
"fileType": 16,
|
595 |
+
"ignore": 0,
|
596 |
+
"ignoreWasSetByUser": 0,
|
597 |
+
"inputAbbreviatedPath": "\/css\/input.css",
|
598 |
+
"outputAbbreviatedPath": "No Output Path",
|
599 |
+
"outputPathIsOutsideProject": 0,
|
600 |
+
"outputPathIsSetByUser": 0
|
601 |
+
},
|
602 |
+
"\/images\/add-ons\/cf7-field-thumb.jpg": {
|
603 |
+
"fileType": 16384,
|
604 |
+
"ignore": 0,
|
605 |
+
"ignoreWasSetByUser": 0,
|
606 |
+
"initialSize": 22418,
|
607 |
+
"inputAbbreviatedPath": "\/images\/add-ons\/cf7-field-thumb.jpg",
|
608 |
+
"outputAbbreviatedPath": "\/images\/add-ons\/cf7-field-thumb.jpg",
|
609 |
+
"outputPathIsOutsideProject": 0,
|
610 |
+
"outputPathIsSetByUser": 0,
|
611 |
+
"processed": 0
|
612 |
+
},
|
613 |
+
"\/images\/add-ons\/date-time-field-thumb.jpg": {
|
614 |
+
"fileType": 16384,
|
615 |
+
"ignore": 0,
|
616 |
+
"ignoreWasSetByUser": 0,
|
617 |
+
"initialSize": 5851,
|
618 |
+
"inputAbbreviatedPath": "\/images\/add-ons\/date-time-field-thumb.jpg",
|
619 |
+
"outputAbbreviatedPath": "\/images\/add-ons\/date-time-field-thumb.jpg",
|
620 |
+
"outputPathIsOutsideProject": 0,
|
621 |
+
"outputPathIsSetByUser": 0,
|
622 |
+
"processed": 0
|
623 |
+
},
|
624 |
+
"\/images\/add-ons\/flexible-content-field-thumb.jpg": {
|
625 |
+
"fileType": 16384,
|
626 |
+
"ignore": 0,
|
627 |
+
"ignoreWasSetByUser": 0,
|
628 |
+
"initialSize": 8488,
|
629 |
+
"inputAbbreviatedPath": "\/images\/add-ons\/flexible-content-field-thumb.jpg",
|
630 |
+
"outputAbbreviatedPath": "\/images\/add-ons\/flexible-content-field-thumb.jpg",
|
631 |
+
"outputPathIsOutsideProject": 0,
|
632 |
+
"outputPathIsSetByUser": 0,
|
633 |
+
"processed": 0
|
634 |
+
},
|
635 |
+
"\/images\/add-ons\/gallery-field-thumb.jpg": {
|
636 |
+
"fileType": 16384,
|
637 |
+
"ignore": 0,
|
638 |
+
"ignoreWasSetByUser": 0,
|
639 |
+
"initialSize": 24886,
|
640 |
+
"inputAbbreviatedPath": "\/images\/add-ons\/gallery-field-thumb.jpg",
|
641 |
+
"outputAbbreviatedPath": "\/images\/add-ons\/gallery-field-thumb.jpg",
|
642 |
+
"outputPathIsOutsideProject": 0,
|
643 |
+
"outputPathIsSetByUser": 0,
|
644 |
+
"processed": 0
|
645 |
+
},
|
646 |
+
"\/images\/add-ons\/google-maps-field-thumb.jpg": {
|
647 |
+
"fileType": 16384,
|
648 |
+
"ignore": 0,
|
649 |
+
"ignoreWasSetByUser": 0,
|
650 |
+
"initialSize": 18725,
|
651 |
+
"inputAbbreviatedPath": "\/images\/add-ons\/google-maps-field-thumb.jpg",
|
652 |
+
"outputAbbreviatedPath": "\/images\/add-ons\/google-maps-field-thumb.jpg",
|
653 |
+
"outputPathIsOutsideProject": 0,
|
654 |
+
"outputPathIsSetByUser": 0,
|
655 |
+
"processed": 0
|
656 |
+
},
|
657 |
+
"\/images\/add-ons\/gravity-forms-field-thumb.jpg": {
|
658 |
+
"fileType": 16384,
|
659 |
+
"ignore": 0,
|
660 |
+
"ignoreWasSetByUser": 0,
|
661 |
+
"initialSize": 6230,
|
662 |
+
"inputAbbreviatedPath": "\/images\/add-ons\/gravity-forms-field-thumb.jpg",
|
663 |
+
"outputAbbreviatedPath": "\/images\/add-ons\/gravity-forms-field-thumb.jpg",
|
664 |
+
"outputPathIsOutsideProject": 0,
|
665 |
+
"outputPathIsSetByUser": 0,
|
666 |
+
"processed": 0
|
667 |
+
},
|
668 |
+
"\/images\/add-ons\/options-page-thumb.jpg": {
|
669 |
+
"fileType": 16384,
|
670 |
+
"ignore": 0,
|
671 |
+
"ignoreWasSetByUser": 0,
|
672 |
+
"initialSize": 16201,
|
673 |
+
"inputAbbreviatedPath": "\/images\/add-ons\/options-page-thumb.jpg",
|
674 |
+
"outputAbbreviatedPath": "\/images\/add-ons\/options-page-thumb.jpg",
|
675 |
+
"outputPathIsOutsideProject": 0,
|
676 |
+
"outputPathIsSetByUser": 0,
|
677 |
+
"processed": 0
|
678 |
+
},
|
679 |
+
"\/images\/add-ons\/repeater-field-thumb.jpg": {
|
680 |
+
"fileType": 16384,
|
681 |
+
"ignore": 0,
|
682 |
+
"ignoreWasSetByUser": 0,
|
683 |
+
"initialSize": 19336,
|
684 |
+
"inputAbbreviatedPath": "\/images\/add-ons\/repeater-field-thumb.jpg",
|
685 |
+
"outputAbbreviatedPath": "\/images\/add-ons\/repeater-field-thumb.jpg",
|
686 |
+
"outputPathIsOutsideProject": 0,
|
687 |
+
"outputPathIsSetByUser": 0,
|
688 |
+
"processed": 0
|
689 |
+
},
|
690 |
+
"\/images\/arrows.png": {
|
691 |
+
"fileType": 32768,
|
692 |
+
"ignore": 0,
|
693 |
+
"ignoreWasSetByUser": 0,
|
694 |
+
"initialSize": 243,
|
695 |
+
"inputAbbreviatedPath": "\/images\/arrows.png",
|
696 |
+
"outputAbbreviatedPath": "\/images\/arrows.png",
|
697 |
+
"outputPathIsOutsideProject": 0,
|
698 |
+
"outputPathIsSetByUser": 0,
|
699 |
+
"processed": 0
|
700 |
+
},
|
701 |
+
"\/images\/arrows@2x.png": {
|
702 |
+
"fileType": 32768,
|
703 |
+
"ignore": 0,
|
704 |
+
"ignoreWasSetByUser": 0,
|
705 |
+
"initialSize": 863,
|
706 |
+
"inputAbbreviatedPath": "\/images\/arrows@2x.png",
|
707 |
+
"outputAbbreviatedPath": "\/images\/arrows@2x.png",
|
708 |
+
"outputPathIsOutsideProject": 0,
|
709 |
+
"outputPathIsSetByUser": 0,
|
710 |
+
"processed": 0
|
711 |
+
},
|
712 |
+
"\/images\/sprite.png": {
|
713 |
+
"fileType": 32768,
|
714 |
+
"ignore": 0,
|
715 |
+
"ignoreWasSetByUser": 0,
|
716 |
+
"initialSize": 6086,
|
717 |
+
"inputAbbreviatedPath": "\/images\/sprite.png",
|
718 |
+
"outputAbbreviatedPath": "\/images\/sprite.png",
|
719 |
+
"outputPathIsOutsideProject": 0,
|
720 |
+
"outputPathIsSetByUser": 0,
|
721 |
+
"processed": 0
|
722 |
+
},
|
723 |
+
"\/images\/sprite@2x.png": {
|
724 |
+
"fileType": 32768,
|
725 |
+
"ignore": 0,
|
726 |
+
"ignoreWasSetByUser": 0,
|
727 |
+
"initialSize": 12829,
|
728 |
+
"inputAbbreviatedPath": "\/images\/sprite@2x.png",
|
729 |
+
"outputAbbreviatedPath": "\/images\/sprite@2x.png",
|
730 |
+
"outputPathIsOutsideProject": 0,
|
731 |
+
"outputPathIsSetByUser": 0,
|
732 |
+
"processed": 0
|
733 |
+
},
|
734 |
+
"\/js\/field-group.js": {
|
735 |
+
"fileType": 64,
|
736 |
+
"ignore": 0,
|
737 |
+
"ignoreWasSetByUser": 0,
|
738 |
+
"inputAbbreviatedPath": "\/js\/field-group.js",
|
739 |
+
"outputAbbreviatedPath": "\/js\/field-group.min.js",
|
740 |
+
"outputPathIsOutsideProject": 0,
|
741 |
+
"outputPathIsSetByUser": 1,
|
742 |
+
"outputStyle": 1,
|
743 |
+
"syntaxCheckerStyle": 1
|
744 |
+
},
|
745 |
+
"\/js\/field-group.min.js": {
|
746 |
+
"fileType": 64,
|
747 |
+
"ignore": 1,
|
748 |
+
"ignoreWasSetByUser": 0,
|
749 |
+
"inputAbbreviatedPath": "\/js\/field-group.min.js",
|
750 |
+
"outputAbbreviatedPath": "\/js\/min\/field-group.min-ck.js",
|
751 |
+
"outputPathIsOutsideProject": 0,
|
752 |
+
"outputPathIsSetByUser": 0,
|
753 |
+
"outputStyle": 1,
|
754 |
+
"syntaxCheckerStyle": 1
|
755 |
+
},
|
756 |
+
"\/js\/input.js": {
|
757 |
+
"fileType": 64,
|
758 |
+
"ignore": 1,
|
759 |
+
"ignoreWasSetByUser": 0,
|
760 |
+
"inputAbbreviatedPath": "\/js\/input.js",
|
761 |
+
"outputAbbreviatedPath": "\/js\/min\/input-ck.js",
|
762 |
+
"outputPathIsOutsideProject": 0,
|
763 |
+
"outputPathIsSetByUser": 0,
|
764 |
+
"outputStyle": 1,
|
765 |
+
"syntaxCheckerStyle": 1
|
766 |
+
},
|
767 |
+
"\/js\/input.min.js": {
|
768 |
+
"fileType": 64,
|
769 |
+
"ignore": 1,
|
770 |
+
"ignoreWasSetByUser": 0,
|
771 |
+
"inputAbbreviatedPath": "\/js\/input.min.js",
|
772 |
+
"outputAbbreviatedPath": "\/js\/min\/input.min-min.js",
|
773 |
+
"outputPathIsOutsideProject": 0,
|
774 |
+
"outputPathIsSetByUser": 0,
|
775 |
+
"outputStyle": 1,
|
776 |
+
"syntaxCheckerStyle": 1
|
777 |
+
},
|
778 |
+
"\/js\/input\/_listener.js": {
|
779 |
+
"fileType": 64,
|
780 |
+
"ignore": 0,
|
781 |
+
"ignoreWasSetByUser": 1,
|
782 |
+
"inputAbbreviatedPath": "\/js\/input\/_listener.js",
|
783 |
+
"outputAbbreviatedPath": "\/js\/input.js",
|
784 |
+
"outputPathIsOutsideProject": 0,
|
785 |
+
"outputPathIsSetByUser": 1,
|
786 |
+
"outputStyle": 0,
|
787 |
+
"syntaxCheckerStyle": 0
|
788 |
+
},
|
789 |
+
"\/js\/input\/_listener.min.js": {
|
790 |
+
"fileType": 64,
|
791 |
+
"ignore": 0,
|
792 |
+
"ignoreWasSetByUser": 1,
|
793 |
+
"inputAbbreviatedPath": "\/js\/input\/_listener.min.js",
|
794 |
+
"outputAbbreviatedPath": "\/js\/input.min.js",
|
795 |
+
"outputPathIsOutsideProject": 0,
|
796 |
+
"outputPathIsSetByUser": 1,
|
797 |
+
"outputStyle": 1,
|
798 |
+
"syntaxCheckerStyle": 0
|
799 |
+
},
|
800 |
+
"\/js\/input\/acf.js": {
|
801 |
+
"fileType": 64,
|
802 |
+
"ignore": 1,
|
803 |
+
"ignoreWasSetByUser": 0,
|
804 |
+
"inputAbbreviatedPath": "\/js\/input\/acf.js",
|
805 |
+
"outputAbbreviatedPath": "\/js\/input\/min\/acf-ck.js",
|
806 |
+
"outputPathIsOutsideProject": 0,
|
807 |
+
"outputPathIsSetByUser": 0,
|
808 |
+
"outputStyle": 1,
|
809 |
+
"syntaxCheckerStyle": 1
|
810 |
+
},
|
811 |
+
"\/js\/input\/ajax.js": {
|
812 |
+
"fileType": 64,
|
813 |
+
"ignore": 1,
|
814 |
+
"ignoreWasSetByUser": 0,
|
815 |
+
"inputAbbreviatedPath": "\/js\/input\/ajax.js",
|
816 |
+
"outputAbbreviatedPath": "\/js\/input\/min\/ajax-ck.js",
|
817 |
+
"outputPathIsOutsideProject": 0,
|
818 |
+
"outputPathIsSetByUser": 0,
|
819 |
+
"outputStyle": 1,
|
820 |
+
"syntaxCheckerStyle": 1
|
821 |
+
},
|
822 |
+
"\/js\/input\/color-picker.js": {
|
823 |
+
"fileType": 64,
|
824 |
+
"ignore": 1,
|
825 |
+
"ignoreWasSetByUser": 0,
|
826 |
+
"inputAbbreviatedPath": "\/js\/input\/color-picker.js",
|
827 |
+
"outputAbbreviatedPath": "\/js\/input\/min\/color-picker-ck.js",
|
828 |
+
"outputPathIsOutsideProject": 0,
|
829 |
+
"outputPathIsSetByUser": 0,
|
830 |
+
"outputStyle": 1,
|
831 |
+
"syntaxCheckerStyle": 1
|
832 |
+
},
|
833 |
+
"\/js\/input\/date-picker.js": {
|
834 |
+
"fileType": 64,
|
835 |
+
"ignore": 1,
|
836 |
+
"ignoreWasSetByUser": 0,
|
837 |
+
"inputAbbreviatedPath": "\/js\/input\/date-picker.js",
|
838 |
+
"outputAbbreviatedPath": "\/js\/input\/min\/date-picker-ck.js",
|
839 |
+
"outputPathIsOutsideProject": 0,
|
840 |
+
"outputPathIsSetByUser": 0,
|
841 |
+
"outputStyle": 1,
|
842 |
+
"syntaxCheckerStyle": 1
|
843 |
+
},
|
844 |
+
"\/js\/input\/file.js": {
|
845 |
+
"fileType": 64,
|
846 |
+
"ignore": 1,
|
847 |
+
"ignoreWasSetByUser": 0,
|
848 |
+
"inputAbbreviatedPath": "\/js\/input\/file.js",
|
849 |
+
"outputAbbreviatedPath": "\/js\/input\/min\/file-ck.js",
|
850 |
+
"outputPathIsOutsideProject": 0,
|
851 |
+
"outputPathIsSetByUser": 0,
|
852 |
+
"outputStyle": 1,
|
853 |
+
"syntaxCheckerStyle": 1
|
854 |
+
},
|
855 |
+
"\/js\/input\/google-map.js": {
|
856 |
+
"fileType": 64,
|
857 |
+
"ignore": 1,
|
858 |
+
"ignoreWasSetByUser": 0,
|
859 |
+
"inputAbbreviatedPath": "\/js\/input\/google-map.js",
|
860 |
+
"outputAbbreviatedPath": "\/js\/input\/min\/google-map-ck.js",
|
861 |
+
"outputPathIsOutsideProject": 0,
|
862 |
+
"outputPathIsSetByUser": 0,
|
863 |
+
"outputStyle": 1,
|
864 |
+
"syntaxCheckerStyle": 1
|
865 |
+
},
|
866 |
+
"\/js\/input\/image.js": {
|
867 |
+
"fileType": 64,
|
868 |
+
"ignore": 1,
|
869 |
+
"ignoreWasSetByUser": 0,
|
870 |
+
"inputAbbreviatedPath": "\/js\/input\/image.js",
|
871 |
+
"outputAbbreviatedPath": "\/js\/input\/min\/image-ck.js",
|
872 |
+
"outputPathIsOutsideProject": 0,
|
873 |
+
"outputPathIsSetByUser": 0,
|
874 |
+
"outputStyle": 1,
|
875 |
+
"syntaxCheckerStyle": 1
|
876 |
+
},
|
877 |
+
"\/js\/input\/radio.js": {
|
878 |
+
"fileType": 64,
|
879 |
+
"ignore": 1,
|
880 |
+
"ignoreWasSetByUser": 0,
|
881 |
+
"inputAbbreviatedPath": "\/js\/input\/radio.js",
|
882 |
+
"outputAbbreviatedPath": "\/js\/input\/min\/radio-ck.js",
|
883 |
+
"outputPathIsOutsideProject": 0,
|
884 |
+
"outputPathIsSetByUser": 0,
|
885 |
+
"outputStyle": 1,
|
886 |
+
"syntaxCheckerStyle": 1
|
887 |
+
},
|
888 |
+
"\/js\/input\/relationship.js": {
|
889 |
+
"fileType": 64,
|
890 |
+
"ignore": 1,
|
891 |
+
"ignoreWasSetByUser": 0,
|
892 |
+
"inputAbbreviatedPath": "\/js\/input\/relationship.js",
|
893 |
+
"outputAbbreviatedPath": "\/js\/input\/min\/relationship-ck.js",
|
894 |
+
"outputPathIsOutsideProject": 0,
|
895 |
+
"outputPathIsSetByUser": 0,
|
896 |
+
"outputStyle": 1,
|
897 |
+
"syntaxCheckerStyle": 1
|
898 |
+
},
|
899 |
+
"\/js\/input\/tab.js": {
|
900 |
+
"fileType": 64,
|
901 |
+
"ignore": 1,
|
902 |
+
"ignoreWasSetByUser": 0,
|
903 |
+
"inputAbbreviatedPath": "\/js\/input\/tab.js",
|
904 |
+
"outputAbbreviatedPath": "\/js\/input\/min\/tab-ck.js",
|
905 |
+
"outputPathIsOutsideProject": 0,
|
906 |
+
"outputPathIsSetByUser": 0,
|
907 |
+
"outputStyle": 1,
|
908 |
+
"syntaxCheckerStyle": 1
|
909 |
+
},
|
910 |
+
"\/js\/input\/validation.js": {
|
911 |
+
"fileType": 64,
|
912 |
+
"ignore": 1,
|
913 |
+
"ignoreWasSetByUser": 0,
|
914 |
+
"inputAbbreviatedPath": "\/js\/input\/validation.js",
|
915 |
+
"outputAbbreviatedPath": "\/js\/input\/min\/validation-ck.js",
|
916 |
+
"outputPathIsOutsideProject": 0,
|
917 |
+
"outputPathIsSetByUser": 0,
|
918 |
+
"outputStyle": 1,
|
919 |
+
"syntaxCheckerStyle": 1
|
920 |
+
},
|
921 |
+
"\/js\/input\/wysiwyg.js": {
|
922 |
+
"fileType": 64,
|
923 |
+
"ignore": 1,
|
924 |
+
"ignoreWasSetByUser": 0,
|
925 |
+
"inputAbbreviatedPath": "\/js\/input\/wysiwyg.js",
|
926 |
+
"outputAbbreviatedPath": "\/js\/input\/min\/wysiwyg-ck.js",
|
927 |
+
"outputPathIsOutsideProject": 0,
|
928 |
+
"outputPathIsSetByUser": 0,
|
929 |
+
"outputStyle": 1,
|
930 |
+
"syntaxCheckerStyle": 1
|
931 |
+
},
|
932 |
+
"\/js\/tinymce.code.min.js": {
|
933 |
+
"fileType": 64,
|
934 |
+
"ignore": 0,
|
935 |
+
"ignoreWasSetByUser": 0,
|
936 |
+
"inputAbbreviatedPath": "\/js\/tinymce.code.min.js",
|
937 |
+
"outputAbbreviatedPath": "\/js\/min\/tinymce.code.min.min.js",
|
938 |
+
"outputPathIsOutsideProject": 0,
|
939 |
+
"outputPathIsSetByUser": 0,
|
940 |
+
"outputStyle": 1,
|
941 |
+
"syntaxCheckerStyle": 1
|
942 |
+
},
|
943 |
+
"\/README.md": {
|
944 |
+
"criticStyle": 0,
|
945 |
+
"enableFootnotes": 0,
|
946 |
+
"enableLabels": 1,
|
947 |
+
"enableSmartQuotes": 1,
|
948 |
+
"escapeLineBreaks": 0,
|
949 |
+
"fileType": 4096,
|
950 |
+
"ignore": 0,
|
951 |
+
"ignoreWasSetByUser": 0,
|
952 |
+
"inputAbbreviatedPath": "\/README.md",
|
953 |
+
"maskEmailAddresses": 1,
|
954 |
+
"outputAbbreviatedPath": "\/README.html",
|
955 |
+
"outputFormat": 0,
|
956 |
+
"outputPathIsOutsideProject": 0,
|
957 |
+
"outputPathIsSetByUser": 0,
|
958 |
+
"outputStyle": 0,
|
959 |
+
"parseMetadata": 1,
|
960 |
+
"processHTML": 0,
|
961 |
+
"randomFootnoteNumbers": 0,
|
962 |
+
"useCompatibilityMode": 0
|
963 |
+
}
|
964 |
+
},
|
965 |
+
"hooks": [
|
966 |
+
],
|
967 |
+
"lastSavedByUser": "elliot condon",
|
968 |
+
"manualImportLinks": {
|
969 |
+
"\/js\/input\/_listener.js": [
|
970 |
+
{
|
971 |
+
"followForSyntaxChecking": 1,
|
972 |
+
"linkedFileAbbreviatedPath": "\/js\/input\/acf.js",
|
973 |
+
"position": 0,
|
974 |
+
"type": 1
|
975 |
+
},
|
976 |
+
{
|
977 |
+
"followForSyntaxChecking": 1,
|
978 |
+
"linkedFileAbbreviatedPath": "\/js\/input\/ajax.js",
|
979 |
+
"position": 1,
|
980 |
+
"type": 1
|
981 |
+
},
|
982 |
+
{
|
983 |
+
"followForSyntaxChecking": 1,
|
984 |
+
"linkedFileAbbreviatedPath": "\/js\/input\/color-picker.js",
|
985 |
+
"position": 2,
|
986 |
+
"type": 1
|
987 |
+
},
|
988 |
+
{
|
989 |
+
"followForSyntaxChecking": 1,
|
990 |
+
"linkedFileAbbreviatedPath": "\/js\/input\/date-picker.js",
|
991 |
+
"position": 3,
|
992 |
+
"type": 1
|
993 |
+
},
|
994 |
+
{
|
995 |
+
"followForSyntaxChecking": 1,
|
996 |
+
"linkedFileAbbreviatedPath": "\/js\/input\/file.js",
|
997 |
+
"position": 4,
|
998 |
+
"type": 1
|
999 |
+
},
|
1000 |
+
{
|
1001 |
+
"followForSyntaxChecking": 1,
|
1002 |
+
"linkedFileAbbreviatedPath": "\/js\/input\/google-map.js",
|
1003 |
+
"position": 5,
|
1004 |
+
"type": 1
|
1005 |
+
},
|
1006 |
+
{
|
1007 |
+
"followForSyntaxChecking": 1,
|
1008 |
+
"linkedFileAbbreviatedPath": "\/js\/input\/image.js",
|
1009 |
+
"position": 6,
|
1010 |
+
"type": 1
|
1011 |
+
},
|
1012 |
+
{
|
1013 |
+
"followForSyntaxChecking": 1,
|
1014 |
+
"linkedFileAbbreviatedPath": "\/js\/input\/radio.js",
|
1015 |
+
"position": 7,
|
1016 |
+
"type": 1
|
1017 |
+
},
|
1018 |
+
{
|
1019 |
+
"followForSyntaxChecking": 1,
|
1020 |
+
"linkedFileAbbreviatedPath": "\/js\/input\/relationship.js",
|
1021 |
+
"position": 8,
|
1022 |
+
"type": 1
|
1023 |
+
},
|
1024 |
+
{
|
1025 |
+
"followForSyntaxChecking": 1,
|
1026 |
+
"linkedFileAbbreviatedPath": "\/js\/input\/tab.js",
|
1027 |
+
"position": 9,
|
1028 |
+
"type": 1
|
1029 |
+
},
|
1030 |
+
{
|
1031 |
+
"followForSyntaxChecking": 1,
|
1032 |
+
"linkedFileAbbreviatedPath": "\/js\/input\/validation.js",
|
1033 |
+
"position": 10,
|
1034 |
+
"type": 1
|
1035 |
+
},
|
1036 |
+
{
|
1037 |
+
"followForSyntaxChecking": 1,
|
1038 |
+
"linkedFileAbbreviatedPath": "\/js\/input\/wysiwyg.js",
|
1039 |
+
"position": 11,
|
1040 |
+
"type": 1
|
1041 |
+
}
|
1042 |
+
],
|
1043 |
+
"\/js\/input\/_listener.min.js": [
|
1044 |
+
{
|
1045 |
+
"followForSyntaxChecking": 1,
|
1046 |
+
"linkedFileAbbreviatedPath": "\/js\/input\/acf.js",
|
1047 |
+
"position": 0,
|
1048 |
+
"type": 1
|
1049 |
+
},
|
1050 |
+
{
|
1051 |
+
"followForSyntaxChecking": 1,
|
1052 |
+
"linkedFileAbbreviatedPath": "\/js\/input\/ajax.js",
|
1053 |
+
"position": 1,
|
1054 |
+
"type": 1
|
1055 |
+
},
|
1056 |
+
{
|
1057 |
+
"followForSyntaxChecking": 1,
|
1058 |
+
"linkedFileAbbreviatedPath": "\/js\/input\/color-picker.js",
|
1059 |
+
"position": 2,
|
1060 |
+
"type": 1
|
1061 |
+
},
|
1062 |
+
{
|
1063 |
+
"followForSyntaxChecking": 1,
|
1064 |
+
"linkedFileAbbreviatedPath": "\/js\/input\/date-picker.js",
|
1065 |
+
"position": 3,
|
1066 |
+
"type": 1
|
1067 |
+
},
|
1068 |
+
{
|
1069 |
+
"followForSyntaxChecking": 1,
|
1070 |
+
"linkedFileAbbreviatedPath": "\/js\/input\/file.js",
|
1071 |
+
"position": 4,
|
1072 |
+
"type": 1
|
1073 |
+
},
|
1074 |
+
{
|
1075 |
+
"followForSyntaxChecking": 1,
|
1076 |
+
"linkedFileAbbreviatedPath": "\/js\/input\/google-map.js",
|
1077 |
+
"position": 5,
|
1078 |
+
"type": 1
|
1079 |
+
},
|
1080 |
+
{
|
1081 |
+
"followForSyntaxChecking": 1,
|
1082 |
+
"linkedFileAbbreviatedPath": "\/js\/input\/image.js",
|
1083 |
+
"position": 6,
|
1084 |
+
"type": 1
|
1085 |
+
},
|
1086 |
+
{
|
1087 |
+
"followForSyntaxChecking": 1,
|
1088 |
+
"linkedFileAbbreviatedPath": "\/js\/input\/radio.js",
|
1089 |
+
"position": 7,
|
1090 |
+
"type": 1
|
1091 |
+
},
|
1092 |
+
{
|
1093 |
+
"followForSyntaxChecking": 1,
|
1094 |
+
"linkedFileAbbreviatedPath": "\/js\/input\/relationship.js",
|
1095 |
+
"position": 8,
|
1096 |
+
"type": 1
|
1097 |
+
},
|
1098 |
+
{
|
1099 |
+
"followForSyntaxChecking": 1,
|
1100 |
+
"linkedFileAbbreviatedPath": "\/js\/input\/tab.js",
|
1101 |
+
"position": 9,
|
1102 |
+
"type": 1
|
1103 |
+
},
|
1104 |
+
{
|
1105 |
+
"followForSyntaxChecking": 1,
|
1106 |
+
"linkedFileAbbreviatedPath": "\/js\/input\/validation.js",
|
1107 |
+
"position": 10,
|
1108 |
+
"type": 1
|
1109 |
+
},
|
1110 |
+
{
|
1111 |
+
"followForSyntaxChecking": 1,
|
1112 |
+
"linkedFileAbbreviatedPath": "\/js\/input\/wysiwyg.js",
|
1113 |
+
"position": 11,
|
1114 |
+
"type": 1
|
1115 |
+
}
|
1116 |
+
]
|
1117 |
+
},
|
1118 |
+
"projectAttributes": {
|
1119 |
+
"bowerAbbreviatedPath": "",
|
1120 |
+
"displayValue": "acf",
|
1121 |
+
"displayValueWasSetByUser": 1,
|
1122 |
+
"iconImageName": "brackets_blue"
|
1123 |
+
},
|
1124 |
+
"projectSettings": {
|
1125 |
+
"alwaysUseExternalServer": 0,
|
1126 |
+
"animateCSSInjections": 1,
|
1127 |
+
"autoApplyPSLanguageSettingsStyle": 0,
|
1128 |
+
"autoprefixerBrowserString": "> 1%, last 2 versions, ff 17, opera 12.1",
|
1129 |
+
"autoSyncProjectSettingsFile": 1,
|
1130 |
+
"browserRefreshDelay": 0,
|
1131 |
+
"coffeeAutoOutputPathEnabled": 1,
|
1132 |
+
"coffeeAutoOutputPathFilenamePattern": "*.js",
|
1133 |
+
"coffeeAutoOutputPathRelativePath": "",
|
1134 |
+
"coffeeAutoOutputPathReplace1": "",
|
1135 |
+
"coffeeAutoOutputPathReplace2": "",
|
1136 |
+
"coffeeAutoOutputPathStyle": 0,
|
1137 |
+
"coffeeCreateSourceMap": 0,
|
1138 |
+
"coffeeLintFlags2": {
|
1139 |
+
"arrow_spacing": {
|
1140 |
+
"active": 0,
|
1141 |
+
"flagValue": -1
|
1142 |
+
},
|
1143 |
+
"camel_case_classes": {
|
1144 |
+
"active": 1,
|
1145 |
+
"flagValue": -1
|
1146 |
+
},
|
1147 |
+
"colon_assignment_spacing": {
|
1148 |
+
"active": 0,
|
1149 |
+
"flagValue": 1
|
1150 |
+
},
|
1151 |
+
"cyclomatic_complexity": {
|
1152 |
+
"active": 0,
|
1153 |
+
"flagValue": 10
|
1154 |
+
},
|
1155 |
+
"duplicate_key": {
|
1156 |
+
"active": 1,
|
1157 |
+
"flagValue": -1
|
1158 |
+
},
|
1159 |
+
"empty_constructor_needs_parens": {
|
1160 |
+
"active": 0,
|
1161 |
+
"flagValue": -1
|
1162 |
+
},
|
1163 |
+
"ensure_comprehensions": {
|
1164 |
+
"active": 1,
|
1165 |
+
"flagValue": -1
|
1166 |
+
},
|
1167 |
+
"indentation": {
|
1168 |
+
"active": 1,
|
1169 |
+
"flagValue": 2
|
1170 |
+
},
|
1171 |
+
"line_endings": {
|
1172 |
+
"active": 0,
|
1173 |
+
"flagValue": 0
|
1174 |
+
},
|
1175 |
+
"max_line_length": {
|
1176 |
+
"active": 0,
|
1177 |
+
"flagValue": 150
|
1178 |
+
},
|
1179 |
+
"missing_fat_arrows": {
|
1180 |
+
"active": 0,
|
1181 |
+
"flagValue": -1
|
1182 |
+
},
|
1183 |
+
"newlines_after_classes": {
|
1184 |
+
"active": 0,
|
1185 |
+
"flagValue": 3
|
1186 |
+
},
|
1187 |
+
"no_backticks": {
|
1188 |
+
"active": 1,
|
1189 |
+
"flagValue": -1
|
1190 |
+
},
|
1191 |
+
"no_debugger": {
|
1192 |
+
"active": 1,
|
1193 |
+
"flagValue": -1
|
1194 |
+
},
|
1195 |
+
"no_empty_functions": {
|
1196 |
+
"active": 0,
|
1197 |
+
"flagValue": -1
|
1198 |
+
},
|
1199 |
+
"no_empty_param_list": {
|
1200 |
+
"active": 0,
|
1201 |
+
"flagValue": -1
|
1202 |
+
},
|
1203 |
+
"no_implicit_braces": {
|
1204 |
+
"active": 1,
|
1205 |
+
"flagValue": -1
|
1206 |
+
},
|
1207 |
+
"no_implicit_parens": {
|
1208 |
+
"active": 0,
|
1209 |
+
"flagValue": -1
|
1210 |
+
},
|
1211 |
+
"no_interpolation_in_single_quotes": {
|
1212 |
+
"active": 0,
|
1213 |
+
"flagValue": -1
|
1214 |
+
},
|
1215 |
+
"no_nested_string_interpolation": {
|
1216 |
+
"active": 1,
|
1217 |
+
"flagValue": -1
|
1218 |
+
},
|
1219 |
+
"no_plusplus": {
|
1220 |
+
"active": 0,
|
1221 |
+
"flagValue": -1
|
1222 |
+
},
|
1223 |
+
"no_private_function_fat_arrows": {
|
1224 |
+
"active": 1,
|
1225 |
+
"flagValue": -1
|
1226 |
+
},
|
1227 |
+
"no_stand_alone_at": {
|
1228 |
+
"active": 1,
|
1229 |
+
"flagValue": -1
|
1230 |
+
},
|
1231 |
+
"no_tabs": {
|
1232 |
+
"active": 1,
|
1233 |
+
"flagValue": -1
|
1234 |
+
},
|
1235 |
+
"no_this": {
|
1236 |
+
"active": 0,
|
1237 |
+
"flagValue": -1
|
1238 |
+
},
|
1239 |
+
"no_throwing_strings": {
|
1240 |
+
"active": 1,
|
1241 |
+
"flagValue": -1
|
1242 |
+
},
|
1243 |
+
"no_trailing_semicolons": {
|
1244 |
+
"active": 1,
|
1245 |
+
"flagValue": -1
|
1246 |
+
},
|
1247 |
+
"no_trailing_whitespace": {
|
1248 |
+
"active": 1,
|
1249 |
+
"flagValue": -1
|
1250 |
+
},
|
1251 |
+
"no_unnecessary_double_quotes": {
|
1252 |
+
"active": 0,
|
1253 |
+
"flagValue": -1
|
1254 |
+
},
|
1255 |
+
"no_unnecessary_fat_arrows": {
|
1256 |
+
"active": 1,
|
1257 |
+
"flagValue": -1
|
1258 |
+
},
|
1259 |
+
"non_empty_constructor_needs_parens": {
|
1260 |
+
"active": 0,
|
1261 |
+
"flagValue": -1
|
1262 |
+
},
|
1263 |
+
"prefer_english_operator": {
|
1264 |
+
"active": 0,
|
1265 |
+
"flagValue": -1
|
1266 |
+
},
|
1267 |
+
"space_operators": {
|
1268 |
+
"active": 0,
|
1269 |
+
"flagValue": -1
|
1270 |
+
},
|
1271 |
+
"spacing_after_comma": {
|
1272 |
+
"active": 1,
|
1273 |
+
"flagValue": -1
|
1274 |
+
}
|
1275 |
+
},
|
1276 |
+
"coffeeMinifyOutput": 1,
|
1277 |
+
"coffeeOutputStyle": 0,
|
1278 |
+
"coffeeSyntaxCheckerStyle": 1,
|
1279 |
+
"externalServerAddress": "http:\/\/localhost:8888",
|
1280 |
+
"externalServerPreviewPathAddition": "",
|
1281 |
+
"genericWebpageFileExtensionsString": "html, htm, shtml, shtm, xhtml, php, jsp, asp, aspx, erb, ctp",
|
1282 |
+
"hamlAutoOutputPathEnabled": 1,
|
1283 |
+
"hamlAutoOutputPathFilenamePattern": "*.html",
|
1284 |
+
"hamlAutoOutputPathRelativePath": "",
|
1285 |
+
"hamlAutoOutputPathReplace1": "",
|
1286 |
+
"hamlAutoOutputPathReplace2": "",
|
1287 |
+
"hamlAutoOutputPathStyle": 0,
|
1288 |
+
"hamlEscapeHTMLCharacters": 0,
|
1289 |
+
"hamlNoEscapeInAttributes": 0,
|
1290 |
+
"hamlOutputFormat": 2,
|
1291 |
+
"hamlOutputStyle": 0,
|
1292 |
+
"hamlUseCDATA": 0,
|
1293 |
+
"hamlUseDoubleQuotes": 0,
|
1294 |
+
"hamlUseUnixNewlines": 0,
|
1295 |
+
"jadeAutoOutputPathEnabled": 1,
|
1296 |
+
"jadeAutoOutputPathFilenamePattern": "*.html",
|
1297 |
+
"jadeAutoOutputPathRelativePath": "",
|
1298 |
+
"jadeAutoOutputPathReplace1": "",
|
1299 |
+
"jadeAutoOutputPathReplace2": "",
|
1300 |
+
"jadeAutoOutputPathStyle": 0,
|
1301 |
+
"jadeCompileDebug": 1,
|
1302 |
+
"jadeOutputStyle": 0,
|
1303 |
+
"javascriptAutoOutputPathEnabled": 1,
|
1304 |
+
"javascriptAutoOutputPathFilenamePattern": "*-min.js",
|
1305 |
+
"javascriptAutoOutputPathRelativePath": "\/min",
|
1306 |
+
"javascriptAutoOutputPathReplace1": "",
|
1307 |
+
"javascriptAutoOutputPathReplace2": "",
|
1308 |
+
"javascriptAutoOutputPathStyle": 2,
|
1309 |
+
"javascriptCreateSourceMap": 1,
|
1310 |
+
"javascriptOutputStyle": 1,
|
1311 |
+
"javascriptSyntaxCheckerStyle": 1,
|
1312 |
+
"jsCheckerReservedNamesString": "",
|
1313 |
+
"jsHintFlags2": {
|
1314 |
+
"asi": {
|
1315 |
+
"active": 0,
|
1316 |
+
"flagValue": -1
|
1317 |
+
},
|
1318 |
+
"bitwise": {
|
1319 |
+
"active": 1,
|
1320 |
+
"flagValue": -1
|
1321 |
+
},
|
1322 |
+
"boss": {
|
1323 |
+
"active": 0,
|
1324 |
+
"flagValue": -1
|
1325 |
+
},
|
1326 |
+
"browser": {
|
1327 |
+
"active": 1,
|
1328 |
+
"flagValue": -1
|
1329 |
+
},
|
1330 |
+
"browserify": {
|
1331 |
+
"active": 0,
|
1332 |
+
"flagValue": -1
|
1333 |
+
},
|
1334 |
+
"camelcase": {
|
1335 |
+
"active": 0,
|
1336 |
+
"flagValue": -1
|
1337 |
+
},
|
1338 |
+
"couch": {
|
1339 |
+
"active": 0,
|
1340 |
+
"flagValue": -1
|
1341 |
+
},
|
1342 |
+
"curly": {
|
1343 |
+
"active": 1,
|
1344 |
+
"flagValue": -1
|
1345 |
+
},
|
1346 |
+
"debug": {
|
1347 |
+
"active": 0,
|
1348 |
+
"flagValue": -1
|
1349 |
+
},
|
1350 |
+
"devel": {
|
1351 |
+
"active": 0,
|
1352 |
+
"flagValue": -1
|
1353 |
+
},
|
1354 |
+
"dojo": {
|
1355 |
+
"active": 0,
|
1356 |
+
"flagValue": -1
|
1357 |
+
},
|
1358 |
+
"elision": {
|
1359 |
+
"active": 1,
|
1360 |
+
"flagValue": -1
|
1361 |
+
},
|
1362 |
+
"eqeqeq": {
|
1363 |
+
"active": 1,
|
1364 |
+
"flagValue": -1
|
1365 |
+
},
|
1366 |
+
"eqnull": {
|
1367 |
+
"active": 0,
|
1368 |
+
"flagValue": -1
|
1369 |
+
},
|
1370 |
+
"es3": {
|
1371 |
+
"active": 0,
|
1372 |
+
"flagValue": -1
|
1373 |
+
},
|
1374 |
+
"esnext": {
|
1375 |
+
"active": 0,
|
1376 |
+
"flagValue": -1
|
1377 |
+
},
|
1378 |
+
"evil": {
|
1379 |
+
"active": 0,
|
1380 |
+
"flagValue": -1
|
1381 |
+
},
|
1382 |
+
"expr": {
|
1383 |
+
"active": 0,
|
1384 |
+
"flagValue": -1
|
1385 |
+
},
|
1386 |
+
"forin": {
|
1387 |
+
"active": 0,
|
1388 |
+
"flagValue": -1
|
1389 |
+
},
|
1390 |
+
"freeze": {
|
1391 |
+
"active": 1,
|
1392 |
+
"flagValue": -1
|
1393 |
+
},
|
1394 |
+
"funcscope": {
|
1395 |
+
"active": 0,
|
1396 |
+
"flagValue": -1
|
1397 |
+
},
|
1398 |
+
"futurehostile": {
|
1399 |
+
"active": 0,
|
1400 |
+
"flagValue": -1
|
1401 |
+
},
|
1402 |
+
"globalstrict": {
|
1403 |
+
"active": 0,
|
1404 |
+
"flagValue": -1
|
1405 |
+
},
|
1406 |
+
"immed": {
|
1407 |
+
"active": 0,
|
1408 |
+
"flagValue": -1
|
1409 |
+
},
|
1410 |
+
"indent": {
|
1411 |
+
"active": 0,
|
1412 |
+
"flagValue": 4
|
1413 |
+
},
|
1414 |
+
"iterator": {
|
1415 |
+
"active": 0,
|
1416 |
+
"flagValue": -1
|
1417 |
+
},
|
1418 |
+
"jasmine": {
|
1419 |
+
"active": 0,
|
1420 |
+
"flagValue": -1
|
1421 |
+
},
|
1422 |
+
"jquery": {
|
1423 |
+
"active": 1,
|
1424 |
+
"flagValue": -1
|
1425 |
+
},
|
1426 |
+
"lastsemic": {
|
1427 |
+
"active": 0,
|
1428 |
+
"flagValue": -1
|
1429 |
+
},
|
1430 |
+
"latedef": {
|
1431 |
+
"active": 1,
|
1432 |
+
"flagValue": -1
|
1433 |
+
},
|
1434 |
+
"laxbreak": {
|
1435 |
+
"active": 0,
|
1436 |
+
"flagValue": -1
|
1437 |
+
},
|
1438 |
+
"laxcomma": {
|
1439 |
+
"active": 0,
|
1440 |
+
"flagValue": -1
|
1441 |
+
},
|
1442 |
+
"loopfunc": {
|
1443 |
+
"active": 0,
|
1444 |
+
"flagValue": -1
|
1445 |
+
},
|
1446 |
+
"maxcomplexity": {
|
1447 |
+
"active": 0,
|
1448 |
+
"flagValue": 10
|
1449 |
+
},
|
1450 |
+
"maxdepth": {
|
1451 |
+
"active": 0,
|
1452 |
+
"flagValue": 3
|
1453 |
+
},
|
1454 |
+
"maxlen": {
|
1455 |
+
"active": 0,
|
1456 |
+
"flagValue": 150
|
1457 |
+
},
|
1458 |
+
"maxparams": {
|
1459 |
+
"active": 0,
|
1460 |
+
"flagValue": 3
|
1461 |
+
},
|
1462 |
+
"maxstatements": {
|
1463 |
+
"active": 0,
|
1464 |
+
"flagValue": 4
|
1465 |
+
},
|
1466 |
+
"mocha": {
|
1467 |
+
"active": 0,
|
1468 |
+
"flagValue": -1
|
1469 |
+
},
|
1470 |
+
"mootools": {
|
1471 |
+
"active": 0,
|
1472 |
+
"flagValue": -1
|
1473 |
+
},
|
1474 |
+
"moz": {
|
1475 |
+
"active": 0,
|
1476 |
+
"flagValue": -1
|
1477 |
+
},
|
1478 |
+
"multistr": {
|
1479 |
+
"active": 0,
|
1480 |
+
"flagValue": -1
|
1481 |
+
},
|
1482 |
+
"newcap": {
|
1483 |
+
"active": 1,
|
1484 |
+
"flagValue": -1
|
1485 |
+
},
|
1486 |
+
"noarg": {
|
1487 |
+
"active": 1,
|
1488 |
+
"flagValue": -1
|
1489 |
+
},
|
1490 |
+
"nocomma": {
|
1491 |
+
"active": 0,
|
1492 |
+
"flagValue": -1
|
1493 |
+
},
|
1494 |
+
"node": {
|
1495 |
+
"active": 0,
|
1496 |
+
"flagValue": -1
|
1497 |
+
},
|
1498 |
+
"noempty": {
|
1499 |
+
"active": 0,
|
1500 |
+
"flagValue": -1
|
1501 |
+
},
|
1502 |
+
"nonbsp": {
|
1503 |
+
"active": 0,
|
1504 |
+
"flagValue": -1
|
1505 |
+
},
|
1506 |
+
"nonew": {
|
1507 |
+
"active": 1,
|
1508 |
+
"flagValue": -1
|
1509 |
+
},
|
1510 |
+
"nonstandard": {
|
1511 |
+
"active": 0,
|
1512 |
+
"flagValue": -1
|
1513 |
+
},
|
1514 |
+
"notypeof": {
|
1515 |
+
"active": 1,
|
1516 |
+
"flagValue": -1
|
1517 |
+
},
|
1518 |
+
"noyield": {
|
1519 |
+
"active": 0,
|
1520 |
+
"flagValue": -1
|
1521 |
+
},
|
1522 |
+
"onecase": {
|
1523 |
+
"active": 0,
|
1524 |
+
"flagValue": -1
|
1525 |
+
},
|
1526 |
+
"phantom": {
|
1527 |
+
"active": 0,
|
1528 |
+
"flagValue": -1
|
1529 |
+
},
|
1530 |
+
"plusplus": {
|
1531 |
+
"active": 0,
|
1532 |
+
"flagValue": -1
|
1533 |
+
},
|
1534 |
+
"proto": {
|
1535 |
+
"active": 0,
|
1536 |
+
"flagValue": -1
|
1537 |
+
},
|
1538 |
+
"prototypejs": {
|
1539 |
+
"active": 0,
|
1540 |
+
"flagValue": -1
|
1541 |
+
},
|
1542 |
+
"qunit": {
|
1543 |
+
"active": 0,
|
1544 |
+
"flagValue": -1
|
1545 |
+
},
|
1546 |
+
"regexp": {
|
1547 |
+
"active": 1,
|
1548 |
+
"flagValue": -1
|
1549 |
+
},
|
1550 |
+
"rhino": {
|
1551 |
+
"active": 0,
|
1552 |
+
"flagValue": -1
|
1553 |
+
},
|
1554 |
+
"scripturl": {
|
1555 |
+
"active": 0,
|
1556 |
+
"flagValue": -1
|
1557 |
+
},
|
1558 |
+
"shadow": {
|
1559 |
+
"active": 0,
|
1560 |
+
"flagValue": -1
|
1561 |
+
},
|
1562 |
+
"shelljs": {
|
1563 |
+
"active": 0,
|
1564 |
+
"flagValue": -1
|
1565 |
+
},
|
1566 |
+
"singleGroups": {
|
1567 |
+
"active": 0,
|
1568 |
+
"flagValue": -1
|
1569 |
+
},
|
1570 |
+
"strict": {
|
1571 |
+
"active": 0,
|
1572 |
+
"flagValue": -1
|
1573 |
+
},
|
1574 |
+
"sub": {
|
1575 |
+
"active": 0,
|
1576 |
+
"flagValue": -1
|
1577 |
+
},
|
1578 |
+
"supernew": {
|
1579 |
+
"active": 0,
|
1580 |
+
"flagValue": -1
|
1581 |
+
},
|
1582 |
+
"typed": {
|
1583 |
+
"active": 0,
|
1584 |
+
"flagValue": -1
|
1585 |
+
},
|
1586 |
+
"undef": {
|
1587 |
+
"active": 1,
|
1588 |
+
"flagValue": -1
|
1589 |
+
},
|
1590 |
+
"unused": {
|
1591 |
+
"active": 1,
|
1592 |
+
"flagValue": -1
|
1593 |
+
},
|
1594 |
+
"varstmt": {
|
1595 |
+
"active": 0,
|
1596 |
+
"flagValue": -1
|
1597 |
+
},
|
1598 |
+
"withstmt": {
|
1599 |
+
"active": 0,
|
1600 |
+
"flagValue": -1
|
1601 |
+
},
|
1602 |
+
"worker": {
|
1603 |
+
"active": 0,
|
1604 |
+
"flagValue": -1
|
1605 |
+
},
|
1606 |
+
"wsh": {
|
1607 |
+
"active": 0,
|
1608 |
+
"flagValue": -1
|
1609 |
+
},
|
1610 |
+
"yui": {
|
1611 |
+
"active": 0,
|
1612 |
+
"flagValue": -1
|
1613 |
+
}
|
1614 |
+
},
|
1615 |
+
"jsLintFlags2": {
|
1616 |
+
"bitwise": {
|
1617 |
+
"active": 0,
|
1618 |
+
"flagValue": -1
|
1619 |
+
},
|
1620 |
+
"browser": {
|
1621 |
+
"active": 1,
|
1622 |
+
"flagValue": -1
|
1623 |
+
},
|
1624 |
+
"couch": {
|
1625 |
+
"active": 0,
|
1626 |
+
"flagValue": -1
|
1627 |
+
},
|
1628 |
+
"devel": {
|
1629 |
+
"active": 0,
|
1630 |
+
"flagValue": -1
|
1631 |
+
},
|
1632 |
+
"es6": {
|
1633 |
+
"active": 0,
|
1634 |
+
"flagValue": -1
|
1635 |
+
},
|
1636 |
+
"eval": {
|
1637 |
+
"active": 0,
|
1638 |
+
"flagValue": -1
|
1639 |
+
},
|
1640 |
+
"for": {
|
1641 |
+
"active": 0,
|
1642 |
+
"flagValue": -1
|
1643 |
+
},
|
1644 |
+
"maxlen": {
|
1645 |
+
"active": 0,
|
1646 |
+
"flagValue": 150
|
1647 |
+
},
|
1648 |
+
"node": {
|
1649 |
+
"active": 0,
|
1650 |
+
"flagValue": -1
|
1651 |
+
},
|
1652 |
+
"this": {
|
1653 |
+
"active": 0,
|
1654 |
+
"flagValue": -1
|
1655 |
+
},
|
1656 |
+
"white": {
|
1657 |
+
"active": 0,
|
1658 |
+
"flagValue": -1
|
1659 |
+
}
|
1660 |
+
},
|
1661 |
+
"jsonAutoOutputPathEnabled": 0,
|
1662 |
+
"jsonAutoOutputPathFilenamePattern": "*-min.json",
|
1663 |
+
"jsonAutoOutputPathRelativePath": "",
|
1664 |
+
"jsonAutoOutputPathReplace1": "",
|
1665 |
+
"jsonAutoOutputPathReplace2": "",
|
1666 |
+
"jsonAutoOutputPathStyle": 0,
|
1667 |
+
"jsonOrderOutput": 0,
|
1668 |
+
"jsonOutputStyle": 1,
|
1669 |
+
"kitAutoOutputPathEnabled": 1,
|
1670 |
+
"kitAutoOutputPathFilenamePattern": "*.html",
|
1671 |
+
"kitAutoOutputPathRelativePath": "",
|
1672 |
+
"kitAutoOutputPathReplace1": "",
|
1673 |
+
"kitAutoOutputPathReplace2": "",
|
1674 |
+
"kitAutoOutputPathStyle": 0,
|
1675 |
+
"lessAllowInsecureImports": 0,
|
1676 |
+
"lessAutoOutputPathEnabled": 1,
|
1677 |
+
"lessAutoOutputPathFilenamePattern": "*.css",
|
1678 |
+
"lessAutoOutputPathRelativePath": "..\/css",
|
1679 |
+
"lessAutoOutputPathReplace1": "less",
|
1680 |
+
"lessAutoOutputPathReplace2": "css",
|
1681 |
+
"lessAutoOutputPathStyle": 2,
|
1682 |
+
"lessCreateSourceMap": 0,
|
1683 |
+
"lessDisableJavascript": 0,
|
1684 |
+
"lessIeCompatibility": 1,
|
1685 |
+
"lessOutputStyle": 0,
|
1686 |
+
"lessRelativeURLS": 0,
|
1687 |
+
"lessStrictImports": 0,
|
1688 |
+
"lessStrictMath": 0,
|
1689 |
+
"lessStrictUnits": 0,
|
1690 |
+
"markdownAutoOutputPathEnabled": 1,
|
1691 |
+
"markdownAutoOutputPathFilenamePattern": "*.html",
|
1692 |
+
"markdownAutoOutputPathRelativePath": "",
|
1693 |
+
"markdownAutoOutputPathReplace1": "",
|
1694 |
+
"markdownAutoOutputPathReplace2": "",
|
1695 |
+
"markdownAutoOutputPathStyle": 0,
|
1696 |
+
"markdownCriticStyle": 0,
|
1697 |
+
"markdownEnableFootnotes": 0,
|
1698 |
+
"markdownEnableLabels": 1,
|
1699 |
+
"markdownEnableSmartQuotes": 1,
|
1700 |
+
"markdownEscapeLineBreaks": 0,
|
1701 |
+
"markdownMaskEmailAddresses": 1,
|
1702 |
+
"markdownOutputFormat": 0,
|
1703 |
+
"markdownOutputStyle": 0,
|
1704 |
+
"markdownParseMetadata": 1,
|
1705 |
+
"markdownProcessHTML": 0,
|
1706 |
+
"markdownRandomFootnoteNumbers": 0,
|
1707 |
+
"markdownUseCompatibilityMode": 0,
|
1708 |
+
"reloadFileURLs": 0,
|
1709 |
+
"sassAutoOutputPathEnabled": 1,
|
1710 |
+
"sassAutoOutputPathFilenamePattern": "*.css",
|
1711 |
+
"sassAutoOutputPathRelativePath": "..\/css",
|
1712 |
+
"sassAutoOutputPathReplace1": "sass",
|
1713 |
+
"sassAutoOutputPathReplace2": "css",
|
1714 |
+
"sassAutoOutputPathStyle": 2,
|
1715 |
+
"sassCreateSourceMap": 0,
|
1716 |
+
"sassDebugStyle": 0,
|
1717 |
+
"sassDecimalPrecision": 5,
|
1718 |
+
"sassOutputStyle": 0,
|
1719 |
+
"sassUseLibsass": 0,
|
1720 |
+
"shouldRunAutoprefixer": 0,
|
1721 |
+
"shouldRunBless": 0,
|
1722 |
+
"skippedItemsString": ".svn, .git, .hg, log, _logs, _cache, cache, logs",
|
1723 |
+
"slimAutoOutputPathEnabled": 1,
|
1724 |
+
"slimAutoOutputPathFilenamePattern": "*.html",
|
1725 |
+
"slimAutoOutputPathRelativePath": "",
|
1726 |
+
"slimAutoOutputPathReplace1": "",
|
1727 |
+
"slimAutoOutputPathReplace2": "",
|
1728 |
+
"slimAutoOutputPathStyle": 0,
|
1729 |
+
"slimCompileOnly": 0,
|
1730 |
+
"slimLogicless": 0,
|
1731 |
+
"slimOutputFormat": 0,
|
1732 |
+
"slimOutputStyle": 1,
|
1733 |
+
"slimRailsCompatible": 0,
|
1734 |
+
"stylusAutoOutputPathEnabled": 1,
|
1735 |
+
"stylusAutoOutputPathFilenamePattern": "*.css",
|
1736 |
+
"stylusAutoOutputPathRelativePath": "..\/css",
|
1737 |
+
"stylusAutoOutputPathReplace1": "stylus",
|
1738 |
+
"stylusAutoOutputPathReplace2": "css",
|
1739 |
+
"stylusAutoOutputPathStyle": 2,
|
1740 |
+
"stylusCreateSourceMap": 0,
|
1741 |
+
"stylusDebugStyle": 0,
|
1742 |
+
"stylusImportCSS": 0,
|
1743 |
+
"stylusOutputStyle": 0,
|
1744 |
+
"stylusResolveRelativeURLS": 0,
|
1745 |
+
"typescriptAutoOutputPathEnabled": 1,
|
1746 |
+
"typescriptAutoOutputPathFilenamePattern": "*.js",
|
1747 |
+
"typescriptAutoOutputPathRelativePath": "\/js",
|
1748 |
+
"typescriptAutoOutputPathReplace1": "",
|
1749 |
+
"typescriptAutoOutputPathReplace2": "",
|
1750 |
+
"typescriptAutoOutputPathStyle": 2,
|
1751 |
+
"typescriptCreateDeclarationFile": 0,
|
1752 |
+
"typescriptCreateSourceMap": 0,
|
1753 |
+
"typescriptJSXMode": 0,
|
1754 |
+
"typescriptMinifyOutput": 0,
|
1755 |
+
"typescriptModuleResolutionType": 0,
|
1756 |
+
"typescriptModuleType": 0,
|
1757 |
+
"typescriptNoImplicitAny": 0,
|
1758 |
+
"typescriptPreserveConstEnums": 0,
|
1759 |
+
"typescriptRemoveComments": 0,
|
1760 |
+
"typescriptSuppressImplicitAnyIndexErrors": 0,
|
1761 |
+
"typescriptTargetECMAVersion": 0,
|
1762 |
+
"uglifyDefinesString": "",
|
1763 |
+
"uglifyFlags2": {
|
1764 |
+
"ascii-only": {
|
1765 |
+
"active": 0,
|
1766 |
+
"flagValue": -1
|
1767 |
+
},
|
1768 |
+
"bare-returns": {
|
1769 |
+
"active": 0,
|
1770 |
+
"flagValue": -1
|
1771 |
+
},
|
1772 |
+
"booleans": {
|
1773 |
+
"active": 1,
|
1774 |
+
"flagValue": -1
|
1775 |
+
},
|
1776 |
+
"bracketize": {
|
1777 |
+
"active": 0,
|
1778 |
+
"flagValue": -1
|
1779 |
+
},
|
1780 |
+
"cascade": {
|
1781 |
+
"active": 1,
|
1782 |
+
"flagValue": -1
|
1783 |
+
},
|
1784 |
+
"comments": {
|
1785 |
+
"active": 1,
|
1786 |
+
"flagValue": -1
|
1787 |
+
},
|
1788 |
+
"comparisons": {
|
1789 |
+
"active": 1,
|
1790 |
+
"flagValue": -1
|
1791 |
+
},
|
1792 |
+
"compress": {
|
1793 |
+
"active": 1,
|
1794 |
+
"flagValue": -1
|
1795 |
+
},
|
1796 |
+
"conditionals": {
|
1797 |
+
"active": 1,
|
1798 |
+
"flagValue": -1
|
1799 |
+
},
|
1800 |
+
"dead_code": {
|
1801 |
+
"active": 0,
|
1802 |
+
"flagValue": -1
|
1803 |
+
},
|
1804 |
+
"drop_console": {
|
1805 |
+
"active": 0,
|
1806 |
+
"flagValue": -1
|
1807 |
+
},
|
1808 |
+
"drop_debugger": {
|
1809 |
+
"active": 1,
|
1810 |
+
"flagValue": -1
|
1811 |
+
},
|
1812 |
+
"eval": {
|
1813 |
+
"active": 0,
|
1814 |
+
"flagValue": -1
|
1815 |
+
},
|
1816 |
+
"evaluate": {
|
1817 |
+
"active": 1,
|
1818 |
+
"flagValue": -1
|
1819 |
+
},
|
1820 |
+
"hoist_funs": {
|
1821 |
+
"active": 1,
|
1822 |
+
"flagValue": -1
|
1823 |
+
},
|
1824 |
+
"hoist_vars": {
|
1825 |
+
"active": 0,
|
1826 |
+
"flagValue": -1
|
1827 |
+
},
|
1828 |
+
"if_return": {
|
1829 |
+
"active": 1,
|
1830 |
+
"flagValue": -1
|
1831 |
+
},
|
1832 |
+
"indent-level": {
|
1833 |
+
"active": 0,
|
1834 |
+
"flagValue": 4
|
1835 |
+
},
|
1836 |
+
"indent-start": {
|
1837 |
+
"active": 0,
|
1838 |
+
"flagValue": 0
|
1839 |
+
},
|
1840 |
+
"inline-script": {
|
1841 |
+
"active": 0,
|
1842 |
+
"flagValue": -1
|
1843 |
+
},
|
1844 |
+
"join_vars": {
|
1845 |
+
"active": 1,
|
1846 |
+
"flagValue": -1
|
1847 |
+
},
|
1848 |
+
"keep_fargs": {
|
1849 |
+
"active": 0,
|
1850 |
+
"flagValue": -1
|
1851 |
+
},
|
1852 |
+
"keep_fnames": {
|
1853 |
+
"active": 0,
|
1854 |
+
"flagValue": -1
|
1855 |
+
},
|
1856 |
+
"loops": {
|
1857 |
+
"active": 1,
|
1858 |
+
"flagValue": -1
|
1859 |
+
},
|
1860 |
+
"mangle": {
|
1861 |
+
"active": 1,
|
1862 |
+
"flagValue": -1
|
1863 |
+
},
|
1864 |
+
"max-line-len": {
|
1865 |
+
"active": 1,
|
1866 |
+
"flagValue": 32000
|
1867 |
+
},
|
1868 |
+
"negate_iife": {
|
1869 |
+
"active": 1,
|
1870 |
+
"flagValue": -1
|
1871 |
+
},
|
1872 |
+
"properties": {
|
1873 |
+
"active": 1,
|
1874 |
+
"flagValue": -1
|
1875 |
+
},
|
1876 |
+
"pure_getters": {
|
1877 |
+
"active": 0,
|
1878 |
+
"flagValue": -1
|
1879 |
+
},
|
1880 |
+
"quote-keys": {
|
1881 |
+
"active": 0,
|
1882 |
+
"flagValue": -1
|
1883 |
+
},
|
1884 |
+
"screw-ie8": {
|
1885 |
+
"active": 0,
|
1886 |
+
"flagValue": -1
|
1887 |
+
},
|
1888 |
+
"semicolons": {
|
1889 |
+
"active": 1,
|
1890 |
+
"flagValue": -1
|
1891 |
+
},
|
1892 |
+
"sequences": {
|
1893 |
+
"active": 1,
|
1894 |
+
"flagValue": -1
|
1895 |
+
},
|
1896 |
+
"sort": {
|
1897 |
+
"active": 0,
|
1898 |
+
"flagValue": -1
|
1899 |
+
},
|
1900 |
+
"space-colon": {
|
1901 |
+
"active": 1,
|
1902 |
+
"flagValue": -1
|
1903 |
+
},
|
1904 |
+
"toplevel": {
|
1905 |
+
"active": 0,
|
1906 |
+
"flagValue": -1
|
1907 |
+
},
|
1908 |
+
"unsafe": {
|
1909 |
+
"active": 0,
|
1910 |
+
"flagValue": -1
|
1911 |
+
},
|
1912 |
+
"unused": {
|
1913 |
+
"active": 0,
|
1914 |
+
"flagValue": -1
|
1915 |
+
},
|
1916 |
+
"warnings": {
|
1917 |
+
"active": 0,
|
1918 |
+
"flagValue": -1
|
1919 |
+
},
|
1920 |
+
"width": {
|
1921 |
+
"active": 1,
|
1922 |
+
"flagValue": 80
|
1923 |
+
}
|
1924 |
+
},
|
1925 |
+
"uglifyReservedNamesString": "$",
|
1926 |
+
"websiteRelativeRoot": ""
|
1927 |
+
},
|
1928 |
+
"settingsFileVersion": "2"
|
1929 |
+
}
|
shared/assets/plugins/advanced-custom-fields/core/actions/export.php
CHANGED
@@ -1,275 +1,275 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* Export
|
5 |
-
*
|
6 |
-
* @description:
|
7 |
-
* @since: 3.6
|
8 |
-
* @created: 25/01/13
|
9 |
-
*/
|
10 |
-
|
11 |
-
// Exit if accessed directly
|
12 |
-
if ( !defined( 'ABSPATH' ) ) exit;
|
13 |
-
|
14 |
-
|
15 |
-
// vars
|
16 |
-
$defaults = array(
|
17 |
-
'acf_posts' => array(),
|
18 |
-
'nonce' => ''
|
19 |
-
);
|
20 |
-
$my_options = array_merge( $defaults, $_POST );
|
21 |
-
|
22 |
-
|
23 |
-
// validate nonce
|
24 |
-
if( !wp_verify_nonce($my_options['nonce'], 'export') )
|
25 |
-
{
|
26 |
-
wp_die(__("Error",'acf'));
|
27 |
-
}
|
28 |
-
|
29 |
-
|
30 |
-
// check for posts
|
31 |
-
if( empty($my_options['acf_posts']) )
|
32 |
-
{
|
33 |
-
wp_die(__("No ACF groups selected",'acf'));
|
34 |
-
}
|
35 |
-
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Version number for the export format.
|
39 |
-
*
|
40 |
-
* Bump this when something changes that might affect compatibility.
|
41 |
-
*
|
42 |
-
* @since 2.5.0
|
43 |
-
*/
|
44 |
-
define( 'WXR_VERSION', '1.1' );
|
45 |
-
|
46 |
-
|
47 |
-
/*
|
48 |
-
* fix_line_breaks
|
49 |
-
*
|
50 |
-
* This function will loop through all array pieces and correct double line breaks from DB to XML
|
51 |
-
*
|
52 |
-
* @type function
|
53 |
-
* @date 2/12/2013
|
54 |
-
* @since 5.0.0
|
55 |
-
*
|
56 |
-
* @param $v (mixed)
|
57 |
-
* @return $v (mixed)
|
58 |
-
*/
|
59 |
-
|
60 |
-
function fix_line_breaks( $v )
|
61 |
-
{
|
62 |
-
if( is_array($v) )
|
63 |
-
{
|
64 |
-
foreach( array_keys($v) as $k )
|
65 |
-
{
|
66 |
-
$v[ $k ] = fix_line_breaks( $v[ $k ] );
|
67 |
-
}
|
68 |
-
}
|
69 |
-
elseif( is_string($v) )
|
70 |
-
{
|
71 |
-
$v = str_replace("\r\n", "\r", $v);
|
72 |
-
}
|
73 |
-
|
74 |
-
return $v;
|
75 |
-
}
|
76 |
-
|
77 |
-
|
78 |
-
/**
|
79 |
-
* Wrap given string in XML CDATA tag.
|
80 |
-
*
|
81 |
-
* @since 2.1.0
|
82 |
-
*
|
83 |
-
* @param string $str String to wrap in XML CDATA tag.
|
84 |
-
*/
|
85 |
-
function wxr_cdata( $str ) {
|
86 |
-
if ( seems_utf8( $str ) == false )
|
87 |
-
$str = utf8_encode( $str );
|
88 |
-
|
89 |
-
// $str = ent2ncr(esc_html($str));
|
90 |
-
$str = "<![CDATA[$str" . ( ( substr( $str, -1 ) == ']' ) ? ' ' : '' ) . ']]>';
|
91 |
-
|
92 |
-
return $str;
|
93 |
-
}
|
94 |
-
|
95 |
-
/**
|
96 |
-
* Return the URL of the site
|
97 |
-
*
|
98 |
-
* @since 2.5.0
|
99 |
-
*
|
100 |
-
* @return string Site URL.
|
101 |
-
*/
|
102 |
-
function wxr_site_url() {
|
103 |
-
// ms: the base url
|
104 |
-
if ( is_multisite() )
|
105 |
-
return network_home_url();
|
106 |
-
// wp: the blog url
|
107 |
-
else
|
108 |
-
return get_site_url();
|
109 |
-
}
|
110 |
-
|
111 |
-
/**
|
112 |
-
* Output a tag_description XML tag from a given tag object
|
113 |
-
*
|
114 |
-
* @since 2.3.0
|
115 |
-
*
|
116 |
-
* @param object $tag Tag Object
|
117 |
-
*/
|
118 |
-
function wxr_tag_description( $tag ) {
|
119 |
-
if ( empty( $tag->description ) )
|
120 |
-
return;
|
121 |
-
|
122 |
-
echo '<wp:tag_description>' . wxr_cdata( $tag->description ) . '</wp:tag_description>';
|
123 |
-
}
|
124 |
-
|
125 |
-
/**
|
126 |
-
* Output a term_name XML tag from a given term object
|
127 |
-
*
|
128 |
-
* @since 2.9.0
|
129 |
-
*
|
130 |
-
* @param object $term Term Object
|
131 |
-
*/
|
132 |
-
function wxr_term_name( $term ) {
|
133 |
-
if ( empty( $term->name ) )
|
134 |
-
return;
|
135 |
-
|
136 |
-
echo '<wp:term_name>' . wxr_cdata( $term->name ) . '</wp:term_name>';
|
137 |
-
}
|
138 |
-
|
139 |
-
/**
|
140 |
-
* Output a term_description XML tag from a given term object
|
141 |
-
*
|
142 |
-
* @since 2.9.0
|
143 |
-
*
|
144 |
-
* @param object $term Term Object
|
145 |
-
*/
|
146 |
-
function wxr_term_description( $term ) {
|
147 |
-
if ( empty( $term->description ) )
|
148 |
-
return;
|
149 |
-
|
150 |
-
echo '<wp:term_description>' . wxr_cdata( $term->description ) . '</wp:term_description>';
|
151 |
-
}
|
152 |
-
|
153 |
-
/**
|
154 |
-
* Output list of authors with posts
|
155 |
-
*
|
156 |
-
* @since 3.1.0
|
157 |
-
*/
|
158 |
-
function wxr_authors_list() {
|
159 |
-
global $wpdb;
|
160 |
-
|
161 |
-
$authors = array();
|
162 |
-
$results = $wpdb->get_results( "SELECT DISTINCT post_author FROM $wpdb->posts" );
|
163 |
-
foreach ( (array) $results as $result )
|
164 |
-
$authors[] = get_userdata( $result->post_author );
|
165 |
-
|
166 |
-
$authors = array_filter( $authors );
|
167 |
-
|
168 |
-
foreach( $authors as $author ) {
|
169 |
-
echo "\t<wp:author>";
|
170 |
-
echo '<wp:author_id>' . $author->ID . '</wp:author_id>';
|
171 |
-
echo '<wp:author_login>' . $author->user_login . '</wp:author_login>';
|
172 |
-
echo '<wp:author_email>' . $author->user_email . '</wp:author_email>';
|
173 |
-
echo '<wp:author_display_name>' . wxr_cdata( $author->display_name ) . '</wp:author_display_name>';
|
174 |
-
echo '<wp:author_first_name>' . wxr_cdata( $author->user_firstname ) . '</wp:author_first_name>';
|
175 |
-
echo '<wp:author_last_name>' . wxr_cdata( $author->user_lastname ) . '</wp:author_last_name>';
|
176 |
-
echo "</wp:author>\n";
|
177 |
-
}
|
178 |
-
}
|
179 |
-
|
180 |
-
header( 'Content-Description: File Transfer' );
|
181 |
-
header( 'Content-Disposition: attachment; filename=advanced-custom-field-export.xml' );
|
182 |
-
header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
|
183 |
-
|
184 |
-
|
185 |
-
echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . "\" ?>\n";
|
186 |
-
|
187 |
-
?>
|
188 |
-
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
|
189 |
-
<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
|
190 |
-
<!-- You may use this file to transfer that content from one site to another. -->
|
191 |
-
<!-- This file is not intended to serve as a complete backup of your site. -->
|
192 |
-
|
193 |
-
<!-- To import this information into a WordPress site follow these steps: -->
|
194 |
-
<!-- 1. Log in to that site as an administrator. -->
|
195 |
-
<!-- 2. Go to Tools: Import in the WordPress admin panel. -->
|
196 |
-
<!-- 3. Install the "WordPress" importer from the list. -->
|
197 |
-
<!-- 4. Activate & Run Importer. -->
|
198 |
-
<!-- 5. Upload this file using the form provided on that page. -->
|
199 |
-
<!-- 6. You will first be asked to map the authors in this export file to users -->
|
200 |
-
<!-- on the site. For each author, you may choose to map to an -->
|
201 |
-
<!-- existing user on the site or to create a new user. -->
|
202 |
-
<!-- 7. WordPress will then import each of the posts, pages, comments, categories, etc. -->
|
203 |
-
<!-- contained in this file into your site. -->
|
204 |
-
|
205 |
-
<?php the_generator( 'export' ); ?>
|
206 |
-
<rss version="2.0"
|
207 |
-
xmlns:excerpt="http://wordpress.org/export/<?php echo WXR_VERSION; ?>/excerpt/"
|
208 |
-
xmlns:content="http://purl.org/rss/1.0/modules/content/"
|
209 |
-
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
|
210 |
-
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
211 |
-
xmlns:wp="http://wordpress.org/export/<?php echo WXR_VERSION; ?>/"
|
212 |
-
>
|
213 |
-
|
214 |
-
<channel>
|
215 |
-
<title><?php bloginfo_rss( 'name' ); ?></title>
|
216 |
-
<link><?php bloginfo_rss( 'url' ); ?></link>
|
217 |
-
<description><?php bloginfo_rss( 'description' ); ?></description>
|
218 |
-
<pubDate><?php echo date( 'D, d M Y H:i:s +0000' ); ?></pubDate>
|
219 |
-
<language><?php echo get_option( 'rss_language' ); ?></language>
|
220 |
-
<wp:wxr_version><?php echo WXR_VERSION; ?></wp:wxr_version>
|
221 |
-
<wp:base_site_url><?php echo wxr_site_url(); ?></wp:base_site_url>
|
222 |
-
<wp:base_blog_url><?php bloginfo_rss( 'url' ); ?></wp:base_blog_url>
|
223 |
-
<?php wxr_authors_list(); ?>
|
224 |
-
<?php if ( $my_options['acf_posts'] ) {
|
225 |
-
|
226 |
-
global $wp_query, $wpdb, $post;
|
227 |
-
$wp_query->in_the_loop = true; // Fake being in the loop.
|
228 |
-
|
229 |
-
// create SQL with %d placeholders
|
230 |
-
$where = 'WHERE ID IN (' . substr(str_repeat('%d,', count($my_options['acf_posts'])), 0, -1) . ')';
|
231 |
-
|
232 |
-
// now prepare the SQL based on the %d + $_POST data
|
233 |
-
$posts = $wpdb->get_results( $wpdb->prepare("SELECT * FROM {$wpdb->posts} $where", $my_options['acf_posts']));
|
234 |
-
|
235 |
-
// Begin Loop
|
236 |
-
foreach ( $posts as $post ) {
|
237 |
-
setup_postdata( $post );
|
238 |
-
?>
|
239 |
-
<item>
|
240 |
-
<title><?php echo apply_filters( 'the_title_rss', $post->post_title ); ?></title>
|
241 |
-
<link><?php the_permalink_rss() ?></link>
|
242 |
-
<pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); ?></pubDate>
|
243 |
-
<dc:creator><?php echo get_the_author_meta( 'login' ); ?></dc:creator>
|
244 |
-
<guid isPermaLink="false"><?php esc_url( the_guid() ); ?></guid>
|
245 |
-
<wp:post_id><?php echo $post->ID; ?></wp:post_id>
|
246 |
-
<wp:post_date><?php echo $post->post_date; ?></wp:post_date>
|
247 |
-
<wp:post_date_gmt><?php echo $post->post_date_gmt; ?></wp:post_date_gmt>
|
248 |
-
<wp:comment_status><?php echo $post->comment_status; ?></wp:comment_status>
|
249 |
-
<wp:ping_status><?php echo $post->ping_status; ?></wp:ping_status>
|
250 |
-
<wp:post_name><?php echo $post->post_name; ?></wp:post_name>
|
251 |
-
<wp:status><?php echo $post->post_status; ?></wp:status>
|
252 |
-
<wp:post_parent><?php echo $post->post_parent; ?></wp:post_parent>
|
253 |
-
<wp:menu_order><?php echo $post->menu_order; ?></wp:menu_order>
|
254 |
-
<wp:post_type><?php echo $post->post_type; ?></wp:post_type>
|
255 |
-
<wp:post_password><?php echo $post->post_password; ?></wp:post_password>
|
256 |
-
<?php $postmeta = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post->ID ) );
|
257 |
-
foreach( $postmeta as $meta ) : if ( $meta->meta_key != '_edit_lock' ) :
|
258 |
-
|
259 |
-
$meta->meta_value = maybe_unserialize( $meta->meta_value );
|
260 |
-
$meta->meta_value = fix_line_breaks( $meta->meta_value );
|
261 |
-
$meta->meta_value = maybe_serialize( $meta->meta_value );
|
262 |
-
|
263 |
-
?>
|
264 |
-
<wp:postmeta>
|
265 |
-
<wp:meta_key><?php echo $meta->meta_key; ?></wp:meta_key>
|
266 |
-
<wp:meta_value><?php echo wxr_cdata( $meta->meta_value ); ?></wp:meta_value>
|
267 |
-
</wp:postmeta>
|
268 |
-
<?php endif; endforeach; ?>
|
269 |
-
</item>
|
270 |
-
<?php
|
271 |
-
}
|
272 |
-
}
|
273 |
-
?>
|
274 |
-
</channel>
|
275 |
-
</rss>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* Export
|
5 |
+
*
|
6 |
+
* @description:
|
7 |
+
* @since: 3.6
|
8 |
+
* @created: 25/01/13
|
9 |
+
*/
|
10 |
+
|
11 |
+
// Exit if accessed directly
|
12 |
+
if ( !defined( 'ABSPATH' ) ) exit;
|
13 |
+
|
14 |
+
|
15 |
+
// vars
|
16 |
+
$defaults = array(
|
17 |
+
'acf_posts' => array(),
|
18 |
+
'nonce' => ''
|
19 |
+
);
|
20 |
+
$my_options = array_merge( $defaults, $_POST );
|
21 |
+
|
22 |
+
|
23 |
+
// validate nonce
|
24 |
+
if( !wp_verify_nonce($my_options['nonce'], 'export') )
|
25 |
+
{
|
26 |
+
wp_die(__("Error",'acf'));
|
27 |
+
}
|
28 |
+
|
29 |
+
|
30 |
+
// check for posts
|
31 |
+
if( empty($my_options['acf_posts']) )
|
32 |
+
{
|
33 |
+
wp_die(__("No ACF groups selected",'acf'));
|
34 |
+
}
|
35 |
+
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Version number for the export format.
|
39 |
+
*
|
40 |
+
* Bump this when something changes that might affect compatibility.
|
41 |
+
*
|
42 |
+
* @since 2.5.0
|
43 |
+
*/
|
44 |
+
define( 'WXR_VERSION', '1.1' );
|
45 |
+
|
46 |
+
|
47 |
+
/*
|
48 |
+
* fix_line_breaks
|
49 |
+
*
|
50 |
+
* This function will loop through all array pieces and correct double line breaks from DB to XML
|
51 |
+
*
|
52 |
+
* @type function
|
53 |
+
* @date 2/12/2013
|
54 |
+
* @since 5.0.0
|
55 |
+
*
|
56 |
+
* @param $v (mixed)
|
57 |
+
* @return $v (mixed)
|
58 |
+
*/
|
59 |
+
|
60 |
+
function fix_line_breaks( $v )
|
61 |
+
{
|
62 |
+
if( is_array($v) )
|
63 |
+
{
|
64 |
+
foreach( array_keys($v) as $k )
|
65 |
+
{
|
66 |
+
$v[ $k ] = fix_line_breaks( $v[ $k ] );
|
67 |
+
}
|
68 |
+
}
|
69 |
+
elseif( is_string($v) )
|
70 |
+
{
|
71 |
+
$v = str_replace("\r\n", "\r", $v);
|
72 |
+
}
|
73 |
+
|
74 |
+
return $v;
|
75 |
+
}
|
76 |
+
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Wrap given string in XML CDATA tag.
|
80 |
+
*
|
81 |
+
* @since 2.1.0
|
82 |
+
*
|
83 |
+
* @param string $str String to wrap in XML CDATA tag.
|
84 |
+
*/
|
85 |
+
function wxr_cdata( $str ) {
|
86 |
+
if ( seems_utf8( $str ) == false )
|
87 |
+
$str = utf8_encode( $str );
|
88 |
+
|
89 |
+
// $str = ent2ncr(esc_html($str));
|
90 |
+
$str = "<![CDATA[$str" . ( ( substr( $str, -1 ) == ']' ) ? ' ' : '' ) . ']]>';
|
91 |
+
|
92 |
+
return $str;
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Return the URL of the site
|
97 |
+
*
|
98 |
+
* @since 2.5.0
|
99 |
+
*
|
100 |
+
* @return string Site URL.
|
101 |
+
*/
|
102 |
+
function wxr_site_url() {
|
103 |
+
// ms: the base url
|
104 |
+
if ( is_multisite() )
|
105 |
+
return network_home_url();
|
106 |
+
// wp: the blog url
|
107 |
+
else
|
108 |
+
return get_site_url();
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Output a tag_description XML tag from a given tag object
|
113 |
+
*
|
114 |
+
* @since 2.3.0
|
115 |
+
*
|
116 |
+
* @param object $tag Tag Object
|
117 |
+
*/
|
118 |
+
function wxr_tag_description( $tag ) {
|
119 |
+
if ( empty( $tag->description ) )
|
120 |
+
return;
|
121 |
+
|
122 |
+
echo '<wp:tag_description>' . wxr_cdata( $tag->description ) . '</wp:tag_description>';
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Output a term_name XML tag from a given term object
|
127 |
+
*
|
128 |
+
* @since 2.9.0
|
129 |
+
*
|
130 |
+
* @param object $term Term Object
|
131 |
+
*/
|
132 |
+
function wxr_term_name( $term ) {
|
133 |
+
if ( empty( $term->name ) )
|
134 |
+
return;
|
135 |
+
|
136 |
+
echo '<wp:term_name>' . wxr_cdata( $term->name ) . '</wp:term_name>';
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Output a term_description XML tag from a given term object
|
141 |
+
*
|
142 |
+
* @since 2.9.0
|
143 |
+
*
|
144 |
+
* @param object $term Term Object
|
145 |
+
*/
|
146 |
+
function wxr_term_description( $term ) {
|
147 |
+
if ( empty( $term->description ) )
|
148 |
+
return;
|
149 |
+
|
150 |
+
echo '<wp:term_description>' . wxr_cdata( $term->description ) . '</wp:term_description>';
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Output list of authors with posts
|
155 |
+
*
|
156 |
+
* @since 3.1.0
|
157 |
+
*/
|
158 |
+
function wxr_authors_list() {
|
159 |
+
global $wpdb;
|
160 |
+
|
161 |
+
$authors = array();
|
162 |
+
$results = $wpdb->get_results( "SELECT DISTINCT post_author FROM $wpdb->posts" );
|
163 |
+
foreach ( (array) $results as $result )
|
164 |
+
$authors[] = get_userdata( $result->post_author );
|
165 |
+
|
166 |
+
$authors = array_filter( $authors );
|
167 |
+
|
168 |
+
foreach( $authors as $author ) {
|
169 |
+
echo "\t<wp:author>";
|
170 |
+
echo '<wp:author_id>' . $author->ID . '</wp:author_id>';
|
171 |
+
echo '<wp:author_login>' . $author->user_login . '</wp:author_login>';
|
172 |
+
echo '<wp:author_email>' . $author->user_email . '</wp:author_email>';
|
173 |
+
echo '<wp:author_display_name>' . wxr_cdata( $author->display_name ) . '</wp:author_display_name>';
|
174 |
+
echo '<wp:author_first_name>' . wxr_cdata( $author->user_firstname ) . '</wp:author_first_name>';
|
175 |
+
echo '<wp:author_last_name>' . wxr_cdata( $author->user_lastname ) . '</wp:author_last_name>';
|
176 |
+
echo "</wp:author>\n";
|
177 |
+
}
|
178 |
+
}
|
179 |
+
|
180 |
+
header( 'Content-Description: File Transfer' );
|
181 |
+
header( 'Content-Disposition: attachment; filename=advanced-custom-field-export.xml' );
|
182 |
+
header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
|
183 |
+
|
184 |
+
|
185 |
+
echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . "\" ?>\n";
|
186 |
+
|
187 |
+
?>
|
188 |
+
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
|
189 |
+
<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
|
190 |
+
<!-- You may use this file to transfer that content from one site to another. -->
|
191 |
+
<!-- This file is not intended to serve as a complete backup of your site. -->
|
192 |
+
|
193 |
+
<!-- To import this information into a WordPress site follow these steps: -->
|
194 |
+
<!-- 1. Log in to that site as an administrator. -->
|
195 |
+
<!-- 2. Go to Tools: Import in the WordPress admin panel. -->
|
196 |
+
<!-- 3. Install the "WordPress" importer from the list. -->
|
197 |
+
<!-- 4. Activate & Run Importer. -->
|
198 |
+
<!-- 5. Upload this file using the form provided on that page. -->
|
199 |
+
<!-- 6. You will first be asked to map the authors in this export file to users -->
|
200 |
+
<!-- on the site. For each author, you may choose to map to an -->
|
201 |
+
<!-- existing user on the site or to create a new user. -->
|
202 |
+
<!-- 7. WordPress will then import each of the posts, pages, comments, categories, etc. -->
|
203 |
+
<!-- contained in this file into your site. -->
|
204 |
+
|
205 |
+
<?php the_generator( 'export' ); ?>
|
206 |
+
<rss version="2.0"
|
207 |
+
xmlns:excerpt="http://wordpress.org/export/<?php echo WXR_VERSION; ?>/excerpt/"
|
208 |
+
xmlns:content="http://purl.org/rss/1.0/modules/content/"
|
209 |
+
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
|
210 |
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
211 |
+
xmlns:wp="http://wordpress.org/export/<?php echo WXR_VERSION; ?>/"
|
212 |
+
>
|
213 |
+
|
214 |
+
<channel>
|
215 |
+
<title><?php bloginfo_rss( 'name' ); ?></title>
|
216 |
+
<link><?php bloginfo_rss( 'url' ); ?></link>
|
217 |
+
<description><?php bloginfo_rss( 'description' ); ?></description>
|
218 |
+
<pubDate><?php echo date( 'D, d M Y H:i:s +0000' ); ?></pubDate>
|
219 |
+
<language><?php echo get_option( 'rss_language' ); ?></language>
|
220 |
+
<wp:wxr_version><?php echo WXR_VERSION; ?></wp:wxr_version>
|
221 |
+
<wp:base_site_url><?php echo wxr_site_url(); ?></wp:base_site_url>
|
222 |
+
<wp:base_blog_url><?php bloginfo_rss( 'url' ); ?></wp:base_blog_url>
|
223 |
+
<?php wxr_authors_list(); ?>
|
224 |
+
<?php if ( $my_options['acf_posts'] ) {
|
225 |
+
|
226 |
+
global $wp_query, $wpdb, $post;
|
227 |
+
$wp_query->in_the_loop = true; // Fake being in the loop.
|
228 |
+
|
229 |
+
// create SQL with %d placeholders
|
230 |
+
$where = 'WHERE ID IN (' . substr(str_repeat('%d,', count($my_options['acf_posts'])), 0, -1) . ')';
|
231 |
+
|
232 |
+
// now prepare the SQL based on the %d + $_POST data
|
233 |
+
$posts = $wpdb->get_results( $wpdb->prepare("SELECT * FROM {$wpdb->posts} $where", $my_options['acf_posts']));
|
234 |
+
|
235 |
+
// Begin Loop
|
236 |
+
foreach ( $posts as $post ) {
|
237 |
+
setup_postdata( $post );
|
238 |
+
?>
|
239 |
+
<item>
|
240 |
+
<title><?php echo apply_filters( 'the_title_rss', $post->post_title ); ?></title>
|
241 |
+
<link><?php the_permalink_rss() ?></link>
|
242 |
+
<pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); ?></pubDate>
|
243 |
+
<dc:creator><?php echo get_the_author_meta( 'login' ); ?></dc:creator>
|
244 |
+
<guid isPermaLink="false"><?php esc_url( the_guid() ); ?></guid>
|
245 |
+
<wp:post_id><?php echo $post->ID; ?></wp:post_id>
|
246 |
+
<wp:post_date><?php echo $post->post_date; ?></wp:post_date>
|
247 |
+
<wp:post_date_gmt><?php echo $post->post_date_gmt; ?></wp:post_date_gmt>
|
248 |
+
<wp:comment_status><?php echo $post->comment_status; ?></wp:comment_status>
|
249 |
+
<wp:ping_status><?php echo $post->ping_status; ?></wp:ping_status>
|
250 |
+
<wp:post_name><?php echo $post->post_name; ?></wp:post_name>
|
251 |
+
<wp:status><?php echo $post->post_status; ?></wp:status>
|
252 |
+
<wp:post_parent><?php echo $post->post_parent; ?></wp:post_parent>
|
253 |
+
<wp:menu_order><?php echo $post->menu_order; ?></wp:menu_order>
|
254 |
+
<wp:post_type><?php echo $post->post_type; ?></wp:post_type>
|
255 |
+
<wp:post_password><?php echo $post->post_password; ?></wp:post_password>
|
256 |
+
<?php $postmeta = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post->ID ) );
|
257 |
+
foreach( $postmeta as $meta ) : if ( $meta->meta_key != '_edit_lock' ) :
|
258 |
+
|
259 |
+
$meta->meta_value = maybe_unserialize( $meta->meta_value );
|
260 |
+
$meta->meta_value = fix_line_breaks( $meta->meta_value );
|
261 |
+
$meta->meta_value = maybe_serialize( $meta->meta_value );
|
262 |
+
|
263 |
+
?>
|
264 |
+
<wp:postmeta>
|
265 |
+
<wp:meta_key><?php echo $meta->meta_key; ?></wp:meta_key>
|
266 |
+
<wp:meta_value><?php echo wxr_cdata( $meta->meta_value ); ?></wp:meta_value>
|
267 |
+
</wp:postmeta>
|
268 |
+
<?php endif; endforeach; ?>
|
269 |
+
</item>
|
270 |
+
<?php
|
271 |
+
}
|
272 |
+
}
|
273 |
+
?>
|
274 |
+
</channel>
|
275 |
+
</rss>
|
shared/assets/plugins/advanced-custom-fields/core/api.php
CHANGED
@@ -1,1668 +1,1668 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* get_field_reference()
|
5 |
-
*
|
6 |
-
* This function will find the $field_key that is related to the $field_name.
|
7 |
-
* This is know as the field value reference
|
8 |
-
*
|
9 |
-
* @type function
|
10 |
-
* @since 3.6
|
11 |
-
* @date 29/01/13
|
12 |
-
*
|
13 |
-
* @param mixed $field_name: the name of the field - 'sub_heading'
|
14 |
-
* @param int $post_id: the post_id of which the value is saved against
|
15 |
-
*
|
16 |
-
* @return string $return: a string containing the field_key
|
17 |
-
*/
|
18 |
-
|
19 |
-
function get_field_reference( $field_name, $post_id ) {
|
20 |
-
|
21 |
-
// cache
|
22 |
-
$found = false;
|
23 |
-
$cache = wp_cache_get( 'field_reference/post_id=' . $post_id . '/name=' . $field_name, 'acf', false, $found );
|
24 |
-
|
25 |
-
if( $found )
|
26 |
-
{
|
27 |
-
return $cache;
|
28 |
-
}
|
29 |
-
|
30 |
-
|
31 |
-
// vars
|
32 |
-
$return = '';
|
33 |
-
|
34 |
-
|
35 |
-
// get field key
|
36 |
-
if( is_numeric($post_id) )
|
37 |
-
{
|
38 |
-
$return = get_post_meta($post_id, '_' . $field_name, true);
|
39 |
-
}
|
40 |
-
elseif( strpos($post_id, 'user_') !== false )
|
41 |
-
{
|
42 |
-
$temp_post_id = str_replace('user_', '', $post_id);
|
43 |
-
$return = get_user_meta($temp_post_id, '_' . $field_name, true);
|
44 |
-
}
|
45 |
-
else
|
46 |
-
{
|
47 |
-
$return = get_option('_' . $post_id . '_' . $field_name);
|
48 |
-
}
|
49 |
-
|
50 |
-
|
51 |
-
// set cache
|
52 |
-
wp_cache_set( 'field_reference/post_id=' . $post_id . '/name=' . $field_name, $return, 'acf' );
|
53 |
-
|
54 |
-
|
55 |
-
// return
|
56 |
-
return $return;
|
57 |
-
}
|
58 |
-
|
59 |
-
|
60 |
-
/*
|
61 |
-
* get_field_objects()
|
62 |
-
*
|
63 |
-
* This function will return an array containing all the custom field objects for a specific post_id.
|
64 |
-
* The function is not very elegant and wastes a lot of PHP memory / SQL queries if you are not using all the fields / values.
|
65 |
-
*
|
66 |
-
* @type function
|
67 |
-
* @since 3.6
|
68 |
-
* @date 29/01/13
|
69 |
-
*
|
70 |
-
* @param mixed $post_id: the post_id of which the value is saved against
|
71 |
-
*
|
72 |
-
* @return array $return: an array containin the field groups
|
73 |
-
*/
|
74 |
-
|
75 |
-
function get_field_objects( $post_id = false, $options = array() ) {
|
76 |
-
|
77 |
-
// global
|
78 |
-
global $wpdb;
|
79 |
-
|
80 |
-
|
81 |
-
// filter post_id
|
82 |
-
$post_id = apply_filters('acf/get_post_id', $post_id );
|
83 |
-
|
84 |
-
|
85 |
-
// vars
|
86 |
-
$field_key = '';
|
87 |
-
$value = array();
|
88 |
-
|
89 |
-
|
90 |
-
// get field_names
|
91 |
-
if( is_numeric($post_id) )
|
92 |
-
{
|
93 |
-
$keys = $wpdb->get_col($wpdb->prepare(
|
94 |
-
"SELECT meta_value FROM $wpdb->postmeta WHERE post_id = %d and meta_key LIKE %s AND meta_value LIKE %s",
|
95 |
-
$post_id,
|
96 |
-
'_%',
|
97 |
-
'field_%'
|
98 |
-
));
|
99 |
-
}
|
100 |
-
elseif( strpos($post_id, 'user_') !== false )
|
101 |
-
{
|
102 |
-
$user_id = str_replace('user_', '', $post_id);
|
103 |
-
|
104 |
-
$keys = $wpdb->get_col($wpdb->prepare(
|
105 |
-
"SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d and meta_key LIKE %s AND meta_value LIKE %s",
|
106 |
-
$user_id,
|
107 |
-
'_%',
|
108 |
-
'field_%'
|
109 |
-
));
|
110 |
-
}
|
111 |
-
else
|
112 |
-
{
|
113 |
-
$keys = $wpdb->get_col($wpdb->prepare(
|
114 |
-
"SELECT option_value FROM $wpdb->options WHERE option_name LIKE %s",
|
115 |
-
'_' . $post_id . '_%'
|
116 |
-
));
|
117 |
-
}
|
118 |
-
|
119 |
-
|
120 |
-
if( is_array($keys) )
|
121 |
-
{
|
122 |
-
foreach( $keys as $key )
|
123 |
-
{
|
124 |
-
$field = get_field_object( $key, $post_id, $options );
|
125 |
-
|
126 |
-
if( !is_array($field) )
|
127 |
-
{
|
128 |
-
continue;
|
129 |
-
}
|
130 |
-
|
131 |
-
$value[ $field['name'] ] = $field;
|
132 |
-
}
|
133 |
-
}
|
134 |
-
|
135 |
-
|
136 |
-
// no value
|
137 |
-
if( empty($value) )
|
138 |
-
{
|
139 |
-
return false;
|
140 |
-
}
|
141 |
-
|
142 |
-
|
143 |
-
// return
|
144 |
-
return $value;
|
145 |
-
}
|
146 |
-
|
147 |
-
|
148 |
-
/*
|
149 |
-
* get_fields()
|
150 |
-
*
|
151 |
-
* This function will return an array containing all the custom field values for a specific post_id.
|
152 |
-
* The function is not very elegant and wastes a lot of PHP memory / SQL queries if you are not using all the values.
|
153 |
-
*
|
154 |
-
* @type function
|
155 |
-
* @since 3.6
|
156 |
-
* @date 29/01/13
|
157 |
-
*
|
158 |
-
* @param mixed $post_id: the post_id of which the value is saved against
|
159 |
-
*
|
160 |
-
* @return array $return: an array containin the field values
|
161 |
-
*/
|
162 |
-
|
163 |
-
function get_fields( $post_id = false, $format_value = true ) {
|
164 |
-
|
165 |
-
// vars
|
166 |
-
$options = array(
|
167 |
-
'load_value' => true,
|
168 |
-
'format_value' => $format_value
|
169 |
-
);
|
170 |
-
|
171 |
-
|
172 |
-
$fields = get_field_objects( $post_id, $options );
|
173 |
-
|
174 |
-
if( is_array($fields) )
|
175 |
-
{
|
176 |
-
foreach( $fields as $k => $field )
|
177 |
-
{
|
178 |
-
$fields[ $k ] = $field['value'];
|
179 |
-
}
|
180 |
-
}
|
181 |
-
|
182 |
-
return $fields;
|
183 |
-
}
|
184 |
-
|
185 |
-
|
186 |
-
/*
|
187 |
-
* get_field()
|
188 |
-
*
|
189 |
-
* This function will return a custom field value for a specific field name/key + post_id.
|
190 |
-
* There is a 3rd parameter to turn on/off formating. This means that an Image field will not use
|
191 |
-
* its 'return option' to format the value but return only what was saved in the database
|
192 |
-
*
|
193 |
-
* @type function
|
194 |
-
* @since 3.6
|
195 |
-
* @date 29/01/13
|
196 |
-
*
|
197 |
-
* @param string $field_key: string containing the name of
|
198 |
-
* @param mixed $post_id: the post_id of which the value is saved against
|
199 |
-
* @param boolean $format_value: whether or not to format the value as described above
|
200 |
-
*
|
201 |
-
* @return mixed $value: the value found
|
202 |
-
*/
|
203 |
-
|
204 |
-
function get_field( $field_key, $post_id = false, $format_value = true ) {
|
205 |
-
|
206 |
-
// vars
|
207 |
-
$return = false;
|
208 |
-
$options = array(
|
209 |
-
'load_value' => true,
|
210 |
-
'format_value' => $format_value
|
211 |
-
);
|
212 |
-
|
213 |
-
|
214 |
-
$field = get_field_object( $field_key, $post_id, $options);
|
215 |
-
|
216 |
-
|
217 |
-
if( is_array($field) )
|
218 |
-
{
|
219 |
-
$return = $field['value'];
|
220 |
-
}
|
221 |
-
|
222 |
-
|
223 |
-
return $return;
|
224 |
-
|
225 |
-
}
|
226 |
-
|
227 |
-
|
228 |
-
/*
|
229 |
-
* get_field_object()
|
230 |
-
*
|
231 |
-
* This function will return an array containing all the field data for a given field_name
|
232 |
-
*
|
233 |
-
* @type function
|
234 |
-
* @since 3.6
|
235 |
-
* @date 3/02/13
|
236 |
-
*
|
237 |
-
* @param string $field_key: string containing the name of
|
238 |
-
* @param mixed $post_id: the post_id of which the value is saved against
|
239 |
-
* @param array $options: an array containing options
|
240 |
-
* boolean + load_value: load the field value or not. Defaults to true
|
241 |
-
* boolean + format_value: format the field value or not. Defaults to true
|
242 |
-
*
|
243 |
-
* @return array $return: an array containin the field groups
|
244 |
-
*/
|
245 |
-
|
246 |
-
function get_field_object( $field_key, $post_id = false, $options = array() ) {
|
247 |
-
|
248 |
-
// make sure add-ons are included
|
249 |
-
acf()->include_3rd_party();
|
250 |
-
|
251 |
-
|
252 |
-
// filter post_id
|
253 |
-
$post_id = apply_filters('acf/get_post_id', $post_id );
|
254 |
-
$field = false;
|
255 |
-
$orig_field_key = $field_key;
|
256 |
-
|
257 |
-
|
258 |
-
// defaults for options
|
259 |
-
$defaults = array(
|
260 |
-
'load_value' => true,
|
261 |
-
'format_value' => true,
|
262 |
-
);
|
263 |
-
|
264 |
-
$options = array_merge($defaults, $options);
|
265 |
-
|
266 |
-
|
267 |
-
// is $field_name a name? pre 3.4.0
|
268 |
-
if( substr($field_key, 0, 6) !== 'field_' )
|
269 |
-
{
|
270 |
-
// get field key
|
271 |
-
$field_key = get_field_reference( $field_key, $post_id );
|
272 |
-
}
|
273 |
-
|
274 |
-
|
275 |
-
// get field
|
276 |
-
if( substr($field_key, 0, 6) === 'field_' )
|
277 |
-
{
|
278 |
-
$field = apply_filters('acf/load_field', false, $field_key );
|
279 |
-
}
|
280 |
-
|
281 |
-
|
282 |
-
// validate field
|
283 |
-
if( !$field )
|
284 |
-
{
|
285 |
-
// treat as text field
|
286 |
-
$field = array(
|
287 |
-
'type' => 'text',
|
288 |
-
'name' => $orig_field_key,
|
289 |
-
'key' => 'field_' . $orig_field_key,
|
290 |
-
);
|
291 |
-
$field = apply_filters('acf/load_field', $field, $field['key'] );
|
292 |
-
}
|
293 |
-
|
294 |
-
|
295 |
-
// load value
|
296 |
-
if( $options['load_value'] )
|
297 |
-
{
|
298 |
-
$field['value'] = apply_filters('acf/load_value', false, $post_id, $field);
|
299 |
-
|
300 |
-
|
301 |
-
// format value
|
302 |
-
if( $options['format_value'] )
|
303 |
-
{
|
304 |
-
$field['value'] = apply_filters('acf/format_value_for_api', $field['value'], $post_id, $field);
|
305 |
-
}
|
306 |
-
}
|
307 |
-
|
308 |
-
|
309 |
-
return $field;
|
310 |
-
|
311 |
-
}
|
312 |
-
|
313 |
-
|
314 |
-
/*
|
315 |
-
* the_field()
|
316 |
-
*
|
317 |
-
* This function is the same as echo get_field().
|
318 |
-
*
|
319 |
-
* @type function
|
320 |
-
* @since 1.0.3
|
321 |
-
* @date 29/01/13
|
322 |
-
*
|
323 |
-
* @param string $field_name: the name of the field - 'sub_heading'
|
324 |
-
* @param mixed $post_id: the post_id of which the value is saved against
|
325 |
-
*
|
326 |
-
* @return string $value
|
327 |
-
*/
|
328 |
-
|
329 |
-
function the_field( $field_name, $post_id = false ) {
|
330 |
-
|
331 |
-
$value = get_field($field_name, $post_id);
|
332 |
-
|
333 |
-
if( is_array($value) )
|
334 |
-
{
|
335 |
-
$value = @implode(', ',$value);
|
336 |
-
}
|
337 |
-
|
338 |
-
echo $value;
|
339 |
-
}
|
340 |
-
|
341 |
-
|
342 |
-
/*
|
343 |
-
* have_rows
|
344 |
-
*
|
345 |
-
* This function will instantiate a global variable containing the rows of a repeater or flexible content field,
|
346 |
-
* afterwhich, it will determine if another row exists to loop through
|
347 |
-
*
|
348 |
-
* @type function
|
349 |
-
* @date 2/09/13
|
350 |
-
* @since 4.3.0
|
351 |
-
*
|
352 |
-
* @param $field_name (string) the name of the field - 'images'
|
353 |
-
* @return $post_id (mixed) the post_id of which the value is saved against
|
354 |
-
*/
|
355 |
-
|
356 |
-
function have_rows( $field_name, $post_id = false ) {
|
357 |
-
|
358 |
-
// vars
|
359 |
-
$depth = 0;
|
360 |
-
$row = array();
|
361 |
-
$new_parent_loop = false;
|
362 |
-
$new_child_loop = false;
|
363 |
-
|
364 |
-
|
365 |
-
// reference
|
366 |
-
$_post_id = $post_id;
|
367 |
-
|
368 |
-
|
369 |
-
// filter post_id
|
370 |
-
$post_id = apply_filters('acf/get_post_id', $post_id );
|
371 |
-
|
372 |
-
|
373 |
-
// empty?
|
374 |
-
if( empty($GLOBALS['acf_field']) )
|
375 |
-
{
|
376 |
-
// reset
|
377 |
-
reset_rows( true );
|
378 |
-
|
379 |
-
|
380 |
-
// create a new loop
|
381 |
-
$new_parent_loop = true;
|
382 |
-
}
|
383 |
-
else
|
384 |
-
{
|
385 |
-
// vars
|
386 |
-
$row = end( $GLOBALS['acf_field'] );
|
387 |
-
$prev = prev( $GLOBALS['acf_field'] );
|
388 |
-
|
389 |
-
|
390 |
-
// If post_id has changed, this is most likely an archive loop
|
391 |
-
if( $post_id != $row['post_id'] )
|
392 |
-
{
|
393 |
-
if( $prev && $prev['post_id'] == $post_id )
|
394 |
-
{
|
395 |
-
// case: Change in $post_id was due to a nested loop ending
|
396 |
-
// action: move up one level through the loops
|
397 |
-
reset_rows();
|
398 |
-
}
|
399 |
-
elseif( empty($_post_id) && isset($row['value'][ $row['i'] ][ $field_name ]) )
|
400 |
-
{
|
401 |
-
// case: Change in $post_id was due to this being a nested loop and not specifying the $post_id
|
402 |
-
// action: move down one level into a new loop
|
403 |
-
$new_child_loop = true;
|
404 |
-
}
|
405 |
-
else
|
406 |
-
{
|
407 |
-
// case: Chang in $post_id is the most obvious, used in an WP_Query loop with multiple $post objects
|
408 |
-
// action: leave this current loop alone and create a new parent loop
|
409 |
-
$new_parent_loop = true;
|
410 |
-
}
|
411 |
-
}
|
412 |
-
elseif( $field_name != $row['name'] )
|
413 |
-
{
|
414 |
-
if( $prev && $prev['name'] == $field_name && $prev['post_id'] == $post_id )
|
415 |
-
{
|
416 |
-
// case: Change in $field_name was due to a nested loop ending
|
417 |
-
// action: move up one level through the loops
|
418 |
-
reset_rows();
|
419 |
-
}
|
420 |
-
elseif( isset($row['value'][ $row['i'] ][ $field_name ]) )
|
421 |
-
{
|
422 |
-
// case: Change in $field_name was due to this being a nested loop
|
423 |
-
// action: move down one level into a new loop
|
424 |
-
$new_child_loop = true;
|
425 |
-
|
426 |
-
}
|
427 |
-
else
|
428 |
-
{
|
429 |
-
// case: Chang in $field_name is the most obvious, this is a new loop for a different field within the $post
|
430 |
-
// action: leave this current loop alone and create a new parent loop
|
431 |
-
$new_parent_loop = true;
|
432 |
-
}
|
433 |
-
|
434 |
-
|
435 |
-
}
|
436 |
-
}
|
437 |
-
|
438 |
-
|
439 |
-
if( $new_parent_loop )
|
440 |
-
{
|
441 |
-
// vars
|
442 |
-
$f = get_field_object( $field_name, $post_id );
|
443 |
-
$v = $f['value'];
|
444 |
-
unset( $f['value'] );
|
445 |
-
|
446 |
-
|
447 |
-
// add row
|
448 |
-
$GLOBALS['acf_field'][] = array(
|
449 |
-
'name' => $field_name,
|
450 |
-
'value' => $v,
|
451 |
-
'field' => $f,
|
452 |
-
'i' => -1,
|
453 |
-
'post_id' => $post_id,
|
454 |
-
);
|
455 |
-
|
456 |
-
}
|
457 |
-
elseif( $new_child_loop )
|
458 |
-
{
|
459 |
-
// vars
|
460 |
-
$f = acf_get_child_field_from_parent_field( $field_name, $row['field'] );
|
461 |
-
$v = $row['value'][ $row['i'] ][ $field_name ];
|
462 |
-
|
463 |
-
$GLOBALS['acf_field'][] = array(
|
464 |
-
'name' => $field_name,
|
465 |
-
'value' => $v,
|
466 |
-
'field' => $f,
|
467 |
-
'i' => -1,
|
468 |
-
'post_id' => $post_id,
|
469 |
-
);
|
470 |
-
|
471 |
-
}
|
472 |
-
|
473 |
-
|
474 |
-
// update vars
|
475 |
-
$row = end( $GLOBALS['acf_field'] );
|
476 |
-
|
477 |
-
|
478 |
-
if( is_array($row['value']) && array_key_exists( $row['i']+1, $row['value'] ) )
|
479 |
-
{
|
480 |
-
// next row exists
|
481 |
-
return true;
|
482 |
-
}
|
483 |
-
|
484 |
-
|
485 |
-
// no next row!
|
486 |
-
reset_rows();
|
487 |
-
|
488 |
-
|
489 |
-
// return
|
490 |
-
return false;
|
491 |
-
|
492 |
-
}
|
493 |
-
|
494 |
-
|
495 |
-
/*
|
496 |
-
* the_row
|
497 |
-
*
|
498 |
-
* This function will progress the global repeater or flexible content value 1 row
|
499 |
-
*
|
500 |
-
* @type function
|
501 |
-
* @date 2/09/13
|
502 |
-
* @since 4.3.0
|
503 |
-
*
|
504 |
-
* @param N/A
|
505 |
-
* @return N/A
|
506 |
-
*/
|
507 |
-
|
508 |
-
function the_row() {
|
509 |
-
|
510 |
-
// vars
|
511 |
-
$depth = count( $GLOBALS['acf_field'] ) - 1;
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
// increase row
|
516 |
-
$GLOBALS['acf_field'][ $depth ]['i']++;
|
517 |
-
|
518 |
-
|
519 |
-
// get row
|
520 |
-
$value = $GLOBALS['acf_field'][ $depth ]['value'];
|
521 |
-
$i = $GLOBALS['acf_field'][ $depth ]['i'];
|
522 |
-
|
523 |
-
|
524 |
-
// return
|
525 |
-
return $value[ $i ];
|
526 |
-
}
|
527 |
-
|
528 |
-
|
529 |
-
/*
|
530 |
-
* reset_rows
|
531 |
-
*
|
532 |
-
* This function will find the current loop and unset it from the global array.
|
533 |
-
* To bo used when loop finishes or a break is used
|
534 |
-
*
|
535 |
-
* @type function
|
536 |
-
* @date 26/10/13
|
537 |
-
* @since 5.0.0
|
538 |
-
*
|
539 |
-
* @param $post_id (int)
|
540 |
-
* @return $post_id (int)
|
541 |
-
*/
|
542 |
-
|
543 |
-
function reset_rows( $hard_reset = false ) {
|
544 |
-
|
545 |
-
// completely destroy?
|
546 |
-
if( $hard_reset )
|
547 |
-
{
|
548 |
-
$GLOBALS['acf_field'] = array();
|
549 |
-
}
|
550 |
-
else
|
551 |
-
{
|
552 |
-
// vars
|
553 |
-
$depth = count( $GLOBALS['acf_field'] ) - 1;
|
554 |
-
|
555 |
-
|
556 |
-
// remove
|
557 |
-
unset( $GLOBALS['acf_field'][$depth] );
|
558 |
-
|
559 |
-
|
560 |
-
// refresh index
|
561 |
-
$GLOBALS['acf_field'] = array_values($GLOBALS['acf_field']);
|
562 |
-
}
|
563 |
-
|
564 |
-
|
565 |
-
// return
|
566 |
-
return true;
|
567 |
-
|
568 |
-
|
569 |
-
}
|
570 |
-
|
571 |
-
|
572 |
-
/*
|
573 |
-
* has_sub_field()
|
574 |
-
*
|
575 |
-
* This function is used inside a while loop to return either true or false (loop again or stop).
|
576 |
-
* When using a repeater or flexible content field, it will loop through the rows until
|
577 |
-
* there are none left or a break is detected
|
578 |
-
*
|
579 |
-
* @type function
|
580 |
-
* @since 1.0.3
|
581 |
-
* @date 29/01/13
|
582 |
-
*
|
583 |
-
* @param string $field_name: the name of the field - 'sub_heading'
|
584 |
-
* @param mixed $post_id: the post_id of which the value is saved against
|
585 |
-
*
|
586 |
-
* @return bool
|
587 |
-
*/
|
588 |
-
|
589 |
-
function has_sub_field( $field_name, $post_id = false ) {
|
590 |
-
|
591 |
-
// vars
|
592 |
-
$r = have_rows( $field_name, $post_id );
|
593 |
-
|
594 |
-
|
595 |
-
// if has rows, progress through 1 row for the while loop to work
|
596 |
-
if( $r )
|
597 |
-
{
|
598 |
-
the_row();
|
599 |
-
}
|
600 |
-
|
601 |
-
|
602 |
-
// return
|
603 |
-
return $r;
|
604 |
-
}
|
605 |
-
|
606 |
-
|
607 |
-
/*
|
608 |
-
* has_sub_fields()
|
609 |
-
*
|
610 |
-
* This function is a replica of 'has_sub_field'
|
611 |
-
*
|
612 |
-
* @type function
|
613 |
-
* @since 4.0.0
|
614 |
-
* @date 29/01/13
|
615 |
-
*
|
616 |
-
* @param string $field_name: the name of the field - 'sub_heading'
|
617 |
-
* @param mixed $post_id: the post_id of which the value is saved against
|
618 |
-
*
|
619 |
-
* @return bool
|
620 |
-
*/
|
621 |
-
|
622 |
-
function has_sub_fields( $field_name, $post_id = false )
|
623 |
-
{
|
624 |
-
return has_sub_field( $field_name, $post_id );
|
625 |
-
}
|
626 |
-
|
627 |
-
|
628 |
-
/*
|
629 |
-
* get_sub_field()
|
630 |
-
*
|
631 |
-
* This function is used inside a 'has_sub_field' while loop to return a sub field value
|
632 |
-
*
|
633 |
-
* @type function
|
634 |
-
* @since 1.0.3
|
635 |
-
* @date 29/01/13
|
636 |
-
*
|
637 |
-
* @param string $field_name: the name of the field - 'sub_heading'
|
638 |
-
*
|
639 |
-
* @return mixed $value
|
640 |
-
*/
|
641 |
-
|
642 |
-
function get_sub_field( $field_name ) {
|
643 |
-
|
644 |
-
// no field?
|
645 |
-
if( empty($GLOBALS['acf_field']) )
|
646 |
-
{
|
647 |
-
return false;
|
648 |
-
}
|
649 |
-
|
650 |
-
|
651 |
-
// vars
|
652 |
-
$row = end( $GLOBALS['acf_field'] );
|
653 |
-
|
654 |
-
|
655 |
-
// return value
|
656 |
-
if( isset($row['value'][ $row['i'] ][ $field_name ]) )
|
657 |
-
{
|
658 |
-
return $row['value'][ $row['i'] ][ $field_name ];
|
659 |
-
}
|
660 |
-
|
661 |
-
|
662 |
-
// return false
|
663 |
-
return false;
|
664 |
-
}
|
665 |
-
|
666 |
-
|
667 |
-
/*
|
668 |
-
* get_sub_field()
|
669 |
-
*
|
670 |
-
* This function is the same as echo get_sub_field
|
671 |
-
*
|
672 |
-
* @type function
|
673 |
-
* @since 1.0.3
|
674 |
-
* @date 29/01/13
|
675 |
-
*
|
676 |
-
* @param string $field_name: the name of the field - 'sub_heading'
|
677 |
-
*
|
678 |
-
* @return string $value
|
679 |
-
*/
|
680 |
-
|
681 |
-
function the_sub_field($field_name)
|
682 |
-
{
|
683 |
-
$value = get_sub_field($field_name);
|
684 |
-
|
685 |
-
if(is_array($value))
|
686 |
-
{
|
687 |
-
$value = implode(', ',$value);
|
688 |
-
}
|
689 |
-
|
690 |
-
echo $value;
|
691 |
-
}
|
692 |
-
|
693 |
-
|
694 |
-
/*
|
695 |
-
* get_sub_field_object()
|
696 |
-
*
|
697 |
-
* This function is used inside a 'has_sub_field' while loop to return a sub field object
|
698 |
-
*
|
699 |
-
* @type function
|
700 |
-
* @since 3.5.8.1
|
701 |
-
* @date 29/01/13
|
702 |
-
*
|
703 |
-
* @param string $field_name: the name of the field - 'sub_heading'
|
704 |
-
*
|
705 |
-
* @return array $sub_field
|
706 |
-
*/
|
707 |
-
|
708 |
-
function get_sub_field_object( $child_name )
|
709 |
-
{
|
710 |
-
// no field?
|
711 |
-
if( empty($GLOBALS['acf_field']) )
|
712 |
-
{
|
713 |
-
return false;
|
714 |
-
}
|
715 |
-
|
716 |
-
|
717 |
-
// vars
|
718 |
-
$depth = count( $GLOBALS['acf_field'] ) - 1;
|
719 |
-
$parent = $GLOBALS['acf_field'][$depth]['field'];
|
720 |
-
|
721 |
-
|
722 |
-
// return
|
723 |
-
return acf_get_child_field_from_parent_field( $child_name, $parent );
|
724 |
-
|
725 |
-
}
|
726 |
-
|
727 |
-
|
728 |
-
/*
|
729 |
-
* acf_get_sub_field_from_parent_field()
|
730 |
-
*
|
731 |
-
* This function is used by the get_sub_field_object to find a sub field within a parent field
|
732 |
-
*
|
733 |
-
* @type function
|
734 |
-
* @since 3.5.8.1
|
735 |
-
* @date 29/01/13
|
736 |
-
*
|
737 |
-
* @param string $child_name: the name of the field - 'sub_heading'
|
738 |
-
* @param array $parent: the parent field object
|
739 |
-
*
|
740 |
-
* @return array $sub_field
|
741 |
-
*/
|
742 |
-
|
743 |
-
function acf_get_child_field_from_parent_field( $child_name, $parent )
|
744 |
-
{
|
745 |
-
// vars
|
746 |
-
$return = false;
|
747 |
-
|
748 |
-
|
749 |
-
// find child
|
750 |
-
if( isset($parent['sub_fields']) && is_array($parent['sub_fields']) )
|
751 |
-
{
|
752 |
-
foreach( $parent['sub_fields'] as $child )
|
753 |
-
{
|
754 |
-
if( $child['name'] == $child_name || $child['key'] == $child_name )
|
755 |
-
{
|
756 |
-
$return = $child;
|
757 |
-
break;
|
758 |
-
}
|
759 |
-
|
760 |
-
// perhaps child has grand children?
|
761 |
-
$grand_child = acf_get_child_field_from_parent_field( $child_name, $child );
|
762 |
-
if( $grand_child )
|
763 |
-
{
|
764 |
-
$return = $grand_child;
|
765 |
-
break;
|
766 |
-
}
|
767 |
-
}
|
768 |
-
}
|
769 |
-
elseif( isset($parent['layouts']) && is_array($parent['layouts']) )
|
770 |
-
{
|
771 |
-
foreach( $parent['layouts'] as $layout )
|
772 |
-
{
|
773 |
-
$child = acf_get_child_field_from_parent_field( $child_name, $layout );
|
774 |
-
if( $child )
|
775 |
-
{
|
776 |
-
$return = $child;
|
777 |
-
break;
|
778 |
-
}
|
779 |
-
}
|
780 |
-
}
|
781 |
-
|
782 |
-
|
783 |
-
// return
|
784 |
-
return $return;
|
785 |
-
|
786 |
-
}
|
787 |
-
|
788 |
-
|
789 |
-
/*
|
790 |
-
* register_field_group()
|
791 |
-
*
|
792 |
-
* This function is used to register a field group via code. It acceps 1 array containing
|
793 |
-
* all the field group data. This data can be obtained by using
|
794 |
-
*
|
795 |
-
* @type function
|
796 |
-
* @since 3.0.6
|
797 |
-
* @date 29/01/13
|
798 |
-
*
|
799 |
-
* @param array $array: an array holding all the field group data
|
800 |
-
*
|
801 |
-
* @return
|
802 |
-
*/
|
803 |
-
|
804 |
-
$GLOBALS['acf_register_field_group'] = array();
|
805 |
-
|
806 |
-
function register_field_group( $array )
|
807 |
-
{
|
808 |
-
// add id
|
809 |
-
if( !isset($array['id']) )
|
810 |
-
{
|
811 |
-
$array['id'] = uniqid();
|
812 |
-
}
|
813 |
-
|
814 |
-
|
815 |
-
// 3.2.5 - changed show_on_page option
|
816 |
-
if( !isset($array['options']['hide_on_screen']) && isset($array['options']['show_on_page']) )
|
817 |
-
{
|
818 |
-
$show_all = array('the_content', 'discussion', 'custom_fields', 'comments', 'slug', 'author');
|
819 |
-
$array['options']['hide_on_screen'] = array_diff($show_all, $array['options']['show_on_page']);
|
820 |
-
unset( $array['options']['show_on_page'] );
|
821 |
-
}
|
822 |
-
|
823 |
-
|
824 |
-
// 4.0.4 - changed location rules architecture
|
825 |
-
if( isset($array['location']['rules']) )
|
826 |
-
{
|
827 |
-
// vars
|
828 |
-
$groups = array();
|
829 |
-
$group_no = 0;
|
830 |
-
|
831 |
-
|
832 |
-
if( is_array($array['location']['rules']) )
|
833 |
-
{
|
834 |
-
foreach( $array['location']['rules'] as $rule )
|
835 |
-
{
|
836 |
-
$rule['group_no'] = $group_no;
|
837 |
-
|
838 |
-
// sperate groups?
|
839 |
-
if( $array['location']['allorany'] == 'any' )
|
840 |
-
{
|
841 |
-
$group_no++;
|
842 |
-
}
|
843 |
-
|
844 |
-
|
845 |
-
// add to group
|
846 |
-
$groups[ $rule['group_no'] ][ $rule['order_no'] ] = $rule;
|
847 |
-
|
848 |
-
|
849 |
-
// sort rules
|
850 |
-
ksort( $groups[ $rule['group_no'] ] );
|
851 |
-
|
852 |
-
}
|
853 |
-
|
854 |
-
// sort groups
|
855 |
-
ksort( $groups );
|
856 |
-
}
|
857 |
-
|
858 |
-
$array['location'] = $groups;
|
859 |
-
}
|
860 |
-
|
861 |
-
|
862 |
-
$GLOBALS['acf_register_field_group'][] = $array;
|
863 |
-
}
|
864 |
-
|
865 |
-
|
866 |
-
add_filter('acf/get_field_groups', 'api_acf_get_field_groups', 2, 1);
|
867 |
-
function api_acf_get_field_groups( $return )
|
868 |
-
{
|
869 |
-
// validate
|
870 |
-
if( empty($GLOBALS['acf_register_field_group']) )
|
871 |
-
{
|
872 |
-
return $return;
|
873 |
-
}
|
874 |
-
|
875 |
-
|
876 |
-
foreach( $GLOBALS['acf_register_field_group'] as $acf )
|
877 |
-
{
|
878 |
-
$return[] = array(
|
879 |
-
'id' => $acf['id'],
|
880 |
-
'title' => $acf['title'],
|
881 |
-
'menu_order' => $acf['menu_order'],
|
882 |
-
);
|
883 |
-
}
|
884 |
-
|
885 |
-
|
886 |
-
// order field groups based on menu_order, title
|
887 |
-
// Obtain a list of columns
|
888 |
-
foreach( $return as $key => $row )
|
889 |
-
{
|
890 |
-
$menu_order[ $key ] = $row['menu_order'];
|
891 |
-
$title[ $key ] = $row['title'];
|
892 |
-
}
|
893 |
-
|
894 |
-
// Sort the array with menu_order ascending
|
895 |
-
// Add $array as the last parameter, to sort by the common key
|
896 |
-
if(isset($menu_order))
|
897 |
-
{
|
898 |
-
array_multisort($menu_order, SORT_ASC, $title, SORT_ASC, $return);
|
899 |
-
}
|
900 |
-
|
901 |
-
return $return;
|
902 |
-
}
|
903 |
-
|
904 |
-
|
905 |
-
add_filter('acf/field_group/get_fields', 'api_acf_field_group_get_fields', 1, 2);
|
906 |
-
function api_acf_field_group_get_fields( $fields, $post_id )
|
907 |
-
{
|
908 |
-
// validate
|
909 |
-
if( !empty($GLOBALS['acf_register_field_group']) )
|
910 |
-
{
|
911 |
-
foreach( $GLOBALS['acf_register_field_group'] as $acf )
|
912 |
-
{
|
913 |
-
if( $acf['id'] == $post_id )
|
914 |
-
{
|
915 |
-
foreach( $acf['fields'] as $f )
|
916 |
-
{
|
917 |
-
$fields[] = apply_filters('acf/load_field', $f, $f['key']);
|
918 |
-
}
|
919 |
-
|
920 |
-
break;
|
921 |
-
}
|
922 |
-
}
|
923 |
-
}
|
924 |
-
|
925 |
-
return $fields;
|
926 |
-
|
927 |
-
}
|
928 |
-
|
929 |
-
|
930 |
-
add_filter('acf/load_field', 'api_acf_load_field', 1, 2);
|
931 |
-
function api_acf_load_field( $field, $field_key )
|
932 |
-
{
|
933 |
-
// validate
|
934 |
-
if( !empty($GLOBALS['acf_register_field_group']) )
|
935 |
-
{
|
936 |
-
foreach( $GLOBALS['acf_register_field_group'] as $acf )
|
937 |
-
{
|
938 |
-
if( !empty($acf['fields']) )
|
939 |
-
{
|
940 |
-
foreach( $acf['fields'] as $f )
|
941 |
-
{
|
942 |
-
if( $f['key'] == $field_key )
|
943 |
-
{
|
944 |
-
$field = $f;
|
945 |
-
break;
|
946 |
-
}
|
947 |
-
}
|
948 |
-
}
|
949 |
-
}
|
950 |
-
}
|
951 |
-
|
952 |
-
return $field;
|
953 |
-
}
|
954 |
-
|
955 |
-
|
956 |
-
add_filter('acf/field_group/get_location', 'api_acf_field_group_get_location', 1, 2);
|
957 |
-
function api_acf_field_group_get_location( $location, $post_id )
|
958 |
-
{
|
959 |
-
// validate
|
960 |
-
if( !empty($GLOBALS['acf_register_field_group']) )
|
961 |
-
{
|
962 |
-
foreach( $GLOBALS['acf_register_field_group'] as $acf )
|
963 |
-
{
|
964 |
-
if( $acf['id'] == $post_id )
|
965 |
-
{
|
966 |
-
$location = $acf['location'];
|
967 |
-
break;
|
968 |
-
}
|
969 |
-
}
|
970 |
-
}
|
971 |
-
|
972 |
-
return $location;
|
973 |
-
}
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
add_filter('acf/field_group/get_options', 'api_acf_field_group_get_options', 1, 2);
|
978 |
-
function api_acf_field_group_get_options( $options, $post_id )
|
979 |
-
{
|
980 |
-
// validate
|
981 |
-
if( !empty($GLOBALS['acf_register_field_group']) )
|
982 |
-
{
|
983 |
-
foreach( $GLOBALS['acf_register_field_group'] as $acf )
|
984 |
-
{
|
985 |
-
if( $acf['id'] == $post_id )
|
986 |
-
{
|
987 |
-
$options = $acf['options'];
|
988 |
-
break;
|
989 |
-
}
|
990 |
-
}
|
991 |
-
}
|
992 |
-
|
993 |
-
return $options;
|
994 |
-
}
|
995 |
-
|
996 |
-
|
997 |
-
/*
|
998 |
-
* get_row_layout()
|
999 |
-
*
|
1000 |
-
* This function will return a string representation of the current row layout within a 'has_sub_field' loop
|
1001 |
-
*
|
1002 |
-
* @type function
|
1003 |
-
* @since 3.0.6
|
1004 |
-
* @date 29/01/13
|
1005 |
-
*
|
1006 |
-
* @return $value - string containing the layout
|
1007 |
-
*/
|
1008 |
-
|
1009 |
-
function get_row_layout()
|
1010 |
-
{
|
1011 |
-
// vars
|
1012 |
-
$value = get_sub_field('acf_fc_layout');
|
1013 |
-
|
1014 |
-
|
1015 |
-
return $value;
|
1016 |
-
}
|
1017 |
-
|
1018 |
-
|
1019 |
-
/*
|
1020 |
-
* acf_shortcode()
|
1021 |
-
*
|
1022 |
-
* This function is used to add basic shortcode support for the ACF plugin
|
1023 |
-
*
|
1024 |
-
* @type function
|
1025 |
-
* @since 1.1.1
|
1026 |
-
* @date 29/01/13
|
1027 |
-
*
|
1028 |
-
* @param array $atts: an array holding the shortcode options
|
1029 |
-
* string + field: the field name
|
1030 |
-
* mixed + post_id: the post_id to load from
|
1031 |
-
*
|
1032 |
-
* @return string $value: the value found by get_field
|
1033 |
-
*/
|
1034 |
-
|
1035 |
-
function acf_shortcode( $atts )
|
1036 |
-
{
|
1037 |
-
// extract attributs
|
1038 |
-
extract( shortcode_atts( array(
|
1039 |
-
'field' => "",
|
1040 |
-
'post_id' => false,
|
1041 |
-
), $atts ) );
|
1042 |
-
|
1043 |
-
|
1044 |
-
// $field is requird
|
1045 |
-
if( !$field || $field == "" )
|
1046 |
-
{
|
1047 |
-
return "";
|
1048 |
-
}
|
1049 |
-
|
1050 |
-
|
1051 |
-
// get value and return it
|
1052 |
-
$value = get_field( $field, $post_id );
|
1053 |
-
|
1054 |
-
|
1055 |
-
if( is_array($value) )
|
1056 |
-
{
|
1057 |
-
$value = @implode( ', ',$value );
|
1058 |
-
}
|
1059 |
-
|
1060 |
-
return $value;
|
1061 |
-
}
|
1062 |
-
add_shortcode( 'acf', 'acf_shortcode' );
|
1063 |
-
|
1064 |
-
|
1065 |
-
/*
|
1066 |
-
* acf_form_head()
|
1067 |
-
*
|
1068 |
-
* This function is placed at the very top of a template (before any HTML is rendered) and saves the $_POST data sent by acf_form.
|
1069 |
-
*
|
1070 |
-
* @type function
|
1071 |
-
* @since 1.1.4
|
1072 |
-
* @date 29/01/13
|
1073 |
-
*
|
1074 |
-
* @param N/A
|
1075 |
-
*
|
1076 |
-
* @return N/A
|
1077 |
-
*/
|
1078 |
-
|
1079 |
-
function acf_form_head()
|
1080 |
-
{
|
1081 |
-
// global vars
|
1082 |
-
global $post_id;
|
1083 |
-
|
1084 |
-
|
1085 |
-
// verify nonce
|
1086 |
-
if( isset($_POST['acf_nonce']) && wp_verify_nonce($_POST['acf_nonce'], 'input') )
|
1087 |
-
{
|
1088 |
-
// $post_id to save against
|
1089 |
-
$post_id = $_POST['post_id'];
|
1090 |
-
|
1091 |
-
|
1092 |
-
// allow for custom save
|
1093 |
-
$post_id = apply_filters('acf/pre_save_post', $post_id);
|
1094 |
-
|
1095 |
-
|
1096 |
-
// save the data
|
1097 |
-
do_action('acf/save_post', $post_id);
|
1098 |
-
|
1099 |
-
|
1100 |
-
// redirect
|
1101 |
-
if(isset($_POST['return']))
|
1102 |
-
{
|
1103 |
-
wp_redirect($_POST['return']);
|
1104 |
-
exit;
|
1105 |
-
}
|
1106 |
-
}
|
1107 |
-
|
1108 |
-
|
1109 |
-
// need wp styling
|
1110 |
-
wp_enqueue_style(array(
|
1111 |
-
'colors-fresh'
|
1112 |
-
));
|
1113 |
-
|
1114 |
-
|
1115 |
-
// actions
|
1116 |
-
do_action('acf/input/admin_enqueue_scripts');
|
1117 |
-
|
1118 |
-
add_action('wp_head', 'acf_form_wp_head');
|
1119 |
-
|
1120 |
-
}
|
1121 |
-
|
1122 |
-
function acf_form_wp_head()
|
1123 |
-
{
|
1124 |
-
do_action('acf/input/admin_head');
|
1125 |
-
}
|
1126 |
-
|
1127 |
-
|
1128 |
-
/*
|
1129 |
-
* acf_form()
|
1130 |
-
*
|
1131 |
-
* This function is used to create an ACF form.
|
1132 |
-
*
|
1133 |
-
* @type function
|
1134 |
-
* @since 1.1.4
|
1135 |
-
* @date 29/01/13
|
1136 |
-
*
|
1137 |
-
* @param array $options: an array containing many options to customize the form
|
1138 |
-
* string + post_id: post id to get field groups from and save data to. Default is false
|
1139 |
-
* array + field_groups: an array containing field group ID's. If this option is set,
|
1140 |
-
* the post_id will not be used to dynamically find the field groups
|
1141 |
-
* boolean + form: display the form tag or not. Defaults to true
|
1142 |
-
* array + form_attributes: an array containg attributes which will be added into the form tag
|
1143 |
-
* string + return: the return URL
|
1144 |
-
* string + html_before_fields: html inside form before fields
|
1145 |
-
* string + html_after_fields: html inside form after fields
|
1146 |
-
* string + submit_value: value of submit button
|
1147 |
-
* string + updated_message: default updated message. Can be false
|
1148 |
-
*
|
1149 |
-
* @return N/A
|
1150 |
-
*/
|
1151 |
-
|
1152 |
-
function acf_form( $options = array() )
|
1153 |
-
{
|
1154 |
-
global $post;
|
1155 |
-
|
1156 |
-
|
1157 |
-
// defaults
|
1158 |
-
$defaults = array(
|
1159 |
-
'post_id' => false,
|
1160 |
-
'field_groups' => array(),
|
1161 |
-
'form' => true,
|
1162 |
-
'form_attributes' => array(
|
1163 |
-
'id' => 'post',
|
1164 |
-
'class' => '',
|
1165 |
-
'action' => '',
|
1166 |
-
'method' => 'post',
|
1167 |
-
),
|
1168 |
-
'return' => add_query_arg( 'updated', 'true', get_permalink() ),
|
1169 |
-
'html_before_fields' => '',
|
1170 |
-
'html_after_fields' => '',
|
1171 |
-
'submit_value' => __("Update", 'acf'),
|
1172 |
-
'updated_message' => __("Post updated", 'acf'),
|
1173 |
-
);
|
1174 |
-
|
1175 |
-
|
1176 |
-
// merge defaults with options
|
1177 |
-
$options = array_merge($defaults, $options);
|
1178 |
-
|
1179 |
-
|
1180 |
-
// merge sub arrays
|
1181 |
-
foreach( $options as $k => $v )
|
1182 |
-
{
|
1183 |
-
if( is_array($v) )
|
1184 |
-
{
|
1185 |
-
$options[ $k ] = array_merge($defaults[ $k ], $options[ $k ]);
|
1186 |
-
}
|
1187 |
-
}
|
1188 |
-
|
1189 |
-
|
1190 |
-
// filter post_id
|
1191 |
-
$options['post_id'] = apply_filters('acf/get_post_id', $options['post_id'] );
|
1192 |
-
|
1193 |
-
|
1194 |
-
// attributes
|
1195 |
-
$options['form_attributes']['class'] .= 'acf-form';
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
// register post box
|
1200 |
-
if( empty($options['field_groups']) )
|
1201 |
-
{
|
1202 |
-
// get field groups
|
1203 |
-
$filter = array(
|
1204 |
-
'post_id' => $options['post_id']
|
1205 |
-
);
|
1206 |
-
|
1207 |
-
|
1208 |
-
if( strpos($options['post_id'], 'user_') !== false )
|
1209 |
-
{
|
1210 |
-
$user_id = str_replace('user_', '', $options['post_id']);
|
1211 |
-
$filter = array(
|
1212 |
-
'ef_user' => $user_id
|
1213 |
-
);
|
1214 |
-
}
|
1215 |
-
elseif( strpos($options['post_id'], 'taxonomy_') !== false )
|
1216 |
-
{
|
1217 |
-
$taxonomy_id = str_replace('taxonomy_', '', $options['post_id']);
|
1218 |
-
$filter = array(
|
1219 |
-
'ef_taxonomy' => $taxonomy_id
|
1220 |
-
);
|
1221 |
-
}
|
1222 |
-
|
1223 |
-
|
1224 |
-
$options['field_groups'] = array();
|
1225 |
-
$options['field_groups'] = apply_filters( 'acf/location/match_field_groups', $options['field_groups'], $filter );
|
1226 |
-
}
|
1227 |
-
|
1228 |
-
|
1229 |
-
// updated message
|
1230 |
-
if(isset($_GET['updated']) && $_GET['updated'] == 'true' && $options['updated_message'])
|
1231 |
-
{
|
1232 |
-
echo '<div id="message" class="updated"><p>' . $options['updated_message'] . '</p></div>';
|
1233 |
-
}
|
1234 |
-
|
1235 |
-
|
1236 |
-
// display form
|
1237 |
-
if( $options['form'] ): ?>
|
1238 |
-
<form <?php if($options['form_attributes']){foreach($options['form_attributes'] as $k => $v){echo $k . '="' . $v .'" '; }} ?>>
|
1239 |
-
<?php endif; ?>
|
1240 |
-
|
1241 |
-
<div style="display:none">
|
1242 |
-
<script type="text/javascript">
|
1243 |
-
acf.o.post_id = <?php echo is_numeric($options['post_id']) ? $options['post_id'] : '"' . $options['post_id'] . '"'; ?>;
|
1244 |
-
</script>
|
1245 |
-
<input type="hidden" name="acf_nonce" value="<?php echo wp_create_nonce( 'input' ); ?>" />
|
1246 |
-
<input type="hidden" name="post_id" value="<?php echo $options['post_id']; ?>" />
|
1247 |
-
<input type="hidden" name="return" value="<?php echo $options['return']; ?>" />
|
1248 |
-
<?php wp_editor('', 'acf_settings'); ?>
|
1249 |
-
</div>
|
1250 |
-
|
1251 |
-
<div id="poststuff">
|
1252 |
-
<?php
|
1253 |
-
|
1254 |
-
// html before fields
|
1255 |
-
echo $options['html_before_fields'];
|
1256 |
-
|
1257 |
-
|
1258 |
-
$acfs = apply_filters('acf/get_field_groups', array());
|
1259 |
-
|
1260 |
-
if( is_array($acfs) ){ foreach( $acfs as $acf ){
|
1261 |
-
|
1262 |
-
// only add the chosen field groups
|
1263 |
-
if( !in_array( $acf['id'], $options['field_groups'] ) )
|
1264 |
-
{
|
1265 |
-
continue;
|
1266 |
-
}
|
1267 |
-
|
1268 |
-
|
1269 |
-
// load options
|
1270 |
-
$acf['options'] = apply_filters('acf/field_group/get_options', array(), $acf['id']);
|
1271 |
-
|
1272 |
-
|
1273 |
-
// load fields
|
1274 |
-
$fields = apply_filters('acf/field_group/get_fields', array(), $acf['id']);
|
1275 |
-
|
1276 |
-
|
1277 |
-
echo '<div id="acf_' . $acf['id'] . '" class="postbox acf_postbox ' . $acf['options']['layout'] . '">';
|
1278 |
-
echo '<h3 class="hndle"><span>' . $acf['title'] . '</span></h3>';
|
1279 |
-
echo '<div class="inside">';
|
1280 |
-
|
1281 |
-
do_action('acf/create_fields', $fields, $options['post_id']);
|
1282 |
-
|
1283 |
-
echo '</div></div>';
|
1284 |
-
|
1285 |
-
}}
|
1286 |
-
|
1287 |
-
|
1288 |
-
// html after fields
|
1289 |
-
echo $options['html_after_fields'];
|
1290 |
-
|
1291 |
-
?>
|
1292 |
-
|
1293 |
-
<?php if( $options['form'] ): ?>
|
1294 |
-
<!-- Submit -->
|
1295 |
-
<div class="field">
|
1296 |
-
<input type="submit" value="<?php echo $options['submit_value']; ?>" />
|
1297 |
-
</div>
|
1298 |
-
<!-- / Submit -->
|
1299 |
-
<?php endif; ?>
|
1300 |
-
|
1301 |
-
</div><!-- <div id="poststuff"> -->
|
1302 |
-
|
1303 |
-
<?php if( $options['form'] ): ?>
|
1304 |
-
</form>
|
1305 |
-
<?php endif;
|
1306 |
-
}
|
1307 |
-
|
1308 |
-
|
1309 |
-
/*
|
1310 |
-
* update_field()
|
1311 |
-
*
|
1312 |
-
* This function will update a value in the database
|
1313 |
-
*
|
1314 |
-
* @type function
|
1315 |
-
* @since 3.1.9
|
1316 |
-
* @date 29/01/13
|
1317 |
-
*
|
1318 |
-
* @param mixed $field_name: the name of the field - 'sub_heading'
|
1319 |
-
* @param mixed $value: the value to save in the database. The variable type is dependant on the field type
|
1320 |
-
* @param mixed $post_id: the post_id of which the value is saved against
|
1321 |
-
*
|
1322 |
-
* @return N/A
|
1323 |
-
*/
|
1324 |
-
|
1325 |
-
function update_field( $field_key, $value, $post_id = false )
|
1326 |
-
{
|
1327 |
-
// filter post_id
|
1328 |
-
$post_id = apply_filters('acf/get_post_id', $post_id );
|
1329 |
-
|
1330 |
-
|
1331 |
-
// vars
|
1332 |
-
$options = array(
|
1333 |
-
'load_value' => false,
|
1334 |
-
'format_value' => false
|
1335 |
-
);
|
1336 |
-
|
1337 |
-
$field = get_field_object( $field_key, $post_id, $options);
|
1338 |
-
|
1339 |
-
|
1340 |
-
// sub fields? They need formatted data
|
1341 |
-
if( $field['type'] == 'repeater' )
|
1342 |
-
{
|
1343 |
-
$value = acf_convert_field_names_to_keys( $value, $field );
|
1344 |
-
}
|
1345 |
-
elseif( $field['type'] == 'flexible_content' )
|
1346 |
-
{
|
1347 |
-
if( $field['layouts'] )
|
1348 |
-
{
|
1349 |
-
foreach( $field['layouts'] as $layout )
|
1350 |
-
{
|
1351 |
-
$value = acf_convert_field_names_to_keys( $value, $layout );
|
1352 |
-
}
|
1353 |
-
}
|
1354 |
-
}
|
1355 |
-
|
1356 |
-
|
1357 |
-
// save
|
1358 |
-
do_action('acf/update_value', $value, $post_id, $field );
|
1359 |
-
|
1360 |
-
|
1361 |
-
return true;
|
1362 |
-
|
1363 |
-
}
|
1364 |
-
|
1365 |
-
|
1366 |
-
/*
|
1367 |
-
* delete_field()
|
1368 |
-
*
|
1369 |
-
* This function will remove a value from the database
|
1370 |
-
*
|
1371 |
-
* @type function
|
1372 |
-
* @since 3.1.9
|
1373 |
-
* @date 29/01/13
|
1374 |
-
*
|
1375 |
-
* @param mixed $field_name: the name of the field - 'sub_heading'
|
1376 |
-
* @param mixed $post_id: the post_id of which the value is saved against
|
1377 |
-
*
|
1378 |
-
* @return N/A
|
1379 |
-
*/
|
1380 |
-
|
1381 |
-
function delete_field( $field_name, $post_id )
|
1382 |
-
{
|
1383 |
-
do_action('acf/delete_value', $post_id, $field_name );
|
1384 |
-
}
|
1385 |
-
|
1386 |
-
|
1387 |
-
/*
|
1388 |
-
* create_field()
|
1389 |
-
*
|
1390 |
-
* This function will creat the HTML for a field
|
1391 |
-
*
|
1392 |
-
* @type function
|
1393 |
-
* @since 4.0.0
|
1394 |
-
* @date 17/03/13
|
1395 |
-
*
|
1396 |
-
* @param array $field - an array containing all the field attributes
|
1397 |
-
*
|
1398 |
-
* @return N/A
|
1399 |
-
*/
|
1400 |
-
|
1401 |
-
function create_field( $field )
|
1402 |
-
{
|
1403 |
-
do_action('acf/create_field', $field );
|
1404 |
-
}
|
1405 |
-
|
1406 |
-
|
1407 |
-
/*
|
1408 |
-
* acf_convert_field_names_to_keys()
|
1409 |
-
*
|
1410 |
-
* Helper for the update_field function
|
1411 |
-
*
|
1412 |
-
* @type function
|
1413 |
-
* @since 4.0.0
|
1414 |
-
* @date 17/03/13
|
1415 |
-
*
|
1416 |
-
* @param array $value: the value returned via get_field
|
1417 |
-
* @param array $field: the field or layout to find sub fields from
|
1418 |
-
*
|
1419 |
-
* @return N/A
|
1420 |
-
*/
|
1421 |
-
|
1422 |
-
function acf_convert_field_names_to_keys( $value, $field )
|
1423 |
-
{
|
1424 |
-
// only if $field has sub fields
|
1425 |
-
if( !isset($field['sub_fields']) )
|
1426 |
-
{
|
1427 |
-
return $value;
|
1428 |
-
}
|
1429 |
-
|
1430 |
-
|
1431 |
-
// define sub field keys
|
1432 |
-
$sub_fields = array();
|
1433 |
-
if( $field['sub_fields'] )
|
1434 |
-
{
|
1435 |
-
foreach( $field['sub_fields'] as $sub_field )
|
1436 |
-
{
|
1437 |
-
$sub_fields[ $sub_field['name'] ] = $sub_field;
|
1438 |
-
}
|
1439 |
-
}
|
1440 |
-
|
1441 |
-
|
1442 |
-
// loop through the values and format the array to use sub field keys
|
1443 |
-
if( is_array($value) )
|
1444 |
-
{
|
1445 |
-
foreach( $value as $row_i => $row)
|
1446 |
-
{
|
1447 |
-
if( $row )
|
1448 |
-
{
|
1449 |
-
foreach( $row as $sub_field_name => $sub_field_value )
|
1450 |
-
{
|
1451 |
-
// sub field must exist!
|
1452 |
-
if( !isset($sub_fields[ $sub_field_name ]) )
|
1453 |
-
{
|
1454 |
-
continue;
|
1455 |
-
}
|
1456 |
-
|
1457 |
-
|
1458 |
-
// vars
|
1459 |
-
$sub_field = $sub_fields[ $sub_field_name ];
|
1460 |
-
$sub_field_value = acf_convert_field_names_to_keys( $sub_field_value, $sub_field );
|
1461 |
-
|
1462 |
-
|
1463 |
-
// set new value
|
1464 |
-
$value[$row_i][ $sub_field['key'] ] = $sub_field_value;
|
1465 |
-
|
1466 |
-
|
1467 |
-
// unset old value
|
1468 |
-
unset( $value[$row_i][$sub_field_name] );
|
1469 |
-
|
1470 |
-
|
1471 |
-
}
|
1472 |
-
// foreach( $row as $sub_field_name => $sub_field_value )
|
1473 |
-
}
|
1474 |
-
// if( $row )
|
1475 |
-
}
|
1476 |
-
// foreach( $value as $row_i => $row)
|
1477 |
-
}
|
1478 |
-
// if( $value )
|
1479 |
-
|
1480 |
-
|
1481 |
-
return $value;
|
1482 |
-
|
1483 |
-
}
|
1484 |
-
|
1485 |
-
|
1486 |
-
/*
|
1487 |
-
* acf_force_type_array
|
1488 |
-
*
|
1489 |
-
* This function will force a variable to become an array
|
1490 |
-
*
|
1491 |
-
* @type function
|
1492 |
-
* @date 4/02/2014
|
1493 |
-
* @since 5.0.0
|
1494 |
-
*
|
1495 |
-
* @param $var (mixed)
|
1496 |
-
* @return (array)
|
1497 |
-
*/
|
1498 |
-
|
1499 |
-
function acf_force_type_array( $var ) {
|
1500 |
-
|
1501 |
-
// is array?
|
1502 |
-
if( is_array($var) ) {
|
1503 |
-
|
1504 |
-
return $var;
|
1505 |
-
|
1506 |
-
}
|
1507 |
-
|
1508 |
-
|
1509 |
-
// bail early if empty
|
1510 |
-
if( empty($var) && !is_numeric($var) ) {
|
1511 |
-
|
1512 |
-
return array();
|
1513 |
-
|
1514 |
-
}
|
1515 |
-
|
1516 |
-
|
1517 |
-
// string
|
1518 |
-
if( is_string($var) ) {
|
1519 |
-
|
1520 |
-
return explode(',', $var);
|
1521 |
-
|
1522 |
-
}
|
1523 |
-
|
1524 |
-
|
1525 |
-
// place in array
|
1526 |
-
return array( $var );
|
1527 |
-
}
|
1528 |
-
|
1529 |
-
|
1530 |
-
/*
|
1531 |
-
* acf_get_valid_terms
|
1532 |
-
*
|
1533 |
-
* This function will replace old terms with new split term ids
|
1534 |
-
*
|
1535 |
-
* @type function
|
1536 |
-
* @date 27/02/2015
|
1537 |
-
* @since 5.1.5
|
1538 |
-
*
|
1539 |
-
* @param $terms (int|array)
|
1540 |
-
* @param $taxonomy (string)
|
1541 |
-
* @return $terms
|
1542 |
-
*/
|
1543 |
-
|
1544 |
-
function acf_get_valid_terms( $terms = false, $taxonomy = 'category' ) {
|
1545 |
-
|
1546 |
-
// bail early if function does not yet exist or
|
1547 |
-
if( !function_exists('wp_get_split_term') || empty($terms) ) {
|
1548 |
-
|
1549 |
-
return $terms;
|
1550 |
-
|
1551 |
-
}
|
1552 |
-
|
1553 |
-
|
1554 |
-
// vars
|
1555 |
-
$is_array = is_array($terms);
|
1556 |
-
|
1557 |
-
|
1558 |
-
// force into array
|
1559 |
-
$terms = acf_force_type_array( $terms );
|
1560 |
-
|
1561 |
-
|
1562 |
-
// force ints
|
1563 |
-
$terms = array_map('intval', $terms);
|
1564 |
-
|
1565 |
-
|
1566 |
-
// attempt to find new terms
|
1567 |
-
foreach( $terms as $i => $term_id ) {
|
1568 |
-
|
1569 |
-
$new_term_id = wp_get_split_term($term_id, $taxonomy);
|
1570 |
-
|
1571 |
-
if( $new_term_id ) {
|
1572 |
-
|
1573 |
-
$terms[ $i ] = $new_term_id;
|
1574 |
-
|
1575 |
-
}
|
1576 |
-
|
1577 |
-
}
|
1578 |
-
|
1579 |
-
|
1580 |
-
// revert array if needed
|
1581 |
-
if( !$is_array ) {
|
1582 |
-
|
1583 |
-
$terms = $terms[0];
|
1584 |
-
|
1585 |
-
}
|
1586 |
-
|
1587 |
-
|
1588 |
-
// return
|
1589 |
-
return $terms;
|
1590 |
-
|
1591 |
-
}
|
1592 |
-
|
1593 |
-
|
1594 |
-
/*
|
1595 |
-
* Depreceated Functions
|
1596 |
-
*
|
1597 |
-
* @description:
|
1598 |
-
* @created: 23/07/12
|
1599 |
-
*/
|
1600 |
-
|
1601 |
-
|
1602 |
-
/*--------------------------------------------------------------------------------------
|
1603 |
-
*
|
1604 |
-
* reset_the_repeater_field
|
1605 |
-
*
|
1606 |
-
* @author Elliot Condon
|
1607 |
-
* @depreciated: 3.3.4 - now use has_sub_field
|
1608 |
-
* @since 1.0.3
|
1609 |
-
*
|
1610 |
-
*-------------------------------------------------------------------------------------*/
|
1611 |
-
|
1612 |
-
function reset_the_repeater_field()
|
1613 |
-
{
|
1614 |
-
// do nothing
|
1615 |
-
}
|
1616 |
-
|
1617 |
-
|
1618 |
-
/*--------------------------------------------------------------------------------------
|
1619 |
-
*
|
1620 |
-
* the_repeater_field
|
1621 |
-
*
|
1622 |
-
* @author Elliot Condon
|
1623 |
-
* @depreciated: 3.3.4 - now use has_sub_field
|
1624 |
-
* @since 1.0.3
|
1625 |
-
*
|
1626 |
-
*-------------------------------------------------------------------------------------*/
|
1627 |
-
|
1628 |
-
function the_repeater_field($field_name, $post_id = false)
|
1629 |
-
{
|
1630 |
-
return has_sub_field($field_name, $post_id);
|
1631 |
-
}
|
1632 |
-
|
1633 |
-
|
1634 |
-
/*--------------------------------------------------------------------------------------
|
1635 |
-
*
|
1636 |
-
* the_flexible_field
|
1637 |
-
*
|
1638 |
-
* @author Elliot Condon
|
1639 |
-
* @depreciated: 3.3.4 - now use has_sub_field
|
1640 |
-
* @since 3.?.?
|
1641 |
-
*
|
1642 |
-
*-------------------------------------------------------------------------------------*/
|
1643 |
-
|
1644 |
-
function the_flexible_field($field_name, $post_id = false)
|
1645 |
-
{
|
1646 |
-
return has_sub_field($field_name, $post_id);
|
1647 |
-
}
|
1648 |
-
|
1649 |
-
/*
|
1650 |
-
* acf_filter_post_id()
|
1651 |
-
*
|
1652 |
-
* This is a deprecated function which is now run through a filter
|
1653 |
-
*
|
1654 |
-
* @type function
|
1655 |
-
* @since 3.6
|
1656 |
-
* @date 29/01/13
|
1657 |
-
*
|
1658 |
-
* @param mixed $post_id
|
1659 |
-
*
|
1660 |
-
* @return mixed $post_id
|
1661 |
-
*/
|
1662 |
-
|
1663 |
-
function acf_filter_post_id( $post_id )
|
1664 |
-
{
|
1665 |
-
return apply_filters('acf/get_post_id', $post_id );
|
1666 |
-
}
|
1667 |
-
|
1668 |
-
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* get_field_reference()
|
5 |
+
*
|
6 |
+
* This function will find the $field_key that is related to the $field_name.
|
7 |
+
* This is know as the field value reference
|
8 |
+
*
|
9 |
+
* @type function
|
10 |
+
* @since 3.6
|
11 |
+
* @date 29/01/13
|
12 |
+
*
|
13 |
+
* @param mixed $field_name: the name of the field - 'sub_heading'
|
14 |
+
* @param int $post_id: the post_id of which the value is saved against
|
15 |
+
*
|
16 |
+
* @return string $return: a string containing the field_key
|
17 |
+
*/
|
18 |
+
|
19 |
+
function get_field_reference( $field_name, $post_id ) {
|
20 |
+
|
21 |
+
// cache
|
22 |
+
$found = false;
|
23 |
+
$cache = wp_cache_get( 'field_reference/post_id=' . $post_id . '/name=' . $field_name, 'acf', false, $found );
|
24 |
+
|
25 |
+
if( $found )
|
26 |
+
{
|
27 |
+
return $cache;
|
28 |
+
}
|
29 |
+
|
30 |
+
|
31 |
+
// vars
|
32 |
+
$return = '';
|
33 |
+
|
34 |
+
|
35 |
+
// get field key
|
36 |
+
if( is_numeric($post_id) )
|
37 |
+
{
|
38 |
+
$return = get_post_meta($post_id, '_' . $field_name, true);
|
39 |
+
}
|
40 |
+
elseif( strpos($post_id, 'user_') !== false )
|
41 |
+
{
|
42 |
+
$temp_post_id = str_replace('user_', '', $post_id);
|
43 |
+
$return = get_user_meta($temp_post_id, '_' . $field_name, true);
|
44 |
+
}
|
45 |
+
else
|
46 |
+
{
|
47 |
+
$return = get_option('_' . $post_id . '_' . $field_name);
|
48 |
+
}
|
49 |
+
|
50 |
+
|
51 |
+
// set cache
|
52 |
+
wp_cache_set( 'field_reference/post_id=' . $post_id . '/name=' . $field_name, $return, 'acf' );
|
53 |
+
|
54 |
+
|
55 |
+
// return
|
56 |
+
return $return;
|
57 |
+
}
|
58 |
+
|
59 |
+
|
60 |
+
/*
|
61 |
+
* get_field_objects()
|
62 |
+
*
|
63 |
+
* This function will return an array containing all the custom field objects for a specific post_id.
|
64 |
+
* The function is not very elegant and wastes a lot of PHP memory / SQL queries if you are not using all the fields / values.
|
65 |
+
*
|
66 |
+
* @type function
|
67 |
+
* @since 3.6
|
68 |
+
* @date 29/01/13
|
69 |
+
*
|
70 |
+
* @param mixed $post_id: the post_id of which the value is saved against
|
71 |
+
*
|
72 |
+
* @return array $return: an array containin the field groups
|
73 |
+
*/
|
74 |
+
|
75 |
+
function get_field_objects( $post_id = false, $options = array() ) {
|
76 |
+
|
77 |
+
// global
|
78 |
+
global $wpdb;
|
79 |
+
|
80 |
+
|
81 |
+
// filter post_id
|
82 |
+
$post_id = apply_filters('acf/get_post_id', $post_id );
|
83 |
+
|
84 |
+
|
85 |
+
// vars
|
86 |
+
$field_key = '';
|
87 |
+
$value = array();
|
88 |
+
|
89 |
+
|
90 |
+
// get field_names
|
91 |
+
if( is_numeric($post_id) )
|
92 |
+
{
|
93 |
+
$keys = $wpdb->get_col($wpdb->prepare(
|
94 |
+
"SELECT meta_value FROM $wpdb->postmeta WHERE post_id = %d and meta_key LIKE %s AND meta_value LIKE %s",
|
95 |
+
$post_id,
|
96 |
+
'_%',
|
97 |
+
'field_%'
|
98 |
+
));
|
99 |
+
}
|
100 |
+
elseif( strpos($post_id, 'user_') !== false )
|
101 |
+
{
|
102 |
+
$user_id = str_replace('user_', '', $post_id);
|
103 |
+
|
104 |
+
$keys = $wpdb->get_col($wpdb->prepare(
|
105 |
+
"SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d and meta_key LIKE %s AND meta_value LIKE %s",
|
106 |
+
$user_id,
|
107 |
+
'_%',
|
108 |
+
'field_%'
|
109 |
+
));
|
110 |
+
}
|
111 |
+
else
|
112 |
+
{
|
113 |
+
$keys = $wpdb->get_col($wpdb->prepare(
|
114 |
+
"SELECT option_value FROM $wpdb->options WHERE option_name LIKE %s",
|
115 |
+
'_' . $post_id . '_%'
|
116 |
+
));
|
117 |
+
}
|
118 |
+
|
119 |
+
|
120 |
+
if( is_array($keys) )
|
121 |
+
{
|
122 |
+
foreach( $keys as $key )
|
123 |
+
{
|
124 |
+
$field = get_field_object( $key, $post_id, $options );
|
125 |
+
|
126 |
+
if( !is_array($field) )
|
127 |
+
{
|
128 |
+
continue;
|
129 |
+
}
|
130 |
+
|
131 |
+
$value[ $field['name'] ] = $field;
|
132 |
+
}
|
133 |
+
}
|
134 |
+
|
135 |
+
|
136 |
+
// no value
|
137 |
+
if( empty($value) )
|
138 |
+
{
|
139 |
+
return false;
|
140 |
+
}
|
141 |
+
|
142 |
+
|
143 |
+
// return
|
144 |
+
return $value;
|
145 |
+
}
|
146 |
+
|
147 |
+
|
148 |
+
/*
|
149 |
+
* get_fields()
|
150 |
+
*
|
151 |
+
* This function will return an array containing all the custom field values for a specific post_id.
|
152 |
+
* The function is not very elegant and wastes a lot of PHP memory / SQL queries if you are not using all the values.
|
153 |
+
*
|
154 |
+
* @type function
|
155 |
+
* @since 3.6
|
156 |
+
* @date 29/01/13
|
157 |
+
*
|
158 |
+
* @param mixed $post_id: the post_id of which the value is saved against
|
159 |
+
*
|
160 |
+
* @return array $return: an array containin the field values
|
161 |
+
*/
|
162 |
+
|
163 |
+
function get_fields( $post_id = false, $format_value = true ) {
|
164 |
+
|
165 |
+
// vars
|
166 |
+
$options = array(
|
167 |
+
'load_value' => true,
|
168 |
+
'format_value' => $format_value
|
169 |
+
);
|
170 |
+
|
171 |
+
|
172 |
+
$fields = get_field_objects( $post_id, $options );
|
173 |
+
|
174 |
+
if( is_array($fields) )
|
175 |
+
{
|
176 |
+
foreach( $fields as $k => $field )
|
177 |
+
{
|
178 |
+
$fields[ $k ] = $field['value'];
|
179 |
+
}
|
180 |
+
}
|
181 |
+
|
182 |
+
return $fields;
|
183 |
+
}
|
184 |
+
|
185 |
+
|
186 |
+
/*
|
187 |
+
* get_field()
|
188 |
+
*
|
189 |
+
* This function will return a custom field value for a specific field name/key + post_id.
|
190 |
+
* There is a 3rd parameter to turn on/off formating. This means that an Image field will not use
|
191 |
+
* its 'return option' to format the value but return only what was saved in the database
|
192 |
+
*
|
193 |
+
* @type function
|
194 |
+
* @since 3.6
|
195 |
+
* @date 29/01/13
|
196 |
+
*
|
197 |
+
* @param string $field_key: string containing the name of the field name / key ('sub_field' / 'field_1')
|
198 |
+
* @param mixed $post_id: the post_id of which the value is saved against
|
199 |
+
* @param boolean $format_value: whether or not to format the value as described above
|
200 |
+
*
|
201 |
+
* @return mixed $value: the value found
|
202 |
+
*/
|
203 |
+
|
204 |
+
function get_field( $field_key, $post_id = false, $format_value = true ) {
|
205 |
+
|
206 |
+
// vars
|
207 |
+
$return = false;
|
208 |
+
$options = array(
|
209 |
+
'load_value' => true,
|
210 |
+
'format_value' => $format_value
|
211 |
+
);
|
212 |
+
|
213 |
+
|
214 |
+
$field = get_field_object( $field_key, $post_id, $options);
|
215 |
+
|
216 |
+
|
217 |
+
if( is_array($field) )
|
218 |
+
{
|
219 |
+
$return = $field['value'];
|
220 |
+
}
|
221 |
+
|
222 |
+
|
223 |
+
return $return;
|
224 |
+
|
225 |
+
}
|
226 |
+
|
227 |
+
|
228 |
+
/*
|
229 |
+
* get_field_object()
|
230 |
+
*
|
231 |
+
* This function will return an array containing all the field data for a given field_name
|
232 |
+
*
|
233 |
+
* @type function
|
234 |
+
* @since 3.6
|
235 |
+
* @date 3/02/13
|
236 |
+
*
|
237 |
+
* @param string $field_key: string containing the name of the field name / key ('sub_field' / 'field_1')
|
238 |
+
* @param mixed $post_id: the post_id of which the value is saved against
|
239 |
+
* @param array $options: an array containing options
|
240 |
+
* boolean + load_value: load the field value or not. Defaults to true
|
241 |
+
* boolean + format_value: format the field value or not. Defaults to true
|
242 |
+
*
|
243 |
+
* @return array $return: an array containin the field groups
|
244 |
+
*/
|
245 |
+
|
246 |
+
function get_field_object( $field_key, $post_id = false, $options = array() ) {
|
247 |
+
|
248 |
+
// make sure add-ons are included
|
249 |
+
acf()->include_3rd_party();
|
250 |
+
|
251 |
+
|
252 |
+
// filter post_id
|
253 |
+
$post_id = apply_filters('acf/get_post_id', $post_id );
|
254 |
+
$field = false;
|
255 |
+
$orig_field_key = $field_key;
|
256 |
+
|
257 |
+
|
258 |
+
// defaults for options
|
259 |
+
$defaults = array(
|
260 |
+
'load_value' => true,
|
261 |
+
'format_value' => true,
|
262 |
+
);
|
263 |
+
|
264 |
+
$options = array_merge($defaults, $options);
|
265 |
+
|
266 |
+
|
267 |
+
// is $field_name a name? pre 3.4.0
|
268 |
+
if( substr($field_key, 0, 6) !== 'field_' )
|
269 |
+
{
|
270 |
+
// get field key
|
271 |
+
$field_key = get_field_reference( $field_key, $post_id );
|
272 |
+
}
|
273 |
+
|
274 |
+
|
275 |
+
// get field
|
276 |
+
if( substr($field_key, 0, 6) === 'field_' )
|
277 |
+
{
|
278 |
+
$field = apply_filters('acf/load_field', false, $field_key );
|
279 |
+
}
|
280 |
+
|
281 |
+
|
282 |
+
// validate field
|
283 |
+
if( !$field )
|
284 |
+
{
|
285 |
+
// treat as text field
|
286 |
+
$field = array(
|
287 |
+
'type' => 'text',
|
288 |
+
'name' => $orig_field_key,
|
289 |
+
'key' => 'field_' . $orig_field_key,
|
290 |
+
);
|
291 |
+
$field = apply_filters('acf/load_field', $field, $field['key'] );
|
292 |
+
}
|
293 |
+
|
294 |
+
|
295 |
+
// load value
|
296 |
+
if( $options['load_value'] )
|
297 |
+
{
|
298 |
+
$field['value'] = apply_filters('acf/load_value', false, $post_id, $field);
|
299 |
+
|
300 |
+
|
301 |
+
// format value
|
302 |
+
if( $options['format_value'] )
|
303 |
+
{
|
304 |
+
$field['value'] = apply_filters('acf/format_value_for_api', $field['value'], $post_id, $field);
|
305 |
+
}
|
306 |
+
}
|
307 |
+
|
308 |
+
|
309 |
+
return $field;
|
310 |
+
|
311 |
+
}
|
312 |
+
|
313 |
+
|
314 |
+
/*
|
315 |
+
* the_field()
|
316 |
+
*
|
317 |
+
* This function is the same as echo get_field().
|
318 |
+
*
|
319 |
+
* @type function
|
320 |
+
* @since 1.0.3
|
321 |
+
* @date 29/01/13
|
322 |
+
*
|
323 |
+
* @param string $field_name: the name of the field - 'sub_heading'
|
324 |
+
* @param mixed $post_id: the post_id of which the value is saved against
|
325 |
+
*
|
326 |
+
* @return string $value
|
327 |
+
*/
|
328 |
+
|
329 |
+
function the_field( $field_name, $post_id = false ) {
|
330 |
+
|
331 |
+
$value = get_field($field_name, $post_id);
|
332 |
+
|
333 |
+
if( is_array($value) )
|
334 |
+
{
|
335 |
+
$value = @implode(', ',$value);
|
336 |
+
}
|
337 |
+
|
338 |
+
echo $value;
|
339 |
+
}
|
340 |
+
|
341 |
+
|
342 |
+
/*
|
343 |
+
* have_rows
|
344 |
+
*
|
345 |
+
* This function will instantiate a global variable containing the rows of a repeater or flexible content field,
|
346 |
+
* afterwhich, it will determine if another row exists to loop through
|
347 |
+
*
|
348 |
+
* @type function
|
349 |
+
* @date 2/09/13
|
350 |
+
* @since 4.3.0
|
351 |
+
*
|
352 |
+
* @param $field_name (string) the name of the field - 'images'
|
353 |
+
* @return $post_id (mixed) the post_id of which the value is saved against
|
354 |
+
*/
|
355 |
+
|
356 |
+
function have_rows( $field_name, $post_id = false ) {
|
357 |
+
|
358 |
+
// vars
|
359 |
+
$depth = 0;
|
360 |
+
$row = array();
|
361 |
+
$new_parent_loop = false;
|
362 |
+
$new_child_loop = false;
|
363 |
+
|
364 |
+
|
365 |
+
// reference
|
366 |
+
$_post_id = $post_id;
|
367 |
+
|
368 |
+
|
369 |
+
// filter post_id
|
370 |
+
$post_id = apply_filters('acf/get_post_id', $post_id );
|
371 |
+
|
372 |
+
|
373 |
+
// empty?
|
374 |
+
if( empty($GLOBALS['acf_field']) )
|
375 |
+
{
|
376 |
+
// reset
|
377 |
+
reset_rows( true );
|
378 |
+
|
379 |
+
|
380 |
+
// create a new loop
|
381 |
+
$new_parent_loop = true;
|
382 |
+
}
|
383 |
+
else
|
384 |
+
{
|
385 |
+
// vars
|
386 |
+
$row = end( $GLOBALS['acf_field'] );
|
387 |
+
$prev = prev( $GLOBALS['acf_field'] );
|
388 |
+
|
389 |
+
|
390 |
+
// If post_id has changed, this is most likely an archive loop
|
391 |
+
if( $post_id != $row['post_id'] )
|
392 |
+
{
|
393 |
+
if( $prev && $prev['post_id'] == $post_id )
|
394 |
+
{
|
395 |
+
// case: Change in $post_id was due to a nested loop ending
|
396 |
+
// action: move up one level through the loops
|
397 |
+
reset_rows();
|
398 |
+
}
|
399 |
+
elseif( empty($_post_id) && isset($row['value'][ $row['i'] ][ $field_name ]) )
|
400 |
+
{
|
401 |
+
// case: Change in $post_id was due to this being a nested loop and not specifying the $post_id
|
402 |
+
// action: move down one level into a new loop
|
403 |
+
$new_child_loop = true;
|
404 |
+
}
|
405 |
+
else
|
406 |
+
{
|
407 |
+
// case: Chang in $post_id is the most obvious, used in an WP_Query loop with multiple $post objects
|
408 |
+
// action: leave this current loop alone and create a new parent loop
|
409 |
+
$new_parent_loop = true;
|
410 |
+
}
|
411 |
+
}
|
412 |
+
elseif( $field_name != $row['name'] )
|
413 |
+
{
|
414 |
+
if( $prev && $prev['name'] == $field_name && $prev['post_id'] == $post_id )
|
415 |
+
{
|
416 |
+
// case: Change in $field_name was due to a nested loop ending
|
417 |
+
// action: move up one level through the loops
|
418 |
+
reset_rows();
|
419 |
+
}
|
420 |
+
elseif( isset($row['value'][ $row['i'] ][ $field_name ]) )
|
421 |
+
{
|
422 |
+
// case: Change in $field_name was due to this being a nested loop
|
423 |
+
// action: move down one level into a new loop
|
424 |
+
$new_child_loop = true;
|
425 |
+
|
426 |
+
}
|
427 |
+
else
|
428 |
+
{
|
429 |
+
// case: Chang in $field_name is the most obvious, this is a new loop for a different field within the $post
|
430 |
+
// action: leave this current loop alone and create a new parent loop
|
431 |
+
$new_parent_loop = true;
|
432 |
+
}
|
433 |
+
|
434 |
+
|
435 |
+
}
|
436 |
+
}
|
437 |
+
|
438 |
+
|
439 |
+
if( $new_parent_loop )
|
440 |
+
{
|
441 |
+
// vars
|
442 |
+
$f = get_field_object( $field_name, $post_id );
|
443 |
+
$v = $f['value'];
|
444 |
+
unset( $f['value'] );
|
445 |
+
|
446 |
+
|
447 |
+
// add row
|
448 |
+
$GLOBALS['acf_field'][] = array(
|
449 |
+
'name' => $field_name,
|
450 |
+
'value' => $v,
|
451 |
+
'field' => $f,
|
452 |
+
'i' => -1,
|
453 |
+
'post_id' => $post_id,
|
454 |
+
);
|
455 |
+
|
456 |
+
}
|
457 |
+
elseif( $new_child_loop )
|
458 |
+
{
|
459 |
+
// vars
|
460 |
+
$f = acf_get_child_field_from_parent_field( $field_name, $row['field'] );
|
461 |
+
$v = $row['value'][ $row['i'] ][ $field_name ];
|
462 |
+
|
463 |
+
$GLOBALS['acf_field'][] = array(
|
464 |
+
'name' => $field_name,
|
465 |
+
'value' => $v,
|
466 |
+
'field' => $f,
|
467 |
+
'i' => -1,
|
468 |
+
'post_id' => $post_id,
|
469 |
+
);
|
470 |
+
|
471 |
+
}
|
472 |
+
|
473 |
+
|
474 |
+
// update vars
|
475 |
+
$row = end( $GLOBALS['acf_field'] );
|
476 |
+
|
477 |
+
|
478 |
+
if( is_array($row['value']) && array_key_exists( $row['i']+1, $row['value'] ) )
|
479 |
+
{
|
480 |
+
// next row exists
|
481 |
+
return true;
|
482 |
+
}
|
483 |
+
|
484 |
+
|
485 |
+
// no next row!
|
486 |
+
reset_rows();
|
487 |
+
|
488 |
+
|
489 |
+
// return
|
490 |
+
return false;
|
491 |
+
|
492 |
+
}
|
493 |
+
|
494 |
+
|
495 |
+
/*
|
496 |
+
* the_row
|
497 |
+
*
|
498 |
+
* This function will progress the global repeater or flexible content value 1 row
|
499 |
+
*
|
500 |
+
* @type function
|
501 |
+
* @date 2/09/13
|
502 |
+
* @since 4.3.0
|
503 |
+
*
|
504 |
+
* @param N/A
|
505 |
+
* @return N/A
|
506 |
+
*/
|
507 |
+
|
508 |
+
function the_row() {
|
509 |
+
|
510 |
+
// vars
|
511 |
+
$depth = count( $GLOBALS['acf_field'] ) - 1;
|
512 |
+
|
513 |
+
|
514 |
+
|
515 |
+
// increase row
|
516 |
+
$GLOBALS['acf_field'][ $depth ]['i']++;
|
517 |
+
|
518 |
+
|
519 |
+
// get row
|
520 |
+
$value = $GLOBALS['acf_field'][ $depth ]['value'];
|
521 |
+
$i = $GLOBALS['acf_field'][ $depth ]['i'];
|
522 |
+
|
523 |
+
|
524 |
+
// return
|
525 |
+
return $value[ $i ];
|
526 |
+
}
|
527 |
+
|
528 |
+
|
529 |
+
/*
|
530 |
+
* reset_rows
|
531 |
+
*
|
532 |
+
* This function will find the current loop and unset it from the global array.
|
533 |
+
* To bo used when loop finishes or a break is used
|
534 |
+
*
|
535 |
+
* @type function
|
536 |
+
* @date 26/10/13
|
537 |
+
* @since 5.0.0
|
538 |
+
*
|
539 |
+
* @param $post_id (int)
|
540 |
+
* @return $post_id (int)
|
541 |
+
*/
|
542 |
+
|
543 |
+
function reset_rows( $hard_reset = false ) {
|
544 |
+
|
545 |
+
// completely destroy?
|
546 |
+
if( $hard_reset )
|
547 |
+
{
|
548 |
+
$GLOBALS['acf_field'] = array();
|
549 |
+
}
|
550 |
+
else
|
551 |
+
{
|
552 |
+
// vars
|
553 |
+
$depth = count( $GLOBALS['acf_field'] ) - 1;
|
554 |
+
|
555 |
+
|
556 |
+
// remove
|
557 |
+
unset( $GLOBALS['acf_field'][$depth] );
|
558 |
+
|
559 |
+
|
560 |
+
// refresh index
|
561 |
+
$GLOBALS['acf_field'] = array_values($GLOBALS['acf_field']);
|
562 |
+
}
|
563 |
+
|
564 |
+
|
565 |
+
// return
|
566 |
+
return true;
|
567 |
+
|
568 |
+
|
569 |
+
}
|
570 |
+
|
571 |
+
|
572 |
+
/*
|
573 |
+
* has_sub_field()
|
574 |
+
*
|
575 |
+
* This function is used inside a while loop to return either true or false (loop again or stop).
|
576 |
+
* When using a repeater or flexible content field, it will loop through the rows until
|
577 |
+
* there are none left or a break is detected
|
578 |
+
*
|
579 |
+
* @type function
|
580 |
+
* @since 1.0.3
|
581 |
+
* @date 29/01/13
|
582 |
+
*
|
583 |
+
* @param string $field_name: the name of the field - 'sub_heading'
|
584 |
+
* @param mixed $post_id: the post_id of which the value is saved against
|
585 |
+
*
|
586 |
+
* @return bool
|
587 |
+
*/
|
588 |
+
|
589 |
+
function has_sub_field( $field_name, $post_id = false ) {
|
590 |
+
|
591 |
+
// vars
|
592 |
+
$r = have_rows( $field_name, $post_id );
|
593 |
+
|
594 |
+
|
595 |
+
// if has rows, progress through 1 row for the while loop to work
|
596 |
+
if( $r )
|
597 |
+
{
|
598 |
+
the_row();
|
599 |
+
}
|
600 |
+
|
601 |
+
|
602 |
+
// return
|
603 |
+
return $r;
|
604 |
+
}
|
605 |
+
|
606 |
+
|
607 |
+
/*
|
608 |
+
* has_sub_fields()
|
609 |
+
*
|
610 |
+
* This function is a replica of 'has_sub_field'
|
611 |
+
*
|
612 |
+
* @type function
|
613 |
+
* @since 4.0.0
|
614 |
+
* @date 29/01/13
|
615 |
+
*
|
616 |
+
* @param string $field_name: the name of the field - 'sub_heading'
|
617 |
+
* @param mixed $post_id: the post_id of which the value is saved against
|
618 |
+
*
|
619 |
+
* @return bool
|
620 |
+
*/
|
621 |
+
|
622 |
+
function has_sub_fields( $field_name, $post_id = false )
|
623 |
+
{
|
624 |
+
return has_sub_field( $field_name, $post_id );
|
625 |
+
}
|
626 |
+
|
627 |
+
|
628 |
+
/*
|
629 |
+
* get_sub_field()
|
630 |
+
*
|
631 |
+
* This function is used inside a 'has_sub_field' while loop to return a sub field value
|
632 |
+
*
|
633 |
+
* @type function
|
634 |
+
* @since 1.0.3
|
635 |
+
* @date 29/01/13
|
636 |
+
*
|
637 |
+
* @param string $field_name: the name of the field - 'sub_heading'
|
638 |
+
*
|
639 |
+
* @return mixed $value
|
640 |
+
*/
|
641 |
+
|
642 |
+
function get_sub_field( $field_name ) {
|
643 |
+
|
644 |
+
// no field?
|
645 |
+
if( empty($GLOBALS['acf_field']) )
|
646 |
+
{
|
647 |
+
return false;
|
648 |
+
}
|
649 |
+
|
650 |
+
|
651 |
+
// vars
|
652 |
+
$row = end( $GLOBALS['acf_field'] );
|
653 |
+
|
654 |
+
|
655 |
+
// return value
|
656 |
+
if( isset($row['value'][ $row['i'] ][ $field_name ]) )
|
657 |
+
{
|
658 |
+
return $row['value'][ $row['i'] ][ $field_name ];
|
659 |
+
}
|
660 |
+
|
661 |
+
|
662 |
+
// return false
|
663 |
+
return false;
|
664 |
+
}
|
665 |
+
|
666 |
+
|
667 |
+
/*
|
668 |
+
* get_sub_field()
|
669 |
+
*
|
670 |
+
* This function is the same as echo get_sub_field
|
671 |
+
*
|
672 |
+
* @type function
|
673 |
+
* @since 1.0.3
|
674 |
+
* @date 29/01/13
|
675 |
+
*
|
676 |
+
* @param string $field_name: the name of the field - 'sub_heading'
|
677 |
+
*
|
678 |
+
* @return string $value
|
679 |
+
*/
|
680 |
+
|
681 |
+
function the_sub_field($field_name)
|
682 |
+
{
|
683 |
+
$value = get_sub_field($field_name);
|
684 |
+
|
685 |
+
if(is_array($value))
|
686 |
+
{
|
687 |
+
$value = implode(', ',$value);
|
688 |
+
}
|
689 |
+
|
690 |
+
echo $value;
|
691 |
+
}
|
692 |
+
|
693 |
+
|
694 |
+
/*
|
695 |
+
* get_sub_field_object()
|
696 |
+
*
|
697 |
+
* This function is used inside a 'has_sub_field' while loop to return a sub field object
|
698 |
+
*
|
699 |
+
* @type function
|
700 |
+
* @since 3.5.8.1
|
701 |
+
* @date 29/01/13
|
702 |
+
*
|
703 |
+
* @param string $field_name: the name of the field - 'sub_heading'
|
704 |
+
*
|
705 |
+
* @return array $sub_field
|
706 |
+
*/
|
707 |
+
|
708 |
+
function get_sub_field_object( $child_name )
|
709 |
+
{
|
710 |
+
// no field?
|
711 |
+
if( empty($GLOBALS['acf_field']) )
|
712 |
+
{
|
713 |
+
return false;
|
714 |
+
}
|
715 |
+
|
716 |
+
|
717 |
+
// vars
|
718 |
+
$depth = count( $GLOBALS['acf_field'] ) - 1;
|
719 |
+
$parent = $GLOBALS['acf_field'][$depth]['field'];
|
720 |
+
|
721 |
+
|
722 |
+
// return
|
723 |
+
return acf_get_child_field_from_parent_field( $child_name, $parent );
|
724 |
+
|
725 |
+
}
|
726 |
+
|
727 |
+
|
728 |
+
/*
|
729 |
+
* acf_get_sub_field_from_parent_field()
|
730 |
+
*
|
731 |
+
* This function is used by the get_sub_field_object to find a sub field within a parent field
|
732 |
+
*
|
733 |
+
* @type function
|
734 |
+
* @since 3.5.8.1
|
735 |
+
* @date 29/01/13
|
736 |
+
*
|
737 |
+
* @param string $child_name: the name of the field - 'sub_heading'
|
738 |
+
* @param array $parent: the parent field object
|
739 |
+
*
|
740 |
+
* @return array $sub_field
|
741 |
+
*/
|
742 |
+
|
743 |
+
function acf_get_child_field_from_parent_field( $child_name, $parent )
|
744 |
+
{
|
745 |
+
// vars
|
746 |
+
$return = false;
|
747 |
+
|
748 |
+
|
749 |
+
// find child
|
750 |
+
if( isset($parent['sub_fields']) && is_array($parent['sub_fields']) )
|
751 |
+
{
|
752 |
+
foreach( $parent['sub_fields'] as $child )
|
753 |
+
{
|
754 |
+
if( $child['name'] == $child_name || $child['key'] == $child_name )
|
755 |
+
{
|
756 |
+
$return = $child;
|
757 |
+
break;
|
758 |
+
}
|
759 |
+
|
760 |
+
// perhaps child has grand children?
|
761 |
+
$grand_child = acf_get_child_field_from_parent_field( $child_name, $child );
|
762 |
+
if( $grand_child )
|
763 |
+
{
|
764 |
+
$return = $grand_child;
|
765 |
+
break;
|
766 |
+
}
|
767 |
+
}
|
768 |
+
}
|
769 |
+
elseif( isset($parent['layouts']) && is_array($parent['layouts']) )
|
770 |
+
{
|
771 |
+
foreach( $parent['layouts'] as $layout )
|
772 |
+
{
|
773 |
+
$child = acf_get_child_field_from_parent_field( $child_name, $layout );
|
774 |
+
if( $child )
|
775 |
+
{
|
776 |
+
$return = $child;
|
777 |
+
break;
|
778 |
+
}
|
779 |
+
}
|
780 |
+
}
|
781 |
+
|
782 |
+
|
783 |
+
// return
|
784 |
+
return $return;
|
785 |
+
|
786 |
+
}
|
787 |
+
|
788 |
+
|
789 |
+
/*
|
790 |
+
* register_field_group()
|
791 |
+
*
|
792 |
+
* This function is used to register a field group via code. It acceps 1 array containing
|
793 |
+
* all the field group data. This data can be obtained by using the export tool within ACF
|
794 |
+
*
|
795 |
+
* @type function
|
796 |
+
* @since 3.0.6
|
797 |
+
* @date 29/01/13
|
798 |
+
*
|
799 |
+
* @param array $array: an array holding all the field group data
|
800 |
+
*
|
801 |
+
* @return
|
802 |
+
*/
|
803 |
+
|
804 |
+
$GLOBALS['acf_register_field_group'] = array();
|
805 |
+
|
806 |
+
function register_field_group( $array )
|
807 |
+
{
|
808 |
+
// add id
|
809 |
+
if( !isset($array['id']) )
|
810 |
+
{
|
811 |
+
$array['id'] = uniqid();
|
812 |
+
}
|
813 |
+
|
814 |
+
|
815 |
+
// 3.2.5 - changed show_on_page option
|
816 |
+
if( !isset($array['options']['hide_on_screen']) && isset($array['options']['show_on_page']) )
|
817 |
+
{
|
818 |
+
$show_all = array('the_content', 'discussion', 'custom_fields', 'comments', 'slug', 'author');
|
819 |
+
$array['options']['hide_on_screen'] = array_diff($show_all, $array['options']['show_on_page']);
|
820 |
+
unset( $array['options']['show_on_page'] );
|
821 |
+
}
|
822 |
+
|
823 |
+
|
824 |
+
// 4.0.4 - changed location rules architecture
|
825 |
+
if( isset($array['location']['rules']) )
|
826 |
+
{
|
827 |
+
// vars
|
828 |
+
$groups = array();
|
829 |
+
$group_no = 0;
|
830 |
+
|
831 |
+
|
832 |
+
if( is_array($array['location']['rules']) )
|
833 |
+
{
|
834 |
+
foreach( $array['location']['rules'] as $rule )
|
835 |
+
{
|
836 |
+
$rule['group_no'] = $group_no;
|
837 |
+
|
838 |
+
// sperate groups?
|
839 |
+
if( $array['location']['allorany'] == 'any' )
|
840 |
+
{
|
841 |
+
$group_no++;
|
842 |
+
}
|
843 |
+
|
844 |
+
|
845 |
+
// add to group
|
846 |
+
$groups[ $rule['group_no'] ][ $rule['order_no'] ] = $rule;
|
847 |
+
|
848 |
+
|
849 |
+
// sort rules
|
850 |
+
ksort( $groups[ $rule['group_no'] ] );
|
851 |
+
|
852 |
+
}
|
853 |
+
|
854 |
+
// sort groups
|
855 |
+
ksort( $groups );
|
856 |
+
}
|
857 |
+
|
858 |
+
$array['location'] = $groups;
|
859 |
+
}
|
860 |
+
|
861 |
+
|
862 |
+
$GLOBALS['acf_register_field_group'][] = $array;
|
863 |
+
}
|
864 |
+
|
865 |
+
|
866 |
+
add_filter('acf/get_field_groups', 'api_acf_get_field_groups', 2, 1);
|
867 |
+
function api_acf_get_field_groups( $return )
|
868 |
+
{
|
869 |
+
// validate
|
870 |
+
if( empty($GLOBALS['acf_register_field_group']) )
|
871 |
+
{
|
872 |
+
return $return;
|
873 |
+
}
|
874 |
+
|
875 |
+
|
876 |
+
foreach( $GLOBALS['acf_register_field_group'] as $acf )
|
877 |
+
{
|
878 |
+
$return[] = array(
|
879 |
+
'id' => $acf['id'],
|
880 |
+
'title' => $acf['title'],
|
881 |
+
'menu_order' => $acf['menu_order'],
|
882 |
+
);
|
883 |
+
}
|
884 |
+
|
885 |
+
|
886 |
+
// order field groups based on menu_order, title
|
887 |
+
// Obtain a list of columns
|
888 |
+
foreach( $return as $key => $row )
|
889 |
+
{
|
890 |
+
$menu_order[ $key ] = $row['menu_order'];
|
891 |
+
$title[ $key ] = $row['title'];
|
892 |
+
}
|
893 |
+
|
894 |
+
// Sort the array with menu_order ascending
|
895 |
+
// Add $array as the last parameter, to sort by the common key
|
896 |
+
if(isset($menu_order))
|
897 |
+
{
|
898 |
+
array_multisort($menu_order, SORT_ASC, $title, SORT_ASC, $return);
|
899 |
+
}
|
900 |
+
|
901 |
+
return $return;
|
902 |
+
}
|
903 |
+
|
904 |
+
|
905 |
+
add_filter('acf/field_group/get_fields', 'api_acf_field_group_get_fields', 1, 2);
|
906 |
+
function api_acf_field_group_get_fields( $fields, $post_id )
|
907 |
+
{
|
908 |
+
// validate
|
909 |
+
if( !empty($GLOBALS['acf_register_field_group']) )
|
910 |
+
{
|
911 |
+
foreach( $GLOBALS['acf_register_field_group'] as $acf )
|
912 |
+
{
|
913 |
+
if( $acf['id'] == $post_id )
|
914 |
+
{
|
915 |
+
foreach( $acf['fields'] as $f )
|
916 |
+
{
|
917 |
+
$fields[] = apply_filters('acf/load_field', $f, $f['key']);
|
918 |
+
}
|
919 |
+
|
920 |
+
break;
|
921 |
+
}
|
922 |
+
}
|
923 |
+
}
|
924 |
+
|
925 |
+
return $fields;
|
926 |
+
|
927 |
+
}
|
928 |
+
|
929 |
+
|
930 |
+
add_filter('acf/load_field', 'api_acf_load_field', 1, 2);
|
931 |
+
function api_acf_load_field( $field, $field_key )
|
932 |
+
{
|
933 |
+
// validate
|
934 |
+
if( !empty($GLOBALS['acf_register_field_group']) )
|
935 |
+
{
|
936 |
+
foreach( $GLOBALS['acf_register_field_group'] as $acf )
|
937 |
+
{
|
938 |
+
if( !empty($acf['fields']) )
|
939 |
+
{
|
940 |
+
foreach( $acf['fields'] as $f )
|
941 |
+
{
|
942 |
+
if( $f['key'] == $field_key )
|
943 |
+
{
|
944 |
+
$field = $f;
|
945 |
+
break;
|
946 |
+
}
|
947 |
+
}
|
948 |
+
}
|
949 |
+
}
|
950 |
+
}
|
951 |
+
|
952 |
+
return $field;
|
953 |
+
}
|
954 |
+
|
955 |
+
|
956 |
+
add_filter('acf/field_group/get_location', 'api_acf_field_group_get_location', 1, 2);
|
957 |
+
function api_acf_field_group_get_location( $location, $post_id )
|
958 |
+
{
|
959 |
+
// validate
|
960 |
+
if( !empty($GLOBALS['acf_register_field_group']) )
|
961 |
+
{
|
962 |
+
foreach( $GLOBALS['acf_register_field_group'] as $acf )
|
963 |
+
{
|
964 |
+
if( $acf['id'] == $post_id )
|
965 |
+
{
|
966 |
+
$location = $acf['location'];
|
967 |
+
break;
|
968 |
+
}
|
969 |
+
}
|
970 |
+
}
|
971 |
+
|
972 |
+
return $location;
|
973 |
+
}
|
974 |
+
|
975 |
+
|
976 |
+
|
977 |
+
add_filter('acf/field_group/get_options', 'api_acf_field_group_get_options', 1, 2);
|
978 |
+
function api_acf_field_group_get_options( $options, $post_id )
|
979 |
+
{
|
980 |
+
// validate
|
981 |
+
if( !empty($GLOBALS['acf_register_field_group']) )
|
982 |
+
{
|
983 |
+
foreach( $GLOBALS['acf_register_field_group'] as $acf )
|
984 |
+
{
|
985 |
+
if( $acf['id'] == $post_id )
|
986 |
+
{
|
987 |
+
$options = $acf['options'];
|
988 |
+
break;
|
989 |
+
}
|
990 |
+
}
|
991 |
+
}
|
992 |
+
|
993 |
+
return $options;
|
994 |
+
}
|
995 |
+
|
996 |
+
|
997 |
+
/*
|
998 |
+
* get_row_layout()
|
999 |
+
*
|
1000 |
+
* This function will return a string representation of the current row layout within a 'has_sub_field' loop
|
1001 |
+
*
|
1002 |
+
* @type function
|
1003 |
+
* @since 3.0.6
|
1004 |
+
* @date 29/01/13
|
1005 |
+
*
|
1006 |
+
* @return $value - string containing the layout
|
1007 |
+
*/
|
1008 |
+
|
1009 |
+
function get_row_layout()
|
1010 |
+
{
|
1011 |
+
// vars
|
1012 |
+
$value = get_sub_field('acf_fc_layout');
|
1013 |
+
|
1014 |
+
|
1015 |
+
return $value;
|
1016 |
+
}
|
1017 |
+
|
1018 |
+
|
1019 |
+
/*
|
1020 |
+
* acf_shortcode()
|
1021 |
+
*
|
1022 |
+
* This function is used to add basic shortcode support for the ACF plugin
|
1023 |
+
*
|
1024 |
+
* @type function
|
1025 |
+
* @since 1.1.1
|
1026 |
+
* @date 29/01/13
|
1027 |
+
*
|
1028 |
+
* @param array $atts: an array holding the shortcode options
|
1029 |
+
* string + field: the field name
|
1030 |
+
* mixed + post_id: the post_id to load from
|
1031 |
+
*
|
1032 |
+
* @return string $value: the value found by get_field
|
1033 |
+
*/
|
1034 |
+
|
1035 |
+
function acf_shortcode( $atts )
|
1036 |
+
{
|
1037 |
+
// extract attributs
|
1038 |
+
extract( shortcode_atts( array(
|
1039 |
+
'field' => "",
|
1040 |
+
'post_id' => false,
|
1041 |
+
), $atts ) );
|
1042 |
+
|
1043 |
+
|
1044 |
+
// $field is requird
|
1045 |
+
if( !$field || $field == "" )
|
1046 |
+
{
|
1047 |
+
return "";
|
1048 |
+
}
|
1049 |
+
|
1050 |
+
|
1051 |
+
// get value and return it
|
1052 |
+
$value = get_field( $field, $post_id );
|
1053 |
+
|
1054 |
+
|
1055 |
+
if( is_array($value) )
|
1056 |
+
{
|
1057 |
+
$value = @implode( ', ',$value );
|
1058 |
+
}
|
1059 |
+
|
1060 |
+
return $value;
|
1061 |
+
}
|
1062 |
+
add_shortcode( 'acf', 'acf_shortcode' );
|
1063 |
+
|
1064 |
+
|
1065 |
+
/*
|
1066 |
+
* acf_form_head()
|
1067 |
+
*
|
1068 |
+
* This function is placed at the very top of a template (before any HTML is rendered) and saves the $_POST data sent by acf_form.
|
1069 |
+
*
|
1070 |
+
* @type function
|
1071 |
+
* @since 1.1.4
|
1072 |
+
* @date 29/01/13
|
1073 |
+
*
|
1074 |
+
* @param N/A
|
1075 |
+
*
|
1076 |
+
* @return N/A
|
1077 |
+
*/
|
1078 |
+
|
1079 |
+
function acf_form_head()
|
1080 |
+
{
|
1081 |
+
// global vars
|
1082 |
+
global $post_id;
|
1083 |
+
|
1084 |
+
|
1085 |
+
// verify nonce
|
1086 |
+
if( isset($_POST['acf_nonce']) && wp_verify_nonce($_POST['acf_nonce'], 'input') )
|
1087 |
+
{
|
1088 |
+
// $post_id to save against
|
1089 |
+
$post_id = $_POST['post_id'];
|
1090 |
+
|
1091 |
+
|
1092 |
+
// allow for custom save
|
1093 |
+
$post_id = apply_filters('acf/pre_save_post', $post_id);
|
1094 |
+
|
1095 |
+
|
1096 |
+
// save the data
|
1097 |
+
do_action('acf/save_post', $post_id);
|
1098 |
+
|
1099 |
+
|
1100 |
+
// redirect
|
1101 |
+
if(isset($_POST['return']))
|
1102 |
+
{
|
1103 |
+
wp_redirect($_POST['return']);
|
1104 |
+
exit;
|
1105 |
+
}
|
1106 |
+
}
|
1107 |
+
|
1108 |
+
|
1109 |
+
// need wp styling
|
1110 |
+
wp_enqueue_style(array(
|
1111 |
+
'colors-fresh'
|
1112 |
+
));
|
1113 |
+
|
1114 |
+
|
1115 |
+
// actions
|
1116 |
+
do_action('acf/input/admin_enqueue_scripts');
|
1117 |
+
|
1118 |
+
add_action('wp_head', 'acf_form_wp_head');
|
1119 |
+
|
1120 |
+
}
|
1121 |
+
|
1122 |
+
function acf_form_wp_head()
|
1123 |
+
{
|
1124 |
+
do_action('acf/input/admin_head');
|
1125 |
+
}
|
1126 |
+
|
1127 |
+
|
1128 |
+
/*
|
1129 |
+
* acf_form()
|
1130 |
+
*
|
1131 |
+
* This function is used to create an ACF form.
|
1132 |
+
*
|
1133 |
+
* @type function
|
1134 |
+
* @since 1.1.4
|
1135 |
+
* @date 29/01/13
|
1136 |
+
*
|
1137 |
+
* @param array $options: an array containing many options to customize the form
|
1138 |
+
* string + post_id: post id to get field groups from and save data to. Default is false
|
1139 |
+
* array + field_groups: an array containing field group ID's. If this option is set,
|
1140 |
+
* the post_id will not be used to dynamically find the field groups
|
1141 |
+
* boolean + form: display the form tag or not. Defaults to true
|
1142 |
+
* array + form_attributes: an array containg attributes which will be added into the form tag
|
1143 |
+
* string + return: the return URL
|
1144 |
+
* string + html_before_fields: html inside form before fields
|
1145 |
+
* string + html_after_fields: html inside form after fields
|
1146 |
+
* string + submit_value: value of submit button
|
1147 |
+
* string + updated_message: default updated message. Can be false
|
1148 |
+
*
|
1149 |
+
* @return N/A
|
1150 |
+
*/
|
1151 |
+
|
1152 |
+
function acf_form( $options = array() )
|
1153 |
+
{
|
1154 |
+
global $post;
|
1155 |
+
|
1156 |
+
|
1157 |
+
// defaults
|
1158 |
+
$defaults = array(
|
1159 |
+
'post_id' => false,
|
1160 |
+
'field_groups' => array(),
|
1161 |
+
'form' => true,
|
1162 |
+
'form_attributes' => array(
|
1163 |
+
'id' => 'post',
|
1164 |
+
'class' => '',
|
1165 |
+
'action' => '',
|
1166 |
+
'method' => 'post',
|
1167 |
+
),
|
1168 |
+
'return' => add_query_arg( 'updated', 'true', get_permalink() ),
|
1169 |
+
'html_before_fields' => '',
|
1170 |
+
'html_after_fields' => '',
|
1171 |
+
'submit_value' => __("Update", 'acf'),
|
1172 |
+
'updated_message' => __("Post updated", 'acf'),
|
1173 |
+
);
|
1174 |
+
|
1175 |
+
|
1176 |
+
// merge defaults with options
|
1177 |
+
$options = array_merge($defaults, $options);
|
1178 |
+
|
1179 |
+
|
1180 |
+
// merge sub arrays
|
1181 |
+
foreach( $options as $k => $v )
|
1182 |
+
{
|
1183 |
+
if( is_array($v) )
|
1184 |
+
{
|
1185 |
+
$options[ $k ] = array_merge($defaults[ $k ], $options[ $k ]);
|
1186 |
+
}
|
1187 |
+
}
|
1188 |
+
|
1189 |
+
|
1190 |
+
// filter post_id
|
1191 |
+
$options['post_id'] = apply_filters('acf/get_post_id', $options['post_id'] );
|
1192 |
+
|
1193 |
+
|
1194 |
+
// attributes
|
1195 |
+
$options['form_attributes']['class'] .= 'acf-form';
|
1196 |
+
|
1197 |
+
|
1198 |
+
|
1199 |
+
// register post box
|
1200 |
+
if( empty($options['field_groups']) )
|
1201 |
+
{
|
1202 |
+
// get field groups
|
1203 |
+
$filter = array(
|
1204 |
+
'post_id' => $options['post_id']
|
1205 |
+
);
|
1206 |
+
|
1207 |
+
|
1208 |
+
if( strpos($options['post_id'], 'user_') !== false )
|
1209 |
+
{
|
1210 |
+
$user_id = str_replace('user_', '', $options['post_id']);
|
1211 |
+
$filter = array(
|
1212 |
+
'ef_user' => $user_id
|
1213 |
+
);
|
1214 |
+
}
|
1215 |
+
elseif( strpos($options['post_id'], 'taxonomy_') !== false )
|
1216 |
+
{
|
1217 |
+
$taxonomy_id = str_replace('taxonomy_', '', $options['post_id']);
|
1218 |
+
$filter = array(
|
1219 |
+
'ef_taxonomy' => $taxonomy_id
|
1220 |
+
);
|
1221 |
+
}
|
1222 |
+
|
1223 |
+
|
1224 |
+
$options['field_groups'] = array();
|
1225 |
+
$options['field_groups'] = apply_filters( 'acf/location/match_field_groups', $options['field_groups'], $filter );
|
1226 |
+
}
|
1227 |
+
|
1228 |
+
|
1229 |
+
// updated message
|
1230 |
+
if(isset($_GET['updated']) && $_GET['updated'] == 'true' && $options['updated_message'])
|
1231 |
+
{
|
1232 |
+
echo '<div id="message" class="updated"><p>' . $options['updated_message'] . '</p></div>';
|
1233 |
+
}
|
1234 |
+
|
1235 |
+
|
1236 |
+
// display form
|
1237 |
+
if( $options['form'] ): ?>
|
1238 |
+
<form <?php if($options['form_attributes']){foreach($options['form_attributes'] as $k => $v){echo $k . '="' . $v .'" '; }} ?>>
|
1239 |
+
<?php endif; ?>
|
1240 |
+
|
1241 |
+
<div style="display:none">
|
1242 |
+
<script type="text/javascript">
|
1243 |
+
acf.o.post_id = <?php echo is_numeric($options['post_id']) ? $options['post_id'] : '"' . $options['post_id'] . '"'; ?>;
|
1244 |
+
</script>
|
1245 |
+
<input type="hidden" name="acf_nonce" value="<?php echo wp_create_nonce( 'input' ); ?>" />
|
1246 |
+
<input type="hidden" name="post_id" value="<?php echo $options['post_id']; ?>" />
|
1247 |
+
<input type="hidden" name="return" value="<?php echo $options['return']; ?>" />
|
1248 |
+
<?php wp_editor('', 'acf_settings'); ?>
|
1249 |
+
</div>
|
1250 |
+
|
1251 |
+
<div id="poststuff">
|
1252 |
+
<?php
|
1253 |
+
|
1254 |
+
// html before fields
|
1255 |
+
echo $options['html_before_fields'];
|
1256 |
+
|
1257 |
+
|
1258 |
+
$acfs = apply_filters('acf/get_field_groups', array());
|
1259 |
+
|
1260 |
+
if( is_array($acfs) ){ foreach( $acfs as $acf ){
|
1261 |
+
|
1262 |
+
// only add the chosen field groups
|
1263 |
+
if( !in_array( $acf['id'], $options['field_groups'] ) )
|
1264 |
+
{
|
1265 |
+
continue;
|
1266 |
+
}
|
1267 |
+
|
1268 |
+
|
1269 |
+
// load options
|
1270 |
+
$acf['options'] = apply_filters('acf/field_group/get_options', array(), $acf['id']);
|
1271 |
+
|
1272 |
+
|
1273 |
+
// load fields
|
1274 |
+
$fields = apply_filters('acf/field_group/get_fields', array(), $acf['id']);
|
1275 |
+
|
1276 |
+
|
1277 |
+
echo '<div id="acf_' . $acf['id'] . '" class="postbox acf_postbox ' . $acf['options']['layout'] . '">';
|
1278 |
+
echo '<h3 class="hndle"><span>' . $acf['title'] . '</span></h3>';
|
1279 |
+
echo '<div class="inside">';
|
1280 |
+
|
1281 |
+
do_action('acf/create_fields', $fields, $options['post_id']);
|
1282 |
+
|
1283 |
+
echo '</div></div>';
|
1284 |
+
|
1285 |
+
}}
|
1286 |
+
|
1287 |
+
|
1288 |
+
// html after fields
|
1289 |
+
echo $options['html_after_fields'];
|
1290 |
+
|
1291 |
+
?>
|
1292 |
+
|
1293 |
+
<?php if( $options['form'] ): ?>
|
1294 |
+
<!-- Submit -->
|
1295 |
+
<div class="field">
|
1296 |
+
<input type="submit" value="<?php echo $options['submit_value']; ?>" />
|
1297 |
+
</div>
|
1298 |
+
<!-- / Submit -->
|
1299 |
+
<?php endif; ?>
|
1300 |
+
|
1301 |
+
</div><!-- <div id="poststuff"> -->
|
1302 |
+
|
1303 |
+
<?php if( $options['form'] ): ?>
|
1304 |
+
</form>
|
1305 |
+
<?php endif;
|
1306 |
+
}
|
1307 |
+
|
1308 |
+
|
1309 |
+
/*
|
1310 |
+
* update_field()
|
1311 |
+
*
|
1312 |
+
* This function will update a value in the database
|
1313 |
+
*
|
1314 |
+
* @type function
|
1315 |
+
* @since 3.1.9
|
1316 |
+
* @date 29/01/13
|
1317 |
+
*
|
1318 |
+
* @param mixed $field_name: the name of the field - 'sub_heading'
|
1319 |
+
* @param mixed $value: the value to save in the database. The variable type is dependant on the field type
|
1320 |
+
* @param mixed $post_id: the post_id of which the value is saved against
|
1321 |
+
*
|
1322 |
+
* @return N/A
|
1323 |
+
*/
|
1324 |
+
|
1325 |
+
function update_field( $field_key, $value, $post_id = false )
|
1326 |
+
{
|
1327 |
+
// filter post_id
|
1328 |
+
$post_id = apply_filters('acf/get_post_id', $post_id );
|
1329 |
+
|
1330 |
+
|
1331 |
+
// vars
|
1332 |
+
$options = array(
|
1333 |
+
'load_value' => false,
|
1334 |
+
'format_value' => false
|
1335 |
+
);
|
1336 |
+
|
1337 |
+
$field = get_field_object( $field_key, $post_id, $options);
|
1338 |
+
|
1339 |
+
|
1340 |
+
// sub fields? They need formatted data
|
1341 |
+
if( $field['type'] == 'repeater' )
|
1342 |
+
{
|
1343 |
+
$value = acf_convert_field_names_to_keys( $value, $field );
|
1344 |
+
}
|
1345 |
+
elseif( $field['type'] == 'flexible_content' )
|
1346 |
+
{
|
1347 |
+
if( $field['layouts'] )
|
1348 |
+
{
|
1349 |
+
foreach( $field['layouts'] as $layout )
|
1350 |
+
{
|
1351 |
+
$value = acf_convert_field_names_to_keys( $value, $layout );
|
1352 |
+
}
|
1353 |
+
}
|
1354 |
+
}
|
1355 |
+
|
1356 |
+
|
1357 |
+
// save
|
1358 |
+
do_action('acf/update_value', $value, $post_id, $field );
|
1359 |
+
|
1360 |
+
|
1361 |
+
return true;
|
1362 |
+
|
1363 |
+
}
|
1364 |
+
|
1365 |
+
|
1366 |
+
/*
|
1367 |
+
* delete_field()
|
1368 |
+
*
|
1369 |
+
* This function will remove a value from the database
|
1370 |
+
*
|
1371 |
+
* @type function
|
1372 |
+
* @since 3.1.9
|
1373 |
+
* @date 29/01/13
|
1374 |
+
*
|
1375 |
+
* @param mixed $field_name: the name of the field - 'sub_heading'
|
1376 |
+
* @param mixed $post_id: the post_id of which the value is saved against
|
1377 |
+
*
|
1378 |
+
* @return N/A
|
1379 |
+
*/
|
1380 |
+
|
1381 |
+
function delete_field( $field_name, $post_id )
|
1382 |
+
{
|
1383 |
+
do_action('acf/delete_value', $post_id, $field_name );
|
1384 |
+
}
|
1385 |
+
|
1386 |
+
|
1387 |
+
/*
|
1388 |
+
* create_field()
|
1389 |
+
*
|
1390 |
+
* This function will creat the HTML for a field
|
1391 |
+
*
|
1392 |
+
* @type function
|
1393 |
+
* @since 4.0.0
|
1394 |
+
* @date 17/03/13
|
1395 |
+
*
|
1396 |
+
* @param array $field - an array containing all the field attributes
|
1397 |
+
*
|
1398 |
+
* @return N/A
|
1399 |
+
*/
|
1400 |
+
|
1401 |
+
function create_field( $field )
|
1402 |
+
{
|
1403 |
+
do_action('acf/create_field', $field );
|
1404 |
+
}
|
1405 |
+
|
1406 |
+
|
1407 |
+
/*
|
1408 |
+
* acf_convert_field_names_to_keys()
|
1409 |
+
*
|
1410 |
+
* Helper for the update_field function
|
1411 |
+
*
|
1412 |
+
* @type function
|
1413 |
+
* @since 4.0.0
|
1414 |
+
* @date 17/03/13
|
1415 |
+
*
|
1416 |
+
* @param array $value: the value returned via get_field
|
1417 |
+
* @param array $field: the field or layout to find sub fields from
|
1418 |
+
*
|
1419 |
+
* @return N/A
|
1420 |
+
*/
|
1421 |
+
|
1422 |
+
function acf_convert_field_names_to_keys( $value, $field )
|
1423 |
+
{
|
1424 |
+
// only if $field has sub fields
|
1425 |
+
if( !isset($field['sub_fields']) )
|
1426 |
+
{
|
1427 |
+
return $value;
|
1428 |
+
}
|
1429 |
+
|
1430 |
+
|
1431 |
+
// define sub field keys
|
1432 |
+
$sub_fields = array();
|
1433 |
+
if( $field['sub_fields'] )
|
1434 |
+
{
|
1435 |
+
foreach( $field['sub_fields'] as $sub_field )
|
1436 |
+
{
|
1437 |
+
$sub_fields[ $sub_field['name'] ] = $sub_field;
|
1438 |
+
}
|
1439 |
+
}
|
1440 |
+
|
1441 |
+
|
1442 |
+
// loop through the values and format the array to use sub field keys
|
1443 |
+
if( is_array($value) )
|
1444 |
+
{
|
1445 |
+
foreach( $value as $row_i => $row)
|
1446 |
+
{
|
1447 |
+
if( $row )
|
1448 |
+
{
|
1449 |
+
foreach( $row as $sub_field_name => $sub_field_value )
|
1450 |
+
{
|
1451 |
+
// sub field must exist!
|
1452 |
+
if( !isset($sub_fields[ $sub_field_name ]) )
|
1453 |
+
{
|
1454 |
+
continue;
|
1455 |
+
}
|
1456 |
+
|
1457 |
+
|
1458 |
+
// vars
|
1459 |
+
$sub_field = $sub_fields[ $sub_field_name ];
|
1460 |
+
$sub_field_value = acf_convert_field_names_to_keys( $sub_field_value, $sub_field );
|
1461 |
+
|
1462 |
+
|
1463 |
+
// set new value
|
1464 |
+
$value[$row_i][ $sub_field['key'] ] = $sub_field_value;
|
1465 |
+
|
1466 |
+
|
1467 |
+
// unset old value
|
1468 |
+
unset( $value[$row_i][$sub_field_name] );
|
1469 |
+
|
1470 |
+
|
1471 |
+
}
|
1472 |
+
// foreach( $row as $sub_field_name => $sub_field_value )
|
1473 |
+
}
|
1474 |
+
// if( $row )
|
1475 |
+
}
|
1476 |
+
// foreach( $value as $row_i => $row)
|
1477 |
+
}
|
1478 |
+
// if( $value )
|
1479 |
+
|
1480 |
+
|
1481 |
+
return $value;
|
1482 |
+
|
1483 |
+
}
|
1484 |
+
|
1485 |
+
|
1486 |
+
/*
|
1487 |
+
* acf_force_type_array
|
1488 |
+
*
|
1489 |
+
* This function will force a variable to become an array
|
1490 |
+
*
|
1491 |
+
* @type function
|
1492 |
+
* @date 4/02/2014
|
1493 |
+
* @since 5.0.0
|
1494 |
+
*
|
1495 |
+
* @param $var (mixed)
|
1496 |
+
* @return (array)
|
1497 |
+
*/
|
1498 |
+
|
1499 |
+
function acf_force_type_array( $var ) {
|
1500 |
+
|
1501 |
+
// is array?
|
1502 |
+
if( is_array($var) ) {
|
1503 |
+
|
1504 |
+
return $var;
|
1505 |
+
|
1506 |
+
}
|
1507 |
+
|
1508 |
+
|
1509 |
+
// bail early if empty
|
1510 |
+
if( empty($var) && !is_numeric($var) ) {
|
1511 |
+
|
1512 |
+
return array();
|
1513 |
+
|
1514 |
+
}
|
1515 |
+
|
1516 |
+
|
1517 |
+
// string
|
1518 |
+
if( is_string($var) ) {
|
1519 |
+
|
1520 |
+
return explode(',', $var);
|
1521 |
+
|
1522 |
+
}
|
1523 |
+
|
1524 |
+
|
1525 |
+
// place in array
|
1526 |
+
return array( $var );
|
1527 |
+
}
|
1528 |
+
|
1529 |
+
|
1530 |
+
/*
|
1531 |
+
* acf_get_valid_terms
|
1532 |
+
*
|
1533 |
+
* This function will replace old terms with new split term ids
|
1534 |
+
*
|
1535 |
+
* @type function
|
1536 |
+
* @date 27/02/2015
|
1537 |
+
* @since 5.1.5
|
1538 |
+
*
|
1539 |
+
* @param $terms (int|array)
|
1540 |
+
* @param $taxonomy (string)
|
1541 |
+
* @return $terms
|
1542 |
+
*/
|
1543 |
+
|
1544 |
+
function acf_get_valid_terms( $terms = false, $taxonomy = 'category' ) {
|
1545 |
+
|
1546 |
+
// bail early if function does not yet exist or
|
1547 |
+
if( !function_exists('wp_get_split_term') || empty($terms) ) {
|
1548 |
+
|
1549 |
+
return $terms;
|
1550 |
+
|
1551 |
+
}
|
1552 |
+
|
1553 |
+
|
1554 |
+
// vars
|
1555 |
+
$is_array = is_array($terms);
|
1556 |
+
|
1557 |
+
|
1558 |
+
// force into array
|
1559 |
+
$terms = acf_force_type_array( $terms );
|
1560 |
+
|
1561 |
+
|
1562 |
+
// force ints
|
1563 |
+
$terms = array_map('intval', $terms);
|
1564 |
+
|
1565 |
+
|
1566 |
+
// attempt to find new terms
|
1567 |
+
foreach( $terms as $i => $term_id ) {
|
1568 |
+
|
1569 |
+
$new_term_id = wp_get_split_term($term_id, $taxonomy);
|
1570 |
+
|
1571 |
+
if( $new_term_id ) {
|
1572 |
+
|
1573 |
+
$terms[ $i ] = $new_term_id;
|
1574 |
+
|
1575 |
+
}
|
1576 |
+
|
1577 |
+
}
|
1578 |
+
|
1579 |
+
|
1580 |
+
// revert array if needed
|
1581 |
+
if( !$is_array ) {
|
1582 |
+
|
1583 |
+
$terms = $terms[0];
|
1584 |
+
|
1585 |
+
}
|
1586 |
+
|
1587 |
+
|
1588 |
+
// return
|
1589 |
+
return $terms;
|
1590 |
+
|
1591 |
+
}
|
1592 |
+
|
1593 |
+
|
1594 |
+
/*
|
1595 |
+
* Depreceated Functions
|
1596 |
+
*
|
1597 |
+
* @description:
|
1598 |
+
* @created: 23/07/12
|
1599 |
+
*/
|
1600 |
+
|
1601 |
+
|
1602 |
+
/*--------------------------------------------------------------------------------------
|
1603 |
+
*
|
1604 |
+
* reset_the_repeater_field
|
1605 |
+
*
|
1606 |
+
* @author Elliot Condon
|
1607 |
+
* @depreciated: 3.3.4 - now use has_sub_field
|
1608 |
+
* @since 1.0.3
|
1609 |
+
*
|
1610 |
+
*-------------------------------------------------------------------------------------*/
|
1611 |
+
|
1612 |
+
function reset_the_repeater_field()
|
1613 |
+
{
|
1614 |
+
// do nothing
|
1615 |
+
}
|
1616 |
+
|
1617 |
+
|
1618 |
+
/*--------------------------------------------------------------------------------------
|
1619 |
+
*
|
1620 |
+
* the_repeater_field
|
1621 |
+
*
|
1622 |
+
* @author Elliot Condon
|
1623 |
+
* @depreciated: 3.3.4 - now use has_sub_field
|
1624 |
+
* @since 1.0.3
|
1625 |
+
*
|
1626 |
+
*-------------------------------------------------------------------------------------*/
|
1627 |
+
|
1628 |
+
function the_repeater_field($field_name, $post_id = false)
|
1629 |
+
{
|
1630 |
+
return has_sub_field($field_name, $post_id);
|
1631 |
+
}
|
1632 |
+
|
1633 |
+
|
1634 |
+
/*--------------------------------------------------------------------------------------
|
1635 |
+
*
|
1636 |
+
* the_flexible_field
|
1637 |
+
*
|
1638 |
+
* @author Elliot Condon
|
1639 |
+
* @depreciated: 3.3.4 - now use has_sub_field
|
1640 |
+
* @since 3.?.?
|
1641 |
+
*
|
1642 |
+
*-------------------------------------------------------------------------------------*/
|
1643 |
+
|
1644 |
+
function the_flexible_field($field_name, $post_id = false)
|
1645 |
+
{
|
1646 |
+
return has_sub_field($field_name, $post_id);
|
1647 |
+
}
|
1648 |
+
|
1649 |
+
/*
|
1650 |
+
* acf_filter_post_id()
|
1651 |
+
*
|
1652 |
+
* This is a deprecated function which is now run through a filter
|
1653 |
+
*
|
1654 |
+
* @type function
|
1655 |
+
* @since 3.6
|
1656 |
+
* @date 29/01/13
|
1657 |
+
*
|
1658 |
+
* @param mixed $post_id
|
1659 |
+
*
|
1660 |
+
* @return mixed $post_id
|
1661 |
+
*/
|
1662 |
+
|
1663 |
+
function acf_filter_post_id( $post_id )
|
1664 |
+
{
|
1665 |
+
return apply_filters('acf/get_post_id', $post_id );
|
1666 |
+
}
|
1667 |
+
|
1668 |
+
?>
|
shared/assets/plugins/advanced-custom-fields/core/controllers/addons.php
CHANGED
@@ -1,287 +1,287 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* acf_addons
|
5 |
-
*
|
6 |
-
* @description: controller for add-ons sub menu page
|
7 |
-
* @since: 3.6
|
8 |
-
* @created: 25/01/13
|
9 |
-
*/
|
10 |
-
|
11 |
-
class acf_addons
|
12 |
-
{
|
13 |
-
|
14 |
-
var $action;
|
15 |
-
|
16 |
-
|
17 |
-
/*
|
18 |
-
* __construct
|
19 |
-
*
|
20 |
-
* @description:
|
21 |
-
* @since 3.1.8
|
22 |
-
* @created: 23/06/12
|
23 |
-
*/
|
24 |
-
|
25 |
-
function __construct()
|
26 |
-
{
|
27 |
-
// actions
|
28 |
-
add_action('admin_menu', array($this,'admin_menu'), 11, 0);
|
29 |
-
}
|
30 |
-
|
31 |
-
|
32 |
-
/*
|
33 |
-
* admin_menu
|
34 |
-
*
|
35 |
-
* @description:
|
36 |
-
* @created: 2/08/12
|
37 |
-
*/
|
38 |
-
|
39 |
-
function admin_menu()
|
40 |
-
{
|
41 |
-
// add page
|
42 |
-
$page = add_submenu_page('edit.php?post_type=acf', __('Add-ons','acf'), __('Add-ons','acf'), 'manage_options', 'acf-addons', array($this,'html'));
|
43 |
-
|
44 |
-
|
45 |
-
// actions
|
46 |
-
add_action('load-' . $page, array($this,'load'));
|
47 |
-
add_action('admin_print_scripts-' . $page, array($this, 'admin_print_scripts'));
|
48 |
-
add_action('admin_print_styles-' . $page, array($this, 'admin_print_styles'));
|
49 |
-
add_action('admin_head-' . $page, array($this,'admin_head'));
|
50 |
-
}
|
51 |
-
|
52 |
-
|
53 |
-
/*
|
54 |
-
* load
|
55 |
-
*
|
56 |
-
* @description:
|
57 |
-
* @since 3.5.2
|
58 |
-
* @created: 16/11/12
|
59 |
-
* @thanks: Kevin Biloski and Charlie Eriksen via Secunia SVCRP
|
60 |
-
*/
|
61 |
-
|
62 |
-
function load()
|
63 |
-
{
|
64 |
-
|
65 |
-
}
|
66 |
-
|
67 |
-
|
68 |
-
/*
|
69 |
-
* admin_print_scripts
|
70 |
-
*
|
71 |
-
* @description:
|
72 |
-
* @since 3.1.8
|
73 |
-
* @created: 23/06/12
|
74 |
-
*/
|
75 |
-
|
76 |
-
function admin_print_scripts()
|
77 |
-
{
|
78 |
-
|
79 |
-
}
|
80 |
-
|
81 |
-
|
82 |
-
/*
|
83 |
-
* admin_print_styles
|
84 |
-
*
|
85 |
-
* @description:
|
86 |
-
* @since 3.1.8
|
87 |
-
* @created: 23/06/12
|
88 |
-
*/
|
89 |
-
|
90 |
-
function admin_print_styles()
|
91 |
-
{
|
92 |
-
wp_enqueue_style(array(
|
93 |
-
'wp-pointer',
|
94 |
-
'acf-global',
|
95 |
-
'acf',
|
96 |
-
));
|
97 |
-
}
|
98 |
-
|
99 |
-
|
100 |
-
/*
|
101 |
-
* admin_head
|
102 |
-
*
|
103 |
-
* @description:
|
104 |
-
* @since 3.1.8
|
105 |
-
* @created: 23/06/12
|
106 |
-
*/
|
107 |
-
|
108 |
-
function admin_head()
|
109 |
-
{
|
110 |
-
|
111 |
-
}
|
112 |
-
|
113 |
-
|
114 |
-
/*
|
115 |
-
* html
|
116 |
-
*
|
117 |
-
* @description:
|
118 |
-
* @since 3.1.8
|
119 |
-
* @created: 23/06/12
|
120 |
-
*/
|
121 |
-
|
122 |
-
function html()
|
123 |
-
{
|
124 |
-
// vars
|
125 |
-
$dir = apply_filters('acf/get_info', 'dir');
|
126 |
-
|
127 |
-
|
128 |
-
$premium = array();
|
129 |
-
$premium[] = array(
|
130 |
-
'title' => __("Repeater Field",'acf'),
|
131 |
-
'description' => __("Create infinite rows of repeatable data with this versatile interface!",'acf'),
|
132 |
-
'thumbnail' => $dir . 'images/add-ons/repeater-field-thumb.jpg',
|
133 |
-
'active' => class_exists('acf_field_repeater'),
|
134 |
-
'url' => 'http://www.advancedcustomfields.com/add-ons/repeater-field/'
|
135 |
-
);
|
136 |
-
$premium[] = array(
|
137 |
-
'title' => __("Gallery Field",'acf'),
|
138 |
-
'description' => __("Create image galleries in a simple and intuitive interface!",'acf'),
|
139 |
-
'thumbnail' => $dir . 'images/add-ons/gallery-field-thumb.jpg',
|
140 |
-
'active' => class_exists('acf_field_gallery'),
|
141 |
-
'url' => 'http://www.advancedcustomfields.com/add-ons/gallery-field/'
|
142 |
-
);
|
143 |
-
$premium[] = array(
|
144 |
-
'title' => __("Options Page",'acf'),
|
145 |
-
'description' => __("Create global data to use throughout your website!",'acf'),
|
146 |
-
'thumbnail' => $dir . 'images/add-ons/options-page-thumb.jpg',
|
147 |
-
'active' => class_exists('acf_options_page_plugin'),
|
148 |
-
'url' => 'http://www.advancedcustomfields.com/add-ons/options-page/'
|
149 |
-
);
|
150 |
-
$premium[] = array(
|
151 |
-
'title' => __("Flexible Content Field",'acf'),
|
152 |
-
'description' => __("Create unique designs with a flexible content layout manager!",'acf'),
|
153 |
-
'thumbnail' => $dir . 'images/add-ons/flexible-content-field-thumb.jpg',
|
154 |
-
'active' => class_exists('acf_field_flexible_content'),
|
155 |
-
'url' => 'http://www.advancedcustomfields.com/add-ons/flexible-content-field/'
|
156 |
-
);
|
157 |
-
|
158 |
-
|
159 |
-
$free = array();
|
160 |
-
$free[] = array(
|
161 |
-
'title' => __("Gravity Forms Field",'acf'),
|
162 |
-
'description' => __("Creates a select field populated with Gravity Forms!",'acf'),
|
163 |
-
'thumbnail' => $dir . 'images/add-ons/gravity-forms-field-thumb.jpg',
|
164 |
-
'active' => class_exists('gravity_forms_field'),
|
165 |
-
'url' => 'https://github.com/stormuk/Gravity-Forms-ACF-Field/'
|
166 |
-
);
|
167 |
-
$free[] = array(
|
168 |
-
'title' => __("Date & Time Picker",'acf'),
|
169 |
-
'description' => __("jQuery date & time picker",'acf'),
|
170 |
-
'thumbnail' => $dir . 'images/add-ons/date-time-field-thumb.jpg',
|
171 |
-
'active' => class_exists('acf_field_date_time_picker'),
|
172 |
-
'url' => 'http://wordpress.org/extend/plugins/acf-field-date-time-picker/'
|
173 |
-
);
|
174 |
-
$free[] = array(
|
175 |
-
'title' => __("Google Map Extended",'acf'),
|
176 |
-
'description' => __("Find addresses and coordinates of a desired location",'acf'),
|
177 |
-
'thumbnail' => $dir . 'images/add-ons/google-maps-field-thumb.jpg',
|
178 |
-
'active' => class_exists('acf_field_google_map_extended'),
|
179 |
-
'url' => 'https://wordpress.org/plugins/advanced-custom-fields-google-map-extended/'
|
180 |
-
);
|
181 |
-
$free[] = array(
|
182 |
-
'title' => __("Contact Form 7 Field",'acf'),
|
183 |
-
'description' => __("Assign one or more contact form 7 forms to a post",'acf'),
|
184 |
-
'thumbnail' => $dir . 'images/add-ons/cf7-field-thumb.jpg',
|
185 |
-
'active' => class_exists('acf_field_cf7'),
|
186 |
-
'url' => 'https://github.com/taylormsj/acf-cf7-field/'
|
187 |
-
);
|
188 |
-
|
189 |
-
?>
|
190 |
-
<div class="wrap" style="max-width:970px;">
|
191 |
-
|
192 |
-
<div class="icon32" id="icon-acf"><br></div>
|
193 |
-
<h2 style="margin: 4px 0 15px;"><?php _e("Advanced Custom Fields Add-Ons",'acf'); ?></h2>
|
194 |
-
|
195 |
-
<div class="acf-alert">
|
196 |
-
<p style=""><?php _e("The following Add-ons are available to increase the functionality of the Advanced Custom Fields plugin.",'acf'); ?><br />
|
197 |
-
<?php _e("Each Add-on can be installed as a separate plugin (receives updates) or included in your theme (does not receive updates).",'acf'); ?></p>
|
198 |
-
</div>
|
199 |
-
<?php /*
|
200 |
-
<div class="acf-alert">
|
201 |
-
<p><strong><?php _e("Just updated to version 4?",'acf'); ?></strong> <?php _e("Activation codes have changed to plugins! Download your purchased add-ons",'acf'); ?> <a href="http://www.advancedcustomfields.com/add-ons-download/" target="_blank"><?php _e("here",'acf'); ?></a></p>
|
202 |
-
</div>
|
203 |
-
*/ ?>
|
204 |
-
|
205 |
-
<div id="add-ons" class="clearfix">
|
206 |
-
|
207 |
-
<div class="add-on-group clearfix">
|
208 |
-
<?php foreach( $premium as $addon ): ?>
|
209 |
-
<div class="add-on wp-box <?php if( $addon['active'] ): ?>add-on-active<?php endif; ?>">
|
210 |
-
<a target="_blank" href="<?php echo $addon['url']; ?>">
|
211 |
-
<img src="<?php echo $addon['thumbnail']; ?>" />
|
212 |
-
</a>
|
213 |
-
<div class="inner">
|
214 |
-
<h3><a target="_blank" href="<?php echo $addon['url']; ?>"><?php echo $addon['title']; ?></a></h3>
|
215 |
-
<p><?php echo $addon['description']; ?></p>
|
216 |
-
</div>
|
217 |
-
<div class="footer">
|
218 |
-
<?php if( $addon['active'] ): ?>
|
219 |
-
<a class="button button-disabled"><span class="acf-sprite-tick"></span><?php _e("Installed",'acf'); ?></a>
|
220 |
-
<?php else: ?>
|
221 |
-
<a target="_blank" href="<?php echo $addon['url']; ?>" class="button"><?php _e("Purchase & Install",'acf'); ?></a>
|
222 |
-
<?php endif; ?>
|
223 |
-
</div>
|
224 |
-
</div>
|
225 |
-
<?php endforeach; ?>
|
226 |
-
</div>
|
227 |
-
|
228 |
-
<div class="add-on-group clearfix">
|
229 |
-
<?php foreach( $free as $addon ): ?>
|
230 |
-
<div class="add-on wp-box <?php if( $addon['active'] ): ?>add-on-active<?php endif; ?>">
|
231 |
-
<a target="_blank" href="<?php echo $addon['url']; ?>">
|
232 |
-
<img src="<?php echo $addon['thumbnail']; ?>" />
|
233 |
-
</a>
|
234 |
-
<div class="inner">
|
235 |
-
<h3><a target="_blank" href="<?php echo $addon['url']; ?>"><?php echo $addon['title']; ?></a></h3>
|
236 |
-
<p><?php echo $addon['description']; ?></p>
|
237 |
-
</div>
|
238 |
-
<div class="footer">
|
239 |
-
<?php if( $addon['active'] ): ?>
|
240 |
-
<a class="button button-disabled"><span class="acf-sprite-tick"></span><?php _e("Installed",'acf'); ?></a>
|
241 |
-
<?php else: ?>
|
242 |
-
<a target="_blank" href="<?php echo $addon['url']; ?>" class="button"><?php _e("Download",'acf'); ?></a>
|
243 |
-
<?php endif; ?>
|
244 |
-
</div>
|
245 |
-
</div>
|
246 |
-
<?php endforeach; ?>
|
247 |
-
</div>
|
248 |
-
|
249 |
-
|
250 |
-
</div>
|
251 |
-
|
252 |
-
</div>
|
253 |
-
<script type="text/javascript">
|
254 |
-
(function($) {
|
255 |
-
|
256 |
-
$(window).on('load', function(){
|
257 |
-
|
258 |
-
$('#add-ons .add-on-group').each(function(){
|
259 |
-
|
260 |
-
var $el = $(this),
|
261 |
-
h = 0;
|
262 |
-
|
263 |
-
|
264 |
-
$el.find('.add-on').each(function(){
|
265 |
-
|
266 |
-
h = Math.max( $(this).height(), h );
|
267 |
-
|
268 |
-
});
|
269 |
-
|
270 |
-
$el.find('.add-on').height( h );
|
271 |
-
|
272 |
-
});
|
273 |
-
|
274 |
-
});
|
275 |
-
|
276 |
-
})(jQuery);
|
277 |
-
</script>
|
278 |
-
<?php
|
279 |
-
|
280 |
-
return;
|
281 |
-
|
282 |
-
}
|
283 |
-
}
|
284 |
-
|
285 |
-
new acf_addons();
|
286 |
-
|
287 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* acf_addons
|
5 |
+
*
|
6 |
+
* @description: controller for add-ons sub menu page
|
7 |
+
* @since: 3.6
|
8 |
+
* @created: 25/01/13
|
9 |
+
*/
|
10 |
+
|
11 |
+
class acf_addons
|
12 |
+
{
|
13 |
+
|
14 |
+
var $action;
|
15 |
+
|
16 |
+
|
17 |
+
/*
|
18 |
+
* __construct
|
19 |
+
*
|
20 |
+
* @description:
|
21 |
+
* @since 3.1.8
|
22 |
+
* @created: 23/06/12
|
23 |
+
*/
|
24 |
+
|
25 |
+
function __construct()
|
26 |
+
{
|
27 |
+
// actions
|
28 |
+
add_action('admin_menu', array($this,'admin_menu'), 11, 0);
|
29 |
+
}
|
30 |
+
|
31 |
+
|
32 |
+
/*
|
33 |
+
* admin_menu
|
34 |
+
*
|
35 |
+
* @description:
|
36 |
+
* @created: 2/08/12
|
37 |
+
*/
|
38 |
+
|
39 |
+
function admin_menu()
|
40 |
+
{
|
41 |
+
// add page
|
42 |
+
$page = add_submenu_page('edit.php?post_type=acf', __('Add-ons','acf'), __('Add-ons','acf'), 'manage_options', 'acf-addons', array($this,'html'));
|
43 |
+
|
44 |
+
|
45 |
+
// actions
|
46 |
+
add_action('load-' . $page, array($this,'load'));
|
47 |
+
add_action('admin_print_scripts-' . $page, array($this, 'admin_print_scripts'));
|
48 |
+
add_action('admin_print_styles-' . $page, array($this, 'admin_print_styles'));
|
49 |
+
add_action('admin_head-' . $page, array($this,'admin_head'));
|
50 |
+
}
|
51 |
+
|
52 |
+
|
53 |
+
/*
|
54 |
+
* load
|
55 |
+
*
|
56 |
+
* @description:
|
57 |
+
* @since 3.5.2
|
58 |
+
* @created: 16/11/12
|
59 |
+
* @thanks: Kevin Biloski and Charlie Eriksen via Secunia SVCRP
|
60 |
+
*/
|
61 |
+
|
62 |
+
function load()
|
63 |
+
{
|
64 |
+
|
65 |
+
}
|
66 |
+
|
67 |
+
|
68 |
+
/*
|
69 |
+
* admin_print_scripts
|
70 |
+
*
|
71 |
+
* @description:
|
72 |
+
* @since 3.1.8
|
73 |
+
* @created: 23/06/12
|
74 |
+
*/
|
75 |
+
|
76 |
+
function admin_print_scripts()
|
77 |
+
{
|
78 |
+
|
79 |
+
}
|
80 |
+
|
81 |
+
|
82 |
+
/*
|
83 |
+
* admin_print_styles
|
84 |
+
*
|
85 |
+
* @description:
|
86 |
+
* @since 3.1.8
|
87 |
+
* @created: 23/06/12
|
88 |
+
*/
|
89 |
+
|
90 |
+
function admin_print_styles()
|
91 |
+
{
|
92 |
+
wp_enqueue_style(array(
|
93 |
+
'wp-pointer',
|
94 |
+
'acf-global',
|
95 |
+
'acf',
|
96 |
+
));
|
97 |
+
}
|
98 |
+
|
99 |
+
|
100 |
+
/*
|
101 |
+
* admin_head
|
102 |
+
*
|
103 |
+
* @description:
|
104 |
+
* @since 3.1.8
|
105 |
+
* @created: 23/06/12
|
106 |
+
*/
|
107 |
+
|
108 |
+
function admin_head()
|
109 |
+
{
|
110 |
+
|
111 |
+
}
|
112 |
+
|
113 |
+
|
114 |
+
/*
|
115 |
+
* html
|
116 |
+
*
|
117 |
+
* @description:
|
118 |
+
* @since 3.1.8
|
119 |
+
* @created: 23/06/12
|
120 |
+
*/
|
121 |
+
|
122 |
+
function html()
|
123 |
+
{
|
124 |
+
// vars
|
125 |
+
$dir = apply_filters('acf/get_info', 'dir');
|
126 |
+
|
127 |
+
|
128 |
+
$premium = array();
|
129 |
+
$premium[] = array(
|
130 |
+
'title' => __("Repeater Field",'acf'),
|
131 |
+
'description' => __("Create infinite rows of repeatable data with this versatile interface!",'acf'),
|
132 |
+
'thumbnail' => $dir . 'images/add-ons/repeater-field-thumb.jpg',
|
133 |
+
'active' => class_exists('acf_field_repeater'),
|
134 |
+
'url' => 'http://www.advancedcustomfields.com/add-ons/repeater-field/'
|
135 |
+
);
|
136 |
+
$premium[] = array(
|
137 |
+
'title' => __("Gallery Field",'acf'),
|
138 |
+
'description' => __("Create image galleries in a simple and intuitive interface!",'acf'),
|
139 |
+
'thumbnail' => $dir . 'images/add-ons/gallery-field-thumb.jpg',
|
140 |
+
'active' => class_exists('acf_field_gallery'),
|
141 |
+
'url' => 'http://www.advancedcustomfields.com/add-ons/gallery-field/'
|
142 |
+
);
|
143 |
+
$premium[] = array(
|
144 |
+
'title' => __("Options Page",'acf'),
|
145 |
+
'description' => __("Create global data to use throughout your website!",'acf'),
|
146 |
+
'thumbnail' => $dir . 'images/add-ons/options-page-thumb.jpg',
|
147 |
+
'active' => class_exists('acf_options_page_plugin'),
|
148 |
+
'url' => 'http://www.advancedcustomfields.com/add-ons/options-page/'
|
149 |
+
);
|
150 |
+
$premium[] = array(
|
151 |
+
'title' => __("Flexible Content Field",'acf'),
|
152 |
+
'description' => __("Create unique designs with a flexible content layout manager!",'acf'),
|
153 |
+
'thumbnail' => $dir . 'images/add-ons/flexible-content-field-thumb.jpg',
|
154 |
+
'active' => class_exists('acf_field_flexible_content'),
|
155 |
+
'url' => 'http://www.advancedcustomfields.com/add-ons/flexible-content-field/'
|
156 |
+
);
|
157 |
+
|
158 |
+
|
159 |
+
$free = array();
|
160 |
+
$free[] = array(
|
161 |
+
'title' => __("Gravity Forms Field",'acf'),
|
162 |
+
'description' => __("Creates a select field populated with Gravity Forms!",'acf'),
|
163 |
+
'thumbnail' => $dir . 'images/add-ons/gravity-forms-field-thumb.jpg',
|
164 |
+
'active' => class_exists('gravity_forms_field'),
|
165 |
+
'url' => 'https://github.com/stormuk/Gravity-Forms-ACF-Field/'
|
166 |
+
);
|
167 |
+
$free[] = array(
|
168 |
+
'title' => __("Date & Time Picker",'acf'),
|
169 |
+
'description' => __("jQuery date & time picker",'acf'),
|
170 |
+
'thumbnail' => $dir . 'images/add-ons/date-time-field-thumb.jpg',
|
171 |
+
'active' => class_exists('acf_field_date_time_picker'),
|
172 |
+
'url' => 'http://wordpress.org/extend/plugins/acf-field-date-time-picker/'
|
173 |
+
);
|
174 |
+
$free[] = array(
|
175 |
+
'title' => __("Google Map Extended",'acf'),
|
176 |
+
'description' => __("Find addresses and coordinates of a desired location",'acf'),
|
177 |
+
'thumbnail' => $dir . 'images/add-ons/google-maps-field-thumb.jpg',
|
178 |
+
'active' => class_exists('acf_field_google_map_extended'),
|
179 |
+
'url' => 'https://wordpress.org/plugins/advanced-custom-fields-google-map-extended/'
|
180 |
+
);
|
181 |
+
$free[] = array(
|
182 |
+
'title' => __("Contact Form 7 Field",'acf'),
|
183 |
+
'description' => __("Assign one or more contact form 7 forms to a post",'acf'),
|
184 |
+
'thumbnail' => $dir . 'images/add-ons/cf7-field-thumb.jpg',
|
185 |
+
'active' => class_exists('acf_field_cf7'),
|
186 |
+
'url' => 'https://github.com/taylormsj/acf-cf7-field/'
|
187 |
+
);
|
188 |
+
|
189 |
+
?>
|
190 |
+
<div class="wrap" style="max-width:970px;">
|
191 |
+
|
192 |
+
<div class="icon32" id="icon-acf"><br></div>
|
193 |
+
<h2 style="margin: 4px 0 15px;"><?php _e("Advanced Custom Fields Add-Ons",'acf'); ?></h2>
|
194 |
+
|
195 |
+
<div class="acf-alert">
|
196 |
+
<p style=""><?php _e("The following Add-ons are available to increase the functionality of the Advanced Custom Fields plugin.",'acf'); ?><br />
|
197 |
+
<?php _e("Each Add-on can be installed as a separate plugin (receives updates) or included in your theme (does not receive updates).",'acf'); ?></p>
|
198 |
+
</div>
|
199 |
+
<?php /*
|
200 |
+
<div class="acf-alert">
|
201 |
+
<p><strong><?php _e("Just updated to version 4?",'acf'); ?></strong> <?php _e("Activation codes have changed to plugins! Download your purchased add-ons",'acf'); ?> <a href="http://www.advancedcustomfields.com/add-ons-download/" target="_blank"><?php _e("here",'acf'); ?></a></p>
|
202 |
+
</div>
|
203 |
+
*/ ?>
|
204 |
+
|
205 |
+
<div id="add-ons" class="clearfix">
|
206 |
+
|
207 |
+
<div class="add-on-group clearfix">
|
208 |
+
<?php foreach( $premium as $addon ): ?>
|
209 |
+
<div class="add-on wp-box <?php if( $addon['active'] ): ?>add-on-active<?php endif; ?>">
|
210 |
+
<a target="_blank" href="<?php echo $addon['url']; ?>">
|
211 |
+
<img src="<?php echo $addon['thumbnail']; ?>" />
|
212 |
+
</a>
|
213 |
+
<div class="inner">
|
214 |
+
<h3><a target="_blank" href="<?php echo $addon['url']; ?>"><?php echo $addon['title']; ?></a></h3>
|
215 |
+
<p><?php echo $addon['description']; ?></p>
|
216 |
+
</div>
|
217 |
+
<div class="footer">
|
218 |
+
<?php if( $addon['active'] ): ?>
|
219 |
+
<a class="button button-disabled"><span class="acf-sprite-tick"></span><?php _e("Installed",'acf'); ?></a>
|
220 |
+
<?php else: ?>
|
221 |
+
<a target="_blank" href="<?php echo $addon['url']; ?>" class="button"><?php _e("Purchase & Install",'acf'); ?></a>
|
222 |
+
<?php endif; ?>
|
223 |
+
</div>
|
224 |
+
</div>
|
225 |
+
<?php endforeach; ?>
|
226 |
+
</div>
|
227 |
+
|
228 |
+
<div class="add-on-group clearfix">
|
229 |
+
<?php foreach( $free as $addon ): ?>
|
230 |
+
<div class="add-on wp-box <?php if( $addon['active'] ): ?>add-on-active<?php endif; ?>">
|
231 |
+
<a target="_blank" href="<?php echo $addon['url']; ?>">
|
232 |
+
<img src="<?php echo $addon['thumbnail']; ?>" />
|
233 |
+
</a>
|
234 |
+
<div class="inner">
|
235 |
+
<h3><a target="_blank" href="<?php echo $addon['url']; ?>"><?php echo $addon['title']; ?></a></h3>
|
236 |
+
<p><?php echo $addon['description']; ?></p>
|
237 |
+
</div>
|
238 |
+
<div class="footer">
|
239 |
+
<?php if( $addon['active'] ): ?>
|
240 |
+
<a class="button button-disabled"><span class="acf-sprite-tick"></span><?php _e("Installed",'acf'); ?></a>
|
241 |
+
<?php else: ?>
|
242 |
+
<a target="_blank" href="<?php echo $addon['url']; ?>" class="button"><?php _e("Download",'acf'); ?></a>
|
243 |
+
<?php endif; ?>
|
244 |
+
</div>
|
245 |
+
</div>
|
246 |
+
<?php endforeach; ?>
|
247 |
+
</div>
|
248 |
+
|
249 |
+
|
250 |
+
</div>
|
251 |
+
|
252 |
+
</div>
|
253 |
+
<script type="text/javascript">
|
254 |
+
(function($) {
|
255 |
+
|
256 |
+
$(window).on('load', function(){
|
257 |
+
|
258 |
+
$('#add-ons .add-on-group').each(function(){
|
259 |
+
|
260 |
+
var $el = $(this),
|
261 |
+
h = 0;
|
262 |
+
|
263 |
+
|
264 |
+
$el.find('.add-on').each(function(){
|
265 |
+
|
266 |
+
h = Math.max( $(this).height(), h );
|
267 |
+
|
268 |
+
});
|
269 |
+
|
270 |
+
$el.find('.add-on').height( h );
|
271 |
+
|
272 |
+
});
|
273 |
+
|
274 |
+
});
|
275 |
+
|
276 |
+
})(jQuery);
|
277 |
+
</script>
|
278 |
+
<?php
|
279 |
+
|
280 |
+
return;
|
281 |
+
|
282 |
+
}
|
283 |
+
}
|
284 |
+
|
285 |
+
new acf_addons();
|
286 |
+
|
287 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/controllers/everything_fields.php
CHANGED
@@ -1,882 +1,882 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_everything_fields
|
4 |
-
{
|
5 |
-
|
6 |
-
var $settings,
|
7 |
-
$data;
|
8 |
-
|
9 |
-
|
10 |
-
/*
|
11 |
-
* __construct
|
12 |
-
*
|
13 |
-
* @description:
|
14 |
-
* @since 3.1.8
|
15 |
-
* @created: 23/06/12
|
16 |
-
*/
|
17 |
-
|
18 |
-
function __construct()
|
19 |
-
{
|
20 |
-
// data for passing variables
|
21 |
-
$this->data = array(
|
22 |
-
'page_id' => '', // a string used to load values
|
23 |
-
'metabox_ids' => array(),
|
24 |
-
'page_type' => '', // taxonomy / user / media
|
25 |
-
'page_action' => '', // add / edit
|
26 |
-
'option_name' => '', // key used to find value in wp_options table. eg: user_1, category_4
|
27 |
-
);
|
28 |
-
|
29 |
-
|
30 |
-
// actions
|
31 |
-
add_action('admin_menu', array($this,'admin_menu'));
|
32 |
-
add_action('wp_ajax_acf/everything_fields', array($this, 'acf_everything_fields'));
|
33 |
-
|
34 |
-
|
35 |
-
// attachment
|
36 |
-
add_filter('attachment_fields_to_edit', array($this, 'attachment_fields_to_edit'), 10, 2);
|
37 |
-
add_filter('attachment_fields_to_save', array($this, 'save_attachment'), 10, 2);
|
38 |
-
|
39 |
-
|
40 |
-
// save
|
41 |
-
add_action('create_term', array($this, 'save_taxonomy'));
|
42 |
-
add_action('edited_term', array($this, 'save_taxonomy'));
|
43 |
-
add_action('edit_user_profile_update', array($this, 'save_user'));
|
44 |
-
add_action('personal_options_update', array($this, 'save_user'));
|
45 |
-
add_action('user_register', array($this, 'save_user'));
|
46 |
-
|
47 |
-
|
48 |
-
// shopp
|
49 |
-
add_action('shopp_category_saved', array($this, 'shopp_category_saved'));
|
50 |
-
|
51 |
-
|
52 |
-
// delete
|
53 |
-
add_action('delete_term', array($this, 'delete_term'), 10, 4);
|
54 |
-
}
|
55 |
-
|
56 |
-
|
57 |
-
/*
|
58 |
-
* attachment_fields_to_edit
|
59 |
-
*
|
60 |
-
* Adds ACF fields to the attachment form fields
|
61 |
-
*
|
62 |
-
* @type filter
|
63 |
-
* @date 14/07/13
|
64 |
-
*
|
65 |
-
* @param {array} $form_fields
|
66 |
-
* @return {object} $post
|
67 |
-
*/
|
68 |
-
|
69 |
-
function attachment_fields_to_edit( $form_fields, $post )
|
70 |
-
{
|
71 |
-
// vars
|
72 |
-
$screen = get_current_screen();
|
73 |
-
$post_id = $post->ID;
|
74 |
-
|
75 |
-
|
76 |
-
if( $screen && $screen->base == 'post' ) {
|
77 |
-
|
78 |
-
return $form_fields;
|
79 |
-
|
80 |
-
}
|
81 |
-
|
82 |
-
|
83 |
-
// get field groups
|
84 |
-
$filter = array( 'post_type' => 'attachment' );
|
85 |
-
$metabox_ids = array();
|
86 |
-
$metabox_ids = apply_filters( 'acf/location/match_field_groups', $metabox_ids, $filter );
|
87 |
-
|
88 |
-
|
89 |
-
// validate
|
90 |
-
if( empty($metabox_ids) )
|
91 |
-
{
|
92 |
-
return $form_fields;
|
93 |
-
}
|
94 |
-
|
95 |
-
|
96 |
-
$acfs = apply_filters('acf/get_field_groups', array());
|
97 |
-
|
98 |
-
|
99 |
-
if( is_array($acfs) ){ foreach( $acfs as $acf ){
|
100 |
-
|
101 |
-
// only add the chosen field groups
|
102 |
-
if( !in_array( $acf['id'], $metabox_ids ) )
|
103 |
-
{
|
104 |
-
continue;
|
105 |
-
}
|
106 |
-
|
107 |
-
|
108 |
-
// load fields
|
109 |
-
$fields = apply_filters('acf/field_group/get_fields', array(), $acf['id']);
|
110 |
-
|
111 |
-
|
112 |
-
if( is_array($fields) ){ foreach( $fields as $i => $field ){
|
113 |
-
|
114 |
-
// if they didn't select a type, skip this field
|
115 |
-
if( !$field || !$field['type'] || $field['type'] == 'null' )
|
116 |
-
{
|
117 |
-
continue;
|
118 |
-
}
|
119 |
-
|
120 |
-
|
121 |
-
// set value
|
122 |
-
if( !isset($field['value']) )
|
123 |
-
{
|
124 |
-
$field['value'] = apply_filters('acf/load_value', false, $post_id, $field);
|
125 |
-
$field['value'] = apply_filters('acf/format_value', $field['value'], $post_id, $field);
|
126 |
-
}
|
127 |
-
|
128 |
-
|
129 |
-
// create field
|
130 |
-
$field['name'] = 'fields[' . $field['key'] . ']';
|
131 |
-
|
132 |
-
ob_start();
|
133 |
-
|
134 |
-
do_action('acf/create_field', $field);
|
135 |
-
|
136 |
-
$html = ob_get_contents();
|
137 |
-
|
138 |
-
ob_end_clean();
|
139 |
-
|
140 |
-
|
141 |
-
$form_fields[ $field['name'] ] = array(
|
142 |
-
'label' => $field['label'],
|
143 |
-
'input' => 'html',
|
144 |
-
'html' => $html
|
145 |
-
);
|
146 |
-
|
147 |
-
}};
|
148 |
-
|
149 |
-
|
150 |
-
}}
|
151 |
-
|
152 |
-
|
153 |
-
// return
|
154 |
-
return $form_fields;
|
155 |
-
}
|
156 |
-
|
157 |
-
|
158 |
-
/*
|
159 |
-
* save_attachment
|
160 |
-
*
|
161 |
-
* Triggers the acf/save_post action
|
162 |
-
*
|
163 |
-
* @type action
|
164 |
-
* @date 14/07/13
|
165 |
-
*
|
166 |
-
* @param {array} $post
|
167 |
-
* @return {array} $attachment
|
168 |
-
*/
|
169 |
-
|
170 |
-
function save_attachment( $post, $attachment )
|
171 |
-
{
|
172 |
-
// verify nonce
|
173 |
-
/*
|
174 |
-
if( !isset($_POST['acf_nonce']) || !wp_verify_nonce($_POST['acf_nonce'], 'input') )
|
175 |
-
{
|
176 |
-
return $post;
|
177 |
-
}
|
178 |
-
*/
|
179 |
-
|
180 |
-
|
181 |
-
// $post_id to save against
|
182 |
-
$post_id = $post['ID'];
|
183 |
-
|
184 |
-
|
185 |
-
// update the post
|
186 |
-
do_action('acf/save_post', $post_id);
|
187 |
-
|
188 |
-
|
189 |
-
return $post;
|
190 |
-
}
|
191 |
-
|
192 |
-
|
193 |
-
/*
|
194 |
-
* validate_page
|
195 |
-
*
|
196 |
-
* @description: returns true | false. Used to stop a function from continuing
|
197 |
-
* @since 3.2.6
|
198 |
-
* @created: 23/06/12
|
199 |
-
*/
|
200 |
-
|
201 |
-
function validate_page()
|
202 |
-
{
|
203 |
-
// global
|
204 |
-
global $pagenow, $wp_version;
|
205 |
-
|
206 |
-
|
207 |
-
// vars
|
208 |
-
$return = false;
|
209 |
-
|
210 |
-
|
211 |
-
// validate page
|
212 |
-
if( in_array( $pagenow, array( 'edit-tags.php', 'term.php', 'profile.php', 'user-new.php', 'user-edit.php', 'media.php' ) ) )
|
213 |
-
{
|
214 |
-
$return = true;
|
215 |
-
}
|
216 |
-
|
217 |
-
|
218 |
-
// validate page (Shopp)
|
219 |
-
if( $pagenow == "admin.php" && isset( $_GET['page'], $_GET['id'] ) && $_GET['page'] == "shopp-categories" )
|
220 |
-
{
|
221 |
-
$return = true;
|
222 |
-
}
|
223 |
-
|
224 |
-
|
225 |
-
// WP4
|
226 |
-
if( $pagenow === 'upload.php' && version_compare($wp_version, '4.0', '>=') ) {
|
227 |
-
|
228 |
-
$return = true;
|
229 |
-
|
230 |
-
}
|
231 |
-
|
232 |
-
|
233 |
-
// return
|
234 |
-
return $return;
|
235 |
-
}
|
236 |
-
|
237 |
-
|
238 |
-
/*--------------------------------------------------------------------------------------
|
239 |
-
*
|
240 |
-
* admin_menu
|
241 |
-
*
|
242 |
-
* @author Elliot Condon
|
243 |
-
* @since 3.1.8
|
244 |
-
*
|
245 |
-
*-------------------------------------------------------------------------------------*/
|
246 |
-
|
247 |
-
function admin_menu()
|
248 |
-
{
|
249 |
-
|
250 |
-
global $pagenow;
|
251 |
-
|
252 |
-
|
253 |
-
// validate page
|
254 |
-
if( ! $this->validate_page() ) return;
|
255 |
-
|
256 |
-
|
257 |
-
// set page type
|
258 |
-
$filter = array();
|
259 |
-
|
260 |
-
if( $pagenow == "admin.php" && isset( $_GET['page'], $_GET['id'] ) && $_GET['page'] == "shopp-categories" )
|
261 |
-
{
|
262 |
-
// filter
|
263 |
-
$_GET['id'] = filter_var($_GET['id'], FILTER_SANITIZE_STRING);
|
264 |
-
|
265 |
-
|
266 |
-
$this->data['page_type'] = "shopp_category";
|
267 |
-
$filter['ef_taxonomy'] = "shopp_category";
|
268 |
-
|
269 |
-
$this->data['page_action'] = "add";
|
270 |
-
$this->data['option_name'] = "";
|
271 |
-
|
272 |
-
if( $_GET['id'] != "new" )
|
273 |
-
{
|
274 |
-
$this->data['page_action'] = "edit";
|
275 |
-
$this->data['option_name'] = "shopp_category_" . $_GET['id'];
|
276 |
-
}
|
277 |
-
|
278 |
-
} elseif( $pagenow == "edit-tags.php" || $pagenow == "term.php" ) {
|
279 |
-
|
280 |
-
// vars
|
281 |
-
$taxonomy = 'post_tag';
|
282 |
-
$term_id = 0;
|
283 |
-
|
284 |
-
|
285 |
-
// $_GET
|
286 |
-
if( !empty($_GET['taxonomy']) ) {
|
287 |
-
|
288 |
-
$taxonomy = filter_var($_GET['taxonomy'], FILTER_SANITIZE_STRING);
|
289 |
-
|
290 |
-
}
|
291 |
-
|
292 |
-
if( !empty($_GET['tag_ID']) ) {
|
293 |
-
|
294 |
-
$term_id = filter_var($_GET['tag_ID'], FILTER_SANITIZE_NUMBER_INT);
|
295 |
-
|
296 |
-
}
|
297 |
-
|
298 |
-
|
299 |
-
// update filter
|
300 |
-
$filter['ef_taxonomy'] = $taxonomy;
|
301 |
-
|
302 |
-
|
303 |
-
// add
|
304 |
-
$this->data['page_type'] = "taxonomy";
|
305 |
-
$this->data['page_action'] = "add";
|
306 |
-
$this->data['option_name'] = "";
|
307 |
-
|
308 |
-
|
309 |
-
// edit
|
310 |
-
if( $term_id ) {
|
311 |
-
|
312 |
-
$this->data['page_action'] = "edit";
|
313 |
-
$this->data['option_name'] = $taxonomy . "_" . $term_id;
|
314 |
-
|
315 |
-
}
|
316 |
-
|
317 |
-
}
|
318 |
-
elseif( $pagenow == "profile.php" )
|
319 |
-
{
|
320 |
-
|
321 |
-
$this->data['page_type'] = "user";
|
322 |
-
$filter['ef_user'] = get_current_user_id();
|
323 |
-
|
324 |
-
$this->data['page_action'] = "edit";
|
325 |
-
$this->data['option_name'] = "user_" . get_current_user_id();
|
326 |
-
|
327 |
-
}
|
328 |
-
elseif( $pagenow == "user-edit.php" && isset($_GET['user_id']) )
|
329 |
-
{
|
330 |
-
// filter
|
331 |
-
$_GET['user_id'] = filter_var($_GET['user_id'], FILTER_SANITIZE_NUMBER_INT);
|
332 |
-
|
333 |
-
|
334 |
-
$this->data['page_type'] = "user";
|
335 |
-
$filter['ef_user'] = $_GET['user_id'];
|
336 |
-
|
337 |
-
$this->data['page_action'] = "edit";
|
338 |
-
$this->data['option_name'] = "user_" . $_GET['user_id'];
|
339 |
-
|
340 |
-
}
|
341 |
-
elseif( $pagenow == "user-new.php" )
|
342 |
-
{
|
343 |
-
$this->data['page_type'] = "user";
|
344 |
-
$filter['ef_user'] ='all';
|
345 |
-
|
346 |
-
$this->data['page_action'] = "add";
|
347 |
-
$this->data['option_name'] = "";
|
348 |
-
|
349 |
-
}
|
350 |
-
elseif( $pagenow == "media.php" || $pagenow == 'upload.php' )
|
351 |
-
{
|
352 |
-
|
353 |
-
$this->data['page_type'] = "media";
|
354 |
-
$filter['post_type'] = 'attachment';
|
355 |
-
|
356 |
-
$this->data['page_action'] = "add";
|
357 |
-
$this->data['option_name'] = "";
|
358 |
-
|
359 |
-
if(isset($_GET['attachment_id']))
|
360 |
-
{
|
361 |
-
// filter
|
362 |
-
$_GET['attachment_id'] = filter_var($_GET['attachment_id'], FILTER_SANITIZE_NUMBER_INT);
|
363 |
-
|
364 |
-
|
365 |
-
$this->data['page_action'] = "edit";
|
366 |
-
$this->data['option_name'] = $_GET['attachment_id'];
|
367 |
-
}
|
368 |
-
|
369 |
-
}
|
370 |
-
|
371 |
-
|
372 |
-
// get field groups
|
373 |
-
$metabox_ids = array();
|
374 |
-
$this->data['metabox_ids'] = apply_filters( 'acf/location/match_field_groups', $metabox_ids, $filter );
|
375 |
-
|
376 |
-
|
377 |
-
// dont continue if no ids were found
|
378 |
-
if( empty( $this->data['metabox_ids'] ) )
|
379 |
-
{
|
380 |
-
return false;
|
381 |
-
}
|
382 |
-
|
383 |
-
|
384 |
-
// actions
|
385 |
-
add_action('admin_enqueue_scripts', array($this,'admin_enqueue_scripts'));
|
386 |
-
add_action('admin_head', array($this,'admin_head'));
|
387 |
-
|
388 |
-
|
389 |
-
}
|
390 |
-
|
391 |
-
|
392 |
-
/*
|
393 |
-
* admin_enqueue_scripts
|
394 |
-
*
|
395 |
-
* @description:
|
396 |
-
* @since: 3.6
|
397 |
-
* @created: 30/01/13
|
398 |
-
*/
|
399 |
-
|
400 |
-
function admin_enqueue_scripts()
|
401 |
-
{
|
402 |
-
do_action('acf/input/admin_enqueue_scripts');
|
403 |
-
}
|
404 |
-
|
405 |
-
|
406 |
-
/*--------------------------------------------------------------------------------------
|
407 |
-
*
|
408 |
-
* admin_head
|
409 |
-
*
|
410 |
-
* @author Elliot Condon
|
411 |
-
* @since 3.1.8
|
412 |
-
*
|
413 |
-
*-------------------------------------------------------------------------------------*/
|
414 |
-
|
415 |
-
function admin_head()
|
416 |
-
{
|
417 |
-
global $pagenow;
|
418 |
-
|
419 |
-
|
420 |
-
// add user js + css
|
421 |
-
do_action('acf/input/admin_head');
|
422 |
-
|
423 |
-
|
424 |
-
?>
|
425 |
-
<script type="text/javascript">
|
426 |
-
(function($){
|
427 |
-
|
428 |
-
acf.data = {
|
429 |
-
action : 'acf/everything_fields',
|
430 |
-
metabox_ids : '<?php echo implode( ',', $this->data['metabox_ids'] ); ?>',
|
431 |
-
page_type : '<?php echo $this->data['page_type']; ?>',
|
432 |
-
page_action : '<?php echo $this->data['page_action']; ?>',
|
433 |
-
option_name : '<?php echo $this->data['option_name']; ?>'
|
434 |
-
};
|
435 |
-
|
436 |
-
$(document).ready(function(){
|
437 |
-
|
438 |
-
$.ajax({
|
439 |
-
url: ajaxurl,
|
440 |
-
data: acf.data,
|
441 |
-
type: 'post',
|
442 |
-
dataType: 'html',
|
443 |
-
success: function(html){
|
444 |
-
|
445 |
-
<?php
|
446 |
-
if($this->data['page_type'] == "user")
|
447 |
-
{
|
448 |
-
if($this->data['page_action'] == "add")
|
449 |
-
{
|
450 |
-
echo "$('#createuser > table.form-table:last > tbody').append( html );";
|
451 |
-
}
|
452 |
-
else
|
453 |
-
{
|
454 |
-
echo "$('#your-profile .form-table:last').after( html );";
|
455 |
-
}
|
456 |
-
}
|
457 |
-
elseif($this->data['page_type'] == "shopp_category")
|
458 |
-
{
|
459 |
-
echo "$('#post-body-content').append( html );";
|
460 |
-
}
|
461 |
-
elseif($this->data['page_type'] == "taxonomy")
|
462 |
-
{
|
463 |
-
if($this->data['page_action'] == "add")
|
464 |
-
{
|
465 |
-
echo "$('#addtag > p.submit').before( html );";
|
466 |
-
}
|
467 |
-
else
|
468 |
-
{
|
469 |
-
echo "$('#edittag > table.form-table:first > tbody').append( html );";
|
470 |
-
}
|
471 |
-
}
|
472 |
-
elseif($this->data['page_type'] == "media")
|
473 |
-
{
|
474 |
-
if($this->data['page_action'] == "add")
|
475 |
-
{
|
476 |
-
echo "$('#addtag > p.submit').before( html );";
|
477 |
-
}
|
478 |
-
else
|
479 |
-
{
|
480 |
-
echo "$('#media-single-form table tbody tr.submit').before( html );";
|
481 |
-
}
|
482 |
-
}
|
483 |
-
?>
|
484 |
-
|
485 |
-
setTimeout( function(){
|
486 |
-
$(document).trigger('acf/setup_fields', $('#wpbody') );
|
487 |
-
}, 200);
|
488 |
-
|
489 |
-
}
|
490 |
-
});
|
491 |
-
|
492 |
-
|
493 |
-
/*
|
494 |
-
* Taxonomy Add
|
495 |
-
*
|
496 |
-
* @description:
|
497 |
-
* @since: 3.6
|
498 |
-
* @created: 24/02/13
|
499 |
-
*/
|
500 |
-
|
501 |
-
$(document).ajaxComplete(function(event, xhr, settings) {
|
502 |
-
|
503 |
-
// vars
|
504 |
-
data = acf.helpers.url_to_object(settings.data);
|
505 |
-
|
506 |
-
|
507 |
-
// validate
|
508 |
-
if( data.action != 'add-tag' )
|
509 |
-
{
|
510 |
-
return;
|
511 |
-
}
|
512 |
-
|
513 |
-
|
514 |
-
// vars
|
515 |
-
var $el = $('#addtag');
|
516 |
-
|
517 |
-
|
518 |
-
// clear WYSIWYG field
|
519 |
-
$el.find('.acf_wysiwyg textarea').each(function(){
|
520 |
-
|
521 |
-
|
522 |
-
// vars
|
523 |
-
var textarea = $(this),
|
524 |
-
id = textarea.attr('id'),
|
525 |
-
editor = tinyMCE.get( id );
|
526 |
-
|
527 |
-
if( editor )
|
528 |
-
{
|
529 |
-
editor.setContent('');
|
530 |
-
editor.save();
|
531 |
-
}
|
532 |
-
|
533 |
-
});
|
534 |
-
|
535 |
-
|
536 |
-
// clear image / file fields
|
537 |
-
$el.find('.field .active').removeClass('active');
|
538 |
-
|
539 |
-
|
540 |
-
// clear checkbox
|
541 |
-
$el.find('input[type="checkbox"]').removeAttr('checked');
|
542 |
-
|
543 |
-
});
|
544 |
-
|
545 |
-
});
|
546 |
-
|
547 |
-
|
548 |
-
})(jQuery);
|
549 |
-
</script>
|
550 |
-
<?php
|
551 |
-
}
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
/*--------------------------------------------------------------------------------------
|
556 |
-
*
|
557 |
-
* save_taxonomy
|
558 |
-
*
|
559 |
-
* @author Elliot Condon
|
560 |
-
* @since 3.1.8
|
561 |
-
*
|
562 |
-
*-------------------------------------------------------------------------------------*/
|
563 |
-
|
564 |
-
function save_taxonomy( $term_id )
|
565 |
-
{
|
566 |
-
// verify nonce
|
567 |
-
if( !isset($_POST['acf_nonce']) || !wp_verify_nonce($_POST['acf_nonce'], 'input') )
|
568 |
-
{
|
569 |
-
return $term_id;
|
570 |
-
}
|
571 |
-
|
572 |
-
|
573 |
-
// for some weird reason, this is triggered by saving a menu...
|
574 |
-
if( !isset($_POST['taxonomy']) )
|
575 |
-
{
|
576 |
-
return;
|
577 |
-
}
|
578 |
-
|
579 |
-
// $post_id to save against
|
580 |
-
$post_id = $_POST['taxonomy'] . '_' . $term_id;
|
581 |
-
|
582 |
-
|
583 |
-
// update the post
|
584 |
-
do_action('acf/save_post', $post_id);
|
585 |
-
|
586 |
-
}
|
587 |
-
|
588 |
-
|
589 |
-
/*--------------------------------------------------------------------------------------
|
590 |
-
*
|
591 |
-
* profile_save
|
592 |
-
*
|
593 |
-
* @author Elliot Condon
|
594 |
-
* @since 3.1.8
|
595 |
-
*
|
596 |
-
*-------------------------------------------------------------------------------------*/
|
597 |
-
|
598 |
-
function save_user( $user_id )
|
599 |
-
{
|
600 |
-
// verify nonce
|
601 |
-
if( !isset($_POST['acf_nonce']) || !wp_verify_nonce($_POST['acf_nonce'], 'input') )
|
602 |
-
{
|
603 |
-
return $user_id;
|
604 |
-
}
|
605 |
-
|
606 |
-
|
607 |
-
// $post_id to save against
|
608 |
-
$post_id = 'user_' . $user_id;
|
609 |
-
|
610 |
-
|
611 |
-
// update the post
|
612 |
-
do_action('acf/save_post', $post_id);
|
613 |
-
|
614 |
-
}
|
615 |
-
|
616 |
-
|
617 |
-
/*
|
618 |
-
* shopp_category_saved
|
619 |
-
*
|
620 |
-
* @description:
|
621 |
-
* @since 3.5.2
|
622 |
-
* @created: 27/11/12
|
623 |
-
*/
|
624 |
-
|
625 |
-
function shopp_category_saved( $category )
|
626 |
-
{
|
627 |
-
// verify nonce
|
628 |
-
if( !isset($_POST['acf_nonce']) || !wp_verify_nonce($_POST['acf_nonce'], 'input') )
|
629 |
-
{
|
630 |
-
return $category;
|
631 |
-
}
|
632 |
-
|
633 |
-
|
634 |
-
// $post_id to save against
|
635 |
-
$post_id = 'shopp_category_' . $category->id;
|
636 |
-
|
637 |
-
|
638 |
-
// update the post
|
639 |
-
do_action('acf/save_post', $post_id);
|
640 |
-
|
641 |
-
|
642 |
-
}
|
643 |
-
|
644 |
-
|
645 |
-
/*--------------------------------------------------------------------------------------
|
646 |
-
*
|
647 |
-
* acf_everything_fields
|
648 |
-
*
|
649 |
-
* @description Ajax call that renders the html needed for the page
|
650 |
-
* @author Elliot Condon
|
651 |
-
* @since 3.1.8
|
652 |
-
*
|
653 |
-
*-------------------------------------------------------------------------------------*/
|
654 |
-
|
655 |
-
function acf_everything_fields()
|
656 |
-
{
|
657 |
-
// defaults
|
658 |
-
$defaults = array(
|
659 |
-
'metabox_ids' => '',
|
660 |
-
'page_type' => '',
|
661 |
-
'page_action' => '',
|
662 |
-
'option_name' => '',
|
663 |
-
);
|
664 |
-
|
665 |
-
|
666 |
-
// load post options
|
667 |
-
$options = array_merge($defaults, $_POST);
|
668 |
-
|
669 |
-
|
670 |
-
// metabox ids is a string with commas
|
671 |
-
$options['metabox_ids'] = explode( ',', $options['metabox_ids'] );
|
672 |
-
|
673 |
-
|
674 |
-
// get acfs
|
675 |
-
$acfs = apply_filters('acf/get_field_groups', false);
|
676 |
-
|
677 |
-
|
678 |
-
// layout
|
679 |
-
$layout = 'tr';
|
680 |
-
if( $options['page_type'] == "taxonomy" && $options['page_action'] == "add")
|
681 |
-
{
|
682 |
-
$layout = 'div';
|
683 |
-
}
|
684 |
-
if( $options['page_type'] == "shopp_category")
|
685 |
-
{
|
686 |
-
$layout = 'metabox';
|
687 |
-
}
|
688 |
-
|
689 |
-
|
690 |
-
if( $acfs )
|
691 |
-
{
|
692 |
-
foreach( $acfs as $acf )
|
693 |
-
{
|
694 |
-
// load options
|
695 |
-
$acf['options'] = apply_filters('acf/field_group/get_options', array(), $acf['id']);
|
696 |
-
|
697 |
-
|
698 |
-
// only add the chosen field groups
|
699 |
-
if( !in_array( $acf['id'], $options['metabox_ids'] ) )
|
700 |
-
{
|
701 |
-
continue;
|
702 |
-
}
|
703 |
-
|
704 |
-
|
705 |
-
// layout dictates heading
|
706 |
-
$title = true;
|
707 |
-
|
708 |
-
if( $acf['options']['layout'] == 'no_box' )
|
709 |
-
{
|
710 |
-
$title = false;
|
711 |
-
}
|
712 |
-
|
713 |
-
|
714 |
-
// title
|
715 |
-
if( $options['page_action'] == "edit" && $options['page_type'] == 'user' )
|
716 |
-
{
|
717 |
-
if( $title )
|
718 |
-
{
|
719 |
-
echo '<h3>' .$acf['title'] . '</h3>';
|
720 |
-
}
|
721 |
-
|
722 |
-
echo '<table class="form-table"><tbody>';
|
723 |
-
}
|
724 |
-
|
725 |
-
|
726 |
-
// wrapper
|
727 |
-
if( $layout == 'tr' )
|
728 |
-
{
|
729 |
-
//nonce
|
730 |
-
echo '<tr style="display:none;"><td colspan="2"><input type="hidden" name="acf_nonce" value="' . wp_create_nonce( 'input' ) . '" /></td></tr>';
|
731 |
-
}
|
732 |
-
else
|
733 |
-
{
|
734 |
-
//nonce
|
735 |
-
echo '<input type="hidden" name="acf_nonce" value="' . wp_create_nonce( 'input' ) . '" />';
|
736 |
-
}
|
737 |
-
|
738 |
-
if( $layout == 'metabox' )
|
739 |
-
{
|
740 |
-
echo '<div class="postbox acf_postbox" id="acf_'. $acf['id'] .'">';
|
741 |
-
echo '<div title="Click to toggle" class="handlediv"><br></div><h3 class="hndle"><span>' . $acf['title'] . '</span></h3>';
|
742 |
-
echo '<div class="inside">';
|
743 |
-
}
|
744 |
-
|
745 |
-
|
746 |
-
// load fields
|
747 |
-
$fields = apply_filters('acf/field_group/get_fields', array(), $acf['id']);
|
748 |
-
|
749 |
-
|
750 |
-
if( is_array($fields) ){ foreach( $fields as $field ){
|
751 |
-
|
752 |
-
// if they didn't select a type, skip this field
|
753 |
-
if( !$field['type'] || $field['type'] == 'null' ) continue;
|
754 |
-
|
755 |
-
|
756 |
-
// set value
|
757 |
-
if( !isset($field['value']) )
|
758 |
-
{
|
759 |
-
$field['value'] = apply_filters('acf/load_value', false, $options['option_name'], $field);
|
760 |
-
$field['value'] = apply_filters('acf/format_value', $field['value'], $options['option_name'], $field);
|
761 |
-
}
|
762 |
-
|
763 |
-
|
764 |
-
// required
|
765 |
-
$required_class = "";
|
766 |
-
$required_label = "";
|
767 |
-
|
768 |
-
if( $field['required'] )
|
769 |
-
{
|
770 |
-
$required_class = ' required';
|
771 |
-
$required_label = ' <span class="required">*</span>';
|
772 |
-
}
|
773 |
-
|
774 |
-
|
775 |
-
if( $layout == 'metabox' )
|
776 |
-
{
|
777 |
-
echo '<div id="acf-' . $field['name'] . '" class="field field_type-' . $field['type'] . ' field_key-' . $field['key'] . $required_class . '" data-field_name="' . $field['name'] . '" data-field_key="' . $field['key'] . '" data-field_type="' . $field['type'] . '">';
|
778 |
-
|
779 |
-
echo '<p class="label">';
|
780 |
-
echo '<label for="fields[' . $field['key'] . ']">' . $field['label'] . $required_label . '</label>';
|
781 |
-
echo $field['instructions'];
|
782 |
-
echo '</p>';
|
783 |
-
|
784 |
-
$field['name'] = 'fields[' . $field['key'] . ']';
|
785 |
-
do_action('acf/create_field', $field);
|
786 |
-
|
787 |
-
echo '</div>';
|
788 |
-
}
|
789 |
-
elseif( $layout == 'div' )
|
790 |
-
{
|
791 |
-
echo '<div id="acf-' . $field['name'] . '" class="form-field field field_type-' . $field['type'] . ' field_key-' . $field['key'] . $required_class . '" data-field_name="' . $field['name'] . '" data-field_key="' . $field['key'] . '" data-field_type="' . $field['type'] . '">';
|
792 |
-
|
793 |
-
echo '<label for="fields[' . $field['key'] . ']">' . $field['label'] . $required_label . '</label>';
|
794 |
-
$field['name'] = 'fields[' . $field['key'] . ']';
|
795 |
-
do_action('acf/create_field', $field );
|
796 |
-
if($field['instructions']) echo '<p class="description">' . $field['instructions'] . '</p>';
|
797 |
-
|
798 |
-
echo '</div>';
|
799 |
-
}
|
800 |
-
else
|
801 |
-
{
|
802 |
-
echo '<tr id="acf-' . $field['name'] . '" class="form-field field field_type-' . $field['type'] . ' field_key-'.$field['key'] . $required_class . '" data-field_name="' . $field['name'] . '" data-field_key="' . $field['key'] . '" data-field_type="' . $field['type'] . '">';
|
803 |
-
echo '<th valign="top" scope="row"><label for="fields[' . $field['key'] . ']">' . $field['label'] . $required_label . '</label></th>';
|
804 |
-
echo '<td>';
|
805 |
-
$field['name'] = 'fields[' . $field['key'] . ']';
|
806 |
-
do_action('acf/create_field', $field );
|
807 |
-
|
808 |
-
if($field['instructions']) echo '<p class="description">' . $field['instructions'] . '</p>';
|
809 |
-
echo '</td>';
|
810 |
-
echo '</tr>';
|
811 |
-
|
812 |
-
}
|
813 |
-
|
814 |
-
}}
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
// wrapper
|
819 |
-
if( $layout == 'metabox' )
|
820 |
-
{
|
821 |
-
echo '</div></div>';
|
822 |
-
}
|
823 |
-
|
824 |
-
|
825 |
-
// title
|
826 |
-
if( $options['page_action'] == "edit" && $options['page_type'] == 'user' )
|
827 |
-
{
|
828 |
-
echo '</tbody></table>';
|
829 |
-
}
|
830 |
-
|
831 |
-
|
832 |
-
}
|
833 |
-
// foreach($acfs as $acf)
|
834 |
-
}
|
835 |
-
// if($acfs)
|
836 |
-
|
837 |
-
// exit for ajax
|
838 |
-
die();
|
839 |
-
|
840 |
-
}
|
841 |
-
|
842 |
-
|
843 |
-
/*
|
844 |
-
* delete_term
|
845 |
-
*
|
846 |
-
* @description:
|
847 |
-
* @since: 3.5.7
|
848 |
-
* @created: 12/01/13
|
849 |
-
*/
|
850 |
-
|
851 |
-
function delete_term( $term, $tt_id, $taxonomy, $deleted_term ) {
|
852 |
-
|
853 |
-
// globals
|
854 |
-
global $wpdb;
|
855 |
-
|
856 |
-
|
857 |
-
// vars
|
858 |
-
$search = $taxonomy . '_' . $term . '_%';
|
859 |
-
$_search = '_' . $search;
|
860 |
-
|
861 |
-
|
862 |
-
// escape '_'
|
863 |
-
// http://stackoverflow.com/questions/2300285/how-do-i-escape-in-sql-server
|
864 |
-
$search = str_replace('_', '\_', $search);
|
865 |
-
$_search = str_replace('_', '\_', $_search);
|
866 |
-
|
867 |
-
|
868 |
-
// delete
|
869 |
-
$result = $wpdb->query($wpdb->prepare(
|
870 |
-
"DELETE FROM $wpdb->options WHERE option_name LIKE %s OR option_name LIKE %s",
|
871 |
-
$search,
|
872 |
-
$_search
|
873 |
-
));
|
874 |
-
|
875 |
-
}
|
876 |
-
|
877 |
-
|
878 |
-
}
|
879 |
-
|
880 |
-
new acf_everything_fields();
|
881 |
-
|
882 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class acf_everything_fields
|
4 |
+
{
|
5 |
+
|
6 |
+
var $settings,
|
7 |
+
$data;
|
8 |
+
|
9 |
+
|
10 |
+
/*
|
11 |
+
* __construct
|
12 |
+
*
|
13 |
+
* @description:
|
14 |
+
* @since 3.1.8
|
15 |
+
* @created: 23/06/12
|
16 |
+
*/
|
17 |
+
|
18 |
+
function __construct()
|
19 |
+
{
|
20 |
+
// data for passing variables
|
21 |
+
$this->data = array(
|
22 |
+
'page_id' => '', // a string used to load values
|
23 |
+
'metabox_ids' => array(),
|
24 |
+
'page_type' => '', // taxonomy / user / media
|
25 |
+
'page_action' => '', // add / edit
|
26 |
+
'option_name' => '', // key used to find value in wp_options table. eg: user_1, category_4
|
27 |
+
);
|
28 |
+
|
29 |
+
|
30 |
+
// actions
|
31 |
+
add_action('admin_menu', array($this,'admin_menu'));
|
32 |
+
add_action('wp_ajax_acf/everything_fields', array($this, 'acf_everything_fields'));
|
33 |
+
|
34 |
+
|
35 |
+
// attachment
|
36 |
+
add_filter('attachment_fields_to_edit', array($this, 'attachment_fields_to_edit'), 10, 2);
|
37 |
+
add_filter('attachment_fields_to_save', array($this, 'save_attachment'), 10, 2);
|
38 |
+
|
39 |
+
|
40 |
+
// save
|
41 |
+
add_action('create_term', array($this, 'save_taxonomy'));
|
42 |
+
add_action('edited_term', array($this, 'save_taxonomy'));
|
43 |
+
add_action('edit_user_profile_update', array($this, 'save_user'));
|
44 |
+
add_action('personal_options_update', array($this, 'save_user'));
|
45 |
+
add_action('user_register', array($this, 'save_user'));
|
46 |
+
|
47 |
+
|
48 |
+
// shopp
|
49 |
+
add_action('shopp_category_saved', array($this, 'shopp_category_saved'));
|
50 |
+
|
51 |
+
|
52 |
+
// delete
|
53 |
+
add_action('delete_term', array($this, 'delete_term'), 10, 4);
|
54 |
+
}
|
55 |
+
|
56 |
+
|
57 |
+
/*
|
58 |
+
* attachment_fields_to_edit
|
59 |
+
*
|
60 |
+
* Adds ACF fields to the attachment form fields
|
61 |
+
*
|
62 |
+
* @type filter
|
63 |
+
* @date 14/07/13
|
64 |
+
*
|
65 |
+
* @param {array} $form_fields
|
66 |
+
* @return {object} $post
|
67 |
+
*/
|
68 |
+
|
69 |
+
function attachment_fields_to_edit( $form_fields, $post )
|
70 |
+
{
|
71 |
+
// vars
|
72 |
+
$screen = get_current_screen();
|
73 |
+
$post_id = $post->ID;
|
74 |
+
|
75 |
+
|
76 |
+
if( $screen && $screen->base == 'post' ) {
|
77 |
+
|
78 |
+
return $form_fields;
|
79 |
+
|
80 |
+
}
|
81 |
+
|
82 |
+
|
83 |
+
// get field groups
|
84 |
+
$filter = array( 'post_type' => 'attachment' );
|
85 |
+
$metabox_ids = array();
|
86 |
+
$metabox_ids = apply_filters( 'acf/location/match_field_groups', $metabox_ids, $filter );
|
87 |
+
|
88 |
+
|
89 |
+
// validate
|
90 |
+
if( empty($metabox_ids) )
|
91 |
+
{
|
92 |
+
return $form_fields;
|
93 |
+
}
|
94 |
+
|
95 |
+
|
96 |
+
$acfs = apply_filters('acf/get_field_groups', array());
|
97 |
+
|
98 |
+
|
99 |
+
if( is_array($acfs) ){ foreach( $acfs as $acf ){
|
100 |
+
|
101 |
+
// only add the chosen field groups
|
102 |
+
if( !in_array( $acf['id'], $metabox_ids ) )
|
103 |
+
{
|
104 |
+
continue;
|
105 |
+
}
|
106 |
+
|
107 |
+
|
108 |
+
// load fields
|
109 |
+
$fields = apply_filters('acf/field_group/get_fields', array(), $acf['id']);
|
110 |
+
|
111 |
+
|
112 |
+
if( is_array($fields) ){ foreach( $fields as $i => $field ){
|
113 |
+
|
114 |
+
// if they didn't select a type, skip this field
|
115 |
+
if( !$field || !$field['type'] || $field['type'] == 'null' )
|
116 |
+
{
|
117 |
+
continue;
|
118 |
+
}
|
119 |
+
|
120 |
+
|
121 |
+
// set value
|
122 |
+
if( !isset($field['value']) )
|
123 |
+
{
|
124 |
+
$field['value'] = apply_filters('acf/load_value', false, $post_id, $field);
|
125 |
+
$field['value'] = apply_filters('acf/format_value', $field['value'], $post_id, $field);
|
126 |
+
}
|
127 |
+
|
128 |
+
|
129 |
+
// create field
|
130 |
+
$field['name'] = 'fields[' . $field['key'] . ']';
|
131 |
+
|
132 |
+
ob_start();
|
133 |
+
|
134 |
+
do_action('acf/create_field', $field);
|
135 |
+
|
136 |
+
$html = ob_get_contents();
|
137 |
+
|
138 |
+
ob_end_clean();
|
139 |
+
|
140 |
+
|
141 |
+
$form_fields[ $field['name'] ] = array(
|
142 |
+
'label' => $field['label'],
|
143 |
+
'input' => 'html',
|
144 |
+
'html' => $html
|
145 |
+
);
|
146 |
+
|
147 |
+
}};
|
148 |
+
|
149 |
+
|
150 |
+
}}
|
151 |
+
|
152 |
+
|
153 |
+
// return
|
154 |
+
return $form_fields;
|
155 |
+
}
|
156 |
+
|
157 |
+
|
158 |
+
/*
|
159 |
+
* save_attachment
|
160 |
+
*
|
161 |
+
* Triggers the acf/save_post action
|
162 |
+
*
|
163 |
+
* @type action
|
164 |
+
* @date 14/07/13
|
165 |
+
*
|
166 |
+
* @param {array} $post
|
167 |
+
* @return {array} $attachment
|
168 |
+
*/
|
169 |
+
|
170 |
+
function save_attachment( $post, $attachment )
|
171 |
+
{
|
172 |
+
// verify nonce
|
173 |
+
/*
|
174 |
+
if( !isset($_POST['acf_nonce']) || !wp_verify_nonce($_POST['acf_nonce'], 'input') )
|
175 |
+
{
|
176 |
+
return $post;
|
177 |
+
}
|
178 |
+
*/
|
179 |
+
|
180 |
+
|
181 |
+
// $post_id to save against
|
182 |
+
$post_id = $post['ID'];
|
183 |
+
|
184 |
+
|
185 |
+
// update the post
|
186 |
+
do_action('acf/save_post', $post_id);
|
187 |
+
|
188 |
+
|
189 |
+
return $post;
|
190 |
+
}
|
191 |
+
|
192 |
+
|
193 |
+
/*
|
194 |
+
* validate_page
|
195 |
+
*
|
196 |
+
* @description: returns true | false. Used to stop a function from continuing
|
197 |
+
* @since 3.2.6
|
198 |
+
* @created: 23/06/12
|
199 |
+
*/
|
200 |
+
|
201 |
+
function validate_page()
|
202 |
+
{
|
203 |
+
// global
|
204 |
+
global $pagenow, $wp_version;
|
205 |
+
|
206 |
+
|
207 |
+
// vars
|
208 |
+
$return = false;
|
209 |
+
|
210 |
+
|
211 |
+
// validate page
|
212 |
+
if( in_array( $pagenow, array( 'edit-tags.php', 'term.php', 'profile.php', 'user-new.php', 'user-edit.php', 'media.php' ) ) )
|
213 |
+
{
|
214 |
+
$return = true;
|
215 |
+
}
|
216 |
+
|
217 |
+
|
218 |
+
// validate page (Shopp)
|
219 |
+
if( $pagenow == "admin.php" && isset( $_GET['page'], $_GET['id'] ) && $_GET['page'] == "shopp-categories" )
|
220 |
+
{
|
221 |
+
$return = true;
|
222 |
+
}
|
223 |
+
|
224 |
+
|
225 |
+
// WP4
|
226 |
+
if( $pagenow === 'upload.php' && version_compare($wp_version, '4.0', '>=') ) {
|
227 |
+
|
228 |
+
$return = true;
|
229 |
+
|
230 |
+
}
|
231 |
+
|
232 |
+
|
233 |
+
// return
|
234 |
+
return $return;
|
235 |
+
}
|
236 |
+
|
237 |
+
|
238 |
+
/*--------------------------------------------------------------------------------------
|
239 |
+
*
|
240 |
+
* admin_menu
|
241 |
+
*
|
242 |
+
* @author Elliot Condon
|
243 |
+
* @since 3.1.8
|
244 |
+
*
|
245 |
+
*-------------------------------------------------------------------------------------*/
|
246 |
+
|
247 |
+
function admin_menu()
|
248 |
+
{
|
249 |
+
|
250 |
+
global $pagenow;
|
251 |
+
|
252 |
+
|
253 |
+
// validate page
|
254 |
+
if( ! $this->validate_page() ) return;
|
255 |
+
|
256 |
+
|
257 |
+
// set page type
|
258 |
+
$filter = array();
|
259 |
+
|
260 |
+
if( $pagenow == "admin.php" && isset( $_GET['page'], $_GET['id'] ) && $_GET['page'] == "shopp-categories" )
|
261 |
+
{
|
262 |
+
// filter
|
263 |
+
$_GET['id'] = filter_var($_GET['id'], FILTER_SANITIZE_STRING);
|
264 |
+
|
265 |
+
|
266 |
+
$this->data['page_type'] = "shopp_category";
|
267 |
+
$filter['ef_taxonomy'] = "shopp_category";
|
268 |
+
|
269 |
+
$this->data['page_action'] = "add";
|
270 |
+
$this->data['option_name'] = "";
|
271 |
+
|
272 |
+
if( $_GET['id'] != "new" )
|
273 |
+
{
|
274 |
+
$this->data['page_action'] = "edit";
|
275 |
+
$this->data['option_name'] = "shopp_category_" . $_GET['id'];
|
276 |
+
}
|
277 |
+
|
278 |
+
} elseif( $pagenow == "edit-tags.php" || $pagenow == "term.php" ) {
|
279 |
+
|
280 |
+
// vars
|
281 |
+
$taxonomy = 'post_tag';
|
282 |
+
$term_id = 0;
|
283 |
+
|
284 |
+
|
285 |
+
// $_GET
|
286 |
+
if( !empty($_GET['taxonomy']) ) {
|
287 |
+
|
288 |
+
$taxonomy = filter_var($_GET['taxonomy'], FILTER_SANITIZE_STRING);
|
289 |
+
|
290 |
+
}
|
291 |
+
|
292 |
+
if( !empty($_GET['tag_ID']) ) {
|
293 |
+
|
294 |
+
$term_id = filter_var($_GET['tag_ID'], FILTER_SANITIZE_NUMBER_INT);
|
295 |
+
|
296 |
+
}
|
297 |
+
|
298 |
+
|
299 |
+
// update filter
|
300 |
+
$filter['ef_taxonomy'] = $taxonomy;
|
301 |
+
|
302 |
+
|
303 |
+
// add
|
304 |
+
$this->data['page_type'] = "taxonomy";
|
305 |
+
$this->data['page_action'] = "add";
|
306 |
+
$this->data['option_name'] = "";
|
307 |
+
|
308 |
+
|
309 |
+
// edit
|
310 |
+
if( $term_id ) {
|
311 |
+
|
312 |
+
$this->data['page_action'] = "edit";
|
313 |
+
$this->data['option_name'] = $taxonomy . "_" . $term_id;
|
314 |
+
|
315 |
+
}
|
316 |
+
|
317 |
+
}
|
318 |
+
elseif( $pagenow == "profile.php" )
|
319 |
+
{
|
320 |
+
|
321 |
+
$this->data['page_type'] = "user";
|
322 |
+
$filter['ef_user'] = get_current_user_id();
|
323 |
+
|
324 |
+
$this->data['page_action'] = "edit";
|
325 |
+
$this->data['option_name'] = "user_" . get_current_user_id();
|
326 |
+
|
327 |
+
}
|
328 |
+
elseif( $pagenow == "user-edit.php" && isset($_GET['user_id']) )
|
329 |
+
{
|
330 |
+
// filter
|
331 |
+
$_GET['user_id'] = filter_var($_GET['user_id'], FILTER_SANITIZE_NUMBER_INT);
|
332 |
+
|
333 |
+
|
334 |
+
$this->data['page_type'] = "user";
|
335 |
+
$filter['ef_user'] = $_GET['user_id'];
|
336 |
+
|
337 |
+
$this->data['page_action'] = "edit";
|
338 |
+
$this->data['option_name'] = "user_" . $_GET['user_id'];
|
339 |
+
|
340 |
+
}
|
341 |
+
elseif( $pagenow == "user-new.php" )
|
342 |
+
{
|
343 |
+
$this->data['page_type'] = "user";
|
344 |
+
$filter['ef_user'] ='all';
|
345 |
+
|
346 |
+
$this->data['page_action'] = "add";
|
347 |
+
$this->data['option_name'] = "";
|
348 |
+
|
349 |
+
}
|
350 |
+
elseif( $pagenow == "media.php" || $pagenow == 'upload.php' )
|
351 |
+
{
|
352 |
+
|
353 |
+
$this->data['page_type'] = "media";
|
354 |
+
$filter['post_type'] = 'attachment';
|
355 |
+
|
356 |
+
$this->data['page_action'] = "add";
|
357 |
+
$this->data['option_name'] = "";
|
358 |
+
|
359 |
+
if(isset($_GET['attachment_id']))
|
360 |
+
{
|
361 |
+
// filter
|
362 |
+
$_GET['attachment_id'] = filter_var($_GET['attachment_id'], FILTER_SANITIZE_NUMBER_INT);
|
363 |
+
|
364 |
+
|
365 |
+
$this->data['page_action'] = "edit";
|
366 |
+
$this->data['option_name'] = $_GET['attachment_id'];
|
367 |
+
}
|
368 |
+
|
369 |
+
}
|
370 |
+
|
371 |
+
|
372 |
+
// get field groups
|
373 |
+
$metabox_ids = array();
|
374 |
+
$this->data['metabox_ids'] = apply_filters( 'acf/location/match_field_groups', $metabox_ids, $filter );
|
375 |
+
|
376 |
+
|
377 |
+
// dont continue if no ids were found
|
378 |
+
if( empty( $this->data['metabox_ids'] ) )
|
379 |
+
{
|
380 |
+
return false;
|
381 |
+
}
|
382 |
+
|
383 |
+
|
384 |
+
// actions
|
385 |
+
add_action('admin_enqueue_scripts', array($this,'admin_enqueue_scripts'));
|
386 |
+
add_action('admin_head', array($this,'admin_head'));
|
387 |
+
|
388 |
+
|
389 |
+
}
|
390 |
+
|
391 |
+
|
392 |
+
/*
|
393 |
+
* admin_enqueue_scripts
|
394 |
+
*
|
395 |
+
* @description:
|
396 |
+
* @since: 3.6
|
397 |
+
* @created: 30/01/13
|
398 |
+
*/
|
399 |
+
|
400 |
+
function admin_enqueue_scripts()
|
401 |
+
{
|
402 |
+
do_action('acf/input/admin_enqueue_scripts');
|
403 |
+
}
|
404 |
+
|
405 |
+
|
406 |
+
/*--------------------------------------------------------------------------------------
|
407 |
+
*
|
408 |
+
* admin_head
|
409 |
+
*
|
410 |
+
* @author Elliot Condon
|
411 |
+
* @since 3.1.8
|
412 |
+
*
|
413 |
+
*-------------------------------------------------------------------------------------*/
|
414 |
+
|
415 |
+
function admin_head()
|
416 |
+
{
|
417 |
+
global $pagenow;
|
418 |
+
|
419 |
+
|
420 |
+
// add user js + css
|
421 |
+
do_action('acf/input/admin_head');
|
422 |
+
|
423 |
+
|
424 |
+
?>
|
425 |
+
<script type="text/javascript">
|
426 |
+
(function($){
|
427 |
+
|
428 |
+
acf.data = {
|
429 |
+
action : 'acf/everything_fields',
|
430 |
+
metabox_ids : '<?php echo implode( ',', $this->data['metabox_ids'] ); ?>',
|
431 |
+
page_type : '<?php echo $this->data['page_type']; ?>',
|
432 |
+
page_action : '<?php echo $this->data['page_action']; ?>',
|
433 |
+
option_name : '<?php echo $this->data['option_name']; ?>'
|
434 |
+
};
|
435 |
+
|
436 |
+
$(document).ready(function(){
|
437 |
+
|
438 |
+
$.ajax({
|
439 |
+
url: ajaxurl,
|
440 |
+
data: acf.data,
|
441 |
+
type: 'post',
|
442 |
+
dataType: 'html',
|
443 |
+
success: function(html){
|
444 |
+
|
445 |
+
<?php
|
446 |
+
if($this->data['page_type'] == "user")
|
447 |
+
{
|
448 |
+
if($this->data['page_action'] == "add")
|
449 |
+
{
|
450 |
+
echo "$('#createuser > table.form-table:last > tbody').append( html );";
|
451 |
+
}
|
452 |
+
else
|
453 |
+
{
|
454 |
+
echo "$('#your-profile .form-table:last').after( html );";
|
455 |
+
}
|
456 |
+
}
|
457 |
+
elseif($this->data['page_type'] == "shopp_category")
|
458 |
+
{
|
459 |
+
echo "$('#post-body-content').append( html );";
|
460 |
+
}
|
461 |
+
elseif($this->data['page_type'] == "taxonomy")
|
462 |
+
{
|
463 |
+
if($this->data['page_action'] == "add")
|
464 |
+
{
|
465 |
+
echo "$('#addtag > p.submit').before( html );";
|
466 |
+
}
|
467 |
+
else
|
468 |
+
{
|
469 |
+
echo "$('#edittag > table.form-table:first > tbody').append( html );";
|
470 |
+
}
|
471 |
+
}
|
472 |
+
elseif($this->data['page_type'] == "media")
|
473 |
+
{
|
474 |
+
if($this->data['page_action'] == "add")
|
475 |
+
{
|
476 |
+
echo "$('#addtag > p.submit').before( html );";
|
477 |
+
}
|
478 |
+
else
|
479 |
+
{
|
480 |
+
echo "$('#media-single-form table tbody tr.submit').before( html );";
|
481 |
+
}
|
482 |
+
}
|
483 |
+
?>
|
484 |
+
|
485 |
+
setTimeout( function(){
|
486 |
+
$(document).trigger('acf/setup_fields', $('#wpbody') );
|
487 |
+
}, 200);
|
488 |
+
|
489 |
+
}
|
490 |
+
});
|
491 |
+
|
492 |
+
|
493 |
+
/*
|
494 |
+
* Taxonomy Add
|
495 |
+
*
|
496 |
+
* @description:
|
497 |
+
* @since: 3.6
|
498 |
+
* @created: 24/02/13
|
499 |
+
*/
|
500 |
+
|
501 |
+
$(document).ajaxComplete(function(event, xhr, settings) {
|
502 |
+
|
503 |
+
// vars
|
504 |
+
data = acf.helpers.url_to_object(settings.data);
|
505 |
+
|
506 |
+
|
507 |
+
// validate
|
508 |
+
if( data.action != 'add-tag' )
|
509 |
+
{
|
510 |
+
return;
|
511 |
+
}
|
512 |
+
|
513 |
+
|
514 |
+
// vars
|
515 |
+
var $el = $('#addtag');
|
516 |
+
|
517 |
+
|
518 |
+
// clear WYSIWYG field
|
519 |
+
$el.find('.acf_wysiwyg textarea').each(function(){
|
520 |
+
|
521 |
+
|
522 |
+
// vars
|
523 |
+
var textarea = $(this),
|
524 |
+
id = textarea.attr('id'),
|
525 |
+
editor = tinyMCE.get( id );
|
526 |
+
|
527 |
+
if( editor )
|
528 |
+
{
|
529 |
+
editor.setContent('');
|
530 |
+
editor.save();
|
531 |
+
}
|
532 |
+
|
533 |
+
});
|
534 |
+
|
535 |
+
|
536 |
+
// clear image / file fields
|
537 |
+
$el.find('.field .active').removeClass('active');
|
538 |
+
|
539 |
+
|
540 |
+
// clear checkbox
|
541 |
+
$el.find('input[type="checkbox"]').removeAttr('checked');
|
542 |
+
|
543 |
+
});
|
544 |
+
|
545 |
+
});
|
546 |
+
|
547 |
+
|
548 |
+
})(jQuery);
|
549 |
+
</script>
|
550 |
+
<?php
|
551 |
+
}
|
552 |
+
|
553 |
+
|
554 |
+
|
555 |
+
/*--------------------------------------------------------------------------------------
|
556 |
+
*
|
557 |
+
* save_taxonomy
|
558 |
+
*
|
559 |
+
* @author Elliot Condon
|
560 |
+
* @since 3.1.8
|
561 |
+
*
|
562 |
+
*-------------------------------------------------------------------------------------*/
|
563 |
+
|
564 |
+
function save_taxonomy( $term_id )
|
565 |
+
{
|
566 |
+
// verify nonce
|
567 |
+
if( !isset($_POST['acf_nonce']) || !wp_verify_nonce($_POST['acf_nonce'], 'input') )
|
568 |
+
{
|
569 |
+
return $term_id;
|
570 |
+
}
|
571 |
+
|
572 |
+
|
573 |
+
// for some weird reason, this is triggered by saving a menu...
|
574 |
+
if( !isset($_POST['taxonomy']) )
|
575 |
+
{
|
576 |
+
return;
|
577 |
+
}
|
578 |
+
|
579 |
+
// $post_id to save against
|
580 |
+
$post_id = $_POST['taxonomy'] . '_' . $term_id;
|
581 |
+
|
582 |
+
|
583 |
+
// update the post
|
584 |
+
do_action('acf/save_post', $post_id);
|
585 |
+
|
586 |
+
}
|
587 |
+
|
588 |
+
|
589 |
+
/*--------------------------------------------------------------------------------------
|
590 |
+
*
|
591 |
+
* profile_save
|
592 |
+
*
|
593 |
+
* @author Elliot Condon
|
594 |
+
* @since 3.1.8
|
595 |
+
*
|
596 |
+
*-------------------------------------------------------------------------------------*/
|
597 |
+
|
598 |
+
function save_user( $user_id )
|
599 |
+
{
|
600 |
+
// verify nonce
|
601 |
+
if( !isset($_POST['acf_nonce']) || !wp_verify_nonce($_POST['acf_nonce'], 'input') )
|
602 |
+
{
|
603 |
+
return $user_id;
|
604 |
+
}
|
605 |
+
|
606 |
+
|
607 |
+
// $post_id to save against
|
608 |
+
$post_id = 'user_' . $user_id;
|
609 |
+
|
610 |
+
|
611 |
+
// update the post
|
612 |
+
do_action('acf/save_post', $post_id);
|
613 |
+
|
614 |
+
}
|
615 |
+
|
616 |
+
|
617 |
+
/*
|
618 |
+
* shopp_category_saved
|
619 |
+
*
|
620 |
+
* @description:
|
621 |
+
* @since 3.5.2
|
622 |
+
* @created: 27/11/12
|
623 |
+
*/
|
624 |
+
|
625 |
+
function shopp_category_saved( $category )
|
626 |
+
{
|
627 |
+
// verify nonce
|
628 |
+
if( !isset($_POST['acf_nonce']) || !wp_verify_nonce($_POST['acf_nonce'], 'input') )
|
629 |
+
{
|
630 |
+
return $category;
|
631 |
+
}
|
632 |
+
|
633 |
+
|
634 |
+
// $post_id to save against
|
635 |
+
$post_id = 'shopp_category_' . $category->id;
|
636 |
+
|
637 |
+
|
638 |
+
// update the post
|
639 |
+
do_action('acf/save_post', $post_id);
|
640 |
+
|
641 |
+
|
642 |
+
}
|
643 |
+
|
644 |
+
|
645 |
+
/*--------------------------------------------------------------------------------------
|
646 |
+
*
|
647 |
+
* acf_everything_fields
|
648 |
+
*
|
649 |
+
* @description Ajax call that renders the html needed for the page
|
650 |
+
* @author Elliot Condon
|
651 |
+
* @since 3.1.8
|
652 |
+
*
|
653 |
+
*-------------------------------------------------------------------------------------*/
|
654 |
+
|
655 |
+
function acf_everything_fields()
|
656 |
+
{
|
657 |
+
// defaults
|
658 |
+
$defaults = array(
|
659 |
+
'metabox_ids' => '',
|
660 |
+
'page_type' => '',
|
661 |
+
'page_action' => '',
|
662 |
+
'option_name' => '',
|
663 |
+
);
|
664 |
+
|
665 |
+
|
666 |
+
// load post options
|
667 |
+
$options = array_merge($defaults, $_POST);
|
668 |
+
|
669 |
+
|
670 |
+
// metabox ids is a string with commas
|
671 |
+
$options['metabox_ids'] = explode( ',', $options['metabox_ids'] );
|
672 |
+
|
673 |
+
|
674 |
+
// get acfs
|
675 |
+
$acfs = apply_filters('acf/get_field_groups', false);
|
676 |
+
|
677 |
+
|
678 |
+
// layout
|
679 |
+
$layout = 'tr';
|
680 |
+
if( $options['page_type'] == "taxonomy" && $options['page_action'] == "add")
|
681 |
+
{
|
682 |
+
$layout = 'div';
|
683 |
+
}
|
684 |
+
if( $options['page_type'] == "shopp_category")
|
685 |
+
{
|
686 |
+
$layout = 'metabox';
|
687 |
+
}
|
688 |
+
|
689 |
+
|
690 |
+
if( $acfs )
|
691 |
+
{
|
692 |
+
foreach( $acfs as $acf )
|
693 |
+
{
|
694 |
+
// load options
|
695 |
+
$acf['options'] = apply_filters('acf/field_group/get_options', array(), $acf['id']);
|
696 |
+
|
697 |
+
|
698 |
+
// only add the chosen field groups
|
699 |
+
if( !in_array( $acf['id'], $options['metabox_ids'] ) )
|
700 |
+
{
|
701 |
+
continue;
|
702 |
+
}
|
703 |
+
|
704 |
+
|
705 |
+
// layout dictates heading
|
706 |
+
$title = true;
|
707 |
+
|
708 |
+
if( $acf['options']['layout'] == 'no_box' )
|
709 |
+
{
|
710 |
+
$title = false;
|
711 |
+
}
|
712 |
+
|
713 |
+
|
714 |
+
// title
|
715 |
+
if( $options['page_action'] == "edit" && $options['page_type'] == 'user' )
|
716 |
+
{
|
717 |
+
if( $title )
|
718 |
+
{
|
719 |
+
echo '<h3>' .$acf['title'] . '</h3>';
|
720 |
+
}
|
721 |
+
|
722 |
+
echo '<table class="form-table"><tbody>';
|
723 |
+
}
|
724 |
+
|
725 |
+
|
726 |
+
// wrapper
|
727 |
+
if( $layout == 'tr' )
|
728 |
+
{
|
729 |
+
//nonce
|
730 |
+
echo '<tr style="display:none;"><td colspan="2"><input type="hidden" name="acf_nonce" value="' . wp_create_nonce( 'input' ) . '" /></td></tr>';
|
731 |
+
}
|
732 |
+
else
|
733 |
+
{
|
734 |
+
//nonce
|
735 |
+
echo '<input type="hidden" name="acf_nonce" value="' . wp_create_nonce( 'input' ) . '" />';
|
736 |
+
}
|
737 |
+
|
738 |
+
if( $layout == 'metabox' )
|
739 |
+
{
|
740 |
+
echo '<div class="postbox acf_postbox" id="acf_'. $acf['id'] .'">';
|
741 |
+
echo '<div title="Click to toggle" class="handlediv"><br></div><h3 class="hndle"><span>' . $acf['title'] . '</span></h3>';
|
742 |
+
echo '<div class="inside">';
|
743 |
+
}
|
744 |
+
|
745 |
+
|
746 |
+
// load fields
|
747 |
+
$fields = apply_filters('acf/field_group/get_fields', array(), $acf['id']);
|
748 |
+
|
749 |
+
|
750 |
+
if( is_array($fields) ){ foreach( $fields as $field ){
|
751 |
+
|
752 |
+
// if they didn't select a type, skip this field
|
753 |
+
if( !$field['type'] || $field['type'] == 'null' ) continue;
|
754 |
+
|
755 |
+
|
756 |
+
// set value
|
757 |
+
if( !isset($field['value']) )
|
758 |
+
{
|
759 |
+
$field['value'] = apply_filters('acf/load_value', false, $options['option_name'], $field);
|
760 |
+
$field['value'] = apply_filters('acf/format_value', $field['value'], $options['option_name'], $field);
|
761 |
+
}
|
762 |
+
|
763 |
+
|
764 |
+
// required
|
765 |
+
$required_class = "";
|
766 |
+
$required_label = "";
|
767 |
+
|
768 |
+
if( $field['required'] )
|
769 |
+
{
|
770 |
+
$required_class = ' required';
|
771 |
+
$required_label = ' <span class="required">*</span>';
|
772 |
+
}
|
773 |
+
|
774 |
+
|
775 |
+
if( $layout == 'metabox' )
|
776 |
+
{
|
777 |
+
echo '<div id="acf-' . $field['name'] . '" class="field field_type-' . $field['type'] . ' field_key-' . $field['key'] . $required_class . '" data-field_name="' . $field['name'] . '" data-field_key="' . $field['key'] . '" data-field_type="' . $field['type'] . '">';
|
778 |
+
|
779 |
+
echo '<p class="label">';
|
780 |
+
echo '<label for="fields[' . $field['key'] . ']">' . $field['label'] . $required_label . '</label>';
|
781 |
+
echo $field['instructions'];
|
782 |
+
echo '</p>';
|
783 |
+
|
784 |
+
$field['name'] = 'fields[' . $field['key'] . ']';
|
785 |
+
do_action('acf/create_field', $field);
|
786 |
+
|
787 |
+
echo '</div>';
|
788 |
+
}
|
789 |
+
elseif( $layout == 'div' )
|
790 |
+
{
|
791 |
+
echo '<div id="acf-' . $field['name'] . '" class="form-field field field_type-' . $field['type'] . ' field_key-' . $field['key'] . $required_class . '" data-field_name="' . $field['name'] . '" data-field_key="' . $field['key'] . '" data-field_type="' . $field['type'] . '">';
|
792 |
+
|
793 |
+
echo '<label for="fields[' . $field['key'] . ']">' . $field['label'] . $required_label . '</label>';
|
794 |
+
$field['name'] = 'fields[' . $field['key'] . ']';
|
795 |
+
do_action('acf/create_field', $field );
|
796 |
+
if($field['instructions']) echo '<p class="description">' . $field['instructions'] . '</p>';
|
797 |
+
|
798 |
+
echo '</div>';
|
799 |
+
}
|
800 |
+
else
|
801 |
+
{
|
802 |
+
echo '<tr id="acf-' . $field['name'] . '" class="form-field field field_type-' . $field['type'] . ' field_key-'.$field['key'] . $required_class . '" data-field_name="' . $field['name'] . '" data-field_key="' . $field['key'] . '" data-field_type="' . $field['type'] . '">';
|
803 |
+
echo '<th valign="top" scope="row"><label for="fields[' . $field['key'] . ']">' . $field['label'] . $required_label . '</label></th>';
|
804 |
+
echo '<td>';
|
805 |
+
$field['name'] = 'fields[' . $field['key'] . ']';
|
806 |
+
do_action('acf/create_field', $field );
|
807 |
+
|
808 |
+
if($field['instructions']) echo '<p class="description">' . $field['instructions'] . '</p>';
|
809 |
+
echo '</td>';
|
810 |
+
echo '</tr>';
|
811 |
+
|
812 |
+
}
|
813 |
+
|
814 |
+
}}
|
815 |
+
|
816 |
+
|
817 |
+
|
818 |
+
// wrapper
|
819 |
+
if( $layout == 'metabox' )
|
820 |
+
{
|
821 |
+
echo '</div></div>';
|
822 |
+
}
|
823 |
+
|
824 |
+
|
825 |
+
// title
|
826 |
+
if( $options['page_action'] == "edit" && $options['page_type'] == 'user' )
|
827 |
+
{
|
828 |
+
echo '</tbody></table>';
|
829 |
+
}
|
830 |
+
|
831 |
+
|
832 |
+
}
|
833 |
+
// foreach($acfs as $acf)
|
834 |
+
}
|
835 |
+
// if($acfs)
|
836 |
+
|
837 |
+
// exit for ajax
|
838 |
+
die();
|
839 |
+
|
840 |
+
}
|
841 |
+
|
842 |
+
|
843 |
+
/*
|
844 |
+
* delete_term
|
845 |
+
*
|
846 |
+
* @description:
|
847 |
+
* @since: 3.5.7
|
848 |
+
* @created: 12/01/13
|
849 |
+
*/
|
850 |
+
|
851 |
+
function delete_term( $term, $tt_id, $taxonomy, $deleted_term ) {
|
852 |
+
|
853 |
+
// globals
|
854 |
+
global $wpdb;
|
855 |
+
|
856 |
+
|
857 |
+
// vars
|
858 |
+
$search = $taxonomy . '_' . $term . '_%';
|
859 |
+
$_search = '_' . $search;
|
860 |
+
|
861 |
+
|
862 |
+
// escape '_'
|
863 |
+
// http://stackoverflow.com/questions/2300285/how-do-i-escape-in-sql-server
|
864 |
+
$search = str_replace('_', '\_', $search);
|
865 |
+
$_search = str_replace('_', '\_', $_search);
|
866 |
+
|
867 |
+
|
868 |
+
// delete
|
869 |
+
$result = $wpdb->query($wpdb->prepare(
|
870 |
+
"DELETE FROM $wpdb->options WHERE option_name LIKE %s OR option_name LIKE %s",
|
871 |
+
$search,
|
872 |
+
$_search
|
873 |
+
));
|
874 |
+
|
875 |
+
}
|
876 |
+
|
877 |
+
|
878 |
+
}
|
879 |
+
|
880 |
+
new acf_everything_fields();
|
881 |
+
|
882 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/controllers/export.php
CHANGED
@@ -1,509 +1,509 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* acf_export
|
5 |
-
*
|
6 |
-
* @description: controller for export sub menu page
|
7 |
-
* @since: 3.6
|
8 |
-
* @created: 25/01/13
|
9 |
-
*/
|
10 |
-
|
11 |
-
class acf_export
|
12 |
-
{
|
13 |
-
|
14 |
-
var $action;
|
15 |
-
|
16 |
-
|
17 |
-
/*
|
18 |
-
* __construct
|
19 |
-
*
|
20 |
-
* @description:
|
21 |
-
* @since 3.1.8
|
22 |
-
* @created: 23/06/12
|
23 |
-
*/
|
24 |
-
|
25 |
-
function __construct()
|
26 |
-
{
|
27 |
-
// vars
|
28 |
-
$this->action = '';
|
29 |
-
|
30 |
-
|
31 |
-
// actions
|
32 |
-
add_action('admin_menu', array($this,'admin_menu'), 11, 0);
|
33 |
-
|
34 |
-
|
35 |
-
// filters
|
36 |
-
add_filter('acf/export/clean_fields', array($this,'clean_fields'), 10, 1);
|
37 |
-
}
|
38 |
-
|
39 |
-
|
40 |
-
/*
|
41 |
-
* admin_menu
|
42 |
-
*
|
43 |
-
* @description:
|
44 |
-
* @created: 2/08/12
|
45 |
-
*/
|
46 |
-
|
47 |
-
function admin_menu()
|
48 |
-
{
|
49 |
-
// add page
|
50 |
-
$page = add_submenu_page('edit.php?post_type=acf', __('Export','acf'), __('Export','acf'), 'manage_options', 'acf-export', array($this,'html'));
|
51 |
-
|
52 |
-
|
53 |
-
// actions
|
54 |
-
add_action('load-' . $page, array($this,'load'));
|
55 |
-
add_action('admin_print_scripts-' . $page, array($this, 'admin_print_scripts'));
|
56 |
-
add_action('admin_print_styles-' . $page, array($this, 'admin_print_styles'));
|
57 |
-
add_action('admin_head-' . $page, array($this,'admin_head'));
|
58 |
-
}
|
59 |
-
|
60 |
-
|
61 |
-
/*
|
62 |
-
* load
|
63 |
-
*
|
64 |
-
* @description:
|
65 |
-
* @since 3.5.2
|
66 |
-
* @created: 16/11/12
|
67 |
-
* @thanks: Kevin Biloski and Charlie Eriksen via Secunia SVCRP
|
68 |
-
*/
|
69 |
-
|
70 |
-
function load()
|
71 |
-
{
|
72 |
-
// vars
|
73 |
-
$path = apply_filters('acf/get_info', 'path');
|
74 |
-
|
75 |
-
|
76 |
-
// verify nonce
|
77 |
-
if( isset($_POST['nonce']) && wp_verify_nonce($_POST['nonce'], 'export') )
|
78 |
-
{
|
79 |
-
if( isset($_POST['export_to_xml']) )
|
80 |
-
{
|
81 |
-
$this->action = 'export_to_xml';
|
82 |
-
}
|
83 |
-
elseif( isset($_POST['export_to_php']) )
|
84 |
-
{
|
85 |
-
$this->action = 'export_to_php';
|
86 |
-
}
|
87 |
-
}
|
88 |
-
|
89 |
-
|
90 |
-
// include export action
|
91 |
-
if( $this->action == 'export_to_xml' )
|
92 |
-
{
|
93 |
-
include_once($path . 'core/actions/export.php');
|
94 |
-
die;
|
95 |
-
}
|
96 |
-
}
|
97 |
-
|
98 |
-
|
99 |
-
/*
|
100 |
-
* admin_print_scripts
|
101 |
-
*
|
102 |
-
* @description:
|
103 |
-
* @since 3.1.8
|
104 |
-
* @created: 23/06/12
|
105 |
-
*/
|
106 |
-
|
107 |
-
function admin_print_scripts()
|
108 |
-
{
|
109 |
-
|
110 |
-
}
|
111 |
-
|
112 |
-
|
113 |
-
/*
|
114 |
-
* admin_print_styles
|
115 |
-
*
|
116 |
-
* @description:
|
117 |
-
* @since 3.1.8
|
118 |
-
* @created: 23/06/12
|
119 |
-
*/
|
120 |
-
|
121 |
-
function admin_print_styles()
|
122 |
-
{
|
123 |
-
wp_enqueue_style(array(
|
124 |
-
'wp-pointer',
|
125 |
-
'acf-global',
|
126 |
-
'acf',
|
127 |
-
));
|
128 |
-
}
|
129 |
-
|
130 |
-
|
131 |
-
/*
|
132 |
-
* admin_head
|
133 |
-
*
|
134 |
-
* @description:
|
135 |
-
* @since 3.1.8
|
136 |
-
* @created: 23/06/12
|
137 |
-
*/
|
138 |
-
|
139 |
-
function admin_head()
|
140 |
-
{
|
141 |
-
|
142 |
-
}
|
143 |
-
|
144 |
-
|
145 |
-
/*
|
146 |
-
* html
|
147 |
-
*
|
148 |
-
* @description:
|
149 |
-
* @since 3.1.8
|
150 |
-
* @created: 23/06/12
|
151 |
-
*/
|
152 |
-
|
153 |
-
function html()
|
154 |
-
{
|
155 |
-
?>
|
156 |
-
<div class="wrap">
|
157 |
-
|
158 |
-
<div class="icon32" id="icon-acf"><br></div>
|
159 |
-
<h2 style="margin: 4px 0 25px;"><?php _e("Export",'acf'); ?></h2>
|
160 |
-
<?php
|
161 |
-
|
162 |
-
if( $this->action == "export_to_php" )
|
163 |
-
{
|
164 |
-
$this->html_php();
|
165 |
-
}
|
166 |
-
else
|
167 |
-
{
|
168 |
-
$this->html_index();
|
169 |
-
}
|
170 |
-
|
171 |
-
?>
|
172 |
-
</div>
|
173 |
-
<?php
|
174 |
-
|
175 |
-
return;
|
176 |
-
|
177 |
-
}
|
178 |
-
|
179 |
-
|
180 |
-
/*
|
181 |
-
* html_index
|
182 |
-
*
|
183 |
-
* @description:
|
184 |
-
* @created: 9/08/12
|
185 |
-
*/
|
186 |
-
|
187 |
-
function html_index()
|
188 |
-
{
|
189 |
-
// vars
|
190 |
-
$acfs = get_posts(array(
|
191 |
-
'numberposts' => -1,
|
192 |
-
'post_type' => 'acf',
|
193 |
-
'orderby' => 'menu_order title',
|
194 |
-
'order' => 'asc',
|
195 |
-
));
|
196 |
-
|
197 |
-
// blank array to hold acfs
|
198 |
-
$choices = array();
|
199 |
-
|
200 |
-
if($acfs)
|
201 |
-
{
|
202 |
-
foreach($acfs as $acf)
|
203 |
-
{
|
204 |
-
// find title. Could use get_the_title, but that uses get_post(), so I think this uses less Memory
|
205 |
-
$title = apply_filters( 'the_title', $acf->post_title, $acf->ID );
|
206 |
-
|
207 |
-
$choices[$acf->ID] = $title;
|
208 |
-
}
|
209 |
-
}
|
210 |
-
|
211 |
-
?>
|
212 |
-
<form method="post">
|
213 |
-
<input type="hidden" name="nonce" value="<?php echo wp_create_nonce( 'export' ); ?>" />
|
214 |
-
<div class="wp-box">
|
215 |
-
<div class="title">
|
216 |
-
<h3><?php _e("Export Field Groups",'acf'); ?></h3>
|
217 |
-
</div>
|
218 |
-
<table class="acf_input widefat">
|
219 |
-
<tr>
|
220 |
-
<td class="label">
|
221 |
-
<label><?php _e("Field Groups",'acf'); ?></label>
|
222 |
-
<p class="description"><?php _e("Select the field groups to be exported",'acf'); ?></p>
|
223 |
-
</td>
|
224 |
-
<td>
|
225 |
-
<?php do_action('acf/create_field', array(
|
226 |
-
'type' => 'select',
|
227 |
-
'name' => 'acf_posts',
|
228 |
-
'value' => '',
|
229 |
-
'choices' => $choices,
|
230 |
-
'multiple' => 1,
|
231 |
-
)); ?>
|
232 |
-
</td>
|
233 |
-
</tr>
|
234 |
-
<tr>
|
235 |
-
<td class="label"></td>
|
236 |
-
<td>
|
237 |
-
<ul class="hl clearfix">
|
238 |
-
<li>
|
239 |
-
<input type="submit" class="acf-button" name="export_to_xml" value="<?php _e("Export to XML",'acf'); ?>" />
|
240 |
-
</li>
|
241 |
-
<li>
|
242 |
-
<input type="submit" class="acf-button" name="export_to_php" value="<?php _e("Export to PHP",'acf'); ?>" />
|
243 |
-
</li>
|
244 |
-
</ul>
|
245 |
-
</td>
|
246 |
-
</tr>
|
247 |
-
</table>
|
248 |
-
</div>
|
249 |
-
</form>
|
250 |
-
|
251 |
-
<p><br /></p>
|
252 |
-
<h3><?php _e("Export to XML",'acf'); ?></h3>
|
253 |
-
<p><?php _e("ACF will create a .xml export file which is compatible with the native WP import plugin.",'acf'); ?></p>
|
254 |
-
<p><?php _e("Imported field groups <b>will</b> appear in the list of editable field groups. This is useful for migrating fields groups between Wp websites.",'acf'); ?></p>
|
255 |
-
<ol>
|
256 |
-
<li><?php _e("Select field group(s) from the list and click \"Export XML\"",'acf'); ?></li>
|
257 |
-
<li><?php _e("Save the .xml file when prompted",'acf'); ?></li>
|
258 |
-
<li><?php _e("Navigate to Tools » Import and select WordPress",'acf'); ?></li>
|
259 |
-
<li><?php _e("Install WP import plugin if prompted",'acf'); ?></li>
|
260 |
-
<li><?php _e("Upload and import your exported .xml file",'acf'); ?></li>
|
261 |
-
<li><?php _e("Select your user and ignore Import Attachments",'acf'); ?></li>
|
262 |
-
<li><?php _e("That's it! Happy WordPressing",'acf'); ?></li>
|
263 |
-
</ol>
|
264 |
-
|
265 |
-
<p><br /></p>
|
266 |
-
|
267 |
-
<h3><?php _e("Export to PHP",'acf'); ?></h3>
|
268 |
-
<p><?php _e("ACF will create the PHP code to include in your theme.",'acf'); ?></p>
|
269 |
-
<p><?php _e("Registered field groups <b>will not</b> appear in the list of editable field groups. This is useful for including fields in themes.",'acf'); ?></p>
|
270 |
-
<p><?php _e("Please note that if you export and register field groups within the same WP, you will see duplicate fields on your edit screens. To fix this, please move the original field group to the trash or remove the code from your functions.php file.",'acf'); ?></p>
|
271 |
-
<ol>
|
272 |
-
<li><?php _e("Select field group(s) from the list and click \"Create PHP\"",'acf'); ?></li>
|
273 |
-
<li><?php _e("Copy the PHP code generated",'acf'); ?></li>
|
274 |
-
<li><?php _e("Paste into your functions.php file",'acf'); ?></li>
|
275 |
-
<li><?php _e("To activate any Add-ons, edit and use the code in the first few lines.",'acf'); ?></li>
|
276 |
-
</ol>
|
277 |
-
<?php
|
278 |
-
|
279 |
-
}
|
280 |
-
|
281 |
-
|
282 |
-
/*
|
283 |
-
* html_php
|
284 |
-
*
|
285 |
-
* @description:
|
286 |
-
* @created: 9/08/12
|
287 |
-
*/
|
288 |
-
|
289 |
-
function html_php()
|
290 |
-
{
|
291 |
-
|
292 |
-
?>
|
293 |
-
<div class="wp-box">
|
294 |
-
<div class="title">
|
295 |
-
<h3><?php _e("Export Field Groups to PHP",'acf'); ?></h3>
|
296 |
-
</div>
|
297 |
-
<table class="acf_input widefat">
|
298 |
-
<tr>
|
299 |
-
<td class="label">
|
300 |
-
<h3><?php _e("Instructions",'acf'); ?></h3>
|
301 |
-
<ol>
|
302 |
-
<li><?php _e("Copy the PHP code generated",'acf'); ?></li>
|
303 |
-
<li><?php _e("Paste into your functions.php file",'acf'); ?></li>
|
304 |
-
<li><?php _e("To activate any Add-ons, edit and use the code in the first few lines.",'acf'); ?></li>
|
305 |
-
</ol>
|
306 |
-
|
307 |
-
<p><br /></p>
|
308 |
-
|
309 |
-
<h3><?php _e("Notes",'acf'); ?></h3>
|
310 |
-
<p><?php _e("Registered field groups <b>will not</b> appear in the list of editable field groups. This is useful for including fields in themes.",'acf'); ?></p>
|
311 |
-
<p><?php _e("Please note that if you export and register field groups within the same WP, you will see duplicate fields on your edit screens. To fix this, please move the original field group to the trash or remove the code from your functions.php file.",'acf'); ?></p>
|
312 |
-
|
313 |
-
|
314 |
-
<p><br /></p>
|
315 |
-
|
316 |
-
<h3><?php _e("Include in theme",'acf'); ?></h3>
|
317 |
-
<p><?php _e("The Advanced Custom Fields plugin can be included within a theme. To do so, move the ACF plugin inside your theme and add the following code to your functions.php file:",'acf'); ?></p>
|
318 |
-
|
319 |
-
<pre>
|
320 |
-
include_once('advanced-custom-fields/acf.php');
|
321 |
-
</pre>
|
322 |
-
|
323 |
-
<p><?php _e("To remove all visual interfaces from the ACF plugin, you can use a constant to enable lite mode. Add the following code to your functions.php file <b>before</b> the include_once code:",'acf'); ?></p>
|
324 |
-
|
325 |
-
<pre>
|
326 |
-
define( 'ACF_LITE', true );
|
327 |
-
</pre>
|
328 |
-
|
329 |
-
<p><br /></p>
|
330 |
-
|
331 |
-
<p><a href="">« <?php _e("Back to export",'acf'); ?></a></p>
|
332 |
-
</td>
|
333 |
-
<td>
|
334 |
-
<textarea class="pre" readonly="true"><?php
|
335 |
-
|
336 |
-
$acfs = array();
|
337 |
-
|
338 |
-
if( isset($_POST['acf_posts']) )
|
339 |
-
{
|
340 |
-
$acfs = get_posts(array(
|
341 |
-
'numberposts' => -1,
|
342 |
-
'post_type' => 'acf',
|
343 |
-
'orderby' => 'menu_order title',
|
344 |
-
'order' => 'asc',
|
345 |
-
'include' => $_POST['acf_posts'],
|
346 |
-
'suppress_filters' => false,
|
347 |
-
));
|
348 |
-
}
|
349 |
-
if( $acfs )
|
350 |
-
{
|
351 |
-
?>
|
352 |
-
if(function_exists("register_field_group"))
|
353 |
-
{
|
354 |
-
<?php
|
355 |
-
foreach( $acfs as $i => $acf )
|
356 |
-
{
|
357 |
-
// populate acfs
|
358 |
-
$var = array(
|
359 |
-
'id' => $acf->post_name,
|
360 |
-
'title' => $acf->post_title,
|
361 |
-
'fields' => apply_filters('acf/field_group/get_fields', array(), $acf->ID),
|
362 |
-
'location' => apply_filters('acf/field_group/get_location', array(), $acf->ID),
|
363 |
-
'options' => apply_filters('acf/field_group/get_options', array(), $acf->ID),
|
364 |
-
'menu_order' => $acf->menu_order,
|
365 |
-
);
|
366 |
-
|
367 |
-
|
368 |
-
$var['fields'] = apply_filters('acf/export/clean_fields', $var['fields']);
|
369 |
-
|
370 |
-
|
371 |
-
// create html
|
372 |
-
$html = var_export($var, true);
|
373 |
-
|
374 |
-
// change double spaces to tabs
|
375 |
-
$html = str_replace(" ", "\t", $html);
|
376 |
-
|
377 |
-
// correctly formats "=> array("
|
378 |
-
$html = preg_replace('/([\t\r\n]+?)array/', 'array', $html);
|
379 |
-
|
380 |
-
// Remove number keys from array
|
381 |
-
$html = preg_replace('/[0-9]+ => array/', 'array', $html);
|
382 |
-
|
383 |
-
// add extra tab at start of each line
|
384 |
-
$html = str_replace("\n", "\n\t", $html);
|
385 |
-
|
386 |
-
// add the WP __() function to specific strings for translation in theme
|
387 |
-
//$html = preg_replace("/'label'(.*?)('.*?')/", "'label'$1__($2)", $html);
|
388 |
-
//$html = preg_replace("/'instructions'(.*?)('.*?')/", "'instructions'$1__($2)", $html);
|
389 |
-
|
390 |
-
|
391 |
-
?> register_field_group(<?php echo $html ?>);
|
392 |
-
<?php
|
393 |
-
}
|
394 |
-
?>
|
395 |
-
}
|
396 |
-
<?php
|
397 |
-
}
|
398 |
-
else
|
399 |
-
{
|
400 |
-
_e("No field groups were selected",'acf');
|
401 |
-
}
|
402 |
-
?></textarea>
|
403 |
-
</td>
|
404 |
-
</tr>
|
405 |
-
</table>
|
406 |
-
</div>
|
407 |
-
<script type="text/javascript">
|
408 |
-
(function($){
|
409 |
-
|
410 |
-
var i = 0;
|
411 |
-
|
412 |
-
$(document).on('click', 'textarea.pre', function(){
|
413 |
-
|
414 |
-
if( i == 0 )
|
415 |
-
{
|
416 |
-
i++;
|
417 |
-
|
418 |
-
$(this).focus().select();
|
419 |
-
|
420 |
-
return false;
|
421 |
-
}
|
422 |
-
|
423 |
-
});
|
424 |
-
|
425 |
-
$(document).on('keyup', 'textarea.pre', function(){
|
426 |
-
|
427 |
-
$(this).height( 0 );
|
428 |
-
$(this).height( this.scrollHeight );
|
429 |
-
|
430 |
-
});
|
431 |
-
|
432 |
-
$(document).ready(function(){
|
433 |
-
|
434 |
-
$('textarea.pre').trigger('keyup');
|
435 |
-
|
436 |
-
});
|
437 |
-
|
438 |
-
})(jQuery);
|
439 |
-
</script>
|
440 |
-
<?php
|
441 |
-
}
|
442 |
-
|
443 |
-
|
444 |
-
/*
|
445 |
-
* clean_fields
|
446 |
-
*
|
447 |
-
* @description:
|
448 |
-
* @since: 3.5.7
|
449 |
-
* @created: 7/03/13
|
450 |
-
*/
|
451 |
-
|
452 |
-
function clean_fields( $fields )
|
453 |
-
{
|
454 |
-
// trim down the fields
|
455 |
-
if( $fields )
|
456 |
-
{
|
457 |
-
foreach( $fields as $i => $field )
|
458 |
-
{
|
459 |
-
// unset unneccessary bits
|
460 |
-
unset( $field['id'], $field['class'], $field['order_no'], $field['field_group'], $field['_name'] );
|
461 |
-
|
462 |
-
|
463 |
-
// instructions
|
464 |
-
if( !$field['instructions'] )
|
465 |
-
{
|
466 |
-
unset( $field['instructions'] );
|
467 |
-
}
|
468 |
-
|
469 |
-
|
470 |
-
// Required
|
471 |
-
if( !$field['required'] )
|
472 |
-
{
|
473 |
-
unset( $field['required'] );
|
474 |
-
}
|
475 |
-
|
476 |
-
|
477 |
-
// conditional logic
|
478 |
-
if( !$field['conditional_logic']['status'] )
|
479 |
-
{
|
480 |
-
unset( $field['conditional_logic'] );
|
481 |
-
}
|
482 |
-
|
483 |
-
|
484 |
-
// children
|
485 |
-
if( isset($field['sub_fields']) )
|
486 |
-
{
|
487 |
-
$field['sub_fields'] = apply_filters('acf/export/clean_fields', $field['sub_fields']);
|
488 |
-
}
|
489 |
-
elseif( isset($field['layouts']) )
|
490 |
-
{
|
491 |
-
foreach( $field['layouts'] as $l => $layout )
|
492 |
-
{
|
493 |
-
$field['layouts'][ $l ]['sub_fields'] = apply_filters('acf/export/clean_fields', $layout['sub_fields']);
|
494 |
-
}
|
495 |
-
}
|
496 |
-
|
497 |
-
|
498 |
-
// override field
|
499 |
-
$fields[ $i ] = $field;
|
500 |
-
}
|
501 |
-
}
|
502 |
-
|
503 |
-
return $fields;
|
504 |
-
}
|
505 |
-
}
|
506 |
-
|
507 |
-
new acf_export();
|
508 |
-
|
509 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* acf_export
|
5 |
+
*
|
6 |
+
* @description: controller for export sub menu page
|
7 |
+
* @since: 3.6
|
8 |
+
* @created: 25/01/13
|
9 |
+
*/
|
10 |
+
|
11 |
+
class acf_export
|
12 |
+
{
|
13 |
+
|
14 |
+
var $action;
|
15 |
+
|
16 |
+
|
17 |
+
/*
|
18 |
+
* __construct
|
19 |
+
*
|
20 |
+
* @description:
|
21 |
+
* @since 3.1.8
|
22 |
+
* @created: 23/06/12
|
23 |
+
*/
|
24 |
+
|
25 |
+
function __construct()
|
26 |
+
{
|
27 |
+
// vars
|
28 |
+
$this->action = '';
|
29 |
+
|
30 |
+
|
31 |
+
// actions
|
32 |
+
add_action('admin_menu', array($this,'admin_menu'), 11, 0);
|
33 |
+
|
34 |
+
|
35 |
+
// filters
|
36 |
+
add_filter('acf/export/clean_fields', array($this,'clean_fields'), 10, 1);
|
37 |
+
}
|
38 |
+
|
39 |
+
|
40 |
+
/*
|
41 |
+
* admin_menu
|
42 |
+
*
|
43 |
+
* @description:
|
44 |
+
* @created: 2/08/12
|
45 |
+
*/
|
46 |
+
|
47 |
+
function admin_menu()
|
48 |
+
{
|
49 |
+
// add page
|
50 |
+
$page = add_submenu_page('edit.php?post_type=acf', __('Export','acf'), __('Export','acf'), 'manage_options', 'acf-export', array($this,'html'));
|
51 |
+
|
52 |
+
|
53 |
+
// actions
|
54 |
+
add_action('load-' . $page, array($this,'load'));
|
55 |
+
add_action('admin_print_scripts-' . $page, array($this, 'admin_print_scripts'));
|
56 |
+
add_action('admin_print_styles-' . $page, array($this, 'admin_print_styles'));
|
57 |
+
add_action('admin_head-' . $page, array($this,'admin_head'));
|
58 |
+
}
|
59 |
+
|
60 |
+
|
61 |
+
/*
|
62 |
+
* load
|
63 |
+
*
|
64 |
+
* @description:
|
65 |
+
* @since 3.5.2
|
66 |
+
* @created: 16/11/12
|
67 |
+
* @thanks: Kevin Biloski and Charlie Eriksen via Secunia SVCRP
|
68 |
+
*/
|
69 |
+
|
70 |
+
function load()
|
71 |
+
{
|
72 |
+
// vars
|
73 |
+
$path = apply_filters('acf/get_info', 'path');
|
74 |
+
|
75 |
+
|
76 |
+
// verify nonce
|
77 |
+
if( isset($_POST['nonce']) && wp_verify_nonce($_POST['nonce'], 'export') )
|
78 |
+
{
|
79 |
+
if( isset($_POST['export_to_xml']) )
|
80 |
+
{
|
81 |
+
$this->action = 'export_to_xml';
|
82 |
+
}
|
83 |
+
elseif( isset($_POST['export_to_php']) )
|
84 |
+
{
|
85 |
+
$this->action = 'export_to_php';
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
|
90 |
+
// include export action
|
91 |
+
if( $this->action == 'export_to_xml' )
|
92 |
+
{
|
93 |
+
include_once($path . 'core/actions/export.php');
|
94 |
+
die;
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
|
99 |
+
/*
|
100 |
+
* admin_print_scripts
|
101 |
+
*
|
102 |
+
* @description:
|
103 |
+
* @since 3.1.8
|
104 |
+
* @created: 23/06/12
|
105 |
+
*/
|
106 |
+
|
107 |
+
function admin_print_scripts()
|
108 |
+
{
|
109 |
+
|
110 |
+
}
|
111 |
+
|
112 |
+
|
113 |
+
/*
|
114 |
+
* admin_print_styles
|
115 |
+
*
|
116 |
+
* @description:
|
117 |
+
* @since 3.1.8
|
118 |
+
* @created: 23/06/12
|
119 |
+
*/
|
120 |
+
|
121 |
+
function admin_print_styles()
|
122 |
+
{
|
123 |
+
wp_enqueue_style(array(
|
124 |
+
'wp-pointer',
|
125 |
+
'acf-global',
|
126 |
+
'acf',
|
127 |
+
));
|
128 |
+
}
|
129 |
+
|
130 |
+
|
131 |
+
/*
|
132 |
+
* admin_head
|
133 |
+
*
|
134 |
+
* @description:
|
135 |
+
* @since 3.1.8
|
136 |
+
* @created: 23/06/12
|
137 |
+
*/
|
138 |
+
|
139 |
+
function admin_head()
|
140 |
+
{
|
141 |
+
|
142 |
+
}
|
143 |
+
|
144 |
+
|
145 |
+
/*
|
146 |
+
* html
|
147 |
+
*
|
148 |
+
* @description:
|
149 |
+
* @since 3.1.8
|
150 |
+
* @created: 23/06/12
|
151 |
+
*/
|
152 |
+
|
153 |
+
function html()
|
154 |
+
{
|
155 |
+
?>
|
156 |
+
<div class="wrap">
|
157 |
+
|
158 |
+
<div class="icon32" id="icon-acf"><br></div>
|
159 |
+
<h2 style="margin: 4px 0 25px;"><?php _e("Export",'acf'); ?></h2>
|
160 |
+
<?php
|
161 |
+
|
162 |
+
if( $this->action == "export_to_php" )
|
163 |
+
{
|
164 |
+
$this->html_php();
|
165 |
+
}
|
166 |
+
else
|
167 |
+
{
|
168 |
+
$this->html_index();
|
169 |
+
}
|
170 |
+
|
171 |
+
?>
|
172 |
+
</div>
|
173 |
+
<?php
|
174 |
+
|
175 |
+
return;
|
176 |
+
|
177 |
+
}
|
178 |
+
|
179 |
+
|
180 |
+
/*
|
181 |
+
* html_index
|
182 |
+
*
|
183 |
+
* @description:
|
184 |
+
* @created: 9/08/12
|
185 |
+
*/
|
186 |
+
|
187 |
+
function html_index()
|
188 |
+
{
|
189 |
+
// vars
|
190 |
+
$acfs = get_posts(array(
|
191 |
+
'numberposts' => -1,
|
192 |
+
'post_type' => 'acf',
|
193 |
+
'orderby' => 'menu_order title',
|
194 |
+
'order' => 'asc',
|
195 |
+
));
|
196 |
+
|
197 |
+
// blank array to hold acfs
|
198 |
+
$choices = array();
|
199 |
+
|
200 |
+
if($acfs)
|
201 |
+
{
|
202 |
+
foreach($acfs as $acf)
|
203 |
+
{
|
204 |
+
// find title. Could use get_the_title, but that uses get_post(), so I think this uses less Memory
|
205 |
+
$title = apply_filters( 'the_title', $acf->post_title, $acf->ID );
|
206 |
+
|
207 |
+
$choices[$acf->ID] = $title;
|
208 |
+
}
|
209 |
+
}
|
210 |
+
|
211 |
+
?>
|
212 |
+
<form method="post">
|
213 |
+
<input type="hidden" name="nonce" value="<?php echo wp_create_nonce( 'export' ); ?>" />
|
214 |
+
<div class="wp-box">
|
215 |
+
<div class="title">
|
216 |
+
<h3><?php _e("Export Field Groups",'acf'); ?></h3>
|
217 |
+
</div>
|
218 |
+
<table class="acf_input widefat">
|
219 |
+
<tr>
|
220 |
+
<td class="label">
|
221 |
+
<label><?php _e("Field Groups",'acf'); ?></label>
|
222 |
+
<p class="description"><?php _e("Select the field groups to be exported",'acf'); ?></p>
|
223 |
+
</td>
|
224 |
+
<td>
|
225 |
+
<?php do_action('acf/create_field', array(
|
226 |
+
'type' => 'select',
|
227 |
+
'name' => 'acf_posts',
|
228 |
+
'value' => '',
|
229 |
+
'choices' => $choices,
|
230 |
+
'multiple' => 1,
|
231 |
+
)); ?>
|
232 |
+
</td>
|
233 |
+
</tr>
|
234 |
+
<tr>
|
235 |
+
<td class="label"></td>
|
236 |
+
<td>
|
237 |
+
<ul class="hl clearfix">
|
238 |
+
<li>
|
239 |
+
<input type="submit" class="acf-button" name="export_to_xml" value="<?php _e("Export to XML",'acf'); ?>" />
|
240 |
+
</li>
|
241 |
+
<li>
|
242 |
+
<input type="submit" class="acf-button" name="export_to_php" value="<?php _e("Export to PHP",'acf'); ?>" />
|
243 |
+
</li>
|
244 |
+
</ul>
|
245 |
+
</td>
|
246 |
+
</tr>
|
247 |
+
</table>
|
248 |
+
</div>
|
249 |
+
</form>
|
250 |
+
|
251 |
+
<p><br /></p>
|
252 |
+
<h3><?php _e("Export to XML",'acf'); ?></h3>
|
253 |
+
<p><?php _e("ACF will create a .xml export file which is compatible with the native WP import plugin.",'acf'); ?></p>
|
254 |
+
<p><?php _e("Imported field groups <b>will</b> appear in the list of editable field groups. This is useful for migrating fields groups between Wp websites.",'acf'); ?></p>
|
255 |
+
<ol>
|
256 |
+
<li><?php _e("Select field group(s) from the list and click \"Export XML\"",'acf'); ?></li>
|
257 |
+
<li><?php _e("Save the .xml file when prompted",'acf'); ?></li>
|
258 |
+
<li><?php _e("Navigate to Tools » Import and select WordPress",'acf'); ?></li>
|
259 |
+
<li><?php _e("Install WP import plugin if prompted",'acf'); ?></li>
|
260 |
+
<li><?php _e("Upload and import your exported .xml file",'acf'); ?></li>
|
261 |
+
<li><?php _e("Select your user and ignore Import Attachments",'acf'); ?></li>
|
262 |
+
<li><?php _e("That's it! Happy WordPressing",'acf'); ?></li>
|
263 |
+
</ol>
|
264 |
+
|
265 |
+
<p><br /></p>
|
266 |
+
|
267 |
+
<h3><?php _e("Export to PHP",'acf'); ?></h3>
|
268 |
+
<p><?php _e("ACF will create the PHP code to include in your theme.",'acf'); ?></p>
|
269 |
+
<p><?php _e("Registered field groups <b>will not</b> appear in the list of editable field groups. This is useful for including fields in themes.",'acf'); ?></p>
|
270 |
+
<p><?php _e("Please note that if you export and register field groups within the same WP, you will see duplicate fields on your edit screens. To fix this, please move the original field group to the trash or remove the code from your functions.php file.",'acf'); ?></p>
|
271 |
+
<ol>
|
272 |
+
<li><?php _e("Select field group(s) from the list and click \"Create PHP\"",'acf'); ?></li>
|
273 |
+
<li><?php _e("Copy the PHP code generated",'acf'); ?></li>
|
274 |
+
<li><?php _e("Paste into your functions.php file",'acf'); ?></li>
|
275 |
+
<li><?php _e("To activate any Add-ons, edit and use the code in the first few lines.",'acf'); ?></li>
|
276 |
+
</ol>
|
277 |
+
<?php
|
278 |
+
|
279 |
+
}
|
280 |
+
|
281 |
+
|
282 |
+
/*
|
283 |
+
* html_php
|
284 |
+
*
|
285 |
+
* @description:
|
286 |
+
* @created: 9/08/12
|
287 |
+
*/
|
288 |
+
|
289 |
+
function html_php()
|
290 |
+
{
|
291 |
+
|
292 |
+
?>
|
293 |
+
<div class="wp-box">
|
294 |
+
<div class="title">
|
295 |
+
<h3><?php _e("Export Field Groups to PHP",'acf'); ?></h3>
|
296 |
+
</div>
|
297 |
+
<table class="acf_input widefat">
|
298 |
+
<tr>
|
299 |
+
<td class="label">
|
300 |
+
<h3><?php _e("Instructions",'acf'); ?></h3>
|
301 |
+
<ol>
|
302 |
+
<li><?php _e("Copy the PHP code generated",'acf'); ?></li>
|
303 |
+
<li><?php _e("Paste into your functions.php file",'acf'); ?></li>
|
304 |
+
<li><?php _e("To activate any Add-ons, edit and use the code in the first few lines.",'acf'); ?></li>
|
305 |
+
</ol>
|
306 |
+
|
307 |
+
<p><br /></p>
|
308 |
+
|
309 |
+
<h3><?php _e("Notes",'acf'); ?></h3>
|
310 |
+
<p><?php _e("Registered field groups <b>will not</b> appear in the list of editable field groups. This is useful for including fields in themes.",'acf'); ?></p>
|
311 |
+
<p><?php _e("Please note that if you export and register field groups within the same WP, you will see duplicate fields on your edit screens. To fix this, please move the original field group to the trash or remove the code from your functions.php file.",'acf'); ?></p>
|
312 |
+
|
313 |
+
|
314 |
+
<p><br /></p>
|
315 |
+
|
316 |
+
<h3><?php _e("Include in theme",'acf'); ?></h3>
|
317 |
+
<p><?php _e("The Advanced Custom Fields plugin can be included within a theme. To do so, move the ACF plugin inside your theme and add the following code to your functions.php file:",'acf'); ?></p>
|
318 |
+
|
319 |
+
<pre>
|
320 |
+
include_once('advanced-custom-fields/acf.php');
|
321 |
+
</pre>
|
322 |
+
|
323 |
+
<p><?php _e("To remove all visual interfaces from the ACF plugin, you can use a constant to enable lite mode. Add the following code to your functions.php file <b>before</b> the include_once code:",'acf'); ?></p>
|
324 |
+
|
325 |
+
<pre>
|
326 |
+
define( 'ACF_LITE', true );
|
327 |
+
</pre>
|
328 |
+
|
329 |
+
<p><br /></p>
|
330 |
+
|
331 |
+
<p><a href="">« <?php _e("Back to export",'acf'); ?></a></p>
|
332 |
+
</td>
|
333 |
+
<td>
|
334 |
+
<textarea class="pre" readonly="true"><?php
|
335 |
+
|
336 |
+
$acfs = array();
|
337 |
+
|
338 |
+
if( isset($_POST['acf_posts']) )
|
339 |
+
{
|
340 |
+
$acfs = get_posts(array(
|
341 |
+
'numberposts' => -1,
|
342 |
+
'post_type' => 'acf',
|
343 |
+
'orderby' => 'menu_order title',
|
344 |
+
'order' => 'asc',
|
345 |
+
'include' => $_POST['acf_posts'],
|
346 |
+
'suppress_filters' => false,
|
347 |
+
));
|
348 |
+
}
|
349 |
+
if( $acfs )
|
350 |
+
{
|
351 |
+
?>
|
352 |
+
if(function_exists("register_field_group"))
|
353 |
+
{
|
354 |
+
<?php
|
355 |
+
foreach( $acfs as $i => $acf )
|
356 |
+
{
|
357 |
+
// populate acfs
|
358 |
+
$var = array(
|
359 |
+
'id' => $acf->post_name,
|
360 |
+
'title' => $acf->post_title,
|
361 |
+
'fields' => apply_filters('acf/field_group/get_fields', array(), $acf->ID),
|
362 |
+
'location' => apply_filters('acf/field_group/get_location', array(), $acf->ID),
|
363 |
+
'options' => apply_filters('acf/field_group/get_options', array(), $acf->ID),
|
364 |
+
'menu_order' => $acf->menu_order,
|
365 |
+
);
|
366 |
+
|
367 |
+
|
368 |
+
$var['fields'] = apply_filters('acf/export/clean_fields', $var['fields']);
|
369 |
+
|
370 |
+
|
371 |
+
// create html
|
372 |
+
$html = var_export($var, true);
|
373 |
+
|
374 |
+
// change double spaces to tabs
|
375 |
+
$html = str_replace(" ", "\t", $html);
|
376 |
+
|
377 |
+
// correctly formats "=> array("
|
378 |
+
$html = preg_replace('/([\t\r\n]+?)array/', 'array', $html);
|
379 |
+
|
380 |
+
// Remove number keys from array
|
381 |
+
$html = preg_replace('/[0-9]+ => array/', 'array', $html);
|
382 |
+
|
383 |
+
// add extra tab at start of each line
|
384 |
+
$html = str_replace("\n", "\n\t", $html);
|
385 |
+
|
386 |
+
// add the WP __() function to specific strings for translation in theme
|
387 |
+
//$html = preg_replace("/'label'(.*?)('.*?')/", "'label'$1__($2)", $html);
|
388 |
+
//$html = preg_replace("/'instructions'(.*?)('.*?')/", "'instructions'$1__($2)", $html);
|
389 |
+
|
390 |
+
|
391 |
+
?> register_field_group(<?php echo $html ?>);
|
392 |
+
<?php
|
393 |
+
}
|
394 |
+
?>
|
395 |
+
}
|
396 |
+
<?php
|
397 |
+
}
|
398 |
+
else
|
399 |
+
{
|
400 |
+
_e("No field groups were selected",'acf');
|
401 |
+
}
|
402 |
+
?></textarea>
|
403 |
+
</td>
|
404 |
+
</tr>
|
405 |
+
</table>
|
406 |
+
</div>
|
407 |
+
<script type="text/javascript">
|
408 |
+
(function($){
|
409 |
+
|
410 |
+
var i = 0;
|
411 |
+
|
412 |
+
$(document).on('click', 'textarea.pre', function(){
|
413 |
+
|
414 |
+
if( i == 0 )
|
415 |
+
{
|
416 |
+
i++;
|
417 |
+
|
418 |
+
$(this).focus().select();
|
419 |
+
|
420 |
+
return false;
|
421 |
+
}
|
422 |
+
|
423 |
+
});
|
424 |
+
|
425 |
+
$(document).on('keyup', 'textarea.pre', function(){
|
426 |
+
|
427 |
+
$(this).height( 0 );
|
428 |
+
$(this).height( this.scrollHeight );
|
429 |
+
|
430 |
+
});
|
431 |
+
|
432 |
+
$(document).ready(function(){
|
433 |
+
|
434 |
+
$('textarea.pre').trigger('keyup');
|
435 |
+
|
436 |
+
});
|
437 |
+
|
438 |
+
})(jQuery);
|
439 |
+
</script>
|
440 |
+
<?php
|
441 |
+
}
|
442 |
+
|
443 |
+
|
444 |
+
/*
|
445 |
+
* clean_fields
|
446 |
+
*
|
447 |
+
* @description:
|
448 |
+
* @since: 3.5.7
|
449 |
+
* @created: 7/03/13
|
450 |
+
*/
|
451 |
+
|
452 |
+
function clean_fields( $fields )
|
453 |
+
{
|
454 |
+
// trim down the fields
|
455 |
+
if( $fields )
|
456 |
+
{
|
457 |
+
foreach( $fields as $i => $field )
|
458 |
+
{
|
459 |
+
// unset unneccessary bits
|
460 |
+
unset( $field['id'], $field['class'], $field['order_no'], $field['field_group'], $field['_name'] );
|
461 |
+
|
462 |
+
|
463 |
+
// instructions
|
464 |
+
if( !$field['instructions'] )
|
465 |
+
{
|
466 |
+
unset( $field['instructions'] );
|
467 |
+
}
|
468 |
+
|
469 |
+
|
470 |
+
// Required
|
471 |
+
if( !$field['required'] )
|
472 |
+
{
|
473 |
+
unset( $field['required'] );
|
474 |
+
}
|
475 |
+
|
476 |
+
|
477 |
+
// conditional logic
|
478 |
+
if( !$field['conditional_logic']['status'] )
|
479 |
+
{
|
480 |
+
unset( $field['conditional_logic'] );
|
481 |
+
}
|
482 |
+
|
483 |
+
|
484 |
+
// children
|
485 |
+
if( isset($field['sub_fields']) )
|
486 |
+
{
|
487 |
+
$field['sub_fields'] = apply_filters('acf/export/clean_fields', $field['sub_fields']);
|
488 |
+
}
|
489 |
+
elseif( isset($field['layouts']) )
|
490 |
+
{
|
491 |
+
foreach( $field['layouts'] as $l => $layout )
|
492 |
+
{
|
493 |
+
$field['layouts'][ $l ]['sub_fields'] = apply_filters('acf/export/clean_fields', $layout['sub_fields']);
|
494 |
+
}
|
495 |
+
}
|
496 |
+
|
497 |
+
|
498 |
+
// override field
|
499 |
+
$fields[ $i ] = $field;
|
500 |
+
}
|
501 |
+
}
|
502 |
+
|
503 |
+
return $fields;
|
504 |
+
}
|
505 |
+
}
|
506 |
+
|
507 |
+
new acf_export();
|
508 |
+
|
509 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/controllers/field_group.php
CHANGED
@@ -1,988 +1,988 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* acf_field_group
|
5 |
-
*
|
6 |
-
* @description: controller for editing a field group
|
7 |
-
* @since: 3.6
|
8 |
-
* @created: 25/01/13
|
9 |
-
*/
|
10 |
-
|
11 |
-
class acf_field_group
|
12 |
-
{
|
13 |
-
|
14 |
-
var $settings;
|
15 |
-
|
16 |
-
|
17 |
-
/*
|
18 |
-
* __construct
|
19 |
-
*
|
20 |
-
* @description:
|
21 |
-
* @since 3.1.8
|
22 |
-
* @created: 23/06/12
|
23 |
-
*/
|
24 |
-
|
25 |
-
function __construct()
|
26 |
-
{
|
27 |
-
// actions
|
28 |
-
add_action('admin_enqueue_scripts', array($this,'admin_enqueue_scripts'));
|
29 |
-
|
30 |
-
|
31 |
-
// filters
|
32 |
-
add_filter('acf/get_field_groups', array($this, 'get_field_groups'), 1, 1);
|
33 |
-
add_filter('acf/field_group/get_fields', array($this, 'get_fields'), 5, 2);
|
34 |
-
add_filter('acf/field_group/get_location', array($this, 'get_location'), 5, 2);
|
35 |
-
add_filter('acf/field_group/get_options', array($this, 'get_options'), 5, 2);
|
36 |
-
add_filter('acf/field_group/get_next_field_id', array($this, 'get_next_field_id'), 5, 1);
|
37 |
-
|
38 |
-
|
39 |
-
// save
|
40 |
-
add_filter('name_save_pre', array($this, 'name_save_pre'));
|
41 |
-
add_action('save_post', array($this, 'save_post'));
|
42 |
-
|
43 |
-
|
44 |
-
// ajax
|
45 |
-
add_action('wp_ajax_acf/field_group/render_options', array($this, 'ajax_render_options'));
|
46 |
-
add_action('wp_ajax_acf/field_group/render_location', array($this, 'ajax_render_location'));
|
47 |
-
|
48 |
-
}
|
49 |
-
|
50 |
-
|
51 |
-
/*
|
52 |
-
* get_field_groups
|
53 |
-
*
|
54 |
-
* @description:
|
55 |
-
* @since: 3.6
|
56 |
-
* @created: 27/01/13
|
57 |
-
*/
|
58 |
-
|
59 |
-
function get_field_groups( $array )
|
60 |
-
{
|
61 |
-
// cache
|
62 |
-
$found = false;
|
63 |
-
$cache = wp_cache_get( 'field_groups', 'acf', false, $found );
|
64 |
-
|
65 |
-
if( $found )
|
66 |
-
{
|
67 |
-
return $cache;
|
68 |
-
}
|
69 |
-
|
70 |
-
|
71 |
-
// get acf's
|
72 |
-
$posts = get_posts(array(
|
73 |
-
'numberposts' => -1,
|
74 |
-
'post_type' => 'acf',
|
75 |
-
'orderby' => 'menu_order title',
|
76 |
-
'order' => 'asc',
|
77 |
-
'suppress_filters' => false,
|
78 |
-
));
|
79 |
-
|
80 |
-
|
81 |
-
// populate acfs
|
82 |
-
if( $posts ){ foreach( $posts as $post ){
|
83 |
-
|
84 |
-
$array[] = array(
|
85 |
-
'id' => $post->ID,
|
86 |
-
'title' => $post->post_title,
|
87 |
-
'menu_order' => $post->menu_order,
|
88 |
-
);
|
89 |
-
|
90 |
-
}}
|
91 |
-
|
92 |
-
|
93 |
-
// set cache
|
94 |
-
wp_cache_set( 'field_groups', $array, 'acf' );
|
95 |
-
|
96 |
-
|
97 |
-
return $array;
|
98 |
-
}
|
99 |
-
|
100 |
-
|
101 |
-
/*
|
102 |
-
* get_fields
|
103 |
-
*
|
104 |
-
* @description: returns all fields for a field group
|
105 |
-
* @since: 3.6
|
106 |
-
* @created: 26/01/13
|
107 |
-
*/
|
108 |
-
|
109 |
-
function get_fields( $fields, $post_id )
|
110 |
-
{
|
111 |
-
// global
|
112 |
-
global $wpdb;
|
113 |
-
|
114 |
-
|
115 |
-
// loaded by PHP already?
|
116 |
-
if( !empty($fields) )
|
117 |
-
{
|
118 |
-
return $fields;
|
119 |
-
}
|
120 |
-
|
121 |
-
|
122 |
-
// get field from postmeta
|
123 |
-
$rows = $wpdb->get_results( $wpdb->prepare("SELECT meta_key FROM $wpdb->postmeta WHERE post_id = %d AND meta_key LIKE %s", $post_id, 'field_%'), ARRAY_A);
|
124 |
-
|
125 |
-
|
126 |
-
if( $rows )
|
127 |
-
{
|
128 |
-
foreach( $rows as $row )
|
129 |
-
{
|
130 |
-
$field = apply_filters('acf/load_field', false, $row['meta_key'], $post_id );
|
131 |
-
|
132 |
-
$fields[ $field['order_no'] ] = $field;
|
133 |
-
}
|
134 |
-
|
135 |
-
// sort
|
136 |
-
ksort( $fields );
|
137 |
-
}
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
// return
|
142 |
-
return $fields;
|
143 |
-
|
144 |
-
}
|
145 |
-
|
146 |
-
|
147 |
-
/*
|
148 |
-
* get_location
|
149 |
-
*
|
150 |
-
* @description:
|
151 |
-
* @since: 3.6
|
152 |
-
* @created: 26/01/13
|
153 |
-
*/
|
154 |
-
|
155 |
-
function get_location( $location, $post_id )
|
156 |
-
{
|
157 |
-
// loaded by PHP already?
|
158 |
-
if( !empty($location) )
|
159 |
-
{
|
160 |
-
return $location;
|
161 |
-
}
|
162 |
-
|
163 |
-
|
164 |
-
// vars
|
165 |
-
$groups = array();
|
166 |
-
$group_no = 0;
|
167 |
-
|
168 |
-
|
169 |
-
// get all rules
|
170 |
-
$rules = get_post_meta($post_id, 'rule', false);
|
171 |
-
|
172 |
-
|
173 |
-
if( is_array($rules) )
|
174 |
-
{
|
175 |
-
foreach( $rules as $rule )
|
176 |
-
{
|
177 |
-
// if field group was duplicated, it may now be a serialized string!
|
178 |
-
$rule = maybe_unserialize($rule);
|
179 |
-
|
180 |
-
|
181 |
-
// does this rule have a group?
|
182 |
-
// + groups were added in 4.0.4
|
183 |
-
if( !isset($rule['group_no']) )
|
184 |
-
{
|
185 |
-
$rule['group_no'] = $group_no;
|
186 |
-
|
187 |
-
// sperate groups?
|
188 |
-
if( get_post_meta($post_id, 'allorany', true) == 'any' )
|
189 |
-
{
|
190 |
-
$group_no++;
|
191 |
-
}
|
192 |
-
}
|
193 |
-
|
194 |
-
|
195 |
-
// add to group
|
196 |
-
$groups[ $rule['group_no'] ][ $rule['order_no'] ] = $rule;
|
197 |
-
|
198 |
-
|
199 |
-
// sort rules
|
200 |
-
ksort( $groups[ $rule['group_no'] ] );
|
201 |
-
|
202 |
-
}
|
203 |
-
|
204 |
-
// sort groups
|
205 |
-
ksort( $groups );
|
206 |
-
}
|
207 |
-
|
208 |
-
|
209 |
-
// return fields
|
210 |
-
return $groups;
|
211 |
-
}
|
212 |
-
|
213 |
-
|
214 |
-
/*
|
215 |
-
* get_options
|
216 |
-
*
|
217 |
-
* @description:
|
218 |
-
* @since: 3.6
|
219 |
-
* @created: 26/01/13
|
220 |
-
*/
|
221 |
-
|
222 |
-
function get_options( $options, $post_id )
|
223 |
-
{
|
224 |
-
// loaded by PHP already?
|
225 |
-
if( !empty($options) )
|
226 |
-
{
|
227 |
-
return $options;
|
228 |
-
}
|
229 |
-
|
230 |
-
|
231 |
-
// defaults
|
232 |
-
$options = array(
|
233 |
-
'position' => 'normal',
|
234 |
-
'layout' => 'no_box',
|
235 |
-
'hide_on_screen' => array(),
|
236 |
-
);
|
237 |
-
|
238 |
-
|
239 |
-
// vars
|
240 |
-
$position = get_post_meta($post_id, 'position', true);
|
241 |
-
if( $position )
|
242 |
-
{
|
243 |
-
$options['position'] = $position;
|
244 |
-
}
|
245 |
-
|
246 |
-
$layout = get_post_meta($post_id, 'layout', true);
|
247 |
-
if( $layout )
|
248 |
-
{
|
249 |
-
$options['layout'] = $layout;
|
250 |
-
}
|
251 |
-
|
252 |
-
$hide_on_screen = get_post_meta($post_id, 'hide_on_screen', true);
|
253 |
-
if( $hide_on_screen )
|
254 |
-
{
|
255 |
-
$hide_on_screen = maybe_unserialize($hide_on_screen);
|
256 |
-
$options['hide_on_screen'] = $hide_on_screen;
|
257 |
-
}
|
258 |
-
|
259 |
-
|
260 |
-
// return
|
261 |
-
return $options;
|
262 |
-
}
|
263 |
-
|
264 |
-
|
265 |
-
/*
|
266 |
-
* validate_page
|
267 |
-
*
|
268 |
-
* @description:
|
269 |
-
* @since 3.2.6
|
270 |
-
* @created: 23/06/12
|
271 |
-
*/
|
272 |
-
|
273 |
-
function validate_page()
|
274 |
-
{
|
275 |
-
// global
|
276 |
-
global $pagenow, $typenow;
|
277 |
-
|
278 |
-
|
279 |
-
// vars
|
280 |
-
$return = false;
|
281 |
-
|
282 |
-
|
283 |
-
// validate page
|
284 |
-
if( in_array( $pagenow, array('post.php', 'post-new.php') ) )
|
285 |
-
{
|
286 |
-
|
287 |
-
// validate post type
|
288 |
-
if( $typenow == "acf" )
|
289 |
-
{
|
290 |
-
$return = true;
|
291 |
-
}
|
292 |
-
|
293 |
-
}
|
294 |
-
|
295 |
-
|
296 |
-
// return
|
297 |
-
return $return;
|
298 |
-
}
|
299 |
-
|
300 |
-
|
301 |
-
/*
|
302 |
-
* admin_enqueue_scripts
|
303 |
-
*
|
304 |
-
* @description: run after post query but before any admin script / head actions. A good place to register all actions.
|
305 |
-
* @since: 3.6
|
306 |
-
* @created: 26/01/13
|
307 |
-
*/
|
308 |
-
|
309 |
-
function admin_enqueue_scripts()
|
310 |
-
{
|
311 |
-
// validate page
|
312 |
-
if( ! $this->validate_page() ){ return; }
|
313 |
-
|
314 |
-
|
315 |
-
// settings
|
316 |
-
$this->settings = apply_filters('acf/get_info', 'all');
|
317 |
-
|
318 |
-
|
319 |
-
// no autosave
|
320 |
-
wp_dequeue_script( 'autosave' );
|
321 |
-
|
322 |
-
|
323 |
-
// custom scripts
|
324 |
-
wp_enqueue_script(array(
|
325 |
-
'acf-field-group',
|
326 |
-
));
|
327 |
-
|
328 |
-
|
329 |
-
// custom styles
|
330 |
-
wp_enqueue_style(array(
|
331 |
-
'acf-global',
|
332 |
-
'acf-field-group',
|
333 |
-
));
|
334 |
-
|
335 |
-
|
336 |
-
// actions
|
337 |
-
do_action('acf/field_group/admin_enqueue_scripts');
|
338 |
-
add_action('admin_head', array($this,'admin_head'));
|
339 |
-
|
340 |
-
}
|
341 |
-
|
342 |
-
|
343 |
-
/*
|
344 |
-
* admin_head
|
345 |
-
*
|
346 |
-
* @description:
|
347 |
-
* @since 3.1.8
|
348 |
-
* @created: 23/06/12
|
349 |
-
*/
|
350 |
-
|
351 |
-
function admin_head()
|
352 |
-
{
|
353 |
-
// global
|
354 |
-
global $wp_version, $post;
|
355 |
-
|
356 |
-
|
357 |
-
// l10n
|
358 |
-
$l10n = array(
|
359 |
-
'move_to_trash' => __("Move to trash. Are you sure?",'acf'),
|
360 |
-
'checked' => __("checked",'acf'),
|
361 |
-
'no_fields' => __("No toggle fields available",'acf'),
|
362 |
-
'title' => __("Field group title is required",'acf'),
|
363 |
-
'copy' => __("copy",'acf'),
|
364 |
-
'or' => __("or",'acf'),
|
365 |
-
'fields' => __("Fields",'acf'),
|
366 |
-
'parent_fields' => __("Parent fields",'acf'),
|
367 |
-
'sibling_fields' => __("Sibling fields",'acf'),
|
368 |
-
'hide_show_all' => __("Hide / Show All",'acf')
|
369 |
-
);
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
?>
|
374 |
-
<script type="text/javascript">
|
375 |
-
(function($) {
|
376 |
-
|
377 |
-
// vars
|
378 |
-
acf.post_id = <?php echo $post->ID; ?>;
|
379 |
-
acf.nonce = "<?php echo wp_create_nonce( 'acf_nonce' ); ?>";
|
380 |
-
acf.admin_url = "<?php echo admin_url(); ?>";
|
381 |
-
acf.ajaxurl = "<?php echo admin_url( 'admin-ajax.php' ); ?>";
|
382 |
-
acf.wp_version = "<?php echo $wp_version; ?>";
|
383 |
-
|
384 |
-
|
385 |
-
// l10n
|
386 |
-
acf.l10n = <?php echo json_encode( $l10n ); ?>;
|
387 |
-
|
388 |
-
})(jQuery);
|
389 |
-
</script>
|
390 |
-
<?php
|
391 |
-
|
392 |
-
// new action
|
393 |
-
do_action('acf/field_group/admin_head');
|
394 |
-
|
395 |
-
|
396 |
-
// add metaboxes
|
397 |
-
add_meta_box('acf_fields', __("Fields",'acf'), array($this, 'html_fields'), 'acf', 'normal', 'high');
|
398 |
-
add_meta_box('acf_location', __("Location",'acf'), array($this, 'html_location'), 'acf', 'normal', 'high');
|
399 |
-
add_meta_box('acf_options', __("Options",'acf'), array($this, 'html_options'), 'acf', 'normal', 'high');
|
400 |
-
|
401 |
-
|
402 |
-
// add screen settings
|
403 |
-
add_filter('screen_settings', array($this, 'screen_settings'), 10, 1);
|
404 |
-
}
|
405 |
-
|
406 |
-
|
407 |
-
/*
|
408 |
-
* html_fields
|
409 |
-
*
|
410 |
-
* @description:
|
411 |
-
* @since 1.0.0
|
412 |
-
* @created: 23/06/12
|
413 |
-
*/
|
414 |
-
|
415 |
-
function html_fields()
|
416 |
-
{
|
417 |
-
include( $this->settings['path'] . 'core/views/meta_box_fields.php' );
|
418 |
-
}
|
419 |
-
|
420 |
-
|
421 |
-
/*
|
422 |
-
* html_location
|
423 |
-
*
|
424 |
-
* @description:
|
425 |
-
* @since 1.0.0
|
426 |
-
* @created: 23/06/12
|
427 |
-
*/
|
428 |
-
|
429 |
-
function html_location()
|
430 |
-
{
|
431 |
-
include( $this->settings['path'] . 'core/views/meta_box_location.php' );
|
432 |
-
}
|
433 |
-
|
434 |
-
|
435 |
-
/*
|
436 |
-
* html_options
|
437 |
-
*
|
438 |
-
* @description:
|
439 |
-
* @since 1.0.0
|
440 |
-
* @created: 23/06/12
|
441 |
-
*/
|
442 |
-
|
443 |
-
function html_options()
|
444 |
-
{
|
445 |
-
include( $this->settings['path'] . 'core/views/meta_box_options.php' );
|
446 |
-
}
|
447 |
-
|
448 |
-
|
449 |
-
/*
|
450 |
-
* screen_settings
|
451 |
-
*
|
452 |
-
* @description:
|
453 |
-
* @since: 3.6
|
454 |
-
* @created: 26/01/13
|
455 |
-
*/
|
456 |
-
|
457 |
-
function screen_settings( $current )
|
458 |
-
{
|
459 |
-
$current .= '<h5>' . __("Fields",'acf') . '</h5>';
|
460 |
-
|
461 |
-
$current .= '<div class="show-field_key">' . __("Show Field Key:",'acf');
|
462 |
-
$current .= '<label class="show-field_key-no"><input checked="checked" type="radio" value="0" name="show-field_key" />' . __("No",'acf') . '</label>';
|
463 |
-
$current .= '<label class="show-field_key-yes"><input type="radio" value="1" name="show-field_key" />' . __("Yes",'acf') . '</label>';
|
464 |
-
$current .= '</div>';
|
465 |
-
|
466 |
-
return $current;
|
467 |
-
}
|
468 |
-
|
469 |
-
|
470 |
-
/*
|
471 |
-
* ajax_render_options
|
472 |
-
*
|
473 |
-
* @description: creates the HTML for a field's options (field group edit page)
|
474 |
-
* @since 3.1.6
|
475 |
-
* @created: 23/06/12
|
476 |
-
*/
|
477 |
-
|
478 |
-
function ajax_render_options()
|
479 |
-
{
|
480 |
-
// vars
|
481 |
-
$options = array(
|
482 |
-
'field_key' => '',
|
483 |
-
'field_type' => '',
|
484 |
-
'post_id' => 0,
|
485 |
-
'nonce' => ''
|
486 |
-
);
|
487 |
-
|
488 |
-
// load post options
|
489 |
-
$options = array_merge($options, $_POST);
|
490 |
-
|
491 |
-
|
492 |
-
// verify nonce
|
493 |
-
if( ! wp_verify_nonce($options['nonce'], 'acf_nonce') )
|
494 |
-
{
|
495 |
-
die(0);
|
496 |
-
}
|
497 |
-
|
498 |
-
|
499 |
-
// required
|
500 |
-
if( ! $options['field_type'] )
|
501 |
-
{
|
502 |
-
die(0);
|
503 |
-
}
|
504 |
-
|
505 |
-
|
506 |
-
// find key (not actual field key, more the html attr name)
|
507 |
-
$options['field_key'] = str_replace("fields[", "", $options['field_key']);
|
508 |
-
$options['field_key'] = str_replace("][type]", "", $options['field_key']) ;
|
509 |
-
|
510 |
-
|
511 |
-
// render options
|
512 |
-
$field = array(
|
513 |
-
'type' => $options['field_type'],
|
514 |
-
'name' => $options['field_key']
|
515 |
-
);
|
516 |
-
do_action('acf/create_field_options', $field );
|
517 |
-
|
518 |
-
|
519 |
-
die();
|
520 |
-
|
521 |
-
}
|
522 |
-
|
523 |
-
|
524 |
-
/*
|
525 |
-
* ajax_render_location
|
526 |
-
*
|
527 |
-
* @description: creates the HTML for the field group location metabox. Called from both Ajax and PHP
|
528 |
-
* @since 3.1.6
|
529 |
-
* @created: 23/06/12
|
530 |
-
*/
|
531 |
-
|
532 |
-
function ajax_render_location( $options = array() )
|
533 |
-
{
|
534 |
-
// defaults
|
535 |
-
$defaults = array(
|
536 |
-
'group_id' => 0,
|
537 |
-
'rule_id' => 0,
|
538 |
-
'value' => null,
|
539 |
-
'param' => null,
|
540 |
-
);
|
541 |
-
|
542 |
-
$is_ajax = false;
|
543 |
-
if( isset($_POST['nonce']) && wp_verify_nonce($_POST['nonce'], 'acf_nonce') )
|
544 |
-
{
|
545 |
-
$is_ajax = true;
|
546 |
-
}
|
547 |
-
|
548 |
-
|
549 |
-
// Is AJAX call?
|
550 |
-
if( $is_ajax )
|
551 |
-
{
|
552 |
-
$options = array_merge($defaults, $_POST);
|
553 |
-
}
|
554 |
-
else
|
555 |
-
{
|
556 |
-
$options = array_merge($defaults, $options);
|
557 |
-
}
|
558 |
-
|
559 |
-
// vars
|
560 |
-
$choices = array();
|
561 |
-
|
562 |
-
|
563 |
-
// some case's have the same outcome
|
564 |
-
if($options['param'] == "page_parent")
|
565 |
-
{
|
566 |
-
$options['param'] = "page";
|
567 |
-
}
|
568 |
-
|
569 |
-
|
570 |
-
switch($options['param'])
|
571 |
-
{
|
572 |
-
case "post_type":
|
573 |
-
|
574 |
-
// all post types except attachment
|
575 |
-
$choices = apply_filters('acf/get_post_types', array(), array('attachment'));
|
576 |
-
|
577 |
-
break;
|
578 |
-
|
579 |
-
|
580 |
-
case "page":
|
581 |
-
|
582 |
-
$post_type = 'page';
|
583 |
-
$posts = get_posts(array(
|
584 |
-
'posts_per_page' => -1,
|
585 |
-
'post_type' => $post_type,
|
586 |
-
'orderby' => 'menu_order title',
|
587 |
-
'order' => 'ASC',
|
588 |
-
'post_status' => 'any',
|
589 |
-
'suppress_filters' => false,
|
590 |
-
'update_post_meta_cache' => false,
|
591 |
-
));
|
592 |
-
|
593 |
-
if( $posts )
|
594 |
-
{
|
595 |
-
// sort into hierachial order!
|
596 |
-
if( is_post_type_hierarchical( $post_type ) )
|
597 |
-
{
|
598 |
-
$posts = get_page_children( 0, $posts );
|
599 |
-
}
|
600 |
-
|
601 |
-
foreach( $posts as $page )
|
602 |
-
{
|
603 |
-
$title = '';
|
604 |
-
$ancestors = get_ancestors($page->ID, 'page');
|
605 |
-
if($ancestors)
|
606 |
-
{
|
607 |
-
foreach($ancestors as $a)
|
608 |
-
{
|
609 |
-
$title .= '- ';
|
610 |
-
}
|
611 |
-
}
|
612 |
-
|
613 |
-
$title .= apply_filters( 'the_title', $page->post_title, $page->ID );
|
614 |
-
|
615 |
-
|
616 |
-
// status
|
617 |
-
if($page->post_status != "publish")
|
618 |
-
{
|
619 |
-
$title .= " ($page->post_status)";
|
620 |
-
}
|
621 |
-
|
622 |
-
$choices[ $page->ID ] = $title;
|
623 |
-
|
624 |
-
}
|
625 |
-
// foreach($pages as $page)
|
626 |
-
|
627 |
-
}
|
628 |
-
|
629 |
-
break;
|
630 |
-
|
631 |
-
|
632 |
-
case "page_type" :
|
633 |
-
|
634 |
-
$choices = array(
|
635 |
-
'front_page' => __("Front Page",'acf'),
|
636 |
-
'posts_page' => __("Posts Page",'acf'),
|
637 |
-
'top_level' => __("Top Level Page (parent of 0)",'acf'),
|
638 |
-
'parent' => __("Parent Page (has children)",'acf'),
|
639 |
-
'child' => __("Child Page (has parent)",'acf'),
|
640 |
-
);
|
641 |
-
|
642 |
-
break;
|
643 |
-
|
644 |
-
case "page_template" :
|
645 |
-
|
646 |
-
$choices = array(
|
647 |
-
'default' => __("Default Template",'acf'),
|
648 |
-
);
|
649 |
-
|
650 |
-
$templates = get_page_templates();
|
651 |
-
foreach($templates as $k => $v)
|
652 |
-
{
|
653 |
-
$choices[$v] = $k;
|
654 |
-
}
|
655 |
-
|
656 |
-
break;
|
657 |
-
|
658 |
-
case "post" :
|
659 |
-
|
660 |
-
$post_types = get_post_types();
|
661 |
-
|
662 |
-
unset( $post_types['page'], $post_types['attachment'], $post_types['revision'] , $post_types['nav_menu_item'], $post_types['acf'] );
|
663 |
-
|
664 |
-
if( $post_types )
|
665 |
-
{
|
666 |
-
foreach( $post_types as $post_type )
|
667 |
-
{
|
668 |
-
|
669 |
-
$posts = get_posts(array(
|
670 |
-
'numberposts' => '-1',
|
671 |
-
'post_type' => $post_type,
|
672 |
-
'post_status' => array('publish', 'private', 'draft', 'inherit', 'future'),
|
673 |
-
'suppress_filters' => false,
|
674 |
-
));
|
675 |
-
|
676 |
-
if( $posts)
|
677 |
-
{
|
678 |
-
$choices[$post_type] = array();
|
679 |
-
|
680 |
-
foreach($posts as $post)
|
681 |
-
{
|
682 |
-
$title = apply_filters( 'the_title', $post->post_title, $post->ID );
|
683 |
-
|
684 |
-
// status
|
685 |
-
if($post->post_status != "publish")
|
686 |
-
{
|
687 |
-
$title .= " ($post->post_status)";
|
688 |
-
}
|
689 |
-
|
690 |
-
$choices[$post_type][$post->ID] = $title;
|
691 |
-
|
692 |
-
}
|
693 |
-
// foreach($posts as $post)
|
694 |
-
}
|
695 |
-
// if( $posts )
|
696 |
-
}
|
697 |
-
// foreach( $post_types as $post_type )
|
698 |
-
}
|
699 |
-
// if( $post_types )
|
700 |
-
|
701 |
-
|
702 |
-
break;
|
703 |
-
|
704 |
-
case "post_category" :
|
705 |
-
|
706 |
-
$terms = get_terms( 'category', array( 'hide_empty' => false ) );
|
707 |
-
|
708 |
-
if( !empty($terms) ) {
|
709 |
-
|
710 |
-
foreach( $terms as $term ) {
|
711 |
-
|
712 |
-
$choices[ $term->term_id ] = $term->name;
|
713 |
-
|
714 |
-
}
|
715 |
-
|
716 |
-
}
|
717 |
-
|
718 |
-
break;
|
719 |
-
|
720 |
-
case "post_format" :
|
721 |
-
|
722 |
-
$choices = get_post_format_strings();
|
723 |
-
|
724 |
-
break;
|
725 |
-
|
726 |
-
case "post_status" :
|
727 |
-
|
728 |
-
$choices = array(
|
729 |
-
'publish' => __( 'Published', 'acf'),
|
730 |
-
'pending' => __( 'Pending Review', 'acf'),
|
731 |
-
'draft' => __( 'Draft', 'acf'),
|
732 |
-
'future' => __( 'Future', 'acf'),
|
733 |
-
'private' => __( 'Private', 'acf'),
|
734 |
-
'inherit' => __( 'Revision', 'acf'),
|
735 |
-
'trash' => __( 'Trash', 'acf'),
|
736 |
-
);
|
737 |
-
|
738 |
-
break;
|
739 |
-
|
740 |
-
case "user_type" :
|
741 |
-
|
742 |
-
global $wp_roles;
|
743 |
-
|
744 |
-
$choices = $wp_roles->get_names();
|
745 |
-
|
746 |
-
if( is_multisite() )
|
747 |
-
{
|
748 |
-
$choices['super_admin'] = __('Super Admin', 'acf');
|
749 |
-
}
|
750 |
-
|
751 |
-
break;
|
752 |
-
|
753 |
-
case "taxonomy" :
|
754 |
-
|
755 |
-
$choices = array();
|
756 |
-
$simple_value = true;
|
757 |
-
$choices = apply_filters('acf/get_taxonomies_for_select', $choices, $simple_value);
|
758 |
-
|
759 |
-
break;
|
760 |
-
|
761 |
-
case "ef_taxonomy" :
|
762 |
-
|
763 |
-
$choices = array('all' => __('All', 'acf'));
|
764 |
-
$taxonomies = get_taxonomies( array('public' => true), 'objects' );
|
765 |
-
|
766 |
-
foreach($taxonomies as $taxonomy)
|
767 |
-
{
|
768 |
-
$choices[ $taxonomy->name ] = $taxonomy->labels->name;
|
769 |
-
}
|
770 |
-
|
771 |
-
// unset post_format (why is this a public taxonomy?)
|
772 |
-
if( isset($choices['post_format']) )
|
773 |
-
{
|
774 |
-
unset( $choices['post_format']) ;
|
775 |
-
}
|
776 |
-
|
777 |
-
|
778 |
-
break;
|
779 |
-
|
780 |
-
case "ef_user" :
|
781 |
-
|
782 |
-
global $wp_roles;
|
783 |
-
|
784 |
-
$choices = array_merge( array('all' => __('All', 'acf')), $wp_roles->get_names() );
|
785 |
-
|
786 |
-
break;
|
787 |
-
|
788 |
-
|
789 |
-
case "ef_media" :
|
790 |
-
|
791 |
-
$choices = array('all' => __('All', 'acf'));
|
792 |
-
|
793 |
-
break;
|
794 |
-
|
795 |
-
}
|
796 |
-
|
797 |
-
|
798 |
-
// allow custom location rules
|
799 |
-
$choices = apply_filters( 'acf/location/rule_values/' . $options['param'], $choices );
|
800 |
-
|
801 |
-
|
802 |
-
// create field
|
803 |
-
do_action('acf/create_field', array(
|
804 |
-
'type' => 'select',
|
805 |
-
'name' => 'location[' . $options['group_id'] . '][' . $options['rule_id'] . '][value]',
|
806 |
-
'value' => $options['value'],
|
807 |
-
'choices' => $choices,
|
808 |
-
));
|
809 |
-
|
810 |
-
|
811 |
-
// ajax?
|
812 |
-
if( $is_ajax )
|
813 |
-
{
|
814 |
-
die();
|
815 |
-
}
|
816 |
-
|
817 |
-
}
|
818 |
-
|
819 |
-
|
820 |
-
/*
|
821 |
-
* name_save_pre
|
822 |
-
*
|
823 |
-
* @description: intercepts the acf post obejct and adds an "acf_" to the start of
|
824 |
-
* it's name to stop conflicts between acf's and page's urls
|
825 |
-
* @since 1.0.0
|
826 |
-
* @created: 23/06/12
|
827 |
-
*/
|
828 |
-
|
829 |
-
function name_save_pre($name)
|
830 |
-
{
|
831 |
-
// validate
|
832 |
-
if( !isset($_POST['post_type']) || $_POST['post_type'] != 'acf' )
|
833 |
-
{
|
834 |
-
return $name;
|
835 |
-
}
|
836 |
-
|
837 |
-
|
838 |
-
// need a title
|
839 |
-
if( !$_POST['post_title'] )
|
840 |
-
{
|
841 |
-
$_POST['post_title'] = 'Unnamed Field Group';
|
842 |
-
}
|
843 |
-
|
844 |
-
|
845 |
-
$name = 'acf_' . sanitize_title($_POST['post_title']);
|
846 |
-
|
847 |
-
|
848 |
-
return $name;
|
849 |
-
}
|
850 |
-
|
851 |
-
|
852 |
-
/*
|
853 |
-
* save_post
|
854 |
-
*
|
855 |
-
* @description: Saves the field / location / option data for a field group
|
856 |
-
* @since 1.0.0
|
857 |
-
* @created: 23/06/12
|
858 |
-
*/
|
859 |
-
|
860 |
-
function save_post($post_id)
|
861 |
-
{
|
862 |
-
// do not save if this is an auto save routine
|
863 |
-
if( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
|
864 |
-
{
|
865 |
-
return $post_id;
|
866 |
-
}
|
867 |
-
|
868 |
-
|
869 |
-
// verify nonce
|
870 |
-
if( !isset($_POST['acf_nonce']) || !wp_verify_nonce($_POST['acf_nonce'], 'field_group') )
|
871 |
-
{
|
872 |
-
return $post_id;
|
873 |
-
}
|
874 |
-
|
875 |
-
|
876 |
-
// only save once! WordPress save's a revision as well.
|
877 |
-
if( wp_is_post_revision($post_id) )
|
878 |
-
{
|
879 |
-
return $post_id;
|
880 |
-
}
|
881 |
-
|
882 |
-
|
883 |
-
/*
|
884 |
-
* save fields
|
885 |
-
*/
|
886 |
-
|
887 |
-
// vars
|
888 |
-
$dont_delete = array();
|
889 |
-
|
890 |
-
if( isset($_POST['fields']) && is_array($_POST['fields']) )
|
891 |
-
{
|
892 |
-
$i = -1;
|
893 |
-
|
894 |
-
|
895 |
-
// remove clone field
|
896 |
-
unset( $_POST['fields']['field_clone'] );
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
// loop through and save fields
|
901 |
-
foreach( $_POST['fields'] as $key => $field )
|
902 |
-
{
|
903 |
-
$i++;
|
904 |
-
|
905 |
-
|
906 |
-
// order + key
|
907 |
-
$field['order_no'] = $i;
|
908 |
-
$field['key'] = $key;
|
909 |
-
|
910 |
-
|
911 |
-
// save
|
912 |
-
do_action('acf/update_field', $field, $post_id );
|
913 |
-
|
914 |
-
|
915 |
-
// add to dont delete array
|
916 |
-
$dont_delete[] = $field['key'];
|
917 |
-
}
|
918 |
-
}
|
919 |
-
unset( $_POST['fields'] );
|
920 |
-
|
921 |
-
|
922 |
-
// delete all other field
|
923 |
-
$keys = get_post_custom_keys($post_id);
|
924 |
-
foreach( $keys as $key )
|
925 |
-
{
|
926 |
-
if( strpos($key, 'field_') !== false && !in_array($key, $dont_delete) )
|
927 |
-
{
|
928 |
-
// this is a field, and it wasn't found in the dont_delete array
|
929 |
-
do_action('acf/delete_field', $post_id, $key);
|
930 |
-
}
|
931 |
-
}
|
932 |
-
|
933 |
-
|
934 |
-
/*
|
935 |
-
* save location rules
|
936 |
-
*/
|
937 |
-
|
938 |
-
if( isset($_POST['location']) && is_array($_POST['location']) )
|
939 |
-
{
|
940 |
-
delete_post_meta( $post_id, 'rule' );
|
941 |
-
|
942 |
-
|
943 |
-
// clean array keys
|
944 |
-
$_POST['location'] = array_values( $_POST['location'] );
|
945 |
-
foreach( $_POST['location'] as $group_id => $group )
|
946 |
-
{
|
947 |
-
if( is_array($group) )
|
948 |
-
{
|
949 |
-
// clean array keys
|
950 |
-
$group = array_values( $group );
|
951 |
-
foreach( $group as $rule_id => $rule )
|
952 |
-
{
|
953 |
-
$rule['order_no'] = $rule_id;
|
954 |
-
$rule['group_no'] = $group_id;
|
955 |
-
|
956 |
-
|
957 |
-
add_post_meta( $post_id, 'rule', $rule );
|
958 |
-
}
|
959 |
-
}
|
960 |
-
}
|
961 |
-
|
962 |
-
unset( $_POST['location'] );
|
963 |
-
}
|
964 |
-
|
965 |
-
|
966 |
-
/*
|
967 |
-
* save options
|
968 |
-
*/
|
969 |
-
|
970 |
-
if( isset($_POST['options']) && is_array($_POST['options']) )
|
971 |
-
{
|
972 |
-
update_post_meta($post_id, 'position', $_POST['options']['position']);
|
973 |
-
update_post_meta($post_id, 'layout', $_POST['options']['layout']);
|
974 |
-
update_post_meta($post_id, 'hide_on_screen', $_POST['options']['hide_on_screen']);
|
975 |
-
}
|
976 |
-
|
977 |
-
|
978 |
-
unset( $_POST['options'] );
|
979 |
-
|
980 |
-
|
981 |
-
}
|
982 |
-
|
983 |
-
|
984 |
-
}
|
985 |
-
|
986 |
-
new acf_field_group();
|
987 |
-
|
988 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* acf_field_group
|
5 |
+
*
|
6 |
+
* @description: controller for editing a field group
|
7 |
+
* @since: 3.6
|
8 |
+
* @created: 25/01/13
|
9 |
+
*/
|
10 |
+
|
11 |
+
class acf_field_group
|
12 |
+
{
|
13 |
+
|
14 |
+
var $settings;
|
15 |
+
|
16 |
+
|
17 |
+
/*
|
18 |
+
* __construct
|
19 |
+
*
|
20 |
+
* @description:
|
21 |
+
* @since 3.1.8
|
22 |
+
* @created: 23/06/12
|
23 |
+
*/
|
24 |
+
|
25 |
+
function __construct()
|
26 |
+
{
|
27 |
+
// actions
|
28 |
+
add_action('admin_enqueue_scripts', array($this,'admin_enqueue_scripts'));
|
29 |
+
|
30 |
+
|
31 |
+
// filters
|
32 |
+
add_filter('acf/get_field_groups', array($this, 'get_field_groups'), 1, 1);
|
33 |
+
add_filter('acf/field_group/get_fields', array($this, 'get_fields'), 5, 2);
|
34 |
+
add_filter('acf/field_group/get_location', array($this, 'get_location'), 5, 2);
|
35 |
+
add_filter('acf/field_group/get_options', array($this, 'get_options'), 5, 2);
|
36 |
+
add_filter('acf/field_group/get_next_field_id', array($this, 'get_next_field_id'), 5, 1);
|
37 |
+
|
38 |
+
|
39 |
+
// save
|
40 |
+
add_filter('name_save_pre', array($this, 'name_save_pre'));
|
41 |
+
add_action('save_post', array($this, 'save_post'));
|
42 |
+
|
43 |
+
|
44 |
+
// ajax
|
45 |
+
add_action('wp_ajax_acf/field_group/render_options', array($this, 'ajax_render_options'));
|
46 |
+
add_action('wp_ajax_acf/field_group/render_location', array($this, 'ajax_render_location'));
|
47 |
+
|
48 |
+
}
|
49 |
+
|
50 |
+
|
51 |
+
/*
|
52 |
+
* get_field_groups
|
53 |
+
*
|
54 |
+
* @description:
|
55 |
+
* @since: 3.6
|
56 |
+
* @created: 27/01/13
|
57 |
+
*/
|
58 |
+
|
59 |
+
function get_field_groups( $array )
|
60 |
+
{
|
61 |
+
// cache
|
62 |
+
$found = false;
|
63 |
+
$cache = wp_cache_get( 'field_groups', 'acf', false, $found );
|
64 |
+
|
65 |
+
if( $found )
|
66 |
+
{
|
67 |
+
return $cache;
|
68 |
+
}
|
69 |
+
|
70 |
+
|
71 |
+
// get acf's
|
72 |
+
$posts = get_posts(array(
|
73 |
+
'numberposts' => -1,
|
74 |
+
'post_type' => 'acf',
|
75 |
+
'orderby' => 'menu_order title',
|
76 |
+
'order' => 'asc',
|
77 |
+
'suppress_filters' => false,
|
78 |
+
));
|
79 |
+
|
80 |
+
|
81 |
+
// populate acfs
|
82 |
+
if( $posts ){ foreach( $posts as $post ){
|
83 |
+
|
84 |
+
$array[] = array(
|
85 |
+
'id' => $post->ID,
|
86 |
+
'title' => $post->post_title,
|
87 |
+
'menu_order' => $post->menu_order,
|
88 |
+
);
|
89 |
+
|
90 |
+
}}
|
91 |
+
|
92 |
+
|
93 |
+
// set cache
|
94 |
+
wp_cache_set( 'field_groups', $array, 'acf' );
|
95 |
+
|
96 |
+
|
97 |
+
return $array;
|
98 |
+
}
|
99 |
+
|
100 |
+
|
101 |
+
/*
|
102 |
+
* get_fields
|
103 |
+
*
|
104 |
+
* @description: returns all fields for a field group
|
105 |
+
* @since: 3.6
|
106 |
+
* @created: 26/01/13
|
107 |
+
*/
|
108 |
+
|
109 |
+
function get_fields( $fields, $post_id )
|
110 |
+
{
|
111 |
+
// global
|
112 |
+
global $wpdb;
|
113 |
+
|
114 |
+
|
115 |
+
// loaded by PHP already?
|
116 |
+
if( !empty($fields) )
|
117 |
+
{
|
118 |
+
return $fields;
|
119 |
+
}
|
120 |
+
|
121 |
+
|
122 |
+
// get field from postmeta
|
123 |
+
$rows = $wpdb->get_results( $wpdb->prepare("SELECT meta_key FROM $wpdb->postmeta WHERE post_id = %d AND meta_key LIKE %s", $post_id, 'field_%'), ARRAY_A);
|
124 |
+
|
125 |
+
|
126 |
+
if( $rows )
|
127 |
+
{
|
128 |
+
foreach( $rows as $row )
|
129 |
+
{
|
130 |
+
$field = apply_filters('acf/load_field', false, $row['meta_key'], $post_id );
|
131 |
+
|
132 |
+
$fields[ $field['order_no'] ] = $field;
|
133 |
+
}
|
134 |
+
|
135 |
+
// sort
|
136 |
+
ksort( $fields );
|
137 |
+
}
|
138 |
+
|
139 |
+
|
140 |
+
|
141 |
+
// return
|
142 |
+
return $fields;
|
143 |
+
|
144 |
+
}
|
145 |
+
|
146 |
+
|
147 |
+
/*
|
148 |
+
* get_location
|
149 |
+
*
|
150 |
+
* @description:
|
151 |
+
* @since: 3.6
|
152 |
+
* @created: 26/01/13
|
153 |
+
*/
|
154 |
+
|
155 |
+
function get_location( $location, $post_id )
|
156 |
+
{
|
157 |
+
// loaded by PHP already?
|
158 |
+
if( !empty($location) )
|
159 |
+
{
|
160 |
+
return $location;
|
161 |
+
}
|
162 |
+
|
163 |
+
|
164 |
+
// vars
|
165 |
+
$groups = array();
|
166 |
+
$group_no = 0;
|
167 |
+
|
168 |
+
|
169 |
+
// get all rules
|
170 |
+
$rules = get_post_meta($post_id, 'rule', false);
|
171 |
+
|
172 |
+
|
173 |
+
if( is_array($rules) )
|
174 |
+
{
|
175 |
+
foreach( $rules as $rule )
|
176 |
+
{
|
177 |
+
// if field group was duplicated, it may now be a serialized string!
|
178 |
+
$rule = maybe_unserialize($rule);
|
179 |
+
|
180 |
+
|
181 |
+
// does this rule have a group?
|
182 |
+
// + groups were added in 4.0.4
|
183 |
+
if( !isset($rule['group_no']) )
|
184 |
+
{
|
185 |
+
$rule['group_no'] = $group_no;
|
186 |
+
|
187 |
+
// sperate groups?
|
188 |
+
if( get_post_meta($post_id, 'allorany', true) == 'any' )
|
189 |
+
{
|
190 |
+
$group_no++;
|
191 |
+
}
|
192 |
+
}
|
193 |
+
|
194 |
+
|
195 |
+
// add to group
|
196 |
+
$groups[ $rule['group_no'] ][ $rule['order_no'] ] = $rule;
|
197 |
+
|
198 |
+
|
199 |
+
// sort rules
|
200 |
+
ksort( $groups[ $rule['group_no'] ] );
|
201 |
+
|
202 |
+
}
|
203 |
+
|
204 |
+
// sort groups
|
205 |
+
ksort( $groups );
|
206 |
+
}
|
207 |
+
|
208 |
+
|
209 |
+
// return fields
|
210 |
+
return $groups;
|
211 |
+
}
|
212 |
+
|
213 |
+
|
214 |
+
/*
|
215 |
+
* get_options
|
216 |
+
*
|
217 |
+
* @description:
|
218 |
+
* @since: 3.6
|
219 |
+
* @created: 26/01/13
|
220 |
+
*/
|
221 |
+
|
222 |
+
function get_options( $options, $post_id )
|
223 |
+
{
|
224 |
+
// loaded by PHP already?
|
225 |
+
if( !empty($options) )
|
226 |
+
{
|
227 |
+
return $options;
|
228 |
+
}
|
229 |
+
|
230 |
+
|
231 |
+
// defaults
|
232 |
+
$options = array(
|
233 |
+
'position' => 'normal',
|
234 |
+
'layout' => 'no_box',
|
235 |
+
'hide_on_screen' => array(),
|
236 |
+
);
|
237 |
+
|
238 |
+
|
239 |
+
// vars
|
240 |
+
$position = get_post_meta($post_id, 'position', true);
|
241 |
+
if( $position )
|
242 |
+
{
|
243 |
+
$options['position'] = $position;
|
244 |
+
}
|
245 |
+
|
246 |
+
$layout = get_post_meta($post_id, 'layout', true);
|
247 |
+
if( $layout )
|
248 |
+
{
|
249 |
+
$options['layout'] = $layout;
|
250 |
+
}
|
251 |
+
|
252 |
+
$hide_on_screen = get_post_meta($post_id, 'hide_on_screen', true);
|
253 |
+
if( $hide_on_screen )
|
254 |
+
{
|
255 |
+
$hide_on_screen = maybe_unserialize($hide_on_screen);
|
256 |
+
$options['hide_on_screen'] = $hide_on_screen;
|
257 |
+
}
|
258 |
+
|
259 |
+
|
260 |
+
// return
|
261 |
+
return $options;
|
262 |
+
}
|
263 |
+
|
264 |
+
|
265 |
+
/*
|
266 |
+
* validate_page
|
267 |
+
*
|
268 |
+
* @description:
|
269 |
+
* @since 3.2.6
|
270 |
+
* @created: 23/06/12
|
271 |
+
*/
|
272 |
+
|
273 |
+
function validate_page()
|
274 |
+
{
|
275 |
+
// global
|
276 |
+
global $pagenow, $typenow;
|
277 |
+
|
278 |
+
|
279 |
+
// vars
|
280 |
+
$return = false;
|
281 |
+
|
282 |
+
|
283 |
+
// validate page
|
284 |
+
if( in_array( $pagenow, array('post.php', 'post-new.php') ) )
|
285 |
+
{
|
286 |
+
|
287 |
+
// validate post type
|
288 |
+
if( $typenow == "acf" )
|
289 |
+
{
|
290 |
+
$return = true;
|
291 |
+
}
|
292 |
+
|
293 |
+
}
|
294 |
+
|
295 |
+
|
296 |
+
// return
|
297 |
+
return $return;
|
298 |
+
}
|
299 |
+
|
300 |
+
|
301 |
+
/*
|
302 |
+
* admin_enqueue_scripts
|
303 |
+
*
|
304 |
+
* @description: run after post query but before any admin script / head actions. A good place to register all actions.
|
305 |
+
* @since: 3.6
|
306 |
+
* @created: 26/01/13
|
307 |
+
*/
|
308 |
+
|
309 |
+
function admin_enqueue_scripts()
|
310 |
+
{
|
311 |
+
// validate page
|
312 |
+
if( ! $this->validate_page() ){ return; }
|
313 |
+
|
314 |
+
|
315 |
+
// settings
|
316 |
+
$this->settings = apply_filters('acf/get_info', 'all');
|
317 |
+
|
318 |
+
|
319 |
+
// no autosave
|
320 |
+
wp_dequeue_script( 'autosave' );
|
321 |
+
|
322 |
+
|
323 |
+
// custom scripts
|
324 |
+
wp_enqueue_script(array(
|
325 |
+
'acf-field-group',
|
326 |
+
));
|
327 |
+
|
328 |
+
|
329 |
+
// custom styles
|
330 |
+
wp_enqueue_style(array(
|
331 |
+
'acf-global',
|
332 |
+
'acf-field-group',
|
333 |
+
));
|
334 |
+
|
335 |
+
|
336 |
+
// actions
|
337 |
+
do_action('acf/field_group/admin_enqueue_scripts');
|
338 |
+
add_action('admin_head', array($this,'admin_head'));
|
339 |
+
|
340 |
+
}
|
341 |
+
|
342 |
+
|
343 |
+
/*
|
344 |
+
* admin_head
|
345 |
+
*
|
346 |
+
* @description:
|
347 |
+
* @since 3.1.8
|
348 |
+
* @created: 23/06/12
|
349 |
+
*/
|
350 |
+
|
351 |
+
function admin_head()
|
352 |
+
{
|
353 |
+
// global
|
354 |
+
global $wp_version, $post;
|
355 |
+
|
356 |
+
|
357 |
+
// l10n
|
358 |
+
$l10n = array(
|
359 |
+
'move_to_trash' => __("Move to trash. Are you sure?",'acf'),
|
360 |
+
'checked' => __("checked",'acf'),
|
361 |
+
'no_fields' => __("No toggle fields available",'acf'),
|
362 |
+
'title' => __("Field group title is required",'acf'),
|
363 |
+
'copy' => __("copy",'acf'),
|
364 |
+
'or' => __("or",'acf'),
|
365 |
+
'fields' => __("Fields",'acf'),
|
366 |
+
'parent_fields' => __("Parent fields",'acf'),
|
367 |
+
'sibling_fields' => __("Sibling fields",'acf'),
|
368 |
+
'hide_show_all' => __("Hide / Show All",'acf')
|
369 |
+
);
|
370 |
+
|
371 |
+
|
372 |
+
|
373 |
+
?>
|
374 |
+
<script type="text/javascript">
|
375 |
+
(function($) {
|
376 |
+
|
377 |
+
// vars
|
378 |
+
acf.post_id = <?php echo $post->ID; ?>;
|
379 |
+
acf.nonce = "<?php echo wp_create_nonce( 'acf_nonce' ); ?>";
|
380 |
+
acf.admin_url = "<?php echo admin_url(); ?>";
|
381 |
+
acf.ajaxurl = "<?php echo admin_url( 'admin-ajax.php' ); ?>";
|
382 |
+
acf.wp_version = "<?php echo $wp_version; ?>";
|
383 |
+
|
384 |
+
|
385 |
+
// l10n
|
386 |
+
acf.l10n = <?php echo json_encode( $l10n ); ?>;
|
387 |
+
|
388 |
+
})(jQuery);
|
389 |
+
</script>
|
390 |
+
<?php
|
391 |
+
|
392 |
+
// new action
|
393 |
+
do_action('acf/field_group/admin_head');
|
394 |
+
|
395 |
+
|
396 |
+
// add metaboxes
|
397 |
+
add_meta_box('acf_fields', __("Fields",'acf'), array($this, 'html_fields'), 'acf', 'normal', 'high');
|
398 |
+
add_meta_box('acf_location', __("Location",'acf'), array($this, 'html_location'), 'acf', 'normal', 'high');
|
399 |
+
add_meta_box('acf_options', __("Options",'acf'), array($this, 'html_options'), 'acf', 'normal', 'high');
|
400 |
+
|
401 |
+
|
402 |
+
// add screen settings
|
403 |
+
add_filter('screen_settings', array($this, 'screen_settings'), 10, 1);
|
404 |
+
}
|
405 |
+
|
406 |
+
|
407 |
+
/*
|
408 |
+
* html_fields
|
409 |
+
*
|
410 |
+
* @description:
|
411 |
+
* @since 1.0.0
|
412 |
+
* @created: 23/06/12
|
413 |
+
*/
|
414 |
+
|
415 |
+
function html_fields()
|
416 |
+
{
|
417 |
+
include( $this->settings['path'] . 'core/views/meta_box_fields.php' );
|
418 |
+
}
|
419 |
+
|
420 |
+
|
421 |
+
/*
|
422 |
+
* html_location
|
423 |
+
*
|
424 |
+
* @description:
|
425 |
+
* @since 1.0.0
|
426 |
+
* @created: 23/06/12
|
427 |
+
*/
|
428 |
+
|
429 |
+
function html_location()
|
430 |
+
{
|
431 |
+
include( $this->settings['path'] . 'core/views/meta_box_location.php' );
|
432 |
+
}
|
433 |
+
|
434 |
+
|
435 |
+
/*
|
436 |
+
* html_options
|
437 |
+
*
|
438 |
+
* @description:
|
439 |
+
* @since 1.0.0
|
440 |
+
* @created: 23/06/12
|
441 |
+
*/
|
442 |
+
|
443 |
+
function html_options()
|
444 |
+
{
|
445 |
+
include( $this->settings['path'] . 'core/views/meta_box_options.php' );
|
446 |
+
}
|
447 |
+
|
448 |
+
|
449 |
+
/*
|
450 |
+
* screen_settings
|
451 |
+
*
|
452 |
+
* @description:
|
453 |
+
* @since: 3.6
|
454 |
+
* @created: 26/01/13
|
455 |
+
*/
|
456 |
+
|
457 |
+
function screen_settings( $current )
|
458 |
+
{
|
459 |
+
$current .= '<h5>' . __("Fields",'acf') . '</h5>';
|
460 |
+
|
461 |
+
$current .= '<div class="show-field_key">' . __("Show Field Key:",'acf');
|
462 |
+
$current .= '<label class="show-field_key-no"><input checked="checked" type="radio" value="0" name="show-field_key" />' . __("No",'acf') . '</label>';
|
463 |
+
$current .= '<label class="show-field_key-yes"><input type="radio" value="1" name="show-field_key" />' . __("Yes",'acf') . '</label>';
|
464 |
+
$current .= '</div>';
|
465 |
+
|
466 |
+
return $current;
|
467 |
+
}
|
468 |
+
|
469 |
+
|
470 |
+
/*
|
471 |
+
* ajax_render_options
|
472 |
+
*
|
473 |
+
* @description: creates the HTML for a field's options (field group edit page)
|
474 |
+
* @since 3.1.6
|
475 |
+
* @created: 23/06/12
|
476 |
+
*/
|
477 |
+
|
478 |
+
function ajax_render_options()
|
479 |
+
{
|
480 |
+
// vars
|
481 |
+
$options = array(
|
482 |
+
'field_key' => '',
|
483 |
+
'field_type' => '',
|
484 |
+
'post_id' => 0,
|
485 |
+
'nonce' => ''
|
486 |
+
);
|
487 |
+
|
488 |
+
// load post options
|
489 |
+
$options = array_merge($options, $_POST);
|
490 |
+
|
491 |
+
|
492 |
+
// verify nonce
|
493 |
+
if( ! wp_verify_nonce($options['nonce'], 'acf_nonce') )
|
494 |
+
{
|
495 |
+
die(0);
|
496 |
+
}
|
497 |
+
|
498 |
+
|
499 |
+
// required
|
500 |
+
if( ! $options['field_type'] )
|
501 |
+
{
|
502 |
+
die(0);
|
503 |
+
}
|
504 |
+
|
505 |
+
|
506 |
+
// find key (not actual field key, more the html attr name)
|
507 |
+
$options['field_key'] = str_replace("fields[", "", $options['field_key']);
|
508 |
+
$options['field_key'] = str_replace("][type]", "", $options['field_key']) ;
|
509 |
+
|
510 |
+
|
511 |
+
// render options
|
512 |
+
$field = array(
|
513 |
+
'type' => $options['field_type'],
|
514 |
+
'name' => $options['field_key']
|
515 |
+
);
|
516 |
+
do_action('acf/create_field_options', $field );
|
517 |
+
|
518 |
+
|
519 |
+
die();
|
520 |
+
|
521 |
+
}
|
522 |
+
|
523 |
+
|
524 |
+
/*
|
525 |
+
* ajax_render_location
|
526 |
+
*
|
527 |
+
* @description: creates the HTML for the field group location metabox. Called from both Ajax and PHP
|
528 |
+
* @since 3.1.6
|
529 |
+
* @created: 23/06/12
|
530 |
+
*/
|
531 |
+
|
532 |
+
function ajax_render_location( $options = array() )
|
533 |
+
{
|
534 |
+
// defaults
|
535 |
+
$defaults = array(
|
536 |
+
'group_id' => 0,
|
537 |
+
'rule_id' => 0,
|
538 |
+
'value' => null,
|
539 |
+
'param' => null,
|
540 |
+
);
|
541 |
+
|
542 |
+
$is_ajax = false;
|
543 |
+
if( isset($_POST['nonce']) && wp_verify_nonce($_POST['nonce'], 'acf_nonce') )
|
544 |
+
{
|
545 |
+
$is_ajax = true;
|
546 |
+
}
|
547 |
+
|
548 |
+
|
549 |
+
// Is AJAX call?
|
550 |
+
if( $is_ajax )
|
551 |
+
{
|
552 |
+
$options = array_merge($defaults, $_POST);
|
553 |
+
}
|
554 |
+
else
|
555 |
+
{
|
556 |
+
$options = array_merge($defaults, $options);
|
557 |
+
}
|
558 |
+
|
559 |
+
// vars
|
560 |
+
$choices = array();
|
561 |
+
|
562 |
+
|
563 |
+
// some case's have the same outcome
|
564 |
+
if($options['param'] == "page_parent")
|
565 |
+
{
|
566 |
+
$options['param'] = "page";
|
567 |
+
}
|
568 |
+
|
569 |
+
|
570 |
+
switch($options['param'])
|
571 |
+
{
|
572 |
+
case "post_type":
|
573 |
+
|
574 |
+
// all post types except attachment
|
575 |
+
$choices = apply_filters('acf/get_post_types', array(), array('attachment'));
|
576 |
+
|
577 |
+
break;
|
578 |
+
|
579 |
+
|
580 |
+
case "page":
|
581 |
+
|
582 |
+
$post_type = 'page';
|
583 |
+
$posts = get_posts(array(
|
584 |
+
'posts_per_page' => -1,
|
585 |
+
'post_type' => $post_type,
|
586 |
+
'orderby' => 'menu_order title',
|
587 |
+
'order' => 'ASC',
|
588 |
+
'post_status' => 'any',
|
589 |
+
'suppress_filters' => false,
|
590 |
+
'update_post_meta_cache' => false,
|
591 |
+
));
|
592 |
+
|
593 |
+
if( $posts )
|
594 |
+
{
|
595 |
+
// sort into hierachial order!
|
596 |
+
if( is_post_type_hierarchical( $post_type ) )
|
597 |
+
{
|
598 |
+
$posts = get_page_children( 0, $posts );
|
599 |
+
}
|
600 |
+
|
601 |
+
foreach( $posts as $page )
|
602 |
+
{
|
603 |
+
$title = '';
|
604 |
+
$ancestors = get_ancestors($page->ID, 'page');
|
605 |
+
if($ancestors)
|
606 |
+
{
|
607 |
+
foreach($ancestors as $a)
|
608 |
+
{
|
609 |
+
$title .= '- ';
|
610 |
+
}
|
611 |
+
}
|
612 |
+
|
613 |
+
$title .= apply_filters( 'the_title', $page->post_title, $page->ID );
|
614 |
+
|
615 |
+
|
616 |
+
// status
|
617 |
+
if($page->post_status != "publish")
|
618 |
+
{
|
619 |
+
$title .= " ($page->post_status)";
|
620 |
+
}
|
621 |
+
|
622 |
+
$choices[ $page->ID ] = $title;
|
623 |
+
|
624 |
+
}
|
625 |
+
// foreach($pages as $page)
|
626 |
+
|
627 |
+
}
|
628 |
+
|
629 |
+
break;
|
630 |
+
|
631 |
+
|
632 |
+
case "page_type" :
|
633 |
+
|
634 |
+
$choices = array(
|
635 |
+
'front_page' => __("Front Page",'acf'),
|
636 |
+
'posts_page' => __("Posts Page",'acf'),
|
637 |
+
'top_level' => __("Top Level Page (parent of 0)",'acf'),
|
638 |
+
'parent' => __("Parent Page (has children)",'acf'),
|
639 |
+
'child' => __("Child Page (has parent)",'acf'),
|
640 |
+
);
|
641 |
+
|
642 |
+
break;
|
643 |
+
|
644 |
+
case "page_template" :
|
645 |
+
|
646 |
+
$choices = array(
|
647 |
+
'default' => __("Default Template",'acf'),
|
648 |
+
);
|
649 |
+
|
650 |
+
$templates = get_page_templates();
|
651 |
+
foreach($templates as $k => $v)
|
652 |
+
{
|
653 |
+
$choices[$v] = $k;
|
654 |
+
}
|
655 |
+
|
656 |
+
break;
|
657 |
+
|
658 |
+
case "post" :
|
659 |
+
|
660 |
+
$post_types = get_post_types();
|
661 |
+
|
662 |
+
unset( $post_types['page'], $post_types['attachment'], $post_types['revision'] , $post_types['nav_menu_item'], $post_types['acf'] );
|
663 |
+
|
664 |
+
if( $post_types )
|
665 |
+
{
|
666 |
+
foreach( $post_types as $post_type )
|
667 |
+
{
|
668 |
+
|
669 |
+
$posts = get_posts(array(
|
670 |
+
'numberposts' => '-1',
|
671 |
+
'post_type' => $post_type,
|
672 |
+
'post_status' => array('publish', 'private', 'draft', 'inherit', 'future'),
|
673 |
+
'suppress_filters' => false,
|
674 |
+
));
|
675 |
+
|
676 |
+
if( $posts)
|
677 |
+
{
|
678 |
+
$choices[$post_type] = array();
|
679 |
+
|
680 |
+
foreach($posts as $post)
|
681 |
+
{
|
682 |
+
$title = apply_filters( 'the_title', $post->post_title, $post->ID );
|
683 |
+
|
684 |
+
// status
|
685 |
+
if($post->post_status != "publish")
|
686 |
+
{
|
687 |
+
$title .= " ($post->post_status)";
|
688 |
+
}
|
689 |
+
|
690 |
+
$choices[$post_type][$post->ID] = $title;
|
691 |
+
|
692 |
+
}
|
693 |
+
// foreach($posts as $post)
|
694 |
+
}
|
695 |
+
// if( $posts )
|
696 |
+
}
|
697 |
+
// foreach( $post_types as $post_type )
|
698 |
+
}
|
699 |
+
// if( $post_types )
|
700 |
+
|
701 |
+
|
702 |
+
break;
|
703 |
+
|
704 |
+
case "post_category" :
|
705 |
+
|
706 |
+
$terms = get_terms( 'category', array( 'hide_empty' => false ) );
|
707 |
+
|
708 |
+
if( !empty($terms) ) {
|
709 |
+
|
710 |
+
foreach( $terms as $term ) {
|
711 |
+
|
712 |
+
$choices[ $term->term_id ] = $term->name;
|
713 |
+
|
714 |
+
}
|
715 |
+
|
716 |
+
}
|
717 |
+
|
718 |
+
break;
|
719 |
+
|
720 |
+
case "post_format" :
|
721 |
+
|
722 |
+
$choices = get_post_format_strings();
|
723 |
+
|
724 |
+
break;
|
725 |
+
|
726 |
+
case "post_status" :
|
727 |
+
|
728 |
+
$choices = array(
|
729 |
+
'publish' => __( 'Published', 'acf'),
|
730 |
+
'pending' => __( 'Pending Review', 'acf'),
|
731 |
+
'draft' => __( 'Draft', 'acf'),
|
732 |
+
'future' => __( 'Future', 'acf'),
|
733 |
+
'private' => __( 'Private', 'acf'),
|
734 |
+
'inherit' => __( 'Revision', 'acf'),
|
735 |
+
'trash' => __( 'Trash', 'acf'),
|
736 |
+
);
|
737 |
+
|
738 |
+
break;
|
739 |
+
|
740 |
+
case "user_type" :
|
741 |
+
|
742 |
+
global $wp_roles;
|
743 |
+
|
744 |
+
$choices = $wp_roles->get_names();
|
745 |
+
|
746 |
+
if( is_multisite() )
|
747 |
+
{
|
748 |
+
$choices['super_admin'] = __('Super Admin', 'acf');
|
749 |
+
}
|
750 |
+
|
751 |
+
break;
|
752 |
+
|
753 |
+
case "taxonomy" :
|
754 |
+
|
755 |
+
$choices = array();
|
756 |
+
$simple_value = true;
|
757 |
+
$choices = apply_filters('acf/get_taxonomies_for_select', $choices, $simple_value);
|
758 |
+
|
759 |
+
break;
|
760 |
+
|
761 |
+
case "ef_taxonomy" :
|
762 |
+
|
763 |
+
$choices = array('all' => __('All', 'acf'));
|
764 |
+
$taxonomies = get_taxonomies( array('public' => true), 'objects' );
|
765 |
+
|
766 |
+
foreach($taxonomies as $taxonomy)
|
767 |
+
{
|
768 |
+
$choices[ $taxonomy->name ] = $taxonomy->labels->name;
|
769 |
+
}
|
770 |
+
|
771 |
+
// unset post_format (why is this a public taxonomy?)
|
772 |
+
if( isset($choices['post_format']) )
|
773 |
+
{
|
774 |
+
unset( $choices['post_format']) ;
|
775 |
+
}
|
776 |
+
|
777 |
+
|
778 |
+
break;
|
779 |
+
|
780 |
+
case "ef_user" :
|
781 |
+
|
782 |
+
global $wp_roles;
|
783 |
+
|
784 |
+
$choices = array_merge( array('all' => __('All', 'acf')), $wp_roles->get_names() );
|
785 |
+
|
786 |
+
break;
|
787 |
+
|
788 |
+
|
789 |
+
case "ef_media" :
|
790 |
+
|
791 |
+
$choices = array('all' => __('All', 'acf'));
|
792 |
+
|
793 |
+
break;
|
794 |
+
|
795 |
+
}
|
796 |
+
|
797 |
+
|
798 |
+
// allow custom location rules
|
799 |
+
$choices = apply_filters( 'acf/location/rule_values/' . $options['param'], $choices );
|
800 |
+
|
801 |
+
|
802 |
+
// create field
|
803 |
+
do_action('acf/create_field', array(
|
804 |
+
'type' => 'select',
|
805 |
+
'name' => 'location[' . $options['group_id'] . '][' . $options['rule_id'] . '][value]',
|
806 |
+
'value' => $options['value'],
|
807 |
+
'choices' => $choices,
|
808 |
+
));
|
809 |
+
|
810 |
+
|
811 |
+
// ajax?
|
812 |
+
if( $is_ajax )
|
813 |
+
{
|
814 |
+
die();
|
815 |
+
}
|
816 |
+
|
817 |
+
}
|
818 |
+
|
819 |
+
|
820 |
+
/*
|
821 |
+
* name_save_pre
|
822 |
+
*
|
823 |
+
* @description: intercepts the acf post obejct and adds an "acf_" to the start of
|
824 |
+
* it's name to stop conflicts between acf's and page's urls
|
825 |
+
* @since 1.0.0
|
826 |
+
* @created: 23/06/12
|
827 |
+
*/
|
828 |
+
|
829 |
+
function name_save_pre($name)
|
830 |
+
{
|
831 |
+
// validate
|
832 |
+
if( !isset($_POST['post_type']) || $_POST['post_type'] != 'acf' )
|
833 |
+
{
|
834 |
+
return $name;
|
835 |
+
}
|
836 |
+
|
837 |
+
|
838 |
+
// need a title
|
839 |
+
if( !$_POST['post_title'] )
|
840 |
+
{
|
841 |
+
$_POST['post_title'] = 'Unnamed Field Group';
|
842 |
+
}
|
843 |
+
|
844 |
+
|
845 |
+
$name = 'acf_' . sanitize_title($_POST['post_title']);
|
846 |
+
|
847 |
+
|
848 |
+
return $name;
|
849 |
+
}
|
850 |
+
|
851 |
+
|
852 |
+
/*
|
853 |
+
* save_post
|
854 |
+
*
|
855 |
+
* @description: Saves the field / location / option data for a field group
|
856 |
+
* @since 1.0.0
|
857 |
+
* @created: 23/06/12
|
858 |
+
*/
|
859 |
+
|
860 |
+
function save_post($post_id)
|
861 |
+
{
|
862 |
+
// do not save if this is an auto save routine
|
863 |
+
if( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
|
864 |
+
{
|
865 |
+
return $post_id;
|
866 |
+
}
|
867 |
+
|
868 |
+
|
869 |
+
// verify nonce
|
870 |
+
if( !isset($_POST['acf_nonce']) || !wp_verify_nonce($_POST['acf_nonce'], 'field_group') )
|
871 |
+
{
|
872 |
+
return $post_id;
|
873 |
+
}
|
874 |
+
|
875 |
+
|
876 |
+
// only save once! WordPress save's a revision as well.
|
877 |
+
if( wp_is_post_revision($post_id) )
|
878 |
+
{
|
879 |
+
return $post_id;
|
880 |
+
}
|
881 |
+
|
882 |
+
|
883 |
+
/*
|
884 |
+
* save fields
|
885 |
+
*/
|
886 |
+
|
887 |
+
// vars
|
888 |
+
$dont_delete = array();
|
889 |
+
|
890 |
+
if( isset($_POST['fields']) && is_array($_POST['fields']) )
|
891 |
+
{
|
892 |
+
$i = -1;
|
893 |
+
|
894 |
+
|
895 |
+
// remove clone field
|
896 |
+
unset( $_POST['fields']['field_clone'] );
|
897 |
+
|
898 |
+
|
899 |
+
|
900 |
+
// loop through and save fields
|
901 |
+
foreach( $_POST['fields'] as $key => $field )
|
902 |
+
{
|
903 |
+
$i++;
|
904 |
+
|
905 |
+
|
906 |
+
// order + key
|
907 |
+
$field['order_no'] = $i;
|
908 |
+
$field['key'] = $key;
|
909 |
+
|
910 |
+
|
911 |
+
// save
|
912 |
+
do_action('acf/update_field', $field, $post_id );
|
913 |
+
|
914 |
+
|
915 |
+
// add to dont delete array
|
916 |
+
$dont_delete[] = $field['key'];
|
917 |
+
}
|
918 |
+
}
|
919 |
+
unset( $_POST['fields'] );
|
920 |
+
|
921 |
+
|
922 |
+
// delete all other field
|
923 |
+
$keys = get_post_custom_keys($post_id);
|
924 |
+
foreach( $keys as $key )
|
925 |
+
{
|
926 |
+
if( strpos($key, 'field_') !== false && !in_array($key, $dont_delete) )
|
927 |
+
{
|
928 |
+
// this is a field, and it wasn't found in the dont_delete array
|
929 |
+
do_action('acf/delete_field', $post_id, $key);
|
930 |
+
}
|
931 |
+
}
|
932 |
+
|
933 |
+
|
934 |
+
/*
|
935 |
+
* save location rules
|
936 |
+
*/
|
937 |
+
|
938 |
+
if( isset($_POST['location']) && is_array($_POST['location']) )
|
939 |
+
{
|
940 |
+
delete_post_meta( $post_id, 'rule' );
|
941 |
+
|
942 |
+
|
943 |
+
// clean array keys
|
944 |
+
$_POST['location'] = array_values( $_POST['location'] );
|
945 |
+
foreach( $_POST['location'] as $group_id => $group )
|
946 |
+
{
|
947 |
+
if( is_array($group) )
|
948 |
+
{
|
949 |
+
// clean array keys
|
950 |
+
$group = array_values( $group );
|
951 |
+
foreach( $group as $rule_id => $rule )
|
952 |
+
{
|
953 |
+
$rule['order_no'] = $rule_id;
|
954 |
+
$rule['group_no'] = $group_id;
|
955 |
+
|
956 |
+
|
957 |
+
add_post_meta( $post_id, 'rule', $rule );
|
958 |
+
}
|
959 |
+
}
|
960 |
+
}
|
961 |
+
|
962 |
+
unset( $_POST['location'] );
|
963 |
+
}
|
964 |
+
|
965 |
+
|
966 |
+
/*
|
967 |
+
* save options
|
968 |
+
*/
|
969 |
+
|
970 |
+
if( isset($_POST['options']) && is_array($_POST['options']) )
|
971 |
+
{
|
972 |
+
update_post_meta($post_id, 'position', $_POST['options']['position']);
|
973 |
+
update_post_meta($post_id, 'layout', $_POST['options']['layout']);
|
974 |
+
update_post_meta($post_id, 'hide_on_screen', $_POST['options']['hide_on_screen']);
|
975 |
+
}
|
976 |
+
|
977 |
+
|
978 |
+
unset( $_POST['options'] );
|
979 |
+
|
980 |
+
|
981 |
+
}
|
982 |
+
|
983 |
+
|
984 |
+
}
|
985 |
+
|
986 |
+
new acf_field_group();
|
987 |
+
|
988 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/controllers/field_groups.php
CHANGED
@@ -1,529 +1,529 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* acf_field_groups
|
5 |
-
*
|
6 |
-
* @description:
|
7 |
-
* @since: 3.6
|
8 |
-
* @created: 25/01/13
|
9 |
-
*/
|
10 |
-
|
11 |
-
class acf_field_groups
|
12 |
-
{
|
13 |
-
|
14 |
-
/*
|
15 |
-
* __construct
|
16 |
-
*
|
17 |
-
* @description:
|
18 |
-
* @since 3.1.8
|
19 |
-
* @created: 23/06/12
|
20 |
-
*/
|
21 |
-
|
22 |
-
function __construct()
|
23 |
-
{
|
24 |
-
// actions
|
25 |
-
add_action('admin_menu', array($this,'admin_menu'));
|
26 |
-
}
|
27 |
-
|
28 |
-
|
29 |
-
/*
|
30 |
-
* admin_menu
|
31 |
-
*
|
32 |
-
* @description:
|
33 |
-
* @created: 2/08/12
|
34 |
-
*/
|
35 |
-
|
36 |
-
function admin_menu()
|
37 |
-
{
|
38 |
-
|
39 |
-
// validate page
|
40 |
-
if( ! $this->validate_page() )
|
41 |
-
{
|
42 |
-
return;
|
43 |
-
}
|
44 |
-
|
45 |
-
|
46 |
-
// actions
|
47 |
-
add_action('admin_print_scripts', array($this,'admin_print_scripts'));
|
48 |
-
add_action('admin_print_styles', array($this,'admin_print_styles'));
|
49 |
-
add_action('admin_footer', array($this,'admin_footer'));
|
50 |
-
|
51 |
-
|
52 |
-
// columns
|
53 |
-
add_filter( 'manage_edit-acf_columns', array($this,'acf_edit_columns'), 10, 1 );
|
54 |
-
add_action( 'manage_acf_posts_custom_column' , array($this,'acf_columns_display'), 10, 2 );
|
55 |
-
|
56 |
-
}
|
57 |
-
|
58 |
-
|
59 |
-
/*
|
60 |
-
* validate_page
|
61 |
-
*
|
62 |
-
* @description: returns true | false. Used to stop a function from continuing
|
63 |
-
* @since 3.2.6
|
64 |
-
* @created: 23/06/12
|
65 |
-
*/
|
66 |
-
|
67 |
-
function validate_page()
|
68 |
-
{
|
69 |
-
// global
|
70 |
-
global $pagenow;
|
71 |
-
|
72 |
-
|
73 |
-
// vars
|
74 |
-
$return = false;
|
75 |
-
|
76 |
-
|
77 |
-
// validate page
|
78 |
-
if( in_array( $pagenow, array('edit.php') ) )
|
79 |
-
{
|
80 |
-
|
81 |
-
// validate post type
|
82 |
-
if( isset($_GET['post_type']) && $_GET['post_type'] == 'acf' )
|
83 |
-
{
|
84 |
-
$return = true;
|
85 |
-
}
|
86 |
-
|
87 |
-
|
88 |
-
if( isset($_GET['page']) )
|
89 |
-
{
|
90 |
-
$return = false;
|
91 |
-
}
|
92 |
-
|
93 |
-
}
|
94 |
-
|
95 |
-
|
96 |
-
// return
|
97 |
-
return $return;
|
98 |
-
}
|
99 |
-
|
100 |
-
|
101 |
-
/*
|
102 |
-
* admin_print_scripts
|
103 |
-
*
|
104 |
-
* @description:
|
105 |
-
* @since 3.1.8
|
106 |
-
* @created: 23/06/12
|
107 |
-
*/
|
108 |
-
|
109 |
-
function admin_print_scripts()
|
110 |
-
{
|
111 |
-
wp_enqueue_script(array(
|
112 |
-
'jquery',
|
113 |
-
'thickbox',
|
114 |
-
));
|
115 |
-
}
|
116 |
-
|
117 |
-
|
118 |
-
/*
|
119 |
-
* admin_print_styles
|
120 |
-
*
|
121 |
-
* @description:
|
122 |
-
* @since 3.1.8
|
123 |
-
* @created: 23/06/12
|
124 |
-
*/
|
125 |
-
|
126 |
-
function admin_print_styles()
|
127 |
-
{
|
128 |
-
wp_enqueue_style(array(
|
129 |
-
'thickbox',
|
130 |
-
'acf-global',
|
131 |
-
'acf',
|
132 |
-
));
|
133 |
-
}
|
134 |
-
|
135 |
-
|
136 |
-
/*
|
137 |
-
* acf_edit_columns
|
138 |
-
*
|
139 |
-
* @description:
|
140 |
-
* @created: 2/08/12
|
141 |
-
*/
|
142 |
-
|
143 |
-
function acf_edit_columns( $columns )
|
144 |
-
{
|
145 |
-
$columns = array(
|
146 |
-
'cb' => '<input type="checkbox" />',
|
147 |
-
'title' => __("Title"),
|
148 |
-
'fields' => __("Fields", 'acf')
|
149 |
-
);
|
150 |
-
|
151 |
-
return $columns;
|
152 |
-
}
|
153 |
-
|
154 |
-
|
155 |
-
/*
|
156 |
-
* acf_columns_display
|
157 |
-
*
|
158 |
-
* @description:
|
159 |
-
* @created: 2/08/12
|
160 |
-
*/
|
161 |
-
|
162 |
-
function acf_columns_display( $column, $post_id )
|
163 |
-
{
|
164 |
-
// vars
|
165 |
-
switch ($column)
|
166 |
-
{
|
167 |
-
case "fields":
|
168 |
-
|
169 |
-
// vars
|
170 |
-
$count =0;
|
171 |
-
$keys = get_post_custom_keys( $post_id );
|
172 |
-
|
173 |
-
if($keys)
|
174 |
-
{
|
175 |
-
foreach($keys as $key)
|
176 |
-
{
|
177 |
-
if(strpos($key, 'field_') !== false)
|
178 |
-
{
|
179 |
-
$count++;
|
180 |
-
}
|
181 |
-
}
|
182 |
-
}
|
183 |
-
|
184 |
-
echo $count;
|
185 |
-
|
186 |
-
break;
|
187 |
-
}
|
188 |
-
}
|
189 |
-
|
190 |
-
|
191 |
-
/*
|
192 |
-
* admin_footer
|
193 |
-
*
|
194 |
-
* @description:
|
195 |
-
* @since 3.1.8
|
196 |
-
* @created: 23/06/12
|
197 |
-
*/
|
198 |
-
|
199 |
-
function admin_footer()
|
200 |
-
{
|
201 |
-
// vars
|
202 |
-
$version = apply_filters('acf/get_info', 'version');
|
203 |
-
$dir = apply_filters('acf/get_info', 'dir');
|
204 |
-
$path = apply_filters('acf/get_info', 'path');
|
205 |
-
$show_tab = isset($_GET['info']);
|
206 |
-
$tab = isset($_GET['info']) ? $_GET['info'] : 'changelog';
|
207 |
-
|
208 |
-
?>
|
209 |
-
<script type="text/html" id="tmpl-acf-column-2">
|
210 |
-
<div class="acf-column-2">
|
211 |
-
<div class="wp-box">
|
212 |
-
<div class="inner">
|
213 |
-
<h2><?php _e("Advanced Custom Fields",'acf'); ?> <?php echo $version; ?></h2>
|
214 |
-
|
215 |
-
<h3><?php _e("Changelog",'acf'); ?></h3>
|
216 |
-
<p><?php printf(__('See what\'s new in %1$sversion %2$s%3$s','acf'),'<a href="'.admin_url('edit.php?post_type=acf&info=changelog').'">',$version,'</a>'); ?></p>
|
217 |
-
|
218 |
-
<h3><?php _e("Resources",'acf'); ?></h3>
|
219 |
-
<ul>
|
220 |
-
<li><a href="http://www.advancedcustomfields.com/resources/#getting-started" target="_blank"><?php _e("Getting Started",'acf'); ?></a></li>
|
221 |
-
<li><a href="http://www.advancedcustomfields.com/resources/#field-types" target="_blank"><?php _e("Field Types",'acf'); ?></a></li>
|
222 |
-
<li><a href="http://www.advancedcustomfields.com/resources/#functions" target="_blank"><?php _e("Functions",'acf'); ?></a></li>
|
223 |
-
<li><a href="http://www.advancedcustomfields.com/resources/#actions" target="_blank"><?php _e("Actions",'acf'); ?></a></li>
|
224 |
-
<li><a href="http://www.advancedcustomfields.com/resources/#filters" target="_blank"><?php _e("Filters",'acf'); ?></a></li>
|
225 |
-
<li><a href="http://www.advancedcustomfields.com/resources/#how-to" target="_blank"><?php _e("'How to' guides",'acf'); ?></a></li>
|
226 |
-
<li><a href="http://www.advancedcustomfields.com/resources/#tutorials" target="_blank"><?php _e("Tutorials",'acf'); ?></a></li>
|
227 |
-
</ul>
|
228 |
-
</div>
|
229 |
-
<div class="footer footer-blue">
|
230 |
-
<ul class="hl">
|
231 |
-
<li><?php _e("Created by",'acf'); ?> Elliot Condon</li>
|
232 |
-
</ul>
|
233 |
-
</div>
|
234 |
-
</div>
|
235 |
-
</div>
|
236 |
-
</script>
|
237 |
-
<script type="text/html" id="tmpl-acf-about">
|
238 |
-
<!-- acf-about -->
|
239 |
-
<div id="acf-about" class="acf-content">
|
240 |
-
|
241 |
-
<!-- acf-content-title -->
|
242 |
-
<div class="acf-content-title">
|
243 |
-
<h1><?php _e("Welcome to Advanced Custom Fields",'acf'); ?> <?php echo $version; ?></h1>
|
244 |
-
<h2><?php _e("Thank you for updating to the latest version!",'acf'); ?> <br /><?php printf(__('ACF %s is more polished and enjoyable than ever before. We hope you like it.','acf'),$version); ?></h2>
|
245 |
-
</div>
|
246 |
-
<!-- / acf-content-title -->
|
247 |
-
|
248 |
-
<!-- acf-content-body -->
|
249 |
-
<div class="acf-content-body">
|
250 |
-
<h2 class="nav-tab-wrapper">
|
251 |
-
<a class="acf-tab-toggle nav-tab <?php if( $tab == 'whats-new' ){ echo 'nav-tab-active'; } ?>" href="<?php echo admin_url('edit.php?post_type=acf&info=whats-new'); ?>"><?php _e("What’s New",'acf'); ?></a>
|
252 |
-
<a class="acf-tab-toggle nav-tab <?php if( $tab == 'changelog' ){ echo 'nav-tab-active'; } ?>" href="<?php echo admin_url('edit.php?post_type=acf&info=changelog'); ?>"><?php _e("Changelog",'acf'); ?></a>
|
253 |
-
<?php if( $tab == 'download-add-ons' ): ?>
|
254 |
-
<a class="acf-tab-toggle nav-tab nav-tab-active" href="<?php echo admin_url('edit.php?post_type=acf&info=download-add-ons'); ?>"><?php _e("Download Add-ons",'acf'); ?></a>
|
255 |
-
<?php endif; ?>
|
256 |
-
</h2>
|
257 |
-
|
258 |
-
<?php if( $tab == 'whats-new' ):
|
259 |
-
|
260 |
-
$activation_codes = array(
|
261 |
-
'repeater' => get_option('acf_repeater_ac', ''),
|
262 |
-
'gallery' => get_option('acf_gallery_ac', ''),
|
263 |
-
'options_page' => get_option('acf_options_page_ac', ''),
|
264 |
-
'flexible_content' => get_option('acf_flexible_content_ac', '')
|
265 |
-
);
|
266 |
-
|
267 |
-
$active = array(
|
268 |
-
'repeater' => class_exists('acf_field_repeater'),
|
269 |
-
'gallery' => class_exists('acf_field_gallery'),
|
270 |
-
'options_page' => class_exists('acf_options_page_plugin'),
|
271 |
-
'flexible_content' => class_exists('acf_field_flexible_content')
|
272 |
-
);
|
273 |
-
|
274 |
-
$update_required = false;
|
275 |
-
$update_complete = true;
|
276 |
-
|
277 |
-
foreach( $activation_codes as $k => $v )
|
278 |
-
{
|
279 |
-
if( $v )
|
280 |
-
{
|
281 |
-
$update_required = true;
|
282 |
-
|
283 |
-
if( !$active[ $k ] )
|
284 |
-
{
|
285 |
-
$update_complete = false;
|
286 |
-
}
|
287 |
-
}
|
288 |
-
}
|
289 |
-
|
290 |
-
|
291 |
-
?>
|
292 |
-
|
293 |
-
<table id="acf-add-ons-table" class="alignright">
|
294 |
-
<tr>
|
295 |
-
<td><img src="<?php echo $dir; ?>images/add-ons/repeater-field-thumb.jpg" /></td>
|
296 |
-
<td><img src="<?php echo $dir; ?>images/add-ons/gallery-field-thumb.jpg" /></td>
|
297 |
-
</tr>
|
298 |
-
<tr>
|
299 |
-
<td><img src="<?php echo $dir; ?>images/add-ons/options-page-thumb.jpg" /></td>
|
300 |
-
<td><img src="<?php echo $dir; ?>images/add-ons/flexible-content-field-thumb.jpg" /></td>
|
301 |
-
</tr>
|
302 |
-
</table>
|
303 |
-
|
304 |
-
<div style="margin-right: 300px;">
|
305 |
-
|
306 |
-
<h3><?php _e("Add-ons",'acf'); ?></h3>
|
307 |
-
|
308 |
-
<h4><?php _e("Activation codes have grown into plugins!",'acf'); ?></h4>
|
309 |
-
<p><?php _e("Add-ons are now activated by downloading and installing individual plugins. Although these plugins will not be hosted on the wordpress.org repository, each Add-on will continue to receive updates in the usual way.",'acf'); ?></p>
|
310 |
-
|
311 |
-
|
312 |
-
<?php if( $update_required ): ?>
|
313 |
-
<?php if( $update_complete ): ?>
|
314 |
-
<div class="acf-alert acf-alert-success">
|
315 |
-
<p><?php _e("All previous Add-ons have been successfully installed",'acf'); ?></p>
|
316 |
-
</div>
|
317 |
-
<?php else: ?>
|
318 |
-
<div class="acf-alert acf-alert-success">
|
319 |
-
<p><?php _e("This website uses premium Add-ons which need to be downloaded",'acf'); ?> <a href="<?php echo admin_url('edit.php?post_type=acf&info=download-add-ons'); ?>" class="acf-button" style="display: inline-block;"><?php _e("Download your activated Add-ons",'acf'); ?></a></p>
|
320 |
-
</div>
|
321 |
-
<?php endif; ?>
|
322 |
-
<?php else: ?>
|
323 |
-
<div class="acf-alert acf-alert-success">
|
324 |
-
<p><?php _e("This website does not use premium Add-ons and will not be affected by this change.",'acf'); ?></p>
|
325 |
-
</div>
|
326 |
-
<?php endif; ?>
|
327 |
-
|
328 |
-
</div>
|
329 |
-
|
330 |
-
<div class="clear"></div>
|
331 |
-
|
332 |
-
<hr />
|
333 |
-
|
334 |
-
<h3><?php _e("Easier Development",'acf'); ?></h3>
|
335 |
-
|
336 |
-
<h4><?php _e("New Field Types",'acf'); ?></h4>
|
337 |
-
<ul>
|
338 |
-
<li><?php _e("Taxonomy Field",'acf'); ?></li>
|
339 |
-
<li><?php _e("User Field",'acf'); ?></li>
|
340 |
-
<li><?php _e("Email Field",'acf'); ?></li>
|
341 |
-
<li><?php _e("Password Field",'acf'); ?></li>
|
342 |
-
</ul>
|
343 |
-
<h4><?php _e("Custom Field Types",'acf'); ?></h4>
|
344 |
-
<p><?php _e("Creating your own field type has never been easier! Unfortunately, version 3 field types are not compatible with version 4.",'acf'); ?><br />
|
345 |
-
<?php printf(__('Migrating your field types is easy, please %sfollow this tutorial%s to learn more.','acf'),'<a href="http://www.advancedcustomfields.com/docs/tutorials/creating-a-new-field-type/" target="_blank">','</a>'); ?></p>
|
346 |
-
|
347 |
-
<h4><?php _e("Actions & Filters",'acf'); ?></h4>
|
348 |
-
<p><?php printf(__('All actions & filters have received a major facelift to make customizing ACF even easier! Please %sread this guide%s to find the updated naming convention.','acf'),'<a href="http://www.advancedcustomfields.com/resources/getting-started/migrating-from-v3-to-v4/" target="_blank">','</a>'); ?></p>
|
349 |
-
|
350 |
-
<h4><?php _e("Preview draft is now working!",'acf'); ?></h4>
|
351 |
-
<p><?php _e("This bug has been squashed along with many other little critters!",'acf'); ?> <a class="acf-tab-toggle" href="<?php echo admin_url('edit.php?post_type=acf&info=changelog'); ?>" data-tab="2"><?php _e("See the full changelog",'acf'); ?></a></p>
|
352 |
-
|
353 |
-
<hr />
|
354 |
-
|
355 |
-
<h3><?php _e("Important",'acf'); ?></h3>
|
356 |
-
|
357 |
-
<h4><?php _e("Database Changes",'acf'); ?></h4>
|
358 |
-
<p><?php _e("Absolutely <strong>no</strong> changes have been made to the database between versions 3 and 4. This means you can roll back to version 3 without any issues.",'acf'); ?></p>
|
359 |
-
|
360 |
-
<h4><?php _e("Potential Issues",'acf'); ?></h4>
|
361 |
-
<p><?php printf(__('Due to the sizable changes surrounding Add-ons, field types and action/filters, your website may not operate correctly. It is important that you read the full %sMigrating from v3 to v4%s guide to view the full list of changes.','acf'),'<a href="http://www.advancedcustomfields.com/resources/getting-started/migrating-from-v3-to-v4/" target="_blank">','</a>'); ?></p>
|
362 |
-
|
363 |
-
<div class="acf-alert acf-alert-error">
|
364 |
-
<p><strong><?php _e("Really Important!",'acf'); ?></strong> <?php printf(__('If you updated the ACF plugin without prior knowledge of such changes, please roll back to the latest %sversion 3%s of this plugin.','acf'),'<a href="http://wordpress.org/extend/plugins/advanced-custom-fields/developers/">','</a>'); ?></p>
|
365 |
-
</div>
|
366 |
-
|
367 |
-
<hr />
|
368 |
-
|
369 |
-
<h3><?php _e("Thank You",'acf'); ?></h3>
|
370 |
-
<p><?php _e("A <strong>BIG</strong> thank you to everyone who has helped test the version 4 beta and for all the support I have received.",'acf'); ?></p>
|
371 |
-
<p><?php _e("Without you all, this release would not have been possible!",'acf'); ?></p>
|
372 |
-
|
373 |
-
<?php elseif( $tab == 'changelog' ): ?>
|
374 |
-
|
375 |
-
<h3><?php _e("Changelog for",'acf'); ?> <?php echo $version; ?></h3>
|
376 |
-
<?php
|
377 |
-
|
378 |
-
$items = file_get_contents( $path . 'readme.txt' );
|
379 |
-
$items = explode('= ' . $version . ' =', $items);
|
380 |
-
|
381 |
-
$items = end( $items );
|
382 |
-
$items = current( explode("\n\n", $items) );
|
383 |
-
$items = array_filter( array_map('trim', explode("*", $items)) );
|
384 |
-
|
385 |
-
?>
|
386 |
-
<ul class="acf-changelog">
|
387 |
-
<?php foreach( $items as $item ):
|
388 |
-
|
389 |
-
$item = explode('http', $item);
|
390 |
-
|
391 |
-
?>
|
392 |
-
<li><?php echo $item[0]; ?><?php if( isset($item[1]) ): ?><a href="http<?php echo $item[1]; ?>" target="_blank"><?php _e("Learn more",'acf'); ?></a><?php endif; ?></li>
|
393 |
-
<?php endforeach; ?>
|
394 |
-
</ul>
|
395 |
-
|
396 |
-
<?php elseif( $tab == 'download-add-ons' ): ?>
|
397 |
-
|
398 |
-
<h3><?php _e("Overview",'acf'); ?></h3>
|
399 |
-
|
400 |
-
<p><?php _e("Previously, all Add-ons were unlocked via an activation code (purchased from the ACF Add-ons store). New to v4, all Add-ons act as separate plugins which need to be individually downloaded, installed and updated.",'acf'); ?></p>
|
401 |
-
|
402 |
-
<p><?php _e("This page will assist you in downloading and installing each available Add-on.",'acf'); ?></p>
|
403 |
-
|
404 |
-
<h3><?php _e("Available Add-ons",'acf'); ?></h3>
|
405 |
-
|
406 |
-
<p><?php _e("The following Add-ons have been detected as activated on this website.",'acf'); ?></p>
|
407 |
-
|
408 |
-
<?php
|
409 |
-
|
410 |
-
$ac_repeater = get_option('acf_repeater_ac', '');
|
411 |
-
$ac_options_page = get_option('acf_options_page_ac', '');
|
412 |
-
$ac_flexible_content = get_option('acf_flexible_content_ac', '');
|
413 |
-
$ac_gallery = get_option('acf_gallery_ac', '');
|
414 |
-
|
415 |
-
?>
|
416 |
-
<table class="widefat" id="acf-download-add-ons-table">
|
417 |
-
<thead>
|
418 |
-
<tr>
|
419 |
-
<th colspan="2"><?php _e("Name",'acf'); ?></th>
|
420 |
-
<th><?php _e("Activation Code",'acf'); ?></th>
|
421 |
-
<th><?php _e("Download",'acf'); ?></th>
|
422 |
-
</tr>
|
423 |
-
</thead>
|
424 |
-
<tbody>
|
425 |
-
<?php if( $ac_repeater ): ?>
|
426 |
-
<tr>
|
427 |
-
<td class="td-image"><img src="<?php echo $dir; ?>images/add-ons/repeater-field-thumb.jpg" style="width:50px" /></td>
|
428 |
-
<th class="td-name"><?php _e("Repeater Field",'acf'); ?></th>
|
429 |
-
<td class="td-code">XXXX-XXXX-XXXX-<?php echo substr($ac_repeater,-4); ?></td>
|
430 |
-
<td class="td-download"><a class="button" href="http://download.advancedcustomfields.com/<?php echo $ac_repeater; ?>/trunk"><?php _e("Download",'acf'); ?></a></td>
|
431 |
-
</tr>
|
432 |
-
<?php endif; ?>
|
433 |
-
<?php if( $ac_gallery ): ?>
|
434 |
-
<tr>
|
435 |
-
<td><img src="<?php echo $dir; ?>images/add-ons/gallery-field-thumb.jpg" /></td>
|
436 |
-
<th><?php _e("Gallery Field",'acf'); ?></th>
|
437 |
-
<td>XXXX-XXXX-XXXX-<?php echo substr($ac_gallery,-4); ?></td>
|
438 |
-
<td><a class="button" href="http://download.advancedcustomfields.com/<?php echo $ac_gallery; ?>/trunk"><?php _e("Download",'acf'); ?></a></td>
|
439 |
-
</tr>
|
440 |
-
<?php endif; ?>
|
441 |
-
<?php if( $ac_options_page ): ?>
|
442 |
-
<tr>
|
443 |
-
<td><img src="<?php echo $dir; ?>images/add-ons/options-page-thumb.jpg" /></td>
|
444 |
-
<th><?php _e("Options Page",'acf'); ?></th>
|
445 |
-
<td>XXXX-XXXX-XXXX-<?php echo substr($ac_options_page,-4); ?></td>
|
446 |
-
<td><a class="button" href="http://download.advancedcustomfields.com/<?php echo $ac_options_page; ?>/trunk"><?php _e("Download",'acf'); ?></a></td>
|
447 |
-
</tr>
|
448 |
-
<?php endif; ?>
|
449 |
-
<?php if($ac_flexible_content): ?>
|
450 |
-
<tr>
|
451 |
-
<td><img src="<?php echo $dir; ?>images/add-ons/flexible-content-field-thumb.jpg" /></td>
|
452 |
-
<th><?php _e("Flexible Content",'acf'); ?></th>
|
453 |
-
<td>XXXX-XXXX-XXXX-<?php echo substr($ac_flexible_content,-4); ?></td>
|
454 |
-
<td><a class="button" href="http://download.advancedcustomfields.com/<?php echo $ac_flexible_content; ?>/trunk"><?php _e("Download",'acf'); ?></a></td>
|
455 |
-
</tr>
|
456 |
-
<?php endif; ?>
|
457 |
-
</tbody>
|
458 |
-
</table>
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
<h3><?php _e("Installation",'acf'); ?></h3>
|
463 |
-
|
464 |
-
<p><?php _e("For each Add-on available, please perform the following:",'acf'); ?></p>
|
465 |
-
<ol>
|
466 |
-
<li><?php _e("Download the Add-on plugin (.zip file) to your desktop",'acf'); ?></li>
|
467 |
-
<li><?php printf(__('Navigate to %sPlugins > Add New > Upload%s','acf'),'<a target="_blank" href="'.admin_url('plugin-install.php?tab=upload').'">','</a>'); ?></li>
|
468 |
-
<li><?php _e("Use the uploader to browse, select and install your Add-on (.zip file)",'acf'); ?></li>
|
469 |
-
<li><?php _e("Once the plugin has been uploaded and installed, click the 'Activate Plugin' link",'acf'); ?></li>
|
470 |
-
<li><?php _e("The Add-on is now installed and activated!",'acf'); ?></li>
|
471 |
-
</ol>
|
472 |
-
|
473 |
-
|
474 |
-
<?php endif; ?>
|
475 |
-
|
476 |
-
|
477 |
-
</div>
|
478 |
-
<!-- / acf-content-body -->
|
479 |
-
|
480 |
-
|
481 |
-
<!-- acf-content-footer -->
|
482 |
-
<div class="acf-content-footer">
|
483 |
-
<ul class="hl clearfix">
|
484 |
-
<li><a class="acf-button acf-button-big" href="<?php echo admin_url('edit.php?post_type=acf'); ?>"><?php _e("Awesome. Let's get to work",'acf'); ?></a></li>
|
485 |
-
</ul>
|
486 |
-
</div>
|
487 |
-
<!-- / acf-content-footer -->
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
</div>
|
492 |
-
<!-- / acf-about -->
|
493 |
-
</script>
|
494 |
-
<script type="text/javascript">
|
495 |
-
(function($){
|
496 |
-
|
497 |
-
// wrap
|
498 |
-
$('#wpbody .wrap').attr('id', 'acf-field-group-wrap');
|
499 |
-
|
500 |
-
|
501 |
-
// wrap column main
|
502 |
-
$('#acf-field-group-wrap').wrapInner('<div class="acf-columns-2" />');
|
503 |
-
|
504 |
-
|
505 |
-
// add column main
|
506 |
-
$('#posts-filter').addClass('acf-column-1');
|
507 |
-
|
508 |
-
|
509 |
-
// add column side
|
510 |
-
$('#posts-filter').after( $('#tmpl-acf-column-2').html() );
|
511 |
-
|
512 |
-
|
513 |
-
<?php if( $show_tab ): ?>
|
514 |
-
// add about copy
|
515 |
-
$('#wpbody-content').prepend( $('#tmpl-acf-about').html() );
|
516 |
-
$('#acf-field-group-wrap').hide();
|
517 |
-
$('#screen-meta-links').hide();
|
518 |
-
<?php endif; ?>
|
519 |
-
|
520 |
-
})(jQuery);
|
521 |
-
</script>
|
522 |
-
<?php
|
523 |
-
}
|
524 |
-
|
525 |
-
}
|
526 |
-
|
527 |
-
new acf_field_groups();
|
528 |
-
|
529 |
-
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* acf_field_groups
|
5 |
+
*
|
6 |
+
* @description:
|
7 |
+
* @since: 3.6
|
8 |
+
* @created: 25/01/13
|
9 |
+
*/
|
10 |
+
|
11 |
+
class acf_field_groups
|
12 |
+
{
|
13 |
+
|
14 |
+
/*
|
15 |
+
* __construct
|
16 |
+
*
|
17 |
+
* @description:
|
18 |
+
* @since 3.1.8
|
19 |
+
* @created: 23/06/12
|
20 |
+
*/
|
21 |
+
|
22 |
+
function __construct()
|
23 |
+
{
|
24 |
+
// actions
|
25 |
+
add_action('admin_menu', array($this,'admin_menu'));
|
26 |
+
}
|
27 |
+
|
28 |
+
|
29 |
+
/*
|
30 |
+
* admin_menu
|
31 |
+
*
|
32 |
+
* @description:
|
33 |
+
* @created: 2/08/12
|
34 |
+
*/
|
35 |
+
|
36 |
+
function admin_menu()
|
37 |
+
{
|
38 |
+
|
39 |
+
// validate page
|
40 |
+
if( ! $this->validate_page() )
|
41 |
+
{
|
42 |
+
return;
|
43 |
+
}
|
44 |
+
|
45 |
+
|
46 |
+
// actions
|
47 |
+
add_action('admin_print_scripts', array($this,'admin_print_scripts'));
|
48 |
+
add_action('admin_print_styles', array($this,'admin_print_styles'));
|
49 |
+
add_action('admin_footer', array($this,'admin_footer'));
|
50 |
+
|
51 |
+
|
52 |
+
// columns
|
53 |
+
add_filter( 'manage_edit-acf_columns', array($this,'acf_edit_columns'), 10, 1 );
|
54 |
+
add_action( 'manage_acf_posts_custom_column' , array($this,'acf_columns_display'), 10, 2 );
|
55 |
+
|
56 |
+
}
|
57 |
+
|
58 |
+
|
59 |
+
/*
|
60 |
+
* validate_page
|
61 |
+
*
|
62 |
+
* @description: returns true | false. Used to stop a function from continuing
|
63 |
+
* @since 3.2.6
|
64 |
+
* @created: 23/06/12
|
65 |
+
*/
|
66 |
+
|
67 |
+
function validate_page()
|
68 |
+
{
|
69 |
+
// global
|
70 |
+
global $pagenow;
|
71 |
+
|
72 |
+
|
73 |
+
// vars
|
74 |
+
$return = false;
|
75 |
+
|
76 |
+
|
77 |
+
// validate page
|
78 |
+
if( in_array( $pagenow, array('edit.php') ) )
|
79 |
+
{
|
80 |
+
|
81 |
+
// validate post type
|
82 |
+
if( isset($_GET['post_type']) && $_GET['post_type'] == 'acf' )
|
83 |
+
{
|
84 |
+
$return = true;
|
85 |
+
}
|
86 |
+
|
87 |
+
|
88 |
+
if( isset($_GET['page']) )
|
89 |
+
{
|
90 |
+
$return = false;
|
91 |
+
}
|
92 |
+
|
93 |
+
}
|
94 |
+
|
95 |
+
|
96 |
+
// return
|
97 |
+
return $return;
|
98 |
+
}
|
99 |
+
|
100 |
+
|
101 |
+
/*
|
102 |
+
* admin_print_scripts
|
103 |
+
*
|
104 |
+
* @description:
|
105 |
+
* @since 3.1.8
|
106 |
+
* @created: 23/06/12
|
107 |
+
*/
|
108 |
+
|
109 |
+
function admin_print_scripts()
|
110 |
+
{
|
111 |
+
wp_enqueue_script(array(
|
112 |
+
'jquery',
|
113 |
+
'thickbox',
|
114 |
+
));
|
115 |
+
}
|
116 |
+
|
117 |
+
|
118 |
+
/*
|
119 |
+
* admin_print_styles
|
120 |
+
*
|
121 |
+
* @description:
|
122 |
+
* @since 3.1.8
|
123 |
+
* @created: 23/06/12
|
124 |
+
*/
|
125 |
+
|
126 |
+
function admin_print_styles()
|
127 |
+
{
|
128 |
+
wp_enqueue_style(array(
|
129 |
+
'thickbox',
|
130 |
+
'acf-global',
|
131 |
+
'acf',
|
132 |
+
));
|
133 |
+
}
|
134 |
+
|
135 |
+
|
136 |
+
/*
|
137 |
+
* acf_edit_columns
|
138 |
+
*
|
139 |
+
* @description:
|
140 |
+
* @created: 2/08/12
|
141 |
+
*/
|
142 |
+
|
143 |
+
function acf_edit_columns( $columns )
|
144 |
+
{
|
145 |
+
$columns = array(
|
146 |
+
'cb' => '<input type="checkbox" />',
|
147 |
+
'title' => __("Title"),
|
148 |
+
'fields' => __("Fields", 'acf')
|
149 |
+
);
|
150 |
+
|
151 |
+
return $columns;
|
152 |
+
}
|
153 |
+
|
154 |
+
|
155 |
+
/*
|
156 |
+
* acf_columns_display
|
157 |
+
*
|
158 |
+
* @description:
|
159 |
+
* @created: 2/08/12
|
160 |
+
*/
|
161 |
+
|
162 |
+
function acf_columns_display( $column, $post_id )
|
163 |
+
{
|
164 |
+
// vars
|
165 |
+
switch ($column)
|
166 |
+
{
|
167 |
+
case "fields":
|
168 |
+
|
169 |
+
// vars
|
170 |
+
$count =0;
|
171 |
+
$keys = get_post_custom_keys( $post_id );
|
172 |
+
|
173 |
+
if($keys)
|
174 |
+
{
|
175 |
+
foreach($keys as $key)
|
176 |
+
{
|
177 |
+
if(strpos($key, 'field_') !== false)
|
178 |
+
{
|
179 |
+
$count++;
|
180 |
+
}
|
181 |
+
}
|
182 |
+
}
|
183 |
+
|
184 |
+
echo $count;
|
185 |
+
|
186 |
+
break;
|
187 |
+
}
|
188 |
+
}
|
189 |
+
|
190 |
+
|
191 |
+
/*
|
192 |
+
* admin_footer
|
193 |
+
*
|
194 |
+
* @description:
|
195 |
+
* @since 3.1.8
|
196 |
+
* @created: 23/06/12
|
197 |
+
*/
|
198 |
+
|
199 |
+
function admin_footer()
|
200 |
+
{
|
201 |
+
// vars
|
202 |
+
$version = apply_filters('acf/get_info', 'version');
|
203 |
+
$dir = apply_filters('acf/get_info', 'dir');
|
204 |
+
$path = apply_filters('acf/get_info', 'path');
|
205 |
+
$show_tab = isset($_GET['info']);
|
206 |
+
$tab = isset($_GET['info']) ? $_GET['info'] : 'changelog';
|
207 |
+
|
208 |
+
?>
|
209 |
+
<script type="text/html" id="tmpl-acf-column-2">
|
210 |
+
<div class="acf-column-2">
|
211 |
+
<div class="wp-box">
|
212 |
+
<div class="inner">
|
213 |
+
<h2><?php _e("Advanced Custom Fields",'acf'); ?> <?php echo $version; ?></h2>
|
214 |
+
|
215 |
+
<h3><?php _e("Changelog",'acf'); ?></h3>
|
216 |
+
<p><?php printf(__('See what\'s new in %1$sversion %2$s%3$s','acf'),'<a href="'.admin_url('edit.php?post_type=acf&info=changelog').'">',$version,'</a>'); ?></p>
|
217 |
+
|
218 |
+
<h3><?php _e("Resources",'acf'); ?></h3>
|
219 |
+
<ul>
|
220 |
+
<li><a href="http://www.advancedcustomfields.com/resources/#getting-started" target="_blank"><?php _e("Getting Started",'acf'); ?></a></li>
|
221 |
+
<li><a href="http://www.advancedcustomfields.com/resources/#field-types" target="_blank"><?php _e("Field Types",'acf'); ?></a></li>
|
222 |
+
<li><a href="http://www.advancedcustomfields.com/resources/#functions" target="_blank"><?php _e("Functions",'acf'); ?></a></li>
|
223 |
+
<li><a href="http://www.advancedcustomfields.com/resources/#actions" target="_blank"><?php _e("Actions",'acf'); ?></a></li>
|
224 |
+
<li><a href="http://www.advancedcustomfields.com/resources/#filters" target="_blank"><?php _e("Filters",'acf'); ?></a></li>
|
225 |
+
<li><a href="http://www.advancedcustomfields.com/resources/#how-to" target="_blank"><?php _e("'How to' guides",'acf'); ?></a></li>
|
226 |
+
<li><a href="http://www.advancedcustomfields.com/resources/#tutorials" target="_blank"><?php _e("Tutorials",'acf'); ?></a></li>
|
227 |
+
</ul>
|
228 |
+
</div>
|
229 |
+
<div class="footer footer-blue">
|
230 |
+
<ul class="hl">
|
231 |
+
<li><?php _e("Created by",'acf'); ?> Elliot Condon</li>
|
232 |
+
</ul>
|
233 |
+
</div>
|
234 |
+
</div>
|
235 |
+
</div>
|
236 |
+
</script>
|
237 |
+
<script type="text/html" id="tmpl-acf-about">
|
238 |
+
<!-- acf-about -->
|
239 |
+
<div id="acf-about" class="acf-content">
|
240 |
+
|
241 |
+
<!-- acf-content-title -->
|
242 |
+
<div class="acf-content-title">
|
243 |
+
<h1><?php _e("Welcome to Advanced Custom Fields",'acf'); ?> <?php echo $version; ?></h1>
|
244 |
+
<h2><?php _e("Thank you for updating to the latest version!",'acf'); ?> <br /><?php printf(__('ACF %s is more polished and enjoyable than ever before. We hope you like it.','acf'),$version); ?></h2>
|
245 |
+
</div>
|
246 |
+
<!-- / acf-content-title -->
|
247 |
+
|
248 |
+
<!-- acf-content-body -->
|
249 |
+
<div class="acf-content-body">
|
250 |
+
<h2 class="nav-tab-wrapper">
|
251 |
+
<a class="acf-tab-toggle nav-tab <?php if( $tab == 'whats-new' ){ echo 'nav-tab-active'; } ?>" href="<?php echo admin_url('edit.php?post_type=acf&info=whats-new'); ?>"><?php _e("What’s New",'acf'); ?></a>
|
252 |
+
<a class="acf-tab-toggle nav-tab <?php if( $tab == 'changelog' ){ echo 'nav-tab-active'; } ?>" href="<?php echo admin_url('edit.php?post_type=acf&info=changelog'); ?>"><?php _e("Changelog",'acf'); ?></a>
|
253 |
+
<?php if( $tab == 'download-add-ons' ): ?>
|
254 |
+
<a class="acf-tab-toggle nav-tab nav-tab-active" href="<?php echo admin_url('edit.php?post_type=acf&info=download-add-ons'); ?>"><?php _e("Download Add-ons",'acf'); ?></a>
|
255 |
+
<?php endif; ?>
|
256 |
+
</h2>
|
257 |
+
|
258 |
+
<?php if( $tab == 'whats-new' ):
|
259 |
+
|
260 |
+
$activation_codes = array(
|
261 |
+
'repeater' => get_option('acf_repeater_ac', ''),
|
262 |
+
'gallery' => get_option('acf_gallery_ac', ''),
|
263 |
+
'options_page' => get_option('acf_options_page_ac', ''),
|
264 |
+
'flexible_content' => get_option('acf_flexible_content_ac', '')
|
265 |
+
);
|
266 |
+
|
267 |
+
$active = array(
|
268 |
+
'repeater' => class_exists('acf_field_repeater'),
|
269 |
+
'gallery' => class_exists('acf_field_gallery'),
|
270 |
+
'options_page' => class_exists('acf_options_page_plugin'),
|
271 |
+
'flexible_content' => class_exists('acf_field_flexible_content')
|
272 |
+
);
|
273 |
+
|
274 |
+
$update_required = false;
|
275 |
+
$update_complete = true;
|
276 |
+
|
277 |
+
foreach( $activation_codes as $k => $v )
|
278 |
+
{
|
279 |
+
if( $v )
|
280 |
+
{
|
281 |
+
$update_required = true;
|
282 |
+
|
283 |
+
if( !$active[ $k ] )
|
284 |
+
{
|
285 |
+
$update_complete = false;
|
286 |
+
}
|
287 |
+
}
|
288 |
+
}
|
289 |
+
|
290 |
+
|
291 |
+
?>
|
292 |
+
|
293 |
+
<table id="acf-add-ons-table" class="alignright">
|
294 |
+
<tr>
|
295 |
+
<td><img src="<?php echo $dir; ?>images/add-ons/repeater-field-thumb.jpg" /></td>
|
296 |
+
<td><img src="<?php echo $dir; ?>images/add-ons/gallery-field-thumb.jpg" /></td>
|
297 |
+
</tr>
|
298 |
+
<tr>
|
299 |
+
<td><img src="<?php echo $dir; ?>images/add-ons/options-page-thumb.jpg" /></td>
|
300 |
+
<td><img src="<?php echo $dir; ?>images/add-ons/flexible-content-field-thumb.jpg" /></td>
|
301 |
+
</tr>
|
302 |
+
</table>
|
303 |
+
|
304 |
+
<div style="margin-right: 300px;">
|
305 |
+
|
306 |
+
<h3><?php _e("Add-ons",'acf'); ?></h3>
|
307 |
+
|
308 |
+
<h4><?php _e("Activation codes have grown into plugins!",'acf'); ?></h4>
|
309 |
+
<p><?php _e("Add-ons are now activated by downloading and installing individual plugins. Although these plugins will not be hosted on the wordpress.org repository, each Add-on will continue to receive updates in the usual way.",'acf'); ?></p>
|
310 |
+
|
311 |
+
|
312 |
+
<?php if( $update_required ): ?>
|
313 |
+
<?php if( $update_complete ): ?>
|
314 |
+
<div class="acf-alert acf-alert-success">
|
315 |
+
<p><?php _e("All previous Add-ons have been successfully installed",'acf'); ?></p>
|
316 |
+
</div>
|
317 |
+
<?php else: ?>
|
318 |
+
<div class="acf-alert acf-alert-success">
|
319 |
+
<p><?php _e("This website uses premium Add-ons which need to be downloaded",'acf'); ?> <a href="<?php echo admin_url('edit.php?post_type=acf&info=download-add-ons'); ?>" class="acf-button" style="display: inline-block;"><?php _e("Download your activated Add-ons",'acf'); ?></a></p>
|
320 |
+
</div>
|
321 |
+
<?php endif; ?>
|
322 |
+
<?php else: ?>
|
323 |
+
<div class="acf-alert acf-alert-success">
|
324 |
+
<p><?php _e("This website does not use premium Add-ons and will not be affected by this change.",'acf'); ?></p>
|
325 |
+
</div>
|
326 |
+
<?php endif; ?>
|
327 |
+
|
328 |
+
</div>
|
329 |
+
|
330 |
+
<div class="clear"></div>
|
331 |
+
|
332 |
+
<hr />
|
333 |
+
|
334 |
+
<h3><?php _e("Easier Development",'acf'); ?></h3>
|
335 |
+
|
336 |
+
<h4><?php _e("New Field Types",'acf'); ?></h4>
|
337 |
+
<ul>
|
338 |
+
<li><?php _e("Taxonomy Field",'acf'); ?></li>
|
339 |
+
<li><?php _e("User Field",'acf'); ?></li>
|
340 |
+
<li><?php _e("Email Field",'acf'); ?></li>
|
341 |
+
<li><?php _e("Password Field",'acf'); ?></li>
|
342 |
+
</ul>
|
343 |
+
<h4><?php _e("Custom Field Types",'acf'); ?></h4>
|
344 |
+
<p><?php _e("Creating your own field type has never been easier! Unfortunately, version 3 field types are not compatible with version 4.",'acf'); ?><br />
|
345 |
+
<?php printf(__('Migrating your field types is easy, please %sfollow this tutorial%s to learn more.','acf'),'<a href="http://www.advancedcustomfields.com/docs/tutorials/creating-a-new-field-type/" target="_blank">','</a>'); ?></p>
|
346 |
+
|
347 |
+
<h4><?php _e("Actions & Filters",'acf'); ?></h4>
|
348 |
+
<p><?php printf(__('All actions & filters have received a major facelift to make customizing ACF even easier! Please %sread this guide%s to find the updated naming convention.','acf'),'<a href="http://www.advancedcustomfields.com/resources/getting-started/migrating-from-v3-to-v4/" target="_blank">','</a>'); ?></p>
|
349 |
+
|
350 |
+
<h4><?php _e("Preview draft is now working!",'acf'); ?></h4>
|
351 |
+
<p><?php _e("This bug has been squashed along with many other little critters!",'acf'); ?> <a class="acf-tab-toggle" href="<?php echo admin_url('edit.php?post_type=acf&info=changelog'); ?>" data-tab="2"><?php _e("See the full changelog",'acf'); ?></a></p>
|
352 |
+
|
353 |
+
<hr />
|
354 |
+
|
355 |
+
<h3><?php _e("Important",'acf'); ?></h3>
|
356 |
+
|
357 |
+
<h4><?php _e("Database Changes",'acf'); ?></h4>
|
358 |
+
<p><?php _e("Absolutely <strong>no</strong> changes have been made to the database between versions 3 and 4. This means you can roll back to version 3 without any issues.",'acf'); ?></p>
|
359 |
+
|
360 |
+
<h4><?php _e("Potential Issues",'acf'); ?></h4>
|
361 |
+
<p><?php printf(__('Due to the sizable changes surrounding Add-ons, field types and action/filters, your website may not operate correctly. It is important that you read the full %sMigrating from v3 to v4%s guide to view the full list of changes.','acf'),'<a href="http://www.advancedcustomfields.com/resources/getting-started/migrating-from-v3-to-v4/" target="_blank">','</a>'); ?></p>
|
362 |
+
|
363 |
+
<div class="acf-alert acf-alert-error">
|
364 |
+
<p><strong><?php _e("Really Important!",'acf'); ?></strong> <?php printf(__('If you updated the ACF plugin without prior knowledge of such changes, please roll back to the latest %sversion 3%s of this plugin.','acf'),'<a href="http://wordpress.org/extend/plugins/advanced-custom-fields/developers/">','</a>'); ?></p>
|
365 |
+
</div>
|
366 |
+
|
367 |
+
<hr />
|
368 |
+
|
369 |
+
<h3><?php _e("Thank You",'acf'); ?></h3>
|
370 |
+
<p><?php _e("A <strong>BIG</strong> thank you to everyone who has helped test the version 4 beta and for all the support I have received.",'acf'); ?></p>
|
371 |
+
<p><?php _e("Without you all, this release would not have been possible!",'acf'); ?></p>
|
372 |
+
|
373 |
+
<?php elseif( $tab == 'changelog' ): ?>
|
374 |
+
|
375 |
+
<h3><?php _e("Changelog for",'acf'); ?> <?php echo $version; ?></h3>
|
376 |
+
<?php
|
377 |
+
|
378 |
+
$items = file_get_contents( $path . 'readme.txt' );
|
379 |
+
$items = explode('= ' . $version . ' =', $items);
|
380 |
+
|
381 |
+
$items = end( $items );
|
382 |
+
$items = current( explode("\n\n", $items) );
|
383 |
+
$items = array_filter( array_map('trim', explode("*", $items)) );
|
384 |
+
|
385 |
+
?>
|
386 |
+
<ul class="acf-changelog">
|
387 |
+
<?php foreach( $items as $item ):
|
388 |
+
|
389 |
+
$item = explode('http', $item);
|
390 |
+
|
391 |
+
?>
|
392 |
+
<li><?php echo $item[0]; ?><?php if( isset($item[1]) ): ?><a href="http<?php echo $item[1]; ?>" target="_blank"><?php _e("Learn more",'acf'); ?></a><?php endif; ?></li>
|
393 |
+
<?php endforeach; ?>
|
394 |
+
</ul>
|
395 |
+
|
396 |
+
<?php elseif( $tab == 'download-add-ons' ): ?>
|
397 |
+
|
398 |
+
<h3><?php _e("Overview",'acf'); ?></h3>
|
399 |
+
|
400 |
+
<p><?php _e("Previously, all Add-ons were unlocked via an activation code (purchased from the ACF Add-ons store). New to v4, all Add-ons act as separate plugins which need to be individually downloaded, installed and updated.",'acf'); ?></p>
|
401 |
+
|
402 |
+
<p><?php _e("This page will assist you in downloading and installing each available Add-on.",'acf'); ?></p>
|
403 |
+
|
404 |
+
<h3><?php _e("Available Add-ons",'acf'); ?></h3>
|
405 |
+
|
406 |
+
<p><?php _e("The following Add-ons have been detected as activated on this website.",'acf'); ?></p>
|
407 |
+
|
408 |
+
<?php
|
409 |
+
|
410 |
+
$ac_repeater = get_option('acf_repeater_ac', '');
|
411 |
+
$ac_options_page = get_option('acf_options_page_ac', '');
|
412 |
+
$ac_flexible_content = get_option('acf_flexible_content_ac', '');
|
413 |
+
$ac_gallery = get_option('acf_gallery_ac', '');
|
414 |
+
|
415 |
+
?>
|
416 |
+
<table class="widefat" id="acf-download-add-ons-table">
|
417 |
+
<thead>
|
418 |
+
<tr>
|
419 |
+
<th colspan="2"><?php _e("Name",'acf'); ?></th>
|
420 |
+
<th><?php _e("Activation Code",'acf'); ?></th>
|
421 |
+
<th><?php _e("Download",'acf'); ?></th>
|
422 |
+
</tr>
|
423 |
+
</thead>
|
424 |
+
<tbody>
|
425 |
+
<?php if( $ac_repeater ): ?>
|
426 |
+
<tr>
|
427 |
+
<td class="td-image"><img src="<?php echo $dir; ?>images/add-ons/repeater-field-thumb.jpg" style="width:50px" /></td>
|
428 |
+
<th class="td-name"><?php _e("Repeater Field",'acf'); ?></th>
|
429 |
+
<td class="td-code">XXXX-XXXX-XXXX-<?php echo substr($ac_repeater,-4); ?></td>
|
430 |
+
<td class="td-download"><a class="button" href="http://download.advancedcustomfields.com/<?php echo $ac_repeater; ?>/trunk"><?php _e("Download",'acf'); ?></a></td>
|
431 |
+
</tr>
|
432 |
+
<?php endif; ?>
|
433 |
+
<?php if( $ac_gallery ): ?>
|
434 |
+
<tr>
|
435 |
+
<td><img src="<?php echo $dir; ?>images/add-ons/gallery-field-thumb.jpg" /></td>
|
436 |
+
<th><?php _e("Gallery Field",'acf'); ?></th>
|
437 |
+
<td>XXXX-XXXX-XXXX-<?php echo substr($ac_gallery,-4); ?></td>
|
438 |
+
<td><a class="button" href="http://download.advancedcustomfields.com/<?php echo $ac_gallery; ?>/trunk"><?php _e("Download",'acf'); ?></a></td>
|
439 |
+
</tr>
|
440 |
+
<?php endif; ?>
|
441 |
+
<?php if( $ac_options_page ): ?>
|
442 |
+
<tr>
|
443 |
+
<td><img src="<?php echo $dir; ?>images/add-ons/options-page-thumb.jpg" /></td>
|
444 |
+
<th><?php _e("Options Page",'acf'); ?></th>
|
445 |
+
<td>XXXX-XXXX-XXXX-<?php echo substr($ac_options_page,-4); ?></td>
|
446 |
+
<td><a class="button" href="http://download.advancedcustomfields.com/<?php echo $ac_options_page; ?>/trunk"><?php _e("Download",'acf'); ?></a></td>
|
447 |
+
</tr>
|
448 |
+
<?php endif; ?>
|
449 |
+
<?php if($ac_flexible_content): ?>
|
450 |
+
<tr>
|
451 |
+
<td><img src="<?php echo $dir; ?>images/add-ons/flexible-content-field-thumb.jpg" /></td>
|
452 |
+
<th><?php _e("Flexible Content",'acf'); ?></th>
|
453 |
+
<td>XXXX-XXXX-XXXX-<?php echo substr($ac_flexible_content,-4); ?></td>
|
454 |
+
<td><a class="button" href="http://download.advancedcustomfields.com/<?php echo $ac_flexible_content; ?>/trunk"><?php _e("Download",'acf'); ?></a></td>
|
455 |
+
</tr>
|
456 |
+
<?php endif; ?>
|
457 |
+
</tbody>
|
458 |
+
</table>
|
459 |
+
|
460 |
+
|
461 |
+
|
462 |
+
<h3><?php _e("Installation",'acf'); ?></h3>
|
463 |
+
|
464 |
+
<p><?php _e("For each Add-on available, please perform the following:",'acf'); ?></p>
|
465 |
+
<ol>
|
466 |
+
<li><?php _e("Download the Add-on plugin (.zip file) to your desktop",'acf'); ?></li>
|
467 |
+
<li><?php printf(__('Navigate to %sPlugins > Add New > Upload%s','acf'),'<a target="_blank" href="'.admin_url('plugin-install.php?tab=upload').'">','</a>'); ?></li>
|
468 |
+
<li><?php _e("Use the uploader to browse, select and install your Add-on (.zip file)",'acf'); ?></li>
|
469 |
+
<li><?php _e("Once the plugin has been uploaded and installed, click the 'Activate Plugin' link",'acf'); ?></li>
|
470 |
+
<li><?php _e("The Add-on is now installed and activated!",'acf'); ?></li>
|
471 |
+
</ol>
|
472 |
+
|
473 |
+
|
474 |
+
<?php endif; ?>
|
475 |
+
|
476 |
+
|
477 |
+
</div>
|
478 |
+
<!-- / acf-content-body -->
|
479 |
+
|
480 |
+
|
481 |
+
<!-- acf-content-footer -->
|
482 |
+
<div class="acf-content-footer">
|
483 |
+
<ul class="hl clearfix">
|
484 |
+
<li><a class="acf-button acf-button-big" href="<?php echo admin_url('edit.php?post_type=acf'); ?>"><?php _e("Awesome. Let's get to work",'acf'); ?></a></li>
|
485 |
+
</ul>
|
486 |
+
</div>
|
487 |
+
<!-- / acf-content-footer -->
|
488 |
+
|
489 |
+
|
490 |
+
|
491 |
+
</div>
|
492 |
+
<!-- / acf-about -->
|
493 |
+
</script>
|
494 |
+
<script type="text/javascript">
|
495 |
+
(function($){
|
496 |
+
|
497 |
+
// wrap
|
498 |
+
$('#wpbody .wrap').attr('id', 'acf-field-group-wrap');
|
499 |
+
|
500 |
+
|
501 |
+
// wrap column main
|
502 |
+
$('#acf-field-group-wrap').wrapInner('<div class="acf-columns-2" />');
|
503 |
+
|
504 |
+
|
505 |
+
// add column main
|
506 |
+
$('#posts-filter').addClass('acf-column-1');
|
507 |
+
|
508 |
+
|
509 |
+
// add column side
|
510 |
+
$('#posts-filter').after( $('#tmpl-acf-column-2').html() );
|
511 |
+
|
512 |
+
|
513 |
+
<?php if( $show_tab ): ?>
|
514 |
+
// add about copy
|
515 |
+
$('#wpbody-content').prepend( $('#tmpl-acf-about').html() );
|
516 |
+
$('#acf-field-group-wrap').hide();
|
517 |
+
$('#screen-meta-links').hide();
|
518 |
+
<?php endif; ?>
|
519 |
+
|
520 |
+
})(jQuery);
|
521 |
+
</script>
|
522 |
+
<?php
|
523 |
+
}
|
524 |
+
|
525 |
+
}
|
526 |
+
|
527 |
+
new acf_field_groups();
|
528 |
+
|
529 |
+
?>
|
shared/assets/plugins/advanced-custom-fields/core/controllers/input.php
CHANGED
@@ -1,170 +1,170 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* acf_controller_input
|
5 |
-
*
|
6 |
-
* This class contains the functionality for input actions used throughout ACF
|
7 |
-
*
|
8 |
-
* @type class
|
9 |
-
* @date 5/09/13
|
10 |
-
* @since 3.1.8
|
11 |
-
*
|
12 |
-
*/
|
13 |
-
|
14 |
-
class acf_controller_input
|
15 |
-
{
|
16 |
-
|
17 |
-
/*
|
18 |
-
* __construct
|
19 |
-
*
|
20 |
-
* @description:
|
21 |
-
* @since 3.1.8
|
22 |
-
* @created: 23/06/12
|
23 |
-
*/
|
24 |
-
|
25 |
-
function __construct()
|
26 |
-
{
|
27 |
-
// actions
|
28 |
-
add_action('acf/input/admin_head', array($this, 'input_admin_head'));
|
29 |
-
add_action('acf/input/admin_enqueue_scripts', array($this, 'input_admin_enqueue_scripts'));
|
30 |
-
}
|
31 |
-
|
32 |
-
|
33 |
-
/*
|
34 |
-
* input_admin_head
|
35 |
-
*
|
36 |
-
* action called when rendering the head of an admin screen. Used primarily for passing PHP to JS
|
37 |
-
*
|
38 |
-
* @type action
|
39 |
-
* @date 27/05/13
|
40 |
-
*
|
41 |
-
* @param N/A
|
42 |
-
* @return N/A
|
43 |
-
*/
|
44 |
-
|
45 |
-
function input_admin_head()
|
46 |
-
{
|
47 |
-
// global
|
48 |
-
global $wp_version, $post;
|
49 |
-
|
50 |
-
|
51 |
-
// vars
|
52 |
-
$toolbars = apply_filters( 'acf/fields/wysiwyg/toolbars', array() );
|
53 |
-
$post_id = 0;
|
54 |
-
if( $post )
|
55 |
-
{
|
56 |
-
$post_id = intval( $post->ID );
|
57 |
-
}
|
58 |
-
|
59 |
-
|
60 |
-
// l10n
|
61 |
-
$l10n = apply_filters( 'acf/input/admin_l10n', array(
|
62 |
-
'core' => array(
|
63 |
-
'expand_details' => __("Expand Details",'acf'),
|
64 |
-
'collapse_details' => __("Collapse Details",'acf')
|
65 |
-
),
|
66 |
-
'validation' => array(
|
67 |
-
'error' => __("Validation Failed. One or more fields below are required.",'acf')
|
68 |
-
)
|
69 |
-
));
|
70 |
-
|
71 |
-
|
72 |
-
// options
|
73 |
-
$o = array(
|
74 |
-
'post_id' => $post_id,
|
75 |
-
'nonce' => wp_create_nonce( 'acf_nonce' ),
|
76 |
-
'admin_url' => admin_url(),
|
77 |
-
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
78 |
-
'wp_version' => $wp_version
|
79 |
-
);
|
80 |
-
|
81 |
-
|
82 |
-
// toolbars
|
83 |
-
$t = array();
|
84 |
-
|
85 |
-
if( is_array($toolbars) ){ foreach( $toolbars as $label => $rows ){
|
86 |
-
|
87 |
-
$label = sanitize_title( $label );
|
88 |
-
$label = str_replace('-', '_', $label);
|
89 |
-
|
90 |
-
$t[ $label ] = array();
|
91 |
-
|
92 |
-
if( is_array($rows) ){ foreach( $rows as $k => $v ){
|
93 |
-
|
94 |
-
$t[ $label ][ 'theme_advanced_buttons' . $k ] = implode(',', $v);
|
95 |
-
|
96 |
-
}}
|
97 |
-
}}
|
98 |
-
|
99 |
-
|
100 |
-
?>
|
101 |
-
<script type="text/javascript">
|
102 |
-
(function($) {
|
103 |
-
|
104 |
-
// vars
|
105 |
-
acf.post_id = <?php echo is_numeric($post_id) ? $post_id : '"' . $post_id . '"'; ?>;
|
106 |
-
acf.nonce = "<?php echo wp_create_nonce( 'acf_nonce' ); ?>";
|
107 |
-
acf.admin_url = "<?php echo admin_url(); ?>";
|
108 |
-
acf.ajaxurl = "<?php echo admin_url( 'admin-ajax.php' ); ?>";
|
109 |
-
acf.wp_version = "<?php echo $wp_version; ?>";
|
110 |
-
|
111 |
-
|
112 |
-
// new vars
|
113 |
-
acf.o = <?php echo json_encode( $o ); ?>;
|
114 |
-
acf.l10n = <?php echo json_encode( $l10n ); ?>;
|
115 |
-
acf.fields.wysiwyg.toolbars = <?php echo json_encode( $t ); ?>;
|
116 |
-
|
117 |
-
})(jQuery);
|
118 |
-
</script>
|
119 |
-
<?php
|
120 |
-
}
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
/*
|
125 |
-
* input_admin_enqueue_scripts
|
126 |
-
*
|
127 |
-
* @description:
|
128 |
-
* @since: 3.6
|
129 |
-
* @created: 30/01/13
|
130 |
-
*/
|
131 |
-
|
132 |
-
function input_admin_enqueue_scripts()
|
133 |
-
{
|
134 |
-
|
135 |
-
// scripts
|
136 |
-
wp_enqueue_script(array(
|
137 |
-
'jquery',
|
138 |
-
'jquery-ui-core',
|
139 |
-
'jquery-ui-tabs',
|
140 |
-
'jquery-ui-sortable',
|
141 |
-
'wp-color-picker',
|
142 |
-
'thickbox',
|
143 |
-
'media-upload',
|
144 |
-
'acf-input',
|
145 |
-
'acf-datepicker',
|
146 |
-
));
|
147 |
-
|
148 |
-
|
149 |
-
// 3.5 media gallery
|
150 |
-
if( function_exists('wp_enqueue_media') && !did_action( 'wp_enqueue_media' ))
|
151 |
-
{
|
152 |
-
wp_enqueue_media();
|
153 |
-
}
|
154 |
-
|
155 |
-
|
156 |
-
// styles
|
157 |
-
wp_enqueue_style(array(
|
158 |
-
'thickbox',
|
159 |
-
'wp-color-picker',
|
160 |
-
'acf-global',
|
161 |
-
'acf-input',
|
162 |
-
'acf-datepicker',
|
163 |
-
));
|
164 |
-
}
|
165 |
-
|
166 |
-
}
|
167 |
-
|
168 |
-
new acf_controller_input();
|
169 |
-
|
170 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* acf_controller_input
|
5 |
+
*
|
6 |
+
* This class contains the functionality for input actions used throughout ACF
|
7 |
+
*
|
8 |
+
* @type class
|
9 |
+
* @date 5/09/13
|
10 |
+
* @since 3.1.8
|
11 |
+
*
|
12 |
+
*/
|
13 |
+
|
14 |
+
class acf_controller_input
|
15 |
+
{
|
16 |
+
|
17 |
+
/*
|
18 |
+
* __construct
|
19 |
+
*
|
20 |
+
* @description:
|
21 |
+
* @since 3.1.8
|
22 |
+
* @created: 23/06/12
|
23 |
+
*/
|
24 |
+
|
25 |
+
function __construct()
|
26 |
+
{
|
27 |
+
// actions
|
28 |
+
add_action('acf/input/admin_head', array($this, 'input_admin_head'));
|
29 |
+
add_action('acf/input/admin_enqueue_scripts', array($this, 'input_admin_enqueue_scripts'));
|
30 |
+
}
|
31 |
+
|
32 |
+
|
33 |
+
/*
|
34 |
+
* input_admin_head
|
35 |
+
*
|
36 |
+
* action called when rendering the head of an admin screen. Used primarily for passing PHP to JS
|
37 |
+
*
|
38 |
+
* @type action
|
39 |
+
* @date 27/05/13
|
40 |
+
*
|
41 |
+
* @param N/A
|
42 |
+
* @return N/A
|
43 |
+
*/
|
44 |
+
|
45 |
+
function input_admin_head()
|
46 |
+
{
|
47 |
+
// global
|
48 |
+
global $wp_version, $post;
|
49 |
+
|
50 |
+
|
51 |
+
// vars
|
52 |
+
$toolbars = apply_filters( 'acf/fields/wysiwyg/toolbars', array() );
|
53 |
+
$post_id = 0;
|
54 |
+
if( $post )
|
55 |
+
{
|
56 |
+
$post_id = intval( $post->ID );
|
57 |
+
}
|
58 |
+
|
59 |
+
|
60 |
+
// l10n
|
61 |
+
$l10n = apply_filters( 'acf/input/admin_l10n', array(
|
62 |
+
'core' => array(
|
63 |
+
'expand_details' => __("Expand Details",'acf'),
|
64 |
+
'collapse_details' => __("Collapse Details",'acf')
|
65 |
+
),
|
66 |
+
'validation' => array(
|
67 |
+
'error' => __("Validation Failed. One or more fields below are required.",'acf')
|
68 |
+
)
|
69 |
+
));
|
70 |
+
|
71 |
+
|
72 |
+
// options
|
73 |
+
$o = array(
|
74 |
+
'post_id' => $post_id,
|
75 |
+
'nonce' => wp_create_nonce( 'acf_nonce' ),
|
76 |
+
'admin_url' => admin_url(),
|
77 |
+
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
78 |
+
'wp_version' => $wp_version
|
79 |
+
);
|
80 |
+
|
81 |
+
|
82 |
+
// toolbars
|
83 |
+
$t = array();
|
84 |
+
|
85 |
+
if( is_array($toolbars) ){ foreach( $toolbars as $label => $rows ){
|
86 |
+
|
87 |
+
$label = sanitize_title( $label );
|
88 |
+
$label = str_replace('-', '_', $label);
|
89 |
+
|
90 |
+
$t[ $label ] = array();
|
91 |
+
|
92 |
+
if( is_array($rows) ){ foreach( $rows as $k => $v ){
|
93 |
+
|
94 |
+
$t[ $label ][ 'theme_advanced_buttons' . $k ] = implode(',', $v);
|
95 |
+
|
96 |
+
}}
|
97 |
+
}}
|
98 |
+
|
99 |
+
|
100 |
+
?>
|
101 |
+
<script type="text/javascript">
|
102 |
+
(function($) {
|
103 |
+
|
104 |
+
// vars
|
105 |
+
acf.post_id = <?php echo is_numeric($post_id) ? $post_id : '"' . $post_id . '"'; ?>;
|
106 |
+
acf.nonce = "<?php echo wp_create_nonce( 'acf_nonce' ); ?>";
|
107 |
+
acf.admin_url = "<?php echo admin_url(); ?>";
|
108 |
+
acf.ajaxurl = "<?php echo admin_url( 'admin-ajax.php' ); ?>";
|
109 |
+
acf.wp_version = "<?php echo $wp_version; ?>";
|
110 |
+
|
111 |
+
|
112 |
+
// new vars
|
113 |
+
acf.o = <?php echo json_encode( $o ); ?>;
|
114 |
+
acf.l10n = <?php echo json_encode( $l10n ); ?>;
|
115 |
+
acf.fields.wysiwyg.toolbars = <?php echo json_encode( $t ); ?>;
|
116 |
+
|
117 |
+
})(jQuery);
|
118 |
+
</script>
|
119 |
+
<?php
|
120 |
+
}
|
121 |
+
|
122 |
+
|
123 |
+
|
124 |
+
/*
|
125 |
+
* input_admin_enqueue_scripts
|
126 |
+
*
|
127 |
+
* @description:
|
128 |
+
* @since: 3.6
|
129 |
+
* @created: 30/01/13
|
130 |
+
*/
|
131 |
+
|
132 |
+
function input_admin_enqueue_scripts()
|
133 |
+
{
|
134 |
+
|
135 |
+
// scripts
|
136 |
+
wp_enqueue_script(array(
|
137 |
+
'jquery',
|
138 |
+
'jquery-ui-core',
|
139 |
+
'jquery-ui-tabs',
|
140 |
+
'jquery-ui-sortable',
|
141 |
+
'wp-color-picker',
|
142 |
+
'thickbox',
|
143 |
+
'media-upload',
|
144 |
+
'acf-input',
|
145 |
+
'acf-datepicker',
|
146 |
+
));
|
147 |
+
|
148 |
+
|
149 |
+
// 3.5 media gallery
|
150 |
+
if( function_exists('wp_enqueue_media') && !did_action( 'wp_enqueue_media' ))
|
151 |
+
{
|
152 |
+
wp_enqueue_media();
|
153 |
+
}
|
154 |
+
|
155 |
+
|
156 |
+
// styles
|
157 |
+
wp_enqueue_style(array(
|
158 |
+
'thickbox',
|
159 |
+
'wp-color-picker',
|
160 |
+
'acf-global',
|
161 |
+
'acf-input',
|
162 |
+
'acf-datepicker',
|
163 |
+
));
|
164 |
+
}
|
165 |
+
|
166 |
+
}
|
167 |
+
|
168 |
+
new acf_controller_input();
|
169 |
+
|
170 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/controllers/location.php
CHANGED
@@ -1,987 +1,987 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* Locations
|
5 |
-
*
|
6 |
-
* @description: controller for location match functionality
|
7 |
-
* @since: 3.6
|
8 |
-
* @created: 25/01/13
|
9 |
-
*/
|
10 |
-
|
11 |
-
class acf_location
|
12 |
-
{
|
13 |
-
|
14 |
-
/*
|
15 |
-
* __construct
|
16 |
-
*
|
17 |
-
* @description:
|
18 |
-
* @since 3.1.8
|
19 |
-
* @created: 23/06/12
|
20 |
-
*/
|
21 |
-
|
22 |
-
function __construct()
|
23 |
-
{
|
24 |
-
// ajax
|
25 |
-
add_action('wp_ajax_acf/location/match_field_groups_ajax', array($this, 'match_field_groups_ajax'));
|
26 |
-
add_action('wp_ajax_nopriv_acf/location/match_field_groups_ajax', array($this, 'match_field_groups_ajax'));
|
27 |
-
|
28 |
-
|
29 |
-
// filters
|
30 |
-
add_filter('acf/location/match_field_groups', array($this, 'match_field_groups'), 10, 2);
|
31 |
-
|
32 |
-
|
33 |
-
// Basic
|
34 |
-
add_filter('acf/location/rule_match/post_type', array($this, 'rule_match_post_type'), 10, 3);
|
35 |
-
add_filter('acf/location/rule_match/user_type', array($this, 'rule_match_user_type'), 10, 3);
|
36 |
-
|
37 |
-
// Page
|
38 |
-
add_filter('acf/location/rule_match/page', array($this, 'rule_match_post'), 10, 3);
|
39 |
-
add_filter('acf/location/rule_match/page_type', array($this, 'rule_match_page_type'), 10, 3);
|
40 |
-
add_filter('acf/location/rule_match/page_parent', array($this, 'rule_match_page_parent'), 10, 3);
|
41 |
-
add_filter('acf/location/rule_match/page_template', array($this, 'rule_match_page_template'), 10, 3);
|
42 |
-
|
43 |
-
// Post
|
44 |
-
add_filter('acf/location/rule_match/post', array($this, 'rule_match_post'), 10, 3);
|
45 |
-
add_filter('acf/location/rule_match/post_category', array($this, 'rule_match_post_category'), 10, 3);
|
46 |
-
add_filter('acf/location/rule_match/post_format', array($this, 'rule_match_post_format'), 10, 3);
|
47 |
-
add_filter('acf/location/rule_match/post_status', array($this, 'rule_match_post_status'), 10, 3);
|
48 |
-
add_filter('acf/location/rule_match/taxonomy', array($this, 'rule_match_taxonomy'), 10, 3);
|
49 |
-
|
50 |
-
// Other
|
51 |
-
add_filter('acf/location/rule_match/ef_taxonomy', array($this, 'rule_match_ef_taxonomy'), 10, 3);
|
52 |
-
add_filter('acf/location/rule_match/ef_user', array($this, 'rule_match_ef_user'), 10, 3);
|
53 |
-
add_filter('acf/location/rule_match/ef_media', array($this, 'rule_match_ef_media'), 10, 3);
|
54 |
-
|
55 |
-
// Options Page
|
56 |
-
add_filter('acf/location/rule_match/options_page', array($this, 'rule_match_options_page'), 10, 3);
|
57 |
-
}
|
58 |
-
|
59 |
-
|
60 |
-
/*
|
61 |
-
* match_field_groups_ajax
|
62 |
-
*
|
63 |
-
* @description:
|
64 |
-
* @since: 3.5.7
|
65 |
-
* @created: 3/01/13
|
66 |
-
*/
|
67 |
-
|
68 |
-
function match_field_groups_ajax()
|
69 |
-
{
|
70 |
-
|
71 |
-
// vars
|
72 |
-
$options = array(
|
73 |
-
'nonce' => '',
|
74 |
-
'ajax' => true
|
75 |
-
);
|
76 |
-
|
77 |
-
|
78 |
-
// load post options
|
79 |
-
$options = array_merge($options, $_POST);
|
80 |
-
|
81 |
-
|
82 |
-
// verify nonce
|
83 |
-
if( ! wp_verify_nonce($options['nonce'], 'acf_nonce') )
|
84 |
-
{
|
85 |
-
die(0);
|
86 |
-
}
|
87 |
-
|
88 |
-
|
89 |
-
// return array
|
90 |
-
$return = apply_filters( 'acf/location/match_field_groups', array(), $options );
|
91 |
-
|
92 |
-
|
93 |
-
// echo json
|
94 |
-
echo json_encode( $return );
|
95 |
-
|
96 |
-
|
97 |
-
die();
|
98 |
-
}
|
99 |
-
|
100 |
-
|
101 |
-
/*
|
102 |
-
* match_field_groups
|
103 |
-
*
|
104 |
-
* @description:
|
105 |
-
* @since: 3.5.7
|
106 |
-
* @created: 3/01/13
|
107 |
-
*/
|
108 |
-
|
109 |
-
function match_field_groups( $return, $options )
|
110 |
-
{
|
111 |
-
|
112 |
-
// vars
|
113 |
-
$defaults = array(
|
114 |
-
'post_id' => 0,
|
115 |
-
'post_type' => 0,
|
116 |
-
'page_template' => 0,
|
117 |
-
'page_parent' => 0,
|
118 |
-
'page_type' => 0,
|
119 |
-
'post_category' => array(),
|
120 |
-
'post_format' => 0,
|
121 |
-
'taxonomy' => array(),
|
122 |
-
'ef_taxonomy' => 0,
|
123 |
-
'ef_user' => 0,
|
124 |
-
'ef_media' => 0,
|
125 |
-
'lang' => 0,
|
126 |
-
'ajax' => false
|
127 |
-
);
|
128 |
-
|
129 |
-
|
130 |
-
// merge in $options
|
131 |
-
$options = array_merge($defaults, $options);
|
132 |
-
|
133 |
-
|
134 |
-
// Parse values
|
135 |
-
$options = apply_filters( 'acf/parse_types', $options );
|
136 |
-
|
137 |
-
|
138 |
-
// WPML
|
139 |
-
if( defined('ICL_LANGUAGE_CODE') )
|
140 |
-
{
|
141 |
-
$options['lang'] = ICL_LANGUAGE_CODE;
|
142 |
-
|
143 |
-
//global $sitepress;
|
144 |
-
//$sitepress->switch_lang( $options['lang'] );
|
145 |
-
}
|
146 |
-
|
147 |
-
|
148 |
-
// find all acf objects
|
149 |
-
$acfs = apply_filters('acf/get_field_groups', array());
|
150 |
-
|
151 |
-
|
152 |
-
// blank array to hold acfs
|
153 |
-
$return = array();
|
154 |
-
|
155 |
-
|
156 |
-
if( $acfs )
|
157 |
-
{
|
158 |
-
foreach( $acfs as $acf )
|
159 |
-
{
|
160 |
-
// load location
|
161 |
-
$acf['location'] = apply_filters('acf/field_group/get_location', array(), $acf['id']);
|
162 |
-
|
163 |
-
|
164 |
-
// vars
|
165 |
-
$add_box = false;
|
166 |
-
|
167 |
-
|
168 |
-
foreach( $acf['location'] as $group_id => $group )
|
169 |
-
{
|
170 |
-
// start of as true, this way, any rule that doesn't match will cause this varaible to false
|
171 |
-
$match_group = true;
|
172 |
-
|
173 |
-
if( is_array($group) )
|
174 |
-
{
|
175 |
-
foreach( $group as $rule_id => $rule )
|
176 |
-
{
|
177 |
-
// Hack for ef_media => now post_type = attachment
|
178 |
-
if( $rule['param'] == 'ef_media' )
|
179 |
-
{
|
180 |
-
$rule['param'] = 'post_type';
|
181 |
-
$rule['value'] = 'attachment';
|
182 |
-
}
|
183 |
-
|
184 |
-
|
185 |
-
// $match = true / false
|
186 |
-
$match = apply_filters( 'acf/location/rule_match/' . $rule['param'] , false, $rule, $options );
|
187 |
-
|
188 |
-
if( !$match )
|
189 |
-
{
|
190 |
-
$match_group = false;
|
191 |
-
}
|
192 |
-
|
193 |
-
}
|
194 |
-
}
|
195 |
-
|
196 |
-
|
197 |
-
// all rules must havematched!
|
198 |
-
if( $match_group )
|
199 |
-
{
|
200 |
-
$add_box = true;
|
201 |
-
}
|
202 |
-
|
203 |
-
}
|
204 |
-
|
205 |
-
|
206 |
-
// add ID to array
|
207 |
-
if( $add_box )
|
208 |
-
{
|
209 |
-
$return[] = $acf['id'];
|
210 |
-
|
211 |
-
}
|
212 |
-
|
213 |
-
}
|
214 |
-
}
|
215 |
-
|
216 |
-
|
217 |
-
return $return;
|
218 |
-
}
|
219 |
-
|
220 |
-
|
221 |
-
/*
|
222 |
-
* rule_match_post_type
|
223 |
-
*
|
224 |
-
* @description:
|
225 |
-
* @since: 3.5.7
|
226 |
-
* @created: 3/01/13
|
227 |
-
*/
|
228 |
-
|
229 |
-
function rule_match_post_type( $match, $rule, $options )
|
230 |
-
{
|
231 |
-
$post_type = $options['post_type'];
|
232 |
-
|
233 |
-
if( !$post_type )
|
234 |
-
{
|
235 |
-
if( !$options['post_id'] )
|
236 |
-
{
|
237 |
-
return false;
|
238 |
-
}
|
239 |
-
|
240 |
-
$post_type = get_post_type( $options['post_id'] );
|
241 |
-
}
|
242 |
-
|
243 |
-
|
244 |
-
if( $rule['operator'] == "==" )
|
245 |
-
{
|
246 |
-
$match = ( $post_type === $rule['value'] );
|
247 |
-
}
|
248 |
-
elseif( $rule['operator'] == "!=" )
|
249 |
-
{
|
250 |
-
$match = ( $post_type !== $rule['value'] );
|
251 |
-
}
|
252 |
-
|
253 |
-
|
254 |
-
return $match;
|
255 |
-
}
|
256 |
-
|
257 |
-
|
258 |
-
/*
|
259 |
-
* rule_match_post
|
260 |
-
*
|
261 |
-
* @description:
|
262 |
-
* @since: 3.5.7
|
263 |
-
* @created: 3/01/13
|
264 |
-
*/
|
265 |
-
|
266 |
-
function rule_match_post( $match, $rule, $options )
|
267 |
-
{
|
268 |
-
// validation
|
269 |
-
if( !$options['post_id'] )
|
270 |
-
{
|
271 |
-
return false;
|
272 |
-
}
|
273 |
-
|
274 |
-
|
275 |
-
// translate $rule['value']
|
276 |
-
// - this variable will hold the original post_id, but $options['post_id'] will hold the translated version
|
277 |
-
//if( function_exists('icl_object_id') )
|
278 |
-
//{
|
279 |
-
// $rule['value'] = icl_object_id( $rule['value'], $options['post_type'], true );
|
280 |
-
//}
|
281 |
-
|
282 |
-
|
283 |
-
if($rule['operator'] == "==")
|
284 |
-
{
|
285 |
-
$match = ( $options['post_id'] == $rule['value'] );
|
286 |
-
}
|
287 |
-
elseif($rule['operator'] == "!=")
|
288 |
-
{
|
289 |
-
$match = ( $options['post_id'] != $rule['value'] );
|
290 |
-
}
|
291 |
-
|
292 |
-
return $match;
|
293 |
-
|
294 |
-
}
|
295 |
-
|
296 |
-
|
297 |
-
/*
|
298 |
-
* rule_match_page_type
|
299 |
-
*
|
300 |
-
* @description:
|
301 |
-
* @since: 3.5.7
|
302 |
-
* @created: 3/01/13
|
303 |
-
*/
|
304 |
-
|
305 |
-
function rule_match_page_type( $match, $rule, $options )
|
306 |
-
{
|
307 |
-
// validation
|
308 |
-
if( !$options['post_id'] )
|
309 |
-
{
|
310 |
-
return false;
|
311 |
-
}
|
312 |
-
|
313 |
-
$post = get_post( $options['post_id'] );
|
314 |
-
|
315 |
-
if( $rule['value'] == 'front_page')
|
316 |
-
{
|
317 |
-
|
318 |
-
$front_page = (int) get_option('page_on_front');
|
319 |
-
|
320 |
-
|
321 |
-
if($rule['operator'] == "==")
|
322 |
-
{
|
323 |
-
$match = ( $front_page == $post->ID );
|
324 |
-
}
|
325 |
-
elseif($rule['operator'] == "!=")
|
326 |
-
{
|
327 |
-
$match = ( $front_page != $post->ID );
|
328 |
-
}
|
329 |
-
|
330 |
-
}
|
331 |
-
elseif( $rule['value'] == 'posts_page')
|
332 |
-
{
|
333 |
-
|
334 |
-
$posts_page = (int) get_option('page_for_posts');
|
335 |
-
|
336 |
-
|
337 |
-
if($rule['operator'] == "==")
|
338 |
-
{
|
339 |
-
$match = ( $posts_page == $post->ID );
|
340 |
-
}
|
341 |
-
elseif($rule['operator'] == "!=")
|
342 |
-
{
|
343 |
-
$match = ( $posts_page != $post->ID );
|
344 |
-
}
|
345 |
-
|
346 |
-
}
|
347 |
-
elseif( $rule['value'] == 'top_level')
|
348 |
-
{
|
349 |
-
$post_parent = $post->post_parent;
|
350 |
-
if( $options['page_parent'] )
|
351 |
-
{
|
352 |
-
$post_parent = $options['page_parent'];
|
353 |
-
}
|
354 |
-
|
355 |
-
|
356 |
-
if($rule['operator'] == "==")
|
357 |
-
{
|
358 |
-
$match = ( $post_parent == 0 );
|
359 |
-
}
|
360 |
-
elseif($rule['operator'] == "!=")
|
361 |
-
{
|
362 |
-
$match = ( $post_parent != 0 );
|
363 |
-
}
|
364 |
-
|
365 |
-
}
|
366 |
-
elseif( $rule['value'] == 'parent')
|
367 |
-
{
|
368 |
-
|
369 |
-
$children = get_pages(array(
|
370 |
-
'post_type' => $post->post_type,
|
371 |
-
'child_of' => $post->ID,
|
372 |
-
));
|
373 |
-
|
374 |
-
|
375 |
-
if($rule['operator'] == "==")
|
376 |
-
{
|
377 |
-
$match = ( count($children) > 0 );
|
378 |
-
}
|
379 |
-
elseif($rule['operator'] == "!=")
|
380 |
-
{
|
381 |
-
$match = ( count($children) == 0 );
|
382 |
-
}
|
383 |
-
|
384 |
-
}
|
385 |
-
elseif( $rule['value'] == 'child')
|
386 |
-
{
|
387 |
-
|
388 |
-
$post_parent = $post->post_parent;
|
389 |
-
if( $options['page_parent'] )
|
390 |
-
{
|
391 |
-
$post_parent = $options['page_parent'];
|
392 |
-
}
|
393 |
-
|
394 |
-
|
395 |
-
if($rule['operator'] == "==")
|
396 |
-
{
|
397 |
-
$match = ( $post_parent != 0 );
|
398 |
-
}
|
399 |
-
elseif($rule['operator'] == "!=")
|
400 |
-
{
|
401 |
-
$match = ( $post_parent == 0 );
|
402 |
-
}
|
403 |
-
|
404 |
-
}
|
405 |
-
|
406 |
-
return $match;
|
407 |
-
|
408 |
-
}
|
409 |
-
|
410 |
-
|
411 |
-
/*
|
412 |
-
* rule_match_page_parent
|
413 |
-
*
|
414 |
-
* @description:
|
415 |
-
* @since: 3.5.7
|
416 |
-
* @created: 3/01/13
|
417 |
-
*/
|
418 |
-
|
419 |
-
function rule_match_page_parent( $match, $rule, $options )
|
420 |
-
{
|
421 |
-
// validation
|
422 |
-
if( !$options['post_id'] )
|
423 |
-
{
|
424 |
-
return false;
|
425 |
-
}
|
426 |
-
|
427 |
-
|
428 |
-
// vars
|
429 |
-
$post = get_post( $options['post_id'] );
|
430 |
-
|
431 |
-
$post_parent = $post->post_parent;
|
432 |
-
if( $options['page_parent'] )
|
433 |
-
{
|
434 |
-
$post_parent = $options['page_parent'];
|
435 |
-
}
|
436 |
-
|
437 |
-
|
438 |
-
if($rule['operator'] == "==")
|
439 |
-
{
|
440 |
-
$match = ( $post_parent == $rule['value'] );
|
441 |
-
}
|
442 |
-
elseif($rule['operator'] == "!=")
|
443 |
-
{
|
444 |
-
$match = ( $post_parent != $rule['value'] );
|
445 |
-
}
|
446 |
-
|
447 |
-
|
448 |
-
return $match;
|
449 |
-
|
450 |
-
}
|
451 |
-
|
452 |
-
|
453 |
-
/*
|
454 |
-
* rule_match_page_template
|
455 |
-
*
|
456 |
-
* @description:
|
457 |
-
* @since: 3.5.7
|
458 |
-
* @created: 3/01/13
|
459 |
-
*/
|
460 |
-
|
461 |
-
function rule_match_page_template( $match, $rule, $options )
|
462 |
-
{
|
463 |
-
$page_template = $options['page_template'];
|
464 |
-
if( ! $page_template )
|
465 |
-
{
|
466 |
-
$page_template = get_post_meta( $options['post_id'], '_wp_page_template', true );
|
467 |
-
}
|
468 |
-
|
469 |
-
|
470 |
-
if( ! $page_template )
|
471 |
-
{
|
472 |
-
$post_type = $options['post_type'];
|
473 |
-
|
474 |
-
if( !$post_type )
|
475 |
-
{
|
476 |
-
$post_type = get_post_type( $options['post_id'] );
|
477 |
-
}
|
478 |
-
|
479 |
-
if( $post_type == 'page' )
|
480 |
-
{
|
481 |
-
$page_template = "default";
|
482 |
-
}
|
483 |
-
}
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
if($rule['operator'] == "==")
|
488 |
-
{
|
489 |
-
$match = ( $page_template === $rule['value'] );
|
490 |
-
}
|
491 |
-
elseif($rule['operator'] == "!=")
|
492 |
-
{
|
493 |
-
$match = ( $page_template !== $rule['value'] );
|
494 |
-
}
|
495 |
-
|
496 |
-
return $match;
|
497 |
-
|
498 |
-
}
|
499 |
-
|
500 |
-
|
501 |
-
/*
|
502 |
-
* rule_match_post_category
|
503 |
-
*
|
504 |
-
* @description:
|
505 |
-
* @since: 3.5.7
|
506 |
-
* @created: 3/01/13
|
507 |
-
*/
|
508 |
-
|
509 |
-
function rule_match_post_category( $match, $rule, $options )
|
510 |
-
{
|
511 |
-
// validate
|
512 |
-
if( !$options['post_id'] )
|
513 |
-
{
|
514 |
-
return false;
|
515 |
-
}
|
516 |
-
|
517 |
-
|
518 |
-
// post type
|
519 |
-
if( !$options['post_type'] )
|
520 |
-
{
|
521 |
-
$options['post_type'] = get_post_type( $options['post_id'] );
|
522 |
-
}
|
523 |
-
|
524 |
-
|
525 |
-
// vars
|
526 |
-
$taxonomies = get_object_taxonomies( $options['post_type'] );
|
527 |
-
$terms = $options['post_category'];
|
528 |
-
|
529 |
-
|
530 |
-
// not AJAX
|
531 |
-
if( !$options['ajax'] )
|
532 |
-
{
|
533 |
-
// no terms? Load them from the post_id
|
534 |
-
if( empty($terms) )
|
535 |
-
{
|
536 |
-
$all_terms = get_the_terms( $options['post_id'], 'category' );
|
537 |
-
if($all_terms)
|
538 |
-
{
|
539 |
-
foreach($all_terms as $all_term)
|
540 |
-
{
|
541 |
-
$terms[] = $all_term->term_id;
|
542 |
-
}
|
543 |
-
}
|
544 |
-
}
|
545 |
-
|
546 |
-
|
547 |
-
// no terms at all?
|
548 |
-
if( empty($terms) )
|
549 |
-
{
|
550 |
-
// If no ters, this is a new post and should be treated as if it has the "Uncategorized" (1) category ticked
|
551 |
-
if( is_array($taxonomies) && in_array('category', $taxonomies) )
|
552 |
-
{
|
553 |
-
$terms[] = '1';
|
554 |
-
}
|
555 |
-
}
|
556 |
-
}
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
if($rule['operator'] == "==")
|
561 |
-
{
|
562 |
-
$match = false;
|
563 |
-
|
564 |
-
if($terms)
|
565 |
-
{
|
566 |
-
if( in_array($rule['value'], $terms) )
|
567 |
-
{
|
568 |
-
$match = true;
|
569 |
-
}
|
570 |
-
}
|
571 |
-
|
572 |
-
}
|
573 |
-
elseif($rule['operator'] == "!=")
|
574 |
-
{
|
575 |
-
$match = true;
|
576 |
-
|
577 |
-
if($terms)
|
578 |
-
{
|
579 |
-
if( in_array($rule['value'], $terms) )
|
580 |
-
{
|
581 |
-
$match = false;
|
582 |
-
}
|
583 |
-
}
|
584 |
-
|
585 |
-
}
|
586 |
-
|
587 |
-
|
588 |
-
return $match;
|
589 |
-
|
590 |
-
}
|
591 |
-
|
592 |
-
|
593 |
-
/*
|
594 |
-
* rule_match_user_type
|
595 |
-
*
|
596 |
-
* @description:
|
597 |
-
* @since: 3.5.7
|
598 |
-
* @created: 3/01/13
|
599 |
-
*/
|
600 |
-
|
601 |
-
function rule_match_user_type( $match, $rule, $options )
|
602 |
-
{
|
603 |
-
$user = wp_get_current_user();
|
604 |
-
|
605 |
-
if( $rule['operator'] == "==" )
|
606 |
-
{
|
607 |
-
if( $rule['value'] == 'super_admin' )
|
608 |
-
{
|
609 |
-
$match = is_super_admin( $user->ID );
|
610 |
-
}
|
611 |
-
else
|
612 |
-
{
|
613 |
-
$match = in_array( $rule['value'], $user->roles );
|
614 |
-
}
|
615 |
-
|
616 |
-
}
|
617 |
-
elseif( $rule['operator'] == "!=" )
|
618 |
-
{
|
619 |
-
if( $rule['value'] == 'super_admin' )
|
620 |
-
{
|
621 |
-
$match = !is_super_admin( $user->ID );
|
622 |
-
}
|
623 |
-
else
|
624 |
-
{
|
625 |
-
$match = ( ! in_array( $rule['value'], $user->roles ) );
|
626 |
-
}
|
627 |
-
}
|
628 |
-
|
629 |
-
return $match;
|
630 |
-
|
631 |
-
}
|
632 |
-
|
633 |
-
|
634 |
-
/*
|
635 |
-
* rule_match_user_type
|
636 |
-
*
|
637 |
-
* @description:
|
638 |
-
* @since: 3.5.7
|
639 |
-
* @created: 3/01/13
|
640 |
-
*/
|
641 |
-
|
642 |
-
function rule_match_options_page( $match, $rule, $options )
|
643 |
-
{
|
644 |
-
global $plugin_page;
|
645 |
-
|
646 |
-
// NOTE
|
647 |
-
// comment out below code as it was interfering with custom slugs
|
648 |
-
|
649 |
-
// older location rules may be "options-pagename"
|
650 |
-
/*
|
651 |
-
if( substr($rule['value'], 0, 8) == 'options-' )
|
652 |
-
{
|
653 |
-
$rule['value'] = 'acf-' . $rule['value'];
|
654 |
-
}
|
655 |
-
*/
|
656 |
-
|
657 |
-
|
658 |
-
// older location ruels may be "Pagename"
|
659 |
-
/*
|
660 |
-
if( substr($rule['value'], 0, 11) != 'acf-options' )
|
661 |
-
{
|
662 |
-
$rule['value'] = 'acf-options-' . sanitize_title( $rule['value'] );
|
663 |
-
|
664 |
-
// value may now be wrong (acf-options-options)
|
665 |
-
if( $rule['value'] == 'acf-options-options' )
|
666 |
-
{
|
667 |
-
$rule['value'] = 'acf-options';
|
668 |
-
}
|
669 |
-
}
|
670 |
-
*/
|
671 |
-
|
672 |
-
|
673 |
-
if($rule['operator'] == "==")
|
674 |
-
{
|
675 |
-
$match = ( $plugin_page === $rule['value'] );
|
676 |
-
}
|
677 |
-
elseif($rule['operator'] == "!=")
|
678 |
-
{
|
679 |
-
$match = ( $plugin_page !== $rule['value'] );
|
680 |
-
}
|
681 |
-
|
682 |
-
|
683 |
-
return $match;
|
684 |
-
|
685 |
-
}
|
686 |
-
|
687 |
-
|
688 |
-
/*
|
689 |
-
* rule_match_post_format
|
690 |
-
*
|
691 |
-
* @description:
|
692 |
-
* @since: 3.5.7
|
693 |
-
* @created: 3/01/13
|
694 |
-
*/
|
695 |
-
|
696 |
-
function rule_match_post_format( $match, $rule, $options )
|
697 |
-
{
|
698 |
-
// vars
|
699 |
-
$post_format = $options['post_format'];
|
700 |
-
if( !$post_format )
|
701 |
-
{
|
702 |
-
// validate
|
703 |
-
if( !$options['post_id'] )
|
704 |
-
{
|
705 |
-
return false;
|
706 |
-
}
|
707 |
-
|
708 |
-
|
709 |
-
// post type
|
710 |
-
if( !$options['post_type'] )
|
711 |
-
{
|
712 |
-
$options['post_type'] = get_post_type( $options['post_id'] );
|
713 |
-
}
|
714 |
-
|
715 |
-
|
716 |
-
// does post_type support 'post-format'
|
717 |
-
if( post_type_supports( $options['post_type'], 'post-formats' ) )
|
718 |
-
{
|
719 |
-
$post_format = get_post_format( $options['post_id'] );
|
720 |
-
|
721 |
-
if( $post_format === false )
|
722 |
-
{
|
723 |
-
$post_format = 'standard';
|
724 |
-
}
|
725 |
-
}
|
726 |
-
}
|
727 |
-
|
728 |
-
|
729 |
-
if($rule['operator'] == "==")
|
730 |
-
{
|
731 |
-
$match = ( $post_format === $rule['value'] );
|
732 |
-
|
733 |
-
}
|
734 |
-
elseif($rule['operator'] == "!=")
|
735 |
-
{
|
736 |
-
$match = ( $post_format !== $rule['value'] );
|
737 |
-
}
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
return $match;
|
742 |
-
|
743 |
-
}
|
744 |
-
|
745 |
-
|
746 |
-
/*
|
747 |
-
* rule_match_post_status
|
748 |
-
*
|
749 |
-
* @description:
|
750 |
-
* @since: 3.5.7
|
751 |
-
* @created: 3/01/13
|
752 |
-
*/
|
753 |
-
|
754 |
-
function rule_match_post_status( $match, $rule, $options )
|
755 |
-
{
|
756 |
-
// validate
|
757 |
-
if( !$options['post_id'] )
|
758 |
-
{
|
759 |
-
return false;
|
760 |
-
}
|
761 |
-
|
762 |
-
|
763 |
-
// vars
|
764 |
-
$post_status = get_post_status( $options['post_id'] );
|
765 |
-
|
766 |
-
|
767 |
-
// auto-draft = draft
|
768 |
-
if( $post_status == 'auto-draft' )
|
769 |
-
{
|
770 |
-
$post_status = 'draft';
|
771 |
-
}
|
772 |
-
|
773 |
-
|
774 |
-
// match
|
775 |
-
if($rule['operator'] == "==")
|
776 |
-
{
|
777 |
-
$match = ( $post_status === $rule['value'] );
|
778 |
-
|
779 |
-
}
|
780 |
-
elseif($rule['operator'] == "!=")
|
781 |
-
{
|
782 |
-
$match = ( $post_status !== $rule['value'] );
|
783 |
-
}
|
784 |
-
|
785 |
-
|
786 |
-
// return
|
787 |
-
return $match;
|
788 |
-
|
789 |
-
}
|
790 |
-
|
791 |
-
|
792 |
-
/*
|
793 |
-
* rule_match_taxonomy
|
794 |
-
*
|
795 |
-
* @description:
|
796 |
-
* @since: 3.5.7
|
797 |
-
* @created: 3/01/13
|
798 |
-
*/
|
799 |
-
|
800 |
-
function rule_match_taxonomy( $match, $rule, $options )
|
801 |
-
{
|
802 |
-
// validate
|
803 |
-
if( !$options['post_id'] )
|
804 |
-
{
|
805 |
-
return false;
|
806 |
-
}
|
807 |
-
|
808 |
-
|
809 |
-
// post type
|
810 |
-
if( !$options['post_type'] )
|
811 |
-
{
|
812 |
-
$options['post_type'] = get_post_type( $options['post_id'] );
|
813 |
-
}
|
814 |
-
|
815 |
-
|
816 |
-
// vars
|
817 |
-
$taxonomies = get_object_taxonomies( $options['post_type'] );
|
818 |
-
$terms = $options['taxonomy'];
|
819 |
-
|
820 |
-
|
821 |
-
// not AJAX
|
822 |
-
if( !$options['ajax'] )
|
823 |
-
{
|
824 |
-
// no terms? Load them from the post_id
|
825 |
-
if( empty($terms) )
|
826 |
-
{
|
827 |
-
if( is_array($taxonomies) )
|
828 |
-
{
|
829 |
-
foreach( $taxonomies as $tax )
|
830 |
-
{
|
831 |
-
$all_terms = get_the_terms( $options['post_id'], $tax );
|
832 |
-
if($all_terms)
|
833 |
-
{
|
834 |
-
foreach($all_terms as $all_term)
|
835 |
-
{
|
836 |
-
$terms[] = $all_term->term_id;
|
837 |
-
}
|
838 |
-
}
|
839 |
-
}
|
840 |
-
}
|
841 |
-
}
|
842 |
-
|
843 |
-
|
844 |
-
// no terms at all?
|
845 |
-
if( empty($terms) )
|
846 |
-
{
|
847 |
-
// If no ters, this is a new post and should be treated as if it has the "Uncategorized" (1) category ticked
|
848 |
-
if( is_array($taxonomies) && in_array('category', $taxonomies) )
|
849 |
-
{
|
850 |
-
$terms[] = '1';
|
851 |
-
}
|
852 |
-
}
|
853 |
-
}
|
854 |
-
|
855 |
-
|
856 |
-
if($rule['operator'] == "==")
|
857 |
-
{
|
858 |
-
$match = false;
|
859 |
-
|
860 |
-
if($terms)
|
861 |
-
{
|
862 |
-
if( in_array($rule['value'], $terms) )
|
863 |
-
{
|
864 |
-
$match = true;
|
865 |
-
}
|
866 |
-
}
|
867 |
-
|
868 |
-
}
|
869 |
-
elseif($rule['operator'] == "!=")
|
870 |
-
{
|
871 |
-
$match = true;
|
872 |
-
|
873 |
-
if($terms)
|
874 |
-
{
|
875 |
-
if( in_array($rule['value'], $terms) )
|
876 |
-
{
|
877 |
-
$match = false;
|
878 |
-
}
|
879 |
-
}
|
880 |
-
|
881 |
-
}
|
882 |
-
|
883 |
-
|
884 |
-
return $match;
|
885 |
-
|
886 |
-
}
|
887 |
-
|
888 |
-
|
889 |
-
/*
|
890 |
-
* rule_match_ef_taxonomy
|
891 |
-
*
|
892 |
-
* @description:
|
893 |
-
* @since: 3.5.7
|
894 |
-
* @created: 3/01/13
|
895 |
-
*/
|
896 |
-
|
897 |
-
function rule_match_ef_taxonomy( $match, $rule, $options )
|
898 |
-
{
|
899 |
-
|
900 |
-
$ef_taxonomy = $options['ef_taxonomy'];
|
901 |
-
|
902 |
-
|
903 |
-
if( $ef_taxonomy )
|
904 |
-
{
|
905 |
-
if($rule['operator'] == "==")
|
906 |
-
{
|
907 |
-
$match = ( $ef_taxonomy == $rule['value'] );
|
908 |
-
|
909 |
-
// override for "all"
|
910 |
-
if( $rule['value'] == "all" )
|
911 |
-
{
|
912 |
-
$match = true;
|
913 |
-
}
|
914 |
-
|
915 |
-
}
|
916 |
-
elseif($rule['operator'] == "!=")
|
917 |
-
{
|
918 |
-
$match = ( $ef_taxonomy != $rule['value'] );
|
919 |
-
|
920 |
-
// override for "all"
|
921 |
-
if( $rule['value'] == "all" )
|
922 |
-
{
|
923 |
-
$match = false;
|
924 |
-
}
|
925 |
-
|
926 |
-
}
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
}
|
932 |
-
|
933 |
-
|
934 |
-
return $match;
|
935 |
-
|
936 |
-
}
|
937 |
-
|
938 |
-
|
939 |
-
/*
|
940 |
-
* rule_match_ef_user
|
941 |
-
*
|
942 |
-
* @description:
|
943 |
-
* @since: 3.5.7
|
944 |
-
* @created: 3/01/13
|
945 |
-
*/
|
946 |
-
|
947 |
-
function rule_match_ef_user( $match, $rule, $options )
|
948 |
-
{
|
949 |
-
|
950 |
-
$ef_user = $options['ef_user'];
|
951 |
-
|
952 |
-
|
953 |
-
if( $ef_user )
|
954 |
-
{
|
955 |
-
if($rule['operator'] == "==")
|
956 |
-
{
|
957 |
-
$match = ( user_can($ef_user, $rule['value']) );
|
958 |
-
|
959 |
-
// override for "all"
|
960 |
-
if( $rule['value'] === "all" )
|
961 |
-
{
|
962 |
-
$match = true;
|
963 |
-
}
|
964 |
-
}
|
965 |
-
elseif($rule['operator'] == "!=")
|
966 |
-
{
|
967 |
-
$match = ( !user_can($ef_user, $rule['value']) );
|
968 |
-
|
969 |
-
// override for "all"
|
970 |
-
if( $rule['value'] === "all" )
|
971 |
-
{
|
972 |
-
$match = false;
|
973 |
-
}
|
974 |
-
}
|
975 |
-
|
976 |
-
}
|
977 |
-
|
978 |
-
|
979 |
-
return $match;
|
980 |
-
|
981 |
-
}
|
982 |
-
|
983 |
-
}
|
984 |
-
|
985 |
-
new acf_location();
|
986 |
-
|
987 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* Locations
|
5 |
+
*
|
6 |
+
* @description: controller for location match functionality
|
7 |
+
* @since: 3.6
|
8 |
+
* @created: 25/01/13
|
9 |
+
*/
|
10 |
+
|
11 |
+
class acf_location
|
12 |
+
{
|
13 |
+
|
14 |
+
/*
|
15 |
+
* __construct
|
16 |
+
*
|
17 |
+
* @description:
|
18 |
+
* @since 3.1.8
|
19 |
+
* @created: 23/06/12
|
20 |
+
*/
|
21 |
+
|
22 |
+
function __construct()
|
23 |
+
{
|
24 |
+
// ajax
|
25 |
+
add_action('wp_ajax_acf/location/match_field_groups_ajax', array($this, 'match_field_groups_ajax'));
|
26 |
+
add_action('wp_ajax_nopriv_acf/location/match_field_groups_ajax', array($this, 'match_field_groups_ajax'));
|
27 |
+
|
28 |
+
|
29 |
+
// filters
|
30 |
+
add_filter('acf/location/match_field_groups', array($this, 'match_field_groups'), 10, 2);
|
31 |
+
|
32 |
+
|
33 |
+
// Basic
|
34 |
+
add_filter('acf/location/rule_match/post_type', array($this, 'rule_match_post_type'), 10, 3);
|
35 |
+
add_filter('acf/location/rule_match/user_type', array($this, 'rule_match_user_type'), 10, 3);
|
36 |
+
|
37 |
+
// Page
|
38 |
+
add_filter('acf/location/rule_match/page', array($this, 'rule_match_post'), 10, 3);
|
39 |
+
add_filter('acf/location/rule_match/page_type', array($this, 'rule_match_page_type'), 10, 3);
|
40 |
+
add_filter('acf/location/rule_match/page_parent', array($this, 'rule_match_page_parent'), 10, 3);
|
41 |
+
add_filter('acf/location/rule_match/page_template', array($this, 'rule_match_page_template'), 10, 3);
|
42 |
+
|
43 |
+
// Post
|
44 |
+
add_filter('acf/location/rule_match/post', array($this, 'rule_match_post'), 10, 3);
|
45 |
+
add_filter('acf/location/rule_match/post_category', array($this, 'rule_match_post_category'), 10, 3);
|
46 |
+
add_filter('acf/location/rule_match/post_format', array($this, 'rule_match_post_format'), 10, 3);
|
47 |
+
add_filter('acf/location/rule_match/post_status', array($this, 'rule_match_post_status'), 10, 3);
|
48 |
+
add_filter('acf/location/rule_match/taxonomy', array($this, 'rule_match_taxonomy'), 10, 3);
|
49 |
+
|
50 |
+
// Other
|
51 |
+
add_filter('acf/location/rule_match/ef_taxonomy', array($this, 'rule_match_ef_taxonomy'), 10, 3);
|
52 |
+
add_filter('acf/location/rule_match/ef_user', array($this, 'rule_match_ef_user'), 10, 3);
|
53 |
+
add_filter('acf/location/rule_match/ef_media', array($this, 'rule_match_ef_media'), 10, 3);
|
54 |
+
|
55 |
+
// Options Page
|
56 |
+
add_filter('acf/location/rule_match/options_page', array($this, 'rule_match_options_page'), 10, 3);
|
57 |
+
}
|
58 |
+
|
59 |
+
|
60 |
+
/*
|
61 |
+
* match_field_groups_ajax
|
62 |
+
*
|
63 |
+
* @description:
|
64 |
+
* @since: 3.5.7
|
65 |
+
* @created: 3/01/13
|
66 |
+
*/
|
67 |
+
|
68 |
+
function match_field_groups_ajax()
|
69 |
+
{
|
70 |
+
|
71 |
+
// vars
|
72 |
+
$options = array(
|
73 |
+
'nonce' => '',
|
74 |
+
'ajax' => true
|
75 |
+
);
|
76 |
+
|
77 |
+
|
78 |
+
// load post options
|
79 |
+
$options = array_merge($options, $_POST);
|
80 |
+
|
81 |
+
|
82 |
+
// verify nonce
|
83 |
+
if( ! wp_verify_nonce($options['nonce'], 'acf_nonce') )
|
84 |
+
{
|
85 |
+
die(0);
|
86 |
+
}
|
87 |
+
|
88 |
+
|
89 |
+
// return array
|
90 |
+
$return = apply_filters( 'acf/location/match_field_groups', array(), $options );
|
91 |
+
|
92 |
+
|
93 |
+
// echo json
|
94 |
+
echo json_encode( $return );
|
95 |
+
|
96 |
+
|
97 |
+
die();
|
98 |
+
}
|
99 |
+
|
100 |
+
|
101 |
+
/*
|
102 |
+
* match_field_groups
|
103 |
+
*
|
104 |
+
* @description:
|
105 |
+
* @since: 3.5.7
|
106 |
+
* @created: 3/01/13
|
107 |
+
*/
|
108 |
+
|
109 |
+
function match_field_groups( $return, $options )
|
110 |
+
{
|
111 |
+
|
112 |
+
// vars
|
113 |
+
$defaults = array(
|
114 |
+
'post_id' => 0,
|
115 |
+
'post_type' => 0,
|
116 |
+
'page_template' => 0,
|
117 |
+
'page_parent' => 0,
|
118 |
+
'page_type' => 0,
|
119 |
+
'post_category' => array(),
|
120 |
+
'post_format' => 0,
|
121 |
+
'taxonomy' => array(),
|
122 |
+
'ef_taxonomy' => 0,
|
123 |
+
'ef_user' => 0,
|
124 |
+
'ef_media' => 0,
|
125 |
+
'lang' => 0,
|
126 |
+
'ajax' => false
|
127 |
+
);
|
128 |
+
|
129 |
+
|
130 |
+
// merge in $options
|
131 |
+
$options = array_merge($defaults, $options);
|
132 |
+
|
133 |
+
|
134 |
+
// Parse values
|
135 |
+
$options = apply_filters( 'acf/parse_types', $options );
|
136 |
+
|
137 |
+
|
138 |
+
// WPML
|
139 |
+
if( defined('ICL_LANGUAGE_CODE') )
|
140 |
+
{
|
141 |
+
$options['lang'] = ICL_LANGUAGE_CODE;
|
142 |
+
|
143 |
+
//global $sitepress;
|
144 |
+
//$sitepress->switch_lang( $options['lang'] );
|
145 |
+
}
|
146 |
+
|
147 |
+
|
148 |
+
// find all acf objects
|
149 |
+
$acfs = apply_filters('acf/get_field_groups', array());
|
150 |
+
|
151 |
+
|
152 |
+
// blank array to hold acfs
|
153 |
+
$return = array();
|
154 |
+
|
155 |
+
|
156 |
+
if( $acfs )
|
157 |
+
{
|
158 |
+
foreach( $acfs as $acf )
|
159 |
+
{
|
160 |
+
// load location
|
161 |
+
$acf['location'] = apply_filters('acf/field_group/get_location', array(), $acf['id']);
|
162 |
+
|
163 |
+
|
164 |
+
// vars
|
165 |
+
$add_box = false;
|
166 |
+
|
167 |
+
|
168 |
+
foreach( $acf['location'] as $group_id => $group )
|
169 |
+
{
|
170 |
+
// start of as true, this way, any rule that doesn't match will cause this varaible to false
|
171 |
+
$match_group = true;
|
172 |
+
|
173 |
+
if( is_array($group) )
|
174 |
+
{
|
175 |
+
foreach( $group as $rule_id => $rule )
|
176 |
+
{
|
177 |
+
// Hack for ef_media => now post_type = attachment
|
178 |
+
if( $rule['param'] == 'ef_media' )
|
179 |
+
{
|
180 |
+
$rule['param'] = 'post_type';
|
181 |
+
$rule['value'] = 'attachment';
|
182 |
+
}
|
183 |
+
|
184 |
+
|
185 |
+
// $match = true / false
|
186 |
+
$match = apply_filters( 'acf/location/rule_match/' . $rule['param'] , false, $rule, $options );
|
187 |
+
|
188 |
+
if( !$match )
|
189 |
+
{
|
190 |
+
$match_group = false;
|
191 |
+
}
|
192 |
+
|
193 |
+
}
|
194 |
+
}
|
195 |
+
|
196 |
+
|
197 |
+
// all rules must havematched!
|
198 |
+
if( $match_group )
|
199 |
+
{
|
200 |
+
$add_box = true;
|
201 |
+
}
|
202 |
+
|
203 |
+
}
|
204 |
+
|
205 |
+
|
206 |
+
// add ID to array
|
207 |
+
if( $add_box )
|
208 |
+
{
|
209 |
+
$return[] = $acf['id'];
|
210 |
+
|
211 |
+
}
|
212 |
+
|
213 |
+
}
|
214 |
+
}
|
215 |
+
|
216 |
+
|
217 |
+
return $return;
|
218 |
+
}
|
219 |
+
|
220 |
+
|
221 |
+
/*
|
222 |
+
* rule_match_post_type
|
223 |
+
*
|
224 |
+
* @description:
|
225 |
+
* @since: 3.5.7
|
226 |
+
* @created: 3/01/13
|
227 |
+
*/
|
228 |
+
|
229 |
+
function rule_match_post_type( $match, $rule, $options )
|
230 |
+
{
|
231 |
+
$post_type = $options['post_type'];
|
232 |
+
|
233 |
+
if( !$post_type )
|
234 |
+
{
|
235 |
+
if( !$options['post_id'] )
|
236 |
+
{
|
237 |
+
return false;
|
238 |
+
}
|
239 |
+
|
240 |
+
$post_type = get_post_type( $options['post_id'] );
|
241 |
+
}
|
242 |
+
|
243 |
+
|
244 |
+
if( $rule['operator'] == "==" )
|
245 |
+
{
|
246 |
+
$match = ( $post_type === $rule['value'] );
|
247 |
+
}
|
248 |
+
elseif( $rule['operator'] == "!=" )
|
249 |
+
{
|
250 |
+
$match = ( $post_type !== $rule['value'] );
|
251 |
+
}
|
252 |
+
|
253 |
+
|
254 |
+
return $match;
|
255 |
+
}
|
256 |
+
|
257 |
+
|
258 |
+
/*
|
259 |
+
* rule_match_post
|
260 |
+
*
|
261 |
+
* @description:
|
262 |
+
* @since: 3.5.7
|
263 |
+
* @created: 3/01/13
|
264 |
+
*/
|
265 |
+
|
266 |
+
function rule_match_post( $match, $rule, $options )
|
267 |
+
{
|
268 |
+
// validation
|
269 |
+
if( !$options['post_id'] )
|
270 |
+
{
|
271 |
+
return false;
|
272 |
+
}
|
273 |
+
|
274 |
+
|
275 |
+
// translate $rule['value']
|
276 |
+
// - this variable will hold the original post_id, but $options['post_id'] will hold the translated version
|
277 |
+
//if( function_exists('icl_object_id') )
|
278 |
+
//{
|
279 |
+
// $rule['value'] = icl_object_id( $rule['value'], $options['post_type'], true );
|
280 |
+
//}
|
281 |
+
|
282 |
+
|
283 |
+
if($rule['operator'] == "==")
|
284 |
+
{
|
285 |
+
$match = ( $options['post_id'] == $rule['value'] );
|
286 |
+
}
|
287 |
+
elseif($rule['operator'] == "!=")
|
288 |
+
{
|
289 |
+
$match = ( $options['post_id'] != $rule['value'] );
|
290 |
+
}
|
291 |
+
|
292 |
+
return $match;
|
293 |
+
|
294 |
+
}
|
295 |
+
|
296 |
+
|
297 |
+
/*
|
298 |
+
* rule_match_page_type
|
299 |
+
*
|
300 |
+
* @description:
|
301 |
+
* @since: 3.5.7
|
302 |
+
* @created: 3/01/13
|
303 |
+
*/
|
304 |
+
|
305 |
+
function rule_match_page_type( $match, $rule, $options )
|
306 |
+
{
|
307 |
+
// validation
|
308 |
+
if( !$options['post_id'] )
|
309 |
+
{
|
310 |
+
return false;
|
311 |
+
}
|
312 |
+
|
313 |
+
$post = get_post( $options['post_id'] );
|
314 |
+
|
315 |
+
if( $rule['value'] == 'front_page')
|
316 |
+
{
|
317 |
+
|
318 |
+
$front_page = (int) get_option('page_on_front');
|
319 |
+
|
320 |
+
|
321 |
+
if($rule['operator'] == "==")
|
322 |
+
{
|
323 |
+
$match = ( $front_page == $post->ID );
|
324 |
+
}
|
325 |
+
elseif($rule['operator'] == "!=")
|
326 |
+
{
|
327 |
+
$match = ( $front_page != $post->ID );
|
328 |
+
}
|
329 |
+
|
330 |
+
}
|
331 |
+
elseif( $rule['value'] == 'posts_page')
|
332 |
+
{
|
333 |
+
|
334 |
+
$posts_page = (int) get_option('page_for_posts');
|
335 |
+
|
336 |
+
|
337 |
+
if($rule['operator'] == "==")
|
338 |
+
{
|
339 |
+
$match = ( $posts_page == $post->ID );
|
340 |
+
}
|
341 |
+
elseif($rule['operator'] == "!=")
|
342 |
+
{
|
343 |
+
$match = ( $posts_page != $post->ID );
|
344 |
+
}
|
345 |
+
|
346 |
+
}
|
347 |
+
elseif( $rule['value'] == 'top_level')
|
348 |
+
{
|
349 |
+
$post_parent = $post->post_parent;
|
350 |
+
if( $options['page_parent'] )
|
351 |
+
{
|
352 |
+
$post_parent = $options['page_parent'];
|
353 |
+
}
|
354 |
+
|
355 |
+
|
356 |
+
if($rule['operator'] == "==")
|
357 |
+
{
|
358 |
+
$match = ( $post_parent == 0 );
|
359 |
+
}
|
360 |
+
elseif($rule['operator'] == "!=")
|
361 |
+
{
|
362 |
+
$match = ( $post_parent != 0 );
|
363 |
+
}
|
364 |
+
|
365 |
+
}
|
366 |
+
elseif( $rule['value'] == 'parent')
|
367 |
+
{
|
368 |
+
|
369 |
+
$children = get_pages(array(
|
370 |
+
'post_type' => $post->post_type,
|
371 |
+
'child_of' => $post->ID,
|
372 |
+
));
|
373 |
+
|
374 |
+
|
375 |
+
if($rule['operator'] == "==")
|
376 |
+
{
|
377 |
+
$match = ( count($children) > 0 );
|
378 |
+
}
|
379 |
+
elseif($rule['operator'] == "!=")
|
380 |
+
{
|
381 |
+
$match = ( count($children) == 0 );
|
382 |
+
}
|
383 |
+
|
384 |
+
}
|
385 |
+
elseif( $rule['value'] == 'child')
|
386 |
+
{
|
387 |
+
|
388 |
+
$post_parent = $post->post_parent;
|
389 |
+
if( $options['page_parent'] )
|
390 |
+
{
|
391 |
+
$post_parent = $options['page_parent'];
|
392 |
+
}
|
393 |
+
|
394 |
+
|
395 |
+
if($rule['operator'] == "==")
|
396 |
+
{
|
397 |
+
$match = ( $post_parent != 0 );
|
398 |
+
}
|
399 |
+
elseif($rule['operator'] == "!=")
|
400 |
+
{
|
401 |
+
$match = ( $post_parent == 0 );
|
402 |
+
}
|
403 |
+
|
404 |
+
}
|
405 |
+
|
406 |
+
return $match;
|
407 |
+
|
408 |
+
}
|
409 |
+
|
410 |
+
|
411 |
+
/*
|
412 |
+
* rule_match_page_parent
|
413 |
+
*
|
414 |
+
* @description:
|
415 |
+
* @since: 3.5.7
|
416 |
+
* @created: 3/01/13
|
417 |
+
*/
|
418 |
+
|
419 |
+
function rule_match_page_parent( $match, $rule, $options )
|
420 |
+
{
|
421 |
+
// validation
|
422 |
+
if( !$options['post_id'] )
|
423 |
+
{
|
424 |
+
return false;
|
425 |
+
}
|
426 |
+
|
427 |
+
|
428 |
+
// vars
|
429 |
+
$post = get_post( $options['post_id'] );
|
430 |
+
|
431 |
+
$post_parent = $post->post_parent;
|
432 |
+
if( $options['page_parent'] )
|
433 |
+
{
|
434 |
+
$post_parent = $options['page_parent'];
|
435 |
+
}
|
436 |
+
|
437 |
+
|
438 |
+
if($rule['operator'] == "==")
|
439 |
+
{
|
440 |
+
$match = ( $post_parent == $rule['value'] );
|
441 |
+
}
|
442 |
+
elseif($rule['operator'] == "!=")
|
443 |
+
{
|
444 |
+
$match = ( $post_parent != $rule['value'] );
|
445 |
+
}
|
446 |
+
|
447 |
+
|
448 |
+
return $match;
|
449 |
+
|
450 |
+
}
|
451 |
+
|
452 |
+
|
453 |
+
/*
|
454 |
+
* rule_match_page_template
|
455 |
+
*
|
456 |
+
* @description:
|
457 |
+
* @since: 3.5.7
|
458 |
+
* @created: 3/01/13
|
459 |
+
*/
|
460 |
+
|
461 |
+
function rule_match_page_template( $match, $rule, $options )
|
462 |
+
{
|
463 |
+
$page_template = $options['page_template'];
|
464 |
+
if( ! $page_template )
|
465 |
+
{
|
466 |
+
$page_template = get_post_meta( $options['post_id'], '_wp_page_template', true );
|
467 |
+
}
|
468 |
+
|
469 |
+
|
470 |
+
if( ! $page_template )
|
471 |
+
{
|
472 |
+
$post_type = $options['post_type'];
|
473 |
+
|
474 |
+
if( !$post_type )
|
475 |
+
{
|
476 |
+
$post_type = get_post_type( $options['post_id'] );
|
477 |
+
}
|
478 |
+
|
479 |
+
if( $post_type == 'page' )
|
480 |
+
{
|
481 |
+
$page_template = "default";
|
482 |
+
}
|
483 |
+
}
|
484 |
+
|
485 |
+
|
486 |
+
|
487 |
+
if($rule['operator'] == "==")
|
488 |
+
{
|
489 |
+
$match = ( $page_template === $rule['value'] );
|
490 |
+
}
|
491 |
+
elseif($rule['operator'] == "!=")
|
492 |
+
{
|
493 |
+
$match = ( $page_template !== $rule['value'] );
|
494 |
+
}
|
495 |
+
|
496 |
+
return $match;
|
497 |
+
|
498 |
+
}
|
499 |
+
|
500 |
+
|
501 |
+
/*
|
502 |
+
* rule_match_post_category
|
503 |
+
*
|
504 |
+
* @description:
|
505 |
+
* @since: 3.5.7
|
506 |
+
* @created: 3/01/13
|
507 |
+
*/
|
508 |
+
|
509 |
+
function rule_match_post_category( $match, $rule, $options )
|
510 |
+
{
|
511 |
+
// validate
|
512 |
+
if( !$options['post_id'] )
|
513 |
+
{
|
514 |
+
return false;
|
515 |
+
}
|
516 |
+
|
517 |
+
|
518 |
+
// post type
|
519 |
+
if( !$options['post_type'] )
|
520 |
+
{
|
521 |
+
$options['post_type'] = get_post_type( $options['post_id'] );
|
522 |
+
}
|
523 |
+
|
524 |
+
|
525 |
+
// vars
|
526 |
+
$taxonomies = get_object_taxonomies( $options['post_type'] );
|
527 |
+
$terms = $options['post_category'];
|
528 |
+
|
529 |
+
|
530 |
+
// not AJAX
|
531 |
+
if( !$options['ajax'] )
|
532 |
+
{
|
533 |
+
// no terms? Load them from the post_id
|
534 |
+
if( empty($terms) )
|
535 |
+
{
|
536 |
+
$all_terms = get_the_terms( $options['post_id'], 'category' );
|
537 |
+
if($all_terms)
|
538 |
+
{
|
539 |
+
foreach($all_terms as $all_term)
|
540 |
+
{
|
541 |
+
$terms[] = $all_term->term_id;
|
542 |
+
}
|
543 |
+
}
|
544 |
+
}
|
545 |
+
|
546 |
+
|
547 |
+
// no terms at all?
|
548 |
+
if( empty($terms) )
|
549 |
+
{
|
550 |
+
// If no ters, this is a new post and should be treated as if it has the "Uncategorized" (1) category ticked
|
551 |
+
if( is_array($taxonomies) && in_array('category', $taxonomies) )
|
552 |
+
{
|
553 |
+
$terms[] = '1';
|
554 |
+
}
|
555 |
+
}
|
556 |
+
}
|
557 |
+
|
558 |
+
|
559 |
+
|
560 |
+
if($rule['operator'] == "==")
|
561 |
+
{
|
562 |
+
$match = false;
|
563 |
+
|
564 |
+
if($terms)
|
565 |
+
{
|
566 |
+
if( in_array($rule['value'], $terms) )
|
567 |
+
{
|
568 |
+
$match = true;
|
569 |
+
}
|
570 |
+
}
|
571 |
+
|
572 |
+
}
|
573 |
+
elseif($rule['operator'] == "!=")
|
574 |
+
{
|
575 |
+
$match = true;
|
576 |
+
|
577 |
+
if($terms)
|
578 |
+
{
|
579 |
+
if( in_array($rule['value'], $terms) )
|
580 |
+
{
|
581 |
+
$match = false;
|
582 |
+
}
|
583 |
+
}
|
584 |
+
|
585 |
+
}
|
586 |
+
|
587 |
+
|
588 |
+
return $match;
|
589 |
+
|
590 |
+
}
|
591 |
+
|
592 |
+
|
593 |
+
/*
|
594 |
+
* rule_match_user_type
|
595 |
+
*
|
596 |
+
* @description:
|
597 |
+
* @since: 3.5.7
|
598 |
+
* @created: 3/01/13
|
599 |
+
*/
|
600 |
+
|
601 |
+
function rule_match_user_type( $match, $rule, $options )
|
602 |
+
{
|
603 |
+
$user = wp_get_current_user();
|
604 |
+
|
605 |
+
if( $rule['operator'] == "==" )
|
606 |
+
{
|
607 |
+
if( $rule['value'] == 'super_admin' )
|
608 |
+
{
|
609 |
+
$match = is_super_admin( $user->ID );
|
610 |
+
}
|
611 |
+
else
|
612 |
+
{
|
613 |
+
$match = in_array( $rule['value'], $user->roles );
|
614 |
+
}
|
615 |
+
|
616 |
+
}
|
617 |
+
elseif( $rule['operator'] == "!=" )
|
618 |
+
{
|
619 |
+
if( $rule['value'] == 'super_admin' )
|
620 |
+
{
|
621 |
+
$match = !is_super_admin( $user->ID );
|
622 |
+
}
|
623 |
+
else
|
624 |
+
{
|
625 |
+
$match = ( ! in_array( $rule['value'], $user->roles ) );
|
626 |
+
}
|
627 |
+
}
|
628 |
+
|
629 |
+
return $match;
|
630 |
+
|
631 |
+
}
|
632 |
+
|
633 |
+
|
634 |
+
/*
|
635 |
+
* rule_match_user_type
|
636 |
+
*
|
637 |
+
* @description:
|
638 |
+
* @since: 3.5.7
|
639 |
+
* @created: 3/01/13
|
640 |
+
*/
|
641 |
+
|
642 |
+
function rule_match_options_page( $match, $rule, $options )
|
643 |
+
{
|
644 |
+
global $plugin_page;
|
645 |
+
|
646 |
+
// NOTE
|
647 |
+
// comment out below code as it was interfering with custom slugs
|
648 |
+
|
649 |
+
// older location rules may be "options-pagename"
|
650 |
+
/*
|
651 |
+
if( substr($rule['value'], 0, 8) == 'options-' )
|
652 |
+
{
|
653 |
+
$rule['value'] = 'acf-' . $rule['value'];
|
654 |
+
}
|
655 |
+
*/
|
656 |
+
|
657 |
+
|
658 |
+
// older location ruels may be "Pagename"
|
659 |
+
/*
|
660 |
+
if( substr($rule['value'], 0, 11) != 'acf-options' )
|
661 |
+
{
|
662 |
+
$rule['value'] = 'acf-options-' . sanitize_title( $rule['value'] );
|
663 |
+
|
664 |
+
// value may now be wrong (acf-options-options)
|
665 |
+
if( $rule['value'] == 'acf-options-options' )
|
666 |
+
{
|
667 |
+
$rule['value'] = 'acf-options';
|
668 |
+
}
|
669 |
+
}
|
670 |
+
*/
|
671 |
+
|
672 |
+
|
673 |
+
if($rule['operator'] == "==")
|
674 |
+
{
|
675 |
+
$match = ( $plugin_page === $rule['value'] );
|
676 |
+
}
|
677 |
+
elseif($rule['operator'] == "!=")
|
678 |
+
{
|
679 |
+
$match = ( $plugin_page !== $rule['value'] );
|
680 |
+
}
|
681 |
+
|
682 |
+
|
683 |
+
return $match;
|
684 |
+
|
685 |
+
}
|
686 |
+
|
687 |
+
|
688 |
+
/*
|
689 |
+
* rule_match_post_format
|
690 |
+
*
|
691 |
+
* @description:
|
692 |
+
* @since: 3.5.7
|
693 |
+
* @created: 3/01/13
|
694 |
+
*/
|
695 |
+
|
696 |
+
function rule_match_post_format( $match, $rule, $options )
|
697 |
+
{
|
698 |
+
// vars
|
699 |
+
$post_format = $options['post_format'];
|
700 |
+
if( !$post_format )
|
701 |
+
{
|
702 |
+
// validate
|
703 |
+
if( !$options['post_id'] )
|
704 |
+
{
|
705 |
+
return false;
|
706 |
+
}
|
707 |
+
|
708 |
+
|
709 |
+
// post type
|
710 |
+
if( !$options['post_type'] )
|
711 |
+
{
|
712 |
+
$options['post_type'] = get_post_type( $options['post_id'] );
|
713 |
+
}
|
714 |
+
|
715 |
+
|
716 |
+
// does post_type support 'post-format'
|
717 |
+
if( post_type_supports( $options['post_type'], 'post-formats' ) )
|
718 |
+
{
|
719 |
+
$post_format = get_post_format( $options['post_id'] );
|
720 |
+
|
721 |
+
if( $post_format === false )
|
722 |
+
{
|
723 |
+
$post_format = 'standard';
|
724 |
+
}
|
725 |
+
}
|
726 |
+
}
|
727 |
+
|
728 |
+
|
729 |
+
if($rule['operator'] == "==")
|
730 |
+
{
|
731 |
+
$match = ( $post_format === $rule['value'] );
|
732 |
+
|
733 |
+
}
|
734 |
+
elseif($rule['operator'] == "!=")
|
735 |
+
{
|
736 |
+
$match = ( $post_format !== $rule['value'] );
|
737 |
+
}
|
738 |
+
|
739 |
+
|
740 |
+
|
741 |
+
return $match;
|
742 |
+
|
743 |
+
}
|
744 |
+
|
745 |
+
|
746 |
+
/*
|
747 |
+
* rule_match_post_status
|
748 |
+
*
|
749 |
+
* @description:
|
750 |
+
* @since: 3.5.7
|
751 |
+
* @created: 3/01/13
|
752 |
+
*/
|
753 |
+
|
754 |
+
function rule_match_post_status( $match, $rule, $options )
|
755 |
+
{
|
756 |
+
// validate
|
757 |
+
if( !$options['post_id'] )
|
758 |
+
{
|
759 |
+
return false;
|
760 |
+
}
|
761 |
+
|
762 |
+
|
763 |
+
// vars
|
764 |
+
$post_status = get_post_status( $options['post_id'] );
|
765 |
+
|
766 |
+
|
767 |
+
// auto-draft = draft
|
768 |
+
if( $post_status == 'auto-draft' )
|
769 |
+
{
|
770 |
+
$post_status = 'draft';
|
771 |
+
}
|
772 |
+
|
773 |
+
|
774 |
+
// match
|
775 |
+
if($rule['operator'] == "==")
|
776 |
+
{
|
777 |
+
$match = ( $post_status === $rule['value'] );
|
778 |
+
|
779 |
+
}
|
780 |
+
elseif($rule['operator'] == "!=")
|
781 |
+
{
|
782 |
+
$match = ( $post_status !== $rule['value'] );
|
783 |
+
}
|
784 |
+
|
785 |
+
|
786 |
+
// return
|
787 |
+
return $match;
|
788 |
+
|
789 |
+
}
|
790 |
+
|
791 |
+
|
792 |
+
/*
|
793 |
+
* rule_match_taxonomy
|
794 |
+
*
|
795 |
+
* @description:
|
796 |
+
* @since: 3.5.7
|
797 |
+
* @created: 3/01/13
|
798 |
+
*/
|
799 |
+
|
800 |
+
function rule_match_taxonomy( $match, $rule, $options )
|
801 |
+
{
|
802 |
+
// validate
|
803 |
+
if( !$options['post_id'] )
|
804 |
+
{
|
805 |
+
return false;
|
806 |
+
}
|
807 |
+
|
808 |
+
|
809 |
+
// post type
|
810 |
+
if( !$options['post_type'] )
|
811 |
+
{
|
812 |
+
$options['post_type'] = get_post_type( $options['post_id'] );
|
813 |
+
}
|
814 |
+
|
815 |
+
|
816 |
+
// vars
|
817 |
+
$taxonomies = get_object_taxonomies( $options['post_type'] );
|
818 |
+
$terms = $options['taxonomy'];
|
819 |
+
|
820 |
+
|
821 |
+
// not AJAX
|
822 |
+
if( !$options['ajax'] )
|
823 |
+
{
|
824 |
+
// no terms? Load them from the post_id
|
825 |
+
if( empty($terms) )
|
826 |
+
{
|
827 |
+
if( is_array($taxonomies) )
|
828 |
+
{
|
829 |
+
foreach( $taxonomies as $tax )
|
830 |
+
{
|
831 |
+
$all_terms = get_the_terms( $options['post_id'], $tax );
|
832 |
+
if($all_terms)
|
833 |
+
{
|
834 |
+
foreach($all_terms as $all_term)
|
835 |
+
{
|
836 |
+
$terms[] = $all_term->term_id;
|
837 |
+
}
|
838 |
+
}
|
839 |
+
}
|
840 |
+
}
|
841 |
+
}
|
842 |
+
|
843 |
+
|
844 |
+
// no terms at all?
|
845 |
+
if( empty($terms) )
|
846 |
+
{
|
847 |
+
// If no ters, this is a new post and should be treated as if it has the "Uncategorized" (1) category ticked
|
848 |
+
if( is_array($taxonomies) && in_array('category', $taxonomies) )
|
849 |
+
{
|
850 |
+
$terms[] = '1';
|
851 |
+
}
|
852 |
+
}
|
853 |
+
}
|
854 |
+
|
855 |
+
|
856 |
+
if($rule['operator'] == "==")
|
857 |
+
{
|
858 |
+
$match = false;
|
859 |
+
|
860 |
+
if($terms)
|
861 |
+
{
|
862 |
+
if( in_array($rule['value'], $terms) )
|
863 |
+
{
|
864 |
+
$match = true;
|
865 |
+
}
|
866 |
+
}
|
867 |
+
|
868 |
+
}
|
869 |
+
elseif($rule['operator'] == "!=")
|
870 |
+
{
|
871 |
+
$match = true;
|
872 |
+
|
873 |
+
if($terms)
|
874 |
+
{
|
875 |
+
if( in_array($rule['value'], $terms) )
|
876 |
+
{
|
877 |
+
$match = false;
|
878 |
+
}
|
879 |
+
}
|
880 |
+
|
881 |
+
}
|
882 |
+
|
883 |
+
|
884 |
+
return $match;
|
885 |
+
|
886 |
+
}
|
887 |
+
|
888 |
+
|
889 |
+
/*
|
890 |
+
* rule_match_ef_taxonomy
|
891 |
+
*
|
892 |
+
* @description:
|
893 |
+
* @since: 3.5.7
|
894 |
+
* @created: 3/01/13
|
895 |
+
*/
|
896 |
+
|
897 |
+
function rule_match_ef_taxonomy( $match, $rule, $options )
|
898 |
+
{
|
899 |
+
|
900 |
+
$ef_taxonomy = $options['ef_taxonomy'];
|
901 |
+
|
902 |
+
|
903 |
+
if( $ef_taxonomy )
|
904 |
+
{
|
905 |
+
if($rule['operator'] == "==")
|
906 |
+
{
|
907 |
+
$match = ( $ef_taxonomy == $rule['value'] );
|
908 |
+
|
909 |
+
// override for "all"
|
910 |
+
if( $rule['value'] == "all" )
|
911 |
+
{
|
912 |
+
$match = true;
|
913 |
+
}
|
914 |
+
|
915 |
+
}
|
916 |
+
elseif($rule['operator'] == "!=")
|
917 |
+
{
|
918 |
+
$match = ( $ef_taxonomy != $rule['value'] );
|
919 |
+
|
920 |
+
// override for "all"
|
921 |
+
if( $rule['value'] == "all" )
|
922 |
+
{
|
923 |
+
$match = false;
|
924 |
+
}
|
925 |
+
|
926 |
+
}
|
927 |
+
|
928 |
+
|
929 |
+
|
930 |
+
|
931 |
+
}
|
932 |
+
|
933 |
+
|
934 |
+
return $match;
|
935 |
+
|
936 |
+
}
|
937 |
+
|
938 |
+
|
939 |
+
/*
|
940 |
+
* rule_match_ef_user
|
941 |
+
*
|
942 |
+
* @description:
|
943 |
+
* @since: 3.5.7
|
944 |
+
* @created: 3/01/13
|
945 |
+
*/
|
946 |
+
|
947 |
+
function rule_match_ef_user( $match, $rule, $options )
|
948 |
+
{
|
949 |
+
|
950 |
+
$ef_user = $options['ef_user'];
|
951 |
+
|
952 |
+
|
953 |
+
if( $ef_user )
|
954 |
+
{
|
955 |
+
if($rule['operator'] == "==")
|
956 |
+
{
|
957 |
+
$match = ( user_can($ef_user, $rule['value']) );
|
958 |
+
|
959 |
+
// override for "all"
|
960 |
+
if( $rule['value'] === "all" )
|
961 |
+
{
|
962 |
+
$match = true;
|
963 |
+
}
|
964 |
+
}
|
965 |
+
elseif($rule['operator'] == "!=")
|
966 |
+
{
|
967 |
+
$match = ( !user_can($ef_user, $rule['value']) );
|
968 |
+
|
969 |
+
// override for "all"
|
970 |
+
if( $rule['value'] === "all" )
|
971 |
+
{
|
972 |
+
$match = false;
|
973 |
+
}
|
974 |
+
}
|
975 |
+
|
976 |
+
}
|
977 |
+
|
978 |
+
|
979 |
+
return $match;
|
980 |
+
|
981 |
+
}
|
982 |
+
|
983 |
+
}
|
984 |
+
|
985 |
+
new acf_location();
|
986 |
+
|
987 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/controllers/post.php
CHANGED
@@ -1,571 +1,571 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* acf_controller_post
|
5 |
-
*
|
6 |
-
* This class contains the functionality to add ACF fields to a post edit form
|
7 |
-
*
|
8 |
-
* @type class
|
9 |
-
* @date 5/09/13
|
10 |
-
* @since 3.1.8
|
11 |
-
*
|
12 |
-
*/
|
13 |
-
|
14 |
-
class acf_controller_post
|
15 |
-
{
|
16 |
-
|
17 |
-
/*
|
18 |
-
* Constructor
|
19 |
-
*
|
20 |
-
* This function will construct all the neccessary actions and filters
|
21 |
-
*
|
22 |
-
* @type function
|
23 |
-
* @date 23/06/12
|
24 |
-
* @since 3.1.8
|
25 |
-
*
|
26 |
-
* @param N/A
|
27 |
-
* @return N/A
|
28 |
-
*/
|
29 |
-
|
30 |
-
function __construct()
|
31 |
-
{
|
32 |
-
// actions
|
33 |
-
add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
|
34 |
-
add_action('save_post', array($this, 'save_post'), 10, 1);
|
35 |
-
|
36 |
-
|
37 |
-
// ajax
|
38 |
-
add_action('wp_ajax_acf/post/render_fields', array($this, 'ajax_render_fields'));
|
39 |
-
add_action('wp_ajax_acf/post/get_style', array($this, 'ajax_get_style'));
|
40 |
-
}
|
41 |
-
|
42 |
-
|
43 |
-
/*
|
44 |
-
* validate_page
|
45 |
-
*
|
46 |
-
* This function will check if the current page is for a post/page edit form
|
47 |
-
*
|
48 |
-
* @type function
|
49 |
-
* @date 23/06/12
|
50 |
-
* @since 3.1.8
|
51 |
-
*
|
52 |
-
* @param N/A
|
53 |
-
* @return (boolean)
|
54 |
-
*/
|
55 |
-
|
56 |
-
function validate_page()
|
57 |
-
{
|
58 |
-
// global
|
59 |
-
global $pagenow, $typenow;
|
60 |
-
|
61 |
-
|
62 |
-
// vars
|
63 |
-
$return = false;
|
64 |
-
|
65 |
-
|
66 |
-
// validate page
|
67 |
-
if( in_array( $pagenow, array('post.php', 'post-new.php') ) )
|
68 |
-
{
|
69 |
-
|
70 |
-
// validate post type
|
71 |
-
global $typenow;
|
72 |
-
|
73 |
-
if( $typenow != "acf" )
|
74 |
-
{
|
75 |
-
$return = true;
|
76 |
-
}
|
77 |
-
|
78 |
-
}
|
79 |
-
|
80 |
-
|
81 |
-
// validate page (Shopp)
|
82 |
-
if( $pagenow == "admin.php" && isset( $_GET['page'] ) && $_GET['page'] == "shopp-products" && isset( $_GET['id'] ) )
|
83 |
-
{
|
84 |
-
$return = true;
|
85 |
-
}
|
86 |
-
|
87 |
-
|
88 |
-
// return
|
89 |
-
return $return;
|
90 |
-
}
|
91 |
-
|
92 |
-
|
93 |
-
/*
|
94 |
-
* admin_enqueue_scripts
|
95 |
-
*
|
96 |
-
* This action is run after post query but before any admin script / head actions.
|
97 |
-
* It is a good place to register all actions.
|
98 |
-
*
|
99 |
-
* @type action (admin_enqueue_scripts)
|
100 |
-
* @date 26/01/13
|
101 |
-
* @since 3.6.0
|
102 |
-
*
|
103 |
-
* @param N/A
|
104 |
-
* @return N/A
|
105 |
-
*/
|
106 |
-
|
107 |
-
function admin_enqueue_scripts()
|
108 |
-
{
|
109 |
-
// validate page
|
110 |
-
if( ! $this->validate_page() )
|
111 |
-
{
|
112 |
-
return;
|
113 |
-
}
|
114 |
-
|
115 |
-
|
116 |
-
// actions
|
117 |
-
do_action('acf/input/admin_enqueue_scripts');
|
118 |
-
|
119 |
-
add_action('admin_head', array($this,'admin_head'));
|
120 |
-
}
|
121 |
-
|
122 |
-
|
123 |
-
/*
|
124 |
-
* admin_head
|
125 |
-
*
|
126 |
-
* This action will find and add field groups to the current edit page
|
127 |
-
*
|
128 |
-
* @type action (admin_head)
|
129 |
-
* @date 23/06/12
|
130 |
-
* @since 3.1.8
|
131 |
-
*
|
132 |
-
* @param N/A
|
133 |
-
* @return N/A
|
134 |
-
*/
|
135 |
-
|
136 |
-
function admin_head()
|
137 |
-
{
|
138 |
-
// globals
|
139 |
-
global $post, $pagenow, $typenow;
|
140 |
-
|
141 |
-
|
142 |
-
// shopp
|
143 |
-
if( $pagenow == "admin.php" && isset( $_GET['page'] ) && $_GET['page'] == "shopp-products" && isset( $_GET['id'] ) )
|
144 |
-
{
|
145 |
-
$typenow = "shopp_product";
|
146 |
-
}
|
147 |
-
|
148 |
-
|
149 |
-
// vars
|
150 |
-
$post_id = $post ? $post->ID : 0;
|
151 |
-
|
152 |
-
|
153 |
-
// get field groups
|
154 |
-
$filter = array(
|
155 |
-
'post_id' => $post_id,
|
156 |
-
'post_type' => $typenow
|
157 |
-
);
|
158 |
-
$metabox_ids = array();
|
159 |
-
$metabox_ids = apply_filters( 'acf/location/match_field_groups', $metabox_ids, $filter );
|
160 |
-
|
161 |
-
|
162 |
-
// get style of first field group
|
163 |
-
$style = '';
|
164 |
-
if( isset($metabox_ids[0]) )
|
165 |
-
{
|
166 |
-
$style = $this->get_style( $metabox_ids[0] );
|
167 |
-
}
|
168 |
-
|
169 |
-
|
170 |
-
// Style
|
171 |
-
echo '<style type="text/css" id="acf_style" >' . $style . '</style>';
|
172 |
-
|
173 |
-
|
174 |
-
// add user js + css
|
175 |
-
do_action('acf/input/admin_head');
|
176 |
-
|
177 |
-
|
178 |
-
// get field groups
|
179 |
-
$acfs = apply_filters('acf/get_field_groups', array());
|
180 |
-
|
181 |
-
|
182 |
-
if( $acfs )
|
183 |
-
{
|
184 |
-
foreach( $acfs as $acf )
|
185 |
-
{
|
186 |
-
// load options
|
187 |
-
$acf['options'] = apply_filters('acf/field_group/get_options', array(), $acf['id']);
|
188 |
-
|
189 |
-
|
190 |
-
// vars
|
191 |
-
$show = in_array( $acf['id'], $metabox_ids ) ? 1 : 0;
|
192 |
-
|
193 |
-
|
194 |
-
// priority
|
195 |
-
$priority = 'high';
|
196 |
-
if( $acf['options']['position'] == 'side' )
|
197 |
-
{
|
198 |
-
$priority = 'core';
|
199 |
-
}
|
200 |
-
$priority = apply_filters('acf/input/meta_box_priority', $priority, $acf);
|
201 |
-
|
202 |
-
|
203 |
-
// add meta box
|
204 |
-
add_meta_box(
|
205 |
-
'acf_' . $acf['id'],
|
206 |
-
$acf['title'],
|
207 |
-
array($this, 'meta_box_input'),
|
208 |
-
$typenow,
|
209 |
-
$acf['options']['position'],
|
210 |
-
$priority,
|
211 |
-
array( 'field_group' => $acf, 'show' => $show, 'post_id' => $post_id )
|
212 |
-
);
|
213 |
-
|
214 |
-
}
|
215 |
-
// foreach($acfs as $acf)
|
216 |
-
}
|
217 |
-
// if($acfs)
|
218 |
-
|
219 |
-
|
220 |
-
// Allow 'acf_after_title' metabox position
|
221 |
-
add_action('edit_form_after_title', array($this, 'edit_form_after_title'));
|
222 |
-
|
223 |
-
|
224 |
-
// remove ACF from meta postbox
|
225 |
-
add_filter( 'is_protected_meta', array($this, 'is_protected_meta'), 10, 3 );
|
226 |
-
}
|
227 |
-
|
228 |
-
|
229 |
-
/*
|
230 |
-
* edit_form_after_title
|
231 |
-
*
|
232 |
-
* This action will allow ACF to render metaboxes after the title
|
233 |
-
*
|
234 |
-
* @type action
|
235 |
-
* @date 17/08/13
|
236 |
-
*
|
237 |
-
* @param N/A
|
238 |
-
* @return N/A
|
239 |
-
*/
|
240 |
-
|
241 |
-
function edit_form_after_title()
|
242 |
-
{
|
243 |
-
// globals
|
244 |
-
global $post, $wp_meta_boxes;
|
245 |
-
|
246 |
-
|
247 |
-
// render
|
248 |
-
do_meta_boxes( get_current_screen(), 'acf_after_title', $post);
|
249 |
-
|
250 |
-
|
251 |
-
// clean up
|
252 |
-
unset( $wp_meta_boxes['post']['acf_after_title'] );
|
253 |
-
|
254 |
-
|
255 |
-
// preview hack
|
256 |
-
// the following code will add a hidden input which will trigger WP to create a revision apon save
|
257 |
-
// http://support.advancedcustomfields.com/forums/topic/preview-solution/#post-4106
|
258 |
-
?>
|
259 |
-
<div style="display:none">
|
260 |
-
<input type="hidden" name="acf_has_changed" id="acf-has-changed" value="0" />
|
261 |
-
</div>
|
262 |
-
<?php
|
263 |
-
}
|
264 |
-
|
265 |
-
|
266 |
-
/*
|
267 |
-
* meta_box_input
|
268 |
-
*
|
269 |
-
* @description:
|
270 |
-
* @since 1.0.0
|
271 |
-
* @created: 23/06/12
|
272 |
-
*/
|
273 |
-
|
274 |
-
function meta_box_input( $post, $args )
|
275 |
-
{
|
276 |
-
// extract $args
|
277 |
-
extract( $args );
|
278 |
-
|
279 |
-
|
280 |
-
// classes
|
281 |
-
$class = 'acf_postbox ' . $args['field_group']['options']['layout'];
|
282 |
-
$toggle_class = 'acf_postbox-toggle';
|
283 |
-
|
284 |
-
|
285 |
-
if( ! $args['show'] )
|
286 |
-
{
|
287 |
-
$class .= ' acf-hidden';
|
288 |
-
$toggle_class .= ' acf-hidden';
|
289 |
-
}
|
290 |
-
|
291 |
-
|
292 |
-
// HTML
|
293 |
-
if( $args['show'] )
|
294 |
-
{
|
295 |
-
$fields = apply_filters('acf/field_group/get_fields', array(), $args['field_group']['id']);
|
296 |
-
|
297 |
-
do_action('acf/create_fields', $fields, $args['post_id']);
|
298 |
-
}
|
299 |
-
else
|
300 |
-
{
|
301 |
-
echo '<div class="acf-replace-with-fields"><div class="acf-loading"></div></div>';
|
302 |
-
}
|
303 |
-
|
304 |
-
|
305 |
-
// nonce
|
306 |
-
echo '<div style="display:none">';
|
307 |
-
echo '<input type="hidden" name="acf_nonce" value="' . wp_create_nonce( 'input' ) . '" />';
|
308 |
-
?>
|
309 |
-
<script type="text/javascript">
|
310 |
-
(function($) {
|
311 |
-
|
312 |
-
$('#<?php echo $id; ?>').addClass('<?php echo $class; ?>').removeClass('hide-if-js');
|
313 |
-
$('#adv-settings label[for="<?php echo $id; ?>-hide"]').addClass('<?php echo $toggle_class; ?>');
|
314 |
-
|
315 |
-
})(jQuery);
|
316 |
-
</script>
|
317 |
-
<?php
|
318 |
-
echo '</div>';
|
319 |
-
}
|
320 |
-
|
321 |
-
|
322 |
-
/*
|
323 |
-
* get_style
|
324 |
-
*
|
325 |
-
* @description: called by admin_head to generate acf css style (hide other metaboxes)
|
326 |
-
* @since 2.0.5
|
327 |
-
* @created: 23/06/12
|
328 |
-
*/
|
329 |
-
|
330 |
-
function get_style( $acf_id )
|
331 |
-
{
|
332 |
-
// vars
|
333 |
-
$options = apply_filters('acf/field_group/get_options', array(), $acf_id);
|
334 |
-
$html = '';
|
335 |
-
|
336 |
-
|
337 |
-
// add style to html
|
338 |
-
if( in_array('permalink',$options['hide_on_screen']) )
|
339 |
-
{
|
340 |
-
$html .= '#edit-slug-box {display: none;} ';
|
341 |
-
}
|
342 |
-
if( in_array('the_content',$options['hide_on_screen']) )
|
343 |
-
{
|
344 |
-
$html .= '#postdivrich {display: none;} ';
|
345 |
-
}
|
346 |
-
if( in_array('excerpt',$options['hide_on_screen']) )
|
347 |
-
{
|
348 |
-
$html .= '#postexcerpt, #screen-meta label[for=postexcerpt-hide] {display: none;} ';
|
349 |
-
}
|
350 |
-
if( in_array('custom_fields',$options['hide_on_screen']) )
|
351 |
-
{
|
352 |
-
$html .= '#postcustom, #screen-meta label[for=postcustom-hide] { display: none; } ';
|
353 |
-
}
|
354 |
-
if( in_array('discussion',$options['hide_on_screen']) )
|
355 |
-
{
|
356 |
-
$html .= '#commentstatusdiv, #screen-meta label[for=commentstatusdiv-hide] {display: none;} ';
|
357 |
-
}
|
358 |
-
if( in_array('comments',$options['hide_on_screen']) )
|
359 |
-
{
|
360 |
-
$html .= '#commentsdiv, #screen-meta label[for=commentsdiv-hide] {display: none;} ';
|
361 |
-
}
|
362 |
-
if( in_array('slug',$options['hide_on_screen']) )
|
363 |
-
{
|
364 |
-
$html .= '#slugdiv, #screen-meta label[for=slugdiv-hide] {display: none;} ';
|
365 |
-
}
|
366 |
-
if( in_array('author',$options['hide_on_screen']) )
|
367 |
-
{
|
368 |
-
$html .= '#authordiv, #screen-meta label[for=authordiv-hide] {display: none;} ';
|
369 |
-
}
|
370 |
-
if( in_array('format',$options['hide_on_screen']) )
|
371 |
-
{
|
372 |
-
$html .= '#formatdiv, #screen-meta label[for=formatdiv-hide] {display: none;} ';
|
373 |
-
}
|
374 |
-
if( in_array('featured_image',$options['hide_on_screen']) )
|
375 |
-
{
|
376 |
-
$html .= '#postimagediv, #screen-meta label[for=postimagediv-hide] {display: none;} ';
|
377 |
-
}
|
378 |
-
if( in_array('revisions',$options['hide_on_screen']) )
|
379 |
-
{
|
380 |
-
$html .= '#revisionsdiv, #screen-meta label[for=revisionsdiv-hide] {display: none;} ';
|
381 |
-
}
|
382 |
-
if( in_array('categories',$options['hide_on_screen']) )
|
383 |
-
{
|
384 |
-
$html .= '#categorydiv, #screen-meta label[for=categorydiv-hide] {display: none;} ';
|
385 |
-
}
|
386 |
-
if( in_array('tags',$options['hide_on_screen']) )
|
387 |
-
{
|
388 |
-
$html .= '#tagsdiv-post_tag, #screen-meta label[for=tagsdiv-post_tag-hide] {display: none;} ';
|
389 |
-
}
|
390 |
-
if( in_array('send-trackbacks',$options['hide_on_screen']) )
|
391 |
-
{
|
392 |
-
$html .= '#trackbacksdiv, #screen-meta label[for=trackbacksdiv-hide] {display: none;} ';
|
393 |
-
}
|
394 |
-
|
395 |
-
|
396 |
-
return $html;
|
397 |
-
}
|
398 |
-
|
399 |
-
|
400 |
-
/*
|
401 |
-
* ajax_get_input_style
|
402 |
-
*
|
403 |
-
* @description: called by input-actions.js to hide / show other metaboxes
|
404 |
-
* @since 2.0.5
|
405 |
-
* @created: 23/06/12
|
406 |
-
*/
|
407 |
-
|
408 |
-
function ajax_get_style()
|
409 |
-
{
|
410 |
-
// vars
|
411 |
-
$options = array(
|
412 |
-
'acf_id' => 0,
|
413 |
-
'nonce' => ''
|
414 |
-
);
|
415 |
-
|
416 |
-
// load post options
|
417 |
-
$options = array_merge($options, $_POST);
|
418 |
-
|
419 |
-
|
420 |
-
// verify nonce
|
421 |
-
if( ! wp_verify_nonce($options['nonce'], 'acf_nonce') )
|
422 |
-
{
|
423 |
-
die(0);
|
424 |
-
}
|
425 |
-
|
426 |
-
|
427 |
-
// return style
|
428 |
-
echo $this->get_style( $options['acf_id'] );
|
429 |
-
|
430 |
-
|
431 |
-
// die
|
432 |
-
die;
|
433 |
-
}
|
434 |
-
|
435 |
-
|
436 |
-
/*
|
437 |
-
* ajax_render_fields
|
438 |
-
*
|
439 |
-
* @description:
|
440 |
-
* @since 3.1.6
|
441 |
-
* @created: 23/06/12
|
442 |
-
*/
|
443 |
-
|
444 |
-
function ajax_render_fields()
|
445 |
-
{
|
446 |
-
|
447 |
-
// defaults
|
448 |
-
$options = array(
|
449 |
-
'acf_id' => 0,
|
450 |
-
'post_id' => 0,
|
451 |
-
'nonce' => ''
|
452 |
-
);
|
453 |
-
|
454 |
-
|
455 |
-
// load post options
|
456 |
-
$options = array_merge($options, $_POST);
|
457 |
-
|
458 |
-
|
459 |
-
// verify nonce
|
460 |
-
if( ! wp_verify_nonce($options['nonce'], 'acf_nonce') )
|
461 |
-
{
|
462 |
-
die(0);
|
463 |
-
}
|
464 |
-
|
465 |
-
|
466 |
-
// get acfs
|
467 |
-
$acfs = apply_filters('acf/get_field_groups', array());
|
468 |
-
if( $acfs )
|
469 |
-
{
|
470 |
-
foreach( $acfs as $acf )
|
471 |
-
{
|
472 |
-
if( $acf['id'] == $options['acf_id'] )
|
473 |
-
{
|
474 |
-
$fields = apply_filters('acf/field_group/get_fields', array(), $acf['id']);
|
475 |
-
|
476 |
-
do_action('acf/create_fields', $fields, $options['post_id']);
|
477 |
-
|
478 |
-
break;
|
479 |
-
}
|
480 |
-
}
|
481 |
-
}
|
482 |
-
|
483 |
-
die();
|
484 |
-
|
485 |
-
}
|
486 |
-
|
487 |
-
|
488 |
-
/*
|
489 |
-
* save_post
|
490 |
-
*
|
491 |
-
* @description: Saves the field / location / option data for a field group
|
492 |
-
* @since 1.0.0
|
493 |
-
* @created: 23/06/12
|
494 |
-
*/
|
495 |
-
|
496 |
-
function save_post( $post_id )
|
497 |
-
{
|
498 |
-
|
499 |
-
// do not save if this is an auto save routine
|
500 |
-
if( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
|
501 |
-
{
|
502 |
-
return $post_id;
|
503 |
-
}
|
504 |
-
|
505 |
-
|
506 |
-
// verify nonce
|
507 |
-
if( !isset($_POST['acf_nonce'], $_POST['fields']) || !wp_verify_nonce($_POST['acf_nonce'], 'input') )
|
508 |
-
{
|
509 |
-
return $post_id;
|
510 |
-
}
|
511 |
-
|
512 |
-
|
513 |
-
// if save lock contains a value, the save_post action is already running for another post.
|
514 |
-
// this would imply that the user is hooking into an ACF update_value or save_post action and inserting a new post
|
515 |
-
// if this is the case, we do not want to save all the $POST data to this post.
|
516 |
-
if( isset($GLOBALS['acf_save_lock']) && $GLOBALS['acf_save_lock'] )
|
517 |
-
{
|
518 |
-
return $post_id;
|
519 |
-
}
|
520 |
-
|
521 |
-
|
522 |
-
// update the post (may even be a revision / autosave preview)
|
523 |
-
do_action('acf/save_post', $post_id);
|
524 |
-
|
525 |
-
}
|
526 |
-
|
527 |
-
|
528 |
-
/*
|
529 |
-
* is_protected_meta
|
530 |
-
*
|
531 |
-
* This function will remove any ACF meta from showing in the meta postbox
|
532 |
-
*
|
533 |
-
* @type function
|
534 |
-
* @date 12/04/2014
|
535 |
-
* @since 5.0.0
|
536 |
-
*
|
537 |
-
* @param $post_id (int)
|
538 |
-
* @return $post_id (int)
|
539 |
-
*/
|
540 |
-
|
541 |
-
function is_protected_meta( $protected, $meta_key, $meta_type ) {
|
542 |
-
|
543 |
-
// globals
|
544 |
-
global $post;
|
545 |
-
|
546 |
-
|
547 |
-
// if acf_get_field_reference returns a valid key, this is an acf value, so protect it!
|
548 |
-
if( !$protected ) {
|
549 |
-
|
550 |
-
$reference = get_field_reference( $meta_key, $post->ID );
|
551 |
-
|
552 |
-
if( substr($reference, 0, 6) === 'field_' ) {
|
553 |
-
|
554 |
-
$protected = true;
|
555 |
-
|
556 |
-
}
|
557 |
-
|
558 |
-
}
|
559 |
-
|
560 |
-
|
561 |
-
// return
|
562 |
-
return $protected;
|
563 |
-
|
564 |
-
}
|
565 |
-
|
566 |
-
|
567 |
-
}
|
568 |
-
|
569 |
-
new acf_controller_post();
|
570 |
-
|
571 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* acf_controller_post
|
5 |
+
*
|
6 |
+
* This class contains the functionality to add ACF fields to a post edit form
|
7 |
+
*
|
8 |
+
* @type class
|
9 |
+
* @date 5/09/13
|
10 |
+
* @since 3.1.8
|
11 |
+
*
|
12 |
+
*/
|
13 |
+
|
14 |
+
class acf_controller_post
|
15 |
+
{
|
16 |
+
|
17 |
+
/*
|
18 |
+
* Constructor
|
19 |
+
*
|
20 |
+
* This function will construct all the neccessary actions and filters
|
21 |
+
*
|
22 |
+
* @type function
|
23 |
+
* @date 23/06/12
|
24 |
+
* @since 3.1.8
|
25 |
+
*
|
26 |
+
* @param N/A
|
27 |
+
* @return N/A
|
28 |
+
*/
|
29 |
+
|
30 |
+
function __construct()
|
31 |
+
{
|
32 |
+
// actions
|
33 |
+
add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
|
34 |
+
add_action('save_post', array($this, 'save_post'), 10, 1);
|
35 |
+
|
36 |
+
|
37 |
+
// ajax
|
38 |
+
add_action('wp_ajax_acf/post/render_fields', array($this, 'ajax_render_fields'));
|
39 |
+
add_action('wp_ajax_acf/post/get_style', array($this, 'ajax_get_style'));
|
40 |
+
}
|
41 |
+
|
42 |
+
|
43 |
+
/*
|
44 |
+
* validate_page
|
45 |
+
*
|
46 |
+
* This function will check if the current page is for a post/page edit form
|
47 |
+
*
|
48 |
+
* @type function
|
49 |
+
* @date 23/06/12
|
50 |
+
* @since 3.1.8
|
51 |
+
*
|
52 |
+
* @param N/A
|
53 |
+
* @return (boolean)
|
54 |
+
*/
|
55 |
+
|
56 |
+
function validate_page()
|
57 |
+
{
|
58 |
+
// global
|
59 |
+
global $pagenow, $typenow;
|
60 |
+
|
61 |
+
|
62 |
+
// vars
|
63 |
+
$return = false;
|
64 |
+
|
65 |
+
|
66 |
+
// validate page
|
67 |
+
if( in_array( $pagenow, array('post.php', 'post-new.php') ) )
|
68 |
+
{
|
69 |
+
|
70 |
+
// validate post type
|
71 |
+
global $typenow;
|
72 |
+
|
73 |
+
if( $typenow != "acf" )
|
74 |
+
{
|
75 |
+
$return = true;
|
76 |
+
}
|
77 |
+
|
78 |
+
}
|
79 |
+
|
80 |
+
|
81 |
+
// validate page (Shopp)
|
82 |
+
if( $pagenow == "admin.php" && isset( $_GET['page'] ) && $_GET['page'] == "shopp-products" && isset( $_GET['id'] ) )
|
83 |
+
{
|
84 |
+
$return = true;
|
85 |
+
}
|
86 |
+
|
87 |
+
|
88 |
+
// return
|
89 |
+
return $return;
|
90 |
+
}
|
91 |
+
|
92 |
+
|
93 |
+
/*
|
94 |
+
* admin_enqueue_scripts
|
95 |
+
*
|
96 |
+
* This action is run after post query but before any admin script / head actions.
|
97 |
+
* It is a good place to register all actions.
|
98 |
+
*
|
99 |
+
* @type action (admin_enqueue_scripts)
|
100 |
+
* @date 26/01/13
|
101 |
+
* @since 3.6.0
|
102 |
+
*
|
103 |
+
* @param N/A
|
104 |
+
* @return N/A
|
105 |
+
*/
|
106 |
+
|
107 |
+
function admin_enqueue_scripts()
|
108 |
+
{
|
109 |
+
// validate page
|
110 |
+
if( ! $this->validate_page() )
|
111 |
+
{
|
112 |
+
return;
|
113 |
+
}
|
114 |
+
|
115 |
+
|
116 |
+
// actions
|
117 |
+
do_action('acf/input/admin_enqueue_scripts');
|
118 |
+
|
119 |
+
add_action('admin_head', array($this,'admin_head'));
|
120 |
+
}
|
121 |
+
|
122 |
+
|
123 |
+
/*
|
124 |
+
* admin_head
|
125 |
+
*
|
126 |
+
* This action will find and add field groups to the current edit page
|
127 |
+
*
|
128 |
+
* @type action (admin_head)
|
129 |
+
* @date 23/06/12
|
130 |
+
* @since 3.1.8
|
131 |
+
*
|
132 |
+
* @param N/A
|
133 |
+
* @return N/A
|
134 |
+
*/
|
135 |
+
|
136 |
+
function admin_head()
|
137 |
+
{
|
138 |
+
// globals
|
139 |
+
global $post, $pagenow, $typenow;
|
140 |
+
|
141 |
+
|
142 |
+
// shopp
|
143 |
+
if( $pagenow == "admin.php" && isset( $_GET['page'] ) && $_GET['page'] == "shopp-products" && isset( $_GET['id'] ) )
|
144 |
+
{
|
145 |
+
$typenow = "shopp_product";
|
146 |
+
}
|
147 |
+
|
148 |
+
|
149 |
+
// vars
|
150 |
+
$post_id = $post ? $post->ID : 0;
|
151 |
+
|
152 |
+
|
153 |
+
// get field groups
|
154 |
+
$filter = array(
|
155 |
+
'post_id' => $post_id,
|
156 |
+
'post_type' => $typenow
|
157 |
+
);
|
158 |
+
$metabox_ids = array();
|
159 |
+
$metabox_ids = apply_filters( 'acf/location/match_field_groups', $metabox_ids, $filter );
|
160 |
+
|
161 |
+
|
162 |
+
// get style of first field group
|
163 |
+
$style = '';
|
164 |
+
if( isset($metabox_ids[0]) )
|
165 |
+
{
|
166 |
+
$style = $this->get_style( $metabox_ids[0] );
|
167 |
+
}
|
168 |
+
|
169 |
+
|
170 |
+
// Style
|
171 |
+
echo '<style type="text/css" id="acf_style" >' . $style . '</style>';
|
172 |
+
|
173 |
+
|
174 |
+
// add user js + css
|
175 |
+
do_action('acf/input/admin_head');
|
176 |
+
|
177 |
+
|
178 |
+
// get field groups
|
179 |
+
$acfs = apply_filters('acf/get_field_groups', array());
|
180 |
+
|
181 |
+
|
182 |
+
if( $acfs )
|
183 |
+
{
|
184 |
+
foreach( $acfs as $acf )
|
185 |
+
{
|
186 |
+
// load options
|
187 |
+
$acf['options'] = apply_filters('acf/field_group/get_options', array(), $acf['id']);
|
188 |
+
|
189 |
+
|
190 |
+
// vars
|
191 |
+
$show = in_array( $acf['id'], $metabox_ids ) ? 1 : 0;
|
192 |
+
|
193 |
+
|
194 |
+
// priority
|
195 |
+
$priority = 'high';
|
196 |
+
if( $acf['options']['position'] == 'side' )
|
197 |
+
{
|
198 |
+
$priority = 'core';
|
199 |
+
}
|
200 |
+
$priority = apply_filters('acf/input/meta_box_priority', $priority, $acf);
|
201 |
+
|
202 |
+
|
203 |
+
// add meta box
|
204 |
+
add_meta_box(
|
205 |
+
'acf_' . $acf['id'],
|
206 |
+
$acf['title'],
|
207 |
+
array($this, 'meta_box_input'),
|
208 |
+
$typenow,
|
209 |
+
$acf['options']['position'],
|
210 |
+
$priority,
|
211 |
+
array( 'field_group' => $acf, 'show' => $show, 'post_id' => $post_id )
|
212 |
+
);
|
213 |
+
|
214 |
+
}
|
215 |
+
// foreach($acfs as $acf)
|
216 |
+
}
|
217 |
+
// if($acfs)
|
218 |
+
|
219 |
+
|
220 |
+
// Allow 'acf_after_title' metabox position
|
221 |
+
add_action('edit_form_after_title', array($this, 'edit_form_after_title'));
|
222 |
+
|
223 |
+
|
224 |
+
// remove ACF from meta postbox
|
225 |
+
add_filter( 'is_protected_meta', array($this, 'is_protected_meta'), 10, 3 );
|
226 |
+
}
|
227 |
+
|
228 |
+
|
229 |
+
/*
|
230 |
+
* edit_form_after_title
|
231 |
+
*
|
232 |
+
* This action will allow ACF to render metaboxes after the title
|
233 |
+
*
|
234 |
+
* @type action
|
235 |
+
* @date 17/08/13
|
236 |
+
*
|
237 |
+
* @param N/A
|
238 |
+
* @return N/A
|
239 |
+
*/
|
240 |
+
|
241 |
+
function edit_form_after_title()
|
242 |
+
{
|
243 |
+
// globals
|
244 |
+
global $post, $wp_meta_boxes;
|
245 |
+
|
246 |
+
|
247 |
+
// render
|
248 |
+
do_meta_boxes( get_current_screen(), 'acf_after_title', $post);
|
249 |
+
|
250 |
+
|
251 |
+
// clean up
|
252 |
+
unset( $wp_meta_boxes['post']['acf_after_title'] );
|
253 |
+
|
254 |
+
|
255 |
+
// preview hack
|
256 |
+
// the following code will add a hidden input which will trigger WP to create a revision apon save
|
257 |
+
// http://support.advancedcustomfields.com/forums/topic/preview-solution/#post-4106
|
258 |
+
?>
|
259 |
+
<div style="display:none">
|
260 |
+
<input type="hidden" name="acf_has_changed" id="acf-has-changed" value="0" />
|
261 |
+
</div>
|
262 |
+
<?php
|
263 |
+
}
|
264 |
+
|
265 |
+
|
266 |
+
/*
|
267 |
+
* meta_box_input
|
268 |
+
*
|
269 |
+
* @description:
|
270 |
+
* @since 1.0.0
|
271 |
+
* @created: 23/06/12
|
272 |
+
*/
|
273 |
+
|
274 |
+
function meta_box_input( $post, $args )
|
275 |
+
{
|
276 |
+
// extract $args
|
277 |
+
extract( $args );
|
278 |
+
|
279 |
+
|
280 |
+
// classes
|
281 |
+
$class = 'acf_postbox ' . $args['field_group']['options']['layout'];
|
282 |
+
$toggle_class = 'acf_postbox-toggle';
|
283 |
+
|
284 |
+
|
285 |
+
if( ! $args['show'] )
|
286 |
+
{
|
287 |
+
$class .= ' acf-hidden';
|
288 |
+
$toggle_class .= ' acf-hidden';
|
289 |
+
}
|
290 |
+
|
291 |
+
|
292 |
+
// HTML
|
293 |
+
if( $args['show'] )
|
294 |
+
{
|
295 |
+
$fields = apply_filters('acf/field_group/get_fields', array(), $args['field_group']['id']);
|
296 |
+
|
297 |
+
do_action('acf/create_fields', $fields, $args['post_id']);
|
298 |
+
}
|
299 |
+
else
|
300 |
+
{
|
301 |
+
echo '<div class="acf-replace-with-fields"><div class="acf-loading"></div></div>';
|
302 |
+
}
|
303 |
+
|
304 |
+
|
305 |
+
// nonce
|
306 |
+
echo '<div style="display:none">';
|
307 |
+
echo '<input type="hidden" name="acf_nonce" value="' . wp_create_nonce( 'input' ) . '" />';
|
308 |
+
?>
|
309 |
+
<script type="text/javascript">
|
310 |
+
(function($) {
|
311 |
+
|
312 |
+
$('#<?php echo $id; ?>').addClass('<?php echo $class; ?>').removeClass('hide-if-js');
|
313 |
+
$('#adv-settings label[for="<?php echo $id; ?>-hide"]').addClass('<?php echo $toggle_class; ?>');
|
314 |
+
|
315 |
+
})(jQuery);
|
316 |
+
</script>
|
317 |
+
<?php
|
318 |
+
echo '</div>';
|
319 |
+
}
|
320 |
+
|
321 |
+
|
322 |
+
/*
|
323 |
+
* get_style
|
324 |
+
*
|
325 |
+
* @description: called by admin_head to generate acf css style (hide other metaboxes)
|
326 |
+
* @since 2.0.5
|
327 |
+
* @created: 23/06/12
|
328 |
+
*/
|
329 |
+
|
330 |
+
function get_style( $acf_id )
|
331 |
+
{
|
332 |
+
// vars
|
333 |
+
$options = apply_filters('acf/field_group/get_options', array(), $acf_id);
|
334 |
+
$html = '';
|
335 |
+
|
336 |
+
|
337 |
+
// add style to html
|
338 |
+
if( in_array('permalink',$options['hide_on_screen']) )
|
339 |
+
{
|
340 |
+
$html .= '#edit-slug-box {display: none;} ';
|
341 |
+
}
|
342 |
+
if( in_array('the_content',$options['hide_on_screen']) )
|
343 |
+
{
|
344 |
+
$html .= '#postdivrich {display: none;} ';
|
345 |
+
}
|
346 |
+
if( in_array('excerpt',$options['hide_on_screen']) )
|
347 |
+
{
|
348 |
+
$html .= '#postexcerpt, #screen-meta label[for=postexcerpt-hide] {display: none;} ';
|
349 |
+
}
|
350 |
+
if( in_array('custom_fields',$options['hide_on_screen']) )
|
351 |
+
{
|
352 |
+
$html .= '#postcustom, #screen-meta label[for=postcustom-hide] { display: none; } ';
|
353 |
+
}
|
354 |
+
if( in_array('discussion',$options['hide_on_screen']) )
|
355 |
+
{
|
356 |
+
$html .= '#commentstatusdiv, #screen-meta label[for=commentstatusdiv-hide] {display: none;} ';
|
357 |
+
}
|
358 |
+
if( in_array('comments',$options['hide_on_screen']) )
|
359 |
+
{
|
360 |
+
$html .= '#commentsdiv, #screen-meta label[for=commentsdiv-hide] {display: none;} ';
|
361 |
+
}
|
362 |
+
if( in_array('slug',$options['hide_on_screen']) )
|
363 |
+
{
|
364 |
+
$html .= '#slugdiv, #screen-meta label[for=slugdiv-hide] {display: none;} ';
|
365 |
+
}
|
366 |
+
if( in_array('author',$options['hide_on_screen']) )
|
367 |
+
{
|
368 |
+
$html .= '#authordiv, #screen-meta label[for=authordiv-hide] {display: none;} ';
|
369 |
+
}
|
370 |
+
if( in_array('format',$options['hide_on_screen']) )
|
371 |
+
{
|
372 |
+
$html .= '#formatdiv, #screen-meta label[for=formatdiv-hide] {display: none;} ';
|
373 |
+
}
|
374 |
+
if( in_array('featured_image',$options['hide_on_screen']) )
|
375 |
+
{
|
376 |
+
$html .= '#postimagediv, #screen-meta label[for=postimagediv-hide] {display: none;} ';
|
377 |
+
}
|
378 |
+
if( in_array('revisions',$options['hide_on_screen']) )
|
379 |
+
{
|
380 |
+
$html .= '#revisionsdiv, #screen-meta label[for=revisionsdiv-hide] {display: none;} ';
|
381 |
+
}
|
382 |
+
if( in_array('categories',$options['hide_on_screen']) )
|
383 |
+
{
|
384 |
+
$html .= '#categorydiv, #screen-meta label[for=categorydiv-hide] {display: none;} ';
|
385 |
+
}
|
386 |
+
if( in_array('tags',$options['hide_on_screen']) )
|
387 |
+
{
|
388 |
+
$html .= '#tagsdiv-post_tag, #screen-meta label[for=tagsdiv-post_tag-hide] {display: none;} ';
|
389 |
+
}
|
390 |
+
if( in_array('send-trackbacks',$options['hide_on_screen']) )
|
391 |
+
{
|
392 |
+
$html .= '#trackbacksdiv, #screen-meta label[for=trackbacksdiv-hide] {display: none;} ';
|
393 |
+
}
|
394 |
+
|
395 |
+
|
396 |
+
return $html;
|
397 |
+
}
|
398 |
+
|
399 |
+
|
400 |
+
/*
|
401 |
+
* ajax_get_input_style
|
402 |
+
*
|
403 |
+
* @description: called by input-actions.js to hide / show other metaboxes
|
404 |
+
* @since 2.0.5
|
405 |
+
* @created: 23/06/12
|
406 |
+
*/
|
407 |
+
|
408 |
+
function ajax_get_style()
|
409 |
+
{
|
410 |
+
// vars
|
411 |
+
$options = array(
|
412 |
+
'acf_id' => 0,
|
413 |
+
'nonce' => ''
|
414 |
+
);
|
415 |
+
|
416 |
+
// load post options
|
417 |
+
$options = array_merge($options, $_POST);
|
418 |
+
|
419 |
+
|
420 |
+
// verify nonce
|
421 |
+
if( ! wp_verify_nonce($options['nonce'], 'acf_nonce') )
|
422 |
+
{
|
423 |
+
die(0);
|
424 |
+
}
|
425 |
+
|
426 |
+
|
427 |
+
// return style
|
428 |
+
echo $this->get_style( $options['acf_id'] );
|
429 |
+
|
430 |
+
|
431 |
+
// die
|
432 |
+
die;
|
433 |
+
}
|
434 |
+
|
435 |
+
|
436 |
+
/*
|
437 |
+
* ajax_render_fields
|
438 |
+
*
|
439 |
+
* @description:
|
440 |
+
* @since 3.1.6
|
441 |
+
* @created: 23/06/12
|
442 |
+
*/
|
443 |
+
|
444 |
+
function ajax_render_fields()
|
445 |
+
{
|
446 |
+
|
447 |
+
// defaults
|
448 |
+
$options = array(
|
449 |
+
'acf_id' => 0,
|
450 |
+
'post_id' => 0,
|
451 |
+
'nonce' => ''
|
452 |
+
);
|
453 |
+
|
454 |
+
|
455 |
+
// load post options
|
456 |
+
$options = array_merge($options, $_POST);
|
457 |
+
|
458 |
+
|
459 |
+
// verify nonce
|
460 |
+
if( ! wp_verify_nonce($options['nonce'], 'acf_nonce') )
|
461 |
+
{
|
462 |
+
die(0);
|
463 |
+
}
|
464 |
+
|
465 |
+
|
466 |
+
// get acfs
|
467 |
+
$acfs = apply_filters('acf/get_field_groups', array());
|
468 |
+
if( $acfs )
|
469 |
+
{
|
470 |
+
foreach( $acfs as $acf )
|
471 |
+
{
|
472 |
+
if( $acf['id'] == $options['acf_id'] )
|
473 |
+
{
|
474 |
+
$fields = apply_filters('acf/field_group/get_fields', array(), $acf['id']);
|
475 |
+
|
476 |
+
do_action('acf/create_fields', $fields, $options['post_id']);
|
477 |
+
|
478 |
+
break;
|
479 |
+
}
|
480 |
+
}
|
481 |
+
}
|
482 |
+
|
483 |
+
die();
|
484 |
+
|
485 |
+
}
|
486 |
+
|
487 |
+
|
488 |
+
/*
|
489 |
+
* save_post
|
490 |
+
*
|
491 |
+
* @description: Saves the field / location / option data for a field group
|
492 |
+
* @since 1.0.0
|
493 |
+
* @created: 23/06/12
|
494 |
+
*/
|
495 |
+
|
496 |
+
function save_post( $post_id )
|
497 |
+
{
|
498 |
+
|
499 |
+
// do not save if this is an auto save routine
|
500 |
+
if( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
|
501 |
+
{
|
502 |
+
return $post_id;
|
503 |
+
}
|
504 |
+
|
505 |
+
|
506 |
+
// verify nonce
|
507 |
+
if( !isset($_POST['acf_nonce'], $_POST['fields']) || !wp_verify_nonce($_POST['acf_nonce'], 'input') )
|
508 |
+
{
|
509 |
+
return $post_id;
|
510 |
+
}
|
511 |
+
|
512 |
+
|
513 |
+
// if save lock contains a value, the save_post action is already running for another post.
|
514 |
+
// this would imply that the user is hooking into an ACF update_value or save_post action and inserting a new post
|
515 |
+
// if this is the case, we do not want to save all the $POST data to this post.
|
516 |
+
if( isset($GLOBALS['acf_save_lock']) && $GLOBALS['acf_save_lock'] )
|
517 |
+
{
|
518 |
+
return $post_id;
|
519 |
+
}
|
520 |
+
|
521 |
+
|
522 |
+
// update the post (may even be a revision / autosave preview)
|
523 |
+
do_action('acf/save_post', $post_id);
|
524 |
+
|
525 |
+
}
|
526 |
+
|
527 |
+
|
528 |
+
/*
|
529 |
+
* is_protected_meta
|
530 |
+
*
|
531 |
+
* This function will remove any ACF meta from showing in the meta postbox
|
532 |
+
*
|
533 |
+
* @type function
|
534 |
+
* @date 12/04/2014
|
535 |
+
* @since 5.0.0
|
536 |
+
*
|
537 |
+
* @param $post_id (int)
|
538 |
+
* @return $post_id (int)
|
539 |
+
*/
|
540 |
+
|
541 |
+
function is_protected_meta( $protected, $meta_key, $meta_type ) {
|
542 |
+
|
543 |
+
// globals
|
544 |
+
global $post;
|
545 |
+
|
546 |
+
|
547 |
+
// if acf_get_field_reference returns a valid key, this is an acf value, so protect it!
|
548 |
+
if( !$protected ) {
|
549 |
+
|
550 |
+
$reference = get_field_reference( $meta_key, $post->ID );
|
551 |
+
|
552 |
+
if( substr($reference, 0, 6) === 'field_' ) {
|
553 |
+
|
554 |
+
$protected = true;
|
555 |
+
|
556 |
+
}
|
557 |
+
|
558 |
+
}
|
559 |
+
|
560 |
+
|
561 |
+
// return
|
562 |
+
return $protected;
|
563 |
+
|
564 |
+
}
|
565 |
+
|
566 |
+
|
567 |
+
}
|
568 |
+
|
569 |
+
new acf_controller_post();
|
570 |
+
|
571 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/controllers/revisions.php
CHANGED
@@ -1,317 +1,306 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* Revisions
|
5 |
-
*
|
6 |
-
* This Class contains all the functionality for adding ACF fields to the WP revisions interface
|
7 |
-
*
|
8 |
-
* @type class
|
9 |
-
* @date 11/08/13
|
10 |
-
*/
|
11 |
-
|
12 |
-
class acf_revisions
|
13 |
-
{
|
14 |
-
|
15 |
-
/*
|
16 |
-
* __construct
|
17 |
-
*
|
18 |
-
* A good place to add actions / filters
|
19 |
-
*
|
20 |
-
* @type function
|
21 |
-
* @date 11/08/13
|
22 |
-
*
|
23 |
-
* @param N/A
|
24 |
-
* @return N/A
|
25 |
-
*/
|
26 |
-
|
27 |
-
function __construct()
|
28 |
-
{
|
29 |
-
// actions
|
30 |
-
add_action('wp_restore_post_revision', array($this, 'wp_restore_post_revision'), 10, 2 );
|
31 |
-
|
32 |
-
|
33 |
-
// filters
|
34 |
-
add_filter('_wp_post_revision_fields', array($this, 'wp_post_revision_fields') );
|
35 |
-
add_filter('wp_save_post_revision_check_for_changes', array($this, 'force_save_revision'), 10, 3);
|
36 |
-
}
|
37 |
-
|
38 |
-
|
39 |
-
/*
|
40 |
-
* force_save_revision
|
41 |
-
*
|
42 |
-
* This filter will return false and force WP to save a revision. This is required due to
|
43 |
-
* WP checking only post_title, post_excerpt and post_content values, not custom fields.
|
44 |
-
*
|
45 |
-
* @type filter
|
46 |
-
* @date 19/09/13
|
47 |
-
*
|
48 |
-
* @param $return (boolean) defaults to true
|
49 |
-
* @param $last_revision (object) the last revision that WP will compare against
|
50 |
-
* @param $post (object) the $post that WP will compare against
|
51 |
-
* @return $return (boolean)
|
52 |
-
*/
|
53 |
-
|
54 |
-
function force_save_revision( $return, $last_revision, $post )
|
55 |
-
{
|
56 |
-
// preview hack
|
57 |
-
if( isset($_POST['acf_has_changed']) && $_POST['acf_has_changed'] == '1' )
|
58 |
-
{
|
59 |
-
$return = false;
|
60 |
-
}
|
61 |
-
|
62 |
-
|
63 |
-
// return
|
64 |
-
return $return;
|
65 |
-
}
|
66 |
-
|
67 |
-
|
68 |
-
/*
|
69 |
-
* wp_post_revision_fields
|
70 |
-
*
|
71 |
-
* This filter will add the ACF fields to the returned array
|
72 |
-
* Versions 3.5 and 3.6 of WP feature different uses of the revisions filters, so there are
|
73 |
-
* some hacks to allow both versions to work correctly
|
74 |
-
*
|
75 |
-
* @type filter
|
76 |
-
* @date 11/08/13
|
77 |
-
*
|
78 |
-
* @param $post_id (int)
|
79 |
-
* @return $post_id (int)
|
80 |
-
*/
|
81 |
-
|
82 |
-
function wp_post_revision_fields( $return ) {
|
83 |
-
|
84 |
-
|
85 |
-
//globals
|
86 |
-
global $post, $pagenow;
|
87 |
-
|
88 |
-
|
89 |
-
// validate
|
90 |
-
$allowed = false;
|
91 |
-
|
92 |
-
|
93 |
-
// Normal revisions page
|
94 |
-
if( $pagenow == 'revision.php' )
|
95 |
-
{
|
96 |
-
$allowed = true;
|
97 |
-
}
|
98 |
-
|
99 |
-
|
100 |
-
// WP 3.6 AJAX revision
|
101 |
-
if( $pagenow == 'admin-ajax.php' && isset($_POST['action']) && $_POST['action'] == 'get-revision-diffs' )
|
102 |
-
{
|
103 |
-
$allowed = true;
|
104 |
-
}
|
105 |
-
|
106 |
-
|
107 |
-
// bail
|
108 |
-
if( !$allowed )
|
109 |
-
{
|
110 |
-
return $return;
|
111 |
-
}
|
112 |
-
|
113 |
-
|
114 |
-
// vars
|
115 |
-
$post_id = 0;
|
116 |
-
|
117 |
-
|
118 |
-
// determine $post_id
|
119 |
-
if( isset($_POST['post_id']) )
|
120 |
-
{
|
121 |
-
$post_id = $_POST['post_id'];
|
122 |
-
}
|
123 |
-
elseif( isset($post->ID) )
|
124 |
-
{
|
125 |
-
$post_id = $post->ID;
|
126 |
-
}
|
127 |
-
else
|
128 |
-
{
|
129 |
-
return $return;
|
130 |
-
}
|
131 |
-
|
132 |
-
|
133 |
-
// get field objects
|
134 |
-
$fields = get_field_objects( $post_id, array('format_value' => false ) );
|
135 |
-
|
136 |
-
|
137 |
-
if( $fields )
|
138 |
-
{
|
139 |
-
foreach( $fields as $field )
|
140 |
-
{
|
141 |
-
// dud field?
|
142 |
-
if( !$field || !isset($field['name']) || !$field['name'] )
|
143 |
-
{
|
144 |
-
continue;
|
145 |
-
}
|
146 |
-
|
147 |
-
|
148 |
-
// Add field key / label
|
149 |
-
$return[ $field['name'] ] = $field['label'];
|
150 |
-
|
151 |
-
|
152 |
-
// load value
|
153 |
-
add_filter('_wp_post_revision_field_' . $field['name'], array($this, 'wp_post_revision_field'), 10, 4);
|
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 |
-
$value
|
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 |
-
new acf_revisions();
|
316 |
-
|
317 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* Revisions
|
5 |
+
*
|
6 |
+
* This Class contains all the functionality for adding ACF fields to the WP revisions interface
|
7 |
+
*
|
8 |
+
* @type class
|
9 |
+
* @date 11/08/13
|
10 |
+
*/
|
11 |
+
|
12 |
+
class acf_revisions
|
13 |
+
{
|
14 |
+
|
15 |
+
/*
|
16 |
+
* __construct
|
17 |
+
*
|
18 |
+
* A good place to add actions / filters
|
19 |
+
*
|
20 |
+
* @type function
|
21 |
+
* @date 11/08/13
|
22 |
+
*
|
23 |
+
* @param N/A
|
24 |
+
* @return N/A
|
25 |
+
*/
|
26 |
+
|
27 |
+
function __construct()
|
28 |
+
{
|
29 |
+
// actions
|
30 |
+
add_action('wp_restore_post_revision', array($this, 'wp_restore_post_revision'), 10, 2 );
|
31 |
+
|
32 |
+
|
33 |
+
// filters
|
34 |
+
add_filter('_wp_post_revision_fields', array($this, 'wp_post_revision_fields') );
|
35 |
+
add_filter('wp_save_post_revision_check_for_changes', array($this, 'force_save_revision'), 10, 3);
|
36 |
+
}
|
37 |
+
|
38 |
+
|
39 |
+
/*
|
40 |
+
* force_save_revision
|
41 |
+
*
|
42 |
+
* This filter will return false and force WP to save a revision. This is required due to
|
43 |
+
* WP checking only post_title, post_excerpt and post_content values, not custom fields.
|
44 |
+
*
|
45 |
+
* @type filter
|
46 |
+
* @date 19/09/13
|
47 |
+
*
|
48 |
+
* @param $return (boolean) defaults to true
|
49 |
+
* @param $last_revision (object) the last revision that WP will compare against
|
50 |
+
* @param $post (object) the $post that WP will compare against
|
51 |
+
* @return $return (boolean)
|
52 |
+
*/
|
53 |
+
|
54 |
+
function force_save_revision( $return, $last_revision, $post )
|
55 |
+
{
|
56 |
+
// preview hack
|
57 |
+
if( isset($_POST['acf_has_changed']) && $_POST['acf_has_changed'] == '1' )
|
58 |
+
{
|
59 |
+
$return = false;
|
60 |
+
}
|
61 |
+
|
62 |
+
|
63 |
+
// return
|
64 |
+
return $return;
|
65 |
+
}
|
66 |
+
|
67 |
+
|
68 |
+
/*
|
69 |
+
* wp_post_revision_fields
|
70 |
+
*
|
71 |
+
* This filter will add the ACF fields to the returned array
|
72 |
+
* Versions 3.5 and 3.6 of WP feature different uses of the revisions filters, so there are
|
73 |
+
* some hacks to allow both versions to work correctly
|
74 |
+
*
|
75 |
+
* @type filter
|
76 |
+
* @date 11/08/13
|
77 |
+
*
|
78 |
+
* @param $post_id (int)
|
79 |
+
* @return $post_id (int)
|
80 |
+
*/
|
81 |
+
|
82 |
+
function wp_post_revision_fields( $return ) {
|
83 |
+
|
84 |
+
|
85 |
+
//globals
|
86 |
+
global $post, $pagenow;
|
87 |
+
|
88 |
+
|
89 |
+
// validate
|
90 |
+
$allowed = false;
|
91 |
+
|
92 |
+
|
93 |
+
// Normal revisions page
|
94 |
+
if( $pagenow == 'revision.php' )
|
95 |
+
{
|
96 |
+
$allowed = true;
|
97 |
+
}
|
98 |
+
|
99 |
+
|
100 |
+
// WP 3.6 AJAX revision
|
101 |
+
if( $pagenow == 'admin-ajax.php' && isset($_POST['action']) && $_POST['action'] == 'get-revision-diffs' )
|
102 |
+
{
|
103 |
+
$allowed = true;
|
104 |
+
}
|
105 |
+
|
106 |
+
|
107 |
+
// bail
|
108 |
+
if( !$allowed )
|
109 |
+
{
|
110 |
+
return $return;
|
111 |
+
}
|
112 |
+
|
113 |
+
|
114 |
+
// vars
|
115 |
+
$post_id = 0;
|
116 |
+
|
117 |
+
|
118 |
+
// determine $post_id
|
119 |
+
if( isset($_POST['post_id']) )
|
120 |
+
{
|
121 |
+
$post_id = $_POST['post_id'];
|
122 |
+
}
|
123 |
+
elseif( isset($post->ID) )
|
124 |
+
{
|
125 |
+
$post_id = $post->ID;
|
126 |
+
}
|
127 |
+
else
|
128 |
+
{
|
129 |
+
return $return;
|
130 |
+
}
|
131 |
+
|
132 |
+
|
133 |
+
// get field objects
|
134 |
+
$fields = get_field_objects( $post_id, array('format_value' => false ) );
|
135 |
+
|
136 |
+
|
137 |
+
if( $fields )
|
138 |
+
{
|
139 |
+
foreach( $fields as $field )
|
140 |
+
{
|
141 |
+
// dud field?
|
142 |
+
if( !$field || !isset($field['name']) || !$field['name'] )
|
143 |
+
{
|
144 |
+
continue;
|
145 |
+
}
|
146 |
+
|
147 |
+
|
148 |
+
// Add field key / label
|
149 |
+
$return[ $field['name'] ] = $field['label'];
|
150 |
+
|
151 |
+
|
152 |
+
// load value
|
153 |
+
add_filter('_wp_post_revision_field_' . $field['name'], array($this, 'wp_post_revision_field'), 10, 4);
|
154 |
+
|
155 |
+
}
|
156 |
+
}
|
157 |
+
|
158 |
+
|
159 |
+
return $return;
|
160 |
+
|
161 |
+
}
|
162 |
+
|
163 |
+
|
164 |
+
/*
|
165 |
+
* wp_post_revision_field
|
166 |
+
*
|
167 |
+
* This filter will load the value for the given field and return it for rendering
|
168 |
+
*
|
169 |
+
* @type filter
|
170 |
+
* @date 11/08/13
|
171 |
+
*
|
172 |
+
* @param $value (mixed) should be false as it has not yet been loaded
|
173 |
+
* @param $field_name (string) The name of the field
|
174 |
+
* @param $post (mixed) Holds the $post object to load from - in WP 3.5, this is not passed!
|
175 |
+
* @param $direction (string) to / from - not used
|
176 |
+
* @return $value (string)
|
177 |
+
*/
|
178 |
+
|
179 |
+
function wp_post_revision_field( $value, $field_name, $post = null, $direction = false)
|
180 |
+
{
|
181 |
+
// vars
|
182 |
+
$post_id = 0;
|
183 |
+
|
184 |
+
|
185 |
+
// determine $post_id
|
186 |
+
if( isset($post->ID) )
|
187 |
+
{
|
188 |
+
// WP 3.6
|
189 |
+
$post_id = $post->ID;
|
190 |
+
}
|
191 |
+
elseif( isset($_GET['revision']) )
|
192 |
+
{
|
193 |
+
// WP 3.5
|
194 |
+
$post_id = (int) $_GET['revision'];
|
195 |
+
}
|
196 |
+
elseif( strpos($value, 'revision_id=') !== false )
|
197 |
+
{
|
198 |
+
// WP 3.5 (left vs right)
|
199 |
+
$post_id = (int) str_replace('revision_id=', '', $value);
|
200 |
+
}
|
201 |
+
|
202 |
+
|
203 |
+
// load field
|
204 |
+
$field = get_field_object($field_name, $post_id, array('format_value' => false ));
|
205 |
+
$value = $field['value'];
|
206 |
+
|
207 |
+
|
208 |
+
// default formatting
|
209 |
+
if( is_array($value) )
|
210 |
+
{
|
211 |
+
$value = implode(', ', $value);
|
212 |
+
}
|
213 |
+
|
214 |
+
|
215 |
+
// format
|
216 |
+
if( $value )
|
217 |
+
{
|
218 |
+
// image?
|
219 |
+
if( $field['type'] == 'image' || $field['type'] == 'file' )
|
220 |
+
{
|
221 |
+
$url = wp_get_attachment_url($value);
|
222 |
+
$value = $value . ' (' . $url . ')';
|
223 |
+
}
|
224 |
+
}
|
225 |
+
|
226 |
+
|
227 |
+
// return
|
228 |
+
return $value;
|
229 |
+
}
|
230 |
+
|
231 |
+
|
232 |
+
/*
|
233 |
+
* wp_restore_post_revision
|
234 |
+
*
|
235 |
+
* This action will copy and paste the metadata from a revision to the post
|
236 |
+
*
|
237 |
+
* @type action
|
238 |
+
* @date 11/08/13
|
239 |
+
*
|
240 |
+
* @param $parent_id (int) the destination post
|
241 |
+
* @return $revision_id (int) the source post
|
242 |
+
*/
|
243 |
+
|
244 |
+
function wp_restore_post_revision( $post_id, $revision_id ) {
|
245 |
+
|
246 |
+
// global
|
247 |
+
global $wpdb;
|
248 |
+
|
249 |
+
|
250 |
+
// vars
|
251 |
+
$fields = array();
|
252 |
+
|
253 |
+
|
254 |
+
// get field from postmeta
|
255 |
+
$rows = $wpdb->get_results( $wpdb->prepare(
|
256 |
+
"SELECT * FROM $wpdb->postmeta WHERE post_id=%d",
|
257 |
+
$revision_id
|
258 |
+
), ARRAY_A);
|
259 |
+
|
260 |
+
|
261 |
+
// populate $fields
|
262 |
+
if( $rows )
|
263 |
+
{
|
264 |
+
foreach( $rows as $row )
|
265 |
+
{
|
266 |
+
// meta_key must start with '_'
|
267 |
+
if( substr($row['meta_key'], 0, 1) !== '_' )
|
268 |
+
{
|
269 |
+
continue;
|
270 |
+
}
|
271 |
+
|
272 |
+
|
273 |
+
// meta_value must start with 'field_'
|
274 |
+
if( substr($row['meta_value'], 0, 6) !== 'field_' )
|
275 |
+
{
|
276 |
+
continue;
|
277 |
+
}
|
278 |
+
|
279 |
+
|
280 |
+
// this is an ACF field, append to $fields
|
281 |
+
$fields[] = substr($row['meta_key'], 1);
|
282 |
+
|
283 |
+
}
|
284 |
+
}
|
285 |
+
|
286 |
+
|
287 |
+
// save data
|
288 |
+
if( $rows )
|
289 |
+
{
|
290 |
+
foreach( $rows as $row )
|
291 |
+
{
|
292 |
+
if( in_array($row['meta_key'], $fields) )
|
293 |
+
{
|
294 |
+
update_post_meta( $post_id, $row['meta_key'], $row['meta_value'] );
|
295 |
+
}
|
296 |
+
}
|
297 |
+
}
|
298 |
+
|
299 |
+
}
|
300 |
+
|
301 |
+
|
302 |
+
}
|
303 |
+
|
304 |
+
new acf_revisions();
|
305 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
306 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/controllers/third_party.php
CHANGED
@@ -1,234 +1,234 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* acf_third_party
|
5 |
-
*
|
6 |
-
* @description: controller for add-ons sub menu page
|
7 |
-
* @since: 3.6
|
8 |
-
* @created: 25/01/13
|
9 |
-
*/
|
10 |
-
|
11 |
-
class acf_third_party
|
12 |
-
{
|
13 |
-
/*
|
14 |
-
* __construct
|
15 |
-
*
|
16 |
-
* @description:
|
17 |
-
* @since 3.1.8
|
18 |
-
* @created: 23/06/12
|
19 |
-
*/
|
20 |
-
|
21 |
-
function __construct()
|
22 |
-
{
|
23 |
-
// Tabify Edit Screen - http://wordpress.org/extend/plugins/tabify-edit-screen/
|
24 |
-
add_action('admin_head-settings_page_tabify-edit-screen', array($this,'admin_head_tabify'));
|
25 |
-
|
26 |
-
|
27 |
-
// Duplicate Post - http://wordpress.org/extend/plugins/duplicate-post/
|
28 |
-
add_action('dp_duplicate_page', array($this, 'dp_duplicate_page'), 11, 2);
|
29 |
-
|
30 |
-
|
31 |
-
// Post Type Switcher - http://wordpress.org/extend/plugins/post-type-switcher/
|
32 |
-
add_filter('pts_post_type_filter', array($this, 'pts_post_type_filter'));
|
33 |
-
}
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
/*
|
38 |
-
* pts_allowed_pages
|
39 |
-
*
|
40 |
-
* @description:
|
41 |
-
* @since 3.5.3
|
42 |
-
* @created: 19/11/12
|
43 |
-
*/
|
44 |
-
|
45 |
-
function pts_post_type_filter( $args )
|
46 |
-
{
|
47 |
-
|
48 |
-
// global
|
49 |
-
global $typenow;
|
50 |
-
|
51 |
-
if( $typenow == "acf" )
|
52 |
-
{
|
53 |
-
$args = array(
|
54 |
-
'public' => false,
|
55 |
-
'show_ui' => true
|
56 |
-
);
|
57 |
-
}
|
58 |
-
|
59 |
-
|
60 |
-
// return
|
61 |
-
return $args;
|
62 |
-
}
|
63 |
-
|
64 |
-
|
65 |
-
/*
|
66 |
-
* admin_head_tabify
|
67 |
-
*
|
68 |
-
* @description:
|
69 |
-
* @since 3.5.1
|
70 |
-
* @created: 9/10/12
|
71 |
-
*/
|
72 |
-
|
73 |
-
function admin_head_tabify()
|
74 |
-
{
|
75 |
-
// remove ACF from the tabs
|
76 |
-
add_filter('tabify_posttypes', array($this, 'tabify_posttypes'));
|
77 |
-
|
78 |
-
|
79 |
-
// add acf metaboxes to list
|
80 |
-
add_action('tabify_add_meta_boxes' , array($this,'tabify_add_meta_boxes'));
|
81 |
-
|
82 |
-
}
|
83 |
-
|
84 |
-
|
85 |
-
/*
|
86 |
-
* tabify_posttypes
|
87 |
-
*
|
88 |
-
* @description:
|
89 |
-
* @since 3.5.1
|
90 |
-
* @created: 9/10/12
|
91 |
-
*/
|
92 |
-
|
93 |
-
function tabify_posttypes( $posttypes )
|
94 |
-
{
|
95 |
-
if( isset($posttypes['acf']) )
|
96 |
-
{
|
97 |
-
unset( $posttypes['acf'] );
|
98 |
-
}
|
99 |
-
|
100 |
-
return $posttypes;
|
101 |
-
}
|
102 |
-
|
103 |
-
|
104 |
-
/*
|
105 |
-
* tabify_add_meta_boxes
|
106 |
-
*
|
107 |
-
* @description:
|
108 |
-
* @since 3.5.1
|
109 |
-
* @created: 9/10/12
|
110 |
-
*/
|
111 |
-
|
112 |
-
function tabify_add_meta_boxes( $post_type )
|
113 |
-
{
|
114 |
-
// get acf's
|
115 |
-
$acfs = apply_filters('acf/get_field_groups', array());
|
116 |
-
|
117 |
-
if($acfs)
|
118 |
-
{
|
119 |
-
foreach($acfs as $acf)
|
120 |
-
{
|
121 |
-
// add meta box
|
122 |
-
add_meta_box(
|
123 |
-
'acf_' . $acf['id'],
|
124 |
-
$acf['title'],
|
125 |
-
array($this, 'dummy'),
|
126 |
-
$post_type
|
127 |
-
);
|
128 |
-
|
129 |
-
}
|
130 |
-
// foreach($acfs as $acf)
|
131 |
-
}
|
132 |
-
// if($acfs)
|
133 |
-
}
|
134 |
-
|
135 |
-
function dummy(){ /* Do Nothing */ }
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
/*
|
140 |
-
* dp_duplicate_page
|
141 |
-
*
|
142 |
-
* @description:
|
143 |
-
* @since 3.5.1
|
144 |
-
* @created: 9/10/12
|
145 |
-
*/
|
146 |
-
|
147 |
-
function dp_duplicate_page( $new_post_id, $old_post_object )
|
148 |
-
{
|
149 |
-
// only for acf
|
150 |
-
if( $old_post_object->post_type != "acf" )
|
151 |
-
{
|
152 |
-
return;
|
153 |
-
}
|
154 |
-
|
155 |
-
|
156 |
-
// update keys
|
157 |
-
$metas = get_post_custom( $new_post_id );
|
158 |
-
|
159 |
-
|
160 |
-
if( $metas )
|
161 |
-
{
|
162 |
-
foreach( $metas as $field_key => $field )
|
163 |
-
{
|
164 |
-
if( strpos($field_key, 'field_') !== false )
|
165 |
-
{
|
166 |
-
$field = $field[0];
|
167 |
-
$field = maybe_unserialize( $field );
|
168 |
-
$field = maybe_unserialize( $field ); // just to be sure!
|
169 |
-
|
170 |
-
// delete old field
|
171 |
-
delete_post_meta($new_post_id, $field_key);
|
172 |
-
|
173 |
-
|
174 |
-
// set new keys (recursive for sub fields)
|
175 |
-
$this->create_new_field_keys( $field );
|
176 |
-
|
177 |
-
|
178 |
-
// save it!
|
179 |
-
update_post_meta($new_post_id, $field['key'], $field);
|
180 |
-
|
181 |
-
}
|
182 |
-
// if( strpos($field_key, 'field_') !== false )
|
183 |
-
}
|
184 |
-
// foreach( $metas as $field_key => $field )
|
185 |
-
}
|
186 |
-
// if( $metas )
|
187 |
-
|
188 |
-
}
|
189 |
-
|
190 |
-
|
191 |
-
/*
|
192 |
-
* create_new_field_keys
|
193 |
-
*
|
194 |
-
* @description:
|
195 |
-
* @since 3.5.1
|
196 |
-
* @created: 9/10/12
|
197 |
-
*/
|
198 |
-
|
199 |
-
function create_new_field_keys( &$field )
|
200 |
-
{
|
201 |
-
// update key
|
202 |
-
$field['key'] = 'field_' . uniqid();
|
203 |
-
|
204 |
-
|
205 |
-
if( isset($field['sub_fields']) && is_array($field['sub_fields']) )
|
206 |
-
{
|
207 |
-
foreach( $field['sub_fields'] as $f )
|
208 |
-
{
|
209 |
-
$this->create_new_field_keys( $f );
|
210 |
-
}
|
211 |
-
}
|
212 |
-
elseif( isset($field['layouts']) && is_array($field['layouts']) )
|
213 |
-
{
|
214 |
-
foreach( $field['layouts'] as $layout )
|
215 |
-
{
|
216 |
-
if( isset($layout['sub_fields']) && is_array($layout['sub_fields']) )
|
217 |
-
{
|
218 |
-
foreach( $layout['sub_fields'] as $f )
|
219 |
-
{
|
220 |
-
$this->create_new_field_keys( $f );
|
221 |
-
}
|
222 |
-
}
|
223 |
-
|
224 |
-
}
|
225 |
-
}
|
226 |
-
}
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
}
|
231 |
-
|
232 |
-
new acf_third_party();
|
233 |
-
|
234 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* acf_third_party
|
5 |
+
*
|
6 |
+
* @description: controller for add-ons sub menu page
|
7 |
+
* @since: 3.6
|
8 |
+
* @created: 25/01/13
|
9 |
+
*/
|
10 |
+
|
11 |
+
class acf_third_party
|
12 |
+
{
|
13 |
+
/*
|
14 |
+
* __construct
|
15 |
+
*
|
16 |
+
* @description:
|
17 |
+
* @since 3.1.8
|
18 |
+
* @created: 23/06/12
|
19 |
+
*/
|
20 |
+
|
21 |
+
function __construct()
|
22 |
+
{
|
23 |
+
// Tabify Edit Screen - http://wordpress.org/extend/plugins/tabify-edit-screen/
|
24 |
+
add_action('admin_head-settings_page_tabify-edit-screen', array($this,'admin_head_tabify'));
|
25 |
+
|
26 |
+
|
27 |
+
// Duplicate Post - http://wordpress.org/extend/plugins/duplicate-post/
|
28 |
+
add_action('dp_duplicate_page', array($this, 'dp_duplicate_page'), 11, 2);
|
29 |
+
|
30 |
+
|
31 |
+
// Post Type Switcher - http://wordpress.org/extend/plugins/post-type-switcher/
|
32 |
+
add_filter('pts_post_type_filter', array($this, 'pts_post_type_filter'));
|
33 |
+
}
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
+
/*
|
38 |
+
* pts_allowed_pages
|
39 |
+
*
|
40 |
+
* @description:
|
41 |
+
* @since 3.5.3
|
42 |
+
* @created: 19/11/12
|
43 |
+
*/
|
44 |
+
|
45 |
+
function pts_post_type_filter( $args )
|
46 |
+
{
|
47 |
+
|
48 |
+
// global
|
49 |
+
global $typenow;
|
50 |
+
|
51 |
+
if( $typenow == "acf" )
|
52 |
+
{
|
53 |
+
$args = array(
|
54 |
+
'public' => false,
|
55 |
+
'show_ui' => true
|
56 |
+
);
|
57 |
+
}
|
58 |
+
|
59 |
+
|
60 |
+
// return
|
61 |
+
return $args;
|
62 |
+
}
|
63 |
+
|
64 |
+
|
65 |
+
/*
|
66 |
+
* admin_head_tabify
|
67 |
+
*
|
68 |
+
* @description:
|
69 |
+
* @since 3.5.1
|
70 |
+
* @created: 9/10/12
|
71 |
+
*/
|
72 |
+
|
73 |
+
function admin_head_tabify()
|
74 |
+
{
|
75 |
+
// remove ACF from the tabs
|
76 |
+
add_filter('tabify_posttypes', array($this, 'tabify_posttypes'));
|
77 |
+
|
78 |
+
|
79 |
+
// add acf metaboxes to list
|
80 |
+
add_action('tabify_add_meta_boxes' , array($this,'tabify_add_meta_boxes'));
|
81 |
+
|
82 |
+
}
|
83 |
+
|
84 |
+
|
85 |
+
/*
|
86 |
+
* tabify_posttypes
|
87 |
+
*
|
88 |
+
* @description:
|
89 |
+
* @since 3.5.1
|
90 |
+
* @created: 9/10/12
|
91 |
+
*/
|
92 |
+
|
93 |
+
function tabify_posttypes( $posttypes )
|
94 |
+
{
|
95 |
+
if( isset($posttypes['acf']) )
|
96 |
+
{
|
97 |
+
unset( $posttypes['acf'] );
|
98 |
+
}
|
99 |
+
|
100 |
+
return $posttypes;
|
101 |
+
}
|
102 |
+
|
103 |
+
|
104 |
+
/*
|
105 |
+
* tabify_add_meta_boxes
|
106 |
+
*
|
107 |
+
* @description:
|
108 |
+
* @since 3.5.1
|
109 |
+
* @created: 9/10/12
|
110 |
+
*/
|
111 |
+
|
112 |
+
function tabify_add_meta_boxes( $post_type )
|
113 |
+
{
|
114 |
+
// get acf's
|
115 |
+
$acfs = apply_filters('acf/get_field_groups', array());
|
116 |
+
|
117 |
+
if($acfs)
|
118 |
+
{
|
119 |
+
foreach($acfs as $acf)
|
120 |
+
{
|
121 |
+
// add meta box
|
122 |
+
add_meta_box(
|
123 |
+
'acf_' . $acf['id'],
|
124 |
+
$acf['title'],
|
125 |
+
array($this, 'dummy'),
|
126 |
+
$post_type
|
127 |
+
);
|
128 |
+
|
129 |
+
}
|
130 |
+
// foreach($acfs as $acf)
|
131 |
+
}
|
132 |
+
// if($acfs)
|
133 |
+
}
|
134 |
+
|
135 |
+
function dummy(){ /* Do Nothing */ }
|
136 |
+
|
137 |
+
|
138 |
+
|
139 |
+
/*
|
140 |
+
* dp_duplicate_page
|
141 |
+
*
|
142 |
+
* @description:
|
143 |
+
* @since 3.5.1
|
144 |
+
* @created: 9/10/12
|
145 |
+
*/
|
146 |
+
|
147 |
+
function dp_duplicate_page( $new_post_id, $old_post_object )
|
148 |
+
{
|
149 |
+
// only for acf
|
150 |
+
if( $old_post_object->post_type != "acf" )
|
151 |
+
{
|
152 |
+
return;
|
153 |
+
}
|
154 |
+
|
155 |
+
|
156 |
+
// update keys
|
157 |
+
$metas = get_post_custom( $new_post_id );
|
158 |
+
|
159 |
+
|
160 |
+
if( $metas )
|
161 |
+
{
|
162 |
+
foreach( $metas as $field_key => $field )
|
163 |
+
{
|
164 |
+
if( strpos($field_key, 'field_') !== false )
|
165 |
+
{
|
166 |
+
$field = $field[0];
|
167 |
+
$field = maybe_unserialize( $field );
|
168 |
+
$field = maybe_unserialize( $field ); // just to be sure!
|
169 |
+
|
170 |
+
// delete old field
|
171 |
+
delete_post_meta($new_post_id, $field_key);
|
172 |
+
|
173 |
+
|
174 |
+
// set new keys (recursive for sub fields)
|
175 |
+
$this->create_new_field_keys( $field );
|
176 |
+
|
177 |
+
|
178 |
+
// save it!
|
179 |
+
update_post_meta($new_post_id, $field['key'], $field);
|
180 |
+
|
181 |
+
}
|
182 |
+
// if( strpos($field_key, 'field_') !== false )
|
183 |
+
}
|
184 |
+
// foreach( $metas as $field_key => $field )
|
185 |
+
}
|
186 |
+
// if( $metas )
|
187 |
+
|
188 |
+
}
|
189 |
+
|
190 |
+
|
191 |
+
/*
|
192 |
+
* create_new_field_keys
|
193 |
+
*
|
194 |
+
* @description:
|
195 |
+
* @since 3.5.1
|
196 |
+
* @created: 9/10/12
|
197 |
+
*/
|
198 |
+
|
199 |
+
function create_new_field_keys( &$field )
|
200 |
+
{
|
201 |
+
// update key
|
202 |
+
$field['key'] = 'field_' . uniqid();
|
203 |
+
|
204 |
+
|
205 |
+
if( isset($field['sub_fields']) && is_array($field['sub_fields']) )
|
206 |
+
{
|
207 |
+
foreach( $field['sub_fields'] as $f )
|
208 |
+
{
|
209 |
+
$this->create_new_field_keys( $f );
|
210 |
+
}
|
211 |
+
}
|
212 |
+
elseif( isset($field['layouts']) && is_array($field['layouts']) )
|
213 |
+
{
|
214 |
+
foreach( $field['layouts'] as $layout )
|
215 |
+
{
|
216 |
+
if( isset($layout['sub_fields']) && is_array($layout['sub_fields']) )
|
217 |
+
{
|
218 |
+
foreach( $layout['sub_fields'] as $f )
|
219 |
+
{
|
220 |
+
$this->create_new_field_keys( $f );
|
221 |
+
}
|
222 |
+
}
|
223 |
+
|
224 |
+
}
|
225 |
+
}
|
226 |
+
}
|
227 |
+
|
228 |
+
|
229 |
+
|
230 |
+
}
|
231 |
+
|
232 |
+
new acf_third_party();
|
233 |
+
|
234 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/controllers/upgrade.php
CHANGED
@@ -1,829 +1,829 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* Upgrade
|
5 |
-
*
|
6 |
-
* @description: All the functionality for upgrading ACF
|
7 |
-
* @since 3.2.6
|
8 |
-
* @created: 23/06/12
|
9 |
-
*/
|
10 |
-
|
11 |
-
class acf_upgrade
|
12 |
-
{
|
13 |
-
|
14 |
-
/*
|
15 |
-
* __construct
|
16 |
-
*
|
17 |
-
* @description:
|
18 |
-
* @since 3.1.8
|
19 |
-
* @created: 23/06/12
|
20 |
-
*/
|
21 |
-
|
22 |
-
function __construct()
|
23 |
-
{
|
24 |
-
// actions
|
25 |
-
add_action('admin_menu', array($this,'admin_menu'), 11);
|
26 |
-
|
27 |
-
|
28 |
-
// ajax
|
29 |
-
add_action('wp_ajax_acf_upgrade', array($this, 'upgrade_ajax'));
|
30 |
-
}
|
31 |
-
|
32 |
-
|
33 |
-
/*
|
34 |
-
* admin_menu
|
35 |
-
*
|
36 |
-
* @description:
|
37 |
-
* @since 3.1.8
|
38 |
-
* @created: 23/06/12
|
39 |
-
*/
|
40 |
-
|
41 |
-
function admin_menu()
|
42 |
-
{
|
43 |
-
// dont run on plugin activate!
|
44 |
-
if( isset($_GET['action']) && $_GET['action'] == 'activate-plugin' )
|
45 |
-
{
|
46 |
-
return;
|
47 |
-
}
|
48 |
-
|
49 |
-
|
50 |
-
// vars
|
51 |
-
$plugin_version = apply_filters('acf/get_info', 'version');
|
52 |
-
$acf_version = get_option('acf_version');
|
53 |
-
|
54 |
-
|
55 |
-
// bail early if a new install
|
56 |
-
if( empty($acf_version) ) {
|
57 |
-
|
58 |
-
update_option('acf_version', $plugin_version );
|
59 |
-
return;
|
60 |
-
|
61 |
-
}
|
62 |
-
|
63 |
-
|
64 |
-
// bail early if $acf_version is >= $plugin_version
|
65 |
-
if( version_compare( $acf_version, $plugin_version, '>=') ) {
|
66 |
-
|
67 |
-
return;
|
68 |
-
|
69 |
-
}
|
70 |
-
|
71 |
-
|
72 |
-
// update version
|
73 |
-
update_option('acf_version', $plugin_version );
|
74 |
-
|
75 |
-
|
76 |
-
// update admin page
|
77 |
-
add_submenu_page('edit.php?post_type=acf', __('Upgrade','acf'), __('Upgrade','acf'), 'manage_options','acf-upgrade', array($this,'html') );
|
78 |
-
}
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
/*
|
83 |
-
* html
|
84 |
-
*
|
85 |
-
* @description:
|
86 |
-
* @since 3.1.8
|
87 |
-
* @created: 23/06/12
|
88 |
-
*/
|
89 |
-
|
90 |
-
function html()
|
91 |
-
{
|
92 |
-
$version = get_option('acf_version','1.0.5');
|
93 |
-
$next = false;
|
94 |
-
|
95 |
-
// list of starting points
|
96 |
-
if( $version < '3.0.0' )
|
97 |
-
{
|
98 |
-
$next = '3.0.0';
|
99 |
-
}
|
100 |
-
elseif( $version < '3.1.8' )
|
101 |
-
{
|
102 |
-
$next = '3.1.8';
|
103 |
-
}
|
104 |
-
elseif( $version < '3.2.5' )
|
105 |
-
{
|
106 |
-
$next = '3.2.5';
|
107 |
-
}
|
108 |
-
elseif( $version < '3.3.3' )
|
109 |
-
{
|
110 |
-
$next = '3.3.3';
|
111 |
-
}
|
112 |
-
elseif( $version < '3.4.1' )
|
113 |
-
{
|
114 |
-
$next = '3.4.1';
|
115 |
-
}
|
116 |
-
|
117 |
-
?>
|
118 |
-
<script type="text/javascript">
|
119 |
-
(function($){
|
120 |
-
|
121 |
-
function add_message(messaage)
|
122 |
-
{
|
123 |
-
$('#wpbody-content').append('<p>' + messaage + '</p>');
|
124 |
-
}
|
125 |
-
|
126 |
-
function run_upgrade(version)
|
127 |
-
{
|
128 |
-
$.ajax({
|
129 |
-
url: ajaxurl,
|
130 |
-
data: {
|
131 |
-
action : 'acf_upgrade',
|
132 |
-
version : version
|
133 |
-
},
|
134 |
-
type: 'post',
|
135 |
-
dataType: 'json',
|
136 |
-
success: function(json){
|
137 |
-
|
138 |
-
if(json)
|
139 |
-
{
|
140 |
-
if(json.status)
|
141 |
-
{
|
142 |
-
add_message(json.message);
|
143 |
-
|
144 |
-
// next update?
|
145 |
-
if(json.next)
|
146 |
-
{
|
147 |
-
run_upgrade(json.next);
|
148 |
-
}
|
149 |
-
else
|
150 |
-
{
|
151 |
-
// all done
|
152 |
-
add_message('Upgrade Complete! <a href="<?php echo admin_url(); ?>edit.php?post_type=acf">Continue to ACF »</a>');
|
153 |
-
}
|
154 |
-
}
|
155 |
-
else
|
156 |
-
{
|
157 |
-
// error!
|
158 |
-
add_message('Error: ' + json.message);
|
159 |
-
}
|
160 |
-
}
|
161 |
-
else
|
162 |
-
{
|
163 |
-
// major error!
|
164 |
-
add_message('Sorry. Something went wrong during the upgrade process. Please report this on the support forum');
|
165 |
-
}
|
166 |
-
}
|
167 |
-
});
|
168 |
-
}
|
169 |
-
|
170 |
-
<?php if($next){ echo 'run_upgrade("' . $next . '");'; } ?>
|
171 |
-
|
172 |
-
})(jQuery);
|
173 |
-
</script>
|
174 |
-
<style type="text/css">
|
175 |
-
#message {
|
176 |
-
display: none;
|
177 |
-
}
|
178 |
-
</style>
|
179 |
-
<?php
|
180 |
-
|
181 |
-
if(!$next)
|
182 |
-
{
|
183 |
-
echo '<p>No Upgrade Required</p>';
|
184 |
-
}
|
185 |
-
}
|
186 |
-
|
187 |
-
|
188 |
-
/*
|
189 |
-
* upgrade_ajax
|
190 |
-
*
|
191 |
-
* @description:
|
192 |
-
* @since 3.1.8
|
193 |
-
* @created: 23/06/12
|
194 |
-
*/
|
195 |
-
|
196 |
-
function upgrade_ajax()
|
197 |
-
{
|
198 |
-
// global
|
199 |
-
global $wpdb;
|
200 |
-
|
201 |
-
|
202 |
-
// tables
|
203 |
-
$acf_fields = $wpdb->prefix.'acf_fields';
|
204 |
-
$acf_values = $wpdb->prefix.'acf_values';
|
205 |
-
$acf_rules = $wpdb->prefix.'acf_rules';
|
206 |
-
$wp_postmeta = $wpdb->prefix.'postmeta';
|
207 |
-
$wp_options = $wpdb->prefix.'options';
|
208 |
-
|
209 |
-
|
210 |
-
// vars
|
211 |
-
$return = array(
|
212 |
-
'status' => false,
|
213 |
-
'message' => "",
|
214 |
-
'next' => false,
|
215 |
-
);
|
216 |
-
|
217 |
-
|
218 |
-
// versions
|
219 |
-
switch($_POST['version'])
|
220 |
-
{
|
221 |
-
|
222 |
-
/*---------------------
|
223 |
-
*
|
224 |
-
* 3.0.0
|
225 |
-
*
|
226 |
-
*--------------------*/
|
227 |
-
|
228 |
-
case '3.0.0':
|
229 |
-
|
230 |
-
// upgrade options first as "field_group_layout" will cause get_fields to fail!
|
231 |
-
|
232 |
-
// get acf's
|
233 |
-
$acfs = get_posts(array(
|
234 |
-
'numberposts' => -1,
|
235 |
-
'post_type' => 'acf',
|
236 |
-
'orderby' => 'menu_order title',
|
237 |
-
'order' => 'asc',
|
238 |
-
'suppress_filters' => false,
|
239 |
-
));
|
240 |
-
|
241 |
-
if($acfs)
|
242 |
-
{
|
243 |
-
foreach($acfs as $acf)
|
244 |
-
{
|
245 |
-
// position
|
246 |
-
update_post_meta($acf->ID, 'position', 'normal');
|
247 |
-
|
248 |
-
//layout
|
249 |
-
$layout = get_post_meta($acf->ID, 'field_group_layout', true) ? get_post_meta($acf->ID, 'field_group_layout', true) : 'in_box';
|
250 |
-
if($layout == 'in_box')
|
251 |
-
{
|
252 |
-
$layout = 'default';
|
253 |
-
}
|
254 |
-
else
|
255 |
-
{
|
256 |
-
$layout = 'no_box';
|
257 |
-
}
|
258 |
-
update_post_meta($acf->ID, 'layout', $layout);
|
259 |
-
delete_post_meta($acf->ID, 'field_group_layout');
|
260 |
-
|
261 |
-
// show_on_page
|
262 |
-
$show_on_page = get_post_meta($acf->ID, 'show_on_page', true) ? get_post_meta($acf->ID, 'show_on_page', true) : array();
|
263 |
-
if($show_on_page)
|
264 |
-
{
|
265 |
-
$show_on_page = unserialize($show_on_page);
|
266 |
-
}
|
267 |
-
update_post_meta($acf->ID, 'show_on_page', $show_on_page);
|
268 |
-
|
269 |
-
}
|
270 |
-
}
|
271 |
-
|
272 |
-
$return = array(
|
273 |
-
'status' => true,
|
274 |
-
'message' => "Migrating Options...",
|
275 |
-
'next' => '3.0.0 (step 2)',
|
276 |
-
);
|
277 |
-
|
278 |
-
break;
|
279 |
-
|
280 |
-
/*---------------------
|
281 |
-
*
|
282 |
-
* 3.0.0
|
283 |
-
*
|
284 |
-
*--------------------*/
|
285 |
-
|
286 |
-
case '3.0.0 (step 2)':
|
287 |
-
|
288 |
-
// get acf's
|
289 |
-
$acfs = get_posts(array(
|
290 |
-
'numberposts' => -1,
|
291 |
-
'post_type' => 'acf',
|
292 |
-
'orderby' => 'menu_order title',
|
293 |
-
'order' => 'asc',
|
294 |
-
'suppress_filters' => false,
|
295 |
-
));
|
296 |
-
|
297 |
-
if($acfs)
|
298 |
-
{
|
299 |
-
foreach($acfs as $acf)
|
300 |
-
{
|
301 |
-
// allorany doesn't need to change!
|
302 |
-
|
303 |
-
$rules = $wpdb->get_results("SELECT * FROM $acf_rules WHERE acf_id = '$acf->ID' ORDER BY order_no ASC", ARRAY_A);
|
304 |
-
|
305 |
-
if($rules)
|
306 |
-
{
|
307 |
-
foreach($rules as $rule)
|
308 |
-
{
|
309 |
-
// options rule has changed
|
310 |
-
if($rule['param'] == 'options_page')
|
311 |
-
{
|
312 |
-
$rule['value'] = 'Options';
|
313 |
-
}
|
314 |
-
|
315 |
-
add_post_meta($acf->ID, 'rule', $rule);
|
316 |
-
}
|
317 |
-
}
|
318 |
-
|
319 |
-
}
|
320 |
-
}
|
321 |
-
|
322 |
-
$return = array(
|
323 |
-
'status' => true,
|
324 |
-
'message' => "Migrating Location Rules...",
|
325 |
-
'next' => '3.0.0 (step 3)',
|
326 |
-
);
|
327 |
-
|
328 |
-
break;
|
329 |
-
|
330 |
-
/*---------------------
|
331 |
-
*
|
332 |
-
* 3.0.0
|
333 |
-
*
|
334 |
-
*--------------------*/
|
335 |
-
|
336 |
-
case '3.0.0 (step 3)':
|
337 |
-
|
338 |
-
$message = "Migrating Fields?";
|
339 |
-
|
340 |
-
$parent_id = 0;
|
341 |
-
$fields = $wpdb->get_results("SELECT * FROM $acf_fields WHERE parent_id = $parent_id ORDER BY order_no, name", ARRAY_A);
|
342 |
-
|
343 |
-
if($fields)
|
344 |
-
{
|
345 |
-
// loop through fields
|
346 |
-
foreach($fields as $field)
|
347 |
-
{
|
348 |
-
|
349 |
-
// unserialize options
|
350 |
-
if(@unserialize($field['options']))
|
351 |
-
{
|
352 |
-
$field['options'] = unserialize($field['options']);
|
353 |
-
}
|
354 |
-
else
|
355 |
-
{
|
356 |
-
$field['options'] = array();
|
357 |
-
}
|
358 |
-
|
359 |
-
|
360 |
-
// sub fields
|
361 |
-
if($field['type'] == 'repeater')
|
362 |
-
{
|
363 |
-
$field['options']['sub_fields'] = array();
|
364 |
-
|
365 |
-
$parent_id = $field['id'];
|
366 |
-
$sub_fields = $wpdb->get_results("SELECT * FROM $acf_fields WHERE parent_id = $parent_id ORDER BY order_no, name", ARRAY_A);
|
367 |
-
|
368 |
-
|
369 |
-
// if fields are empty, this must be a new or broken acf.
|
370 |
-
if(empty($sub_fields))
|
371 |
-
{
|
372 |
-
$field['options']['sub_fields'] = array();
|
373 |
-
}
|
374 |
-
else
|
375 |
-
{
|
376 |
-
// loop through fields
|
377 |
-
foreach($sub_fields as $sub_field)
|
378 |
-
{
|
379 |
-
// unserialize options
|
380 |
-
if(@unserialize($sub_field['options']))
|
381 |
-
{
|
382 |
-
$sub_field['options'] = @unserialize($sub_field['options']);
|
383 |
-
}
|
384 |
-
else
|
385 |
-
{
|
386 |
-
$sub_field['options'] = array();
|
387 |
-
}
|
388 |
-
|
389 |
-
// merge options with field
|
390 |
-
$sub_field = array_merge($sub_field, $sub_field['options']);
|
391 |
-
|
392 |
-
unset($sub_field['options']);
|
393 |
-
|
394 |
-
// each field has a unique id!
|
395 |
-
if(!isset($sub_field['key'])) $sub_field['key'] = 'field_' . $sub_field['id'];
|
396 |
-
|
397 |
-
$field['options']['sub_fields'][] = $sub_field;
|
398 |
-
}
|
399 |
-
}
|
400 |
-
|
401 |
-
}
|
402 |
-
// end if sub field
|
403 |
-
|
404 |
-
|
405 |
-
// merge options with field
|
406 |
-
$field = array_merge($field, $field['options']);
|
407 |
-
|
408 |
-
unset($field['options']);
|
409 |
-
|
410 |
-
// each field has a unique id!
|
411 |
-
if(!isset($field['key'])) $field['key'] = 'field_' . $field['id'];
|
412 |
-
|
413 |
-
// update field
|
414 |
-
$this->parent->update_field( $field['post_id'], $field);
|
415 |
-
|
416 |
-
// create field name (field_rand)
|
417 |
-
//$message .= print_r($field, true) . '<br /><br />';
|
418 |
-
}
|
419 |
-
// end foreach $fields
|
420 |
-
}
|
421 |
-
|
422 |
-
|
423 |
-
$return = array(
|
424 |
-
'status' => true,
|
425 |
-
'message' => $message,
|
426 |
-
'next' => '3.0.0 (step 4)',
|
427 |
-
);
|
428 |
-
|
429 |
-
break;
|
430 |
-
|
431 |
-
/*---------------------
|
432 |
-
*
|
433 |
-
* 3.0.0
|
434 |
-
*
|
435 |
-
*--------------------*/
|
436 |
-
|
437 |
-
case '3.0.0 (step 4)':
|
438 |
-
|
439 |
-
$message = "Migrating Values...";
|
440 |
-
|
441 |
-
// update normal values
|
442 |
-
$values = $wpdb->get_results("SELECT v.field_id, m.post_id, m.meta_key, m.meta_value FROM $acf_values v LEFT JOIN $wp_postmeta m ON v.value = m.meta_id WHERE v.sub_field_id = 0", ARRAY_A);
|
443 |
-
if($values)
|
444 |
-
{
|
445 |
-
foreach($values as $value)
|
446 |
-
{
|
447 |
-
// options page
|
448 |
-
if($value['post_id'] == 0) $value['post_id'] = 999999999;
|
449 |
-
|
450 |
-
// unserialize value (relationship, multi select, etc)
|
451 |
-
if(@unserialize($value['meta_value']))
|
452 |
-
{
|
453 |
-
$value['meta_value'] = unserialize($value['meta_value']);
|
454 |
-
}
|
455 |
-
|
456 |
-
update_post_meta($value['post_id'], $value['meta_key'], $value['meta_value']);
|
457 |
-
update_post_meta($value['post_id'], '_' . $value['meta_key'], 'field_' . $value['field_id']);
|
458 |
-
}
|
459 |
-
}
|
460 |
-
|
461 |
-
// update repeater values
|
462 |
-
$values = $wpdb->get_results("SELECT v.field_id, v.sub_field_id, v.order_no, m.post_id, m.meta_key, m.meta_value FROM $acf_values v LEFT JOIN $wp_postmeta m ON v.value = m.meta_id WHERE v.sub_field_id != 0", ARRAY_A);
|
463 |
-
if($values)
|
464 |
-
{
|
465 |
-
$rows = array();
|
466 |
-
|
467 |
-
foreach($values as $value)
|
468 |
-
{
|
469 |
-
// update row count
|
470 |
-
$row = (int) $value['order_no'] + 1;
|
471 |
-
|
472 |
-
// options page
|
473 |
-
if($value['post_id'] == 0) $value['post_id'] = 999999999;
|
474 |
-
|
475 |
-
// unserialize value (relationship, multi select, etc)
|
476 |
-
if(@unserialize($value['meta_value']))
|
477 |
-
{
|
478 |
-
$value['meta_value'] = unserialize($value['meta_value']);
|
479 |
-
}
|
480 |
-
|
481 |
-
// current row
|
482 |
-
$current_row = isset($rows[$value['post_id']][$value['field_id']]) ? $rows[$value['post_id']][$value['field_id']] : 0;
|
483 |
-
if($row > $current_row) $rows[$value['post_id']][$value['field_id']] = (int) $row;
|
484 |
-
|
485 |
-
// get field name
|
486 |
-
$field_name = $wpdb->get_var($wpdb->prepare("SELECT name FROM $acf_fields WHERE id = %d", $value['field_id']));
|
487 |
-
|
488 |
-
// get sub field name
|
489 |
-
$sub_field_name = $wpdb->get_var($wpdb->prepare("SELECT name FROM $acf_fields WHERE id = %d", $value['sub_field_id']));
|
490 |
-
|
491 |
-
// save new value
|
492 |
-
$new_meta_key = $field_name . '_' . $value['order_no'] . '_' . $sub_field_name;
|
493 |
-
update_post_meta($value['post_id'], $new_meta_key , $value['meta_value']);
|
494 |
-
|
495 |
-
// save value hidden field id
|
496 |
-
update_post_meta($value['post_id'], '_' . $new_meta_key, 'field_' . $value['sub_field_id']);
|
497 |
-
}
|
498 |
-
|
499 |
-
foreach($rows as $post_id => $field_ids)
|
500 |
-
{
|
501 |
-
foreach($field_ids as $field_id => $row_count)
|
502 |
-
{
|
503 |
-
// get sub field name
|
504 |
-
$field_name = $wpdb->get_var($wpdb->prepare("SELECT name FROM $acf_fields WHERE id = %d", $field_id));
|
505 |
-
|
506 |
-
delete_post_meta($post_id, $field_name);
|
507 |
-
update_post_meta($post_id, $field_name, $row_count);
|
508 |
-
update_post_meta($post_id, '_' . $field_name, 'field_' . $field_id);
|
509 |
-
|
510 |
-
}
|
511 |
-
}
|
512 |
-
|
513 |
-
}
|
514 |
-
|
515 |
-
// update version (only upgrade 1 time)
|
516 |
-
update_option('acf_version','3.0.0');
|
517 |
-
|
518 |
-
$return = array(
|
519 |
-
'status' => true,
|
520 |
-
'message' => $message,
|
521 |
-
'next' => '3.1.8',
|
522 |
-
);
|
523 |
-
|
524 |
-
break;
|
525 |
-
|
526 |
-
|
527 |
-
/*---------------------
|
528 |
-
*
|
529 |
-
* 3.1.8
|
530 |
-
*
|
531 |
-
*--------------------*/
|
532 |
-
|
533 |
-
case '3.1.8':
|
534 |
-
|
535 |
-
// vars
|
536 |
-
$message = __("Migrating options values from the $wp_postmeta table to the $wp_options table",'acf') . '...';
|
537 |
-
|
538 |
-
// update normal values
|
539 |
-
$rows = $wpdb->get_results( $wpdb->prepare("SELECT meta_key FROM $wp_postmeta WHERE post_id = %d", 999999999) , ARRAY_A);
|
540 |
-
|
541 |
-
if($rows)
|
542 |
-
{
|
543 |
-
foreach($rows as $row)
|
544 |
-
{
|
545 |
-
// original name
|
546 |
-
$field_name = $row['meta_key'];
|
547 |
-
|
548 |
-
|
549 |
-
// name
|
550 |
-
$new_name = "";
|
551 |
-
if( substr($field_name, 0, 1) == "_" )
|
552 |
-
{
|
553 |
-
$new_name = '_options' . $field_name;
|
554 |
-
}
|
555 |
-
else
|
556 |
-
{
|
557 |
-
$new_name = 'options_' . $field_name;
|
558 |
-
}
|
559 |
-
|
560 |
-
|
561 |
-
// value
|
562 |
-
$value = get_post_meta( 999999999, $field_name, true );
|
563 |
-
|
564 |
-
|
565 |
-
// update option
|
566 |
-
update_option( $new_name, $value );
|
567 |
-
|
568 |
-
|
569 |
-
// deleet old postmeta
|
570 |
-
delete_post_meta( 999999999, $field_name );
|
571 |
-
|
572 |
-
}
|
573 |
-
// foreach($values as $value)
|
574 |
-
}
|
575 |
-
// if($values)
|
576 |
-
|
577 |
-
|
578 |
-
// update version
|
579 |
-
update_option('acf_version','3.1.8');
|
580 |
-
|
581 |
-
$return = array(
|
582 |
-
'status' => true,
|
583 |
-
'message' => $message,
|
584 |
-
'next' => '3.2.5',
|
585 |
-
);
|
586 |
-
|
587 |
-
break;
|
588 |
-
|
589 |
-
|
590 |
-
/*---------------------
|
591 |
-
*
|
592 |
-
* 3.1.8
|
593 |
-
*
|
594 |
-
*--------------------*/
|
595 |
-
|
596 |
-
case '3.2.5':
|
597 |
-
|
598 |
-
// vars
|
599 |
-
$message = __("Modifying field group options 'show on page'",'acf') . '...';
|
600 |
-
|
601 |
-
|
602 |
-
// get acf's
|
603 |
-
$acfs = get_posts(array(
|
604 |
-
'numberposts' => -1,
|
605 |
-
'post_type' => 'acf',
|
606 |
-
'orderby' => 'menu_order title',
|
607 |
-
'order' => 'asc',
|
608 |
-
'suppress_filters' => false,
|
609 |
-
));
|
610 |
-
|
611 |
-
|
612 |
-
$show_all = array('the_content', 'discussion', 'custom_fields', 'comments', 'slug', 'author');
|
613 |
-
|
614 |
-
|
615 |
-
// populate acfs
|
616 |
-
if($acfs)
|
617 |
-
{
|
618 |
-
foreach($acfs as $acf)
|
619 |
-
{
|
620 |
-
$show_on_page = get_post_meta($acf->ID, 'show_on_page', true) ? get_post_meta($acf->ID, 'show_on_page', true) : array();
|
621 |
-
|
622 |
-
$hide_on_screen = array_diff($show_all, $show_on_page);
|
623 |
-
|
624 |
-
update_post_meta($acf->ID, 'hide_on_screen', $hide_on_screen);
|
625 |
-
delete_post_meta($acf->ID, 'show_on_page');
|
626 |
-
|
627 |
-
}
|
628 |
-
}
|
629 |
-
|
630 |
-
|
631 |
-
// update version
|
632 |
-
update_option('acf_version','3.2.5');
|
633 |
-
|
634 |
-
$return = array(
|
635 |
-
'status' => true,
|
636 |
-
'message' => $message,
|
637 |
-
'next' => '3.3.3',
|
638 |
-
);
|
639 |
-
|
640 |
-
break;
|
641 |
-
|
642 |
-
|
643 |
-
/*
|
644 |
-
* 3.3.3
|
645 |
-
*
|
646 |
-
* @description: changed field option: taxonomies filter on relationship / post object and page link fields.
|
647 |
-
* @created: 20/07/12
|
648 |
-
*/
|
649 |
-
|
650 |
-
case '3.3.3':
|
651 |
-
|
652 |
-
// vars
|
653 |
-
$message = __("Modifying field option 'taxonomy'",'acf') . '...';
|
654 |
-
$wp_term_taxonomy = $wpdb->prefix.'term_taxonomy';
|
655 |
-
$term_taxonomies = array();
|
656 |
-
|
657 |
-
$rows = $wpdb->get_results("SELECT * FROM $wp_term_taxonomy", ARRAY_A);
|
658 |
-
|
659 |
-
if($rows)
|
660 |
-
{
|
661 |
-
foreach($rows as $row)
|
662 |
-
{
|
663 |
-
$term_taxonomies[ $row['term_id'] ] = $row['taxonomy'] . ":" . $row['term_id'];
|
664 |
-
}
|
665 |
-
}
|
666 |
-
|
667 |
-
|
668 |
-
// get acf's
|
669 |
-
$acfs = get_posts(array(
|
670 |
-
'numberposts' => -1,
|
671 |
-
'post_type' => 'acf',
|
672 |
-
'orderby' => 'menu_order title',
|
673 |
-
'order' => 'asc',
|
674 |
-
'suppress_filters' => false,
|
675 |
-
));
|
676 |
-
|
677 |
-
// populate acfs
|
678 |
-
if($acfs)
|
679 |
-
{
|
680 |
-
foreach($acfs as $acf)
|
681 |
-
{
|
682 |
-
$fields = $this->parent->get_acf_fields($acf->ID);
|
683 |
-
|
684 |
-
if( $fields )
|
685 |
-
{
|
686 |
-
foreach( $fields as $field )
|
687 |
-
{
|
688 |
-
|
689 |
-
// only edit the option: taxonomy
|
690 |
-
if( !isset($field['taxonomy']) )
|
691 |
-
{
|
692 |
-
continue;
|
693 |
-
}
|
694 |
-
|
695 |
-
|
696 |
-
if( is_array($field['taxonomy']) )
|
697 |
-
{
|
698 |
-
foreach( $field['taxonomy'] as $k => $v )
|
699 |
-
{
|
700 |
-
|
701 |
-
// could be "all"
|
702 |
-
if( !is_numeric($v) )
|
703 |
-
{
|
704 |
-
continue;
|
705 |
-
}
|
706 |
-
|
707 |
-
$field['taxonomy'][ $k ] = $term_taxonomies[ $v ];
|
708 |
-
|
709 |
-
|
710 |
-
}
|
711 |
-
// foreach( $field['taxonomy'] as $k => $v )
|
712 |
-
}
|
713 |
-
// if( $field['taxonomy'] )
|
714 |
-
|
715 |
-
|
716 |
-
$this->parent->update_field( $acf->ID, $field);
|
717 |
-
|
718 |
-
}
|
719 |
-
// foreach( $fields as $field )
|
720 |
-
}
|
721 |
-
// if( $fields )
|
722 |
-
}
|
723 |
-
// foreach($acfs as $acf)
|
724 |
-
}
|
725 |
-
// if($acfs)
|
726 |
-
|
727 |
-
|
728 |
-
// update version
|
729 |
-
update_option('acf_version','3.3.3');
|
730 |
-
|
731 |
-
$return = array(
|
732 |
-
'status' => true,
|
733 |
-
'message' => $message,
|
734 |
-
'next' => '3.4.1',
|
735 |
-
);
|
736 |
-
|
737 |
-
break;
|
738 |
-
|
739 |
-
|
740 |
-
/*
|
741 |
-
* 3.4.1
|
742 |
-
*
|
743 |
-
* @description: Move user custom fields from wp_options to wp_usermeta
|
744 |
-
* @created: 20/07/12
|
745 |
-
*/
|
746 |
-
|
747 |
-
case '3.4.1':
|
748 |
-
|
749 |
-
// vars
|
750 |
-
$message = __("Moving user custom fields from wp_options to wp_usermeta",'acf') . '...';
|
751 |
-
|
752 |
-
$option_row_ids = array();
|
753 |
-
$option_rows = $wpdb->get_results("SELECT option_id, option_name, option_value FROM $wpdb->options WHERE option_name LIKE 'user%' OR option_name LIKE '\_user%'", ARRAY_A);
|
754 |
-
|
755 |
-
|
756 |
-
if( $option_rows )
|
757 |
-
{
|
758 |
-
foreach( $option_rows as $k => $row)
|
759 |
-
{
|
760 |
-
preg_match('/user_([0-9]+)_(.*)/', $row['option_name'], $matches);
|
761 |
-
|
762 |
-
|
763 |
-
// if no matches, this is not an acf value, ignore it
|
764 |
-
if( !$matches )
|
765 |
-
{
|
766 |
-
continue;
|
767 |
-
}
|
768 |
-
|
769 |
-
|
770 |
-
// add to $delete_option_rows
|
771 |
-
$option_row_ids[] = $row['option_id'];
|
772 |
-
|
773 |
-
|
774 |
-
// meta_key prefix
|
775 |
-
$meta_key_prefix = "";
|
776 |
-
if( substr($row['option_name'], 0, 1) == "_" )
|
777 |
-
{
|
778 |
-
$meta_key_prefix = '_';
|
779 |
-
}
|
780 |
-
|
781 |
-
|
782 |
-
// update user meta
|
783 |
-
update_user_meta( $matches[1], $meta_key_prefix . $matches[2], $row['option_value'] );
|
784 |
-
|
785 |
-
}
|
786 |
-
}
|
787 |
-
|
788 |
-
|
789 |
-
// clear up some memory ( aprox 14 kb )
|
790 |
-
unset( $option_rows );
|
791 |
-
|
792 |
-
|
793 |
-
// remove $option_row_ids
|
794 |
-
if( $option_row_ids )
|
795 |
-
{
|
796 |
-
$option_row_ids = implode(', ', $option_row_ids);
|
797 |
-
|
798 |
-
$wpdb->query("DELETE FROM $wpdb->options WHERE option_id IN ($option_row_ids)");
|
799 |
-
}
|
800 |
-
|
801 |
-
|
802 |
-
// update version
|
803 |
-
update_option('acf_version','3.4.1');
|
804 |
-
|
805 |
-
$return = array(
|
806 |
-
'status' => true,
|
807 |
-
'message' => $message,
|
808 |
-
'next' => false,
|
809 |
-
);
|
810 |
-
|
811 |
-
break;
|
812 |
-
|
813 |
-
|
814 |
-
}
|
815 |
-
|
816 |
-
// return json
|
817 |
-
echo json_encode($return);
|
818 |
-
die;
|
819 |
-
|
820 |
-
}
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
}
|
826 |
-
|
827 |
-
new acf_upgrade();
|
828 |
-
|
829 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* Upgrade
|
5 |
+
*
|
6 |
+
* @description: All the functionality for upgrading ACF
|
7 |
+
* @since 3.2.6
|
8 |
+
* @created: 23/06/12
|
9 |
+
*/
|
10 |
+
|
11 |
+
class acf_upgrade
|
12 |
+
{
|
13 |
+
|
14 |
+
/*
|
15 |
+
* __construct
|
16 |
+
*
|
17 |
+
* @description:
|
18 |
+
* @since 3.1.8
|
19 |
+
* @created: 23/06/12
|
20 |
+
*/
|
21 |
+
|
22 |
+
function __construct()
|
23 |
+
{
|
24 |
+
// actions
|
25 |
+
add_action('admin_menu', array($this,'admin_menu'), 11);
|
26 |
+
|
27 |
+
|
28 |
+
// ajax
|
29 |
+
add_action('wp_ajax_acf_upgrade', array($this, 'upgrade_ajax'));
|
30 |
+
}
|
31 |
+
|
32 |
+
|
33 |
+
/*
|
34 |
+
* admin_menu
|
35 |
+
*
|
36 |
+
* @description:
|
37 |
+
* @since 3.1.8
|
38 |
+
* @created: 23/06/12
|
39 |
+
*/
|
40 |
+
|
41 |
+
function admin_menu()
|
42 |
+
{
|
43 |
+
// dont run on plugin activate!
|
44 |
+
if( isset($_GET['action']) && $_GET['action'] == 'activate-plugin' )
|
45 |
+
{
|
46 |
+
return;
|
47 |
+
}
|
48 |
+
|
49 |
+
|
50 |
+
// vars
|
51 |
+
$plugin_version = apply_filters('acf/get_info', 'version');
|
52 |
+
$acf_version = get_option('acf_version');
|
53 |
+
|
54 |
+
|
55 |
+
// bail early if a new install
|
56 |
+
if( empty($acf_version) ) {
|
57 |
+
|
58 |
+
update_option('acf_version', $plugin_version );
|
59 |
+
return;
|
60 |
+
|
61 |
+
}
|
62 |
+
|
63 |
+
|
64 |
+
// bail early if $acf_version is >= $plugin_version
|
65 |
+
if( version_compare( $acf_version, $plugin_version, '>=') ) {
|
66 |
+
|
67 |
+
return;
|
68 |
+
|
69 |
+
}
|
70 |
+
|
71 |
+
|
72 |
+
// update version
|
73 |
+
update_option('acf_version', $plugin_version );
|
74 |
+
|
75 |
+
|
76 |
+
// update admin page
|
77 |
+
add_submenu_page('edit.php?post_type=acf', __('Upgrade','acf'), __('Upgrade','acf'), 'manage_options','acf-upgrade', array($this,'html') );
|
78 |
+
}
|
79 |
+
|
80 |
+
|
81 |
+
|
82 |
+
/*
|
83 |
+
* html
|
84 |
+
*
|
85 |
+
* @description:
|
86 |
+
* @since 3.1.8
|
87 |
+
* @created: 23/06/12
|
88 |
+
*/
|
89 |
+
|
90 |
+
function html()
|
91 |
+
{
|
92 |
+
$version = get_option('acf_version','1.0.5');
|
93 |
+
$next = false;
|
94 |
+
|
95 |
+
// list of starting points
|
96 |
+
if( $version < '3.0.0' )
|
97 |
+
{
|
98 |
+
$next = '3.0.0';
|
99 |
+
}
|
100 |
+
elseif( $version < '3.1.8' )
|
101 |
+
{
|
102 |
+
$next = '3.1.8';
|
103 |
+
}
|
104 |
+
elseif( $version < '3.2.5' )
|
105 |
+
{
|
106 |
+
$next = '3.2.5';
|
107 |
+
}
|
108 |
+
elseif( $version < '3.3.3' )
|
109 |
+
{
|
110 |
+
$next = '3.3.3';
|
111 |
+
}
|
112 |
+
elseif( $version < '3.4.1' )
|
113 |
+
{
|
114 |
+
$next = '3.4.1';
|
115 |
+
}
|
116 |
+
|
117 |
+
?>
|
118 |
+
<script type="text/javascript">
|
119 |
+
(function($){
|
120 |
+
|
121 |
+
function add_message(messaage)
|
122 |
+
{
|
123 |
+
$('#wpbody-content').append('<p>' + messaage + '</p>');
|
124 |
+
}
|
125 |
+
|
126 |
+
function run_upgrade(version)
|
127 |
+
{
|
128 |
+
$.ajax({
|
129 |
+
url: ajaxurl,
|
130 |
+
data: {
|
131 |
+
action : 'acf_upgrade',
|
132 |
+
version : version
|
133 |
+
},
|
134 |
+
type: 'post',
|
135 |
+
dataType: 'json',
|
136 |
+
success: function(json){
|
137 |
+
|
138 |
+
if(json)
|
139 |
+
{
|
140 |
+
if(json.status)
|
141 |
+
{
|
142 |
+
add_message(json.message);
|
143 |
+
|
144 |
+
// next update?
|
145 |
+
if(json.next)
|
146 |
+
{
|
147 |
+
run_upgrade(json.next);
|
148 |
+
}
|
149 |
+
else
|
150 |
+
{
|
151 |
+
// all done
|
152 |
+
add_message('Upgrade Complete! <a href="<?php echo admin_url(); ?>edit.php?post_type=acf">Continue to ACF »</a>');
|
153 |
+
}
|
154 |
+
}
|
155 |
+
else
|
156 |
+
{
|
157 |
+
// error!
|
158 |
+
add_message('Error: ' + json.message);
|
159 |
+
}
|
160 |
+
}
|
161 |
+
else
|
162 |
+
{
|
163 |
+
// major error!
|
164 |
+
add_message('Sorry. Something went wrong during the upgrade process. Please report this on the support forum');
|
165 |
+
}
|
166 |
+
}
|
167 |
+
});
|
168 |
+
}
|
169 |
+
|
170 |
+
<?php if($next){ echo 'run_upgrade("' . $next . '");'; } ?>
|
171 |
+
|
172 |
+
})(jQuery);
|
173 |
+
</script>
|
174 |
+
<style type="text/css">
|
175 |
+
#message {
|
176 |
+
display: none;
|
177 |
+
}
|
178 |
+
</style>
|
179 |
+
<?php
|
180 |
+
|
181 |
+
if(!$next)
|
182 |
+
{
|
183 |
+
echo '<p>No Upgrade Required</p>';
|
184 |
+
}
|
185 |
+
}
|
186 |
+
|
187 |
+
|
188 |
+
/*
|
189 |
+
* upgrade_ajax
|
190 |
+
*
|
191 |
+
* @description:
|
192 |
+
* @since 3.1.8
|
193 |
+
* @created: 23/06/12
|
194 |
+
*/
|
195 |
+
|
196 |
+
function upgrade_ajax()
|
197 |
+
{
|
198 |
+
// global
|
199 |
+
global $wpdb;
|
200 |
+
|
201 |
+
|
202 |
+
// tables
|
203 |
+
$acf_fields = $wpdb->prefix.'acf_fields';
|
204 |
+
$acf_values = $wpdb->prefix.'acf_values';
|
205 |
+
$acf_rules = $wpdb->prefix.'acf_rules';
|
206 |
+
$wp_postmeta = $wpdb->prefix.'postmeta';
|
207 |
+
$wp_options = $wpdb->prefix.'options';
|
208 |
+
|
209 |
+
|
210 |
+
// vars
|
211 |
+
$return = array(
|
212 |
+
'status' => false,
|
213 |
+
'message' => "",
|
214 |
+
'next' => false,
|
215 |
+
);
|
216 |
+
|
217 |
+
|
218 |
+
// versions
|
219 |
+
switch($_POST['version'])
|
220 |
+
{
|
221 |
+
|
222 |
+
/*---------------------
|
223 |
+
*
|
224 |
+
* 3.0.0
|
225 |
+
*
|
226 |
+
*--------------------*/
|
227 |
+
|
228 |
+
case '3.0.0':
|
229 |
+
|
230 |
+
// upgrade options first as "field_group_layout" will cause get_fields to fail!
|
231 |
+
|
232 |
+
// get acf's
|
233 |
+
$acfs = get_posts(array(
|
234 |
+
'numberposts' => -1,
|
235 |
+
'post_type' => 'acf',
|
236 |
+
'orderby' => 'menu_order title',
|
237 |
+
'order' => 'asc',
|
238 |
+
'suppress_filters' => false,
|
239 |
+
));
|
240 |
+
|
241 |
+
if($acfs)
|
242 |
+
{
|
243 |
+
foreach($acfs as $acf)
|
244 |
+
{
|
245 |
+
// position
|
246 |
+
update_post_meta($acf->ID, 'position', 'normal');
|
247 |
+
|
248 |
+
//layout
|
249 |
+
$layout = get_post_meta($acf->ID, 'field_group_layout', true) ? get_post_meta($acf->ID, 'field_group_layout', true) : 'in_box';
|
250 |
+
if($layout == 'in_box')
|
251 |
+
{
|
252 |
+
$layout = 'default';
|
253 |
+
}
|
254 |
+
else
|
255 |
+
{
|
256 |
+
$layout = 'no_box';
|
257 |
+
}
|
258 |
+
update_post_meta($acf->ID, 'layout', $layout);
|
259 |
+
delete_post_meta($acf->ID, 'field_group_layout');
|
260 |
+
|
261 |
+
// show_on_page
|
262 |
+
$show_on_page = get_post_meta($acf->ID, 'show_on_page', true) ? get_post_meta($acf->ID, 'show_on_page', true) : array();
|
263 |
+
if($show_on_page)
|
264 |
+
{
|
265 |
+
$show_on_page = unserialize($show_on_page);
|
266 |
+
}
|
267 |
+
update_post_meta($acf->ID, 'show_on_page', $show_on_page);
|
268 |
+
|
269 |
+
}
|
270 |
+
}
|
271 |
+
|
272 |
+
$return = array(
|
273 |
+
'status' => true,
|
274 |
+
'message' => "Migrating Options...",
|
275 |
+
'next' => '3.0.0 (step 2)',
|
276 |
+
);
|
277 |
+
|
278 |
+
break;
|
279 |
+
|
280 |
+
/*---------------------
|
281 |
+
*
|
282 |
+
* 3.0.0
|
283 |
+
*
|
284 |
+
*--------------------*/
|
285 |
+
|
286 |
+
case '3.0.0 (step 2)':
|
287 |
+
|
288 |
+
// get acf's
|
289 |
+
$acfs = get_posts(array(
|
290 |
+
'numberposts' => -1,
|
291 |
+
'post_type' => 'acf',
|
292 |
+
'orderby' => 'menu_order title',
|
293 |
+
'order' => 'asc',
|
294 |
+
'suppress_filters' => false,
|
295 |
+
));
|
296 |
+
|
297 |
+
if($acfs)
|
298 |
+
{
|
299 |
+
foreach($acfs as $acf)
|
300 |
+
{
|
301 |
+
// allorany doesn't need to change!
|
302 |
+
|
303 |
+
$rules = $wpdb->get_results("SELECT * FROM $acf_rules WHERE acf_id = '$acf->ID' ORDER BY order_no ASC", ARRAY_A);
|
304 |
+
|
305 |
+
if($rules)
|
306 |
+
{
|
307 |
+
foreach($rules as $rule)
|
308 |
+
{
|
309 |
+
// options rule has changed
|
310 |
+
if($rule['param'] == 'options_page')
|
311 |
+
{
|
312 |
+
$rule['value'] = 'Options';
|
313 |
+
}
|
314 |
+
|
315 |
+
add_post_meta($acf->ID, 'rule', $rule);
|
316 |
+
}
|
317 |
+
}
|
318 |
+
|
319 |
+
}
|
320 |
+
}
|
321 |
+
|
322 |
+
$return = array(
|
323 |
+
'status' => true,
|
324 |
+
'message' => "Migrating Location Rules...",
|
325 |
+
'next' => '3.0.0 (step 3)',
|
326 |
+
);
|
327 |
+
|
328 |
+
break;
|
329 |
+
|
330 |
+
/*---------------------
|
331 |
+
*
|
332 |
+
* 3.0.0
|
333 |
+
*
|
334 |
+
*--------------------*/
|
335 |
+
|
336 |
+
case '3.0.0 (step 3)':
|
337 |
+
|
338 |
+
$message = "Migrating Fields?";
|
339 |
+
|
340 |
+
$parent_id = 0;
|
341 |
+
$fields = $wpdb->get_results("SELECT * FROM $acf_fields WHERE parent_id = $parent_id ORDER BY order_no, name", ARRAY_A);
|
342 |
+
|
343 |
+
if($fields)
|
344 |
+
{
|
345 |
+
// loop through fields
|
346 |
+
foreach($fields as $field)
|
347 |
+
{
|
348 |
+
|
349 |
+
// unserialize options
|
350 |
+
if(@unserialize($field['options']))
|
351 |
+
{
|
352 |
+
$field['options'] = unserialize($field['options']);
|
353 |
+
}
|
354 |
+
else
|
355 |
+
{
|
356 |
+
$field['options'] = array();
|
357 |
+
}
|
358 |
+
|
359 |
+
|
360 |
+
// sub fields
|
361 |
+
if($field['type'] == 'repeater')
|
362 |
+
{
|
363 |
+
$field['options']['sub_fields'] = array();
|
364 |
+
|
365 |
+
$parent_id = $field['id'];
|
366 |
+
$sub_fields = $wpdb->get_results("SELECT * FROM $acf_fields WHERE parent_id = $parent_id ORDER BY order_no, name", ARRAY_A);
|
367 |
+
|
368 |
+
|
369 |
+
// if fields are empty, this must be a new or broken acf.
|
370 |
+
if(empty($sub_fields))
|
371 |
+
{
|
372 |
+
$field['options']['sub_fields'] = array();
|
373 |
+
}
|
374 |
+
else
|
375 |
+
{
|
376 |
+
// loop through fields
|
377 |
+
foreach($sub_fields as $sub_field)
|
378 |
+
{
|
379 |
+
// unserialize options
|
380 |
+
if(@unserialize($sub_field['options']))
|
381 |
+
{
|
382 |
+
$sub_field['options'] = @unserialize($sub_field['options']);
|
383 |
+
}
|
384 |
+
else
|
385 |
+
{
|
386 |
+
$sub_field['options'] = array();
|
387 |
+
}
|
388 |
+
|
389 |
+
// merge options with field
|
390 |
+
$sub_field = array_merge($sub_field, $sub_field['options']);
|
391 |
+
|
392 |
+
unset($sub_field['options']);
|
393 |
+
|
394 |
+
// each field has a unique id!
|
395 |
+
if(!isset($sub_field['key'])) $sub_field['key'] = 'field_' . $sub_field['id'];
|
396 |
+
|
397 |
+
$field['options']['sub_fields'][] = $sub_field;
|
398 |
+
}
|
399 |
+
}
|
400 |
+
|
401 |
+
}
|
402 |
+
// end if sub field
|
403 |
+
|
404 |
+
|
405 |
+
// merge options with field
|
406 |
+
$field = array_merge($field, $field['options']);
|
407 |
+
|
408 |
+
unset($field['options']);
|
409 |
+
|
410 |
+
// each field has a unique id!
|
411 |
+
if(!isset($field['key'])) $field['key'] = 'field_' . $field['id'];
|
412 |
+
|
413 |
+
// update field
|
414 |
+
$this->parent->update_field( $field['post_id'], $field);
|
415 |
+
|
416 |
+
// create field name (field_rand)
|
417 |
+
//$message .= print_r($field, true) . '<br /><br />';
|
418 |
+
}
|
419 |
+
// end foreach $fields
|
420 |
+
}
|
421 |
+
|
422 |
+
|
423 |
+
$return = array(
|
424 |
+
'status' => true,
|
425 |
+
'message' => $message,
|
426 |
+
'next' => '3.0.0 (step 4)',
|
427 |
+
);
|
428 |
+
|
429 |
+
break;
|
430 |
+
|
431 |
+
/*---------------------
|
432 |
+
*
|
433 |
+
* 3.0.0
|
434 |
+
*
|
435 |
+
*--------------------*/
|
436 |
+
|
437 |
+
case '3.0.0 (step 4)':
|
438 |
+
|
439 |
+
$message = "Migrating Values...";
|
440 |
+
|
441 |
+
// update normal values
|
442 |
+
$values = $wpdb->get_results("SELECT v.field_id, m.post_id, m.meta_key, m.meta_value FROM $acf_values v LEFT JOIN $wp_postmeta m ON v.value = m.meta_id WHERE v.sub_field_id = 0", ARRAY_A);
|
443 |
+
if($values)
|
444 |
+
{
|
445 |
+
foreach($values as $value)
|
446 |
+
{
|
447 |
+
// options page
|
448 |
+
if($value['post_id'] == 0) $value['post_id'] = 999999999;
|
449 |
+
|
450 |
+
// unserialize value (relationship, multi select, etc)
|
451 |
+
if(@unserialize($value['meta_value']))
|
452 |
+
{
|
453 |
+
$value['meta_value'] = unserialize($value['meta_value']);
|
454 |
+
}
|
455 |
+
|
456 |
+
update_post_meta($value['post_id'], $value['meta_key'], $value['meta_value']);
|
457 |
+
update_post_meta($value['post_id'], '_' . $value['meta_key'], 'field_' . $value['field_id']);
|
458 |
+
}
|
459 |
+
}
|
460 |
+
|
461 |
+
// update repeater values
|
462 |
+
$values = $wpdb->get_results("SELECT v.field_id, v.sub_field_id, v.order_no, m.post_id, m.meta_key, m.meta_value FROM $acf_values v LEFT JOIN $wp_postmeta m ON v.value = m.meta_id WHERE v.sub_field_id != 0", ARRAY_A);
|
463 |
+
if($values)
|
464 |
+
{
|
465 |
+
$rows = array();
|
466 |
+
|
467 |
+
foreach($values as $value)
|
468 |
+
{
|
469 |
+
// update row count
|
470 |
+
$row = (int) $value['order_no'] + 1;
|
471 |
+
|
472 |
+
// options page
|
473 |
+
if($value['post_id'] == 0) $value['post_id'] = 999999999;
|
474 |
+
|
475 |
+
// unserialize value (relationship, multi select, etc)
|
476 |
+
if(@unserialize($value['meta_value']))
|
477 |
+
{
|
478 |
+
$value['meta_value'] = unserialize($value['meta_value']);
|
479 |
+
}
|
480 |
+
|
481 |
+
// current row
|
482 |
+
$current_row = isset($rows[$value['post_id']][$value['field_id']]) ? $rows[$value['post_id']][$value['field_id']] : 0;
|
483 |
+
if($row > $current_row) $rows[$value['post_id']][$value['field_id']] = (int) $row;
|
484 |
+
|
485 |
+
// get field name
|
486 |
+
$field_name = $wpdb->get_var($wpdb->prepare("SELECT name FROM $acf_fields WHERE id = %d", $value['field_id']));
|
487 |
+
|
488 |
+
// get sub field name
|
489 |
+
$sub_field_name = $wpdb->get_var($wpdb->prepare("SELECT name FROM $acf_fields WHERE id = %d", $value['sub_field_id']));
|
490 |
+
|
491 |
+
// save new value
|
492 |
+
$new_meta_key = $field_name . '_' . $value['order_no'] . '_' . $sub_field_name;
|
493 |
+
update_post_meta($value['post_id'], $new_meta_key , $value['meta_value']);
|
494 |
+
|
495 |
+
// save value hidden field id
|
496 |
+
update_post_meta($value['post_id'], '_' . $new_meta_key, 'field_' . $value['sub_field_id']);
|
497 |
+
}
|
498 |
+
|
499 |
+
foreach($rows as $post_id => $field_ids)
|
500 |
+
{
|
501 |
+
foreach($field_ids as $field_id => $row_count)
|
502 |
+
{
|
503 |
+
// get sub field name
|
504 |
+
$field_name = $wpdb->get_var($wpdb->prepare("SELECT name FROM $acf_fields WHERE id = %d", $field_id));
|
505 |
+
|
506 |
+
delete_post_meta($post_id, $field_name);
|
507 |
+
update_post_meta($post_id, $field_name, $row_count);
|
508 |
+
update_post_meta($post_id, '_' . $field_name, 'field_' . $field_id);
|
509 |
+
|
510 |
+
}
|
511 |
+
}
|
512 |
+
|
513 |
+
}
|
514 |
+
|
515 |
+
// update version (only upgrade 1 time)
|
516 |
+
update_option('acf_version','3.0.0');
|
517 |
+
|
518 |
+
$return = array(
|
519 |
+
'status' => true,
|
520 |
+
'message' => $message,
|
521 |
+
'next' => '3.1.8',
|
522 |
+
);
|
523 |
+
|
524 |
+
break;
|
525 |
+
|
526 |
+
|
527 |
+
/*---------------------
|
528 |
+
*
|
529 |
+
* 3.1.8
|
530 |
+
*
|
531 |
+
*--------------------*/
|
532 |
+
|
533 |
+
case '3.1.8':
|
534 |
+
|
535 |
+
// vars
|
536 |
+
$message = __("Migrating options values from the $wp_postmeta table to the $wp_options table",'acf') . '...';
|
537 |
+
|
538 |
+
// update normal values
|
539 |
+
$rows = $wpdb->get_results( $wpdb->prepare("SELECT meta_key FROM $wp_postmeta WHERE post_id = %d", 999999999) , ARRAY_A);
|
540 |
+
|
541 |
+
if($rows)
|
542 |
+
{
|
543 |
+
foreach($rows as $row)
|
544 |
+
{
|
545 |
+
// original name
|
546 |
+
$field_name = $row['meta_key'];
|
547 |
+
|
548 |
+
|
549 |
+
// name
|
550 |
+
$new_name = "";
|
551 |
+
if( substr($field_name, 0, 1) == "_" )
|
552 |
+
{
|
553 |
+
$new_name = '_options' . $field_name;
|
554 |
+
}
|
555 |
+
else
|
556 |
+
{
|
557 |
+
$new_name = 'options_' . $field_name;
|
558 |
+
}
|
559 |
+
|
560 |
+
|
561 |
+
// value
|
562 |
+
$value = get_post_meta( 999999999, $field_name, true );
|
563 |
+
|
564 |
+
|
565 |
+
// update option
|
566 |
+
update_option( $new_name, $value );
|
567 |
+
|
568 |
+
|
569 |
+
// deleet old postmeta
|
570 |
+
delete_post_meta( 999999999, $field_name );
|
571 |
+
|
572 |
+
}
|
573 |
+
// foreach($values as $value)
|
574 |
+
}
|
575 |
+
// if($values)
|
576 |
+
|
577 |
+
|
578 |
+
// update version
|
579 |
+
update_option('acf_version','3.1.8');
|
580 |
+
|
581 |
+
$return = array(
|
582 |
+
'status' => true,
|
583 |
+
'message' => $message,
|
584 |
+
'next' => '3.2.5',
|
585 |
+
);
|
586 |
+
|
587 |
+
break;
|
588 |
+
|
589 |
+
|
590 |
+
/*---------------------
|
591 |
+
*
|
592 |
+
* 3.1.8
|
593 |
+
*
|
594 |
+
*--------------------*/
|
595 |
+
|
596 |
+
case '3.2.5':
|
597 |
+
|
598 |
+
// vars
|
599 |
+
$message = __("Modifying field group options 'show on page'",'acf') . '...';
|
600 |
+
|
601 |
+
|
602 |
+
// get acf's
|
603 |
+
$acfs = get_posts(array(
|
604 |
+
'numberposts' => -1,
|
605 |
+
'post_type' => 'acf',
|
606 |
+
'orderby' => 'menu_order title',
|
607 |
+
'order' => 'asc',
|
608 |
+
'suppress_filters' => false,
|
609 |
+
));
|
610 |
+
|
611 |
+
|
612 |
+
$show_all = array('the_content', 'discussion', 'custom_fields', 'comments', 'slug', 'author');
|
613 |
+
|
614 |
+
|
615 |
+
// populate acfs
|
616 |
+
if($acfs)
|
617 |
+
{
|
618 |
+
foreach($acfs as $acf)
|
619 |
+
{
|
620 |
+
$show_on_page = get_post_meta($acf->ID, 'show_on_page', true) ? get_post_meta($acf->ID, 'show_on_page', true) : array();
|
621 |
+
|
622 |
+
$hide_on_screen = array_diff($show_all, $show_on_page);
|
623 |
+
|
624 |
+
update_post_meta($acf->ID, 'hide_on_screen', $hide_on_screen);
|
625 |
+
delete_post_meta($acf->ID, 'show_on_page');
|
626 |
+
|
627 |
+
}
|
628 |
+
}
|
629 |
+
|
630 |
+
|
631 |
+
// update version
|
632 |
+
update_option('acf_version','3.2.5');
|
633 |
+
|
634 |
+
$return = array(
|
635 |
+
'status' => true,
|
636 |
+
'message' => $message,
|
637 |
+
'next' => '3.3.3',
|
638 |
+
);
|
639 |
+
|
640 |
+
break;
|
641 |
+
|
642 |
+
|
643 |
+
/*
|
644 |
+
* 3.3.3
|
645 |
+
*
|
646 |
+
* @description: changed field option: taxonomies filter on relationship / post object and page link fields.
|
647 |
+
* @created: 20/07/12
|
648 |
+
*/
|
649 |
+
|
650 |
+
case '3.3.3':
|
651 |
+
|
652 |
+
// vars
|
653 |
+
$message = __("Modifying field option 'taxonomy'",'acf') . '...';
|
654 |
+
$wp_term_taxonomy = $wpdb->prefix.'term_taxonomy';
|
655 |
+
$term_taxonomies = array();
|
656 |
+
|
657 |
+
$rows = $wpdb->get_results("SELECT * FROM $wp_term_taxonomy", ARRAY_A);
|
658 |
+
|
659 |
+
if($rows)
|
660 |
+
{
|
661 |
+
foreach($rows as $row)
|
662 |
+
{
|
663 |
+
$term_taxonomies[ $row['term_id'] ] = $row['taxonomy'] . ":" . $row['term_id'];
|
664 |
+
}
|
665 |
+
}
|
666 |
+
|
667 |
+
|
668 |
+
// get acf's
|
669 |
+
$acfs = get_posts(array(
|
670 |
+
'numberposts' => -1,
|
671 |
+
'post_type' => 'acf',
|
672 |
+
'orderby' => 'menu_order title',
|
673 |
+
'order' => 'asc',
|
674 |
+
'suppress_filters' => false,
|
675 |
+
));
|
676 |
+
|
677 |
+
// populate acfs
|
678 |
+
if($acfs)
|
679 |
+
{
|
680 |
+
foreach($acfs as $acf)
|
681 |
+
{
|
682 |
+
$fields = $this->parent->get_acf_fields($acf->ID);
|
683 |
+
|
684 |
+
if( $fields )
|
685 |
+
{
|
686 |
+
foreach( $fields as $field )
|
687 |
+
{
|
688 |
+
|
689 |
+
// only edit the option: taxonomy
|
690 |
+
if( !isset($field['taxonomy']) )
|
691 |
+
{
|
692 |
+
continue;
|
693 |
+
}
|
694 |
+
|
695 |
+
|
696 |
+
if( is_array($field['taxonomy']) )
|
697 |
+
{
|
698 |
+
foreach( $field['taxonomy'] as $k => $v )
|
699 |
+
{
|
700 |
+
|
701 |
+
// could be "all"
|
702 |
+
if( !is_numeric($v) )
|
703 |
+
{
|
704 |
+
continue;
|
705 |
+
}
|
706 |
+
|
707 |
+
$field['taxonomy'][ $k ] = $term_taxonomies[ $v ];
|
708 |
+
|
709 |
+
|
710 |
+
}
|
711 |
+
// foreach( $field['taxonomy'] as $k => $v )
|
712 |
+
}
|
713 |
+
// if( $field['taxonomy'] )
|
714 |
+
|
715 |
+
|
716 |
+
$this->parent->update_field( $acf->ID, $field);
|
717 |
+
|
718 |
+
}
|
719 |
+
// foreach( $fields as $field )
|
720 |
+
}
|
721 |
+
// if( $fields )
|
722 |
+
}
|
723 |
+
// foreach($acfs as $acf)
|
724 |
+
}
|
725 |
+
// if($acfs)
|
726 |
+
|
727 |
+
|
728 |
+
// update version
|
729 |
+
update_option('acf_version','3.3.3');
|
730 |
+
|
731 |
+
$return = array(
|
732 |
+
'status' => true,
|
733 |
+
'message' => $message,
|
734 |
+
'next' => '3.4.1',
|
735 |
+
);
|
736 |
+
|
737 |
+
break;
|
738 |
+
|
739 |
+
|
740 |
+
/*
|
741 |
+
* 3.4.1
|
742 |
+
*
|
743 |
+
* @description: Move user custom fields from wp_options to wp_usermeta
|
744 |
+
* @created: 20/07/12
|
745 |
+
*/
|
746 |
+
|
747 |
+
case '3.4.1':
|
748 |
+
|
749 |
+
// vars
|
750 |
+
$message = __("Moving user custom fields from wp_options to wp_usermeta",'acf') . '...';
|
751 |
+
|
752 |
+
$option_row_ids = array();
|
753 |
+
$option_rows = $wpdb->get_results("SELECT option_id, option_name, option_value FROM $wpdb->options WHERE option_name LIKE 'user%' OR option_name LIKE '\_user%'", ARRAY_A);
|
754 |
+
|
755 |
+
|
756 |
+
if( $option_rows )
|
757 |
+
{
|
758 |
+
foreach( $option_rows as $k => $row)
|
759 |
+
{
|
760 |
+
preg_match('/user_([0-9]+)_(.*)/', $row['option_name'], $matches);
|
761 |
+
|
762 |
+
|
763 |
+
// if no matches, this is not an acf value, ignore it
|
764 |
+
if( !$matches )
|
765 |
+
{
|
766 |
+
continue;
|
767 |
+
}
|
768 |
+
|
769 |
+
|
770 |
+
// add to $delete_option_rows
|
771 |
+
$option_row_ids[] = $row['option_id'];
|
772 |
+
|
773 |
+
|
774 |
+
// meta_key prefix
|
775 |
+
$meta_key_prefix = "";
|
776 |
+
if( substr($row['option_name'], 0, 1) == "_" )
|
777 |
+
{
|
778 |
+
$meta_key_prefix = '_';
|
779 |
+
}
|
780 |
+
|
781 |
+
|
782 |
+
// update user meta
|
783 |
+
update_user_meta( $matches[1], $meta_key_prefix . $matches[2], $row['option_value'] );
|
784 |
+
|
785 |
+
}
|
786 |
+
}
|
787 |
+
|
788 |
+
|
789 |
+
// clear up some memory ( aprox 14 kb )
|
790 |
+
unset( $option_rows );
|
791 |
+
|
792 |
+
|
793 |
+
// remove $option_row_ids
|
794 |
+
if( $option_row_ids )
|
795 |
+
{
|
796 |
+
$option_row_ids = implode(', ', $option_row_ids);
|
797 |
+
|
798 |
+
$wpdb->query("DELETE FROM $wpdb->options WHERE option_id IN ($option_row_ids)");
|
799 |
+
}
|
800 |
+
|
801 |
+
|
802 |
+
// update version
|
803 |
+
update_option('acf_version','3.4.1');
|
804 |
+
|
805 |
+
$return = array(
|
806 |
+
'status' => true,
|
807 |
+
'message' => $message,
|
808 |
+
'next' => false,
|
809 |
+
);
|
810 |
+
|
811 |
+
break;
|
812 |
+
|
813 |
+
|
814 |
+
}
|
815 |
+
|
816 |
+
// return json
|
817 |
+
echo json_encode($return);
|
818 |
+
die;
|
819 |
+
|
820 |
+
}
|
821 |
+
|
822 |
+
|
823 |
+
|
824 |
+
|
825 |
+
}
|
826 |
+
|
827 |
+
new acf_upgrade();
|
828 |
+
|
829 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/early-access.php
ADDED
@@ -0,0 +1,351 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
4 |
+
|
5 |
+
if( !class_exists('acf_early_access') ):
|
6 |
+
|
7 |
+
class acf_early_access {
|
8 |
+
|
9 |
+
/** @var string The plugin basename */
|
10 |
+
var $basename = 'advanced-custom-fields/acf.php';
|
11 |
+
|
12 |
+
|
13 |
+
/** @var string The early access value */
|
14 |
+
var $access = '';
|
15 |
+
|
16 |
+
|
17 |
+
/** @var boolean If the transient has been checked */
|
18 |
+
var $checked = false;
|
19 |
+
|
20 |
+
|
21 |
+
/**
|
22 |
+
* __construct
|
23 |
+
*
|
24 |
+
* This function will setup the class functionality
|
25 |
+
*
|
26 |
+
* @type function
|
27 |
+
* @date 12/9/17
|
28 |
+
* @since 1.0.0
|
29 |
+
*
|
30 |
+
* @param n/a
|
31 |
+
* @return n/a
|
32 |
+
*/
|
33 |
+
|
34 |
+
function __construct() {
|
35 |
+
|
36 |
+
// bail early if no access
|
37 |
+
if( !ACF_EARLY_ACCESS ) return;
|
38 |
+
|
39 |
+
|
40 |
+
// vars
|
41 |
+
$this->access = (string) ACF_EARLY_ACCESS;
|
42 |
+
//$this->basename = apply_filters('acf/get_info', 'basename');
|
43 |
+
|
44 |
+
|
45 |
+
// modify plugins transient
|
46 |
+
add_filter( 'pre_set_site_transient_update_plugins', array($this, 'modify_plugins_transient'), 10, 1 );
|
47 |
+
add_filter( 'site_transient_update_plugins', array($this, 'check_plugins_transient'), 10, 1 );
|
48 |
+
|
49 |
+
|
50 |
+
// admin
|
51 |
+
if( is_admin() ) {
|
52 |
+
|
53 |
+
// modify plugin update message
|
54 |
+
add_action('in_plugin_update_message-' . $this->basename, array($this, 'modify_plugin_update_message'), 10, 2 );
|
55 |
+
|
56 |
+
}
|
57 |
+
|
58 |
+
}
|
59 |
+
|
60 |
+
|
61 |
+
/**
|
62 |
+
* request
|
63 |
+
*
|
64 |
+
* This function will make a request to an external server
|
65 |
+
*
|
66 |
+
* @type function
|
67 |
+
* @date 8/4/17
|
68 |
+
* @since 1.0.0
|
69 |
+
*
|
70 |
+
* @param $url (string)
|
71 |
+
* @param $body (array)
|
72 |
+
* @return (mixed)
|
73 |
+
*/
|
74 |
+
|
75 |
+
function request( $url = '', $body = null ) {
|
76 |
+
|
77 |
+
// post
|
78 |
+
$raw_response = wp_remote_post($url, array(
|
79 |
+
'timeout' => 10,
|
80 |
+
'body' => $body
|
81 |
+
));
|
82 |
+
|
83 |
+
|
84 |
+
// wp error
|
85 |
+
if( is_wp_error($raw_response) ) {
|
86 |
+
|
87 |
+
return $raw_response;
|
88 |
+
|
89 |
+
// http error
|
90 |
+
} elseif( wp_remote_retrieve_response_code($raw_response) != 200 ) {
|
91 |
+
|
92 |
+
return new WP_Error( 'server_error', wp_remote_retrieve_response_message($raw_response) );
|
93 |
+
|
94 |
+
}
|
95 |
+
|
96 |
+
|
97 |
+
// vars
|
98 |
+
$raw_body = wp_remote_retrieve_body($raw_response);
|
99 |
+
|
100 |
+
|
101 |
+
// attempt object
|
102 |
+
$obj = @unserialize( $raw_body );
|
103 |
+
if( $obj ) return $obj;
|
104 |
+
|
105 |
+
|
106 |
+
// attempt json
|
107 |
+
$json = json_decode( $raw_body, true );
|
108 |
+
if( $json ) return $json;
|
109 |
+
|
110 |
+
|
111 |
+
// return
|
112 |
+
return $json;
|
113 |
+
|
114 |
+
}
|
115 |
+
|
116 |
+
|
117 |
+
/**
|
118 |
+
* get_plugin_info
|
119 |
+
*
|
120 |
+
* This function will get plugin info and save as transient
|
121 |
+
*
|
122 |
+
* @type function
|
123 |
+
* @date 9/4/17
|
124 |
+
* @since 1.0.0
|
125 |
+
*
|
126 |
+
* @param n/a
|
127 |
+
* @return (array)
|
128 |
+
*/
|
129 |
+
|
130 |
+
function get_plugin_info() {
|
131 |
+
|
132 |
+
// var
|
133 |
+
$transient_name = 'acf_early_access_info';
|
134 |
+
|
135 |
+
|
136 |
+
// delete transient (force-check is used to refresh)
|
137 |
+
if( !empty($_GET['force-check']) ) {
|
138 |
+
|
139 |
+
delete_transient($transient_name);
|
140 |
+
|
141 |
+
}
|
142 |
+
|
143 |
+
|
144 |
+
// try transient
|
145 |
+
$transient = get_transient($transient_name);
|
146 |
+
if( $transient !== false ) return $transient;
|
147 |
+
|
148 |
+
|
149 |
+
// connect
|
150 |
+
$response = $this->request('http://api.wordpress.org/plugins/info/1.0/advanced-custom-fields');
|
151 |
+
|
152 |
+
|
153 |
+
// ensure response is expected object
|
154 |
+
if( !is_wp_error($response) ) {
|
155 |
+
|
156 |
+
// store minimal data
|
157 |
+
$info = array(
|
158 |
+
'version' => $response->version,
|
159 |
+
'versions' => array_keys( $response->versions ),
|
160 |
+
'tested' => $response->tested
|
161 |
+
);
|
162 |
+
|
163 |
+
|
164 |
+
// order versions (latest first)
|
165 |
+
$info['versions'] = array_reverse($info['versions']);
|
166 |
+
|
167 |
+
|
168 |
+
// update var
|
169 |
+
$response = $info;
|
170 |
+
|
171 |
+
}
|
172 |
+
|
173 |
+
|
174 |
+
// update transient
|
175 |
+
set_transient($transient_name, $response, HOUR_IN_SECONDS);
|
176 |
+
|
177 |
+
|
178 |
+
// return
|
179 |
+
return $response;
|
180 |
+
|
181 |
+
}
|
182 |
+
|
183 |
+
|
184 |
+
/**
|
185 |
+
* check_plugins_transient
|
186 |
+
*
|
187 |
+
* This function will check the 'update_plugins' transient and maybe modify it's value
|
188 |
+
*
|
189 |
+
* @date 19/9/17
|
190 |
+
* @since 5.6.3
|
191 |
+
*
|
192 |
+
* @param n/a
|
193 |
+
* @return n/a
|
194 |
+
*/
|
195 |
+
|
196 |
+
function check_plugins_transient( $transient ) {
|
197 |
+
|
198 |
+
// bail ealry if has been checked
|
199 |
+
if( $this->checked ) return $transient;
|
200 |
+
$this->checked = true;
|
201 |
+
|
202 |
+
|
203 |
+
// vars
|
204 |
+
$basename = $this->basename;
|
205 |
+
|
206 |
+
|
207 |
+
// bail early if empty
|
208 |
+
if( !$transient || empty($transient->checked) ) return $transient;
|
209 |
+
|
210 |
+
|
211 |
+
// bail early if acf was not checked
|
212 |
+
// - rules out possible included file in theme / plugin
|
213 |
+
if( !isset($transient->checked[ $basename ]) ) return $transient;
|
214 |
+
|
215 |
+
|
216 |
+
// flush cache if no 'acf' update exists
|
217 |
+
// flush cache if 'acf' update does not contain early access info
|
218 |
+
// flush cache if 'acf' update contains different early access info
|
219 |
+
if( empty($transient->response[ $basename ]) ||
|
220 |
+
empty($transient->response[ $basename ]->early_access) ||
|
221 |
+
$transient->response[ $basename ]->early_access !== $this->access ) {
|
222 |
+
wp_clean_plugins_cache();
|
223 |
+
}
|
224 |
+
|
225 |
+
|
226 |
+
// return
|
227 |
+
return $transient;
|
228 |
+
|
229 |
+
}
|
230 |
+
|
231 |
+
|
232 |
+
|
233 |
+
/**
|
234 |
+
* modify_plugins_transient
|
235 |
+
*
|
236 |
+
* This function will modify the 'update_plugins' transient with custom data
|
237 |
+
*
|
238 |
+
* @type function
|
239 |
+
* @date 11/9/17
|
240 |
+
* @since 1.0.0
|
241 |
+
*
|
242 |
+
* @param $transient (object)
|
243 |
+
* @return $transient
|
244 |
+
*/
|
245 |
+
|
246 |
+
function modify_plugins_transient( $transient ) {
|
247 |
+
|
248 |
+
// vars
|
249 |
+
$basename = $this->basename;
|
250 |
+
|
251 |
+
|
252 |
+
// bail early if empty
|
253 |
+
if( !$transient || empty($transient->checked) ) return $transient;
|
254 |
+
|
255 |
+
|
256 |
+
// bail early if acf was not checked
|
257 |
+
// - rules out possible included file in theme / plugin
|
258 |
+
if( !isset($transient->checked[ $basename ]) ) return $transient;
|
259 |
+
|
260 |
+
|
261 |
+
// bail early if already modified
|
262 |
+
if( !empty($transient->response[ $basename ]->early_access) ) return $transient;
|
263 |
+
|
264 |
+
|
265 |
+
// vars
|
266 |
+
$info = $this->get_plugin_info();
|
267 |
+
$old_version = $transient->checked[ $basename ];
|
268 |
+
$new_version = '';
|
269 |
+
|
270 |
+
|
271 |
+
// attempt to find latest tag
|
272 |
+
foreach( $info['versions'] as $version ) {
|
273 |
+
|
274 |
+
// ignore trunk
|
275 |
+
if( $version == 'trunk' ) continue;
|
276 |
+
|
277 |
+
|
278 |
+
// restirct versions that don't start with '5'
|
279 |
+
if( strpos($version, $this->access) !== 0 ) continue;
|
280 |
+
|
281 |
+
|
282 |
+
// ignore if $version is older than $old_version
|
283 |
+
if( version_compare($version, $old_version, '<=') ) continue;
|
284 |
+
|
285 |
+
|
286 |
+
// ignore if $version is older than $new_version
|
287 |
+
if( version_compare($version, $new_version, '<=') ) continue;
|
288 |
+
|
289 |
+
|
290 |
+
// this tag is a newer version!
|
291 |
+
$new_version = $version;
|
292 |
+
|
293 |
+
}
|
294 |
+
|
295 |
+
|
296 |
+
// bail ealry if no $new_version
|
297 |
+
if( !$new_version ) return $transient;
|
298 |
+
|
299 |
+
|
300 |
+
// response
|
301 |
+
$response = new stdClass();
|
302 |
+
$response->id = 'w.org/plugins/advanced-custom-fields';
|
303 |
+
$response->slug = 'advanced-custom-fields';
|
304 |
+
$response->plugin = $basename;
|
305 |
+
$response->new_version = $new_version;
|
306 |
+
$response->url = 'https://wordpress.org/plugins/advanced-custom-fields/';
|
307 |
+
$response->package = 'https://downloads.wordpress.org/plugin/advanced-custom-fields.'.$new_version.'.zip';
|
308 |
+
$response->tested = $info['tested'];
|
309 |
+
$response->early_access = $this->access;
|
310 |
+
|
311 |
+
|
312 |
+
// append
|
313 |
+
$transient->response[ $basename ] = $response;
|
314 |
+
|
315 |
+
|
316 |
+
// return
|
317 |
+
return $transient;
|
318 |
+
|
319 |
+
}
|
320 |
+
|
321 |
+
|
322 |
+
/*
|
323 |
+
* modify_plugin_update_message
|
324 |
+
*
|
325 |
+
* Displays an update message for plugin list screens.
|
326 |
+
*
|
327 |
+
* @type function
|
328 |
+
* @date 14/06/2016
|
329 |
+
* @since 5.3.8
|
330 |
+
*
|
331 |
+
* @param $message (string)
|
332 |
+
* @param $plugin_data (array)
|
333 |
+
* @param $r (object)
|
334 |
+
* @return $message
|
335 |
+
*/
|
336 |
+
|
337 |
+
function modify_plugin_update_message( $plugin_data, $response ) {
|
338 |
+
|
339 |
+
// display message
|
340 |
+
echo ' <em>' . __('(Early access enabled)', 'acf') . '</em>';
|
341 |
+
|
342 |
+
}
|
343 |
+
|
344 |
+
}
|
345 |
+
|
346 |
+
// instantiate
|
347 |
+
new acf_early_access();
|
348 |
+
|
349 |
+
endif; // class_exists check
|
350 |
+
|
351 |
+
?>
|
shared/assets/plugins/advanced-custom-fields/core/fields/_base.php
CHANGED
@@ -1,191 +1,191 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* acf_field
|
5 |
-
*
|
6 |
-
* @description: This is the base class for all fields.
|
7 |
-
* @since: 3.6
|
8 |
-
* @created: 30/01/13
|
9 |
-
*/
|
10 |
-
|
11 |
-
class acf_field
|
12 |
-
{
|
13 |
-
/*
|
14 |
-
* Vars
|
15 |
-
*
|
16 |
-
* @description:
|
17 |
-
* @since: 3.6
|
18 |
-
* @created: 30/01/13
|
19 |
-
*/
|
20 |
-
|
21 |
-
var $name,
|
22 |
-
$title,
|
23 |
-
$category,
|
24 |
-
$defaults,
|
25 |
-
$l10n;
|
26 |
-
|
27 |
-
|
28 |
-
/*
|
29 |
-
* __construct()
|
30 |
-
*
|
31 |
-
* Adds neccessary Actions / Filters
|
32 |
-
*
|
33 |
-
* @since 3.6
|
34 |
-
* @date 30/01/13
|
35 |
-
*/
|
36 |
-
|
37 |
-
function __construct()
|
38 |
-
{
|
39 |
-
// register field
|
40 |
-
add_filter('acf/registered_fields', array($this, 'registered_fields'), 10, 1);
|
41 |
-
add_filter('acf/load_field_defaults/type=' . $this->name, array($this, 'load_field_defaults'), 10, 1);
|
42 |
-
|
43 |
-
|
44 |
-
// value
|
45 |
-
$this->add_filter('acf/load_value/type=' . $this->name, array($this, 'load_value'), 10, 3);
|
46 |
-
$this->add_filter('acf/update_value/type=' . $this->name, array($this, 'update_value'), 10, 3);
|
47 |
-
$this->add_filter('acf/format_value/type=' . $this->name, array($this, 'format_value'), 10, 3);
|
48 |
-
$this->add_filter('acf/format_value_for_api/type=' . $this->name, array($this, 'format_value_for_api'), 10, 3);
|
49 |
-
|
50 |
-
|
51 |
-
// field
|
52 |
-
$this->add_filter('acf/load_field/type=' . $this->name, array($this, 'load_field'), 10, 3);
|
53 |
-
$this->add_filter('acf/update_field/type=' . $this->name, array($this, 'update_field'), 10, 2);
|
54 |
-
$this->add_action('acf/create_field/type=' . $this->name, array($this, 'create_field'), 10, 1);
|
55 |
-
$this->add_action('acf/create_field_options/type=' . $this->name, array($this, 'create_options'), 10, 1);
|
56 |
-
|
57 |
-
|
58 |
-
// input actions
|
59 |
-
$this->add_action('acf/input/admin_enqueue_scripts', array($this, 'input_admin_enqueue_scripts'), 10, 0);
|
60 |
-
$this->add_action('acf/input/admin_head', array($this, 'input_admin_head'), 10, 0);
|
61 |
-
$this->add_filter('acf/input/admin_l10n', array($this, 'input_admin_l10n'), 10, 1);
|
62 |
-
|
63 |
-
|
64 |
-
// field group actions
|
65 |
-
$this->add_action('acf/field_group/admin_enqueue_scripts', array($this, 'field_group_admin_enqueue_scripts'), 10, 0);
|
66 |
-
$this->add_action('acf/field_group/admin_head', array($this, 'field_group_admin_head'), 10, 0);
|
67 |
-
|
68 |
-
}
|
69 |
-
|
70 |
-
|
71 |
-
/*
|
72 |
-
* add_filter
|
73 |
-
*
|
74 |
-
* @description: checks if the function is_callable before adding the filter
|
75 |
-
* @since: 3.6
|
76 |
-
* @created: 30/01/13
|
77 |
-
*/
|
78 |
-
|
79 |
-
function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1)
|
80 |
-
{
|
81 |
-
if( is_callable($function_to_add) )
|
82 |
-
{
|
83 |
-
add_filter($tag, $function_to_add, $priority, $accepted_args);
|
84 |
-
}
|
85 |
-
}
|
86 |
-
|
87 |
-
|
88 |
-
/*
|
89 |
-
* add_action
|
90 |
-
*
|
91 |
-
* @description: checks if the function is_callable before adding the action
|
92 |
-
* @since: 3.6
|
93 |
-
* @created: 30/01/13
|
94 |
-
*/
|
95 |
-
|
96 |
-
function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1)
|
97 |
-
{
|
98 |
-
if( is_callable($function_to_add) )
|
99 |
-
{
|
100 |
-
add_action($tag, $function_to_add, $priority, $accepted_args);
|
101 |
-
}
|
102 |
-
}
|
103 |
-
|
104 |
-
|
105 |
-
/*
|
106 |
-
* registered_fields()
|
107 |
-
*
|
108 |
-
* Adds this field to the select list when creating a new field
|
109 |
-
*
|
110 |
-
* @type filter
|
111 |
-
* @since 3.6
|
112 |
-
* @date 23/01/13
|
113 |
-
*
|
114 |
-
* @param $fields - the array of all registered fields
|
115 |
-
*
|
116 |
-
* @return $fields - the array of all registered fields
|
117 |
-
*/
|
118 |
-
|
119 |
-
function registered_fields( $fields )
|
120 |
-
{
|
121 |
-
// defaults
|
122 |
-
if( !$this->category )
|
123 |
-
{
|
124 |
-
$this->category = __('Basic', 'acf');
|
125 |
-
}
|
126 |
-
|
127 |
-
|
128 |
-
// add to array
|
129 |
-
$fields[ $this->category ][ $this->name ] = $this->label;
|
130 |
-
|
131 |
-
|
132 |
-
// return array
|
133 |
-
return $fields;
|
134 |
-
}
|
135 |
-
|
136 |
-
|
137 |
-
/*
|
138 |
-
* load_field_defaults
|
139 |
-
*
|
140 |
-
* action called when rendering the head of an admin screen. Used primarily for passing PHP to JS
|
141 |
-
*
|
142 |
-
* @type filer
|
143 |
-
* @date 1/06/13
|
144 |
-
*
|
145 |
-
* @param $field {array}
|
146 |
-
* @return $field {array}
|
147 |
-
*/
|
148 |
-
|
149 |
-
function load_field_defaults( $field )
|
150 |
-
{
|
151 |
-
if( !empty($this->defaults) )
|
152 |
-
{
|
153 |
-
foreach( $this->defaults as $k => $v )
|
154 |
-
{
|
155 |
-
if( !isset($field[ $k ]) )
|
156 |
-
{
|
157 |
-
$field[ $k ] = $v;
|
158 |
-
}
|
159 |
-
}
|
160 |
-
}
|
161 |
-
|
162 |
-
return $field;
|
163 |
-
}
|
164 |
-
|
165 |
-
|
166 |
-
/*
|
167 |
-
* admin_l10n
|
168 |
-
*
|
169 |
-
* filter is called to load all l10n text translations into the admin head script tag
|
170 |
-
*
|
171 |
-
* @type filer
|
172 |
-
* @date 1/06/13
|
173 |
-
*
|
174 |
-
* @param $field {array}
|
175 |
-
* @return $field {array}
|
176 |
-
*/
|
177 |
-
|
178 |
-
function input_admin_l10n( $l10n )
|
179 |
-
{
|
180 |
-
if( !empty($this->l10n) )
|
181 |
-
{
|
182 |
-
$l10n[ $this->name ] = $this->l10n;
|
183 |
-
}
|
184 |
-
|
185 |
-
return $l10n;
|
186 |
-
}
|
187 |
-
|
188 |
-
|
189 |
-
}
|
190 |
-
|
191 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* acf_field
|
5 |
+
*
|
6 |
+
* @description: This is the base class for all fields.
|
7 |
+
* @since: 3.6
|
8 |
+
* @created: 30/01/13
|
9 |
+
*/
|
10 |
+
|
11 |
+
class acf_field
|
12 |
+
{
|
13 |
+
/*
|
14 |
+
* Vars
|
15 |
+
*
|
16 |
+
* @description:
|
17 |
+
* @since: 3.6
|
18 |
+
* @created: 30/01/13
|
19 |
+
*/
|
20 |
+
|
21 |
+
var $name,
|
22 |
+
$title,
|
23 |
+
$category,
|
24 |
+
$defaults,
|
25 |
+
$l10n;
|
26 |
+
|
27 |
+
|
28 |
+
/*
|
29 |
+
* __construct()
|
30 |
+
*
|
31 |
+
* Adds neccessary Actions / Filters
|
32 |
+
*
|
33 |
+
* @since 3.6
|
34 |
+
* @date 30/01/13
|
35 |
+
*/
|
36 |
+
|
37 |
+
function __construct()
|
38 |
+
{
|
39 |
+
// register field
|
40 |
+
add_filter('acf/registered_fields', array($this, 'registered_fields'), 10, 1);
|
41 |
+
add_filter('acf/load_field_defaults/type=' . $this->name, array($this, 'load_field_defaults'), 10, 1);
|
42 |
+
|
43 |
+
|
44 |
+
// value
|
45 |
+
$this->add_filter('acf/load_value/type=' . $this->name, array($this, 'load_value'), 10, 3);
|
46 |
+
$this->add_filter('acf/update_value/type=' . $this->name, array($this, 'update_value'), 10, 3);
|
47 |
+
$this->add_filter('acf/format_value/type=' . $this->name, array($this, 'format_value'), 10, 3);
|
48 |
+
$this->add_filter('acf/format_value_for_api/type=' . $this->name, array($this, 'format_value_for_api'), 10, 3);
|
49 |
+
|
50 |
+
|
51 |
+
// field
|
52 |
+
$this->add_filter('acf/load_field/type=' . $this->name, array($this, 'load_field'), 10, 3);
|
53 |
+
$this->add_filter('acf/update_field/type=' . $this->name, array($this, 'update_field'), 10, 2);
|
54 |
+
$this->add_action('acf/create_field/type=' . $this->name, array($this, 'create_field'), 10, 1);
|
55 |
+
$this->add_action('acf/create_field_options/type=' . $this->name, array($this, 'create_options'), 10, 1);
|
56 |
+
|
57 |
+
|
58 |
+
// input actions
|
59 |
+
$this->add_action('acf/input/admin_enqueue_scripts', array($this, 'input_admin_enqueue_scripts'), 10, 0);
|
60 |
+
$this->add_action('acf/input/admin_head', array($this, 'input_admin_head'), 10, 0);
|
61 |
+
$this->add_filter('acf/input/admin_l10n', array($this, 'input_admin_l10n'), 10, 1);
|
62 |
+
|
63 |
+
|
64 |
+
// field group actions
|
65 |
+
$this->add_action('acf/field_group/admin_enqueue_scripts', array($this, 'field_group_admin_enqueue_scripts'), 10, 0);
|
66 |
+
$this->add_action('acf/field_group/admin_head', array($this, 'field_group_admin_head'), 10, 0);
|
67 |
+
|
68 |
+
}
|
69 |
+
|
70 |
+
|
71 |
+
/*
|
72 |
+
* add_filter
|
73 |
+
*
|
74 |
+
* @description: checks if the function is_callable before adding the filter
|
75 |
+
* @since: 3.6
|
76 |
+
* @created: 30/01/13
|
77 |
+
*/
|
78 |
+
|
79 |
+
function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1)
|
80 |
+
{
|
81 |
+
if( is_callable($function_to_add) )
|
82 |
+
{
|
83 |
+
add_filter($tag, $function_to_add, $priority, $accepted_args);
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
|
88 |
+
/*
|
89 |
+
* add_action
|
90 |
+
*
|
91 |
+
* @description: checks if the function is_callable before adding the action
|
92 |
+
* @since: 3.6
|
93 |
+
* @created: 30/01/13
|
94 |
+
*/
|
95 |
+
|
96 |
+
function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1)
|
97 |
+
{
|
98 |
+
if( is_callable($function_to_add) )
|
99 |
+
{
|
100 |
+
add_action($tag, $function_to_add, $priority, $accepted_args);
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
|
105 |
+
/*
|
106 |
+
* registered_fields()
|
107 |
+
*
|
108 |
+
* Adds this field to the select list when creating a new field
|
109 |
+
*
|
110 |
+
* @type filter
|
111 |
+
* @since 3.6
|
112 |
+
* @date 23/01/13
|
113 |
+
*
|
114 |
+
* @param $fields - the array of all registered fields
|
115 |
+
*
|
116 |
+
* @return $fields - the array of all registered fields
|
117 |
+
*/
|
118 |
+
|
119 |
+
function registered_fields( $fields )
|
120 |
+
{
|
121 |
+
// defaults
|
122 |
+
if( !$this->category )
|
123 |
+
{
|
124 |
+
$this->category = __('Basic', 'acf');
|
125 |
+
}
|
126 |
+
|
127 |
+
|
128 |
+
// add to array
|
129 |
+
$fields[ $this->category ][ $this->name ] = $this->label;
|
130 |
+
|
131 |
+
|
132 |
+
// return array
|
133 |
+
return $fields;
|
134 |
+
}
|
135 |
+
|
136 |
+
|
137 |
+
/*
|
138 |
+
* load_field_defaults
|
139 |
+
*
|
140 |
+
* action called when rendering the head of an admin screen. Used primarily for passing PHP to JS
|
141 |
+
*
|
142 |
+
* @type filer
|
143 |
+
* @date 1/06/13
|
144 |
+
*
|
145 |
+
* @param $field {array}
|
146 |
+
* @return $field {array}
|
147 |
+
*/
|
148 |
+
|
149 |
+
function load_field_defaults( $field )
|
150 |
+
{
|
151 |
+
if( !empty($this->defaults) )
|
152 |
+
{
|
153 |
+
foreach( $this->defaults as $k => $v )
|
154 |
+
{
|
155 |
+
if( !isset($field[ $k ]) )
|
156 |
+
{
|
157 |
+
$field[ $k ] = $v;
|
158 |
+
}
|
159 |
+
}
|
160 |
+
}
|
161 |
+
|
162 |
+
return $field;
|
163 |
+
}
|
164 |
+
|
165 |
+
|
166 |
+
/*
|
167 |
+
* admin_l10n
|
168 |
+
*
|
169 |
+
* filter is called to load all l10n text translations into the admin head script tag
|
170 |
+
*
|
171 |
+
* @type filer
|
172 |
+
* @date 1/06/13
|
173 |
+
*
|
174 |
+
* @param $field {array}
|
175 |
+
* @return $field {array}
|
176 |
+
*/
|
177 |
+
|
178 |
+
function input_admin_l10n( $l10n )
|
179 |
+
{
|
180 |
+
if( !empty($this->l10n) )
|
181 |
+
{
|
182 |
+
$l10n[ $this->name ] = $this->l10n;
|
183 |
+
}
|
184 |
+
|
185 |
+
return $l10n;
|
186 |
+
}
|
187 |
+
|
188 |
+
|
189 |
+
}
|
190 |
+
|
191 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/fields/_functions.php
CHANGED
@@ -1,598 +1,598 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* Field Functions
|
5 |
-
*
|
6 |
-
* @description: The API for all fields
|
7 |
-
* @since: 3.6
|
8 |
-
* @created: 23/01/13
|
9 |
-
*/
|
10 |
-
|
11 |
-
class acf_field_functions
|
12 |
-
{
|
13 |
-
|
14 |
-
/*
|
15 |
-
* __construct
|
16 |
-
*
|
17 |
-
* @description:
|
18 |
-
* @since 3.1.8
|
19 |
-
* @created: 23/06/12
|
20 |
-
*/
|
21 |
-
|
22 |
-
function __construct()
|
23 |
-
{
|
24 |
-
//value
|
25 |
-
add_filter('acf/load_value', array($this, 'load_value'), 5, 3);
|
26 |
-
add_action('acf/update_value', array($this, 'update_value'), 5, 3);
|
27 |
-
add_action('acf/delete_value', array($this, 'delete_value'), 5, 2);
|
28 |
-
add_action('acf/format_value', array($this, 'format_value'), 5, 3);
|
29 |
-
add_action('acf/format_value_for_api', array($this, 'format_value_for_api'), 5, 3);
|
30 |
-
|
31 |
-
|
32 |
-
// field
|
33 |
-
add_filter('acf/load_field', array($this, 'load_field'), 5, 3);
|
34 |
-
add_action('acf/update_field', array($this, 'update_field'), 5, 2);
|
35 |
-
add_action('acf/delete_field', array($this, 'delete_field'), 5, 2);
|
36 |
-
add_action('acf/create_field', array($this, 'create_field'), 5, 1);
|
37 |
-
add_action('acf/create_field_options', array($this, 'create_field_options'), 5, 1);
|
38 |
-
|
39 |
-
|
40 |
-
// extra
|
41 |
-
add_filter('acf/load_field_defaults', array($this, 'load_field_defaults'), 5, 1);
|
42 |
-
}
|
43 |
-
|
44 |
-
|
45 |
-
/*
|
46 |
-
* load_value
|
47 |
-
*
|
48 |
-
* @description: loads basic value from the db
|
49 |
-
* @since: 3.6
|
50 |
-
* @created: 23/01/13
|
51 |
-
*/
|
52 |
-
|
53 |
-
function load_value($value, $post_id, $field)
|
54 |
-
{
|
55 |
-
$found = false;
|
56 |
-
$cache = wp_cache_get( 'load_value/post_id=' . $post_id . '/name=' . $field['name'], 'acf', false, $found );
|
57 |
-
|
58 |
-
if( $found )
|
59 |
-
{
|
60 |
-
return $cache;
|
61 |
-
}
|
62 |
-
|
63 |
-
|
64 |
-
// set default value
|
65 |
-
$value = false;
|
66 |
-
|
67 |
-
|
68 |
-
// if $post_id is a string, then it is used in the everything fields and can be found in the options table
|
69 |
-
if( is_numeric($post_id) )
|
70 |
-
{
|
71 |
-
$v = get_post_meta( $post_id, $field['name'], false );
|
72 |
-
|
73 |
-
// value is an array
|
74 |
-
if( isset($v[0]) )
|
75 |
-
{
|
76 |
-
$value = $v[0];
|
77 |
-
}
|
78 |
-
|
79 |
-
}
|
80 |
-
elseif( strpos($post_id, 'user_') !== false )
|
81 |
-
{
|
82 |
-
$user_id = str_replace('user_', '', $post_id);
|
83 |
-
|
84 |
-
$v = get_user_meta( $user_id, $field['name'], false );
|
85 |
-
|
86 |
-
// value is an array
|
87 |
-
if( isset($v[0]) )
|
88 |
-
{
|
89 |
-
$value = $v[0];
|
90 |
-
}
|
91 |
-
|
92 |
-
}
|
93 |
-
else
|
94 |
-
{
|
95 |
-
$v = get_option( $post_id . '_' . $field['name'], false );
|
96 |
-
|
97 |
-
if( !is_null($value) )
|
98 |
-
{
|
99 |
-
$value = $v;
|
100 |
-
}
|
101 |
-
}
|
102 |
-
|
103 |
-
|
104 |
-
// no value?
|
105 |
-
if( $value === false )
|
106 |
-
{
|
107 |
-
if( isset($field['default_value']) && $field['default_value'] !== "" )
|
108 |
-
{
|
109 |
-
$value = $field['default_value'];
|
110 |
-
}
|
111 |
-
}
|
112 |
-
|
113 |
-
|
114 |
-
// if value was duplicated, it may now be a serialized string!
|
115 |
-
$value = maybe_unserialize($value);
|
116 |
-
|
117 |
-
|
118 |
-
// apply filters
|
119 |
-
foreach( array('type', 'name', 'key') as $key )
|
120 |
-
{
|
121 |
-
// run filters
|
122 |
-
$value = apply_filters('acf/load_value/' . $key . '=' . $field[ $key ], $value, $post_id, $field); // new filter
|
123 |
-
}
|
124 |
-
|
125 |
-
|
126 |
-
//update cache
|
127 |
-
wp_cache_set( 'load_value/post_id=' . $post_id . '/name=' . $field['name'], $value, 'acf' );
|
128 |
-
|
129 |
-
|
130 |
-
return $value;
|
131 |
-
}
|
132 |
-
|
133 |
-
|
134 |
-
/*
|
135 |
-
* format_value
|
136 |
-
*
|
137 |
-
* @description: uses the basic value and allows the field type to format it
|
138 |
-
* @since: 3.6
|
139 |
-
* @created: 26/01/13
|
140 |
-
*/
|
141 |
-
|
142 |
-
function format_value( $value, $post_id, $field )
|
143 |
-
{
|
144 |
-
$value = apply_filters('acf/format_value/type=' . $field['type'], $value, $post_id, $field);
|
145 |
-
|
146 |
-
return $value;
|
147 |
-
}
|
148 |
-
|
149 |
-
|
150 |
-
/*
|
151 |
-
* format_value_for_api
|
152 |
-
*
|
153 |
-
* @description: uses the basic value and allows the field type to format it or the api functions
|
154 |
-
* @since: 3.6
|
155 |
-
* @created: 26/01/13
|
156 |
-
*/
|
157 |
-
|
158 |
-
function format_value_for_api( $value, $post_id, $field )
|
159 |
-
{
|
160 |
-
$value = apply_filters('acf/format_value_for_api/type=' . $field['type'], $value, $post_id, $field);
|
161 |
-
|
162 |
-
return $value;
|
163 |
-
}
|
164 |
-
|
165 |
-
|
166 |
-
/*
|
167 |
-
* update_value
|
168 |
-
*
|
169 |
-
* updates a value into the db
|
170 |
-
*
|
171 |
-
* @type action
|
172 |
-
* @date 23/01/13
|
173 |
-
*
|
174 |
-
* @param {mixed} $value the value to be saved
|
175 |
-
* @param {int} $post_id the post ID to save the value to
|
176 |
-
* @param {array} $field the field array
|
177 |
-
* @param {boolean} $exact allows the update_value filter to be skipped
|
178 |
-
* @return N/A
|
179 |
-
*/
|
180 |
-
|
181 |
-
function update_value( $value, $post_id, $field )
|
182 |
-
{
|
183 |
-
|
184 |
-
// strip slashes
|
185 |
-
// - not needed? http://support.advancedcustomfields.com/discussion/3168/backslashes-stripped-in-wysiwyg-filed
|
186 |
-
//if( get_magic_quotes_gpc() )
|
187 |
-
//{
|
188 |
-
$value = stripslashes_deep($value);
|
189 |
-
//}
|
190 |
-
|
191 |
-
|
192 |
-
// apply filters
|
193 |
-
foreach( array('key', 'name', 'type') as $key )
|
194 |
-
{
|
195 |
-
// run filters
|
196 |
-
$value = apply_filters('acf/update_value/' . $key . '=' . $field[ $key ], $value, $post_id, $field); // new filter
|
197 |
-
}
|
198 |
-
|
199 |
-
|
200 |
-
// if $post_id is a string, then it is used in the everything fields and can be found in the options table
|
201 |
-
if( is_numeric($post_id) )
|
202 |
-
{
|
203 |
-
// allow ACF to save to revision!
|
204 |
-
update_metadata('post', $post_id, $field['name'], $value );
|
205 |
-
update_metadata('post', $post_id, '_' . $field['name'], $field['key']);
|
206 |
-
}
|
207 |
-
elseif( strpos($post_id, 'user_') !== false )
|
208 |
-
{
|
209 |
-
$user_id = str_replace('user_', '', $post_id);
|
210 |
-
update_metadata('user', $user_id, $field['name'], $value);
|
211 |
-
update_metadata('user', $user_id, '_' . $field['name'], $field['key']);
|
212 |
-
}
|
213 |
-
else
|
214 |
-
{
|
215 |
-
// for some reason, update_option does not use stripslashes_deep.
|
216 |
-
// update_metadata -> http://core.trac.wordpress.org/browser/tags/3.4.2/wp-includes/meta.php#L82: line 101 (does use stripslashes_deep)
|
217 |
-
// update_option -> http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/option.php#L0: line 215 (does not use stripslashes_deep)
|
218 |
-
$value = stripslashes_deep($value);
|
219 |
-
|
220 |
-
$this->update_option( $post_id . '_' . $field['name'], $value );
|
221 |
-
$this->update_option( '_' . $post_id . '_' . $field['name'], $field['key'] );
|
222 |
-
}
|
223 |
-
|
224 |
-
|
225 |
-
// update the cache
|
226 |
-
wp_cache_set( 'load_value/post_id=' . $post_id . '/name=' . $field['name'], $value, 'acf' );
|
227 |
-
|
228 |
-
}
|
229 |
-
|
230 |
-
|
231 |
-
/*
|
232 |
-
* update_option
|
233 |
-
*
|
234 |
-
* This function is a wrapper for the WP update_option but provides logic for a 'no' autoload
|
235 |
-
*
|
236 |
-
* @type function
|
237 |
-
* @date 4/01/2014
|
238 |
-
* @since 5.0.0
|
239 |
-
*
|
240 |
-
* @param $option (string)
|
241 |
-
* @param $value (mixed)
|
242 |
-
* @return (boolean)
|
243 |
-
*/
|
244 |
-
|
245 |
-
function update_option( $option = '', $value = false, $autoload = 'no' ) {
|
246 |
-
|
247 |
-
// vars
|
248 |
-
$deprecated = '';
|
249 |
-
$return = false;
|
250 |
-
|
251 |
-
|
252 |
-
if( get_option($option) !== false )
|
253 |
-
{
|
254 |
-
$return = update_option( $option, $value );
|
255 |
-
}
|
256 |
-
else
|
257 |
-
{
|
258 |
-
$return = add_option( $option, $value, $deprecated, $autoload );
|
259 |
-
}
|
260 |
-
|
261 |
-
|
262 |
-
// return
|
263 |
-
return $return;
|
264 |
-
|
265 |
-
}
|
266 |
-
|
267 |
-
|
268 |
-
/*
|
269 |
-
* delete_value
|
270 |
-
*
|
271 |
-
* @description: deletes a value from the database
|
272 |
-
* @since: 3.6
|
273 |
-
* @created: 23/01/13
|
274 |
-
*/
|
275 |
-
|
276 |
-
function delete_value( $post_id, $key )
|
277 |
-
{
|
278 |
-
// if $post_id is a string, then it is used in the everything fields and can be found in the options table
|
279 |
-
if( is_numeric($post_id) )
|
280 |
-
{
|
281 |
-
delete_post_meta( $post_id, $key );
|
282 |
-
delete_post_meta( $post_id, '_' . $key );
|
283 |
-
}
|
284 |
-
elseif( strpos($post_id, 'user_') !== false )
|
285 |
-
{
|
286 |
-
$post_id = str_replace('user_', '', $post_id);
|
287 |
-
delete_user_meta( $post_id, $key );
|
288 |
-
delete_user_meta( $post_id, '_' . $key );
|
289 |
-
}
|
290 |
-
else
|
291 |
-
{
|
292 |
-
delete_option( $post_id . '_' . $key );
|
293 |
-
delete_option( '_' . $post_id . '_' . $key );
|
294 |
-
}
|
295 |
-
|
296 |
-
wp_cache_delete( 'load_value/post_id=' . $post_id . '/name=' . $key, 'acf' );
|
297 |
-
}
|
298 |
-
|
299 |
-
|
300 |
-
/*
|
301 |
-
* load_field
|
302 |
-
*
|
303 |
-
* @description: loads a field from the database
|
304 |
-
* @since 3.5.1
|
305 |
-
* @created: 14/10/12
|
306 |
-
*/
|
307 |
-
|
308 |
-
function load_field( $field, $field_key, $post_id = false )
|
309 |
-
{
|
310 |
-
// load cache
|
311 |
-
if( !$field )
|
312 |
-
{
|
313 |
-
$field = wp_cache_get( 'load_field/key=' . $field_key, 'acf' );
|
314 |
-
}
|
315 |
-
|
316 |
-
|
317 |
-
// load from DB
|
318 |
-
if( !$field )
|
319 |
-
{
|
320 |
-
// vars
|
321 |
-
global $wpdb;
|
322 |
-
|
323 |
-
|
324 |
-
// get field from postmeta
|
325 |
-
$sql = $wpdb->prepare("SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = %s", $field_key);
|
326 |
-
|
327 |
-
if( $post_id )
|
328 |
-
{
|
329 |
-
$sql .= $wpdb->prepare("AND post_id = %d", $post_id);
|
330 |
-
}
|
331 |
-
|
332 |
-
$rows = $wpdb->get_results( $sql, ARRAY_A );
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
// nothing found?
|
337 |
-
if( !empty($rows) )
|
338 |
-
{
|
339 |
-
$row = $rows[0];
|
340 |
-
|
341 |
-
|
342 |
-
/*
|
343 |
-
* WPML compatibility
|
344 |
-
*
|
345 |
-
* If WPML is active, and the $post_id (Field group ID) was not defined,
|
346 |
-
* it is assumed that the load_field functio has been called from the API (front end).
|
347 |
-
* In this case, the field group ID is never known and we can check for the correct translated field group
|
348 |
-
*/
|
349 |
-
|
350 |
-
if( defined('ICL_LANGUAGE_CODE') && !$post_id )
|
351 |
-
{
|
352 |
-
$wpml_post_id = icl_object_id($row['post_id'], 'acf', true, ICL_LANGUAGE_CODE);
|
353 |
-
|
354 |
-
foreach( $rows as $r )
|
355 |
-
{
|
356 |
-
if( $r['post_id'] == $wpml_post_id )
|
357 |
-
{
|
358 |
-
// this row is a field from the translated field group
|
359 |
-
$row = $r;
|
360 |
-
}
|
361 |
-
}
|
362 |
-
}
|
363 |
-
|
364 |
-
|
365 |
-
// return field if it is not in a trashed field group
|
366 |
-
if( get_post_status( $row['post_id'] ) != "trash" )
|
367 |
-
{
|
368 |
-
$field = $row['meta_value'];
|
369 |
-
$field = maybe_unserialize( $field );
|
370 |
-
$field = maybe_unserialize( $field ); // run again for WPML
|
371 |
-
|
372 |
-
|
373 |
-
// add field_group ID
|
374 |
-
$field['field_group'] = $row['post_id'];
|
375 |
-
}
|
376 |
-
|
377 |
-
}
|
378 |
-
}
|
379 |
-
|
380 |
-
|
381 |
-
// apply filters
|
382 |
-
$field = apply_filters('acf/load_field_defaults', $field);
|
383 |
-
|
384 |
-
|
385 |
-
// apply filters
|
386 |
-
foreach( array('type', 'name', 'key') as $key )
|
387 |
-
{
|
388 |
-
// run filters
|
389 |
-
$field = apply_filters('acf/load_field/' . $key . '=' . $field[ $key ], $field); // new filter
|
390 |
-
}
|
391 |
-
|
392 |
-
|
393 |
-
// set cache
|
394 |
-
wp_cache_set( 'load_field/key=' . $field_key, $field, 'acf' );
|
395 |
-
|
396 |
-
return $field;
|
397 |
-
}
|
398 |
-
|
399 |
-
|
400 |
-
/*
|
401 |
-
* load_field_defaults
|
402 |
-
*
|
403 |
-
* @description: applies default values to the field after it has been loaded
|
404 |
-
* @since 3.5.1
|
405 |
-
* @created: 14/10/12
|
406 |
-
*/
|
407 |
-
|
408 |
-
function load_field_defaults( $field )
|
409 |
-
{
|
410 |
-
// validate $field
|
411 |
-
if( !is_array($field) )
|
412 |
-
{
|
413 |
-
$field = array();
|
414 |
-
}
|
415 |
-
|
416 |
-
|
417 |
-
// defaults
|
418 |
-
$defaults = array(
|
419 |
-
'key' => '',
|
420 |
-
'label' => '',
|
421 |
-
'name' => '',
|
422 |
-
'_name' => '',
|
423 |
-
'type' => 'text',
|
424 |
-
'order_no' => 1,
|
425 |
-
'instructions' => '',
|
426 |
-
'required' => 0,
|
427 |
-
'id' => '',
|
428 |
-
'class' => '',
|
429 |
-
'conditional_logic' => array(
|
430 |
-
'status' => 0,
|
431 |
-
'allorany' => 'all',
|
432 |
-
'rules' => 0
|
433 |
-
),
|
434 |
-
);
|
435 |
-
$field = array_merge($defaults, $field);
|
436 |
-
|
437 |
-
|
438 |
-
// Parse Values
|
439 |
-
$field = apply_filters( 'acf/parse_types', $field );
|
440 |
-
|
441 |
-
|
442 |
-
// field specific defaults
|
443 |
-
$field = apply_filters('acf/load_field_defaults/type=' . $field['type'] , $field);
|
444 |
-
|
445 |
-
|
446 |
-
// class
|
447 |
-
if( !$field['class'] )
|
448 |
-
{
|
449 |
-
$field['class'] = $field['type'];
|
450 |
-
}
|
451 |
-
|
452 |
-
|
453 |
-
// id
|
454 |
-
if( !$field['id'] )
|
455 |
-
{
|
456 |
-
$id = $field['name'];
|
457 |
-
$id = str_replace('][', '_', $id);
|
458 |
-
$id = str_replace('fields[', '', $id);
|
459 |
-
$id = str_replace('[', '-', $id); // location rules (select) does'nt have "fields[" in it
|
460 |
-
$id = str_replace(']', '', $id);
|
461 |
-
|
462 |
-
$field['id'] = 'acf-field-' . $id;
|
463 |
-
}
|
464 |
-
|
465 |
-
|
466 |
-
// _name
|
467 |
-
if( !$field['_name'] )
|
468 |
-
{
|
469 |
-
$field['_name'] = $field['name'];
|
470 |
-
}
|
471 |
-
|
472 |
-
|
473 |
-
// clean up conditional logic keys
|
474 |
-
if( !empty($field['conditional_logic']['rules']) )
|
475 |
-
{
|
476 |
-
$field['conditional_logic']['rules'] = array_values($field['conditional_logic']['rules']);
|
477 |
-
}
|
478 |
-
|
479 |
-
|
480 |
-
// return
|
481 |
-
return $field;
|
482 |
-
}
|
483 |
-
|
484 |
-
|
485 |
-
/*
|
486 |
-
* update_field
|
487 |
-
*
|
488 |
-
* @description: updates a field in the database
|
489 |
-
* @since: 3.6
|
490 |
-
* @created: 24/01/13
|
491 |
-
*/
|
492 |
-
|
493 |
-
function update_field( $field, $post_id )
|
494 |
-
{
|
495 |
-
// sanitize field name
|
496 |
-
// - http://support.advancedcustomfields.com/discussion/5262/sanitize_title-on-field-name
|
497 |
-
// - issue with camel case! Replaced with JS
|
498 |
-
//$field['name'] = sanitize_title( $field['name'] );
|
499 |
-
|
500 |
-
|
501 |
-
// filters
|
502 |
-
$field = apply_filters('acf/update_field/type=' . $field['type'], $field, $post_id ); // new filter
|
503 |
-
|
504 |
-
|
505 |
-
// clear cache
|
506 |
-
wp_cache_delete( 'load_field/key=' . $field['key'], 'acf' );
|
507 |
-
|
508 |
-
|
509 |
-
// save
|
510 |
-
update_post_meta( $post_id, $field['key'], $field );
|
511 |
-
}
|
512 |
-
|
513 |
-
|
514 |
-
/*
|
515 |
-
* delete_field
|
516 |
-
*
|
517 |
-
* @description: deletes a field in the database
|
518 |
-
* @since: 3.6
|
519 |
-
* @created: 24/01/13
|
520 |
-
*/
|
521 |
-
|
522 |
-
function delete_field( $post_id, $field_key )
|
523 |
-
{
|
524 |
-
// clear cache
|
525 |
-
wp_cache_delete( 'load_field/key=' . $field_key, 'acf' );
|
526 |
-
|
527 |
-
|
528 |
-
// delete
|
529 |
-
delete_post_meta($post_id, $field_key);
|
530 |
-
}
|
531 |
-
|
532 |
-
|
533 |
-
/*
|
534 |
-
* create_field
|
535 |
-
*
|
536 |
-
* @description: renders a field into a HTML interface
|
537 |
-
* @since: 3.6
|
538 |
-
* @created: 23/01/13
|
539 |
-
*/
|
540 |
-
|
541 |
-
function create_field( $field )
|
542 |
-
{
|
543 |
-
// load defaults
|
544 |
-
// if field was loaded from db, these default will already be appield
|
545 |
-
// if field was written by hand, it may be missing keys
|
546 |
-
$field = apply_filters('acf/load_field_defaults', $field);
|
547 |
-
|
548 |
-
|
549 |
-
// create field specific html
|
550 |
-
do_action('acf/create_field/type=' . $field['type'], $field);
|
551 |
-
|
552 |
-
|
553 |
-
// conditional logic
|
554 |
-
if( $field['conditional_logic']['status'] )
|
555 |
-
{
|
556 |
-
$field['conditional_logic']['field'] = $field['key'];
|
557 |
-
|
558 |
-
?>
|
559 |
-
<script type="text/javascript">
|
560 |
-
(function($) {
|
561 |
-
|
562 |
-
if( typeof acf !== 'undefined' )
|
563 |
-
{
|
564 |
-
acf.conditional_logic.items.push(<?php echo json_encode($field['conditional_logic']); ?>);
|
565 |
-
}
|
566 |
-
|
567 |
-
})(jQuery);
|
568 |
-
</script>
|
569 |
-
<?php
|
570 |
-
}
|
571 |
-
|
572 |
-
}
|
573 |
-
|
574 |
-
|
575 |
-
/*
|
576 |
-
* create_field_options
|
577 |
-
*
|
578 |
-
* @description: renders a field into a HTML interface
|
579 |
-
* @since: 3.6
|
580 |
-
* @created: 23/01/13
|
581 |
-
*/
|
582 |
-
|
583 |
-
function create_field_options($field)
|
584 |
-
{
|
585 |
-
// load standard + field specific defaults
|
586 |
-
$field = apply_filters('acf/load_field_defaults', $field);
|
587 |
-
|
588 |
-
// render HTML
|
589 |
-
do_action('acf/create_field_options/type=' . $field['type'], $field);
|
590 |
-
}
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
}
|
595 |
-
|
596 |
-
new acf_field_functions();
|
597 |
-
|
598 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* Field Functions
|
5 |
+
*
|
6 |
+
* @description: The API for all fields
|
7 |
+
* @since: 3.6
|
8 |
+
* @created: 23/01/13
|
9 |
+
*/
|
10 |
+
|
11 |
+
class acf_field_functions
|
12 |
+
{
|
13 |
+
|
14 |
+
/*
|
15 |
+
* __construct
|
16 |
+
*
|
17 |
+
* @description:
|
18 |
+
* @since 3.1.8
|
19 |
+
* @created: 23/06/12
|
20 |
+
*/
|
21 |
+
|
22 |
+
function __construct()
|
23 |
+
{
|
24 |
+
//value
|
25 |
+
add_filter('acf/load_value', array($this, 'load_value'), 5, 3);
|
26 |
+
add_action('acf/update_value', array($this, 'update_value'), 5, 3);
|
27 |
+
add_action('acf/delete_value', array($this, 'delete_value'), 5, 2);
|
28 |
+
add_action('acf/format_value', array($this, 'format_value'), 5, 3);
|
29 |
+
add_action('acf/format_value_for_api', array($this, 'format_value_for_api'), 5, 3);
|
30 |
+
|
31 |
+
|
32 |
+
// field
|
33 |
+
add_filter('acf/load_field', array($this, 'load_field'), 5, 3);
|
34 |
+
add_action('acf/update_field', array($this, 'update_field'), 5, 2);
|
35 |
+
add_action('acf/delete_field', array($this, 'delete_field'), 5, 2);
|
36 |
+
add_action('acf/create_field', array($this, 'create_field'), 5, 1);
|
37 |
+
add_action('acf/create_field_options', array($this, 'create_field_options'), 5, 1);
|
38 |
+
|
39 |
+
|
40 |
+
// extra
|
41 |
+
add_filter('acf/load_field_defaults', array($this, 'load_field_defaults'), 5, 1);
|
42 |
+
}
|
43 |
+
|
44 |
+
|
45 |
+
/*
|
46 |
+
* load_value
|
47 |
+
*
|
48 |
+
* @description: loads basic value from the db
|
49 |
+
* @since: 3.6
|
50 |
+
* @created: 23/01/13
|
51 |
+
*/
|
52 |
+
|
53 |
+
function load_value($value, $post_id, $field)
|
54 |
+
{
|
55 |
+
$found = false;
|
56 |
+
$cache = wp_cache_get( 'load_value/post_id=' . $post_id . '/name=' . $field['name'], 'acf', false, $found );
|
57 |
+
|
58 |
+
if( $found )
|
59 |
+
{
|
60 |
+
return $cache;
|
61 |
+
}
|
62 |
+
|
63 |
+
|
64 |
+
// set default value
|
65 |
+
$value = false;
|
66 |
+
|
67 |
+
|
68 |
+
// if $post_id is a string, then it is used in the everything fields and can be found in the options table
|
69 |
+
if( is_numeric($post_id) )
|
70 |
+
{
|
71 |
+
$v = get_post_meta( $post_id, $field['name'], false );
|
72 |
+
|
73 |
+
// value is an array
|
74 |
+
if( isset($v[0]) )
|
75 |
+
{
|
76 |
+
$value = $v[0];
|
77 |
+
}
|
78 |
+
|
79 |
+
}
|
80 |
+
elseif( strpos($post_id, 'user_') !== false )
|
81 |
+
{
|
82 |
+
$user_id = str_replace('user_', '', $post_id);
|
83 |
+
|
84 |
+
$v = get_user_meta( $user_id, $field['name'], false );
|
85 |
+
|
86 |
+
// value is an array
|
87 |
+
if( isset($v[0]) )
|
88 |
+
{
|
89 |
+
$value = $v[0];
|
90 |
+
}
|
91 |
+
|
92 |
+
}
|
93 |
+
else
|
94 |
+
{
|
95 |
+
$v = get_option( $post_id . '_' . $field['name'], false );
|
96 |
+
|
97 |
+
if( !is_null($value) )
|
98 |
+
{
|
99 |
+
$value = $v;
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
|
104 |
+
// no value?
|
105 |
+
if( $value === false )
|
106 |
+
{
|
107 |
+
if( isset($field['default_value']) && $field['default_value'] !== "" )
|
108 |
+
{
|
109 |
+
$value = $field['default_value'];
|
110 |
+
}
|
111 |
+
}
|
112 |
+
|
113 |
+
|
114 |
+
// if value was duplicated, it may now be a serialized string!
|
115 |
+
$value = maybe_unserialize($value);
|
116 |
+
|
117 |
+
|
118 |
+
// apply filters
|
119 |
+
foreach( array('type', 'name', 'key') as $key )
|
120 |
+
{
|
121 |
+
// run filters
|
122 |
+
$value = apply_filters('acf/load_value/' . $key . '=' . $field[ $key ], $value, $post_id, $field); // new filter
|
123 |
+
}
|
124 |
+
|
125 |
+
|
126 |
+
//update cache
|
127 |
+
wp_cache_set( 'load_value/post_id=' . $post_id . '/name=' . $field['name'], $value, 'acf' );
|
128 |
+
|
129 |
+
|
130 |
+
return $value;
|
131 |
+
}
|
132 |
+
|
133 |
+
|
134 |
+
/*
|
135 |
+
* format_value
|
136 |
+
*
|
137 |
+
* @description: uses the basic value and allows the field type to format it
|
138 |
+
* @since: 3.6
|
139 |
+
* @created: 26/01/13
|
140 |
+
*/
|
141 |
+
|
142 |
+
function format_value( $value, $post_id, $field )
|
143 |
+
{
|
144 |
+
$value = apply_filters('acf/format_value/type=' . $field['type'], $value, $post_id, $field);
|
145 |
+
|
146 |
+
return $value;
|
147 |
+
}
|
148 |
+
|
149 |
+
|
150 |
+
/*
|
151 |
+
* format_value_for_api
|
152 |
+
*
|
153 |
+
* @description: uses the basic value and allows the field type to format it or the api functions
|
154 |
+
* @since: 3.6
|
155 |
+
* @created: 26/01/13
|
156 |
+
*/
|
157 |
+
|
158 |
+
function format_value_for_api( $value, $post_id, $field )
|
159 |
+
{
|
160 |
+
$value = apply_filters('acf/format_value_for_api/type=' . $field['type'], $value, $post_id, $field);
|
161 |
+
|
162 |
+
return $value;
|
163 |
+
}
|
164 |
+
|
165 |
+
|
166 |
+
/*
|
167 |
+
* update_value
|
168 |
+
*
|
169 |
+
* updates a value into the db
|
170 |
+
*
|
171 |
+
* @type action
|
172 |
+
* @date 23/01/13
|
173 |
+
*
|
174 |
+
* @param {mixed} $value the value to be saved
|
175 |
+
* @param {int} $post_id the post ID to save the value to
|
176 |
+
* @param {array} $field the field array
|
177 |
+
* @param {boolean} $exact allows the update_value filter to be skipped
|
178 |
+
* @return N/A
|
179 |
+
*/
|
180 |
+
|
181 |
+
function update_value( $value, $post_id, $field )
|
182 |
+
{
|
183 |
+
|
184 |
+
// strip slashes
|
185 |
+
// - not needed? http://support.advancedcustomfields.com/discussion/3168/backslashes-stripped-in-wysiwyg-filed
|
186 |
+
//if( get_magic_quotes_gpc() )
|
187 |
+
//{
|
188 |
+
$value = stripslashes_deep($value);
|
189 |
+
//}
|
190 |
+
|
191 |
+
|
192 |
+
// apply filters
|
193 |
+
foreach( array('key', 'name', 'type') as $key )
|
194 |
+
{
|
195 |
+
// run filters
|
196 |
+
$value = apply_filters('acf/update_value/' . $key . '=' . $field[ $key ], $value, $post_id, $field); // new filter
|
197 |
+
}
|
198 |
+
|
199 |
+
|
200 |
+
// if $post_id is a string, then it is used in the everything fields and can be found in the options table
|
201 |
+
if( is_numeric($post_id) )
|
202 |
+
{
|
203 |
+
// allow ACF to save to revision!
|
204 |
+
update_metadata('post', $post_id, $field['name'], $value );
|
205 |
+
update_metadata('post', $post_id, '_' . $field['name'], $field['key']);
|
206 |
+
}
|
207 |
+
elseif( strpos($post_id, 'user_') !== false )
|
208 |
+
{
|
209 |
+
$user_id = str_replace('user_', '', $post_id);
|
210 |
+
update_metadata('user', $user_id, $field['name'], $value);
|
211 |
+
update_metadata('user', $user_id, '_' . $field['name'], $field['key']);
|
212 |
+
}
|
213 |
+
else
|
214 |
+
{
|
215 |
+
// for some reason, update_option does not use stripslashes_deep.
|
216 |
+
// update_metadata -> http://core.trac.wordpress.org/browser/tags/3.4.2/wp-includes/meta.php#L82: line 101 (does use stripslashes_deep)
|
217 |
+
// update_option -> http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/option.php#L0: line 215 (does not use stripslashes_deep)
|
218 |
+
$value = stripslashes_deep($value);
|
219 |
+
|
220 |
+
$this->update_option( $post_id . '_' . $field['name'], $value );
|
221 |
+
$this->update_option( '_' . $post_id . '_' . $field['name'], $field['key'] );
|
222 |
+
}
|
223 |
+
|
224 |
+
|
225 |
+
// update the cache
|
226 |
+
wp_cache_set( 'load_value/post_id=' . $post_id . '/name=' . $field['name'], $value, 'acf' );
|
227 |
+
|
228 |
+
}
|
229 |
+
|
230 |
+
|
231 |
+
/*
|
232 |
+
* update_option
|
233 |
+
*
|
234 |
+
* This function is a wrapper for the WP update_option but provides logic for a 'no' autoload
|
235 |
+
*
|
236 |
+
* @type function
|
237 |
+
* @date 4/01/2014
|
238 |
+
* @since 5.0.0
|
239 |
+
*
|
240 |
+
* @param $option (string)
|
241 |
+
* @param $value (mixed)
|
242 |
+
* @return (boolean)
|
243 |
+
*/
|
244 |
+
|
245 |
+
function update_option( $option = '', $value = false, $autoload = 'no' ) {
|
246 |
+
|
247 |
+
// vars
|
248 |
+
$deprecated = '';
|
249 |
+
$return = false;
|
250 |
+
|
251 |
+
|
252 |
+
if( get_option($option) !== false )
|
253 |
+
{
|
254 |
+
$return = update_option( $option, $value );
|
255 |
+
}
|
256 |
+
else
|
257 |
+
{
|
258 |
+
$return = add_option( $option, $value, $deprecated, $autoload );
|
259 |
+
}
|
260 |
+
|
261 |
+
|
262 |
+
// return
|
263 |
+
return $return;
|
264 |
+
|
265 |
+
}
|
266 |
+
|
267 |
+
|
268 |
+
/*
|
269 |
+
* delete_value
|
270 |
+
*
|
271 |
+
* @description: deletes a value from the database
|
272 |
+
* @since: 3.6
|
273 |
+
* @created: 23/01/13
|
274 |
+
*/
|
275 |
+
|
276 |
+
function delete_value( $post_id, $key )
|
277 |
+
{
|
278 |
+
// if $post_id is a string, then it is used in the everything fields and can be found in the options table
|
279 |
+
if( is_numeric($post_id) )
|
280 |
+
{
|
281 |
+
delete_post_meta( $post_id, $key );
|
282 |
+
delete_post_meta( $post_id, '_' . $key );
|
283 |
+
}
|
284 |
+
elseif( strpos($post_id, 'user_') !== false )
|
285 |
+
{
|
286 |
+
$post_id = str_replace('user_', '', $post_id);
|
287 |
+
delete_user_meta( $post_id, $key );
|
288 |
+
delete_user_meta( $post_id, '_' . $key );
|
289 |
+
}
|
290 |
+
else
|
291 |
+
{
|
292 |
+
delete_option( $post_id . '_' . $key );
|
293 |
+
delete_option( '_' . $post_id . '_' . $key );
|
294 |
+
}
|
295 |
+
|
296 |
+
wp_cache_delete( 'load_value/post_id=' . $post_id . '/name=' . $key, 'acf' );
|
297 |
+
}
|
298 |
+
|
299 |
+
|
300 |
+
/*
|
301 |
+
* load_field
|
302 |
+
*
|
303 |
+
* @description: loads a field from the database
|
304 |
+
* @since 3.5.1
|
305 |
+
* @created: 14/10/12
|
306 |
+
*/
|
307 |
+
|
308 |
+
function load_field( $field, $field_key, $post_id = false )
|
309 |
+
{
|
310 |
+
// load cache
|
311 |
+
if( !$field )
|
312 |
+
{
|
313 |
+
$field = wp_cache_get( 'load_field/key=' . $field_key, 'acf' );
|
314 |
+
}
|
315 |
+
|
316 |
+
|
317 |
+
// load from DB
|
318 |
+
if( !$field )
|
319 |
+
{
|
320 |
+
// vars
|
321 |
+
global $wpdb;
|
322 |
+
|
323 |
+
|
324 |
+
// get field from postmeta
|
325 |
+
$sql = $wpdb->prepare("SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = %s", $field_key);
|
326 |
+
|
327 |
+
if( $post_id )
|
328 |
+
{
|
329 |
+
$sql .= $wpdb->prepare("AND post_id = %d", $post_id);
|
330 |
+
}
|
331 |
+
|
332 |
+
$rows = $wpdb->get_results( $sql, ARRAY_A );
|
333 |
+
|
334 |
+
|
335 |
+
|
336 |
+
// nothing found?
|
337 |
+
if( !empty($rows) )
|
338 |
+
{
|
339 |
+
$row = $rows[0];
|
340 |
+
|
341 |
+
|
342 |
+
/*
|
343 |
+
* WPML compatibility
|
344 |
+
*
|
345 |
+
* If WPML is active, and the $post_id (Field group ID) was not defined,
|
346 |
+
* it is assumed that the load_field functio has been called from the API (front end).
|
347 |
+
* In this case, the field group ID is never known and we can check for the correct translated field group
|
348 |
+
*/
|
349 |
+
|
350 |
+
if( defined('ICL_LANGUAGE_CODE') && !$post_id )
|
351 |
+
{
|
352 |
+
$wpml_post_id = icl_object_id($row['post_id'], 'acf', true, ICL_LANGUAGE_CODE);
|
353 |
+
|
354 |
+
foreach( $rows as $r )
|
355 |
+
{
|
356 |
+
if( $r['post_id'] == $wpml_post_id )
|
357 |
+
{
|
358 |
+
// this row is a field from the translated field group
|
359 |
+
$row = $r;
|
360 |
+
}
|
361 |
+
}
|
362 |
+
}
|
363 |
+
|
364 |
+
|
365 |
+
// return field if it is not in a trashed field group
|
366 |
+
if( get_post_status( $row['post_id'] ) != "trash" )
|
367 |
+
{
|
368 |
+
$field = $row['meta_value'];
|
369 |
+
$field = maybe_unserialize( $field );
|
370 |
+
$field = maybe_unserialize( $field ); // run again for WPML
|
371 |
+
|
372 |
+
|
373 |
+
// add field_group ID
|
374 |
+
$field['field_group'] = $row['post_id'];
|
375 |
+
}
|
376 |
+
|
377 |
+
}
|
378 |
+
}
|
379 |
+
|
380 |
+
|
381 |
+
// apply filters
|
382 |
+
$field = apply_filters('acf/load_field_defaults', $field);
|
383 |
+
|
384 |
+
|
385 |
+
// apply filters
|
386 |
+
foreach( array('type', 'name', 'key') as $key )
|
387 |
+
{
|
388 |
+
// run filters
|
389 |
+
$field = apply_filters('acf/load_field/' . $key . '=' . $field[ $key ], $field); // new filter
|
390 |
+
}
|
391 |
+
|
392 |
+
|
393 |
+
// set cache
|
394 |
+
wp_cache_set( 'load_field/key=' . $field_key, $field, 'acf' );
|
395 |
+
|
396 |
+
return $field;
|
397 |
+
}
|
398 |
+
|
399 |
+
|
400 |
+
/*
|
401 |
+
* load_field_defaults
|
402 |
+
*
|
403 |
+
* @description: applies default values to the field after it has been loaded
|
404 |
+
* @since 3.5.1
|
405 |
+
* @created: 14/10/12
|
406 |
+
*/
|
407 |
+
|
408 |
+
function load_field_defaults( $field )
|
409 |
+
{
|
410 |
+
// validate $field
|
411 |
+
if( !is_array($field) )
|
412 |
+
{
|
413 |
+
$field = array();
|
414 |
+
}
|
415 |
+
|
416 |
+
|
417 |
+
// defaults
|
418 |
+
$defaults = array(
|
419 |
+
'key' => '',
|
420 |
+
'label' => '',
|
421 |
+
'name' => '',
|
422 |
+
'_name' => '',
|
423 |
+
'type' => 'text',
|
424 |
+
'order_no' => 1,
|
425 |
+
'instructions' => '',
|
426 |
+
'required' => 0,
|
427 |
+
'id' => '',
|
428 |
+
'class' => '',
|
429 |
+
'conditional_logic' => array(
|
430 |
+
'status' => 0,
|
431 |
+
'allorany' => 'all',
|
432 |
+
'rules' => 0
|
433 |
+
),
|
434 |
+
);
|
435 |
+
$field = array_merge($defaults, $field);
|
436 |
+
|
437 |
+
|
438 |
+
// Parse Values
|
439 |
+
$field = apply_filters( 'acf/parse_types', $field );
|
440 |
+
|
441 |
+
|
442 |
+
// field specific defaults
|
443 |
+
$field = apply_filters('acf/load_field_defaults/type=' . $field['type'] , $field);
|
444 |
+
|
445 |
+
|
446 |
+
// class
|
447 |
+
if( !$field['class'] )
|
448 |
+
{
|
449 |
+
$field['class'] = $field['type'];
|
450 |
+
}
|
451 |
+
|
452 |
+
|
453 |
+
// id
|
454 |
+
if( !$field['id'] )
|
455 |
+
{
|
456 |
+
$id = $field['name'];
|
457 |
+
$id = str_replace('][', '_', $id);
|
458 |
+
$id = str_replace('fields[', '', $id);
|
459 |
+
$id = str_replace('[', '-', $id); // location rules (select) does'nt have "fields[" in it
|
460 |
+
$id = str_replace(']', '', $id);
|
461 |
+
|
462 |
+
$field['id'] = 'acf-field-' . $id;
|
463 |
+
}
|
464 |
+
|
465 |
+
|
466 |
+
// _name
|
467 |
+
if( !$field['_name'] )
|
468 |
+
{
|
469 |
+
$field['_name'] = $field['name'];
|
470 |
+
}
|
471 |
+
|
472 |
+
|
473 |
+
// clean up conditional logic keys
|
474 |
+
if( !empty($field['conditional_logic']['rules']) )
|
475 |
+
{
|
476 |
+
$field['conditional_logic']['rules'] = array_values($field['conditional_logic']['rules']);
|
477 |
+
}
|
478 |
+
|
479 |
+
|
480 |
+
// return
|
481 |
+
return $field;
|
482 |
+
}
|
483 |
+
|
484 |
+
|
485 |
+
/*
|
486 |
+
* update_field
|
487 |
+
*
|
488 |
+
* @description: updates a field in the database
|
489 |
+
* @since: 3.6
|
490 |
+
* @created: 24/01/13
|
491 |
+
*/
|
492 |
+
|
493 |
+
function update_field( $field, $post_id )
|
494 |
+
{
|
495 |
+
// sanitize field name
|
496 |
+
// - http://support.advancedcustomfields.com/discussion/5262/sanitize_title-on-field-name
|
497 |
+
// - issue with camel case! Replaced with JS
|
498 |
+
//$field['name'] = sanitize_title( $field['name'] );
|
499 |
+
|
500 |
+
|
501 |
+
// filters
|
502 |
+
$field = apply_filters('acf/update_field/type=' . $field['type'], $field, $post_id ); // new filter
|
503 |
+
|
504 |
+
|
505 |
+
// clear cache
|
506 |
+
wp_cache_delete( 'load_field/key=' . $field['key'], 'acf' );
|
507 |
+
|
508 |
+
|
509 |
+
// save
|
510 |
+
update_post_meta( $post_id, $field['key'], $field );
|
511 |
+
}
|
512 |
+
|
513 |
+
|
514 |
+
/*
|
515 |
+
* delete_field
|
516 |
+
*
|
517 |
+
* @description: deletes a field in the database
|
518 |
+
* @since: 3.6
|
519 |
+
* @created: 24/01/13
|
520 |
+
*/
|
521 |
+
|
522 |
+
function delete_field( $post_id, $field_key )
|
523 |
+
{
|
524 |
+
// clear cache
|
525 |
+
wp_cache_delete( 'load_field/key=' . $field_key, 'acf' );
|
526 |
+
|
527 |
+
|
528 |
+
// delete
|
529 |
+
delete_post_meta($post_id, $field_key);
|
530 |
+
}
|
531 |
+
|
532 |
+
|
533 |
+
/*
|
534 |
+
* create_field
|
535 |
+
*
|
536 |
+
* @description: renders a field into a HTML interface
|
537 |
+
* @since: 3.6
|
538 |
+
* @created: 23/01/13
|
539 |
+
*/
|
540 |
+
|
541 |
+
function create_field( $field )
|
542 |
+
{
|
543 |
+
// load defaults
|
544 |
+
// if field was loaded from db, these default will already be appield
|
545 |
+
// if field was written by hand, it may be missing keys
|
546 |
+
$field = apply_filters('acf/load_field_defaults', $field);
|
547 |
+
|
548 |
+
|
549 |
+
// create field specific html
|
550 |
+
do_action('acf/create_field/type=' . $field['type'], $field);
|
551 |
+
|
552 |
+
|
553 |
+
// conditional logic
|
554 |
+
if( $field['conditional_logic']['status'] )
|
555 |
+
{
|
556 |
+
$field['conditional_logic']['field'] = $field['key'];
|
557 |
+
|
558 |
+
?>
|
559 |
+
<script type="text/javascript">
|
560 |
+
(function($) {
|
561 |
+
|
562 |
+
if( typeof acf !== 'undefined' )
|
563 |
+
{
|
564 |
+
acf.conditional_logic.items.push(<?php echo json_encode($field['conditional_logic']); ?>);
|
565 |
+
}
|
566 |
+
|
567 |
+
})(jQuery);
|
568 |
+
</script>
|
569 |
+
<?php
|
570 |
+
}
|
571 |
+
|
572 |
+
}
|
573 |
+
|
574 |
+
|
575 |
+
/*
|
576 |
+
* create_field_options
|
577 |
+
*
|
578 |
+
* @description: renders a field into a HTML interface
|
579 |
+
* @since: 3.6
|
580 |
+
* @created: 23/01/13
|
581 |
+
*/
|
582 |
+
|
583 |
+
function create_field_options($field)
|
584 |
+
{
|
585 |
+
// load standard + field specific defaults
|
586 |
+
$field = apply_filters('acf/load_field_defaults', $field);
|
587 |
+
|
588 |
+
// render HTML
|
589 |
+
do_action('acf/create_field_options/type=' . $field['type'], $field);
|
590 |
+
}
|
591 |
+
|
592 |
+
|
593 |
+
|
594 |
+
}
|
595 |
+
|
596 |
+
new acf_field_functions();
|
597 |
+
|
598 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/fields/checkbox.php
CHANGED
@@ -1,210 +1,210 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_field_checkbox extends acf_field
|
4 |
-
{
|
5 |
-
|
6 |
-
/*
|
7 |
-
* __construct
|
8 |
-
*
|
9 |
-
* Set name / label needed for actions / filters
|
10 |
-
*
|
11 |
-
* @since 3.6
|
12 |
-
* @date 23/01/13
|
13 |
-
*/
|
14 |
-
|
15 |
-
function __construct()
|
16 |
-
{
|
17 |
-
// vars
|
18 |
-
$this->name = 'checkbox';
|
19 |
-
$this->label = __("Checkbox",'acf');
|
20 |
-
$this->category = __("Choice",'acf');
|
21 |
-
$this->defaults = array(
|
22 |
-
'layout' => 'vertical',
|
23 |
-
'choices' => array(),
|
24 |
-
'default_value' => '',
|
25 |
-
);
|
26 |
-
|
27 |
-
|
28 |
-
// do not delete!
|
29 |
-
parent::__construct();
|
30 |
-
}
|
31 |
-
|
32 |
-
|
33 |
-
/*
|
34 |
-
* create_field()
|
35 |
-
*
|
36 |
-
* Create the HTML interface for your field
|
37 |
-
*
|
38 |
-
* @param $field - an array holding all the field's data
|
39 |
-
*
|
40 |
-
* @type action
|
41 |
-
* @since 3.6
|
42 |
-
* @date 23/01/13
|
43 |
-
*/
|
44 |
-
|
45 |
-
function create_field( $field )
|
46 |
-
{
|
47 |
-
// value must be array
|
48 |
-
if( !is_array($field['value']) )
|
49 |
-
{
|
50 |
-
// perhaps this is a default value with new lines in it?
|
51 |
-
if( strpos($field['value'], "\n") !== false )
|
52 |
-
{
|
53 |
-
// found multiple lines, explode it
|
54 |
-
$field['value'] = explode("\n", $field['value']);
|
55 |
-
}
|
56 |
-
else
|
57 |
-
{
|
58 |
-
$field['value'] = array( $field['value'] );
|
59 |
-
}
|
60 |
-
}
|
61 |
-
|
62 |
-
|
63 |
-
// trim value
|
64 |
-
$field['value'] = array_map('trim', $field['value']);
|
65 |
-
|
66 |
-
|
67 |
-
// vars
|
68 |
-
$i = 0;
|
69 |
-
$e = '<input type="hidden" name="' . esc_attr($field['name']) . '" value="" />';
|
70 |
-
$e .= '<ul class="acf-checkbox-list ' . esc_attr($field['class']) . ' ' . esc_attr($field['layout']) . '">';
|
71 |
-
|
72 |
-
|
73 |
-
// checkbox saves an array
|
74 |
-
$field['name'] .= '[]';
|
75 |
-
|
76 |
-
|
77 |
-
// foreach choices
|
78 |
-
foreach( $field['choices'] as $key => $value )
|
79 |
-
{
|
80 |
-
// vars
|
81 |
-
$i++;
|
82 |
-
$atts = '';
|
83 |
-
|
84 |
-
|
85 |
-
if( in_array($key, $field['value']) )
|
86 |
-
{
|
87 |
-
$atts = 'checked="yes"';
|
88 |
-
}
|
89 |
-
if( isset($field['disabled']) && in_array($key, $field['disabled']) )
|
90 |
-
{
|
91 |
-
$atts .= ' disabled="true"';
|
92 |
-
}
|
93 |
-
|
94 |
-
|
95 |
-
// each checkbox ID is generated with the $key, however, the first checkbox must not use $key so that it matches the field's label for attribute
|
96 |
-
$id = $field['id'];
|
97 |
-
|
98 |
-
if( $i > 1 )
|
99 |
-
{
|
100 |
-
$id .= '-' . $key;
|
101 |
-
}
|
102 |
-
|
103 |
-
$e .= '<li><label><input id="' . esc_attr($id) . '" type="checkbox" class="' . esc_attr($field['class']) . '" name="' . esc_attr($field['name']) . '" value="' . esc_attr($key) . '" ' . $atts . ' />' . $value . '</label></li>';
|
104 |
-
}
|
105 |
-
|
106 |
-
$e .= '</ul>';
|
107 |
-
|
108 |
-
|
109 |
-
// return
|
110 |
-
echo $e;
|
111 |
-
}
|
112 |
-
|
113 |
-
|
114 |
-
/*
|
115 |
-
* create_options()
|
116 |
-
*
|
117 |
-
* Create extra options for your field. This is rendered when editing a field.
|
118 |
-
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
119 |
-
*
|
120 |
-
* @type action
|
121 |
-
* @since 3.6
|
122 |
-
* @date 23/01/13
|
123 |
-
*
|
124 |
-
* @param $field - an array holding all the field's data
|
125 |
-
*/
|
126 |
-
|
127 |
-
function create_options( $field )
|
128 |
-
{
|
129 |
-
// vars
|
130 |
-
$key = $field['name'];
|
131 |
-
|
132 |
-
|
133 |
-
// implode checkboxes so they work in a textarea
|
134 |
-
if( is_array($field['choices']) )
|
135 |
-
{
|
136 |
-
foreach( $field['choices'] as $k => $v )
|
137 |
-
{
|
138 |
-
$field['choices'][ $k ] = $k . ' : ' . $v;
|
139 |
-
}
|
140 |
-
$field['choices'] = implode("\n", $field['choices']);
|
141 |
-
}
|
142 |
-
|
143 |
-
?>
|
144 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
145 |
-
<td class="label">
|
146 |
-
<label for=""><?php _e("Choices",'acf'); ?></label>
|
147 |
-
<p><?php _e("Enter each choice on a new line.",'acf'); ?></p>
|
148 |
-
<p><?php _e("For more control, you may specify both a value and label like this:",'acf'); ?></p>
|
149 |
-
<p><?php _e("red : Red",'acf'); ?><br /><?php _e("blue : Blue",'acf'); ?></p>
|
150 |
-
</td>
|
151 |
-
<td>
|
152 |
-
<?php
|
153 |
-
|
154 |
-
do_action('acf/create_field', array(
|
155 |
-
'type' => 'textarea',
|
156 |
-
'class' => 'textarea field_option-choices',
|
157 |
-
'name' => 'fields['.$key.'][choices]',
|
158 |
-
'value' => $field['choices'],
|
159 |
-
));
|
160 |
-
|
161 |
-
?>
|
162 |
-
</td>
|
163 |
-
</tr>
|
164 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
165 |
-
<td class="label">
|
166 |
-
<label><?php _e("Default Value",'acf'); ?></label>
|
167 |
-
<p class="description"><?php _e("Enter each default value on a new line",'acf'); ?></p>
|
168 |
-
</td>
|
169 |
-
<td>
|
170 |
-
<?php
|
171 |
-
|
172 |
-
do_action('acf/create_field', array(
|
173 |
-
'type' => 'textarea',
|
174 |
-
'name' => 'fields['.$key.'][default_value]',
|
175 |
-
'value' => $field['default_value'],
|
176 |
-
));
|
177 |
-
|
178 |
-
?>
|
179 |
-
</td>
|
180 |
-
</tr>
|
181 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
182 |
-
<td class="label">
|
183 |
-
<label for=""><?php _e("Layout",'acf'); ?></label>
|
184 |
-
</td>
|
185 |
-
<td>
|
186 |
-
<?php
|
187 |
-
|
188 |
-
do_action('acf/create_field', array(
|
189 |
-
'type' => 'radio',
|
190 |
-
'name' => 'fields['.$key.'][layout]',
|
191 |
-
'value' => $field['layout'],
|
192 |
-
'layout' => 'horizontal',
|
193 |
-
'choices' => array(
|
194 |
-
'vertical' => __("Vertical",'acf'),
|
195 |
-
'horizontal' => __("Horizontal",'acf')
|
196 |
-
)
|
197 |
-
));
|
198 |
-
|
199 |
-
?>
|
200 |
-
</td>
|
201 |
-
</tr>
|
202 |
-
<?php
|
203 |
-
|
204 |
-
}
|
205 |
-
|
206 |
-
}
|
207 |
-
|
208 |
-
new acf_field_checkbox();
|
209 |
-
|
210 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class acf_field_checkbox extends acf_field
|
4 |
+
{
|
5 |
+
|
6 |
+
/*
|
7 |
+
* __construct
|
8 |
+
*
|
9 |
+
* Set name / label needed for actions / filters
|
10 |
+
*
|
11 |
+
* @since 3.6
|
12 |
+
* @date 23/01/13
|
13 |
+
*/
|
14 |
+
|
15 |
+
function __construct()
|
16 |
+
{
|
17 |
+
// vars
|
18 |
+
$this->name = 'checkbox';
|
19 |
+
$this->label = __("Checkbox",'acf');
|
20 |
+
$this->category = __("Choice",'acf');
|
21 |
+
$this->defaults = array(
|
22 |
+
'layout' => 'vertical',
|
23 |
+
'choices' => array(),
|
24 |
+
'default_value' => '',
|
25 |
+
);
|
26 |
+
|
27 |
+
|
28 |
+
// do not delete!
|
29 |
+
parent::__construct();
|
30 |
+
}
|
31 |
+
|
32 |
+
|
33 |
+
/*
|
34 |
+
* create_field()
|
35 |
+
*
|
36 |
+
* Create the HTML interface for your field
|
37 |
+
*
|
38 |
+
* @param $field - an array holding all the field's data
|
39 |
+
*
|
40 |
+
* @type action
|
41 |
+
* @since 3.6
|
42 |
+
* @date 23/01/13
|
43 |
+
*/
|
44 |
+
|
45 |
+
function create_field( $field )
|
46 |
+
{
|
47 |
+
// value must be array
|
48 |
+
if( !is_array($field['value']) )
|
49 |
+
{
|
50 |
+
// perhaps this is a default value with new lines in it?
|
51 |
+
if( strpos($field['value'], "\n") !== false )
|
52 |
+
{
|
53 |
+
// found multiple lines, explode it
|
54 |
+
$field['value'] = explode("\n", $field['value']);
|
55 |
+
}
|
56 |
+
else
|
57 |
+
{
|
58 |
+
$field['value'] = array( $field['value'] );
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
|
63 |
+
// trim value
|
64 |
+
$field['value'] = array_map('trim', $field['value']);
|
65 |
+
|
66 |
+
|
67 |
+
// vars
|
68 |
+
$i = 0;
|
69 |
+
$e = '<input type="hidden" name="' . esc_attr($field['name']) . '" value="" />';
|
70 |
+
$e .= '<ul class="acf-checkbox-list ' . esc_attr($field['class']) . ' ' . esc_attr($field['layout']) . '">';
|
71 |
+
|
72 |
+
|
73 |
+
// checkbox saves an array
|
74 |
+
$field['name'] .= '[]';
|
75 |
+
|
76 |
+
|
77 |
+
// foreach choices
|
78 |
+
foreach( $field['choices'] as $key => $value )
|
79 |
+
{
|
80 |
+
// vars
|
81 |
+
$i++;
|
82 |
+
$atts = '';
|
83 |
+
|
84 |
+
|
85 |
+
if( in_array($key, $field['value']) )
|
86 |
+
{
|
87 |
+
$atts = 'checked="yes"';
|
88 |
+
}
|
89 |
+
if( isset($field['disabled']) && in_array($key, $field['disabled']) )
|
90 |
+
{
|
91 |
+
$atts .= ' disabled="true"';
|
92 |
+
}
|
93 |
+
|
94 |
+
|
95 |
+
// each checkbox ID is generated with the $key, however, the first checkbox must not use $key so that it matches the field's label for attribute
|
96 |
+
$id = $field['id'];
|
97 |
+
|
98 |
+
if( $i > 1 )
|
99 |
+
{
|
100 |
+
$id .= '-' . $key;
|
101 |
+
}
|
102 |
+
|
103 |
+
$e .= '<li><label><input id="' . esc_attr($id) . '" type="checkbox" class="' . esc_attr($field['class']) . '" name="' . esc_attr($field['name']) . '" value="' . esc_attr($key) . '" ' . $atts . ' />' . $value . '</label></li>';
|
104 |
+
}
|
105 |
+
|
106 |
+
$e .= '</ul>';
|
107 |
+
|
108 |
+
|
109 |
+
// return
|
110 |
+
echo $e;
|
111 |
+
}
|
112 |
+
|
113 |
+
|
114 |
+
/*
|
115 |
+
* create_options()
|
116 |
+
*
|
117 |
+
* Create extra options for your field. This is rendered when editing a field.
|
118 |
+
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
119 |
+
*
|
120 |
+
* @type action
|
121 |
+
* @since 3.6
|
122 |
+
* @date 23/01/13
|
123 |
+
*
|
124 |
+
* @param $field - an array holding all the field's data
|
125 |
+
*/
|
126 |
+
|
127 |
+
function create_options( $field )
|
128 |
+
{
|
129 |
+
// vars
|
130 |
+
$key = $field['name'];
|
131 |
+
|
132 |
+
|
133 |
+
// implode checkboxes so they work in a textarea
|
134 |
+
if( is_array($field['choices']) )
|
135 |
+
{
|
136 |
+
foreach( $field['choices'] as $k => $v )
|
137 |
+
{
|
138 |
+
$field['choices'][ $k ] = $k . ' : ' . $v;
|
139 |
+
}
|
140 |
+
$field['choices'] = implode("\n", $field['choices']);
|
141 |
+
}
|
142 |
+
|
143 |
+
?>
|
144 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
145 |
+
<td class="label">
|
146 |
+
<label for=""><?php _e("Choices",'acf'); ?></label>
|
147 |
+
<p><?php _e("Enter each choice on a new line.",'acf'); ?></p>
|
148 |
+
<p><?php _e("For more control, you may specify both a value and label like this:",'acf'); ?></p>
|
149 |
+
<p><?php _e("red : Red",'acf'); ?><br /><?php _e("blue : Blue",'acf'); ?></p>
|
150 |
+
</td>
|
151 |
+
<td>
|
152 |
+
<?php
|
153 |
+
|
154 |
+
do_action('acf/create_field', array(
|
155 |
+
'type' => 'textarea',
|
156 |
+
'class' => 'textarea field_option-choices',
|
157 |
+
'name' => 'fields['.$key.'][choices]',
|
158 |
+
'value' => $field['choices'],
|
159 |
+
));
|
160 |
+
|
161 |
+
?>
|
162 |
+
</td>
|
163 |
+
</tr>
|
164 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
165 |
+
<td class="label">
|
166 |
+
<label><?php _e("Default Value",'acf'); ?></label>
|
167 |
+
<p class="description"><?php _e("Enter each default value on a new line",'acf'); ?></p>
|
168 |
+
</td>
|
169 |
+
<td>
|
170 |
+
<?php
|
171 |
+
|
172 |
+
do_action('acf/create_field', array(
|
173 |
+
'type' => 'textarea',
|
174 |
+
'name' => 'fields['.$key.'][default_value]',
|
175 |
+
'value' => $field['default_value'],
|
176 |
+
));
|
177 |
+
|
178 |
+
?>
|
179 |
+
</td>
|
180 |
+
</tr>
|
181 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
182 |
+
<td class="label">
|
183 |
+
<label for=""><?php _e("Layout",'acf'); ?></label>
|
184 |
+
</td>
|
185 |
+
<td>
|
186 |
+
<?php
|
187 |
+
|
188 |
+
do_action('acf/create_field', array(
|
189 |
+
'type' => 'radio',
|
190 |
+
'name' => 'fields['.$key.'][layout]',
|
191 |
+
'value' => $field['layout'],
|
192 |
+
'layout' => 'horizontal',
|
193 |
+
'choices' => array(
|
194 |
+
'vertical' => __("Vertical",'acf'),
|
195 |
+
'horizontal' => __("Horizontal",'acf')
|
196 |
+
)
|
197 |
+
));
|
198 |
+
|
199 |
+
?>
|
200 |
+
</td>
|
201 |
+
</tr>
|
202 |
+
<?php
|
203 |
+
|
204 |
+
}
|
205 |
+
|
206 |
+
}
|
207 |
+
|
208 |
+
new acf_field_checkbox();
|
209 |
+
|
210 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/fields/color_picker.php
CHANGED
@@ -1,110 +1,110 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_field_color_picker extends acf_field
|
4 |
-
{
|
5 |
-
|
6 |
-
/*
|
7 |
-
* __construct
|
8 |
-
*
|
9 |
-
* Set name / label needed for actions / filters
|
10 |
-
*
|
11 |
-
* @since 3.6
|
12 |
-
* @date 23/01/13
|
13 |
-
*/
|
14 |
-
|
15 |
-
function __construct()
|
16 |
-
{
|
17 |
-
// vars
|
18 |
-
$this->name = 'color_picker';
|
19 |
-
$this->label = __("Color Picker",'acf');
|
20 |
-
$this->category = __("jQuery",'acf');
|
21 |
-
$this->defaults = array(
|
22 |
-
'default_value' => '',
|
23 |
-
);
|
24 |
-
|
25 |
-
|
26 |
-
// do not delete!
|
27 |
-
parent::__construct();
|
28 |
-
|
29 |
-
}
|
30 |
-
|
31 |
-
|
32 |
-
/*
|
33 |
-
* create_field()
|
34 |
-
*
|
35 |
-
* Create the HTML interface for your field
|
36 |
-
*
|
37 |
-
* @param $field - an array holding all the field's data
|
38 |
-
*
|
39 |
-
* @type action
|
40 |
-
* @since 3.6
|
41 |
-
* @date 23/01/13
|
42 |
-
*/
|
43 |
-
|
44 |
-
function create_field( $field )
|
45 |
-
{
|
46 |
-
// vars
|
47 |
-
$o = array( 'id', 'class', 'name', 'value' );
|
48 |
-
$e = '';
|
49 |
-
|
50 |
-
|
51 |
-
$e .= '<div class="acf-color_picker">';
|
52 |
-
$e .= '<input type="text"';
|
53 |
-
|
54 |
-
foreach( $o as $k )
|
55 |
-
{
|
56 |
-
$e .= ' ' . $k . '="' . esc_attr( $field[ $k ] ) . '"';
|
57 |
-
}
|
58 |
-
|
59 |
-
$e .= ' />';
|
60 |
-
$e .= '</div>';
|
61 |
-
|
62 |
-
|
63 |
-
// return
|
64 |
-
echo $e;
|
65 |
-
}
|
66 |
-
|
67 |
-
|
68 |
-
/*
|
69 |
-
* create_options()
|
70 |
-
*
|
71 |
-
* Create extra options for your field. This is rendered when editing a field.
|
72 |
-
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
73 |
-
*
|
74 |
-
* @type action
|
75 |
-
* @since 3.6
|
76 |
-
* @date 23/01/13
|
77 |
-
*
|
78 |
-
* @param $field - an array holding all the field's data
|
79 |
-
*/
|
80 |
-
|
81 |
-
function create_options( $field )
|
82 |
-
{
|
83 |
-
// vars
|
84 |
-
$key = $field['name'];
|
85 |
-
|
86 |
-
?>
|
87 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
88 |
-
<td class="label">
|
89 |
-
<label><?php _e("Default Value",'acf'); ?></label>
|
90 |
-
</td>
|
91 |
-
<td>
|
92 |
-
<?php
|
93 |
-
do_action('acf/create_field', array(
|
94 |
-
'type' => 'text',
|
95 |
-
'name' => 'fields[' .$key.'][default_value]',
|
96 |
-
'value' => $field['default_value'],
|
97 |
-
'placeholder' => '#ffffff'
|
98 |
-
));
|
99 |
-
?>
|
100 |
-
</td>
|
101 |
-
</tr>
|
102 |
-
<?php
|
103 |
-
|
104 |
-
}
|
105 |
-
|
106 |
-
}
|
107 |
-
|
108 |
-
new acf_field_color_picker();
|
109 |
-
|
110 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class acf_field_color_picker extends acf_field
|
4 |
+
{
|
5 |
+
|
6 |
+
/*
|
7 |
+
* __construct
|
8 |
+
*
|
9 |
+
* Set name / label needed for actions / filters
|
10 |
+
*
|
11 |
+
* @since 3.6
|
12 |
+
* @date 23/01/13
|
13 |
+
*/
|
14 |
+
|
15 |
+
function __construct()
|
16 |
+
{
|
17 |
+
// vars
|
18 |
+
$this->name = 'color_picker';
|
19 |
+
$this->label = __("Color Picker",'acf');
|
20 |
+
$this->category = __("jQuery",'acf');
|
21 |
+
$this->defaults = array(
|
22 |
+
'default_value' => '',
|
23 |
+
);
|
24 |
+
|
25 |
+
|
26 |
+
// do not delete!
|
27 |
+
parent::__construct();
|
28 |
+
|
29 |
+
}
|
30 |
+
|
31 |
+
|
32 |
+
/*
|
33 |
+
* create_field()
|
34 |
+
*
|
35 |
+
* Create the HTML interface for your field
|
36 |
+
*
|
37 |
+
* @param $field - an array holding all the field's data
|
38 |
+
*
|
39 |
+
* @type action
|
40 |
+
* @since 3.6
|
41 |
+
* @date 23/01/13
|
42 |
+
*/
|
43 |
+
|
44 |
+
function create_field( $field )
|
45 |
+
{
|
46 |
+
// vars
|
47 |
+
$o = array( 'id', 'class', 'name', 'value' );
|
48 |
+
$e = '';
|
49 |
+
|
50 |
+
|
51 |
+
$e .= '<div class="acf-color_picker">';
|
52 |
+
$e .= '<input type="text"';
|
53 |
+
|
54 |
+
foreach( $o as $k )
|
55 |
+
{
|
56 |
+
$e .= ' ' . $k . '="' . esc_attr( $field[ $k ] ) . '"';
|
57 |
+
}
|
58 |
+
|
59 |
+
$e .= ' />';
|
60 |
+
$e .= '</div>';
|
61 |
+
|
62 |
+
|
63 |
+
// return
|
64 |
+
echo $e;
|
65 |
+
}
|
66 |
+
|
67 |
+
|
68 |
+
/*
|
69 |
+
* create_options()
|
70 |
+
*
|
71 |
+
* Create extra options for your field. This is rendered when editing a field.
|
72 |
+
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
73 |
+
*
|
74 |
+
* @type action
|
75 |
+
* @since 3.6
|
76 |
+
* @date 23/01/13
|
77 |
+
*
|
78 |
+
* @param $field - an array holding all the field's data
|
79 |
+
*/
|
80 |
+
|
81 |
+
function create_options( $field )
|
82 |
+
{
|
83 |
+
// vars
|
84 |
+
$key = $field['name'];
|
85 |
+
|
86 |
+
?>
|
87 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
88 |
+
<td class="label">
|
89 |
+
<label><?php _e("Default Value",'acf'); ?></label>
|
90 |
+
</td>
|
91 |
+
<td>
|
92 |
+
<?php
|
93 |
+
do_action('acf/create_field', array(
|
94 |
+
'type' => 'text',
|
95 |
+
'name' => 'fields[' .$key.'][default_value]',
|
96 |
+
'value' => $field['default_value'],
|
97 |
+
'placeholder' => '#ffffff'
|
98 |
+
));
|
99 |
+
?>
|
100 |
+
</td>
|
101 |
+
</tr>
|
102 |
+
<?php
|
103 |
+
|
104 |
+
}
|
105 |
+
|
106 |
+
}
|
107 |
+
|
108 |
+
new acf_field_color_picker();
|
109 |
+
|
110 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/fields/date_picker/date_picker.php
CHANGED
@@ -1,183 +1,183 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_field_date_picker extends acf_field
|
4 |
-
{
|
5 |
-
|
6 |
-
/*
|
7 |
-
* __construct
|
8 |
-
*
|
9 |
-
* Set name / label needed for actions / filters
|
10 |
-
*
|
11 |
-
* @since 3.6
|
12 |
-
* @date 23/01/13
|
13 |
-
*/
|
14 |
-
|
15 |
-
function __construct()
|
16 |
-
{
|
17 |
-
// vars
|
18 |
-
$this->name = 'date_picker';
|
19 |
-
$this->label = __("Date Picker",'acf');
|
20 |
-
$this->category = __("jQuery",'acf');
|
21 |
-
$this->defaults = array(
|
22 |
-
'date_format' => 'yymmdd',
|
23 |
-
'display_format' => 'dd/mm/yy',
|
24 |
-
'first_day' => 1, // monday
|
25 |
-
);
|
26 |
-
|
27 |
-
|
28 |
-
// actions
|
29 |
-
add_action('init', array($this, 'init'));
|
30 |
-
|
31 |
-
|
32 |
-
// do not delete!
|
33 |
-
parent::__construct();
|
34 |
-
}
|
35 |
-
|
36 |
-
|
37 |
-
/*
|
38 |
-
* init
|
39 |
-
*
|
40 |
-
* This function is run on the 'init' action to set the field's $l10n data. Before the init action,
|
41 |
-
* access to the $wp_locale variable is not possible.
|
42 |
-
*
|
43 |
-
* @type action (init)
|
44 |
-
* @date 3/09/13
|
45 |
-
*
|
46 |
-
* @param N/A
|
47 |
-
* @return N/A
|
48 |
-
*/
|
49 |
-
|
50 |
-
function init()
|
51 |
-
{
|
52 |
-
global $wp_locale;
|
53 |
-
|
54 |
-
$this->l10n = array(
|
55 |
-
'closeText' => __( 'Done', 'acf' ),
|
56 |
-
'currentText' => __( 'Today', 'acf' ),
|
57 |
-
'monthNames' => array_values( $wp_locale->month ),
|
58 |
-
'monthNamesShort' => array_values( $wp_locale->month_abbrev ),
|
59 |
-
'monthStatus' => __( 'Show a different month', 'acf' ),
|
60 |
-
'dayNames' => array_values( $wp_locale->weekday ),
|
61 |
-
'dayNamesShort' => array_values( $wp_locale->weekday_abbrev ),
|
62 |
-
'dayNamesMin' => array_values( $wp_locale->weekday_initial ),
|
63 |
-
'isRTL' => isset($wp_locale->is_rtl) ? $wp_locale->is_rtl : false,
|
64 |
-
);
|
65 |
-
}
|
66 |
-
|
67 |
-
|
68 |
-
/*
|
69 |
-
* create_field()
|
70 |
-
*
|
71 |
-
* Create the HTML interface for your field
|
72 |
-
*
|
73 |
-
* @param $field - an array holding all the field's data
|
74 |
-
*
|
75 |
-
* @type action
|
76 |
-
* @since 3.6
|
77 |
-
* @date 23/01/13
|
78 |
-
*/
|
79 |
-
|
80 |
-
function create_field( $field )
|
81 |
-
{
|
82 |
-
// make sure it's not blank
|
83 |
-
if( !$field['date_format'] )
|
84 |
-
{
|
85 |
-
$field['date_format'] = 'yymmdd';
|
86 |
-
}
|
87 |
-
if( !$field['display_format'] )
|
88 |
-
{
|
89 |
-
$field['display_format'] = 'dd/mm/yy';
|
90 |
-
}
|
91 |
-
|
92 |
-
|
93 |
-
// html
|
94 |
-
echo '<div class="acf-date_picker" data-save_format="' . $field['date_format'] . '" data-display_format="' . $field['display_format'] . '" data-first_day="' . $field['first_day'] . '">';
|
95 |
-
echo '<input type="hidden" value="' . $field['value'] . '" name="' . $field['name'] . '" class="input-alt" />';
|
96 |
-
echo '<input type="text" value="" class="input" />';
|
97 |
-
echo '</div>';
|
98 |
-
}
|
99 |
-
|
100 |
-
|
101 |
-
/*
|
102 |
-
* create_options()
|
103 |
-
*
|
104 |
-
* Create extra options for your field. This is rendered when editing a field.
|
105 |
-
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
106 |
-
*
|
107 |
-
* @type action
|
108 |
-
* @since 3.6
|
109 |
-
* @date 23/01/13
|
110 |
-
*
|
111 |
-
* @param $field - an array holding all the field's data
|
112 |
-
*/
|
113 |
-
|
114 |
-
function create_options( $field )
|
115 |
-
{
|
116 |
-
// global
|
117 |
-
global $wp_locale;
|
118 |
-
|
119 |
-
|
120 |
-
// vars
|
121 |
-
$key = $field['name'];
|
122 |
-
|
123 |
-
?>
|
124 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
125 |
-
<td class="label">
|
126 |
-
<label><?php _e("Save format",'acf'); ?></label>
|
127 |
-
<p class="description"><?php _e("This format will determine the value saved to the database and returned via the API",'acf'); ?></p>
|
128 |
-
<p><?php _e("\"yymmdd\" is the most versatile save format. Read more about",'acf'); ?> <a href="http://docs.jquery.com/UI/Datepicker/formatDate"><?php _e("jQuery date formats",'acf'); ?></a></p>
|
129 |
-
</td>
|
130 |
-
<td>
|
131 |
-
<?php
|
132 |
-
do_action('acf/create_field', array(
|
133 |
-
'type' => 'text',
|
134 |
-
'name' => 'fields[' .$key.'][date_format]',
|
135 |
-
'value' => $field['date_format'],
|
136 |
-
));
|
137 |
-
?>
|
138 |
-
</td>
|
139 |
-
</tr>
|
140 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
141 |
-
<td class="label">
|
142 |
-
<label><?php _e("Display format",'acf'); ?></label>
|
143 |
-
<p class="description"><?php _e("This format will be seen by the user when entering a value",'acf'); ?></p>
|
144 |
-
<p><?php _e("\"dd/mm/yy\" or \"mm/dd/yy\" are the most used display formats. Read more about",'acf'); ?> <a href="http://docs.jquery.com/UI/Datepicker/formatDate" target="_blank"><?php _e("jQuery date formats",'acf'); ?></a></p>
|
145 |
-
</td>
|
146 |
-
<td>
|
147 |
-
<?php
|
148 |
-
do_action('acf/create_field', array(
|
149 |
-
'type' => 'text',
|
150 |
-
'name' => 'fields[' .$key.'][display_format]',
|
151 |
-
'value' => $field['display_format'],
|
152 |
-
));
|
153 |
-
?>
|
154 |
-
</td>
|
155 |
-
</tr>
|
156 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
157 |
-
<td class="label">
|
158 |
-
<label for=""><?php _e("Week Starts On",'acf'); ?></label>
|
159 |
-
</td>
|
160 |
-
<td>
|
161 |
-
<?php
|
162 |
-
|
163 |
-
$choices = array_values( $wp_locale->weekday );
|
164 |
-
|
165 |
-
do_action('acf/create_field', array(
|
166 |
-
'type' => 'select',
|
167 |
-
'name' => 'fields['.$key.'][first_day]',
|
168 |
-
'value' => $field['first_day'],
|
169 |
-
'choices' => $choices,
|
170 |
-
));
|
171 |
-
|
172 |
-
?>
|
173 |
-
</td>
|
174 |
-
</tr>
|
175 |
-
<?php
|
176 |
-
|
177 |
-
}
|
178 |
-
|
179 |
-
}
|
180 |
-
|
181 |
-
new acf_field_date_picker();
|
182 |
-
|
183 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class acf_field_date_picker extends acf_field
|
4 |
+
{
|
5 |
+
|
6 |
+
/*
|
7 |
+
* __construct
|
8 |
+
*
|
9 |
+
* Set name / label needed for actions / filters
|
10 |
+
*
|
11 |
+
* @since 3.6
|
12 |
+
* @date 23/01/13
|
13 |
+
*/
|
14 |
+
|
15 |
+
function __construct()
|
16 |
+
{
|
17 |
+
// vars
|
18 |
+
$this->name = 'date_picker';
|
19 |
+
$this->label = __("Date Picker",'acf');
|
20 |
+
$this->category = __("jQuery",'acf');
|
21 |
+
$this->defaults = array(
|
22 |
+
'date_format' => 'yymmdd',
|
23 |
+
'display_format' => 'dd/mm/yy',
|
24 |
+
'first_day' => 1, // monday
|
25 |
+
);
|
26 |
+
|
27 |
+
|
28 |
+
// actions
|
29 |
+
add_action('init', array($this, 'init'));
|
30 |
+
|
31 |
+
|
32 |
+
// do not delete!
|
33 |
+
parent::__construct();
|
34 |
+
}
|
35 |
+
|
36 |
+
|
37 |
+
/*
|
38 |
+
* init
|
39 |
+
*
|
40 |
+
* This function is run on the 'init' action to set the field's $l10n data. Before the init action,
|
41 |
+
* access to the $wp_locale variable is not possible.
|
42 |
+
*
|
43 |
+
* @type action (init)
|
44 |
+
* @date 3/09/13
|
45 |
+
*
|
46 |
+
* @param N/A
|
47 |
+
* @return N/A
|
48 |
+
*/
|
49 |
+
|
50 |
+
function init()
|
51 |
+
{
|
52 |
+
global $wp_locale;
|
53 |
+
|
54 |
+
$this->l10n = array(
|
55 |
+
'closeText' => __( 'Done', 'acf' ),
|
56 |
+
'currentText' => __( 'Today', 'acf' ),
|
57 |
+
'monthNames' => array_values( $wp_locale->month ),
|
58 |
+
'monthNamesShort' => array_values( $wp_locale->month_abbrev ),
|
59 |
+
'monthStatus' => __( 'Show a different month', 'acf' ),
|
60 |
+
'dayNames' => array_values( $wp_locale->weekday ),
|
61 |
+
'dayNamesShort' => array_values( $wp_locale->weekday_abbrev ),
|
62 |
+
'dayNamesMin' => array_values( $wp_locale->weekday_initial ),
|
63 |
+
'isRTL' => isset($wp_locale->is_rtl) ? $wp_locale->is_rtl : false,
|
64 |
+
);
|
65 |
+
}
|
66 |
+
|
67 |
+
|
68 |
+
/*
|
69 |
+
* create_field()
|
70 |
+
*
|
71 |
+
* Create the HTML interface for your field
|
72 |
+
*
|
73 |
+
* @param $field - an array holding all the field's data
|
74 |
+
*
|
75 |
+
* @type action
|
76 |
+
* @since 3.6
|
77 |
+
* @date 23/01/13
|
78 |
+
*/
|
79 |
+
|
80 |
+
function create_field( $field )
|
81 |
+
{
|
82 |
+
// make sure it's not blank
|
83 |
+
if( !$field['date_format'] )
|
84 |
+
{
|
85 |
+
$field['date_format'] = 'yymmdd';
|
86 |
+
}
|
87 |
+
if( !$field['display_format'] )
|
88 |
+
{
|
89 |
+
$field['display_format'] = 'dd/mm/yy';
|
90 |
+
}
|
91 |
+
|
92 |
+
|
93 |
+
// html
|
94 |
+
echo '<div class="acf-date_picker" data-save_format="' . $field['date_format'] . '" data-display_format="' . $field['display_format'] . '" data-first_day="' . $field['first_day'] . '">';
|
95 |
+
echo '<input type="hidden" value="' . $field['value'] . '" name="' . $field['name'] . '" class="input-alt" />';
|
96 |
+
echo '<input type="text" value="" class="input" />';
|
97 |
+
echo '</div>';
|
98 |
+
}
|
99 |
+
|
100 |
+
|
101 |
+
/*
|
102 |
+
* create_options()
|
103 |
+
*
|
104 |
+
* Create extra options for your field. This is rendered when editing a field.
|
105 |
+
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
106 |
+
*
|
107 |
+
* @type action
|
108 |
+
* @since 3.6
|
109 |
+
* @date 23/01/13
|
110 |
+
*
|
111 |
+
* @param $field - an array holding all the field's data
|
112 |
+
*/
|
113 |
+
|
114 |
+
function create_options( $field )
|
115 |
+
{
|
116 |
+
// global
|
117 |
+
global $wp_locale;
|
118 |
+
|
119 |
+
|
120 |
+
// vars
|
121 |
+
$key = $field['name'];
|
122 |
+
|
123 |
+
?>
|
124 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
125 |
+
<td class="label">
|
126 |
+
<label><?php _e("Save format",'acf'); ?></label>
|
127 |
+
<p class="description"><?php _e("This format will determine the value saved to the database and returned via the API",'acf'); ?></p>
|
128 |
+
<p><?php _e("\"yymmdd\" is the most versatile save format. Read more about",'acf'); ?> <a href="http://docs.jquery.com/UI/Datepicker/formatDate"><?php _e("jQuery date formats",'acf'); ?></a></p>
|
129 |
+
</td>
|
130 |
+
<td>
|
131 |
+
<?php
|
132 |
+
do_action('acf/create_field', array(
|
133 |
+
'type' => 'text',
|
134 |
+
'name' => 'fields[' .$key.'][date_format]',
|
135 |
+
'value' => $field['date_format'],
|
136 |
+
));
|
137 |
+
?>
|
138 |
+
</td>
|
139 |
+
</tr>
|
140 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
141 |
+
<td class="label">
|
142 |
+
<label><?php _e("Display format",'acf'); ?></label>
|
143 |
+
<p class="description"><?php _e("This format will be seen by the user when entering a value",'acf'); ?></p>
|
144 |
+
<p><?php _e("\"dd/mm/yy\" or \"mm/dd/yy\" are the most used display formats. Read more about",'acf'); ?> <a href="http://docs.jquery.com/UI/Datepicker/formatDate" target="_blank"><?php _e("jQuery date formats",'acf'); ?></a></p>
|
145 |
+
</td>
|
146 |
+
<td>
|
147 |
+
<?php
|
148 |
+
do_action('acf/create_field', array(
|
149 |
+
'type' => 'text',
|
150 |
+
'name' => 'fields[' .$key.'][display_format]',
|
151 |
+
'value' => $field['display_format'],
|
152 |
+
));
|
153 |
+
?>
|
154 |
+
</td>
|
155 |
+
</tr>
|
156 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
157 |
+
<td class="label">
|
158 |
+
<label for=""><?php _e("Week Starts On",'acf'); ?></label>
|
159 |
+
</td>
|
160 |
+
<td>
|
161 |
+
<?php
|
162 |
+
|
163 |
+
$choices = array_values( $wp_locale->weekday );
|
164 |
+
|
165 |
+
do_action('acf/create_field', array(
|
166 |
+
'type' => 'select',
|
167 |
+
'name' => 'fields['.$key.'][first_day]',
|
168 |
+
'value' => $field['first_day'],
|
169 |
+
'choices' => $choices,
|
170 |
+
));
|
171 |
+
|
172 |
+
?>
|
173 |
+
</td>
|
174 |
+
</tr>
|
175 |
+
<?php
|
176 |
+
|
177 |
+
}
|
178 |
+
|
179 |
+
}
|
180 |
+
|
181 |
+
new acf_field_date_picker();
|
182 |
+
|
183 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/fields/date_picker/jquery.ui.datepicker.js
CHANGED
@@ -1,1814 +1,1814 @@
|
|
1 |
-
/*
|
2 |
-
* jQuery UI Datepicker 1.8.14
|
3 |
-
*
|
4 |
-
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
5 |
-
* Dual licensed under the MIT or GPL Version 2 licenses.
|
6 |
-
* http://jquery.org/license
|
7 |
-
*
|
8 |
-
* http://docs.jquery.com/UI/Datepicker
|
9 |
-
*
|
10 |
-
* Depends:
|
11 |
-
* jquery.ui.core.js
|
12 |
-
*/
|
13 |
-
(function( $, undefined ) {
|
14 |
-
|
15 |
-
$.extend($.ui, { datepicker: { version: "1.8.14" } });
|
16 |
-
|
17 |
-
var PROP_NAME = 'datepicker';
|
18 |
-
var dpuuid = new Date().getTime();
|
19 |
-
var instActive;
|
20 |
-
|
21 |
-
/* Date picker manager.
|
22 |
-
Use the singleton instance of this class, $.datepicker, to interact with the date picker.
|
23 |
-
Settings for (groups of) date pickers are maintained in an instance object,
|
24 |
-
allowing multiple different settings on the same page. */
|
25 |
-
|
26 |
-
function Datepicker() {
|
27 |
-
this.debug = false; // Change this to true to start debugging
|
28 |
-
this._curInst = null; // The current instance in use
|
29 |
-
this._keyEvent = false; // If the last event was a key event
|
30 |
-
this._disabledInputs = []; // List of date picker inputs that have been disabled
|
31 |
-
this._datepickerShowing = false; // True if the popup picker is showing , false if not
|
32 |
-
this._inDialog = false; // True if showing within a "dialog", false if not
|
33 |
-
this._mainDivId = 'ui-datepicker-div'; // The ID of the main datepicker division
|
34 |
-
this._inlineClass = 'ui-datepicker-inline'; // The name of the inline marker class
|
35 |
-
this._appendClass = 'ui-datepicker-append'; // The name of the append marker class
|
36 |
-
this._triggerClass = 'ui-datepicker-trigger'; // The name of the trigger marker class
|
37 |
-
this._dialogClass = 'ui-datepicker-dialog'; // The name of the dialog marker class
|
38 |
-
this._disableClass = 'ui-datepicker-disabled'; // The name of the disabled covering marker class
|
39 |
-
this._unselectableClass = 'ui-datepicker-unselectable'; // The name of the unselectable cell marker class
|
40 |
-
this._currentClass = 'ui-datepicker-current-day'; // The name of the current day marker class
|
41 |
-
this._dayOverClass = 'ui-datepicker-days-cell-over'; // The name of the day hover marker class
|
42 |
-
this.regional = []; // Available regional settings, indexed by language code
|
43 |
-
this.regional[''] = { // Default regional settings
|
44 |
-
closeText: 'Done', // Display text for close link
|
45 |
-
prevText: 'Prev', // Display text for previous month link
|
46 |
-
nextText: 'Next', // Display text for next month link
|
47 |
-
currentText: 'Today', // Display text for current month link
|
48 |
-
monthNames: ['January','February','March','April','May','June',
|
49 |
-
'July','August','September','October','November','December'], // Names of months for drop-down and formatting
|
50 |
-
monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], // For formatting
|
51 |
-
dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting
|
52 |
-
dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting
|
53 |
-
dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Column headings for days starting at Sunday
|
54 |
-
weekHeader: 'Wk', // Column header for week of the year
|
55 |
-
dateFormat: 'mm/dd/yy', // See format options on parseDate
|
56 |
-
firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
|
57 |
-
isRTL: false, // True if right-to-left language, false if left-to-right
|
58 |
-
showMonthAfterYear: false, // True if the year select precedes month, false for month then year
|
59 |
-
yearSuffix: '' // Additional text to append to the year in the month headers
|
60 |
-
};
|
61 |
-
this._defaults = { // Global defaults for all the date picker instances
|
62 |
-
showOn: 'focus', // 'focus' for popup on focus,
|
63 |
-
// 'button' for trigger button, or 'both' for either
|
64 |
-
showAnim: 'fadeIn', // Name of jQuery animation for popup
|
65 |
-
showOptions: {}, // Options for enhanced animations
|
66 |
-
defaultDate: null, // Used when field is blank: actual date,
|
67 |
-
// +/-number for offset from today, null for today
|
68 |
-
appendText: '', // Display text following the input box, e.g. showing the format
|
69 |
-
buttonText: '...', // Text for trigger button
|
70 |
-
buttonImage: '', // URL for trigger button image
|
71 |
-
buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
|
72 |
-
hideIfNoPrevNext: false, // True to hide next/previous month links
|
73 |
-
// if not applicable, false to just disable them
|
74 |
-
navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
|
75 |
-
gotoCurrent: false, // True if today link goes back to current selection instead
|
76 |
-
changeMonth: false, // True if month can be selected directly, false if only prev/next
|
77 |
-
changeYear: false, // True if year can be selected directly, false if only prev/next
|
78 |
-
yearRange: 'c-10:c+10', // Range of years to display in drop-down,
|
79 |
-
// either relative to today's year (-nn:+nn), relative to currently displayed year
|
80 |
-
// (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
|
81 |
-
showOtherMonths: false, // True to show dates in other months, false to leave blank
|
82 |
-
selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
|
83 |
-
showWeek: false, // True to show week of the year, false to not show it
|
84 |
-
calculateWeek: this.iso8601Week, // How to calculate the week of the year,
|
85 |
-
// takes a Date and returns the number of the week for it
|
86 |
-
shortYearCutoff: '+10', // Short year values < this are in the current century,
|
87 |
-
// > this are in the previous century,
|
88 |
-
// string value starting with '+' for current year + value
|
89 |
-
minDate: null, // The earliest selectable date, or null for no limit
|
90 |
-
maxDate: null, // The latest selectable date, or null for no limit
|
91 |
-
duration: 'fast', // Duration of display/closure
|
92 |
-
beforeShowDay: null, // Function that takes a date and returns an array with
|
93 |
-
// [0] = true if selectable, false if not, [1] = custom CSS class name(s) or '',
|
94 |
-
// [2] = cell title (optional), e.g. $.datepicker.noWeekends
|
95 |
-
beforeShow: null, // Function that takes an input field and
|
96 |
-
// returns a set of custom settings for the date picker
|
97 |
-
onSelect: null, // Define a callback function when a date is selected
|
98 |
-
onChangeMonthYear: null, // Define a callback function when the month or year is changed
|
99 |
-
onClose: null, // Define a callback function when the datepicker is closed
|
100 |
-
numberOfMonths: 1, // Number of months to show at a time
|
101 |
-
showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
|
102 |
-
stepMonths: 1, // Number of months to step back/forward
|
103 |
-
stepBigMonths: 12, // Number of months to step back/forward for the big links
|
104 |
-
altField: '', // Selector for an alternate field to store selected dates into
|
105 |
-
altFormat: '', // The date format to use for the alternate field
|
106 |
-
constrainInput: true, // The input is constrained by the current date format
|
107 |
-
showButtonPanel: false, // True to show button panel, false to not show it
|
108 |
-
autoSize: false // True to size the input for the date format, false to leave as is
|
109 |
-
};
|
110 |
-
$.extend(this._defaults, this.regional['']);
|
111 |
-
this.dpDiv = bindHover($('<div id="' + this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'));
|
112 |
-
}
|
113 |
-
|
114 |
-
$.extend(Datepicker.prototype, {
|
115 |
-
/* Class name added to elements to indicate already configured with a date picker. */
|
116 |
-
markerClassName: 'hasDatepicker',
|
117 |
-
|
118 |
-
//Keep track of the maximum number of rows displayed (see #7043)
|
119 |
-
maxRows: 4,
|
120 |
-
|
121 |
-
/* Debug logging (if enabled). */
|
122 |
-
log: function () {
|
123 |
-
if (this.debug)
|
124 |
-
console.log.apply('', arguments);
|
125 |
-
},
|
126 |
-
|
127 |
-
// TODO rename to "widget" when switching to widget factory
|
128 |
-
_widgetDatepicker: function() {
|
129 |
-
return this.dpDiv;
|
130 |
-
},
|
131 |
-
|
132 |
-
/* Override the default settings for all instances of the date picker.
|
133 |
-
@param settings object - the new settings to use as defaults (anonymous object)
|
134 |
-
@return the manager object */
|
135 |
-
setDefaults: function(settings) {
|
136 |
-
extendRemove(this._defaults, settings || {});
|
137 |
-
return this;
|
138 |
-
},
|
139 |
-
|
140 |
-
/* Attach the date picker to a jQuery selection.
|
141 |
-
@param target element - the target input field or division or span
|
142 |
-
@param settings object - the new settings to use for this date picker instance (anonymous) */
|
143 |
-
_attachDatepicker: function(target, settings) {
|
144 |
-
// check for settings on the control itself - in namespace 'date:'
|
145 |
-
var inlineSettings = null;
|
146 |
-
for (var attrName in this._defaults) {
|
147 |
-
var attrValue = target.getAttribute('date:' + attrName);
|
148 |
-
if (attrValue) {
|
149 |
-
inlineSettings = inlineSettings || {};
|
150 |
-
try {
|
151 |
-
inlineSettings[attrName] = eval(attrValue);
|
152 |
-
} catch (err) {
|
153 |
-
inlineSettings[attrName] = attrValue;
|
154 |
-
}
|
155 |
-
}
|
156 |
-
}
|
157 |
-
var nodeName = target.nodeName.toLowerCase();
|
158 |
-
var inline = (nodeName == 'div' || nodeName == 'span');
|
159 |
-
if (!target.id) {
|
160 |
-
this.uuid += 1;
|
161 |
-
target.id = 'dp' + this.uuid;
|
162 |
-
}
|
163 |
-
var inst = this._newInst($(target), inline);
|
164 |
-
inst.settings = $.extend({}, settings || {}, inlineSettings || {});
|
165 |
-
if (nodeName == 'input') {
|
166 |
-
this._connectDatepicker(target, inst);
|
167 |
-
} else if (inline) {
|
168 |
-
this._inlineDatepicker(target, inst);
|
169 |
-
}
|
170 |
-
},
|
171 |
-
|
172 |
-
/* Create a new instance object. */
|
173 |
-
_newInst: function(target, inline) {
|
174 |
-
var id = target[0].id.replace(/([^A-Za-z0-9_-])/g, '\\\\$1'); // escape jQuery meta chars
|
175 |
-
return {id: id, input: target, // associated target
|
176 |
-
selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
|
177 |
-
drawMonth: 0, drawYear: 0, // month being drawn
|
178 |
-
inline: inline, // is datepicker inline or not
|
179 |
-
dpDiv: (!inline ? this.dpDiv : // presentation div
|
180 |
-
bindHover($('<div class="' + this._inlineClass + ' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>')))};
|
181 |
-
},
|
182 |
-
|
183 |
-
/* Attach the date picker to an input field. */
|
184 |
-
_connectDatepicker: function(target, inst) {
|
185 |
-
var input = $(target);
|
186 |
-
inst.append = $([]);
|
187 |
-
inst.trigger = $([]);
|
188 |
-
if (input.hasClass(this.markerClassName))
|
189 |
-
return;
|
190 |
-
this._attachments(input, inst);
|
191 |
-
input.addClass(this.markerClassName).keydown(this._doKeyDown).
|
192 |
-
keypress(this._doKeyPress).keyup(this._doKeyUp).
|
193 |
-
bind("setData.datepicker", function(event, key, value) {
|
194 |
-
inst.settings[key] = value;
|
195 |
-
}).bind("getData.datepicker", function(event, key) {
|
196 |
-
return this._get(inst, key);
|
197 |
-
});
|
198 |
-
this._autoSize(inst);
|
199 |
-
$.data(target, PROP_NAME, inst);
|
200 |
-
},
|
201 |
-
|
202 |
-
/* Make attachments based on settings. */
|
203 |
-
_attachments: function(input, inst) {
|
204 |
-
var appendText = this._get(inst, 'appendText');
|
205 |
-
var isRTL = this._get(inst, 'isRTL');
|
206 |
-
if (inst.append)
|
207 |
-
inst.append.remove();
|
208 |
-
if (appendText) {
|
209 |
-
inst.append = $('<span class="' + this._appendClass + '">' + appendText + '</span>');
|
210 |
-
input[isRTL ? 'before' : 'after'](inst.append);
|
211 |
-
}
|
212 |
-
input.unbind('focus', this._showDatepicker);
|
213 |
-
if (inst.trigger)
|
214 |
-
inst.trigger.remove();
|
215 |
-
var showOn = this._get(inst, 'showOn');
|
216 |
-
if (showOn == 'focus' || showOn == 'both') // pop-up date picker when in the marked field
|
217 |
-
input.focus(this._showDatepicker);
|
218 |
-
if (showOn == 'button' || showOn == 'both') { // pop-up date picker when button clicked
|
219 |
-
var buttonText = this._get(inst, 'buttonText');
|
220 |
-
var buttonImage = this._get(inst, 'buttonImage');
|
221 |
-
inst.trigger = $(this._get(inst, 'buttonImageOnly') ?
|
222 |
-
$('<img/>').addClass(this._triggerClass).
|
223 |
-
attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
|
224 |
-
$('<button type="button"></button>').addClass(this._triggerClass).
|
225 |
-
html(buttonImage == '' ? buttonText : $('<img/>').attr(
|
226 |
-
{ src:buttonImage, alt:buttonText, title:buttonText })));
|
227 |
-
input[isRTL ? 'before' : 'after'](inst.trigger);
|
228 |
-
inst.trigger.click(function() {
|
229 |
-
if ($.datepicker._datepickerShowing && $.datepicker._lastInput == input[0])
|
230 |
-
$.datepicker._hideDatepicker();
|
231 |
-
else
|
232 |
-
$.datepicker._showDatepicker(input[0]);
|
233 |
-
return false;
|
234 |
-
});
|
235 |
-
}
|
236 |
-
},
|
237 |
-
|
238 |
-
/* Apply the maximum length for the date format. */
|
239 |
-
_autoSize: function(inst) {
|
240 |
-
if (this._get(inst, 'autoSize') && !inst.inline) {
|
241 |
-
var date = new Date(2009, 12 - 1, 20); // Ensure double digits
|
242 |
-
var dateFormat = this._get(inst, 'dateFormat');
|
243 |
-
if (dateFormat.match(/[DM]/)) {
|
244 |
-
var findMax = function(names) {
|
245 |
-
var max = 0;
|
246 |
-
var maxI = 0;
|
247 |
-
for (var i = 0; i < names.length; i++) {
|
248 |
-
if (names[i].length > max) {
|
249 |
-
max = names[i].length;
|
250 |
-
maxI = i;
|
251 |
-
}
|
252 |
-
}
|
253 |
-
return maxI;
|
254 |
-
};
|
255 |
-
date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
|
256 |
-
'monthNames' : 'monthNamesShort'))));
|
257 |
-
date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
|
258 |
-
'dayNames' : 'dayNamesShort'))) + 20 - date.getDay());
|
259 |
-
}
|
260 |
-
inst.input.attr('size', this._formatDate(inst, date).length);
|
261 |
-
}
|
262 |
-
},
|
263 |
-
|
264 |
-
/* Attach an inline date picker to a div. */
|
265 |
-
_inlineDatepicker: function(target, inst) {
|
266 |
-
var divSpan = $(target);
|
267 |
-
if (divSpan.hasClass(this.markerClassName))
|
268 |
-
return;
|
269 |
-
divSpan.addClass(this.markerClassName).append(inst.dpDiv).
|
270 |
-
bind("setData.datepicker", function(event, key, value){
|
271 |
-
inst.settings[key] = value;
|
272 |
-
}).bind("getData.datepicker", function(event, key){
|
273 |
-
return this._get(inst, key);
|
274 |
-
});
|
275 |
-
$.data(target, PROP_NAME, inst);
|
276 |
-
this._setDate(inst, this._getDefaultDate(inst), true);
|
277 |
-
this._updateDatepicker(inst);
|
278 |
-
this._updateAlternate(inst);
|
279 |
-
inst.dpDiv.show();
|
280 |
-
},
|
281 |
-
|
282 |
-
/* Pop-up the date picker in a "dialog" box.
|
283 |
-
@param input element - ignored
|
284 |
-
@param date string or Date - the initial date to display
|
285 |
-
@param onSelect function - the function to call when a date is selected
|
286 |
-
@param settings object - update the dialog date picker instance's settings (anonymous object)
|
287 |
-
@param pos int[2] - coordinates for the dialog's position within the screen or
|
288 |
-
event - with x/y coordinates or
|
289 |
-
leave empty for default (screen centre)
|
290 |
-
@return the manager object */
|
291 |
-
_dialogDatepicker: function(input, date, onSelect, settings, pos) {
|
292 |
-
var inst = this._dialogInst; // internal instance
|
293 |
-
if (!inst) {
|
294 |
-
this.uuid += 1;
|
295 |
-
var id = 'dp' + this.uuid;
|
296 |
-
this._dialogInput = $('<input type="text" id="' + id +
|
297 |
-
'" style="position: absolute; top: -100px; width: 0px; z-index: -10;"/>');
|
298 |
-
this._dialogInput.keydown(this._doKeyDown);
|
299 |
-
$('body').append(this._dialogInput);
|
300 |
-
inst = this._dialogInst = this._newInst(this._dialogInput, false);
|
301 |
-
inst.settings = {};
|
302 |
-
$.data(this._dialogInput[0], PROP_NAME, inst);
|
303 |
-
}
|
304 |
-
extendRemove(inst.settings, settings || {});
|
305 |
-
date = (date && date.constructor == Date ? this._formatDate(inst, date) : date);
|
306 |
-
this._dialogInput.val(date);
|
307 |
-
|
308 |
-
this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
|
309 |
-
if (!this._pos) {
|
310 |
-
var browserWidth = document.documentElement.clientWidth;
|
311 |
-
var browserHeight = document.documentElement.clientHeight;
|
312 |
-
var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
|
313 |
-
var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
|
314 |
-
this._pos = // should use actual width/height below
|
315 |
-
[(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
|
316 |
-
}
|
317 |
-
|
318 |
-
// move input on screen for focus, but hidden behind dialog
|
319 |
-
this._dialogInput.css('left', (this._pos[0] + 20) + 'px').css('top', this._pos[1] + 'px');
|
320 |
-
inst.settings.onSelect = onSelect;
|
321 |
-
this._inDialog = true;
|
322 |
-
this.dpDiv.addClass(this._dialogClass);
|
323 |
-
this._showDatepicker(this._dialogInput[0]);
|
324 |
-
if ($.blockUI)
|
325 |
-
$.blockUI(this.dpDiv);
|
326 |
-
$.data(this._dialogInput[0], PROP_NAME, inst);
|
327 |
-
return this;
|
328 |
-
},
|
329 |
-
|
330 |
-
/* Detach a datepicker from its control.
|
331 |
-
@param target element - the target input field or division or span */
|
332 |
-
_destroyDatepicker: function(target) {
|
333 |
-
var $target = $(target);
|
334 |
-
var inst = $.data(target, PROP_NAME);
|
335 |
-
if (!$target.hasClass(this.markerClassName)) {
|
336 |
-
return;
|
337 |
-
}
|
338 |
-
var nodeName = target.nodeName.toLowerCase();
|
339 |
-
$.removeData(target, PROP_NAME);
|
340 |
-
if (nodeName == 'input') {
|
341 |
-
inst.append.remove();
|
342 |
-
inst.trigger.remove();
|
343 |
-
$target.removeClass(this.markerClassName).
|
344 |
-
unbind('focus', this._showDatepicker).
|
345 |
-
unbind('keydown', this._doKeyDown).
|
346 |
-
unbind('keypress', this._doKeyPress).
|
347 |
-
unbind('keyup', this._doKeyUp);
|
348 |
-
} else if (nodeName == 'div' || nodeName == 'span')
|
349 |
-
$target.removeClass(this.markerClassName).empty();
|
350 |
-
},
|
351 |
-
|
352 |
-
/* Enable the date picker to a jQuery selection.
|
353 |
-
@param target element - the target input field or division or span */
|
354 |
-
_enableDatepicker: function(target) {
|
355 |
-
var $target = $(target);
|
356 |
-
var inst = $.data(target, PROP_NAME);
|
357 |
-
if (!$target.hasClass(this.markerClassName)) {
|
358 |
-
return;
|
359 |
-
}
|
360 |
-
var nodeName = target.nodeName.toLowerCase();
|
361 |
-
if (nodeName == 'input') {
|
362 |
-
target.disabled = false;
|
363 |
-
inst.trigger.filter('button').
|
364 |
-
each(function() { this.disabled = false; }).end().
|
365 |
-
filter('img').css({opacity: '1.0', cursor: ''});
|
366 |
-
}
|
367 |
-
else if (nodeName == 'div' || nodeName == 'span') {
|
368 |
-
var inline = $target.children('.' + this._inlineClass);
|
369 |
-
inline.children().removeClass('ui-state-disabled');
|
370 |
-
inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
|
371 |
-
removeAttr("disabled");
|
372 |
-
}
|
373 |
-
this._disabledInputs = $.map(this._disabledInputs,
|
374 |
-
function(value) { return (value == target ? null : value); }); // delete entry
|
375 |
-
},
|
376 |
-
|
377 |
-
/* Disable the date picker to a jQuery selection.
|
378 |
-
@param target element - the target input field or division or span */
|
379 |
-
_disableDatepicker: function(target) {
|
380 |
-
var $target = $(target);
|
381 |
-
var inst = $.data(target, PROP_NAME);
|
382 |
-
if (!$target.hasClass(this.markerClassName)) {
|
383 |
-
return;
|
384 |
-
}
|
385 |
-
var nodeName = target.nodeName.toLowerCase();
|
386 |
-
if (nodeName == 'input') {
|
387 |
-
target.disabled = true;
|
388 |
-
inst.trigger.filter('button').
|
389 |
-
each(function() { this.disabled = true; }).end().
|
390 |
-
filter('img').css({opacity: '0.5', cursor: 'default'});
|
391 |
-
}
|
392 |
-
else if (nodeName == 'div' || nodeName == 'span') {
|
393 |
-
var inline = $target.children('.' + this._inlineClass);
|
394 |
-
inline.children().addClass('ui-state-disabled');
|
395 |
-
inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
|
396 |
-
attr("disabled", "disabled");
|
397 |
-
}
|
398 |
-
this._disabledInputs = $.map(this._disabledInputs,
|
399 |
-
function(value) { return (value == target ? null : value); }); // delete entry
|
400 |
-
this._disabledInputs[this._disabledInputs.length] = target;
|
401 |
-
},
|
402 |
-
|
403 |
-
/* Is the first field in a jQuery collection disabled as a datepicker?
|
404 |
-
@param target element - the target input field or division or span
|
405 |
-
@return boolean - true if disabled, false if enabled */
|
406 |
-
_isDisabledDatepicker: function(target) {
|
407 |
-
if (!target) {
|
408 |
-
return false;
|
409 |
-
}
|
410 |
-
for (var i = 0; i < this._disabledInputs.length; i++) {
|
411 |
-
if (this._disabledInputs[i] == target)
|
412 |
-
return true;
|
413 |
-
}
|
414 |
-
return false;
|
415 |
-
},
|
416 |
-
|
417 |
-
/* Retrieve the instance data for the target control.
|
418 |
-
@param target element - the target input field or division or span
|
419 |
-
@return object - the associated instance data
|
420 |
-
@throws error if a jQuery problem getting data */
|
421 |
-
_getInst: function(target) {
|
422 |
-
try {
|
423 |
-
return $.data(target, PROP_NAME);
|
424 |
-
}
|
425 |
-
catch (err) {
|
426 |
-
throw 'Missing instance data for this datepicker';
|
427 |
-
}
|
428 |
-
},
|
429 |
-
|
430 |
-
/* Update or retrieve the settings for a date picker attached to an input field or division.
|
431 |
-
@param target element - the target input field or division or span
|
432 |
-
@param name object - the new settings to update or
|
433 |
-
string - the name of the setting to change or retrieve,
|
434 |
-
when retrieving also 'all' for all instance settings or
|
435 |
-
'defaults' for all global defaults
|
436 |
-
@param value any - the new value for the setting
|
437 |
-
(omit if above is an object or to retrieve a value) */
|
438 |
-
_optionDatepicker: function(target, name, value) {
|
439 |
-
var inst = this._getInst(target);
|
440 |
-
if (arguments.length == 2 && typeof name == 'string') {
|
441 |
-
return (name == 'defaults' ? $.extend({}, $.datepicker._defaults) :
|
442 |
-
(inst ? (name == 'all' ? $.extend({}, inst.settings) :
|
443 |
-
this._get(inst, name)) : null));
|
444 |
-
}
|
445 |
-
var settings = name || {};
|
446 |
-
if (typeof name == 'string') {
|
447 |
-
settings = {};
|
448 |
-
settings[name] = value;
|
449 |
-
}
|
450 |
-
if (inst) {
|
451 |
-
if (this._curInst == inst) {
|
452 |
-
this._hideDatepicker();
|
453 |
-
}
|
454 |
-
var date = this._getDateDatepicker(target, true);
|
455 |
-
var minDate = this._getMinMaxDate(inst, 'min');
|
456 |
-
var maxDate = this._getMinMaxDate(inst, 'max');
|
457 |
-
extendRemove(inst.settings, settings);
|
458 |
-
// reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
|
459 |
-
if (minDate !== null && settings['dateFormat'] !== undefined && settings['minDate'] === undefined)
|
460 |
-
inst.settings.minDate = this._formatDate(inst, minDate);
|
461 |
-
if (maxDate !== null && settings['dateFormat'] !== undefined && settings['maxDate'] === undefined)
|
462 |
-
inst.settings.maxDate = this._formatDate(inst, maxDate);
|
463 |
-
this._attachments($(target), inst);
|
464 |
-
this._autoSize(inst);
|
465 |
-
this._setDate(inst, date);
|
466 |
-
this._updateAlternate(inst);
|
467 |
-
this._updateDatepicker(inst);
|
468 |
-
}
|
469 |
-
},
|
470 |
-
|
471 |
-
// change method deprecated
|
472 |
-
_changeDatepicker: function(target, name, value) {
|
473 |
-
this._optionDatepicker(target, name, value);
|
474 |
-
},
|
475 |
-
|
476 |
-
/* Redraw the date picker attached to an input field or division.
|
477 |
-
@param target element - the target input field or division or span */
|
478 |
-
_refreshDatepicker: function(target) {
|
479 |
-
var inst = this._getInst(target);
|
480 |
-
if (inst) {
|
481 |
-
this._updateDatepicker(inst);
|
482 |
-
}
|
483 |
-
},
|
484 |
-
|
485 |
-
/* Set the dates for a jQuery selection.
|
486 |
-
@param target element - the target input field or division or span
|
487 |
-
@param date Date - the new date */
|
488 |
-
_setDateDatepicker: function(target, date) {
|
489 |
-
var inst = this._getInst(target);
|
490 |
-
if (inst) {
|
491 |
-
this._setDate(inst, date);
|
492 |
-
this._updateDatepicker(inst);
|
493 |
-
this._updateAlternate(inst);
|
494 |
-
}
|
495 |
-
},
|
496 |
-
|
497 |
-
/* Get the date(s) for the first entry in a jQuery selection.
|
498 |
-
@param target element - the target input field or division or span
|
499 |
-
@param noDefault boolean - true if no default date is to be used
|
500 |
-
@return Date - the current date */
|
501 |
-
_getDateDatepicker: function(target, noDefault) {
|
502 |
-
var inst = this._getInst(target);
|
503 |
-
if (inst && !inst.inline)
|
504 |
-
this._setDateFromField(inst, noDefault);
|
505 |
-
return (inst ? this._getDate(inst) : null);
|
506 |
-
},
|
507 |
-
|
508 |
-
/* Handle keystrokes. */
|
509 |
-
_doKeyDown: function(event) {
|
510 |
-
var inst = $.datepicker._getInst(event.target);
|
511 |
-
var handled = true;
|
512 |
-
var isRTL = inst.dpDiv.is('.ui-datepicker-rtl');
|
513 |
-
inst._keyEvent = true;
|
514 |
-
if ($.datepicker._datepickerShowing)
|
515 |
-
switch (event.keyCode) {
|
516 |
-
case 9: $.datepicker._hideDatepicker();
|
517 |
-
handled = false;
|
518 |
-
break; // hide on tab out
|
519 |
-
case 13: var sel = $('td.' + $.datepicker._dayOverClass + ':not(.' +
|
520 |
-
$.datepicker._currentClass + ')', inst.dpDiv);
|
521 |
-
if (sel[0])
|
522 |
-
$.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
|
523 |
-
else
|
524 |
-
$.datepicker._hideDatepicker();
|
525 |
-
return false; // don't submit the form
|
526 |
-
break; // select the value on enter
|
527 |
-
case 27: $.datepicker._hideDatepicker();
|
528 |
-
break; // hide on escape
|
529 |
-
case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
|
530 |
-
-$.datepicker._get(inst, 'stepBigMonths') :
|
531 |
-
-$.datepicker._get(inst, 'stepMonths')), 'M');
|
532 |
-
break; // previous month/year on page up/+ ctrl
|
533 |
-
case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
|
534 |
-
+$.datepicker._get(inst, 'stepBigMonths') :
|
535 |
-
+$.datepicker._get(inst, 'stepMonths')), 'M');
|
536 |
-
break; // next month/year on page down/+ ctrl
|
537 |
-
case 35: if (event.ctrlKey || event.metaKey) $.datepicker._clearDate(event.target);
|
538 |
-
handled = event.ctrlKey || event.metaKey;
|
539 |
-
break; // clear on ctrl or command +end
|
540 |
-
case 36: if (event.ctrlKey || event.metaKey) $.datepicker._gotoToday(event.target);
|
541 |
-
handled = event.ctrlKey || event.metaKey;
|
542 |
-
break; // current on ctrl or command +home
|
543 |
-
case 37: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), 'D');
|
544 |
-
handled = event.ctrlKey || event.metaKey;
|
545 |
-
// -1 day on ctrl or command +left
|
546 |
-
if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
|
547 |
-
-$.datepicker._get(inst, 'stepBigMonths') :
|
548 |
-
-$.datepicker._get(inst, 'stepMonths')), 'M');
|
549 |
-
// next month/year on alt +left on Mac
|
550 |
-
break;
|
551 |
-
case 38: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, -7, 'D');
|
552 |
-
handled = event.ctrlKey || event.metaKey;
|
553 |
-
break; // -1 week on ctrl or command +up
|
554 |
-
case 39: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), 'D');
|
555 |
-
handled = event.ctrlKey || event.metaKey;
|
556 |
-
// +1 day on ctrl or command +right
|
557 |
-
if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
|
558 |
-
+$.datepicker._get(inst, 'stepBigMonths') :
|
559 |
-
+$.datepicker._get(inst, 'stepMonths')), 'M');
|
560 |
-
// next month/year on alt +right
|
561 |
-
break;
|
562 |
-
case 40: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, +7, 'D');
|
563 |
-
handled = event.ctrlKey || event.metaKey;
|
564 |
-
break; // +1 week on ctrl or command +down
|
565 |
-
default: handled = false;
|
566 |
-
}
|
567 |
-
else if (event.keyCode == 36 && event.ctrlKey) // display the date picker on ctrl+home
|
568 |
-
$.datepicker._showDatepicker(this);
|
569 |
-
else {
|
570 |
-
handled = false;
|
571 |
-
}
|
572 |
-
if (handled) {
|
573 |
-
event.preventDefault();
|
574 |
-
event.stopPropagation();
|
575 |
-
}
|
576 |
-
},
|
577 |
-
|
578 |
-
/* Filter entered characters - based on date format. */
|
579 |
-
_doKeyPress: function(event) {
|
580 |
-
var inst = $.datepicker._getInst(event.target);
|
581 |
-
if ($.datepicker._get(inst, 'constrainInput')) {
|
582 |
-
var chars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat'));
|
583 |
-
var chr = String.fromCharCode(event.charCode == undefined ? event.keyCode : event.charCode);
|
584 |
-
return event.ctrlKey || event.metaKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1);
|
585 |
-
}
|
586 |
-
},
|
587 |
-
|
588 |
-
/* Synchronise manual entry and field/alternate field. */
|
589 |
-
_doKeyUp: function(event) {
|
590 |
-
var inst = $.datepicker._getInst(event.target);
|
591 |
-
if (inst.input.val() != inst.lastVal) {
|
592 |
-
try {
|
593 |
-
var date = $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'),
|
594 |
-
(inst.input ? inst.input.val() : null),
|
595 |
-
$.datepicker._getFormatConfig(inst));
|
596 |
-
if (date) { // only if valid
|
597 |
-
$.datepicker._setDateFromField(inst);
|
598 |
-
$.datepicker._updateAlternate(inst);
|
599 |
-
$.datepicker._updateDatepicker(inst);
|
600 |
-
}
|
601 |
-
}
|
602 |
-
catch (event) {
|
603 |
-
$.datepicker.log(event);
|
604 |
-
}
|
605 |
-
}
|
606 |
-
return true;
|
607 |
-
},
|
608 |
-
|
609 |
-
/* Pop-up the date picker for a given input field.
|
610 |
-
@param input element - the input field attached to the date picker or
|
611 |
-
event - if triggered by focus */
|
612 |
-
_showDatepicker: function(input) {
|
613 |
-
input = input.target || input;
|
614 |
-
if (input.nodeName.toLowerCase() != 'input') // find from button/image trigger
|
615 |
-
input = $('input', input.parentNode)[0];
|
616 |
-
if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput == input) // already here
|
617 |
-
return;
|
618 |
-
var inst = $.datepicker._getInst(input);
|
619 |
-
if ($.datepicker._curInst && $.datepicker._curInst != inst) {
|
620 |
-
if ( $.datepicker._datepickerShowing ) {
|
621 |
-
$.datepicker._triggerOnClose($.datepicker._curInst);
|
622 |
-
}
|
623 |
-
$.datepicker._curInst.dpDiv.stop(true, true);
|
624 |
-
}
|
625 |
-
var beforeShow = $.datepicker._get(inst, 'beforeShow');
|
626 |
-
extendRemove(inst.settings, (beforeShow ? beforeShow.apply(input, [input, inst]) : {}));
|
627 |
-
inst.lastVal = null;
|
628 |
-
$.datepicker._lastInput = input;
|
629 |
-
$.datepicker._setDateFromField(inst);
|
630 |
-
if ($.datepicker._inDialog) // hide cursor
|
631 |
-
input.value = '';
|
632 |
-
if (!$.datepicker._pos) { // position below input
|
633 |
-
$.datepicker._pos = $.datepicker._findPos(input);
|
634 |
-
$.datepicker._pos[1] += input.offsetHeight; // add the height
|
635 |
-
}
|
636 |
-
var isFixed = false;
|
637 |
-
$(input).parents().each(function() {
|
638 |
-
isFixed |= $(this).css('position') == 'fixed';
|
639 |
-
return !isFixed;
|
640 |
-
});
|
641 |
-
if (isFixed && $.browser.opera) { // correction for Opera when fixed and scrolled
|
642 |
-
$.datepicker._pos[0] -= document.documentElement.scrollLeft;
|
643 |
-
$.datepicker._pos[1] -= document.documentElement.scrollTop;
|
644 |
-
}
|
645 |
-
var offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
|
646 |
-
$.datepicker._pos = null;
|
647 |
-
//to avoid flashes on Firefox
|
648 |
-
inst.dpDiv.empty();
|
649 |
-
// determine sizing offscreen
|
650 |
-
inst.dpDiv.css({position: 'absolute', display: 'block', top: '-1000px'});
|
651 |
-
$.datepicker._updateDatepicker(inst);
|
652 |
-
// fix width for dynamic number of date pickers
|
653 |
-
// and adjust position before showing
|
654 |
-
offset = $.datepicker._checkOffset(inst, offset, isFixed);
|
655 |
-
inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
|
656 |
-
'static' : (isFixed ? 'fixed' : 'absolute')), display: 'none',
|
657 |
-
left: offset.left + 'px', top: offset.top + 'px'});
|
658 |
-
if (!inst.inline) {
|
659 |
-
var showAnim = $.datepicker._get(inst, 'showAnim');
|
660 |
-
var duration = $.datepicker._get(inst, 'duration');
|
661 |
-
var postProcess = function() {
|
662 |
-
var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only
|
663 |
-
if( !! cover.length ){
|
664 |
-
var borders = $.datepicker._getBorders(inst.dpDiv);
|
665 |
-
cover.css({left: -borders[0], top: -borders[1],
|
666 |
-
width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()});
|
667 |
-
}
|
668 |
-
};
|
669 |
-
inst.dpDiv.zIndex($(input).zIndex()+1);
|
670 |
-
$.datepicker._datepickerShowing = true;
|
671 |
-
if ($.effects && $.effects[showAnim])
|
672 |
-
inst.dpDiv.show(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
|
673 |
-
else
|
674 |
-
inst.dpDiv[showAnim || 'show']((showAnim ? duration : null), postProcess);
|
675 |
-
if (!showAnim || !duration)
|
676 |
-
postProcess();
|
677 |
-
if (inst.input.is(':visible') && !inst.input.is(':disabled'))
|
678 |
-
inst.input.focus();
|
679 |
-
$.datepicker._curInst = inst;
|
680 |
-
}
|
681 |
-
},
|
682 |
-
|
683 |
-
/* Generate the date picker content. */
|
684 |
-
_updateDatepicker: function(inst) {
|
685 |
-
var self = this;
|
686 |
-
self.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
|
687 |
-
var borders = $.datepicker._getBorders(inst.dpDiv);
|
688 |
-
instActive = inst; // for delegate hover events
|
689 |
-
inst.dpDiv.empty().append(this._generateHTML(inst));
|
690 |
-
var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only
|
691 |
-
if( !!cover.length ){ //avoid call to outerXXXX() when not in IE6
|
692 |
-
cover.css({left: -borders[0], top: -borders[1], width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()})
|
693 |
-
}
|
694 |
-
inst.dpDiv.find('.' + this._dayOverClass + ' a').mouseover();
|
695 |
-
var numMonths = this._getNumberOfMonths(inst);
|
696 |
-
var cols = numMonths[1];
|
697 |
-
var width = 17;
|
698 |
-
inst.dpDiv.removeClass('ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4').width('');
|
699 |
-
if (cols > 1)
|
700 |
-
inst.dpDiv.addClass('ui-datepicker-multi-' + cols).css('width', (width * cols) + 'em');
|
701 |
-
inst.dpDiv[(numMonths[0] != 1 || numMonths[1] != 1 ? 'add' : 'remove') +
|
702 |
-
'Class']('ui-datepicker-multi');
|
703 |
-
inst.dpDiv[(this._get(inst, 'isRTL') ? 'add' : 'remove') +
|
704 |
-
'Class']('ui-datepicker-rtl');
|
705 |
-
if (inst == $.datepicker._curInst && $.datepicker._datepickerShowing && inst.input &&
|
706 |
-
// #6694 - don't focus the input if it's already focused
|
707 |
-
// this breaks the change event in IE
|
708 |
-
inst.input.is(':visible') && !inst.input.is(':disabled') && inst.input[0] != document.activeElement)
|
709 |
-
inst.input.focus();
|
710 |
-
// deffered render of the years select (to avoid flashes on Firefox)
|
711 |
-
if( inst.yearshtml ){
|
712 |
-
var origyearshtml = inst.yearshtml;
|
713 |
-
setTimeout(function(){
|
714 |
-
//assure that inst.yearshtml didn't change.
|
715 |
-
if( origyearshtml === inst.yearshtml && inst.yearshtml ){
|
716 |
-
inst.dpDiv.find('select.ui-datepicker-year:first').replaceWith(inst.yearshtml);
|
717 |
-
}
|
718 |
-
origyearshtml = inst.yearshtml = null;
|
719 |
-
}, 0);
|
720 |
-
}
|
721 |
-
},
|
722 |
-
|
723 |
-
/* Retrieve the size of left and top borders for an element.
|
724 |
-
@param elem (jQuery object) the element of interest
|
725 |
-
@return (number[2]) the left and top borders */
|
726 |
-
_getBorders: function(elem) {
|
727 |
-
var convert = function(value) {
|
728 |
-
return {thin: 1, medium: 2, thick: 3}[value] || value;
|
729 |
-
};
|
730 |
-
return [parseFloat(convert(elem.css('border-left-width'))),
|
731 |
-
parseFloat(convert(elem.css('border-top-width')))];
|
732 |
-
},
|
733 |
-
|
734 |
-
/* Check positioning to remain on screen. */
|
735 |
-
_checkOffset: function(inst, offset, isFixed) {
|
736 |
-
var dpWidth = inst.dpDiv.outerWidth();
|
737 |
-
var dpHeight = inst.dpDiv.outerHeight();
|
738 |
-
var inputWidth = inst.input ? inst.input.outerWidth() : 0;
|
739 |
-
var inputHeight = inst.input ? inst.input.outerHeight() : 0;
|
740 |
-
var viewWidth = document.documentElement.clientWidth + $(document).scrollLeft();
|
741 |
-
var viewHeight = document.documentElement.clientHeight + $(document).scrollTop();
|
742 |
-
|
743 |
-
offset.left -= (this._get(inst, 'isRTL') ? (dpWidth - inputWidth) : 0);
|
744 |
-
offset.left -= (isFixed && offset.left == inst.input.offset().left) ? $(document).scrollLeft() : 0;
|
745 |
-
offset.top -= (isFixed && offset.top == (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
|
746 |
-
|
747 |
-
// now check if datepicker is showing outside window viewport - move to a better place if so.
|
748 |
-
offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
|
749 |
-
Math.abs(offset.left + dpWidth - viewWidth) : 0);
|
750 |
-
offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
|
751 |
-
Math.abs(dpHeight + inputHeight) : 0);
|
752 |
-
|
753 |
-
return offset;
|
754 |
-
},
|
755 |
-
|
756 |
-
/* Find an object's position on the screen. */
|
757 |
-
_findPos: function(obj) {
|
758 |
-
var inst = this._getInst(obj);
|
759 |
-
var isRTL = this._get(inst, 'isRTL');
|
760 |
-
while (obj && (obj.type == 'hidden' || obj.nodeType != 1 || $.expr.filters.hidden(obj))) {
|
761 |
-
obj = obj[isRTL ? 'previousSibling' : 'nextSibling'];
|
762 |
-
}
|
763 |
-
var position = $(obj).offset();
|
764 |
-
return [position.left, position.top];
|
765 |
-
},
|
766 |
-
|
767 |
-
/* Trigger custom callback of onClose. */
|
768 |
-
_triggerOnClose: function(inst) {
|
769 |
-
var onClose = this._get(inst, 'onClose');
|
770 |
-
if (onClose)
|
771 |
-
onClose.apply((inst.input ? inst.input[0] : null),
|
772 |
-
[(inst.input ? inst.input.val() : ''), inst]);
|
773 |
-
},
|
774 |
-
|
775 |
-
/* Hide the date picker from view.
|
776 |
-
@param input element - the input field attached to the date picker */
|
777 |
-
_hideDatepicker: function(input) {
|
778 |
-
var inst = this._curInst;
|
779 |
-
if (!inst || (input && inst != $.data(input, PROP_NAME)))
|
780 |
-
return;
|
781 |
-
if (this._datepickerShowing) {
|
782 |
-
var showAnim = this._get(inst, 'showAnim');
|
783 |
-
var duration = this._get(inst, 'duration');
|
784 |
-
var postProcess = function() {
|
785 |
-
$.datepicker._tidyDialog(inst);
|
786 |
-
this._curInst = null;
|
787 |
-
};
|
788 |
-
if ($.effects && $.effects[showAnim])
|
789 |
-
inst.dpDiv.hide(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
|
790 |
-
else
|
791 |
-
inst.dpDiv[(showAnim == 'slideDown' ? 'slideUp' :
|
792 |
-
(showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))]((showAnim ? duration : null), postProcess);
|
793 |
-
if (!showAnim)
|
794 |
-
postProcess();
|
795 |
-
$.datepicker._triggerOnClose(inst);
|
796 |
-
this._datepickerShowing = false;
|
797 |
-
this._lastInput = null;
|
798 |
-
if (this._inDialog) {
|
799 |
-
this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' });
|
800 |
-
if ($.blockUI) {
|
801 |
-
$.unblockUI();
|
802 |
-
$('body').append(this.dpDiv);
|
803 |
-
}
|
804 |
-
}
|
805 |
-
this._inDialog = false;
|
806 |
-
}
|
807 |
-
},
|
808 |
-
|
809 |
-
/* Tidy up after a dialog display. */
|
810 |
-
_tidyDialog: function(inst) {
|
811 |
-
inst.dpDiv.removeClass(this._dialogClass).unbind('.ui-datepicker-calendar');
|
812 |
-
},
|
813 |
-
|
814 |
-
/* Close date picker if clicked elsewhere. */
|
815 |
-
_checkExternalClick: function(event) {
|
816 |
-
if (!$.datepicker._curInst)
|
817 |
-
return;
|
818 |
-
var $target = $(event.target);
|
819 |
-
if ($target[0].id != $.datepicker._mainDivId &&
|
820 |
-
$target.parents('#' + $.datepicker._mainDivId).length == 0 &&
|
821 |
-
!$target.hasClass($.datepicker.markerClassName) &&
|
822 |
-
!$target.hasClass($.datepicker._triggerClass) &&
|
823 |
-
$.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI))
|
824 |
-
$.datepicker._hideDatepicker();
|
825 |
-
},
|
826 |
-
|
827 |
-
/* Adjust one of the date sub-fields. */
|
828 |
-
_adjustDate: function(id, offset, period) {
|
829 |
-
var target = $(id);
|
830 |
-
var inst = this._getInst(target[0]);
|
831 |
-
if (this._isDisabledDatepicker(target[0])) {
|
832 |
-
return;
|
833 |
-
}
|
834 |
-
this._adjustInstDate(inst, offset +
|
835 |
-
(period == 'M' ? this._get(inst, 'showCurrentAtPos') : 0), // undo positioning
|
836 |
-
period);
|
837 |
-
this._updateDatepicker(inst);
|
838 |
-
},
|
839 |
-
|
840 |
-
/* Action for current link. */
|
841 |
-
_gotoToday: function(id) {
|
842 |
-
var target = $(id);
|
843 |
-
var inst = this._getInst(target[0]);
|
844 |
-
if (this._get(inst, 'gotoCurrent') && inst.currentDay) {
|
845 |
-
inst.selectedDay = inst.currentDay;
|
846 |
-
inst.drawMonth = inst.selectedMonth = inst.currentMonth;
|
847 |
-
inst.drawYear = inst.selectedYear = inst.currentYear;
|
848 |
-
}
|
849 |
-
else {
|
850 |
-
var date = new Date();
|
851 |
-
inst.selectedDay = date.getDate();
|
852 |
-
inst.drawMonth = inst.selectedMonth = date.getMonth();
|
853 |
-
inst.drawYear = inst.selectedYear = date.getFullYear();
|
854 |
-
}
|
855 |
-
this._notifyChange(inst);
|
856 |
-
this._adjustDate(target);
|
857 |
-
},
|
858 |
-
|
859 |
-
/* Action for selecting a new month/year. */
|
860 |
-
_selectMonthYear: function(id, select, period) {
|
861 |
-
var target = $(id);
|
862 |
-
var inst = this._getInst(target[0]);
|
863 |
-
inst._selectingMonthYear = false;
|
864 |
-
inst['selected' + (period == 'M' ? 'Month' : 'Year')] =
|
865 |
-
inst['draw' + (period == 'M' ? 'Month' : 'Year')] =
|
866 |
-
parseInt(select.options[select.selectedIndex].value,10);
|
867 |
-
this._notifyChange(inst);
|
868 |
-
this._adjustDate(target);
|
869 |
-
},
|
870 |
-
|
871 |
-
/* Restore input focus after not changing month/year. */
|
872 |
-
_clickMonthYear: function(id) {
|
873 |
-
var target = $(id);
|
874 |
-
var inst = this._getInst(target[0]);
|
875 |
-
if (inst.input && inst._selectingMonthYear) {
|
876 |
-
setTimeout(function() {
|
877 |
-
inst.input.focus();
|
878 |
-
}, 0);
|
879 |
-
}
|
880 |
-
inst._selectingMonthYear = !inst._selectingMonthYear;
|
881 |
-
},
|
882 |
-
|
883 |
-
/* Action for selecting a day. */
|
884 |
-
_selectDay: function(id, month, year, td) {
|
885 |
-
var target = $(id);
|
886 |
-
if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
|
887 |
-
return;
|
888 |
-
}
|
889 |
-
var inst = this._getInst(target[0]);
|
890 |
-
inst.selectedDay = inst.currentDay = $('a', td).html();
|
891 |
-
inst.selectedMonth = inst.currentMonth = month;
|
892 |
-
inst.selectedYear = inst.currentYear = year;
|
893 |
-
this._selectDate(id, this._formatDate(inst,
|
894 |
-
inst.currentDay, inst.currentMonth, inst.currentYear));
|
895 |
-
},
|
896 |
-
|
897 |
-
/* Erase the input field and hide the date picker. */
|
898 |
-
_clearDate: function(id) {
|
899 |
-
var target = $(id);
|
900 |
-
var inst = this._getInst(target[0]);
|
901 |
-
this._selectDate(target, '');
|
902 |
-
},
|
903 |
-
|
904 |
-
/* Update the input field with the selected date. */
|
905 |
-
_selectDate: function(id, dateStr) {
|
906 |
-
var target = $(id);
|
907 |
-
var inst = this._getInst(target[0]);
|
908 |
-
dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
|
909 |
-
if (inst.input)
|
910 |
-
inst.input.val(dateStr);
|
911 |
-
this._updateAlternate(inst);
|
912 |
-
var onSelect = this._get(inst, 'onSelect');
|
913 |
-
if (onSelect)
|
914 |
-
onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
|
915 |
-
else if (inst.input)
|
916 |
-
inst.input.trigger('change'); // fire the change event
|
917 |
-
if (inst.inline)
|
918 |
-
this._updateDatepicker(inst);
|
919 |
-
else {
|
920 |
-
this._hideDatepicker();
|
921 |
-
this._lastInput = inst.input[0];
|
922 |
-
if (typeof(inst.input[0]) != 'object')
|
923 |
-
inst.input.focus(); // restore focus
|
924 |
-
this._lastInput = null;
|
925 |
-
}
|
926 |
-
},
|
927 |
-
|
928 |
-
/* Update any alternate field to synchronise with the main field. */
|
929 |
-
_updateAlternate: function(inst) {
|
930 |
-
var altField = this._get(inst, 'altField');
|
931 |
-
if (altField) { // update alternate field too
|
932 |
-
var altFormat = this._get(inst, 'altFormat') || this._get(inst, 'dateFormat');
|
933 |
-
var date = this._getDate(inst);
|
934 |
-
var dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
|
935 |
-
$(altField).each(function() { $(this).val(dateStr); });
|
936 |
-
}
|
937 |
-
},
|
938 |
-
|
939 |
-
/* Set as beforeShowDay function to prevent selection of weekends.
|
940 |
-
@param date Date - the date to customise
|
941 |
-
@return [boolean, string] - is this date selectable?, what is its CSS class? */
|
942 |
-
noWeekends: function(date) {
|
943 |
-
var day = date.getDay();
|
944 |
-
return [(day > 0 && day < 6), ''];
|
945 |
-
},
|
946 |
-
|
947 |
-
/* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
|
948 |
-
@param date Date - the date to get the week for
|
949 |
-
@return number - the number of the week within the year that contains this date */
|
950 |
-
iso8601Week: function(date) {
|
951 |
-
var checkDate = new Date(date.getTime());
|
952 |
-
// Find Thursday of this week starting on Monday
|
953 |
-
checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
|
954 |
-
var time = checkDate.getTime();
|
955 |
-
checkDate.setMonth(0); // Compare with Jan 1
|
956 |
-
checkDate.setDate(1);
|
957 |
-
return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
|
958 |
-
},
|
959 |
-
|
960 |
-
/* Parse a string value into a date object.
|
961 |
-
See formatDate below for the possible formats.
|
962 |
-
|
963 |
-
@param format string - the expected format of the date
|
964 |
-
@param value string - the date in the above format
|
965 |
-
@param settings Object - attributes include:
|
966 |
-
shortYearCutoff number - the cutoff year for determining the century (optional)
|
967 |
-
dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
|
968 |
-
dayNames string[7] - names of the days from Sunday (optional)
|
969 |
-
monthNamesShort string[12] - abbreviated names of the months (optional)
|
970 |
-
monthNames string[12] - names of the months (optional)
|
971 |
-
@return Date - the extracted date value or null if value is blank */
|
972 |
-
parseDate: function (format, value, settings) {
|
973 |
-
if (format == null || value == null)
|
974 |
-
throw 'Invalid arguments';
|
975 |
-
value = (typeof value == 'object' ? value.toString() : value + '');
|
976 |
-
if (value == '')
|
977 |
-
return null;
|
978 |
-
var shortYearCutoff = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff;
|
979 |
-
shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff :
|
980 |
-
new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
|
981 |
-
var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
|
982 |
-
var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
|
983 |
-
var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
|
984 |
-
var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
|
985 |
-
var year = -1;
|
986 |
-
var month = -1;
|
987 |
-
var day = -1;
|
988 |
-
var doy = -1;
|
989 |
-
var literal = false;
|
990 |
-
// Check whether a format character is doubled
|
991 |
-
var lookAhead = function(match) {
|
992 |
-
var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
|
993 |
-
if (matches)
|
994 |
-
iFormat++;
|
995 |
-
return matches;
|
996 |
-
};
|
997 |
-
// Extract a number from the string value
|
998 |
-
var getNumber = function(match) {
|
999 |
-
var isDoubled = lookAhead(match);
|
1000 |
-
var size = (match == '@' ? 14 : (match == '!' ? 20 :
|
1001 |
-
(match == 'y' && isDoubled ? 4 : (match == 'o' ? 3 : 2))));
|
1002 |
-
var digits = new RegExp('^\\d{1,' + size + '}');
|
1003 |
-
var num = value.substring(iValue).match(digits);
|
1004 |
-
if (!num)
|
1005 |
-
throw 'Missing number at position ' + iValue;
|
1006 |
-
iValue += num[0].length;
|
1007 |
-
return parseInt(num[0], 10);
|
1008 |
-
};
|
1009 |
-
// Extract a name from the string value and convert to an index
|
1010 |
-
var getName = function(match, shortNames, longNames) {
|
1011 |
-
var names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
|
1012 |
-
return [ [k, v] ];
|
1013 |
-
}).sort(function (a, b) {
|
1014 |
-
return -(a[1].length - b[1].length);
|
1015 |
-
});
|
1016 |
-
var index = -1;
|
1017 |
-
$.each(names, function (i, pair) {
|
1018 |
-
var name = pair[1];
|
1019 |
-
if (value.substr(iValue, name.length).toLowerCase() == name.toLowerCase()) {
|
1020 |
-
index = pair[0];
|
1021 |
-
iValue += name.length;
|
1022 |
-
return false;
|
1023 |
-
}
|
1024 |
-
});
|
1025 |
-
if (index != -1)
|
1026 |
-
return index + 1;
|
1027 |
-
else
|
1028 |
-
throw 'Unknown name at position ' + iValue;
|
1029 |
-
};
|
1030 |
-
// Confirm that a literal character matches the string value
|
1031 |
-
var checkLiteral = function() {
|
1032 |
-
if (value.charAt(iValue) != format.charAt(iFormat))
|
1033 |
-
throw 'Unexpected literal at position ' + iValue;
|
1034 |
-
iValue++;
|
1035 |
-
};
|
1036 |
-
var iValue = 0;
|
1037 |
-
for (var iFormat = 0; iFormat < format.length; iFormat++) {
|
1038 |
-
if (literal)
|
1039 |
-
if (format.charAt(iFormat) == "'" && !lookAhead("'"))
|
1040 |
-
literal = false;
|
1041 |
-
else
|
1042 |
-
checkLiteral();
|
1043 |
-
else
|
1044 |
-
switch (format.charAt(iFormat)) {
|
1045 |
-
case 'd':
|
1046 |
-
day = getNumber('d');
|
1047 |
-
break;
|
1048 |
-
case 'D':
|
1049 |
-
getName('D', dayNamesShort, dayNames);
|
1050 |
-
break;
|
1051 |
-
case 'o':
|
1052 |
-
doy = getNumber('o');
|
1053 |
-
break;
|
1054 |
-
case 'm':
|
1055 |
-
month = getNumber('m');
|
1056 |
-
break;
|
1057 |
-
case 'M':
|
1058 |
-
month = getName('M', monthNamesShort, monthNames);
|
1059 |
-
break;
|
1060 |
-
case 'y':
|
1061 |
-
year = getNumber('y');
|
1062 |
-
break;
|
1063 |
-
case '@':
|
1064 |
-
var date = new Date(getNumber('@'));
|
1065 |
-
year = date.getFullYear();
|
1066 |
-
month = date.getMonth() + 1;
|
1067 |
-
day = date.getDate();
|
1068 |
-
break;
|
1069 |
-
case '!':
|
1070 |
-
var date = new Date((getNumber('!') - this._ticksTo1970) / 10000);
|
1071 |
-
year = date.getFullYear();
|
1072 |
-
month = date.getMonth() + 1;
|
1073 |
-
day = date.getDate();
|
1074 |
-
break;
|
1075 |
-
case "'":
|
1076 |
-
if (lookAhead("'"))
|
1077 |
-
checkLiteral();
|
1078 |
-
else
|
1079 |
-
literal = true;
|
1080 |
-
break;
|
1081 |
-
default:
|
1082 |
-
checkLiteral();
|
1083 |
-
}
|
1084 |
-
}
|
1085 |
-
if (iValue < value.length){
|
1086 |
-
throw "Extra/unparsed characters found in date: " + value.substring(iValue);
|
1087 |
-
}
|
1088 |
-
if (year == -1)
|
1089 |
-
year = new Date().getFullYear();
|
1090 |
-
else if (year < 100)
|
1091 |
-
year += new Date().getFullYear() - new Date().getFullYear() % 100 +
|
1092 |
-
(year <= shortYearCutoff ? 0 : -100);
|
1093 |
-
if (doy > -1) {
|
1094 |
-
month = 1;
|
1095 |
-
day = doy;
|
1096 |
-
do {
|
1097 |
-
var dim = this._getDaysInMonth(year, month - 1);
|
1098 |
-
if (day <= dim)
|
1099 |
-
break;
|
1100 |
-
month++;
|
1101 |
-
day -= dim;
|
1102 |
-
} while (true);
|
1103 |
-
}
|
1104 |
-
var date = this._daylightSavingAdjust(new Date(year, month - 1, day));
|
1105 |
-
if (date.getFullYear() != year || date.getMonth() + 1 != month || date.getDate() != day)
|
1106 |
-
throw 'Invalid date'; // E.g. 31/02/00
|
1107 |
-
return date;
|
1108 |
-
},
|
1109 |
-
|
1110 |
-
/* Standard date formats. */
|
1111 |
-
ATOM: 'yy-mm-dd', // RFC 3339 (ISO 8601)
|
1112 |
-
COOKIE: 'D, dd M yy',
|
1113 |
-
ISO_8601: 'yy-mm-dd',
|
1114 |
-
RFC_822: 'D, d M y',
|
1115 |
-
RFC_850: 'DD, dd-M-y',
|
1116 |
-
RFC_1036: 'D, d M y',
|
1117 |
-
RFC_1123: 'D, d M yy',
|
1118 |
-
RFC_2822: 'D, d M yy',
|
1119 |
-
RSS: 'D, d M y', // RFC 822
|
1120 |
-
TICKS: '!',
|
1121 |
-
TIMESTAMP: '@',
|
1122 |
-
W3C: 'yy-mm-dd', // ISO 8601
|
1123 |
-
|
1124 |
-
_ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
|
1125 |
-
Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
|
1126 |
-
|
1127 |
-
/* Format a date object into a string value.
|
1128 |
-
The format can be combinations of the following:
|
1129 |
-
d - day of month (no leading zero)
|
1130 |
-
dd - day of month (two digit)
|
1131 |
-
o - day of year (no leading zeros)
|
1132 |
-
oo - day of year (three digit)
|
1133 |
-
D - day name short
|
1134 |
-
DD - day name long
|
1135 |
-
m - month of year (no leading zero)
|
1136 |
-
mm - month of year (two digit)
|
1137 |
-
M - month name short
|
1138 |
-
MM - month name long
|
1139 |
-
y - year (two digit)
|
1140 |
-
yy - year (four digit)
|
1141 |
-
@ - Unix timestamp (ms since 01/01/1970)
|
1142 |
-
! - Windows ticks (100ns since 01/01/0001)
|
1143 |
-
'...' - literal text
|
1144 |
-
'' - single quote
|
1145 |
-
|
1146 |
-
@param format string - the desired format of the date
|
1147 |
-
@param date Date - the date value to format
|
1148 |
-
@param settings Object - attributes include:
|
1149 |
-
dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
|
1150 |
-
dayNames string[7] - names of the days from Sunday (optional)
|
1151 |
-
monthNamesShort string[12] - abbreviated names of the months (optional)
|
1152 |
-
monthNames string[12] - names of the months (optional)
|
1153 |
-
@return string - the date in the above format */
|
1154 |
-
formatDate: function (format, date, settings) {
|
1155 |
-
if (!date)
|
1156 |
-
return '';
|
1157 |
-
var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
|
1158 |
-
var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
|
1159 |
-
var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
|
1160 |
-
var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
|
1161 |
-
// Check whether a format character is doubled
|
1162 |
-
var lookAhead = function(match) {
|
1163 |
-
var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
|
1164 |
-
if (matches)
|
1165 |
-
iFormat++;
|
1166 |
-
return matches;
|
1167 |
-
};
|
1168 |
-
// Format a number, with leading zero if necessary
|
1169 |
-
var formatNumber = function(match, value, len) {
|
1170 |
-
var num = '' + value;
|
1171 |
-
if (lookAhead(match))
|
1172 |
-
while (num.length < len)
|
1173 |
-
num = '0' + num;
|
1174 |
-
return num;
|
1175 |
-
};
|
1176 |
-
// Format a name, short or long as requested
|
1177 |
-
var formatName = function(match, value, shortNames, longNames) {
|
1178 |
-
return (lookAhead(match) ? longNames[value] : shortNames[value]);
|
1179 |
-
};
|
1180 |
-
var output = '';
|
1181 |
-
var literal = false;
|
1182 |
-
if (date)
|
1183 |
-
for (var iFormat = 0; iFormat < format.length; iFormat++) {
|
1184 |
-
if (literal)
|
1185 |
-
if (format.charAt(iFormat) == "'" && !lookAhead("'"))
|
1186 |
-
literal = false;
|
1187 |
-
else
|
1188 |
-
output += format.charAt(iFormat);
|
1189 |
-
else
|
1190 |
-
switch (format.charAt(iFormat)) {
|
1191 |
-
case 'd':
|
1192 |
-
output += formatNumber('d', date.getDate(), 2);
|
1193 |
-
break;
|
1194 |
-
case 'D':
|
1195 |
-
output += formatName('D', date.getDay(), dayNamesShort, dayNames);
|
1196 |
-
break;
|
1197 |
-
case 'o':
|
1198 |
-
output += formatNumber('o',
|
1199 |
-
Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
|
1200 |
-
break;
|
1201 |
-
case 'm':
|
1202 |
-
output += formatNumber('m', date.getMonth() + 1, 2);
|
1203 |
-
break;
|
1204 |
-
case 'M':
|
1205 |
-
output += formatName('M', date.getMonth(), monthNamesShort, monthNames);
|
1206 |
-
break;
|
1207 |
-
case 'y':
|
1208 |
-
output += (lookAhead('y') ? date.getFullYear() :
|
1209 |
-
(date.getYear() % 100 < 10 ? '0' : '') + date.getYear() % 100);
|
1210 |
-
break;
|
1211 |
-
case '@':
|
1212 |
-
output += date.getTime();
|
1213 |
-
break;
|
1214 |
-
case '!':
|
1215 |
-
output += date.getTime() * 10000 + this._ticksTo1970;
|
1216 |
-
break;
|
1217 |
-
case "'":
|
1218 |
-
if (lookAhead("'"))
|
1219 |
-
output += "'";
|
1220 |
-
else
|
1221 |
-
literal = true;
|
1222 |
-
break;
|
1223 |
-
default:
|
1224 |
-
output += format.charAt(iFormat);
|
1225 |
-
}
|
1226 |
-
}
|
1227 |
-
return output;
|
1228 |
-
},
|
1229 |
-
|
1230 |
-
/* Extract all possible characters from the date format. */
|
1231 |
-
_possibleChars: function (format) {
|
1232 |
-
var chars = '';
|
1233 |
-
var literal = false;
|
1234 |
-
// Check whether a format character is doubled
|
1235 |
-
var lookAhead = function(match) {
|
1236 |
-
var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
|
1237 |
-
if (matches)
|
1238 |
-
iFormat++;
|
1239 |
-
return matches;
|
1240 |
-
};
|
1241 |
-
for (var iFormat = 0; iFormat < format.length; iFormat++)
|
1242 |
-
if (literal)
|
1243 |
-
if (format.charAt(iFormat) == "'" && !lookAhead("'"))
|
1244 |
-
literal = false;
|
1245 |
-
else
|
1246 |
-
chars += format.charAt(iFormat);
|
1247 |
-
else
|
1248 |
-
switch (format.charAt(iFormat)) {
|
1249 |
-
case 'd': case 'm': case 'y': case '@':
|
1250 |
-
chars += '0123456789';
|
1251 |
-
break;
|
1252 |
-
case 'D': case 'M':
|
1253 |
-
return null; // Accept anything
|
1254 |
-
case "'":
|
1255 |
-
if (lookAhead("'"))
|
1256 |
-
chars += "'";
|
1257 |
-
else
|
1258 |
-
literal = true;
|
1259 |
-
break;
|
1260 |
-
default:
|
1261 |
-
chars += format.charAt(iFormat);
|
1262 |
-
}
|
1263 |
-
return chars;
|
1264 |
-
},
|
1265 |
-
|
1266 |
-
/* Get a setting value, defaulting if necessary. */
|
1267 |
-
_get: function(inst, name) {
|
1268 |
-
return inst.settings[name] !== undefined ?
|
1269 |
-
inst.settings[name] : this._defaults[name];
|
1270 |
-
},
|
1271 |
-
|
1272 |
-
/* Parse existing date and initialise date picker. */
|
1273 |
-
_setDateFromField: function(inst, noDefault) {
|
1274 |
-
if (inst.input.val() == inst.lastVal) {
|
1275 |
-
return;
|
1276 |
-
}
|
1277 |
-
var dateFormat = this._get(inst, 'dateFormat');
|
1278 |
-
var dates = inst.lastVal = inst.input ? inst.input.val() : null;
|
1279 |
-
var date, defaultDate;
|
1280 |
-
date = defaultDate = this._getDefaultDate(inst);
|
1281 |
-
var settings = this._getFormatConfig(inst);
|
1282 |
-
try {
|
1283 |
-
date = this.parseDate(dateFormat, dates, settings) || defaultDate;
|
1284 |
-
} catch (event) {
|
1285 |
-
this.log(event);
|
1286 |
-
dates = (noDefault ? '' : dates);
|
1287 |
-
}
|
1288 |
-
inst.selectedDay = date.getDate();
|
1289 |
-
inst.drawMonth = inst.selectedMonth = date.getMonth();
|
1290 |
-
inst.drawYear = inst.selectedYear = date.getFullYear();
|
1291 |
-
inst.currentDay = (dates ? date.getDate() : 0);
|
1292 |
-
inst.currentMonth = (dates ? date.getMonth() : 0);
|
1293 |
-
inst.currentYear = (dates ? date.getFullYear() : 0);
|
1294 |
-
this._adjustInstDate(inst);
|
1295 |
-
},
|
1296 |
-
|
1297 |
-
/* Retrieve the default date shown on opening. */
|
1298 |
-
_getDefaultDate: function(inst) {
|
1299 |
-
return this._restrictMinMax(inst,
|
1300 |
-
this._determineDate(inst, this._get(inst, 'defaultDate'), new Date()));
|
1301 |
-
},
|
1302 |
-
|
1303 |
-
/* A date may be specified as an exact value or a relative one. */
|
1304 |
-
_determineDate: function(inst, date, defaultDate) {
|
1305 |
-
var offsetNumeric = function(offset) {
|
1306 |
-
var date = new Date();
|
1307 |
-
date.setDate(date.getDate() + offset);
|
1308 |
-
return date;
|
1309 |
-
};
|
1310 |
-
var offsetString = function(offset) {
|
1311 |
-
try {
|
1312 |
-
return $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'),
|
1313 |
-
offset, $.datepicker._getFormatConfig(inst));
|
1314 |
-
}
|
1315 |
-
catch (e) {
|
1316 |
-
// Ignore
|
1317 |
-
}
|
1318 |
-
var date = (offset.toLowerCase().match(/^c/) ?
|
1319 |
-
$.datepicker._getDate(inst) : null) || new Date();
|
1320 |
-
var year = date.getFullYear();
|
1321 |
-
var month = date.getMonth();
|
1322 |
-
var day = date.getDate();
|
1323 |
-
var pattern = /([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g;
|
1324 |
-
var matches = pattern.exec(offset);
|
1325 |
-
while (matches) {
|
1326 |
-
switch (matches[2] || 'd') {
|
1327 |
-
case 'd' : case 'D' :
|
1328 |
-
day += parseInt(matches[1],10); break;
|
1329 |
-
case 'w' : case 'W' :
|
1330 |
-
day += parseInt(matches[1],10) * 7; break;
|
1331 |
-
case 'm' : case 'M' :
|
1332 |
-
month += parseInt(matches[1],10);
|
1333 |
-
day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
|
1334 |
-
break;
|
1335 |
-
case 'y': case 'Y' :
|
1336 |
-
year += parseInt(matches[1],10);
|
1337 |
-
day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
|
1338 |
-
break;
|
1339 |
-
}
|
1340 |
-
matches = pattern.exec(offset);
|
1341 |
-
}
|
1342 |
-
return new Date(year, month, day);
|
1343 |
-
};
|
1344 |
-
var newDate = (date == null || date === '' ? defaultDate : (typeof date == 'string' ? offsetString(date) :
|
1345 |
-
(typeof date == 'number' ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
|
1346 |
-
newDate = (newDate && newDate.toString() == 'Invalid Date' ? defaultDate : newDate);
|
1347 |
-
if (newDate) {
|
1348 |
-
newDate.setHours(0);
|
1349 |
-
newDate.setMinutes(0);
|
1350 |
-
newDate.setSeconds(0);
|
1351 |
-
newDate.setMilliseconds(0);
|
1352 |
-
}
|
1353 |
-
return this._daylightSavingAdjust(newDate);
|
1354 |
-
},
|
1355 |
-
|
1356 |
-
/* Handle switch to/from daylight saving.
|
1357 |
-
Hours may be non-zero on daylight saving cut-over:
|
1358 |
-
> 12 when midnight changeover, but then cannot generate
|
1359 |
-
midnight datetime, so jump to 1AM, otherwise reset.
|
1360 |
-
@param date (Date) the date to check
|
1361 |
-
@return (Date) the corrected date */
|
1362 |
-
_daylightSavingAdjust: function(date) {
|
1363 |
-
if (!date) return null;
|
1364 |
-
date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
|
1365 |
-
return date;
|
1366 |
-
},
|
1367 |
-
|
1368 |
-
/* Set the date(s) directly. */
|
1369 |
-
_setDate: function(inst, date, noChange) {
|
1370 |
-
var clear = !date;
|
1371 |
-
var origMonth = inst.selectedMonth;
|
1372 |
-
var origYear = inst.selectedYear;
|
1373 |
-
var newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
|
1374 |
-
inst.selectedDay = inst.currentDay = newDate.getDate();
|
1375 |
-
inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
|
1376 |
-
inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
|
1377 |
-
if ((origMonth != inst.selectedMonth || origYear != inst.selectedYear) && !noChange)
|
1378 |
-
this._notifyChange(inst);
|
1379 |
-
this._adjustInstDate(inst);
|
1380 |
-
if (inst.input) {
|
1381 |
-
inst.input.val(clear ? '' : this._formatDate(inst));
|
1382 |
-
}
|
1383 |
-
},
|
1384 |
-
|
1385 |
-
/* Retrieve the date(s) directly. */
|
1386 |
-
_getDate: function(inst) {
|
1387 |
-
var startDate = (!inst.currentYear || (inst.input && inst.input.val() == '') ? null :
|
1388 |
-
this._daylightSavingAdjust(new Date(
|
1389 |
-
inst.currentYear, inst.currentMonth, inst.currentDay)));
|
1390 |
-
return startDate;
|
1391 |
-
},
|
1392 |
-
|
1393 |
-
/* Generate the HTML for the current state of the date picker. */
|
1394 |
-
_generateHTML: function(inst) {
|
1395 |
-
var today = new Date();
|
1396 |
-
today = this._daylightSavingAdjust(
|
1397 |
-
new Date(today.getFullYear(), today.getMonth(), today.getDate())); // clear time
|
1398 |
-
var isRTL = this._get(inst, 'isRTL');
|
1399 |
-
var showButtonPanel = this._get(inst, 'showButtonPanel');
|
1400 |
-
var hideIfNoPrevNext = this._get(inst, 'hideIfNoPrevNext');
|
1401 |
-
var navigationAsDateFormat = this._get(inst, 'navigationAsDateFormat');
|
1402 |
-
var numMonths = this._getNumberOfMonths(inst);
|
1403 |
-
var showCurrentAtPos = this._get(inst, 'showCurrentAtPos');
|
1404 |
-
var stepMonths = this._get(inst, 'stepMonths');
|
1405 |
-
var isMultiMonth = (numMonths[0] != 1 || numMonths[1] != 1);
|
1406 |
-
var currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
|
1407 |
-
new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
|
1408 |
-
var minDate = this._getMinMaxDate(inst, 'min');
|
1409 |
-
var maxDate = this._getMinMaxDate(inst, 'max');
|
1410 |
-
var drawMonth = inst.drawMonth - showCurrentAtPos;
|
1411 |
-
var drawYear = inst.drawYear;
|
1412 |
-
if (drawMonth < 0) {
|
1413 |
-
drawMonth += 12;
|
1414 |
-
drawYear--;
|
1415 |
-
}
|
1416 |
-
if (maxDate) {
|
1417 |
-
var maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
|
1418 |
-
maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
|
1419 |
-
maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
|
1420 |
-
while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
|
1421 |
-
drawMonth--;
|
1422 |
-
if (drawMonth < 0) {
|
1423 |
-
drawMonth = 11;
|
1424 |
-
drawYear--;
|
1425 |
-
}
|
1426 |
-
}
|
1427 |
-
}
|
1428 |
-
inst.drawMonth = drawMonth;
|
1429 |
-
inst.drawYear = drawYear;
|
1430 |
-
var prevText = this._get(inst, 'prevText');
|
1431 |
-
prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
|
1432 |
-
this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
|
1433 |
-
this._getFormatConfig(inst)));
|
1434 |
-
var prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
|
1435 |
-
'<a class="ui-datepicker-prev ui-corner-all" onclick="DP_jQuery_' + dpuuid +
|
1436 |
-
'.datepicker._adjustDate(\'#' + inst.id + '\', -' + stepMonths + ', \'M\');"' +
|
1437 |
-
' title="' + prevText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>' :
|
1438 |
-
(hideIfNoPrevNext ? '' : '<a class="ui-datepicker-prev ui-corner-all ui-state-disabled" title="'+ prevText +'"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>'));
|
1439 |
-
var nextText = this._get(inst, 'nextText');
|
1440 |
-
nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
|
1441 |
-
this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
|
1442 |
-
this._getFormatConfig(inst)));
|
1443 |
-
var next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
|
1444 |
-
'<a class="ui-datepicker-next ui-corner-all" onclick="DP_jQuery_' + dpuuid +
|
1445 |
-
'.datepicker._adjustDate(\'#' + inst.id + '\', +' + stepMonths + ', \'M\');"' +
|
1446 |
-
' title="' + nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>' :
|
1447 |
-
(hideIfNoPrevNext ? '' : '<a class="ui-datepicker-next ui-corner-all ui-state-disabled" title="'+ nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>'));
|
1448 |
-
var currentText = this._get(inst, 'currentText');
|
1449 |
-
var gotoDate = (this._get(inst, 'gotoCurrent') && inst.currentDay ? currentDate : today);
|
1450 |
-
currentText = (!navigationAsDateFormat ? currentText :
|
1451 |
-
this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
|
1452 |
-
var controls = (!inst.inline ? '<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" onclick="DP_jQuery_' + dpuuid +
|
1453 |
-
'.datepicker._hideDatepicker();">' + this._get(inst, 'closeText') + '</button>' : '');
|
1454 |
-
var buttonPanel = (showButtonPanel) ? '<div class="ui-datepicker-buttonpane ui-widget-content">' + (isRTL ? controls : '') +
|
1455 |
-
(this._isInRange(inst, gotoDate) ? '<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" onclick="DP_jQuery_' + dpuuid +
|
1456 |
-
'.datepicker._gotoToday(\'#' + inst.id + '\');"' +
|
1457 |
-
'>' + currentText + '</button>' : '') + (isRTL ? '' : controls) + '</div>' : '';
|
1458 |
-
var firstDay = parseInt(this._get(inst, 'firstDay'),10);
|
1459 |
-
firstDay = (isNaN(firstDay) ? 0 : firstDay);
|
1460 |
-
var showWeek = this._get(inst, 'showWeek');
|
1461 |
-
var dayNames = this._get(inst, 'dayNames');
|
1462 |
-
var dayNamesShort = this._get(inst, 'dayNamesShort');
|
1463 |
-
var dayNamesMin = this._get(inst, 'dayNamesMin');
|
1464 |
-
var monthNames = this._get(inst, 'monthNames');
|
1465 |
-
var monthNamesShort = this._get(inst, 'monthNamesShort');
|
1466 |
-
var beforeShowDay = this._get(inst, 'beforeShowDay');
|
1467 |
-
var showOtherMonths = this._get(inst, 'showOtherMonths');
|
1468 |
-
var selectOtherMonths = this._get(inst, 'selectOtherMonths');
|
1469 |
-
var calculateWeek = this._get(inst, 'calculateWeek') || this.iso8601Week;
|
1470 |
-
var defaultDate = this._getDefaultDate(inst);
|
1471 |
-
var html = '';
|
1472 |
-
for (var row = 0; row < numMonths[0]; row++) {
|
1473 |
-
var group = '';
|
1474 |
-
this.maxRows = 4;
|
1475 |
-
for (var col = 0; col < numMonths[1]; col++) {
|
1476 |
-
var selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
|
1477 |
-
var cornerClass = ' ui-corner-all';
|
1478 |
-
var calender = '';
|
1479 |
-
if (isMultiMonth) {
|
1480 |
-
calender += '<div class="ui-datepicker-group';
|
1481 |
-
if (numMonths[1] > 1)
|
1482 |
-
switch (col) {
|
1483 |
-
case 0: calender += ' ui-datepicker-group-first';
|
1484 |
-
cornerClass = ' ui-corner-' + (isRTL ? 'right' : 'left'); break;
|
1485 |
-
case numMonths[1]-1: calender += ' ui-datepicker-group-last';
|
1486 |
-
cornerClass = ' ui-corner-' + (isRTL ? 'left' : 'right'); break;
|
1487 |
-
default: calender += ' ui-datepicker-group-middle'; cornerClass = ''; break;
|
1488 |
-
}
|
1489 |
-
calender += '">';
|
1490 |
-
}
|
1491 |
-
calender += '<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix' + cornerClass + '">' +
|
1492 |
-
(/all|left/.test(cornerClass) && row == 0 ? (isRTL ? next : prev) : '') +
|
1493 |
-
(/all|right/.test(cornerClass) && row == 0 ? (isRTL ? prev : next) : '') +
|
1494 |
-
this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
|
1495 |
-
row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
|
1496 |
-
'</div><table class="ui-datepicker-calendar"><thead>' +
|
1497 |
-
'<tr>';
|
1498 |
-
var thead = (showWeek ? '<th class="ui-datepicker-week-col">' + this._get(inst, 'weekHeader') + '</th>' : '');
|
1499 |
-
for (var dow = 0; dow < 7; dow++) { // days of the week
|
1500 |
-
var day = (dow + firstDay) % 7;
|
1501 |
-
thead += '<th' + ((dow + firstDay + 6) % 7 >= 5 ? ' class="ui-datepicker-week-end"' : '') + '>' +
|
1502 |
-
'<span title="' + dayNames[day] + '">' + dayNamesMin[day] + '</span></th>';
|
1503 |
-
}
|
1504 |
-
calender += thead + '</tr></thead><tbody>';
|
1505 |
-
var daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
|
1506 |
-
if (drawYear == inst.selectedYear && drawMonth == inst.selectedMonth)
|
1507 |
-
inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
|
1508 |
-
var leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
|
1509 |
-
var curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
|
1510 |
-
var numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
|
1511 |
-
this.maxRows = numRows;
|
1512 |
-
var printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
|
1513 |
-
for (var dRow = 0; dRow < numRows; dRow++) { // create date picker rows
|
1514 |
-
calender += '<tr>';
|
1515 |
-
var tbody = (!showWeek ? '' : '<td class="ui-datepicker-week-col">' +
|
1516 |
-
this._get(inst, 'calculateWeek')(printDate) + '</td>');
|
1517 |
-
for (var dow = 0; dow < 7; dow++) { // create date picker days
|
1518 |
-
var daySettings = (beforeShowDay ?
|
1519 |
-
beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, '']);
|
1520 |
-
var otherMonth = (printDate.getMonth() != drawMonth);
|
1521 |
-
var unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
|
1522 |
-
(minDate && printDate < minDate) || (maxDate && printDate > maxDate);
|
1523 |
-
tbody += '<td class="' +
|
1524 |
-
((dow + firstDay + 6) % 7 >= 5 ? ' ui-datepicker-week-end' : '') + // highlight weekends
|
1525 |
-
(otherMonth ? ' ui-datepicker-other-month' : '') + // highlight days from other months
|
1526 |
-
((printDate.getTime() == selectedDate.getTime() && drawMonth == inst.selectedMonth && inst._keyEvent) || // user pressed key
|
1527 |
-
(defaultDate.getTime() == printDate.getTime() && defaultDate.getTime() == selectedDate.getTime()) ?
|
1528 |
-
// or defaultDate is current printedDate and defaultDate is selectedDate
|
1529 |
-
' ' + this._dayOverClass : '') + // highlight selected day
|
1530 |
-
(unselectable ? ' ' + this._unselectableClass + ' ui-state-disabled': '') + // highlight unselectable days
|
1531 |
-
(otherMonth && !showOtherMonths ? '' : ' ' + daySettings[1] + // highlight custom dates
|
1532 |
-
(printDate.getTime() == currentDate.getTime() ? ' ' + this._currentClass : '') + // highlight selected day
|
1533 |
-
(printDate.getTime() == today.getTime() ? ' ui-datepicker-today' : '')) + '"' + // highlight today (if different)
|
1534 |
-
((!otherMonth || showOtherMonths) && daySettings[2] ? ' title="' + daySettings[2] + '"' : '') + // cell title
|
1535 |
-
(unselectable ? '' : ' onclick="DP_jQuery_' + dpuuid + '.datepicker._selectDay(\'#' +
|
1536 |
-
inst.id + '\',' + printDate.getMonth() + ',' + printDate.getFullYear() + ', this);return false;"') + '>' + // actions
|
1537 |
-
(otherMonth && !showOtherMonths ? ' ' : // display for other months
|
1538 |
-
(unselectable ? '<span class="ui-state-default">' + printDate.getDate() + '</span>' : '<a class="ui-state-default' +
|
1539 |
-
(printDate.getTime() == today.getTime() ? ' ui-state-highlight' : '') +
|
1540 |
-
(printDate.getTime() == currentDate.getTime() ? ' ui-state-active' : '') + // highlight selected day
|
1541 |
-
(otherMonth ? ' ui-priority-secondary' : '') + // distinguish dates from other months
|
1542 |
-
'" href="#">' + printDate.getDate() + '</a>')) + '</td>'; // display selectable date
|
1543 |
-
printDate.setDate(printDate.getDate() + 1);
|
1544 |
-
printDate = this._daylightSavingAdjust(printDate);
|
1545 |
-
}
|
1546 |
-
calender += tbody + '</tr>';
|
1547 |
-
}
|
1548 |
-
drawMonth++;
|
1549 |
-
if (drawMonth > 11) {
|
1550 |
-
drawMonth = 0;
|
1551 |
-
drawYear++;
|
1552 |
-
}
|
1553 |
-
calender += '</tbody></table>' + (isMultiMonth ? '</div>' +
|
1554 |
-
((numMonths[0] > 0 && col == numMonths[1]-1) ? '<div class="ui-datepicker-row-break"></div>' : '') : '');
|
1555 |
-
group += calender;
|
1556 |
-
}
|
1557 |
-
html += group;
|
1558 |
-
}
|
1559 |
-
html += buttonPanel + ($.browser.msie && parseInt($.browser.version,10) < 7 && !inst.inline ?
|
1560 |
-
'<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>' : '');
|
1561 |
-
inst._keyEvent = false;
|
1562 |
-
return html;
|
1563 |
-
},
|
1564 |
-
|
1565 |
-
/* Generate the month and year header. */
|
1566 |
-
_generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
|
1567 |
-
secondary, monthNames, monthNamesShort) {
|
1568 |
-
var changeMonth = this._get(inst, 'changeMonth');
|
1569 |
-
var changeYear = this._get(inst, 'changeYear');
|
1570 |
-
var showMonthAfterYear = this._get(inst, 'showMonthAfterYear');
|
1571 |
-
var html = '<div class="ui-datepicker-title">';
|
1572 |
-
var monthHtml = '';
|
1573 |
-
// month selection
|
1574 |
-
if (secondary || !changeMonth)
|
1575 |
-
monthHtml += '<span class="ui-datepicker-month">' + monthNames[drawMonth] + '</span>';
|
1576 |
-
else {
|
1577 |
-
var inMinYear = (minDate && minDate.getFullYear() == drawYear);
|
1578 |
-
var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear);
|
1579 |
-
monthHtml += '<select class="ui-datepicker-month" ' +
|
1580 |
-
'onchange="DP_jQuery_' + dpuuid + '.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'M\');" ' +
|
1581 |
-
'onclick="DP_jQuery_' + dpuuid + '.datepicker._clickMonthYear(\'#' + inst.id + '\');"' +
|
1582 |
-
'>';
|
1583 |
-
for (var month = 0; month < 12; month++) {
|
1584 |
-
if ((!inMinYear || month >= minDate.getMonth()) &&
|
1585 |
-
(!inMaxYear || month <= maxDate.getMonth()))
|
1586 |
-
monthHtml += '<option value="' + month + '"' +
|
1587 |
-
(month == drawMonth ? ' selected="selected"' : '') +
|
1588 |
-
'>' + monthNamesShort[month] + '</option>';
|
1589 |
-
}
|
1590 |
-
monthHtml += '</select>';
|
1591 |
-
}
|
1592 |
-
if (!showMonthAfterYear)
|
1593 |
-
html += monthHtml + (secondary || !(changeMonth && changeYear) ? ' ' : '');
|
1594 |
-
// year selection
|
1595 |
-
if ( !inst.yearshtml ) {
|
1596 |
-
inst.yearshtml = '';
|
1597 |
-
if (secondary || !changeYear)
|
1598 |
-
html += '<span class="ui-datepicker-year">' + drawYear + '</span>';
|
1599 |
-
else {
|
1600 |
-
// determine range of years to display
|
1601 |
-
var years = this._get(inst, 'yearRange').split(':');
|
1602 |
-
var thisYear = new Date().getFullYear();
|
1603 |
-
var determineYear = function(value) {
|
1604 |
-
var year = (value.match(/c[+-].*/) ? drawYear + parseInt(value.substring(1), 10) :
|
1605 |
-
(value.match(/[+-].*/) ? thisYear + parseInt(value, 10) :
|
1606 |
-
parseInt(value, 10)));
|
1607 |
-
return (isNaN(year) ? thisYear : year);
|
1608 |
-
};
|
1609 |
-
var year = determineYear(years[0]);
|
1610 |
-
var endYear = Math.max(year, determineYear(years[1] || ''));
|
1611 |
-
year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
|
1612 |
-
endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
|
1613 |
-
inst.yearshtml += '<select class="ui-datepicker-year" ' +
|
1614 |
-
'onchange="DP_jQuery_' + dpuuid + '.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'Y\');" ' +
|
1615 |
-
'onclick="DP_jQuery_' + dpuuid + '.datepicker._clickMonthYear(\'#' + inst.id + '\');"' +
|
1616 |
-
'>';
|
1617 |
-
for (; year <= endYear; year++) {
|
1618 |
-
inst.yearshtml += '<option value="' + year + '"' +
|
1619 |
-
(year == drawYear ? ' selected="selected"' : '') +
|
1620 |
-
'>' + year + '</option>';
|
1621 |
-
}
|
1622 |
-
inst.yearshtml += '</select>';
|
1623 |
-
|
1624 |
-
html += inst.yearshtml;
|
1625 |
-
inst.yearshtml = null;
|
1626 |
-
}
|
1627 |
-
}
|
1628 |
-
html += this._get(inst, 'yearSuffix');
|
1629 |
-
if (showMonthAfterYear)
|
1630 |
-
html += (secondary || !(changeMonth && changeYear) ? ' ' : '') + monthHtml;
|
1631 |
-
html += '</div>'; // Close datepicker_header
|
1632 |
-
return html;
|
1633 |
-
},
|
1634 |
-
|
1635 |
-
/* Adjust one of the date sub-fields. */
|
1636 |
-
_adjustInstDate: function(inst, offset, period) {
|
1637 |
-
var year = inst.drawYear + (period == 'Y' ? offset : 0);
|
1638 |
-
var month = inst.drawMonth + (period == 'M' ? offset : 0);
|
1639 |
-
var day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) +
|
1640 |
-
(period == 'D' ? offset : 0);
|
1641 |
-
var date = this._restrictMinMax(inst,
|
1642 |
-
this._daylightSavingAdjust(new Date(year, month, day)));
|
1643 |
-
inst.selectedDay = date.getDate();
|
1644 |
-
inst.drawMonth = inst.selectedMonth = date.getMonth();
|
1645 |
-
inst.drawYear = inst.selectedYear = date.getFullYear();
|
1646 |
-
if (period == 'M' || period == 'Y')
|
1647 |
-
this._notifyChange(inst);
|
1648 |
-
},
|
1649 |
-
|
1650 |
-
/* Ensure a date is within any min/max bounds. */
|
1651 |
-
_restrictMinMax: function(inst, date) {
|
1652 |
-
var minDate = this._getMinMaxDate(inst, 'min');
|
1653 |
-
var maxDate = this._getMinMaxDate(inst, 'max');
|
1654 |
-
var newDate = (minDate && date < minDate ? minDate : date);
|
1655 |
-
newDate = (maxDate && newDate > maxDate ? maxDate : newDate);
|
1656 |
-
return newDate;
|
1657 |
-
},
|
1658 |
-
|
1659 |
-
/* Notify change of month/year. */
|
1660 |
-
_notifyChange: function(inst) {
|
1661 |
-
var onChange = this._get(inst, 'onChangeMonthYear');
|
1662 |
-
if (onChange)
|
1663 |
-
onChange.apply((inst.input ? inst.input[0] : null),
|
1664 |
-
[inst.selectedYear, inst.selectedMonth + 1, inst]);
|
1665 |
-
},
|
1666 |
-
|
1667 |
-
/* Determine the number of months to show. */
|
1668 |
-
_getNumberOfMonths: function(inst) {
|
1669 |
-
var numMonths = this._get(inst, 'numberOfMonths');
|
1670 |
-
return (numMonths == null ? [1, 1] : (typeof numMonths == 'number' ? [1, numMonths] : numMonths));
|
1671 |
-
},
|
1672 |
-
|
1673 |
-
/* Determine the current maximum date - ensure no time components are set. */
|
1674 |
-
_getMinMaxDate: function(inst, minMax) {
|
1675 |
-
return this._determineDate(inst, this._get(inst, minMax + 'Date'), null);
|
1676 |
-
},
|
1677 |
-
|
1678 |
-
/* Find the number of days in a given month. */
|
1679 |
-
_getDaysInMonth: function(year, month) {
|
1680 |
-
return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
|
1681 |
-
},
|
1682 |
-
|
1683 |
-
/* Find the day of the week of the first of a month. */
|
1684 |
-
_getFirstDayOfMonth: function(year, month) {
|
1685 |
-
return new Date(year, month, 1).getDay();
|
1686 |
-
},
|
1687 |
-
|
1688 |
-
/* Determines if we should allow a "next/prev" month display change. */
|
1689 |
-
_canAdjustMonth: function(inst, offset, curYear, curMonth) {
|
1690 |
-
var numMonths = this._getNumberOfMonths(inst);
|
1691 |
-
var date = this._daylightSavingAdjust(new Date(curYear,
|
1692 |
-
curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
|
1693 |
-
if (offset < 0)
|
1694 |
-
date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
|
1695 |
-
return this._isInRange(inst, date);
|
1696 |
-
},
|
1697 |
-
|
1698 |
-
/* Is the given date in the accepted range? */
|
1699 |
-
_isInRange: function(inst, date) {
|
1700 |
-
var minDate = this._getMinMaxDate(inst, 'min');
|
1701 |
-
var maxDate = this._getMinMaxDate(inst, 'max');
|
1702 |
-
return ((!minDate || date.getTime() >= minDate.getTime()) &&
|
1703 |
-
(!maxDate || date.getTime() <= maxDate.getTime()));
|
1704 |
-
},
|
1705 |
-
|
1706 |
-
/* Provide the configuration settings for formatting/parsing. */
|
1707 |
-
_getFormatConfig: function(inst) {
|
1708 |
-
var shortYearCutoff = this._get(inst, 'shortYearCutoff');
|
1709 |
-
shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff :
|
1710 |
-
new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
|
1711 |
-
return {shortYearCutoff: shortYearCutoff,
|
1712 |
-
dayNamesShort: this._get(inst, 'dayNamesShort'), dayNames: this._get(inst, 'dayNames'),
|
1713 |
-
monthNamesShort: this._get(inst, 'monthNamesShort'), monthNames: this._get(inst, 'monthNames')};
|
1714 |
-
},
|
1715 |
-
|
1716 |
-
/* Format the given date for display. */
|
1717 |
-
_formatDate: function(inst, day, month, year) {
|
1718 |
-
if (!day) {
|
1719 |
-
inst.currentDay = inst.selectedDay;
|
1720 |
-
inst.currentMonth = inst.selectedMonth;
|
1721 |
-
inst.currentYear = inst.selectedYear;
|
1722 |
-
}
|
1723 |
-
var date = (day ? (typeof day == 'object' ? day :
|
1724 |
-
this._daylightSavingAdjust(new Date(year, month, day))) :
|
1725 |
-
this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
|
1726 |
-
return this.formatDate(this._get(inst, 'dateFormat'), date, this._getFormatConfig(inst));
|
1727 |
-
}
|
1728 |
-
});
|
1729 |
-
|
1730 |
-
/*
|
1731 |
-
* Bind hover events for datepicker elements.
|
1732 |
-
* Done via delegate so the binding only occurs once in the lifetime of the parent div.
|
1733 |
-
* Global instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
|
1734 |
-
*/
|
1735 |
-
function bindHover(dpDiv) {
|
1736 |
-
var selector = 'button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a';
|
1737 |
-
return dpDiv.bind('mouseout', function(event) {
|
1738 |
-
var elem = $( event.target ).closest( selector );
|
1739 |
-
if ( !elem.length ) {
|
1740 |
-
return;
|
1741 |
-
}
|
1742 |
-
elem.removeClass( "ui-state-hover ui-datepicker-prev-hover ui-datepicker-next-hover" );
|
1743 |
-
})
|
1744 |
-
.bind('mouseover', function(event) {
|
1745 |
-
var elem = $( event.target ).closest( selector );
|
1746 |
-
if ($.datepicker._isDisabledDatepicker( instActive.inline ? dpDiv.parent()[0] : instActive.input[0]) ||
|
1747 |
-
!elem.length ) {
|
1748 |
-
return;
|
1749 |
-
}
|
1750 |
-
elem.parents('.ui-datepicker-calendar').find('a').removeClass('ui-state-hover');
|
1751 |
-
elem.addClass('ui-state-hover');
|
1752 |
-
if (elem.hasClass('ui-datepicker-prev')) elem.addClass('ui-datepicker-prev-hover');
|
1753 |
-
if (elem.hasClass('ui-datepicker-next')) elem.addClass('ui-datepicker-next-hover');
|
1754 |
-
});
|
1755 |
-
}
|
1756 |
-
|
1757 |
-
/* jQuery extend now ignores nulls! */
|
1758 |
-
function extendRemove(target, props) {
|
1759 |
-
$.extend(target, props);
|
1760 |
-
for (var name in props)
|
1761 |
-
if (props[name] == null || props[name] == undefined)
|
1762 |
-
target[name] = props[name];
|
1763 |
-
return target;
|
1764 |
-
};
|
1765 |
-
|
1766 |
-
/* Determine whether an object is an array. */
|
1767 |
-
function isArray(a) {
|
1768 |
-
return (a && (($.browser.safari && typeof a == 'object' && a.length) ||
|
1769 |
-
(a.constructor && a.constructor.toString().match(/\Array\(\)/))));
|
1770 |
-
};
|
1771 |
-
|
1772 |
-
/* Invoke the datepicker functionality.
|
1773 |
-
@param options string - a command, optionally followed by additional parameters or
|
1774 |
-
Object - settings for attaching new datepicker functionality
|
1775 |
-
@return jQuery object */
|
1776 |
-
$.fn.datepicker = function(options){
|
1777 |
-
|
1778 |
-
/* Verify an empty collection wasn't passed - Fixes #6976 */
|
1779 |
-
if ( !this.length ) {
|
1780 |
-
return this;
|
1781 |
-
}
|
1782 |
-
|
1783 |
-
/* Initialise the date picker. */
|
1784 |
-
if (!$.datepicker.initialized) {
|
1785 |
-
$(document).mousedown($.datepicker._checkExternalClick).
|
1786 |
-
find('body').append($.datepicker.dpDiv);
|
1787 |
-
$.datepicker.initialized = true;
|
1788 |
-
}
|
1789 |
-
|
1790 |
-
var otherArgs = Array.prototype.slice.call(arguments, 1);
|
1791 |
-
if (typeof options == 'string' && (options == 'isDisabled' || options == 'getDate' || options == 'widget'))
|
1792 |
-
return $.datepicker['_' + options + 'Datepicker'].
|
1793 |
-
apply($.datepicker, [this[0]].concat(otherArgs));
|
1794 |
-
if (options == 'option' && arguments.length == 2 && typeof arguments[1] == 'string')
|
1795 |
-
return $.datepicker['_' + options + 'Datepicker'].
|
1796 |
-
apply($.datepicker, [this[0]].concat(otherArgs));
|
1797 |
-
return this.each(function() {
|
1798 |
-
typeof options == 'string' ?
|
1799 |
-
$.datepicker['_' + options + 'Datepicker'].
|
1800 |
-
apply($.datepicker, [this].concat(otherArgs)) :
|
1801 |
-
$.datepicker._attachDatepicker(this, options);
|
1802 |
-
});
|
1803 |
-
};
|
1804 |
-
|
1805 |
-
$.datepicker = new Datepicker(); // singleton instance
|
1806 |
-
$.datepicker.initialized = false;
|
1807 |
-
$.datepicker.uuid = new Date().getTime();
|
1808 |
-
$.datepicker.version = "1.8.14";
|
1809 |
-
|
1810 |
-
// Workaround for #4055
|
1811 |
-
// Add another global to avoid noConflict issues with inline event handlers
|
1812 |
-
window['DP_jQuery_' + dpuuid] = $;
|
1813 |
-
|
1814 |
-
})(jQuery);
|
1 |
+
/*
|
2 |
+
* jQuery UI Datepicker 1.8.14
|
3 |
+
*
|
4 |
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
5 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
6 |
+
* http://jquery.org/license
|
7 |
+
*
|
8 |
+
* http://docs.jquery.com/UI/Datepicker
|
9 |
+
*
|
10 |
+
* Depends:
|
11 |
+
* jquery.ui.core.js
|
12 |
+
*/
|
13 |
+
(function( $, undefined ) {
|
14 |
+
|
15 |
+
$.extend($.ui, { datepicker: { version: "1.8.14" } });
|
16 |
+
|
17 |
+
var PROP_NAME = 'datepicker';
|
18 |
+
var dpuuid = new Date().getTime();
|
19 |
+
var instActive;
|
20 |
+
|
21 |
+
/* Date picker manager.
|
22 |
+
Use the singleton instance of this class, $.datepicker, to interact with the date picker.
|
23 |
+
Settings for (groups of) date pickers are maintained in an instance object,
|
24 |
+
allowing multiple different settings on the same page. */
|
25 |
+
|
26 |
+
function Datepicker() {
|
27 |
+
this.debug = false; // Change this to true to start debugging
|
28 |
+
this._curInst = null; // The current instance in use
|
29 |
+
this._keyEvent = false; // If the last event was a key event
|
30 |
+
this._disabledInputs = []; // List of date picker inputs that have been disabled
|
31 |
+
this._datepickerShowing = false; // True if the popup picker is showing , false if not
|
32 |
+
this._inDialog = false; // True if showing within a "dialog", false if not
|
33 |
+
this._mainDivId = 'ui-datepicker-div'; // The ID of the main datepicker division
|
34 |
+
this._inlineClass = 'ui-datepicker-inline'; // The name of the inline marker class
|
35 |
+
this._appendClass = 'ui-datepicker-append'; // The name of the append marker class
|
36 |
+
this._triggerClass = 'ui-datepicker-trigger'; // The name of the trigger marker class
|
37 |
+
this._dialogClass = 'ui-datepicker-dialog'; // The name of the dialog marker class
|
38 |
+
this._disableClass = 'ui-datepicker-disabled'; // The name of the disabled covering marker class
|
39 |
+
this._unselectableClass = 'ui-datepicker-unselectable'; // The name of the unselectable cell marker class
|
40 |
+
this._currentClass = 'ui-datepicker-current-day'; // The name of the current day marker class
|
41 |
+
this._dayOverClass = 'ui-datepicker-days-cell-over'; // The name of the day hover marker class
|
42 |
+
this.regional = []; // Available regional settings, indexed by language code
|
43 |
+
this.regional[''] = { // Default regional settings
|
44 |
+
closeText: 'Done', // Display text for close link
|
45 |
+
prevText: 'Prev', // Display text for previous month link
|
46 |
+
nextText: 'Next', // Display text for next month link
|
47 |
+
currentText: 'Today', // Display text for current month link
|
48 |
+
monthNames: ['January','February','March','April','May','June',
|
49 |
+
'July','August','September','October','November','December'], // Names of months for drop-down and formatting
|
50 |
+
monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], // For formatting
|
51 |
+
dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting
|
52 |
+
dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting
|
53 |
+
dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Column headings for days starting at Sunday
|
54 |
+
weekHeader: 'Wk', // Column header for week of the year
|
55 |
+
dateFormat: 'mm/dd/yy', // See format options on parseDate
|
56 |
+
firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
|
57 |
+
isRTL: false, // True if right-to-left language, false if left-to-right
|
58 |
+
showMonthAfterYear: false, // True if the year select precedes month, false for month then year
|
59 |
+
yearSuffix: '' // Additional text to append to the year in the month headers
|
60 |
+
};
|
61 |
+
this._defaults = { // Global defaults for all the date picker instances
|
62 |
+
showOn: 'focus', // 'focus' for popup on focus,
|
63 |
+
// 'button' for trigger button, or 'both' for either
|
64 |
+
showAnim: 'fadeIn', // Name of jQuery animation for popup
|
65 |
+
showOptions: {}, // Options for enhanced animations
|
66 |
+
defaultDate: null, // Used when field is blank: actual date,
|
67 |
+
// +/-number for offset from today, null for today
|
68 |
+
appendText: '', // Display text following the input box, e.g. showing the format
|
69 |
+
buttonText: '...', // Text for trigger button
|
70 |
+
buttonImage: '', // URL for trigger button image
|
71 |
+
buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
|
72 |
+
hideIfNoPrevNext: false, // True to hide next/previous month links
|
73 |
+
// if not applicable, false to just disable them
|
74 |
+
navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
|
75 |
+
gotoCurrent: false, // True if today link goes back to current selection instead
|
76 |
+
changeMonth: false, // True if month can be selected directly, false if only prev/next
|
77 |
+
changeYear: false, // True if year can be selected directly, false if only prev/next
|
78 |
+
yearRange: 'c-10:c+10', // Range of years to display in drop-down,
|
79 |
+
// either relative to today's year (-nn:+nn), relative to currently displayed year
|
80 |
+
// (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
|
81 |
+
showOtherMonths: false, // True to show dates in other months, false to leave blank
|
82 |
+
selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
|
83 |
+
showWeek: false, // True to show week of the year, false to not show it
|
84 |
+
calculateWeek: this.iso8601Week, // How to calculate the week of the year,
|
85 |
+
// takes a Date and returns the number of the week for it
|
86 |
+
shortYearCutoff: '+10', // Short year values < this are in the current century,
|
87 |
+
// > this are in the previous century,
|
88 |
+
// string value starting with '+' for current year + value
|
89 |
+
minDate: null, // The earliest selectable date, or null for no limit
|
90 |
+
maxDate: null, // The latest selectable date, or null for no limit
|
91 |
+
duration: 'fast', // Duration of display/closure
|
92 |
+
beforeShowDay: null, // Function that takes a date and returns an array with
|
93 |
+
// [0] = true if selectable, false if not, [1] = custom CSS class name(s) or '',
|
94 |
+
// [2] = cell title (optional), e.g. $.datepicker.noWeekends
|
95 |
+
beforeShow: null, // Function that takes an input field and
|
96 |
+
// returns a set of custom settings for the date picker
|
97 |
+
onSelect: null, // Define a callback function when a date is selected
|
98 |
+
onChangeMonthYear: null, // Define a callback function when the month or year is changed
|
99 |
+
onClose: null, // Define a callback function when the datepicker is closed
|
100 |
+
numberOfMonths: 1, // Number of months to show at a time
|
101 |
+
showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
|
102 |
+
stepMonths: 1, // Number of months to step back/forward
|
103 |
+
stepBigMonths: 12, // Number of months to step back/forward for the big links
|
104 |
+
altField: '', // Selector for an alternate field to store selected dates into
|
105 |
+
altFormat: '', // The date format to use for the alternate field
|
106 |
+
constrainInput: true, // The input is constrained by the current date format
|
107 |
+
showButtonPanel: false, // True to show button panel, false to not show it
|
108 |
+
autoSize: false // True to size the input for the date format, false to leave as is
|
109 |
+
};
|
110 |
+
$.extend(this._defaults, this.regional['']);
|
111 |
+
this.dpDiv = bindHover($('<div id="' + this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'));
|
112 |
+
}
|
113 |
+
|
114 |
+
$.extend(Datepicker.prototype, {
|
115 |
+
/* Class name added to elements to indicate already configured with a date picker. */
|
116 |
+
markerClassName: 'hasDatepicker',
|
117 |
+
|
118 |
+
//Keep track of the maximum number of rows displayed (see #7043)
|
119 |
+
maxRows: 4,
|
120 |
+
|
121 |
+
/* Debug logging (if enabled). */
|
122 |
+
log: function () {
|
123 |
+
if (this.debug)
|
124 |
+
console.log.apply('', arguments);
|
125 |
+
},
|
126 |
+
|
127 |
+
// TODO rename to "widget" when switching to widget factory
|
128 |
+
_widgetDatepicker: function() {
|
129 |
+
return this.dpDiv;
|
130 |
+
},
|
131 |
+
|
132 |
+
/* Override the default settings for all instances of the date picker.
|
133 |
+
@param settings object - the new settings to use as defaults (anonymous object)
|
134 |
+
@return the manager object */
|
135 |
+
setDefaults: function(settings) {
|
136 |
+
extendRemove(this._defaults, settings || {});
|
137 |
+
return this;
|
138 |
+
},
|
139 |
+
|
140 |
+
/* Attach the date picker to a jQuery selection.
|
141 |
+
@param target element - the target input field or division or span
|
142 |
+
@param settings object - the new settings to use for this date picker instance (anonymous) */
|
143 |
+
_attachDatepicker: function(target, settings) {
|
144 |
+
// check for settings on the control itself - in namespace 'date:'
|
145 |
+
var inlineSettings = null;
|
146 |
+
for (var attrName in this._defaults) {
|
147 |
+
var attrValue = target.getAttribute('date:' + attrName);
|
148 |
+
if (attrValue) {
|
149 |
+
inlineSettings = inlineSettings || {};
|
150 |
+
try {
|
151 |
+
inlineSettings[attrName] = eval(attrValue);
|
152 |
+
} catch (err) {
|
153 |
+
inlineSettings[attrName] = attrValue;
|
154 |
+
}
|
155 |
+
}
|
156 |
+
}
|
157 |
+
var nodeName = target.nodeName.toLowerCase();
|
158 |
+
var inline = (nodeName == 'div' || nodeName == 'span');
|
159 |
+
if (!target.id) {
|
160 |
+
this.uuid += 1;
|
161 |
+
target.id = 'dp' + this.uuid;
|
162 |
+
}
|
163 |
+
var inst = this._newInst($(target), inline);
|
164 |
+
inst.settings = $.extend({}, settings || {}, inlineSettings || {});
|
165 |
+
if (nodeName == 'input') {
|
166 |
+
this._connectDatepicker(target, inst);
|
167 |
+
} else if (inline) {
|
168 |
+
this._inlineDatepicker(target, inst);
|
169 |
+
}
|
170 |
+
},
|
171 |
+
|
172 |
+
/* Create a new instance object. */
|
173 |
+
_newInst: function(target, inline) {
|
174 |
+
var id = target[0].id.replace(/([^A-Za-z0-9_-])/g, '\\\\$1'); // escape jQuery meta chars
|
175 |
+
return {id: id, input: target, // associated target
|
176 |
+
selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
|
177 |
+
drawMonth: 0, drawYear: 0, // month being drawn
|
178 |
+
inline: inline, // is datepicker inline or not
|
179 |
+
dpDiv: (!inline ? this.dpDiv : // presentation div
|
180 |
+
bindHover($('<div class="' + this._inlineClass + ' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>')))};
|
181 |
+
},
|
182 |
+
|
183 |
+
/* Attach the date picker to an input field. */
|
184 |
+
_connectDatepicker: function(target, inst) {
|
185 |
+
var input = $(target);
|
186 |
+
inst.append = $([]);
|
187 |
+
inst.trigger = $([]);
|
188 |
+
if (input.hasClass(this.markerClassName))
|
189 |
+
return;
|
190 |
+
this._attachments(input, inst);
|
191 |
+
input.addClass(this.markerClassName).keydown(this._doKeyDown).
|
192 |
+
keypress(this._doKeyPress).keyup(this._doKeyUp).
|
193 |
+
bind("setData.datepicker", function(event, key, value) {
|
194 |
+
inst.settings[key] = value;
|
195 |
+
}).bind("getData.datepicker", function(event, key) {
|
196 |
+
return this._get(inst, key);
|
197 |
+
});
|
198 |
+
this._autoSize(inst);
|
199 |
+
$.data(target, PROP_NAME, inst);
|
200 |
+
},
|
201 |
+
|
202 |
+
/* Make attachments based on settings. */
|
203 |
+
_attachments: function(input, inst) {
|
204 |
+
var appendText = this._get(inst, 'appendText');
|
205 |
+
var isRTL = this._get(inst, 'isRTL');
|
206 |
+
if (inst.append)
|
207 |
+
inst.append.remove();
|
208 |
+
if (appendText) {
|
209 |
+
inst.append = $('<span class="' + this._appendClass + '">' + appendText + '</span>');
|
210 |
+
input[isRTL ? 'before' : 'after'](inst.append);
|
211 |
+
}
|
212 |
+
input.unbind('focus', this._showDatepicker);
|
213 |
+
if (inst.trigger)
|
214 |
+
inst.trigger.remove();
|
215 |
+
var showOn = this._get(inst, 'showOn');
|
216 |
+
if (showOn == 'focus' || showOn == 'both') // pop-up date picker when in the marked field
|
217 |
+
input.focus(this._showDatepicker);
|
218 |
+
if (showOn == 'button' || showOn == 'both') { // pop-up date picker when button clicked
|
219 |
+
var buttonText = this._get(inst, 'buttonText');
|
220 |
+
var buttonImage = this._get(inst, 'buttonImage');
|
221 |
+
inst.trigger = $(this._get(inst, 'buttonImageOnly') ?
|
222 |
+
$('<img/>').addClass(this._triggerClass).
|
223 |
+
attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
|
224 |
+
$('<button type="button"></button>').addClass(this._triggerClass).
|
225 |
+
html(buttonImage == '' ? buttonText : $('<img/>').attr(
|
226 |
+
{ src:buttonImage, alt:buttonText, title:buttonText })));
|
227 |
+
input[isRTL ? 'before' : 'after'](inst.trigger);
|
228 |
+
inst.trigger.click(function() {
|
229 |
+
if ($.datepicker._datepickerShowing && $.datepicker._lastInput == input[0])
|
230 |
+
$.datepicker._hideDatepicker();
|
231 |
+
else
|
232 |
+
$.datepicker._showDatepicker(input[0]);
|
233 |
+
return false;
|
234 |
+
});
|
235 |
+
}
|
236 |
+
},
|
237 |
+
|
238 |
+
/* Apply the maximum length for the date format. */
|
239 |
+
_autoSize: function(inst) {
|
240 |
+
if (this._get(inst, 'autoSize') && !inst.inline) {
|
241 |
+
var date = new Date(2009, 12 - 1, 20); // Ensure double digits
|
242 |
+
var dateFormat = this._get(inst, 'dateFormat');
|
243 |
+
if (dateFormat.match(/[DM]/)) {
|
244 |
+
var findMax = function(names) {
|
245 |
+
var max = 0;
|
246 |
+
var maxI = 0;
|
247 |
+
for (var i = 0; i < names.length; i++) {
|
248 |
+
if (names[i].length > max) {
|
249 |
+
max = names[i].length;
|
250 |
+
maxI = i;
|
251 |
+
}
|
252 |
+
}
|
253 |
+
return maxI;
|
254 |
+
};
|
255 |
+
date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
|
256 |
+
'monthNames' : 'monthNamesShort'))));
|
257 |
+
date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
|
258 |
+
'dayNames' : 'dayNamesShort'))) + 20 - date.getDay());
|
259 |
+
}
|
260 |
+
inst.input.attr('size', this._formatDate(inst, date).length);
|
261 |
+
}
|
262 |
+
},
|
263 |
+
|
264 |
+
/* Attach an inline date picker to a div. */
|
265 |
+
_inlineDatepicker: function(target, inst) {
|
266 |
+
var divSpan = $(target);
|
267 |
+
if (divSpan.hasClass(this.markerClassName))
|
268 |
+
return;
|
269 |
+
divSpan.addClass(this.markerClassName).append(inst.dpDiv).
|
270 |
+
bind("setData.datepicker", function(event, key, value){
|
271 |
+
inst.settings[key] = value;
|
272 |
+
}).bind("getData.datepicker", function(event, key){
|
273 |
+
return this._get(inst, key);
|
274 |
+
});
|
275 |
+
$.data(target, PROP_NAME, inst);
|
276 |
+
this._setDate(inst, this._getDefaultDate(inst), true);
|
277 |
+
this._updateDatepicker(inst);
|
278 |
+
this._updateAlternate(inst);
|
279 |
+
inst.dpDiv.show();
|
280 |
+
},
|
281 |
+
|
282 |
+
/* Pop-up the date picker in a "dialog" box.
|
283 |
+
@param input element - ignored
|
284 |
+
@param date string or Date - the initial date to display
|
285 |
+
@param onSelect function - the function to call when a date is selected
|
286 |
+
@param settings object - update the dialog date picker instance's settings (anonymous object)
|
287 |
+
@param pos int[2] - coordinates for the dialog's position within the screen or
|
288 |
+
event - with x/y coordinates or
|
289 |
+
leave empty for default (screen centre)
|
290 |
+
@return the manager object */
|
291 |
+
_dialogDatepicker: function(input, date, onSelect, settings, pos) {
|
292 |
+
var inst = this._dialogInst; // internal instance
|
293 |
+
if (!inst) {
|
294 |
+
this.uuid += 1;
|
295 |
+
var id = 'dp' + this.uuid;
|
296 |
+
this._dialogInput = $('<input type="text" id="' + id +
|
297 |
+
'" style="position: absolute; top: -100px; width: 0px; z-index: -10;"/>');
|
298 |
+
this._dialogInput.keydown(this._doKeyDown);
|
299 |
+
$('body').append(this._dialogInput);
|
300 |
+
inst = this._dialogInst = this._newInst(this._dialogInput, false);
|
301 |
+
inst.settings = {};
|
302 |
+
$.data(this._dialogInput[0], PROP_NAME, inst);
|
303 |
+
}
|
304 |
+
extendRemove(inst.settings, settings || {});
|
305 |
+
date = (date && date.constructor == Date ? this._formatDate(inst, date) : date);
|
306 |
+
this._dialogInput.val(date);
|
307 |
+
|
308 |
+
this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
|
309 |
+
if (!this._pos) {
|
310 |
+
var browserWidth = document.documentElement.clientWidth;
|
311 |
+
var browserHeight = document.documentElement.clientHeight;
|
312 |
+
var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
|
313 |
+
var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
|
314 |
+
this._pos = // should use actual width/height below
|
315 |
+
[(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
|
316 |
+
}
|
317 |
+
|
318 |
+
// move input on screen for focus, but hidden behind dialog
|
319 |
+
this._dialogInput.css('left', (this._pos[0] + 20) + 'px').css('top', this._pos[1] + 'px');
|
320 |
+
inst.settings.onSelect = onSelect;
|
321 |
+
this._inDialog = true;
|
322 |
+
this.dpDiv.addClass(this._dialogClass);
|
323 |
+
this._showDatepicker(this._dialogInput[0]);
|
324 |
+
if ($.blockUI)
|
325 |
+
$.blockUI(this.dpDiv);
|
326 |
+
$.data(this._dialogInput[0], PROP_NAME, inst);
|
327 |
+
return this;
|
328 |
+
},
|
329 |
+
|
330 |
+
/* Detach a datepicker from its control.
|
331 |
+
@param target element - the target input field or division or span */
|
332 |
+
_destroyDatepicker: function(target) {
|
333 |
+
var $target = $(target);
|
334 |
+
var inst = $.data(target, PROP_NAME);
|
335 |
+
if (!$target.hasClass(this.markerClassName)) {
|
336 |
+
return;
|
337 |
+
}
|
338 |
+
var nodeName = target.nodeName.toLowerCase();
|
339 |
+
$.removeData(target, PROP_NAME);
|
340 |
+
if (nodeName == 'input') {
|
341 |
+
inst.append.remove();
|
342 |
+
inst.trigger.remove();
|
343 |
+
$target.removeClass(this.markerClassName).
|
344 |
+
unbind('focus', this._showDatepicker).
|
345 |
+
unbind('keydown', this._doKeyDown).
|
346 |
+
unbind('keypress', this._doKeyPress).
|
347 |
+
unbind('keyup', this._doKeyUp);
|
348 |
+
} else if (nodeName == 'div' || nodeName == 'span')
|
349 |
+
$target.removeClass(this.markerClassName).empty();
|
350 |
+
},
|
351 |
+
|
352 |
+
/* Enable the date picker to a jQuery selection.
|
353 |
+
@param target element - the target input field or division or span */
|
354 |
+
_enableDatepicker: function(target) {
|
355 |
+
var $target = $(target);
|
356 |
+
var inst = $.data(target, PROP_NAME);
|
357 |
+
if (!$target.hasClass(this.markerClassName)) {
|
358 |
+
return;
|
359 |
+
}
|
360 |
+
var nodeName = target.nodeName.toLowerCase();
|
361 |
+
if (nodeName == 'input') {
|
362 |
+
target.disabled = false;
|
363 |
+
inst.trigger.filter('button').
|
364 |
+
each(function() { this.disabled = false; }).end().
|
365 |
+
filter('img').css({opacity: '1.0', cursor: ''});
|
366 |
+
}
|
367 |
+
else if (nodeName == 'div' || nodeName == 'span') {
|
368 |
+
var inline = $target.children('.' + this._inlineClass);
|
369 |
+
inline.children().removeClass('ui-state-disabled');
|
370 |
+
inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
|
371 |
+
removeAttr("disabled");
|
372 |
+
}
|
373 |
+
this._disabledInputs = $.map(this._disabledInputs,
|
374 |
+
function(value) { return (value == target ? null : value); }); // delete entry
|
375 |
+
},
|
376 |
+
|
377 |
+
/* Disable the date picker to a jQuery selection.
|
378 |
+
@param target element - the target input field or division or span */
|
379 |
+
_disableDatepicker: function(target) {
|
380 |
+
var $target = $(target);
|
381 |
+
var inst = $.data(target, PROP_NAME);
|
382 |
+
if (!$target.hasClass(this.markerClassName)) {
|
383 |
+
return;
|
384 |
+
}
|
385 |
+
var nodeName = target.nodeName.toLowerCase();
|
386 |
+
if (nodeName == 'input') {
|
387 |
+
target.disabled = true;
|
388 |
+
inst.trigger.filter('button').
|
389 |
+
each(function() { this.disabled = true; }).end().
|
390 |
+
filter('img').css({opacity: '0.5', cursor: 'default'});
|
391 |
+
}
|
392 |
+
else if (nodeName == 'div' || nodeName == 'span') {
|
393 |
+
var inline = $target.children('.' + this._inlineClass);
|
394 |
+
inline.children().addClass('ui-state-disabled');
|
395 |
+
inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
|
396 |
+
attr("disabled", "disabled");
|
397 |
+
}
|
398 |
+
this._disabledInputs = $.map(this._disabledInputs,
|
399 |
+
function(value) { return (value == target ? null : value); }); // delete entry
|
400 |
+
this._disabledInputs[this._disabledInputs.length] = target;
|
401 |
+
},
|
402 |
+
|
403 |
+
/* Is the first field in a jQuery collection disabled as a datepicker?
|
404 |
+
@param target element - the target input field or division or span
|
405 |
+
@return boolean - true if disabled, false if enabled */
|
406 |
+
_isDisabledDatepicker: function(target) {
|
407 |
+
if (!target) {
|
408 |
+
return false;
|
409 |
+
}
|
410 |
+
for (var i = 0; i < this._disabledInputs.length; i++) {
|
411 |
+
if (this._disabledInputs[i] == target)
|
412 |
+
return true;
|
413 |
+
}
|
414 |
+
return false;
|
415 |
+
},
|
416 |
+
|
417 |
+
/* Retrieve the instance data for the target control.
|
418 |
+
@param target element - the target input field or division or span
|
419 |
+
@return object - the associated instance data
|
420 |
+
@throws error if a jQuery problem getting data */
|
421 |
+
_getInst: function(target) {
|
422 |
+
try {
|
423 |
+
return $.data(target, PROP_NAME);
|
424 |
+
}
|
425 |
+
catch (err) {
|
426 |
+
throw 'Missing instance data for this datepicker';
|
427 |
+
}
|
428 |
+
},
|
429 |
+
|
430 |
+
/* Update or retrieve the settings for a date picker attached to an input field or division.
|
431 |
+
@param target element - the target input field or division or span
|
432 |
+
@param name object - the new settings to update or
|
433 |
+
string - the name of the setting to change or retrieve,
|
434 |
+
when retrieving also 'all' for all instance settings or
|
435 |
+
'defaults' for all global defaults
|
436 |
+
@param value any - the new value for the setting
|
437 |
+
(omit if above is an object or to retrieve a value) */
|
438 |
+
_optionDatepicker: function(target, name, value) {
|
439 |
+
var inst = this._getInst(target);
|
440 |
+
if (arguments.length == 2 && typeof name == 'string') {
|
441 |
+
return (name == 'defaults' ? $.extend({}, $.datepicker._defaults) :
|
442 |
+
(inst ? (name == 'all' ? $.extend({}, inst.settings) :
|
443 |
+
this._get(inst, name)) : null));
|
444 |
+
}
|
445 |
+
var settings = name || {};
|
446 |
+
if (typeof name == 'string') {
|
447 |
+
settings = {};
|
448 |
+
settings[name] = value;
|
449 |
+
}
|
450 |
+
if (inst) {
|
451 |
+
if (this._curInst == inst) {
|
452 |
+
this._hideDatepicker();
|
453 |
+
}
|
454 |
+
var date = this._getDateDatepicker(target, true);
|
455 |
+
var minDate = this._getMinMaxDate(inst, 'min');
|
456 |
+
var maxDate = this._getMinMaxDate(inst, 'max');
|
457 |
+
extendRemove(inst.settings, settings);
|
458 |
+
// reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
|
459 |
+
if (minDate !== null && settings['dateFormat'] !== undefined && settings['minDate'] === undefined)
|
460 |
+
inst.settings.minDate = this._formatDate(inst, minDate);
|
461 |
+
if (maxDate !== null && settings['dateFormat'] !== undefined && settings['maxDate'] === undefined)
|
462 |
+
inst.settings.maxDate = this._formatDate(inst, maxDate);
|
463 |
+
this._attachments($(target), inst);
|
464 |
+
this._autoSize(inst);
|
465 |
+
this._setDate(inst, date);
|
466 |
+
this._updateAlternate(inst);
|
467 |
+
this._updateDatepicker(inst);
|
468 |
+
}
|
469 |
+
},
|
470 |
+
|
471 |
+
// change method deprecated
|
472 |
+
_changeDatepicker: function(target, name, value) {
|
473 |
+
this._optionDatepicker(target, name, value);
|
474 |
+
},
|
475 |
+
|
476 |
+
/* Redraw the date picker attached to an input field or division.
|
477 |
+
@param target element - the target input field or division or span */
|
478 |
+
_refreshDatepicker: function(target) {
|
479 |
+
var inst = this._getInst(target);
|
480 |
+
if (inst) {
|
481 |
+
this._updateDatepicker(inst);
|
482 |
+
}
|
483 |
+
},
|
484 |
+
|
485 |
+
/* Set the dates for a jQuery selection.
|
486 |
+
@param target element - the target input field or division or span
|
487 |
+
@param date Date - the new date */
|
488 |
+
_setDateDatepicker: function(target, date) {
|
489 |
+
var inst = this._getInst(target);
|
490 |
+
if (inst) {
|
491 |
+
this._setDate(inst, date);
|
492 |
+
this._updateDatepicker(inst);
|
493 |
+
this._updateAlternate(inst);
|
494 |
+
}
|
495 |
+
},
|
496 |
+
|
497 |
+
/* Get the date(s) for the first entry in a jQuery selection.
|
498 |
+
@param target element - the target input field or division or span
|
499 |
+
@param noDefault boolean - true if no default date is to be used
|
500 |
+
@return Date - the current date */
|
501 |
+
_getDateDatepicker: function(target, noDefault) {
|
502 |
+
var inst = this._getInst(target);
|
503 |
+
if (inst && !inst.inline)
|
504 |
+
this._setDateFromField(inst, noDefault);
|
505 |
+
return (inst ? this._getDate(inst) : null);
|
506 |
+
},
|
507 |
+
|
508 |
+
/* Handle keystrokes. */
|
509 |
+
_doKeyDown: function(event) {
|
510 |
+
var inst = $.datepicker._getInst(event.target);
|
511 |
+
var handled = true;
|
512 |
+
var isRTL = inst.dpDiv.is('.ui-datepicker-rtl');
|
513 |
+
inst._keyEvent = true;
|
514 |
+
if ($.datepicker._datepickerShowing)
|
515 |
+
switch (event.keyCode) {
|
516 |
+
case 9: $.datepicker._hideDatepicker();
|
517 |
+
handled = false;
|
518 |
+
break; // hide on tab out
|
519 |
+
case 13: var sel = $('td.' + $.datepicker._dayOverClass + ':not(.' +
|
520 |
+
$.datepicker._currentClass + ')', inst.dpDiv);
|
521 |
+
if (sel[0])
|
522 |
+
$.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
|
523 |
+
else
|
524 |
+
$.datepicker._hideDatepicker();
|
525 |
+
return false; // don't submit the form
|
526 |
+
break; // select the value on enter
|
527 |
+
case 27: $.datepicker._hideDatepicker();
|
528 |
+
break; // hide on escape
|
529 |
+
case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
|
530 |
+
-$.datepicker._get(inst, 'stepBigMonths') :
|
531 |
+
-$.datepicker._get(inst, 'stepMonths')), 'M');
|
532 |
+
break; // previous month/year on page up/+ ctrl
|
533 |
+
case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
|
534 |
+
+$.datepicker._get(inst, 'stepBigMonths') :
|
535 |
+
+$.datepicker._get(inst, 'stepMonths')), 'M');
|
536 |
+
break; // next month/year on page down/+ ctrl
|
537 |
+
case 35: if (event.ctrlKey || event.metaKey) $.datepicker._clearDate(event.target);
|
538 |
+
handled = event.ctrlKey || event.metaKey;
|
539 |
+
break; // clear on ctrl or command +end
|
540 |
+
case 36: if (event.ctrlKey || event.metaKey) $.datepicker._gotoToday(event.target);
|
541 |
+
handled = event.ctrlKey || event.metaKey;
|
542 |
+
break; // current on ctrl or command +home
|
543 |
+
case 37: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), 'D');
|
544 |
+
handled = event.ctrlKey || event.metaKey;
|
545 |
+
// -1 day on ctrl or command +left
|
546 |
+
if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
|
547 |
+
-$.datepicker._get(inst, 'stepBigMonths') :
|
548 |
+
-$.datepicker._get(inst, 'stepMonths')), 'M');
|
549 |
+
// next month/year on alt +left on Mac
|
550 |
+
break;
|
551 |
+
case 38: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, -7, 'D');
|
552 |
+
handled = event.ctrlKey || event.metaKey;
|
553 |
+
break; // -1 week on ctrl or command +up
|
554 |
+
case 39: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), 'D');
|
555 |
+
handled = event.ctrlKey || event.metaKey;
|
556 |
+
// +1 day on ctrl or command +right
|
557 |
+
if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
|
558 |
+
+$.datepicker._get(inst, 'stepBigMonths') :
|
559 |
+
+$.datepicker._get(inst, 'stepMonths')), 'M');
|
560 |
+
// next month/year on alt +right
|
561 |
+
break;
|
562 |
+
case 40: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, +7, 'D');
|
563 |
+
handled = event.ctrlKey || event.metaKey;
|
564 |
+
break; // +1 week on ctrl or command +down
|
565 |
+
default: handled = false;
|
566 |
+
}
|
567 |
+
else if (event.keyCode == 36 && event.ctrlKey) // display the date picker on ctrl+home
|
568 |
+
$.datepicker._showDatepicker(this);
|
569 |
+
else {
|
570 |
+
handled = false;
|
571 |
+
}
|
572 |
+
if (handled) {
|
573 |
+
event.preventDefault();
|
574 |
+
event.stopPropagation();
|
575 |
+
}
|
576 |
+
},
|
577 |
+
|
578 |
+
/* Filter entered characters - based on date format. */
|
579 |
+
_doKeyPress: function(event) {
|
580 |
+
var inst = $.datepicker._getInst(event.target);
|
581 |
+
if ($.datepicker._get(inst, 'constrainInput')) {
|
582 |
+
var chars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat'));
|
583 |
+
var chr = String.fromCharCode(event.charCode == undefined ? event.keyCode : event.charCode);
|
584 |
+
return event.ctrlKey || event.metaKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1);
|
585 |
+
}
|
586 |
+
},
|
587 |
+
|
588 |
+
/* Synchronise manual entry and field/alternate field. */
|
589 |
+
_doKeyUp: function(event) {
|
590 |
+
var inst = $.datepicker._getInst(event.target);
|
591 |
+
if (inst.input.val() != inst.lastVal) {
|
592 |
+
try {
|
593 |
+
var date = $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'),
|
594 |
+
(inst.input ? inst.input.val() : null),
|
595 |
+
$.datepicker._getFormatConfig(inst));
|
596 |
+
if (date) { // only if valid
|
597 |
+
$.datepicker._setDateFromField(inst);
|
598 |
+
$.datepicker._updateAlternate(inst);
|
599 |
+
$.datepicker._updateDatepicker(inst);
|
600 |
+
}
|
601 |
+
}
|
602 |
+
catch (event) {
|
603 |
+
$.datepicker.log(event);
|
604 |
+
}
|
605 |
+
}
|
606 |
+
return true;
|
607 |
+
},
|
608 |
+
|
609 |
+
/* Pop-up the date picker for a given input field.
|
610 |
+
@param input element - the input field attached to the date picker or
|
611 |
+
event - if triggered by focus */
|
612 |
+
_showDatepicker: function(input) {
|
613 |
+
input = input.target || input;
|
614 |
+
if (input.nodeName.toLowerCase() != 'input') // find from button/image trigger
|
615 |
+
input = $('input', input.parentNode)[0];
|
616 |
+
if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput == input) // already here
|
617 |
+
return;
|
618 |
+
var inst = $.datepicker._getInst(input);
|
619 |
+
if ($.datepicker._curInst && $.datepicker._curInst != inst) {
|
620 |
+
if ( $.datepicker._datepickerShowing ) {
|
621 |
+
$.datepicker._triggerOnClose($.datepicker._curInst);
|
622 |
+
}
|
623 |
+
$.datepicker._curInst.dpDiv.stop(true, true);
|
624 |
+
}
|
625 |
+
var beforeShow = $.datepicker._get(inst, 'beforeShow');
|
626 |
+
extendRemove(inst.settings, (beforeShow ? beforeShow.apply(input, [input, inst]) : {}));
|
627 |
+
inst.lastVal = null;
|
628 |
+
$.datepicker._lastInput = input;
|
629 |
+
$.datepicker._setDateFromField(inst);
|
630 |
+
if ($.datepicker._inDialog) // hide cursor
|
631 |
+
input.value = '';
|
632 |
+
if (!$.datepicker._pos) { // position below input
|
633 |
+
$.datepicker._pos = $.datepicker._findPos(input);
|
634 |
+
$.datepicker._pos[1] += input.offsetHeight; // add the height
|
635 |
+
}
|
636 |
+
var isFixed = false;
|
637 |
+
$(input).parents().each(function() {
|
638 |
+
isFixed |= $(this).css('position') == 'fixed';
|
639 |
+
return !isFixed;
|
640 |
+
});
|
641 |
+
if (isFixed && $.browser.opera) { // correction for Opera when fixed and scrolled
|
642 |
+
$.datepicker._pos[0] -= document.documentElement.scrollLeft;
|
643 |
+
$.datepicker._pos[1] -= document.documentElement.scrollTop;
|
644 |
+
}
|
645 |
+
var offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
|
646 |
+
$.datepicker._pos = null;
|
647 |
+
//to avoid flashes on Firefox
|
648 |
+
inst.dpDiv.empty();
|
649 |
+
// determine sizing offscreen
|
650 |
+
inst.dpDiv.css({position: 'absolute', display: 'block', top: '-1000px'});
|
651 |
+
$.datepicker._updateDatepicker(inst);
|
652 |
+
// fix width for dynamic number of date pickers
|
653 |
+
// and adjust position before showing
|
654 |
+
offset = $.datepicker._checkOffset(inst, offset, isFixed);
|
655 |
+
inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
|
656 |
+
'static' : (isFixed ? 'fixed' : 'absolute')), display: 'none',
|
657 |
+
left: offset.left + 'px', top: offset.top + 'px'});
|
658 |
+
if (!inst.inline) {
|
659 |
+
var showAnim = $.datepicker._get(inst, 'showAnim');
|
660 |
+
var duration = $.datepicker._get(inst, 'duration');
|
661 |
+
var postProcess = function() {
|
662 |
+
var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only
|
663 |
+
if( !! cover.length ){
|
664 |
+
var borders = $.datepicker._getBorders(inst.dpDiv);
|
665 |
+
cover.css({left: -borders[0], top: -borders[1],
|
666 |
+
width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()});
|
667 |
+
}
|
668 |
+
};
|
669 |
+
inst.dpDiv.zIndex($(input).zIndex()+1);
|
670 |
+
$.datepicker._datepickerShowing = true;
|
671 |
+
if ($.effects && $.effects[showAnim])
|
672 |
+
inst.dpDiv.show(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
|
673 |
+
else
|
674 |
+
inst.dpDiv[showAnim || 'show']((showAnim ? duration : null), postProcess);
|
675 |
+
if (!showAnim || !duration)
|
676 |
+
postProcess();
|
677 |
+
if (inst.input.is(':visible') && !inst.input.is(':disabled'))
|
678 |
+
inst.input.focus();
|
679 |
+
$.datepicker._curInst = inst;
|
680 |
+
}
|
681 |
+
},
|
682 |
+
|
683 |
+
/* Generate the date picker content. */
|
684 |
+
_updateDatepicker: function(inst) {
|
685 |
+
var self = this;
|
686 |
+
self.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
|
687 |
+
var borders = $.datepicker._getBorders(inst.dpDiv);
|
688 |
+
instActive = inst; // for delegate hover events
|
689 |
+
inst.dpDiv.empty().append(this._generateHTML(inst));
|
690 |
+
var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only
|
691 |
+
if( !!cover.length ){ //avoid call to outerXXXX() when not in IE6
|
692 |
+
cover.css({left: -borders[0], top: -borders[1], width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()})
|
693 |
+
}
|
694 |
+
inst.dpDiv.find('.' + this._dayOverClass + ' a').mouseover();
|
695 |
+
var numMonths = this._getNumberOfMonths(inst);
|
696 |
+
var cols = numMonths[1];
|
697 |
+
var width = 17;
|
698 |
+
inst.dpDiv.removeClass('ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4').width('');
|
699 |
+
if (cols > 1)
|
700 |
+
inst.dpDiv.addClass('ui-datepicker-multi-' + cols).css('width', (width * cols) + 'em');
|
701 |
+
inst.dpDiv[(numMonths[0] != 1 || numMonths[1] != 1 ? 'add' : 'remove') +
|
702 |
+
'Class']('ui-datepicker-multi');
|
703 |
+
inst.dpDiv[(this._get(inst, 'isRTL') ? 'add' : 'remove') +
|
704 |
+
'Class']('ui-datepicker-rtl');
|
705 |
+
if (inst == $.datepicker._curInst && $.datepicker._datepickerShowing && inst.input &&
|
706 |
+
// #6694 - don't focus the input if it's already focused
|
707 |
+
// this breaks the change event in IE
|
708 |
+
inst.input.is(':visible') && !inst.input.is(':disabled') && inst.input[0] != document.activeElement)
|
709 |
+
inst.input.focus();
|
710 |
+
// deffered render of the years select (to avoid flashes on Firefox)
|
711 |
+
if( inst.yearshtml ){
|
712 |
+
var origyearshtml = inst.yearshtml;
|
713 |
+
setTimeout(function(){
|
714 |
+
//assure that inst.yearshtml didn't change.
|
715 |
+
if( origyearshtml === inst.yearshtml && inst.yearshtml ){
|
716 |
+
inst.dpDiv.find('select.ui-datepicker-year:first').replaceWith(inst.yearshtml);
|
717 |
+
}
|
718 |
+
origyearshtml = inst.yearshtml = null;
|
719 |
+
}, 0);
|
720 |
+
}
|
721 |
+
},
|
722 |
+
|
723 |
+
/* Retrieve the size of left and top borders for an element.
|
724 |
+
@param elem (jQuery object) the element of interest
|
725 |
+
@return (number[2]) the left and top borders */
|
726 |
+
_getBorders: function(elem) {
|
727 |
+
var convert = function(value) {
|
728 |
+
return {thin: 1, medium: 2, thick: 3}[value] || value;
|
729 |
+
};
|
730 |
+
return [parseFloat(convert(elem.css('border-left-width'))),
|
731 |
+
parseFloat(convert(elem.css('border-top-width')))];
|
732 |
+
},
|
733 |
+
|
734 |
+
/* Check positioning to remain on screen. */
|
735 |
+
_checkOffset: function(inst, offset, isFixed) {
|
736 |
+
var dpWidth = inst.dpDiv.outerWidth();
|
737 |
+
var dpHeight = inst.dpDiv.outerHeight();
|
738 |
+
var inputWidth = inst.input ? inst.input.outerWidth() : 0;
|
739 |
+
var inputHeight = inst.input ? inst.input.outerHeight() : 0;
|
740 |
+
var viewWidth = document.documentElement.clientWidth + $(document).scrollLeft();
|
741 |
+
var viewHeight = document.documentElement.clientHeight + $(document).scrollTop();
|
742 |
+
|
743 |
+
offset.left -= (this._get(inst, 'isRTL') ? (dpWidth - inputWidth) : 0);
|
744 |
+
offset.left -= (isFixed && offset.left == inst.input.offset().left) ? $(document).scrollLeft() : 0;
|
745 |
+
offset.top -= (isFixed && offset.top == (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
|
746 |
+
|
747 |
+
// now check if datepicker is showing outside window viewport - move to a better place if so.
|
748 |
+
offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
|
749 |
+
Math.abs(offset.left + dpWidth - viewWidth) : 0);
|
750 |
+
offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
|
751 |
+
Math.abs(dpHeight + inputHeight) : 0);
|
752 |
+
|
753 |
+
return offset;
|
754 |
+
},
|
755 |
+
|
756 |
+
/* Find an object's position on the screen. */
|
757 |
+
_findPos: function(obj) {
|
758 |
+
var inst = this._getInst(obj);
|
759 |
+
var isRTL = this._get(inst, 'isRTL');
|
760 |
+
while (obj && (obj.type == 'hidden' || obj.nodeType != 1 || $.expr.filters.hidden(obj))) {
|
761 |
+
obj = obj[isRTL ? 'previousSibling' : 'nextSibling'];
|
762 |
+
}
|
763 |
+
var position = $(obj).offset();
|
764 |
+
return [position.left, position.top];
|
765 |
+
},
|
766 |
+
|
767 |
+
/* Trigger custom callback of onClose. */
|
768 |
+
_triggerOnClose: function(inst) {
|
769 |
+
var onClose = this._get(inst, 'onClose');
|
770 |
+
if (onClose)
|
771 |
+
onClose.apply((inst.input ? inst.input[0] : null),
|
772 |
+
[(inst.input ? inst.input.val() : ''), inst]);
|
773 |
+
},
|
774 |
+
|
775 |
+
/* Hide the date picker from view.
|
776 |
+
@param input element - the input field attached to the date picker */
|
777 |
+
_hideDatepicker: function(input) {
|
778 |
+
var inst = this._curInst;
|
779 |
+
if (!inst || (input && inst != $.data(input, PROP_NAME)))
|
780 |
+
return;
|
781 |
+
if (this._datepickerShowing) {
|
782 |
+
var showAnim = this._get(inst, 'showAnim');
|
783 |
+
var duration = this._get(inst, 'duration');
|
784 |
+
var postProcess = function() {
|
785 |
+
$.datepicker._tidyDialog(inst);
|
786 |
+
this._curInst = null;
|
787 |
+
};
|
788 |
+
if ($.effects && $.effects[showAnim])
|
789 |
+
inst.dpDiv.hide(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
|
790 |
+
else
|
791 |
+
inst.dpDiv[(showAnim == 'slideDown' ? 'slideUp' :
|
792 |
+
(showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))]((showAnim ? duration : null), postProcess);
|
793 |
+
if (!showAnim)
|
794 |
+
postProcess();
|
795 |
+
$.datepicker._triggerOnClose(inst);
|
796 |
+
this._datepickerShowing = false;
|
797 |
+
this._lastInput = null;
|
798 |
+
if (this._inDialog) {
|
799 |
+
this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' });
|
800 |
+
if ($.blockUI) {
|
801 |
+
$.unblockUI();
|
802 |
+
$('body').append(this.dpDiv);
|
803 |
+
}
|
804 |
+
}
|
805 |
+
this._inDialog = false;
|
806 |
+
}
|
807 |
+
},
|
808 |
+
|
809 |
+
/* Tidy up after a dialog display. */
|
810 |
+
_tidyDialog: function(inst) {
|
811 |
+
inst.dpDiv.removeClass(this._dialogClass).unbind('.ui-datepicker-calendar');
|
812 |
+
},
|
813 |
+
|
814 |
+
/* Close date picker if clicked elsewhere. */
|
815 |
+
_checkExternalClick: function(event) {
|
816 |
+
if (!$.datepicker._curInst)
|
817 |
+
return;
|
818 |
+
var $target = $(event.target);
|
819 |
+
if ($target[0].id != $.datepicker._mainDivId &&
|
820 |
+
$target.parents('#' + $.datepicker._mainDivId).length == 0 &&
|
821 |
+
!$target.hasClass($.datepicker.markerClassName) &&
|
822 |
+
!$target.hasClass($.datepicker._triggerClass) &&
|
823 |
+
$.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI))
|
824 |
+
$.datepicker._hideDatepicker();
|
825 |
+
},
|
826 |
+
|
827 |
+
/* Adjust one of the date sub-fields. */
|
828 |
+
_adjustDate: function(id, offset, period) {
|
829 |
+
var target = $(id);
|
830 |
+
var inst = this._getInst(target[0]);
|
831 |
+
if (this._isDisabledDatepicker(target[0])) {
|
832 |
+
return;
|
833 |
+
}
|
834 |
+
this._adjustInstDate(inst, offset +
|
835 |
+
(period == 'M' ? this._get(inst, 'showCurrentAtPos') : 0), // undo positioning
|
836 |
+
period);
|
837 |
+
this._updateDatepicker(inst);
|
838 |
+
},
|
839 |
+
|
840 |
+
/* Action for current link. */
|
841 |
+
_gotoToday: function(id) {
|
842 |
+
var target = $(id);
|
843 |
+
var inst = this._getInst(target[0]);
|
844 |
+
if (this._get(inst, 'gotoCurrent') && inst.currentDay) {
|
845 |
+
inst.selectedDay = inst.currentDay;
|
846 |
+
inst.drawMonth = inst.selectedMonth = inst.currentMonth;
|
847 |
+
inst.drawYear = inst.selectedYear = inst.currentYear;
|
848 |
+
}
|
849 |
+
else {
|
850 |
+
var date = new Date();
|
851 |
+
inst.selectedDay = date.getDate();
|
852 |
+
inst.drawMonth = inst.selectedMonth = date.getMonth();
|
853 |
+
inst.drawYear = inst.selectedYear = date.getFullYear();
|
854 |
+
}
|
855 |
+
this._notifyChange(inst);
|
856 |
+
this._adjustDate(target);
|
857 |
+
},
|
858 |
+
|
859 |
+
/* Action for selecting a new month/year. */
|
860 |
+
_selectMonthYear: function(id, select, period) {
|
861 |
+
var target = $(id);
|
862 |
+
var inst = this._getInst(target[0]);
|
863 |
+
inst._selectingMonthYear = false;
|
864 |
+
inst['selected' + (period == 'M' ? 'Month' : 'Year')] =
|
865 |
+
inst['draw' + (period == 'M' ? 'Month' : 'Year')] =
|
866 |
+
parseInt(select.options[select.selectedIndex].value,10);
|
867 |
+
this._notifyChange(inst);
|
868 |
+
this._adjustDate(target);
|
869 |
+
},
|
870 |
+
|
871 |
+
/* Restore input focus after not changing month/year. */
|
872 |
+
_clickMonthYear: function(id) {
|
873 |
+
var target = $(id);
|
874 |
+
var inst = this._getInst(target[0]);
|
875 |
+
if (inst.input && inst._selectingMonthYear) {
|
876 |
+
setTimeout(function() {
|
877 |
+
inst.input.focus();
|
878 |
+
}, 0);
|
879 |
+
}
|
880 |
+
inst._selectingMonthYear = !inst._selectingMonthYear;
|
881 |
+
},
|
882 |
+
|
883 |
+
/* Action for selecting a day. */
|
884 |
+
_selectDay: function(id, month, year, td) {
|
885 |
+
var target = $(id);
|
886 |
+
if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
|
887 |
+
return;
|
888 |
+
}
|
889 |
+
var inst = this._getInst(target[0]);
|
890 |
+
inst.selectedDay = inst.currentDay = $('a', td).html();
|
891 |
+
inst.selectedMonth = inst.currentMonth = month;
|
892 |
+
inst.selectedYear = inst.currentYear = year;
|
893 |
+
this._selectDate(id, this._formatDate(inst,
|
894 |
+
inst.currentDay, inst.currentMonth, inst.currentYear));
|
895 |
+
},
|
896 |
+
|
897 |
+
/* Erase the input field and hide the date picker. */
|
898 |
+
_clearDate: function(id) {
|
899 |
+
var target = $(id);
|
900 |
+
var inst = this._getInst(target[0]);
|
901 |
+
this._selectDate(target, '');
|
902 |
+
},
|
903 |
+
|
904 |
+
/* Update the input field with the selected date. */
|
905 |
+
_selectDate: function(id, dateStr) {
|
906 |
+
var target = $(id);
|
907 |
+
var inst = this._getInst(target[0]);
|
908 |
+
dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
|
909 |
+
if (inst.input)
|
910 |
+
inst.input.val(dateStr);
|
911 |
+
this._updateAlternate(inst);
|
912 |
+
var onSelect = this._get(inst, 'onSelect');
|
913 |
+
if (onSelect)
|
914 |
+
onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
|
915 |
+
else if (inst.input)
|
916 |
+
inst.input.trigger('change'); // fire the change event
|
917 |
+
if (inst.inline)
|
918 |
+
this._updateDatepicker(inst);
|
919 |
+
else {
|
920 |
+
this._hideDatepicker();
|
921 |
+
this._lastInput = inst.input[0];
|
922 |
+
if (typeof(inst.input[0]) != 'object')
|
923 |
+
inst.input.focus(); // restore focus
|
924 |
+
this._lastInput = null;
|
925 |
+
}
|
926 |
+
},
|
927 |
+
|
928 |
+
/* Update any alternate field to synchronise with the main field. */
|
929 |
+
_updateAlternate: function(inst) {
|
930 |
+
var altField = this._get(inst, 'altField');
|
931 |
+
if (altField) { // update alternate field too
|
932 |
+
var altFormat = this._get(inst, 'altFormat') || this._get(inst, 'dateFormat');
|
933 |
+
var date = this._getDate(inst);
|
934 |
+
var dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
|
935 |
+
$(altField).each(function() { $(this).val(dateStr); });
|
936 |
+
}
|
937 |
+
},
|
938 |
+
|
939 |
+
/* Set as beforeShowDay function to prevent selection of weekends.
|
940 |
+
@param date Date - the date to customise
|
941 |
+
@return [boolean, string] - is this date selectable?, what is its CSS class? */
|
942 |
+
noWeekends: function(date) {
|
943 |
+
var day = date.getDay();
|
944 |
+
return [(day > 0 && day < 6), ''];
|
945 |
+
},
|
946 |
+
|
947 |
+
/* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
|
948 |
+
@param date Date - the date to get the week for
|
949 |
+
@return number - the number of the week within the year that contains this date */
|
950 |
+
iso8601Week: function(date) {
|
951 |
+
var checkDate = new Date(date.getTime());
|
952 |
+
// Find Thursday of this week starting on Monday
|
953 |
+
checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
|
954 |
+
var time = checkDate.getTime();
|
955 |
+
checkDate.setMonth(0); // Compare with Jan 1
|
956 |
+
checkDate.setDate(1);
|
957 |
+
return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
|
958 |
+
},
|
959 |
+
|
960 |
+
/* Parse a string value into a date object.
|
961 |
+
See formatDate below for the possible formats.
|
962 |
+
|
963 |
+
@param format string - the expected format of the date
|
964 |
+
@param value string - the date in the above format
|
965 |
+
@param settings Object - attributes include:
|
966 |
+
shortYearCutoff number - the cutoff year for determining the century (optional)
|
967 |
+
dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
|
968 |
+
dayNames string[7] - names of the days from Sunday (optional)
|
969 |
+
monthNamesShort string[12] - abbreviated names of the months (optional)
|
970 |
+
monthNames string[12] - names of the months (optional)
|
971 |
+
@return Date - the extracted date value or null if value is blank */
|
972 |
+
parseDate: function (format, value, settings) {
|
973 |
+
if (format == null || value == null)
|
974 |
+
throw 'Invalid arguments';
|
975 |
+
value = (typeof value == 'object' ? value.toString() : value + '');
|
976 |
+
if (value == '')
|
977 |
+
return null;
|
978 |
+
var shortYearCutoff = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff;
|
979 |
+
shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff :
|
980 |
+
new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
|
981 |
+
var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
|
982 |
+
var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
|
983 |
+
var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
|
984 |
+
var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
|
985 |
+
var year = -1;
|
986 |
+
var month = -1;
|
987 |
+
var day = -1;
|
988 |
+
var doy = -1;
|
989 |
+
var literal = false;
|
990 |
+
// Check whether a format character is doubled
|
991 |
+
var lookAhead = function(match) {
|
992 |
+
var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
|
993 |
+
if (matches)
|
994 |
+
iFormat++;
|
995 |
+
return matches;
|
996 |
+
};
|
997 |
+
// Extract a number from the string value
|
998 |
+
var getNumber = function(match) {
|
999 |
+
var isDoubled = lookAhead(match);
|
1000 |
+
var size = (match == '@' ? 14 : (match == '!' ? 20 :
|
1001 |
+
(match == 'y' && isDoubled ? 4 : (match == 'o' ? 3 : 2))));
|
1002 |
+
var digits = new RegExp('^\\d{1,' + size + '}');
|
1003 |
+
var num = value.substring(iValue).match(digits);
|
1004 |
+
if (!num)
|
1005 |
+
throw 'Missing number at position ' + iValue;
|
1006 |
+
iValue += num[0].length;
|
1007 |
+
return parseInt(num[0], 10);
|
1008 |
+
};
|
1009 |
+
// Extract a name from the string value and convert to an index
|
1010 |
+
var getName = function(match, shortNames, longNames) {
|
1011 |
+
var names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
|
1012 |
+
return [ [k, v] ];
|
1013 |
+
}).sort(function (a, b) {
|
1014 |
+
return -(a[1].length - b[1].length);
|
1015 |
+
});
|
1016 |
+
var index = -1;
|
1017 |
+
$.each(names, function (i, pair) {
|
1018 |
+
var name = pair[1];
|
1019 |
+
if (value.substr(iValue, name.length).toLowerCase() == name.toLowerCase()) {
|
1020 |
+
index = pair[0];
|
1021 |
+
iValue += name.length;
|
1022 |
+
return false;
|
1023 |
+
}
|
1024 |
+
});
|
1025 |
+
if (index != -1)
|
1026 |
+
return index + 1;
|
1027 |
+
else
|
1028 |
+
throw 'Unknown name at position ' + iValue;
|
1029 |
+
};
|
1030 |
+
// Confirm that a literal character matches the string value
|
1031 |
+
var checkLiteral = function() {
|
1032 |
+
if (value.charAt(iValue) != format.charAt(iFormat))
|
1033 |
+
throw 'Unexpected literal at position ' + iValue;
|
1034 |
+
iValue++;
|
1035 |
+
};
|
1036 |
+
var iValue = 0;
|
1037 |
+
for (var iFormat = 0; iFormat < format.length; iFormat++) {
|
1038 |
+
if (literal)
|
1039 |
+
if (format.charAt(iFormat) == "'" && !lookAhead("'"))
|
1040 |
+
literal = false;
|
1041 |
+
else
|
1042 |
+
checkLiteral();
|
1043 |
+
else
|
1044 |
+
switch (format.charAt(iFormat)) {
|
1045 |
+
case 'd':
|
1046 |
+
day = getNumber('d');
|
1047 |
+
break;
|
1048 |
+
case 'D':
|
1049 |
+
getName('D', dayNamesShort, dayNames);
|
1050 |
+
break;
|
1051 |
+
case 'o':
|
1052 |
+
doy = getNumber('o');
|
1053 |
+
break;
|
1054 |
+
case 'm':
|
1055 |
+
month = getNumber('m');
|
1056 |
+
break;
|
1057 |
+
case 'M':
|
1058 |
+
month = getName('M', monthNamesShort, monthNames);
|
1059 |
+
break;
|
1060 |
+
case 'y':
|
1061 |
+
year = getNumber('y');
|
1062 |
+
break;
|
1063 |
+
case '@':
|
1064 |
+
var date = new Date(getNumber('@'));
|
1065 |
+
year = date.getFullYear();
|
1066 |
+
month = date.getMonth() + 1;
|
1067 |
+
day = date.getDate();
|
1068 |
+
break;
|
1069 |
+
case '!':
|
1070 |
+
var date = new Date((getNumber('!') - this._ticksTo1970) / 10000);
|
1071 |
+
year = date.getFullYear();
|
1072 |
+
month = date.getMonth() + 1;
|
1073 |
+
day = date.getDate();
|
1074 |
+
break;
|
1075 |
+
case "'":
|
1076 |
+
if (lookAhead("'"))
|
1077 |
+
checkLiteral();
|
1078 |
+
else
|
1079 |
+
literal = true;
|
1080 |
+
break;
|
1081 |
+
default:
|
1082 |
+
checkLiteral();
|
1083 |
+
}
|
1084 |
+
}
|
1085 |
+
if (iValue < value.length){
|
1086 |
+
throw "Extra/unparsed characters found in date: " + value.substring(iValue);
|
1087 |
+
}
|
1088 |
+
if (year == -1)
|
1089 |
+
year = new Date().getFullYear();
|
1090 |
+
else if (year < 100)
|
1091 |
+
year += new Date().getFullYear() - new Date().getFullYear() % 100 +
|
1092 |
+
(year <= shortYearCutoff ? 0 : -100);
|
1093 |
+
if (doy > -1) {
|
1094 |
+
month = 1;
|
1095 |
+
day = doy;
|
1096 |
+
do {
|
1097 |
+
var dim = this._getDaysInMonth(year, month - 1);
|
1098 |
+
if (day <= dim)
|
1099 |
+
break;
|
1100 |
+
month++;
|
1101 |
+
day -= dim;
|
1102 |
+
} while (true);
|
1103 |
+
}
|
1104 |
+
var date = this._daylightSavingAdjust(new Date(year, month - 1, day));
|
1105 |
+
if (date.getFullYear() != year || date.getMonth() + 1 != month || date.getDate() != day)
|
1106 |
+
throw 'Invalid date'; // E.g. 31/02/00
|
1107 |
+
return date;
|
1108 |
+
},
|
1109 |
+
|
1110 |
+
/* Standard date formats. */
|
1111 |
+
ATOM: 'yy-mm-dd', // RFC 3339 (ISO 8601)
|
1112 |
+
COOKIE: 'D, dd M yy',
|
1113 |
+
ISO_8601: 'yy-mm-dd',
|
1114 |
+
RFC_822: 'D, d M y',
|
1115 |
+
RFC_850: 'DD, dd-M-y',
|
1116 |
+
RFC_1036: 'D, d M y',
|
1117 |
+
RFC_1123: 'D, d M yy',
|
1118 |
+
RFC_2822: 'D, d M yy',
|
1119 |
+
RSS: 'D, d M y', // RFC 822
|
1120 |
+
TICKS: '!',
|
1121 |
+
TIMESTAMP: '@',
|
1122 |
+
W3C: 'yy-mm-dd', // ISO 8601
|
1123 |
+
|
1124 |
+
_ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
|
1125 |
+
Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
|
1126 |
+
|
1127 |
+
/* Format a date object into a string value.
|
1128 |
+
The format can be combinations of the following:
|
1129 |
+
d - day of month (no leading zero)
|
1130 |
+
dd - day of month (two digit)
|
1131 |
+
o - day of year (no leading zeros)
|
1132 |
+
oo - day of year (three digit)
|
1133 |
+
D - day name short
|
1134 |
+
DD - day name long
|
1135 |
+
m - month of year (no leading zero)
|
1136 |
+
mm - month of year (two digit)
|
1137 |
+
M - month name short
|
1138 |
+
MM - month name long
|
1139 |
+
y - year (two digit)
|
1140 |
+
yy - year (four digit)
|
1141 |
+
@ - Unix timestamp (ms since 01/01/1970)
|
1142 |
+
! - Windows ticks (100ns since 01/01/0001)
|
1143 |
+
'...' - literal text
|
1144 |
+
'' - single quote
|
1145 |
+
|
1146 |
+
@param format string - the desired format of the date
|
1147 |
+
@param date Date - the date value to format
|
1148 |
+
@param settings Object - attributes include:
|
1149 |
+
dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
|
1150 |
+
dayNames string[7] - names of the days from Sunday (optional)
|
1151 |
+
monthNamesShort string[12] - abbreviated names of the months (optional)
|
1152 |
+
monthNames string[12] - names of the months (optional)
|
1153 |
+
@return string - the date in the above format */
|
1154 |
+
formatDate: function (format, date, settings) {
|
1155 |
+
if (!date)
|
1156 |
+
return '';
|
1157 |
+
var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
|
1158 |
+
var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
|
1159 |
+
var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
|
1160 |
+
var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
|
1161 |
+
// Check whether a format character is doubled
|
1162 |
+
var lookAhead = function(match) {
|
1163 |
+
var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
|
1164 |
+
if (matches)
|
1165 |
+
iFormat++;
|
1166 |
+
return matches;
|
1167 |
+
};
|
1168 |
+
// Format a number, with leading zero if necessary
|
1169 |
+
var formatNumber = function(match, value, len) {
|
1170 |
+
var num = '' + value;
|
1171 |
+
if (lookAhead(match))
|
1172 |
+
while (num.length < len)
|
1173 |
+
num = '0' + num;
|
1174 |
+
return num;
|
1175 |
+
};
|
1176 |
+
// Format a name, short or long as requested
|
1177 |
+
var formatName = function(match, value, shortNames, longNames) {
|
1178 |
+
return (lookAhead(match) ? longNames[value] : shortNames[value]);
|
1179 |
+
};
|
1180 |
+
var output = '';
|
1181 |
+
var literal = false;
|
1182 |
+
if (date)
|
1183 |
+
for (var iFormat = 0; iFormat < format.length; iFormat++) {
|
1184 |
+
if (literal)
|
1185 |
+
if (format.charAt(iFormat) == "'" && !lookAhead("'"))
|
1186 |
+
literal = false;
|
1187 |
+
else
|
1188 |
+
output += format.charAt(iFormat);
|
1189 |
+
else
|
1190 |
+
switch (format.charAt(iFormat)) {
|
1191 |
+
case 'd':
|
1192 |
+
output += formatNumber('d', date.getDate(), 2);
|
1193 |
+
break;
|
1194 |
+
case 'D':
|
1195 |
+
output += formatName('D', date.getDay(), dayNamesShort, dayNames);
|
1196 |
+
break;
|
1197 |
+
case 'o':
|
1198 |
+
output += formatNumber('o',
|
1199 |
+
Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
|
1200 |
+
break;
|
1201 |
+
case 'm':
|
1202 |
+
output += formatNumber('m', date.getMonth() + 1, 2);
|
1203 |
+
break;
|
1204 |
+
case 'M':
|
1205 |
+
output += formatName('M', date.getMonth(), monthNamesShort, monthNames);
|
1206 |
+
break;
|
1207 |
+
case 'y':
|
1208 |
+
output += (lookAhead('y') ? date.getFullYear() :
|
1209 |
+
(date.getYear() % 100 < 10 ? '0' : '') + date.getYear() % 100);
|
1210 |
+
break;
|
1211 |
+
case '@':
|
1212 |
+
output += date.getTime();
|
1213 |
+
break;
|
1214 |
+
case '!':
|
1215 |
+
output += date.getTime() * 10000 + this._ticksTo1970;
|
1216 |
+
break;
|
1217 |
+
case "'":
|
1218 |
+
if (lookAhead("'"))
|
1219 |
+
output += "'";
|
1220 |
+
else
|
1221 |
+
literal = true;
|
1222 |
+
break;
|
1223 |
+
default:
|
1224 |
+
output += format.charAt(iFormat);
|
1225 |
+
}
|
1226 |
+
}
|
1227 |
+
return output;
|
1228 |
+
},
|
1229 |
+
|
1230 |
+
/* Extract all possible characters from the date format. */
|
1231 |
+
_possibleChars: function (format) {
|
1232 |
+
var chars = '';
|
1233 |
+
var literal = false;
|
1234 |
+
// Check whether a format character is doubled
|
1235 |
+
var lookAhead = function(match) {
|
1236 |
+
var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
|
1237 |
+
if (matches)
|
1238 |
+
iFormat++;
|
1239 |
+
return matches;
|
1240 |
+
};
|
1241 |
+
for (var iFormat = 0; iFormat < format.length; iFormat++)
|
1242 |
+
if (literal)
|
1243 |
+
if (format.charAt(iFormat) == "'" && !lookAhead("'"))
|
1244 |
+
literal = false;
|
1245 |
+
else
|
1246 |
+
chars += format.charAt(iFormat);
|
1247 |
+
else
|
1248 |
+
switch (format.charAt(iFormat)) {
|
1249 |
+
case 'd': case 'm': case 'y': case '@':
|
1250 |
+
chars += '0123456789';
|
1251 |
+
break;
|
1252 |
+
case 'D': case 'M':
|
1253 |
+
return null; // Accept anything
|
1254 |
+
case "'":
|
1255 |
+
if (lookAhead("'"))
|
1256 |
+
chars += "'";
|
1257 |
+
else
|
1258 |
+
literal = true;
|
1259 |
+
break;
|
1260 |
+
default:
|
1261 |
+
chars += format.charAt(iFormat);
|
1262 |
+
}
|
1263 |
+
return chars;
|
1264 |
+
},
|
1265 |
+
|
1266 |
+
/* Get a setting value, defaulting if necessary. */
|
1267 |
+
_get: function(inst, name) {
|
1268 |
+
return inst.settings[name] !== undefined ?
|
1269 |
+
inst.settings[name] : this._defaults[name];
|
1270 |
+
},
|
1271 |
+
|
1272 |
+
/* Parse existing date and initialise date picker. */
|
1273 |
+
_setDateFromField: function(inst, noDefault) {
|
1274 |
+
if (inst.input.val() == inst.lastVal) {
|
1275 |
+
return;
|
1276 |
+
}
|
1277 |
+
var dateFormat = this._get(inst, 'dateFormat');
|
1278 |
+
var dates = inst.lastVal = inst.input ? inst.input.val() : null;
|
1279 |
+
var date, defaultDate;
|
1280 |
+
date = defaultDate = this._getDefaultDate(inst);
|
1281 |
+
var settings = this._getFormatConfig(inst);
|
1282 |
+
try {
|
1283 |
+
date = this.parseDate(dateFormat, dates, settings) || defaultDate;
|
1284 |
+
} catch (event) {
|
1285 |
+
this.log(event);
|
1286 |
+
dates = (noDefault ? '' : dates);
|
1287 |
+
}
|
1288 |
+
inst.selectedDay = date.getDate();
|
1289 |
+
inst.drawMonth = inst.selectedMonth = date.getMonth();
|
1290 |
+
inst.drawYear = inst.selectedYear = date.getFullYear();
|
1291 |
+
inst.currentDay = (dates ? date.getDate() : 0);
|
1292 |
+
inst.currentMonth = (dates ? date.getMonth() : 0);
|
1293 |
+
inst.currentYear = (dates ? date.getFullYear() : 0);
|
1294 |
+
this._adjustInstDate(inst);
|
1295 |
+
},
|
1296 |
+
|
1297 |
+
/* Retrieve the default date shown on opening. */
|
1298 |
+
_getDefaultDate: function(inst) {
|
1299 |
+
return this._restrictMinMax(inst,
|
1300 |
+
this._determineDate(inst, this._get(inst, 'defaultDate'), new Date()));
|
1301 |
+
},
|
1302 |
+
|
1303 |
+
/* A date may be specified as an exact value or a relative one. */
|
1304 |
+
_determineDate: function(inst, date, defaultDate) {
|
1305 |
+
var offsetNumeric = function(offset) {
|
1306 |
+
var date = new Date();
|
1307 |
+
date.setDate(date.getDate() + offset);
|
1308 |
+
return date;
|
1309 |
+
};
|
1310 |
+
var offsetString = function(offset) {
|
1311 |
+
try {
|
1312 |
+
return $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'),
|
1313 |
+
offset, $.datepicker._getFormatConfig(inst));
|
1314 |
+
}
|
1315 |
+
catch (e) {
|
1316 |
+
// Ignore
|
1317 |
+
}
|
1318 |
+
var date = (offset.toLowerCase().match(/^c/) ?
|
1319 |
+
$.datepicker._getDate(inst) : null) || new Date();
|
1320 |
+
var year = date.getFullYear();
|
1321 |
+
var month = date.getMonth();
|
1322 |
+
var day = date.getDate();
|
1323 |
+
var pattern = /([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g;
|
1324 |
+
var matches = pattern.exec(offset);
|
1325 |
+
while (matches) {
|
1326 |
+
switch (matches[2] || 'd') {
|
1327 |
+
case 'd' : case 'D' :
|
1328 |
+
day += parseInt(matches[1],10); break;
|
1329 |
+
case 'w' : case 'W' :
|
1330 |
+
day += parseInt(matches[1],10) * 7; break;
|
1331 |
+
case 'm' : case 'M' :
|
1332 |
+
month += parseInt(matches[1],10);
|
1333 |
+
day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
|
1334 |
+
break;
|
1335 |
+
case 'y': case 'Y' :
|
1336 |
+
year += parseInt(matches[1],10);
|
1337 |
+
day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
|
1338 |
+
break;
|
1339 |
+
}
|
1340 |
+
matches = pattern.exec(offset);
|
1341 |
+
}
|
1342 |
+
return new Date(year, month, day);
|
1343 |
+
};
|
1344 |
+
var newDate = (date == null || date === '' ? defaultDate : (typeof date == 'string' ? offsetString(date) :
|
1345 |
+
(typeof date == 'number' ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
|
1346 |
+
newDate = (newDate && newDate.toString() == 'Invalid Date' ? defaultDate : newDate);
|
1347 |
+
if (newDate) {
|
1348 |
+
newDate.setHours(0);
|
1349 |
+
newDate.setMinutes(0);
|
1350 |
+
newDate.setSeconds(0);
|
1351 |
+
newDate.setMilliseconds(0);
|
1352 |
+
}
|
1353 |
+
return this._daylightSavingAdjust(newDate);
|
1354 |
+
},
|
1355 |
+
|
1356 |
+
/* Handle switch to/from daylight saving.
|
1357 |
+
Hours may be non-zero on daylight saving cut-over:
|
1358 |
+
> 12 when midnight changeover, but then cannot generate
|
1359 |
+
midnight datetime, so jump to 1AM, otherwise reset.
|
1360 |
+
@param date (Date) the date to check
|
1361 |
+
@return (Date) the corrected date */
|
1362 |
+
_daylightSavingAdjust: function(date) {
|
1363 |
+
if (!date) return null;
|
1364 |
+
date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
|
1365 |
+
return date;
|
1366 |
+
},
|
1367 |
+
|
1368 |
+
/* Set the date(s) directly. */
|
1369 |
+
_setDate: function(inst, date, noChange) {
|
1370 |
+
var clear = !date;
|
1371 |
+
var origMonth = inst.selectedMonth;
|
1372 |
+
var origYear = inst.selectedYear;
|
1373 |
+
var newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
|
1374 |
+
inst.selectedDay = inst.currentDay = newDate.getDate();
|
1375 |
+
inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
|
1376 |
+
inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
|
1377 |
+
if ((origMonth != inst.selectedMonth || origYear != inst.selectedYear) && !noChange)
|
1378 |
+
this._notifyChange(inst);
|
1379 |
+
this._adjustInstDate(inst);
|
1380 |
+
if (inst.input) {
|
1381 |
+
inst.input.val(clear ? '' : this._formatDate(inst));
|
1382 |
+
}
|
1383 |
+
},
|
1384 |
+
|
1385 |
+
/* Retrieve the date(s) directly. */
|
1386 |
+
_getDate: function(inst) {
|
1387 |
+
var startDate = (!inst.currentYear || (inst.input && inst.input.val() == '') ? null :
|
1388 |
+
this._daylightSavingAdjust(new Date(
|
1389 |
+
inst.currentYear, inst.currentMonth, inst.currentDay)));
|
1390 |
+
return startDate;
|
1391 |
+
},
|
1392 |
+
|
1393 |
+
/* Generate the HTML for the current state of the date picker. */
|
1394 |
+
_generateHTML: function(inst) {
|
1395 |
+
var today = new Date();
|
1396 |
+
today = this._daylightSavingAdjust(
|
1397 |
+
new Date(today.getFullYear(), today.getMonth(), today.getDate())); // clear time
|
1398 |
+
var isRTL = this._get(inst, 'isRTL');
|
1399 |
+
var showButtonPanel = this._get(inst, 'showButtonPanel');
|
1400 |
+
var hideIfNoPrevNext = this._get(inst, 'hideIfNoPrevNext');
|
1401 |
+
var navigationAsDateFormat = this._get(inst, 'navigationAsDateFormat');
|
1402 |
+
var numMonths = this._getNumberOfMonths(inst);
|
1403 |
+
var showCurrentAtPos = this._get(inst, 'showCurrentAtPos');
|
1404 |
+
var stepMonths = this._get(inst, 'stepMonths');
|
1405 |
+
var isMultiMonth = (numMonths[0] != 1 || numMonths[1] != 1);
|
1406 |
+
var currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
|
1407 |
+
new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
|
1408 |
+
var minDate = this._getMinMaxDate(inst, 'min');
|
1409 |
+
var maxDate = this._getMinMaxDate(inst, 'max');
|
1410 |
+
var drawMonth = inst.drawMonth - showCurrentAtPos;
|
1411 |
+
var drawYear = inst.drawYear;
|
1412 |
+
if (drawMonth < 0) {
|
1413 |
+
drawMonth += 12;
|
1414 |
+
drawYear--;
|
1415 |
+
}
|
1416 |
+
if (maxDate) {
|
1417 |
+
var maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
|
1418 |
+
maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
|
1419 |
+
maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
|
1420 |
+
while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
|
1421 |
+
drawMonth--;
|
1422 |
+
if (drawMonth < 0) {
|
1423 |
+
drawMonth = 11;
|
1424 |
+
drawYear--;
|
1425 |
+
}
|
1426 |
+
}
|
1427 |
+
}
|
1428 |
+
inst.drawMonth = drawMonth;
|
1429 |
+
inst.drawYear = drawYear;
|
1430 |
+
var prevText = this._get(inst, 'prevText');
|
1431 |
+
prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
|
1432 |
+
this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
|
1433 |
+
this._getFormatConfig(inst)));
|
1434 |
+
var prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
|
1435 |
+
'<a class="ui-datepicker-prev ui-corner-all" onclick="DP_jQuery_' + dpuuid +
|
1436 |
+
'.datepicker._adjustDate(\'#' + inst.id + '\', -' + stepMonths + ', \'M\');"' +
|
1437 |
+
' title="' + prevText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>' :
|
1438 |
+
(hideIfNoPrevNext ? '' : '<a class="ui-datepicker-prev ui-corner-all ui-state-disabled" title="'+ prevText +'"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>'));
|
1439 |
+
var nextText = this._get(inst, 'nextText');
|
1440 |
+
nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
|
1441 |
+
this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
|
1442 |
+
this._getFormatConfig(inst)));
|
1443 |
+
var next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
|
1444 |
+
'<a class="ui-datepicker-next ui-corner-all" onclick="DP_jQuery_' + dpuuid +
|
1445 |
+
'.datepicker._adjustDate(\'#' + inst.id + '\', +' + stepMonths + ', \'M\');"' +
|
1446 |
+
' title="' + nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>' :
|
1447 |
+
(hideIfNoPrevNext ? '' : '<a class="ui-datepicker-next ui-corner-all ui-state-disabled" title="'+ nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>'));
|
1448 |
+
var currentText = this._get(inst, 'currentText');
|
1449 |
+
var gotoDate = (this._get(inst, 'gotoCurrent') && inst.currentDay ? currentDate : today);
|
1450 |
+
currentText = (!navigationAsDateFormat ? currentText :
|
1451 |
+
this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
|
1452 |
+
var controls = (!inst.inline ? '<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" onclick="DP_jQuery_' + dpuuid +
|
1453 |
+
'.datepicker._hideDatepicker();">' + this._get(inst, 'closeText') + '</button>' : '');
|
1454 |
+
var buttonPanel = (showButtonPanel) ? '<div class="ui-datepicker-buttonpane ui-widget-content">' + (isRTL ? controls : '') +
|
1455 |
+
(this._isInRange(inst, gotoDate) ? '<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" onclick="DP_jQuery_' + dpuuid +
|
1456 |
+
'.datepicker._gotoToday(\'#' + inst.id + '\');"' +
|
1457 |
+
'>' + currentText + '</button>' : '') + (isRTL ? '' : controls) + '</div>' : '';
|
1458 |
+
var firstDay = parseInt(this._get(inst, 'firstDay'),10);
|
1459 |
+
firstDay = (isNaN(firstDay) ? 0 : firstDay);
|
1460 |
+
var showWeek = this._get(inst, 'showWeek');
|
1461 |
+
var dayNames = this._get(inst, 'dayNames');
|
1462 |
+
var dayNamesShort = this._get(inst, 'dayNamesShort');
|
1463 |
+
var dayNamesMin = this._get(inst, 'dayNamesMin');
|
1464 |
+
var monthNames = this._get(inst, 'monthNames');
|
1465 |
+
var monthNamesShort = this._get(inst, 'monthNamesShort');
|
1466 |
+
var beforeShowDay = this._get(inst, 'beforeShowDay');
|
1467 |
+
var showOtherMonths = this._get(inst, 'showOtherMonths');
|
1468 |
+
var selectOtherMonths = this._get(inst, 'selectOtherMonths');
|
1469 |
+
var calculateWeek = this._get(inst, 'calculateWeek') || this.iso8601Week;
|
1470 |
+
var defaultDate = this._getDefaultDate(inst);
|
1471 |
+
var html = '';
|
1472 |
+
for (var row = 0; row < numMonths[0]; row++) {
|
1473 |
+
var group = '';
|
1474 |
+
this.maxRows = 4;
|
1475 |
+
for (var col = 0; col < numMonths[1]; col++) {
|
1476 |
+
var selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
|
1477 |
+
var cornerClass = ' ui-corner-all';
|
1478 |
+
var calender = '';
|
1479 |
+
if (isMultiMonth) {
|
1480 |
+
calender += '<div class="ui-datepicker-group';
|
1481 |
+
if (numMonths[1] > 1)
|
1482 |
+
switch (col) {
|
1483 |
+
case 0: calender += ' ui-datepicker-group-first';
|
1484 |
+
cornerClass = ' ui-corner-' + (isRTL ? 'right' : 'left'); break;
|
1485 |
+
case numMonths[1]-1: calender += ' ui-datepicker-group-last';
|
1486 |
+
cornerClass = ' ui-corner-' + (isRTL ? 'left' : 'right'); break;
|
1487 |
+
default: calender += ' ui-datepicker-group-middle'; cornerClass = ''; break;
|
1488 |
+
}
|
1489 |
+
calender += '">';
|
1490 |
+
}
|
1491 |
+
calender += '<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix' + cornerClass + '">' +
|
1492 |
+
(/all|left/.test(cornerClass) && row == 0 ? (isRTL ? next : prev) : '') +
|
1493 |
+
(/all|right/.test(cornerClass) && row == 0 ? (isRTL ? prev : next) : '') +
|
1494 |
+
this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
|
1495 |
+
row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
|
1496 |
+
'</div><table class="ui-datepicker-calendar"><thead>' +
|
1497 |
+
'<tr>';
|
1498 |
+
var thead = (showWeek ? '<th class="ui-datepicker-week-col">' + this._get(inst, 'weekHeader') + '</th>' : '');
|
1499 |
+
for (var dow = 0; dow < 7; dow++) { // days of the week
|
1500 |
+
var day = (dow + firstDay) % 7;
|
1501 |
+
thead += '<th' + ((dow + firstDay + 6) % 7 >= 5 ? ' class="ui-datepicker-week-end"' : '') + '>' +
|
1502 |
+
'<span title="' + dayNames[day] + '">' + dayNamesMin[day] + '</span></th>';
|
1503 |
+
}
|
1504 |
+
calender += thead + '</tr></thead><tbody>';
|
1505 |
+
var daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
|
1506 |
+
if (drawYear == inst.selectedYear && drawMonth == inst.selectedMonth)
|
1507 |
+
inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
|
1508 |
+
var leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
|
1509 |
+
var curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
|
1510 |
+
var numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
|
1511 |
+
this.maxRows = numRows;
|
1512 |
+
var printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
|
1513 |
+
for (var dRow = 0; dRow < numRows; dRow++) { // create date picker rows
|
1514 |
+
calender += '<tr>';
|
1515 |
+
var tbody = (!showWeek ? '' : '<td class="ui-datepicker-week-col">' +
|
1516 |
+
this._get(inst, 'calculateWeek')(printDate) + '</td>');
|
1517 |
+
for (var dow = 0; dow < 7; dow++) { // create date picker days
|
1518 |
+
var daySettings = (beforeShowDay ?
|
1519 |
+
beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, '']);
|
1520 |
+
var otherMonth = (printDate.getMonth() != drawMonth);
|
1521 |
+
var unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
|
1522 |
+
(minDate && printDate < minDate) || (maxDate && printDate > maxDate);
|
1523 |
+
tbody += '<td class="' +
|
1524 |
+
((dow + firstDay + 6) % 7 >= 5 ? ' ui-datepicker-week-end' : '') + // highlight weekends
|
1525 |
+
(otherMonth ? ' ui-datepicker-other-month' : '') + // highlight days from other months
|
1526 |
+
((printDate.getTime() == selectedDate.getTime() && drawMonth == inst.selectedMonth && inst._keyEvent) || // user pressed key
|
1527 |
+
(defaultDate.getTime() == printDate.getTime() && defaultDate.getTime() == selectedDate.getTime()) ?
|
1528 |
+
// or defaultDate is current printedDate and defaultDate is selectedDate
|
1529 |
+
' ' + this._dayOverClass : '') + // highlight selected day
|
1530 |
+
(unselectable ? ' ' + this._unselectableClass + ' ui-state-disabled': '') + // highlight unselectable days
|
1531 |
+
(otherMonth && !showOtherMonths ? '' : ' ' + daySettings[1] + // highlight custom dates
|
1532 |
+
(printDate.getTime() == currentDate.getTime() ? ' ' + this._currentClass : '') + // highlight selected day
|
1533 |
+
(printDate.getTime() == today.getTime() ? ' ui-datepicker-today' : '')) + '"' + // highlight today (if different)
|
1534 |
+
((!otherMonth || showOtherMonths) && daySettings[2] ? ' title="' + daySettings[2] + '"' : '') + // cell title
|
1535 |
+
(unselectable ? '' : ' onclick="DP_jQuery_' + dpuuid + '.datepicker._selectDay(\'#' +
|
1536 |
+
inst.id + '\',' + printDate.getMonth() + ',' + printDate.getFullYear() + ', this);return false;"') + '>' + // actions
|
1537 |
+
(otherMonth && !showOtherMonths ? ' ' : // display for other months
|
1538 |
+
(unselectable ? '<span class="ui-state-default">' + printDate.getDate() + '</span>' : '<a class="ui-state-default' +
|
1539 |
+
(printDate.getTime() == today.getTime() ? ' ui-state-highlight' : '') +
|
1540 |
+
(printDate.getTime() == currentDate.getTime() ? ' ui-state-active' : '') + // highlight selected day
|
1541 |
+
(otherMonth ? ' ui-priority-secondary' : '') + // distinguish dates from other months
|
1542 |
+
'" href="#">' + printDate.getDate() + '</a>')) + '</td>'; // display selectable date
|
1543 |
+
printDate.setDate(printDate.getDate() + 1);
|
1544 |
+
printDate = this._daylightSavingAdjust(printDate);
|
1545 |
+
}
|
1546 |
+
calender += tbody + '</tr>';
|
1547 |
+
}
|
1548 |
+
drawMonth++;
|
1549 |
+
if (drawMonth > 11) {
|
1550 |
+
drawMonth = 0;
|
1551 |
+
drawYear++;
|
1552 |
+
}
|
1553 |
+
calender += '</tbody></table>' + (isMultiMonth ? '</div>' +
|
1554 |
+
((numMonths[0] > 0 && col == numMonths[1]-1) ? '<div class="ui-datepicker-row-break"></div>' : '') : '');
|
1555 |
+
group += calender;
|
1556 |
+
}
|
1557 |
+
html += group;
|
1558 |
+
}
|
1559 |
+
html += buttonPanel + ($.browser.msie && parseInt($.browser.version,10) < 7 && !inst.inline ?
|
1560 |
+
'<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>' : '');
|
1561 |
+
inst._keyEvent = false;
|
1562 |
+
return html;
|
1563 |
+
},
|
1564 |
+
|
1565 |
+
/* Generate the month and year header. */
|
1566 |
+
_generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
|
1567 |
+
secondary, monthNames, monthNamesShort) {
|
1568 |
+
var changeMonth = this._get(inst, 'changeMonth');
|
1569 |
+
var changeYear = this._get(inst, 'changeYear');
|
1570 |
+
var showMonthAfterYear = this._get(inst, 'showMonthAfterYear');
|
1571 |
+
var html = '<div class="ui-datepicker-title">';
|
1572 |
+
var monthHtml = '';
|
1573 |
+
// month selection
|
1574 |
+
if (secondary || !changeMonth)
|
1575 |
+
monthHtml += '<span class="ui-datepicker-month">' + monthNames[drawMonth] + '</span>';
|
1576 |
+
else {
|
1577 |
+
var inMinYear = (minDate && minDate.getFullYear() == drawYear);
|
1578 |
+
var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear);
|
1579 |
+
monthHtml += '<select class="ui-datepicker-month" ' +
|
1580 |
+
'onchange="DP_jQuery_' + dpuuid + '.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'M\');" ' +
|
1581 |
+
'onclick="DP_jQuery_' + dpuuid + '.datepicker._clickMonthYear(\'#' + inst.id + '\');"' +
|
1582 |
+
'>';
|
1583 |
+
for (var month = 0; month < 12; month++) {
|
1584 |
+
if ((!inMinYear || month >= minDate.getMonth()) &&
|
1585 |
+
(!inMaxYear || month <= maxDate.getMonth()))
|
1586 |
+
monthHtml += '<option value="' + month + '"' +
|
1587 |
+
(month == drawMonth ? ' selected="selected"' : '') +
|
1588 |
+
'>' + monthNamesShort[month] + '</option>';
|
1589 |
+
}
|
1590 |
+
monthHtml += '</select>';
|
1591 |
+
}
|
1592 |
+
if (!showMonthAfterYear)
|
1593 |
+
html += monthHtml + (secondary || !(changeMonth && changeYear) ? ' ' : '');
|
1594 |
+
// year selection
|
1595 |
+
if ( !inst.yearshtml ) {
|
1596 |
+
inst.yearshtml = '';
|
1597 |
+
if (secondary || !changeYear)
|
1598 |
+
html += '<span class="ui-datepicker-year">' + drawYear + '</span>';
|
1599 |
+
else {
|
1600 |
+
// determine range of years to display
|
1601 |
+
var years = this._get(inst, 'yearRange').split(':');
|
1602 |
+
var thisYear = new Date().getFullYear();
|
1603 |
+
var determineYear = function(value) {
|
1604 |
+
var year = (value.match(/c[+-].*/) ? drawYear + parseInt(value.substring(1), 10) :
|
1605 |
+
(value.match(/[+-].*/) ? thisYear + parseInt(value, 10) :
|
1606 |
+
parseInt(value, 10)));
|
1607 |
+
return (isNaN(year) ? thisYear : year);
|
1608 |
+
};
|
1609 |
+
var year = determineYear(years[0]);
|
1610 |
+
var endYear = Math.max(year, determineYear(years[1] || ''));
|
1611 |
+
year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
|
1612 |
+
endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
|
1613 |
+
inst.yearshtml += '<select class="ui-datepicker-year" ' +
|
1614 |
+
'onchange="DP_jQuery_' + dpuuid + '.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'Y\');" ' +
|
1615 |
+
'onclick="DP_jQuery_' + dpuuid + '.datepicker._clickMonthYear(\'#' + inst.id + '\');"' +
|
1616 |
+
'>';
|
1617 |
+
for (; year <= endYear; year++) {
|
1618 |
+
inst.yearshtml += '<option value="' + year + '"' +
|
1619 |
+
(year == drawYear ? ' selected="selected"' : '') +
|
1620 |
+
'>' + year + '</option>';
|
1621 |
+
}
|
1622 |
+
inst.yearshtml += '</select>';
|
1623 |
+
|
1624 |
+
html += inst.yearshtml;
|
1625 |
+
inst.yearshtml = null;
|
1626 |
+
}
|
1627 |
+
}
|
1628 |
+
html += this._get(inst, 'yearSuffix');
|
1629 |
+
if (showMonthAfterYear)
|
1630 |
+
html += (secondary || !(changeMonth && changeYear) ? ' ' : '') + monthHtml;
|
1631 |
+
html += '</div>'; // Close datepicker_header
|
1632 |
+
return html;
|
1633 |
+
},
|
1634 |
+
|
1635 |
+
/* Adjust one of the date sub-fields. */
|
1636 |
+
_adjustInstDate: function(inst, offset, period) {
|
1637 |
+
var year = inst.drawYear + (period == 'Y' ? offset : 0);
|
1638 |
+
var month = inst.drawMonth + (period == 'M' ? offset : 0);
|
1639 |
+
var day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) +
|
1640 |
+
(period == 'D' ? offset : 0);
|
1641 |
+
var date = this._restrictMinMax(inst,
|
1642 |
+
this._daylightSavingAdjust(new Date(year, month, day)));
|
1643 |
+
inst.selectedDay = date.getDate();
|
1644 |
+
inst.drawMonth = inst.selectedMonth = date.getMonth();
|
1645 |
+
inst.drawYear = inst.selectedYear = date.getFullYear();
|
1646 |
+
if (period == 'M' || period == 'Y')
|
1647 |
+
this._notifyChange(inst);
|
1648 |
+
},
|
1649 |
+
|
1650 |
+
/* Ensure a date is within any min/max bounds. */
|
1651 |
+
_restrictMinMax: function(inst, date) {
|
1652 |
+
var minDate = this._getMinMaxDate(inst, 'min');
|
1653 |
+
var maxDate = this._getMinMaxDate(inst, 'max');
|
1654 |
+
var newDate = (minDate && date < minDate ? minDate : date);
|
1655 |
+
newDate = (maxDate && newDate > maxDate ? maxDate : newDate);
|
1656 |
+
return newDate;
|
1657 |
+
},
|
1658 |
+
|
1659 |
+
/* Notify change of month/year. */
|
1660 |
+
_notifyChange: function(inst) {
|
1661 |
+
var onChange = this._get(inst, 'onChangeMonthYear');
|
1662 |
+
if (onChange)
|
1663 |
+
onChange.apply((inst.input ? inst.input[0] : null),
|
1664 |
+
[inst.selectedYear, inst.selectedMonth + 1, inst]);
|
1665 |
+
},
|
1666 |
+
|
1667 |
+
/* Determine the number of months to show. */
|
1668 |
+
_getNumberOfMonths: function(inst) {
|
1669 |
+
var numMonths = this._get(inst, 'numberOfMonths');
|
1670 |
+
return (numMonths == null ? [1, 1] : (typeof numMonths == 'number' ? [1, numMonths] : numMonths));
|
1671 |
+
},
|
1672 |
+
|
1673 |
+
/* Determine the current maximum date - ensure no time components are set. */
|
1674 |
+
_getMinMaxDate: function(inst, minMax) {
|
1675 |
+
return this._determineDate(inst, this._get(inst, minMax + 'Date'), null);
|
1676 |
+
},
|
1677 |
+
|
1678 |
+
/* Find the number of days in a given month. */
|
1679 |
+
_getDaysInMonth: function(year, month) {
|
1680 |
+
return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
|
1681 |
+
},
|
1682 |
+
|
1683 |
+
/* Find the day of the week of the first of a month. */
|
1684 |
+
_getFirstDayOfMonth: function(year, month) {
|
1685 |
+
return new Date(year, month, 1).getDay();
|
1686 |
+
},
|
1687 |
+
|
1688 |
+
/* Determines if we should allow a "next/prev" month display change. */
|
1689 |
+
_canAdjustMonth: function(inst, offset, curYear, curMonth) {
|
1690 |
+
var numMonths = this._getNumberOfMonths(inst);
|
1691 |
+
var date = this._daylightSavingAdjust(new Date(curYear,
|
1692 |
+
curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
|
1693 |
+
if (offset < 0)
|
1694 |
+
date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
|
1695 |
+
return this._isInRange(inst, date);
|
1696 |
+
},
|
1697 |
+
|
1698 |
+
/* Is the given date in the accepted range? */
|
1699 |
+
_isInRange: function(inst, date) {
|
1700 |
+
var minDate = this._getMinMaxDate(inst, 'min');
|
1701 |
+
var maxDate = this._getMinMaxDate(inst, 'max');
|
1702 |
+
return ((!minDate || date.getTime() >= minDate.getTime()) &&
|
1703 |
+
(!maxDate || date.getTime() <= maxDate.getTime()));
|
1704 |
+
},
|
1705 |
+
|
1706 |
+
/* Provide the configuration settings for formatting/parsing. */
|
1707 |
+
_getFormatConfig: function(inst) {
|
1708 |
+
var shortYearCutoff = this._get(inst, 'shortYearCutoff');
|
1709 |
+
shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff :
|
1710 |
+
new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
|
1711 |
+
return {shortYearCutoff: shortYearCutoff,
|
1712 |
+
dayNamesShort: this._get(inst, 'dayNamesShort'), dayNames: this._get(inst, 'dayNames'),
|
1713 |
+
monthNamesShort: this._get(inst, 'monthNamesShort'), monthNames: this._get(inst, 'monthNames')};
|
1714 |
+
},
|
1715 |
+
|
1716 |
+
/* Format the given date for display. */
|
1717 |
+
_formatDate: function(inst, day, month, year) {
|
1718 |
+
if (!day) {
|
1719 |
+
inst.currentDay = inst.selectedDay;
|
1720 |
+
inst.currentMonth = inst.selectedMonth;
|
1721 |
+
inst.currentYear = inst.selectedYear;
|
1722 |
+
}
|
1723 |
+
var date = (day ? (typeof day == 'object' ? day :
|
1724 |
+
this._daylightSavingAdjust(new Date(year, month, day))) :
|
1725 |
+
this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
|
1726 |
+
return this.formatDate(this._get(inst, 'dateFormat'), date, this._getFormatConfig(inst));
|
1727 |
+
}
|
1728 |
+
});
|
1729 |
+
|
1730 |
+
/*
|
1731 |
+
* Bind hover events for datepicker elements.
|
1732 |
+
* Done via delegate so the binding only occurs once in the lifetime of the parent div.
|
1733 |
+
* Global instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
|
1734 |
+
*/
|
1735 |
+
function bindHover(dpDiv) {
|
1736 |
+
var selector = 'button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a';
|
1737 |
+
return dpDiv.bind('mouseout', function(event) {
|
1738 |
+
var elem = $( event.target ).closest( selector );
|
1739 |
+
if ( !elem.length ) {
|
1740 |
+
return;
|
1741 |
+
}
|
1742 |
+
elem.removeClass( "ui-state-hover ui-datepicker-prev-hover ui-datepicker-next-hover" );
|
1743 |
+
})
|
1744 |
+
.bind('mouseover', function(event) {
|
1745 |
+
var elem = $( event.target ).closest( selector );
|
1746 |
+
if ($.datepicker._isDisabledDatepicker( instActive.inline ? dpDiv.parent()[0] : instActive.input[0]) ||
|
1747 |
+
!elem.length ) {
|
1748 |
+
return;
|
1749 |
+
}
|
1750 |
+
elem.parents('.ui-datepicker-calendar').find('a').removeClass('ui-state-hover');
|
1751 |
+
elem.addClass('ui-state-hover');
|
1752 |
+
if (elem.hasClass('ui-datepicker-prev')) elem.addClass('ui-datepicker-prev-hover');
|
1753 |
+
if (elem.hasClass('ui-datepicker-next')) elem.addClass('ui-datepicker-next-hover');
|
1754 |
+
});
|
1755 |
+
}
|
1756 |
+
|
1757 |
+
/* jQuery extend now ignores nulls! */
|
1758 |
+
function extendRemove(target, props) {
|
1759 |
+
$.extend(target, props);
|
1760 |
+
for (var name in props)
|
1761 |
+
if (props[name] == null || props[name] == undefined)
|
1762 |
+
target[name] = props[name];
|
1763 |
+
return target;
|
1764 |
+
};
|
1765 |
+
|
1766 |
+
/* Determine whether an object is an array. */
|
1767 |
+
function isArray(a) {
|
1768 |
+
return (a && (($.browser.safari && typeof a == 'object' && a.length) ||
|
1769 |
+
(a.constructor && a.constructor.toString().match(/\Array\(\)/))));
|
1770 |
+
};
|
1771 |
+
|
1772 |
+
/* Invoke the datepicker functionality.
|
1773 |
+
@param options string - a command, optionally followed by additional parameters or
|
1774 |
+
Object - settings for attaching new datepicker functionality
|
1775 |
+
@return jQuery object */
|
1776 |
+
$.fn.datepicker = function(options){
|
1777 |
+
|
1778 |
+
/* Verify an empty collection wasn't passed - Fixes #6976 */
|
1779 |
+
if ( !this.length ) {
|
1780 |
+
return this;
|
1781 |
+
}
|
1782 |
+
|
1783 |
+
/* Initialise the date picker. */
|
1784 |
+
if (!$.datepicker.initialized) {
|
1785 |
+
$(document).mousedown($.datepicker._checkExternalClick).
|
1786 |
+
find('body').append($.datepicker.dpDiv);
|
1787 |
+
$.datepicker.initialized = true;
|
1788 |
+
}
|
1789 |
+
|
1790 |
+
var otherArgs = Array.prototype.slice.call(arguments, 1);
|
1791 |
+
if (typeof options == 'string' && (options == 'isDisabled' || options == 'getDate' || options == 'widget'))
|
1792 |
+
return $.datepicker['_' + options + 'Datepicker'].
|
1793 |
+
apply($.datepicker, [this[0]].concat(otherArgs));
|
1794 |
+
if (options == 'option' && arguments.length == 2 && typeof arguments[1] == 'string')
|
1795 |
+
return $.datepicker['_' + options + 'Datepicker'].
|
1796 |
+
apply($.datepicker, [this[0]].concat(otherArgs));
|
1797 |
+
return this.each(function() {
|
1798 |
+
typeof options == 'string' ?
|
1799 |
+
$.datepicker['_' + options + 'Datepicker'].
|
1800 |
+
apply($.datepicker, [this].concat(otherArgs)) :
|
1801 |
+
$.datepicker._attachDatepicker(this, options);
|
1802 |
+
});
|
1803 |
+
};
|
1804 |
+
|
1805 |
+
$.datepicker = new Datepicker(); // singleton instance
|
1806 |
+
$.datepicker.initialized = false;
|
1807 |
+
$.datepicker.uuid = new Date().getTime();
|
1808 |
+
$.datepicker.version = "1.8.14";
|
1809 |
+
|
1810 |
+
// Workaround for #4055
|
1811 |
+
// Add another global to avoid noConflict issues with inline event handlers
|
1812 |
+
window['DP_jQuery_' + dpuuid] = $;
|
1813 |
+
|
1814 |
+
})(jQuery);
|
shared/assets/plugins/advanced-custom-fields/core/fields/date_picker/style.date_picker.css
CHANGED
@@ -1,410 +1,410 @@
|
|
1 |
-
/*
|
2 |
-
* jQuery UI CSS Framework 1.8.14
|
3 |
-
*
|
4 |
-
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
5 |
-
* Dual licensed under the MIT or GPL Version 2 licenses.
|
6 |
-
* http://jquery.org/license
|
7 |
-
*
|
8 |
-
* http://docs.jquery.com/UI/Theming/API
|
9 |
-
*/
|
10 |
-
|
11 |
-
/* Layout helpers
|
12 |
-
----------------------------------*/
|
13 |
-
.ui-acf .ui-helper-hidden { display: none; }
|
14 |
-
.ui-acf .ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); }
|
15 |
-
.ui-acf .ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; }
|
16 |
-
.ui-acf .ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
|
17 |
-
.ui-acf .ui-helper-clearfix { display: inline-block; }
|
18 |
-
/* required comment for clearfix to work in Opera \*/
|
19 |
-
* html .ui-helper-clearfix { height:1%; }
|
20 |
-
.ui-acf .ui-helper-clearfix { display:block; }
|
21 |
-
/* end clearfix */
|
22 |
-
.ui-acf .ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); }
|
23 |
-
|
24 |
-
|
25 |
-
/* Interaction Cues
|
26 |
-
----------------------------------*/
|
27 |
-
.ui-acf .ui-state-disabled { cursor: default !important; }
|
28 |
-
|
29 |
-
|
30 |
-
/* Icons
|
31 |
-
----------------------------------*/
|
32 |
-
|
33 |
-
/* states and images */
|
34 |
-
.ui-acf .ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; }
|
35 |
-
|
36 |
-
|
37 |
-
/* Misc visuals
|
38 |
-
----------------------------------*/
|
39 |
-
|
40 |
-
/* Overlays */
|
41 |
-
.ui-acf .ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
|
42 |
-
|
43 |
-
|
44 |
-
/*
|
45 |
-
* jQuery UI CSS Framework 1.8.14
|
46 |
-
*
|
47 |
-
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
48 |
-
* Dual licensed under the MIT or GPL Version 2 licenses.
|
49 |
-
* http://jquery.org/license
|
50 |
-
*
|
51 |
-
* http://docs.jquery.com/UI/Theming/API
|
52 |
-
*
|
53 |
-
* To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Verdana,Arial,sans-serif&fwDefault=normal&fsDefault=1.1em&cornerRadius=4px&bgColorHeader=444444&bgTextureHeader=03_highlight_soft.png&bgImgOpacityHeader=0&borderColorHeader=000000&fcHeader=e5e5e5&iconColorHeader=222222&bgColorContent=ffffff&bgTextureContent=01_flat.png&bgImgOpacityContent=75&borderColorContent=aaaaaa&fcContent=222222&iconColorContent=222222&bgColorDefault=e6e6e6&bgTextureDefault=02_glass.png&bgImgOpacityDefault=75&borderColorDefault=d3d3d3&fcDefault=555555&iconColorDefault=888888&bgColorHover=dadada&bgTextureHover=02_glass.png&bgImgOpacityHover=75&borderColorHover=999999&fcHover=212121&iconColorHover=454545&bgColorActive=ffffff&bgTextureActive=02_glass.png&bgImgOpacityActive=65&borderColorActive=aaaaaa&fcActive=212121&iconColorActive=454545&bgColorHighlight=5bc6f5&bgTextureHighlight=01_flat.png&bgImgOpacityHighlight=55&borderColorHighlight=1cb1f2&fcHighlight=ffffff&iconColorHighlight=2e83ff&bgColorError=fef1ec&bgTextureError=02_glass.png&bgImgOpacityError=95&borderColorError=cd0a0a&fcError=cd0a0a&iconColorError=cd0a0a&bgColorOverlay=aaaaaa&bgTextureOverlay=01_flat.png&bgImgOpacityOverlay=0&opacityOverlay=30&bgColorShadow=aaaaaa&bgTextureShadow=01_flat.png&bgImgOpacityShadow=0&opacityShadow=30&thicknessShadow=8px&offsetTopShadow=-8px&offsetLeftShadow=-8px&cornerRadiusShadow=8px
|
54 |
-
*/
|
55 |
-
|
56 |
-
|
57 |
-
/* Component containers
|
58 |
-
----------------------------------*/
|
59 |
-
.ui-acf .ui-widget { font-family: Verdana,Arial,sans-serif; font-size: 1.1em; }
|
60 |
-
.ui-acf .ui-widget .ui-widget { font-size: 1em; }
|
61 |
-
.ui-acf .ui-widget input, .ui-acf .ui-widget select, .ui-acf .ui-widget textarea, .ui-acf .ui-widget button { font-family: Verdana,Arial,sans-serif; font-size: 1em; }
|
62 |
-
.ui-acf .ui-widget-content {
|
63 |
-
border: 1px solid #E1E1E1;
|
64 |
-
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
65 |
-
color: #222222;
|
66 |
-
background: #fff;
|
67 |
-
}
|
68 |
-
.ui-acf .ui-widget-content a { color: #222222; }
|
69 |
-
.ui-acf .ui-widget-header {
|
70 |
-
background: #2EA2CC;
|
71 |
-
color: #e5e5e5;
|
72 |
-
font-weight: bold;
|
73 |
-
border-radius: 0 !important;
|
74 |
-
width: 100%;
|
75 |
-
padding: 8px 3px;
|
76 |
-
position: relative;
|
77 |
-
margin: -3px 0 0 -3px;
|
78 |
-
}
|
79 |
-
|
80 |
-
.ui-acf .ui-widget-header a { color: #e5e5e5; }
|
81 |
-
|
82 |
-
/* Interaction states
|
83 |
-
----------------------------------*/
|
84 |
-
.ui-acf .ui-state-default, .ui-acf .ui-widget-content .ui-state-default, .ui-acf .ui-widget-header .ui-state-default { border: 1px solid #E1E1E1; background: #F9F9F9; font-weight: normal; color: #555555; }
|
85 |
-
.ui-acf .ui-state-default a, .ui-acf .ui-state-default a:link, .ui-acf .ui-state-default a:visited { color: #555555; text-decoration: none; }
|
86 |
-
.ui-acf .ui-state-hover, .ui-acf .ui-widget-content .ui-state-hover, .ui-acf .ui-widget-header .ui-state-hover, .ui-acf .ui-state-focus, .ui-acf .ui-widget-content .ui-state-focus, .ui-acf .ui-widget-header .ui-state-focus { border: 1px solid #999999; background: #dadada url(images/ui-bg_glass_75_dadada_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #212121; }
|
87 |
-
.ui-acf .ui-state-hover a, .ui-acf .ui-state-hover a:hover { color: #212121; text-decoration: none; }
|
88 |
-
.ui-acf .ui-state-active, .ui-acf .ui-widget-content .ui-state-active, .ui-acf .ui-widget-header .ui-state-active { border: 1px solid #aaaaaa; background: #ffffff url(images/ui-bg_glass_65_ffffff_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #212121; }
|
89 |
-
.ui-acf .ui-state-active a, .ui-acf .ui-state-active a:link, .ui-acf .ui-state-active a:visited { color: #212121; text-decoration: none; }
|
90 |
-
.ui-acf .ui-widget :active { outline: none; }
|
91 |
-
|
92 |
-
/* Interaction Cues
|
93 |
-
----------------------------------*/
|
94 |
-
.ui-acf .ui-state-highlight, .ui-acf .ui-widget-content .ui-state-highlight, .ui-acf .ui-widget-header .ui-state-highlight {border: 1px solid #1cb1f2; background: #5bc6f5 url(images/ui-bg_flat_55_5bc6f5_40x100.png) 50% 50% repeat-x; color: #ffffff; }
|
95 |
-
.ui-acf .ui-state-highlight a, .ui-acf .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #ffffff; }
|
96 |
-
.ui-acf .ui-state-error, .ui-acf .ui-widget-content .ui-state-error, .ui-acf .ui-widget-header .ui-state-error {border: 1px solid #cd0a0a; background: #fef1ec url(images/ui-bg_glass_95_fef1ec_1x400.png) 50% 50% repeat-x; color: #cd0a0a; }
|
97 |
-
.ui-acf .ui-state-error a, .ui-acf .ui-widget-content .ui-state-error a, .ui-acf .ui-widget-header .ui-state-error a { color: #cd0a0a; }
|
98 |
-
.ui-acf .ui-state-error-text, .ui-acf .ui-widget-content .ui-state-error-text, .ui-acf .ui-widget-header .ui-state-error-text { color: #cd0a0a; }
|
99 |
-
.ui-acf .ui-priority-primary, .ui-acf .ui-widget-content .ui-priority-primary, .ui-acf .ui-widget-header .ui-priority-primary { font-weight: bold; }
|
100 |
-
.ui-acf .ui-priority-secondary, .ui-acf .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; }
|
101 |
-
.ui-acf .ui-state-disabled, .ui-acf .ui-widget-content .ui-state-disabled, .ui-acf .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; }
|
102 |
-
|
103 |
-
/* Icons
|
104 |
-
----------------------------------*/
|
105 |
-
|
106 |
-
/* states and images */
|
107 |
-
.ui-acf .ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_222222_256x240.png); }
|
108 |
-
.ui-acf .ui-widget-content .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); }
|
109 |
-
.ui-acf .ui-widget-header .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); }
|
110 |
-
.ui-acf .ui-state-default .ui-icon { background-image: url(images/ui-icons_888888_256x240.png); }
|
111 |
-
.ui-acf .ui-state-hover .ui-icon, .ui-acf .ui-state-focus .ui-icon {background-image: url(images/ui-icons_454545_256x240.png); }
|
112 |
-
.ui-acf .ui-state-active .ui-icon {background-image: url(images/ui-icons_454545_256x240.png); }
|
113 |
-
.ui-acf .ui-state-highlight .ui-icon {background-image: url(images/ui-icons_2e83ff_256x240.png); }
|
114 |
-
.ui-acf .ui-state-error .ui-icon, .ui-acf .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_cd0a0a_256x240.png); }
|
115 |
-
|
116 |
-
/* positioning */
|
117 |
-
.ui-acf .ui-icon-carat-1-n { background-position: 0 0; }
|
118 |
-
.ui-acf .ui-icon-carat-1-ne { background-position: -16px 0; }
|
119 |
-
.ui-acf .ui-icon-carat-1-e { background-position: -32px 0; }
|
120 |
-
.ui-acf .ui-icon-carat-1-se { background-position: -48px 0; }
|
121 |
-
.ui-acf .ui-icon-carat-1-s { background-position: -64px 0; }
|
122 |
-
.ui-acf .ui-icon-carat-1-sw { background-position: -80px 0; }
|
123 |
-
.ui-acf .ui-icon-carat-1-w { background-position: -96px 0; }
|
124 |
-
.ui-acf .ui-icon-carat-1-nw { background-position: -112px 0; }
|
125 |
-
.ui-acf .ui-icon-carat-2-n-s { background-position: -128px 0; }
|
126 |
-
.ui-acf .ui-icon-carat-2-e-w { background-position: -144px 0; }
|
127 |
-
.ui-acf .ui-icon-triangle-1-n { background-position: 0 -16px; }
|
128 |
-
.ui-acf .ui-icon-triangle-1-ne { background-position: -16px -16px; }
|
129 |
-
.ui-acf .ui-icon-triangle-1-e { background-position: -32px -16px; }
|
130 |
-
.ui-acf .ui-icon-triangle-1-se { background-position: -48px -16px; }
|
131 |
-
.ui-acf .ui-icon-triangle-1-s { background-position: -64px -16px; }
|
132 |
-
.ui-acf .ui-icon-triangle-1-sw { background-position: -80px -16px; }
|
133 |
-
.ui-acf .ui-icon-triangle-1-w { background-position: -96px -16px; }
|
134 |
-
.ui-acf .ui-icon-triangle-1-nw { background-position: -112px -16px; }
|
135 |
-
.ui-acf .ui-icon-triangle-2-n-s { background-position: -128px -16px; }
|
136 |
-
.ui-acf .ui-icon-triangle-2-e-w { background-position: -144px -16px; }
|
137 |
-
.ui-acf .ui-icon-arrow-1-n { background-position: 0 -32px; }
|
138 |
-
.ui-acf .ui-icon-arrow-1-ne { background-position: -16px -32px; }
|
139 |
-
.ui-acf .ui-icon-arrow-1-e { background-position: -32px -32px; }
|
140 |
-
.ui-acf .ui-icon-arrow-1-se { background-position: -48px -32px; }
|
141 |
-
.ui-acf .ui-icon-arrow-1-s { background-position: -64px -32px; }
|
142 |
-
.ui-acf .ui-icon-arrow-1-sw { background-position: -80px -32px; }
|
143 |
-
.ui-acf .ui-icon-arrow-1-w { background-position: -96px -32px; }
|
144 |
-
.ui-acf .ui-icon-arrow-1-nw { background-position: -112px -32px; }
|
145 |
-
.ui-acf .ui-icon-arrow-2-n-s { background-position: -128px -32px; }
|
146 |
-
.ui-acf .ui-icon-arrow-2-ne-sw { background-position: -144px -32px; }
|
147 |
-
.ui-acf .ui-icon-arrow-2-e-w { background-position: -160px -32px; }
|
148 |
-
.ui-acf .ui-icon-arrow-2-se-nw { background-position: -176px -32px; }
|
149 |
-
.ui-acf .ui-icon-arrowstop-1-n { background-position: -192px -32px; }
|
150 |
-
.ui-acf .ui-icon-arrowstop-1-e { background-position: -208px -32px; }
|
151 |
-
.ui-acf .ui-icon-arrowstop-1-s { background-position: -224px -32px; }
|
152 |
-
.ui-acf .ui-icon-arrowstop-1-w { background-position: -240px -32px; }
|
153 |
-
.ui-acf .ui-icon-arrowthick-1-n { background-position: 0 -48px; }
|
154 |
-
.ui-acf .ui-icon-arrowthick-1-ne { background-position: -16px -48px; }
|
155 |
-
.ui-acf .ui-icon-arrowthick-1-e { background-position: -32px -48px; }
|
156 |
-
.ui-acf .ui-icon-arrowthick-1-se { background-position: -48px -48px; }
|
157 |
-
.ui-acf .ui-icon-arrowthick-1-s { background-position: -64px -48px; }
|
158 |
-
.ui-acf .ui-icon-arrowthick-1-sw { background-position: -80px -48px; }
|
159 |
-
.ui-acf .ui-icon-arrowthick-1-w { background-position: -96px -48px; }
|
160 |
-
.ui-acf .ui-icon-arrowthick-1-nw { background-position: -112px -48px; }
|
161 |
-
.ui-acf .ui-icon-arrowthick-2-n-s { background-position: -128px -48px; }
|
162 |
-
.ui-acf .ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; }
|
163 |
-
.ui-acf .ui-icon-arrowthick-2-e-w { background-position: -160px -48px; }
|
164 |
-
.ui-acf .ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; }
|
165 |
-
.ui-acf .ui-icon-arrowthickstop-1-n { background-position: -192px -48px; }
|
166 |
-
.ui-acf .ui-icon-arrowthickstop-1-e { background-position: -208px -48px; }
|
167 |
-
.ui-acf .ui-icon-arrowthickstop-1-s { background-position: -224px -48px; }
|
168 |
-
.ui-acf .ui-icon-arrowthickstop-1-w { background-position: -240px -48px; }
|
169 |
-
.ui-acf .ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; }
|
170 |
-
.ui-acf .ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; }
|
171 |
-
.ui-acf .ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; }
|
172 |
-
.ui-acf .ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; }
|
173 |
-
.ui-acf .ui-icon-arrowreturn-1-w { background-position: -64px -64px; }
|
174 |
-
.ui-acf .ui-icon-arrowreturn-1-n { background-position: -80px -64px; }
|
175 |
-
.ui-acf .ui-icon-arrowreturn-1-e { background-position: -96px -64px; }
|
176 |
-
.ui-acf .ui-icon-arrowreturn-1-s { background-position: -112px -64px; }
|
177 |
-
.ui-acf .ui-icon-arrowrefresh-1-w { background-position: -128px -64px; }
|
178 |
-
.ui-acf .ui-icon-arrowrefresh-1-n { background-position: -144px -64px; }
|
179 |
-
.ui-acf .ui-icon-arrowrefresh-1-e { background-position: -160px -64px; }
|
180 |
-
.ui-acf .ui-icon-arrowrefresh-1-s { background-position: -176px -64px; }
|
181 |
-
.ui-acf .ui-icon-arrow-4 { background-position: 0 -80px; }
|
182 |
-
.ui-acf .ui-icon-arrow-4-diag { background-position: -16px -80px; }
|
183 |
-
.ui-acf .ui-icon-extlink { background-position: -32px -80px; }
|
184 |
-
.ui-acf .ui-icon-newwin { background-position: -48px -80px; }
|
185 |
-
.ui-acf .ui-icon-refresh { background-position: -64px -80px; }
|
186 |
-
.ui-acf .ui-icon-shuffle { background-position: -80px -80px; }
|
187 |
-
.ui-acf .ui-icon-transfer-e-w { background-position: -96px -80px; }
|
188 |
-
.ui-acf .ui-icon-transferthick-e-w { background-position: -112px -80px; }
|
189 |
-
.ui-acf .ui-icon-folder-collapsed { background-position: 0 -96px; }
|
190 |
-
.ui-acf .ui-icon-folder-open { background-position: -16px -96px; }
|
191 |
-
.ui-acf .ui-icon-document { background-position: -32px -96px; }
|
192 |
-
.ui-acf .ui-icon-document-b { background-position: -48px -96px; }
|
193 |
-
.ui-acf .ui-icon-note { background-position: -64px -96px; }
|
194 |
-
.ui-acf .ui-icon-mail-closed { background-position: -80px -96px; }
|
195 |
-
.ui-acf .ui-icon-mail-open { background-position: -96px -96px; }
|
196 |
-
.ui-acf .ui-icon-suitcase { background-position: -112px -96px; }
|
197 |
-
.ui-acf .ui-icon-comment { background-position: -128px -96px; }
|
198 |
-
.ui-acf .ui-icon-person { background-position: -144px -96px; }
|
199 |
-
.ui-acf .ui-icon-print { background-position: -160px -96px; }
|
200 |
-
.ui-acf .ui-icon-trash { background-position: -176px -96px; }
|
201 |
-
.ui-acf .ui-icon-locked { background-position: -192px -96px; }
|
202 |
-
.ui-acf .ui-icon-unlocked { background-position: -208px -96px; }
|
203 |
-
.ui-acf .ui-icon-bookmark { background-position: -224px -96px; }
|
204 |
-
.ui-acf .ui-icon-tag { background-position: -240px -96px; }
|
205 |
-
.ui-acf .ui-icon-home { background-position: 0 -112px; }
|
206 |
-
.ui-acf .ui-icon-flag { background-position: -16px -112px; }
|
207 |
-
.ui-acf .ui-icon-calendar { background-position: -32px -112px; }
|
208 |
-
.ui-acf .ui-icon-cart { background-position: -48px -112px; }
|
209 |
-
.ui-acf .ui-icon-pencil { background-position: -64px -112px; }
|
210 |
-
.ui-acf .ui-icon-clock { background-position: -80px -112px; }
|
211 |
-
.ui-acf .ui-icon-disk { background-position: -96px -112px; }
|
212 |
-
.ui-acf .ui-icon-calculator { background-position: -112px -112px; }
|
213 |
-
.ui-acf .ui-icon-zoomin { background-position: -128px -112px; }
|
214 |
-
.ui-acf .ui-icon-zoomout { background-position: -144px -112px; }
|
215 |
-
.ui-acf .ui-icon-search { background-position: -160px -112px; }
|
216 |
-
.ui-acf .ui-icon-wrench { background-position: -176px -112px; }
|
217 |
-
.ui-acf .ui-icon-gear { background-position: -192px -112px; }
|
218 |
-
.ui-acf .ui-icon-heart { background-position: -208px -112px; }
|
219 |
-
.ui-acf .ui-icon-star { background-position: -224px -112px; }
|
220 |
-
.ui-acf .ui-icon-link { background-position: -240px -112px; }
|
221 |
-
.ui-acf .ui-icon-cancel { background-position: 0 -128px; }
|
222 |
-
.ui-acf .ui-icon-plus { background-position: -16px -128px; }
|
223 |
-
.ui-acf .ui-icon-plusthick { background-position: -32px -128px; }
|
224 |
-
.ui-acf .ui-icon-minus { background-position: -48px -128px; }
|
225 |
-
.ui-acf .ui-icon-minusthick { background-position: -64px -128px; }
|
226 |
-
.ui-acf .ui-icon-close { background-position: -80px -128px; }
|
227 |
-
.ui-acf .ui-icon-closethick { background-position: -96px -128px; }
|
228 |
-
.ui-acf .ui-icon-key { background-position: -112px -128px; }
|
229 |
-
.ui-acf .ui-icon-lightbulb { background-position: -128px -128px; }
|
230 |
-
.ui-acf .ui-icon-scissors { background-position: -144px -128px; }
|
231 |
-
.ui-acf .ui-icon-clipboard { background-position: -160px -128px; }
|
232 |
-
.ui-acf .ui-icon-copy { background-position: -176px -128px; }
|
233 |
-
.ui-acf .ui-icon-contact { background-position: -192px -128px; }
|
234 |
-
.ui-acf .ui-icon-image { background-position: -208px -128px; }
|
235 |
-
.ui-acf .ui-icon-video { background-position: -224px -128px; }
|
236 |
-
.ui-acf .ui-icon-script { background-position: -240px -128px; }
|
237 |
-
.ui-acf .ui-icon-alert { background-position: 0 -144px; }
|
238 |
-
.ui-acf .ui-icon-info { background-position: -16px -144px; }
|
239 |
-
.ui-acf .ui-icon-notice { background-position: -32px -144px; }
|
240 |
-
.ui-acf .ui-icon-help { background-position: -48px -144px; }
|
241 |
-
.ui-acf .ui-icon-check { background-position: -64px -144px; }
|
242 |
-
.ui-acf .ui-icon-bullet { background-position: -80px -144px; }
|
243 |
-
.ui-acf .ui-icon-radio-off { background-position: -96px -144px; }
|
244 |
-
.ui-acf .ui-icon-radio-on { background-position: -112px -144px; }
|
245 |
-
.ui-acf .ui-icon-pin-w { background-position: -128px -144px; }
|
246 |
-
.ui-acf .ui-icon-pin-s { background-position: -144px -144px; }
|
247 |
-
.ui-acf .ui-icon-play { background-position: 0 -160px; }
|
248 |
-
.ui-acf .ui-icon-pause { background-position: -16px -160px; }
|
249 |
-
.ui-acf .ui-icon-seek-next { background-position: -32px -160px; }
|
250 |
-
.ui-acf .ui-icon-seek-prev { background-position: -48px -160px; }
|
251 |
-
.ui-acf .ui-icon-seek-end { background-position: -64px -160px; }
|
252 |
-
.ui-acf .ui-icon-seek-start { background-position: -80px -160px; }
|
253 |
-
/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */
|
254 |
-
.ui-acf .ui-icon-seek-first { background-position: -80px -160px; }
|
255 |
-
.ui-acf .ui-icon-stop { background-position: -96px -160px; }
|
256 |
-
.ui-acf .ui-icon-eject { background-position: -112px -160px; }
|
257 |
-
.ui-acf .ui-icon-volume-off { background-position: -128px -160px; }
|
258 |
-
.ui-acf .ui-icon-volume-on { background-position: -144px -160px; }
|
259 |
-
.ui-acf .ui-icon-power { background-position: 0 -176px; }
|
260 |
-
.ui-acf .ui-icon-signal-diag { background-position: -16px -176px; }
|
261 |
-
.ui-acf .ui-icon-signal { background-position: -32px -176px; }
|
262 |
-
.ui-acf .ui-icon-battery-0 { background-position: -48px -176px; }
|
263 |
-
.ui-acf .ui-icon-battery-1 { background-position: -64px -176px; }
|
264 |
-
.ui-acf .ui-icon-battery-2 { background-position: -80px -176px; }
|
265 |
-
.ui-acf .ui-icon-battery-3 { background-position: -96px -176px; }
|
266 |
-
.ui-acf .ui-icon-circle-plus { background-position: 0 -192px; }
|
267 |
-
.ui-acf .ui-icon-circle-minus { background-position: -16px -192px; }
|
268 |
-
.ui-acf .ui-icon-circle-close { background-position: -32px -192px; }
|
269 |
-
.ui-acf .ui-icon-circle-triangle-e { background-position: -48px -192px; }
|
270 |
-
.ui-acf .ui-icon-circle-triangle-s { background-position: -64px -192px; }
|
271 |
-
.ui-acf .ui-icon-circle-triangle-w { background-position: -80px -192px; }
|
272 |
-
.ui-acf .ui-icon-circle-triangle-n { background-position: -96px -192px; }
|
273 |
-
.ui-acf .ui-icon-circle-arrow-e { background-position: -112px -192px; }
|
274 |
-
.ui-acf .ui-icon-circle-arrow-s { background-position: -128px -192px; }
|
275 |
-
.ui-acf .ui-icon-circle-arrow-w { background-position: -144px -192px; }
|
276 |
-
.ui-acf .ui-icon-circle-arrow-n { background-position: -160px -192px; }
|
277 |
-
.ui-acf .ui-icon-circle-zoomin { background-position: -176px -192px; }
|
278 |
-
.ui-acf .ui-icon-circle-zoomout { background-position: -192px -192px; }
|
279 |
-
.ui-acf .ui-icon-circle-check { background-position: -208px -192px; }
|
280 |
-
.ui-acf .ui-icon-circlesmall-plus { background-position: 0 -208px; }
|
281 |
-
.ui-acf .ui-icon-circlesmall-minus { background-position: -16px -208px; }
|
282 |
-
.ui-acf .ui-icon-circlesmall-close { background-position: -32px -208px; }
|
283 |
-
.ui-acf .ui-icon-squaresmall-plus { background-position: -48px -208px; }
|
284 |
-
.ui-acf .ui-icon-squaresmall-minus { background-position: -64px -208px; }
|
285 |
-
.ui-acf .ui-icon-squaresmall-close { background-position: -80px -208px; }
|
286 |
-
.ui-acf .ui-icon-grip-dotted-vertical { background-position: 0 -224px; }
|
287 |
-
.ui-acf .ui-icon-grip-dotted-horizontal { background-position: -16px -224px; }
|
288 |
-
.ui-acf .ui-icon-grip-solid-vertical { background-position: -32px -224px; }
|
289 |
-
.ui-acf .ui-icon-grip-solid-horizontal { background-position: -48px -224px; }
|
290 |
-
.ui-acf .ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; }
|
291 |
-
.ui-acf .ui-icon-grip-diagonal-se { background-position: -80px -224px; }
|
292 |
-
|
293 |
-
|
294 |
-
/* Misc visuals
|
295 |
-
----------------------------------*/
|
296 |
-
|
297 |
-
/* Corner radius */
|
298 |
-
.ui-acf .ui-corner-all, .ui-acf .ui-corner-top, .ui-acf .ui-corner-left, .ui-acf .ui-corner-tl { -moz-border-radius-topleft: 4px; -webkit-border-top-left-radius: 4px; -khtml-border-top-left-radius: 4px; border-top-left-radius: 4px; }
|
299 |
-
.ui-acf .ui-corner-all, .ui-acf .ui-corner-top, .ui-acf .ui-corner-right, .ui-acf .ui-corner-tr { -moz-border-radius-topright: 4px; -webkit-border-top-right-radius: 4px; -khtml-border-top-right-radius: 4px; border-top-right-radius: 4px; }
|
300 |
-
.ui-acf .ui-corner-all, .ui-acf .ui-corner-bottom, .ui-acf .ui-corner-left, .ui-acf .ui-corner-bl { -moz-border-radius-bottomleft: 4px; -webkit-border-bottom-left-radius: 4px; -khtml-border-bottom-left-radius: 4px; border-bottom-left-radius: 4px; }
|
301 |
-
.ui-acf .ui-corner-all, .ui-acf .ui-corner-bottom, .ui-acf .ui-corner-right, .ui-acf .ui-corner-br { -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 4px; -khtml-border-bottom-right-radius: 4px; border-bottom-right-radius: 4px; }
|
302 |
-
|
303 |
-
/* Overlays */
|
304 |
-
.ui-acf .ui-widget-overlay { background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); }
|
305 |
-
.ui-acf .ui-widget-shadow { margin: -8px 0 0 -8px; padding: 8px; background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); -moz-border-radius: 8px; -khtml-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; }/*
|
306 |
-
* jQuery UI Datepicker 1.8.14
|
307 |
-
*
|
308 |
-
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
309 |
-
* Dual licensed under the MIT or GPL Version 2 licenses.
|
310 |
-
* http://jquery.org/license
|
311 |
-
*
|
312 |
-
* http://docs.jquery.com/UI/Datepicker#theming
|
313 |
-
*/
|
314 |
-
.ui-acf .ui-datepicker { width: 17em; padding: .2em .2em 0; display: none; border-radius: 0 !important; }
|
315 |
-
.ui-acf .ui-datepicker .ui-datepicker-header { }
|
316 |
-
.ui-acf .ui-datepicker .ui-datepicker-prev, .ui-acf .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; display: none; }
|
317 |
-
.ui-acf .ui-datepicker .ui-datepicker-prev-hover, .ui-acf .ui-datepicker .ui-datepicker-next-hover { top: 1px; }
|
318 |
-
.ui-acf .ui-datepicker .ui-datepicker-prev { left:2px; }
|
319 |
-
.ui-acf .ui-datepicker .ui-datepicker-next { right:2px; }
|
320 |
-
.ui-acf .ui-datepicker .ui-datepicker-prev-hover { left:1px; }
|
321 |
-
.ui-acf .ui-datepicker .ui-datepicker-next-hover { right:1px; }
|
322 |
-
.ui-acf .ui-datepicker .ui-datepicker-prev span, .ui-acf .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; }
|
323 |
-
.ui-acf .ui-datepicker .ui-datepicker-title { margin: 0; }
|
324 |
-
.ui-acf .ui-datepicker .ui-datepicker-title select { font-size:1em; margin:0 0 0 2%; }
|
325 |
-
.ui-acf .ui-datepicker select.ui-datepicker-month-year {width: 100%;}
|
326 |
-
.ui-acf .ui-datepicker select.ui-datepicker-month,
|
327 |
-
.ui-acf .ui-datepicker select.ui-datepicker-year { width: 47%; padding: 1px; font-size: 12px; font-weight: normal;}
|
328 |
-
.ui-acf .ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; }
|
329 |
-
.ui-acf .ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; width: 14%; }
|
330 |
-
.ui-acf .ui-datepicker td { border: 0; padding: 1px; }
|
331 |
-
.ui-acf .ui-datepicker td span, .ui-acf .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; }
|
332 |
-
.ui-acf .ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; }
|
333 |
-
.ui-acf .ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; }
|
334 |
-
.ui-acf .ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; }
|
335 |
-
|
336 |
-
/* with multiple calendars */
|
337 |
-
.ui-acf .ui-datepicker.ui-datepicker-multi { width:auto; }
|
338 |
-
.ui-acf .ui-datepicker-multi .ui-datepicker-group { float:left; }
|
339 |
-
.ui-acf .ui-datepicker-multi .ui-datepicker-group table { width:95%; margin:0 auto .4em; }
|
340 |
-
.ui-acf .ui-datepicker-multi-2 .ui-datepicker-group { width:50%; }
|
341 |
-
.ui-acf .ui-datepicker-multi-3 .ui-datepicker-group { width:33.3%; }
|
342 |
-
.ui-acf .ui-datepicker-multi-4 .ui-datepicker-group { width:25%; }
|
343 |
-
.ui-acf .ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header { border-left-width:0; }
|
344 |
-
.ui-acf .ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { border-left-width:0; }
|
345 |
-
.ui-acf .ui-datepicker-multi .ui-datepicker-buttonpane { clear:left; }
|
346 |
-
.ui-acf .ui-datepicker-row-break { clear:both; width:100%; font-size:0em; }
|
347 |
-
|
348 |
-
/* RTL support */
|
349 |
-
.ui-acf .ui-datepicker-rtl { direction: rtl; }
|
350 |
-
.ui-acf .ui-datepicker-rtl .ui-datepicker-prev { right: 2px; left: auto; }
|
351 |
-
.ui-acf .ui-datepicker-rtl .ui-datepicker-next { left: 2px; right: auto; }
|
352 |
-
.ui-acf .ui-datepicker-rtl .ui-datepicker-prev:hover { right: 1px; left: auto; }
|
353 |
-
.ui-acf .ui-datepicker-rtl .ui-datepicker-next:hover { left: 1px; right: auto; }
|
354 |
-
.ui-acf .ui-datepicker-rtl .ui-datepicker-buttonpane { clear:right; }
|
355 |
-
.ui-acf .ui-datepicker-rtl .ui-datepicker-buttonpane button { float: left; }
|
356 |
-
.ui-acf .ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current { float:right; }
|
357 |
-
.ui-acf .ui-datepicker-rtl .ui-datepicker-group { float:right; }
|
358 |
-
.ui-acf .ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
|
359 |
-
.ui-acf .ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
|
360 |
-
|
361 |
-
/* IE6 IFRAME FIX (taken from datepicker 1.5.3 */
|
362 |
-
.ui-acf .ui-datepicker-cover {
|
363 |
-
display: none; /*sorry for IE5*/
|
364 |
-
display/**/: block; /*sorry for IE5*/
|
365 |
-
position: absolute; /*must have*/
|
366 |
-
z-index: -1; /*must have*/
|
367 |
-
filter: mask(); /*must have*/
|
368 |
-
top: -4px; /*must have*/
|
369 |
-
left: -4px; /*must have*/
|
370 |
-
width: 200px; /*must have*/
|
371 |
-
height: 200px; /*must have*/
|
372 |
-
}
|
373 |
-
|
374 |
-
.ui-acf .ui-datepicker .ui-datepicker-buttonpane {
|
375 |
-
background: #EAF2FA;
|
376 |
-
border-top: 1px solid #E1E1E1;
|
377 |
-
width: 100%;
|
378 |
-
padding: 3px;
|
379 |
-
margin: 0;
|
380 |
-
margin: 0 0 0 -3px;
|
381 |
-
position: relative;
|
382 |
-
overflow: hidden;
|
383 |
-
}
|
384 |
-
|
385 |
-
.ui-acf .ui-datepicker .ui-datepicker-buttonpane button {
|
386 |
-
margin: 0;
|
387 |
-
padding: 0px;
|
388 |
-
font-size: 12px;
|
389 |
-
background: transparent;
|
390 |
-
border: 0 none;
|
391 |
-
text-shadow: 0 1px 0 #FFFFFF;
|
392 |
-
color: #7A9BBE;
|
393 |
-
opacity: 1;
|
394 |
-
display: block;line-height: 1em;
|
395 |
-
padding: 5px;
|
396 |
-
}
|
397 |
-
|
398 |
-
.ui-acf .ui-datepicker .ui-state-highlight {
|
399 |
-
background: #EAF2FA;
|
400 |
-
color: #555555;
|
401 |
-
border: 1px solid #95B1CE;
|
402 |
-
}
|
403 |
-
|
404 |
-
.ui-acf .ui-datepicker .ui-state-active {
|
405 |
-
background: #2EA2CC;
|
406 |
-
|
407 |
-
color: #FFFFFF;
|
408 |
-
border: #0074A2 solid 1px;
|
409 |
-
|
410 |
}
|
1 |
+
/*
|
2 |
+
* jQuery UI CSS Framework 1.8.14
|
3 |
+
*
|
4 |
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
5 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
6 |
+
* http://jquery.org/license
|
7 |
+
*
|
8 |
+
* http://docs.jquery.com/UI/Theming/API
|
9 |
+
*/
|
10 |
+
|
11 |
+
/* Layout helpers
|
12 |
+
----------------------------------*/
|
13 |
+
.ui-acf .ui-helper-hidden { display: none; }
|
14 |
+
.ui-acf .ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); }
|
15 |
+
.ui-acf .ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; }
|
16 |
+
.ui-acf .ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
|
17 |
+
.ui-acf .ui-helper-clearfix { display: inline-block; }
|
18 |
+
/* required comment for clearfix to work in Opera \*/
|
19 |
+
* html .ui-helper-clearfix { height:1%; }
|
20 |
+
.ui-acf .ui-helper-clearfix { display:block; }
|
21 |
+
/* end clearfix */
|
22 |
+
.ui-acf .ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); }
|
23 |
+
|
24 |
+
|
25 |
+
/* Interaction Cues
|
26 |
+
----------------------------------*/
|
27 |
+
.ui-acf .ui-state-disabled { cursor: default !important; }
|
28 |
+
|
29 |
+
|
30 |
+
/* Icons
|
31 |
+
----------------------------------*/
|
32 |
+
|
33 |
+
/* states and images */
|
34 |
+
.ui-acf .ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; }
|
35 |
+
|
36 |
+
|
37 |
+
/* Misc visuals
|
38 |
+
----------------------------------*/
|
39 |
+
|
40 |
+
/* Overlays */
|
41 |
+
.ui-acf .ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
|
42 |
+
|
43 |
+
|
44 |
+
/*
|
45 |
+
* jQuery UI CSS Framework 1.8.14
|
46 |
+
*
|
47 |
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
48 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
49 |
+
* http://jquery.org/license
|
50 |
+
*
|
51 |
+
* http://docs.jquery.com/UI/Theming/API
|
52 |
+
*
|
53 |
+
* To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Verdana,Arial,sans-serif&fwDefault=normal&fsDefault=1.1em&cornerRadius=4px&bgColorHeader=444444&bgTextureHeader=03_highlight_soft.png&bgImgOpacityHeader=0&borderColorHeader=000000&fcHeader=e5e5e5&iconColorHeader=222222&bgColorContent=ffffff&bgTextureContent=01_flat.png&bgImgOpacityContent=75&borderColorContent=aaaaaa&fcContent=222222&iconColorContent=222222&bgColorDefault=e6e6e6&bgTextureDefault=02_glass.png&bgImgOpacityDefault=75&borderColorDefault=d3d3d3&fcDefault=555555&iconColorDefault=888888&bgColorHover=dadada&bgTextureHover=02_glass.png&bgImgOpacityHover=75&borderColorHover=999999&fcHover=212121&iconColorHover=454545&bgColorActive=ffffff&bgTextureActive=02_glass.png&bgImgOpacityActive=65&borderColorActive=aaaaaa&fcActive=212121&iconColorActive=454545&bgColorHighlight=5bc6f5&bgTextureHighlight=01_flat.png&bgImgOpacityHighlight=55&borderColorHighlight=1cb1f2&fcHighlight=ffffff&iconColorHighlight=2e83ff&bgColorError=fef1ec&bgTextureError=02_glass.png&bgImgOpacityError=95&borderColorError=cd0a0a&fcError=cd0a0a&iconColorError=cd0a0a&bgColorOverlay=aaaaaa&bgTextureOverlay=01_flat.png&bgImgOpacityOverlay=0&opacityOverlay=30&bgColorShadow=aaaaaa&bgTextureShadow=01_flat.png&bgImgOpacityShadow=0&opacityShadow=30&thicknessShadow=8px&offsetTopShadow=-8px&offsetLeftShadow=-8px&cornerRadiusShadow=8px
|
54 |
+
*/
|
55 |
+
|
56 |
+
|
57 |
+
/* Component containers
|
58 |
+
----------------------------------*/
|
59 |
+
.ui-acf .ui-widget { font-family: Verdana,Arial,sans-serif; font-size: 1.1em; }
|
60 |
+
.ui-acf .ui-widget .ui-widget { font-size: 1em; }
|
61 |
+
.ui-acf .ui-widget input, .ui-acf .ui-widget select, .ui-acf .ui-widget textarea, .ui-acf .ui-widget button { font-family: Verdana,Arial,sans-serif; font-size: 1em; }
|
62 |
+
.ui-acf .ui-widget-content {
|
63 |
+
border: 1px solid #E1E1E1;
|
64 |
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
65 |
+
color: #222222;
|
66 |
+
background: #fff;
|
67 |
+
}
|
68 |
+
.ui-acf .ui-widget-content a { color: #222222; }
|
69 |
+
.ui-acf .ui-widget-header {
|
70 |
+
background: #2EA2CC;
|
71 |
+
color: #e5e5e5;
|
72 |
+
font-weight: bold;
|
73 |
+
border-radius: 0 !important;
|
74 |
+
width: 100%;
|
75 |
+
padding: 8px 3px;
|
76 |
+
position: relative;
|
77 |
+
margin: -3px 0 0 -3px;
|
78 |
+
}
|
79 |
+
|
80 |
+
.ui-acf .ui-widget-header a { color: #e5e5e5; }
|
81 |
+
|
82 |
+
/* Interaction states
|
83 |
+
----------------------------------*/
|
84 |
+
.ui-acf .ui-state-default, .ui-acf .ui-widget-content .ui-state-default, .ui-acf .ui-widget-header .ui-state-default { border: 1px solid #E1E1E1; background: #F9F9F9; font-weight: normal; color: #555555; }
|
85 |
+
.ui-acf .ui-state-default a, .ui-acf .ui-state-default a:link, .ui-acf .ui-state-default a:visited { color: #555555; text-decoration: none; }
|
86 |
+
.ui-acf .ui-state-hover, .ui-acf .ui-widget-content .ui-state-hover, .ui-acf .ui-widget-header .ui-state-hover, .ui-acf .ui-state-focus, .ui-acf .ui-widget-content .ui-state-focus, .ui-acf .ui-widget-header .ui-state-focus { border: 1px solid #999999; background: #dadada url(images/ui-bg_glass_75_dadada_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #212121; }
|
87 |
+
.ui-acf .ui-state-hover a, .ui-acf .ui-state-hover a:hover { color: #212121; text-decoration: none; }
|
88 |
+
.ui-acf .ui-state-active, .ui-acf .ui-widget-content .ui-state-active, .ui-acf .ui-widget-header .ui-state-active { border: 1px solid #aaaaaa; background: #ffffff url(images/ui-bg_glass_65_ffffff_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #212121; }
|
89 |
+
.ui-acf .ui-state-active a, .ui-acf .ui-state-active a:link, .ui-acf .ui-state-active a:visited { color: #212121; text-decoration: none; }
|
90 |
+
.ui-acf .ui-widget :active { outline: none; }
|
91 |
+
|
92 |
+
/* Interaction Cues
|
93 |
+
----------------------------------*/
|
94 |
+
.ui-acf .ui-state-highlight, .ui-acf .ui-widget-content .ui-state-highlight, .ui-acf .ui-widget-header .ui-state-highlight {border: 1px solid #1cb1f2; background: #5bc6f5 url(images/ui-bg_flat_55_5bc6f5_40x100.png) 50% 50% repeat-x; color: #ffffff; }
|
95 |
+
.ui-acf .ui-state-highlight a, .ui-acf .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #ffffff; }
|
96 |
+
.ui-acf .ui-state-error, .ui-acf .ui-widget-content .ui-state-error, .ui-acf .ui-widget-header .ui-state-error {border: 1px solid #cd0a0a; background: #fef1ec url(images/ui-bg_glass_95_fef1ec_1x400.png) 50% 50% repeat-x; color: #cd0a0a; }
|
97 |
+
.ui-acf .ui-state-error a, .ui-acf .ui-widget-content .ui-state-error a, .ui-acf .ui-widget-header .ui-state-error a { color: #cd0a0a; }
|
98 |
+
.ui-acf .ui-state-error-text, .ui-acf .ui-widget-content .ui-state-error-text, .ui-acf .ui-widget-header .ui-state-error-text { color: #cd0a0a; }
|
99 |
+
.ui-acf .ui-priority-primary, .ui-acf .ui-widget-content .ui-priority-primary, .ui-acf .ui-widget-header .ui-priority-primary { font-weight: bold; }
|
100 |
+
.ui-acf .ui-priority-secondary, .ui-acf .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; }
|
101 |
+
.ui-acf .ui-state-disabled, .ui-acf .ui-widget-content .ui-state-disabled, .ui-acf .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; }
|
102 |
+
|
103 |
+
/* Icons
|
104 |
+
----------------------------------*/
|
105 |
+
|
106 |
+
/* states and images */
|
107 |
+
.ui-acf .ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_222222_256x240.png); }
|
108 |
+
.ui-acf .ui-widget-content .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); }
|
109 |
+
.ui-acf .ui-widget-header .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); }
|
110 |
+
.ui-acf .ui-state-default .ui-icon { background-image: url(images/ui-icons_888888_256x240.png); }
|
111 |
+
.ui-acf .ui-state-hover .ui-icon, .ui-acf .ui-state-focus .ui-icon {background-image: url(images/ui-icons_454545_256x240.png); }
|
112 |
+
.ui-acf .ui-state-active .ui-icon {background-image: url(images/ui-icons_454545_256x240.png); }
|
113 |
+
.ui-acf .ui-state-highlight .ui-icon {background-image: url(images/ui-icons_2e83ff_256x240.png); }
|
114 |
+
.ui-acf .ui-state-error .ui-icon, .ui-acf .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_cd0a0a_256x240.png); }
|
115 |
+
|
116 |
+
/* positioning */
|
117 |
+
.ui-acf .ui-icon-carat-1-n { background-position: 0 0; }
|
118 |
+
.ui-acf .ui-icon-carat-1-ne { background-position: -16px 0; }
|
119 |
+
.ui-acf .ui-icon-carat-1-e { background-position: -32px 0; }
|
120 |
+
.ui-acf .ui-icon-carat-1-se { background-position: -48px 0; }
|
121 |
+
.ui-acf .ui-icon-carat-1-s { background-position: -64px 0; }
|
122 |
+
.ui-acf .ui-icon-carat-1-sw { background-position: -80px 0; }
|
123 |
+
.ui-acf .ui-icon-carat-1-w { background-position: -96px 0; }
|
124 |
+
.ui-acf .ui-icon-carat-1-nw { background-position: -112px 0; }
|
125 |
+
.ui-acf .ui-icon-carat-2-n-s { background-position: -128px 0; }
|
126 |
+
.ui-acf .ui-icon-carat-2-e-w { background-position: -144px 0; }
|
127 |
+
.ui-acf .ui-icon-triangle-1-n { background-position: 0 -16px; }
|
128 |
+
.ui-acf .ui-icon-triangle-1-ne { background-position: -16px -16px; }
|
129 |
+
.ui-acf .ui-icon-triangle-1-e { background-position: -32px -16px; }
|
130 |
+
.ui-acf .ui-icon-triangle-1-se { background-position: -48px -16px; }
|
131 |
+
.ui-acf .ui-icon-triangle-1-s { background-position: -64px -16px; }
|
132 |
+
.ui-acf .ui-icon-triangle-1-sw { background-position: -80px -16px; }
|
133 |
+
.ui-acf .ui-icon-triangle-1-w { background-position: -96px -16px; }
|
134 |
+
.ui-acf .ui-icon-triangle-1-nw { background-position: -112px -16px; }
|
135 |
+
.ui-acf .ui-icon-triangle-2-n-s { background-position: -128px -16px; }
|
136 |
+
.ui-acf .ui-icon-triangle-2-e-w { background-position: -144px -16px; }
|
137 |
+
.ui-acf .ui-icon-arrow-1-n { background-position: 0 -32px; }
|
138 |
+
.ui-acf .ui-icon-arrow-1-ne { background-position: -16px -32px; }
|
139 |
+
.ui-acf .ui-icon-arrow-1-e { background-position: -32px -32px; }
|
140 |
+
.ui-acf .ui-icon-arrow-1-se { background-position: -48px -32px; }
|
141 |
+
.ui-acf .ui-icon-arrow-1-s { background-position: -64px -32px; }
|
142 |
+
.ui-acf .ui-icon-arrow-1-sw { background-position: -80px -32px; }
|
143 |
+
.ui-acf .ui-icon-arrow-1-w { background-position: -96px -32px; }
|
144 |
+
.ui-acf .ui-icon-arrow-1-nw { background-position: -112px -32px; }
|
145 |
+
.ui-acf .ui-icon-arrow-2-n-s { background-position: -128px -32px; }
|
146 |
+
.ui-acf .ui-icon-arrow-2-ne-sw { background-position: -144px -32px; }
|
147 |
+
.ui-acf .ui-icon-arrow-2-e-w { background-position: -160px -32px; }
|
148 |
+
.ui-acf .ui-icon-arrow-2-se-nw { background-position: -176px -32px; }
|
149 |
+
.ui-acf .ui-icon-arrowstop-1-n { background-position: -192px -32px; }
|
150 |
+
.ui-acf .ui-icon-arrowstop-1-e { background-position: -208px -32px; }
|
151 |
+
.ui-acf .ui-icon-arrowstop-1-s { background-position: -224px -32px; }
|
152 |
+
.ui-acf .ui-icon-arrowstop-1-w { background-position: -240px -32px; }
|
153 |
+
.ui-acf .ui-icon-arrowthick-1-n { background-position: 0 -48px; }
|
154 |
+
.ui-acf .ui-icon-arrowthick-1-ne { background-position: -16px -48px; }
|
155 |
+
.ui-acf .ui-icon-arrowthick-1-e { background-position: -32px -48px; }
|
156 |
+
.ui-acf .ui-icon-arrowthick-1-se { background-position: -48px -48px; }
|
157 |
+
.ui-acf .ui-icon-arrowthick-1-s { background-position: -64px -48px; }
|
158 |
+
.ui-acf .ui-icon-arrowthick-1-sw { background-position: -80px -48px; }
|
159 |
+
.ui-acf .ui-icon-arrowthick-1-w { background-position: -96px -48px; }
|
160 |
+
.ui-acf .ui-icon-arrowthick-1-nw { background-position: -112px -48px; }
|
161 |
+
.ui-acf .ui-icon-arrowthick-2-n-s { background-position: -128px -48px; }
|
162 |
+
.ui-acf .ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; }
|
163 |
+
.ui-acf .ui-icon-arrowthick-2-e-w { background-position: -160px -48px; }
|
164 |
+
.ui-acf .ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; }
|
165 |
+
.ui-acf .ui-icon-arrowthickstop-1-n { background-position: -192px -48px; }
|
166 |
+
.ui-acf .ui-icon-arrowthickstop-1-e { background-position: -208px -48px; }
|
167 |
+
.ui-acf .ui-icon-arrowthickstop-1-s { background-position: -224px -48px; }
|
168 |
+
.ui-acf .ui-icon-arrowthickstop-1-w { background-position: -240px -48px; }
|
169 |
+
.ui-acf .ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; }
|
170 |
+
.ui-acf .ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; }
|
171 |
+
.ui-acf .ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; }
|
172 |
+
.ui-acf .ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; }
|
173 |
+
.ui-acf .ui-icon-arrowreturn-1-w { background-position: -64px -64px; }
|
174 |
+
.ui-acf .ui-icon-arrowreturn-1-n { background-position: -80px -64px; }
|
175 |
+
.ui-acf .ui-icon-arrowreturn-1-e { background-position: -96px -64px; }
|
176 |
+
.ui-acf .ui-icon-arrowreturn-1-s { background-position: -112px -64px; }
|
177 |
+
.ui-acf .ui-icon-arrowrefresh-1-w { background-position: -128px -64px; }
|
178 |
+
.ui-acf .ui-icon-arrowrefresh-1-n { background-position: -144px -64px; }
|
179 |
+
.ui-acf .ui-icon-arrowrefresh-1-e { background-position: -160px -64px; }
|
180 |
+
.ui-acf .ui-icon-arrowrefresh-1-s { background-position: -176px -64px; }
|
181 |
+
.ui-acf .ui-icon-arrow-4 { background-position: 0 -80px; }
|
182 |
+
.ui-acf .ui-icon-arrow-4-diag { background-position: -16px -80px; }
|
183 |
+
.ui-acf .ui-icon-extlink { background-position: -32px -80px; }
|
184 |
+
.ui-acf .ui-icon-newwin { background-position: -48px -80px; }
|
185 |
+
.ui-acf .ui-icon-refresh { background-position: -64px -80px; }
|
186 |
+
.ui-acf .ui-icon-shuffle { background-position: -80px -80px; }
|
187 |
+
.ui-acf .ui-icon-transfer-e-w { background-position: -96px -80px; }
|
188 |
+
.ui-acf .ui-icon-transferthick-e-w { background-position: -112px -80px; }
|
189 |
+
.ui-acf .ui-icon-folder-collapsed { background-position: 0 -96px; }
|
190 |
+
.ui-acf .ui-icon-folder-open { background-position: -16px -96px; }
|
191 |
+
.ui-acf .ui-icon-document { background-position: -32px -96px; }
|
192 |
+
.ui-acf .ui-icon-document-b { background-position: -48px -96px; }
|
193 |
+
.ui-acf .ui-icon-note { background-position: -64px -96px; }
|
194 |
+
.ui-acf .ui-icon-mail-closed { background-position: -80px -96px; }
|
195 |
+
.ui-acf .ui-icon-mail-open { background-position: -96px -96px; }
|
196 |
+
.ui-acf .ui-icon-suitcase { background-position: -112px -96px; }
|
197 |
+
.ui-acf .ui-icon-comment { background-position: -128px -96px; }
|
198 |
+
.ui-acf .ui-icon-person { background-position: -144px -96px; }
|
199 |
+
.ui-acf .ui-icon-print { background-position: -160px -96px; }
|
200 |
+
.ui-acf .ui-icon-trash { background-position: -176px -96px; }
|
201 |
+
.ui-acf .ui-icon-locked { background-position: -192px -96px; }
|
202 |
+
.ui-acf .ui-icon-unlocked { background-position: -208px -96px; }
|
203 |
+
.ui-acf .ui-icon-bookmark { background-position: -224px -96px; }
|
204 |
+
.ui-acf .ui-icon-tag { background-position: -240px -96px; }
|
205 |
+
.ui-acf .ui-icon-home { background-position: 0 -112px; }
|
206 |
+
.ui-acf .ui-icon-flag { background-position: -16px -112px; }
|
207 |
+
.ui-acf .ui-icon-calendar { background-position: -32px -112px; }
|
208 |
+
.ui-acf .ui-icon-cart { background-position: -48px -112px; }
|
209 |
+
.ui-acf .ui-icon-pencil { background-position: -64px -112px; }
|
210 |
+
.ui-acf .ui-icon-clock { background-position: -80px -112px; }
|
211 |
+
.ui-acf .ui-icon-disk { background-position: -96px -112px; }
|
212 |
+
.ui-acf .ui-icon-calculator { background-position: -112px -112px; }
|
213 |
+
.ui-acf .ui-icon-zoomin { background-position: -128px -112px; }
|
214 |
+
.ui-acf .ui-icon-zoomout { background-position: -144px -112px; }
|
215 |
+
.ui-acf .ui-icon-search { background-position: -160px -112px; }
|
216 |
+
.ui-acf .ui-icon-wrench { background-position: -176px -112px; }
|
217 |
+
.ui-acf .ui-icon-gear { background-position: -192px -112px; }
|
218 |
+
.ui-acf .ui-icon-heart { background-position: -208px -112px; }
|
219 |
+
.ui-acf .ui-icon-star { background-position: -224px -112px; }
|
220 |
+
.ui-acf .ui-icon-link { background-position: -240px -112px; }
|
221 |
+
.ui-acf .ui-icon-cancel { background-position: 0 -128px; }
|
222 |
+
.ui-acf .ui-icon-plus { background-position: -16px -128px; }
|
223 |
+
.ui-acf .ui-icon-plusthick { background-position: -32px -128px; }
|
224 |
+
.ui-acf .ui-icon-minus { background-position: -48px -128px; }
|
225 |
+
.ui-acf .ui-icon-minusthick { background-position: -64px -128px; }
|
226 |
+
.ui-acf .ui-icon-close { background-position: -80px -128px; }
|
227 |
+
.ui-acf .ui-icon-closethick { background-position: -96px -128px; }
|
228 |
+
.ui-acf .ui-icon-key { background-position: -112px -128px; }
|
229 |
+
.ui-acf .ui-icon-lightbulb { background-position: -128px -128px; }
|
230 |
+
.ui-acf .ui-icon-scissors { background-position: -144px -128px; }
|
231 |
+
.ui-acf .ui-icon-clipboard { background-position: -160px -128px; }
|
232 |
+
.ui-acf .ui-icon-copy { background-position: -176px -128px; }
|
233 |
+
.ui-acf .ui-icon-contact { background-position: -192px -128px; }
|
234 |
+
.ui-acf .ui-icon-image { background-position: -208px -128px; }
|
235 |
+
.ui-acf .ui-icon-video { background-position: -224px -128px; }
|
236 |
+
.ui-acf .ui-icon-script { background-position: -240px -128px; }
|
237 |
+
.ui-acf .ui-icon-alert { background-position: 0 -144px; }
|
238 |
+
.ui-acf .ui-icon-info { background-position: -16px -144px; }
|
239 |
+
.ui-acf .ui-icon-notice { background-position: -32px -144px; }
|
240 |
+
.ui-acf .ui-icon-help { background-position: -48px -144px; }
|
241 |
+
.ui-acf .ui-icon-check { background-position: -64px -144px; }
|
242 |
+
.ui-acf .ui-icon-bullet { background-position: -80px -144px; }
|
243 |
+
.ui-acf .ui-icon-radio-off { background-position: -96px -144px; }
|
244 |
+
.ui-acf .ui-icon-radio-on { background-position: -112px -144px; }
|
245 |
+
.ui-acf .ui-icon-pin-w { background-position: -128px -144px; }
|
246 |
+
.ui-acf .ui-icon-pin-s { background-position: -144px -144px; }
|
247 |
+
.ui-acf .ui-icon-play { background-position: 0 -160px; }
|
248 |
+
.ui-acf .ui-icon-pause { background-position: -16px -160px; }
|
249 |
+
.ui-acf .ui-icon-seek-next { background-position: -32px -160px; }
|
250 |
+
.ui-acf .ui-icon-seek-prev { background-position: -48px -160px; }
|
251 |
+
.ui-acf .ui-icon-seek-end { background-position: -64px -160px; }
|
252 |
+
.ui-acf .ui-icon-seek-start { background-position: -80px -160px; }
|
253 |
+
/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */
|
254 |
+
.ui-acf .ui-icon-seek-first { background-position: -80px -160px; }
|
255 |
+
.ui-acf .ui-icon-stop { background-position: -96px -160px; }
|
256 |
+
.ui-acf .ui-icon-eject { background-position: -112px -160px; }
|
257 |
+
.ui-acf .ui-icon-volume-off { background-position: -128px -160px; }
|
258 |
+
.ui-acf .ui-icon-volume-on { background-position: -144px -160px; }
|
259 |
+
.ui-acf .ui-icon-power { background-position: 0 -176px; }
|
260 |
+
.ui-acf .ui-icon-signal-diag { background-position: -16px -176px; }
|
261 |
+
.ui-acf .ui-icon-signal { background-position: -32px -176px; }
|
262 |
+
.ui-acf .ui-icon-battery-0 { background-position: -48px -176px; }
|
263 |
+
.ui-acf .ui-icon-battery-1 { background-position: -64px -176px; }
|
264 |
+
.ui-acf .ui-icon-battery-2 { background-position: -80px -176px; }
|
265 |
+
.ui-acf .ui-icon-battery-3 { background-position: -96px -176px; }
|
266 |
+
.ui-acf .ui-icon-circle-plus { background-position: 0 -192px; }
|
267 |
+
.ui-acf .ui-icon-circle-minus { background-position: -16px -192px; }
|
268 |
+
.ui-acf .ui-icon-circle-close { background-position: -32px -192px; }
|
269 |
+
.ui-acf .ui-icon-circle-triangle-e { background-position: -48px -192px; }
|
270 |
+
.ui-acf .ui-icon-circle-triangle-s { background-position: -64px -192px; }
|
271 |
+
.ui-acf .ui-icon-circle-triangle-w { background-position: -80px -192px; }
|
272 |
+
.ui-acf .ui-icon-circle-triangle-n { background-position: -96px -192px; }
|
273 |
+
.ui-acf .ui-icon-circle-arrow-e { background-position: -112px -192px; }
|
274 |
+
.ui-acf .ui-icon-circle-arrow-s { background-position: -128px -192px; }
|
275 |
+
.ui-acf .ui-icon-circle-arrow-w { background-position: -144px -192px; }
|
276 |
+
.ui-acf .ui-icon-circle-arrow-n { background-position: -160px -192px; }
|
277 |
+
.ui-acf .ui-icon-circle-zoomin { background-position: -176px -192px; }
|
278 |
+
.ui-acf .ui-icon-circle-zoomout { background-position: -192px -192px; }
|
279 |
+
.ui-acf .ui-icon-circle-check { background-position: -208px -192px; }
|
280 |
+
.ui-acf .ui-icon-circlesmall-plus { background-position: 0 -208px; }
|
281 |
+
.ui-acf .ui-icon-circlesmall-minus { background-position: -16px -208px; }
|
282 |
+
.ui-acf .ui-icon-circlesmall-close { background-position: -32px -208px; }
|
283 |
+
.ui-acf .ui-icon-squaresmall-plus { background-position: -48px -208px; }
|
284 |
+
.ui-acf .ui-icon-squaresmall-minus { background-position: -64px -208px; }
|
285 |
+
.ui-acf .ui-icon-squaresmall-close { background-position: -80px -208px; }
|
286 |
+
.ui-acf .ui-icon-grip-dotted-vertical { background-position: 0 -224px; }
|
287 |
+
.ui-acf .ui-icon-grip-dotted-horizontal { background-position: -16px -224px; }
|
288 |
+
.ui-acf .ui-icon-grip-solid-vertical { background-position: -32px -224px; }
|
289 |
+
.ui-acf .ui-icon-grip-solid-horizontal { background-position: -48px -224px; }
|
290 |
+
.ui-acf .ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; }
|
291 |
+
.ui-acf .ui-icon-grip-diagonal-se { background-position: -80px -224px; }
|
292 |
+
|
293 |
+
|
294 |
+
/* Misc visuals
|
295 |
+
----------------------------------*/
|
296 |
+
|
297 |
+
/* Corner radius */
|
298 |
+
.ui-acf .ui-corner-all, .ui-acf .ui-corner-top, .ui-acf .ui-corner-left, .ui-acf .ui-corner-tl { -moz-border-radius-topleft: 4px; -webkit-border-top-left-radius: 4px; -khtml-border-top-left-radius: 4px; border-top-left-radius: 4px; }
|
299 |
+
.ui-acf .ui-corner-all, .ui-acf .ui-corner-top, .ui-acf .ui-corner-right, .ui-acf .ui-corner-tr { -moz-border-radius-topright: 4px; -webkit-border-top-right-radius: 4px; -khtml-border-top-right-radius: 4px; border-top-right-radius: 4px; }
|
300 |
+
.ui-acf .ui-corner-all, .ui-acf .ui-corner-bottom, .ui-acf .ui-corner-left, .ui-acf .ui-corner-bl { -moz-border-radius-bottomleft: 4px; -webkit-border-bottom-left-radius: 4px; -khtml-border-bottom-left-radius: 4px; border-bottom-left-radius: 4px; }
|
301 |
+
.ui-acf .ui-corner-all, .ui-acf .ui-corner-bottom, .ui-acf .ui-corner-right, .ui-acf .ui-corner-br { -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 4px; -khtml-border-bottom-right-radius: 4px; border-bottom-right-radius: 4px; }
|
302 |
+
|
303 |
+
/* Overlays */
|
304 |
+
.ui-acf .ui-widget-overlay { background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); }
|
305 |
+
.ui-acf .ui-widget-shadow { margin: -8px 0 0 -8px; padding: 8px; background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); -moz-border-radius: 8px; -khtml-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; }/*
|
306 |
+
* jQuery UI Datepicker 1.8.14
|
307 |
+
*
|
308 |
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
309 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
310 |
+
* http://jquery.org/license
|
311 |
+
*
|
312 |
+
* http://docs.jquery.com/UI/Datepicker#theming
|
313 |
+
*/
|
314 |
+
.ui-acf .ui-datepicker { width: 17em; padding: .2em .2em 0; display: none; border-radius: 0 !important; }
|
315 |
+
.ui-acf .ui-datepicker .ui-datepicker-header { }
|
316 |
+
.ui-acf .ui-datepicker .ui-datepicker-prev, .ui-acf .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; display: none; }
|
317 |
+
.ui-acf .ui-datepicker .ui-datepicker-prev-hover, .ui-acf .ui-datepicker .ui-datepicker-next-hover { top: 1px; }
|
318 |
+
.ui-acf .ui-datepicker .ui-datepicker-prev { left:2px; }
|
319 |
+
.ui-acf .ui-datepicker .ui-datepicker-next { right:2px; }
|
320 |
+
.ui-acf .ui-datepicker .ui-datepicker-prev-hover { left:1px; }
|
321 |
+
.ui-acf .ui-datepicker .ui-datepicker-next-hover { right:1px; }
|
322 |
+
.ui-acf .ui-datepicker .ui-datepicker-prev span, .ui-acf .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; }
|
323 |
+
.ui-acf .ui-datepicker .ui-datepicker-title { margin: 0; }
|
324 |
+
.ui-acf .ui-datepicker .ui-datepicker-title select { font-size:1em; margin:0 0 0 2%; }
|
325 |
+
.ui-acf .ui-datepicker select.ui-datepicker-month-year {width: 100%;}
|
326 |
+
.ui-acf .ui-datepicker select.ui-datepicker-month,
|
327 |
+
.ui-acf .ui-datepicker select.ui-datepicker-year { width: 47%; padding: 1px; font-size: 12px; font-weight: normal;}
|
328 |
+
.ui-acf .ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; }
|
329 |
+
.ui-acf .ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; width: 14%; }
|
330 |
+
.ui-acf .ui-datepicker td { border: 0; padding: 1px; }
|
331 |
+
.ui-acf .ui-datepicker td span, .ui-acf .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; }
|
332 |
+
.ui-acf .ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; }
|
333 |
+
.ui-acf .ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; }
|
334 |
+
.ui-acf .ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; }
|
335 |
+
|
336 |
+
/* with multiple calendars */
|
337 |
+
.ui-acf .ui-datepicker.ui-datepicker-multi { width:auto; }
|
338 |
+
.ui-acf .ui-datepicker-multi .ui-datepicker-group { float:left; }
|
339 |
+
.ui-acf .ui-datepicker-multi .ui-datepicker-group table { width:95%; margin:0 auto .4em; }
|
340 |
+
.ui-acf .ui-datepicker-multi-2 .ui-datepicker-group { width:50%; }
|
341 |
+
.ui-acf .ui-datepicker-multi-3 .ui-datepicker-group { width:33.3%; }
|
342 |
+
.ui-acf .ui-datepicker-multi-4 .ui-datepicker-group { width:25%; }
|
343 |
+
.ui-acf .ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header { border-left-width:0; }
|
344 |
+
.ui-acf .ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { border-left-width:0; }
|
345 |
+
.ui-acf .ui-datepicker-multi .ui-datepicker-buttonpane { clear:left; }
|
346 |
+
.ui-acf .ui-datepicker-row-break { clear:both; width:100%; font-size:0em; }
|
347 |
+
|
348 |
+
/* RTL support */
|
349 |
+
.ui-acf .ui-datepicker-rtl { direction: rtl; }
|
350 |
+
.ui-acf .ui-datepicker-rtl .ui-datepicker-prev { right: 2px; left: auto; }
|
351 |
+
.ui-acf .ui-datepicker-rtl .ui-datepicker-next { left: 2px; right: auto; }
|
352 |
+
.ui-acf .ui-datepicker-rtl .ui-datepicker-prev:hover { right: 1px; left: auto; }
|
353 |
+
.ui-acf .ui-datepicker-rtl .ui-datepicker-next:hover { left: 1px; right: auto; }
|
354 |
+
.ui-acf .ui-datepicker-rtl .ui-datepicker-buttonpane { clear:right; }
|
355 |
+
.ui-acf .ui-datepicker-rtl .ui-datepicker-buttonpane button { float: left; }
|
356 |
+
.ui-acf .ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current { float:right; }
|
357 |
+
.ui-acf .ui-datepicker-rtl .ui-datepicker-group { float:right; }
|
358 |
+
.ui-acf .ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
|
359 |
+
.ui-acf .ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
|
360 |
+
|
361 |
+
/* IE6 IFRAME FIX (taken from datepicker 1.5.3 */
|
362 |
+
.ui-acf .ui-datepicker-cover {
|
363 |
+
display: none; /*sorry for IE5*/
|
364 |
+
display/**/: block; /*sorry for IE5*/
|
365 |
+
position: absolute; /*must have*/
|
366 |
+
z-index: -1; /*must have*/
|
367 |
+
filter: mask(); /*must have*/
|
368 |
+
top: -4px; /*must have*/
|
369 |
+
left: -4px; /*must have*/
|
370 |
+
width: 200px; /*must have*/
|
371 |
+
height: 200px; /*must have*/
|
372 |
+
}
|
373 |
+
|
374 |
+
.ui-acf .ui-datepicker .ui-datepicker-buttonpane {
|
375 |
+
background: #EAF2FA;
|
376 |
+
border-top: 1px solid #E1E1E1;
|
377 |
+
width: 100%;
|
378 |
+
padding: 3px;
|
379 |
+
margin: 0;
|
380 |
+
margin: 0 0 0 -3px;
|
381 |
+
position: relative;
|
382 |
+
overflow: hidden;
|
383 |
+
}
|
384 |
+
|
385 |
+
.ui-acf .ui-datepicker .ui-datepicker-buttonpane button {
|
386 |
+
margin: 0;
|
387 |
+
padding: 0px;
|
388 |
+
font-size: 12px;
|
389 |
+
background: transparent;
|
390 |
+
border: 0 none;
|
391 |
+
text-shadow: 0 1px 0 #FFFFFF;
|
392 |
+
color: #7A9BBE;
|
393 |
+
opacity: 1;
|
394 |
+
display: block;line-height: 1em;
|
395 |
+
padding: 5px;
|
396 |
+
}
|
397 |
+
|
398 |
+
.ui-acf .ui-datepicker .ui-state-highlight {
|
399 |
+
background: #EAF2FA;
|
400 |
+
color: #555555;
|
401 |
+
border: 1px solid #95B1CE;
|
402 |
+
}
|
403 |
+
|
404 |
+
.ui-acf .ui-datepicker .ui-state-active {
|
405 |
+
background: #2EA2CC;
|
406 |
+
|
407 |
+
color: #FFFFFF;
|
408 |
+
border: #0074A2 solid 1px;
|
409 |
+
|
410 |
}
|
shared/assets/plugins/advanced-custom-fields/core/fields/dummy.php
CHANGED
@@ -1,279 +1,279 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_field_dummy extends acf_field
|
4 |
-
{
|
5 |
-
|
6 |
-
/*
|
7 |
-
* __construct
|
8 |
-
*
|
9 |
-
* Set name / label needed for actions / filters
|
10 |
-
*
|
11 |
-
* @since 3.6
|
12 |
-
* @date 23/01/13
|
13 |
-
*/
|
14 |
-
|
15 |
-
function __construct()
|
16 |
-
{
|
17 |
-
// vars
|
18 |
-
$this->name = 'dummy';
|
19 |
-
$this->label = __('Dummy');
|
20 |
-
|
21 |
-
|
22 |
-
// do not delete!
|
23 |
-
parent::__construct();
|
24 |
-
}
|
25 |
-
|
26 |
-
|
27 |
-
/*
|
28 |
-
* load_value()
|
29 |
-
*
|
30 |
-
* This filter is appied to the $value after it is loaded from the db
|
31 |
-
*
|
32 |
-
* @type filter
|
33 |
-
* @since 3.6
|
34 |
-
* @date 23/01/13
|
35 |
-
*
|
36 |
-
* @param $value - the value found in the database
|
37 |
-
* @param $post_id - the $post_id from which the value was loaded from
|
38 |
-
* @param $field - the field array holding all the field options
|
39 |
-
*
|
40 |
-
* @return $value - the value to be saved in te database
|
41 |
-
*/
|
42 |
-
|
43 |
-
function load_value( $value, $post_id, $field )
|
44 |
-
{
|
45 |
-
return $value;
|
46 |
-
}
|
47 |
-
|
48 |
-
|
49 |
-
/*
|
50 |
-
* format_value()
|
51 |
-
*
|
52 |
-
* This filter is appied to the $value after it is loaded from the db and before it is passed to the create_field action
|
53 |
-
*
|
54 |
-
* @type filter
|
55 |
-
* @since 3.6
|
56 |
-
* @date 23/01/13
|
57 |
-
*
|
58 |
-
* @param $value - the value which was loaded from the database
|
59 |
-
* @param $post_id - the $post_id from which the value was loaded
|
60 |
-
* @param $field - the field array holding all the field options
|
61 |
-
*
|
62 |
-
* @return $value - the modified value
|
63 |
-
*/
|
64 |
-
|
65 |
-
function format_value( $value, $post_id, $field )
|
66 |
-
{
|
67 |
-
return $value;
|
68 |
-
}
|
69 |
-
|
70 |
-
|
71 |
-
/*
|
72 |
-
* format_value_for_api()
|
73 |
-
*
|
74 |
-
* This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
|
75 |
-
*
|
76 |
-
* @type filter
|
77 |
-
* @since 3.6
|
78 |
-
* @date 23/01/13
|
79 |
-
*
|
80 |
-
* @param $value - the value which was loaded from the database
|
81 |
-
* @param $post_id - the $post_id from which the value was loaded
|
82 |
-
* @param $field - the field array holding all the field options
|
83 |
-
*
|
84 |
-
* @return $value - the modified value
|
85 |
-
*/
|
86 |
-
|
87 |
-
function format_value_for_api( $value, $post_id, $field )
|
88 |
-
{
|
89 |
-
return $value;
|
90 |
-
}
|
91 |
-
|
92 |
-
|
93 |
-
/*
|
94 |
-
* update_value()
|
95 |
-
*
|
96 |
-
* This filter is appied to the $value before it is updated in the db
|
97 |
-
*
|
98 |
-
* @type filter
|
99 |
-
* @since 3.6
|
100 |
-
* @date 23/01/13
|
101 |
-
*
|
102 |
-
* @param $value - the value which will be saved in the database
|
103 |
-
* @param $field - the field array holding all the field options
|
104 |
-
* @param $post_id - the $post_id of which the value will be saved
|
105 |
-
*
|
106 |
-
* @return $value - the modified value
|
107 |
-
*/
|
108 |
-
|
109 |
-
function update_value( $value, $post_id, $field )
|
110 |
-
{
|
111 |
-
return $value;
|
112 |
-
}
|
113 |
-
|
114 |
-
|
115 |
-
/*
|
116 |
-
* load_field()
|
117 |
-
*
|
118 |
-
* This filter is appied to the $field after it is loaded from the database
|
119 |
-
*
|
120 |
-
* @type filter
|
121 |
-
* @since 3.6
|
122 |
-
* @date 23/01/13
|
123 |
-
*
|
124 |
-
* @param $field - the field array holding all the field options
|
125 |
-
*
|
126 |
-
* @return $field - the field array holding all the field options
|
127 |
-
*/
|
128 |
-
|
129 |
-
function load_field( $field )
|
130 |
-
{
|
131 |
-
return $field;
|
132 |
-
}
|
133 |
-
|
134 |
-
|
135 |
-
/*
|
136 |
-
* update_field()
|
137 |
-
*
|
138 |
-
* This filter is appied to the $field before it is saved to the database
|
139 |
-
*
|
140 |
-
* @type filter
|
141 |
-
* @since 3.6
|
142 |
-
* @date 23/01/13
|
143 |
-
*
|
144 |
-
* @param $field - the field array holding all the field options
|
145 |
-
* @param $post_id - the field group ID (post_type = acf)
|
146 |
-
*
|
147 |
-
* @return $field - the modified field
|
148 |
-
*/
|
149 |
-
|
150 |
-
function update_field( $field, $post_id )
|
151 |
-
{
|
152 |
-
return $field;
|
153 |
-
}
|
154 |
-
|
155 |
-
|
156 |
-
/*
|
157 |
-
* create_field()
|
158 |
-
*
|
159 |
-
* Create the HTML interface for your field
|
160 |
-
*
|
161 |
-
* @type action
|
162 |
-
* @since 3.6
|
163 |
-
* @date 23/01/13
|
164 |
-
*
|
165 |
-
* @param $field - an array holding all the field's data
|
166 |
-
*/
|
167 |
-
|
168 |
-
function create_field( $field )
|
169 |
-
{
|
170 |
-
|
171 |
-
}
|
172 |
-
|
173 |
-
|
174 |
-
/*
|
175 |
-
* create_options()
|
176 |
-
*
|
177 |
-
* Create extra options for your field. This is rendered when editing a field.
|
178 |
-
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
179 |
-
*
|
180 |
-
* @type action
|
181 |
-
* @since 3.6
|
182 |
-
* @date 23/01/13
|
183 |
-
*
|
184 |
-
* @param $field - an array holding all the field's data
|
185 |
-
*/
|
186 |
-
|
187 |
-
function create_options( $field )
|
188 |
-
{
|
189 |
-
|
190 |
-
}
|
191 |
-
|
192 |
-
|
193 |
-
/*
|
194 |
-
* input_admin_enqueue_scripts()
|
195 |
-
*
|
196 |
-
* This action is called in the admin_enqueue_scripts action on the edit screen where your field is created.
|
197 |
-
* Use this action to add css + javascript to assist your create_field() action.
|
198 |
-
*
|
199 |
-
* $info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts
|
200 |
-
* @type action
|
201 |
-
* @since 3.6
|
202 |
-
* @date 23/01/13
|
203 |
-
*/
|
204 |
-
|
205 |
-
function input_admin_enqueue_scripts()
|
206 |
-
{
|
207 |
-
|
208 |
-
}
|
209 |
-
|
210 |
-
|
211 |
-
/*
|
212 |
-
* input_admin_head()
|
213 |
-
*
|
214 |
-
* This action is called in the admin_head action on the edit screen where your field is created.
|
215 |
-
* Use this action to add css and javascript to assist your create_field() action.
|
216 |
-
*
|
217 |
-
* @info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_head
|
218 |
-
* @type action
|
219 |
-
* @since 3.6
|
220 |
-
* @date 23/01/13
|
221 |
-
*/
|
222 |
-
|
223 |
-
function input_admin_head()
|
224 |
-
{
|
225 |
-
|
226 |
-
}
|
227 |
-
|
228 |
-
|
229 |
-
/*
|
230 |
-
* field_group_admin_enqueue_scripts()
|
231 |
-
*
|
232 |
-
* This action is called in the admin_enqueue_scripts action on the edit screen where your field is edited.
|
233 |
-
* Use this action to add css + javascript to assist your create_field_options() action.
|
234 |
-
*
|
235 |
-
* $info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts
|
236 |
-
* @type action
|
237 |
-
* @since 3.6
|
238 |
-
* @date 23/01/13
|
239 |
-
*/
|
240 |
-
|
241 |
-
function field_group_admin_enqueue_scripts()
|
242 |
-
{
|
243 |
-
|
244 |
-
}
|
245 |
-
|
246 |
-
|
247 |
-
/*
|
248 |
-
* field_group_admin_head()
|
249 |
-
*
|
250 |
-
* This action is called in the admin_head action on the edit screen where your field is edited.
|
251 |
-
* Use this action to add css and javascript to assist your create_field_options() action.
|
252 |
-
*
|
253 |
-
* @info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_head
|
254 |
-
* @type action
|
255 |
-
* @since 3.6
|
256 |
-
* @date 23/01/13
|
257 |
-
*/
|
258 |
-
|
259 |
-
function field_group_admin_head()
|
260 |
-
{
|
261 |
-
|
262 |
-
}
|
263 |
-
}
|
264 |
-
|
265 |
-
|
266 |
-
// create field
|
267 |
-
new acf_field_dummy();
|
268 |
-
|
269 |
-
|
270 |
-
/*--------------------------------------- fuctions.php ----------------------------------------------------*/
|
271 |
-
|
272 |
-
add_action('acf/register_fields', 'my_register_fields');
|
273 |
-
|
274 |
-
function my_register_fields()
|
275 |
-
{
|
276 |
-
include_once('fields/dummy.php');
|
277 |
-
}
|
278 |
-
|
279 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class acf_field_dummy extends acf_field
|
4 |
+
{
|
5 |
+
|
6 |
+
/*
|
7 |
+
* __construct
|
8 |
+
*
|
9 |
+
* Set name / label needed for actions / filters
|
10 |
+
*
|
11 |
+
* @since 3.6
|
12 |
+
* @date 23/01/13
|
13 |
+
*/
|
14 |
+
|
15 |
+
function __construct()
|
16 |
+
{
|
17 |
+
// vars
|
18 |
+
$this->name = 'dummy';
|
19 |
+
$this->label = __('Dummy');
|
20 |
+
|
21 |
+
|
22 |
+
// do not delete!
|
23 |
+
parent::__construct();
|
24 |
+
}
|
25 |
+
|
26 |
+
|
27 |
+
/*
|
28 |
+
* load_value()
|
29 |
+
*
|
30 |
+
* This filter is appied to the $value after it is loaded from the db
|
31 |
+
*
|
32 |
+
* @type filter
|
33 |
+
* @since 3.6
|
34 |
+
* @date 23/01/13
|
35 |
+
*
|
36 |
+
* @param $value - the value found in the database
|
37 |
+
* @param $post_id - the $post_id from which the value was loaded from
|
38 |
+
* @param $field - the field array holding all the field options
|
39 |
+
*
|
40 |
+
* @return $value - the value to be saved in te database
|
41 |
+
*/
|
42 |
+
|
43 |
+
function load_value( $value, $post_id, $field )
|
44 |
+
{
|
45 |
+
return $value;
|
46 |
+
}
|
47 |
+
|
48 |
+
|
49 |
+
/*
|
50 |
+
* format_value()
|
51 |
+
*
|
52 |
+
* This filter is appied to the $value after it is loaded from the db and before it is passed to the create_field action
|
53 |
+
*
|
54 |
+
* @type filter
|
55 |
+
* @since 3.6
|
56 |
+
* @date 23/01/13
|
57 |
+
*
|
58 |
+
* @param $value - the value which was loaded from the database
|
59 |
+
* @param $post_id - the $post_id from which the value was loaded
|
60 |
+
* @param $field - the field array holding all the field options
|
61 |
+
*
|
62 |
+
* @return $value - the modified value
|
63 |
+
*/
|
64 |
+
|
65 |
+
function format_value( $value, $post_id, $field )
|
66 |
+
{
|
67 |
+
return $value;
|
68 |
+
}
|
69 |
+
|
70 |
+
|
71 |
+
/*
|
72 |
+
* format_value_for_api()
|
73 |
+
*
|
74 |
+
* This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
|
75 |
+
*
|
76 |
+
* @type filter
|
77 |
+
* @since 3.6
|
78 |
+
* @date 23/01/13
|
79 |
+
*
|
80 |
+
* @param $value - the value which was loaded from the database
|
81 |
+
* @param $post_id - the $post_id from which the value was loaded
|
82 |
+
* @param $field - the field array holding all the field options
|
83 |
+
*
|
84 |
+
* @return $value - the modified value
|
85 |
+
*/
|
86 |
+
|
87 |
+
function format_value_for_api( $value, $post_id, $field )
|
88 |
+
{
|
89 |
+
return $value;
|
90 |
+
}
|
91 |
+
|
92 |
+
|
93 |
+
/*
|
94 |
+
* update_value()
|
95 |
+
*
|
96 |
+
* This filter is appied to the $value before it is updated in the db
|
97 |
+
*
|
98 |
+
* @type filter
|
99 |
+
* @since 3.6
|
100 |
+
* @date 23/01/13
|
101 |
+
*
|
102 |
+
* @param $value - the value which will be saved in the database
|
103 |
+
* @param $field - the field array holding all the field options
|
104 |
+
* @param $post_id - the $post_id of which the value will be saved
|
105 |
+
*
|
106 |
+
* @return $value - the modified value
|
107 |
+
*/
|
108 |
+
|
109 |
+
function update_value( $value, $post_id, $field )
|
110 |
+
{
|
111 |
+
return $value;
|
112 |
+
}
|
113 |
+
|
114 |
+
|
115 |
+
/*
|
116 |
+
* load_field()
|
117 |
+
*
|
118 |
+
* This filter is appied to the $field after it is loaded from the database
|
119 |
+
*
|
120 |
+
* @type filter
|
121 |
+
* @since 3.6
|
122 |
+
* @date 23/01/13
|
123 |
+
*
|
124 |
+
* @param $field - the field array holding all the field options
|
125 |
+
*
|
126 |
+
* @return $field - the field array holding all the field options
|
127 |
+
*/
|
128 |
+
|
129 |
+
function load_field( $field )
|
130 |
+
{
|
131 |
+
return $field;
|
132 |
+
}
|
133 |
+
|
134 |
+
|
135 |
+
/*
|
136 |
+
* update_field()
|
137 |
+
*
|
138 |
+
* This filter is appied to the $field before it is saved to the database
|
139 |
+
*
|
140 |
+
* @type filter
|
141 |
+
* @since 3.6
|
142 |
+
* @date 23/01/13
|
143 |
+
*
|
144 |
+
* @param $field - the field array holding all the field options
|
145 |
+
* @param $post_id - the field group ID (post_type = acf)
|
146 |
+
*
|
147 |
+
* @return $field - the modified field
|
148 |
+
*/
|
149 |
+
|
150 |
+
function update_field( $field, $post_id )
|
151 |
+
{
|
152 |
+
return $field;
|
153 |
+
}
|
154 |
+
|
155 |
+
|
156 |
+
/*
|
157 |
+
* create_field()
|
158 |
+
*
|
159 |
+
* Create the HTML interface for your field
|
160 |
+
*
|
161 |
+
* @type action
|
162 |
+
* @since 3.6
|
163 |
+
* @date 23/01/13
|
164 |
+
*
|
165 |
+
* @param $field - an array holding all the field's data
|
166 |
+
*/
|
167 |
+
|
168 |
+
function create_field( $field )
|
169 |
+
{
|
170 |
+
|
171 |
+
}
|
172 |
+
|
173 |
+
|
174 |
+
/*
|
175 |
+
* create_options()
|
176 |
+
*
|
177 |
+
* Create extra options for your field. This is rendered when editing a field.
|
178 |
+
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
179 |
+
*
|
180 |
+
* @type action
|
181 |
+
* @since 3.6
|
182 |
+
* @date 23/01/13
|
183 |
+
*
|
184 |
+
* @param $field - an array holding all the field's data
|
185 |
+
*/
|
186 |
+
|
187 |
+
function create_options( $field )
|
188 |
+
{
|
189 |
+
|
190 |
+
}
|
191 |
+
|
192 |
+
|
193 |
+
/*
|
194 |
+
* input_admin_enqueue_scripts()
|
195 |
+
*
|
196 |
+
* This action is called in the admin_enqueue_scripts action on the edit screen where your field is created.
|
197 |
+
* Use this action to add css + javascript to assist your create_field() action.
|
198 |
+
*
|
199 |
+
* $info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts
|
200 |
+
* @type action
|
201 |
+
* @since 3.6
|
202 |
+
* @date 23/01/13
|
203 |
+
*/
|
204 |
+
|
205 |
+
function input_admin_enqueue_scripts()
|
206 |
+
{
|
207 |
+
|
208 |
+
}
|
209 |
+
|
210 |
+
|
211 |
+
/*
|
212 |
+
* input_admin_head()
|
213 |
+
*
|
214 |
+
* This action is called in the admin_head action on the edit screen where your field is created.
|
215 |
+
* Use this action to add css and javascript to assist your create_field() action.
|
216 |
+
*
|
217 |
+
* @info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_head
|
218 |
+
* @type action
|
219 |
+
* @since 3.6
|
220 |
+
* @date 23/01/13
|
221 |
+
*/
|
222 |
+
|
223 |
+
function input_admin_head()
|
224 |
+
{
|
225 |
+
|
226 |
+
}
|
227 |
+
|
228 |
+
|
229 |
+
/*
|
230 |
+
* field_group_admin_enqueue_scripts()
|
231 |
+
*
|
232 |
+
* This action is called in the admin_enqueue_scripts action on the edit screen where your field is edited.
|
233 |
+
* Use this action to add css + javascript to assist your create_field_options() action.
|
234 |
+
*
|
235 |
+
* $info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts
|
236 |
+
* @type action
|
237 |
+
* @since 3.6
|
238 |
+
* @date 23/01/13
|
239 |
+
*/
|
240 |
+
|
241 |
+
function field_group_admin_enqueue_scripts()
|
242 |
+
{
|
243 |
+
|
244 |
+
}
|
245 |
+
|
246 |
+
|
247 |
+
/*
|
248 |
+
* field_group_admin_head()
|
249 |
+
*
|
250 |
+
* This action is called in the admin_head action on the edit screen where your field is edited.
|
251 |
+
* Use this action to add css and javascript to assist your create_field_options() action.
|
252 |
+
*
|
253 |
+
* @info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_head
|
254 |
+
* @type action
|
255 |
+
* @since 3.6
|
256 |
+
* @date 23/01/13
|
257 |
+
*/
|
258 |
+
|
259 |
+
function field_group_admin_head()
|
260 |
+
{
|
261 |
+
|
262 |
+
}
|
263 |
+
}
|
264 |
+
|
265 |
+
|
266 |
+
// create field
|
267 |
+
new acf_field_dummy();
|
268 |
+
|
269 |
+
|
270 |
+
/*--------------------------------------- fuctions.php ----------------------------------------------------*/
|
271 |
+
|
272 |
+
add_action('acf/register_fields', 'my_register_fields');
|
273 |
+
|
274 |
+
function my_register_fields()
|
275 |
+
{
|
276 |
+
include_once('fields/dummy.php');
|
277 |
+
}
|
278 |
+
|
279 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/fields/email.php
CHANGED
@@ -1,173 +1,173 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_field_email extends acf_field
|
4 |
-
{
|
5 |
-
|
6 |
-
/*
|
7 |
-
* __construct
|
8 |
-
*
|
9 |
-
* Set name / label needed for actions / filters
|
10 |
-
*
|
11 |
-
* @since 3.6
|
12 |
-
* @date 23/01/13
|
13 |
-
*/
|
14 |
-
|
15 |
-
function __construct()
|
16 |
-
{
|
17 |
-
// vars
|
18 |
-
$this->name = 'email';
|
19 |
-
$this->label = __("Email",'acf');
|
20 |
-
$this->defaults = array(
|
21 |
-
'default_value' => '',
|
22 |
-
'placeholder' => '',
|
23 |
-
'prepend' => '',
|
24 |
-
'append' => ''
|
25 |
-
);
|
26 |
-
|
27 |
-
|
28 |
-
// do not delete!
|
29 |
-
parent::__construct();
|
30 |
-
}
|
31 |
-
|
32 |
-
|
33 |
-
/*
|
34 |
-
* create_field()
|
35 |
-
*
|
36 |
-
* Create the HTML interface for your field
|
37 |
-
*
|
38 |
-
* @param $field - an array holding all the field's data
|
39 |
-
*
|
40 |
-
* @type action
|
41 |
-
* @since 3.6
|
42 |
-
* @date 23/01/13
|
43 |
-
*/
|
44 |
-
|
45 |
-
function create_field( $field )
|
46 |
-
{
|
47 |
-
// vars
|
48 |
-
$o = array( 'id', 'class', 'name', 'value', 'placeholder' );
|
49 |
-
$e = '';
|
50 |
-
|
51 |
-
|
52 |
-
// prepend
|
53 |
-
if( $field['prepend'] !== "" )
|
54 |
-
{
|
55 |
-
$field['class'] .= ' acf-is-prepended';
|
56 |
-
$e .= '<div class="acf-input-prepend">' . $field['prepend'] . '</div>';
|
57 |
-
}
|
58 |
-
|
59 |
-
|
60 |
-
// append
|
61 |
-
if( $field['append'] !== "" )
|
62 |
-
{
|
63 |
-
$field['class'] .= ' acf-is-appended';
|
64 |
-
$e .= '<div class="acf-input-append">' . $field['append'] . '</div>';
|
65 |
-
}
|
66 |
-
|
67 |
-
|
68 |
-
$e .= '<div class="acf-input-wrap">';
|
69 |
-
$e .= '<input type="email"';
|
70 |
-
|
71 |
-
foreach( $o as $k )
|
72 |
-
{
|
73 |
-
$e .= ' ' . $k . '="' . esc_attr( $field[ $k ] ) . '"';
|
74 |
-
}
|
75 |
-
|
76 |
-
$e .= ' />';
|
77 |
-
$e .= '</div>';
|
78 |
-
|
79 |
-
|
80 |
-
// return
|
81 |
-
echo $e;
|
82 |
-
}
|
83 |
-
|
84 |
-
|
85 |
-
/*
|
86 |
-
* create_options()
|
87 |
-
*
|
88 |
-
* Create extra options for your field. This is rendered when editing a field.
|
89 |
-
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
90 |
-
*
|
91 |
-
* @type action
|
92 |
-
* @since 3.6
|
93 |
-
* @date 23/01/13
|
94 |
-
*
|
95 |
-
* @param $field - an array holding all the field's data
|
96 |
-
*/
|
97 |
-
|
98 |
-
function create_options( $field )
|
99 |
-
{
|
100 |
-
// vars
|
101 |
-
$key = $field['name'];
|
102 |
-
|
103 |
-
?>
|
104 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
105 |
-
<td class="label">
|
106 |
-
<label><?php _e("Default Value",'acf'); ?></label>
|
107 |
-
<p><?php _e("Appears when creating a new post",'acf') ?></p>
|
108 |
-
</td>
|
109 |
-
<td>
|
110 |
-
<?php
|
111 |
-
|
112 |
-
do_action('acf/create_field', array(
|
113 |
-
'type' => 'text',
|
114 |
-
'name' => 'fields['.$key.'][default_value]',
|
115 |
-
'value' => $field['default_value'],
|
116 |
-
));
|
117 |
-
|
118 |
-
?>
|
119 |
-
</td>
|
120 |
-
</tr>
|
121 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
122 |
-
<td class="label">
|
123 |
-
<label><?php _e("Placeholder Text",'acf'); ?></label>
|
124 |
-
<p><?php _e("Appears within the input",'acf') ?></p>
|
125 |
-
</td>
|
126 |
-
<td>
|
127 |
-
<?php
|
128 |
-
do_action('acf/create_field', array(
|
129 |
-
'type' => 'text',
|
130 |
-
'name' => 'fields[' .$key.'][placeholder]',
|
131 |
-
'value' => $field['placeholder'],
|
132 |
-
));
|
133 |
-
?>
|
134 |
-
</td>
|
135 |
-
</tr>
|
136 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
137 |
-
<td class="label">
|
138 |
-
<label><?php _e("Prepend",'acf'); ?></label>
|
139 |
-
<p><?php _e("Appears before the input",'acf') ?></p>
|
140 |
-
</td>
|
141 |
-
<td>
|
142 |
-
<?php
|
143 |
-
do_action('acf/create_field', array(
|
144 |
-
'type' => 'text',
|
145 |
-
'name' => 'fields[' .$key.'][prepend]',
|
146 |
-
'value' => $field['prepend'],
|
147 |
-
));
|
148 |
-
?>
|
149 |
-
</td>
|
150 |
-
</tr>
|
151 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
152 |
-
<td class="label">
|
153 |
-
<label><?php _e("Append",'acf'); ?></label>
|
154 |
-
<p><?php _e("Appears after the input",'acf') ?></p>
|
155 |
-
</td>
|
156 |
-
<td>
|
157 |
-
<?php
|
158 |
-
do_action('acf/create_field', array(
|
159 |
-
'type' => 'text',
|
160 |
-
'name' => 'fields[' .$key.'][append]',
|
161 |
-
'value' => $field['append'],
|
162 |
-
));
|
163 |
-
?>
|
164 |
-
</td>
|
165 |
-
</tr>
|
166 |
-
<?php
|
167 |
-
}
|
168 |
-
|
169 |
-
}
|
170 |
-
|
171 |
-
new acf_field_email();
|
172 |
-
|
173 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class acf_field_email extends acf_field
|
4 |
+
{
|
5 |
+
|
6 |
+
/*
|
7 |
+
* __construct
|
8 |
+
*
|
9 |
+
* Set name / label needed for actions / filters
|
10 |
+
*
|
11 |
+
* @since 3.6
|
12 |
+
* @date 23/01/13
|
13 |
+
*/
|
14 |
+
|
15 |
+
function __construct()
|
16 |
+
{
|
17 |
+
// vars
|
18 |
+
$this->name = 'email';
|
19 |
+
$this->label = __("Email",'acf');
|
20 |
+
$this->defaults = array(
|
21 |
+
'default_value' => '',
|
22 |
+
'placeholder' => '',
|
23 |
+
'prepend' => '',
|
24 |
+
'append' => ''
|
25 |
+
);
|
26 |
+
|
27 |
+
|
28 |
+
// do not delete!
|
29 |
+
parent::__construct();
|
30 |
+
}
|
31 |
+
|
32 |
+
|
33 |
+
/*
|
34 |
+
* create_field()
|
35 |
+
*
|
36 |
+
* Create the HTML interface for your field
|
37 |
+
*
|
38 |
+
* @param $field - an array holding all the field's data
|
39 |
+
*
|
40 |
+
* @type action
|
41 |
+
* @since 3.6
|
42 |
+
* @date 23/01/13
|
43 |
+
*/
|
44 |
+
|
45 |
+
function create_field( $field )
|
46 |
+
{
|
47 |
+
// vars
|
48 |
+
$o = array( 'id', 'class', 'name', 'value', 'placeholder' );
|
49 |
+
$e = '';
|
50 |
+
|
51 |
+
|
52 |
+
// prepend
|
53 |
+
if( $field['prepend'] !== "" )
|
54 |
+
{
|
55 |
+
$field['class'] .= ' acf-is-prepended';
|
56 |
+
$e .= '<div class="acf-input-prepend">' . $field['prepend'] . '</div>';
|
57 |
+
}
|
58 |
+
|
59 |
+
|
60 |
+
// append
|
61 |
+
if( $field['append'] !== "" )
|
62 |
+
{
|
63 |
+
$field['class'] .= ' acf-is-appended';
|
64 |
+
$e .= '<div class="acf-input-append">' . $field['append'] . '</div>';
|
65 |
+
}
|
66 |
+
|
67 |
+
|
68 |
+
$e .= '<div class="acf-input-wrap">';
|
69 |
+
$e .= '<input type="email"';
|
70 |
+
|
71 |
+
foreach( $o as $k )
|
72 |
+
{
|
73 |
+
$e .= ' ' . $k . '="' . esc_attr( $field[ $k ] ) . '"';
|
74 |
+
}
|
75 |
+
|
76 |
+
$e .= ' />';
|
77 |
+
$e .= '</div>';
|
78 |
+
|
79 |
+
|
80 |
+
// return
|
81 |
+
echo $e;
|
82 |
+
}
|
83 |
+
|
84 |
+
|
85 |
+
/*
|
86 |
+
* create_options()
|
87 |
+
*
|
88 |
+
* Create extra options for your field. This is rendered when editing a field.
|
89 |
+
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
90 |
+
*
|
91 |
+
* @type action
|
92 |
+
* @since 3.6
|
93 |
+
* @date 23/01/13
|
94 |
+
*
|
95 |
+
* @param $field - an array holding all the field's data
|
96 |
+
*/
|
97 |
+
|
98 |
+
function create_options( $field )
|
99 |
+
{
|
100 |
+
// vars
|
101 |
+
$key = $field['name'];
|
102 |
+
|
103 |
+
?>
|
104 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
105 |
+
<td class="label">
|
106 |
+
<label><?php _e("Default Value",'acf'); ?></label>
|
107 |
+
<p><?php _e("Appears when creating a new post",'acf') ?></p>
|
108 |
+
</td>
|
109 |
+
<td>
|
110 |
+
<?php
|
111 |
+
|
112 |
+
do_action('acf/create_field', array(
|
113 |
+
'type' => 'text',
|
114 |
+
'name' => 'fields['.$key.'][default_value]',
|
115 |
+
'value' => $field['default_value'],
|
116 |
+
));
|
117 |
+
|
118 |
+
?>
|
119 |
+
</td>
|
120 |
+
</tr>
|
121 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
122 |
+
<td class="label">
|
123 |
+
<label><?php _e("Placeholder Text",'acf'); ?></label>
|
124 |
+
<p><?php _e("Appears within the input",'acf') ?></p>
|
125 |
+
</td>
|
126 |
+
<td>
|
127 |
+
<?php
|
128 |
+
do_action('acf/create_field', array(
|
129 |
+
'type' => 'text',
|
130 |
+
'name' => 'fields[' .$key.'][placeholder]',
|
131 |
+
'value' => $field['placeholder'],
|
132 |
+
));
|
133 |
+
?>
|
134 |
+
</td>
|
135 |
+
</tr>
|
136 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
137 |
+
<td class="label">
|
138 |
+
<label><?php _e("Prepend",'acf'); ?></label>
|
139 |
+
<p><?php _e("Appears before the input",'acf') ?></p>
|
140 |
+
</td>
|
141 |
+
<td>
|
142 |
+
<?php
|
143 |
+
do_action('acf/create_field', array(
|
144 |
+
'type' => 'text',
|
145 |
+
'name' => 'fields[' .$key.'][prepend]',
|
146 |
+
'value' => $field['prepend'],
|
147 |
+
));
|
148 |
+
?>
|
149 |
+
</td>
|
150 |
+
</tr>
|
151 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
152 |
+
<td class="label">
|
153 |
+
<label><?php _e("Append",'acf'); ?></label>
|
154 |
+
<p><?php _e("Appears after the input",'acf') ?></p>
|
155 |
+
</td>
|
156 |
+
<td>
|
157 |
+
<?php
|
158 |
+
do_action('acf/create_field', array(
|
159 |
+
'type' => 'text',
|
160 |
+
'name' => 'fields[' .$key.'][append]',
|
161 |
+
'value' => $field['append'],
|
162 |
+
));
|
163 |
+
?>
|
164 |
+
</td>
|
165 |
+
</tr>
|
166 |
+
<?php
|
167 |
+
}
|
168 |
+
|
169 |
+
}
|
170 |
+
|
171 |
+
new acf_field_email();
|
172 |
+
|
173 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/fields/file.php
CHANGED
@@ -1,399 +1,399 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_field_file extends acf_field
|
4 |
-
{
|
5 |
-
|
6 |
-
/*
|
7 |
-
* __construct
|
8 |
-
*
|
9 |
-
* Set name / label needed for actions / filters
|
10 |
-
*
|
11 |
-
* @since 3.6
|
12 |
-
* @date 23/01/13
|
13 |
-
*/
|
14 |
-
|
15 |
-
function __construct()
|
16 |
-
{
|
17 |
-
// vars
|
18 |
-
$this->name = 'file';
|
19 |
-
$this->label = __("File",'acf');
|
20 |
-
$this->category = __("Content",'acf');
|
21 |
-
$this->defaults = array(
|
22 |
-
'save_format' => 'object',
|
23 |
-
'library' => 'all'
|
24 |
-
);
|
25 |
-
$this->l10n = array(
|
26 |
-
'select' => __("Select File",'acf'),
|
27 |
-
'edit' => __("Edit File",'acf'),
|
28 |
-
'update' => __("Update File",'acf'),
|
29 |
-
'uploadedTo' => __("Uploaded to this post",'acf'),
|
30 |
-
);
|
31 |
-
|
32 |
-
|
33 |
-
// do not delete!
|
34 |
-
parent::__construct();
|
35 |
-
|
36 |
-
|
37 |
-
// filters
|
38 |
-
add_filter('get_media_item_args', array($this, 'get_media_item_args'));
|
39 |
-
add_filter('wp_prepare_attachment_for_js', array($this, 'wp_prepare_attachment_for_js'), 10, 3);
|
40 |
-
|
41 |
-
|
42 |
-
// JSON
|
43 |
-
add_action('wp_ajax_acf/fields/file/get_files', array($this, 'ajax_get_files'));
|
44 |
-
add_action('wp_ajax_nopriv_acf/fields/file/get_files', array($this, 'ajax_get_files'), 10, 1);
|
45 |
-
}
|
46 |
-
|
47 |
-
|
48 |
-
/*
|
49 |
-
* create_field()
|
50 |
-
*
|
51 |
-
* Create the HTML interface for your field
|
52 |
-
*
|
53 |
-
* @param $field - an array holding all the field's data
|
54 |
-
*
|
55 |
-
* @type action
|
56 |
-
* @since 3.6
|
57 |
-
* @date 23/01/13
|
58 |
-
*/
|
59 |
-
|
60 |
-
function create_field( $field )
|
61 |
-
{
|
62 |
-
// vars
|
63 |
-
$o = array(
|
64 |
-
'class' => '',
|
65 |
-
'icon' => '',
|
66 |
-
'title' => '',
|
67 |
-
'size' => '',
|
68 |
-
'url' => '',
|
69 |
-
'name' => '',
|
70 |
-
);
|
71 |
-
|
72 |
-
if( $field['value'] && is_numeric($field['value']) )
|
73 |
-
{
|
74 |
-
$file = get_post( $field['value'] );
|
75 |
-
|
76 |
-
if( $file )
|
77 |
-
{
|
78 |
-
$o['class'] = 'active';
|
79 |
-
$o['icon'] = wp_mime_type_icon( $file->ID );
|
80 |
-
$o['title'] = $file->post_title;
|
81 |
-
$o['size'] = size_format(filesize( get_attached_file( $file->ID ) ));
|
82 |
-
$o['url'] = wp_get_attachment_url( $file->ID );
|
83 |
-
|
84 |
-
$explode = explode('/', $o['url']);
|
85 |
-
$o['name'] = end( $explode );
|
86 |
-
}
|
87 |
-
}
|
88 |
-
|
89 |
-
|
90 |
-
?>
|
91 |
-
<div class="acf-file-uploader clearfix <?php echo $o['class']; ?>" data-library="<?php echo $field['library']; ?>">
|
92 |
-
<input class="acf-file-value" type="hidden" name="<?php echo $field['name']; ?>" value="<?php echo $field['value']; ?>" />
|
93 |
-
<div class="has-file">
|
94 |
-
<ul class="hl clearfix">
|
95 |
-
<li>
|
96 |
-
<img class="acf-file-icon" src="<?php echo $o['icon']; ?>" alt=""/>
|
97 |
-
<div class="hover">
|
98 |
-
<ul class="bl">
|
99 |
-
<li><a href="#" class="acf-button-delete ir">Remove</a></li>
|
100 |
-
<li><a href="#" class="acf-button-edit ir">Edit</a></li>
|
101 |
-
</ul>
|
102 |
-
</div>
|
103 |
-
</li>
|
104 |
-
<li>
|
105 |
-
<p>
|
106 |
-
<strong class="acf-file-title"><?php echo $o['title']; ?></strong>
|
107 |
-
</p>
|
108 |
-
<p>
|
109 |
-
<strong><?php _e('Name', 'acf'); ?>:</strong>
|
110 |
-
<a class="acf-file-name" href="<?php echo $o['url']; ?>" target="_blank"><?php echo $o['name']; ?></a>
|
111 |
-
</p>
|
112 |
-
<p>
|
113 |
-
<strong><?php _e('Size', 'acf'); ?>:</strong>
|
114 |
-
<span class="acf-file-size"><?php echo $o['size']; ?></span>
|
115 |
-
</p>
|
116 |
-
|
117 |
-
</li>
|
118 |
-
</ul>
|
119 |
-
</div>
|
120 |
-
<div class="no-file">
|
121 |
-
<ul class="hl clearfix">
|
122 |
-
<li>
|
123 |
-
<span><?php _e('No File Selected','acf'); ?></span>. <a href="#" class="button add-file"><?php _e('Add File','acf'); ?></a>
|
124 |
-
</li>
|
125 |
-
</ul>
|
126 |
-
</div>
|
127 |
-
</div>
|
128 |
-
<?php
|
129 |
-
}
|
130 |
-
|
131 |
-
|
132 |
-
/*
|
133 |
-
* create_options()
|
134 |
-
*
|
135 |
-
* Create extra options for your field. This is rendered when editing a field.
|
136 |
-
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
137 |
-
*
|
138 |
-
* @type action
|
139 |
-
* @since 3.6
|
140 |
-
* @date 23/01/13
|
141 |
-
*
|
142 |
-
* @param $field - an array holding all the field's data
|
143 |
-
*/
|
144 |
-
|
145 |
-
function create_options( $field )
|
146 |
-
{
|
147 |
-
// vars
|
148 |
-
$key = $field['name'];
|
149 |
-
|
150 |
-
?>
|
151 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
152 |
-
<td class="label">
|
153 |
-
<label><?php _e("Return Value",'acf'); ?></label>
|
154 |
-
</td>
|
155 |
-
<td>
|
156 |
-
<?php
|
157 |
-
|
158 |
-
do_action('acf/create_field', array(
|
159 |
-
'type' => 'radio',
|
160 |
-
'name' => 'fields['.$key.'][save_format]',
|
161 |
-
'value' => $field['save_format'],
|
162 |
-
'layout' => 'horizontal',
|
163 |
-
'choices' => array(
|
164 |
-
'object' => __("File Object",'acf'),
|
165 |
-
'url' => __("File URL",'acf'),
|
166 |
-
'id' => __("File ID",'acf')
|
167 |
-
)
|
168 |
-
));
|
169 |
-
|
170 |
-
?>
|
171 |
-
</td>
|
172 |
-
</tr>
|
173 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
174 |
-
<td class="label">
|
175 |
-
<label><?php _e("Library",'acf'); ?></label>
|
176 |
-
</td>
|
177 |
-
<td>
|
178 |
-
<?php
|
179 |
-
|
180 |
-
do_action('acf/create_field', array(
|
181 |
-
'type' => 'radio',
|
182 |
-
'name' => 'fields['.$key.'][library]',
|
183 |
-
'value' => $field['library'],
|
184 |
-
'layout' => 'horizontal',
|
185 |
-
'choices' => array(
|
186 |
-
'all' => __('All', 'acf'),
|
187 |
-
'uploadedTo' => __('Uploaded to post', 'acf')
|
188 |
-
)
|
189 |
-
));
|
190 |
-
|
191 |
-
?>
|
192 |
-
</td>
|
193 |
-
</tr>
|
194 |
-
<?php
|
195 |
-
|
196 |
-
}
|
197 |
-
|
198 |
-
|
199 |
-
/*
|
200 |
-
* format_value_for_api()
|
201 |
-
*
|
202 |
-
* This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
|
203 |
-
*
|
204 |
-
* @type filter
|
205 |
-
* @since 3.6
|
206 |
-
* @date 23/01/13
|
207 |
-
*
|
208 |
-
* @param $value - the value which was loaded from the database
|
209 |
-
* @param $post_id - the $post_id from which the value was loaded
|
210 |
-
* @param $field - the field array holding all the field options
|
211 |
-
*
|
212 |
-
* @return $value - the modified value
|
213 |
-
*/
|
214 |
-
|
215 |
-
function format_value_for_api( $value, $post_id, $field )
|
216 |
-
{
|
217 |
-
|
218 |
-
// validate
|
219 |
-
if( !$value )
|
220 |
-
{
|
221 |
-
return false;
|
222 |
-
}
|
223 |
-
|
224 |
-
|
225 |
-
// format
|
226 |
-
if( $field['save_format'] == 'url' )
|
227 |
-
{
|
228 |
-
$value = wp_get_attachment_url($value);
|
229 |
-
}
|
230 |
-
elseif( $field['save_format'] == 'object' )
|
231 |
-
{
|
232 |
-
$attachment = get_post( $value );
|
233 |
-
|
234 |
-
|
235 |
-
// validate
|
236 |
-
if( !$attachment )
|
237 |
-
{
|
238 |
-
return false;
|
239 |
-
}
|
240 |
-
|
241 |
-
|
242 |
-
// create array to hold value data
|
243 |
-
$value = array(
|
244 |
-
'id' => $attachment->ID,
|
245 |
-
'alt' => get_post_meta($attachment->ID, '_wp_attachment_image_alt', true),
|
246 |
-
'title' => $attachment->post_title,
|
247 |
-
'caption' => $attachment->post_excerpt,
|
248 |
-
'description' => $attachment->post_content,
|
249 |
-
'mime_type' => $attachment->post_mime_type,
|
250 |
-
'url' => wp_get_attachment_url( $attachment->ID ),
|
251 |
-
);
|
252 |
-
}
|
253 |
-
|
254 |
-
return $value;
|
255 |
-
}
|
256 |
-
|
257 |
-
|
258 |
-
/*
|
259 |
-
* get_media_item_args
|
260 |
-
*
|
261 |
-
* @description:
|
262 |
-
* @since: 3.6
|
263 |
-
* @created: 27/01/13
|
264 |
-
*/
|
265 |
-
|
266 |
-
function get_media_item_args( $vars )
|
267 |
-
{
|
268 |
-
$vars['send'] = true;
|
269 |
-
return($vars);
|
270 |
-
}
|
271 |
-
|
272 |
-
|
273 |
-
/*
|
274 |
-
* ajax_get_files
|
275 |
-
*
|
276 |
-
* @description:
|
277 |
-
* @since: 3.5.7
|
278 |
-
* @created: 13/01/13
|
279 |
-
*/
|
280 |
-
|
281 |
-
function ajax_get_files()
|
282 |
-
{
|
283 |
-
// vars
|
284 |
-
$options = array(
|
285 |
-
'nonce' => '',
|
286 |
-
'files' => array()
|
287 |
-
);
|
288 |
-
$return = array();
|
289 |
-
|
290 |
-
|
291 |
-
// load post options
|
292 |
-
$options = array_merge($options, $_POST);
|
293 |
-
|
294 |
-
|
295 |
-
// verify nonce
|
296 |
-
if( ! wp_verify_nonce($options['nonce'], 'acf_nonce') )
|
297 |
-
{
|
298 |
-
die(0);
|
299 |
-
}
|
300 |
-
|
301 |
-
|
302 |
-
if( $options['files'] )
|
303 |
-
{
|
304 |
-
foreach( $options['files'] as $id )
|
305 |
-
{
|
306 |
-
$o = array();
|
307 |
-
$file = get_post( $id );
|
308 |
-
|
309 |
-
$o['id'] = $file->ID;
|
310 |
-
$o['icon'] = wp_mime_type_icon( $file->ID );
|
311 |
-
$o['title'] = $file->post_title;
|
312 |
-
$o['size'] = size_format(filesize( get_attached_file( $file->ID ) ));
|
313 |
-
$o['url'] = wp_get_attachment_url( $file->ID );
|
314 |
-
$o['name'] = end(explode('/', $o['url']));
|
315 |
-
|
316 |
-
$return[] = $o;
|
317 |
-
}
|
318 |
-
}
|
319 |
-
|
320 |
-
|
321 |
-
// return json
|
322 |
-
echo json_encode( $return );
|
323 |
-
die;
|
324 |
-
|
325 |
-
}
|
326 |
-
|
327 |
-
|
328 |
-
/*
|
329 |
-
* update_value()
|
330 |
-
*
|
331 |
-
* This filter is appied to the $value before it is updated in the db
|
332 |
-
*
|
333 |
-
* @type filter
|
334 |
-
* @since 3.6
|
335 |
-
* @date 23/01/13
|
336 |
-
*
|
337 |
-
* @param $value - the value which will be saved in the database
|
338 |
-
* @param $post_id - the $post_id of which the value will be saved
|
339 |
-
* @param $field - the field array holding all the field options
|
340 |
-
*
|
341 |
-
* @return $value - the modified value
|
342 |
-
*/
|
343 |
-
|
344 |
-
function update_value( $value, $post_id, $field )
|
345 |
-
{
|
346 |
-
// array?
|
347 |
-
if( is_array($value) && isset($value['id']) )
|
348 |
-
{
|
349 |
-
$value = $value['id'];
|
350 |
-
}
|
351 |
-
|
352 |
-
// object?
|
353 |
-
if( is_object($value) && isset($value->ID) )
|
354 |
-
{
|
355 |
-
$value = $value->ID;
|
356 |
-
}
|
357 |
-
|
358 |
-
return $value;
|
359 |
-
}
|
360 |
-
|
361 |
-
|
362 |
-
/*
|
363 |
-
* wp_prepare_attachment_for_js
|
364 |
-
*
|
365 |
-
* this filter allows ACF to add in extra data to an attachment JS object
|
366 |
-
*
|
367 |
-
* @type function
|
368 |
-
* @date 1/06/13
|
369 |
-
*
|
370 |
-
* @param {int} $post_id
|
371 |
-
* @return {int} $post_id
|
372 |
-
*/
|
373 |
-
|
374 |
-
function wp_prepare_attachment_for_js( $response, $attachment, $meta )
|
375 |
-
{
|
376 |
-
// default
|
377 |
-
$fs = '0 kb';
|
378 |
-
|
379 |
-
|
380 |
-
// supress PHP warnings caused by corrupt images
|
381 |
-
if( $i = @filesize( get_attached_file( $attachment->ID ) ) )
|
382 |
-
{
|
383 |
-
$fs = size_format( $i );
|
384 |
-
}
|
385 |
-
|
386 |
-
|
387 |
-
// update JSON
|
388 |
-
$response['filesize'] = $fs;
|
389 |
-
|
390 |
-
|
391 |
-
// return
|
392 |
-
return $response;
|
393 |
-
}
|
394 |
-
|
395 |
-
}
|
396 |
-
|
397 |
-
new acf_field_file();
|
398 |
-
|
399 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class acf_field_file extends acf_field
|
4 |
+
{
|
5 |
+
|
6 |
+
/*
|
7 |
+
* __construct
|
8 |
+
*
|
9 |
+
* Set name / label needed for actions / filters
|
10 |
+
*
|
11 |
+
* @since 3.6
|
12 |
+
* @date 23/01/13
|
13 |
+
*/
|
14 |
+
|
15 |
+
function __construct()
|
16 |
+
{
|
17 |
+
// vars
|
18 |
+
$this->name = 'file';
|
19 |
+
$this->label = __("File",'acf');
|
20 |
+
$this->category = __("Content",'acf');
|
21 |
+
$this->defaults = array(
|
22 |
+
'save_format' => 'object',
|
23 |
+
'library' => 'all'
|
24 |
+
);
|
25 |
+
$this->l10n = array(
|
26 |
+
'select' => __("Select File",'acf'),
|
27 |
+
'edit' => __("Edit File",'acf'),
|
28 |
+
'update' => __("Update File",'acf'),
|
29 |
+
'uploadedTo' => __("Uploaded to this post",'acf'),
|
30 |
+
);
|
31 |
+
|
32 |
+
|
33 |
+
// do not delete!
|
34 |
+
parent::__construct();
|
35 |
+
|
36 |
+
|
37 |
+
// filters
|
38 |
+
add_filter('get_media_item_args', array($this, 'get_media_item_args'));
|
39 |
+
add_filter('wp_prepare_attachment_for_js', array($this, 'wp_prepare_attachment_for_js'), 10, 3);
|
40 |
+
|
41 |
+
|
42 |
+
// JSON
|
43 |
+
add_action('wp_ajax_acf/fields/file/get_files', array($this, 'ajax_get_files'));
|
44 |
+
add_action('wp_ajax_nopriv_acf/fields/file/get_files', array($this, 'ajax_get_files'), 10, 1);
|
45 |
+
}
|
46 |
+
|
47 |
+
|
48 |
+
/*
|
49 |
+
* create_field()
|
50 |
+
*
|
51 |
+
* Create the HTML interface for your field
|
52 |
+
*
|
53 |
+
* @param $field - an array holding all the field's data
|
54 |
+
*
|
55 |
+
* @type action
|
56 |
+
* @since 3.6
|
57 |
+
* @date 23/01/13
|
58 |
+
*/
|
59 |
+
|
60 |
+
function create_field( $field )
|
61 |
+
{
|
62 |
+
// vars
|
63 |
+
$o = array(
|
64 |
+
'class' => '',
|
65 |
+
'icon' => '',
|
66 |
+
'title' => '',
|
67 |
+
'size' => '',
|
68 |
+
'url' => '',
|
69 |
+
'name' => '',
|
70 |
+
);
|
71 |
+
|
72 |
+
if( $field['value'] && is_numeric($field['value']) )
|
73 |
+
{
|
74 |
+
$file = get_post( $field['value'] );
|
75 |
+
|
76 |
+
if( $file )
|
77 |
+
{
|
78 |
+
$o['class'] = 'active';
|
79 |
+
$o['icon'] = wp_mime_type_icon( $file->ID );
|
80 |
+
$o['title'] = $file->post_title;
|
81 |
+
$o['size'] = size_format(filesize( get_attached_file( $file->ID ) ));
|
82 |
+
$o['url'] = wp_get_attachment_url( $file->ID );
|
83 |
+
|
84 |
+
$explode = explode('/', $o['url']);
|
85 |
+
$o['name'] = end( $explode );
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
|
90 |
+
?>
|
91 |
+
<div class="acf-file-uploader clearfix <?php echo $o['class']; ?>" data-library="<?php echo $field['library']; ?>">
|
92 |
+
<input class="acf-file-value" type="hidden" name="<?php echo $field['name']; ?>" value="<?php echo $field['value']; ?>" />
|
93 |
+
<div class="has-file">
|
94 |
+
<ul class="hl clearfix">
|
95 |
+
<li>
|
96 |
+
<img class="acf-file-icon" src="<?php echo $o['icon']; ?>" alt=""/>
|
97 |
+
<div class="hover">
|
98 |
+
<ul class="bl">
|
99 |
+
<li><a href="#" class="acf-button-delete ir">Remove</a></li>
|
100 |
+
<li><a href="#" class="acf-button-edit ir">Edit</a></li>
|
101 |
+
</ul>
|
102 |
+
</div>
|
103 |
+
</li>
|
104 |
+
<li>
|
105 |
+
<p>
|
106 |
+
<strong class="acf-file-title"><?php echo $o['title']; ?></strong>
|
107 |
+
</p>
|
108 |
+
<p>
|
109 |
+
<strong><?php _e('Name', 'acf'); ?>:</strong>
|
110 |
+
<a class="acf-file-name" href="<?php echo $o['url']; ?>" target="_blank"><?php echo $o['name']; ?></a>
|
111 |
+
</p>
|
112 |
+
<p>
|
113 |
+
<strong><?php _e('Size', 'acf'); ?>:</strong>
|
114 |
+
<span class="acf-file-size"><?php echo $o['size']; ?></span>
|
115 |
+
</p>
|
116 |
+
|
117 |
+
</li>
|
118 |
+
</ul>
|
119 |
+
</div>
|
120 |
+
<div class="no-file">
|
121 |
+
<ul class="hl clearfix">
|
122 |
+
<li>
|
123 |
+
<span><?php _e('No File Selected','acf'); ?></span>. <a href="#" class="button add-file"><?php _e('Add File','acf'); ?></a>
|
124 |
+
</li>
|
125 |
+
</ul>
|
126 |
+
</div>
|
127 |
+
</div>
|
128 |
+
<?php
|
129 |
+
}
|
130 |
+
|
131 |
+
|
132 |
+
/*
|
133 |
+
* create_options()
|
134 |
+
*
|
135 |
+
* Create extra options for your field. This is rendered when editing a field.
|
136 |
+
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
137 |
+
*
|
138 |
+
* @type action
|
139 |
+
* @since 3.6
|
140 |
+
* @date 23/01/13
|
141 |
+
*
|
142 |
+
* @param $field - an array holding all the field's data
|
143 |
+
*/
|
144 |
+
|
145 |
+
function create_options( $field )
|
146 |
+
{
|
147 |
+
// vars
|
148 |
+
$key = $field['name'];
|
149 |
+
|
150 |
+
?>
|
151 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
152 |
+
<td class="label">
|
153 |
+
<label><?php _e("Return Value",'acf'); ?></label>
|
154 |
+
</td>
|
155 |
+
<td>
|
156 |
+
<?php
|
157 |
+
|
158 |
+
do_action('acf/create_field', array(
|
159 |
+
'type' => 'radio',
|
160 |
+
'name' => 'fields['.$key.'][save_format]',
|
161 |
+
'value' => $field['save_format'],
|
162 |
+
'layout' => 'horizontal',
|
163 |
+
'choices' => array(
|
164 |
+
'object' => __("File Object",'acf'),
|
165 |
+
'url' => __("File URL",'acf'),
|
166 |
+
'id' => __("File ID",'acf')
|
167 |
+
)
|
168 |
+
));
|
169 |
+
|
170 |
+
?>
|
171 |
+
</td>
|
172 |
+
</tr>
|
173 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
174 |
+
<td class="label">
|
175 |
+
<label><?php _e("Library",'acf'); ?></label>
|
176 |
+
</td>
|
177 |
+
<td>
|
178 |
+
<?php
|
179 |
+
|
180 |
+
do_action('acf/create_field', array(
|
181 |
+
'type' => 'radio',
|
182 |
+
'name' => 'fields['.$key.'][library]',
|
183 |
+
'value' => $field['library'],
|
184 |
+
'layout' => 'horizontal',
|
185 |
+
'choices' => array(
|
186 |
+
'all' => __('All', 'acf'),
|
187 |
+
'uploadedTo' => __('Uploaded to post', 'acf')
|
188 |
+
)
|
189 |
+
));
|
190 |
+
|
191 |
+
?>
|
192 |
+
</td>
|
193 |
+
</tr>
|
194 |
+
<?php
|
195 |
+
|
196 |
+
}
|
197 |
+
|
198 |
+
|
199 |
+
/*
|
200 |
+
* format_value_for_api()
|
201 |
+
*
|
202 |
+
* This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
|
203 |
+
*
|
204 |
+
* @type filter
|
205 |
+
* @since 3.6
|
206 |
+
* @date 23/01/13
|
207 |
+
*
|
208 |
+
* @param $value - the value which was loaded from the database
|
209 |
+
* @param $post_id - the $post_id from which the value was loaded
|
210 |
+
* @param $field - the field array holding all the field options
|
211 |
+
*
|
212 |
+
* @return $value - the modified value
|
213 |
+
*/
|
214 |
+
|
215 |
+
function format_value_for_api( $value, $post_id, $field )
|
216 |
+
{
|
217 |
+
|
218 |
+
// validate
|
219 |
+
if( !$value )
|
220 |
+
{
|
221 |
+
return false;
|
222 |
+
}
|
223 |
+
|
224 |
+
|
225 |
+
// format
|
226 |
+
if( $field['save_format'] == 'url' )
|
227 |
+
{
|
228 |
+
$value = wp_get_attachment_url($value);
|
229 |
+
}
|
230 |
+
elseif( $field['save_format'] == 'object' )
|
231 |
+
{
|
232 |
+
$attachment = get_post( $value );
|
233 |
+
|
234 |
+
|
235 |
+
// validate
|
236 |
+
if( !$attachment )
|
237 |
+
{
|
238 |
+
return false;
|
239 |
+
}
|
240 |
+
|
241 |
+
|
242 |
+
// create array to hold value data
|
243 |
+
$value = array(
|
244 |
+
'id' => $attachment->ID,
|
245 |
+
'alt' => get_post_meta($attachment->ID, '_wp_attachment_image_alt', true),
|
246 |
+
'title' => $attachment->post_title,
|
247 |
+
'caption' => $attachment->post_excerpt,
|
248 |
+
'description' => $attachment->post_content,
|
249 |
+
'mime_type' => $attachment->post_mime_type,
|
250 |
+
'url' => wp_get_attachment_url( $attachment->ID ),
|
251 |
+
);
|
252 |
+
}
|
253 |
+
|
254 |
+
return $value;
|
255 |
+
}
|
256 |
+
|
257 |
+
|
258 |
+
/*
|
259 |
+
* get_media_item_args
|
260 |
+
*
|
261 |
+
* @description:
|
262 |
+
* @since: 3.6
|
263 |
+
* @created: 27/01/13
|
264 |
+
*/
|
265 |
+
|
266 |
+
function get_media_item_args( $vars )
|
267 |
+
{
|
268 |
+
$vars['send'] = true;
|
269 |
+
return($vars);
|
270 |
+
}
|
271 |
+
|
272 |
+
|
273 |
+
/*
|
274 |
+
* ajax_get_files
|
275 |
+
*
|
276 |
+
* @description:
|
277 |
+
* @since: 3.5.7
|
278 |
+
* @created: 13/01/13
|
279 |
+
*/
|
280 |
+
|
281 |
+
function ajax_get_files()
|
282 |
+
{
|
283 |
+
// vars
|
284 |
+
$options = array(
|
285 |
+
'nonce' => '',
|
286 |
+
'files' => array()
|
287 |
+
);
|
288 |
+
$return = array();
|
289 |
+
|
290 |
+
|
291 |
+
// load post options
|
292 |
+
$options = array_merge($options, $_POST);
|
293 |
+
|
294 |
+
|
295 |
+
// verify nonce
|
296 |
+
if( ! wp_verify_nonce($options['nonce'], 'acf_nonce') )
|
297 |
+
{
|
298 |
+
die(0);
|
299 |
+
}
|
300 |
+
|
301 |
+
|
302 |
+
if( $options['files'] )
|
303 |
+
{
|
304 |
+
foreach( $options['files'] as $id )
|
305 |
+
{
|
306 |
+
$o = array();
|
307 |
+
$file = get_post( $id );
|
308 |
+
|
309 |
+
$o['id'] = $file->ID;
|
310 |
+
$o['icon'] = wp_mime_type_icon( $file->ID );
|
311 |
+
$o['title'] = $file->post_title;
|
312 |
+
$o['size'] = size_format(filesize( get_attached_file( $file->ID ) ));
|
313 |
+
$o['url'] = wp_get_attachment_url( $file->ID );
|
314 |
+
$o['name'] = end(explode('/', $o['url']));
|
315 |
+
|
316 |
+
$return[] = $o;
|
317 |
+
}
|
318 |
+
}
|
319 |
+
|
320 |
+
|
321 |
+
// return json
|
322 |
+
echo json_encode( $return );
|
323 |
+
die;
|
324 |
+
|
325 |
+
}
|
326 |
+
|
327 |
+
|
328 |
+
/*
|
329 |
+
* update_value()
|
330 |
+
*
|
331 |
+
* This filter is appied to the $value before it is updated in the db
|
332 |
+
*
|
333 |
+
* @type filter
|
334 |
+
* @since 3.6
|
335 |
+
* @date 23/01/13
|
336 |
+
*
|
337 |
+
* @param $value - the value which will be saved in the database
|
338 |
+
* @param $post_id - the $post_id of which the value will be saved
|
339 |
+
* @param $field - the field array holding all the field options
|
340 |
+
*
|
341 |
+
* @return $value - the modified value
|
342 |
+
*/
|
343 |
+
|
344 |
+
function update_value( $value, $post_id, $field )
|
345 |
+
{
|
346 |
+
// array?
|
347 |
+
if( is_array($value) && isset($value['id']) )
|
348 |
+
{
|
349 |
+
$value = $value['id'];
|
350 |
+
}
|
351 |
+
|
352 |
+
// object?
|
353 |
+
if( is_object($value) && isset($value->ID) )
|
354 |
+
{
|
355 |
+
$value = $value->ID;
|
356 |
+
}
|
357 |
+
|
358 |
+
return $value;
|
359 |
+
}
|
360 |
+
|
361 |
+
|
362 |
+
/*
|
363 |
+
* wp_prepare_attachment_for_js
|
364 |
+
*
|
365 |
+
* this filter allows ACF to add in extra data to an attachment JS object
|
366 |
+
*
|
367 |
+
* @type function
|
368 |
+
* @date 1/06/13
|
369 |
+
*
|
370 |
+
* @param {int} $post_id
|
371 |
+
* @return {int} $post_id
|
372 |
+
*/
|
373 |
+
|
374 |
+
function wp_prepare_attachment_for_js( $response, $attachment, $meta )
|
375 |
+
{
|
376 |
+
// default
|
377 |
+
$fs = '0 kb';
|
378 |
+
|
379 |
+
|
380 |
+
// supress PHP warnings caused by corrupt images
|
381 |
+
if( $i = @filesize( get_attached_file( $attachment->ID ) ) )
|
382 |
+
{
|
383 |
+
$fs = size_format( $i );
|
384 |
+
}
|
385 |
+
|
386 |
+
|
387 |
+
// update JSON
|
388 |
+
$response['filesize'] = $fs;
|
389 |
+
|
390 |
+
|
391 |
+
// return
|
392 |
+
return $response;
|
393 |
+
}
|
394 |
+
|
395 |
+
}
|
396 |
+
|
397 |
+
new acf_field_file();
|
398 |
+
|
399 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/fields/google-map.php
CHANGED
@@ -1,318 +1,319 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_field_google_map extends acf_field
|
4 |
-
{
|
5 |
-
/*
|
6 |
-
* __construct
|
7 |
-
*
|
8 |
-
* Set name / label needed for actions / filters
|
9 |
-
*
|
10 |
-
* @since 3.6
|
11 |
-
* @date 23/01/13
|
12 |
-
*/
|
13 |
-
|
14 |
-
function __construct()
|
15 |
-
{
|
16 |
-
// vars
|
17 |
-
$this->name = 'google_map';
|
18 |
-
$this->label = __("Google Map",'acf');
|
19 |
-
$this->category = __("jQuery",'acf');
|
20 |
-
$this->defaults = array(
|
21 |
-
'height' => '',
|
22 |
-
'center_lat' => '',
|
23 |
-
'center_lng' => '',
|
24 |
-
'zoom' => ''
|
25 |
-
);
|
26 |
-
$this->default_values = array(
|
27 |
-
'height' => '400',
|
28 |
-
'center_lat' => '-37.81411',
|
29 |
-
'center_lng' => '144.96328',
|
30 |
-
'zoom' => '14'
|
31 |
-
);
|
32 |
-
$this->l10n = array(
|
33 |
-
'locating' => __("Locating",'acf'),
|
34 |
-
'browser_support' => __("Sorry, this browser does not support geolocation",'acf'),
|
35 |
-
);
|
36 |
-
|
37 |
-
|
38 |
-
// do not delete!
|
39 |
-
parent::__construct();
|
40 |
-
}
|
41 |
-
|
42 |
-
|
43 |
-
/*
|
44 |
-
* create_field()
|
45 |
-
*
|
46 |
-
* Create the HTML interface for your field
|
47 |
-
*
|
48 |
-
* @param $field - an array holding all the field's data
|
49 |
-
*
|
50 |
-
* @type action
|
51 |
-
* @since 3.6
|
52 |
-
* @date 23/01/13
|
53 |
-
*/
|
54 |
-
|
55 |
-
function create_field( $field )
|
56 |
-
{
|
57 |
-
// require the googlemaps JS ( this script is now lazy loaded via JS )
|
58 |
-
//wp_enqueue_script('acf-googlemaps');
|
59 |
-
|
60 |
-
|
61 |
-
// default value
|
62 |
-
if( !is_array($field['value']) )
|
63 |
-
{
|
64 |
-
$field['value'] = array();
|
65 |
-
}
|
66 |
-
|
67 |
-
$field['value'] = wp_parse_args($field['value'], array(
|
68 |
-
'address' => '',
|
69 |
-
'lat' => '',
|
70 |
-
'lng' => ''
|
71 |
-
));
|
72 |
-
|
73 |
-
|
74 |
-
// default options
|
75 |
-
foreach( $this->default_values as $k => $v )
|
76 |
-
{
|
77 |
-
if( ! $field[ $k ] )
|
78 |
-
{
|
79 |
-
$field[ $k ] = $v;
|
80 |
-
}
|
81 |
-
}
|
82 |
-
|
83 |
-
|
84 |
-
// vars
|
85 |
-
$o = array(
|
86 |
-
'class' => '',
|
87 |
-
);
|
88 |
-
|
89 |
-
if( $field['value']['address'] )
|
90 |
-
{
|
91 |
-
$o['class'] = 'active';
|
92 |
-
}
|
93 |
-
|
94 |
-
|
95 |
-
$atts = '';
|
96 |
-
$keys = array(
|
97 |
-
'data-id' => 'id',
|
98 |
-
'data-lat' => 'center_lat',
|
99 |
-
'data-lng' => 'center_lng',
|
100 |
-
'data-zoom' => 'zoom'
|
101 |
-
);
|
102 |
-
|
103 |
-
foreach( $keys as $k => $v )
|
104 |
-
{
|
105 |
-
$atts .= ' ' . $k . '="' . esc_attr( $field[ $v ] ) . '"';
|
106 |
-
}
|
107 |
-
|
108 |
-
?>
|
109 |
-
<div class="acf-google-map <?php echo $o['class']; ?>" <?php echo $atts; ?>>
|
110 |
-
|
111 |
-
<div style="display:none;">
|
112 |
-
<?php foreach( $field['value'] as $k => $v ): ?>
|
113 |
-
<input type="hidden" class="input-<?php echo $k; ?>" name="<?php echo esc_attr($field['name']); ?>[<?php echo $k; ?>]" value="<?php echo esc_attr( $v ); ?>" />
|
114 |
-
<?php endforeach; ?>
|
115 |
-
</div>
|
116 |
-
|
117 |
-
<div class="title">
|
118 |
-
|
119 |
-
<div class="has-value">
|
120 |
-
<a href="#" class="acf-sprite-remove ir" title="<?php _e("Clear location",'acf'); ?>">Remove</a>
|
121 |
-
<h4><?php echo $field['value']['address']; ?></h4>
|
122 |
-
</div>
|
123 |
-
|
124 |
-
<div class="no-value">
|
125 |
-
<a href="#" class="acf-sprite-locate ir" title="<?php _e("Find current location",'acf'); ?>">Locate</a>
|
126 |
-
<input type="text" placeholder="<?php _e("Search for address...",'acf'); ?>" class="search" />
|
127 |
-
</div>
|
128 |
-
|
129 |
-
</div>
|
130 |
-
|
131 |
-
<div class="canvas" style="height: <?php echo $field['height']; ?>px">
|
132 |
-
|
133 |
-
</div>
|
134 |
-
|
135 |
-
</div>
|
136 |
-
<?php
|
137 |
-
}
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
/*
|
142 |
-
* create_options()
|
143 |
-
*
|
144 |
-
* Create extra options for your field. This is rendered when editing a field.
|
145 |
-
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
146 |
-
*
|
147 |
-
* @type action
|
148 |
-
* @since 3.6
|
149 |
-
* @date 23/01/13
|
150 |
-
*
|
151 |
-
* @param $field - an array holding all the field's data
|
152 |
-
*/
|
153 |
-
|
154 |
-
function create_options( $field )
|
155 |
-
{
|
156 |
-
// vars
|
157 |
-
$key = $field['name'];
|
158 |
-
|
159 |
-
?>
|
160 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
161 |
-
<td class="label">
|
162 |
-
<label><?php _e("Center",'acf'); ?></label>
|
163 |
-
<p class="description"><?php _e('Center the initial map','acf'); ?></p>
|
164 |
-
</td>
|
165 |
-
<td>
|
166 |
-
<ul class="hl clearfix">
|
167 |
-
<li style="width:48%;">
|
168 |
-
<?php
|
169 |
-
|
170 |
-
do_action('acf/create_field', array(
|
171 |
-
'type' => 'text',
|
172 |
-
'name' => 'fields['.$key.'][center_lat]',
|
173 |
-
'value' => $field['center_lat'],
|
174 |
-
'prepend' => 'lat',
|
175 |
-
'placeholder' => $this->default_values['center_lat']
|
176 |
-
));
|
177 |
-
|
178 |
-
?>
|
179 |
-
</li>
|
180 |
-
<li style="width:48%; margin-left:4%;">
|
181 |
-
<?php
|
182 |
-
|
183 |
-
do_action('acf/create_field', array(
|
184 |
-
'type' => 'text',
|
185 |
-
'name' => 'fields['.$key.'][center_lng]',
|
186 |
-
'value' => $field['center_lng'],
|
187 |
-
'prepend' => 'lng',
|
188 |
-
'placeholder' => $this->default_values['center_lng']
|
189 |
-
));
|
190 |
-
|
191 |
-
?>
|
192 |
-
</li>
|
193 |
-
</ul>
|
194 |
-
|
195 |
-
</td>
|
196 |
-
</tr>
|
197 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
198 |
-
<td class="label">
|
199 |
-
<label><?php _e("Zoom",'acf'); ?></label>
|
200 |
-
<p class="description"><?php _e('Set the initial zoom level','acf'); ?></p>
|
201 |
-
</td>
|
202 |
-
<td>
|
203 |
-
<?php
|
204 |
-
|
205 |
-
do_action('acf/create_field', array(
|
206 |
-
'type' => 'number',
|
207 |
-
'name' => 'fields['.$key.'][zoom]',
|
208 |
-
'value' => $field['zoom'],
|
209 |
-
'placeholder' => $this->default_values['zoom']
|
210 |
-
));
|
211 |
-
|
212 |
-
?>
|
213 |
-
</td>
|
214 |
-
</tr>
|
215 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
216 |
-
<td class="label">
|
217 |
-
<label><?php _e("Height",'acf'); ?></label>
|
218 |
-
<p class="description"><?php _e('Customise the map height','acf'); ?></p>
|
219 |
-
</td>
|
220 |
-
<td>
|
221 |
-
<?php
|
222 |
-
|
223 |
-
do_action('acf/create_field', array(
|
224 |
-
'type' => 'number',
|
225 |
-
'name' => 'fields['.$key.'][height]',
|
226 |
-
'value' => $field['height'],
|
227 |
-
'append' => 'px',
|
228 |
-
'placeholder' => $this->default_values['height']
|
229 |
-
));
|
230 |
-
|
231 |
-
?>
|
232 |
-
</td>
|
233 |
-
</tr>
|
234 |
-
<?php
|
235 |
-
|
236 |
-
}
|
237 |
-
|
238 |
-
|
239 |
-
/*
|
240 |
-
* update_value()
|
241 |
-
*
|
242 |
-
* This filter is appied to the $value before it is updated in the db
|
243 |
-
*
|
244 |
-
* @type filter
|
245 |
-
* @since 3.6
|
246 |
-
* @date 23/01/13
|
247 |
-
*
|
248 |
-
* @param $value - the value which will be saved in the database
|
249 |
-
* @param $post_id - the $post_id of which the value will be saved
|
250 |
-
* @param $field - the field array holding all the field options
|
251 |
-
*
|
252 |
-
* @return $value - the modified value
|
253 |
-
*/
|
254 |
-
|
255 |
-
function update_value( $value, $post_id, $field ) {
|
256 |
-
|
257 |
-
if( empty($value) || empty($value['lat']) || empty($value['lng']) ) {
|
258 |
-
|
259 |
-
return false;
|
260 |
-
|
261 |
-
}
|
262 |
-
|
263 |
-
|
264 |
-
// return
|
265 |
-
return $value;
|
266 |
-
}
|
267 |
-
|
268 |
-
|
269 |
-
/*
|
270 |
-
* input_admin_footer
|
271 |
-
*
|
272 |
-
* description
|
273 |
-
*
|
274 |
-
* @type function
|
275 |
-
* @date 6/03/2014
|
276 |
-
* @since 5.0.0
|
277 |
-
*
|
278 |
-
* @param $post_id (int)
|
279 |
-
* @return $post_id (int)
|
280 |
-
*/
|
281 |
-
|
282 |
-
function input_admin_head() {
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
'
|
294 |
-
'
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
if( empty($api['
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
}
|
315 |
-
|
316 |
-
|
317 |
-
|
|
|
318 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class acf_field_google_map extends acf_field
|
4 |
+
{
|
5 |
+
/*
|
6 |
+
* __construct
|
7 |
+
*
|
8 |
+
* Set name / label needed for actions / filters
|
9 |
+
*
|
10 |
+
* @since 3.6
|
11 |
+
* @date 23/01/13
|
12 |
+
*/
|
13 |
+
|
14 |
+
function __construct()
|
15 |
+
{
|
16 |
+
// vars
|
17 |
+
$this->name = 'google_map';
|
18 |
+
$this->label = __("Google Map",'acf');
|
19 |
+
$this->category = __("jQuery",'acf');
|
20 |
+
$this->defaults = array(
|
21 |
+
'height' => '',
|
22 |
+
'center_lat' => '',
|
23 |
+
'center_lng' => '',
|
24 |
+
'zoom' => ''
|
25 |
+
);
|
26 |
+
$this->default_values = array(
|
27 |
+
'height' => '400',
|
28 |
+
'center_lat' => '-37.81411',
|
29 |
+
'center_lng' => '144.96328',
|
30 |
+
'zoom' => '14'
|
31 |
+
);
|
32 |
+
$this->l10n = array(
|
33 |
+
'locating' => __("Locating",'acf'),
|
34 |
+
'browser_support' => __("Sorry, this browser does not support geolocation",'acf'),
|
35 |
+
);
|
36 |
+
|
37 |
+
|
38 |
+
// do not delete!
|
39 |
+
parent::__construct();
|
40 |
+
}
|
41 |
+
|
42 |
+
|
43 |
+
/*
|
44 |
+
* create_field()
|
45 |
+
*
|
46 |
+
* Create the HTML interface for your field
|
47 |
+
*
|
48 |
+
* @param $field - an array holding all the field's data
|
49 |
+
*
|
50 |
+
* @type action
|
51 |
+
* @since 3.6
|
52 |
+
* @date 23/01/13
|
53 |
+
*/
|
54 |
+
|
55 |
+
function create_field( $field )
|
56 |
+
{
|
57 |
+
// require the googlemaps JS ( this script is now lazy loaded via JS )
|
58 |
+
//wp_enqueue_script('acf-googlemaps');
|
59 |
+
|
60 |
+
|
61 |
+
// default value
|
62 |
+
if( !is_array($field['value']) )
|
63 |
+
{
|
64 |
+
$field['value'] = array();
|
65 |
+
}
|
66 |
+
|
67 |
+
$field['value'] = wp_parse_args($field['value'], array(
|
68 |
+
'address' => '',
|
69 |
+
'lat' => '',
|
70 |
+
'lng' => ''
|
71 |
+
));
|
72 |
+
|
73 |
+
|
74 |
+
// default options
|
75 |
+
foreach( $this->default_values as $k => $v )
|
76 |
+
{
|
77 |
+
if( ! $field[ $k ] )
|
78 |
+
{
|
79 |
+
$field[ $k ] = $v;
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
|
84 |
+
// vars
|
85 |
+
$o = array(
|
86 |
+
'class' => '',
|
87 |
+
);
|
88 |
+
|
89 |
+
if( $field['value']['address'] )
|
90 |
+
{
|
91 |
+
$o['class'] = 'active';
|
92 |
+
}
|
93 |
+
|
94 |
+
|
95 |
+
$atts = '';
|
96 |
+
$keys = array(
|
97 |
+
'data-id' => 'id',
|
98 |
+
'data-lat' => 'center_lat',
|
99 |
+
'data-lng' => 'center_lng',
|
100 |
+
'data-zoom' => 'zoom'
|
101 |
+
);
|
102 |
+
|
103 |
+
foreach( $keys as $k => $v )
|
104 |
+
{
|
105 |
+
$atts .= ' ' . $k . '="' . esc_attr( $field[ $v ] ) . '"';
|
106 |
+
}
|
107 |
+
|
108 |
+
?>
|
109 |
+
<div class="acf-google-map <?php echo $o['class']; ?>" <?php echo $atts; ?>>
|
110 |
+
|
111 |
+
<div style="display:none;">
|
112 |
+
<?php foreach( $field['value'] as $k => $v ): ?>
|
113 |
+
<input type="hidden" class="input-<?php echo $k; ?>" name="<?php echo esc_attr($field['name']); ?>[<?php echo $k; ?>]" value="<?php echo esc_attr( $v ); ?>" />
|
114 |
+
<?php endforeach; ?>
|
115 |
+
</div>
|
116 |
+
|
117 |
+
<div class="title">
|
118 |
+
|
119 |
+
<div class="has-value">
|
120 |
+
<a href="#" class="acf-sprite-remove ir" title="<?php _e("Clear location",'acf'); ?>">Remove</a>
|
121 |
+
<h4><?php echo $field['value']['address']; ?></h4>
|
122 |
+
</div>
|
123 |
+
|
124 |
+
<div class="no-value">
|
125 |
+
<a href="#" class="acf-sprite-locate ir" title="<?php _e("Find current location",'acf'); ?>">Locate</a>
|
126 |
+
<input type="text" placeholder="<?php _e("Search for address...",'acf'); ?>" class="search" />
|
127 |
+
</div>
|
128 |
+
|
129 |
+
</div>
|
130 |
+
|
131 |
+
<div class="canvas" style="height: <?php echo $field['height']; ?>px">
|
132 |
+
|
133 |
+
</div>
|
134 |
+
|
135 |
+
</div>
|
136 |
+
<?php
|
137 |
+
}
|
138 |
+
|
139 |
+
|
140 |
+
|
141 |
+
/*
|
142 |
+
* create_options()
|
143 |
+
*
|
144 |
+
* Create extra options for your field. This is rendered when editing a field.
|
145 |
+
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
146 |
+
*
|
147 |
+
* @type action
|
148 |
+
* @since 3.6
|
149 |
+
* @date 23/01/13
|
150 |
+
*
|
151 |
+
* @param $field - an array holding all the field's data
|
152 |
+
*/
|
153 |
+
|
154 |
+
function create_options( $field )
|
155 |
+
{
|
156 |
+
// vars
|
157 |
+
$key = $field['name'];
|
158 |
+
|
159 |
+
?>
|
160 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
161 |
+
<td class="label">
|
162 |
+
<label><?php _e("Center",'acf'); ?></label>
|
163 |
+
<p class="description"><?php _e('Center the initial map','acf'); ?></p>
|
164 |
+
</td>
|
165 |
+
<td>
|
166 |
+
<ul class="hl clearfix">
|
167 |
+
<li style="width:48%;">
|
168 |
+
<?php
|
169 |
+
|
170 |
+
do_action('acf/create_field', array(
|
171 |
+
'type' => 'text',
|
172 |
+
'name' => 'fields['.$key.'][center_lat]',
|
173 |
+
'value' => $field['center_lat'],
|
174 |
+
'prepend' => 'lat',
|
175 |
+
'placeholder' => $this->default_values['center_lat']
|
176 |
+
));
|
177 |
+
|
178 |
+
?>
|
179 |
+
</li>
|
180 |
+
<li style="width:48%; margin-left:4%;">
|
181 |
+
<?php
|
182 |
+
|
183 |
+
do_action('acf/create_field', array(
|
184 |
+
'type' => 'text',
|
185 |
+
'name' => 'fields['.$key.'][center_lng]',
|
186 |
+
'value' => $field['center_lng'],
|
187 |
+
'prepend' => 'lng',
|
188 |
+
'placeholder' => $this->default_values['center_lng']
|
189 |
+
));
|
190 |
+
|
191 |
+
?>
|
192 |
+
</li>
|
193 |
+
</ul>
|
194 |
+
|
195 |
+
</td>
|
196 |
+
</tr>
|
197 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
198 |
+
<td class="label">
|
199 |
+
<label><?php _e("Zoom",'acf'); ?></label>
|
200 |
+
<p class="description"><?php _e('Set the initial zoom level','acf'); ?></p>
|
201 |
+
</td>
|
202 |
+
<td>
|
203 |
+
<?php
|
204 |
+
|
205 |
+
do_action('acf/create_field', array(
|
206 |
+
'type' => 'number',
|
207 |
+
'name' => 'fields['.$key.'][zoom]',
|
208 |
+
'value' => $field['zoom'],
|
209 |
+
'placeholder' => $this->default_values['zoom']
|
210 |
+
));
|
211 |
+
|
212 |
+
?>
|
213 |
+
</td>
|
214 |
+
</tr>
|
215 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
216 |
+
<td class="label">
|
217 |
+
<label><?php _e("Height",'acf'); ?></label>
|
218 |
+
<p class="description"><?php _e('Customise the map height','acf'); ?></p>
|
219 |
+
</td>
|
220 |
+
<td>
|
221 |
+
<?php
|
222 |
+
|
223 |
+
do_action('acf/create_field', array(
|
224 |
+
'type' => 'number',
|
225 |
+
'name' => 'fields['.$key.'][height]',
|
226 |
+
'value' => $field['height'],
|
227 |
+
'append' => 'px',
|
228 |
+
'placeholder' => $this->default_values['height']
|
229 |
+
));
|
230 |
+
|
231 |
+
?>
|
232 |
+
</td>
|
233 |
+
</tr>
|
234 |
+
<?php
|
235 |
+
|
236 |
+
}
|
237 |
+
|
238 |
+
|
239 |
+
/*
|
240 |
+
* update_value()
|
241 |
+
*
|
242 |
+
* This filter is appied to the $value before it is updated in the db
|
243 |
+
*
|
244 |
+
* @type filter
|
245 |
+
* @since 3.6
|
246 |
+
* @date 23/01/13
|
247 |
+
*
|
248 |
+
* @param $value - the value which will be saved in the database
|
249 |
+
* @param $post_id - the $post_id of which the value will be saved
|
250 |
+
* @param $field - the field array holding all the field options
|
251 |
+
*
|
252 |
+
* @return $value - the modified value
|
253 |
+
*/
|
254 |
+
|
255 |
+
function update_value( $value, $post_id, $field ) {
|
256 |
+
|
257 |
+
if( empty($value) || empty($value['lat']) || empty($value['lng']) ) {
|
258 |
+
|
259 |
+
return false;
|
260 |
+
|
261 |
+
}
|
262 |
+
|
263 |
+
|
264 |
+
// return
|
265 |
+
return $value;
|
266 |
+
}
|
267 |
+
|
268 |
+
|
269 |
+
/*
|
270 |
+
* input_admin_footer
|
271 |
+
*
|
272 |
+
* description
|
273 |
+
*
|
274 |
+
* @type function
|
275 |
+
* @date 6/03/2014
|
276 |
+
* @since 5.0.0
|
277 |
+
*
|
278 |
+
* @param $post_id (int)
|
279 |
+
* @return $post_id (int)
|
280 |
+
*/
|
281 |
+
|
282 |
+
function input_admin_head() {
|
283 |
+
|
284 |
+
$action = is_admin() ? 'admin_footer' : 'wp_footer';
|
285 |
+
add_action( $action, array( $this, 'input_admin_footer') );
|
286 |
+
|
287 |
+
}
|
288 |
+
|
289 |
+
function input_admin_footer() {
|
290 |
+
|
291 |
+
// vars
|
292 |
+
$api = array(
|
293 |
+
'libraries' => 'places',
|
294 |
+
'key' => '',
|
295 |
+
'client' => ''
|
296 |
+
);
|
297 |
+
|
298 |
+
|
299 |
+
// filter
|
300 |
+
$api = apply_filters('acf/fields/google_map/api', $api);
|
301 |
+
|
302 |
+
|
303 |
+
// remove empty
|
304 |
+
if( empty($api['key']) ) unset($api['key']);
|
305 |
+
if( empty($api['client']) ) unset($api['client']);
|
306 |
+
|
307 |
+
|
308 |
+
?>
|
309 |
+
<script type="text/javascript">
|
310 |
+
acf.fields.google_map.api = <?php echo json_encode($api); ?>;
|
311 |
+
</script>
|
312 |
+
<?php
|
313 |
+
|
314 |
+
}
|
315 |
+
}
|
316 |
+
|
317 |
+
new acf_field_google_map();
|
318 |
+
|
319 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/fields/image.php
CHANGED
@@ -1,458 +1,458 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_field_image extends acf_field
|
4 |
-
{
|
5 |
-
|
6 |
-
/*
|
7 |
-
* __construct
|
8 |
-
*
|
9 |
-
* Set name / label needed for actions / filters
|
10 |
-
*
|
11 |
-
* @since 3.6
|
12 |
-
* @date 23/01/13
|
13 |
-
*/
|
14 |
-
|
15 |
-
function __construct()
|
16 |
-
{
|
17 |
-
// vars
|
18 |
-
$this->name = 'image';
|
19 |
-
$this->label = __("Image",'acf');
|
20 |
-
$this->category = __("Content",'acf');
|
21 |
-
$this->defaults = array(
|
22 |
-
'save_format' => 'object',
|
23 |
-
'preview_size' => 'thumbnail',
|
24 |
-
'library' => 'all'
|
25 |
-
);
|
26 |
-
$this->l10n = array(
|
27 |
-
'select' => __("Select Image",'acf'),
|
28 |
-
'edit' => __("Edit Image",'acf'),
|
29 |
-
'update' => __("Update Image",'acf'),
|
30 |
-
'uploadedTo' => __("Uploaded to this post",'acf'),
|
31 |
-
);
|
32 |
-
|
33 |
-
|
34 |
-
// do not delete!
|
35 |
-
parent::__construct();
|
36 |
-
|
37 |
-
|
38 |
-
// filters
|
39 |
-
add_filter('get_media_item_args', array($this, 'get_media_item_args'));
|
40 |
-
add_filter('wp_prepare_attachment_for_js', array($this, 'wp_prepare_attachment_for_js'), 10, 3);
|
41 |
-
|
42 |
-
|
43 |
-
// JSON
|
44 |
-
add_action('wp_ajax_acf/fields/image/get_images', array($this, 'ajax_get_images'), 10, 1);
|
45 |
-
add_action('wp_ajax_nopriv_acf/fields/image/get_images', array($this, 'ajax_get_images'), 10, 1);
|
46 |
-
}
|
47 |
-
|
48 |
-
|
49 |
-
/*
|
50 |
-
* create_field()
|
51 |
-
*
|
52 |
-
* Create the HTML interface for your field
|
53 |
-
*
|
54 |
-
* @param $field - an array holding all the field's data
|
55 |
-
*
|
56 |
-
* @type action
|
57 |
-
* @since 3.6
|
58 |
-
* @date 23/01/13
|
59 |
-
*/
|
60 |
-
|
61 |
-
function create_field( $field )
|
62 |
-
{
|
63 |
-
// vars
|
64 |
-
$o = array(
|
65 |
-
'class' => '',
|
66 |
-
'url' => '',
|
67 |
-
);
|
68 |
-
|
69 |
-
|
70 |
-
// has value?
|
71 |
-
if( $field['value'] && is_numeric($field['value']) ) {
|
72 |
-
|
73 |
-
$url = wp_get_attachment_image_src($field['value'], $field['preview_size']);
|
74 |
-
|
75 |
-
if( $url ) {
|
76 |
-
|
77 |
-
$o['url'] = $url[0];
|
78 |
-
$o['class'] = 'active';
|
79 |
-
|
80 |
-
}
|
81 |
-
|
82 |
-
}
|
83 |
-
|
84 |
-
?>
|
85 |
-
<div class="acf-image-uploader clearfix <?php echo $o['class']; ?>" data-preview_size="<?php echo $field['preview_size']; ?>" data-library="<?php echo $field['library']; ?>" >
|
86 |
-
<input class="acf-image-value" type="hidden" name="<?php echo $field['name']; ?>" value="<?php echo $field['value']; ?>" />
|
87 |
-
<div class="has-image">
|
88 |
-
<div class="hover">
|
89 |
-
<ul class="bl">
|
90 |
-
<li><a class="acf-button-delete ir" href="#"><?php _e("Remove",'acf'); ?></a></li>
|
91 |
-
<li><a class="acf-button-edit ir" href="#"><?php _e("Edit",'acf'); ?></a></li>
|
92 |
-
</ul>
|
93 |
-
</div>
|
94 |
-
<img class="acf-image-image" src="<?php echo $o['url']; ?>" alt=""/>
|
95 |
-
</div>
|
96 |
-
<div class="no-image">
|
97 |
-
<p><?php _e('No image selected','acf'); ?> <input type="button" class="button add-image" value="<?php _e('Add Image','acf'); ?>" />
|
98 |
-
</div>
|
99 |
-
</div>
|
100 |
-
<?php
|
101 |
-
}
|
102 |
-
|
103 |
-
|
104 |
-
/*
|
105 |
-
* create_options()
|
106 |
-
*
|
107 |
-
* Create extra options for your field. This is rendered when editing a field.
|
108 |
-
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
109 |
-
*
|
110 |
-
* @type action
|
111 |
-
* @since 3.6
|
112 |
-
* @date 23/01/13
|
113 |
-
*
|
114 |
-
* @param $field - an array holding all the field's data
|
115 |
-
*/
|
116 |
-
|
117 |
-
function create_options( $field )
|
118 |
-
{
|
119 |
-
// vars
|
120 |
-
$key = $field['name'];
|
121 |
-
|
122 |
-
?>
|
123 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
124 |
-
<td class="label">
|
125 |
-
<label><?php _e("Return Value",'acf'); ?></label>
|
126 |
-
<p><?php _e("Specify the returned value on front end",'acf') ?></p>
|
127 |
-
</td>
|
128 |
-
<td>
|
129 |
-
<?php
|
130 |
-
do_action('acf/create_field', array(
|
131 |
-
'type' => 'radio',
|
132 |
-
'name' => 'fields['.$key.'][save_format]',
|
133 |
-
'value' => $field['save_format'],
|
134 |
-
'layout' => 'horizontal',
|
135 |
-
'choices' => array(
|
136 |
-
'object' => __("Image Object",'acf'),
|
137 |
-
'url' => __("Image URL",'acf'),
|
138 |
-
'id' => __("Image ID",'acf')
|
139 |
-
)
|
140 |
-
));
|
141 |
-
?>
|
142 |
-
</td>
|
143 |
-
</tr>
|
144 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
145 |
-
<td class="label">
|
146 |
-
<label><?php _e("Preview Size",'acf'); ?></label>
|
147 |
-
<p><?php _e("Shown when entering data",'acf') ?></p>
|
148 |
-
</td>
|
149 |
-
<td>
|
150 |
-
<?php
|
151 |
-
|
152 |
-
do_action('acf/create_field', array(
|
153 |
-
'type' => 'radio',
|
154 |
-
'name' => 'fields['.$key.'][preview_size]',
|
155 |
-
'value' => $field['preview_size'],
|
156 |
-
'layout' => 'horizontal',
|
157 |
-
'choices' => apply_filters('acf/get_image_sizes', array())
|
158 |
-
));
|
159 |
-
|
160 |
-
?>
|
161 |
-
</td>
|
162 |
-
</tr>
|
163 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
164 |
-
<td class="label">
|
165 |
-
<label><?php _e("Library",'acf'); ?></label>
|
166 |
-
<p><?php _e("Limit the media library choice",'acf') ?></p>
|
167 |
-
</td>
|
168 |
-
<td>
|
169 |
-
<?php
|
170 |
-
|
171 |
-
do_action('acf/create_field', array(
|
172 |
-
'type' => 'radio',
|
173 |
-
'name' => 'fields['.$key.'][library]',
|
174 |
-
'value' => $field['library'],
|
175 |
-
'layout' => 'horizontal',
|
176 |
-
'choices' => array(
|
177 |
-
'all' => __('All', 'acf'),
|
178 |
-
'uploadedTo' => __('Uploaded to post', 'acf')
|
179 |
-
)
|
180 |
-
));
|
181 |
-
|
182 |
-
?>
|
183 |
-
</td>
|
184 |
-
</tr>
|
185 |
-
<?php
|
186 |
-
|
187 |
-
}
|
188 |
-
|
189 |
-
|
190 |
-
/*
|
191 |
-
* format_value_for_api()
|
192 |
-
*
|
193 |
-
* This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
|
194 |
-
*
|
195 |
-
* @type filter
|
196 |
-
* @since 3.6
|
197 |
-
* @date 23/01/13
|
198 |
-
*
|
199 |
-
* @param $value - the value which was loaded from the database
|
200 |
-
* @param $post_id - the $post_id from which the value was loaded
|
201 |
-
* @param $field - the field array holding all the field options
|
202 |
-
*
|
203 |
-
* @return $value - the modified value
|
204 |
-
*/
|
205 |
-
|
206 |
-
function format_value_for_api( $value, $post_id, $field )
|
207 |
-
{
|
208 |
-
|
209 |
-
// validate
|
210 |
-
if( !$value )
|
211 |
-
{
|
212 |
-
return false;
|
213 |
-
}
|
214 |
-
|
215 |
-
|
216 |
-
// format
|
217 |
-
if( $field['save_format'] == 'url' )
|
218 |
-
{
|
219 |
-
$value = wp_get_attachment_url( $value );
|
220 |
-
}
|
221 |
-
elseif( $field['save_format'] == 'object' )
|
222 |
-
{
|
223 |
-
$attachment = get_post( $value );
|
224 |
-
|
225 |
-
|
226 |
-
// validate
|
227 |
-
if( !$attachment )
|
228 |
-
{
|
229 |
-
return false;
|
230 |
-
}
|
231 |
-
|
232 |
-
|
233 |
-
// create array to hold value data
|
234 |
-
$src = wp_get_attachment_image_src( $attachment->ID, 'full' );
|
235 |
-
|
236 |
-
$value = array(
|
237 |
-
'id' => $attachment->ID,
|
238 |
-
'alt' => get_post_meta($attachment->ID, '_wp_attachment_image_alt', true),
|
239 |
-
'title' => $attachment->post_title,
|
240 |
-
'caption' => $attachment->post_excerpt,
|
241 |
-
'description' => $attachment->post_content,
|
242 |
-
'mime_type' => $attachment->post_mime_type,
|
243 |
-
'url' => $src[0],
|
244 |
-
'width' => $src[1],
|
245 |
-
'height' => $src[2],
|
246 |
-
'sizes' => array(),
|
247 |
-
);
|
248 |
-
|
249 |
-
|
250 |
-
// find all image sizes
|
251 |
-
$image_sizes = get_intermediate_image_sizes();
|
252 |
-
|
253 |
-
if( $image_sizes )
|
254 |
-
{
|
255 |
-
foreach( $image_sizes as $image_size )
|
256 |
-
{
|
257 |
-
// find src
|
258 |
-
$src = wp_get_attachment_image_src( $attachment->ID, $image_size );
|
259 |
-
|
260 |
-
// add src
|
261 |
-
$value[ 'sizes' ][ $image_size ] = $src[0];
|
262 |
-
$value[ 'sizes' ][ $image_size . '-width' ] = $src[1];
|
263 |
-
$value[ 'sizes' ][ $image_size . '-height' ] = $src[2];
|
264 |
-
}
|
265 |
-
// foreach( $image_sizes as $image_size )
|
266 |
-
}
|
267 |
-
// if( $image_sizes )
|
268 |
-
|
269 |
-
}
|
270 |
-
|
271 |
-
return $value;
|
272 |
-
|
273 |
-
}
|
274 |
-
|
275 |
-
|
276 |
-
/*
|
277 |
-
* get_media_item_args
|
278 |
-
*
|
279 |
-
* @description:
|
280 |
-
* @since: 3.6
|
281 |
-
* @created: 27/01/13
|
282 |
-
*/
|
283 |
-
|
284 |
-
function get_media_item_args( $vars )
|
285 |
-
{
|
286 |
-
$vars['send'] = true;
|
287 |
-
return($vars);
|
288 |
-
}
|
289 |
-
|
290 |
-
|
291 |
-
/*
|
292 |
-
* ajax_get_images
|
293 |
-
*
|
294 |
-
* @description:
|
295 |
-
* @since: 3.5.7
|
296 |
-
* @created: 13/01/13
|
297 |
-
*/
|
298 |
-
|
299 |
-
function ajax_get_images()
|
300 |
-
{
|
301 |
-
// vars
|
302 |
-
$options = array(
|
303 |
-
'nonce' => '',
|
304 |
-
'images' => array(),
|
305 |
-
'preview_size' => 'thumbnail'
|
306 |
-
);
|
307 |
-
$return = array();
|
308 |
-
|
309 |
-
|
310 |
-
// load post options
|
311 |
-
$options = array_merge($options, $_POST);
|
312 |
-
|
313 |
-
|
314 |
-
// verify nonce
|
315 |
-
if( ! wp_verify_nonce($options['nonce'], 'acf_nonce') )
|
316 |
-
{
|
317 |
-
die(0);
|
318 |
-
}
|
319 |
-
|
320 |
-
|
321 |
-
if( $options['images'] )
|
322 |
-
{
|
323 |
-
foreach( $options['images'] as $id )
|
324 |
-
{
|
325 |
-
$url = wp_get_attachment_image_src( $id, $options['preview_size'] );
|
326 |
-
|
327 |
-
|
328 |
-
$return[] = array(
|
329 |
-
'id' => $id,
|
330 |
-
'url' => $url[0],
|
331 |
-
);
|
332 |
-
}
|
333 |
-
}
|
334 |
-
|
335 |
-
|
336 |
-
// return json
|
337 |
-
echo json_encode( $return );
|
338 |
-
die;
|
339 |
-
|
340 |
-
}
|
341 |
-
|
342 |
-
|
343 |
-
/*
|
344 |
-
* image_size_names_choose
|
345 |
-
*
|
346 |
-
* @description:
|
347 |
-
* @since: 3.5.7
|
348 |
-
* @created: 13/01/13
|
349 |
-
*/
|
350 |
-
|
351 |
-
function image_size_names_choose( $sizes )
|
352 |
-
{
|
353 |
-
global $_wp_additional_image_sizes;
|
354 |
-
|
355 |
-
if( $_wp_additional_image_sizes )
|
356 |
-
{
|
357 |
-
foreach( $_wp_additional_image_sizes as $k => $v )
|
358 |
-
{
|
359 |
-
$title = $k;
|
360 |
-
$title = str_replace('-', ' ', $title);
|
361 |
-
$title = str_replace('_', ' ', $title);
|
362 |
-
$title = ucwords( $title );
|
363 |
-
|
364 |
-
$sizes[ $k ] = $title;
|
365 |
-
}
|
366 |
-
// foreach( $image_sizes as $image_size )
|
367 |
-
}
|
368 |
-
|
369 |
-
return $sizes;
|
370 |
-
}
|
371 |
-
|
372 |
-
|
373 |
-
/*
|
374 |
-
* wp_prepare_attachment_for_js
|
375 |
-
*
|
376 |
-
* @description: This sneaky hook adds the missing sizes to each attachment in the 3.5 uploader. It would be a lot easier to add all the sizes to the 'image_size_names_choose' filter but then it will show up on the normal the_content editor
|
377 |
-
* @since: 3.5.7
|
378 |
-
* @created: 13/01/13
|
379 |
-
*/
|
380 |
-
|
381 |
-
function wp_prepare_attachment_for_js( $response, $attachment, $meta )
|
382 |
-
{
|
383 |
-
// only for image
|
384 |
-
if( $response['type'] != 'image' )
|
385 |
-
{
|
386 |
-
return $response;
|
387 |
-
}
|
388 |
-
|
389 |
-
|
390 |
-
// make sure sizes exist. Perhaps they dont?
|
391 |
-
if( !isset($meta['sizes']) )
|
392 |
-
{
|
393 |
-
return $response;
|
394 |
-
}
|
395 |
-
|
396 |
-
|
397 |
-
$attachment_url = $response['url'];
|
398 |
-
$base_url = str_replace( wp_basename( $attachment_url ), '', $attachment_url );
|
399 |
-
|
400 |
-
if( isset($meta['sizes']) && is_array($meta['sizes']) )
|
401 |
-
{
|
402 |
-
foreach( $meta['sizes'] as $k => $v )
|
403 |
-
{
|
404 |
-
if( !isset($response['sizes'][ $k ]) )
|
405 |
-
{
|
406 |
-
$response['sizes'][ $k ] = array(
|
407 |
-
'height' => $v['height'],
|
408 |
-
'width' => $v['width'],
|
409 |
-
'url' => $base_url . $v['file'],
|
410 |
-
'orientation' => $v['height'] > $v['width'] ? 'portrait' : 'landscape',
|
411 |
-
);
|
412 |
-
}
|
413 |
-
}
|
414 |
-
}
|
415 |
-
|
416 |
-
return $response;
|
417 |
-
}
|
418 |
-
|
419 |
-
|
420 |
-
/*
|
421 |
-
* update_value()
|
422 |
-
*
|
423 |
-
* This filter is appied to the $value before it is updated in the db
|
424 |
-
*
|
425 |
-
* @type filter
|
426 |
-
* @since 3.6
|
427 |
-
* @date 23/01/13
|
428 |
-
*
|
429 |
-
* @param $value - the value which will be saved in the database
|
430 |
-
* @param $post_id - the $post_id of which the value will be saved
|
431 |
-
* @param $field - the field array holding all the field options
|
432 |
-
*
|
433 |
-
* @return $value - the modified value
|
434 |
-
*/
|
435 |
-
|
436 |
-
function update_value( $value, $post_id, $field )
|
437 |
-
{
|
438 |
-
// array?
|
439 |
-
if( is_array($value) && isset($value['id']) )
|
440 |
-
{
|
441 |
-
$value = $value['id'];
|
442 |
-
}
|
443 |
-
|
444 |
-
// object?
|
445 |
-
if( is_object($value) && isset($value->ID) )
|
446 |
-
{
|
447 |
-
$value = $value->ID;
|
448 |
-
}
|
449 |
-
|
450 |
-
return $value;
|
451 |
-
}
|
452 |
-
|
453 |
-
|
454 |
-
}
|
455 |
-
|
456 |
-
new acf_field_image();
|
457 |
-
|
458 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class acf_field_image extends acf_field
|
4 |
+
{
|
5 |
+
|
6 |
+
/*
|
7 |
+
* __construct
|
8 |
+
*
|
9 |
+
* Set name / label needed for actions / filters
|
10 |
+
*
|
11 |
+
* @since 3.6
|
12 |
+
* @date 23/01/13
|
13 |
+
*/
|
14 |
+
|
15 |
+
function __construct()
|
16 |
+
{
|
17 |
+
// vars
|
18 |
+
$this->name = 'image';
|
19 |
+
$this->label = __("Image",'acf');
|
20 |
+
$this->category = __("Content",'acf');
|
21 |
+
$this->defaults = array(
|
22 |
+
'save_format' => 'object',
|
23 |
+
'preview_size' => 'thumbnail',
|
24 |
+
'library' => 'all'
|
25 |
+
);
|
26 |
+
$this->l10n = array(
|
27 |
+
'select' => __("Select Image",'acf'),
|
28 |
+
'edit' => __("Edit Image",'acf'),
|
29 |
+
'update' => __("Update Image",'acf'),
|
30 |
+
'uploadedTo' => __("Uploaded to this post",'acf'),
|
31 |
+
);
|
32 |
+
|
33 |
+
|
34 |
+
// do not delete!
|
35 |
+
parent::__construct();
|
36 |
+
|
37 |
+
|
38 |
+
// filters
|
39 |
+
add_filter('get_media_item_args', array($this, 'get_media_item_args'));
|
40 |
+
add_filter('wp_prepare_attachment_for_js', array($this, 'wp_prepare_attachment_for_js'), 10, 3);
|
41 |
+
|
42 |
+
|
43 |
+
// JSON
|
44 |
+
add_action('wp_ajax_acf/fields/image/get_images', array($this, 'ajax_get_images'), 10, 1);
|
45 |
+
add_action('wp_ajax_nopriv_acf/fields/image/get_images', array($this, 'ajax_get_images'), 10, 1);
|
46 |
+
}
|
47 |
+
|
48 |
+
|
49 |
+
/*
|
50 |
+
* create_field()
|
51 |
+
*
|
52 |
+
* Create the HTML interface for your field
|
53 |
+
*
|
54 |
+
* @param $field - an array holding all the field's data
|
55 |
+
*
|
56 |
+
* @type action
|
57 |
+
* @since 3.6
|
58 |
+
* @date 23/01/13
|
59 |
+
*/
|
60 |
+
|
61 |
+
function create_field( $field )
|
62 |
+
{
|
63 |
+
// vars
|
64 |
+
$o = array(
|
65 |
+
'class' => '',
|
66 |
+
'url' => '',
|
67 |
+
);
|
68 |
+
|
69 |
+
|
70 |
+
// has value?
|
71 |
+
if( $field['value'] && is_numeric($field['value']) ) {
|
72 |
+
|
73 |
+
$url = wp_get_attachment_image_src($field['value'], $field['preview_size']);
|
74 |
+
|
75 |
+
if( $url ) {
|
76 |
+
|
77 |
+
$o['url'] = $url[0];
|
78 |
+
$o['class'] = 'active';
|
79 |
+
|
80 |
+
}
|
81 |
+
|
82 |
+
}
|
83 |
+
|
84 |
+
?>
|
85 |
+
<div class="acf-image-uploader clearfix <?php echo $o['class']; ?>" data-preview_size="<?php echo $field['preview_size']; ?>" data-library="<?php echo $field['library']; ?>" >
|
86 |
+
<input class="acf-image-value" type="hidden" name="<?php echo $field['name']; ?>" value="<?php echo $field['value']; ?>" />
|
87 |
+
<div class="has-image">
|
88 |
+
<div class="hover">
|
89 |
+
<ul class="bl">
|
90 |
+
<li><a class="acf-button-delete ir" href="#"><?php _e("Remove",'acf'); ?></a></li>
|
91 |
+
<li><a class="acf-button-edit ir" href="#"><?php _e("Edit",'acf'); ?></a></li>
|
92 |
+
</ul>
|
93 |
+
</div>
|
94 |
+
<img class="acf-image-image" src="<?php echo $o['url']; ?>" alt=""/>
|
95 |
+
</div>
|
96 |
+
<div class="no-image">
|
97 |
+
<p><?php _e('No image selected','acf'); ?> <input type="button" class="button add-image" value="<?php _e('Add Image','acf'); ?>" />
|
98 |
+
</div>
|
99 |
+
</div>
|
100 |
+
<?php
|
101 |
+
}
|
102 |
+
|
103 |
+
|
104 |
+
/*
|
105 |
+
* create_options()
|
106 |
+
*
|
107 |
+
* Create extra options for your field. This is rendered when editing a field.
|
108 |
+
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
109 |
+
*
|
110 |
+
* @type action
|
111 |
+
* @since 3.6
|
112 |
+
* @date 23/01/13
|
113 |
+
*
|
114 |
+
* @param $field - an array holding all the field's data
|
115 |
+
*/
|
116 |
+
|
117 |
+
function create_options( $field )
|
118 |
+
{
|
119 |
+
// vars
|
120 |
+
$key = $field['name'];
|
121 |
+
|
122 |
+
?>
|
123 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
124 |
+
<td class="label">
|
125 |
+
<label><?php _e("Return Value",'acf'); ?></label>
|
126 |
+
<p><?php _e("Specify the returned value on front end",'acf') ?></p>
|
127 |
+
</td>
|
128 |
+
<td>
|
129 |
+
<?php
|
130 |
+
do_action('acf/create_field', array(
|
131 |
+
'type' => 'radio',
|
132 |
+
'name' => 'fields['.$key.'][save_format]',
|
133 |
+
'value' => $field['save_format'],
|
134 |
+
'layout' => 'horizontal',
|
135 |
+
'choices' => array(
|
136 |
+
'object' => __("Image Object",'acf'),
|
137 |
+
'url' => __("Image URL",'acf'),
|
138 |
+
'id' => __("Image ID",'acf')
|
139 |
+
)
|
140 |
+
));
|
141 |
+
?>
|
142 |
+
</td>
|
143 |
+
</tr>
|
144 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
145 |
+
<td class="label">
|
146 |
+
<label><?php _e("Preview Size",'acf'); ?></label>
|
147 |
+
<p><?php _e("Shown when entering data",'acf') ?></p>
|
148 |
+
</td>
|
149 |
+
<td>
|
150 |
+
<?php
|
151 |
+
|
152 |
+
do_action('acf/create_field', array(
|
153 |
+
'type' => 'radio',
|
154 |
+
'name' => 'fields['.$key.'][preview_size]',
|
155 |
+
'value' => $field['preview_size'],
|
156 |
+
'layout' => 'horizontal',
|
157 |
+
'choices' => apply_filters('acf/get_image_sizes', array())
|
158 |
+
));
|
159 |
+
|
160 |
+
?>
|
161 |
+
</td>
|
162 |
+
</tr>
|
163 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
164 |
+
<td class="label">
|
165 |
+
<label><?php _e("Library",'acf'); ?></label>
|
166 |
+
<p><?php _e("Limit the media library choice",'acf') ?></p>
|
167 |
+
</td>
|
168 |
+
<td>
|
169 |
+
<?php
|
170 |
+
|
171 |
+
do_action('acf/create_field', array(
|
172 |
+
'type' => 'radio',
|
173 |
+
'name' => 'fields['.$key.'][library]',
|
174 |
+
'value' => $field['library'],
|
175 |
+
'layout' => 'horizontal',
|
176 |
+
'choices' => array(
|
177 |
+
'all' => __('All', 'acf'),
|
178 |
+
'uploadedTo' => __('Uploaded to post', 'acf')
|
179 |
+
)
|
180 |
+
));
|
181 |
+
|
182 |
+
?>
|
183 |
+
</td>
|
184 |
+
</tr>
|
185 |
+
<?php
|
186 |
+
|
187 |
+
}
|
188 |
+
|
189 |
+
|
190 |
+
/*
|
191 |
+
* format_value_for_api()
|
192 |
+
*
|
193 |
+
* This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
|
194 |
+
*
|
195 |
+
* @type filter
|
196 |
+
* @since 3.6
|
197 |
+
* @date 23/01/13
|
198 |
+
*
|
199 |
+
* @param $value - the value which was loaded from the database
|
200 |
+
* @param $post_id - the $post_id from which the value was loaded
|
201 |
+
* @param $field - the field array holding all the field options
|
202 |
+
*
|
203 |
+
* @return $value - the modified value
|
204 |
+
*/
|
205 |
+
|
206 |
+
function format_value_for_api( $value, $post_id, $field )
|
207 |
+
{
|
208 |
+
|
209 |
+
// validate
|
210 |
+
if( !$value )
|
211 |
+
{
|
212 |
+
return false;
|
213 |
+
}
|
214 |
+
|
215 |
+
|
216 |
+
// format
|
217 |
+
if( $field['save_format'] == 'url' )
|
218 |
+
{
|
219 |
+
$value = wp_get_attachment_url( $value );
|
220 |
+
}
|
221 |
+
elseif( $field['save_format'] == 'object' )
|
222 |
+
{
|
223 |
+
$attachment = get_post( $value );
|
224 |
+
|
225 |
+
|
226 |
+
// validate
|
227 |
+
if( !$attachment )
|
228 |
+
{
|
229 |
+
return false;
|
230 |
+
}
|
231 |
+
|
232 |
+
|
233 |
+
// create array to hold value data
|
234 |
+
$src = wp_get_attachment_image_src( $attachment->ID, 'full' );
|
235 |
+
|
236 |
+
$value = array(
|
237 |
+
'id' => $attachment->ID,
|
238 |
+
'alt' => get_post_meta($attachment->ID, '_wp_attachment_image_alt', true),
|
239 |
+
'title' => $attachment->post_title,
|
240 |
+
'caption' => $attachment->post_excerpt,
|
241 |
+
'description' => $attachment->post_content,
|
242 |
+
'mime_type' => $attachment->post_mime_type,
|
243 |
+
'url' => $src[0],
|
244 |
+
'width' => $src[1],
|
245 |
+
'height' => $src[2],
|
246 |
+
'sizes' => array(),
|
247 |
+
);
|
248 |
+
|
249 |
+
|
250 |
+
// find all image sizes
|
251 |
+
$image_sizes = get_intermediate_image_sizes();
|
252 |
+
|
253 |
+
if( $image_sizes )
|
254 |
+
{
|
255 |
+
foreach( $image_sizes as $image_size )
|
256 |
+
{
|
257 |
+
// find src
|
258 |
+
$src = wp_get_attachment_image_src( $attachment->ID, $image_size );
|
259 |
+
|
260 |
+
// add src
|
261 |
+
$value[ 'sizes' ][ $image_size ] = $src[0];
|
262 |
+
$value[ 'sizes' ][ $image_size . '-width' ] = $src[1];
|
263 |
+
$value[ 'sizes' ][ $image_size . '-height' ] = $src[2];
|
264 |
+
}
|
265 |
+
// foreach( $image_sizes as $image_size )
|
266 |
+
}
|
267 |
+
// if( $image_sizes )
|
268 |
+
|
269 |
+
}
|
270 |
+
|
271 |
+
return $value;
|
272 |
+
|
273 |
+
}
|
274 |
+
|
275 |
+
|
276 |
+
/*
|
277 |
+
* get_media_item_args
|
278 |
+
*
|
279 |
+
* @description:
|
280 |
+
* @since: 3.6
|
281 |
+
* @created: 27/01/13
|
282 |
+
*/
|
283 |
+
|
284 |
+
function get_media_item_args( $vars )
|
285 |
+
{
|
286 |
+
$vars['send'] = true;
|
287 |
+
return($vars);
|
288 |
+
}
|
289 |
+
|
290 |
+
|
291 |
+
/*
|
292 |
+
* ajax_get_images
|
293 |
+
*
|
294 |
+
* @description:
|
295 |
+
* @since: 3.5.7
|
296 |
+
* @created: 13/01/13
|
297 |
+
*/
|
298 |
+
|
299 |
+
function ajax_get_images()
|
300 |
+
{
|
301 |
+
// vars
|
302 |
+
$options = array(
|
303 |
+
'nonce' => '',
|
304 |
+
'images' => array(),
|
305 |
+
'preview_size' => 'thumbnail'
|
306 |
+
);
|
307 |
+
$return = array();
|
308 |
+
|
309 |
+
|
310 |
+
// load post options
|
311 |
+
$options = array_merge($options, $_POST);
|
312 |
+
|
313 |
+
|
314 |
+
// verify nonce
|
315 |
+
if( ! wp_verify_nonce($options['nonce'], 'acf_nonce') )
|
316 |
+
{
|
317 |
+
die(0);
|
318 |
+
}
|
319 |
+
|
320 |
+
|
321 |
+
if( $options['images'] )
|
322 |
+
{
|
323 |
+
foreach( $options['images'] as $id )
|
324 |
+
{
|
325 |
+
$url = wp_get_attachment_image_src( $id, $options['preview_size'] );
|
326 |
+
|
327 |
+
|
328 |
+
$return[] = array(
|
329 |
+
'id' => $id,
|
330 |
+
'url' => $url[0],
|
331 |
+
);
|
332 |
+
}
|
333 |
+
}
|
334 |
+
|
335 |
+
|
336 |
+
// return json
|
337 |
+
echo json_encode( $return );
|
338 |
+
die;
|
339 |
+
|
340 |
+
}
|
341 |
+
|
342 |
+
|
343 |
+
/*
|
344 |
+
* image_size_names_choose
|
345 |
+
*
|
346 |
+
* @description:
|
347 |
+
* @since: 3.5.7
|
348 |
+
* @created: 13/01/13
|
349 |
+
*/
|
350 |
+
|
351 |
+
function image_size_names_choose( $sizes )
|
352 |
+
{
|
353 |
+
global $_wp_additional_image_sizes;
|
354 |
+
|
355 |
+
if( $_wp_additional_image_sizes )
|
356 |
+
{
|
357 |
+
foreach( $_wp_additional_image_sizes as $k => $v )
|
358 |
+
{
|
359 |
+
$title = $k;
|
360 |
+
$title = str_replace('-', ' ', $title);
|
361 |
+
$title = str_replace('_', ' ', $title);
|
362 |
+
$title = ucwords( $title );
|
363 |
+
|
364 |
+
$sizes[ $k ] = $title;
|
365 |
+
}
|
366 |
+
// foreach( $image_sizes as $image_size )
|
367 |
+
}
|
368 |
+
|
369 |
+
return $sizes;
|
370 |
+
}
|
371 |
+
|
372 |
+
|
373 |
+
/*
|
374 |
+
* wp_prepare_attachment_for_js
|
375 |
+
*
|
376 |
+
* @description: This sneaky hook adds the missing sizes to each attachment in the 3.5 uploader. It would be a lot easier to add all the sizes to the 'image_size_names_choose' filter but then it will show up on the normal the_content editor
|
377 |
+
* @since: 3.5.7
|
378 |
+
* @created: 13/01/13
|
379 |
+
*/
|
380 |
+
|
381 |
+
function wp_prepare_attachment_for_js( $response, $attachment, $meta )
|
382 |
+
{
|
383 |
+
// only for image
|
384 |
+
if( $response['type'] != 'image' )
|
385 |
+
{
|
386 |
+
return $response;
|
387 |
+
}
|
388 |
+
|
389 |
+
|
390 |
+
// make sure sizes exist. Perhaps they dont?
|
391 |
+
if( !isset($meta['sizes']) )
|
392 |
+
{
|
393 |
+
return $response;
|
394 |
+
}
|
395 |
+
|
396 |
+
|
397 |
+
$attachment_url = $response['url'];
|
398 |
+
$base_url = str_replace( wp_basename( $attachment_url ), '', $attachment_url );
|
399 |
+
|
400 |
+
if( isset($meta['sizes']) && is_array($meta['sizes']) )
|
401 |
+
{
|
402 |
+
foreach( $meta['sizes'] as $k => $v )
|
403 |
+
{
|
404 |
+
if( !isset($response['sizes'][ $k ]) )
|
405 |
+
{
|
406 |
+
$response['sizes'][ $k ] = array(
|
407 |
+
'height' => $v['height'],
|
408 |
+
'width' => $v['width'],
|
409 |
+
'url' => $base_url . $v['file'],
|
410 |
+
'orientation' => $v['height'] > $v['width'] ? 'portrait' : 'landscape',
|
411 |
+
);
|
412 |
+
}
|
413 |
+
}
|
414 |
+
}
|
415 |
+
|
416 |
+
return $response;
|
417 |
+
}
|
418 |
+
|
419 |
+
|
420 |
+
/*
|
421 |
+
* update_value()
|
422 |
+
*
|
423 |
+
* This filter is appied to the $value before it is updated in the db
|
424 |
+
*
|
425 |
+
* @type filter
|
426 |
+
* @since 3.6
|
427 |
+
* @date 23/01/13
|
428 |
+
*
|
429 |
+
* @param $value - the value which will be saved in the database
|
430 |
+
* @param $post_id - the $post_id of which the value will be saved
|
431 |
+
* @param $field - the field array holding all the field options
|
432 |
+
*
|
433 |
+
* @return $value - the modified value
|
434 |
+
*/
|
435 |
+
|
436 |
+
function update_value( $value, $post_id, $field )
|
437 |
+
{
|
438 |
+
// array?
|
439 |
+
if( is_array($value) && isset($value['id']) )
|
440 |
+
{
|
441 |
+
$value = $value['id'];
|
442 |
+
}
|
443 |
+
|
444 |
+
// object?
|
445 |
+
if( is_object($value) && isset($value->ID) )
|
446 |
+
{
|
447 |
+
$value = $value->ID;
|
448 |
+
}
|
449 |
+
|
450 |
+
return $value;
|
451 |
+
}
|
452 |
+
|
453 |
+
|
454 |
+
}
|
455 |
+
|
456 |
+
new acf_field_image();
|
457 |
+
|
458 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/fields/message.php
CHANGED
@@ -1,93 +1,93 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_field_message extends acf_field
|
4 |
-
{
|
5 |
-
|
6 |
-
/*
|
7 |
-
* __construct
|
8 |
-
*
|
9 |
-
* Set name / label needed for actions / filters
|
10 |
-
*
|
11 |
-
* @since 3.6
|
12 |
-
* @date 23/01/13
|
13 |
-
*/
|
14 |
-
|
15 |
-
function __construct()
|
16 |
-
{
|
17 |
-
// vars
|
18 |
-
$this->name = 'message';
|
19 |
-
$this->label = __("Message",'acf');
|
20 |
-
$this->category = __("Layout",'acf');
|
21 |
-
$this->defaults = array(
|
22 |
-
'message' => '',
|
23 |
-
);
|
24 |
-
|
25 |
-
|
26 |
-
// do not delete!
|
27 |
-
parent::__construct();
|
28 |
-
}
|
29 |
-
|
30 |
-
|
31 |
-
/*
|
32 |
-
* create_field()
|
33 |
-
*
|
34 |
-
* Create the HTML interface for your field
|
35 |
-
*
|
36 |
-
* @param $field - an array holding all the field's data
|
37 |
-
*
|
38 |
-
* @type action
|
39 |
-
* @since 3.6
|
40 |
-
* @date 23/01/13
|
41 |
-
*/
|
42 |
-
|
43 |
-
function create_field( $field )
|
44 |
-
{
|
45 |
-
echo wpautop( $field['message'] );
|
46 |
-
}
|
47 |
-
|
48 |
-
|
49 |
-
/*
|
50 |
-
* create_options()
|
51 |
-
*
|
52 |
-
* Create extra options for your field. This is rendered when editing a field.
|
53 |
-
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
54 |
-
*
|
55 |
-
* @param $field - an array holding all the field's data
|
56 |
-
*
|
57 |
-
* @type action
|
58 |
-
* @since 3.6
|
59 |
-
* @date 23/01/13
|
60 |
-
*/
|
61 |
-
|
62 |
-
function create_options( $field )
|
63 |
-
{
|
64 |
-
// vars
|
65 |
-
$key = $field['name'];
|
66 |
-
|
67 |
-
?>
|
68 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
69 |
-
<td class="label">
|
70 |
-
<label for=""><?php _e("Message",'acf'); ?></label>
|
71 |
-
<p class="description"><?php _e("Text & HTML entered here will appear inline with the fields",'acf'); ?><br /><br />
|
72 |
-
<?php _e("Please note that all text will first be passed through the wp function ",'acf'); ?><a href="http://codex.wordpress.org/Function_Reference/wpautop" target="_blank">wpautop</a></p>
|
73 |
-
</td>
|
74 |
-
<td>
|
75 |
-
<?php
|
76 |
-
do_action('acf/create_field', array(
|
77 |
-
'type' => 'textarea',
|
78 |
-
'class' => 'textarea',
|
79 |
-
'name' => 'fields['.$key.'][message]',
|
80 |
-
'value' => $field['message'],
|
81 |
-
));
|
82 |
-
?>
|
83 |
-
</td>
|
84 |
-
</tr>
|
85 |
-
<?php
|
86 |
-
|
87 |
-
}
|
88 |
-
|
89 |
-
}
|
90 |
-
|
91 |
-
new acf_field_message();
|
92 |
-
|
93 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class acf_field_message extends acf_field
|
4 |
+
{
|
5 |
+
|
6 |
+
/*
|
7 |
+
* __construct
|
8 |
+
*
|
9 |
+
* Set name / label needed for actions / filters
|
10 |
+
*
|
11 |
+
* @since 3.6
|
12 |
+
* @date 23/01/13
|
13 |
+
*/
|
14 |
+
|
15 |
+
function __construct()
|
16 |
+
{
|
17 |
+
// vars
|
18 |
+
$this->name = 'message';
|
19 |
+
$this->label = __("Message",'acf');
|
20 |
+
$this->category = __("Layout",'acf');
|
21 |
+
$this->defaults = array(
|
22 |
+
'message' => '',
|
23 |
+
);
|
24 |
+
|
25 |
+
|
26 |
+
// do not delete!
|
27 |
+
parent::__construct();
|
28 |
+
}
|
29 |
+
|
30 |
+
|
31 |
+
/*
|
32 |
+
* create_field()
|
33 |
+
*
|
34 |
+
* Create the HTML interface for your field
|
35 |
+
*
|
36 |
+
* @param $field - an array holding all the field's data
|
37 |
+
*
|
38 |
+
* @type action
|
39 |
+
* @since 3.6
|
40 |
+
* @date 23/01/13
|
41 |
+
*/
|
42 |
+
|
43 |
+
function create_field( $field )
|
44 |
+
{
|
45 |
+
echo wpautop( $field['message'] );
|
46 |
+
}
|
47 |
+
|
48 |
+
|
49 |
+
/*
|
50 |
+
* create_options()
|
51 |
+
*
|
52 |
+
* Create extra options for your field. This is rendered when editing a field.
|
53 |
+
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
54 |
+
*
|
55 |
+
* @param $field - an array holding all the field's data
|
56 |
+
*
|
57 |
+
* @type action
|
58 |
+
* @since 3.6
|
59 |
+
* @date 23/01/13
|
60 |
+
*/
|
61 |
+
|
62 |
+
function create_options( $field )
|
63 |
+
{
|
64 |
+
// vars
|
65 |
+
$key = $field['name'];
|
66 |
+
|
67 |
+
?>
|
68 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
69 |
+
<td class="label">
|
70 |
+
<label for=""><?php _e("Message",'acf'); ?></label>
|
71 |
+
<p class="description"><?php _e("Text & HTML entered here will appear inline with the fields",'acf'); ?><br /><br />
|
72 |
+
<?php _e("Please note that all text will first be passed through the wp function ",'acf'); ?><a href="http://codex.wordpress.org/Function_Reference/wpautop" target="_blank">wpautop</a></p>
|
73 |
+
</td>
|
74 |
+
<td>
|
75 |
+
<?php
|
76 |
+
do_action('acf/create_field', array(
|
77 |
+
'type' => 'textarea',
|
78 |
+
'class' => 'textarea',
|
79 |
+
'name' => 'fields['.$key.'][message]',
|
80 |
+
'value' => $field['message'],
|
81 |
+
));
|
82 |
+
?>
|
83 |
+
</td>
|
84 |
+
</tr>
|
85 |
+
<?php
|
86 |
+
|
87 |
+
}
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
new acf_field_message();
|
92 |
+
|
93 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/fields/number.php
CHANGED
@@ -1,274 +1,274 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_field_number extends acf_field
|
4 |
-
{
|
5 |
-
|
6 |
-
/*
|
7 |
-
* __construct
|
8 |
-
*
|
9 |
-
* Set name / label needed for actions / filters
|
10 |
-
*
|
11 |
-
* @since 3.6
|
12 |
-
* @date 23/01/13
|
13 |
-
*/
|
14 |
-
|
15 |
-
function __construct()
|
16 |
-
{
|
17 |
-
// vars
|
18 |
-
$this->name = 'number';
|
19 |
-
$this->label = __("Number",'acf');
|
20 |
-
$this->defaults = array(
|
21 |
-
'default_value' => '',
|
22 |
-
'min' => '',
|
23 |
-
'max' => '',
|
24 |
-
'step' => '',
|
25 |
-
'placeholder' => '',
|
26 |
-
'prepend' => '',
|
27 |
-
'append' => ''
|
28 |
-
);
|
29 |
-
|
30 |
-
|
31 |
-
// do not delete!
|
32 |
-
parent::__construct();
|
33 |
-
}
|
34 |
-
|
35 |
-
|
36 |
-
/*
|
37 |
-
* create_field()
|
38 |
-
*
|
39 |
-
* Create the HTML interface for your field
|
40 |
-
*
|
41 |
-
* @param $field - an array holding all the field's data
|
42 |
-
*
|
43 |
-
* @type action
|
44 |
-
* @since 3.6
|
45 |
-
* @date 23/01/13
|
46 |
-
*/
|
47 |
-
|
48 |
-
function create_field( $field )
|
49 |
-
{
|
50 |
-
// vars
|
51 |
-
$o = array( 'id', 'class', 'min', 'max', 'step', 'name', 'value', 'placeholder' );
|
52 |
-
$e = '';
|
53 |
-
|
54 |
-
|
55 |
-
// step
|
56 |
-
if( !$field['step'] )
|
57 |
-
{
|
58 |
-
$field['step'] = 'any';
|
59 |
-
}
|
60 |
-
|
61 |
-
// prepend
|
62 |
-
if( $field['prepend'] !== "" )
|
63 |
-
{
|
64 |
-
$field['class'] .= ' acf-is-prepended';
|
65 |
-
$e .= '<div class="acf-input-prepend">' . $field['prepend'] . '</div>';
|
66 |
-
}
|
67 |
-
|
68 |
-
|
69 |
-
// append
|
70 |
-
if( $field['append'] !== "" )
|
71 |
-
{
|
72 |
-
$field['class'] .= ' acf-is-appended';
|
73 |
-
$e .= '<div class="acf-input-append">' . $field['append'] . '</div>';
|
74 |
-
}
|
75 |
-
|
76 |
-
|
77 |
-
$e .= '<div class="acf-input-wrap">';
|
78 |
-
$e .= '<input type="number"';
|
79 |
-
|
80 |
-
foreach( $o as $k )
|
81 |
-
{
|
82 |
-
$e .= ' ' . $k . '="' . esc_attr( $field[ $k ] ) . '"';
|
83 |
-
}
|
84 |
-
|
85 |
-
$e .= ' />';
|
86 |
-
$e .= '</div>';
|
87 |
-
|
88 |
-
|
89 |
-
// return
|
90 |
-
echo $e;
|
91 |
-
|
92 |
-
}
|
93 |
-
|
94 |
-
|
95 |
-
/*
|
96 |
-
* create_options()
|
97 |
-
*
|
98 |
-
* Create extra options for your field. This is rendered when editing a field.
|
99 |
-
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
100 |
-
*
|
101 |
-
* @type action
|
102 |
-
* @since 3.6
|
103 |
-
* @date 23/01/13
|
104 |
-
*
|
105 |
-
* @param $field - an array holding all the field's data
|
106 |
-
*/
|
107 |
-
|
108 |
-
function create_options( $field )
|
109 |
-
{
|
110 |
-
// vars
|
111 |
-
$key = $field['name'];
|
112 |
-
|
113 |
-
?>
|
114 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
115 |
-
<td class="label">
|
116 |
-
<label><?php _e("Default Value",'acf'); ?></label>
|
117 |
-
<p><?php _e("Appears when creating a new post",'acf') ?></p>
|
118 |
-
</td>
|
119 |
-
<td>
|
120 |
-
<?php
|
121 |
-
|
122 |
-
do_action('acf/create_field', array(
|
123 |
-
'type' => 'number',
|
124 |
-
'name' => 'fields['.$key.'][default_value]',
|
125 |
-
'value' => $field['default_value'],
|
126 |
-
));
|
127 |
-
|
128 |
-
?>
|
129 |
-
</td>
|
130 |
-
</tr>
|
131 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
132 |
-
<td class="label">
|
133 |
-
<label><?php _e("Placeholder Text",'acf'); ?></label>
|
134 |
-
<p><?php _e("Appears within the input",'acf') ?></p>
|
135 |
-
</td>
|
136 |
-
<td>
|
137 |
-
<?php
|
138 |
-
do_action('acf/create_field', array(
|
139 |
-
'type' => 'text',
|
140 |
-
'name' => 'fields[' .$key.'][placeholder]',
|
141 |
-
'value' => $field['placeholder'],
|
142 |
-
));
|
143 |
-
?>
|
144 |
-
</td>
|
145 |
-
</tr>
|
146 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
147 |
-
<td class="label">
|
148 |
-
<label><?php _e("Prepend",'acf'); ?></label>
|
149 |
-
<p><?php _e("Appears before the input",'acf') ?></p>
|
150 |
-
</td>
|
151 |
-
<td>
|
152 |
-
<?php
|
153 |
-
do_action('acf/create_field', array(
|
154 |
-
'type' => 'text',
|
155 |
-
'name' => 'fields[' .$key.'][prepend]',
|
156 |
-
'value' => $field['prepend'],
|
157 |
-
));
|
158 |
-
?>
|
159 |
-
</td>
|
160 |
-
</tr>
|
161 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
162 |
-
<td class="label">
|
163 |
-
<label><?php _e("Append",'acf'); ?></label>
|
164 |
-
<p><?php _e("Appears after the input",'acf') ?></p>
|
165 |
-
</td>
|
166 |
-
<td>
|
167 |
-
<?php
|
168 |
-
do_action('acf/create_field', array(
|
169 |
-
'type' => 'text',
|
170 |
-
'name' => 'fields[' .$key.'][append]',
|
171 |
-
'value' => $field['append'],
|
172 |
-
));
|
173 |
-
?>
|
174 |
-
</td>
|
175 |
-
</tr>
|
176 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
177 |
-
<td class="label">
|
178 |
-
<label><?php _e("Minimum Value",'acf'); ?></label>
|
179 |
-
</td>
|
180 |
-
<td>
|
181 |
-
<?php
|
182 |
-
|
183 |
-
do_action('acf/create_field', array(
|
184 |
-
'type' => 'number',
|
185 |
-
'name' => 'fields['.$key.'][min]',
|
186 |
-
'value' => $field['min'],
|
187 |
-
));
|
188 |
-
|
189 |
-
?>
|
190 |
-
</td>
|
191 |
-
</tr>
|
192 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
193 |
-
<td class="label">
|
194 |
-
<label><?php _e("Maximum Value",'acf'); ?></label>
|
195 |
-
</td>
|
196 |
-
<td>
|
197 |
-
<?php
|
198 |
-
|
199 |
-
do_action('acf/create_field', array(
|
200 |
-
'type' => 'number',
|
201 |
-
'name' => 'fields['.$key.'][max]',
|
202 |
-
'value' => $field['max'],
|
203 |
-
));
|
204 |
-
|
205 |
-
?>
|
206 |
-
</td>
|
207 |
-
</tr>
|
208 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
209 |
-
<td class="label">
|
210 |
-
<label><?php _e("Step Size",'acf'); ?></label>
|
211 |
-
</td>
|
212 |
-
<td>
|
213 |
-
<?php
|
214 |
-
|
215 |
-
do_action('acf/create_field', array(
|
216 |
-
'type' => 'number',
|
217 |
-
'name' => 'fields['.$key.'][step]',
|
218 |
-
'value' => $field['step'],
|
219 |
-
));
|
220 |
-
|
221 |
-
?>
|
222 |
-
</td>
|
223 |
-
</tr>
|
224 |
-
<?php
|
225 |
-
}
|
226 |
-
|
227 |
-
|
228 |
-
/*
|
229 |
-
* update_value()
|
230 |
-
*
|
231 |
-
* This filter is appied to the $value before it is updated in the db
|
232 |
-
*
|
233 |
-
* @type filter
|
234 |
-
* @since 3.6
|
235 |
-
* @date 23/01/13
|
236 |
-
*
|
237 |
-
* @param $value - the value which will be saved in the database
|
238 |
-
* @param $field - the field array holding all the field options
|
239 |
-
* @param $post_id - the $post_id of which the value will be saved
|
240 |
-
*
|
241 |
-
* @return $value - the modified value
|
242 |
-
*/
|
243 |
-
|
244 |
-
function update_value( $value, $post_id, $field )
|
245 |
-
{
|
246 |
-
// no formatting needed for empty value
|
247 |
-
if( empty($value) ) {
|
248 |
-
|
249 |
-
return $value;
|
250 |
-
|
251 |
-
}
|
252 |
-
|
253 |
-
|
254 |
-
// remove ','
|
255 |
-
$value = str_replace(',', '', $value);
|
256 |
-
|
257 |
-
|
258 |
-
// convert to float. This removes any chars
|
259 |
-
$value = floatval( $value );
|
260 |
-
|
261 |
-
|
262 |
-
// convert back to string. This alows decimals to save
|
263 |
-
$value = (string) $value;
|
264 |
-
|
265 |
-
|
266 |
-
return $value;
|
267 |
-
}
|
268 |
-
|
269 |
-
|
270 |
-
}
|
271 |
-
|
272 |
-
new acf_field_number();
|
273 |
-
|
274 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class acf_field_number extends acf_field
|
4 |
+
{
|
5 |
+
|
6 |
+
/*
|
7 |
+
* __construct
|
8 |
+
*
|
9 |
+
* Set name / label needed for actions / filters
|
10 |
+
*
|
11 |
+
* @since 3.6
|
12 |
+
* @date 23/01/13
|
13 |
+
*/
|
14 |
+
|
15 |
+
function __construct()
|
16 |
+
{
|
17 |
+
// vars
|
18 |
+
$this->name = 'number';
|
19 |
+
$this->label = __("Number",'acf');
|
20 |
+
$this->defaults = array(
|
21 |
+
'default_value' => '',
|
22 |
+
'min' => '',
|
23 |
+
'max' => '',
|
24 |
+
'step' => '',
|
25 |
+
'placeholder' => '',
|
26 |
+
'prepend' => '',
|
27 |
+
'append' => ''
|
28 |
+
);
|
29 |
+
|
30 |
+
|
31 |
+
// do not delete!
|
32 |
+
parent::__construct();
|
33 |
+
}
|
34 |
+
|
35 |
+
|
36 |
+
/*
|
37 |
+
* create_field()
|
38 |
+
*
|
39 |
+
* Create the HTML interface for your field
|
40 |
+
*
|
41 |
+
* @param $field - an array holding all the field's data
|
42 |
+
*
|
43 |
+
* @type action
|
44 |
+
* @since 3.6
|
45 |
+
* @date 23/01/13
|
46 |
+
*/
|
47 |
+
|
48 |
+
function create_field( $field )
|
49 |
+
{
|
50 |
+
// vars
|
51 |
+
$o = array( 'id', 'class', 'min', 'max', 'step', 'name', 'value', 'placeholder' );
|
52 |
+
$e = '';
|
53 |
+
|
54 |
+
|
55 |
+
// step
|
56 |
+
if( !$field['step'] )
|
57 |
+
{
|
58 |
+
$field['step'] = 'any';
|
59 |
+
}
|
60 |
+
|
61 |
+
// prepend
|
62 |
+
if( $field['prepend'] !== "" )
|
63 |
+
{
|
64 |
+
$field['class'] .= ' acf-is-prepended';
|
65 |
+
$e .= '<div class="acf-input-prepend">' . $field['prepend'] . '</div>';
|
66 |
+
}
|
67 |
+
|
68 |
+
|
69 |
+
// append
|
70 |
+
if( $field['append'] !== "" )
|
71 |
+
{
|
72 |
+
$field['class'] .= ' acf-is-appended';
|
73 |
+
$e .= '<div class="acf-input-append">' . $field['append'] . '</div>';
|
74 |
+
}
|
75 |
+
|
76 |
+
|
77 |
+
$e .= '<div class="acf-input-wrap">';
|
78 |
+
$e .= '<input type="number"';
|
79 |
+
|
80 |
+
foreach( $o as $k )
|
81 |
+
{
|
82 |
+
$e .= ' ' . $k . '="' . esc_attr( $field[ $k ] ) . '"';
|
83 |
+
}
|
84 |
+
|
85 |
+
$e .= ' />';
|
86 |
+
$e .= '</div>';
|
87 |
+
|
88 |
+
|
89 |
+
// return
|
90 |
+
echo $e;
|
91 |
+
|
92 |
+
}
|
93 |
+
|
94 |
+
|
95 |
+
/*
|
96 |
+
* create_options()
|
97 |
+
*
|
98 |
+
* Create extra options for your field. This is rendered when editing a field.
|
99 |
+
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
100 |
+
*
|
101 |
+
* @type action
|
102 |
+
* @since 3.6
|
103 |
+
* @date 23/01/13
|
104 |
+
*
|
105 |
+
* @param $field - an array holding all the field's data
|
106 |
+
*/
|
107 |
+
|
108 |
+
function create_options( $field )
|
109 |
+
{
|
110 |
+
// vars
|
111 |
+
$key = $field['name'];
|
112 |
+
|
113 |
+
?>
|
114 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
115 |
+
<td class="label">
|
116 |
+
<label><?php _e("Default Value",'acf'); ?></label>
|
117 |
+
<p><?php _e("Appears when creating a new post",'acf') ?></p>
|
118 |
+
</td>
|
119 |
+
<td>
|
120 |
+
<?php
|
121 |
+
|
122 |
+
do_action('acf/create_field', array(
|
123 |
+
'type' => 'number',
|
124 |
+
'name' => 'fields['.$key.'][default_value]',
|
125 |
+
'value' => $field['default_value'],
|
126 |
+
));
|
127 |
+
|
128 |
+
?>
|
129 |
+
</td>
|
130 |
+
</tr>
|
131 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
132 |
+
<td class="label">
|
133 |
+
<label><?php _e("Placeholder Text",'acf'); ?></label>
|
134 |
+
<p><?php _e("Appears within the input",'acf') ?></p>
|
135 |
+
</td>
|
136 |
+
<td>
|
137 |
+
<?php
|
138 |
+
do_action('acf/create_field', array(
|
139 |
+
'type' => 'text',
|
140 |
+
'name' => 'fields[' .$key.'][placeholder]',
|
141 |
+
'value' => $field['placeholder'],
|
142 |
+
));
|
143 |
+
?>
|
144 |
+
</td>
|
145 |
+
</tr>
|
146 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
147 |
+
<td class="label">
|
148 |
+
<label><?php _e("Prepend",'acf'); ?></label>
|
149 |
+
<p><?php _e("Appears before the input",'acf') ?></p>
|
150 |
+
</td>
|
151 |
+
<td>
|
152 |
+
<?php
|
153 |
+
do_action('acf/create_field', array(
|
154 |
+
'type' => 'text',
|
155 |
+
'name' => 'fields[' .$key.'][prepend]',
|
156 |
+
'value' => $field['prepend'],
|
157 |
+
));
|
158 |
+
?>
|
159 |
+
</td>
|
160 |
+
</tr>
|
161 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
162 |
+
<td class="label">
|
163 |
+
<label><?php _e("Append",'acf'); ?></label>
|
164 |
+
<p><?php _e("Appears after the input",'acf') ?></p>
|
165 |
+
</td>
|
166 |
+
<td>
|
167 |
+
<?php
|
168 |
+
do_action('acf/create_field', array(
|
169 |
+
'type' => 'text',
|
170 |
+
'name' => 'fields[' .$key.'][append]',
|
171 |
+
'value' => $field['append'],
|
172 |
+
));
|
173 |
+
?>
|
174 |
+
</td>
|
175 |
+
</tr>
|
176 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
177 |
+
<td class="label">
|
178 |
+
<label><?php _e("Minimum Value",'acf'); ?></label>
|
179 |
+
</td>
|
180 |
+
<td>
|
181 |
+
<?php
|
182 |
+
|
183 |
+
do_action('acf/create_field', array(
|
184 |
+
'type' => 'number',
|
185 |
+
'name' => 'fields['.$key.'][min]',
|
186 |
+
'value' => $field['min'],
|
187 |
+
));
|
188 |
+
|
189 |
+
?>
|
190 |
+
</td>
|
191 |
+
</tr>
|
192 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
193 |
+
<td class="label">
|
194 |
+
<label><?php _e("Maximum Value",'acf'); ?></label>
|
195 |
+
</td>
|
196 |
+
<td>
|
197 |
+
<?php
|
198 |
+
|
199 |
+
do_action('acf/create_field', array(
|
200 |
+
'type' => 'number',
|
201 |
+
'name' => 'fields['.$key.'][max]',
|
202 |
+
'value' => $field['max'],
|
203 |
+
));
|
204 |
+
|
205 |
+
?>
|
206 |
+
</td>
|
207 |
+
</tr>
|
208 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
209 |
+
<td class="label">
|
210 |
+
<label><?php _e("Step Size",'acf'); ?></label>
|
211 |
+
</td>
|
212 |
+
<td>
|
213 |
+
<?php
|
214 |
+
|
215 |
+
do_action('acf/create_field', array(
|
216 |
+
'type' => 'number',
|
217 |
+
'name' => 'fields['.$key.'][step]',
|
218 |
+
'value' => $field['step'],
|
219 |
+
));
|
220 |
+
|
221 |
+
?>
|
222 |
+
</td>
|
223 |
+
</tr>
|
224 |
+
<?php
|
225 |
+
}
|
226 |
+
|
227 |
+
|
228 |
+
/*
|
229 |
+
* update_value()
|
230 |
+
*
|
231 |
+
* This filter is appied to the $value before it is updated in the db
|
232 |
+
*
|
233 |
+
* @type filter
|
234 |
+
* @since 3.6
|
235 |
+
* @date 23/01/13
|
236 |
+
*
|
237 |
+
* @param $value - the value which will be saved in the database
|
238 |
+
* @param $field - the field array holding all the field options
|
239 |
+
* @param $post_id - the $post_id of which the value will be saved
|
240 |
+
*
|
241 |
+
* @return $value - the modified value
|
242 |
+
*/
|
243 |
+
|
244 |
+
function update_value( $value, $post_id, $field )
|
245 |
+
{
|
246 |
+
// no formatting needed for empty value
|
247 |
+
if( empty($value) ) {
|
248 |
+
|
249 |
+
return $value;
|
250 |
+
|
251 |
+
}
|
252 |
+
|
253 |
+
|
254 |
+
// remove ','
|
255 |
+
$value = str_replace(',', '', $value);
|
256 |
+
|
257 |
+
|
258 |
+
// convert to float. This removes any chars
|
259 |
+
$value = floatval( $value );
|
260 |
+
|
261 |
+
|
262 |
+
// convert back to string. This alows decimals to save
|
263 |
+
$value = (string) $value;
|
264 |
+
|
265 |
+
|
266 |
+
return $value;
|
267 |
+
}
|
268 |
+
|
269 |
+
|
270 |
+
}
|
271 |
+
|
272 |
+
new acf_field_number();
|
273 |
+
|
274 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/fields/page_link.php
CHANGED
@@ -1,219 +1,219 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_field_page_link extends acf_field
|
4 |
-
{
|
5 |
-
/*
|
6 |
-
* __construct
|
7 |
-
*
|
8 |
-
* Set name / label needed for actions / filters
|
9 |
-
*
|
10 |
-
* @since 3.6
|
11 |
-
* @date 23/01/13
|
12 |
-
*/
|
13 |
-
|
14 |
-
function __construct()
|
15 |
-
{
|
16 |
-
// vars
|
17 |
-
$this->name = 'page_link';
|
18 |
-
$this->label = __("Page Link",'acf');
|
19 |
-
$this->category = __("Relational",'acf');
|
20 |
-
$this->defaults = array(
|
21 |
-
'post_type' => array('all'),
|
22 |
-
'multiple' => 0,
|
23 |
-
'allow_null' => 0,
|
24 |
-
);
|
25 |
-
|
26 |
-
|
27 |
-
// do not delete!
|
28 |
-
parent::__construct();
|
29 |
-
|
30 |
-
}
|
31 |
-
|
32 |
-
|
33 |
-
/*
|
34 |
-
* load_field()
|
35 |
-
*
|
36 |
-
* This filter is appied to the $field after it is loaded from the database
|
37 |
-
*
|
38 |
-
* @type filter
|
39 |
-
* @since 3.6
|
40 |
-
* @date 23/01/13
|
41 |
-
*
|
42 |
-
* @param $field - the field array holding all the field options
|
43 |
-
*
|
44 |
-
* @return $field - the field array holding all the field options
|
45 |
-
*/
|
46 |
-
|
47 |
-
function load_field( $field )
|
48 |
-
{
|
49 |
-
|
50 |
-
// validate post_type
|
51 |
-
if( !$field['post_type'] || !is_array($field['post_type']) || in_array('', $field['post_type']) )
|
52 |
-
{
|
53 |
-
$field['post_type'] = array( 'all' );
|
54 |
-
}
|
55 |
-
|
56 |
-
|
57 |
-
// return
|
58 |
-
return $field;
|
59 |
-
}
|
60 |
-
|
61 |
-
|
62 |
-
/*
|
63 |
-
* create_field()
|
64 |
-
*
|
65 |
-
* Create the HTML interface for your field
|
66 |
-
*
|
67 |
-
* @param $field - an array holding all the field's data
|
68 |
-
*
|
69 |
-
* @type action
|
70 |
-
* @since 3.6
|
71 |
-
* @date 23/01/13
|
72 |
-
*/
|
73 |
-
|
74 |
-
function create_field( $field )
|
75 |
-
{
|
76 |
-
// let post_object create the field
|
77 |
-
$field['type'] = 'post_object';
|
78 |
-
|
79 |
-
do_action('acf/create_field', $field );
|
80 |
-
}
|
81 |
-
|
82 |
-
|
83 |
-
/*
|
84 |
-
* create_options()
|
85 |
-
*
|
86 |
-
* Create extra options for your field. This is rendered when editing a field.
|
87 |
-
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
88 |
-
*
|
89 |
-
* @type action
|
90 |
-
* @since 3.6
|
91 |
-
* @date 23/01/13
|
92 |
-
*
|
93 |
-
* @param $field - an array holding all the field's data
|
94 |
-
*/
|
95 |
-
|
96 |
-
function create_options( $field )
|
97 |
-
{
|
98 |
-
$key = $field['name'];
|
99 |
-
|
100 |
-
?>
|
101 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
102 |
-
<td class="label">
|
103 |
-
<label for=""><?php _e("Post Type",'acf'); ?></label>
|
104 |
-
</td>
|
105 |
-
<td>
|
106 |
-
<?php
|
107 |
-
|
108 |
-
$choices = array(
|
109 |
-
'all' => __("All",'acf')
|
110 |
-
);
|
111 |
-
$choices = apply_filters('acf/get_post_types', $choices);
|
112 |
-
|
113 |
-
|
114 |
-
do_action('acf/create_field', array(
|
115 |
-
'type' => 'select',
|
116 |
-
'name' => 'fields['.$key.'][post_type]',
|
117 |
-
'value' => $field['post_type'],
|
118 |
-
'choices' => $choices,
|
119 |
-
'multiple' => 1,
|
120 |
-
));
|
121 |
-
|
122 |
-
?>
|
123 |
-
</td>
|
124 |
-
</tr>
|
125 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
126 |
-
<td class="label">
|
127 |
-
<label><?php _e("Allow Null?",'acf'); ?></label>
|
128 |
-
</td>
|
129 |
-
<td>
|
130 |
-
<?php
|
131 |
-
|
132 |
-
do_action('acf/create_field', array(
|
133 |
-
'type' => 'radio',
|
134 |
-
'name' => 'fields['.$key.'][allow_null]',
|
135 |
-
'value' => $field['allow_null'],
|
136 |
-
'choices' => array(
|
137 |
-
1 => __("Yes",'acf'),
|
138 |
-
0 => __("No",'acf'),
|
139 |
-
),
|
140 |
-
'layout' => 'horizontal',
|
141 |
-
));
|
142 |
-
|
143 |
-
?>
|
144 |
-
</td>
|
145 |
-
</tr>
|
146 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
147 |
-
<td class="label">
|
148 |
-
<label><?php _e("Select multiple values?",'acf'); ?></label>
|
149 |
-
</td>
|
150 |
-
<td>
|
151 |
-
<?php
|
152 |
-
|
153 |
-
do_action('acf/create_field', array(
|
154 |
-
'type' => 'radio',
|
155 |
-
'name' => 'fields['.$key.'][multiple]',
|
156 |
-
'value' => $field['multiple'],
|
157 |
-
'choices' => array(
|
158 |
-
1 => __("Yes",'acf'),
|
159 |
-
0 => __("No",'acf'),
|
160 |
-
),
|
161 |
-
'layout' => 'horizontal',
|
162 |
-
));
|
163 |
-
|
164 |
-
?>
|
165 |
-
</td>
|
166 |
-
</tr>
|
167 |
-
<?php
|
168 |
-
|
169 |
-
}
|
170 |
-
|
171 |
-
|
172 |
-
/*
|
173 |
-
* format_value_for_api()
|
174 |
-
*
|
175 |
-
* This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
|
176 |
-
*
|
177 |
-
* @type filter
|
178 |
-
* @since 3.6
|
179 |
-
* @date 23/01/13
|
180 |
-
*
|
181 |
-
* @param $value - the value which was loaded from the database
|
182 |
-
* @param $post_id - the $post_id from which the value was loaded
|
183 |
-
* @param $field - the field array holding all the field options
|
184 |
-
*
|
185 |
-
* @return $value - the modified value
|
186 |
-
*/
|
187 |
-
|
188 |
-
function format_value_for_api( $value, $post_id, $field )
|
189 |
-
{
|
190 |
-
if( !$value )
|
191 |
-
{
|
192 |
-
return false;
|
193 |
-
}
|
194 |
-
|
195 |
-
if( $value == 'null' )
|
196 |
-
{
|
197 |
-
return false;
|
198 |
-
}
|
199 |
-
|
200 |
-
if( is_array($value) )
|
201 |
-
{
|
202 |
-
foreach( $value as $k => $v )
|
203 |
-
{
|
204 |
-
$value[ $k ] = get_permalink($v);
|
205 |
-
}
|
206 |
-
}
|
207 |
-
else
|
208 |
-
{
|
209 |
-
$value = get_permalink($value);
|
210 |
-
}
|
211 |
-
|
212 |
-
return $value;
|
213 |
-
}
|
214 |
-
|
215 |
-
}
|
216 |
-
|
217 |
-
new acf_field_page_link();
|
218 |
-
|
219 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class acf_field_page_link extends acf_field
|
4 |
+
{
|
5 |
+
/*
|
6 |
+
* __construct
|
7 |
+
*
|
8 |
+
* Set name / label needed for actions / filters
|
9 |
+
*
|
10 |
+
* @since 3.6
|
11 |
+
* @date 23/01/13
|
12 |
+
*/
|
13 |
+
|
14 |
+
function __construct()
|
15 |
+
{
|
16 |
+
// vars
|
17 |
+
$this->name = 'page_link';
|
18 |
+
$this->label = __("Page Link",'acf');
|
19 |
+
$this->category = __("Relational",'acf');
|
20 |
+
$this->defaults = array(
|
21 |
+
'post_type' => array('all'),
|
22 |
+
'multiple' => 0,
|
23 |
+
'allow_null' => 0,
|
24 |
+
);
|
25 |
+
|
26 |
+
|
27 |
+
// do not delete!
|
28 |
+
parent::__construct();
|
29 |
+
|
30 |
+
}
|
31 |
+
|
32 |
+
|
33 |
+
/*
|
34 |
+
* load_field()
|
35 |
+
*
|
36 |
+
* This filter is appied to the $field after it is loaded from the database
|
37 |
+
*
|
38 |
+
* @type filter
|
39 |
+
* @since 3.6
|
40 |
+
* @date 23/01/13
|
41 |
+
*
|
42 |
+
* @param $field - the field array holding all the field options
|
43 |
+
*
|
44 |
+
* @return $field - the field array holding all the field options
|
45 |
+
*/
|
46 |
+
|
47 |
+
function load_field( $field )
|
48 |
+
{
|
49 |
+
|
50 |
+
// validate post_type
|
51 |
+
if( !$field['post_type'] || !is_array($field['post_type']) || in_array('', $field['post_type']) )
|
52 |
+
{
|
53 |
+
$field['post_type'] = array( 'all' );
|
54 |
+
}
|
55 |
+
|
56 |
+
|
57 |
+
// return
|
58 |
+
return $field;
|
59 |
+
}
|
60 |
+
|
61 |
+
|
62 |
+
/*
|
63 |
+
* create_field()
|
64 |
+
*
|
65 |
+
* Create the HTML interface for your field
|
66 |
+
*
|
67 |
+
* @param $field - an array holding all the field's data
|
68 |
+
*
|
69 |
+
* @type action
|
70 |
+
* @since 3.6
|
71 |
+
* @date 23/01/13
|
72 |
+
*/
|
73 |
+
|
74 |
+
function create_field( $field )
|
75 |
+
{
|
76 |
+
// let post_object create the field
|
77 |
+
$field['type'] = 'post_object';
|
78 |
+
|
79 |
+
do_action('acf/create_field', $field );
|
80 |
+
}
|
81 |
+
|
82 |
+
|
83 |
+
/*
|
84 |
+
* create_options()
|
85 |
+
*
|
86 |
+
* Create extra options for your field. This is rendered when editing a field.
|
87 |
+
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
88 |
+
*
|
89 |
+
* @type action
|
90 |
+
* @since 3.6
|
91 |
+
* @date 23/01/13
|
92 |
+
*
|
93 |
+
* @param $field - an array holding all the field's data
|
94 |
+
*/
|
95 |
+
|
96 |
+
function create_options( $field )
|
97 |
+
{
|
98 |
+
$key = $field['name'];
|
99 |
+
|
100 |
+
?>
|
101 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
102 |
+
<td class="label">
|
103 |
+
<label for=""><?php _e("Post Type",'acf'); ?></label>
|
104 |
+
</td>
|
105 |
+
<td>
|
106 |
+
<?php
|
107 |
+
|
108 |
+
$choices = array(
|
109 |
+
'all' => __("All",'acf')
|
110 |
+
);
|
111 |
+
$choices = apply_filters('acf/get_post_types', $choices);
|
112 |
+
|
113 |
+
|
114 |
+
do_action('acf/create_field', array(
|
115 |
+
'type' => 'select',
|
116 |
+
'name' => 'fields['.$key.'][post_type]',
|
117 |
+
'value' => $field['post_type'],
|
118 |
+
'choices' => $choices,
|
119 |
+
'multiple' => 1,
|
120 |
+
));
|
121 |
+
|
122 |
+
?>
|
123 |
+
</td>
|
124 |
+
</tr>
|
125 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
126 |
+
<td class="label">
|
127 |
+
<label><?php _e("Allow Null?",'acf'); ?></label>
|
128 |
+
</td>
|
129 |
+
<td>
|
130 |
+
<?php
|
131 |
+
|
132 |
+
do_action('acf/create_field', array(
|
133 |
+
'type' => 'radio',
|
134 |
+
'name' => 'fields['.$key.'][allow_null]',
|
135 |
+
'value' => $field['allow_null'],
|
136 |
+
'choices' => array(
|
137 |
+
1 => __("Yes",'acf'),
|
138 |
+
0 => __("No",'acf'),
|
139 |
+
),
|
140 |
+
'layout' => 'horizontal',
|
141 |
+
));
|
142 |
+
|
143 |
+
?>
|
144 |
+
</td>
|
145 |
+
</tr>
|
146 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
147 |
+
<td class="label">
|
148 |
+
<label><?php _e("Select multiple values?",'acf'); ?></label>
|
149 |
+
</td>
|
150 |
+
<td>
|
151 |
+
<?php
|
152 |
+
|
153 |
+
do_action('acf/create_field', array(
|
154 |
+
'type' => 'radio',
|
155 |
+
'name' => 'fields['.$key.'][multiple]',
|
156 |
+
'value' => $field['multiple'],
|
157 |
+
'choices' => array(
|
158 |
+
1 => __("Yes",'acf'),
|
159 |
+
0 => __("No",'acf'),
|
160 |
+
),
|
161 |
+
'layout' => 'horizontal',
|
162 |
+
));
|
163 |
+
|
164 |
+
?>
|
165 |
+
</td>
|
166 |
+
</tr>
|
167 |
+
<?php
|
168 |
+
|
169 |
+
}
|
170 |
+
|
171 |
+
|
172 |
+
/*
|
173 |
+
* format_value_for_api()
|
174 |
+
*
|
175 |
+
* This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
|
176 |
+
*
|
177 |
+
* @type filter
|
178 |
+
* @since 3.6
|
179 |
+
* @date 23/01/13
|
180 |
+
*
|
181 |
+
* @param $value - the value which was loaded from the database
|
182 |
+
* @param $post_id - the $post_id from which the value was loaded
|
183 |
+
* @param $field - the field array holding all the field options
|
184 |
+
*
|
185 |
+
* @return $value - the modified value
|
186 |
+
*/
|
187 |
+
|
188 |
+
function format_value_for_api( $value, $post_id, $field )
|
189 |
+
{
|
190 |
+
if( !$value )
|
191 |
+
{
|
192 |
+
return false;
|
193 |
+
}
|
194 |
+
|
195 |
+
if( $value == 'null' )
|
196 |
+
{
|
197 |
+
return false;
|
198 |
+
}
|
199 |
+
|
200 |
+
if( is_array($value) )
|
201 |
+
{
|
202 |
+
foreach( $value as $k => $v )
|
203 |
+
{
|
204 |
+
$value[ $k ] = get_permalink($v);
|
205 |
+
}
|
206 |
+
}
|
207 |
+
else
|
208 |
+
{
|
209 |
+
$value = get_permalink($value);
|
210 |
+
}
|
211 |
+
|
212 |
+
return $value;
|
213 |
+
}
|
214 |
+
|
215 |
+
}
|
216 |
+
|
217 |
+
new acf_field_page_link();
|
218 |
+
|
219 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/fields/password.php
CHANGED
@@ -1,155 +1,155 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_field_password extends acf_field
|
4 |
-
{
|
5 |
-
|
6 |
-
/*
|
7 |
-
* __construct
|
8 |
-
*
|
9 |
-
* Set name / label needed for actions / filters
|
10 |
-
*
|
11 |
-
* @since 3.6
|
12 |
-
* @date 23/01/13
|
13 |
-
*/
|
14 |
-
|
15 |
-
function __construct()
|
16 |
-
{
|
17 |
-
// vars
|
18 |
-
$this->name = 'password';
|
19 |
-
$this->label = __("Password",'acf');
|
20 |
-
$this->defaults = array(
|
21 |
-
'placeholder' => '',
|
22 |
-
'prepend' => '',
|
23 |
-
'append' => ''
|
24 |
-
);
|
25 |
-
|
26 |
-
|
27 |
-
// do not delete!
|
28 |
-
parent::__construct();
|
29 |
-
}
|
30 |
-
|
31 |
-
|
32 |
-
/*
|
33 |
-
* create_field()
|
34 |
-
*
|
35 |
-
* Create the HTML interface for your field
|
36 |
-
*
|
37 |
-
* @param $field - an array holding all the field's data
|
38 |
-
*
|
39 |
-
* @type action
|
40 |
-
* @since 3.6
|
41 |
-
* @date 23/01/13
|
42 |
-
*/
|
43 |
-
|
44 |
-
function create_field( $field )
|
45 |
-
{
|
46 |
-
// vars
|
47 |
-
$o = array( 'id', 'class', 'name', 'value', 'placeholder' );
|
48 |
-
$e = '';
|
49 |
-
|
50 |
-
|
51 |
-
// prepend
|
52 |
-
if( $field['prepend'] !== "" )
|
53 |
-
{
|
54 |
-
$field['class'] .= ' acf-is-prepended';
|
55 |
-
$e .= '<div class="acf-input-prepend">' . $field['prepend'] . '</div>';
|
56 |
-
}
|
57 |
-
|
58 |
-
|
59 |
-
// append
|
60 |
-
if( $field['append'] !== "" )
|
61 |
-
{
|
62 |
-
$field['class'] .= ' acf-is-appended';
|
63 |
-
$e .= '<div class="acf-input-append">' . $field['append'] . '</div>';
|
64 |
-
}
|
65 |
-
|
66 |
-
|
67 |
-
$e .= '<div class="acf-input-wrap">';
|
68 |
-
$e .= '<input type="password"';
|
69 |
-
|
70 |
-
foreach( $o as $k )
|
71 |
-
{
|
72 |
-
$e .= ' ' . $k . '="' . esc_attr( $field[ $k ] ) . '"';
|
73 |
-
}
|
74 |
-
|
75 |
-
$e .= ' />';
|
76 |
-
$e .= '</div>';
|
77 |
-
|
78 |
-
|
79 |
-
// return
|
80 |
-
echo $e;
|
81 |
-
}
|
82 |
-
|
83 |
-
|
84 |
-
/*
|
85 |
-
* create_options()
|
86 |
-
*
|
87 |
-
* Create extra options for your field. This is rendered when editing a field.
|
88 |
-
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
89 |
-
*
|
90 |
-
* @type action
|
91 |
-
* @since 3.6
|
92 |
-
* @date 23/01/13
|
93 |
-
*
|
94 |
-
* @param $field - an array holding all the field's data
|
95 |
-
*/
|
96 |
-
|
97 |
-
function create_options( $field )
|
98 |
-
{
|
99 |
-
// vars
|
100 |
-
$key = $field['name'];
|
101 |
-
|
102 |
-
?>
|
103 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
104 |
-
<td class="label">
|
105 |
-
<label><?php _e("Placeholder Text",'acf'); ?></label>
|
106 |
-
<p><?php _e("Appears within the input",'acf') ?></p>
|
107 |
-
</td>
|
108 |
-
<td>
|
109 |
-
<?php
|
110 |
-
do_action('acf/create_field', array(
|
111 |
-
'type' => 'text',
|
112 |
-
'name' => 'fields[' .$key.'][placeholder]',
|
113 |
-
'value' => $field['placeholder'],
|
114 |
-
));
|
115 |
-
?>
|
116 |
-
</td>
|
117 |
-
</tr>
|
118 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
119 |
-
<td class="label">
|
120 |
-
<label><?php _e("Prepend",'acf'); ?></label>
|
121 |
-
<p><?php _e("Appears before the input",'acf') ?></p>
|
122 |
-
</td>
|
123 |
-
<td>
|
124 |
-
<?php
|
125 |
-
do_action('acf/create_field', array(
|
126 |
-
'type' => 'text',
|
127 |
-
'name' => 'fields[' .$key.'][prepend]',
|
128 |
-
'value' => $field['prepend'],
|
129 |
-
));
|
130 |
-
?>
|
131 |
-
</td>
|
132 |
-
</tr>
|
133 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
134 |
-
<td class="label">
|
135 |
-
<label><?php _e("Append",'acf'); ?></label>
|
136 |
-
<p><?php _e("Appears after the input",'acf') ?></p>
|
137 |
-
</td>
|
138 |
-
<td>
|
139 |
-
<?php
|
140 |
-
do_action('acf/create_field', array(
|
141 |
-
'type' => 'text',
|
142 |
-
'name' => 'fields[' .$key.'][append]',
|
143 |
-
'value' => $field['append'],
|
144 |
-
));
|
145 |
-
?>
|
146 |
-
</td>
|
147 |
-
</tr>
|
148 |
-
<?php
|
149 |
-
}
|
150 |
-
|
151 |
-
}
|
152 |
-
|
153 |
-
new acf_field_password();
|
154 |
-
|
155 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class acf_field_password extends acf_field
|
4 |
+
{
|
5 |
+
|
6 |
+
/*
|
7 |
+
* __construct
|
8 |
+
*
|
9 |
+
* Set name / label needed for actions / filters
|
10 |
+
*
|
11 |
+
* @since 3.6
|
12 |
+
* @date 23/01/13
|
13 |
+
*/
|
14 |
+
|
15 |
+
function __construct()
|
16 |
+
{
|
17 |
+
// vars
|
18 |
+
$this->name = 'password';
|
19 |
+
$this->label = __("Password",'acf');
|
20 |
+
$this->defaults = array(
|
21 |
+
'placeholder' => '',
|
22 |
+
'prepend' => '',
|
23 |
+
'append' => ''
|
24 |
+
);
|
25 |
+
|
26 |
+
|
27 |
+
// do not delete!
|
28 |
+
parent::__construct();
|
29 |
+
}
|
30 |
+
|
31 |
+
|
32 |
+
/*
|
33 |
+
* create_field()
|
34 |
+
*
|
35 |
+
* Create the HTML interface for your field
|
36 |
+
*
|
37 |
+
* @param $field - an array holding all the field's data
|
38 |
+
*
|
39 |
+
* @type action
|
40 |
+
* @since 3.6
|
41 |
+
* @date 23/01/13
|
42 |
+
*/
|
43 |
+
|
44 |
+
function create_field( $field )
|
45 |
+
{
|
46 |
+
// vars
|
47 |
+
$o = array( 'id', 'class', 'name', 'value', 'placeholder' );
|
48 |
+
$e = '';
|
49 |
+
|
50 |
+
|
51 |
+
// prepend
|
52 |
+
if( $field['prepend'] !== "" )
|
53 |
+
{
|
54 |
+
$field['class'] .= ' acf-is-prepended';
|
55 |
+
$e .= '<div class="acf-input-prepend">' . $field['prepend'] . '</div>';
|
56 |
+
}
|
57 |
+
|
58 |
+
|
59 |
+
// append
|
60 |
+
if( $field['append'] !== "" )
|
61 |
+
{
|
62 |
+
$field['class'] .= ' acf-is-appended';
|
63 |
+
$e .= '<div class="acf-input-append">' . $field['append'] . '</div>';
|
64 |
+
}
|
65 |
+
|
66 |
+
|
67 |
+
$e .= '<div class="acf-input-wrap">';
|
68 |
+
$e .= '<input type="password"';
|
69 |
+
|
70 |
+
foreach( $o as $k )
|
71 |
+
{
|
72 |
+
$e .= ' ' . $k . '="' . esc_attr( $field[ $k ] ) . '"';
|
73 |
+
}
|
74 |
+
|
75 |
+
$e .= ' />';
|
76 |
+
$e .= '</div>';
|
77 |
+
|
78 |
+
|
79 |
+
// return
|
80 |
+
echo $e;
|
81 |
+
}
|
82 |
+
|
83 |
+
|
84 |
+
/*
|
85 |
+
* create_options()
|
86 |
+
*
|
87 |
+
* Create extra options for your field. This is rendered when editing a field.
|
88 |
+
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
89 |
+
*
|
90 |
+
* @type action
|
91 |
+
* @since 3.6
|
92 |
+
* @date 23/01/13
|
93 |
+
*
|
94 |
+
* @param $field - an array holding all the field's data
|
95 |
+
*/
|
96 |
+
|
97 |
+
function create_options( $field )
|
98 |
+
{
|
99 |
+
// vars
|
100 |
+
$key = $field['name'];
|
101 |
+
|
102 |
+
?>
|
103 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
104 |
+
<td class="label">
|
105 |
+
<label><?php _e("Placeholder Text",'acf'); ?></label>
|
106 |
+
<p><?php _e("Appears within the input",'acf') ?></p>
|
107 |
+
</td>
|
108 |
+
<td>
|
109 |
+
<?php
|
110 |
+
do_action('acf/create_field', array(
|
111 |
+
'type' => 'text',
|
112 |
+
'name' => 'fields[' .$key.'][placeholder]',
|
113 |
+
'value' => $field['placeholder'],
|
114 |
+
));
|
115 |
+
?>
|
116 |
+
</td>
|
117 |
+
</tr>
|
118 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
119 |
+
<td class="label">
|
120 |
+
<label><?php _e("Prepend",'acf'); ?></label>
|
121 |
+
<p><?php _e("Appears before the input",'acf') ?></p>
|
122 |
+
</td>
|
123 |
+
<td>
|
124 |
+
<?php
|
125 |
+
do_action('acf/create_field', array(
|
126 |
+
'type' => 'text',
|
127 |
+
'name' => 'fields[' .$key.'][prepend]',
|
128 |
+
'value' => $field['prepend'],
|
129 |
+
));
|
130 |
+
?>
|
131 |
+
</td>
|
132 |
+
</tr>
|
133 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
134 |
+
<td class="label">
|
135 |
+
<label><?php _e("Append",'acf'); ?></label>
|
136 |
+
<p><?php _e("Appears after the input",'acf') ?></p>
|
137 |
+
</td>
|
138 |
+
<td>
|
139 |
+
<?php
|
140 |
+
do_action('acf/create_field', array(
|
141 |
+
'type' => 'text',
|
142 |
+
'name' => 'fields[' .$key.'][append]',
|
143 |
+
'value' => $field['append'],
|
144 |
+
));
|
145 |
+
?>
|
146 |
+
</td>
|
147 |
+
</tr>
|
148 |
+
<?php
|
149 |
+
}
|
150 |
+
|
151 |
+
}
|
152 |
+
|
153 |
+
new acf_field_password();
|
154 |
+
|
155 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/fields/post_object.php
CHANGED
@@ -1,545 +1,545 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_field_post_object extends acf_field
|
4 |
-
{
|
5 |
-
/*
|
6 |
-
* __construct
|
7 |
-
*
|
8 |
-
* Set name / label needed for actions / filters
|
9 |
-
*
|
10 |
-
* @since 3.6
|
11 |
-
* @date 23/01/13
|
12 |
-
*/
|
13 |
-
|
14 |
-
function __construct()
|
15 |
-
{
|
16 |
-
// vars
|
17 |
-
$this->name = 'post_object';
|
18 |
-
$this->label = __("Post Object",'acf');
|
19 |
-
$this->category = __("Relational",'acf');
|
20 |
-
$this->defaults = array(
|
21 |
-
'post_type' => array('all'),
|
22 |
-
'taxonomy' => array('all'),
|
23 |
-
'multiple' => 0,
|
24 |
-
'allow_null' => 0,
|
25 |
-
);
|
26 |
-
|
27 |
-
|
28 |
-
// do not delete!
|
29 |
-
parent::__construct();
|
30 |
-
|
31 |
-
}
|
32 |
-
|
33 |
-
|
34 |
-
/*
|
35 |
-
* load_field()
|
36 |
-
*
|
37 |
-
* This filter is appied to the $field after it is loaded from the database
|
38 |
-
*
|
39 |
-
* @type filter
|
40 |
-
* @since 3.6
|
41 |
-
* @date 23/01/13
|
42 |
-
*
|
43 |
-
* @param $field - the field array holding all the field options
|
44 |
-
*
|
45 |
-
* @return $field - the field array holding all the field options
|
46 |
-
*/
|
47 |
-
|
48 |
-
function load_field( $field )
|
49 |
-
{
|
50 |
-
// validate post_type
|
51 |
-
if( !$field['post_type'] || !is_array($field['post_type']) || in_array('', $field['post_type']) )
|
52 |
-
{
|
53 |
-
$field['post_type'] = array( 'all' );
|
54 |
-
}
|
55 |
-
|
56 |
-
|
57 |
-
// validate taxonomy
|
58 |
-
if( !$field['taxonomy'] || !is_array($field['taxonomy']) || in_array('', $field['taxonomy']) )
|
59 |
-
{
|
60 |
-
$field['taxonomy'] = array( 'all' );
|
61 |
-
}
|
62 |
-
|
63 |
-
|
64 |
-
// return
|
65 |
-
return $field;
|
66 |
-
}
|
67 |
-
|
68 |
-
|
69 |
-
/*
|
70 |
-
* create_field()
|
71 |
-
*
|
72 |
-
* Create the HTML interface for your field
|
73 |
-
*
|
74 |
-
* @param $field - an array holding all the field's data
|
75 |
-
*
|
76 |
-
* @type action
|
77 |
-
* @since 3.6
|
78 |
-
* @date 23/01/13
|
79 |
-
*/
|
80 |
-
|
81 |
-
function create_field( $field )
|
82 |
-
{
|
83 |
-
// global
|
84 |
-
global $post;
|
85 |
-
|
86 |
-
|
87 |
-
// vars
|
88 |
-
$args = array(
|
89 |
-
'numberposts' => -1,
|
90 |
-
'post_type' => null,
|
91 |
-
'orderby' => 'title',
|
92 |
-
'order' => 'ASC',
|
93 |
-
'post_status' => array('publish', 'private', 'draft', 'inherit', 'future'),
|
94 |
-
'suppress_filters' => false,
|
95 |
-
);
|
96 |
-
|
97 |
-
|
98 |
-
// load all post types by default
|
99 |
-
if( in_array('all', $field['post_type']) )
|
100 |
-
{
|
101 |
-
$field['post_type'] = apply_filters('acf/get_post_types', array());
|
102 |
-
}
|
103 |
-
|
104 |
-
|
105 |
-
// create tax queries
|
106 |
-
if( ! in_array('all', $field['taxonomy']) )
|
107 |
-
{
|
108 |
-
// vars
|
109 |
-
$taxonomies = array();
|
110 |
-
$args['tax_query'] = array();
|
111 |
-
|
112 |
-
foreach( $field['taxonomy'] as $v )
|
113 |
-
{
|
114 |
-
|
115 |
-
// find term (find taxonomy!)
|
116 |
-
// $term = array( 0 => $taxonomy, 1 => $term_id )
|
117 |
-
$term = explode(':', $v);
|
118 |
-
|
119 |
-
|
120 |
-
// validate
|
121 |
-
if( !is_array($term) || !isset($term[1]) )
|
122 |
-
{
|
123 |
-
continue;
|
124 |
-
}
|
125 |
-
|
126 |
-
|
127 |
-
// add to tax array
|
128 |
-
$taxonomies[ $term[0] ][] = $term[1];
|
129 |
-
|
130 |
-
}
|
131 |
-
|
132 |
-
|
133 |
-
// now create the tax queries
|
134 |
-
foreach( $taxonomies as $k => $v )
|
135 |
-
{
|
136 |
-
$args['tax_query'][] = array(
|
137 |
-
'taxonomy' => $k,
|
138 |
-
'field' => 'id',
|
139 |
-
'terms' => $v,
|
140 |
-
);
|
141 |
-
}
|
142 |
-
}
|
143 |
-
|
144 |
-
|
145 |
-
// Change Field into a select
|
146 |
-
$field['type'] = 'select';
|
147 |
-
$field['choices'] = array();
|
148 |
-
|
149 |
-
|
150 |
-
foreach( $field['post_type'] as $post_type )
|
151 |
-
{
|
152 |
-
// set post_type
|
153 |
-
$args['post_type'] = $post_type;
|
154 |
-
|
155 |
-
|
156 |
-
// set order
|
157 |
-
$get_pages = false;
|
158 |
-
if( is_post_type_hierarchical($post_type) && !isset($args['tax_query']) )
|
159 |
-
{
|
160 |
-
$args['sort_column'] = 'menu_order, post_title';
|
161 |
-
$args['sort_order'] = 'ASC';
|
162 |
-
|
163 |
-
$get_pages = true;
|
164 |
-
}
|
165 |
-
|
166 |
-
|
167 |
-
// filters
|
168 |
-
$args = apply_filters('acf/fields/post_object/query', $args, $field, $post);
|
169 |
-
$args = apply_filters('acf/fields/post_object/query/name=' . $field['_name'], $args, $field, $post );
|
170 |
-
$args = apply_filters('acf/fields/post_object/query/key=' . $field['key'], $args, $field, $post );
|
171 |
-
|
172 |
-
|
173 |
-
if( $get_pages )
|
174 |
-
{
|
175 |
-
$posts = get_pages( $args );
|
176 |
-
}
|
177 |
-
else
|
178 |
-
{
|
179 |
-
$posts = get_posts( $args );
|
180 |
-
}
|
181 |
-
|
182 |
-
|
183 |
-
if($posts) {
|
184 |
-
|
185 |
-
foreach( $posts as $p ) {
|
186 |
-
|
187 |
-
// title
|
188 |
-
$title = get_the_title( $p->ID );
|
189 |
-
|
190 |
-
|
191 |
-
// empty
|
192 |
-
if( $title === '' ) {
|
193 |
-
|
194 |
-
$title = __('(no title)', 'acf');
|
195 |
-
|
196 |
-
}
|
197 |
-
|
198 |
-
|
199 |
-
// ancestors
|
200 |
-
if( $p->post_type != 'attachment' ) {
|
201 |
-
|
202 |
-
$ancestors = get_ancestors( $p->ID, $p->post_type );
|
203 |
-
|
204 |
-
$title = str_repeat('- ', count($ancestors)) . $title;
|
205 |
-
|
206 |
-
}
|
207 |
-
|
208 |
-
|
209 |
-
// status
|
210 |
-
if( get_post_status( $p->ID ) != "publish" ) {
|
211 |
-
|
212 |
-
$title .= ' (' . get_post_status( $p->ID ) . ')';
|
213 |
-
|
214 |
-
}
|
215 |
-
|
216 |
-
|
217 |
-
// WPML
|
218 |
-
if( defined('ICL_LANGUAGE_CODE') ) {
|
219 |
-
|
220 |
-
$title .= ' (' . ICL_LANGUAGE_CODE . ')';
|
221 |
-
|
222 |
-
}
|
223 |
-
|
224 |
-
|
225 |
-
// filters
|
226 |
-
$title = apply_filters('acf/fields/post_object/result', $title, $p, $field, $post);
|
227 |
-
$title = apply_filters('acf/fields/post_object/result/name=' . $field['_name'] , $title, $p, $field, $post);
|
228 |
-
$title = apply_filters('acf/fields/post_object/result/key=' . $field['key'], $title, $p, $field, $post);
|
229 |
-
|
230 |
-
|
231 |
-
// add to choices
|
232 |
-
if( count($field['post_type']) == 1 )
|
233 |
-
{
|
234 |
-
$field['choices'][ $p->ID ] = $title;
|
235 |
-
}
|
236 |
-
else
|
237 |
-
{
|
238 |
-
// group by post type
|
239 |
-
$post_type_object = get_post_type_object( $p->post_type );
|
240 |
-
$post_type_name = $post_type_object->labels->name;
|
241 |
-
|
242 |
-
$field['choices'][ $post_type_name ][ $p->ID ] = $title;
|
243 |
-
}
|
244 |
-
|
245 |
-
|
246 |
-
}
|
247 |
-
// foreach( $posts as $post )
|
248 |
-
}
|
249 |
-
// if($posts)
|
250 |
-
}
|
251 |
-
// foreach( $field['post_type'] as $post_type )
|
252 |
-
|
253 |
-
|
254 |
-
// create field
|
255 |
-
do_action('acf/create_field', $field );
|
256 |
-
}
|
257 |
-
|
258 |
-
|
259 |
-
/*
|
260 |
-
* create_options()
|
261 |
-
*
|
262 |
-
* Create extra options for your field. This is rendered when editing a field.
|
263 |
-
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
264 |
-
*
|
265 |
-
* @type action
|
266 |
-
* @since 3.6
|
267 |
-
* @date 23/01/13
|
268 |
-
*
|
269 |
-
* @param $field - an array holding all the field's data
|
270 |
-
*/
|
271 |
-
|
272 |
-
function create_options( $field )
|
273 |
-
{
|
274 |
-
// vars
|
275 |
-
$key = $field['name'];
|
276 |
-
|
277 |
-
?>
|
278 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
279 |
-
<td class="label">
|
280 |
-
<label for=""><?php _e("Post Type",'acf'); ?></label>
|
281 |
-
</td>
|
282 |
-
<td>
|
283 |
-
<?php
|
284 |
-
|
285 |
-
$choices = array(
|
286 |
-
'all' => __("All",'acf')
|
287 |
-
);
|
288 |
-
$choices = apply_filters('acf/get_post_types', $choices);
|
289 |
-
|
290 |
-
|
291 |
-
do_action('acf/create_field', array(
|
292 |
-
'type' => 'select',
|
293 |
-
'name' => 'fields['.$key.'][post_type]',
|
294 |
-
'value' => $field['post_type'],
|
295 |
-
'choices' => $choices,
|
296 |
-
'multiple' => 1,
|
297 |
-
));
|
298 |
-
|
299 |
-
?>
|
300 |
-
</td>
|
301 |
-
</tr>
|
302 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
303 |
-
<td class="label">
|
304 |
-
<label><?php _e("Filter from Taxonomy",'acf'); ?></label>
|
305 |
-
</td>
|
306 |
-
<td>
|
307 |
-
<?php
|
308 |
-
$choices = array(
|
309 |
-
'' => array(
|
310 |
-
'all' => __("All",'acf')
|
311 |
-
)
|
312 |
-
);
|
313 |
-
$simple_value = false;
|
314 |
-
$choices = apply_filters('acf/get_taxonomies_for_select', $choices, $simple_value);
|
315 |
-
|
316 |
-
do_action('acf/create_field', array(
|
317 |
-
'type' => 'select',
|
318 |
-
'name' => 'fields['.$key.'][taxonomy]',
|
319 |
-
'value' => $field['taxonomy'],
|
320 |
-
'choices' => $choices,
|
321 |
-
'multiple' => 1,
|
322 |
-
));
|
323 |
-
|
324 |
-
?>
|
325 |
-
</td>
|
326 |
-
</tr>
|
327 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
328 |
-
<td class="label">
|
329 |
-
<label><?php _e("Allow Null?",'acf'); ?></label>
|
330 |
-
</td>
|
331 |
-
<td>
|
332 |
-
<?php
|
333 |
-
|
334 |
-
do_action('acf/create_field', array(
|
335 |
-
'type' => 'radio',
|
336 |
-
'name' => 'fields['.$key.'][allow_null]',
|
337 |
-
'value' => $field['allow_null'],
|
338 |
-
'choices' => array(
|
339 |
-
1 => __("Yes",'acf'),
|
340 |
-
0 => __("No",'acf'),
|
341 |
-
),
|
342 |
-
'layout' => 'horizontal',
|
343 |
-
));
|
344 |
-
|
345 |
-
?>
|
346 |
-
</td>
|
347 |
-
</tr>
|
348 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
349 |
-
<td class="label">
|
350 |
-
<label><?php _e("Select multiple values?",'acf'); ?></label>
|
351 |
-
</td>
|
352 |
-
<td>
|
353 |
-
<?php
|
354 |
-
|
355 |
-
do_action('acf/create_field', array(
|
356 |
-
'type' => 'radio',
|
357 |
-
'name' => 'fields['.$key.'][multiple]',
|
358 |
-
'value' => $field['multiple'],
|
359 |
-
'choices' => array(
|
360 |
-
1 => __("Yes",'acf'),
|
361 |
-
0 => __("No",'acf'),
|
362 |
-
),
|
363 |
-
'layout' => 'horizontal',
|
364 |
-
));
|
365 |
-
|
366 |
-
?>
|
367 |
-
</td>
|
368 |
-
</tr>
|
369 |
-
<?php
|
370 |
-
|
371 |
-
}
|
372 |
-
|
373 |
-
|
374 |
-
/*
|
375 |
-
* format_value()
|
376 |
-
*
|
377 |
-
* This filter is appied to the $value after it is loaded from the db and before it is passed to the create_field action
|
378 |
-
*
|
379 |
-
* @type filter
|
380 |
-
* @since 3.6
|
381 |
-
* @date 23/01/13
|
382 |
-
*
|
383 |
-
* @param $value - the value which was loaded from the database
|
384 |
-
* @param $post_id - the $post_id from which the value was loaded
|
385 |
-
* @param $field - the field array holding all the field options
|
386 |
-
*
|
387 |
-
* @return $value - the modified value
|
388 |
-
*/
|
389 |
-
|
390 |
-
function format_value( $value, $post_id, $field )
|
391 |
-
{
|
392 |
-
// empty?
|
393 |
-
if( !empty($value) )
|
394 |
-
{
|
395 |
-
// convert to integers
|
396 |
-
if( is_array($value) )
|
397 |
-
{
|
398 |
-
$value = array_map('intval', $value);
|
399 |
-
}
|
400 |
-
else
|
401 |
-
{
|
402 |
-
$value = intval($value);
|
403 |
-
}
|
404 |
-
}
|
405 |
-
|
406 |
-
|
407 |
-
// return value
|
408 |
-
return $value;
|
409 |
-
}
|
410 |
-
|
411 |
-
|
412 |
-
/*
|
413 |
-
* format_value_for_api()
|
414 |
-
*
|
415 |
-
* This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
|
416 |
-
*
|
417 |
-
* @type filter
|
418 |
-
* @since 3.6
|
419 |
-
* @date 23/01/13
|
420 |
-
*
|
421 |
-
* @param $value - the value which was loaded from the database
|
422 |
-
* @param $post_id - the $post_id from which the value was loaded
|
423 |
-
* @param $field - the field array holding all the field options
|
424 |
-
*
|
425 |
-
* @return $value - the modified value
|
426 |
-
*/
|
427 |
-
|
428 |
-
function format_value_for_api( $value, $post_id, $field )
|
429 |
-
{
|
430 |
-
// no value?
|
431 |
-
if( !$value )
|
432 |
-
{
|
433 |
-
return false;
|
434 |
-
}
|
435 |
-
|
436 |
-
|
437 |
-
// null?
|
438 |
-
if( $value == 'null' )
|
439 |
-
{
|
440 |
-
return false;
|
441 |
-
}
|
442 |
-
|
443 |
-
|
444 |
-
// multiple / single
|
445 |
-
if( is_array($value) )
|
446 |
-
{
|
447 |
-
// find posts (DISTINCT POSTS)
|
448 |
-
$posts = get_posts(array(
|
449 |
-
'numberposts' => -1,
|
450 |
-
'post__in' => $value,
|
451 |
-
'post_type' => apply_filters('acf/get_post_types', array()),
|
452 |
-
'post_status' => array('publish', 'private', 'draft', 'inherit', 'future'),
|
453 |
-
));
|
454 |
-
|
455 |
-
|
456 |
-
$ordered_posts = array();
|
457 |
-
foreach( $posts as $post )
|
458 |
-
{
|
459 |
-
// create array to hold value data
|
460 |
-
$ordered_posts[ $post->ID ] = $post;
|
461 |
-
}
|
462 |
-
|
463 |
-
|
464 |
-
// override value array with attachments
|
465 |
-
foreach( $value as $k => $v)
|
466 |
-
{
|
467 |
-
// check that post exists (my have been trashed)
|
468 |
-
if( !isset($ordered_posts[ $v ]) )
|
469 |
-
{
|
470 |
-
unset( $value[ $k ] );
|
471 |
-
}
|
472 |
-
else
|
473 |
-
{
|
474 |
-
$value[ $k ] = $ordered_posts[ $v ];
|
475 |
-
}
|
476 |
-
}
|
477 |
-
|
478 |
-
}
|
479 |
-
else
|
480 |
-
{
|
481 |
-
$value = get_post($value);
|
482 |
-
}
|
483 |
-
|
484 |
-
|
485 |
-
// return the value
|
486 |
-
return $value;
|
487 |
-
}
|
488 |
-
|
489 |
-
|
490 |
-
/*
|
491 |
-
* update_value()
|
492 |
-
*
|
493 |
-
* This filter is appied to the $value before it is updated in the db
|
494 |
-
*
|
495 |
-
* @type filter
|
496 |
-
* @since 3.6
|
497 |
-
* @date 23/01/13
|
498 |
-
*
|
499 |
-
* @param $value - the value which will be saved in the database
|
500 |
-
* @param $post_id - the $post_id of which the value will be saved
|
501 |
-
* @param $field - the field array holding all the field options
|
502 |
-
*
|
503 |
-
* @return $value - the modified value
|
504 |
-
*/
|
505 |
-
|
506 |
-
function update_value( $value, $post_id, $field )
|
507 |
-
{
|
508 |
-
// validate
|
509 |
-
if( empty($value) )
|
510 |
-
{
|
511 |
-
return $value;
|
512 |
-
}
|
513 |
-
|
514 |
-
|
515 |
-
if( is_object($value) && isset($value->ID) )
|
516 |
-
{
|
517 |
-
// object
|
518 |
-
$value = $value->ID;
|
519 |
-
|
520 |
-
}
|
521 |
-
elseif( is_array($value) )
|
522 |
-
{
|
523 |
-
// array
|
524 |
-
foreach( $value as $k => $v ){
|
525 |
-
|
526 |
-
// object?
|
527 |
-
if( is_object($v) && isset($v->ID) )
|
528 |
-
{
|
529 |
-
$value[ $k ] = $v->ID;
|
530 |
-
}
|
531 |
-
}
|
532 |
-
|
533 |
-
// save value as strings, so we can clearly search for them in SQL LIKE statements
|
534 |
-
$value = array_map('strval', $value);
|
535 |
-
|
536 |
-
}
|
537 |
-
|
538 |
-
return $value;
|
539 |
-
}
|
540 |
-
|
541 |
-
}
|
542 |
-
|
543 |
-
new acf_field_post_object();
|
544 |
-
|
545 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class acf_field_post_object extends acf_field
|
4 |
+
{
|
5 |
+
/*
|
6 |
+
* __construct
|
7 |
+
*
|
8 |
+
* Set name / label needed for actions / filters
|
9 |
+
*
|
10 |
+
* @since 3.6
|
11 |
+
* @date 23/01/13
|
12 |
+
*/
|
13 |
+
|
14 |
+
function __construct()
|
15 |
+
{
|
16 |
+
// vars
|
17 |
+
$this->name = 'post_object';
|
18 |
+
$this->label = __("Post Object",'acf');
|
19 |
+
$this->category = __("Relational",'acf');
|
20 |
+
$this->defaults = array(
|
21 |
+
'post_type' => array('all'),
|
22 |
+
'taxonomy' => array('all'),
|
23 |
+
'multiple' => 0,
|
24 |
+
'allow_null' => 0,
|
25 |
+
);
|
26 |
+
|
27 |
+
|
28 |
+
// do not delete!
|
29 |
+
parent::__construct();
|
30 |
+
|
31 |
+
}
|
32 |
+
|
33 |
+
|
34 |
+
/*
|
35 |
+
* load_field()
|
36 |
+
*
|
37 |
+
* This filter is appied to the $field after it is loaded from the database
|
38 |
+
*
|
39 |
+
* @type filter
|
40 |
+
* @since 3.6
|
41 |
+
* @date 23/01/13
|
42 |
+
*
|
43 |
+
* @param $field - the field array holding all the field options
|
44 |
+
*
|
45 |
+
* @return $field - the field array holding all the field options
|
46 |
+
*/
|
47 |
+
|
48 |
+
function load_field( $field )
|
49 |
+
{
|
50 |
+
// validate post_type
|
51 |
+
if( !$field['post_type'] || !is_array($field['post_type']) || in_array('', $field['post_type']) )
|
52 |
+
{
|
53 |
+
$field['post_type'] = array( 'all' );
|
54 |
+
}
|
55 |
+
|
56 |
+
|
57 |
+
// validate taxonomy
|
58 |
+
if( !$field['taxonomy'] || !is_array($field['taxonomy']) || in_array('', $field['taxonomy']) )
|
59 |
+
{
|
60 |
+
$field['taxonomy'] = array( 'all' );
|
61 |
+
}
|
62 |
+
|
63 |
+
|
64 |
+
// return
|
65 |
+
return $field;
|
66 |
+
}
|
67 |
+
|
68 |
+
|
69 |
+
/*
|
70 |
+
* create_field()
|
71 |
+
*
|
72 |
+
* Create the HTML interface for your field
|
73 |
+
*
|
74 |
+
* @param $field - an array holding all the field's data
|
75 |
+
*
|
76 |
+
* @type action
|
77 |
+
* @since 3.6
|
78 |
+
* @date 23/01/13
|
79 |
+
*/
|
80 |
+
|
81 |
+
function create_field( $field )
|
82 |
+
{
|
83 |
+
// global
|
84 |
+
global $post;
|
85 |
+
|
86 |
+
|
87 |
+
// vars
|
88 |
+
$args = array(
|
89 |
+
'numberposts' => -1,
|
90 |
+
'post_type' => null,
|
91 |
+
'orderby' => 'title',
|
92 |
+
'order' => 'ASC',
|
93 |
+
'post_status' => array('publish', 'private', 'draft', 'inherit', 'future'),
|
94 |
+
'suppress_filters' => false,
|
95 |
+
);
|
96 |
+
|
97 |
+
|
98 |
+
// load all post types by default
|
99 |
+
if( in_array('all', $field['post_type']) )
|
100 |
+
{
|
101 |
+
$field['post_type'] = apply_filters('acf/get_post_types', array());
|
102 |
+
}
|
103 |
+
|
104 |
+
|
105 |
+
// create tax queries
|
106 |
+
if( ! in_array('all', $field['taxonomy']) )
|
107 |
+
{
|
108 |
+
// vars
|
109 |
+
$taxonomies = array();
|
110 |
+
$args['tax_query'] = array();
|
111 |
+
|
112 |
+
foreach( $field['taxonomy'] as $v )
|
113 |
+
{
|
114 |
+
|
115 |
+
// find term (find taxonomy!)
|
116 |
+
// $term = array( 0 => $taxonomy, 1 => $term_id )
|
117 |
+
$term = explode(':', $v);
|
118 |
+
|
119 |
+
|
120 |
+
// validate
|
121 |
+
if( !is_array($term) || !isset($term[1]) )
|
122 |
+
{
|
123 |
+
continue;
|
124 |
+
}
|
125 |
+
|
126 |
+
|
127 |
+
// add to tax array
|
128 |
+
$taxonomies[ $term[0] ][] = $term[1];
|
129 |
+
|
130 |
+
}
|
131 |
+
|
132 |
+
|
133 |
+
// now create the tax queries
|
134 |
+
foreach( $taxonomies as $k => $v )
|
135 |
+
{
|
136 |
+
$args['tax_query'][] = array(
|
137 |
+
'taxonomy' => $k,
|
138 |
+
'field' => 'id',
|
139 |
+
'terms' => $v,
|
140 |
+
);
|
141 |
+
}
|
142 |
+
}
|
143 |
+
|
144 |
+
|
145 |
+
// Change Field into a select
|
146 |
+
$field['type'] = 'select';
|
147 |
+
$field['choices'] = array();
|
148 |
+
|
149 |
+
|
150 |
+
foreach( $field['post_type'] as $post_type )
|
151 |
+
{
|
152 |
+
// set post_type
|
153 |
+
$args['post_type'] = $post_type;
|
154 |
+
|
155 |
+
|
156 |
+
// set order
|
157 |
+
$get_pages = false;
|
158 |
+
if( is_post_type_hierarchical($post_type) && !isset($args['tax_query']) )
|
159 |
+
{
|
160 |
+
$args['sort_column'] = 'menu_order, post_title';
|
161 |
+
$args['sort_order'] = 'ASC';
|
162 |
+
|
163 |
+
$get_pages = true;
|
164 |
+
}
|
165 |
+
|
166 |
+
|
167 |
+
// filters
|
168 |
+
$args = apply_filters('acf/fields/post_object/query', $args, $field, $post);
|
169 |
+
$args = apply_filters('acf/fields/post_object/query/name=' . $field['_name'], $args, $field, $post );
|
170 |
+
$args = apply_filters('acf/fields/post_object/query/key=' . $field['key'], $args, $field, $post );
|
171 |
+
|
172 |
+
|
173 |
+
if( $get_pages )
|
174 |
+
{
|
175 |
+
$posts = get_pages( $args );
|
176 |
+
}
|
177 |
+
else
|
178 |
+
{
|
179 |
+
$posts = get_posts( $args );
|
180 |
+
}
|
181 |
+
|
182 |
+
|
183 |
+
if($posts) {
|
184 |
+
|
185 |
+
foreach( $posts as $p ) {
|
186 |
+
|
187 |
+
// title
|
188 |
+
$title = get_the_title( $p->ID );
|
189 |
+
|
190 |
+
|
191 |
+
// empty
|
192 |
+
if( $title === '' ) {
|
193 |
+
|
194 |
+
$title = __('(no title)', 'acf');
|
195 |
+
|
196 |
+
}
|
197 |
+
|
198 |
+
|
199 |
+
// ancestors
|
200 |
+
if( $p->post_type != 'attachment' ) {
|
201 |
+
|
202 |
+
$ancestors = get_ancestors( $p->ID, $p->post_type );
|
203 |
+
|
204 |
+
$title = str_repeat('- ', count($ancestors)) . $title;
|
205 |
+
|
206 |
+
}
|
207 |
+
|
208 |
+
|
209 |
+
// status
|
210 |
+
if( get_post_status( $p->ID ) != "publish" ) {
|
211 |
+
|
212 |
+
$title .= ' (' . get_post_status( $p->ID ) . ')';
|
213 |
+
|
214 |
+
}
|
215 |
+
|
216 |
+
|
217 |
+
// WPML
|
218 |
+
if( defined('ICL_LANGUAGE_CODE') ) {
|
219 |
+
|
220 |
+
$title .= ' (' . ICL_LANGUAGE_CODE . ')';
|
221 |
+
|
222 |
+
}
|
223 |
+
|
224 |
+
|
225 |
+
// filters
|
226 |
+
$title = apply_filters('acf/fields/post_object/result', $title, $p, $field, $post);
|
227 |
+
$title = apply_filters('acf/fields/post_object/result/name=' . $field['_name'] , $title, $p, $field, $post);
|
228 |
+
$title = apply_filters('acf/fields/post_object/result/key=' . $field['key'], $title, $p, $field, $post);
|
229 |
+
|
230 |
+
|
231 |
+
// add to choices
|
232 |
+
if( count($field['post_type']) == 1 )
|
233 |
+
{
|
234 |
+
$field['choices'][ $p->ID ] = $title;
|
235 |
+
}
|
236 |
+
else
|
237 |
+
{
|
238 |
+
// group by post type
|
239 |
+
$post_type_object = get_post_type_object( $p->post_type );
|
240 |
+
$post_type_name = $post_type_object->labels->name;
|
241 |
+
|
242 |
+
$field['choices'][ $post_type_name ][ $p->ID ] = $title;
|
243 |
+
}
|
244 |
+
|
245 |
+
|
246 |
+
}
|
247 |
+
// foreach( $posts as $post )
|
248 |
+
}
|
249 |
+
// if($posts)
|
250 |
+
}
|
251 |
+
// foreach( $field['post_type'] as $post_type )
|
252 |
+
|
253 |
+
|
254 |
+
// create field
|
255 |
+
do_action('acf/create_field', $field );
|
256 |
+
}
|
257 |
+
|
258 |
+
|
259 |
+
/*
|
260 |
+
* create_options()
|
261 |
+
*
|
262 |
+
* Create extra options for your field. This is rendered when editing a field.
|
263 |
+
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
264 |
+
*
|
265 |
+
* @type action
|
266 |
+
* @since 3.6
|
267 |
+
* @date 23/01/13
|
268 |
+
*
|
269 |
+
* @param $field - an array holding all the field's data
|
270 |
+
*/
|
271 |
+
|
272 |
+
function create_options( $field )
|
273 |
+
{
|
274 |
+
// vars
|
275 |
+
$key = $field['name'];
|
276 |
+
|
277 |
+
?>
|
278 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
279 |
+
<td class="label">
|
280 |
+
<label for=""><?php _e("Post Type",'acf'); ?></label>
|
281 |
+
</td>
|
282 |
+
<td>
|
283 |
+
<?php
|
284 |
+
|
285 |
+
$choices = array(
|
286 |
+
'all' => __("All",'acf')
|
287 |
+
);
|
288 |
+
$choices = apply_filters('acf/get_post_types', $choices);
|
289 |
+
|
290 |
+
|
291 |
+
do_action('acf/create_field', array(
|
292 |
+
'type' => 'select',
|
293 |
+
'name' => 'fields['.$key.'][post_type]',
|
294 |
+
'value' => $field['post_type'],
|
295 |
+
'choices' => $choices,
|
296 |
+
'multiple' => 1,
|
297 |
+
));
|
298 |
+
|
299 |
+
?>
|
300 |
+
</td>
|
301 |
+
</tr>
|
302 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
303 |
+
<td class="label">
|
304 |
+
<label><?php _e("Filter from Taxonomy",'acf'); ?></label>
|
305 |
+
</td>
|
306 |
+
<td>
|
307 |
+
<?php
|
308 |
+
$choices = array(
|
309 |
+
'' => array(
|
310 |
+
'all' => __("All",'acf')
|
311 |
+
)
|
312 |
+
);
|
313 |
+
$simple_value = false;
|
314 |
+
$choices = apply_filters('acf/get_taxonomies_for_select', $choices, $simple_value);
|
315 |
+
|
316 |
+
do_action('acf/create_field', array(
|
317 |
+
'type' => 'select',
|
318 |
+
'name' => 'fields['.$key.'][taxonomy]',
|
319 |
+
'value' => $field['taxonomy'],
|
320 |
+
'choices' => $choices,
|
321 |
+
'multiple' => 1,
|
322 |
+
));
|
323 |
+
|
324 |
+
?>
|
325 |
+
</td>
|
326 |
+
</tr>
|
327 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
328 |
+
<td class="label">
|
329 |
+
<label><?php _e("Allow Null?",'acf'); ?></label>
|
330 |
+
</td>
|
331 |
+
<td>
|
332 |
+
<?php
|
333 |
+
|
334 |
+
do_action('acf/create_field', array(
|
335 |
+
'type' => 'radio',
|
336 |
+
'name' => 'fields['.$key.'][allow_null]',
|
337 |
+
'value' => $field['allow_null'],
|
338 |
+
'choices' => array(
|
339 |
+
1 => __("Yes",'acf'),
|
340 |
+
0 => __("No",'acf'),
|
341 |
+
),
|
342 |
+
'layout' => 'horizontal',
|
343 |
+
));
|
344 |
+
|
345 |
+
?>
|
346 |
+
</td>
|
347 |
+
</tr>
|
348 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
349 |
+
<td class="label">
|
350 |
+
<label><?php _e("Select multiple values?",'acf'); ?></label>
|
351 |
+
</td>
|
352 |
+
<td>
|
353 |
+
<?php
|
354 |
+
|
355 |
+
do_action('acf/create_field', array(
|
356 |
+
'type' => 'radio',
|
357 |
+
'name' => 'fields['.$key.'][multiple]',
|
358 |
+
'value' => $field['multiple'],
|
359 |
+
'choices' => array(
|
360 |
+
1 => __("Yes",'acf'),
|
361 |
+
0 => __("No",'acf'),
|
362 |
+
),
|
363 |
+
'layout' => 'horizontal',
|
364 |
+
));
|
365 |
+
|
366 |
+
?>
|
367 |
+
</td>
|
368 |
+
</tr>
|
369 |
+
<?php
|
370 |
+
|
371 |
+
}
|
372 |
+
|
373 |
+
|
374 |
+
/*
|
375 |
+
* format_value()
|
376 |
+
*
|
377 |
+
* This filter is appied to the $value after it is loaded from the db and before it is passed to the create_field action
|
378 |
+
*
|
379 |
+
* @type filter
|
380 |
+
* @since 3.6
|
381 |
+
* @date 23/01/13
|
382 |
+
*
|
383 |
+
* @param $value - the value which was loaded from the database
|
384 |
+
* @param $post_id - the $post_id from which the value was loaded
|
385 |
+
* @param $field - the field array holding all the field options
|
386 |
+
*
|
387 |
+
* @return $value - the modified value
|
388 |
+
*/
|
389 |
+
|
390 |
+
function format_value( $value, $post_id, $field )
|
391 |
+
{
|
392 |
+
// empty?
|
393 |
+
if( !empty($value) )
|
394 |
+
{
|
395 |
+
// convert to integers
|
396 |
+
if( is_array($value) )
|
397 |
+
{
|
398 |
+
$value = array_map('intval', $value);
|
399 |
+
}
|
400 |
+
else
|
401 |
+
{
|
402 |
+
$value = intval($value);
|
403 |
+
}
|
404 |
+
}
|
405 |
+
|
406 |
+
|
407 |
+
// return value
|
408 |
+
return $value;
|
409 |
+
}
|
410 |
+
|
411 |
+
|
412 |
+
/*
|
413 |
+
* format_value_for_api()
|
414 |
+
*
|
415 |
+
* This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
|
416 |
+
*
|
417 |
+
* @type filter
|
418 |
+
* @since 3.6
|
419 |
+
* @date 23/01/13
|
420 |
+
*
|
421 |
+
* @param $value - the value which was loaded from the database
|
422 |
+
* @param $post_id - the $post_id from which the value was loaded
|
423 |
+
* @param $field - the field array holding all the field options
|
424 |
+
*
|
425 |
+
* @return $value - the modified value
|
426 |
+
*/
|
427 |
+
|
428 |
+
function format_value_for_api( $value, $post_id, $field )
|
429 |
+
{
|
430 |
+
// no value?
|
431 |
+
if( !$value )
|
432 |
+
{
|
433 |
+
return false;
|
434 |
+
}
|
435 |
+
|
436 |
+
|
437 |
+
// null?
|
438 |
+
if( $value == 'null' )
|
439 |
+
{
|
440 |
+
return false;
|
441 |
+
}
|
442 |
+
|
443 |
+
|
444 |
+
// multiple / single
|
445 |
+
if( is_array($value) )
|
446 |
+
{
|
447 |
+
// find posts (DISTINCT POSTS)
|
448 |
+
$posts = get_posts(array(
|
449 |
+
'numberposts' => -1,
|
450 |
+
'post__in' => $value,
|
451 |
+
'post_type' => apply_filters('acf/get_post_types', array()),
|
452 |
+
'post_status' => array('publish', 'private', 'draft', 'inherit', 'future'),
|
453 |
+
));
|
454 |
+
|
455 |
+
|
456 |
+
$ordered_posts = array();
|
457 |
+
foreach( $posts as $post )
|
458 |
+
{
|
459 |
+
// create array to hold value data
|
460 |
+
$ordered_posts[ $post->ID ] = $post;
|
461 |
+
}
|
462 |
+
|
463 |
+
|
464 |
+
// override value array with attachments
|
465 |
+
foreach( $value as $k => $v)
|
466 |
+
{
|
467 |
+
// check that post exists (my have been trashed)
|
468 |
+
if( !isset($ordered_posts[ $v ]) )
|
469 |
+
{
|
470 |
+
unset( $value[ $k ] );
|
471 |
+
}
|
472 |
+
else
|
473 |
+
{
|
474 |
+
$value[ $k ] = $ordered_posts[ $v ];
|
475 |
+
}
|
476 |
+
}
|
477 |
+
|
478 |
+
}
|
479 |
+
else
|
480 |
+
{
|
481 |
+
$value = get_post($value);
|
482 |
+
}
|
483 |
+
|
484 |
+
|
485 |
+
// return the value
|
486 |
+
return $value;
|
487 |
+
}
|
488 |
+
|
489 |
+
|
490 |
+
/*
|
491 |
+
* update_value()
|
492 |
+
*
|
493 |
+
* This filter is appied to the $value before it is updated in the db
|
494 |
+
*
|
495 |
+
* @type filter
|
496 |
+
* @since 3.6
|
497 |
+
* @date 23/01/13
|
498 |
+
*
|
499 |
+
* @param $value - the value which will be saved in the database
|
500 |
+
* @param $post_id - the $post_id of which the value will be saved
|
501 |
+
* @param $field - the field array holding all the field options
|
502 |
+
*
|
503 |
+
* @return $value - the modified value
|
504 |
+
*/
|
505 |
+
|
506 |
+
function update_value( $value, $post_id, $field )
|
507 |
+
{
|
508 |
+
// validate
|
509 |
+
if( empty($value) )
|
510 |
+
{
|
511 |
+
return $value;
|
512 |
+
}
|
513 |
+
|
514 |
+
|
515 |
+
if( is_object($value) && isset($value->ID) )
|
516 |
+
{
|
517 |
+
// object
|
518 |
+
$value = $value->ID;
|
519 |
+
|
520 |
+
}
|
521 |
+
elseif( is_array($value) )
|
522 |
+
{
|
523 |
+
// array
|
524 |
+
foreach( $value as $k => $v ){
|
525 |
+
|
526 |
+
// object?
|
527 |
+
if( is_object($v) && isset($v->ID) )
|
528 |
+
{
|
529 |
+
$value[ $k ] = $v->ID;
|
530 |
+
}
|
531 |
+
}
|
532 |
+
|
533 |
+
// save value as strings, so we can clearly search for them in SQL LIKE statements
|
534 |
+
$value = array_map('strval', $value);
|
535 |
+
|
536 |
+
}
|
537 |
+
|
538 |
+
return $value;
|
539 |
+
}
|
540 |
+
|
541 |
+
}
|
542 |
+
|
543 |
+
new acf_field_post_object();
|
544 |
+
|
545 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/fields/radio.php
CHANGED
@@ -1,280 +1,280 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_field_radio extends acf_field
|
4 |
-
{
|
5 |
-
/*
|
6 |
-
* __construct
|
7 |
-
*
|
8 |
-
* Set name / label needed for actions / filters
|
9 |
-
*
|
10 |
-
* @since 3.6
|
11 |
-
* @date 23/01/13
|
12 |
-
*/
|
13 |
-
|
14 |
-
function __construct()
|
15 |
-
{
|
16 |
-
// vars
|
17 |
-
$this->name = 'radio';
|
18 |
-
$this->label = __("Radio Button",'acf');
|
19 |
-
$this->category = __("Choice",'acf');
|
20 |
-
$this->defaults = array(
|
21 |
-
'layout' => 'vertical',
|
22 |
-
'choices' => array(),
|
23 |
-
'default_value' => '',
|
24 |
-
'other_choice' => 0,
|
25 |
-
'save_other_choice' => 0,
|
26 |
-
);
|
27 |
-
|
28 |
-
|
29 |
-
// do not delete!
|
30 |
-
parent::__construct();
|
31 |
-
|
32 |
-
}
|
33 |
-
|
34 |
-
|
35 |
-
/*
|
36 |
-
* create_field()
|
37 |
-
*
|
38 |
-
* Create the HTML interface for your field
|
39 |
-
*
|
40 |
-
* @param $field - an array holding all the field's data
|
41 |
-
*
|
42 |
-
* @type action
|
43 |
-
* @since 3.6
|
44 |
-
* @date 23/01/13
|
45 |
-
*/
|
46 |
-
|
47 |
-
function create_field( $field )
|
48 |
-
{
|
49 |
-
// vars
|
50 |
-
$i = 0;
|
51 |
-
$e = '<ul class="acf-radio-list ' . esc_attr($field['class']) . ' ' . esc_attr($field['layout']) . '">';
|
52 |
-
|
53 |
-
|
54 |
-
// add choices
|
55 |
-
if( is_array($field['choices']) )
|
56 |
-
{
|
57 |
-
foreach( $field['choices'] as $key => $value )
|
58 |
-
{
|
59 |
-
// vars
|
60 |
-
$i++;
|
61 |
-
$atts = '';
|
62 |
-
|
63 |
-
|
64 |
-
// if there is no value and this is the first of the choices, select this on by default
|
65 |
-
if( $field['value'] === false )
|
66 |
-
{
|
67 |
-
if( $i === 1 )
|
68 |
-
{
|
69 |
-
$atts = 'checked="checked" data-checked="checked"';
|
70 |
-
}
|
71 |
-
}
|
72 |
-
else
|
73 |
-
{
|
74 |
-
if( strval($key) === strval($field['value']) )
|
75 |
-
{
|
76 |
-
$atts = 'checked="checked" data-checked="checked"';
|
77 |
-
}
|
78 |
-
}
|
79 |
-
|
80 |
-
|
81 |
-
// HTML
|
82 |
-
$e .= '<li><label><input id="' . esc_attr($field['id']) . '-' . esc_attr($key) . '" type="radio" name="' . esc_attr($field['name']) . '" value="' . esc_attr($key) . '" ' . esc_attr( $atts ) . ' />' . $value . '</label></li>';
|
83 |
-
}
|
84 |
-
}
|
85 |
-
|
86 |
-
|
87 |
-
// other choice
|
88 |
-
if( $field['other_choice'] )
|
89 |
-
{
|
90 |
-
// vars
|
91 |
-
$atts = '';
|
92 |
-
$atts2 = 'name="" value="" style="display:none"';
|
93 |
-
|
94 |
-
|
95 |
-
if( $field['value'] !== false )
|
96 |
-
{
|
97 |
-
if( !isset($field['choices'][ $field['value'] ]) )
|
98 |
-
{
|
99 |
-
$atts = 'checked="checked" data-checked="checked"';
|
100 |
-
$atts2 = 'name="' . esc_attr($field['name']) . '" value="' . esc_attr($field['value']) . '"' ;
|
101 |
-
}
|
102 |
-
}
|
103 |
-
|
104 |
-
|
105 |
-
$e .= '<li><label><input id="' . esc_attr($field['id']) . '-other" type="radio" name="' . esc_attr($field['name']) . '" value="other" ' . $atts . ' />' . __("Other", 'acf') . '</label> <input type="text" ' . $atts2 . ' /></li>';
|
106 |
-
}
|
107 |
-
|
108 |
-
|
109 |
-
$e .= '</ul>';
|
110 |
-
|
111 |
-
echo $e;
|
112 |
-
|
113 |
-
}
|
114 |
-
|
115 |
-
|
116 |
-
/*
|
117 |
-
* create_options()
|
118 |
-
*
|
119 |
-
* Create extra options for your field. This is rendered when editing a field.
|
120 |
-
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
121 |
-
*
|
122 |
-
* @type action
|
123 |
-
* @since 3.6
|
124 |
-
* @date 23/01/13
|
125 |
-
*
|
126 |
-
* @param $field - an array holding all the field's data
|
127 |
-
*/
|
128 |
-
|
129 |
-
function create_options( $field )
|
130 |
-
{
|
131 |
-
// vars
|
132 |
-
$key = $field['name'];
|
133 |
-
|
134 |
-
// implode checkboxes so they work in a textarea
|
135 |
-
if( is_array($field['choices']) )
|
136 |
-
{
|
137 |
-
foreach( $field['choices'] as $k => $v )
|
138 |
-
{
|
139 |
-
$field['choices'][ $k ] = $k . ' : ' . $v;
|
140 |
-
}
|
141 |
-
$field['choices'] = implode("\n", $field['choices']);
|
142 |
-
}
|
143 |
-
|
144 |
-
?>
|
145 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
146 |
-
<td class="label">
|
147 |
-
<label for=""><?php _e("Choices",'acf'); ?></label>
|
148 |
-
<p class="description"><?php _e("Enter your choices one per line",'acf'); ?><br />
|
149 |
-
<br />
|
150 |
-
<?php _e("Red",'acf'); ?><br />
|
151 |
-
<?php _e("Blue",'acf'); ?><br />
|
152 |
-
<br />
|
153 |
-
<?php _e("red : Red",'acf'); ?><br />
|
154 |
-
<?php _e("blue : Blue",'acf'); ?><br />
|
155 |
-
</p>
|
156 |
-
</td>
|
157 |
-
<td>
|
158 |
-
<?php
|
159 |
-
|
160 |
-
do_action('acf/create_field', array(
|
161 |
-
'type' => 'textarea',
|
162 |
-
'class' => 'textarea field_option-choices',
|
163 |
-
'name' => 'fields['.$key.'][choices]',
|
164 |
-
'value' => $field['choices'],
|
165 |
-
));
|
166 |
-
|
167 |
-
?>
|
168 |
-
<div class="radio-option-other_choice">
|
169 |
-
<?php
|
170 |
-
|
171 |
-
do_action('acf/create_field', array(
|
172 |
-
'type' => 'true_false',
|
173 |
-
'name' => 'fields['.$key.'][other_choice]',
|
174 |
-
'value' => $field['other_choice'],
|
175 |
-
'message' => __("Add 'other' choice to allow for custom values", 'acf')
|
176 |
-
));
|
177 |
-
|
178 |
-
?>
|
179 |
-
</div>
|
180 |
-
<div class="radio-option-save_other_choice" <?php if( !$field['other_choice'] ): ?>style="display:none"<?php endif; ?>>
|
181 |
-
<?php
|
182 |
-
|
183 |
-
do_action('acf/create_field', array(
|
184 |
-
'type' => 'true_false',
|
185 |
-
'name' => 'fields['.$key.'][save_other_choice]',
|
186 |
-
'value' => $field['save_other_choice'],
|
187 |
-
'message' => __("Save 'other' values to the field's choices", 'acf')
|
188 |
-
));
|
189 |
-
|
190 |
-
?>
|
191 |
-
</div>
|
192 |
-
</td>
|
193 |
-
</tr>
|
194 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
195 |
-
<td class="label">
|
196 |
-
<label><?php _e("Default Value",'acf'); ?></label>
|
197 |
-
</td>
|
198 |
-
<td>
|
199 |
-
<?php
|
200 |
-
|
201 |
-
do_action('acf/create_field', array(
|
202 |
-
'type' => 'text',
|
203 |
-
'name' => 'fields['.$key.'][default_value]',
|
204 |
-
'value' => $field['default_value'],
|
205 |
-
));
|
206 |
-
|
207 |
-
?>
|
208 |
-
</td>
|
209 |
-
</tr>
|
210 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
211 |
-
<td class="label">
|
212 |
-
<label for=""><?php _e("Layout",'acf'); ?></label>
|
213 |
-
</td>
|
214 |
-
<td>
|
215 |
-
<?php
|
216 |
-
|
217 |
-
do_action('acf/create_field', array(
|
218 |
-
'type' => 'radio',
|
219 |
-
'name' => 'fields['.$key.'][layout]',
|
220 |
-
'value' => $field['layout'],
|
221 |
-
'layout' => 'horizontal',
|
222 |
-
'choices' => array(
|
223 |
-
'vertical' => __("Vertical",'acf'),
|
224 |
-
'horizontal' => __("Horizontal",'acf')
|
225 |
-
)
|
226 |
-
));
|
227 |
-
|
228 |
-
?>
|
229 |
-
</td>
|
230 |
-
</tr>
|
231 |
-
<?php
|
232 |
-
|
233 |
-
}
|
234 |
-
|
235 |
-
|
236 |
-
/*
|
237 |
-
* update_value()
|
238 |
-
*
|
239 |
-
* This filter is appied to the $value before it is updated in the db
|
240 |
-
*
|
241 |
-
* @type filter
|
242 |
-
* @since 3.6
|
243 |
-
* @date 23/01/13
|
244 |
-
*
|
245 |
-
* @param $value - the value which will be saved in the database
|
246 |
-
* @param $post_id - the $post_id of which the value will be saved
|
247 |
-
* @param $field - the field array holding all the field options
|
248 |
-
*
|
249 |
-
* @return $value - the modified value
|
250 |
-
*/
|
251 |
-
|
252 |
-
function update_value( $value, $post_id, $field )
|
253 |
-
{
|
254 |
-
// validate
|
255 |
-
if( $field['save_other_choice'] )
|
256 |
-
{
|
257 |
-
// value isn't in choices yet
|
258 |
-
if( !isset($field['choices'][ $value ]) )
|
259 |
-
{
|
260 |
-
// update $field
|
261 |
-
$field['choices'][ $value ] = $value;
|
262 |
-
|
263 |
-
|
264 |
-
// can save
|
265 |
-
if( isset($field['field_group']) )
|
266 |
-
{
|
267 |
-
do_action('acf/update_field', $field, $field['field_group']);
|
268 |
-
}
|
269 |
-
|
270 |
-
}
|
271 |
-
}
|
272 |
-
|
273 |
-
return $value;
|
274 |
-
}
|
275 |
-
|
276 |
-
}
|
277 |
-
|
278 |
-
new acf_field_radio();
|
279 |
-
|
280 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class acf_field_radio extends acf_field
|
4 |
+
{
|
5 |
+
/*
|
6 |
+
* __construct
|
7 |
+
*
|
8 |
+
* Set name / label needed for actions / filters
|
9 |
+
*
|
10 |
+
* @since 3.6
|
11 |
+
* @date 23/01/13
|
12 |
+
*/
|
13 |
+
|
14 |
+
function __construct()
|
15 |
+
{
|
16 |
+
// vars
|
17 |
+
$this->name = 'radio';
|
18 |
+
$this->label = __("Radio Button",'acf');
|
19 |
+
$this->category = __("Choice",'acf');
|
20 |
+
$this->defaults = array(
|
21 |
+
'layout' => 'vertical',
|
22 |
+
'choices' => array(),
|
23 |
+
'default_value' => '',
|
24 |
+
'other_choice' => 0,
|
25 |
+
'save_other_choice' => 0,
|
26 |
+
);
|
27 |
+
|
28 |
+
|
29 |
+
// do not delete!
|
30 |
+
parent::__construct();
|
31 |
+
|
32 |
+
}
|
33 |
+
|
34 |
+
|
35 |
+
/*
|
36 |
+
* create_field()
|
37 |
+
*
|
38 |
+
* Create the HTML interface for your field
|
39 |
+
*
|
40 |
+
* @param $field - an array holding all the field's data
|
41 |
+
*
|
42 |
+
* @type action
|
43 |
+
* @since 3.6
|
44 |
+
* @date 23/01/13
|
45 |
+
*/
|
46 |
+
|
47 |
+
function create_field( $field )
|
48 |
+
{
|
49 |
+
// vars
|
50 |
+
$i = 0;
|
51 |
+
$e = '<ul class="acf-radio-list ' . esc_attr($field['class']) . ' ' . esc_attr($field['layout']) . '">';
|
52 |
+
|
53 |
+
|
54 |
+
// add choices
|
55 |
+
if( is_array($field['choices']) )
|
56 |
+
{
|
57 |
+
foreach( $field['choices'] as $key => $value )
|
58 |
+
{
|
59 |
+
// vars
|
60 |
+
$i++;
|
61 |
+
$atts = '';
|
62 |
+
|
63 |
+
|
64 |
+
// if there is no value and this is the first of the choices, select this on by default
|
65 |
+
if( $field['value'] === false )
|
66 |
+
{
|
67 |
+
if( $i === 1 )
|
68 |
+
{
|
69 |
+
$atts = 'checked="checked" data-checked="checked"';
|
70 |
+
}
|
71 |
+
}
|
72 |
+
else
|
73 |
+
{
|
74 |
+
if( strval($key) === strval($field['value']) )
|
75 |
+
{
|
76 |
+
$atts = 'checked="checked" data-checked="checked"';
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
|
81 |
+
// HTML
|
82 |
+
$e .= '<li><label><input id="' . esc_attr($field['id']) . '-' . esc_attr($key) . '" type="radio" name="' . esc_attr($field['name']) . '" value="' . esc_attr($key) . '" ' . esc_attr( $atts ) . ' />' . $value . '</label></li>';
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
|
87 |
+
// other choice
|
88 |
+
if( $field['other_choice'] )
|
89 |
+
{
|
90 |
+
// vars
|
91 |
+
$atts = '';
|
92 |
+
$atts2 = 'name="" value="" style="display:none"';
|
93 |
+
|
94 |
+
|
95 |
+
if( $field['value'] !== false )
|
96 |
+
{
|
97 |
+
if( !isset($field['choices'][ $field['value'] ]) )
|
98 |
+
{
|
99 |
+
$atts = 'checked="checked" data-checked="checked"';
|
100 |
+
$atts2 = 'name="' . esc_attr($field['name']) . '" value="' . esc_attr($field['value']) . '"' ;
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
|
105 |
+
$e .= '<li><label><input id="' . esc_attr($field['id']) . '-other" type="radio" name="' . esc_attr($field['name']) . '" value="other" ' . $atts . ' />' . __("Other", 'acf') . '</label> <input type="text" ' . $atts2 . ' /></li>';
|
106 |
+
}
|
107 |
+
|
108 |
+
|
109 |
+
$e .= '</ul>';
|
110 |
+
|
111 |
+
echo $e;
|
112 |
+
|
113 |
+
}
|
114 |
+
|
115 |
+
|
116 |
+
/*
|
117 |
+
* create_options()
|
118 |
+
*
|
119 |
+
* Create extra options for your field. This is rendered when editing a field.
|
120 |
+
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
121 |
+
*
|
122 |
+
* @type action
|
123 |
+
* @since 3.6
|
124 |
+
* @date 23/01/13
|
125 |
+
*
|
126 |
+
* @param $field - an array holding all the field's data
|
127 |
+
*/
|
128 |
+
|
129 |
+
function create_options( $field )
|
130 |
+
{
|
131 |
+
// vars
|
132 |
+
$key = $field['name'];
|
133 |
+
|
134 |
+
// implode checkboxes so they work in a textarea
|
135 |
+
if( is_array($field['choices']) )
|
136 |
+
{
|
137 |
+
foreach( $field['choices'] as $k => $v )
|
138 |
+
{
|
139 |
+
$field['choices'][ $k ] = $k . ' : ' . $v;
|
140 |
+
}
|
141 |
+
$field['choices'] = implode("\n", $field['choices']);
|
142 |
+
}
|
143 |
+
|
144 |
+
?>
|
145 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
146 |
+
<td class="label">
|
147 |
+
<label for=""><?php _e("Choices",'acf'); ?></label>
|
148 |
+
<p class="description"><?php _e("Enter your choices one per line",'acf'); ?><br />
|
149 |
+
<br />
|
150 |
+
<?php _e("Red",'acf'); ?><br />
|
151 |
+
<?php _e("Blue",'acf'); ?><br />
|
152 |
+
<br />
|
153 |
+
<?php _e("red : Red",'acf'); ?><br />
|
154 |
+
<?php _e("blue : Blue",'acf'); ?><br />
|
155 |
+
</p>
|
156 |
+
</td>
|
157 |
+
<td>
|
158 |
+
<?php
|
159 |
+
|
160 |
+
do_action('acf/create_field', array(
|
161 |
+
'type' => 'textarea',
|
162 |
+
'class' => 'textarea field_option-choices',
|
163 |
+
'name' => 'fields['.$key.'][choices]',
|
164 |
+
'value' => $field['choices'],
|
165 |
+
));
|
166 |
+
|
167 |
+
?>
|
168 |
+
<div class="radio-option-other_choice">
|
169 |
+
<?php
|
170 |
+
|
171 |
+
do_action('acf/create_field', array(
|
172 |
+
'type' => 'true_false',
|
173 |
+
'name' => 'fields['.$key.'][other_choice]',
|
174 |
+
'value' => $field['other_choice'],
|
175 |
+
'message' => __("Add 'other' choice to allow for custom values", 'acf')
|
176 |
+
));
|
177 |
+
|
178 |
+
?>
|
179 |
+
</div>
|
180 |
+
<div class="radio-option-save_other_choice" <?php if( !$field['other_choice'] ): ?>style="display:none"<?php endif; ?>>
|
181 |
+
<?php
|
182 |
+
|
183 |
+
do_action('acf/create_field', array(
|
184 |
+
'type' => 'true_false',
|
185 |
+
'name' => 'fields['.$key.'][save_other_choice]',
|
186 |
+
'value' => $field['save_other_choice'],
|
187 |
+
'message' => __("Save 'other' values to the field's choices", 'acf')
|
188 |
+
));
|
189 |
+
|
190 |
+
?>
|
191 |
+
</div>
|
192 |
+
</td>
|
193 |
+
</tr>
|
194 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
195 |
+
<td class="label">
|
196 |
+
<label><?php _e("Default Value",'acf'); ?></label>
|
197 |
+
</td>
|
198 |
+
<td>
|
199 |
+
<?php
|
200 |
+
|
201 |
+
do_action('acf/create_field', array(
|
202 |
+
'type' => 'text',
|
203 |
+
'name' => 'fields['.$key.'][default_value]',
|
204 |
+
'value' => $field['default_value'],
|
205 |
+
));
|
206 |
+
|
207 |
+
?>
|
208 |
+
</td>
|
209 |
+
</tr>
|
210 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
211 |
+
<td class="label">
|
212 |
+
<label for=""><?php _e("Layout",'acf'); ?></label>
|
213 |
+
</td>
|
214 |
+
<td>
|
215 |
+
<?php
|
216 |
+
|
217 |
+
do_action('acf/create_field', array(
|
218 |
+
'type' => 'radio',
|
219 |
+
'name' => 'fields['.$key.'][layout]',
|
220 |
+
'value' => $field['layout'],
|
221 |
+
'layout' => 'horizontal',
|
222 |
+
'choices' => array(
|
223 |
+
'vertical' => __("Vertical",'acf'),
|
224 |
+
'horizontal' => __("Horizontal",'acf')
|
225 |
+
)
|
226 |
+
));
|
227 |
+
|
228 |
+
?>
|
229 |
+
</td>
|
230 |
+
</tr>
|
231 |
+
<?php
|
232 |
+
|
233 |
+
}
|
234 |
+
|
235 |
+
|
236 |
+
/*
|
237 |
+
* update_value()
|
238 |
+
*
|
239 |
+
* This filter is appied to the $value before it is updated in the db
|
240 |
+
*
|
241 |
+
* @type filter
|
242 |
+
* @since 3.6
|
243 |
+
* @date 23/01/13
|
244 |
+
*
|
245 |
+
* @param $value - the value which will be saved in the database
|
246 |
+
* @param $post_id - the $post_id of which the value will be saved
|
247 |
+
* @param $field - the field array holding all the field options
|
248 |
+
*
|
249 |
+
* @return $value - the modified value
|
250 |
+
*/
|
251 |
+
|
252 |
+
function update_value( $value, $post_id, $field )
|
253 |
+
{
|
254 |
+
// validate
|
255 |
+
if( $field['save_other_choice'] )
|
256 |
+
{
|
257 |
+
// value isn't in choices yet
|
258 |
+
if( !isset($field['choices'][ $value ]) )
|
259 |
+
{
|
260 |
+
// update $field
|
261 |
+
$field['choices'][ $value ] = $value;
|
262 |
+
|
263 |
+
|
264 |
+
// can save
|
265 |
+
if( isset($field['field_group']) )
|
266 |
+
{
|
267 |
+
do_action('acf/update_field', $field, $field['field_group']);
|
268 |
+
}
|
269 |
+
|
270 |
+
}
|
271 |
+
}
|
272 |
+
|
273 |
+
return $value;
|
274 |
+
}
|
275 |
+
|
276 |
+
}
|
277 |
+
|
278 |
+
new acf_field_radio();
|
279 |
+
|
280 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/fields/relationship.php
CHANGED
@@ -1,905 +1,905 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_field_relationship extends acf_field
|
4 |
-
{
|
5 |
-
/*
|
6 |
-
* __construct
|
7 |
-
*
|
8 |
-
* Set name / label needed for actions / filters
|
9 |
-
*
|
10 |
-
* @since 3.6
|
11 |
-
* @date 23/01/13
|
12 |
-
*/
|
13 |
-
|
14 |
-
function __construct()
|
15 |
-
{
|
16 |
-
// vars
|
17 |
-
$this->name = 'relationship';
|
18 |
-
$this->label = __("Relationship",'acf');
|
19 |
-
$this->category = __("Relational",'acf');
|
20 |
-
$this->defaults = array(
|
21 |
-
'post_type' => array('all'),
|
22 |
-
'max' => '',
|
23 |
-
'taxonomy' => array('all'),
|
24 |
-
'filters' => array('search'),
|
25 |
-
'result_elements' => array('post_title', 'post_type'),
|
26 |
-
'return_format' => 'object'
|
27 |
-
);
|
28 |
-
$this->l10n = array(
|
29 |
-
'max' => __("Maximum values reached ( {max} values )",'acf')
|
30 |
-
);
|
31 |
-
|
32 |
-
|
33 |
-
// do not delete!
|
34 |
-
parent::__construct();
|
35 |
-
|
36 |
-
|
37 |
-
// extra
|
38 |
-
add_action('wp_ajax_acf/fields/relationship/query_posts', array($this, 'query_posts'));
|
39 |
-
add_action('wp_ajax_nopriv_acf/fields/relationship/query_posts', array($this, 'query_posts'));
|
40 |
-
}
|
41 |
-
|
42 |
-
|
43 |
-
/*
|
44 |
-
* load_field()
|
45 |
-
*
|
46 |
-
* This filter is appied to the $field after it is loaded from the database
|
47 |
-
*
|
48 |
-
* @type filter
|
49 |
-
* @since 3.6
|
50 |
-
* @date 23/01/13
|
51 |
-
*
|
52 |
-
* @param $field - the field array holding all the field options
|
53 |
-
*
|
54 |
-
* @return $field - the field array holding all the field options
|
55 |
-
*/
|
56 |
-
|
57 |
-
function load_field( $field )
|
58 |
-
{
|
59 |
-
// validate post_type
|
60 |
-
if( !$field['post_type'] || !is_array($field['post_type']) || in_array('', $field['post_type']) )
|
61 |
-
{
|
62 |
-
$field['post_type'] = array( 'all' );
|
63 |
-
}
|
64 |
-
|
65 |
-
|
66 |
-
// validate taxonomy
|
67 |
-
if( !$field['taxonomy'] || !is_array($field['taxonomy']) || in_array('', $field['taxonomy']) )
|
68 |
-
{
|
69 |
-
$field['taxonomy'] = array( 'all' );
|
70 |
-
}
|
71 |
-
|
72 |
-
|
73 |
-
// validate result_elements
|
74 |
-
if( !is_array( $field['result_elements'] ) )
|
75 |
-
{
|
76 |
-
$field['result_elements'] = array();
|
77 |
-
}
|
78 |
-
|
79 |
-
if( !in_array('post_title', $field['result_elements']) )
|
80 |
-
{
|
81 |
-
$field['result_elements'][] = 'post_title';
|
82 |
-
}
|
83 |
-
|
84 |
-
|
85 |
-
// filters
|
86 |
-
if( !is_array( $field['filters'] ) )
|
87 |
-
{
|
88 |
-
$field['filters'] = array();
|
89 |
-
}
|
90 |
-
|
91 |
-
|
92 |
-
// return
|
93 |
-
return $field;
|
94 |
-
}
|
95 |
-
|
96 |
-
|
97 |
-
/*
|
98 |
-
* get_result
|
99 |
-
*
|
100 |
-
* description
|
101 |
-
*
|
102 |
-
* @type function
|
103 |
-
* @date 5/02/2015
|
104 |
-
* @since 5.1.5
|
105 |
-
*
|
106 |
-
* @param $post_id (int)
|
107 |
-
* @return $post_id (int)
|
108 |
-
*/
|
109 |
-
|
110 |
-
function get_result( $post, $field, $the_post, $options = array() ) {
|
111 |
-
|
112 |
-
// right aligned info
|
113 |
-
$title = '<span class="relationship-item-info">';
|
114 |
-
|
115 |
-
if( in_array('post_type', $field['result_elements']) ) {
|
116 |
-
|
117 |
-
$post_type_object = get_post_type_object( $post->post_type );
|
118 |
-
$title .= $post_type_object->labels->singular_name;
|
119 |
-
|
120 |
-
}
|
121 |
-
|
122 |
-
|
123 |
-
// WPML
|
124 |
-
if( !empty($options['lang']) ) {
|
125 |
-
|
126 |
-
$title .= ' (' . $options['lang'] . ')';
|
127 |
-
|
128 |
-
} elseif( defined('ICL_LANGUAGE_CODE') ) {
|
129 |
-
|
130 |
-
$title .= ' (' . ICL_LANGUAGE_CODE . ')';
|
131 |
-
|
132 |
-
}
|
133 |
-
|
134 |
-
$title .= '</span>';
|
135 |
-
|
136 |
-
|
137 |
-
// featured_image
|
138 |
-
if( in_array('featured_image', $field['result_elements']) ) {
|
139 |
-
|
140 |
-
$image = '';
|
141 |
-
|
142 |
-
if( $post->post_type == 'attachment' ) {
|
143 |
-
|
144 |
-
$image = wp_get_attachment_image( $post->ID, array(21, 21) );
|
145 |
-
|
146 |
-
} else {
|
147 |
-
|
148 |
-
$image = get_the_post_thumbnail( $post->ID, array(21, 21) );
|
149 |
-
|
150 |
-
}
|
151 |
-
|
152 |
-
$title .= '<div class="result-thumbnail">' . $image . '</div>';
|
153 |
-
|
154 |
-
}
|
155 |
-
|
156 |
-
|
157 |
-
// title
|
158 |
-
$post_title = get_the_title( $post->ID );
|
159 |
-
|
160 |
-
|
161 |
-
// empty
|
162 |
-
if( $post_title === '' ) {
|
163 |
-
|
164 |
-
$post_title = __('(no title)', 'acf');
|
165 |
-
|
166 |
-
}
|
167 |
-
|
168 |
-
|
169 |
-
$title .= $post_title;
|
170 |
-
|
171 |
-
|
172 |
-
// status
|
173 |
-
if( get_post_status( $post->ID ) != "publish" ) {
|
174 |
-
|
175 |
-
$title .= ' (' . get_post_status( $post->ID ) . ')';
|
176 |
-
|
177 |
-
}
|
178 |
-
|
179 |
-
|
180 |
-
// filters
|
181 |
-
$title = apply_filters('acf/fields/relationship/result', $title, $post, $field, $the_post);
|
182 |
-
$title = apply_filters('acf/fields/relationship/result/name=' . $field['_name'] , $title, $post, $field, $the_post);
|
183 |
-
$title = apply_filters('acf/fields/relationship/result/key=' . $field['key'], $title, $post, $field, $the_post);
|
184 |
-
|
185 |
-
|
186 |
-
// return
|
187 |
-
return $title;
|
188 |
-
|
189 |
-
}
|
190 |
-
|
191 |
-
|
192 |
-
/*
|
193 |
-
* query_posts
|
194 |
-
*
|
195 |
-
* @description:
|
196 |
-
* @since: 3.6
|
197 |
-
* @created: 27/01/13
|
198 |
-
*/
|
199 |
-
|
200 |
-
function query_posts()
|
201 |
-
{
|
202 |
-
// vars
|
203 |
-
$r = array(
|
204 |
-
'next_page_exists' => 1,
|
205 |
-
'html' => ''
|
206 |
-
);
|
207 |
-
|
208 |
-
|
209 |
-
// options
|
210 |
-
$options = array(
|
211 |
-
'post_type' => 'all',
|
212 |
-
'taxonomy' => 'all',
|
213 |
-
'posts_per_page' => 10,
|
214 |
-
'paged' => 1,
|
215 |
-
'orderby' => 'title',
|
216 |
-
'order' => 'ASC',
|
217 |
-
'post_status' => 'any',
|
218 |
-
'suppress_filters' => false,
|
219 |
-
's' => '',
|
220 |
-
'lang' => false,
|
221 |
-
'update_post_meta_cache' => false,
|
222 |
-
'field_key' => '',
|
223 |
-
'nonce' => '',
|
224 |
-
'ancestor' => false,
|
225 |
-
);
|
226 |
-
|
227 |
-
$options = array_merge( $options, $_POST );
|
228 |
-
|
229 |
-
|
230 |
-
// validate
|
231 |
-
if( ! wp_verify_nonce($options['nonce'], 'acf_nonce') )
|
232 |
-
{
|
233 |
-
die();
|
234 |
-
}
|
235 |
-
|
236 |
-
|
237 |
-
// WPML
|
238 |
-
if( $options['lang'] )
|
239 |
-
{
|
240 |
-
global $sitepress;
|
241 |
-
|
242 |
-
if( !empty($sitepress) )
|
243 |
-
{
|
244 |
-
$sitepress->switch_lang( $options['lang'] );
|
245 |
-
}
|
246 |
-
}
|
247 |
-
|
248 |
-
|
249 |
-
// convert types
|
250 |
-
$options['post_type'] = explode(',', $options['post_type']);
|
251 |
-
$options['taxonomy'] = explode(',', $options['taxonomy']);
|
252 |
-
|
253 |
-
|
254 |
-
// load all post types by default
|
255 |
-
if( in_array('all', $options['post_type']) )
|
256 |
-
{
|
257 |
-
$options['post_type'] = apply_filters('acf/get_post_types', array());
|
258 |
-
}
|
259 |
-
|
260 |
-
|
261 |
-
// attachment doesn't work if it is the only item in an array???
|
262 |
-
if( is_array($options['post_type']) && count($options['post_type']) == 1 )
|
263 |
-
{
|
264 |
-
$options['post_type'] = $options['post_type'][0];
|
265 |
-
}
|
266 |
-
|
267 |
-
|
268 |
-
// create tax queries
|
269 |
-
if( ! in_array('all', $options['taxonomy']) )
|
270 |
-
{
|
271 |
-
// vars
|
272 |
-
$taxonomies = array();
|
273 |
-
$options['tax_query'] = array();
|
274 |
-
|
275 |
-
foreach( $options['taxonomy'] as $v )
|
276 |
-
{
|
277 |
-
|
278 |
-
// find term (find taxonomy!)
|
279 |
-
// $term = array( 0 => $taxonomy, 1 => $term_id )
|
280 |
-
$term = explode(':', $v);
|
281 |
-
|
282 |
-
|
283 |
-
// validate
|
284 |
-
if( !is_array($term) || !isset($term[1]) )
|
285 |
-
{
|
286 |
-
continue;
|
287 |
-
}
|
288 |
-
|
289 |
-
|
290 |
-
// add to tax array
|
291 |
-
$taxonomies[ $term[0] ][] = $term[1];
|
292 |
-
|
293 |
-
}
|
294 |
-
|
295 |
-
|
296 |
-
// now create the tax queries
|
297 |
-
foreach( $taxonomies as $k => $v )
|
298 |
-
{
|
299 |
-
$options['tax_query'][] = array(
|
300 |
-
'taxonomy' => $k,
|
301 |
-
'field' => 'id',
|
302 |
-
'terms' => $v,
|
303 |
-
);
|
304 |
-
}
|
305 |
-
}
|
306 |
-
|
307 |
-
unset( $options['taxonomy'] );
|
308 |
-
|
309 |
-
|
310 |
-
// load field
|
311 |
-
$field = array();
|
312 |
-
if( $options['ancestor'] )
|
313 |
-
{
|
314 |
-
$ancestor = apply_filters('acf/load_field', array(), $options['ancestor'] );
|
315 |
-
$field = acf_get_child_field_from_parent_field( $options['field_key'], $ancestor );
|
316 |
-
}
|
317 |
-
else
|
318 |
-
{
|
319 |
-
$field = apply_filters('acf/load_field', array(), $options['field_key'] );
|
320 |
-
}
|
321 |
-
|
322 |
-
|
323 |
-
// get the post from which this field is rendered on
|
324 |
-
$the_post = get_post( $options['post_id'] );
|
325 |
-
|
326 |
-
|
327 |
-
// filters
|
328 |
-
$options = apply_filters('acf/fields/relationship/query', $options, $field, $the_post);
|
329 |
-
$options = apply_filters('acf/fields/relationship/query/name=' . $field['_name'], $options, $field, $the_post );
|
330 |
-
$options = apply_filters('acf/fields/relationship/query/key=' . $field['key'], $options, $field, $the_post );
|
331 |
-
|
332 |
-
|
333 |
-
// query
|
334 |
-
$wp_query = new WP_Query( $options );
|
335 |
-
|
336 |
-
|
337 |
-
// global
|
338 |
-
global $post;
|
339 |
-
|
340 |
-
|
341 |
-
// loop
|
342 |
-
while( $wp_query->have_posts() ) {
|
343 |
-
|
344 |
-
$wp_query->the_post();
|
345 |
-
|
346 |
-
|
347 |
-
// get title
|
348 |
-
$title = $this->get_result($post, $field, $the_post, $options);
|
349 |
-
|
350 |
-
|
351 |
-
// update html
|
352 |
-
$r['html'] .= '<li><a href="' . get_permalink($post->ID) . '" data-post_id="' . $post->ID . '">' . $title . '<span class="acf-button-add"></span></a></li>';
|
353 |
-
|
354 |
-
}
|
355 |
-
|
356 |
-
|
357 |
-
// next page
|
358 |
-
if( (int)$options['paged'] >= $wp_query->max_num_pages ) {
|
359 |
-
|
360 |
-
$r['next_page_exists'] = 0;
|
361 |
-
|
362 |
-
}
|
363 |
-
|
364 |
-
|
365 |
-
// reset
|
366 |
-
wp_reset_postdata();
|
367 |
-
|
368 |
-
|
369 |
-
// return JSON
|
370 |
-
echo json_encode( $r );
|
371 |
-
|
372 |
-
die();
|
373 |
-
|
374 |
-
}
|
375 |
-
|
376 |
-
|
377 |
-
/*
|
378 |
-
* create_field()
|
379 |
-
*
|
380 |
-
* Create the HTML interface for your field
|
381 |
-
*
|
382 |
-
* @param $field - an array holding all the field's data
|
383 |
-
*
|
384 |
-
* @type action
|
385 |
-
* @since 3.6
|
386 |
-
* @date 23/01/13
|
387 |
-
*/
|
388 |
-
|
389 |
-
function create_field( $field )
|
390 |
-
{
|
391 |
-
// global
|
392 |
-
global $post;
|
393 |
-
|
394 |
-
|
395 |
-
// no row limit?
|
396 |
-
if( !$field['max'] || $field['max'] < 1 )
|
397 |
-
{
|
398 |
-
$field['max'] = 9999;
|
399 |
-
}
|
400 |
-
|
401 |
-
|
402 |
-
// class
|
403 |
-
$class = '';
|
404 |
-
if( $field['filters'] )
|
405 |
-
{
|
406 |
-
foreach( $field['filters'] as $filter )
|
407 |
-
{
|
408 |
-
$class .= ' has-' . $filter;
|
409 |
-
}
|
410 |
-
}
|
411 |
-
|
412 |
-
$attributes = array(
|
413 |
-
'max' => $field['max'],
|
414 |
-
's' => '',
|
415 |
-
'paged' => 1,
|
416 |
-
'post_type' => implode(',', $field['post_type']),
|
417 |
-
'taxonomy' => implode(',', $field['taxonomy']),
|
418 |
-
'field_key' => $field['key']
|
419 |
-
);
|
420 |
-
|
421 |
-
|
422 |
-
// Lang
|
423 |
-
if( defined('ICL_LANGUAGE_CODE') )
|
424 |
-
{
|
425 |
-
$attributes['lang'] = ICL_LANGUAGE_CODE;
|
426 |
-
}
|
427 |
-
|
428 |
-
|
429 |
-
// parent
|
430 |
-
preg_match('/\[(field_.*?)\]/', $field['name'], $ancestor);
|
431 |
-
if( isset($ancestor[1]) && $ancestor[1] != $field['key'])
|
432 |
-
{
|
433 |
-
$attributes['ancestor'] = $ancestor[1];
|
434 |
-
}
|
435 |
-
|
436 |
-
?>
|
437 |
-
<div class="acf_relationship<?php echo $class; ?>"<?php foreach( $attributes as $k => $v ): ?> data-<?php echo $k; ?>="<?php echo $v; ?>"<?php endforeach; ?>>
|
438 |
-
|
439 |
-
|
440 |
-
<!-- Hidden Blank default value -->
|
441 |
-
<input type="hidden" name="<?php echo $field['name']; ?>" value="" />
|
442 |
-
|
443 |
-
|
444 |
-
<!-- Left List -->
|
445 |
-
<div class="relationship_left">
|
446 |
-
<table class="widefat">
|
447 |
-
<thead>
|
448 |
-
<?php if(in_array( 'search', $field['filters']) ): ?>
|
449 |
-
<tr>
|
450 |
-
<th>
|
451 |
-
<input class="relationship_search" placeholder="<?php _e("Search...",'acf'); ?>" type="text" id="relationship_<?php echo $field['name']; ?>" />
|
452 |
-
</th>
|
453 |
-
</tr>
|
454 |
-
<?php endif; ?>
|
455 |
-
<?php if(in_array( 'post_type', $field['filters']) ): ?>
|
456 |
-
<tr>
|
457 |
-
<th>
|
458 |
-
<?php
|
459 |
-
|
460 |
-
// vars
|
461 |
-
$choices = array(
|
462 |
-
'all' => __("Filter by post type",'acf')
|
463 |
-
);
|
464 |
-
|
465 |
-
|
466 |
-
if( in_array('all', $field['post_type']) )
|
467 |
-
{
|
468 |
-
$post_types = apply_filters( 'acf/get_post_types', array() );
|
469 |
-
$choices = array_merge( $choices, $post_types);
|
470 |
-
}
|
471 |
-
else
|
472 |
-
{
|
473 |
-
foreach( $field['post_type'] as $post_type )
|
474 |
-
{
|
475 |
-
$choices[ $post_type ] = $post_type;
|
476 |
-
}
|
477 |
-
}
|
478 |
-
|
479 |
-
|
480 |
-
// create field
|
481 |
-
do_action('acf/create_field', array(
|
482 |
-
'type' => 'select',
|
483 |
-
'name' => '',
|
484 |
-
'class' => 'select-post_type',
|
485 |
-
'value' => '',
|
486 |
-
'choices' => $choices,
|
487 |
-
));
|
488 |
-
|
489 |
-
?>
|
490 |
-
</th>
|
491 |
-
</tr>
|
492 |
-
<?php endif; ?>
|
493 |
-
</thead>
|
494 |
-
</table>
|
495 |
-
<ul class="bl relationship_list">
|
496 |
-
<li class="load-more">
|
497 |
-
<div class="acf-loading"></div>
|
498 |
-
</li>
|
499 |
-
</ul>
|
500 |
-
</div>
|
501 |
-
<!-- /Left List -->
|
502 |
-
|
503 |
-
<!-- Right List -->
|
504 |
-
<div class="relationship_right">
|
505 |
-
<ul class="bl relationship_list">
|
506 |
-
<?php
|
507 |
-
|
508 |
-
if( $field['value'] )
|
509 |
-
{
|
510 |
-
foreach( $field['value'] as $p )
|
511 |
-
{
|
512 |
-
$title = $this->get_result($p, $field, $post);
|
513 |
-
|
514 |
-
|
515 |
-
echo '<li>
|
516 |
-
<a href="' . get_permalink($p->ID) . '" class="" data-post_id="' . $p->ID . '">' . $title . '<span class="acf-button-remove"></span></a>
|
517 |
-
<input type="hidden" name="' . $field['name'] . '[]" value="' . $p->ID . '" />
|
518 |
-
</li>';
|
519 |
-
|
520 |
-
|
521 |
-
}
|
522 |
-
}
|
523 |
-
|
524 |
-
?>
|
525 |
-
</ul>
|
526 |
-
</div>
|
527 |
-
<!-- / Right List -->
|
528 |
-
|
529 |
-
</div>
|
530 |
-
<?php
|
531 |
-
}
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
/*
|
536 |
-
* create_options()
|
537 |
-
*
|
538 |
-
* Create extra options for your field. This is rendered when editing a field.
|
539 |
-
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
540 |
-
*
|
541 |
-
* @type action
|
542 |
-
* @since 3.6
|
543 |
-
* @date 23/01/13
|
544 |
-
*
|
545 |
-
* @param $field - an array holding all the field's data
|
546 |
-
*/
|
547 |
-
|
548 |
-
function create_options( $field )
|
549 |
-
{
|
550 |
-
// vars
|
551 |
-
$key = $field['name'];
|
552 |
-
|
553 |
-
?>
|
554 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
555 |
-
<td class="label">
|
556 |
-
<label><?php _e("Return Format",'acf'); ?></label>
|
557 |
-
<p><?php _e("Specify the returned value on front end",'acf') ?></p>
|
558 |
-
</td>
|
559 |
-
<td>
|
560 |
-
<?php
|
561 |
-
do_action('acf/create_field', array(
|
562 |
-
'type' => 'radio',
|
563 |
-
'name' => 'fields['.$key.'][return_format]',
|
564 |
-
'value' => $field['return_format'],
|
565 |
-
'layout' => 'horizontal',
|
566 |
-
'choices' => array(
|
567 |
-
'object' => __("Post Objects",'acf'),
|
568 |
-
'id' => __("Post IDs",'acf')
|
569 |
-
)
|
570 |
-
));
|
571 |
-
?>
|
572 |
-
</td>
|
573 |
-
</tr>
|
574 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
575 |
-
<td class="label">
|
576 |
-
<label for=""><?php _e("Post Type",'acf'); ?></label>
|
577 |
-
</td>
|
578 |
-
<td>
|
579 |
-
<?php
|
580 |
-
|
581 |
-
$choices = array(
|
582 |
-
'all' => __("All",'acf')
|
583 |
-
);
|
584 |
-
$choices = apply_filters('acf/get_post_types', $choices);
|
585 |
-
|
586 |
-
|
587 |
-
do_action('acf/create_field', array(
|
588 |
-
'type' => 'select',
|
589 |
-
'name' => 'fields['.$key.'][post_type]',
|
590 |
-
'value' => $field['post_type'],
|
591 |
-
'choices' => $choices,
|
592 |
-
'multiple' => 1,
|
593 |
-
));
|
594 |
-
|
595 |
-
?>
|
596 |
-
</td>
|
597 |
-
</tr>
|
598 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
599 |
-
<td class="label">
|
600 |
-
<label><?php _e("Filter from Taxonomy",'acf'); ?></label>
|
601 |
-
</td>
|
602 |
-
<td>
|
603 |
-
<?php
|
604 |
-
$choices = array(
|
605 |
-
'' => array(
|
606 |
-
'all' => __("All",'acf')
|
607 |
-
)
|
608 |
-
);
|
609 |
-
$simple_value = false;
|
610 |
-
$choices = apply_filters('acf/get_taxonomies_for_select', $choices, $simple_value);
|
611 |
-
|
612 |
-
|
613 |
-
do_action('acf/create_field', array(
|
614 |
-
'type' => 'select',
|
615 |
-
'name' => 'fields['.$key.'][taxonomy]',
|
616 |
-
'value' => $field['taxonomy'],
|
617 |
-
'choices' => $choices,
|
618 |
-
'multiple' => 1,
|
619 |
-
));
|
620 |
-
?>
|
621 |
-
</td>
|
622 |
-
</tr>
|
623 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
624 |
-
<td class="label">
|
625 |
-
<label><?php _e("Filters",'acf'); ?></label>
|
626 |
-
</td>
|
627 |
-
<td>
|
628 |
-
<?php
|
629 |
-
do_action('acf/create_field', array(
|
630 |
-
'type' => 'checkbox',
|
631 |
-
'name' => 'fields['.$key.'][filters]',
|
632 |
-
'value' => $field['filters'],
|
633 |
-
'choices' => array(
|
634 |
-
'search' => __("Search",'acf'),
|
635 |
-
'post_type' => __("Post Type Select",'acf'),
|
636 |
-
)
|
637 |
-
));
|
638 |
-
?>
|
639 |
-
</td>
|
640 |
-
</tr>
|
641 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
642 |
-
<td class="label">
|
643 |
-
<label><?php _e("Elements",'acf'); ?></label>
|
644 |
-
<p><?php _e("Selected elements will be displayed in each result",'acf') ?></p>
|
645 |
-
</td>
|
646 |
-
<td>
|
647 |
-
<?php
|
648 |
-
do_action('acf/create_field', array(
|
649 |
-
'type' => 'checkbox',
|
650 |
-
'name' => 'fields['.$key.'][result_elements]',
|
651 |
-
'value' => $field['result_elements'],
|
652 |
-
'choices' => array(
|
653 |
-
'featured_image' => __("Featured Image",'acf'),
|
654 |
-
'post_title' => __("Post Title",'acf'),
|
655 |
-
'post_type' => __("Post Type",'acf'),
|
656 |
-
),
|
657 |
-
'disabled' => array(
|
658 |
-
'post_title'
|
659 |
-
)
|
660 |
-
));
|
661 |
-
?>
|
662 |
-
</td>
|
663 |
-
</tr>
|
664 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
665 |
-
<td class="label">
|
666 |
-
<label><?php _e("Maximum posts",'acf'); ?></label>
|
667 |
-
</td>
|
668 |
-
<td>
|
669 |
-
<?php
|
670 |
-
do_action('acf/create_field', array(
|
671 |
-
'type' => 'number',
|
672 |
-
'name' => 'fields['.$key.'][max]',
|
673 |
-
'value' => $field['max'],
|
674 |
-
));
|
675 |
-
?>
|
676 |
-
</td>
|
677 |
-
</tr>
|
678 |
-
<?php
|
679 |
-
|
680 |
-
}
|
681 |
-
|
682 |
-
|
683 |
-
/*
|
684 |
-
* format_value()
|
685 |
-
*
|
686 |
-
* This filter is appied to the $value after it is loaded from the db and before it is passed to the create_field action
|
687 |
-
*
|
688 |
-
* @type filter
|
689 |
-
* @since 3.6
|
690 |
-
* @date 23/01/13
|
691 |
-
*
|
692 |
-
* @param $value - the value which was loaded from the database
|
693 |
-
* @param $post_id - the $post_id from which the value was loaded
|
694 |
-
* @param $field - the field array holding all the field options
|
695 |
-
*
|
696 |
-
* @return $value - the modified value
|
697 |
-
*/
|
698 |
-
|
699 |
-
function format_value( $value, $post_id, $field )
|
700 |
-
{
|
701 |
-
// empty?
|
702 |
-
if( !empty($value) )
|
703 |
-
{
|
704 |
-
// Pre 3.3.3, the value is a string coma seperated
|
705 |
-
if( is_string($value) )
|
706 |
-
{
|
707 |
-
$value = explode(',', $value);
|
708 |
-
}
|
709 |
-
|
710 |
-
|
711 |
-
// convert to integers
|
712 |
-
if( is_array($value) )
|
713 |
-
{
|
714 |
-
$value = array_map('intval', $value);
|
715 |
-
|
716 |
-
// convert into post objects
|
717 |
-
$value = $this->get_posts( $value );
|
718 |
-
}
|
719 |
-
|
720 |
-
}
|
721 |
-
|
722 |
-
|
723 |
-
// return value
|
724 |
-
return $value;
|
725 |
-
}
|
726 |
-
|
727 |
-
|
728 |
-
/*
|
729 |
-
* format_value_for_api()
|
730 |
-
*
|
731 |
-
* This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
|
732 |
-
*
|
733 |
-
* @type filter
|
734 |
-
* @since 3.6
|
735 |
-
* @date 23/01/13
|
736 |
-
*
|
737 |
-
* @param $value - the value which was loaded from the database
|
738 |
-
* @param $post_id - the $post_id from which the value was loaded
|
739 |
-
* @param $field - the field array holding all the field options
|
740 |
-
*
|
741 |
-
* @return $value - the modified value
|
742 |
-
*/
|
743 |
-
|
744 |
-
function format_value_for_api( $value, $post_id, $field )
|
745 |
-
{
|
746 |
-
// empty?
|
747 |
-
if( !$value )
|
748 |
-
{
|
749 |
-
return $value;
|
750 |
-
}
|
751 |
-
|
752 |
-
|
753 |
-
// Pre 3.3.3, the value is a string coma seperated
|
754 |
-
if( is_string($value) )
|
755 |
-
{
|
756 |
-
$value = explode(',', $value);
|
757 |
-
}
|
758 |
-
|
759 |
-
|
760 |
-
// empty?
|
761 |
-
if( !is_array($value) || empty($value) )
|
762 |
-
{
|
763 |
-
return $value;
|
764 |
-
}
|
765 |
-
|
766 |
-
|
767 |
-
// convert to integers
|
768 |
-
$value = array_map('intval', $value);
|
769 |
-
|
770 |
-
|
771 |
-
// return format
|
772 |
-
if( $field['return_format'] == 'object' )
|
773 |
-
{
|
774 |
-
$value = $this->get_posts( $value );
|
775 |
-
}
|
776 |
-
|
777 |
-
|
778 |
-
// return
|
779 |
-
return $value;
|
780 |
-
|
781 |
-
}
|
782 |
-
|
783 |
-
|
784 |
-
/*
|
785 |
-
* get_posts
|
786 |
-
*
|
787 |
-
* This function will take an array of post_id's ($value) and return an array of post_objects
|
788 |
-
*
|
789 |
-
* @type function
|
790 |
-
* @date 7/08/13
|
791 |
-
*
|
792 |
-
* @param $post_ids (array) the array of post ID's
|
793 |
-
* @return (array) an array of post objects
|
794 |
-
*/
|
795 |
-
|
796 |
-
function get_posts( $post_ids )
|
797 |
-
{
|
798 |
-
// validate
|
799 |
-
if( empty($post_ids) )
|
800 |
-
{
|
801 |
-
return $post_ids;
|
802 |
-
}
|
803 |
-
|
804 |
-
|
805 |
-
// vars
|
806 |
-
$r = array();
|
807 |
-
|
808 |
-
|
809 |
-
// find posts (DISTINCT POSTS)
|
810 |
-
$posts = get_posts(array(
|
811 |
-
'numberposts' => -1,
|
812 |
-
'post__in' => $post_ids,
|
813 |
-
'post_type' => apply_filters('acf/get_post_types', array()),
|
814 |
-
'post_status' => 'any',
|
815 |
-
));
|
816 |
-
|
817 |
-
|
818 |
-
$ordered_posts = array();
|
819 |
-
foreach( $posts as $p )
|
820 |
-
{
|
821 |
-
// create array to hold value data
|
822 |
-
$ordered_posts[ $p->ID ] = $p;
|
823 |
-
}
|
824 |
-
|
825 |
-
|
826 |
-
// override value array with attachments
|
827 |
-
foreach( $post_ids as $k => $v)
|
828 |
-
{
|
829 |
-
// check that post exists (my have been trashed)
|
830 |
-
if( isset($ordered_posts[ $v ]) )
|
831 |
-
{
|
832 |
-
$r[] = $ordered_posts[ $v ];
|
833 |
-
}
|
834 |
-
}
|
835 |
-
|
836 |
-
|
837 |
-
// return
|
838 |
-
return $r;
|
839 |
-
}
|
840 |
-
|
841 |
-
|
842 |
-
/*
|
843 |
-
* update_value()
|
844 |
-
*
|
845 |
-
* This filter is appied to the $value before it is updated in the db
|
846 |
-
*
|
847 |
-
* @type filter
|
848 |
-
* @since 3.6
|
849 |
-
* @date 23/01/13
|
850 |
-
*
|
851 |
-
* @param $value - the value which will be saved in the database
|
852 |
-
* @param $post_id - the $post_id of which the value will be saved
|
853 |
-
* @param $field - the field array holding all the field options
|
854 |
-
*
|
855 |
-
* @return $value - the modified value
|
856 |
-
*/
|
857 |
-
|
858 |
-
function update_value( $value, $post_id, $field )
|
859 |
-
{
|
860 |
-
// validate
|
861 |
-
if( empty($value) )
|
862 |
-
{
|
863 |
-
return $value;
|
864 |
-
}
|
865 |
-
|
866 |
-
|
867 |
-
if( is_string($value) )
|
868 |
-
{
|
869 |
-
// string
|
870 |
-
$value = explode(',', $value);
|
871 |
-
|
872 |
-
}
|
873 |
-
elseif( is_object($value) && isset($value->ID) )
|
874 |
-
{
|
875 |
-
// object
|
876 |
-
$value = array( $value->ID );
|
877 |
-
|
878 |
-
}
|
879 |
-
elseif( is_array($value) )
|
880 |
-
{
|
881 |
-
// array
|
882 |
-
foreach( $value as $k => $v ){
|
883 |
-
|
884 |
-
// object?
|
885 |
-
if( is_object($v) && isset($v->ID) )
|
886 |
-
{
|
887 |
-
$value[ $k ] = $v->ID;
|
888 |
-
}
|
889 |
-
}
|
890 |
-
|
891 |
-
}
|
892 |
-
|
893 |
-
|
894 |
-
// save value as strings, so we can clearly search for them in SQL LIKE statements
|
895 |
-
$value = array_map('strval', $value);
|
896 |
-
|
897 |
-
|
898 |
-
return $value;
|
899 |
-
}
|
900 |
-
|
901 |
-
}
|
902 |
-
|
903 |
-
new acf_field_relationship();
|
904 |
-
|
905 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class acf_field_relationship extends acf_field
|
4 |
+
{
|
5 |
+
/*
|
6 |
+
* __construct
|
7 |
+
*
|
8 |
+
* Set name / label needed for actions / filters
|
9 |
+
*
|
10 |
+
* @since 3.6
|
11 |
+
* @date 23/01/13
|
12 |
+
*/
|
13 |
+
|
14 |
+
function __construct()
|
15 |
+
{
|
16 |
+
// vars
|
17 |
+
$this->name = 'relationship';
|
18 |
+
$this->label = __("Relationship",'acf');
|
19 |
+
$this->category = __("Relational",'acf');
|
20 |
+
$this->defaults = array(
|
21 |
+
'post_type' => array('all'),
|
22 |
+
'max' => '',
|
23 |
+
'taxonomy' => array('all'),
|
24 |
+
'filters' => array('search'),
|
25 |
+
'result_elements' => array('post_title', 'post_type'),
|
26 |
+
'return_format' => 'object'
|
27 |
+
);
|
28 |
+
$this->l10n = array(
|
29 |
+
'max' => __("Maximum values reached ( {max} values )",'acf')
|
30 |
+
);
|
31 |
+
|
32 |
+
|
33 |
+
// do not delete!
|
34 |
+
parent::__construct();
|
35 |
+
|
36 |
+
|
37 |
+
// extra
|
38 |
+
add_action('wp_ajax_acf/fields/relationship/query_posts', array($this, 'query_posts'));
|
39 |
+
add_action('wp_ajax_nopriv_acf/fields/relationship/query_posts', array($this, 'query_posts'));
|
40 |
+
}
|
41 |
+
|
42 |
+
|
43 |
+
/*
|
44 |
+
* load_field()
|
45 |
+
*
|
46 |
+
* This filter is appied to the $field after it is loaded from the database
|
47 |
+
*
|
48 |
+
* @type filter
|
49 |
+
* @since 3.6
|
50 |
+
* @date 23/01/13
|
51 |
+
*
|
52 |
+
* @param $field - the field array holding all the field options
|
53 |
+
*
|
54 |
+
* @return $field - the field array holding all the field options
|
55 |
+
*/
|
56 |
+
|
57 |
+
function load_field( $field )
|
58 |
+
{
|
59 |
+
// validate post_type
|
60 |
+
if( !$field['post_type'] || !is_array($field['post_type']) || in_array('', $field['post_type']) )
|
61 |
+
{
|
62 |
+
$field['post_type'] = array( 'all' );
|
63 |
+
}
|
64 |
+
|
65 |
+
|
66 |
+
// validate taxonomy
|
67 |
+
if( !$field['taxonomy'] || !is_array($field['taxonomy']) || in_array('', $field['taxonomy']) )
|
68 |
+
{
|
69 |
+
$field['taxonomy'] = array( 'all' );
|
70 |
+
}
|
71 |
+
|
72 |
+
|
73 |
+
// validate result_elements
|
74 |
+
if( !is_array( $field['result_elements'] ) )
|
75 |
+
{
|
76 |
+
$field['result_elements'] = array();
|
77 |
+
}
|
78 |
+
|
79 |
+
if( !in_array('post_title', $field['result_elements']) )
|
80 |
+
{
|
81 |
+
$field['result_elements'][] = 'post_title';
|
82 |
+
}
|
83 |
+
|
84 |
+
|
85 |
+
// filters
|
86 |
+
if( !is_array( $field['filters'] ) )
|
87 |
+
{
|
88 |
+
$field['filters'] = array();
|
89 |
+
}
|
90 |
+
|
91 |
+
|
92 |
+
// return
|
93 |
+
return $field;
|
94 |
+
}
|
95 |
+
|
96 |
+
|
97 |
+
/*
|
98 |
+
* get_result
|
99 |
+
*
|
100 |
+
* description
|
101 |
+
*
|
102 |
+
* @type function
|
103 |
+
* @date 5/02/2015
|
104 |
+
* @since 5.1.5
|
105 |
+
*
|
106 |
+
* @param $post_id (int)
|
107 |
+
* @return $post_id (int)
|
108 |
+
*/
|
109 |
+
|
110 |
+
function get_result( $post, $field, $the_post, $options = array() ) {
|
111 |
+
|
112 |
+
// right aligned info
|
113 |
+
$title = '<span class="relationship-item-info">';
|
114 |
+
|
115 |
+
if( in_array('post_type', $field['result_elements']) ) {
|
116 |
+
|
117 |
+
$post_type_object = get_post_type_object( $post->post_type );
|
118 |
+
$title .= $post_type_object->labels->singular_name;
|
119 |
+
|
120 |
+
}
|
121 |
+
|
122 |
+
|
123 |
+
// WPML
|
124 |
+
if( !empty($options['lang']) ) {
|
125 |
+
|
126 |
+
$title .= ' (' . $options['lang'] . ')';
|
127 |
+
|
128 |
+
} elseif( defined('ICL_LANGUAGE_CODE') ) {
|
129 |
+
|
130 |
+
$title .= ' (' . ICL_LANGUAGE_CODE . ')';
|
131 |
+
|
132 |
+
}
|
133 |
+
|
134 |
+
$title .= '</span>';
|
135 |
+
|
136 |
+
|
137 |
+
// featured_image
|
138 |
+
if( in_array('featured_image', $field['result_elements']) ) {
|
139 |
+
|
140 |
+
$image = '';
|
141 |
+
|
142 |
+
if( $post->post_type == 'attachment' ) {
|
143 |
+
|
144 |
+
$image = wp_get_attachment_image( $post->ID, array(21, 21) );
|
145 |
+
|
146 |
+
} else {
|
147 |
+
|
148 |
+
$image = get_the_post_thumbnail( $post->ID, array(21, 21) );
|
149 |
+
|
150 |
+
}
|
151 |
+
|
152 |
+
$title .= '<div class="result-thumbnail">' . $image . '</div>';
|
153 |
+
|
154 |
+
}
|
155 |
+
|
156 |
+
|
157 |
+
// title
|
158 |
+
$post_title = get_the_title( $post->ID );
|
159 |
+
|
160 |
+
|
161 |
+
// empty
|
162 |
+
if( $post_title === '' ) {
|
163 |
+
|
164 |
+
$post_title = __('(no title)', 'acf');
|
165 |
+
|
166 |
+
}
|
167 |
+
|
168 |
+
|
169 |
+
$title .= $post_title;
|
170 |
+
|
171 |
+
|
172 |
+
// status
|
173 |
+
if( get_post_status( $post->ID ) != "publish" ) {
|
174 |
+
|
175 |
+
$title .= ' (' . get_post_status( $post->ID ) . ')';
|
176 |
+
|
177 |
+
}
|
178 |
+
|
179 |
+
|
180 |
+
// filters
|
181 |
+
$title = apply_filters('acf/fields/relationship/result', $title, $post, $field, $the_post);
|
182 |
+
$title = apply_filters('acf/fields/relationship/result/name=' . $field['_name'] , $title, $post, $field, $the_post);
|
183 |
+
$title = apply_filters('acf/fields/relationship/result/key=' . $field['key'], $title, $post, $field, $the_post);
|
184 |
+
|
185 |
+
|
186 |
+
// return
|
187 |
+
return $title;
|
188 |
+
|
189 |
+
}
|
190 |
+
|
191 |
+
|
192 |
+
/*
|
193 |
+
* query_posts
|
194 |
+
*
|
195 |
+
* @description:
|
196 |
+
* @since: 3.6
|
197 |
+
* @created: 27/01/13
|
198 |
+
*/
|
199 |
+
|
200 |
+
function query_posts()
|
201 |
+
{
|
202 |
+
// vars
|
203 |
+
$r = array(
|
204 |
+
'next_page_exists' => 1,
|
205 |
+
'html' => ''
|
206 |
+
);
|
207 |
+
|
208 |
+
|
209 |
+
// options
|
210 |
+
$options = array(
|
211 |
+
'post_type' => 'all',
|
212 |
+
'taxonomy' => 'all',
|
213 |
+
'posts_per_page' => 10,
|
214 |
+
'paged' => 1,
|
215 |
+
'orderby' => 'title',
|
216 |
+
'order' => 'ASC',
|
217 |
+
'post_status' => 'any',
|
218 |
+
'suppress_filters' => false,
|
219 |
+
's' => '',
|
220 |
+
'lang' => false,
|
221 |
+
'update_post_meta_cache' => false,
|
222 |
+
'field_key' => '',
|
223 |
+
'nonce' => '',
|
224 |
+
'ancestor' => false,
|
225 |
+
);
|
226 |
+
|
227 |
+
$options = array_merge( $options, $_POST );
|
228 |
+
|
229 |
+
|
230 |
+
// validate
|
231 |
+
if( ! wp_verify_nonce($options['nonce'], 'acf_nonce') )
|
232 |
+
{
|
233 |
+
die();
|
234 |
+
}
|
235 |
+
|
236 |
+
|
237 |
+
// WPML
|
238 |
+
if( $options['lang'] )
|
239 |
+
{
|
240 |
+
global $sitepress;
|
241 |
+
|
242 |
+
if( !empty($sitepress) )
|
243 |
+
{
|
244 |
+
$sitepress->switch_lang( $options['lang'] );
|
245 |
+
}
|
246 |
+
}
|
247 |
+
|
248 |
+
|
249 |
+
// convert types
|
250 |
+
$options['post_type'] = explode(',', $options['post_type']);
|
251 |
+
$options['taxonomy'] = explode(',', $options['taxonomy']);
|
252 |
+
|
253 |
+
|
254 |
+
// load all post types by default
|
255 |
+
if( in_array('all', $options['post_type']) )
|
256 |
+
{
|
257 |
+
$options['post_type'] = apply_filters('acf/get_post_types', array());
|
258 |
+
}
|
259 |
+
|
260 |
+
|
261 |
+
// attachment doesn't work if it is the only item in an array???
|
262 |
+
if( is_array($options['post_type']) && count($options['post_type']) == 1 )
|
263 |
+
{
|
264 |
+
$options['post_type'] = $options['post_type'][0];
|
265 |
+
}
|
266 |
+
|
267 |
+
|
268 |
+
// create tax queries
|
269 |
+
if( ! in_array('all', $options['taxonomy']) )
|
270 |
+
{
|
271 |
+
// vars
|
272 |
+
$taxonomies = array();
|
273 |
+
$options['tax_query'] = array();
|
274 |
+
|
275 |
+
foreach( $options['taxonomy'] as $v )
|
276 |
+
{
|
277 |
+
|
278 |
+
// find term (find taxonomy!)
|
279 |
+
// $term = array( 0 => $taxonomy, 1 => $term_id )
|
280 |
+
$term = explode(':', $v);
|
281 |
+
|
282 |
+
|
283 |
+
// validate
|
284 |
+
if( !is_array($term) || !isset($term[1]) )
|
285 |
+
{
|
286 |
+
continue;
|
287 |
+
}
|
288 |
+
|
289 |
+
|
290 |
+
// add to tax array
|
291 |
+
$taxonomies[ $term[0] ][] = $term[1];
|
292 |
+
|
293 |
+
}
|
294 |
+
|
295 |
+
|
296 |
+
// now create the tax queries
|
297 |
+
foreach( $taxonomies as $k => $v )
|
298 |
+
{
|
299 |
+
$options['tax_query'][] = array(
|
300 |
+
'taxonomy' => $k,
|
301 |
+
'field' => 'id',
|
302 |
+
'terms' => $v,
|
303 |
+
);
|
304 |
+
}
|
305 |
+
}
|
306 |
+
|
307 |
+
unset( $options['taxonomy'] );
|
308 |
+
|
309 |
+
|
310 |
+
// load field
|
311 |
+
$field = array();
|
312 |
+
if( $options['ancestor'] )
|
313 |
+
{
|
314 |
+
$ancestor = apply_filters('acf/load_field', array(), $options['ancestor'] );
|
315 |
+
$field = acf_get_child_field_from_parent_field( $options['field_key'], $ancestor );
|
316 |
+
}
|
317 |
+
else
|
318 |
+
{
|
319 |
+
$field = apply_filters('acf/load_field', array(), $options['field_key'] );
|
320 |
+
}
|
321 |
+
|
322 |
+
|
323 |
+
// get the post from which this field is rendered on
|
324 |
+
$the_post = get_post( $options['post_id'] );
|
325 |
+
|
326 |
+
|
327 |
+
// filters
|
328 |
+
$options = apply_filters('acf/fields/relationship/query', $options, $field, $the_post);
|
329 |
+
$options = apply_filters('acf/fields/relationship/query/name=' . $field['_name'], $options, $field, $the_post );
|
330 |
+
$options = apply_filters('acf/fields/relationship/query/key=' . $field['key'], $options, $field, $the_post );
|
331 |
+
|
332 |
+
|
333 |
+
// query
|
334 |
+
$wp_query = new WP_Query( $options );
|
335 |
+
|
336 |
+
|
337 |
+
// global
|
338 |
+
global $post;
|
339 |
+
|
340 |
+
|
341 |
+
// loop
|
342 |
+
while( $wp_query->have_posts() ) {
|
343 |
+
|
344 |
+
$wp_query->the_post();
|
345 |
+
|
346 |
+
|
347 |
+
// get title
|
348 |
+
$title = $this->get_result($post, $field, $the_post, $options);
|
349 |
+
|
350 |
+
|
351 |
+
// update html
|
352 |
+
$r['html'] .= '<li><a href="' . get_permalink($post->ID) . '" data-post_id="' . $post->ID . '">' . $title . '<span class="acf-button-add"></span></a></li>';
|
353 |
+
|
354 |
+
}
|
355 |
+
|
356 |
+
|
357 |
+
// next page
|
358 |
+
if( (int)$options['paged'] >= $wp_query->max_num_pages ) {
|
359 |
+
|
360 |
+
$r['next_page_exists'] = 0;
|
361 |
+
|
362 |
+
}
|
363 |
+
|
364 |
+
|
365 |
+
// reset
|
366 |
+
wp_reset_postdata();
|
367 |
+
|
368 |
+
|
369 |
+
// return JSON
|
370 |
+
echo json_encode( $r );
|
371 |
+
|
372 |
+
die();
|
373 |
+
|
374 |
+
}
|
375 |
+
|
376 |
+
|
377 |
+
/*
|
378 |
+
* create_field()
|
379 |
+
*
|
380 |
+
* Create the HTML interface for your field
|
381 |
+
*
|
382 |
+
* @param $field - an array holding all the field's data
|
383 |
+
*
|
384 |
+
* @type action
|
385 |
+
* @since 3.6
|
386 |
+
* @date 23/01/13
|
387 |
+
*/
|
388 |
+
|
389 |
+
function create_field( $field )
|
390 |
+
{
|
391 |
+
// global
|
392 |
+
global $post;
|
393 |
+
|
394 |
+
|
395 |
+
// no row limit?
|
396 |
+
if( !$field['max'] || $field['max'] < 1 )
|
397 |
+
{
|
398 |
+
$field['max'] = 9999;
|
399 |
+
}
|
400 |
+
|
401 |
+
|
402 |
+
// class
|
403 |
+
$class = '';
|
404 |
+
if( $field['filters'] )
|
405 |
+
{
|
406 |
+
foreach( $field['filters'] as $filter )
|
407 |
+
{
|
408 |
+
$class .= ' has-' . $filter;
|
409 |
+
}
|
410 |
+
}
|
411 |
+
|
412 |
+
$attributes = array(
|
413 |
+
'max' => $field['max'],
|
414 |
+
's' => '',
|
415 |
+
'paged' => 1,
|
416 |
+
'post_type' => implode(',', $field['post_type']),
|
417 |
+
'taxonomy' => implode(',', $field['taxonomy']),
|
418 |
+
'field_key' => $field['key']
|
419 |
+
);
|
420 |
+
|
421 |
+
|
422 |
+
// Lang
|
423 |
+
if( defined('ICL_LANGUAGE_CODE') )
|
424 |
+
{
|
425 |
+
$attributes['lang'] = ICL_LANGUAGE_CODE;
|
426 |
+
}
|
427 |
+
|
428 |
+
|
429 |
+
// parent
|
430 |
+
preg_match('/\[(field_.*?)\]/', $field['name'], $ancestor);
|
431 |
+
if( isset($ancestor[1]) && $ancestor[1] != $field['key'])
|
432 |
+
{
|
433 |
+
$attributes['ancestor'] = $ancestor[1];
|
434 |
+
}
|
435 |
+
|
436 |
+
?>
|
437 |
+
<div class="acf_relationship<?php echo $class; ?>"<?php foreach( $attributes as $k => $v ): ?> data-<?php echo $k; ?>="<?php echo $v; ?>"<?php endforeach; ?>>
|
438 |
+
|
439 |
+
|
440 |
+
<!-- Hidden Blank default value -->
|
441 |
+
<input type="hidden" name="<?php echo $field['name']; ?>" value="" />
|
442 |
+
|
443 |
+
|
444 |
+
<!-- Left List -->
|
445 |
+
<div class="relationship_left">
|
446 |
+
<table class="widefat">
|
447 |
+
<thead>
|
448 |
+
<?php if(in_array( 'search', $field['filters']) ): ?>
|
449 |
+
<tr>
|
450 |
+
<th>
|
451 |
+
<input class="relationship_search" placeholder="<?php _e("Search...",'acf'); ?>" type="text" id="relationship_<?php echo $field['name']; ?>" />
|
452 |
+
</th>
|
453 |
+
</tr>
|
454 |
+
<?php endif; ?>
|
455 |
+
<?php if(in_array( 'post_type', $field['filters']) ): ?>
|
456 |
+
<tr>
|
457 |
+
<th>
|
458 |
+
<?php
|
459 |
+
|
460 |
+
// vars
|
461 |
+
$choices = array(
|
462 |
+
'all' => __("Filter by post type",'acf')
|
463 |
+
);
|
464 |
+
|
465 |
+
|
466 |
+
if( in_array('all', $field['post_type']) )
|
467 |
+
{
|
468 |
+
$post_types = apply_filters( 'acf/get_post_types', array() );
|
469 |
+
$choices = array_merge( $choices, $post_types);
|
470 |
+
}
|
471 |
+
else
|
472 |
+
{
|
473 |
+
foreach( $field['post_type'] as $post_type )
|
474 |
+
{
|
475 |
+
$choices[ $post_type ] = $post_type;
|
476 |
+
}
|
477 |
+
}
|
478 |
+
|
479 |
+
|
480 |
+
// create field
|
481 |
+
do_action('acf/create_field', array(
|
482 |
+
'type' => 'select',
|
483 |
+
'name' => '',
|
484 |
+
'class' => 'select-post_type',
|
485 |
+
'value' => '',
|
486 |
+
'choices' => $choices,
|
487 |
+
));
|
488 |
+
|
489 |
+
?>
|
490 |
+
</th>
|
491 |
+
</tr>
|
492 |
+
<?php endif; ?>
|
493 |
+
</thead>
|
494 |
+
</table>
|
495 |
+
<ul class="bl relationship_list">
|
496 |
+
<li class="load-more">
|
497 |
+
<div class="acf-loading"></div>
|
498 |
+
</li>
|
499 |
+
</ul>
|
500 |
+
</div>
|
501 |
+
<!-- /Left List -->
|
502 |
+
|
503 |
+
<!-- Right List -->
|
504 |
+
<div class="relationship_right">
|
505 |
+
<ul class="bl relationship_list">
|
506 |
+
<?php
|
507 |
+
|
508 |
+
if( $field['value'] )
|
509 |
+
{
|
510 |
+
foreach( $field['value'] as $p )
|
511 |
+
{
|
512 |
+
$title = $this->get_result($p, $field, $post);
|
513 |
+
|
514 |
+
|
515 |
+
echo '<li>
|
516 |
+
<a href="' . get_permalink($p->ID) . '" class="" data-post_id="' . $p->ID . '">' . $title . '<span class="acf-button-remove"></span></a>
|
517 |
+
<input type="hidden" name="' . $field['name'] . '[]" value="' . $p->ID . '" />
|
518 |
+
</li>';
|
519 |
+
|
520 |
+
|
521 |
+
}
|
522 |
+
}
|
523 |
+
|
524 |
+
?>
|
525 |
+
</ul>
|
526 |
+
</div>
|
527 |
+
<!-- / Right List -->
|
528 |
+
|
529 |
+
</div>
|
530 |
+
<?php
|
531 |
+
}
|
532 |
+
|
533 |
+
|
534 |
+
|
535 |
+
/*
|
536 |
+
* create_options()
|
537 |
+
*
|
538 |
+
* Create extra options for your field. This is rendered when editing a field.
|
539 |
+
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
540 |
+
*
|
541 |
+
* @type action
|
542 |
+
* @since 3.6
|
543 |
+
* @date 23/01/13
|
544 |
+
*
|
545 |
+
* @param $field - an array holding all the field's data
|
546 |
+
*/
|
547 |
+
|
548 |
+
function create_options( $field )
|
549 |
+
{
|
550 |
+
// vars
|
551 |
+
$key = $field['name'];
|
552 |
+
|
553 |
+
?>
|
554 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
555 |
+
<td class="label">
|
556 |
+
<label><?php _e("Return Format",'acf'); ?></label>
|
557 |
+
<p><?php _e("Specify the returned value on front end",'acf') ?></p>
|
558 |
+
</td>
|
559 |
+
<td>
|
560 |
+
<?php
|
561 |
+
do_action('acf/create_field', array(
|
562 |
+
'type' => 'radio',
|
563 |
+
'name' => 'fields['.$key.'][return_format]',
|
564 |
+
'value' => $field['return_format'],
|
565 |
+
'layout' => 'horizontal',
|
566 |
+
'choices' => array(
|
567 |
+
'object' => __("Post Objects",'acf'),
|
568 |
+
'id' => __("Post IDs",'acf')
|
569 |
+
)
|
570 |
+
));
|
571 |
+
?>
|
572 |
+
</td>
|
573 |
+
</tr>
|
574 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
575 |
+
<td class="label">
|
576 |
+
<label for=""><?php _e("Post Type",'acf'); ?></label>
|
577 |
+
</td>
|
578 |
+
<td>
|
579 |
+
<?php
|
580 |
+
|
581 |
+
$choices = array(
|
582 |
+
'all' => __("All",'acf')
|
583 |
+
);
|
584 |
+
$choices = apply_filters('acf/get_post_types', $choices);
|
585 |
+
|
586 |
+
|
587 |
+
do_action('acf/create_field', array(
|
588 |
+
'type' => 'select',
|
589 |
+
'name' => 'fields['.$key.'][post_type]',
|
590 |
+
'value' => $field['post_type'],
|
591 |
+
'choices' => $choices,
|
592 |
+
'multiple' => 1,
|
593 |
+
));
|
594 |
+
|
595 |
+
?>
|
596 |
+
</td>
|
597 |
+
</tr>
|
598 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
599 |
+
<td class="label">
|
600 |
+
<label><?php _e("Filter from Taxonomy",'acf'); ?></label>
|
601 |
+
</td>
|
602 |
+
<td>
|
603 |
+
<?php
|
604 |
+
$choices = array(
|
605 |
+
'' => array(
|
606 |
+
'all' => __("All",'acf')
|
607 |
+
)
|
608 |
+
);
|
609 |
+
$simple_value = false;
|
610 |
+
$choices = apply_filters('acf/get_taxonomies_for_select', $choices, $simple_value);
|
611 |
+
|
612 |
+
|
613 |
+
do_action('acf/create_field', array(
|
614 |
+
'type' => 'select',
|
615 |
+
'name' => 'fields['.$key.'][taxonomy]',
|
616 |
+
'value' => $field['taxonomy'],
|
617 |
+
'choices' => $choices,
|
618 |
+
'multiple' => 1,
|
619 |
+
));
|
620 |
+
?>
|
621 |
+
</td>
|
622 |
+
</tr>
|
623 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
624 |
+
<td class="label">
|
625 |
+
<label><?php _e("Filters",'acf'); ?></label>
|
626 |
+
</td>
|
627 |
+
<td>
|
628 |
+
<?php
|
629 |
+
do_action('acf/create_field', array(
|
630 |
+
'type' => 'checkbox',
|
631 |
+
'name' => 'fields['.$key.'][filters]',
|
632 |
+
'value' => $field['filters'],
|
633 |
+
'choices' => array(
|
634 |
+
'search' => __("Search",'acf'),
|
635 |
+
'post_type' => __("Post Type Select",'acf'),
|
636 |
+
)
|
637 |
+
));
|
638 |
+
?>
|
639 |
+
</td>
|
640 |
+
</tr>
|
641 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
642 |
+
<td class="label">
|
643 |
+
<label><?php _e("Elements",'acf'); ?></label>
|
644 |
+
<p><?php _e("Selected elements will be displayed in each result",'acf') ?></p>
|
645 |
+
</td>
|
646 |
+
<td>
|
647 |
+
<?php
|
648 |
+
do_action('acf/create_field', array(
|
649 |
+
'type' => 'checkbox',
|
650 |
+
'name' => 'fields['.$key.'][result_elements]',
|
651 |
+
'value' => $field['result_elements'],
|
652 |
+
'choices' => array(
|
653 |
+
'featured_image' => __("Featured Image",'acf'),
|
654 |
+
'post_title' => __("Post Title",'acf'),
|
655 |
+
'post_type' => __("Post Type",'acf'),
|
656 |
+
),
|
657 |
+
'disabled' => array(
|
658 |
+
'post_title'
|
659 |
+
)
|
660 |
+
));
|
661 |
+
?>
|
662 |
+
</td>
|
663 |
+
</tr>
|
664 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
665 |
+
<td class="label">
|
666 |
+
<label><?php _e("Maximum posts",'acf'); ?></label>
|
667 |
+
</td>
|
668 |
+
<td>
|
669 |
+
<?php
|
670 |
+
do_action('acf/create_field', array(
|
671 |
+
'type' => 'number',
|
672 |
+
'name' => 'fields['.$key.'][max]',
|
673 |
+
'value' => $field['max'],
|
674 |
+
));
|
675 |
+
?>
|
676 |
+
</td>
|
677 |
+
</tr>
|
678 |
+
<?php
|
679 |
+
|
680 |
+
}
|
681 |
+
|
682 |
+
|
683 |
+
/*
|
684 |
+
* format_value()
|
685 |
+
*
|
686 |
+
* This filter is appied to the $value after it is loaded from the db and before it is passed to the create_field action
|
687 |
+
*
|
688 |
+
* @type filter
|
689 |
+
* @since 3.6
|
690 |
+
* @date 23/01/13
|
691 |
+
*
|
692 |
+
* @param $value - the value which was loaded from the database
|
693 |
+
* @param $post_id - the $post_id from which the value was loaded
|
694 |
+
* @param $field - the field array holding all the field options
|
695 |
+
*
|
696 |
+
* @return $value - the modified value
|
697 |
+
*/
|
698 |
+
|
699 |
+
function format_value( $value, $post_id, $field )
|
700 |
+
{
|
701 |
+
// empty?
|
702 |
+
if( !empty($value) )
|
703 |
+
{
|
704 |
+
// Pre 3.3.3, the value is a string coma seperated
|
705 |
+
if( is_string($value) )
|
706 |
+
{
|
707 |
+
$value = explode(',', $value);
|
708 |
+
}
|
709 |
+
|
710 |
+
|
711 |
+
// convert to integers
|
712 |
+
if( is_array($value) )
|
713 |
+
{
|
714 |
+
$value = array_map('intval', $value);
|
715 |
+
|
716 |
+
// convert into post objects
|
717 |
+
$value = $this->get_posts( $value );
|
718 |
+
}
|
719 |
+
|
720 |
+
}
|
721 |
+
|
722 |
+
|
723 |
+
// return value
|
724 |
+
return $value;
|
725 |
+
}
|
726 |
+
|
727 |
+
|
728 |
+
/*
|
729 |
+
* format_value_for_api()
|
730 |
+
*
|
731 |
+
* This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
|
732 |
+
*
|
733 |
+
* @type filter
|
734 |
+
* @since 3.6
|
735 |
+
* @date 23/01/13
|
736 |
+
*
|
737 |
+
* @param $value - the value which was loaded from the database
|
738 |
+
* @param $post_id - the $post_id from which the value was loaded
|
739 |
+
* @param $field - the field array holding all the field options
|
740 |
+
*
|
741 |
+
* @return $value - the modified value
|
742 |
+
*/
|
743 |
+
|
744 |
+
function format_value_for_api( $value, $post_id, $field )
|
745 |
+
{
|
746 |
+
// empty?
|
747 |
+
if( !$value )
|
748 |
+
{
|
749 |
+
return $value;
|
750 |
+
}
|
751 |
+
|
752 |
+
|
753 |
+
// Pre 3.3.3, the value is a string coma seperated
|
754 |
+
if( is_string($value) )
|
755 |
+
{
|
756 |
+
$value = explode(',', $value);
|
757 |
+
}
|
758 |
+
|
759 |
+
|
760 |
+
// empty?
|
761 |
+
if( !is_array($value) || empty($value) )
|
762 |
+
{
|
763 |
+
return $value;
|
764 |
+
}
|
765 |
+
|
766 |
+
|
767 |
+
// convert to integers
|
768 |
+
$value = array_map('intval', $value);
|
769 |
+
|
770 |
+
|
771 |
+
// return format
|
772 |
+
if( $field['return_format'] == 'object' )
|
773 |
+
{
|
774 |
+
$value = $this->get_posts( $value );
|
775 |
+
}
|
776 |
+
|
777 |
+
|
778 |
+
// return
|
779 |
+
return $value;
|
780 |
+
|
781 |
+
}
|
782 |
+
|
783 |
+
|
784 |
+
/*
|
785 |
+
* get_posts
|
786 |
+
*
|
787 |
+
* This function will take an array of post_id's ($value) and return an array of post_objects
|
788 |
+
*
|
789 |
+
* @type function
|
790 |
+
* @date 7/08/13
|
791 |
+
*
|
792 |
+
* @param $post_ids (array) the array of post ID's
|
793 |
+
* @return (array) an array of post objects
|
794 |
+
*/
|
795 |
+
|
796 |
+
function get_posts( $post_ids )
|
797 |
+
{
|
798 |
+
// validate
|
799 |
+
if( empty($post_ids) )
|
800 |
+
{
|
801 |
+
return $post_ids;
|
802 |
+
}
|
803 |
+
|
804 |
+
|
805 |
+
// vars
|
806 |
+
$r = array();
|
807 |
+
|
808 |
+
|
809 |
+
// find posts (DISTINCT POSTS)
|
810 |
+
$posts = get_posts(array(
|
811 |
+
'numberposts' => -1,
|
812 |
+
'post__in' => $post_ids,
|
813 |
+
'post_type' => apply_filters('acf/get_post_types', array()),
|
814 |
+
'post_status' => 'any',
|
815 |
+
));
|
816 |
+
|
817 |
+
|
818 |
+
$ordered_posts = array();
|
819 |
+
foreach( $posts as $p )
|
820 |
+
{
|
821 |
+
// create array to hold value data
|
822 |
+
$ordered_posts[ $p->ID ] = $p;
|
823 |
+
}
|
824 |
+
|
825 |
+
|
826 |
+
// override value array with attachments
|
827 |
+
foreach( $post_ids as $k => $v)
|
828 |
+
{
|
829 |
+
// check that post exists (my have been trashed)
|
830 |
+
if( isset($ordered_posts[ $v ]) )
|
831 |
+
{
|
832 |
+
$r[] = $ordered_posts[ $v ];
|
833 |
+
}
|
834 |
+
}
|
835 |
+
|
836 |
+
|
837 |
+
// return
|
838 |
+
return $r;
|
839 |
+
}
|
840 |
+
|
841 |
+
|
842 |
+
/*
|
843 |
+
* update_value()
|
844 |
+
*
|
845 |
+
* This filter is appied to the $value before it is updated in the db
|
846 |
+
*
|
847 |
+
* @type filter
|
848 |
+
* @since 3.6
|
849 |
+
* @date 23/01/13
|
850 |
+
*
|
851 |
+
* @param $value - the value which will be saved in the database
|
852 |
+
* @param $post_id - the $post_id of which the value will be saved
|
853 |
+
* @param $field - the field array holding all the field options
|
854 |
+
*
|
855 |
+
* @return $value - the modified value
|
856 |
+
*/
|
857 |
+
|
858 |
+
function update_value( $value, $post_id, $field )
|
859 |
+
{
|
860 |
+
// validate
|
861 |
+
if( empty($value) )
|
862 |
+
{
|
863 |
+
return $value;
|
864 |
+
}
|
865 |
+
|
866 |
+
|
867 |
+
if( is_string($value) )
|
868 |
+
{
|
869 |
+
// string
|
870 |
+
$value = explode(',', $value);
|
871 |
+
|
872 |
+
}
|
873 |
+
elseif( is_object($value) && isset($value->ID) )
|
874 |
+
{
|
875 |
+
// object
|
876 |
+
$value = array( $value->ID );
|
877 |
+
|
878 |
+
}
|
879 |
+
elseif( is_array($value) )
|
880 |
+
{
|
881 |
+
// array
|
882 |
+
foreach( $value as $k => $v ){
|
883 |
+
|
884 |
+
// object?
|
885 |
+
if( is_object($v) && isset($v->ID) )
|
886 |
+
{
|
887 |
+
$value[ $k ] = $v->ID;
|
888 |
+
}
|
889 |
+
}
|
890 |
+
|
891 |
+
}
|
892 |
+
|
893 |
+
|
894 |
+
// save value as strings, so we can clearly search for them in SQL LIKE statements
|
895 |
+
$value = array_map('strval', $value);
|
896 |
+
|
897 |
+
|
898 |
+
return $value;
|
899 |
+
}
|
900 |
+
|
901 |
+
}
|
902 |
+
|
903 |
+
new acf_field_relationship();
|
904 |
+
|
905 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/fields/select.php
CHANGED
@@ -1,357 +1,357 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_field_select extends acf_field
|
4 |
-
{
|
5 |
-
/*
|
6 |
-
* __construct
|
7 |
-
*
|
8 |
-
* Set name / label needed for actions / filters
|
9 |
-
*
|
10 |
-
* @since 3.6
|
11 |
-
* @date 23/01/13
|
12 |
-
*/
|
13 |
-
|
14 |
-
function __construct()
|
15 |
-
{
|
16 |
-
// vars
|
17 |
-
$this->name = 'select';
|
18 |
-
$this->label = __("Select",'acf');
|
19 |
-
$this->category = __("Choice",'acf');
|
20 |
-
$this->defaults = array(
|
21 |
-
'multiple' => 0,
|
22 |
-
'allow_null' => 0,
|
23 |
-
'choices' => array(),
|
24 |
-
'default_value' => ''
|
25 |
-
);
|
26 |
-
|
27 |
-
|
28 |
-
// do not delete!
|
29 |
-
parent::__construct();
|
30 |
-
|
31 |
-
|
32 |
-
// extra
|
33 |
-
//add_filter('acf/update_field/type=select', array($this, 'update_field'), 5, 2);
|
34 |
-
add_filter('acf/update_field/type=checkbox', array($this, 'update_field'), 5, 2);
|
35 |
-
add_filter('acf/update_field/type=radio', array($this, 'update_field'), 5, 2);
|
36 |
-
}
|
37 |
-
|
38 |
-
|
39 |
-
/*
|
40 |
-
* create_field()
|
41 |
-
*
|
42 |
-
* Create the HTML interface for your field
|
43 |
-
*
|
44 |
-
* @param $field - an array holding all the field's data
|
45 |
-
*
|
46 |
-
* @type action
|
47 |
-
* @since 3.6
|
48 |
-
* @date 23/01/13
|
49 |
-
*/
|
50 |
-
|
51 |
-
function create_field( $field )
|
52 |
-
{
|
53 |
-
// vars
|
54 |
-
$optgroup = false;
|
55 |
-
|
56 |
-
|
57 |
-
// determine if choices are grouped (2 levels of array)
|
58 |
-
if( is_array($field['choices']) )
|
59 |
-
{
|
60 |
-
foreach( $field['choices'] as $k => $v )
|
61 |
-
{
|
62 |
-
if( is_array($v) )
|
63 |
-
{
|
64 |
-
$optgroup = true;
|
65 |
-
}
|
66 |
-
}
|
67 |
-
}
|
68 |
-
|
69 |
-
|
70 |
-
// value must be array
|
71 |
-
if( !is_array($field['value']) )
|
72 |
-
{
|
73 |
-
// perhaps this is a default value with new lines in it?
|
74 |
-
if( strpos($field['value'], "\n") !== false )
|
75 |
-
{
|
76 |
-
// found multiple lines, explode it
|
77 |
-
$field['value'] = explode("\n", $field['value']);
|
78 |
-
}
|
79 |
-
else
|
80 |
-
{
|
81 |
-
$field['value'] = array( $field['value'] );
|
82 |
-
}
|
83 |
-
}
|
84 |
-
|
85 |
-
|
86 |
-
// trim value
|
87 |
-
$field['value'] = array_map('trim', $field['value']);
|
88 |
-
|
89 |
-
|
90 |
-
// multiple select
|
91 |
-
$multiple = '';
|
92 |
-
if( $field['multiple'] )
|
93 |
-
{
|
94 |
-
// create a hidden field to allow for no selections
|
95 |
-
echo '<input type="hidden" name="' . $field['name'] . '" />';
|
96 |
-
|
97 |
-
$multiple = ' multiple="multiple" size="5" ';
|
98 |
-
$field['name'] .= '[]';
|
99 |
-
}
|
100 |
-
|
101 |
-
|
102 |
-
// html
|
103 |
-
echo '<select id="' . $field['id'] . '" class="' . $field['class'] . '" name="' . $field['name'] . '" ' . $multiple . ' >';
|
104 |
-
|
105 |
-
|
106 |
-
// null
|
107 |
-
if( $field['allow_null'] )
|
108 |
-
{
|
109 |
-
echo '<option value="null">- ' . __("Select",'acf') . ' -</option>';
|
110 |
-
}
|
111 |
-
|
112 |
-
// loop through values and add them as options
|
113 |
-
if( is_array($field['choices']) )
|
114 |
-
{
|
115 |
-
foreach( $field['choices'] as $key => $value )
|
116 |
-
{
|
117 |
-
if( $optgroup )
|
118 |
-
{
|
119 |
-
// this select is grouped with optgroup
|
120 |
-
if($key != '') echo '<optgroup label="'.$key.'">';
|
121 |
-
|
122 |
-
if( is_array($value) )
|
123 |
-
{
|
124 |
-
foreach($value as $id => $label)
|
125 |
-
{
|
126 |
-
$selected = in_array($id, $field['value']) ? 'selected="selected"' : '';
|
127 |
-
|
128 |
-
echo '<option value="'.$id.'" '.$selected.'>'.$label.'</option>';
|
129 |
-
}
|
130 |
-
}
|
131 |
-
|
132 |
-
if($key != '') echo '</optgroup>';
|
133 |
-
}
|
134 |
-
else
|
135 |
-
{
|
136 |
-
$selected = in_array($key, $field['value']) ? 'selected="selected"' : '';
|
137 |
-
echo '<option value="'.$key.'" '.$selected.'>'.$value.'</option>';
|
138 |
-
}
|
139 |
-
}
|
140 |
-
}
|
141 |
-
|
142 |
-
echo '</select>';
|
143 |
-
}
|
144 |
-
|
145 |
-
|
146 |
-
/*
|
147 |
-
* create_options()
|
148 |
-
*
|
149 |
-
* Create extra options for your field. This is rendered when editing a field.
|
150 |
-
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
151 |
-
*
|
152 |
-
* @type action
|
153 |
-
* @since 3.6
|
154 |
-
* @date 23/01/13
|
155 |
-
*
|
156 |
-
* @param $field - an array holding all the field's data
|
157 |
-
*/
|
158 |
-
|
159 |
-
function create_options( $field )
|
160 |
-
{
|
161 |
-
$key = $field['name'];
|
162 |
-
|
163 |
-
|
164 |
-
// implode choices so they work in a textarea
|
165 |
-
if( is_array($field['choices']) )
|
166 |
-
{
|
167 |
-
foreach( $field['choices'] as $k => $v )
|
168 |
-
{
|
169 |
-
$field['choices'][ $k ] = $k . ' : ' . $v;
|
170 |
-
}
|
171 |
-
$field['choices'] = implode("\n", $field['choices']);
|
172 |
-
}
|
173 |
-
|
174 |
-
?>
|
175 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
176 |
-
<td class="label">
|
177 |
-
<label for=""><?php _e("Choices",'acf'); ?></label>
|
178 |
-
<p><?php _e("Enter each choice on a new line.",'acf'); ?></p>
|
179 |
-
<p><?php _e("For more control, you may specify both a value and label like this:",'acf'); ?></p>
|
180 |
-
<p><?php _e("red : Red",'acf'); ?><br /><?php _e("blue : Blue",'acf'); ?></p>
|
181 |
-
</td>
|
182 |
-
<td>
|
183 |
-
<?php
|
184 |
-
|
185 |
-
do_action('acf/create_field', array(
|
186 |
-
'type' => 'textarea',
|
187 |
-
'class' => 'textarea field_option-choices',
|
188 |
-
'name' => 'fields['.$key.'][choices]',
|
189 |
-
'value' => $field['choices'],
|
190 |
-
));
|
191 |
-
|
192 |
-
?>
|
193 |
-
</td>
|
194 |
-
</tr>
|
195 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
196 |
-
<td class="label">
|
197 |
-
<label><?php _e("Default Value",'acf'); ?></label>
|
198 |
-
<p class="description"><?php _e("Enter each default value on a new line",'acf'); ?></p>
|
199 |
-
</td>
|
200 |
-
<td>
|
201 |
-
<?php
|
202 |
-
|
203 |
-
do_action('acf/create_field', array(
|
204 |
-
'type' => 'textarea',
|
205 |
-
'name' => 'fields['.$key.'][default_value]',
|
206 |
-
'value' => $field['default_value'],
|
207 |
-
));
|
208 |
-
|
209 |
-
?>
|
210 |
-
</td>
|
211 |
-
</tr>
|
212 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
213 |
-
<td class="label">
|
214 |
-
<label><?php _e("Allow Null?",'acf'); ?></label>
|
215 |
-
</td>
|
216 |
-
<td>
|
217 |
-
<?php
|
218 |
-
do_action('acf/create_field', array(
|
219 |
-
'type' => 'radio',
|
220 |
-
'name' => 'fields['.$key.'][allow_null]',
|
221 |
-
'value' => $field['allow_null'],
|
222 |
-
'choices' => array(
|
223 |
-
1 => __("Yes",'acf'),
|
224 |
-
0 => __("No",'acf'),
|
225 |
-
),
|
226 |
-
'layout' => 'horizontal',
|
227 |
-
));
|
228 |
-
?>
|
229 |
-
</td>
|
230 |
-
</tr>
|
231 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
232 |
-
<td class="label">
|
233 |
-
<label><?php _e("Select multiple values?",'acf'); ?></label>
|
234 |
-
</td>
|
235 |
-
<td>
|
236 |
-
<?php
|
237 |
-
do_action('acf/create_field', array(
|
238 |
-
'type' => 'radio',
|
239 |
-
'name' => 'fields['.$key.'][multiple]',
|
240 |
-
'value' => $field['multiple'],
|
241 |
-
'choices' => array(
|
242 |
-
1 => __("Yes",'acf'),
|
243 |
-
0 => __("No",'acf'),
|
244 |
-
),
|
245 |
-
'layout' => 'horizontal',
|
246 |
-
));
|
247 |
-
?>
|
248 |
-
</td>
|
249 |
-
</tr>
|
250 |
-
<?php
|
251 |
-
|
252 |
-
}
|
253 |
-
|
254 |
-
|
255 |
-
/*
|
256 |
-
* format_value_for_api()
|
257 |
-
*
|
258 |
-
* This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
|
259 |
-
*
|
260 |
-
* @type filter
|
261 |
-
* @since 3.6
|
262 |
-
* @date 23/01/13
|
263 |
-
*
|
264 |
-
* @param $value - the value which was loaded from the database
|
265 |
-
* @param $post_id - the $post_id from which the value was loaded
|
266 |
-
* @param $field - the field array holding all the field options
|
267 |
-
*
|
268 |
-
* @return $value - the modified value
|
269 |
-
*/
|
270 |
-
|
271 |
-
function format_value_for_api( $value, $post_id, $field )
|
272 |
-
{
|
273 |
-
if( $value == 'null' )
|
274 |
-
{
|
275 |
-
$value = false;
|
276 |
-
}
|
277 |
-
|
278 |
-
|
279 |
-
return $value;
|
280 |
-
}
|
281 |
-
|
282 |
-
|
283 |
-
/*
|
284 |
-
* update_field()
|
285 |
-
*
|
286 |
-
* This filter is appied to the $field before it is saved to the database
|
287 |
-
*
|
288 |
-
* @type filter
|
289 |
-
* @since 3.6
|
290 |
-
* @date 23/01/13
|
291 |
-
*
|
292 |
-
* @param $field - the field array holding all the field options
|
293 |
-
* @param $post_id - the field group ID (post_type = acf)
|
294 |
-
*
|
295 |
-
* @return $field - the modified field
|
296 |
-
*/
|
297 |
-
|
298 |
-
function update_field( $field, $post_id )
|
299 |
-
{
|
300 |
-
|
301 |
-
// check if is array. Normal back end edit posts a textarea, but a user might use update_field from the front end
|
302 |
-
if( is_array( $field['choices'] ))
|
303 |
-
{
|
304 |
-
return $field;
|
305 |
-
}
|
306 |
-
|
307 |
-
|
308 |
-
// vars
|
309 |
-
$new_choices = array();
|
310 |
-
|
311 |
-
|
312 |
-
// explode choices from each line
|
313 |
-
if( $field['choices'] )
|
314 |
-
{
|
315 |
-
// stripslashes ("")
|
316 |
-
$field['choices'] = stripslashes_deep($field['choices']);
|
317 |
-
|
318 |
-
if(strpos($field['choices'], "\n") !== false)
|
319 |
-
{
|
320 |
-
// found multiple lines, explode it
|
321 |
-
$field['choices'] = explode("\n", $field['choices']);
|
322 |
-
}
|
323 |
-
else
|
324 |
-
{
|
325 |
-
// no multiple lines!
|
326 |
-
$field['choices'] = array($field['choices']);
|
327 |
-
}
|
328 |
-
|
329 |
-
|
330 |
-
// key => value
|
331 |
-
foreach($field['choices'] as $choice)
|
332 |
-
{
|
333 |
-
if(strpos($choice, ' : ') !== false)
|
334 |
-
{
|
335 |
-
$choice = explode(' : ', $choice);
|
336 |
-
$new_choices[ trim($choice[0]) ] = trim($choice[1]);
|
337 |
-
}
|
338 |
-
else
|
339 |
-
{
|
340 |
-
$new_choices[ trim($choice) ] = trim($choice);
|
341 |
-
}
|
342 |
-
}
|
343 |
-
}
|
344 |
-
|
345 |
-
|
346 |
-
// update choices
|
347 |
-
$field['choices'] = $new_choices;
|
348 |
-
|
349 |
-
|
350 |
-
return $field;
|
351 |
-
}
|
352 |
-
|
353 |
-
}
|
354 |
-
|
355 |
-
new acf_field_select();
|
356 |
-
|
357 |
-
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class acf_field_select extends acf_field
|
4 |
+
{
|
5 |
+
/*
|
6 |
+
* __construct
|
7 |
+
*
|
8 |
+
* Set name / label needed for actions / filters
|
9 |
+
*
|
10 |
+
* @since 3.6
|
11 |
+
* @date 23/01/13
|
12 |
+
*/
|
13 |
+
|
14 |
+
function __construct()
|
15 |
+
{
|
16 |
+
// vars
|
17 |
+
$this->name = 'select';
|
18 |
+
$this->label = __("Select",'acf');
|
19 |
+
$this->category = __("Choice",'acf');
|
20 |
+
$this->defaults = array(
|
21 |
+
'multiple' => 0,
|
22 |
+
'allow_null' => 0,
|
23 |
+
'choices' => array(),
|
24 |
+
'default_value' => ''
|
25 |
+
);
|
26 |
+
|
27 |
+
|
28 |
+
// do not delete!
|
29 |
+
parent::__construct();
|
30 |
+
|
31 |
+
|
32 |
+
// extra
|
33 |
+
//add_filter('acf/update_field/type=select', array($this, 'update_field'), 5, 2);
|
34 |
+
add_filter('acf/update_field/type=checkbox', array($this, 'update_field'), 5, 2);
|
35 |
+
add_filter('acf/update_field/type=radio', array($this, 'update_field'), 5, 2);
|
36 |
+
}
|
37 |
+
|
38 |
+
|
39 |
+
/*
|
40 |
+
* create_field()
|
41 |
+
*
|
42 |
+
* Create the HTML interface for your field
|
43 |
+
*
|
44 |
+
* @param $field - an array holding all the field's data
|
45 |
+
*
|
46 |
+
* @type action
|
47 |
+
* @since 3.6
|
48 |
+
* @date 23/01/13
|
49 |
+
*/
|
50 |
+
|
51 |
+
function create_field( $field )
|
52 |
+
{
|
53 |
+
// vars
|
54 |
+
$optgroup = false;
|
55 |
+
|
56 |
+
|
57 |
+
// determine if choices are grouped (2 levels of array)
|
58 |
+
if( is_array($field['choices']) )
|
59 |
+
{
|
60 |
+
foreach( $field['choices'] as $k => $v )
|
61 |
+
{
|
62 |
+
if( is_array($v) )
|
63 |
+
{
|
64 |
+
$optgroup = true;
|
65 |
+
}
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
|
70 |
+
// value must be array
|
71 |
+
if( !is_array($field['value']) )
|
72 |
+
{
|
73 |
+
// perhaps this is a default value with new lines in it?
|
74 |
+
if( strpos($field['value'], "\n") !== false )
|
75 |
+
{
|
76 |
+
// found multiple lines, explode it
|
77 |
+
$field['value'] = explode("\n", $field['value']);
|
78 |
+
}
|
79 |
+
else
|
80 |
+
{
|
81 |
+
$field['value'] = array( $field['value'] );
|
82 |
+
}
|
83 |
+
}
|
84 |
+
|
85 |
+
|
86 |
+
// trim value
|
87 |
+
$field['value'] = array_map('trim', $field['value']);
|
88 |
+
|
89 |
+
|
90 |
+
// multiple select
|
91 |
+
$multiple = '';
|
92 |
+
if( $field['multiple'] )
|
93 |
+
{
|
94 |
+
// create a hidden field to allow for no selections
|
95 |
+
echo '<input type="hidden" name="' . $field['name'] . '" />';
|
96 |
+
|
97 |
+
$multiple = ' multiple="multiple" size="5" ';
|
98 |
+
$field['name'] .= '[]';
|
99 |
+
}
|
100 |
+
|
101 |
+
|
102 |
+
// html
|
103 |
+
echo '<select id="' . $field['id'] . '" class="' . $field['class'] . '" name="' . $field['name'] . '" ' . $multiple . ' >';
|
104 |
+
|
105 |
+
|
106 |
+
// null
|
107 |
+
if( $field['allow_null'] )
|
108 |
+
{
|
109 |
+
echo '<option value="null">- ' . __("Select",'acf') . ' -</option>';
|
110 |
+
}
|
111 |
+
|
112 |
+
// loop through values and add them as options
|
113 |
+
if( is_array($field['choices']) )
|
114 |
+
{
|
115 |
+
foreach( $field['choices'] as $key => $value )
|
116 |
+
{
|
117 |
+
if( $optgroup )
|
118 |
+
{
|
119 |
+
// this select is grouped with optgroup
|
120 |
+
if($key != '') echo '<optgroup label="'.$key.'">';
|
121 |
+
|
122 |
+
if( is_array($value) )
|
123 |
+
{
|
124 |
+
foreach($value as $id => $label)
|
125 |
+
{
|
126 |
+
$selected = in_array($id, $field['value']) ? 'selected="selected"' : '';
|
127 |
+
|
128 |
+
echo '<option value="'.$id.'" '.$selected.'>'.$label.'</option>';
|
129 |
+
}
|
130 |
+
}
|
131 |
+
|
132 |
+
if($key != '') echo '</optgroup>';
|
133 |
+
}
|
134 |
+
else
|
135 |
+
{
|
136 |
+
$selected = in_array($key, $field['value']) ? 'selected="selected"' : '';
|
137 |
+
echo '<option value="'.$key.'" '.$selected.'>'.$value.'</option>';
|
138 |
+
}
|
139 |
+
}
|
140 |
+
}
|
141 |
+
|
142 |
+
echo '</select>';
|
143 |
+
}
|
144 |
+
|
145 |
+
|
146 |
+
/*
|
147 |
+
* create_options()
|
148 |
+
*
|
149 |
+
* Create extra options for your field. This is rendered when editing a field.
|
150 |
+
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
151 |
+
*
|
152 |
+
* @type action
|
153 |
+
* @since 3.6
|
154 |
+
* @date 23/01/13
|
155 |
+
*
|
156 |
+
* @param $field - an array holding all the field's data
|
157 |
+
*/
|
158 |
+
|
159 |
+
function create_options( $field )
|
160 |
+
{
|
161 |
+
$key = $field['name'];
|
162 |
+
|
163 |
+
|
164 |
+
// implode choices so they work in a textarea
|
165 |
+
if( is_array($field['choices']) )
|
166 |
+
{
|
167 |
+
foreach( $field['choices'] as $k => $v )
|
168 |
+
{
|
169 |
+
$field['choices'][ $k ] = $k . ' : ' . $v;
|
170 |
+
}
|
171 |
+
$field['choices'] = implode("\n", $field['choices']);
|
172 |
+
}
|
173 |
+
|
174 |
+
?>
|
175 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
176 |
+
<td class="label">
|
177 |
+
<label for=""><?php _e("Choices",'acf'); ?></label>
|
178 |
+
<p><?php _e("Enter each choice on a new line.",'acf'); ?></p>
|
179 |
+
<p><?php _e("For more control, you may specify both a value and label like this:",'acf'); ?></p>
|
180 |
+
<p><?php _e("red : Red",'acf'); ?><br /><?php _e("blue : Blue",'acf'); ?></p>
|
181 |
+
</td>
|
182 |
+
<td>
|
183 |
+
<?php
|
184 |
+
|
185 |
+
do_action('acf/create_field', array(
|
186 |
+
'type' => 'textarea',
|
187 |
+
'class' => 'textarea field_option-choices',
|
188 |
+
'name' => 'fields['.$key.'][choices]',
|
189 |
+
'value' => $field['choices'],
|
190 |
+
));
|
191 |
+
|
192 |
+
?>
|
193 |
+
</td>
|
194 |
+
</tr>
|
195 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
196 |
+
<td class="label">
|
197 |
+
<label><?php _e("Default Value",'acf'); ?></label>
|
198 |
+
<p class="description"><?php _e("Enter each default value on a new line",'acf'); ?></p>
|
199 |
+
</td>
|
200 |
+
<td>
|
201 |
+
<?php
|
202 |
+
|
203 |
+
do_action('acf/create_field', array(
|
204 |
+
'type' => 'textarea',
|
205 |
+
'name' => 'fields['.$key.'][default_value]',
|
206 |
+
'value' => $field['default_value'],
|
207 |
+
));
|
208 |
+
|
209 |
+
?>
|
210 |
+
</td>
|
211 |
+
</tr>
|
212 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
213 |
+
<td class="label">
|
214 |
+
<label><?php _e("Allow Null?",'acf'); ?></label>
|
215 |
+
</td>
|
216 |
+
<td>
|
217 |
+
<?php
|
218 |
+
do_action('acf/create_field', array(
|
219 |
+
'type' => 'radio',
|
220 |
+
'name' => 'fields['.$key.'][allow_null]',
|
221 |
+
'value' => $field['allow_null'],
|
222 |
+
'choices' => array(
|
223 |
+
1 => __("Yes",'acf'),
|
224 |
+
0 => __("No",'acf'),
|
225 |
+
),
|
226 |
+
'layout' => 'horizontal',
|
227 |
+
));
|
228 |
+
?>
|
229 |
+
</td>
|
230 |
+
</tr>
|
231 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
232 |
+
<td class="label">
|
233 |
+
<label><?php _e("Select multiple values?",'acf'); ?></label>
|
234 |
+
</td>
|
235 |
+
<td>
|
236 |
+
<?php
|
237 |
+
do_action('acf/create_field', array(
|
238 |
+
'type' => 'radio',
|
239 |
+
'name' => 'fields['.$key.'][multiple]',
|
240 |
+
'value' => $field['multiple'],
|
241 |
+
'choices' => array(
|
242 |
+
1 => __("Yes",'acf'),
|
243 |
+
0 => __("No",'acf'),
|
244 |
+
),
|
245 |
+
'layout' => 'horizontal',
|
246 |
+
));
|
247 |
+
?>
|
248 |
+
</td>
|
249 |
+
</tr>
|
250 |
+
<?php
|
251 |
+
|
252 |
+
}
|
253 |
+
|
254 |
+
|
255 |
+
/*
|
256 |
+
* format_value_for_api()
|
257 |
+
*
|
258 |
+
* This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
|
259 |
+
*
|
260 |
+
* @type filter
|
261 |
+
* @since 3.6
|
262 |
+
* @date 23/01/13
|
263 |
+
*
|
264 |
+
* @param $value - the value which was loaded from the database
|
265 |
+
* @param $post_id - the $post_id from which the value was loaded
|
266 |
+
* @param $field - the field array holding all the field options
|
267 |
+
*
|
268 |
+
* @return $value - the modified value
|
269 |
+
*/
|
270 |
+
|
271 |
+
function format_value_for_api( $value, $post_id, $field )
|
272 |
+
{
|
273 |
+
if( $value == 'null' )
|
274 |
+
{
|
275 |
+
$value = false;
|
276 |
+
}
|
277 |
+
|
278 |
+
|
279 |
+
return $value;
|
280 |
+
}
|
281 |
+
|
282 |
+
|
283 |
+
/*
|
284 |
+
* update_field()
|
285 |
+
*
|
286 |
+
* This filter is appied to the $field before it is saved to the database
|
287 |
+
*
|
288 |
+
* @type filter
|
289 |
+
* @since 3.6
|
290 |
+
* @date 23/01/13
|
291 |
+
*
|
292 |
+
* @param $field - the field array holding all the field options
|
293 |
+
* @param $post_id - the field group ID (post_type = acf)
|
294 |
+
*
|
295 |
+
* @return $field - the modified field
|
296 |
+
*/
|
297 |
+
|
298 |
+
function update_field( $field, $post_id )
|
299 |
+
{
|
300 |
+
|
301 |
+
// check if is array. Normal back end edit posts a textarea, but a user might use update_field from the front end
|
302 |
+
if( is_array( $field['choices'] ))
|
303 |
+
{
|
304 |
+
return $field;
|
305 |
+
}
|
306 |
+
|
307 |
+
|
308 |
+
// vars
|
309 |
+
$new_choices = array();
|
310 |
+
|
311 |
+
|
312 |
+
// explode choices from each line
|
313 |
+
if( $field['choices'] )
|
314 |
+
{
|
315 |
+
// stripslashes ("")
|
316 |
+
$field['choices'] = stripslashes_deep($field['choices']);
|
317 |
+
|
318 |
+
if(strpos($field['choices'], "\n") !== false)
|
319 |
+
{
|
320 |
+
// found multiple lines, explode it
|
321 |
+
$field['choices'] = explode("\n", $field['choices']);
|
322 |
+
}
|
323 |
+
else
|
324 |
+
{
|
325 |
+
// no multiple lines!
|
326 |
+
$field['choices'] = array($field['choices']);
|
327 |
+
}
|
328 |
+
|
329 |
+
|
330 |
+
// key => value
|
331 |
+
foreach($field['choices'] as $choice)
|
332 |
+
{
|
333 |
+
if(strpos($choice, ' : ') !== false)
|
334 |
+
{
|
335 |
+
$choice = explode(' : ', $choice);
|
336 |
+
$new_choices[ trim($choice[0]) ] = trim($choice[1]);
|
337 |
+
}
|
338 |
+
else
|
339 |
+
{
|
340 |
+
$new_choices[ trim($choice) ] = trim($choice);
|
341 |
+
}
|
342 |
+
}
|
343 |
+
}
|
344 |
+
|
345 |
+
|
346 |
+
// update choices
|
347 |
+
$field['choices'] = $new_choices;
|
348 |
+
|
349 |
+
|
350 |
+
return $field;
|
351 |
+
}
|
352 |
+
|
353 |
+
}
|
354 |
+
|
355 |
+
new acf_field_select();
|
356 |
+
|
357 |
+
?>
|
shared/assets/plugins/advanced-custom-fields/core/fields/tab.php
CHANGED
@@ -1,81 +1,81 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_field_tab extends acf_field
|
4 |
-
{
|
5 |
-
|
6 |
-
/*
|
7 |
-
* __construct
|
8 |
-
*
|
9 |
-
* Set name / label needed for actions / filters
|
10 |
-
*
|
11 |
-
* @since 3.6
|
12 |
-
* @date 23/01/13
|
13 |
-
*/
|
14 |
-
|
15 |
-
function __construct()
|
16 |
-
{
|
17 |
-
// vars
|
18 |
-
$this->name = 'tab';
|
19 |
-
$this->label = __("Tab",'acf');
|
20 |
-
$this->category = __("Layout",'acf');
|
21 |
-
|
22 |
-
|
23 |
-
// do not delete!
|
24 |
-
parent::__construct();
|
25 |
-
}
|
26 |
-
|
27 |
-
|
28 |
-
/*
|
29 |
-
* create_field()
|
30 |
-
*
|
31 |
-
* Create the HTML interface for your field
|
32 |
-
*
|
33 |
-
* @param $field - an array holding all the field's data
|
34 |
-
*
|
35 |
-
* @type action
|
36 |
-
* @since 3.6
|
37 |
-
* @date 23/01/13
|
38 |
-
*/
|
39 |
-
|
40 |
-
function create_field( $field )
|
41 |
-
{
|
42 |
-
echo '<div class="acf-tab">' . $field['label'] . '</div>';
|
43 |
-
}
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
/*
|
48 |
-
* create_options()
|
49 |
-
*
|
50 |
-
* Create extra options for your field. This is rendered when editing a field.
|
51 |
-
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
52 |
-
*
|
53 |
-
* @param $field - an array holding all the field's data
|
54 |
-
*
|
55 |
-
* @type action
|
56 |
-
* @since 3.6
|
57 |
-
* @date 23/01/13
|
58 |
-
*/
|
59 |
-
|
60 |
-
function create_options( $field )
|
61 |
-
{
|
62 |
-
?>
|
63 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
64 |
-
<td class="label">
|
65 |
-
<label><?php _e("Instructions",'acf'); ?></label>
|
66 |
-
</td>
|
67 |
-
<td>
|
68 |
-
<p><?php _e("Use \"Tab Fields\" to better organize your edit screen by grouping your fields together under separate tab headings.",'acf'); ?></p>
|
69 |
-
<p><?php _e("All the fields following this \"tab field\" (or until another \"tab field\" is defined) will be grouped together.",'acf'); ?></p>
|
70 |
-
<p><?php _e("Use multiple tabs to divide your fields into sections.",'acf'); ?></p>
|
71 |
-
</td>
|
72 |
-
</tr>
|
73 |
-
<?php
|
74 |
-
|
75 |
-
}
|
76 |
-
|
77 |
-
}
|
78 |
-
|
79 |
-
new acf_field_tab();
|
80 |
-
|
81 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class acf_field_tab extends acf_field
|
4 |
+
{
|
5 |
+
|
6 |
+
/*
|
7 |
+
* __construct
|
8 |
+
*
|
9 |
+
* Set name / label needed for actions / filters
|
10 |
+
*
|
11 |
+
* @since 3.6
|
12 |
+
* @date 23/01/13
|
13 |
+
*/
|
14 |
+
|
15 |
+
function __construct()
|
16 |
+
{
|
17 |
+
// vars
|
18 |
+
$this->name = 'tab';
|
19 |
+
$this->label = __("Tab",'acf');
|
20 |
+
$this->category = __("Layout",'acf');
|
21 |
+
|
22 |
+
|
23 |
+
// do not delete!
|
24 |
+
parent::__construct();
|
25 |
+
}
|
26 |
+
|
27 |
+
|
28 |
+
/*
|
29 |
+
* create_field()
|
30 |
+
*
|
31 |
+
* Create the HTML interface for your field
|
32 |
+
*
|
33 |
+
* @param $field - an array holding all the field's data
|
34 |
+
*
|
35 |
+
* @type action
|
36 |
+
* @since 3.6
|
37 |
+
* @date 23/01/13
|
38 |
+
*/
|
39 |
+
|
40 |
+
function create_field( $field )
|
41 |
+
{
|
42 |
+
echo '<div class="acf-tab">' . $field['label'] . '</div>';
|
43 |
+
}
|
44 |
+
|
45 |
+
|
46 |
+
|
47 |
+
/*
|
48 |
+
* create_options()
|
49 |
+
*
|
50 |
+
* Create extra options for your field. This is rendered when editing a field.
|
51 |
+
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
52 |
+
*
|
53 |
+
* @param $field - an array holding all the field's data
|
54 |
+
*
|
55 |
+
* @type action
|
56 |
+
* @since 3.6
|
57 |
+
* @date 23/01/13
|
58 |
+
*/
|
59 |
+
|
60 |
+
function create_options( $field )
|
61 |
+
{
|
62 |
+
?>
|
63 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
64 |
+
<td class="label">
|
65 |
+
<label><?php _e("Instructions",'acf'); ?></label>
|
66 |
+
</td>
|
67 |
+
<td>
|
68 |
+
<p><?php _e("Use \"Tab Fields\" to better organize your edit screen by grouping your fields together under separate tab headings.",'acf'); ?></p>
|
69 |
+
<p><?php _e("All the fields following this \"tab field\" (or until another \"tab field\" is defined) will be grouped together.",'acf'); ?></p>
|
70 |
+
<p><?php _e("Use multiple tabs to divide your fields into sections.",'acf'); ?></p>
|
71 |
+
</td>
|
72 |
+
</tr>
|
73 |
+
<?php
|
74 |
+
|
75 |
+
}
|
76 |
+
|
77 |
+
}
|
78 |
+
|
79 |
+
new acf_field_tab();
|
80 |
+
|
81 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/fields/taxonomy.php
CHANGED
@@ -1,631 +1,631 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_field_taxonomy extends acf_field
|
4 |
-
{
|
5 |
-
/*
|
6 |
-
* __construct
|
7 |
-
*
|
8 |
-
* Set name / label needed for actions / filters
|
9 |
-
*
|
10 |
-
* @since 3.6
|
11 |
-
* @date 23/01/13
|
12 |
-
*/
|
13 |
-
|
14 |
-
function __construct()
|
15 |
-
{
|
16 |
-
// vars
|
17 |
-
$this->name = 'taxonomy';
|
18 |
-
$this->label = __("Taxonomy",'acf');
|
19 |
-
$this->category = __("Relational",'acf');
|
20 |
-
$this->defaults = array(
|
21 |
-
'taxonomy' => 'category',
|
22 |
-
'field_type' => 'checkbox',
|
23 |
-
'allow_null' => 0,
|
24 |
-
'load_save_terms' => 0,
|
25 |
-
'multiple' => 0,
|
26 |
-
'return_format' => 'id'
|
27 |
-
);
|
28 |
-
|
29 |
-
|
30 |
-
// do not delete!
|
31 |
-
parent::__construct();
|
32 |
-
|
33 |
-
}
|
34 |
-
|
35 |
-
|
36 |
-
/*
|
37 |
-
* get_terms
|
38 |
-
*
|
39 |
-
* This function will return an array of terms for a given field value
|
40 |
-
*
|
41 |
-
* @type function
|
42 |
-
* @date 13/06/2014
|
43 |
-
* @since 5.0.0
|
44 |
-
*
|
45 |
-
* @param $value (array)
|
46 |
-
* @return $value
|
47 |
-
*/
|
48 |
-
|
49 |
-
function get_terms( $value, $taxonomy = 'category' ) {
|
50 |
-
|
51 |
-
// load terms in 1 query to save multiple DB calls from following code
|
52 |
-
if( count($value) > 1 ) {
|
53 |
-
|
54 |
-
$terms = get_terms($taxonomy, array(
|
55 |
-
'hide_empty' => false,
|
56 |
-
'include' => $value,
|
57 |
-
));
|
58 |
-
|
59 |
-
}
|
60 |
-
|
61 |
-
|
62 |
-
// update value to include $post
|
63 |
-
foreach( array_keys($value) as $i ) {
|
64 |
-
|
65 |
-
$value[ $i ] = get_term( $value[ $i ], $taxonomy );
|
66 |
-
|
67 |
-
}
|
68 |
-
|
69 |
-
|
70 |
-
// filter out null values
|
71 |
-
$value = array_filter($value);
|
72 |
-
|
73 |
-
|
74 |
-
// return
|
75 |
-
return $value;
|
76 |
-
}
|
77 |
-
|
78 |
-
|
79 |
-
/*
|
80 |
-
* load_value()
|
81 |
-
*
|
82 |
-
* This filter is appied to the $value after it is loaded from the db
|
83 |
-
*
|
84 |
-
* @type filter
|
85 |
-
* @since 3.6
|
86 |
-
* @date 23/01/13
|
87 |
-
*
|
88 |
-
* @param $value - the value found in the database
|
89 |
-
* @param $post_id - the $post_id from which the value was loaded from
|
90 |
-
* @param $field - the field array holding all the field options
|
91 |
-
*
|
92 |
-
* @return $value - the value to be saved in te database
|
93 |
-
*/
|
94 |
-
|
95 |
-
function load_value( $value, $post_id, $field ) {
|
96 |
-
|
97 |
-
// get valid terms
|
98 |
-
$value = acf_get_valid_terms($value, $field['taxonomy']);
|
99 |
-
|
100 |
-
|
101 |
-
// load/save
|
102 |
-
if( $field['load_save_terms'] ) {
|
103 |
-
|
104 |
-
// bail early if no value
|
105 |
-
if( empty($value) ) {
|
106 |
-
|
107 |
-
return $value;
|
108 |
-
|
109 |
-
}
|
110 |
-
|
111 |
-
|
112 |
-
// get current ID's
|
113 |
-
$term_ids = wp_get_object_terms($post_id, $field['taxonomy'], array('fields' => 'ids', 'orderby' => 'none'));
|
114 |
-
|
115 |
-
|
116 |
-
// case
|
117 |
-
if( empty($term_ids) ) {
|
118 |
-
|
119 |
-
// 1. no terms for this post
|
120 |
-
return null;
|
121 |
-
|
122 |
-
} elseif( is_array($value) ) {
|
123 |
-
|
124 |
-
// 2. remove metadata terms which are no longer for this post
|
125 |
-
$value = array_map('intval', $value);
|
126 |
-
$value = array_intersect( $value, $term_ids );
|
127 |
-
|
128 |
-
} elseif( !in_array($value, $term_ids)) {
|
129 |
-
|
130 |
-
// 3. term is no longer for this post
|
131 |
-
return null;
|
132 |
-
|
133 |
-
}
|
134 |
-
|
135 |
-
}
|
136 |
-
|
137 |
-
|
138 |
-
// return
|
139 |
-
return $value;
|
140 |
-
}
|
141 |
-
|
142 |
-
|
143 |
-
/*
|
144 |
-
* update_value()
|
145 |
-
*
|
146 |
-
* This filter is appied to the $value before it is updated in the db
|
147 |
-
*
|
148 |
-
* @type filter
|
149 |
-
* @since 3.6
|
150 |
-
* @date 23/01/13
|
151 |
-
*
|
152 |
-
* @param $value - the value which will be saved in the database
|
153 |
-
* @param $field - the field array holding all the field options
|
154 |
-
* @param $post_id - the $post_id of which the value will be saved
|
155 |
-
*
|
156 |
-
* @return $value - the modified value
|
157 |
-
*/
|
158 |
-
|
159 |
-
function update_value( $value, $post_id, $field ) {
|
160 |
-
|
161 |
-
// vars
|
162 |
-
if( is_array($value) ) {
|
163 |
-
|
164 |
-
$value = array_filter($value);
|
165 |
-
|
166 |
-
}
|
167 |
-
|
168 |
-
|
169 |
-
// load_save_terms
|
170 |
-
if( $field['load_save_terms'] ) {
|
171 |
-
|
172 |
-
// vars
|
173 |
-
$taxonomy = $field['taxonomy'];
|
174 |
-
|
175 |
-
|
176 |
-
// force value to array
|
177 |
-
$term_ids = acf_force_type_array( $value );
|
178 |
-
|
179 |
-
|
180 |
-
// convert to int
|
181 |
-
$term_ids = array_map('intval', $term_ids);
|
182 |
-
|
183 |
-
|
184 |
-
// bypass $this->set_terms if called directly from update_field
|
185 |
-
if( !did_action('acf/save_post') ) {
|
186 |
-
|
187 |
-
wp_set_object_terms( $post_id, $term_ids, $taxonomy, false );
|
188 |
-
|
189 |
-
return $value;
|
190 |
-
|
191 |
-
}
|
192 |
-
|
193 |
-
|
194 |
-
// initialize
|
195 |
-
if( empty($this->set_terms) ) {
|
196 |
-
|
197 |
-
// create holder
|
198 |
-
$this->set_terms = array();
|
199 |
-
|
200 |
-
|
201 |
-
// add action
|
202 |
-
add_action('acf/save_post', array($this, 'set_terms'), 15, 1);
|
203 |
-
|
204 |
-
}
|
205 |
-
|
206 |
-
|
207 |
-
// append
|
208 |
-
if( empty($this->set_terms[ $taxonomy ]) ) {
|
209 |
-
|
210 |
-
$this->set_terms[ $taxonomy ] = array();
|
211 |
-
|
212 |
-
}
|
213 |
-
|
214 |
-
$this->set_terms[ $taxonomy ] = array_merge($this->set_terms[ $taxonomy ], $term_ids);
|
215 |
-
|
216 |
-
}
|
217 |
-
|
218 |
-
|
219 |
-
// return
|
220 |
-
return $value;
|
221 |
-
|
222 |
-
}
|
223 |
-
|
224 |
-
|
225 |
-
/*
|
226 |
-
* set_terms
|
227 |
-
*
|
228 |
-
* description
|
229 |
-
*
|
230 |
-
* @type function
|
231 |
-
* @date 26/11/2014
|
232 |
-
* @since 5.0.9
|
233 |
-
*
|
234 |
-
* @param $post_id (int)
|
235 |
-
* @return $post_id (int)
|
236 |
-
*/
|
237 |
-
|
238 |
-
function set_terms( $post_id ) {
|
239 |
-
|
240 |
-
// bail ealry if no terms
|
241 |
-
if( empty($this->set_terms) ) {
|
242 |
-
|
243 |
-
return;
|
244 |
-
|
245 |
-
}
|
246 |
-
|
247 |
-
|
248 |
-
// loop over terms
|
249 |
-
foreach( $this->set_terms as $taxonomy => $term_ids ){
|
250 |
-
|
251 |
-
wp_set_object_terms( $post_id, $term_ids, $taxonomy, false );
|
252 |
-
|
253 |
-
}
|
254 |
-
|
255 |
-
|
256 |
-
// reset array ( WP saves twice )
|
257 |
-
$this->set_terms = array();
|
258 |
-
|
259 |
-
}
|
260 |
-
|
261 |
-
|
262 |
-
/*
|
263 |
-
* format_value_for_api()
|
264 |
-
*
|
265 |
-
* This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
|
266 |
-
*
|
267 |
-
* @type filter
|
268 |
-
* @since 3.6
|
269 |
-
* @date 23/01/13
|
270 |
-
*
|
271 |
-
* @param $value - the value which was loaded from the database
|
272 |
-
* @param $post_id - the $post_id from which the value was loaded
|
273 |
-
* @param $field - the field array holding all the field options
|
274 |
-
*
|
275 |
-
* @return $value - the modified value
|
276 |
-
*/
|
277 |
-
|
278 |
-
function format_value_for_api( $value, $post_id, $field ) {
|
279 |
-
|
280 |
-
// bail early if no value
|
281 |
-
if( empty($value) ) {
|
282 |
-
|
283 |
-
return $value;
|
284 |
-
|
285 |
-
}
|
286 |
-
|
287 |
-
|
288 |
-
// force value to array
|
289 |
-
$value = acf_force_type_array( $value );
|
290 |
-
|
291 |
-
|
292 |
-
// convert values to int
|
293 |
-
$value = array_map('intval', $value);
|
294 |
-
|
295 |
-
|
296 |
-
// load posts if needed
|
297 |
-
if( $field['return_format'] == 'object' ) {
|
298 |
-
|
299 |
-
|
300 |
-
// get posts
|
301 |
-
$value = $this->get_terms( $value, $field["taxonomy"] );
|
302 |
-
|
303 |
-
}
|
304 |
-
|
305 |
-
|
306 |
-
// convert back from array if neccessary
|
307 |
-
if( $field['field_type'] == 'select' || $field['field_type'] == 'radio' ) {
|
308 |
-
|
309 |
-
$value = array_shift($value);
|
310 |
-
|
311 |
-
}
|
312 |
-
|
313 |
-
|
314 |
-
// return
|
315 |
-
return $value;
|
316 |
-
}
|
317 |
-
|
318 |
-
|
319 |
-
/*
|
320 |
-
* create_field()
|
321 |
-
*
|
322 |
-
* Create the HTML interface for your field
|
323 |
-
*
|
324 |
-
* @type action
|
325 |
-
* @since 3.6
|
326 |
-
* @date 23/01/13
|
327 |
-
*
|
328 |
-
* @param $field - an array holding all the field's data
|
329 |
-
*/
|
330 |
-
|
331 |
-
function create_field( $field )
|
332 |
-
{
|
333 |
-
// vars
|
334 |
-
$single_name = $field['name'];
|
335 |
-
|
336 |
-
|
337 |
-
// multi select?
|
338 |
-
if( $field['field_type'] == 'multi_select' )
|
339 |
-
{
|
340 |
-
$field['multiple'] = 1;
|
341 |
-
$field['field_type'] = 'select';
|
342 |
-
$field['name'] .= '[]';
|
343 |
-
}
|
344 |
-
elseif( $field['field_type'] == 'checkbox' )
|
345 |
-
{
|
346 |
-
$field['name'] .= '[]';
|
347 |
-
}
|
348 |
-
|
349 |
-
// value must be array!
|
350 |
-
if( !is_array($field['value']) )
|
351 |
-
{
|
352 |
-
$field['value'] = array( $field['value'] );
|
353 |
-
}
|
354 |
-
|
355 |
-
|
356 |
-
// vars
|
357 |
-
$args = array(
|
358 |
-
'taxonomy' => $field['taxonomy'],
|
359 |
-
'hide_empty' => false,
|
360 |
-
'style' => 'none',
|
361 |
-
'walker' => new acf_taxonomy_field_walker( $field ),
|
362 |
-
);
|
363 |
-
|
364 |
-
$args = apply_filters('acf/fields/taxonomy/wp_list_categories', $args, $field );
|
365 |
-
|
366 |
-
?>
|
367 |
-
<div class="acf-taxonomy-field" data-load_save="<?php echo $field['load_save_terms']; ?>">
|
368 |
-
<input type="hidden" name="<?php echo $single_name; ?>" value="" />
|
369 |
-
|
370 |
-
<?php if( $field['field_type'] == 'select' ): ?>
|
371 |
-
|
372 |
-
<select id="<?php echo $field['id']; ?>" name="<?php echo $field['name']; ?>" <?php if( $field['multiple'] ): ?>multiple="multiple" size="5"<?php endif; ?>>
|
373 |
-
<?php if( $field['allow_null'] ): ?>
|
374 |
-
<option value=""><?php _e("None", 'acf'); ?></option>
|
375 |
-
<?php endif; ?>
|
376 |
-
|
377 |
-
<?php else: ?>
|
378 |
-
<div class="categorychecklist-holder">
|
379 |
-
<ul class="acf-checkbox-list">
|
380 |
-
<?php if( $field['allow_null'] ): ?>
|
381 |
-
<li>
|
382 |
-
<label class="selectit">
|
383 |
-
<input type="<?php echo $field['field_type']; ?>" name="<?php echo $field['name']; ?>" value="" /> <?php _e("None", 'acf'); ?>
|
384 |
-
</label>
|
385 |
-
</li>
|
386 |
-
<?php endif; ?>
|
387 |
-
|
388 |
-
<?php endif; ?>
|
389 |
-
|
390 |
-
<?php wp_list_categories( $args ); ?>
|
391 |
-
|
392 |
-
<?php if( $field['field_type'] == 'select' ): ?>
|
393 |
-
|
394 |
-
</select>
|
395 |
-
|
396 |
-
<?php else: ?>
|
397 |
-
|
398 |
-
</ul>
|
399 |
-
</div>
|
400 |
-
|
401 |
-
<?php endif; ?>
|
402 |
-
|
403 |
-
</div>
|
404 |
-
<?php
|
405 |
-
|
406 |
-
}
|
407 |
-
|
408 |
-
|
409 |
-
/*
|
410 |
-
* create_options()
|
411 |
-
*
|
412 |
-
* Create extra options for your field. This is rendered when editing a field.
|
413 |
-
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
414 |
-
*
|
415 |
-
* @type action
|
416 |
-
* @since 3.6
|
417 |
-
* @date 23/01/13
|
418 |
-
*
|
419 |
-
* @param $field - an array holding all the field's data
|
420 |
-
*/
|
421 |
-
|
422 |
-
function create_options( $field )
|
423 |
-
{
|
424 |
-
// vars
|
425 |
-
$key = $field['name'];
|
426 |
-
|
427 |
-
?>
|
428 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
429 |
-
<td class="label">
|
430 |
-
<label><?php _e("Taxonomy",'acf'); ?></label>
|
431 |
-
</td>
|
432 |
-
<td>
|
433 |
-
<?php
|
434 |
-
|
435 |
-
// vars
|
436 |
-
$choices = array();
|
437 |
-
$taxonomies = get_taxonomies( array(), 'objects' );
|
438 |
-
$ignore = array( 'post_format', 'nav_menu', 'link_category' );
|
439 |
-
|
440 |
-
|
441 |
-
foreach( $taxonomies as $taxonomy )
|
442 |
-
{
|
443 |
-
if( in_array($taxonomy->name, $ignore) )
|
444 |
-
{
|
445 |
-
continue;
|
446 |
-
}
|
447 |
-
|
448 |
-
$choices[ $taxonomy->name ] = $taxonomy->name;
|
449 |
-
}
|
450 |
-
|
451 |
-
|
452 |
-
do_action('acf/create_field', array(
|
453 |
-
'type' => 'select',
|
454 |
-
'name' => 'fields['.$key.'][taxonomy]',
|
455 |
-
'value' => $field['taxonomy'],
|
456 |
-
'choices' => $choices,
|
457 |
-
));
|
458 |
-
|
459 |
-
?>
|
460 |
-
</td>
|
461 |
-
</tr>
|
462 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
463 |
-
<td class="label">
|
464 |
-
<label><?php _e("Field Type",'acf'); ?></label>
|
465 |
-
</td>
|
466 |
-
<td>
|
467 |
-
<?php
|
468 |
-
do_action('acf/create_field', array(
|
469 |
-
'type' => 'select',
|
470 |
-
'name' => 'fields['.$key.'][field_type]',
|
471 |
-
'value' => $field['field_type'],
|
472 |
-
'optgroup' => true,
|
473 |
-
'choices' => array(
|
474 |
-
__("Multiple Values",'acf') => array(
|
475 |
-
'checkbox' => __('Checkbox', 'acf'),
|
476 |
-
'multi_select' => __('Multi Select', 'acf')
|
477 |
-
),
|
478 |
-
__("Single Value",'acf') => array(
|
479 |
-
'radio' => __('Radio Buttons', 'acf'),
|
480 |
-
'select' => __('Select', 'acf')
|
481 |
-
)
|
482 |
-
)
|
483 |
-
));
|
484 |
-
?>
|
485 |
-
</td>
|
486 |
-
</tr>
|
487 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
488 |
-
<td class="label">
|
489 |
-
<label><?php _e("Allow Null?",'acf'); ?></label>
|
490 |
-
</td>
|
491 |
-
<td>
|
492 |
-
<?php
|
493 |
-
do_action('acf/create_field', array(
|
494 |
-
'type' => 'radio',
|
495 |
-
'name' => 'fields['.$key.'][allow_null]',
|
496 |
-
'value' => $field['allow_null'],
|
497 |
-
'choices' => array(
|
498 |
-
1 => __("Yes",'acf'),
|
499 |
-
0 => __("No",'acf'),
|
500 |
-
),
|
501 |
-
'layout' => 'horizontal',
|
502 |
-
));
|
503 |
-
?>
|
504 |
-
</td>
|
505 |
-
</tr>
|
506 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
507 |
-
<td class="label">
|
508 |
-
<label><?php _e("Load & Save Terms to Post",'acf'); ?></label>
|
509 |
-
</td>
|
510 |
-
<td>
|
511 |
-
<?php
|
512 |
-
do_action('acf/create_field', array(
|
513 |
-
'type' => 'true_false',
|
514 |
-
'name' => 'fields['.$key.'][load_save_terms]',
|
515 |
-
'value' => $field['load_save_terms'],
|
516 |
-
'message' => __("Load value based on the post's terms and update the post's terms on save",'acf')
|
517 |
-
));
|
518 |
-
?>
|
519 |
-
</td>
|
520 |
-
</tr>
|
521 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
522 |
-
<td class="label">
|
523 |
-
<label><?php _e("Return Value",'acf'); ?></label>
|
524 |
-
</td>
|
525 |
-
<td>
|
526 |
-
<?php
|
527 |
-
do_action('acf/create_field', array(
|
528 |
-
'type' => 'radio',
|
529 |
-
'name' => 'fields['.$key.'][return_format]',
|
530 |
-
'value' => $field['return_format'],
|
531 |
-
'layout' => 'horizontal',
|
532 |
-
'choices' => array(
|
533 |
-
'object' => __("Term Object",'acf'),
|
534 |
-
'id' => __("Term ID",'acf')
|
535 |
-
)
|
536 |
-
));
|
537 |
-
?>
|
538 |
-
</td>
|
539 |
-
</tr>
|
540 |
-
<?php
|
541 |
-
|
542 |
-
}
|
543 |
-
|
544 |
-
|
545 |
-
}
|
546 |
-
|
547 |
-
new acf_field_taxonomy();
|
548 |
-
|
549 |
-
|
550 |
-
class acf_taxonomy_field_walker extends Walker
|
551 |
-
{
|
552 |
-
// vars
|
553 |
-
var $field = null,
|
554 |
-
$tree_type = 'category',
|
555 |
-
$db_fields = array ( 'parent' => 'parent', 'id' => 'term_id' );
|
556 |
-
|
557 |
-
|
558 |
-
// construct
|
559 |
-
function __construct( $field )
|
560 |
-
{
|
561 |
-
$this->field = $field;
|
562 |
-
}
|
563 |
-
|
564 |
-
|
565 |
-
// start_el
|
566 |
-
function start_el( &$output, $term, $depth = 0, $args = array(), $current_object_id = 0)
|
567 |
-
{
|
568 |
-
// vars
|
569 |
-
$selected = in_array( $term->term_id, $this->field['value'] );
|
570 |
-
|
571 |
-
if( $this->field['field_type'] == 'checkbox' )
|
572 |
-
{
|
573 |
-
$output .= '<li><label class="selectit"><input type="checkbox" name="' . $this->field['name'] . '" value="' . $term->term_id . '" ' . ($selected ? 'checked="checked"' : '') . ' /> ' . $term->name . '</label>';
|
574 |
-
}
|
575 |
-
elseif( $this->field['field_type'] == 'radio' )
|
576 |
-
{
|
577 |
-
$output .= '<li><label class="selectit"><input type="radio" name="' . $this->field['name'] . '" value="' . $term->term_id . '" ' . ($selected ? 'checked="checkbox"' : '') . ' /> ' . $term->name . '</label>';
|
578 |
-
}
|
579 |
-
elseif( $this->field['field_type'] == 'select' )
|
580 |
-
{
|
581 |
-
$indent = str_repeat("— ", $depth);
|
582 |
-
$output .= '<option value="' . $term->term_id . '" ' . ($selected ? 'selected="selected"' : '') . '>' . $indent . $term->name . '</option>';
|
583 |
-
}
|
584 |
-
|
585 |
-
}
|
586 |
-
|
587 |
-
|
588 |
-
//end_el
|
589 |
-
function end_el( &$output, $term, $depth = 0, $args = array() )
|
590 |
-
{
|
591 |
-
if( in_array($this->field['field_type'], array('checkbox', 'radio')) )
|
592 |
-
{
|
593 |
-
$output .= '</li>';
|
594 |
-
}
|
595 |
-
|
596 |
-
$output .= "\n";
|
597 |
-
}
|
598 |
-
|
599 |
-
|
600 |
-
// start_lvl
|
601 |
-
function start_lvl( &$output, $depth = 0, $args = array() )
|
602 |
-
{
|
603 |
-
// indent
|
604 |
-
//$output .= str_repeat( "\t", $depth);
|
605 |
-
|
606 |
-
|
607 |
-
// wrap element
|
608 |
-
if( in_array($this->field['field_type'], array('checkbox', 'radio')) )
|
609 |
-
{
|
610 |
-
$output .= '<ul class="children">' . "\n";
|
611 |
-
}
|
612 |
-
}
|
613 |
-
|
614 |
-
|
615 |
-
// end_lvl
|
616 |
-
function end_lvl( &$output, $depth = 0, $args = array() )
|
617 |
-
{
|
618 |
-
// indent
|
619 |
-
//$output .= str_repeat( "\t", $depth);
|
620 |
-
|
621 |
-
|
622 |
-
// wrap element
|
623 |
-
if( in_array($this->field['field_type'], array('checkbox', 'radio')) )
|
624 |
-
{
|
625 |
-
$output .= '</ul>' . "\n";
|
626 |
-
}
|
627 |
-
}
|
628 |
-
|
629 |
-
}
|
630 |
-
|
631 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class acf_field_taxonomy extends acf_field
|
4 |
+
{
|
5 |
+
/*
|
6 |
+
* __construct
|
7 |
+
*
|
8 |
+
* Set name / label needed for actions / filters
|
9 |
+
*
|
10 |
+
* @since 3.6
|
11 |
+
* @date 23/01/13
|
12 |
+
*/
|
13 |
+
|
14 |
+
function __construct()
|
15 |
+
{
|
16 |
+
// vars
|
17 |
+
$this->name = 'taxonomy';
|
18 |
+
$this->label = __("Taxonomy",'acf');
|
19 |
+
$this->category = __("Relational",'acf');
|
20 |
+
$this->defaults = array(
|
21 |
+
'taxonomy' => 'category',
|
22 |
+
'field_type' => 'checkbox',
|
23 |
+
'allow_null' => 0,
|
24 |
+
'load_save_terms' => 0,
|
25 |
+
'multiple' => 0,
|
26 |
+
'return_format' => 'id'
|
27 |
+
);
|
28 |
+
|
29 |
+
|
30 |
+
// do not delete!
|
31 |
+
parent::__construct();
|
32 |
+
|
33 |
+
}
|
34 |
+
|
35 |
+
|
36 |
+
/*
|
37 |
+
* get_terms
|
38 |
+
*
|
39 |
+
* This function will return an array of terms for a given field value
|
40 |
+
*
|
41 |
+
* @type function
|
42 |
+
* @date 13/06/2014
|
43 |
+
* @since 5.0.0
|
44 |
+
*
|
45 |
+
* @param $value (array)
|
46 |
+
* @return $value
|
47 |
+
*/
|
48 |
+
|
49 |
+
function get_terms( $value, $taxonomy = 'category' ) {
|
50 |
+
|
51 |
+
// load terms in 1 query to save multiple DB calls from following code
|
52 |
+
if( count($value) > 1 ) {
|
53 |
+
|
54 |
+
$terms = get_terms($taxonomy, array(
|
55 |
+
'hide_empty' => false,
|
56 |
+
'include' => $value,
|
57 |
+
));
|
58 |
+
|
59 |
+
}
|
60 |
+
|
61 |
+
|
62 |
+
// update value to include $post
|
63 |
+
foreach( array_keys($value) as $i ) {
|
64 |
+
|
65 |
+
$value[ $i ] = get_term( $value[ $i ], $taxonomy );
|
66 |
+
|
67 |
+
}
|
68 |
+
|
69 |
+
|
70 |
+
// filter out null values
|
71 |
+
$value = array_filter($value);
|
72 |
+
|
73 |
+
|
74 |
+
// return
|
75 |
+
return $value;
|
76 |
+
}
|
77 |
+
|
78 |
+
|
79 |
+
/*
|
80 |
+
* load_value()
|
81 |
+
*
|
82 |
+
* This filter is appied to the $value after it is loaded from the db
|
83 |
+
*
|
84 |
+
* @type filter
|
85 |
+
* @since 3.6
|
86 |
+
* @date 23/01/13
|
87 |
+
*
|
88 |
+
* @param $value - the value found in the database
|
89 |
+
* @param $post_id - the $post_id from which the value was loaded from
|
90 |
+
* @param $field - the field array holding all the field options
|
91 |
+
*
|
92 |
+
* @return $value - the value to be saved in te database
|
93 |
+
*/
|
94 |
+
|
95 |
+
function load_value( $value, $post_id, $field ) {
|
96 |
+
|
97 |
+
// get valid terms
|
98 |
+
$value = acf_get_valid_terms($value, $field['taxonomy']);
|
99 |
+
|
100 |
+
|
101 |
+
// load/save
|
102 |
+
if( $field['load_save_terms'] ) {
|
103 |
+
|
104 |
+
// bail early if no value
|
105 |
+
if( empty($value) ) {
|
106 |
+
|
107 |
+
return $value;
|
108 |
+
|
109 |
+
}
|
110 |
+
|
111 |
+
|
112 |
+
// get current ID's
|
113 |
+
$term_ids = wp_get_object_terms($post_id, $field['taxonomy'], array('fields' => 'ids', 'orderby' => 'none'));
|
114 |
+
|
115 |
+
|
116 |
+
// case
|
117 |
+
if( empty($term_ids) ) {
|
118 |
+
|
119 |
+
// 1. no terms for this post
|
120 |
+
return null;
|
121 |
+
|
122 |
+
} elseif( is_array($value) ) {
|
123 |
+
|
124 |
+
// 2. remove metadata terms which are no longer for this post
|
125 |
+
$value = array_map('intval', $value);
|
126 |
+
$value = array_intersect( $value, $term_ids );
|
127 |
+
|
128 |
+
} elseif( !in_array($value, $term_ids)) {
|
129 |
+
|
130 |
+
// 3. term is no longer for this post
|
131 |
+
return null;
|
132 |
+
|
133 |
+
}
|
134 |
+
|
135 |
+
}
|
136 |
+
|
137 |
+
|
138 |
+
// return
|
139 |
+
return $value;
|
140 |
+
}
|
141 |
+
|
142 |
+
|
143 |
+
/*
|
144 |
+
* update_value()
|
145 |
+
*
|
146 |
+
* This filter is appied to the $value before it is updated in the db
|
147 |
+
*
|
148 |
+
* @type filter
|
149 |
+
* @since 3.6
|
150 |
+
* @date 23/01/13
|
151 |
+
*
|
152 |
+
* @param $value - the value which will be saved in the database
|
153 |
+
* @param $field - the field array holding all the field options
|
154 |
+
* @param $post_id - the $post_id of which the value will be saved
|
155 |
+
*
|
156 |
+
* @return $value - the modified value
|
157 |
+
*/
|
158 |
+
|
159 |
+
function update_value( $value, $post_id, $field ) {
|
160 |
+
|
161 |
+
// vars
|
162 |
+
if( is_array($value) ) {
|
163 |
+
|
164 |
+
$value = array_filter($value);
|
165 |
+
|
166 |
+
}
|
167 |
+
|
168 |
+
|
169 |
+
// load_save_terms
|
170 |
+
if( $field['load_save_terms'] ) {
|
171 |
+
|
172 |
+
// vars
|
173 |
+
$taxonomy = $field['taxonomy'];
|
174 |
+
|
175 |
+
|
176 |
+
// force value to array
|
177 |
+
$term_ids = acf_force_type_array( $value );
|
178 |
+
|
179 |
+
|
180 |
+
// convert to int
|
181 |
+
$term_ids = array_map('intval', $term_ids);
|
182 |
+
|
183 |
+
|
184 |
+
// bypass $this->set_terms if called directly from update_field
|
185 |
+
if( !did_action('acf/save_post') ) {
|
186 |
+
|
187 |
+
wp_set_object_terms( $post_id, $term_ids, $taxonomy, false );
|
188 |
+
|
189 |
+
return $value;
|
190 |
+
|
191 |
+
}
|
192 |
+
|
193 |
+
|
194 |
+
// initialize
|
195 |
+
if( empty($this->set_terms) ) {
|
196 |
+
|
197 |
+
// create holder
|
198 |
+
$this->set_terms = array();
|
199 |
+
|
200 |
+
|
201 |
+
// add action
|
202 |
+
add_action('acf/save_post', array($this, 'set_terms'), 15, 1);
|
203 |
+
|
204 |
+
}
|
205 |
+
|
206 |
+
|
207 |
+
// append
|
208 |
+
if( empty($this->set_terms[ $taxonomy ]) ) {
|
209 |
+
|
210 |
+
$this->set_terms[ $taxonomy ] = array();
|
211 |
+
|
212 |
+
}
|
213 |
+
|
214 |
+
$this->set_terms[ $taxonomy ] = array_merge($this->set_terms[ $taxonomy ], $term_ids);
|
215 |
+
|
216 |
+
}
|
217 |
+
|
218 |
+
|
219 |
+
// return
|
220 |
+
return $value;
|
221 |
+
|
222 |
+
}
|
223 |
+
|
224 |
+
|
225 |
+
/*
|
226 |
+
* set_terms
|
227 |
+
*
|
228 |
+
* description
|
229 |
+
*
|
230 |
+
* @type function
|
231 |
+
* @date 26/11/2014
|
232 |
+
* @since 5.0.9
|
233 |
+
*
|
234 |
+
* @param $post_id (int)
|
235 |
+
* @return $post_id (int)
|
236 |
+
*/
|
237 |
+
|
238 |
+
function set_terms( $post_id ) {
|
239 |
+
|
240 |
+
// bail ealry if no terms
|
241 |
+
if( empty($this->set_terms) ) {
|
242 |
+
|
243 |
+
return;
|
244 |
+
|
245 |
+
}
|
246 |
+
|
247 |
+
|
248 |
+
// loop over terms
|
249 |
+
foreach( $this->set_terms as $taxonomy => $term_ids ){
|
250 |
+
|
251 |
+
wp_set_object_terms( $post_id, $term_ids, $taxonomy, false );
|
252 |
+
|
253 |
+
}
|
254 |
+
|
255 |
+
|
256 |
+
// reset array ( WP saves twice )
|
257 |
+
$this->set_terms = array();
|
258 |
+
|
259 |
+
}
|
260 |
+
|
261 |
+
|
262 |
+
/*
|
263 |
+
* format_value_for_api()
|
264 |
+
*
|
265 |
+
* This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
|
266 |
+
*
|
267 |
+
* @type filter
|
268 |
+
* @since 3.6
|
269 |
+
* @date 23/01/13
|
270 |
+
*
|
271 |
+
* @param $value - the value which was loaded from the database
|
272 |
+
* @param $post_id - the $post_id from which the value was loaded
|
273 |
+
* @param $field - the field array holding all the field options
|
274 |
+
*
|
275 |
+
* @return $value - the modified value
|
276 |
+
*/
|
277 |
+
|
278 |
+
function format_value_for_api( $value, $post_id, $field ) {
|
279 |
+
|
280 |
+
// bail early if no value
|
281 |
+
if( empty($value) ) {
|
282 |
+
|
283 |
+
return $value;
|
284 |
+
|
285 |
+
}
|
286 |
+
|
287 |
+
|
288 |
+
// force value to array
|
289 |
+
$value = acf_force_type_array( $value );
|
290 |
+
|
291 |
+
|
292 |
+
// convert values to int
|
293 |
+
$value = array_map('intval', $value);
|
294 |
+
|
295 |
+
|
296 |
+
// load posts if needed
|
297 |
+
if( $field['return_format'] == 'object' ) {
|
298 |
+
|
299 |
+
|
300 |
+
// get posts
|
301 |
+
$value = $this->get_terms( $value, $field["taxonomy"] );
|
302 |
+
|
303 |
+
}
|
304 |
+
|
305 |
+
|
306 |
+
// convert back from array if neccessary
|
307 |
+
if( $field['field_type'] == 'select' || $field['field_type'] == 'radio' ) {
|
308 |
+
|
309 |
+
$value = array_shift($value);
|
310 |
+
|
311 |
+
}
|
312 |
+
|
313 |
+
|
314 |
+
// return
|
315 |
+
return $value;
|
316 |
+
}
|
317 |
+
|
318 |
+
|
319 |
+
/*
|
320 |
+
* create_field()
|
321 |
+
*
|
322 |
+
* Create the HTML interface for your field
|
323 |
+
*
|
324 |
+
* @type action
|
325 |
+
* @since 3.6
|
326 |
+
* @date 23/01/13
|
327 |
+
*
|
328 |
+
* @param $field - an array holding all the field's data
|
329 |
+
*/
|
330 |
+
|
331 |
+
function create_field( $field )
|
332 |
+
{
|
333 |
+
// vars
|
334 |
+
$single_name = $field['name'];
|
335 |
+
|
336 |
+
|
337 |
+
// multi select?
|
338 |
+
if( $field['field_type'] == 'multi_select' )
|
339 |
+
{
|
340 |
+
$field['multiple'] = 1;
|
341 |
+
$field['field_type'] = 'select';
|
342 |
+
$field['name'] .= '[]';
|
343 |
+
}
|
344 |
+
elseif( $field['field_type'] == 'checkbox' )
|
345 |
+
{
|
346 |
+
$field['name'] .= '[]';
|
347 |
+
}
|
348 |
+
|
349 |
+
// value must be array!
|
350 |
+
if( !is_array($field['value']) )
|
351 |
+
{
|
352 |
+
$field['value'] = array( $field['value'] );
|
353 |
+
}
|
354 |
+
|
355 |
+
|
356 |
+
// vars
|
357 |
+
$args = array(
|
358 |
+
'taxonomy' => $field['taxonomy'],
|
359 |
+
'hide_empty' => false,
|
360 |
+
'style' => 'none',
|
361 |
+
'walker' => new acf_taxonomy_field_walker( $field ),
|
362 |
+
);
|
363 |
+
|
364 |
+
$args = apply_filters('acf/fields/taxonomy/wp_list_categories', $args, $field );
|
365 |
+
|
366 |
+
?>
|
367 |
+
<div class="acf-taxonomy-field" data-load_save="<?php echo $field['load_save_terms']; ?>">
|
368 |
+
<input type="hidden" name="<?php echo $single_name; ?>" value="" />
|
369 |
+
|
370 |
+
<?php if( $field['field_type'] == 'select' ): ?>
|
371 |
+
|
372 |
+
<select id="<?php echo $field['id']; ?>" name="<?php echo $field['name']; ?>" <?php if( $field['multiple'] ): ?>multiple="multiple" size="5"<?php endif; ?>>
|
373 |
+
<?php if( $field['allow_null'] ): ?>
|
374 |
+
<option value=""><?php _e("None", 'acf'); ?></option>
|
375 |
+
<?php endif; ?>
|
376 |
+
|
377 |
+
<?php else: ?>
|
378 |
+
<div class="categorychecklist-holder">
|
379 |
+
<ul class="acf-checkbox-list">
|
380 |
+
<?php if( $field['allow_null'] ): ?>
|
381 |
+
<li>
|
382 |
+
<label class="selectit">
|
383 |
+
<input type="<?php echo $field['field_type']; ?>" name="<?php echo $field['name']; ?>" value="" /> <?php _e("None", 'acf'); ?>
|
384 |
+
</label>
|
385 |
+
</li>
|
386 |
+
<?php endif; ?>
|
387 |
+
|
388 |
+
<?php endif; ?>
|
389 |
+
|
390 |
+
<?php wp_list_categories( $args ); ?>
|
391 |
+
|
392 |
+
<?php if( $field['field_type'] == 'select' ): ?>
|
393 |
+
|
394 |
+
</select>
|
395 |
+
|
396 |
+
<?php else: ?>
|
397 |
+
|
398 |
+
</ul>
|
399 |
+
</div>
|
400 |
+
|
401 |
+
<?php endif; ?>
|
402 |
+
|
403 |
+
</div>
|
404 |
+
<?php
|
405 |
+
|
406 |
+
}
|
407 |
+
|
408 |
+
|
409 |
+
/*
|
410 |
+
* create_options()
|
411 |
+
*
|
412 |
+
* Create extra options for your field. This is rendered when editing a field.
|
413 |
+
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
414 |
+
*
|
415 |
+
* @type action
|
416 |
+
* @since 3.6
|
417 |
+
* @date 23/01/13
|
418 |
+
*
|
419 |
+
* @param $field - an array holding all the field's data
|
420 |
+
*/
|
421 |
+
|
422 |
+
function create_options( $field )
|
423 |
+
{
|
424 |
+
// vars
|
425 |
+
$key = $field['name'];
|
426 |
+
|
427 |
+
?>
|
428 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
429 |
+
<td class="label">
|
430 |
+
<label><?php _e("Taxonomy",'acf'); ?></label>
|
431 |
+
</td>
|
432 |
+
<td>
|
433 |
+
<?php
|
434 |
+
|
435 |
+
// vars
|
436 |
+
$choices = array();
|
437 |
+
$taxonomies = get_taxonomies( array(), 'objects' );
|
438 |
+
$ignore = array( 'post_format', 'nav_menu', 'link_category' );
|
439 |
+
|
440 |
+
|
441 |
+
foreach( $taxonomies as $taxonomy )
|
442 |
+
{
|
443 |
+
if( in_array($taxonomy->name, $ignore) )
|
444 |
+
{
|
445 |
+
continue;
|
446 |
+
}
|
447 |
+
|
448 |
+
$choices[ $taxonomy->name ] = $taxonomy->name;
|
449 |
+
}
|
450 |
+
|
451 |
+
|
452 |
+
do_action('acf/create_field', array(
|
453 |
+
'type' => 'select',
|
454 |
+
'name' => 'fields['.$key.'][taxonomy]',
|
455 |
+
'value' => $field['taxonomy'],
|
456 |
+
'choices' => $choices,
|
457 |
+
));
|
458 |
+
|
459 |
+
?>
|
460 |
+
</td>
|
461 |
+
</tr>
|
462 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
463 |
+
<td class="label">
|
464 |
+
<label><?php _e("Field Type",'acf'); ?></label>
|
465 |
+
</td>
|
466 |
+
<td>
|
467 |
+
<?php
|
468 |
+
do_action('acf/create_field', array(
|
469 |
+
'type' => 'select',
|
470 |
+
'name' => 'fields['.$key.'][field_type]',
|
471 |
+
'value' => $field['field_type'],
|
472 |
+
'optgroup' => true,
|
473 |
+
'choices' => array(
|
474 |
+
__("Multiple Values",'acf') => array(
|
475 |
+
'checkbox' => __('Checkbox', 'acf'),
|
476 |
+
'multi_select' => __('Multi Select', 'acf')
|
477 |
+
),
|
478 |
+
__("Single Value",'acf') => array(
|
479 |
+
'radio' => __('Radio Buttons', 'acf'),
|
480 |
+
'select' => __('Select', 'acf')
|
481 |
+
)
|
482 |
+
)
|
483 |
+
));
|
484 |
+
?>
|
485 |
+
</td>
|
486 |
+
</tr>
|
487 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
488 |
+
<td class="label">
|
489 |
+
<label><?php _e("Allow Null?",'acf'); ?></label>
|
490 |
+
</td>
|
491 |
+
<td>
|
492 |
+
<?php
|
493 |
+
do_action('acf/create_field', array(
|
494 |
+
'type' => 'radio',
|
495 |
+
'name' => 'fields['.$key.'][allow_null]',
|
496 |
+
'value' => $field['allow_null'],
|
497 |
+
'choices' => array(
|
498 |
+
1 => __("Yes",'acf'),
|
499 |
+
0 => __("No",'acf'),
|
500 |
+
),
|
501 |
+
'layout' => 'horizontal',
|
502 |
+
));
|
503 |
+
?>
|
504 |
+
</td>
|
505 |
+
</tr>
|
506 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
507 |
+
<td class="label">
|
508 |
+
<label><?php _e("Load & Save Terms to Post",'acf'); ?></label>
|
509 |
+
</td>
|
510 |
+
<td>
|
511 |
+
<?php
|
512 |
+
do_action('acf/create_field', array(
|
513 |
+
'type' => 'true_false',
|
514 |
+
'name' => 'fields['.$key.'][load_save_terms]',
|
515 |
+
'value' => $field['load_save_terms'],
|
516 |
+
'message' => __("Load value based on the post's terms and update the post's terms on save",'acf')
|
517 |
+
));
|
518 |
+
?>
|
519 |
+
</td>
|
520 |
+
</tr>
|
521 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
522 |
+
<td class="label">
|
523 |
+
<label><?php _e("Return Value",'acf'); ?></label>
|
524 |
+
</td>
|
525 |
+
<td>
|
526 |
+
<?php
|
527 |
+
do_action('acf/create_field', array(
|
528 |
+
'type' => 'radio',
|
529 |
+
'name' => 'fields['.$key.'][return_format]',
|
530 |
+
'value' => $field['return_format'],
|
531 |
+
'layout' => 'horizontal',
|
532 |
+
'choices' => array(
|
533 |
+
'object' => __("Term Object",'acf'),
|
534 |
+
'id' => __("Term ID",'acf')
|
535 |
+
)
|
536 |
+
));
|
537 |
+
?>
|
538 |
+
</td>
|
539 |
+
</tr>
|
540 |
+
<?php
|
541 |
+
|
542 |
+
}
|
543 |
+
|
544 |
+
|
545 |
+
}
|
546 |
+
|
547 |
+
new acf_field_taxonomy();
|
548 |
+
|
549 |
+
|
550 |
+
class acf_taxonomy_field_walker extends Walker
|
551 |
+
{
|
552 |
+
// vars
|
553 |
+
var $field = null,
|
554 |
+
$tree_type = 'category',
|
555 |
+
$db_fields = array ( 'parent' => 'parent', 'id' => 'term_id' );
|
556 |
+
|
557 |
+
|
558 |
+
// construct
|
559 |
+
function __construct( $field )
|
560 |
+
{
|
561 |
+
$this->field = $field;
|
562 |
+
}
|
563 |
+
|
564 |
+
|
565 |
+
// start_el
|
566 |
+
function start_el( &$output, $term, $depth = 0, $args = array(), $current_object_id = 0)
|
567 |
+
{
|
568 |
+
// vars
|
569 |
+
$selected = in_array( $term->term_id, $this->field['value'] );
|
570 |
+
|
571 |
+
if( $this->field['field_type'] == 'checkbox' )
|
572 |
+
{
|
573 |
+
$output .= '<li><label class="selectit"><input type="checkbox" name="' . $this->field['name'] . '" value="' . $term->term_id . '" ' . ($selected ? 'checked="checked"' : '') . ' /> ' . $term->name . '</label>';
|
574 |
+
}
|
575 |
+
elseif( $this->field['field_type'] == 'radio' )
|
576 |
+
{
|
577 |
+
$output .= '<li><label class="selectit"><input type="radio" name="' . $this->field['name'] . '" value="' . $term->term_id . '" ' . ($selected ? 'checked="checkbox"' : '') . ' /> ' . $term->name . '</label>';
|
578 |
+
}
|
579 |
+
elseif( $this->field['field_type'] == 'select' )
|
580 |
+
{
|
581 |
+
$indent = str_repeat("— ", $depth);
|
582 |
+
$output .= '<option value="' . $term->term_id . '" ' . ($selected ? 'selected="selected"' : '') . '>' . $indent . $term->name . '</option>';
|
583 |
+
}
|
584 |
+
|
585 |
+
}
|
586 |
+
|
587 |
+
|
588 |
+
//end_el
|
589 |
+
function end_el( &$output, $term, $depth = 0, $args = array() )
|
590 |
+
{
|
591 |
+
if( in_array($this->field['field_type'], array('checkbox', 'radio')) )
|
592 |
+
{
|
593 |
+
$output .= '</li>';
|
594 |
+
}
|
595 |
+
|
596 |
+
$output .= "\n";
|
597 |
+
}
|
598 |
+
|
599 |
+
|
600 |
+
// start_lvl
|
601 |
+
function start_lvl( &$output, $depth = 0, $args = array() )
|
602 |
+
{
|
603 |
+
// indent
|
604 |
+
//$output .= str_repeat( "\t", $depth);
|
605 |
+
|
606 |
+
|
607 |
+
// wrap element
|
608 |
+
if( in_array($this->field['field_type'], array('checkbox', 'radio')) )
|
609 |
+
{
|
610 |
+
$output .= '<ul class="children">' . "\n";
|
611 |
+
}
|
612 |
+
}
|
613 |
+
|
614 |
+
|
615 |
+
// end_lvl
|
616 |
+
function end_lvl( &$output, $depth = 0, $args = array() )
|
617 |
+
{
|
618 |
+
// indent
|
619 |
+
//$output .= str_repeat( "\t", $depth);
|
620 |
+
|
621 |
+
|
622 |
+
// wrap element
|
623 |
+
if( in_array($this->field['field_type'], array('checkbox', 'radio')) )
|
624 |
+
{
|
625 |
+
$output .= '</ul>' . "\n";
|
626 |
+
}
|
627 |
+
}
|
628 |
+
|
629 |
+
}
|
630 |
+
|
631 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/fields/text.php
CHANGED
@@ -1,279 +1,279 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_field_text extends acf_field
|
4 |
-
{
|
5 |
-
|
6 |
-
/*
|
7 |
-
* __construct
|
8 |
-
*
|
9 |
-
* Set name / label needed for actions / filters
|
10 |
-
*
|
11 |
-
* @since 3.6
|
12 |
-
* @date 23/01/13
|
13 |
-
*/
|
14 |
-
|
15 |
-
function __construct()
|
16 |
-
{
|
17 |
-
// vars
|
18 |
-
$this->name = 'text';
|
19 |
-
$this->label = __("Text",'acf');
|
20 |
-
$this->defaults = array(
|
21 |
-
'default_value' => '',
|
22 |
-
'formatting' => 'html',
|
23 |
-
'maxlength' => '',
|
24 |
-
'placeholder' => '',
|
25 |
-
'prepend' => '',
|
26 |
-
'append' => ''
|
27 |
-
);
|
28 |
-
|
29 |
-
|
30 |
-
// do not delete!
|
31 |
-
parent::__construct();
|
32 |
-
}
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
/*
|
37 |
-
* create_field()
|
38 |
-
*
|
39 |
-
* Create the HTML interface for your field
|
40 |
-
*
|
41 |
-
* @param $field - an array holding all the field's data
|
42 |
-
*
|
43 |
-
* @type action
|
44 |
-
* @since 3.6
|
45 |
-
* @date 23/01/13
|
46 |
-
*/
|
47 |
-
|
48 |
-
function create_field( $field )
|
49 |
-
{
|
50 |
-
// vars
|
51 |
-
$o = array( 'id', 'class', 'name', 'value', 'placeholder' );
|
52 |
-
$e = '';
|
53 |
-
|
54 |
-
|
55 |
-
// maxlength
|
56 |
-
if( $field['maxlength'] !== "" )
|
57 |
-
{
|
58 |
-
$o[] = 'maxlength';
|
59 |
-
}
|
60 |
-
|
61 |
-
|
62 |
-
// prepend
|
63 |
-
if( $field['prepend'] !== "" )
|
64 |
-
{
|
65 |
-
$field['class'] .= ' acf-is-prepended';
|
66 |
-
$e .= '<div class="acf-input-prepend">' . $field['prepend'] . '</div>';
|
67 |
-
}
|
68 |
-
|
69 |
-
|
70 |
-
// append
|
71 |
-
if( $field['append'] !== "" )
|
72 |
-
{
|
73 |
-
$field['class'] .= ' acf-is-appended';
|
74 |
-
$e .= '<div class="acf-input-append">' . $field['append'] . '</div>';
|
75 |
-
}
|
76 |
-
|
77 |
-
|
78 |
-
$e .= '<div class="acf-input-wrap">';
|
79 |
-
$e .= '<input type="text"';
|
80 |
-
|
81 |
-
foreach( $o as $k )
|
82 |
-
{
|
83 |
-
$e .= ' ' . $k . '="' . esc_attr( $field[ $k ] ) . '"';
|
84 |
-
}
|
85 |
-
|
86 |
-
$e .= ' />';
|
87 |
-
$e .= '</div>';
|
88 |
-
|
89 |
-
|
90 |
-
// return
|
91 |
-
echo $e;
|
92 |
-
}
|
93 |
-
|
94 |
-
|
95 |
-
/*
|
96 |
-
* create_options()
|
97 |
-
*
|
98 |
-
* Create extra options for your field. This is rendered when editing a field.
|
99 |
-
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
100 |
-
*
|
101 |
-
* @param $field - an array holding all the field's data
|
102 |
-
*
|
103 |
-
* @type action
|
104 |
-
* @since 3.6
|
105 |
-
* @date 23/01/13
|
106 |
-
*/
|
107 |
-
|
108 |
-
function create_options( $field )
|
109 |
-
{
|
110 |
-
// vars
|
111 |
-
$key = $field['name'];
|
112 |
-
|
113 |
-
?>
|
114 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
115 |
-
<td class="label">
|
116 |
-
<label><?php _e("Default Value",'acf'); ?></label>
|
117 |
-
<p><?php _e("Appears when creating a new post",'acf') ?></p>
|
118 |
-
</td>
|
119 |
-
<td>
|
120 |
-
<?php
|
121 |
-
do_action('acf/create_field', array(
|
122 |
-
'type' => 'text',
|
123 |
-
'name' => 'fields[' .$key.'][default_value]',
|
124 |
-
'value' => $field['default_value'],
|
125 |
-
));
|
126 |
-
?>
|
127 |
-
</td>
|
128 |
-
</tr>
|
129 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
130 |
-
<td class="label">
|
131 |
-
<label><?php _e("Placeholder Text",'acf'); ?></label>
|
132 |
-
<p><?php _e("Appears within the input",'acf') ?></p>
|
133 |
-
</td>
|
134 |
-
<td>
|
135 |
-
<?php
|
136 |
-
do_action('acf/create_field', array(
|
137 |
-
'type' => 'text',
|
138 |
-
'name' => 'fields[' .$key.'][placeholder]',
|
139 |
-
'value' => $field['placeholder'],
|
140 |
-
));
|
141 |
-
?>
|
142 |
-
</td>
|
143 |
-
</tr>
|
144 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
145 |
-
<td class="label">
|
146 |
-
<label><?php _e("Prepend",'acf'); ?></label>
|
147 |
-
<p><?php _e("Appears before the input",'acf') ?></p>
|
148 |
-
</td>
|
149 |
-
<td>
|
150 |
-
<?php
|
151 |
-
do_action('acf/create_field', array(
|
152 |
-
'type' => 'text',
|
153 |
-
'name' => 'fields[' .$key.'][prepend]',
|
154 |
-
'value' => $field['prepend'],
|
155 |
-
));
|
156 |
-
?>
|
157 |
-
</td>
|
158 |
-
</tr>
|
159 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
160 |
-
<td class="label">
|
161 |
-
<label><?php _e("Append",'acf'); ?></label>
|
162 |
-
<p><?php _e("Appears after the input",'acf') ?></p>
|
163 |
-
</td>
|
164 |
-
<td>
|
165 |
-
<?php
|
166 |
-
do_action('acf/create_field', array(
|
167 |
-
'type' => 'text',
|
168 |
-
'name' => 'fields[' .$key.'][append]',
|
169 |
-
'value' => $field['append'],
|
170 |
-
));
|
171 |
-
?>
|
172 |
-
</td>
|
173 |
-
</tr>
|
174 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
175 |
-
<td class="label">
|
176 |
-
<label><?php _e("Formatting",'acf'); ?></label>
|
177 |
-
<p><?php _e("Affects value on front end",'acf') ?></p>
|
178 |
-
</td>
|
179 |
-
<td>
|
180 |
-
<?php
|
181 |
-
do_action('acf/create_field', array(
|
182 |
-
'type' => 'select',
|
183 |
-
'name' => 'fields['.$key.'][formatting]',
|
184 |
-
'value' => $field['formatting'],
|
185 |
-
'choices' => array(
|
186 |
-
'none' => __("No formatting",'acf'),
|
187 |
-
'html' => __("Convert HTML into tags",'acf')
|
188 |
-
)
|
189 |
-
));
|
190 |
-
?>
|
191 |
-
</td>
|
192 |
-
</tr>
|
193 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
194 |
-
<td class="label">
|
195 |
-
<label><?php _e("Character Limit",'acf'); ?></label>
|
196 |
-
<p><?php _e("Leave blank for no limit",'acf') ?></p>
|
197 |
-
</td>
|
198 |
-
<td>
|
199 |
-
<?php
|
200 |
-
do_action('acf/create_field', array(
|
201 |
-
'type' => 'number',
|
202 |
-
'name' => 'fields[' .$key.'][maxlength]',
|
203 |
-
'value' => $field['maxlength'],
|
204 |
-
));
|
205 |
-
?>
|
206 |
-
</td>
|
207 |
-
</tr>
|
208 |
-
<?php
|
209 |
-
|
210 |
-
}
|
211 |
-
|
212 |
-
|
213 |
-
/*
|
214 |
-
* format_value()
|
215 |
-
*
|
216 |
-
* This filter is appied to the $value after it is loaded from the db and before it is passed to the create_field action
|
217 |
-
*
|
218 |
-
* @type filter
|
219 |
-
* @since 3.6
|
220 |
-
* @date 23/01/13
|
221 |
-
*
|
222 |
-
* @param $value - the value which was loaded from the database
|
223 |
-
* @param $post_id - the $post_id from which the value was loaded
|
224 |
-
* @param $field - the field array holding all the field options
|
225 |
-
*
|
226 |
-
* @return $value - the modified value
|
227 |
-
*/
|
228 |
-
|
229 |
-
function format_value( $value, $post_id, $field )
|
230 |
-
{
|
231 |
-
$value = htmlspecialchars($value, ENT_QUOTES);
|
232 |
-
|
233 |
-
return $value;
|
234 |
-
}
|
235 |
-
|
236 |
-
|
237 |
-
/*
|
238 |
-
* format_value_for_api()
|
239 |
-
*
|
240 |
-
* This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
|
241 |
-
*
|
242 |
-
* @type filter
|
243 |
-
* @since 3.6
|
244 |
-
* @date 23/01/13
|
245 |
-
*
|
246 |
-
* @param $value - the value which was loaded from the database
|
247 |
-
* @param $post_id - the $post_id from which the value was loaded
|
248 |
-
* @param $field - the field array holding all the field options
|
249 |
-
*
|
250 |
-
* @return $value - the modified value
|
251 |
-
*/
|
252 |
-
|
253 |
-
function format_value_for_api( $value, $post_id, $field )
|
254 |
-
{
|
255 |
-
// validate type
|
256 |
-
if( !is_string($value) )
|
257 |
-
{
|
258 |
-
return $value;
|
259 |
-
}
|
260 |
-
|
261 |
-
|
262 |
-
if( $field['formatting'] == 'none' )
|
263 |
-
{
|
264 |
-
$value = htmlspecialchars($value, ENT_QUOTES);
|
265 |
-
}
|
266 |
-
elseif( $field['formatting'] == 'html' )
|
267 |
-
{
|
268 |
-
$value = nl2br($value);
|
269 |
-
}
|
270 |
-
|
271 |
-
|
272 |
-
return $value;
|
273 |
-
}
|
274 |
-
|
275 |
-
}
|
276 |
-
|
277 |
-
new acf_field_text();
|
278 |
-
|
279 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class acf_field_text extends acf_field
|
4 |
+
{
|
5 |
+
|
6 |
+
/*
|
7 |
+
* __construct
|
8 |
+
*
|
9 |
+
* Set name / label needed for actions / filters
|
10 |
+
*
|
11 |
+
* @since 3.6
|
12 |
+
* @date 23/01/13
|
13 |
+
*/
|
14 |
+
|
15 |
+
function __construct()
|
16 |
+
{
|
17 |
+
// vars
|
18 |
+
$this->name = 'text';
|
19 |
+
$this->label = __("Text",'acf');
|
20 |
+
$this->defaults = array(
|
21 |
+
'default_value' => '',
|
22 |
+
'formatting' => 'html',
|
23 |
+
'maxlength' => '',
|
24 |
+
'placeholder' => '',
|
25 |
+
'prepend' => '',
|
26 |
+
'append' => ''
|
27 |
+
);
|
28 |
+
|
29 |
+
|
30 |
+
// do not delete!
|
31 |
+
parent::__construct();
|
32 |
+
}
|
33 |
+
|
34 |
+
|
35 |
+
|
36 |
+
/*
|
37 |
+
* create_field()
|
38 |
+
*
|
39 |
+
* Create the HTML interface for your field
|
40 |
+
*
|
41 |
+
* @param $field - an array holding all the field's data
|
42 |
+
*
|
43 |
+
* @type action
|
44 |
+
* @since 3.6
|
45 |
+
* @date 23/01/13
|
46 |
+
*/
|
47 |
+
|
48 |
+
function create_field( $field )
|
49 |
+
{
|
50 |
+
// vars
|
51 |
+
$o = array( 'id', 'class', 'name', 'value', 'placeholder' );
|
52 |
+
$e = '';
|
53 |
+
|
54 |
+
|
55 |
+
// maxlength
|
56 |
+
if( $field['maxlength'] !== "" )
|
57 |
+
{
|
58 |
+
$o[] = 'maxlength';
|
59 |
+
}
|
60 |
+
|
61 |
+
|
62 |
+
// prepend
|
63 |
+
if( $field['prepend'] !== "" )
|
64 |
+
{
|
65 |
+
$field['class'] .= ' acf-is-prepended';
|
66 |
+
$e .= '<div class="acf-input-prepend">' . $field['prepend'] . '</div>';
|
67 |
+
}
|
68 |
+
|
69 |
+
|
70 |
+
// append
|
71 |
+
if( $field['append'] !== "" )
|
72 |
+
{
|
73 |
+
$field['class'] .= ' acf-is-appended';
|
74 |
+
$e .= '<div class="acf-input-append">' . $field['append'] . '</div>';
|
75 |
+
}
|
76 |
+
|
77 |
+
|
78 |
+
$e .= '<div class="acf-input-wrap">';
|
79 |
+
$e .= '<input type="text"';
|
80 |
+
|
81 |
+
foreach( $o as $k )
|
82 |
+
{
|
83 |
+
$e .= ' ' . $k . '="' . esc_attr( $field[ $k ] ) . '"';
|
84 |
+
}
|
85 |
+
|
86 |
+
$e .= ' />';
|
87 |
+
$e .= '</div>';
|
88 |
+
|
89 |
+
|
90 |
+
// return
|
91 |
+
echo $e;
|
92 |
+
}
|
93 |
+
|
94 |
+
|
95 |
+
/*
|
96 |
+
* create_options()
|
97 |
+
*
|
98 |
+
* Create extra options for your field. This is rendered when editing a field.
|
99 |
+
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
100 |
+
*
|
101 |
+
* @param $field - an array holding all the field's data
|
102 |
+
*
|
103 |
+
* @type action
|
104 |
+
* @since 3.6
|
105 |
+
* @date 23/01/13
|
106 |
+
*/
|
107 |
+
|
108 |
+
function create_options( $field )
|
109 |
+
{
|
110 |
+
// vars
|
111 |
+
$key = $field['name'];
|
112 |
+
|
113 |
+
?>
|
114 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
115 |
+
<td class="label">
|
116 |
+
<label><?php _e("Default Value",'acf'); ?></label>
|
117 |
+
<p><?php _e("Appears when creating a new post",'acf') ?></p>
|
118 |
+
</td>
|
119 |
+
<td>
|
120 |
+
<?php
|
121 |
+
do_action('acf/create_field', array(
|
122 |
+
'type' => 'text',
|
123 |
+
'name' => 'fields[' .$key.'][default_value]',
|
124 |
+
'value' => $field['default_value'],
|
125 |
+
));
|
126 |
+
?>
|
127 |
+
</td>
|
128 |
+
</tr>
|
129 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
130 |
+
<td class="label">
|
131 |
+
<label><?php _e("Placeholder Text",'acf'); ?></label>
|
132 |
+
<p><?php _e("Appears within the input",'acf') ?></p>
|
133 |
+
</td>
|
134 |
+
<td>
|
135 |
+
<?php
|
136 |
+
do_action('acf/create_field', array(
|
137 |
+
'type' => 'text',
|
138 |
+
'name' => 'fields[' .$key.'][placeholder]',
|
139 |
+
'value' => $field['placeholder'],
|
140 |
+
));
|
141 |
+
?>
|
142 |
+
</td>
|
143 |
+
</tr>
|
144 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
145 |
+
<td class="label">
|
146 |
+
<label><?php _e("Prepend",'acf'); ?></label>
|
147 |
+
<p><?php _e("Appears before the input",'acf') ?></p>
|
148 |
+
</td>
|
149 |
+
<td>
|
150 |
+
<?php
|
151 |
+
do_action('acf/create_field', array(
|
152 |
+
'type' => 'text',
|
153 |
+
'name' => 'fields[' .$key.'][prepend]',
|
154 |
+
'value' => $field['prepend'],
|
155 |
+
));
|
156 |
+
?>
|
157 |
+
</td>
|
158 |
+
</tr>
|
159 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
160 |
+
<td class="label">
|
161 |
+
<label><?php _e("Append",'acf'); ?></label>
|
162 |
+
<p><?php _e("Appears after the input",'acf') ?></p>
|
163 |
+
</td>
|
164 |
+
<td>
|
165 |
+
<?php
|
166 |
+
do_action('acf/create_field', array(
|
167 |
+
'type' => 'text',
|
168 |
+
'name' => 'fields[' .$key.'][append]',
|
169 |
+
'value' => $field['append'],
|
170 |
+
));
|
171 |
+
?>
|
172 |
+
</td>
|
173 |
+
</tr>
|
174 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
175 |
+
<td class="label">
|
176 |
+
<label><?php _e("Formatting",'acf'); ?></label>
|
177 |
+
<p><?php _e("Affects value on front end",'acf') ?></p>
|
178 |
+
</td>
|
179 |
+
<td>
|
180 |
+
<?php
|
181 |
+
do_action('acf/create_field', array(
|
182 |
+
'type' => 'select',
|
183 |
+
'name' => 'fields['.$key.'][formatting]',
|
184 |
+
'value' => $field['formatting'],
|
185 |
+
'choices' => array(
|
186 |
+
'none' => __("No formatting",'acf'),
|
187 |
+
'html' => __("Convert HTML into tags",'acf')
|
188 |
+
)
|
189 |
+
));
|
190 |
+
?>
|
191 |
+
</td>
|
192 |
+
</tr>
|
193 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
194 |
+
<td class="label">
|
195 |
+
<label><?php _e("Character Limit",'acf'); ?></label>
|
196 |
+
<p><?php _e("Leave blank for no limit",'acf') ?></p>
|
197 |
+
</td>
|
198 |
+
<td>
|
199 |
+
<?php
|
200 |
+
do_action('acf/create_field', array(
|
201 |
+
'type' => 'number',
|
202 |
+
'name' => 'fields[' .$key.'][maxlength]',
|
203 |
+
'value' => $field['maxlength'],
|
204 |
+
));
|
205 |
+
?>
|
206 |
+
</td>
|
207 |
+
</tr>
|
208 |
+
<?php
|
209 |
+
|
210 |
+
}
|
211 |
+
|
212 |
+
|
213 |
+
/*
|
214 |
+
* format_value()
|
215 |
+
*
|
216 |
+
* This filter is appied to the $value after it is loaded from the db and before it is passed to the create_field action
|
217 |
+
*
|
218 |
+
* @type filter
|
219 |
+
* @since 3.6
|
220 |
+
* @date 23/01/13
|
221 |
+
*
|
222 |
+
* @param $value - the value which was loaded from the database
|
223 |
+
* @param $post_id - the $post_id from which the value was loaded
|
224 |
+
* @param $field - the field array holding all the field options
|
225 |
+
*
|
226 |
+
* @return $value - the modified value
|
227 |
+
*/
|
228 |
+
|
229 |
+
function format_value( $value, $post_id, $field )
|
230 |
+
{
|
231 |
+
$value = htmlspecialchars($value, ENT_QUOTES);
|
232 |
+
|
233 |
+
return $value;
|
234 |
+
}
|
235 |
+
|
236 |
+
|
237 |
+
/*
|
238 |
+
* format_value_for_api()
|
239 |
+
*
|
240 |
+
* This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
|
241 |
+
*
|
242 |
+
* @type filter
|
243 |
+
* @since 3.6
|
244 |
+
* @date 23/01/13
|
245 |
+
*
|
246 |
+
* @param $value - the value which was loaded from the database
|
247 |
+
* @param $post_id - the $post_id from which the value was loaded
|
248 |
+
* @param $field - the field array holding all the field options
|
249 |
+
*
|
250 |
+
* @return $value - the modified value
|
251 |
+
*/
|
252 |
+
|
253 |
+
function format_value_for_api( $value, $post_id, $field )
|
254 |
+
{
|
255 |
+
// validate type
|
256 |
+
if( !is_string($value) )
|
257 |
+
{
|
258 |
+
return $value;
|
259 |
+
}
|
260 |
+
|
261 |
+
|
262 |
+
if( $field['formatting'] == 'none' )
|
263 |
+
{
|
264 |
+
$value = htmlspecialchars($value, ENT_QUOTES);
|
265 |
+
}
|
266 |
+
elseif( $field['formatting'] == 'html' )
|
267 |
+
{
|
268 |
+
$value = nl2br($value);
|
269 |
+
}
|
270 |
+
|
271 |
+
|
272 |
+
return $value;
|
273 |
+
}
|
274 |
+
|
275 |
+
}
|
276 |
+
|
277 |
+
new acf_field_text();
|
278 |
+
|
279 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/fields/textarea.php
CHANGED
@@ -1,235 +1,235 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_field_textarea extends acf_field
|
4 |
-
{
|
5 |
-
|
6 |
-
/*
|
7 |
-
* __construct
|
8 |
-
*
|
9 |
-
* Set name / label needed for actions / filters
|
10 |
-
*
|
11 |
-
* @since 3.6
|
12 |
-
* @date 23/01/13
|
13 |
-
*/
|
14 |
-
|
15 |
-
function __construct()
|
16 |
-
{
|
17 |
-
// vars
|
18 |
-
$this->name = 'textarea';
|
19 |
-
$this->label = __("Text Area",'acf');
|
20 |
-
$this->defaults = array(
|
21 |
-
'default_value' => '',
|
22 |
-
'formatting' => 'br',
|
23 |
-
'maxlength' => '',
|
24 |
-
'placeholder' => '',
|
25 |
-
'rows' => ''
|
26 |
-
);
|
27 |
-
|
28 |
-
|
29 |
-
// do not delete!
|
30 |
-
parent::__construct();
|
31 |
-
}
|
32 |
-
|
33 |
-
|
34 |
-
/*
|
35 |
-
* create_field()
|
36 |
-
*
|
37 |
-
* Create the HTML interface for your field
|
38 |
-
*
|
39 |
-
* @param $field - an array holding all the field's data
|
40 |
-
*
|
41 |
-
* @type action
|
42 |
-
* @since 3.6
|
43 |
-
* @date 23/01/13
|
44 |
-
*/
|
45 |
-
|
46 |
-
function create_field( $field )
|
47 |
-
{
|
48 |
-
// vars
|
49 |
-
$o = array( 'id', 'class', 'name', 'placeholder', 'rows' );
|
50 |
-
$e = '';
|
51 |
-
|
52 |
-
|
53 |
-
// maxlength
|
54 |
-
if( $field['maxlength'] !== "" )
|
55 |
-
{
|
56 |
-
$o[] = 'maxlength';
|
57 |
-
}
|
58 |
-
|
59 |
-
|
60 |
-
// rows
|
61 |
-
if( empty($field['rows']) )
|
62 |
-
{
|
63 |
-
$field['rows'] = 8;
|
64 |
-
}
|
65 |
-
|
66 |
-
$e .= '<textarea';
|
67 |
-
|
68 |
-
foreach( $o as $k )
|
69 |
-
{
|
70 |
-
$e .= ' ' . $k . '="' . esc_attr( $field[ $k ] ) . '"';
|
71 |
-
}
|
72 |
-
|
73 |
-
$e .= '>';
|
74 |
-
$e .= esc_textarea($field['value']);
|
75 |
-
$e .= '</textarea>';
|
76 |
-
|
77 |
-
// return
|
78 |
-
echo $e;
|
79 |
-
|
80 |
-
}
|
81 |
-
|
82 |
-
/*
|
83 |
-
* create_options()
|
84 |
-
*
|
85 |
-
* Create extra options for your field. This is rendered when editing a field.
|
86 |
-
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
87 |
-
*
|
88 |
-
* @param $field - an array holding all the field's data
|
89 |
-
*
|
90 |
-
* @type action
|
91 |
-
* @since 3.6
|
92 |
-
* @date 23/01/13
|
93 |
-
*/
|
94 |
-
|
95 |
-
function create_options( $field )
|
96 |
-
{
|
97 |
-
// vars
|
98 |
-
$key = $field['name'];
|
99 |
-
|
100 |
-
?>
|
101 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
102 |
-
<td class="label">
|
103 |
-
<label><?php _e("Default Value",'acf'); ?></label>
|
104 |
-
<p><?php _e("Appears when creating a new post",'acf') ?></p>
|
105 |
-
</td>
|
106 |
-
<td>
|
107 |
-
<?php
|
108 |
-
do_action('acf/create_field', array(
|
109 |
-
'type' => 'textarea',
|
110 |
-
'name' => 'fields['.$key.'][default_value]',
|
111 |
-
'value' => $field['default_value'],
|
112 |
-
));
|
113 |
-
?>
|
114 |
-
</td>
|
115 |
-
</tr>
|
116 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
117 |
-
<td class="label">
|
118 |
-
<label><?php _e("Placeholder Text",'acf'); ?></label>
|
119 |
-
<p><?php _e("Appears within the input",'acf') ?></p>
|
120 |
-
</td>
|
121 |
-
<td>
|
122 |
-
<?php
|
123 |
-
do_action('acf/create_field', array(
|
124 |
-
'type' => 'text',
|
125 |
-
'name' => 'fields[' .$key.'][placeholder]',
|
126 |
-
'value' => $field['placeholder'],
|
127 |
-
));
|
128 |
-
?>
|
129 |
-
</td>
|
130 |
-
</tr>
|
131 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
132 |
-
<td class="label">
|
133 |
-
<label><?php _e("Character Limit",'acf'); ?></label>
|
134 |
-
<p><?php _e("Leave blank for no limit",'acf') ?></p>
|
135 |
-
</td>
|
136 |
-
<td>
|
137 |
-
<?php
|
138 |
-
do_action('acf/create_field', array(
|
139 |
-
'type' => 'number',
|
140 |
-
'name' => 'fields[' .$key.'][maxlength]',
|
141 |
-
'value' => $field['maxlength'],
|
142 |
-
));
|
143 |
-
?>
|
144 |
-
</td>
|
145 |
-
</tr>
|
146 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
147 |
-
<td class="label">
|
148 |
-
<label><?php _e("Rows",'acf'); ?></label>
|
149 |
-
<p><?php _e("Sets the textarea height",'acf') ?></p>
|
150 |
-
</td>
|
151 |
-
<td>
|
152 |
-
<?php
|
153 |
-
do_action('acf/create_field', array(
|
154 |
-
'type' => 'number',
|
155 |
-
'name' => 'fields[' .$key.'][rows]',
|
156 |
-
'value' => $field['rows'],
|
157 |
-
'placeholder' => 8
|
158 |
-
));
|
159 |
-
?>
|
160 |
-
</td>
|
161 |
-
</tr>
|
162 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
163 |
-
<td class="label">
|
164 |
-
<label><?php _e("Formatting",'acf'); ?></label>
|
165 |
-
<p><?php _e("Affects value on front end",'acf') ?></p>
|
166 |
-
</td>
|
167 |
-
<td>
|
168 |
-
<?php
|
169 |
-
do_action('acf/create_field', array(
|
170 |
-
'type' => 'select',
|
171 |
-
'name' => 'fields['.$key.'][formatting]',
|
172 |
-
'value' => $field['formatting'],
|
173 |
-
'choices' => array(
|
174 |
-
'none' => __("No formatting",'acf'),
|
175 |
-
'br' => __("Convert new lines into <br /> tags",'acf'),
|
176 |
-
'html' => __("Convert HTML into tags",'acf')
|
177 |
-
)
|
178 |
-
));
|
179 |
-
?>
|
180 |
-
</td>
|
181 |
-
</tr>
|
182 |
-
<?php
|
183 |
-
|
184 |
-
}
|
185 |
-
|
186 |
-
|
187 |
-
/*
|
188 |
-
* format_value_for_api()
|
189 |
-
*
|
190 |
-
* This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
|
191 |
-
*
|
192 |
-
* @type filter
|
193 |
-
* @since 3.6
|
194 |
-
* @date 23/01/13
|
195 |
-
*
|
196 |
-
* @param $value - the value which was loaded from the database
|
197 |
-
* @param $post_id - the $post_id from which the value was loaded
|
198 |
-
* @param $field - the field array holding all the field options
|
199 |
-
*
|
200 |
-
* @return $value - the modified value
|
201 |
-
*/
|
202 |
-
|
203 |
-
function format_value_for_api( $value, $post_id, $field )
|
204 |
-
{
|
205 |
-
// validate type
|
206 |
-
if( !is_string($value) )
|
207 |
-
{
|
208 |
-
return $value;
|
209 |
-
}
|
210 |
-
|
211 |
-
|
212 |
-
if( $field['formatting'] == 'none' )
|
213 |
-
{
|
214 |
-
$value = htmlspecialchars($value, ENT_QUOTES);
|
215 |
-
}
|
216 |
-
elseif( $field['formatting'] == 'html' )
|
217 |
-
{
|
218 |
-
//$value = html_entity_decode($value);
|
219 |
-
//$value = nl2br($value);
|
220 |
-
}
|
221 |
-
elseif( $field['formatting'] == 'br' )
|
222 |
-
{
|
223 |
-
$value = htmlspecialchars($value, ENT_QUOTES);
|
224 |
-
$value = nl2br($value);
|
225 |
-
}
|
226 |
-
|
227 |
-
|
228 |
-
return $value;
|
229 |
-
}
|
230 |
-
|
231 |
-
}
|
232 |
-
|
233 |
-
new acf_field_textarea();
|
234 |
-
|
235 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class acf_field_textarea extends acf_field
|
4 |
+
{
|
5 |
+
|
6 |
+
/*
|
7 |
+
* __construct
|
8 |
+
*
|
9 |
+
* Set name / label needed for actions / filters
|
10 |
+
*
|
11 |
+
* @since 3.6
|
12 |
+
* @date 23/01/13
|
13 |
+
*/
|
14 |
+
|
15 |
+
function __construct()
|
16 |
+
{
|
17 |
+
// vars
|
18 |
+
$this->name = 'textarea';
|
19 |
+
$this->label = __("Text Area",'acf');
|
20 |
+
$this->defaults = array(
|
21 |
+
'default_value' => '',
|
22 |
+
'formatting' => 'br',
|
23 |
+
'maxlength' => '',
|
24 |
+
'placeholder' => '',
|
25 |
+
'rows' => ''
|
26 |
+
);
|
27 |
+
|
28 |
+
|
29 |
+
// do not delete!
|
30 |
+
parent::__construct();
|
31 |
+
}
|
32 |
+
|
33 |
+
|
34 |
+
/*
|
35 |
+
* create_field()
|
36 |
+
*
|
37 |
+
* Create the HTML interface for your field
|
38 |
+
*
|
39 |
+
* @param $field - an array holding all the field's data
|
40 |
+
*
|
41 |
+
* @type action
|
42 |
+
* @since 3.6
|
43 |
+
* @date 23/01/13
|
44 |
+
*/
|
45 |
+
|
46 |
+
function create_field( $field )
|
47 |
+
{
|
48 |
+
// vars
|
49 |
+
$o = array( 'id', 'class', 'name', 'placeholder', 'rows' );
|
50 |
+
$e = '';
|
51 |
+
|
52 |
+
|
53 |
+
// maxlength
|
54 |
+
if( $field['maxlength'] !== "" )
|
55 |
+
{
|
56 |
+
$o[] = 'maxlength';
|
57 |
+
}
|
58 |
+
|
59 |
+
|
60 |
+
// rows
|
61 |
+
if( empty($field['rows']) )
|
62 |
+
{
|
63 |
+
$field['rows'] = 8;
|
64 |
+
}
|
65 |
+
|
66 |
+
$e .= '<textarea';
|
67 |
+
|
68 |
+
foreach( $o as $k )
|
69 |
+
{
|
70 |
+
$e .= ' ' . $k . '="' . esc_attr( $field[ $k ] ) . '"';
|
71 |
+
}
|
72 |
+
|
73 |
+
$e .= '>';
|
74 |
+
$e .= esc_textarea($field['value']);
|
75 |
+
$e .= '</textarea>';
|
76 |
+
|
77 |
+
// return
|
78 |
+
echo $e;
|
79 |
+
|
80 |
+
}
|
81 |
+
|
82 |
+
/*
|
83 |
+
* create_options()
|
84 |
+
*
|
85 |
+
* Create extra options for your field. This is rendered when editing a field.
|
86 |
+
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
87 |
+
*
|
88 |
+
* @param $field - an array holding all the field's data
|
89 |
+
*
|
90 |
+
* @type action
|
91 |
+
* @since 3.6
|
92 |
+
* @date 23/01/13
|
93 |
+
*/
|
94 |
+
|
95 |
+
function create_options( $field )
|
96 |
+
{
|
97 |
+
// vars
|
98 |
+
$key = $field['name'];
|
99 |
+
|
100 |
+
?>
|
101 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
102 |
+
<td class="label">
|
103 |
+
<label><?php _e("Default Value",'acf'); ?></label>
|
104 |
+
<p><?php _e("Appears when creating a new post",'acf') ?></p>
|
105 |
+
</td>
|
106 |
+
<td>
|
107 |
+
<?php
|
108 |
+
do_action('acf/create_field', array(
|
109 |
+
'type' => 'textarea',
|
110 |
+
'name' => 'fields['.$key.'][default_value]',
|
111 |
+
'value' => $field['default_value'],
|
112 |
+
));
|
113 |
+
?>
|
114 |
+
</td>
|
115 |
+
</tr>
|
116 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
117 |
+
<td class="label">
|
118 |
+
<label><?php _e("Placeholder Text",'acf'); ?></label>
|
119 |
+
<p><?php _e("Appears within the input",'acf') ?></p>
|
120 |
+
</td>
|
121 |
+
<td>
|
122 |
+
<?php
|
123 |
+
do_action('acf/create_field', array(
|
124 |
+
'type' => 'text',
|
125 |
+
'name' => 'fields[' .$key.'][placeholder]',
|
126 |
+
'value' => $field['placeholder'],
|
127 |
+
));
|
128 |
+
?>
|
129 |
+
</td>
|
130 |
+
</tr>
|
131 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
132 |
+
<td class="label">
|
133 |
+
<label><?php _e("Character Limit",'acf'); ?></label>
|
134 |
+
<p><?php _e("Leave blank for no limit",'acf') ?></p>
|
135 |
+
</td>
|
136 |
+
<td>
|
137 |
+
<?php
|
138 |
+
do_action('acf/create_field', array(
|
139 |
+
'type' => 'number',
|
140 |
+
'name' => 'fields[' .$key.'][maxlength]',
|
141 |
+
'value' => $field['maxlength'],
|
142 |
+
));
|
143 |
+
?>
|
144 |
+
</td>
|
145 |
+
</tr>
|
146 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
147 |
+
<td class="label">
|
148 |
+
<label><?php _e("Rows",'acf'); ?></label>
|
149 |
+
<p><?php _e("Sets the textarea height",'acf') ?></p>
|
150 |
+
</td>
|
151 |
+
<td>
|
152 |
+
<?php
|
153 |
+
do_action('acf/create_field', array(
|
154 |
+
'type' => 'number',
|
155 |
+
'name' => 'fields[' .$key.'][rows]',
|
156 |
+
'value' => $field['rows'],
|
157 |
+
'placeholder' => 8
|
158 |
+
));
|
159 |
+
?>
|
160 |
+
</td>
|
161 |
+
</tr>
|
162 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
163 |
+
<td class="label">
|
164 |
+
<label><?php _e("Formatting",'acf'); ?></label>
|
165 |
+
<p><?php _e("Affects value on front end",'acf') ?></p>
|
166 |
+
</td>
|
167 |
+
<td>
|
168 |
+
<?php
|
169 |
+
do_action('acf/create_field', array(
|
170 |
+
'type' => 'select',
|
171 |
+
'name' => 'fields['.$key.'][formatting]',
|
172 |
+
'value' => $field['formatting'],
|
173 |
+
'choices' => array(
|
174 |
+
'none' => __("No formatting",'acf'),
|
175 |
+
'br' => __("Convert new lines into <br /> tags",'acf'),
|
176 |
+
'html' => __("Convert HTML into tags",'acf')
|
177 |
+
)
|
178 |
+
));
|
179 |
+
?>
|
180 |
+
</td>
|
181 |
+
</tr>
|
182 |
+
<?php
|
183 |
+
|
184 |
+
}
|
185 |
+
|
186 |
+
|
187 |
+
/*
|
188 |
+
* format_value_for_api()
|
189 |
+
*
|
190 |
+
* This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
|
191 |
+
*
|
192 |
+
* @type filter
|
193 |
+
* @since 3.6
|
194 |
+
* @date 23/01/13
|
195 |
+
*
|
196 |
+
* @param $value - the value which was loaded from the database
|
197 |
+
* @param $post_id - the $post_id from which the value was loaded
|
198 |
+
* @param $field - the field array holding all the field options
|
199 |
+
*
|
200 |
+
* @return $value - the modified value
|
201 |
+
*/
|
202 |
+
|
203 |
+
function format_value_for_api( $value, $post_id, $field )
|
204 |
+
{
|
205 |
+
// validate type
|
206 |
+
if( !is_string($value) )
|
207 |
+
{
|
208 |
+
return $value;
|
209 |
+
}
|
210 |
+
|
211 |
+
|
212 |
+
if( $field['formatting'] == 'none' )
|
213 |
+
{
|
214 |
+
$value = htmlspecialchars($value, ENT_QUOTES);
|
215 |
+
}
|
216 |
+
elseif( $field['formatting'] == 'html' )
|
217 |
+
{
|
218 |
+
//$value = html_entity_decode($value);
|
219 |
+
//$value = nl2br($value);
|
220 |
+
}
|
221 |
+
elseif( $field['formatting'] == 'br' )
|
222 |
+
{
|
223 |
+
$value = htmlspecialchars($value, ENT_QUOTES);
|
224 |
+
$value = nl2br($value);
|
225 |
+
}
|
226 |
+
|
227 |
+
|
228 |
+
return $value;
|
229 |
+
}
|
230 |
+
|
231 |
+
}
|
232 |
+
|
233 |
+
new acf_field_textarea();
|
234 |
+
|
235 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/fields/true_false.php
CHANGED
@@ -1,140 +1,140 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_field_true_false extends acf_field
|
4 |
-
{
|
5 |
-
|
6 |
-
/*
|
7 |
-
* __construct
|
8 |
-
*
|
9 |
-
* Set name / label needed for actions / filters
|
10 |
-
*
|
11 |
-
* @since 3.6
|
12 |
-
* @date 23/01/13
|
13 |
-
*/
|
14 |
-
|
15 |
-
function __construct()
|
16 |
-
{
|
17 |
-
// vars
|
18 |
-
$this->name = 'true_false';
|
19 |
-
$this->label = __("True / False",'acf');
|
20 |
-
$this->category = __("Choice",'acf');
|
21 |
-
$this->defaults = array(
|
22 |
-
'default_value' => 0,
|
23 |
-
'message' => '',
|
24 |
-
);
|
25 |
-
|
26 |
-
|
27 |
-
// do not delete!
|
28 |
-
parent::__construct();
|
29 |
-
|
30 |
-
}
|
31 |
-
|
32 |
-
|
33 |
-
/*
|
34 |
-
* create_field()
|
35 |
-
*
|
36 |
-
* Create the HTML interface for your field
|
37 |
-
*
|
38 |
-
* @param $field - an array holding all the field's data
|
39 |
-
*
|
40 |
-
* @type action
|
41 |
-
* @since 3.6
|
42 |
-
* @date 23/01/13
|
43 |
-
*/
|
44 |
-
|
45 |
-
function create_field( $field )
|
46 |
-
{
|
47 |
-
// html
|
48 |
-
echo '<ul class="acf-checkbox-list ' . $field['class'] . '">';
|
49 |
-
echo '<input type="hidden" name="'.$field['name'].'" value="0" />';
|
50 |
-
$selected = ($field['value'] == 1) ? 'checked="yes"' : '';
|
51 |
-
echo '<li><label><input id="' . $field['id'] . '-1" type="checkbox" name="'.$field['name'].'" value="1" ' . $selected . ' />' . $field['message'] . '</label></li>';
|
52 |
-
|
53 |
-
echo '</ul>';
|
54 |
-
}
|
55 |
-
|
56 |
-
|
57 |
-
/*
|
58 |
-
* create_options()
|
59 |
-
*
|
60 |
-
* Create extra options for your field. This is rendered when editing a field.
|
61 |
-
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
62 |
-
*
|
63 |
-
* @type action
|
64 |
-
* @since 3.6
|
65 |
-
* @date 23/01/13
|
66 |
-
*
|
67 |
-
* @param $field - an array holding all the field's data
|
68 |
-
*/
|
69 |
-
|
70 |
-
function create_options( $field )
|
71 |
-
{
|
72 |
-
// vars
|
73 |
-
$key = $field['name'];
|
74 |
-
|
75 |
-
|
76 |
-
?>
|
77 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
78 |
-
<td class="label">
|
79 |
-
<label><?php _e("Message",'acf'); ?></label>
|
80 |
-
<p class="description"><?php _e("eg. Show extra content",'acf'); ?></a></p>
|
81 |
-
</td>
|
82 |
-
<td>
|
83 |
-
<?php
|
84 |
-
do_action('acf/create_field', array(
|
85 |
-
'type' => 'text',
|
86 |
-
'name' => 'fields['.$key.'][message]',
|
87 |
-
'value' => $field['message'],
|
88 |
-
));
|
89 |
-
?>
|
90 |
-
</td>
|
91 |
-
</tr>
|
92 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
93 |
-
<td class="label">
|
94 |
-
<label><?php _e("Default Value",'acf'); ?></label>
|
95 |
-
</td>
|
96 |
-
<td>
|
97 |
-
<?php
|
98 |
-
|
99 |
-
do_action('acf/create_field', array(
|
100 |
-
'type' => 'true_false',
|
101 |
-
'name' => 'fields['.$key.'][default_value]',
|
102 |
-
'value' => $field['default_value'],
|
103 |
-
));
|
104 |
-
|
105 |
-
?>
|
106 |
-
</td>
|
107 |
-
</tr>
|
108 |
-
<?php
|
109 |
-
|
110 |
-
}
|
111 |
-
|
112 |
-
|
113 |
-
/*
|
114 |
-
* format_value_for_api()
|
115 |
-
*
|
116 |
-
* This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
|
117 |
-
*
|
118 |
-
* @type filter
|
119 |
-
* @since 3.6
|
120 |
-
* @date 23/01/13
|
121 |
-
*
|
122 |
-
* @param $value - the value which was loaded from the database
|
123 |
-
* @param $post_id - the $post_id from which the value was loaded
|
124 |
-
* @param $field - the field array holding all the field options
|
125 |
-
*
|
126 |
-
* @return $value - the modified value
|
127 |
-
*/
|
128 |
-
|
129 |
-
function format_value_for_api( $value, $post_id, $field )
|
130 |
-
{
|
131 |
-
$value = ($value == 1) ? true : false;
|
132 |
-
|
133 |
-
return $value;
|
134 |
-
}
|
135 |
-
|
136 |
-
}
|
137 |
-
|
138 |
-
new acf_field_true_false();
|
139 |
-
|
140 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class acf_field_true_false extends acf_field
|
4 |
+
{
|
5 |
+
|
6 |
+
/*
|
7 |
+
* __construct
|
8 |
+
*
|
9 |
+
* Set name / label needed for actions / filters
|
10 |
+
*
|
11 |
+
* @since 3.6
|
12 |
+
* @date 23/01/13
|
13 |
+
*/
|
14 |
+
|
15 |
+
function __construct()
|
16 |
+
{
|
17 |
+
// vars
|
18 |
+
$this->name = 'true_false';
|
19 |
+
$this->label = __("True / False",'acf');
|
20 |
+
$this->category = __("Choice",'acf');
|
21 |
+
$this->defaults = array(
|
22 |
+
'default_value' => 0,
|
23 |
+
'message' => '',
|
24 |
+
);
|
25 |
+
|
26 |
+
|
27 |
+
// do not delete!
|
28 |
+
parent::__construct();
|
29 |
+
|
30 |
+
}
|
31 |
+
|
32 |
+
|
33 |
+
/*
|
34 |
+
* create_field()
|
35 |
+
*
|
36 |
+
* Create the HTML interface for your field
|
37 |
+
*
|
38 |
+
* @param $field - an array holding all the field's data
|
39 |
+
*
|
40 |
+
* @type action
|
41 |
+
* @since 3.6
|
42 |
+
* @date 23/01/13
|
43 |
+
*/
|
44 |
+
|
45 |
+
function create_field( $field )
|
46 |
+
{
|
47 |
+
// html
|
48 |
+
echo '<ul class="acf-checkbox-list ' . $field['class'] . '">';
|
49 |
+
echo '<input type="hidden" name="'.$field['name'].'" value="0" />';
|
50 |
+
$selected = ($field['value'] == 1) ? 'checked="yes"' : '';
|
51 |
+
echo '<li><label><input id="' . $field['id'] . '-1" type="checkbox" name="'.$field['name'].'" value="1" ' . $selected . ' />' . $field['message'] . '</label></li>';
|
52 |
+
|
53 |
+
echo '</ul>';
|
54 |
+
}
|
55 |
+
|
56 |
+
|
57 |
+
/*
|
58 |
+
* create_options()
|
59 |
+
*
|
60 |
+
* Create extra options for your field. This is rendered when editing a field.
|
61 |
+
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
62 |
+
*
|
63 |
+
* @type action
|
64 |
+
* @since 3.6
|
65 |
+
* @date 23/01/13
|
66 |
+
*
|
67 |
+
* @param $field - an array holding all the field's data
|
68 |
+
*/
|
69 |
+
|
70 |
+
function create_options( $field )
|
71 |
+
{
|
72 |
+
// vars
|
73 |
+
$key = $field['name'];
|
74 |
+
|
75 |
+
|
76 |
+
?>
|
77 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
78 |
+
<td class="label">
|
79 |
+
<label><?php _e("Message",'acf'); ?></label>
|
80 |
+
<p class="description"><?php _e("eg. Show extra content",'acf'); ?></a></p>
|
81 |
+
</td>
|
82 |
+
<td>
|
83 |
+
<?php
|
84 |
+
do_action('acf/create_field', array(
|
85 |
+
'type' => 'text',
|
86 |
+
'name' => 'fields['.$key.'][message]',
|
87 |
+
'value' => $field['message'],
|
88 |
+
));
|
89 |
+
?>
|
90 |
+
</td>
|
91 |
+
</tr>
|
92 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
93 |
+
<td class="label">
|
94 |
+
<label><?php _e("Default Value",'acf'); ?></label>
|
95 |
+
</td>
|
96 |
+
<td>
|
97 |
+
<?php
|
98 |
+
|
99 |
+
do_action('acf/create_field', array(
|
100 |
+
'type' => 'true_false',
|
101 |
+
'name' => 'fields['.$key.'][default_value]',
|
102 |
+
'value' => $field['default_value'],
|
103 |
+
));
|
104 |
+
|
105 |
+
?>
|
106 |
+
</td>
|
107 |
+
</tr>
|
108 |
+
<?php
|
109 |
+
|
110 |
+
}
|
111 |
+
|
112 |
+
|
113 |
+
/*
|
114 |
+
* format_value_for_api()
|
115 |
+
*
|
116 |
+
* This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
|
117 |
+
*
|
118 |
+
* @type filter
|
119 |
+
* @since 3.6
|
120 |
+
* @date 23/01/13
|
121 |
+
*
|
122 |
+
* @param $value - the value which was loaded from the database
|
123 |
+
* @param $post_id - the $post_id from which the value was loaded
|
124 |
+
* @param $field - the field array holding all the field options
|
125 |
+
*
|
126 |
+
* @return $value - the modified value
|
127 |
+
*/
|
128 |
+
|
129 |
+
function format_value_for_api( $value, $post_id, $field )
|
130 |
+
{
|
131 |
+
$value = ($value == 1) ? true : false;
|
132 |
+
|
133 |
+
return $value;
|
134 |
+
}
|
135 |
+
|
136 |
+
}
|
137 |
+
|
138 |
+
new acf_field_true_false();
|
139 |
+
|
140 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/fields/user.php
CHANGED
@@ -1,382 +1,382 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_field_user extends acf_field
|
4 |
-
{
|
5 |
-
/*
|
6 |
-
* __construct
|
7 |
-
*
|
8 |
-
* Set name / label needed for actions / filters
|
9 |
-
*
|
10 |
-
* @since 3.6
|
11 |
-
* @date 23/01/13
|
12 |
-
*/
|
13 |
-
|
14 |
-
function __construct()
|
15 |
-
{
|
16 |
-
// vars
|
17 |
-
$this->name = 'user';
|
18 |
-
$this->label = __("User",'acf');
|
19 |
-
$this->category = __("Relational",'acf');
|
20 |
-
$this->defaults = array(
|
21 |
-
'role' => 'all',
|
22 |
-
'field_type' => 'select',
|
23 |
-
'allow_null' => 0,
|
24 |
-
);
|
25 |
-
|
26 |
-
|
27 |
-
// do not delete!
|
28 |
-
parent::__construct();
|
29 |
-
|
30 |
-
}
|
31 |
-
|
32 |
-
|
33 |
-
/*
|
34 |
-
* format_value_for_api()
|
35 |
-
*
|
36 |
-
* This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
|
37 |
-
*
|
38 |
-
* @type filter
|
39 |
-
* @since 3.6
|
40 |
-
* @date 23/01/13
|
41 |
-
*
|
42 |
-
* @param $value - the value which was loaded from the database
|
43 |
-
* @param $field - the field array holding all the field options
|
44 |
-
*
|
45 |
-
* @return $value - the modified value
|
46 |
-
*/
|
47 |
-
|
48 |
-
function format_value_for_api( $value, $post_id, $field )
|
49 |
-
{
|
50 |
-
|
51 |
-
// format value
|
52 |
-
if( !$value || $value == 'null' )
|
53 |
-
{
|
54 |
-
return false;
|
55 |
-
}
|
56 |
-
|
57 |
-
|
58 |
-
// temp convert to array
|
59 |
-
$is_array = true;
|
60 |
-
|
61 |
-
if( !is_array($value) )
|
62 |
-
{
|
63 |
-
$is_array = false;
|
64 |
-
$value = array( $value );
|
65 |
-
}
|
66 |
-
|
67 |
-
|
68 |
-
foreach( $value as $k => $v )
|
69 |
-
{
|
70 |
-
$user_data = get_userdata( $v );
|
71 |
-
|
72 |
-
//cope with deleted users by @adampope
|
73 |
-
if( !is_object($user_data) )
|
74 |
-
{
|
75 |
-
unset( $value[$k] );
|
76 |
-
continue;
|
77 |
-
}
|
78 |
-
|
79 |
-
|
80 |
-
$value[ $k ] = array();
|
81 |
-
$value[ $k ]['ID'] = $v;
|
82 |
-
$value[ $k ]['user_firstname'] = $user_data->user_firstname;
|
83 |
-
$value[ $k ]['user_lastname'] = $user_data->user_lastname;
|
84 |
-
$value[ $k ]['nickname'] = $user_data->nickname;
|
85 |
-
$value[ $k ]['user_nicename'] = $user_data->user_nicename;
|
86 |
-
$value[ $k ]['display_name'] = $user_data->display_name;
|
87 |
-
$value[ $k ]['user_email'] = $user_data->user_email;
|
88 |
-
$value[ $k ]['user_url'] = $user_data->user_url;
|
89 |
-
$value[ $k ]['user_registered'] = $user_data->user_registered;
|
90 |
-
$value[ $k ]['user_description'] = $user_data->user_description;
|
91 |
-
$value[ $k ]['user_avatar'] = get_avatar( $v );
|
92 |
-
|
93 |
-
}
|
94 |
-
|
95 |
-
|
96 |
-
// de-convert from array
|
97 |
-
if( !$is_array && isset($value[0]) )
|
98 |
-
{
|
99 |
-
$value = $value[0];
|
100 |
-
}
|
101 |
-
|
102 |
-
|
103 |
-
// return value
|
104 |
-
return $value;
|
105 |
-
|
106 |
-
}
|
107 |
-
|
108 |
-
|
109 |
-
/*
|
110 |
-
* input_admin_head()
|
111 |
-
*
|
112 |
-
* This action is called in the admin_head action on the edit screen where your field is created.
|
113 |
-
* Use this action to add css and javascript to assist your create_field() action.
|
114 |
-
*
|
115 |
-
* @info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_head
|
116 |
-
* @type action
|
117 |
-
* @since 3.6
|
118 |
-
* @date 23/01/13
|
119 |
-
*/
|
120 |
-
|
121 |
-
function input_admin_head()
|
122 |
-
{
|
123 |
-
if( ! function_exists( 'get_editable_roles' ) )
|
124 |
-
{
|
125 |
-
// if using front-end forms then we need to add this core file
|
126 |
-
require_once( ABSPATH . '/wp-admin/includes/user.php' );
|
127 |
-
}
|
128 |
-
}
|
129 |
-
|
130 |
-
|
131 |
-
/*
|
132 |
-
* create_field()
|
133 |
-
*
|
134 |
-
* Create the HTML interface for your field
|
135 |
-
*
|
136 |
-
* @type action
|
137 |
-
* @since 3.6
|
138 |
-
* @date 23/01/13
|
139 |
-
*
|
140 |
-
* @param $field - an array holding all the field's data
|
141 |
-
*/
|
142 |
-
|
143 |
-
function create_field( $field )
|
144 |
-
{
|
145 |
-
if( ! function_exists( 'get_editable_roles' ) )
|
146 |
-
{
|
147 |
-
// if using front-end forms then we need to add this core file
|
148 |
-
require_once( ABSPATH . '/wp-admin/includes/user.php' );
|
149 |
-
}
|
150 |
-
|
151 |
-
// options
|
152 |
-
$options = array(
|
153 |
-
'post_id' => get_the_ID(),
|
154 |
-
);
|
155 |
-
|
156 |
-
|
157 |
-
// vars
|
158 |
-
$args = array();
|
159 |
-
|
160 |
-
|
161 |
-
// editable roles
|
162 |
-
$editable_roles = get_editable_roles();
|
163 |
-
|
164 |
-
if( !empty($field['role']) )
|
165 |
-
{
|
166 |
-
if( ! in_array('all', $field['role']) )
|
167 |
-
{
|
168 |
-
foreach( $editable_roles as $role => $role_info )
|
169 |
-
{
|
170 |
-
if( !in_array($role, $field['role']) )
|
171 |
-
{
|
172 |
-
unset( $editable_roles[ $role ] );
|
173 |
-
}
|
174 |
-
}
|
175 |
-
}
|
176 |
-
|
177 |
-
}
|
178 |
-
|
179 |
-
// filters
|
180 |
-
$args = apply_filters('acf/fields/user/query', $args, $field, $options['post_id']);
|
181 |
-
$args = apply_filters('acf/fields/user/query/name=' . $field['_name'], $args, $field, $options['post_id'] );
|
182 |
-
$args = apply_filters('acf/fields/user/query/key=' . $field['key'], $args, $field, $options['post_id'] );
|
183 |
-
|
184 |
-
|
185 |
-
// get users
|
186 |
-
$users = get_users( $args );
|
187 |
-
|
188 |
-
|
189 |
-
if( !empty($users) && !empty($editable_roles) )
|
190 |
-
{
|
191 |
-
$field['choices'] = array();
|
192 |
-
|
193 |
-
foreach( $editable_roles as $role => $role_info )
|
194 |
-
{
|
195 |
-
// vars
|
196 |
-
$this_users = array();
|
197 |
-
$this_json = array();
|
198 |
-
|
199 |
-
|
200 |
-
// loop over users
|
201 |
-
$keys = array_keys($users);
|
202 |
-
foreach( $keys as $key )
|
203 |
-
{
|
204 |
-
if( in_array($role, $users[ $key ]->roles) )
|
205 |
-
{
|
206 |
-
$this_users[] = $users[ $key ];
|
207 |
-
unset( $users[ $key ] );
|
208 |
-
}
|
209 |
-
}
|
210 |
-
|
211 |
-
|
212 |
-
// bail early if no users for this role
|
213 |
-
if( empty($this_users) )
|
214 |
-
{
|
215 |
-
continue;
|
216 |
-
}
|
217 |
-
|
218 |
-
|
219 |
-
// label
|
220 |
-
$label = translate_user_role( $role_info['name'] );
|
221 |
-
|
222 |
-
|
223 |
-
// append to choices
|
224 |
-
$field['choices'][ $label ] = array();
|
225 |
-
|
226 |
-
foreach( $this_users as $user )
|
227 |
-
{
|
228 |
-
$field['choices'][ $label ][ $user->ID ] = ucfirst( $user->display_name );
|
229 |
-
}
|
230 |
-
|
231 |
-
}
|
232 |
-
}
|
233 |
-
|
234 |
-
|
235 |
-
// modify field
|
236 |
-
if( $field['field_type'] == 'multi_select' )
|
237 |
-
{
|
238 |
-
$field['multiple'] = 1;
|
239 |
-
}
|
240 |
-
|
241 |
-
|
242 |
-
$field['type'] = 'select';
|
243 |
-
|
244 |
-
|
245 |
-
do_action('acf/create_field', $field);
|
246 |
-
|
247 |
-
}
|
248 |
-
|
249 |
-
|
250 |
-
/*
|
251 |
-
* create_options()
|
252 |
-
*
|
253 |
-
* Create extra options for your field. This is rendered when editing a field.
|
254 |
-
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
255 |
-
*
|
256 |
-
* @type action
|
257 |
-
* @since 3.6
|
258 |
-
* @date 23/01/13
|
259 |
-
*
|
260 |
-
* @param $field - an array holding all the field's data
|
261 |
-
*/
|
262 |
-
|
263 |
-
function create_options( $field )
|
264 |
-
{
|
265 |
-
// vars
|
266 |
-
$key = $field['name'];
|
267 |
-
|
268 |
-
?>
|
269 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
270 |
-
<td class="label">
|
271 |
-
<label><?php _e( "Filter by role", 'acf' ); ?></label>
|
272 |
-
</td>
|
273 |
-
<td>
|
274 |
-
<?php
|
275 |
-
|
276 |
-
$choices = array('all' => __('All', 'acf'));
|
277 |
-
$editable_roles = get_editable_roles();
|
278 |
-
|
279 |
-
foreach( $editable_roles as $role => $details )
|
280 |
-
{
|
281 |
-
// only translate the output not the value
|
282 |
-
$choices[$role] = translate_user_role( $details['name'] );
|
283 |
-
}
|
284 |
-
|
285 |
-
do_action('acf/create_field', array(
|
286 |
-
'type' => 'select',
|
287 |
-
'name' => 'fields[' . $key . '][role]',
|
288 |
-
'value' => $field['role'],
|
289 |
-
'choices' => $choices,
|
290 |
-
'multiple' => '1',
|
291 |
-
));
|
292 |
-
|
293 |
-
?>
|
294 |
-
</td>
|
295 |
-
</tr>
|
296 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
297 |
-
<td class="label">
|
298 |
-
<label><?php _e("Field Type",'acf'); ?></label>
|
299 |
-
</td>
|
300 |
-
<td>
|
301 |
-
<?php
|
302 |
-
do_action('acf/create_field', array(
|
303 |
-
'type' => 'select',
|
304 |
-
'name' => 'fields['.$key.'][field_type]',
|
305 |
-
'value' => $field['field_type'],
|
306 |
-
'choices' => array(
|
307 |
-
__("Multiple Values",'acf') => array(
|
308 |
-
//'checkbox' => __('Checkbox', 'acf'),
|
309 |
-
'multi_select' => __('Multi Select', 'acf')
|
310 |
-
),
|
311 |
-
__("Single Value",'acf') => array(
|
312 |
-
//'radio' => __('Radio Buttons', 'acf'),
|
313 |
-
'select' => __('Select', 'acf')
|
314 |
-
)
|
315 |
-
)
|
316 |
-
));
|
317 |
-
?>
|
318 |
-
</td>
|
319 |
-
</tr>
|
320 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
321 |
-
<td class="label">
|
322 |
-
<label><?php _e("Allow Null?",'acf'); ?></label>
|
323 |
-
</td>
|
324 |
-
<td>
|
325 |
-
<?php
|
326 |
-
do_action('acf/create_field', array(
|
327 |
-
'type' => 'radio',
|
328 |
-
'name' => 'fields['.$key.'][allow_null]',
|
329 |
-
'value' => $field['allow_null'],
|
330 |
-
'choices' => array(
|
331 |
-
1 => __("Yes",'acf'),
|
332 |
-
0 => __("No",'acf'),
|
333 |
-
),
|
334 |
-
'layout' => 'horizontal',
|
335 |
-
));
|
336 |
-
?>
|
337 |
-
</td>
|
338 |
-
</tr>
|
339 |
-
<?php
|
340 |
-
|
341 |
-
}
|
342 |
-
|
343 |
-
|
344 |
-
/*
|
345 |
-
* update_value()
|
346 |
-
*
|
347 |
-
* This filter is appied to the $value before it is updated in the db
|
348 |
-
*
|
349 |
-
* @type filter
|
350 |
-
* @since 3.6
|
351 |
-
* @date 23/01/13
|
352 |
-
*
|
353 |
-
* @param $value - the value which will be saved in the database
|
354 |
-
* @param $post_id - the $post_id of which the value will be saved
|
355 |
-
* @param $field - the field array holding all the field options
|
356 |
-
*
|
357 |
-
* @return $value - the modified value
|
358 |
-
*/
|
359 |
-
|
360 |
-
function update_value( $value, $post_id, $field )
|
361 |
-
{
|
362 |
-
// array?
|
363 |
-
if( is_array($value) && isset($value['ID']) )
|
364 |
-
{
|
365 |
-
$value = $value['ID'];
|
366 |
-
}
|
367 |
-
|
368 |
-
// object?
|
369 |
-
if( is_object($value) && isset($value->ID) )
|
370 |
-
{
|
371 |
-
$value = $value->ID;
|
372 |
-
}
|
373 |
-
|
374 |
-
return $value;
|
375 |
-
}
|
376 |
-
|
377 |
-
|
378 |
-
}
|
379 |
-
|
380 |
-
new acf_field_user();
|
381 |
-
|
382 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class acf_field_user extends acf_field
|
4 |
+
{
|
5 |
+
/*
|
6 |
+
* __construct
|
7 |
+
*
|
8 |
+
* Set name / label needed for actions / filters
|
9 |
+
*
|
10 |
+
* @since 3.6
|
11 |
+
* @date 23/01/13
|
12 |
+
*/
|
13 |
+
|
14 |
+
function __construct()
|
15 |
+
{
|
16 |
+
// vars
|
17 |
+
$this->name = 'user';
|
18 |
+
$this->label = __("User",'acf');
|
19 |
+
$this->category = __("Relational",'acf');
|
20 |
+
$this->defaults = array(
|
21 |
+
'role' => 'all',
|
22 |
+
'field_type' => 'select',
|
23 |
+
'allow_null' => 0,
|
24 |
+
);
|
25 |
+
|
26 |
+
|
27 |
+
// do not delete!
|
28 |
+
parent::__construct();
|
29 |
+
|
30 |
+
}
|
31 |
+
|
32 |
+
|
33 |
+
/*
|
34 |
+
* format_value_for_api()
|
35 |
+
*
|
36 |
+
* This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
|
37 |
+
*
|
38 |
+
* @type filter
|
39 |
+
* @since 3.6
|
40 |
+
* @date 23/01/13
|
41 |
+
*
|
42 |
+
* @param $value - the value which was loaded from the database
|
43 |
+
* @param $field - the field array holding all the field options
|
44 |
+
*
|
45 |
+
* @return $value - the modified value
|
46 |
+
*/
|
47 |
+
|
48 |
+
function format_value_for_api( $value, $post_id, $field )
|
49 |
+
{
|
50 |
+
|
51 |
+
// format value
|
52 |
+
if( !$value || $value == 'null' )
|
53 |
+
{
|
54 |
+
return false;
|
55 |
+
}
|
56 |
+
|
57 |
+
|
58 |
+
// temp convert to array
|
59 |
+
$is_array = true;
|
60 |
+
|
61 |
+
if( !is_array($value) )
|
62 |
+
{
|
63 |
+
$is_array = false;
|
64 |
+
$value = array( $value );
|
65 |
+
}
|
66 |
+
|
67 |
+
|
68 |
+
foreach( $value as $k => $v )
|
69 |
+
{
|
70 |
+
$user_data = get_userdata( $v );
|
71 |
+
|
72 |
+
//cope with deleted users by @adampope
|
73 |
+
if( !is_object($user_data) )
|
74 |
+
{
|
75 |
+
unset( $value[$k] );
|
76 |
+
continue;
|
77 |
+
}
|
78 |
+
|
79 |
+
|
80 |
+
$value[ $k ] = array();
|
81 |
+
$value[ $k ]['ID'] = $v;
|
82 |
+
$value[ $k ]['user_firstname'] = $user_data->user_firstname;
|
83 |
+
$value[ $k ]['user_lastname'] = $user_data->user_lastname;
|
84 |
+
$value[ $k ]['nickname'] = $user_data->nickname;
|
85 |
+
$value[ $k ]['user_nicename'] = $user_data->user_nicename;
|
86 |
+
$value[ $k ]['display_name'] = $user_data->display_name;
|
87 |
+
$value[ $k ]['user_email'] = $user_data->user_email;
|
88 |
+
$value[ $k ]['user_url'] = $user_data->user_url;
|
89 |
+
$value[ $k ]['user_registered'] = $user_data->user_registered;
|
90 |
+
$value[ $k ]['user_description'] = $user_data->user_description;
|
91 |
+
$value[ $k ]['user_avatar'] = get_avatar( $v );
|
92 |
+
|
93 |
+
}
|
94 |
+
|
95 |
+
|
96 |
+
// de-convert from array
|
97 |
+
if( !$is_array && isset($value[0]) )
|
98 |
+
{
|
99 |
+
$value = $value[0];
|
100 |
+
}
|
101 |
+
|
102 |
+
|
103 |
+
// return value
|
104 |
+
return $value;
|
105 |
+
|
106 |
+
}
|
107 |
+
|
108 |
+
|
109 |
+
/*
|
110 |
+
* input_admin_head()
|
111 |
+
*
|
112 |
+
* This action is called in the admin_head action on the edit screen where your field is created.
|
113 |
+
* Use this action to add css and javascript to assist your create_field() action.
|
114 |
+
*
|
115 |
+
* @info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_head
|
116 |
+
* @type action
|
117 |
+
* @since 3.6
|
118 |
+
* @date 23/01/13
|
119 |
+
*/
|
120 |
+
|
121 |
+
function input_admin_head()
|
122 |
+
{
|
123 |
+
if( ! function_exists( 'get_editable_roles' ) )
|
124 |
+
{
|
125 |
+
// if using front-end forms then we need to add this core file
|
126 |
+
require_once( ABSPATH . '/wp-admin/includes/user.php' );
|
127 |
+
}
|
128 |
+
}
|
129 |
+
|
130 |
+
|
131 |
+
/*
|
132 |
+
* create_field()
|
133 |
+
*
|
134 |
+
* Create the HTML interface for your field
|
135 |
+
*
|
136 |
+
* @type action
|
137 |
+
* @since 3.6
|
138 |
+
* @date 23/01/13
|
139 |
+
*
|
140 |
+
* @param $field - an array holding all the field's data
|
141 |
+
*/
|
142 |
+
|
143 |
+
function create_field( $field )
|
144 |
+
{
|
145 |
+
if( ! function_exists( 'get_editable_roles' ) )
|
146 |
+
{
|
147 |
+
// if using front-end forms then we need to add this core file
|
148 |
+
require_once( ABSPATH . '/wp-admin/includes/user.php' );
|
149 |
+
}
|
150 |
+
|
151 |
+
// options
|
152 |
+
$options = array(
|
153 |
+
'post_id' => get_the_ID(),
|
154 |
+
);
|
155 |
+
|
156 |
+
|
157 |
+
// vars
|
158 |
+
$args = array();
|
159 |
+
|
160 |
+
|
161 |
+
// editable roles
|
162 |
+
$editable_roles = get_editable_roles();
|
163 |
+
|
164 |
+
if( !empty($field['role']) )
|
165 |
+
{
|
166 |
+
if( ! in_array('all', $field['role']) )
|
167 |
+
{
|
168 |
+
foreach( $editable_roles as $role => $role_info )
|
169 |
+
{
|
170 |
+
if( !in_array($role, $field['role']) )
|
171 |
+
{
|
172 |
+
unset( $editable_roles[ $role ] );
|
173 |
+
}
|
174 |
+
}
|
175 |
+
}
|
176 |
+
|
177 |
+
}
|
178 |
+
|
179 |
+
// filters
|
180 |
+
$args = apply_filters('acf/fields/user/query', $args, $field, $options['post_id']);
|
181 |
+
$args = apply_filters('acf/fields/user/query/name=' . $field['_name'], $args, $field, $options['post_id'] );
|
182 |
+
$args = apply_filters('acf/fields/user/query/key=' . $field['key'], $args, $field, $options['post_id'] );
|
183 |
+
|
184 |
+
|
185 |
+
// get users
|
186 |
+
$users = get_users( $args );
|
187 |
+
|
188 |
+
|
189 |
+
if( !empty($users) && !empty($editable_roles) )
|
190 |
+
{
|
191 |
+
$field['choices'] = array();
|
192 |
+
|
193 |
+
foreach( $editable_roles as $role => $role_info )
|
194 |
+
{
|
195 |
+
// vars
|
196 |
+
$this_users = array();
|
197 |
+
$this_json = array();
|
198 |
+
|
199 |
+
|
200 |
+
// loop over users
|
201 |
+
$keys = array_keys($users);
|
202 |
+
foreach( $keys as $key )
|
203 |
+
{
|
204 |
+
if( in_array($role, $users[ $key ]->roles) )
|
205 |
+
{
|
206 |
+
$this_users[] = $users[ $key ];
|
207 |
+
unset( $users[ $key ] );
|
208 |
+
}
|
209 |
+
}
|
210 |
+
|
211 |
+
|
212 |
+
// bail early if no users for this role
|
213 |
+
if( empty($this_users) )
|
214 |
+
{
|
215 |
+
continue;
|
216 |
+
}
|
217 |
+
|
218 |
+
|
219 |
+
// label
|
220 |
+
$label = translate_user_role( $role_info['name'] );
|
221 |
+
|
222 |
+
|
223 |
+
// append to choices
|
224 |
+
$field['choices'][ $label ] = array();
|
225 |
+
|
226 |
+
foreach( $this_users as $user )
|
227 |
+
{
|
228 |
+
$field['choices'][ $label ][ $user->ID ] = ucfirst( $user->display_name );
|
229 |
+
}
|
230 |
+
|
231 |
+
}
|
232 |
+
}
|
233 |
+
|
234 |
+
|
235 |
+
// modify field
|
236 |
+
if( $field['field_type'] == 'multi_select' )
|
237 |
+
{
|
238 |
+
$field['multiple'] = 1;
|
239 |
+
}
|
240 |
+
|
241 |
+
|
242 |
+
$field['type'] = 'select';
|
243 |
+
|
244 |
+
|
245 |
+
do_action('acf/create_field', $field);
|
246 |
+
|
247 |
+
}
|
248 |
+
|
249 |
+
|
250 |
+
/*
|
251 |
+
* create_options()
|
252 |
+
*
|
253 |
+
* Create extra options for your field. This is rendered when editing a field.
|
254 |
+
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
255 |
+
*
|
256 |
+
* @type action
|
257 |
+
* @since 3.6
|
258 |
+
* @date 23/01/13
|
259 |
+
*
|
260 |
+
* @param $field - an array holding all the field's data
|
261 |
+
*/
|
262 |
+
|
263 |
+
function create_options( $field )
|
264 |
+
{
|
265 |
+
// vars
|
266 |
+
$key = $field['name'];
|
267 |
+
|
268 |
+
?>
|
269 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
270 |
+
<td class="label">
|
271 |
+
<label><?php _e( "Filter by role", 'acf' ); ?></label>
|
272 |
+
</td>
|
273 |
+
<td>
|
274 |
+
<?php
|
275 |
+
|
276 |
+
$choices = array('all' => __('All', 'acf'));
|
277 |
+
$editable_roles = get_editable_roles();
|
278 |
+
|
279 |
+
foreach( $editable_roles as $role => $details )
|
280 |
+
{
|
281 |
+
// only translate the output not the value
|
282 |
+
$choices[$role] = translate_user_role( $details['name'] );
|
283 |
+
}
|
284 |
+
|
285 |
+
do_action('acf/create_field', array(
|
286 |
+
'type' => 'select',
|
287 |
+
'name' => 'fields[' . $key . '][role]',
|
288 |
+
'value' => $field['role'],
|
289 |
+
'choices' => $choices,
|
290 |
+
'multiple' => '1',
|
291 |
+
));
|
292 |
+
|
293 |
+
?>
|
294 |
+
</td>
|
295 |
+
</tr>
|
296 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
297 |
+
<td class="label">
|
298 |
+
<label><?php _e("Field Type",'acf'); ?></label>
|
299 |
+
</td>
|
300 |
+
<td>
|
301 |
+
<?php
|
302 |
+
do_action('acf/create_field', array(
|
303 |
+
'type' => 'select',
|
304 |
+
'name' => 'fields['.$key.'][field_type]',
|
305 |
+
'value' => $field['field_type'],
|
306 |
+
'choices' => array(
|
307 |
+
__("Multiple Values",'acf') => array(
|
308 |
+
//'checkbox' => __('Checkbox', 'acf'),
|
309 |
+
'multi_select' => __('Multi Select', 'acf')
|
310 |
+
),
|
311 |
+
__("Single Value",'acf') => array(
|
312 |
+
//'radio' => __('Radio Buttons', 'acf'),
|
313 |
+
'select' => __('Select', 'acf')
|
314 |
+
)
|
315 |
+
)
|
316 |
+
));
|
317 |
+
?>
|
318 |
+
</td>
|
319 |
+
</tr>
|
320 |
+
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
321 |
+
<td class="label">
|
322 |
+
<label><?php _e("Allow Null?",'acf'); ?></label>
|
323 |
+
</td>
|
324 |
+
<td>
|
325 |
+
<?php
|
326 |
+
do_action('acf/create_field', array(
|
327 |
+
'type' => 'radio',
|
328 |
+
'name' => 'fields['.$key.'][allow_null]',
|
329 |
+
'value' => $field['allow_null'],
|
330 |
+
'choices' => array(
|
331 |
+
1 => __("Yes",'acf'),
|
332 |
+
0 => __("No",'acf'),
|
333 |
+
),
|
334 |
+
'layout' => 'horizontal',
|
335 |
+
));
|
336 |
+
?>
|
337 |
+
</td>
|
338 |
+
</tr>
|
339 |
+
<?php
|
340 |
+
|
341 |
+
}
|
342 |
+
|
343 |
+
|
344 |
+
/*
|
345 |
+
* update_value()
|
346 |
+
*
|
347 |
+
* This filter is appied to the $value before it is updated in the db
|
348 |
+
*
|
349 |
+
* @type filter
|
350 |
+
* @since 3.6
|
351 |
+
* @date 23/01/13
|
352 |
+
*
|
353 |
+
* @param $value - the value which will be saved in the database
|
354 |
+
* @param $post_id - the $post_id of which the value will be saved
|
355 |
+
* @param $field - the field array holding all the field options
|
356 |
+
*
|
357 |
+
* @return $value - the modified value
|
358 |
+
*/
|
359 |
+
|
360 |
+
function update_value( $value, $post_id, $field )
|
361 |
+
{
|
362 |
+
// array?
|
363 |
+
if( is_array($value) && isset($value['ID']) )
|
364 |
+
{
|
365 |
+
$value = $value['ID'];
|
366 |
+
}
|
367 |
+
|
368 |
+
// object?
|
369 |
+
if( is_object($value) && isset($value->ID) )
|
370 |
+
{
|
371 |
+
$value = $value->ID;
|
372 |
+
}
|
373 |
+
|
374 |
+
return $value;
|
375 |
+
}
|
376 |
+
|
377 |
+
|
378 |
+
}
|
379 |
+
|
380 |
+
new acf_field_user();
|
381 |
+
|
382 |
?>
|
shared/assets/plugins/advanced-custom-fields/core/fields/wysiwyg.php
CHANGED
@@ -1,388 +1,388 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class acf_field_wysiwyg extends acf_field
|
4 |
-
{
|
5 |
-
|
6 |
-
/*
|
7 |
-
* __construct
|
8 |
-
*
|
9 |
-
* Set name / label needed for actions / filters
|
10 |
-
*
|
11 |
-
* @since 3.6
|
12 |
-
* @date 23/01/13
|
13 |
-
*/
|
14 |
-
|
15 |
-
function __construct()
|
16 |
-
{
|
17 |
-
// vars
|
18 |
-
$this->name = 'wysiwyg';
|
19 |
-
$this->label = __("Wysiwyg Editor",'acf');
|
20 |
-
$this->category = __("Content",'acf');
|
21 |
-
$this->defaults = array(
|
22 |
-
'toolbar' => 'full',
|
23 |
-
'media_upload' => 'yes',
|
24 |
-
'default_value' => '',
|
25 |
-
);
|
26 |
-
|
27 |
-
|
28 |
-
// Create an acf version of the_content filter (acf_the_content)
|
29 |
-
if( isset($GLOBALS['wp_embed']) ) {
|
30 |
-
|
31 |
-
add_filter( 'acf_the_content', array( $GLOBALS['wp_embed'], 'run_shortcode' ), 8 );
|
32 |
-
add_filter( 'acf_the_content', array( $GLOBALS['wp_embed'], 'autoembed' ), 8 );
|
33 |
-
|
34 |
-
}
|
35 |
-
|
36 |
-
add_filter( 'acf_the_content', 'capital_P_dangit', 11 );
|
37 |
-
add_filter( 'acf_the_content', 'wptexturize' );
|
38 |
-
add_filter( 'acf_the_content', 'convert_smilies' );
|
39 |
-
add_filter( 'acf_the_content', 'convert_chars' );
|
40 |
-
add_filter( 'acf_the_content', 'wpautop' );
|
41 |
-
add_filter( 'acf_the_content', 'shortcode_unautop' );
|
42 |
-
//add_filter( 'acf_the_content', 'prepend_attachment' ); *should only be for the_content (causes double image on attachment page)
|
43 |
-
add_filter( 'acf_the_content', 'do_shortcode', 11);
|
44 |
-
|
45 |
-
|
46 |
-
// do not delete!
|
47 |
-
parent::__construct();
|
48 |
-
|
49 |
-
|
50 |
-
// filters
|
51 |
-
add_filter( 'acf/fields/wysiwyg/toolbars', array( $this, 'toolbars'), 1, 1 );
|
52 |
-
add_filter( 'mce_external_plugins', array( $this, 'mce_external_plugins'), 20, 1 );
|
53 |
-
|
54 |
-
}
|
55 |
-
|
56 |
-
|
57 |
-
/*
|
58 |
-
* mce_external_plugins
|
59 |
-
*
|
60 |
-
* This filter will add in the tinyMCE 'code' plugin which is missing in WP 3.9
|
61 |
-
*
|
62 |
-
* @type function
|
63 |
-
* @date 18/04/2014
|
64 |
-
* @since 5.0.0
|
65 |
-
*
|
66 |
-
* @param $post_id (int)
|
67 |
-
* @return $post_id (int)
|
68 |
-
*/
|
69 |
-
|
70 |
-
function mce_external_plugins( $plugins ){
|
71 |
-
|
72 |
-
// global
|
73 |
-
global $wp_version;
|
74 |
-
|
75 |
-
|
76 |
-
// WP 3.9 an above
|
77 |
-
if( version_compare($wp_version, '3.9', '>=' ) ) {
|
78 |
-
|
79 |
-
// add code
|
80 |
-
$plugins['code'] = apply_filters('acf/get_info', 'dir') . 'js/tinymce.code.min.js';
|
81 |
-
|
82 |
-
}
|
83 |
-
|
84 |
-
|
85 |
-
// return
|
86 |
-
return $plugins;
|
87 |
-
|
88 |
-
}
|
89 |
-
|
90 |
-
|
91 |
-
/*
|
92 |
-
* toolbars()
|
93 |
-
*
|
94 |
-
* This filter allowsyou to customize the WYSIWYG toolbars
|
95 |
-
*
|
96 |
-
* @param $toolbars - an array of toolbars
|
97 |
-
*
|
98 |
-
* @return $toolbars - the modified $toolbars
|
99 |
-
*
|
100 |
-
* @type filter
|
101 |
-
* @since 3.6
|
102 |
-
* @date 23/01/13
|
103 |
-
*/
|
104 |
-
|
105 |
-
function toolbars( $toolbars ) {
|
106 |
-
|
107 |
-
// global
|
108 |
-
global $wp_version;
|
109 |
-
|
110 |
-
|
111 |
-
// vars
|
112 |
-
$editor_id = 'acf_settings';
|
113 |
-
|
114 |
-
|
115 |
-
if( version_compare($wp_version, '3.9', '>=' ) ) {
|
116 |
-
|
117 |
-
// Full
|
118 |
-
$toolbars['Full'] = array(
|
119 |
-
|
120 |
-
1 => apply_filters( 'mce_buttons', array('bold', 'italic', 'strikethrough', 'bullist', 'numlist', 'blockquote', 'hr', 'alignleft', 'aligncenter', 'alignright', 'link', 'unlink', 'wp_more', 'spellchecker', 'fullscreen', 'wp_adv' ), $editor_id ),
|
121 |
-
|
122 |
-
2 => apply_filters( 'mce_buttons_2', array( 'formatselect', 'underline', 'alignjustify', 'forecolor', 'pastetext', 'removeformat', 'charmap', 'outdent', 'indent', 'undo', 'redo', 'wp_help', 'code' ), $editor_id ),
|
123 |
-
|
124 |
-
3 => apply_filters('mce_buttons_3', array(), $editor_id),
|
125 |
-
|
126 |
-
4 => apply_filters('mce_buttons_4', array(), $editor_id),
|
127 |
-
|
128 |
-
);
|
129 |
-
|
130 |
-
|
131 |
-
// Basic
|
132 |
-
$toolbars['Basic'] = array(
|
133 |
-
|
134 |
-
1 => apply_filters( 'teeny_mce_buttons', array('bold', 'italic', 'underline', 'blockquote', 'strikethrough', 'bullist', 'numlist', 'alignleft', 'aligncenter', 'alignright', 'undo', 'redo', 'link', 'unlink', 'fullscreen'), $editor_id ),
|
135 |
-
|
136 |
-
);
|
137 |
-
|
138 |
-
} else {
|
139 |
-
|
140 |
-
// Full
|
141 |
-
$toolbars['Full'] = array(
|
142 |
-
|
143 |
-
1 => apply_filters( 'mce_buttons', array('bold', 'italic', 'strikethrough', 'bullist', 'numlist', 'blockquote', 'justifyleft', 'justifycenter', 'justifyright', 'link', 'unlink', 'wp_more', 'spellchecker', 'fullscreen', 'wp_adv' ), $editor_id ),
|
144 |
-
|
145 |
-
2 => apply_filters( 'mce_buttons_2', array( 'formatselect', 'underline', 'justifyfull', 'forecolor', 'pastetext', 'pasteword', 'removeformat', 'charmap', 'outdent', 'indent', 'undo', 'redo', 'wp_help', 'code' ), $editor_id ),
|
146 |
-
|
147 |
-
3 => apply_filters('mce_buttons_3', array(), $editor_id),
|
148 |
-
|
149 |
-
4 => apply_filters('mce_buttons_4', array(), $editor_id),
|
150 |
-
|
151 |
-
);
|
152 |
-
|
153 |
-
|
154 |
-
// Basic
|
155 |
-
$toolbars['Basic'] = array(
|
156 |
-
|
157 |
-
1 => apply_filters( 'teeny_mce_buttons', array('bold', 'italic', 'underline', 'blockquote', 'strikethrough', 'bullist', 'numlist', 'justifyleft', 'justifycenter', 'justifyright', 'undo', 'redo', 'link', 'unlink', 'fullscreen'), $editor_id ),
|
158 |
-
|
159 |
-
);
|
160 |
-
|
161 |
-
}
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
// Custom - can be added with acf/fields/wysiwyg/toolbars filter
|
166 |
-
|
167 |
-
|
168 |
-
return $toolbars;
|
169 |
-
}
|
170 |
-
|
171 |
-
|
172 |
-
/*
|
173 |
-
* input_admin_head()
|
174 |
-
*
|
175 |
-
* This action is called in the admin_head action on the edit screen where your field is created.
|
176 |
-
* Use this action to add css and javascript to assist your create_field() action.
|
177 |
-
*
|
178 |
-
* @info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_head
|
179 |
-
* @type action
|
180 |
-
* @since 3.6
|
181 |
-
* @date 23/01/13
|
182 |
-
*/
|
183 |
-
|
184 |
-
function input_admin_head()
|
185 |
-
{
|
186 |
-
add_action( 'admin_footer', array( $this, 'admin_footer') );
|
187 |
-
}
|
188 |
-
|
189 |
-
function admin_footer()
|
190 |
-
{
|
191 |
-
?>
|
192 |
-
<div style="display:none;">
|
193 |
-
<?php wp_editor( '', 'acf_settings' ); ?>
|
194 |
-
</div>
|
195 |
-
<?php
|
196 |
-
}
|
197 |
-
|
198 |
-
|
199 |
-
/*
|
200 |
-
* create_field()
|
201 |
-
*
|
202 |
-
* Create the HTML interface for your field
|
203 |
-
*
|
204 |
-
* @param $field - an array holding all the field's data
|
205 |
-
*
|
206 |
-
* @type action
|
207 |
-
* @since 3.6
|
208 |
-
* @date 23/01/13
|
209 |
-
*/
|
210 |
-
|
211 |
-
function create_field( $field ) {
|
212 |
-
|
213 |
-
// global
|
214 |
-
global $wp_version;
|
215 |
-
|
216 |
-
|
217 |
-
// vars
|
218 |
-
//$id = uniqid('acf-editor-');
|
219 |
-
$id = 'wysiwyg-' . $field['id'] . '-' . uniqid();
|
220 |
-
$default_editor = 'tinymce';
|
221 |
-
|
222 |
-
|
223 |
-
// filter value for editor
|
224 |
-
remove_filter( 'acf_the_editor_content', 'format_for_editor', 10, 2 );
|
225 |
-
remove_filter( 'acf_the_editor_content', 'wp_htmledit_pre', 10, 1 );
|
226 |
-
remove_filter( 'acf_the_editor_content', 'wp_richedit_pre', 10, 1 );
|
227 |
-
|
228 |
-
|
229 |
-
// WP 4.3
|
230 |
-
if( version_compare($wp_version, '4.3', '>=' ) ) {
|
231 |
-
|
232 |
-
add_filter( 'acf_the_editor_content', 'format_for_editor', 10, 2 );
|
233 |
-
|
234 |
-
|
235 |
-
// WP < 4.3
|
236 |
-
} else {
|
237 |
-
|
238 |
-
$function = user_can_richedit() ? 'wp_richedit_pre' : 'wp_htmledit_pre';
|
239 |
-
|
240 |
-
add_filter('acf_the_editor_content', $function, 10, 1);
|
241 |
-
|
242 |
-
}
|
243 |
-
|
244 |
-
|
245 |
-
// filter
|
246 |
-
$field['value'] = apply_filters( 'acf_the_editor_content', $field['value'], $default_editor );
|
247 |
-
|
248 |
-
?>
|
249 |
-
<div id="wp-<?php echo $id; ?>-wrap" class="acf_wysiwyg wp-core-ui wp-editor-wrap tmce-active" data-toolbar="<?php echo $field['toolbar']; ?>" data-upload="<?php echo $field['media_upload']; ?>">
|
250 |
-
<div id="wp-<?php echo $id; ?>-editor-tools" class="wp-editor-tools hide-if-no-js">
|
251 |
-
<?php if( user_can_richedit() && $field['media_upload'] == 'yes' ): ?>
|
252 |
-
<div id="wp-<?php echo $id; ?>-media-buttons" class="wp-media-buttons">
|
253 |
-
<?php do_action( 'media_buttons', $id ); ?>
|
254 |
-
</div>
|
255 |
-
<?php endif; ?>
|
256 |
-
</div>
|
257 |
-
<div id="wp-<?php echo $id; ?>-editor-container" class="wp-editor-container">
|
258 |
-
<textarea id="<?php echo $id; ?>" class="wp-editor-area" name="<?php echo $field['name']; ?>"><?php echo $field['value']; ?></textarea>
|
259 |
-
</div>
|
260 |
-
</div>
|
261 |
-
<?php
|
262 |
-
|
263 |
-
}
|
264 |
-
|
265 |
-
|
266 |
-
/*
|
267 |
-
* create_options()
|
268 |
-
*
|
269 |
-
* Create extra options for your field. This is rendered when editing a field.
|
270 |
-
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
271 |
-
*
|
272 |
-
* @type action
|
273 |
-
* @since 3.6
|
274 |
-
* @date 23/01/13
|
275 |
-
*
|
276 |
-
* @param $field - an array holding all the field's data
|
277 |
-
*/
|
278 |
-
|
279 |
-
function create_options( $field )
|
280 |
-
{
|
281 |
-
// vars
|
282 |
-
$key = $field['name'];
|
283 |
-
|
284 |
-
?>
|
285 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
286 |
-
<td class="label">
|
287 |
-
<label><?php _e("Default Value",'acf'); ?></label>
|
288 |
-
<p><?php _e("Appears when creating a new post",'acf') ?></p>
|
289 |
-
</td>
|
290 |
-
<td>
|
291 |
-
<?php
|
292 |
-
do_action('acf/create_field', array(
|
293 |
-
'type' => 'textarea',
|
294 |
-
'name' => 'fields['.$key.'][default_value]',
|
295 |
-
'value' => $field['default_value'],
|
296 |
-
));
|
297 |
-
?>
|
298 |
-
</td>
|
299 |
-
</tr>
|
300 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
301 |
-
<td class="label">
|
302 |
-
<label><?php _e("Toolbar",'acf'); ?></label>
|
303 |
-
</td>
|
304 |
-
<td>
|
305 |
-
<?php
|
306 |
-
|
307 |
-
$toolbars = apply_filters( 'acf/fields/wysiwyg/toolbars', array() );
|
308 |
-
$choices = array();
|
309 |
-
|
310 |
-
if( is_array($toolbars) )
|
311 |
-
{
|
312 |
-
foreach( $toolbars as $k => $v )
|
313 |
-
{
|
314 |
-
$label = $k;
|
315 |
-
$name = sanitize_title( $label );
|
316 |
-
$name = str_replace('-', '_', $name);
|
317 |
-
|
318 |
-
$choices[ $name ] = $label;
|
319 |
-
}
|
320 |
-
}
|
321 |
-
|
322 |
-
do_action('acf/create_field', array(
|
323 |
-
'type' => 'radio',
|
324 |
-
'name' => 'fields['.$key.'][toolbar]',
|
325 |
-
'value' => $field['toolbar'],
|
326 |
-
'layout' => 'horizontal',
|
327 |
-
'choices' => $choices
|
328 |
-
));
|
329 |
-
?>
|
330 |
-
</td>
|
331 |
-
</tr>
|
332 |
-
<tr class="field_option field_option_<?php echo $this->name; ?>">
|
333 |
-
<td class="label">
|
334 |
-
<label><?php _e("Show Media Upload Buttons?",'acf'); ?></label>
|
335 |
-
</td>
|
336 |
-
<td>
|
337 |
-
<?php
|
338 |
-
do_action('acf/create_field', array(
|
339 |
-
'type' => 'radio',
|
340 |
-
'name' => 'fields['.$key.'][media_upload]',
|
341 |
-
'value' => $field['media_upload'],
|
342 |
-
'layout' => 'horizontal',
|
343 |
-
'choices' => array(
|
344 |
-
'yes' => __("Yes",'acf'),
|
345 |
-
'no' => __("No",'acf'),
|
346 |
-
)
|
347 |
-
));
|
348 |
-
?>
|
349 |
-
</td>
|
350 |
-
</tr>
|
351 |
-
<?php
|
352 |
-
}
|
353 |
-
|
354 |
-
|
355 |
-
/*
|
356 |
-
* format_value_for_api()
|
357 |
-
*
|
358 |
-
* This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
|
359 |
-
*
|
360 |
-
* @type filter
|
361 |
-
* @since 3.6
|
362 |
-
* @date 23/01/13
|
363 |
-
*
|
364 |
-
* @param $value - the value which was loaded from the da
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|