Advanced Custom Fields - Version 3.0.0

Version Description

  • ACF doesn't use any custom tables anymore! All data is saved as post_meta!
  • Faster and more stable across different servers
  • Drag-able / order-able metaboxes
  • Fields extend from a parent object! Now you can create you own field types!
  • New location rule: Taxonomy
  • New function: register_field($class, $url);
  • New Field: Color Picker
  • New Option: Text + Textarea formatting
  • New Option: WYSIWYG Show / Hide media buttons, Full / Basic Toolbar buttons (Great for a basic wysiwyg inside a repeater for your clients)
  • Lots of bug fixes
Download this release

Release Info

Developer elliotcondon
Plugin Icon 128x128 Advanced Custom Fields
Version 3.0.0
Comparing to
See all releases

Code changes from version 2.1.4 to 3.0.0

Files changed (62) hide show
  1. acf.php +776 -938
  2. core/actions/admin_head.php +0 -55
  3. core/actions/fields_save.php +0 -94
  4. core/actions/init.php +55 -132
  5. core/actions/input_save.php +0 -101
  6. core/actions/location_save.php +0 -45
  7. core/actions/options_save.php +0 -19
  8. core/actions/save_fields.php +77 -0
  9. core/actions/save_input.php +20 -0
  10. core/admin/fields_meta_box.php +0 -222
  11. core/admin/input_meta_box.php +0 -169
  12. core/admin/location_meta_box.php +0 -310
  13. core/admin/meta_box_acf.php +106 -0
  14. core/admin/meta_box_fields.php +152 -0
  15. core/admin/meta_box_input.php +42 -0
  16. core/admin/meta_box_location.php +347 -0
  17. core/admin/meta_box_options.php +95 -0
  18. core/admin/options_meta_box.php +0 -73
  19. core/admin/options_page.php +0 -498
  20. core/admin/upgrade.php +87 -0
  21. core/admin/upgrade_ajax.php +387 -0
  22. core/api.php +80 -217
  23. core/fields/acf_field.php +203 -0
  24. core/fields/checkbox.php +91 -107
  25. core/fields/color_picker.php +132 -0
  26. core/fields/date_picker/date_picker.php +106 -19
  27. core/fields/date_picker/jquery.ui.datepicker.js +0 -0
  28. core/fields/date_picker/style.date_picker.css +263 -263
  29. core/fields/file.php +159 -71
  30. core/fields/image.php +173 -74
  31. core/fields/page_link.php +123 -132
  32. core/fields/post_object.php +137 -153
  33. core/fields/radio.php +77 -119
  34. core/fields/relationship.php +339 -101
  35. core/fields/repeater.php +570 -504
  36. core/fields/select.php +164 -144
  37. core/fields/text.php +105 -21
  38. core/fields/textarea.php +92 -28
  39. core/fields/true_false.php +71 -75
  40. core/fields/wysiwyg.php +291 -15
  41. core/import.php +0 -235
  42. core/options_page.php +302 -0
  43. core/screen_extra.php +0 -44
  44. core/screen_extra_activate.php +0 -85
  45. core/screen_extra_export.php +0 -54
  46. core/third_party.php +0 -166
  47. core/upgrade.php +0 -248
  48. css/{style.screen_extra.css → acf.css} +8 -11
  49. css/{style.fields.css → fields.css} +150 -4
  50. css/{style.global.css → global.css} +4 -0
  51. css/{style.input.css → input.css} +41 -91
  52. css/style.location.css +0 -99
  53. css/style.options.css +0 -27
  54. js/{functions.screen_extra.js → acf.js} +0 -0
  55. js/{functions.fields.js → fields.js} +138 -30
  56. js/functions.input.js +0 -689
  57. js/functions.location.js +0 -112
  58. js/input.js +198 -0
  59. lang/{advanced-custom-fields-nl_NL.mo → acf-nl_NL.mo} +0 -0
  60. lang/{advanced-custom-fields-ru-RU.mo → acf-ru-RU.mo} +0 -0
  61. lang/{advanced-custom-fields.pot → acf.pot} +0 -0
  62. readme.txt +17 -3
acf.php CHANGED
@@ -3,34 +3,28 @@
3
  Plugin Name: Advanced Custom Fields
4
  Plugin URI: http://plugins.elliotcondon.com/advanced-custom-fields/
5
  Description: Customise your edit pages with an assortment of field types: Wysiwyg, Repeater, text, textarea, image, file, select, checkbox post type, page link and more! Hide unwanted metaboxes and assign to any edit page!
6
- Version: 2.1.4
7
  Author: Elliot Condon
8
  Author URI: http://www.elliotcondon.com/
9
  License: GPL
10
  Copyright: Elliot Condon
11
  */
12
 
13
- //ini_set('display_errors',1);
14
- //error_reporting(E_ALL|E_STRICT);
15
-
16
-
17
- include('core/admin/options_page.php');
18
-
19
- $acf = new Acf();
20
 
21
  include('core/api.php');
22
 
 
23
 
24
  class Acf
25
  {
26
-
27
  var $dir;
28
  var $path;
29
  var $siteurl;
30
  var $wpadminurl;
31
  var $version;
 
32
  var $fields;
33
- var $activated_fields;
34
  var $options_page;
35
 
36
 
@@ -51,56 +45,138 @@ class Acf
51
  $this->dir = plugins_url('',__FILE__);
52
  $this->siteurl = get_bloginfo('url');
53
  $this->wpadminurl = admin_url();
54
- $this->version = '2.1.4';
55
- $this->upgrade_version = '2.1.4'; // this is the latest version which requires an upgrade
56
- $this->activated_fields = $this->get_activated_fields();
57
- $this->options_page = new Acf_options_page($this);
58
 
59
 
60
  // set text domain
61
- load_plugin_textdomain('acf', false, $this->path.'/lang' );
 
62
 
63
-
64
- // populate post types
65
- $this->fields = $this->get_field_types();
66
-
67
 
68
- // add actions
69
  add_action('init', array($this, 'init'));
70
- add_action('init', array($this, 'import'));
71
- add_action('init', array($this, 'export'));
72
- add_action('init', array($this, 'third_party'));
73
- add_action('admin_head', array($this,'admin_head'));
74
  add_action('admin_menu', array($this,'admin_menu'));
 
75
  add_action('save_post', array($this, 'save_post'));
76
- add_action('delete_post', array($this, 'delete_post'), 10);
 
77
  add_action('admin_footer', array($this, 'admin_footer'));
78
- add_action('wp_ajax_input_meta_box_html', array($this, 'input_meta_box_html'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
 
 
 
80
 
81
- // admin styles + scripts
82
- add_action("admin_print_scripts", array($this, 'admin_print_scripts'));
83
- add_action("admin_print_styles", array($this, 'admin_print_styles'));
84
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
 
86
- return true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  }
88
 
89
 
90
  /*--------------------------------------------------------------------------------------
91
  *
92
- * Upgrade
93
  *
94
  * @author Elliot Condon
95
- * @since 2.0.6
96
  *
97
  *-------------------------------------------------------------------------------------*/
98
 
99
- function upgrade()
100
  {
101
- include('core/upgrade.php');
 
102
  }
103
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
 
105
 
106
  /*--------------------------------------------------------------------------------------
@@ -120,712 +196,822 @@ class Acf
120
 
121
  /*--------------------------------------------------------------------------------------
122
  *
123
- * admin_print_scripts
124
  *
125
  * @author Elliot Condon
126
  * @since 1.0.0
127
  *
128
  *-------------------------------------------------------------------------------------*/
129
 
130
- function admin_print_scripts()
131
  {
132
- if(in_array($GLOBALS['pagenow'], array('post.php', 'post-new.php', 'edit.php')))
133
- {
134
- // jquery
135
- wp_enqueue_script('jquery');
136
- wp_enqueue_script('jquery-ui-core');
137
-
138
-
139
- // wysiwyg
140
- wp_enqueue_script('media-upload');
141
- wp_enqueue_script('thickbox');
142
- wp_enqueue_script('word-count');
143
- wp_enqueue_script('post');
144
- wp_enqueue_script('editor');
145
-
146
-
147
- // repeater
148
- wp_enqueue_script('jquery-ui-sortable');
149
- }
150
  }
151
 
152
 
153
  /*--------------------------------------------------------------------------------------
154
  *
155
- * admin_print_styles
156
  *
157
  * @author Elliot Condon
158
  * @since 1.0.0
159
  *
160
  *-------------------------------------------------------------------------------------*/
161
 
162
- function admin_print_styles()
163
- {
164
- if(in_array($GLOBALS['pagenow'], array('post.php', 'post-new.php', 'edit.php')))
165
- {
166
- wp_enqueue_style('thickbox');
167
- }
168
  }
169
 
170
 
 
171
  /*--------------------------------------------------------------------------------------
172
  *
173
- * save_post
174
  *
175
  * @author Elliot Condon
176
- * @since 1.0.0
177
  *
178
  *-------------------------------------------------------------------------------------*/
179
 
180
- function save_post($post_id)
181
- {
182
-
183
- // do not save if this is an auto save routine
184
- if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return $post_id;
185
-
186
-
187
- // verify this with nonce because save_post can be triggered at other times
188
- if(!isset($_POST['ei_noncename'])) return $post_id;
189
- if(!wp_verify_nonce($_POST['ei_noncename'], 'ei-n')) return $post_id;
190
-
191
-
192
- // only save once! WordPress save's twice for some strange reason.
193
- global $flag;
194
- if ($flag != 0) return $post_id;
195
- $flag = 1;
196
-
197
 
198
- // set post ID if is a revision
199
- if(wp_is_post_revision($post_id))
200
  {
201
- $post_id = wp_is_post_revision($post_id);
 
 
 
 
 
 
 
 
 
 
 
202
  }
203
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
 
205
- // include save files
206
- include('core/actions/fields_save.php');
207
- include('core/actions/location_save.php');
208
- include('core/actions/options_save.php');
209
- include('core/actions/input_save.php');
210
  }
211
-
212
 
213
  /*--------------------------------------------------------------------------------------
214
  *
215
- * delete_post
216
  *
217
  * @author Elliot Condon
218
- * @since 2.1.4
219
  *
220
  *-------------------------------------------------------------------------------------*/
221
 
222
- function delete_post($post_id)
223
  {
224
- //echo 'delete_posts';
 
225
 
226
- // global
227
- global $wpdb;
228
 
229
- // tables
230
- $acf_fields = $wpdb->prefix.'acf_fields';
231
- $acf_values = $wpdb->prefix.'acf_values';
232
- $acf_rules = $wpdb->prefix.'acf_rules';
233
- $wp_postmeta = $wpdb->prefix.'postmeta';
234
 
235
- if(get_post_type($post_id) == 'acf')
 
236
  {
237
- // delete fields
238
- $wpdb->query("DELETE FROM $acf_fields WHERE post_id = '$post_id'");
239
 
240
- // delete rules
241
- $wpdb->query("DELETE FROM $acf_rules WHERE acf_id = '$post_id'");
242
- }
243
- else
244
- {
245
- // delete values
246
- $wpdb->query("DELETE FROM $acf_values WHERE post_id = '$post_id'");
247
- }
 
 
 
 
 
 
 
 
248
 
249
- return true;
 
250
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
251
  }
252
 
253
 
254
  /*--------------------------------------------------------------------------------------
255
  *
256
- * admin_menu
257
  *
258
  * @author Elliot Condon
259
  * @since 1.0.0
260
  *
261
  *-------------------------------------------------------------------------------------*/
262
 
263
- function admin_menu() {
264
-
265
- // add sub menu
266
- add_options_page(__("Adv Custom Fields",'acf'), __("Adv Custom Fields",'acf'), 'manage_options', 'edit.php?post_type=acf');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
267
 
268
  }
269
 
270
 
271
  /*--------------------------------------------------------------------------------------
272
  *
273
- * admin_head
274
  *
275
  * @author Elliot Condon
276
  * @since 1.0.0
277
  *
278
  *-------------------------------------------------------------------------------------*/
279
 
280
- function admin_head()
281
  {
282
- include('core/actions/admin_head.php');
283
  }
284
-
285
 
286
  /*--------------------------------------------------------------------------------------
287
  *
288
- * get_field_types
289
  *
290
  * @author Elliot Condon
291
  * @since 1.0.0
292
  *
293
  *-------------------------------------------------------------------------------------*/
294
 
295
- function get_field_types()
296
  {
297
- $array = array();
298
-
299
- include_once('core/fields/text.php');
300
- include_once('core/fields/textarea.php');
301
- include_once('core/fields/wysiwyg.php');
302
- include_once('core/fields/image.php');
303
- include_once('core/fields/file.php');
304
- include_once('core/fields/select.php');
305
- include_once('core/fields/checkbox.php');
306
- include_once('core/fields/radio.php');
307
- include_once('core/fields/true_false.php');
308
- include_once('core/fields/page_link.php');
309
- include_once('core/fields/post_object.php');
310
- include_once('core/fields/relationship.php');
311
- include_once('core/fields/date_picker/date_picker.php');
312
- include_once('core/fields/repeater.php');
313
-
314
- $array['text'] = new acf_Text($this);
315
- $array['textarea'] = new acf_Textarea($this);
316
- $array['wysiwyg'] = new acf_Wysiwyg();
317
- $array['image'] = new acf_Image($this);
318
- $array['file'] = new acf_File($this);
319
- $array['select'] = new acf_Select($this);
320
- $array['checkbox'] = new acf_Checkbox();
321
- $array['radio'] = new acf_Radio();
322
- $array['true_false'] = new acf_True_false();
323
- $array['page_link'] = new acf_Page_link($this);
324
- $array['post_object'] = new acf_Post_object($this);
325
- $array['relationship'] = new acf_Relationship($this);
326
- $array['date_picker'] = new acf_Date_picker($this->dir);
327
-
328
- if(array_key_exists('repeater', $this->activated_fields))
329
- {
330
- $array['repeater'] = new acf_Repeater($this);
331
- }
332
-
333
- return $array;
334
  }
335
 
336
 
337
  /*--------------------------------------------------------------------------------------
338
  *
339
- * create_field
340
  *
341
  * @author Elliot Condon
342
  * @since 1.0.0
343
  *
344
  *-------------------------------------------------------------------------------------*/
345
 
346
- function create_field($field)
347
  {
348
- if(!is_object($this->fields[$field->type]))
349
- {
350
- _e('Error: Field Type does not exist!','acf');
351
- return false;
352
- }
353
-
354
- $this->fields[$field->type]->html($field);
355
  }
356
 
357
 
358
  /*--------------------------------------------------------------------------------------
359
  *
360
- * save_field
361
  *
362
  * @author Elliot Condon
363
  * @since 1.0.0
364
  *
365
  *-------------------------------------------------------------------------------------*/
366
 
367
- function save_field($options)
368
  {
369
- if(!$this->fields[$options['field_type']])
370
- {
371
- _e('Error: Field Type does not exist!','acf');
372
- return false;
373
- }
374
-
375
- $this->fields[$options['field_type']]->save_field($options['post_id'], $options['field_name'], $options['field_value']);
376
  }
377
 
378
-
379
  /*--------------------------------------------------------------------------------------
380
  *
381
- * _fields_meta_box
 
382
  *
383
  * @author Elliot Condon
384
  * @since 1.0.0
385
  *
386
  *-------------------------------------------------------------------------------------*/
387
-
388
- function _fields_meta_box()
389
  {
390
- include('core/admin/fields_meta_box.php');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
391
  }
392
 
393
 
394
  /*--------------------------------------------------------------------------------------
395
  *
396
- * _location_meta_box
 
397
  *
398
  * @author Elliot Condon
399
  * @since 1.0.0
400
  *
401
  *-------------------------------------------------------------------------------------*/
402
-
403
- function _location_meta_box()
404
  {
405
- include('core/admin/location_meta_box.php');
 
 
 
 
 
406
  }
407
 
408
 
409
  /*--------------------------------------------------------------------------------------
410
  *
411
- * _options_meta_box
 
412
  *
413
  * @author Elliot Condon
414
  * @since 1.0.0
415
  *
416
  *-------------------------------------------------------------------------------------*/
417
-
418
- function _options_meta_box()
419
  {
420
- include('core/admin/options_meta_box.php');
 
 
 
 
 
421
  }
422
 
423
 
424
  /*--------------------------------------------------------------------------------------
425
  *
426
- * _input_meta_box
427
  *
428
  * @author Elliot Condon
429
  * @since 1.0.0
430
  *
431
  *-------------------------------------------------------------------------------------*/
432
 
433
- function input_meta_box($post, $args)
434
  {
435
- include('core/admin/input_meta_box.php');
 
 
 
 
 
 
 
 
 
436
  }
437
 
438
-
439
-
440
-
441
 
442
  /*--------------------------------------------------------------------------------------
443
  *
444
- * get_fields
445
  *
446
  * @author Elliot Condon
447
  * @since 1.0.0
448
  *
449
  *-------------------------------------------------------------------------------------*/
450
-
451
- function get_fields($acf_id)
452
  {
453
-
454
- // set table name
455
- global $wpdb;
456
- $table_name = $wpdb->prefix.'acf_fields';
457
-
458
-
459
- // get fields
460
- $parent_id = 0;
461
- $fields = $wpdb->get_results("SELECT * FROM $table_name WHERE post_id = '$acf_id' AND parent_id = $parent_id ORDER BY order_no,name");
462
-
463
 
464
- // if fields are empty, this must be a new or broken acf. add blank field
465
- if(!$fields)
466
  {
467
- return array();
 
 
 
468
  }
469
 
470
-
471
- // loop through fields
472
- foreach($fields as $field)
473
- {
474
-
475
- // unserialize options
476
- if(@unserialize($field->options))
477
- {
478
- $field->options = unserialize($field->options);
479
- }
480
- else
481
- {
482
- $field->options = array();
483
- }
484
-
485
-
486
- // sub fields
487
- if($field->type == 'repeater')
488
- {
489
- $sub_fields = $wpdb->get_results("SELECT * FROM $table_name WHERE parent_id = '$field->id' ORDER BY order_no,name");
490
-
491
-
492
- // if fields are empty, this must be a new or broken acf.
493
- if(empty($sub_fields))
494
- {
495
- $field->options['sub_fields'] = array();
496
- }
497
- else
498
- {
499
- // loop through fields
500
- foreach($sub_fields as $sub_field)
501
- {
502
- // unserialize options
503
- if(@unserialize($sub_field->options))
504
- {
505
- $sub_field->options = @unserialize($sub_field->options);
506
- }
507
- else
508
- {
509
- $sub_field->options = array();
510
- }
511
-
512
- }
513
-
514
-
515
- // assign array to the field options array
516
- $field->options['sub_fields'] = $sub_fields;
517
- }
518
-
519
- }
520
- // end if sub field
521
- }
522
- // end foreach $fields
523
-
524
 
525
  // return fields
526
- return $fields;
527
-
528
  }
529
-
530
-
531
  /*--------------------------------------------------------------------------------------
532
  *
533
- * get_field_options
534
  *
535
  * @author Elliot Condon
536
  * @since 1.0.0
537
  *
538
  *-------------------------------------------------------------------------------------*/
539
 
540
- function get_field_options($type, $options)
541
  {
542
- $field_options = $this->fields[$type]->options();
 
 
 
 
 
543
 
544
- ?>
545
- <table class="field_options">
546
- <?php foreach($field_options as $field_option): ?>
547
- <tr>
548
- <td class="label">
549
- <label for="post_type"><?php echo $field_options[0]['label'] ?></label>
550
- </td>
551
- <td>
552
- <?php $acf->create_field('text',$options); ?>
553
- </td>
554
- </tr>
555
- <?php endforeach; ?>
556
- </table>
557
- <?php
558
  }
559
 
560
 
561
  /*--------------------------------------------------------------------------------------
562
  *
563
- * get_acf_location
564
  *
565
  * @author Elliot Condon
566
  * @since 1.0.0
567
  *
568
  *-------------------------------------------------------------------------------------*/
569
 
570
- function get_acf_location($acf_id)
571
- {
 
 
 
572
 
573
- // set table name
574
- global $wpdb;
575
- $table_name = $wpdb->prefix.'acf_rules';
576
- $location = new stdClass();
577
-
578
-
579
- // get fields and add them to $options
580
- $location->rules = $wpdb->get_results("SELECT * FROM $table_name WHERE acf_id = '$acf_id' ORDER BY order_no ASC");
581
- $location->allorany = get_post_meta($acf_id, 'allorany', true) ? get_post_meta($acf_id, 'allorany', true) : 'all';
582
-
583
-
584
- // return location
585
- return $location;
586
-
 
587
  }
588
-
589
 
590
  /*--------------------------------------------------------------------------------------
591
  *
592
- * get_acf_options
593
  *
594
  * @author Elliot Condon
595
- * @since 1.0.0
596
  *
597
  *-------------------------------------------------------------------------------------*/
598
 
599
- function get_acf_options($acf_id)
600
  {
601
-
602
- $options = new stdClass();
603
-
604
-
605
- // If this is a new acf, there will be no custom keys!
606
- if(!get_post_custom_keys($acf_id))
607
- {
608
- $options->show_on_page = array('the_content', 'discussion', 'custom_fields', 'comments', 'slug', 'author');
609
- }
610
- else
611
- {
612
- if(@unserialize(get_post_meta($acf_id, 'show_on_page', true)))
613
- {
614
- $options->show_on_page = unserialize(get_post_meta($acf_id, 'show_on_page', true));
615
- }
616
- else
617
- {
618
- $options->show_on_page = array();
619
- }
620
-
621
- if(get_post_meta($acf_id, 'field_group_layout', true))
622
- {
623
- $options->field_group_layout = get_post_meta($acf_id, 'field_group_layout', true);
624
- }
625
- else
626
- {
627
- $options->field_group_layout = "no_box";
628
- }
629
-
630
- }
631
-
632
- return $options;
633
-
634
  }
635
-
636
-
637
  /*--------------------------------------------------------------------------------------
638
  *
639
- * admin_footer
640
  *
641
  * @author Elliot Condon
642
- * @since 1.0.0
643
  *
644
  *-------------------------------------------------------------------------------------*/
645
 
646
- function admin_footer()
647
  {
648
-
649
- if($GLOBALS['pagenow'] == 'edit.php' && $GLOBALS['post_type'] == 'acf')
650
  {
651
- echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/style.screen_extra.css" />';
652
- echo '<script type="text/javascript" src="'.$this->dir.'/js/functions.screen_extra.js" ></script>';
653
- include('core/screen_extra.php');
654
  }
655
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
656
  }
657
 
658
 
659
  /*--------------------------------------------------------------------------------------
660
  *
661
- * field_method_exists
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
662
  *
663
  * @author Elliot Condon
664
- * @since 2.0.6
665
  *
666
  *-------------------------------------------------------------------------------------*/
667
 
668
- function field_method_exists($field_type, $method)
669
  {
670
- if(method_exists($this->fields[$field_type], $method))
671
  {
672
- return true;
 
673
  }
674
  else
675
  {
676
- return false;
677
  }
 
678
  }
679
-
 
680
  /*--------------------------------------------------------------------------------------
681
  *
682
- * load_value_for_input
683
  *
684
  * @author Elliot Condon
685
- * @since 1.0.6
686
  *
687
  *-------------------------------------------------------------------------------------*/
688
-
689
- function load_value_for_input($post_id, $field)
690
  {
691
-
692
- $value;
693
-
694
-
695
- if($this->field_method_exists($field->type, 'load_value_for_input'))
 
 
 
 
 
 
 
 
 
 
 
 
 
696
  {
697
- $value = $this->fields[$field->type]->load_value_for_input($post_id, $field);
 
 
 
 
 
 
 
 
698
  }
699
- else
 
 
 
 
 
 
 
 
 
 
 
 
 
 
700
  {
701
- // tables
702
- global $wpdb;
703
- $acf_values = $wpdb->prefix.'acf_values';
704
- $wp_postmeta = $wpdb->prefix.'postmeta';
705
-
706
-
707
- // get row
708
- $value = $wpdb->get_row("SELECT m.meta_value as value, m.meta_id, v.id as value_id FROM $wp_postmeta m LEFT JOIN $acf_values v ON m.meta_id = v.value WHERE v.field_id = '$field->id' AND m.post_id = '$post_id'");
709
- //$value = $wpdb->get_var("SELECT value FROM $table_name WHERE field_id = '$field->id' AND post_id = '$post_id'");
710
-
711
- if($value)
712
  {
713
- // format if needed
714
- if($this->field_method_exists($field->type, 'format_value_for_input'))
 
 
715
  {
716
- $value->value = $this->fields[$field->type]->format_value_for_input($value->value);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
717
  }
718
- }
719
- else
720
- {
721
- $value = new stdClass();
722
- $value->value = false;
723
-
724
-
725
- // override with default value
726
- if($post_id != 0)
727
  {
728
- $post_meta = get_post_custom($post_id);
729
- if(empty($post_meta) && isset($field->default_value))
 
 
 
730
  {
731
- $value->value = $field->default_value;
 
 
 
 
 
 
 
732
  }
733
-
734
  }
735
-
 
 
 
 
736
 
737
  }
738
  }
739
 
 
 
 
 
 
 
 
 
 
 
740
 
741
- // return value
742
- return $value;
743
  }
744
 
745
-
746
 
747
  /*--------------------------------------------------------------------------------------
748
  *
749
- * load_value_for_api
750
- *
 
751
  * @author Elliot Condon
752
- * @since 1.0.6
753
  *
754
  *-------------------------------------------------------------------------------------*/
755
-
756
- function load_value_for_api($post_id, $field)
757
  {
 
 
 
758
 
759
- if($this->field_method_exists($field->type, 'load_value_for_api'))
 
760
  {
761
- $value = $this->fields[$field->type]->load_value_for_api($post_id, $field);
762
  }
763
- else
764
  {
765
- // tables
766
- global $wpdb;
767
- $acf_values = $wpdb->prefix.'acf_values';
768
- $wp_postmeta = $wpdb->prefix.'postmeta';
769
-
770
-
771
- // get var
772
- $value = $wpdb->get_var("SELECT m.meta_value FROM $wp_postmeta m LEFT JOIN $acf_values v ON m.meta_id = v.value WHERE v.field_id = '$field->id' AND m.post_id = '$post_id'");
773
-
774
-
775
- // format if needed
776
- if($this->field_method_exists($field->type, 'format_value_for_api'))
777
- {
778
- $value = $this->fields[$field->type]->format_value_for_api($value, $field->options);
779
- }
780
  }
781
-
782
-
783
- if(empty($value) || $value == null || $value == "")
 
 
 
 
 
 
 
 
 
 
784
  {
785
- $value = false;
786
  }
787
 
 
788
 
789
- // return value
790
- return $value;
791
  }
792
-
793
 
794
  /*--------------------------------------------------------------------------------------
795
  *
796
- * get_activated_fields
797
- *
 
798
  * @author Elliot Condon
799
- * @since 2.0.0
800
  *
801
  *-------------------------------------------------------------------------------------*/
802
-
803
- function get_activated_fields()
804
  {
805
- $activated = array();
806
-
807
- // repeater
808
- if(get_option("acf_repeater_ac"))
809
  {
810
- $md5 = md5(get_option("acf_repeater_ac"));
811
- if($md5 == "bbefed143f1ec106ff3a11437bd73432")
812
- {
813
- $activated['repeater'] = get_option("acf_repeater_ac");
814
- }
815
  }
816
 
 
817
 
818
- // options
819
- if(get_option("acf_options_page_ac"))
820
- {
821
- $md5 = md5(get_option("acf_options_page_ac"));
822
- if($md5 == "1fc8b993548891dc2b9a63ac057935d8")
823
- {
824
- $activated['options_page'] = get_option("acf_options_page_ac");
825
- }
826
- }
827
-
828
- return $activated;
829
  }
830
 
831
 
@@ -840,26 +1026,38 @@ class Acf
840
 
841
  function match_location_rule($post, $rule, $overrides = array())
842
  {
 
 
 
 
 
 
 
 
 
 
 
843
 
844
- switch ($rule->param) {
 
845
 
846
  // POST TYPE
847
  case "post_type":
848
 
849
  $post_type = isset($overrides['post_type']) ? $overrides['post_type'] : get_post_type($post);
850
 
851
- if($rule->operator == "==")
852
  {
853
- if($post_type == $rule->value)
854
  {
855
  return true;
856
  }
857
 
858
  return false;
859
  }
860
- elseif($rule->operator == "!=")
861
  {
862
- if($post_type != $rule->value)
863
  {
864
  return true;
865
  }
@@ -874,18 +1072,18 @@ class Acf
874
 
875
  $page = isset($overrides['page']) ? $overrides['page'] : $post->ID;
876
 
877
- if($rule->operator == "==")
878
  {
879
- if($page == $rule->value)
880
  {
881
  return true;
882
  }
883
 
884
  return false;
885
  }
886
- elseif($rule->operator == "!=")
887
  {
888
- if($page != $rule->value)
889
  {
890
  return true;
891
  }
@@ -900,28 +1098,28 @@ class Acf
900
 
901
  $page_type = isset($overrides['page_type']) ? $overrides['page_type'] : $post->post_parent;
902
 
903
- if($rule->operator == "==")
904
  {
905
- if($rule->value == "parent" && $page_type == "0")
906
  {
907
  return true;
908
  }
909
 
910
- if($rule->value == "child" && $page_type != "0")
911
  {
912
  return true;
913
  }
914
 
915
  return false;
916
  }
917
- elseif($rule->operator == "!=")
918
  {
919
- if($rule->value == "parent" && $page_type != "0")
920
  {
921
  return true;
922
  }
923
 
924
- if($rule->value == "child" && $page_type == "0")
925
  {
926
  return true;
927
  }
@@ -936,9 +1134,9 @@ class Acf
936
 
937
  $page_parent = isset($overrides['page_parent']) ? $overrides['page_parent'] : $post->post_parent;
938
 
939
- if($rule->operator == "==")
940
  {
941
- if($page_parent == $rule->value)
942
  {
943
  return true;
944
  }
@@ -946,9 +1144,9 @@ class Acf
946
  return false;
947
 
948
  }
949
- elseif($rule->operator == "!=")
950
  {
951
- if($page_parent != $rule->value)
952
  {
953
  return true;
954
  }
@@ -963,23 +1161,23 @@ class Acf
963
 
964
  $page_template = isset($overrides['page_template']) ? $overrides['page_template'] : get_post_meta($post->ID,'_wp_page_template',true);
965
 
966
- if($rule->operator == "==")
967
  {
968
- if($page_template == $rule->value)
969
  {
970
  return true;
971
  }
972
 
973
- if($rule->value == "default" && !$page_template)
974
  {
975
  return true;
976
  }
977
 
978
  return false;
979
  }
980
- elseif($rule->operator == "!=")
981
  {
982
- if($page_template != $rule->value)
983
  {
984
  return true;
985
  }
@@ -994,18 +1192,18 @@ class Acf
994
 
995
  $post_id = isset($overrides['post']) ? $overrides['post'] : $post->ID;
996
 
997
- if($rule->operator == "==")
998
  {
999
- if($post_id == $rule->value)
1000
  {
1001
  return true;
1002
  }
1003
 
1004
  return false;
1005
  }
1006
- elseif($rule->operator == "!=")
1007
  {
1008
- if($post_id != $rule->value)
1009
  {
1010
  return true;
1011
  }
@@ -1032,12 +1230,11 @@ class Acf
1032
  $cats[] = $cat->term_id;
1033
  }
1034
  }
1035
-
1036
- if($rule->operator == "==")
1037
  {
1038
  if($cats)
1039
  {
1040
- if(in_array($rule->value, $cats))
1041
  {
1042
  return true;
1043
  }
@@ -1045,11 +1242,11 @@ class Acf
1045
 
1046
  return false;
1047
  }
1048
- elseif($rule->operator == "!=")
1049
  {
1050
  if($cats)
1051
  {
1052
- if(!in_array($rule->value, $cats))
1053
  {
1054
  return true;
1055
  }
@@ -1066,9 +1263,9 @@ class Acf
1066
 
1067
  $post_format = isset($overrides['post_format']) ? $overrides['post_format'] : get_post_format();
1068
 
1069
- if($rule->operator == "==")
1070
  {
1071
- if($post_format == $rule->value)
1072
  {
1073
  return true;
1074
  }
@@ -1078,7 +1275,7 @@ class Acf
1078
  }
1079
  elseif($post_format == "!=")
1080
  {
1081
- if($post->post_parent != $rule->value)
1082
  {
1083
  return true;
1084
  }
@@ -1092,18 +1289,18 @@ class Acf
1092
  // USER TYPE
1093
  case "user_type":
1094
 
1095
- if($rule->operator == "==")
1096
  {
1097
- if(current_user_can($rule->value))
1098
  {
1099
  return true;
1100
  }
1101
 
1102
  return false;
1103
  }
1104
- elseif($rule->operator == "!=")
1105
  {
1106
- if(!current_user_can($rule->value))
1107
  {
1108
  return true;
1109
  }
@@ -1117,18 +1314,18 @@ class Acf
1117
  case "options_page":
1118
 
1119
 
1120
- if($rule->operator == "==")
1121
  {
1122
- if(get_admin_page_title() == $rule->value)
1123
  {
1124
  return true;
1125
  }
1126
 
1127
  return false;
1128
  }
1129
- elseif($rule->operator == "!=")
1130
  {
1131
- if(get_admin_page_title() != $rule->value)
1132
  {
1133
  return true;
1134
  }
@@ -1143,9 +1340,9 @@ class Acf
1143
  case "post_format":
1144
 
1145
 
1146
- $post_format = isset($overrides['post_format']) ? has_post_format($overrides['post_format'],$post->ID) : has_post_format($rule->value,$post->ID);
1147
 
1148
- if($rule->operator == "==")
1149
  {
1150
  if($post_format)
1151
  {
@@ -1154,7 +1351,7 @@ class Acf
1154
 
1155
  return false;
1156
  }
1157
- elseif($rule->operator == "!=")
1158
  {
1159
  if(!$post_format)
1160
  {
@@ -1166,184 +1363,100 @@ class Acf
1166
 
1167
  break;
1168
 
1169
-
1170
- }
1171
-
1172
- }
1173
 
1174
-
1175
-
1176
- /*--------------------------------------------------------------------------------------
1177
- *
1178
- * export
1179
- *
1180
- * @author Elliot Condon
1181
- * @since 2.0.5
1182
- *
1183
- *-------------------------------------------------------------------------------------*/
1184
-
1185
- function export()
1186
- {
1187
- if(!isset($_POST['acf_export']))
1188
- {
1189
- return;
1190
- }
1191
-
1192
-
1193
- // get the acfs to save
1194
- $acfs = isset($_POST['acf_objects']) ? $_POST['acf_objects'] : null;
1195
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1196
 
1197
- // quick function for writing an array
1198
- function echo_value_xml($value)
1199
- {
1200
- if(!is_array($value))
1201
- {
1202
- echo $value;
1203
- }
1204
- else
1205
- {
1206
- echo '<array>';
1207
- foreach($value as $k => $v)
1208
- {
1209
- echo '<piece key="'.$k.'">'.$v.'</piece>';
1210
- }
1211
- echo '</array>';
1212
- }
1213
  }
1214
 
1215
- // save as file
1216
- header( 'Content-Description: File Transfer' );
1217
- header( 'Content-Disposition: attachment; filename=advanced-custom-fields.xml' );
1218
- header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
1219
-
1220
-
1221
-
1222
- // display document in browser as plain text
1223
- //header("Content-Type: text/plain");
1224
- echo '<?xml version="1.0"?> ';
1225
- ?>
1226
-
1227
- <?php if($acfs): ?>
1228
- <posts>
1229
- <?php
1230
- foreach($acfs as $acf):
1231
- $post = get_post($acf);
1232
- $fields = $this->get_fields($post->ID);
1233
- $location = $this->get_acf_location($post->ID);
1234
- $options = $this->get_acf_options($post->ID);
1235
- ?>
1236
- <post>
1237
- <title><?php echo apply_filters( 'the_title_rss', $post->post_title ); ?></title>
1238
- <post_status><?php echo $post->post_status; ?></post_status>
1239
- <post_parent><?php echo $post->post_parent; ?></post_parent>
1240
- <menu_order><?php echo $post->menu_order; ?></menu_order>
1241
- <fields>
1242
- <?php if($fields):
1243
- foreach($fields as $field): ?>
1244
- <field>
1245
- <label><?php echo $field->label; ?></label>
1246
- <name><?php echo $field->name; ?></name>
1247
- <type><?php echo $field->type; ?></type>
1248
- <default_value><?php echo $field->default_value; ?></default_value>
1249
- <options>
1250
- <?php if($field->options):
1251
- foreach($field->options as $k => $option):
1252
- if($k == 'sub_fields'): ?>
1253
- <<?php echo $k; ?>>
1254
- <?php foreach($field->options['sub_fields'] as $sub_field): ?>
1255
- <field>
1256
- <label><?php echo $sub_field->label; ?></label>
1257
- <name><?php echo $sub_field->name; ?></name>
1258
- <type><?php echo $sub_field->type; ?></type>
1259
- <default_value><?php echo $sub_field->default_value; ?></default_value>
1260
- <options>
1261
- <?php if($sub_field->options):
1262
- foreach($sub_field->options as $k2 => $option2): ?>
1263
- <<?php echo $k2; ?>><?php echo_value_xml($option2); ?></<?php echo $k2; ?>>
1264
- <?php endforeach;
1265
- endif; ?>
1266
- </options>
1267
- </field>
1268
- <?php endforeach; ?>
1269
- </<?php echo $k; ?>>
1270
- <?php else: ?>
1271
- <<?php echo $k; ?>><?php echo_value_xml($option); ?></<?php echo $k; ?>>
1272
- <?php endif;
1273
- endforeach;
1274
- endif; ?>
1275
- </options>
1276
- <instructions><?php echo $field->instructions ?></instructions>
1277
- </field>
1278
- <?php endforeach;
1279
- endif; ?>
1280
- </fields>
1281
- <location>
1282
- <?php if($location->rules):
1283
- foreach($location->rules as $k => $rule): ?>
1284
- <rule>
1285
- <param><?php echo $rule->param; ?></param>
1286
- <operator><?php echo $rule->operator; ?></operator>
1287
- <value><?php echo $rule->value; ?></value>
1288
- </rule>
1289
- <?php endforeach;
1290
- endif; ?>
1291
- <allorany><?php echo $location->allorany; ?></allorany>
1292
- </location>
1293
- <options>
1294
- <show_on_page><?php echo_value_xml($options->show_on_page); ?></show_on_page>
1295
- <field_group_layout><?php echo $options->field_group_layout; ?></field_group_layout>
1296
- </options>
1297
- </post>
1298
- <?php endforeach; ?>
1299
- </posts>
1300
- <?php
1301
- endif;
1302
-
1303
- die;
1304
  }
1305
 
1306
 
1307
-
1308
  /*--------------------------------------------------------------------------------------
1309
  *
1310
- * import
1311
  *
1312
  * @author Elliot Condon
1313
- * @since 2.0.5
1314
  *
1315
  *-------------------------------------------------------------------------------------*/
1316
 
1317
- function import()
1318
  {
1319
- // Checkpoint: Did someone submit the form
1320
- if(isset($_POST['acf_import']))
1321
- {
1322
- include('core/import.php');
1323
- }
 
 
 
1324
  }
1325
 
1326
-
1327
  /*--------------------------------------------------------------------------------------
1328
  *
1329
- * admin_error
1330
  *
1331
  * @author Elliot Condon
1332
- * @since 2.0.5
1333
  *
1334
  *-------------------------------------------------------------------------------------*/
1335
 
1336
- function admin_error($message = "")
1337
  {
1338
- global $acf_mesage;
1339
- $acf_mesage = $message;
1340
-
1341
- function my_admin_notice()
1342
- {
1343
- global $acf_mesage;
1344
- echo '<div class="error" id="message"><p>'.$acf_mesage.'</p></div>';
1345
- }
1346
- add_action('admin_notices', 'my_admin_notice');
1347
  }
1348
 
1349
 
@@ -1356,294 +1469,19 @@ class Acf
1356
  *
1357
  *-------------------------------------------------------------------------------------*/
1358
 
1359
- function admin_message($message = "")
1360
  {
1361
- global $acf_mesage;
1362
- $acf_mesage = $message;
1363
 
1364
  function my_admin_notice()
1365
  {
1366
- global $acf_mesage;
1367
- echo '<div class="updated" id="message"><p>'.$acf_mesage.'</p></div>';
1368
  }
1369
  add_action('admin_notices', 'my_admin_notice');
1370
  }
1371
 
1372
-
1373
- /*--------------------------------------------------------------------------------------
1374
- *
1375
- * input_meta_box_html
1376
- *
1377
- * @author Elliot Condon
1378
- * @since 2.0.6
1379
- *
1380
- *-------------------------------------------------------------------------------------*/
1381
- function input_meta_box_html($ajax = true)
1382
- {
1383
-
1384
- $overrides = array();
1385
- if(isset($_POST['page_template']) && $_POST['page_template'] != 'false') $overrides['page_template'] = $_POST['page_template'];
1386
- if(isset($_POST['page_parent']) && $_POST['page_parent'] != 'false') $overrides['page_parent'] = $_POST['page_parent'];
1387
- if(isset($_POST['page_type']) && $_POST['page_type'] != 'false') $overrides['page_type'] = $_POST['page_type'];
1388
- if(isset($_POST['page']) && $_POST['page'] != 'false') $overrides['page'] = $_POST['page'];
1389
- if(isset($_POST['post']) && $_POST['post'] != 'false') $overrides['post'] = $_POST['post'];
1390
- if(isset($_POST['post_category']) && $_POST['post_category'] != 'false') $overrides['post_category'] = $_POST['post_category'];
1391
- if(isset($_POST['post_format']) && $_POST['post_format'] != 'false') $overrides['post_format'] = $_POST['post_format'];
1392
-
1393
- $this->input_meta_box_html_no_ajax($_POST['post_id'], $overrides);
1394
-
1395
- die;
1396
-
1397
- }
1398
-
1399
-
1400
- /*--------------------------------------------------------------------------------------
1401
- *
1402
- * input_meta_box_html_no_ajax
1403
- *
1404
- * @author Elliot Condon
1405
- * @since 2.0.6
1406
- *
1407
- *-------------------------------------------------------------------------------------*/
1408
-
1409
- function input_meta_box_html_no_ajax($post_id, $overrides = array())
1410
- {
1411
- // create post object to match against
1412
- $post = get_post($post_id);
1413
-
1414
-
1415
- //var_dump($overrides);
1416
- $acfs = get_pages(array(
1417
- 'numberposts' => -1,
1418
- 'post_type' => 'acf',
1419
- 'sort_column' => 'menu_order',
1420
- ));
1421
-
1422
-
1423
- // blank array to hold acfs
1424
- $add_acf = array();
1425
-
1426
- if($acfs)
1427
- {
1428
- foreach($acfs as $acf)
1429
- {
1430
- $add_box = false;
1431
- $location = $this->get_acf_location($acf->ID);
1432
-
1433
-
1434
- if($location->allorany == 'all')
1435
- {
1436
- // ALL
1437
-
1438
- $add_box = true;
1439
-
1440
- if($location->rules)
1441
- {
1442
- foreach($location->rules as $rule)
1443
- {
1444
- // if any rules dont return true, dont add this acf
1445
- if(!$this->match_location_rule($post, $rule, $overrides))
1446
- {
1447
- $add_box = false;
1448
- }
1449
- }
1450
- }
1451
-
1452
- }
1453
- elseif($location->allorany == 'any')
1454
- {
1455
- // ANY
1456
-
1457
- $add_box = false;
1458
-
1459
- if($location->rules)
1460
- {
1461
- foreach($location->rules as $rule)
1462
- {
1463
- // if any rules return true, add this acf
1464
- if($this->match_location_rule($post, $rule, $overrides))
1465
- {
1466
- $add_box = true;
1467
- }
1468
- }
1469
- }
1470
- }
1471
-
1472
- if($add_box == true)
1473
- {
1474
- $add_acf[] = $acf;
1475
- }
1476
-
1477
- }// end foreach
1478
-
1479
- if(!empty($add_acf))
1480
- {
1481
-
1482
- $adv_options = $this->get_acf_options($add_acf[0]->ID);
1483
-
1484
-
1485
- $fields = array();
1486
- foreach($add_acf as $acf)
1487
- {
1488
- // get this acf's fields and add them to the global $fields
1489
- $this_fields = $this->get_fields($acf->ID);
1490
- foreach($this_fields as $this_field)
1491
- {
1492
- $fields[] = $this_field;
1493
- }
1494
-
1495
- }
1496
-
1497
- ?>
1498
-
1499
-
1500
- <style type="text/css" id="acf_dynamic_style">
1501
- <?php if(!in_array('the_content',$adv_options->show_on_page)): ?>
1502
- #postdivrich {display: none;}
1503
- <?php endif; ?>
1504
-
1505
- <?php if(!in_array('custom_fields',$adv_options->show_on_page)): ?>
1506
- #postcustom,
1507
- #screen-meta label[for=postcustom-hide] {display: none;}
1508
- <?php endif; ?>
1509
-
1510
- <?php if(!in_array('discussion',$adv_options->show_on_page)): ?>
1511
- #commentstatusdiv,
1512
- #screen-meta label[for=commentstatusdiv-hide] {display: none;}
1513
- <?php endif; ?>
1514
-
1515
- <?php if(!in_array('comments',$adv_options->show_on_page)): ?>
1516
- #commentsdiv,
1517
- #screen-meta label[for=commentsdiv-hide] {display: none;}
1518
- <?php endif; ?>
1519
-
1520
- <?php if(!in_array('slug',$adv_options->show_on_page)): ?>
1521
- #slugdiv,
1522
- #screen-meta label[for=slugdiv-hide] {display: none;}
1523
- <?php endif; ?>
1524
-
1525
- <?php if(!in_array('author',$adv_options->show_on_page)): ?>
1526
- #authordiv,
1527
- #screen-meta label[for=authordiv-hide] {display: none;}
1528
- <?php endif; ?>
1529
-
1530
- #screen-meta label[for=acf_input-hide] {display: none;}
1531
- </style>
1532
-
1533
-
1534
-
1535
-
1536
- <?php
1537
-
1538
- foreach($add_acf as $acf)
1539
- {
1540
-
1541
- // load acf data
1542
- $options = $this->get_acf_options($acf->ID);
1543
- $fields = $this->get_fields($acf->ID);
1544
- $html = '';
1545
-
1546
-
1547
- if($options->field_group_layout == "in_box")
1548
- {
1549
- echo '<div class="acf_ajax_fields postbox" data-acf_id="'.$acf->ID.'"><h3><span>'.$acf->post_title.'</span></h3><div class="inside">';
1550
- }
1551
- else
1552
- {
1553
- echo '<div class="acf_ajax_fields" data-acf_id="'.$acf->ID.'">';
1554
- }
1555
-
1556
-
1557
- foreach($fields as $field)
1558
- {
1559
-
1560
- // if they didn't select a type, skip this field
1561
- if($field->type == 'null')
1562
- {
1563
- continue;
1564
- }
1565
-
1566
-
1567
- // set value, id and name for field
1568
- $field->value = $this->load_value_for_input($post->ID, $field);
1569
- $field->input_name = isset($field->input_name) ? $field->input_name : '';
1570
-
1571
- $temp_field = new stdClass();
1572
-
1573
-
1574
- echo '<div class="field">';
1575
-
1576
- echo '<input type="hidden" name="acf['.$field->id.'][field_id]" value="'.$field->id.'" />';
1577
- echo '<input type="hidden" name="acf['.$field->id.'][field_type]" value="'.$field->type.'" />';
1578
- echo '<input type="hidden" name="acf['.$field->id.'][field_name]" value="'.$field->name.'" />';
1579
-
1580
- if($field->type != 'repeater')
1581
- {
1582
- $value_id = isset($field->value->value_id) ? $field->value->value_id : '';
1583
- $meta_id = isset($field->value->meta_id) ? $field->value->meta_id : '';
1584
- $temp_field->value = $field->value->value;
1585
-
1586
- echo '<input type="hidden" name="acf['.$field->id.'][value_id]" value="' . $value_id . '" />';
1587
- echo '<input type="hidden" name="acf['.$field->id.'][meta_id]" value="' . $meta_id . '" />';
1588
- }
1589
- else
1590
- {
1591
- $temp_field->value = $field->value;
1592
- }
1593
-
1594
-
1595
- echo '<label for="'.$field->input_name.'">'.$field->label.'</label>';
1596
-
1597
-
1598
- if($field->instructions)
1599
- {
1600
- echo '<p class="instructions">'.$field->instructions.'</p>';
1601
- }
1602
-
1603
- $temp_field->type = $field->type;
1604
- $temp_field->input_name = 'acf['.$field->id.'][value]';
1605
- $temp_field->input_class = $field->type;
1606
- $temp_field->options = $field->options;
1607
-
1608
- $this->create_field($temp_field);
1609
-
1610
-
1611
- echo '</div>';
1612
-
1613
 
1614
- }
1615
-
1616
-
1617
- if($options->field_group_layout == "in_box")
1618
- {
1619
- echo '</div></div>';
1620
- }
1621
- else
1622
- {
1623
- echo '</div>';
1624
- }
1625
- }
1626
-
1627
- }
1628
-
1629
- }// end if
1630
-
1631
-
1632
- }
1633
-
1634
-
1635
- /*--------------------------------------------------------------------------------------
1636
- *
1637
- * third_party
1638
- *
1639
- * @author Elliot Condon
1640
- * @since 2.0.6
1641
- *
1642
- *-------------------------------------------------------------------------------------*/
1643
- function third_party()
1644
- {
1645
- include('core/third_party.php');
1646
- }
1647
-
1648
 
1649
- }
 
3
  Plugin Name: Advanced Custom Fields
4
  Plugin URI: http://plugins.elliotcondon.com/advanced-custom-fields/
5
  Description: Customise your edit pages with an assortment of field types: Wysiwyg, Repeater, text, textarea, image, file, select, checkbox post type, page link and more! Hide unwanted metaboxes and assign to any edit page!
6
+ Version: 3.0.0
7
  Author: Elliot Condon
8
  Author URI: http://www.elliotcondon.com/
9
  License: GPL
10
  Copyright: Elliot Condon
11
  */
12
 
13
+ //ini_set('error_reporting', E_ALL);
 
 
 
 
 
 
14
 
15
  include('core/api.php');
16
 
17
+ $acf = new Acf();
18
 
19
  class Acf
20
  {
 
21
  var $dir;
22
  var $path;
23
  var $siteurl;
24
  var $wpadminurl;
25
  var $version;
26
+ var $upgrade_version;
27
  var $fields;
 
28
  var $options_page;
29
 
30
 
45
  $this->dir = plugins_url('',__FILE__);
46
  $this->siteurl = get_bloginfo('url');
47
  $this->wpadminurl = admin_url();
48
+ $this->version = '3.0.0';
49
+ $this->upgrade_version = '3.0.0'; // this is the latest version which requires an upgrade
 
 
50
 
51
 
52
  // set text domain
53
+ //load_plugin_textdomain('acf', false, $this->path.'/lang' );
54
+ load_plugin_textdomain('acf', false, basename(dirname(__FILE__)).'/lang' );
55
 
56
+ // load options page
57
+ $this->setup_options_page();
 
 
58
 
59
+ // actions
60
  add_action('init', array($this, 'init'));
 
 
 
 
61
  add_action('admin_menu', array($this,'admin_menu'));
62
+ add_action('admin_head', array($this,'admin_head'));
63
  add_action('save_post', array($this, 'save_post'));
64
+ add_action('wp_ajax_get_input_metabox_ids', array($this, 'get_input_metabox_ids'));
65
+ add_action('wp_ajax_get_input_style', array($this, 'the_input_style'));
66
  add_action('admin_footer', array($this, 'admin_footer'));
67
+ add_action('admin_print_scripts', array($this, 'admin_print_scripts'));
68
+ add_action('admin_print_styles', array($this, 'admin_print_styles'));
69
+ add_action('wp_ajax_acf_upgrade', array($this, 'upgrade_ajax'));
70
+ return true;
71
+ }
72
+
73
+
74
+ /*--------------------------------------------------------------------------------------
75
+ *
76
+ * setup_fields
77
+ *
78
+ * @author Elliot Condon
79
+ * @since 1.0.0
80
+ *
81
+ *-------------------------------------------------------------------------------------*/
82
+
83
+ function setup_fields()
84
+ {
85
+ // vars
86
+ $return = array();
87
 
88
+ // include parent field
89
+ include_once('core/fields/acf_field.php');
90
 
91
+ // include child fields
92
+ include_once('core/fields/acf_field.php');
93
+ include_once('core/fields/text.php');
94
+ include_once('core/fields/textarea.php');
95
+ include_once('core/fields/wysiwyg.php');
96
+ include_once('core/fields/image.php');
97
+ include_once('core/fields/file.php');
98
+ include_once('core/fields/select.php');
99
+ include_once('core/fields/checkbox.php');
100
+ include_once('core/fields/radio.php');
101
+ include_once('core/fields/true_false.php');
102
+ include_once('core/fields/page_link.php');
103
+ include_once('core/fields/post_object.php');
104
+ include_once('core/fields/relationship.php');
105
+ include_once('core/fields/date_picker/date_picker.php');
106
+ include_once('core/fields/color_picker.php');
107
+
108
+ $return['text'] = new acf_Text($this);
109
+ $return['textarea'] = new acf_Textarea($this);
110
+ $return['wysiwyg'] = new acf_Wysiwyg($this);
111
+ $return['image'] = new acf_Image($this);
112
+ $return['file'] = new acf_File($this);
113
+ $return['select'] = new acf_Select($this);
114
+ $return['checkbox'] = new acf_Checkbox($this);
115
+ $return['radio'] = new acf_Radio($this);
116
+ $return['true_false'] = new acf_True_false($this);
117
+ $return['page_link'] = new acf_Page_link($this);
118
+ $return['post_object'] = new acf_Post_object($this);
119
+ $return['relationship'] = new acf_Relationship($this);
120
+ $return['date_picker'] = new acf_Date_picker($this);
121
+ $return['color_picker'] = new acf_Color_picker($this);
122
+
123
+ // hook to load in third party fields
124
+ if($this->is_field_unlocked('repeater'))
125
+ {
126
+ include_once('core/fields/repeater.php');
127
+ $return['repeater'] = new acf_Repeater($this);
128
+ }
129
 
130
+ // custom fields
131
+ $custom = apply_filters('acf_register_field',array());
132
+
133
+ if(!empty($custom))
134
+ {
135
+ foreach($custom as $v)
136
+ {
137
+ //var_dump($v['url']);
138
+ include($v['url']);
139
+ $name = $v['class'];
140
+ $custom_field = new $name($this);
141
+ $return[$custom_field->name] = $custom_field;
142
+ }
143
+ }
144
+
145
+ $this->fields = $return;
146
  }
147
 
148
 
149
  /*--------------------------------------------------------------------------------------
150
  *
151
+ * setup_options_page
152
  *
153
  * @author Elliot Condon
154
+ * @since 1.0.0
155
  *
156
  *-------------------------------------------------------------------------------------*/
157
 
158
+ function setup_options_page()
159
  {
160
+ include_once('core/options_page.php');
161
+ $this->options_page = new Options_page($this);
162
  }
163
 
164
+ /*--------------------------------------------------------------------------------------
165
+ *
166
+ * admin_menu
167
+ *
168
+ * @author Elliot Condon
169
+ * @since 1.0.0
170
+ *
171
+ *-------------------------------------------------------------------------------------*/
172
+
173
+ function admin_menu() {
174
+
175
+ // add acf page to options menu
176
+ add_options_page(__("Adv Custom Fields",'acf'), __("Adv Custom Fields",'acf'), 'manage_options', 'edit.php?post_type=acf');
177
+ add_options_page(__("ACF Upgrade",'acf'), __("Adv Upgrade",'acf'), 'manage_options', 'acf-upgrade', array($this, 'upgrade'));
178
+
179
+ }
180
 
181
 
182
  /*--------------------------------------------------------------------------------------
196
 
197
  /*--------------------------------------------------------------------------------------
198
  *
199
+ * upgrade
200
  *
201
  * @author Elliot Condon
202
  * @since 1.0.0
203
  *
204
  *-------------------------------------------------------------------------------------*/
205
 
206
+ function upgrade()
207
  {
208
+ include('core/admin/upgrade.php');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
  }
210
 
211
 
212
  /*--------------------------------------------------------------------------------------
213
  *
214
+ * ajax_upgrade
215
  *
216
  * @author Elliot Condon
217
  * @since 1.0.0
218
  *
219
  *-------------------------------------------------------------------------------------*/
220
 
221
+ function upgrade_ajax()
222
+ {
223
+ include('core/admin/upgrade_ajax.php');
 
 
 
224
  }
225
 
226
 
227
+
228
  /*--------------------------------------------------------------------------------------
229
  *
230
+ * admin_print_scripts / admin_print_styles
231
  *
232
  * @author Elliot Condon
233
+ * @since 3.0.0
234
  *
235
  *-------------------------------------------------------------------------------------*/
236
 
237
+ function admin_print_scripts() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
 
239
+ if(in_array($GLOBALS['pagenow'], array('post.php', 'post-new.php')))
 
240
  {
241
+ if($GLOBALS['post_type'] == 'acf')
242
+ {
243
+ // hmmm
244
+ }
245
+ else
246
+ {
247
+ // fields admin_head
248
+ foreach($this->fields as $field)
249
+ {
250
+ $this->fields[$field->name]->admin_print_scripts();
251
+ }
252
+ }
253
  }
254
 
255
+ }
256
+
257
+ function admin_print_styles() {
258
+
259
+ if(in_array($GLOBALS['pagenow'], array('post.php', 'post-new.php')))
260
+ {
261
+ if($GLOBALS['post_type'] == 'acf')
262
+ {
263
+ // hmmm
264
+ }
265
+ else
266
+ {
267
+ // fields admin_head
268
+ foreach($this->fields as $field)
269
+ {
270
+ $this->fields[$field->name]->admin_print_styles();
271
+ }
272
+ }
273
+ }
274
 
 
 
 
 
 
275
  }
276
+
277
 
278
  /*--------------------------------------------------------------------------------------
279
  *
280
+ * admin_head
281
  *
282
  * @author Elliot Condon
283
+ * @since 1.0.0
284
  *
285
  *-------------------------------------------------------------------------------------*/
286
 
287
+ function admin_head()
288
  {
289
+ // vars
290
+ global $post;
291
 
292
+ // hide upgrade page fro nav
293
+ echo '<style type="text/css"> #menu-settings a[href="options-general.php?page=acf-upgrade"]{ display:none; }</style>';
294
 
 
 
 
 
 
295
 
296
+ // only add to edit pages
297
+ if(in_array($GLOBALS['pagenow'], array('post.php', 'post-new.php')))
298
  {
 
 
299
 
300
+ if($GLOBALS['post_type'] == 'acf')
301
+ {
302
+ echo '<script type="text/javascript" src="'.$this->dir.'/js/fields.js" ></script>';
303
+ echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/global.css" />';
304
+ echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/fields.css" />';
305
+
306
+ add_meta_box('acf_fields', 'Fields', array($this, 'meta_box_fields'), 'acf', 'normal', 'high');
307
+ add_meta_box('acf_location', 'Location </span><span class="description">- Add Fields to Edit Screens', array($this, 'meta_box_location'), 'acf', 'normal', 'high');
308
+ add_meta_box('acf_options', 'Options</span><span class="description">- Customise the edit page', array($this, 'meta_box_options'), 'acf', 'normal', 'high');
309
+
310
+ }
311
+ else
312
+ {
313
+
314
+ // create tyn mce instance for wysiwyg
315
+ wp_tiny_mce();
316
 
317
+ // find post type and add wysiwyg support
318
+ $post_type = get_post_type($post);
319
 
320
+ // add css + javascript
321
+ echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/global.css" />';
322
+ echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/input.css" />';
323
+ echo '<script type="text/javascript" src="'.$this->dir.'/js/input.js" ></script>';
324
+ echo '<style type="text/css">.acf_postbox, .postbox[id*="acf_"] { display: none; }</style>';
325
+
326
+ // get style for page
327
+ $metabox_ids = $this->get_input_metabox_ids(array('post_id' => $post->ID), false);
328
+ $style = isset($metabox_ids[0]) ? $this->get_input_style($metabox_ids[0]) : '';
329
+ echo '<style type="text/css" id="acf_style" >' .$style . '</style>';
330
+
331
+ // fields admin_head
332
+ foreach($this->fields as $field)
333
+ {
334
+ $this->fields[$field->name]->admin_head();
335
+ }
336
+
337
+ // get acf's
338
+ $acfs = get_pages(array(
339
+ 'numberposts' => -1,
340
+ 'post_type' => 'acf',
341
+ 'sort_column' => 'menu_order',
342
+ 'order' => 'ASC',
343
+ ));
344
+ if($acfs)
345
+ {
346
+ foreach($acfs as $acf)
347
+ {
348
+ // hide / show
349
+ $show = in_array($acf->ID, $metabox_ids) ? "true" : "false";
350
+
351
+ // load
352
+ $options = $this->get_acf_options($acf->ID);
353
+ $fields = $this->get_acf_fields($acf->ID);
354
+
355
+ // add meta box
356
+ add_meta_box(
357
+ 'acf_' . $acf->ID,
358
+ $acf->post_title,
359
+ array($this, 'meta_box_input'),
360
+ $post_type,
361
+ $options['position'],
362
+ 'default',
363
+ array( 'fields' => $fields, 'options' => $options, 'show' => $show )
364
+ );
365
+ }
366
+
367
+ }
368
+
369
+
370
+
371
+ }
372
+ }
373
  }
374
 
375
 
376
  /*--------------------------------------------------------------------------------------
377
  *
378
+ * admin_footer
379
  *
380
  * @author Elliot Condon
381
  * @since 1.0.0
382
  *
383
  *-------------------------------------------------------------------------------------*/
384
 
385
+ function admin_footer()
386
+ {
387
+ // acf edit list
388
+ if($GLOBALS['pagenow'] == 'edit.php' && $GLOBALS['post_type'] == 'acf')
389
+ {
390
+ include('core/admin/meta_box_acf.php');
391
+ }
392
+
393
+ // input meta boxes
394
+ if(in_array($GLOBALS['pagenow'], array('post.php', 'post-new.php')) && $GLOBALS['post_type'] != 'acf')
395
+ {
396
+ ?>
397
+ <script type="text/javascript">
398
+ (function($){
399
+
400
+ // add classes
401
+ $('#poststuff .postbox[id*="acf_"]').addClass('acf_postbox');
402
+ $('#adv-settings label[for*="acf_"]').addClass('acf_hide_label');
403
+
404
+ // hide acf stuff
405
+ $('#poststuff .acf_postbox').hide();
406
+ $('#adv-settings .acf_hide_label').hide();
407
+
408
+ // loop through acf metaboxes
409
+ $('#poststuff .postbox.acf_postbox').each(function(){
410
+
411
+ // vars
412
+ var options = $(this).find('.inside > .options');
413
+ var show = options.attr('data-show');
414
+ var layout = options.attr('data-layout');
415
+ var id = $(this).attr('id').replace('acf_', '');
416
+
417
+ // layout
418
+ $(this).addClass('acf_postbox').addClass(layout);
419
+
420
+ // show / hide
421
+ if(show == 'true')
422
+ {
423
+ $(this).show();
424
+ $('#adv-settings .acf_hide_label[for="acf_' + id + '-hide"]').show();
425
+ }
426
+
427
+ });
428
+
429
+ })(jQuery);
430
+ </script>
431
+ <?php
432
+ }
433
 
434
  }
435
 
436
 
437
  /*--------------------------------------------------------------------------------------
438
  *
439
+ * meta_box_fields
440
  *
441
  * @author Elliot Condon
442
  * @since 1.0.0
443
  *
444
  *-------------------------------------------------------------------------------------*/
445
 
446
+ function meta_box_fields()
447
  {
448
+ include('core/admin/meta_box_fields.php');
449
  }
450
+
451
 
452
  /*--------------------------------------------------------------------------------------
453
  *
454
+ * meta_box_location
455
  *
456
  * @author Elliot Condon
457
  * @since 1.0.0
458
  *
459
  *-------------------------------------------------------------------------------------*/
460
 
461
+ function meta_box_location()
462
  {
463
+ include('core/admin/meta_box_location.php');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
464
  }
465
 
466
 
467
  /*--------------------------------------------------------------------------------------
468
  *
469
+ * meta_box_options
470
  *
471
  * @author Elliot Condon
472
  * @since 1.0.0
473
  *
474
  *-------------------------------------------------------------------------------------*/
475
 
476
+ function meta_box_options()
477
  {
478
+ include('core/admin/meta_box_options.php');
 
 
 
 
 
 
479
  }
480
 
481
 
482
  /*--------------------------------------------------------------------------------------
483
  *
484
+ * meta_box_input
485
  *
486
  * @author Elliot Condon
487
  * @since 1.0.0
488
  *
489
  *-------------------------------------------------------------------------------------*/
490
 
491
+ function meta_box_input($post, $args)
492
  {
493
+ include('core/admin/meta_box_input.php');
 
 
 
 
 
 
494
  }
495
 
496
+
497
  /*--------------------------------------------------------------------------------------
498
  *
499
+ * get_acf_fields
500
+ * - returns an array of fields for a acf object
501
  *
502
  * @author Elliot Condon
503
  * @since 1.0.0
504
  *
505
  *-------------------------------------------------------------------------------------*/
506
+
507
+ function get_acf_fields($post_id)
508
  {
509
+ // vars
510
+ $return = array();
511
+ $keys = get_post_custom_keys($post_id);
512
+
513
+ if($keys)
514
+ {
515
+ foreach($keys as $key)
516
+ {
517
+ if(strpos($key, 'field_') !== false)
518
+ {
519
+ $field = $this->get_acf_field($key, $post_id);
520
+
521
+ $return[$field['order_no']] = $field;
522
+ }
523
+ }
524
+
525
+ ksort($return);
526
+ }
527
+ // return fields
528
+ return $return;
529
+
530
  }
531
 
532
 
533
  /*--------------------------------------------------------------------------------------
534
  *
535
+ * get_acf_field
536
+ * - returns a field
537
  *
538
  * @author Elliot Condon
539
  * @since 1.0.0
540
  *
541
  *-------------------------------------------------------------------------------------*/
542
+
543
+ function get_acf_field($field_name, $post_id = false)
544
  {
545
+ $post_id = $post_id ? $post_id : $this->get_post_meta_post_id($field_name);
546
+
547
+ $field = get_post_meta($post_id, $field_name, true);
548
+
549
+ return $field;
550
+
551
  }
552
 
553
 
554
  /*--------------------------------------------------------------------------------------
555
  *
556
+ * get_post_meta_post_id
557
+ * - returns the post_id for a meta_key
558
  *
559
  * @author Elliot Condon
560
  * @since 1.0.0
561
  *
562
  *-------------------------------------------------------------------------------------*/
563
+
564
+ function get_post_meta_post_id($field_name)
565
  {
566
+ global $wpdb;
567
+ $post_id = $wpdb->get_var( $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s", $field_name) );
568
+
569
+ if($post_id) return (int)$post_id;
570
+
571
+ return false;
572
  }
573
 
574
 
575
  /*--------------------------------------------------------------------------------------
576
  *
577
+ * create_field
578
  *
579
  * @author Elliot Condon
580
  * @since 1.0.0
581
  *
582
  *-------------------------------------------------------------------------------------*/
583
 
584
+ function create_field($field)
585
  {
586
+ if(!isset($this->fields[$field['type']]) || !is_object($this->fields[$field['type']]))
587
+ {
588
+ _e('Error: Field Type does not exist!','acf');
589
+ return false;
590
+ }
591
+
592
+ // defaults
593
+ if(!isset($field['class'])) $field['class'] = $field['type'];
594
+
595
+ $this->fields[$field['type']]->create_field($field);
596
  }
597
 
 
 
 
598
 
599
  /*--------------------------------------------------------------------------------------
600
  *
601
+ * get_acf_location
602
  *
603
  * @author Elliot Condon
604
  * @since 1.0.0
605
  *
606
  *-------------------------------------------------------------------------------------*/
607
+
608
+ function get_acf_location($post_id)
609
  {
610
+ // vars
611
+ $return = array(
612
+ 'rules' => array(),
613
+ 'allorany' => get_post_meta($post_id, 'allorany', true) ? get_post_meta($post_id, 'allorany', true) : 'all',
614
+ );
615
+
616
+ // get all fields
617
+ $rules = get_post_meta($post_id, 'rule', false);
 
 
618
 
619
+ if($rules)
 
620
  {
621
+ foreach($rules as $rule)
622
+ {
623
+ $return['rules'][$rule['order_no']] = $rule;
624
+ }
625
  }
626
 
627
+ ksort($return['rules']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
628
 
629
  // return fields
630
+ return $return;
631
+
632
  }
633
+
634
+
635
  /*--------------------------------------------------------------------------------------
636
  *
637
+ * get_acf_options
638
  *
639
  * @author Elliot Condon
640
  * @since 1.0.0
641
  *
642
  *-------------------------------------------------------------------------------------*/
643
 
644
+ function get_acf_options($post_id)
645
  {
646
+ // defaults
647
+ $options = array(
648
+ 'position' => get_post_meta($post_id, 'position', true) ? get_post_meta($post_id, 'position', true) : 'normal',
649
+ 'layout' => get_post_meta($post_id, 'layout', true) ? get_post_meta($post_id, 'layout', true) : 'default',
650
+ 'show_on_page' => get_post_meta($post_id, 'show_on_page', true) ? get_post_meta($post_id, 'show_on_page', true) : array(),
651
+ );
652
 
653
+ // If this is a new acf, there will be no custom keys!
654
+ if(!get_post_custom_keys($post_id))
655
+ {
656
+ $options['show_on_page'] = array('the_content', 'discussion', 'custom_fields', 'comments', 'slug', 'author');
657
+ }
658
+
659
+ // return
660
+ return $options;
 
 
 
 
 
 
661
  }
662
 
663
 
664
  /*--------------------------------------------------------------------------------------
665
  *
666
+ * save_post
667
  *
668
  * @author Elliot Condon
669
  * @since 1.0.0
670
  *
671
  *-------------------------------------------------------------------------------------*/
672
 
673
+ function save_post($post_id)
674
+ {
675
+
676
+ // do not save if this is an auto save routine
677
+ if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return $post_id;
678
 
679
+ // only save once! WordPress save's twice for some strange reason.
680
+ global $flag;
681
+ if ($flag != 0) return $post_id;
682
+ $flag = 1;
683
+
684
+ // set post ID if is a revision
685
+ if(wp_is_post_revision($post_id))
686
+ {
687
+ $post_id = wp_is_post_revision($post_id);
688
+ }
689
+
690
+ // include save files
691
+ if(isset($_POST['save_fields']) && $_POST['save_fields'] == 'true') include('core/actions/save_fields.php');
692
+ if(isset($_POST['save_input']) && $_POST['save_input'] == 'true') include('core/actions/save_input.php');
693
+
694
  }
695
+
696
 
697
  /*--------------------------------------------------------------------------------------
698
  *
699
+ * get_value
700
  *
701
  * @author Elliot Condon
702
+ * @since 3.0.0
703
  *
704
  *-------------------------------------------------------------------------------------*/
705
 
706
+ function get_value($post_id, $field)
707
  {
708
+ if(!isset($this->fields[$field['type']]) || !is_object($this->fields[$field['type']]))
709
+ {
710
+ return '';
711
+ }
712
+
713
+ return $this->fields[$field['type']]->get_value($post_id, $field);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
714
  }
715
+
716
+
717
  /*--------------------------------------------------------------------------------------
718
  *
719
+ * get_value_for_api
720
  *
721
  * @author Elliot Condon
722
+ * @since 3.0.0
723
  *
724
  *-------------------------------------------------------------------------------------*/
725
 
726
+ function get_value_for_api($post_id, $field)
727
  {
728
+ if(!isset($this->fields[$field['type']]) || !is_object($this->fields[$field['type']]))
 
729
  {
730
+ return '';
 
 
731
  }
732
 
733
+ return $this->fields[$field['type']]->get_value_for_api($post_id, $field);
734
+ }
735
+
736
+
737
+ /*--------------------------------------------------------------------------------------
738
+ *
739
+ * update_value
740
+ *
741
+ * @author Elliot Condon
742
+ * @since 3.0.0
743
+ *
744
+ *-------------------------------------------------------------------------------------*/
745
+
746
+ function update_value($post_id, $field, $value)
747
+ {
748
+ $this->fields[$field['type']]->update_value($post_id, $field, $value);
749
+ }
750
+
751
+
752
+ /*--------------------------------------------------------------------------------------
753
+ *
754
+ * update_field
755
+ *
756
+ * @author Elliot Condon
757
+ * @since 3.0.0
758
+ *
759
+ *-------------------------------------------------------------------------------------*/
760
+
761
+ function update_field($post_id, $field)
762
+ {
763
+ // format the field (select, repeater, etc)
764
+ $field = $this->pre_save_field($field);
765
+
766
+ // save it!
767
+ update_post_meta($post_id, $field['key'], $field);
768
  }
769
 
770
 
771
  /*--------------------------------------------------------------------------------------
772
  *
773
+ * pre_save_field
774
+ *
775
+ * @author Elliot Condon
776
+ * @since 3.0.0
777
+ *
778
+ *-------------------------------------------------------------------------------------*/
779
+
780
+ function pre_save_field($field)
781
+ {
782
+ // format the field (select, repeater, etc)
783
+ return $this->fields[$field['type']]->pre_save_field($field);
784
+ }
785
+
786
+
787
+ /*--------------------------------------------------------------------------------------
788
+ *
789
+ * format_value_for_input
790
+ *
791
+ * @author Elliot Condon
792
+ * @since 3.0.0
793
+ *
794
+ *-------------------------------------------------------------------------------------*/
795
+
796
+ //function format_value_for_input($value, $field)
797
+ //{
798
+ // return $this->fields[$field['type']]->format_value_for_input($value, $field);
799
+ //}
800
+
801
+
802
+ /*--------------------------------------------------------------------------------------
803
+ *
804
+ * format_value_for_api
805
  *
806
  * @author Elliot Condon
807
+ * @since 3.0.0
808
  *
809
  *-------------------------------------------------------------------------------------*/
810
 
811
+ function format_value_for_api($value, $field)
812
  {
813
+ if(!isset($this))
814
  {
815
+ // called form api!
816
+
817
  }
818
  else
819
  {
820
+ // called from object
821
  }
822
+ return $this->fields[$field['type']]->format_value_for_api($value, $field);
823
  }
824
+
825
+
826
  /*--------------------------------------------------------------------------------------
827
  *
828
+ * create_format_data
829
  *
830
  * @author Elliot Condon
831
+ * @since 3.0.0
832
  *
833
  *-------------------------------------------------------------------------------------*/
834
+
835
+ function create_format_data($field)
836
  {
837
+ return $this->fields[$field['type']]->create_format_data($field);
838
+ }
839
+
840
+
841
+ /*--------------------------------------------------------------------------------------
842
+ *
843
+ * get_input_metabox_ids
844
+ * - called by function.fields to hide / show metaboxes
845
+ *
846
+ * @author Elliot Condon
847
+ * @since 2.0.5
848
+ *
849
+ *-------------------------------------------------------------------------------------*/
850
+
851
+ function get_input_metabox_ids($overrides = array(), $json = true)
852
+ {
853
+ // overrides
854
+ if(isset($_POST))
855
  {
856
+ if(isset($_POST['post_id']) && $_POST['post_id'] != 'false') $overrides['post_id'] = $_POST['post_id'];
857
+ if(isset($_POST['page_template']) && $_POST['page_template'] != 'false') $overrides['page_template'] = $_POST['page_template'];
858
+ if(isset($_POST['page_parent']) && $_POST['page_parent'] != 'false') $overrides['page_parent'] = $_POST['page_parent'];
859
+ if(isset($_POST['page_type']) && $_POST['page_type'] != 'false') $overrides['page_type'] = $_POST['page_type'];
860
+ if(isset($_POST['page']) && $_POST['page'] != 'false') $overrides['page'] = $_POST['page'];
861
+ if(isset($_POST['post']) && $_POST['post'] != 'false') $overrides['post'] = $_POST['post'];
862
+ if(isset($_POST['post_category']) && $_POST['post_category'] != 'false') $overrides['post_category'] = $_POST['post_category'];
863
+ if(isset($_POST['post_format']) && $_POST['post_format'] != 'false') $overrides['post_format'] = $_POST['post_format'];
864
+ if(isset($_POST['taxonomy']) && $_POST['taxonomy'] != 'false') $overrides['taxonomy'] = $_POST['taxonomy'];
865
  }
866
+
867
+ // create post object to match against
868
+ $post = isset($overrides['post_id']) ? get_post($_POST['post_id']) : false;
869
+
870
+ // find all acf objects
871
+ $acfs = get_pages(array(
872
+ 'numberposts' => -1,
873
+ 'post_type' => 'acf',
874
+ 'sort_column' => 'menu_order',
875
+ ));
876
+
877
+ // blank array to hold acfs
878
+ $return = array();
879
+
880
+ if($acfs)
881
  {
882
+
883
+ foreach($acfs as $acf)
 
 
 
 
 
 
 
 
 
884
  {
885
+ $add_box = false;
886
+ $location = $this->get_acf_location($acf->ID);
887
+
888
+ if($location['allorany'] == 'all')
889
  {
890
+ // ALL
891
+ $add_box = true;
892
+
893
+ if($location['rules'])
894
+ {
895
+ foreach($location['rules'] as $rule)
896
+ {
897
+
898
+ // if any rules dont return true, dont add this acf
899
+ if(!$this->match_location_rule($post, $rule, $overrides))
900
+ {
901
+ $add_box = false;
902
+ }
903
+ }
904
+ }
905
+
906
  }
907
+ elseif($location['allorany'] == 'any')
 
 
 
 
 
 
 
 
908
  {
909
+ // ANY
910
+
911
+ $add_box = false;
912
+
913
+ if($location['rules'])
914
  {
915
+ foreach($location['rules'] as $rule)
916
+ {
917
+ // if any rules return true, add this acf
918
+ if($this->match_location_rule($post, $rule, $overrides))
919
+ {
920
+ $add_box = true;
921
+ }
922
+ }
923
  }
 
924
  }
925
+
926
+ if($add_box == true)
927
+ {
928
+ $return[] = $acf->ID;
929
+ }
930
 
931
  }
932
  }
933
 
934
+ if($json)
935
+ {
936
+ echo json_encode($return);
937
+ die;
938
+ }
939
+ else
940
+ {
941
+ return $return;
942
+ }
943
+
944
 
 
 
945
  }
946
 
 
947
 
948
  /*--------------------------------------------------------------------------------------
949
  *
950
+ * get_input_style
951
+ * - called by function.fields to hide / show other metaboxes
952
+ *
953
  * @author Elliot Condon
954
+ * @since 2.0.5
955
  *
956
  *-------------------------------------------------------------------------------------*/
957
+
958
+ function get_input_style($acf_id = false)
959
  {
960
+ // get field group options
961
+ $options = $this->get_acf_options($acf_id);
962
+ $html = "";
963
 
964
+ // html
965
+ if(!in_array('the_content',$options['show_on_page']))
966
  {
967
+ $html .= '#postdivrich {display: none;} ';
968
  }
969
+ if(!in_array('custom_fields',$options['show_on_page']))
970
  {
971
+ $html .= '#postcustom, #screen-meta label[for=postcustom-hide] { display: none; } ';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
972
  }
973
+ if(!in_array('discussion',$options['show_on_page']))
974
+ {
975
+ $html .= '#commentstatusdiv, #screen-meta label[for=commentstatusdiv-hide] {display: none;} ';
976
+ }
977
+ if(!in_array('comments',$options['show_on_page']))
978
+ {
979
+ $html .= '#commentsdiv, #screen-meta label[for=commentsdiv-hide] {display: none;} ';
980
+ }
981
+ if(!in_array('slug',$options['show_on_page']))
982
+ {
983
+ $html .= '#slugdiv, #screen-meta label[for=slugdiv-hide] {display: none;} ';
984
+ }
985
+ if(!in_array('author',$options['show_on_page']))
986
  {
987
+ $html .= '#authordiv, #screen-meta label[for=authordiv-hide] {display: none;} ';
988
  }
989
 
990
+ return $html;
991
 
 
 
992
  }
993
+
994
 
995
  /*--------------------------------------------------------------------------------------
996
  *
997
+ * the_input_style
998
+ * - called by function.fields to hide / show other metaboxes
999
+ *
1000
  * @author Elliot Condon
1001
+ * @since 2.0.5
1002
  *
1003
  *-------------------------------------------------------------------------------------*/
1004
+
1005
+ function the_input_style()
1006
  {
1007
+ // overrides
1008
+ if(isset($_POST['acf_id']))
 
 
1009
  {
1010
+ echo $this->get_input_style($_POST['acf_id']);
 
 
 
 
1011
  }
1012
 
1013
+ die;
1014
 
 
 
 
 
 
 
 
 
 
 
 
1015
  }
1016
 
1017
 
1026
 
1027
  function match_location_rule($post, $rule, $overrides = array())
1028
  {
1029
+
1030
+ if(!$post)
1031
+ {
1032
+ // post is false! that's okay if the rule is for user_type or options_page
1033
+ if($rule['param'] != 'user_type' && $rule['param'] != 'options_page')
1034
+ {
1035
+ return false;
1036
+ }
1037
+ }
1038
+
1039
+
1040
 
1041
+
1042
+ switch ($rule['param']) {
1043
 
1044
  // POST TYPE
1045
  case "post_type":
1046
 
1047
  $post_type = isset($overrides['post_type']) ? $overrides['post_type'] : get_post_type($post);
1048
 
1049
+ if($rule['operator'] == "==")
1050
  {
1051
+ if($post_type == $rule['value'])
1052
  {
1053
  return true;
1054
  }
1055
 
1056
  return false;
1057
  }
1058
+ elseif($rule['operator'] == "!=")
1059
  {
1060
+ if($post_type != $rule['value'])
1061
  {
1062
  return true;
1063
  }
1072
 
1073
  $page = isset($overrides['page']) ? $overrides['page'] : $post->ID;
1074
 
1075
+ if($rule['operator'] == "==")
1076
  {
1077
+ if($page == $rule['value'])
1078
  {
1079
  return true;
1080
  }
1081
 
1082
  return false;
1083
  }
1084
+ elseif($rule['operator'] == "!=")
1085
  {
1086
+ if($page != $rule['value'])
1087
  {
1088
  return true;
1089
  }
1098
 
1099
  $page_type = isset($overrides['page_type']) ? $overrides['page_type'] : $post->post_parent;
1100
 
1101
+ if($rule['operator'] == "==")
1102
  {
1103
+ if($rule['value'] == "parent" && $page_type == "0")
1104
  {
1105
  return true;
1106
  }
1107
 
1108
+ if($rule['value'] == "child" && $page_type != "0")
1109
  {
1110
  return true;
1111
  }
1112
 
1113
  return false;
1114
  }
1115
+ elseif($rule['operator'] == "!=")
1116
  {
1117
+ if($rule['value'] == "parent" && $page_type != "0")
1118
  {
1119
  return true;
1120
  }
1121
 
1122
+ if($rule['value'] == "child" && $page_type == "0")
1123
  {
1124
  return true;
1125
  }
1134
 
1135
  $page_parent = isset($overrides['page_parent']) ? $overrides['page_parent'] : $post->post_parent;
1136
 
1137
+ if($rule['operator'] == "==")
1138
  {
1139
+ if($page_parent == $rule['value'])
1140
  {
1141
  return true;
1142
  }
1144
  return false;
1145
 
1146
  }
1147
+ elseif($rule['operator'] == "!=")
1148
  {
1149
+ if($page_parent != $rule['value'])
1150
  {
1151
  return true;
1152
  }
1161
 
1162
  $page_template = isset($overrides['page_template']) ? $overrides['page_template'] : get_post_meta($post->ID,'_wp_page_template',true);
1163
 
1164
+ if($rule['operator'] == "==")
1165
  {
1166
+ if($page_template == $rule['value'])
1167
  {
1168
  return true;
1169
  }
1170
 
1171
+ if($rule['value'] == "default" && !$page_template)
1172
  {
1173
  return true;
1174
  }
1175
 
1176
  return false;
1177
  }
1178
+ elseif($rule['operator'] == "!=")
1179
  {
1180
+ if($page_template != $rule['value'])
1181
  {
1182
  return true;
1183
  }
1192
 
1193
  $post_id = isset($overrides['post']) ? $overrides['post'] : $post->ID;
1194
 
1195
+ if($rule['operator'] == "==")
1196
  {
1197
+ if($post_id == $rule['value'])
1198
  {
1199
  return true;
1200
  }
1201
 
1202
  return false;
1203
  }
1204
+ elseif($rule['operator'] == "!=")
1205
  {
1206
+ if($post_id != $rule['value'])
1207
  {
1208
  return true;
1209
  }
1230
  $cats[] = $cat->term_id;
1231
  }
1232
  }
1233
+ if($rule['operator'] == "==")
 
1234
  {
1235
  if($cats)
1236
  {
1237
+ if(in_array($rule['value'], $cats))
1238
  {
1239
  return true;
1240
  }
1242
 
1243
  return false;
1244
  }
1245
+ elseif($rule['operator'] == "!=")
1246
  {
1247
  if($cats)
1248
  {
1249
+ if(!in_array($rule['value'], $cats))
1250
  {
1251
  return true;
1252
  }
1263
 
1264
  $post_format = isset($overrides['post_format']) ? $overrides['post_format'] : get_post_format();
1265
 
1266
+ if($rule['operator'] == "==")
1267
  {
1268
+ if($post_format == $rule['value'])
1269
  {
1270
  return true;
1271
  }
1275
  }
1276
  elseif($post_format == "!=")
1277
  {
1278
+ if($post->post_parent != $rule['value'])
1279
  {
1280
  return true;
1281
  }
1289
  // USER TYPE
1290
  case "user_type":
1291
 
1292
+ if($rule['operator'] == "==")
1293
  {
1294
+ if(current_user_can($rule['value']))
1295
  {
1296
  return true;
1297
  }
1298
 
1299
  return false;
1300
  }
1301
+ elseif($rule['operator'] == "!=")
1302
  {
1303
+ if(!current_user_can($rule['value']))
1304
  {
1305
  return true;
1306
  }
1314
  case "options_page":
1315
 
1316
 
1317
+ if($rule['operator'] == "==")
1318
  {
1319
+ if(get_admin_page_title() == $rule['value'])
1320
  {
1321
  return true;
1322
  }
1323
 
1324
  return false;
1325
  }
1326
+ elseif($rule['operator'] == "!=")
1327
  {
1328
+ if(get_admin_page_title() != $rule['value'])
1329
  {
1330
  return true;
1331
  }
1340
  case "post_format":
1341
 
1342
 
1343
+ $post_format = isset($overrides['post_format']) ? has_post_format($overrides['post_format'],$post->ID) : has_post_format($rule['value'],$post->ID);
1344
 
1345
+ if($rule['operator'] == "==")
1346
  {
1347
  if($post_format)
1348
  {
1351
 
1352
  return false;
1353
  }
1354
+ elseif($rule['operator'] == "!=")
1355
  {
1356
  if(!$post_format)
1357
  {
1363
 
1364
  break;
1365
 
1366
+ // Taxonomy
1367
+ case "taxonomy":
1368
+
1369
+ $terms = array();
1370
 
1371
+ if(isset($overrides['taxonomy']))
1372
+ {
1373
+ $terms = $overrides['taxonomy'];
1374
+ }
1375
+ else
1376
+ {
1377
+ $taxonomies = get_object_taxonomies($post->post_type);
1378
+ if($taxonomies)
1379
+ {
1380
+ foreach($taxonomies as $tax)
1381
+ {
1382
+ $all_terms = get_the_terms($post->ID, $tax);
1383
+ if($all_terms)
1384
+ {
1385
+ foreach($all_terms as $all_term)
1386
+ {
1387
+ $terms[] = $all_term->term_id;
1388
+ }
1389
+ }
1390
+ }
1391
+ }
1392
+ }
1393
+
1394
+ if($rule['operator'] == "==")
1395
+ {
1396
+ if($terms)
1397
+ {
1398
+ if(in_array($rule['value'], $terms))
1399
+ {
1400
+ return true;
1401
+ }
1402
+ }
1403
+
1404
+ return false;
1405
+ }
1406
+ elseif($rule['operator'] == "!=")
1407
+ {
1408
+ if($terms)
1409
+ {
1410
+ if(!in_array($rule['value'], $terms))
1411
+ {
1412
+ return true;
1413
+ }
1414
+ }
1415
+
1416
+ return false;
1417
+ }
1418
+
1419
+
1420
+ break;
1421
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1422
  }
1423
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1424
  }
1425
 
1426
 
 
1427
  /*--------------------------------------------------------------------------------------
1428
  *
1429
+ * is_field_unlocked
1430
  *
1431
  * @author Elliot Condon
1432
+ * @since 3.0.0
1433
  *
1434
  *-------------------------------------------------------------------------------------*/
1435
 
1436
+ function is_field_unlocked($field_name)
1437
  {
1438
+ switch ($field_name) {
1439
+ case 'repeater':
1440
+ if(md5($this->get_license_key($field_name)) == "bbefed143f1ec106ff3a11437bd73432"){ return true; }else{ return false; }
1441
+ break;
1442
+ case 'options_page':
1443
+ if(md5($this->get_license_key($field_name)) == "1fc8b993548891dc2b9a63ac057935d8"){ return true; }else{ return false; }
1444
+ break;
1445
+ }
1446
  }
1447
 
 
1448
  /*--------------------------------------------------------------------------------------
1449
  *
1450
+ * is_field_unlocked
1451
  *
1452
  * @author Elliot Condon
1453
+ * @since 3.0.0
1454
  *
1455
  *-------------------------------------------------------------------------------------*/
1456
 
1457
+ function get_license_key($field_name)
1458
  {
1459
+ return get_option('acf_' . $field_name . '_ac');
 
 
 
 
 
 
 
 
1460
  }
1461
 
1462
 
1469
  *
1470
  *-------------------------------------------------------------------------------------*/
1471
 
1472
+ function admin_message($message = "", $type = 'updated')
1473
  {
1474
+ $GLOBALS['acf_mesage'] = $message;
1475
+ $GLOBALS['acf_mesage_type'] = $type;
1476
 
1477
  function my_admin_notice()
1478
  {
1479
+ echo '<div class="' . $GLOBALS['acf_mesage_type'] . '" id="message">'.$GLOBALS['acf_mesage'].'</div>';
 
1480
  }
1481
  add_action('admin_notices', 'my_admin_notice');
1482
  }
1483
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1484
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1485
 
1486
+ }
1487
+ ?>
core/actions/admin_head.php DELETED
@@ -1,55 +0,0 @@
1
- <?php
2
-
3
- global $post;
4
-
5
-
6
- /*----------------------------------------------------------------------
7
- *
8
- * Add Post Boxes
9
- *
10
- *---------------------------------------------------------------------*/
11
-
12
- if(in_array($GLOBALS['pagenow'], array('post.php', 'post-new.php')))
13
- {
14
-
15
- if($GLOBALS['post_type'] == 'acf')
16
- {
17
- echo '<script type="text/javascript" src="'.$this->dir.'/js/functions.fields.js" ></script>';
18
- echo '<script type="text/javascript" src="'.$this->dir.'/js/functions.location.js" ></script>';
19
-
20
- echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/style.global.css" />';
21
- echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/style.fields.css" />';
22
- echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/style.location.css" />';
23
- echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/style.options.css" />';
24
-
25
- add_meta_box('acf_fields', 'Fields', array($this, '_fields_meta_box'), 'acf', 'normal', 'high');
26
- add_meta_box('acf_location', 'Location </span><span class="description">- Add Fields to Edit Screens', array($this, '_location_meta_box'), 'acf', 'normal', 'high');
27
- add_meta_box('acf_options', 'Advanced Options</span><span class="description">- Customise the edit page', array($this, '_options_meta_box'), 'acf', 'normal', 'high');
28
-
29
- }
30
- else
31
- {
32
- // find post type and add wysiwyg support
33
- $post_type = get_post_type($post);
34
- if(!post_type_supports($post_type, 'editor'))
35
- {
36
- wp_tiny_mce();
37
- }
38
-
39
- // add css + javascript
40
- echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/style.global.css" />';
41
- echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/style.input.css" />';
42
- echo '<script type="text/javascript" src="'.$this->dir.'/js/functions.input.js" ></script>';
43
-
44
- // add datepicker
45
- echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/core/fields/date_picker/style.date_picker.css" />';
46
- echo '<script type="text/javascript" src="'.$this->dir.'/core/fields/date_picker/jquery.ui.datepicker.js" ></script>';
47
-
48
- // add meta box
49
- add_meta_box('acf_input', 'ACF Fields', array($this, 'input_meta_box'), $post_type, 'normal', 'high');
50
-
51
- }
52
- }
53
-
54
-
55
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
core/actions/fields_save.php DELETED
@@ -1,94 +0,0 @@
1
- <?php
2
- /*---------------------------------------------------------------------------------------------
3
- Save Fields Meta Box
4
- ---------------------------------------------------------------------------------------------*/
5
- if(isset($_POST['fields_meta_box']) && $_POST['fields_meta_box'] == 'true')
6
- {
7
-
8
- // set table name
9
- global $wpdb;
10
- $table_name = $wpdb->prefix.'acf_fields';
11
-
12
-
13
- // remove all old fields from the database
14
- $wpdb->query("DELETE FROM $table_name WHERE post_id = '$post_id'");
15
-
16
-
17
- // loop through fields and save them
18
- $i = 0;
19
- foreach($_POST['acf']['fields'] as $key => $field)
20
- {
21
-
22
- if($key == 999)
23
- {
24
- continue;
25
- }
26
-
27
-
28
- // defaults
29
- if(!isset($field['label'])) { $field['label'] = ""; }
30
- if(!isset($field['name'])) { $field['label'] = ""; }
31
- if(!isset($field['type'])) { $field['label'] = "text"; }
32
- if(!isset($field['options'])) { $field['options'] = array(); }
33
- if(!isset($field['instructions'])) { $field['instructions'] = ""; }
34
- if(!isset($field['default_value'])) { $field['default_value'] = ""; }
35
-
36
-
37
- // clean field
38
- $field = stripslashes_deep($field);
39
-
40
-
41
- // format options if needed
42
- if($this->field_method_exists($field['type'], 'format_options'))
43
- {
44
- $field['options'] = $this->fields[$field['type']]->format_options($field['options']);
45
- }
46
-
47
-
48
- // create data
49
- $data = array(
50
- 'order_no' => $i,
51
- 'post_id' => $post_id,
52
- 'label' => $field['label'],
53
- 'name' => $field['name'],
54
- 'type' => $field['type'],
55
- 'options' => serialize($field['options']),
56
- 'instructions' => $field['instructions'],
57
- 'default_value' => $field['default_value'],
58
- );
59
-
60
-
61
- // if there is an id, this field already exists, so save it in the same ID spot
62
- if($field['id'])
63
- {
64
- $data['id'] = (int) $field['id'];
65
- }
66
-
67
-
68
- // save field as row in database
69
- $wpdb->insert($table_name, $data);
70
-
71
-
72
- // save field if needed (used to save sub fields)
73
- if($this->field_method_exists($field['type'], 'save_field'))
74
- {
75
- if($field['id'])
76
- {
77
- $parent_id = $field['id'];
78
- }
79
- else
80
- {
81
- $parent_id = $wpdb->insert_id;
82
- }
83
-
84
-
85
- $this->fields[$field['type']]->save_field($post_id, $parent_id, $field);
86
- }
87
-
88
-
89
- // increase order_no
90
- $i++;
91
- }
92
- }
93
-
94
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
core/actions/init.php CHANGED
@@ -1,162 +1,93 @@
1
  <?php
2
 
3
- /*----------------------------------------------------------------------
4
- *
5
- * upgrade
6
- *
7
- *---------------------------------------------------------------------*/
8
-
9
- $version = get_option('acf_version','1.0.5');
10
 
11
- if(isset($_POST['acf_upgrade']))
12
- {
13
- $this->upgrade();
14
- }
15
- else
16
  {
17
- // if current version is less than the latest upgrade version, show the upgrade message
18
  if(version_compare($version,$this->upgrade_version) < 0)
19
  {
20
- global $acf_temp_mesage;
21
- $acf_temp_mesage = '<form method="post"><p>Advanced Custom Fields v' . $this->version . ' requires a database upgrade. Please <a href="http://codex.wordpress.org/Backing_Up_Your_Database">backup your database</a> then click <input type="submit" class="button" name="acf_upgrade" value="Upgrade Database" /></p></form>';
22
 
23
- function my_temp_notice()
24
- {
25
- global $acf_temp_mesage;
26
- echo '<div class="updated" id="message">'.$acf_temp_mesage.'</div>';
27
- }
28
- add_action('admin_notices', 'my_temp_notice');
29
- }
30
- elseif($version != $this->version)
31
- {
32
- update_option('acf_version',$this->version);
33
  }
34
  }
 
 
 
 
35
 
36
-
37
-
38
-
39
-
40
-
41
-
42
- /*----------------------------------------------------------------------
43
- *
44
- * deactivate_field
45
- *
46
- *---------------------------------------------------------------------*/
47
-
48
  if(isset($_POST['acf_field_deactivate']))
49
  {
50
- // delete field
 
51
  $field = $_POST['acf_field_deactivate'];
52
- $option = 'acf_'.$field.'_ac';
53
- delete_option($option);
54
-
55
-
56
- // update activated fields
57
- $this->activated_fields = $this->get_activated_fields();
58
- $this->fields = $this->get_field_types();
59
 
 
 
60
 
61
  //set message
62
- $acf_message_field = "";
63
  if($field == "repeater")
64
  {
65
- $acf_message_field = "Repeater Field";
66
  }
67
  elseif($field == "options_page")
68
  {
69
- $acf_message_field = "Options Page";
70
  }
71
 
72
-
73
  // show message on page
74
- $this->admin_message($acf_message_field.' deactivated');
75
-
76
  }
77
 
78
 
79
-
80
- /*----------------------------------------------------------------------
81
- *
82
- * activate_field
83
- *
84
- *---------------------------------------------------------------------*/
85
-
86
- if(isset($_POST['acf_field_activate']) && isset($_POST['acf_ac']))
87
  {
88
-
 
89
  $field = $_POST['acf_field_activate'];
90
- $ac = $_POST['acf_ac'];
91
-
92
-
93
  // update option
94
- $option = 'acf_'.$field.'_ac';
95
- update_option($option, $ac);
96
-
97
-
98
- // update activated fields
99
- $old_count = count($this->activated_fields);
100
- $this->activated_fields = $this->get_activated_fields();
101
- $this->fields = $this->get_field_types();
102
- $new_count = count($this->activated_fields);
103
-
104
-
105
- // set message
106
- global $acf_message_field;
107
- $acf_message_field = "";
108
- if($field == "repeater")
109
- {
110
- $acf_message_field = "Repeater Field activated";
111
- }
112
- elseif($field == "options_page")
113
- {
114
- $acf_message_field = "Options Page activated";
115
- }
116
-
117
 
118
- // show message
119
- if($new_count == $old_count)
120
  {
121
- $this->admin_message('Activation code unrecognized');
 
 
 
 
 
 
 
 
 
 
122
  }
123
  else
124
  {
125
- $this->admin_message($acf_message_field);
126
- }
127
-
128
  }
129
 
130
-
131
-
132
- /*--------------------------------------------------------------------------------------
133
- *
134
- * Create Post Type
135
- *
136
- * @author Elliot Condon
137
- * @since 1.0.6
138
- *
139
- *-------------------------------------------------------------------------------------*/
140
-
141
  $labels = array(
142
  'name' => __( 'Advanced&nbsp;Custom&nbsp;Fields', 'acf' ),
143
  'singular_name' => __( 'Advanced Custom Fields', 'acf' ),
144
  'add_new' => __( 'Add New' , 'acf' ),
145
- 'add_new_item' => __( 'Add New Advanced Custom Field Group' , 'acf' ),
146
- 'edit_item' => __( 'Edit Advanced Custom Field Group' , 'acf' ),
147
- 'new_item' => __( 'New Advanced Custom Field Group' , 'acf' ),
148
- 'view_item' => __('View Advanced Custom Field Group'),
149
- 'search_items' => __('Search Advanced Custom Field Groups'),
150
- 'not_found' => __('No Advanced Custom Field Groups found'),
151
- 'not_found_in_trash' => __('No Advanced Custom Field Groups found in Trash'),
152
- );
153
-
154
-
155
- $supports = array(
156
- 'title',
157
- //'revisions',
158
- //'custom-fields',
159
- 'page-attributes'
160
  );
161
 
162
  register_post_type('acf', array(
@@ -166,22 +97,15 @@ register_post_type('acf', array(
166
  '_builtin' => false,
167
  'capability_type' => 'page',
168
  'hierarchical' => true,
169
- 'rewrite' => array("slug" => "acf"),
170
  'query_var' => "acf",
171
- 'supports' => $supports,
172
- 'show_in_menu' =>false,
 
 
173
  ));
174
 
175
-
176
- /*--------------------------------------------------------------------------------------
177
- *
178
- * Custom Columns
179
- *
180
- * @author Elliot Condon
181
- * @since 2.1.0
182
- *
183
- *-------------------------------------------------------------------------------------*/
184
-
185
  function acf_columns_filter($columns)
186
  {
187
  $columns = array(
@@ -192,5 +116,4 @@ function acf_columns_filter($columns)
192
  }
193
 
194
  add_filter("manage_edit-acf_columns", "acf_columns_filter");
195
-
196
  ?>
1
  <?php
2
 
3
+ // setup fields
4
+ $this->setup_fields();
5
+
6
+ // upgrade
7
+ $version = get_option('acf_version', false);
 
 
8
 
9
+ if($version)
 
 
 
 
10
  {
 
11
  if(version_compare($version,$this->upgrade_version) < 0)
12
  {
13
+ $this->admin_message('<p>Advanced Custom Fields v' . $this->version . ' requires a database upgrade. Please <a href="http://codex.wordpress.org/Backing_Up_Your_Database">backup your database</a> then click <a href="' . admin_url() . 'options-general.php?page=acf-upgrade" class="button">Upgrade Database</a></p>');
 
14
 
 
 
 
 
 
 
 
 
 
 
15
  }
16
  }
17
+ else
18
+ {
19
+ update_option('acf_version', $this->version );
20
+ }
21
 
22
+ // deactivate field
 
 
 
 
 
 
 
 
 
 
 
23
  if(isset($_POST['acf_field_deactivate']))
24
  {
25
+ // vars
26
+ $message = "";
27
  $field = $_POST['acf_field_deactivate'];
 
 
 
 
 
 
 
28
 
29
+ // delete field
30
+ delete_option('acf_'.$field.'_ac');
31
 
32
  //set message
 
33
  if($field == "repeater")
34
  {
35
+ $message = "<p>Repeater field deactivated</p>";
36
  }
37
  elseif($field == "options_page")
38
  {
39
+ $message = "<p>Options page deactivated</p>";
40
  }
41
 
 
42
  // show message on page
43
+ $this->admin_message($message);
 
44
  }
45
 
46
 
47
+ // activate field
48
+ if(isset($_POST['acf_field_activate']) && isset($_POST['key']))
 
 
 
 
 
 
49
  {
50
+ // vars
51
+ $message = "";
52
  $field = $_POST['acf_field_activate'];
53
+ $key = trim($_POST['key']);
54
+
 
55
  // update option
56
+ update_option('acf_'.$field.'_ac', $key);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
 
58
+ // did it unlock?
59
+ if($this->is_field_unlocked($field))
60
  {
61
+ //set message
62
+ if($field == "repeater")
63
+ {
64
+ $message = "<p>Repeater field activated</p>";
65
+ }
66
+ elseif($field == "options_page")
67
+ {
68
+ $message = "<p>Options page activated</p>";
69
+ }
70
+
71
+ $this->admin_message($message);
72
  }
73
  else
74
  {
75
+ $this->admin_message('<p>License key unrecognised</p>', 'error');
76
+ }
 
77
  }
78
 
79
+ // create acf post type
 
 
 
 
 
 
 
 
 
 
80
  $labels = array(
81
  'name' => __( 'Advanced&nbsp;Custom&nbsp;Fields', 'acf' ),
82
  'singular_name' => __( 'Advanced Custom Fields', 'acf' ),
83
  'add_new' => __( 'Add New' , 'acf' ),
84
+ 'add_new_item' => __( 'Add New Field Group' , 'acf' ),
85
+ 'edit_item' => __( 'Edit Field Group' , 'acf' ),
86
+ 'new_item' => __( 'New Field Group' , 'acf' ),
87
+ 'view_item' => __('View Field Group'),
88
+ 'search_items' => __('Search Field Groups'),
89
+ 'not_found' => __('No Field Groups found'),
90
+ 'not_found_in_trash' => __('No Field Groups found in Trash'),
 
 
 
 
 
 
 
 
91
  );
92
 
93
  register_post_type('acf', array(
97
  '_builtin' => false,
98
  'capability_type' => 'page',
99
  'hierarchical' => true,
100
+ 'rewrite' => false,
101
  'query_var' => "acf",
102
+ 'supports' => array(
103
+ 'title',
104
+ ),
105
+ 'show_in_menu' => false,
106
  ));
107
 
108
+ // set custom columns for acf post type
 
 
 
 
 
 
 
 
 
109
  function acf_columns_filter($columns)
110
  {
111
  $columns = array(
116
  }
117
 
118
  add_filter("manage_edit-acf_columns", "acf_columns_filter");
 
119
  ?>
core/actions/input_save.php DELETED
@@ -1,101 +0,0 @@
1
- <?php
2
- /*---------------------------------------------------------------------------------------------
3
- Fields Meta Box
4
- ---------------------------------------------------------------------------------------------*/
5
- if(isset($_POST['input_meta_box']) && $_POST['input_meta_box'] == 'true')
6
- {
7
-
8
- // If acf was not posted, don't go any further
9
- if(!isset($_POST['acf']))
10
- {
11
- return true;
12
- }
13
-
14
-
15
- // tables
16
- global $wpdb;
17
- $acf_values = $wpdb->prefix.'acf_values';
18
- $wp_postmeta = $wpdb->prefix.'postmeta';
19
-
20
-
21
- // delete old data
22
- $values = $wpdb->get_results("SELECT v.id, m.meta_id FROM $acf_values v LEFT JOIN $wp_postmeta m ON v.value = m.meta_id WHERE v.post_id = '$post_id'");
23
- if($values)
24
- {
25
- foreach($values as $value)
26
- {
27
- $wpdb->query("DELETE FROM $acf_values WHERE id = '$value->id'");
28
- $wpdb->query("DELETE FROM $wp_postmeta WHERE meta_id = '$value->meta_id'");
29
- }
30
- }
31
-
32
- // add the new values to the database
33
- foreach($_POST['acf'] as $field)
34
- {
35
-
36
- // remove all old values from the database
37
- $field_id = $field['field_id'];
38
-
39
-
40
- if(method_exists($this->fields[$field['field_type']], 'save_input'))
41
- {
42
- $this->fields[$field['field_type']]->save_input($post_id, $field);
43
- }
44
- else
45
- {
46
- //$field = apply_filters('wp_insert_post_data', $field);
47
- $field = stripslashes_deep( $field );
48
-
49
-
50
- // if select is a multiple (multiple select value), you need to save it as an array!
51
- if(is_array($field['value']))
52
- {
53
- $field['value'] = serialize($field['value']);
54
- }
55
-
56
-
57
- // create data: wp_postmeta
58
- $data1 = array(
59
- 'meta_id' => null,
60
- 'post_id' => $post_id,
61
- 'meta_key' => $field['field_name'],
62
- 'meta_value' => $field['value']
63
- );
64
- if(isset($field['meta_id']) && !empty($field['meta_id']))
65
- {
66
- $data1['meta_id'] = $field['meta_id'];
67
- }
68
-
69
- $wpdb->insert($wp_postmeta, $data1);
70
-
71
- $new_id = $wpdb->insert_id;
72
-
73
- // create data: acf_values
74
- if($new_id && $new_id != 0)
75
- {
76
-
77
- $data2 = array(
78
- 'id' => null,
79
- 'post_id' => $post_id,
80
- 'field_id' => $field['field_id'],
81
- 'value' => $new_id,
82
- );
83
- if(isset($field['value_id']) && !empty($field['value_id']))
84
- {
85
- $data2['id'] = $field['value_id'];
86
- }
87
-
88
- $wpdb->insert($acf_values, $data2);
89
-
90
- }
91
-
92
- }
93
-
94
-
95
- }
96
- //foreach($_POST['acf'] as $field)
97
-
98
-
99
- }
100
-
101
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
core/actions/location_save.php DELETED
@@ -1,45 +0,0 @@
1
- <?php
2
- /*---------------------------------------------------------------------------------------------
3
- Fields Meta Box
4
- ---------------------------------------------------------------------------------------------*/
5
- if(isset($_POST['location_meta_box']) && $_POST['location_meta_box'] == 'true')
6
- {
7
-
8
- global $wpdb;
9
- $table_name = $wpdb->prefix.'acf_rules';
10
-
11
-
12
- // remove all old fields from the database
13
- $wpdb->query("DELETE FROM $table_name WHERE acf_id = '$post_id'");
14
-
15
-
16
- // turn inputs into database friendly data
17
- $rules = $_POST['acf']['location']['rules'];
18
- $allorany = $_POST['acf']['location']['allorany'];
19
-
20
- update_post_meta($post_id, 'allorany', $allorany);
21
-
22
- if($rules)
23
- {
24
- foreach($rules as $k => $rule)
25
- {
26
- $data = array(
27
- 'acf_id' => $post_id,
28
- 'order_no' => $k,
29
- 'param' => $rule['param'],
30
- 'operator' => $rule['operator'],
31
- 'value' => $rule['value']
32
- );
33
-
34
- if(isset($rule['id']))
35
- {
36
- $data['id'] = $rule['id'];
37
- }
38
-
39
- $wpdb->insert($table_name, $data);
40
- }
41
- }
42
-
43
- }
44
-
45
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
core/actions/options_save.php DELETED
@@ -1,19 +0,0 @@
1
- <?php
2
- /*---------------------------------------------------------------------------------------------
3
- Fields Meta Box
4
- ---------------------------------------------------------------------------------------------*/
5
- if(isset($_POST['options_meta_box']) && $_POST['options_meta_box'] == 'true')
6
- {
7
-
8
- // turn inputs into database friendly data
9
- $options = $_POST['acf']['options'];
10
-
11
- if(!isset($options['show_on_page'])) { $options['show_on_page'] = array(); }
12
- if(!isset($options['field_group_layout'])) { $options['field_group_layout'] = 'default'; }
13
-
14
- update_post_meta($post_id, 'show_on_page', serialize($options['show_on_page']));
15
- update_post_meta($post_id, 'field_group_layout', $options['field_group_layout']);
16
-
17
- }
18
-
19
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
core/actions/save_fields.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // strip slashes
4
+ $_POST = array_map('stripslashes_deep', $_POST);
5
+
6
+
7
+ // save fields
8
+ $fields = $_POST['fields'];
9
+
10
+ // get all keys to find fields
11
+ $dont_delete = array();
12
+
13
+ if($fields)
14
+ {
15
+ $i = -1;
16
+
17
+ // remove dummy field
18
+ unset($fields['999']);
19
+
20
+ // loop through and save fields
21
+ foreach($fields as $field)
22
+ {
23
+ $i++;
24
+
25
+ // each field has a unique id!
26
+ if(!isset($field['key'])) $field['key'] = 'field_' . uniqid();
27
+
28
+ // add to dont delete array
29
+ $dont_delete[] = $field['key'];
30
+
31
+ // order
32
+ $field['order_no'] = $i;
33
+
34
+ // update field
35
+ $this->update_field($post_id, $field);
36
+ }
37
+ }
38
+
39
+ // delete all other field
40
+ foreach(get_post_custom_keys($post_id) as $key)
41
+ {
42
+ if(strpos($key, 'field_') !== false && !in_array($key, $dont_delete))
43
+ {
44
+ // this is a field, and it wasn't found in the dont_delete array
45
+ delete_post_meta($post_id, $key);
46
+ }
47
+ }
48
+
49
+ // save location
50
+ $location = $_POST['location'];
51
+
52
+ if(!isset($location['allorany'])) { $location['allorany'] = 'all'; }
53
+ update_post_meta($post_id, 'allorany', $location['allorany']);
54
+
55
+ delete_post_meta($post_id, 'rule');
56
+ if($location['rules'])
57
+ {
58
+ foreach($location['rules'] as $k => $rule)
59
+ {
60
+
61
+ $rule['order_no'] = $k;
62
+ add_post_meta($post_id, 'rule', $rule);
63
+ }
64
+ }
65
+
66
+ // save options
67
+ $options = $_POST['options'];
68
+
69
+ if(!isset($options['position'])) { $options['position'] = 'normal'; }
70
+ if(!isset($options['layout'])) { $options['layout'] = 'default'; }
71
+ if(!isset($options['show_on_page'])) { $options['show_on_page'] = array(); }
72
+
73
+ update_post_meta($post_id, 'position', $options['position']);
74
+ update_post_meta($post_id, 'layout', $options['layout']);
75
+ update_post_meta($post_id, 'show_on_page', $options['show_on_page']);
76
+
77
+ ?>
core/actions/save_input.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // strip slashes
4
+ $_POST = array_map('stripslashes_deep', $_POST);
5
+
6
+ // save fields
7
+ $fields = $_POST['fields'];
8
+
9
+ if($fields)
10
+ {
11
+ foreach($fields as $key => $value)
12
+ {
13
+ // get field
14
+ $field = $this->get_acf_field($key);
15
+
16
+ $this->update_value($post_id, $field, $value);
17
+ }
18
+ }
19
+
20
+ ?>
core/admin/fields_meta_box.php DELETED
@@ -1,222 +0,0 @@
1
- <?php
2
-
3
- // get fields
4
- global $post;
5
- $fields = $this->get_fields($post->ID);
6
-
7
-
8
- // add clone
9
- $field = new stdClass();
10
- $field->label = 'New Field';
11
- $field->name = 'new_field';
12
- $field->type = 'text';
13
- $field->options = array();
14
- $field->instructions = '';
15
- $field->default_value = '';
16
- $fields[999] = $field;
17
-
18
-
19
- // get name of all fields for use in field type drop down
20
- $fields_names = array();
21
- foreach($this->fields as $field)
22
- {
23
- $fields_names[$field->name] = $field->title;
24
- }
25
-
26
- ?>
27
-
28
- <input type="hidden" name="fields_meta_box" value="true" />
29
- <input type="hidden" name="total_fields" value="<?php echo count($fields); ?>" />
30
- <input type="hidden" name="fields_limit" value="99" />
31
- <input type="hidden" name="ei_noncename" id="ei_noncename" value="<?php echo wp_create_nonce('ei-n'); ?>" />
32
-
33
- <?php
34
- /*--------------------------------------------------------------------------------------
35
- *
36
- * Fields Header
37
- *
38
- *-------------------------------------------------------------------------------------*/
39
- ?>
40
- <div class="fields_header">
41
- <table class="acf widefat">
42
- <thead>
43
- <tr>
44
- <th class="field_order"><?php _e('Field Order','acf'); ?></th>
45
- <th class="field_label"><?php _e('Field Label','acf'); ?></th>
46
- <th class="field_name"><?php _e('Field Name','acf'); ?></th>
47
- <th class="field_type"><?php _e('Field Type','acf'); ?></th>
48
- </tr>
49
- </thead>
50
- </table>
51
- </div>
52
- <div class="fields">
53
-
54
- <div class="no_fields_message" <?php if(sizeof($fields) > 1){ echo 'style="display:none;"'; } ?>>
55
- <?php _e("No fields. Click the \"+ Add Field button\" to create your first field.",'acf'); ?>
56
- </div>
57
-
58
- <?php foreach($fields as $key => $field): ?>
59
-
60
-
61
- <div class="<?php if($key == 999){echo "field_clone";}else{echo "field";} ?>">
62
- <input type="hidden" name="acf[fields][<?php echo $key; ?>][id]'" value="<?php echo $field->id; ?>" />
63
- <?php
64
- /*--------------------------------------------------------------------------------------
65
- *
66
- * Field Meta
67
- *
68
- *-------------------------------------------------------------------------------------*/
69
- ?>
70
- <div class="field_meta">
71
- <table class="acf widefat">
72
- <tr>
73
- <td class="field_order"><span class="circle"><?php echo ($key+1); ?></span></td>
74
- <td class="field_label">
75
-
76
- <strong>
77
- <a class="acf_edit_field row-title" title="Edit this Field" href="javascript:;"><?php echo $field->label; ?></a>
78
- </strong>
79
- <div class="row_options">
80
- <span><a class="acf_edit_field" title="Edit this Field" href="javascript:;"><?php _e("Edit",'acf'); ?></a> | </span>
81
- <span><a class="acf_delete_field" title="Delete this Field" href="javascript:;"><?php _e("Delete",'acf'); ?></a>
82
- </div>
83
-
84
- </td>
85
- <td class="field_name">
86
-
87
- <?php echo $field->name; ?>
88
-
89
- </td>
90
- <td class="field_type">
91
-
92
- <?php echo $field->type; ?>
93
-
94
- </td>
95
- </tr>
96
- </table>
97
- </div>
98
- <div class="field_form_mask">
99
- <div class="field_form">
100
-
101
- <table class="acf_input widefat">
102
- <tbody>
103
- <tr class="field_label">
104
- <td class="label">
105
- <label><span class="required">*</span><?php _e("Field Label",'acf'); ?></label>
106
- <p class="description"><?php _e("This is the name which will appear on the EDIT page",'acf'); ?></p>
107
- </td>
108
- <td>
109
- <?php
110
- $temp_field = new stdClass();
111
-
112
- $temp_field->type = 'text';
113
- $temp_field->input_name = 'acf[fields]['.$key.'][label]';
114
- $temp_field->input_class = 'label';
115
- $temp_field->value = $field->label;
116
-
117
- $this->create_field($temp_field);
118
-
119
- ?>
120
-
121
- </td>
122
- </tr>
123
- <tr class="field_name">
124
- <td class="label"><label><span class="required">*</span><?php _e("Field Name",'acf'); ?></label>
125
- <p class="description"><?php _e("Single word, no spaces. Underscores and dashes allowed",'acf'); ?></p>
126
- </td>
127
- <td>
128
- <?php
129
-
130
- $temp_field->type = 'text';
131
- $temp_field->input_name = 'acf[fields]['.$key.'][name]';
132
- $temp_field->input_class = 'name';
133
- $temp_field->value = $field->name;
134
-
135
- $this->create_field($temp_field);
136
-
137
- ?>
138
-
139
- </td>
140
- </tr>
141
- <tr class="field_type">
142
- <td class="label"><label><span class="required">*</span><?php _e("Field Type",'acf'); ?></label></td>
143
- <td>
144
- <?php
145
-
146
- $temp_field->type = 'select';
147
- $temp_field->input_name = 'acf[fields]['.$key.'][type]';
148
- $temp_field->input_class = 'type';
149
- $temp_field->value = $field->type;
150
- $temp_field->options = array('choices' => $fields_names);
151
-
152
- $this->create_field($temp_field);
153
-
154
- ?>
155
- </td>
156
- </tr>
157
- <tr class="field_instructions">
158
- <td class="label"><label><?php _e("Field Instructions",'acf'); ?></label>
159
- <p class="description"><?php _e("Instructions for authors. Shown when submitting data",'acf'); ?></p></td>
160
- <td>
161
- <?php
162
-
163
- $temp_field->type = 'textarea';
164
- $temp_field->input_name = 'acf[fields]['.$key.'][instructions]';
165
- $temp_field->input_class = 'instructions';
166
- $temp_field->value = $field->instructions;
167
-
168
- $this->create_field($temp_field);
169
-
170
- ?>
171
- </td>
172
- </tr>
173
- <?php
174
- /*<tr class="field_save_as_cf">
175
- <td class="label">
176
- <label><?php _e("Is field searchable?",'acf'); ?></label>
177
- </td>
178
- <td>
179
- <?php
180
- $temp_field->type = 'true_false';
181
- $temp_field->input_name = 'acf[fields]['.$key.'][save_as_cf]';
182
- $temp_field->input_class = 'save_as_cf';
183
- $temp_field->value = $field->save_as_cf;
184
- $temp_field->options = array('message' => __("Save this field's value as a standard WordPress Custom Field",'acf'));
185
- $this->create_field($temp_field);
186
- ?>
187
- </td>
188
- </tr>*/
189
- ?>
190
-
191
- <?php foreach($fields_names as $field_name => $field_title): ?>
192
- <?php if(method_exists($this->fields[$field_name], 'options_html')): ?>
193
-
194
- <?php $this->fields[$field_name]->options_html($key, $field); ?>
195
-
196
- <?php endif; ?>
197
- <?php endforeach; ?>
198
- <tr class="field_save">
199
- <td class="label">
200
- <label>Save Field</label>
201
- </td>
202
- <td><input type="submit" value="Save Field" class="button-primary" name="save" />
203
- or <a class="acf_edit_field" title="Hide this edit screen" href="javascript:;">continue editing ACF</a>
204
- </td>
205
-
206
- </tr>
207
- </tbody>
208
- </table>
209
-
210
- </div>
211
- </div>
212
-
213
- </div>
214
- <?php endforeach; ?>
215
-
216
-
217
- </div>
218
-
219
- <div class="table_footer">
220
- <div class="order_message"></div>
221
- <a href="javascript:;" id="add_field" class="button-primary"><?php _e('+ Add Field','acf'); ?></a>
222
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
core/admin/input_meta_box.php DELETED
@@ -1,169 +0,0 @@
1
- <input type="hidden" name="ei_noncename" id="ei_noncename" value="<?php echo wp_create_nonce('ei-n'); ?>" />
2
- <input type="hidden" name="input_meta_box" value="true" />
3
-
4
- <div id="acf_loading"></div>
5
- <div id="acf_fields_ajax">
6
- <?php
7
- global $acf;
8
- global $post;
9
-
10
- // false parameter stops the function from calling die (ajax on/off)
11
- $acf->input_meta_box_html_no_ajax($post->ID);
12
- ?>
13
- </div>
14
-
15
- <script type="text/javascript">
16
-
17
- (function($){
18
-
19
- /*--------------------------------------------------------------------------------------
20
- *
21
- * overrides
22
- *
23
- *-------------------------------------------------------------------------------------*/
24
- var page_template = false;
25
- var page_parent = false;
26
- var page_type = false;
27
- var page = $('input#post_ID').val();
28
- var post = $('input#post_ID').val();
29
- var post_category = false;
30
- var post_format = false;
31
-
32
-
33
-
34
- /*--------------------------------------------------------------------------------------
35
- *
36
- * Change
37
- *
38
- *-------------------------------------------------------------------------------------*/
39
-
40
- $('#page_template').change(function(){
41
-
42
- page_template = $(this).val();
43
- update_fields();
44
-
45
- });
46
-
47
- $('#parent_id').change(function(){
48
-
49
- page_parent = $(this).val();
50
-
51
- if($(this).val() != "")
52
- {
53
- page_type = 'child';
54
- }
55
- else
56
- {
57
- page_type = 'parent';
58
- }
59
-
60
- update_fields();
61
-
62
- });
63
-
64
- $('#categorychecklist input[type="checkbox"]').change(function(){
65
-
66
- post_category = [];
67
-
68
- $('#categorychecklist :checked').each(function(){
69
- post_category.push($(this).val())
70
- });
71
-
72
- console.log(post_category);
73
-
74
- update_fields();
75
-
76
- });
77
-
78
-
79
- $('#post-formats-select input[type="radio"]').change(function(){
80
-
81
- post_format = $(this).val();
82
- update_fields();
83
-
84
- });
85
-
86
- function update_fields()
87
- {
88
-
89
-
90
- // fade out fields and show loading
91
- /*$('#acf_input').addClass('loading');
92
- $('#acf_fields_ajax').animate({
93
- opacity : 0.5
94
- }, 500);*/
95
-
96
-
97
- // get post id
98
- var post_id = $('input#post_ID').val();
99
-
100
- // create data
101
- var data = {
102
- action : 'input_meta_box_html',
103
- post_id : post_id,
104
- page_template : page_template,
105
- page_parent : page_parent,
106
- page_type : page_type,
107
- page : page,
108
- post : post,
109
- post_category : post_category,
110
- post_format : post_format,
111
-
112
- };
113
- //console.log(data);
114
-
115
- // post off and find new fields
116
- $.post(ajaxurl, data, function(data) {
117
-
118
- var new_divs = [];
119
- var old_divs = [];
120
-
121
- /*$('#acf_input').removeClass('loading');
122
- $('#acf_fields_ajax').animate({
123
- opacity : 1
124
- }, 500);*/
125
-
126
- $('#acf_fields_ajax .acf_ajax_fields').each(function(){
127
-
128
- old_divs[$(this).attr('data-acf_id')] = $(this);
129
-
130
- $(this).remove();
131
- });
132
-
133
- var divs = $(data).filter(function(){ return $(this).is('.acf_ajax_fields') });
134
- divs.each(function(){
135
-
136
- if(old_divs[$(this).attr('data-acf_id')])
137
- {
138
- $('#acf_fields_ajax').append(old_divs[$(this).attr('data-acf_id')]);
139
- }
140
- else
141
- {
142
- $('#acf_fields_ajax').append($(this));
143
- }
144
-
145
- });
146
-
147
-
148
- // new dynamic style
149
- $('#acf_fields_ajax #acf_dynamic_style').remove();
150
- var style = $(data).filter(function(){ return $(this).is('style')});
151
- style.each(function(){
152
- $('#acf_fields_ajax').append($(this));
153
- });
154
-
155
-
156
- $('body').setup_acf();
157
-
158
-
159
- });
160
- }
161
-
162
- $(document).ready(function(){
163
- update_fields();
164
- });
165
-
166
-
167
- })(jQuery);
168
-
169
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
core/admin/location_meta_box.php DELETED
@@ -1,310 +0,0 @@
1
- <?php
2
-
3
- global $post;
4
-
5
- // get options
6
- $location = $this->get_acf_location($post->ID);
7
- if(!isset($location->rules) || empty($location->rules))
8
- {
9
- $rule = new stdClass();
10
- $rule->param = '';
11
- $rule->operator = '';
12
- $rule->value = '';
13
-
14
- $location->rules = array();
15
- $location->rules[] = $rule;
16
- }
17
- // create temp field from creating inputs
18
- $temp_field = new stdClass();
19
- ?>
20
-
21
- <input type="hidden" name="location_meta_box" value="true" />
22
- <input type="hidden" name="ei_noncename" id="ei_noncename" value="<?php echo wp_create_nonce('ei-n'); ?>" />
23
-
24
- <table class="acf_input widefat" id="acf_location">
25
- <tbody>
26
- <tr>
27
- <td class="label">
28
- <label for="post_type">Rules</label>
29
- <p class="description">Create a set of rules to determine which edit screens will use these advanced custom fields</p>
30
- </td>
31
- <td>
32
-
33
- <div class="location_rules">
34
- <?php if($location->rules): ?>
35
- <table class="acf_input widefat" id="location_rules">
36
- <tbody>
37
- <?php foreach($location->rules as $k => $rule): ?>
38
- <tr>
39
- <td class="param">
40
- <?php
41
-
42
- $temp_field->type = 'select';
43
- $temp_field->input_name = 'acf[location][rules]['.$k.'][param]';
44
- $temp_field->input_class = '';
45
- $temp_field->value = $rule->param;
46
- $temp_field->options = array('choices' => array(
47
- 'post_type' => 'Post Type',
48
- 'page' => 'Page',
49
- 'page_type' => 'Page Type',
50
- 'page_parent' => 'Page Parent',
51
- 'page_template' => 'Page Template',
52
- 'post' => 'Post',
53
- 'post_category' => 'Post Category',
54
- 'post_format' => 'Post Format',
55
- 'user_type' => 'User Type',
56
- ));
57
-
58
- if(array_key_exists('options_page', $this->activated_fields))
59
- {
60
- $temp_field->options['choices']['options_page'] = "Options Page";
61
- }
62
-
63
- $this->create_field($temp_field);
64
-
65
- ?>
66
-
67
- </td>
68
- <td class="operator">
69
- <?php
70
-
71
- $temp_field->type = 'select';
72
- $temp_field->input_name = 'acf[location][rules]['.$k.'][operator]';
73
- $temp_field->input_class = '';
74
- $temp_field->value = $rule->operator;
75
- $temp_field->options = array('choices' => array(
76
- '==' => 'is equal to',
77
- '!=' => 'is not equal to',
78
- ));
79
-
80
- $this->create_field($temp_field);
81
-
82
- ?>
83
- </td>
84
- <td class="value">
85
- <div rel="post_type">
86
- <?php
87
- $choices = get_post_types();
88
-
89
- unset($choices['attachment']);
90
- unset($choices['nav_menu_item']);
91
- unset($choices['revision']);
92
- unset($choices['acf']);
93
-
94
- $temp_field->type = 'select';
95
- $temp_field->input_name = 'acf[location][rules]['.$k.'][value]';
96
- $temp_field->input_class = '';
97
- $temp_field->value = $rule->value;
98
- $temp_field->options = array(
99
- 'choices' => $choices,
100
- );
101
-
102
- $this->create_field($temp_field);
103
-
104
- ?>
105
- </div>
106
- <div rel="page">
107
- <?php
108
- $choices = array();
109
-
110
- foreach(get_pages('sort_column=menu_order&sort_order=desc') as $page)
111
- {
112
- if($page->post_parent != 0)
113
- {
114
- $choices[$page->ID] = '- '.$page->post_title;
115
- }
116
- else
117
- {
118
- $choices[$page->ID] = $page->post_title;
119
- }
120
-
121
- }
122
- $temp_field->options = array(
123
- 'choices' => $choices,
124
- );
125
-
126
- $this->create_field($temp_field);
127
-
128
- ?>
129
- </div>
130
- <div rel="page_type">
131
- <?php
132
- $choices = array(
133
- 'parent' => 'Parent Page',
134
- 'child' => 'Child Page'
135
- );
136
-
137
- $temp_field->options = array(
138
- 'choices' => $choices,
139
- );
140
-
141
- $this->create_field($temp_field);
142
-
143
- ?>
144
- </div>
145
- <div rel="page_parent">
146
- <?php
147
- $choices = array();
148
- foreach(get_pages('sort_column=menu_order&sort_order=desc') as $page)
149
- {
150
- if($page->post_parent != 0)
151
- {
152
- $choices[$page->ID] = '- '.$page->post_title;
153
- }
154
- else
155
- {
156
- $choices[$page->ID] = $page->post_title;
157
- }
158
-
159
- }
160
- $temp_field->options = array(
161
- 'choices' => $choices,
162
- );
163
-
164
- $this->create_field($temp_field);
165
-
166
- ?>
167
- </div>
168
- <div rel="page_template">
169
-
170
- <?php
171
-
172
- $choices = array();
173
- $choices['default'] = 'Default Template';
174
- foreach(get_page_templates() as $k => $v)
175
- {
176
- $choices[$v] = $k;
177
- }
178
- $temp_field->options = array(
179
- 'choices' => $choices,
180
- );
181
-
182
- $this->create_field($temp_field);
183
-
184
- ?>
185
- </div>
186
- <div rel="post">
187
-
188
- <?php
189
- $choices = array();
190
- foreach(get_posts(array('numberposts'=>'-1')) as $v)
191
- {
192
- $choices[$v->ID] = $v->post_title;
193
- }
194
- $temp_field->options = array(
195
- 'choices' => $choices,
196
- );
197
-
198
- $this->create_field($temp_field);
199
-
200
- ?>
201
- </div>
202
- <div rel="post_category">
203
-
204
- <?php
205
- $choices = array();
206
- $category_ids = get_all_category_ids();
207
-
208
- foreach($category_ids as $cat_id)
209
- {
210
- $cat_name = get_cat_name($cat_id);
211
- $choices[$cat_id] = $cat_name;
212
- }
213
-
214
-
215
- $temp_field->options = array(
216
- 'choices' => $choices,
217
- );
218
-
219
- $this->create_field($temp_field);
220
-
221
- ?>
222
- </div>
223
- <div rel="post_format">
224
- <?php
225
- $choices = array(
226
- '0' => 'Standard',
227
- 'aside' => 'Aside',
228
- 'link' => 'Link',
229
- 'gallery' => 'Gallery',
230
- 'status' => 'Status',
231
- 'quote' => 'Quote',
232
- 'image' => 'Image',
233
- );
234
-
235
- $temp_field->options = array(
236
- 'choices' => $choices,
237
- );
238
-
239
- $this->create_field($temp_field);
240
- ?>
241
- </div>
242
- <div rel="user_type">
243
-
244
- <?php
245
-
246
- $choices = array(
247
- 'administrator' => 'Administrator',
248
- 'editor' => 'Editor',
249
- 'author' => 'Author',
250
- 'contributor' => 'contributor'
251
- );
252
-
253
- $temp_field->options = array(
254
- 'choices' => $choices,
255
- );
256
-
257
- $this->create_field($temp_field);
258
-
259
- ?>
260
- </div>
261
- <div rel="options_page">
262
-
263
- <?php
264
-
265
- $choices = array(
266
- 'acf_options' => 'Options',
267
- );
268
-
269
- $temp_field->options = array(
270
- 'choices' => $choices,
271
- );
272
-
273
- $this->create_field($temp_field);
274
-
275
- ?>
276
- </div>
277
- </td>
278
- <td class="buttons">
279
- <a href="javascript:;" class="remove"></a>
280
- <a href="javascript:;" class="add"></a>
281
- </td>
282
- </tr>
283
- <?php endforeach; ?>
284
- </tbody>
285
-
286
- </table>
287
- <?php endif; ?>
288
- <p>match <?php
289
-
290
- $temp_field->type = 'select';
291
- $temp_field->input_name = 'acf[location][allorany]';
292
- $temp_field->input_class = '';
293
- $temp_field->value = $location->allorany;
294
- $temp_field->options = array('choices' => array(
295
- 'all' => 'all',
296
- 'any' => 'any',
297
- ));
298
-
299
- $this->create_field($temp_field);
300
-
301
- ?> of the above criteria</p>
302
- </div>
303
-
304
-
305
- </td>
306
-
307
- </tr>
308
-
309
- </tbody>
310
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
core/admin/meta_box_acf.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <link rel="stylesheet" type="text/css" href="<?php echo $this->dir ?>/css/acf.css" />
2
+ <script type="text/javascript" src="<?php echo $this->dir ?>/js/acf.js" ></script>
3
+
4
+ <div id="screen-meta-activate-acf-wrap" class="screen-meta-wrap hidden acf">
5
+ <div class="screen-meta-content">
6
+
7
+ <h5><?php _e("Unlock Special Fields.",'acf'); ?></h5>
8
+ <p><?php _e("Special Fields can be unlocked by purchasing a license key. Each key can be used on multiple sites.",'acf'); ?> <a href="http://plugins.elliotcondon.com/shop/"><?php _e("Visit the Plugin Store",'acf'); ?></a></p>
9
+ <table class="acf_activate widefat">
10
+ <thead>
11
+ <tr>
12
+ <th><?php _e("Field Type",'acf'); ?></th>
13
+ <th><?php _e("Status",'acf'); ?></th>
14
+ <th><?php _e("Activation Code",'acf'); ?></th>
15
+ </tr>
16
+ </thead>
17
+ <tbody>
18
+ <?php
19
+ /*--------------------------------------------------------------------------------------
20
+ *
21
+ * Repeater Field
22
+ *
23
+ *-------------------------------------------------------------------------------------*/
24
+ ?>
25
+ <tr>
26
+ <td><?php _e("Repeater",'acf'); ?></td>
27
+ <td><?php echo $this->is_field_unlocked('repeater') ? __("Active",'acf') : __("Inactive",'acf'); ?></td>
28
+ <td>
29
+ <form action="" method="post">
30
+ <?php if($this->is_field_unlocked('repeater')){
31
+ echo '<span class="activation_code">XXXX-XXXX-XXXX-'.substr($this->get_license_key('repeater'),-4) .'</span>';
32
+ echo '<input type="hidden" name="acf_field_deactivate" value="repeater" />';
33
+ echo '<input type="submit" class="button" value="Deactivate" />';
34
+ }
35
+ else
36
+ {
37
+ echo '<input type="text" name="key" value="" />';
38
+ echo '<input type="hidden" name="acf_field_activate" value="repeater" />';
39
+ echo '<input type="submit" class="button" value="Activate" />';
40
+ } ?>
41
+ </form>
42
+ </td>
43
+ </tr>
44
+ <?php
45
+ /*--------------------------------------------------------------------------------------
46
+ *
47
+ * Options Page
48
+ *
49
+ *-------------------------------------------------------------------------------------*/
50
+ ?>
51
+ <tr>
52
+ <td><?php _e("Options Page",'acf'); ?></td>
53
+ <td><?php echo $this->is_field_unlocked('options_page') ? __("Active",'acf') : __("Inactive",'acf'); ?></td>
54
+ <td>
55
+ <form action="" method="post">
56
+ <?php if($this->is_field_unlocked('options_page')){
57
+ echo '<span class="activation_code">XXXX-XXXX-XXXX-'.substr($this->get_license_key('options_page'),-4) .'</span>';
58
+ echo '<input type="hidden" name="acf_field_deactivate" value="options_page" />';
59
+ echo '<input type="submit" class="button" value="Deactivate" />';
60
+ }
61
+ else
62
+ {
63
+ echo '<input type="text" name="key" value="" />';
64
+ echo '<input type="hidden" name="acf_field_activate" value="options_page" />';
65
+ echo '<input type="submit" class="button" value="Activate" />';
66
+ } ?>
67
+ </form>
68
+ </td>
69
+ </tr>
70
+ </tbody>
71
+ </table>
72
+ </div>
73
+ </div>
74
+ <div id="screen-meta-activate-acf-link-wrap" class="hide-if-no-js screen-meta-toggle acf">
75
+ <a href="#screen-meta-activate-acf" id="screen-meta-activate-acf-link" class="show-settings"><?php _e("Unlock Fields",'acf'); ?></a>
76
+ </div>
77
+
78
+ <div class="acf_col_right hidden metabox-holder" id="poststuff" >
79
+
80
+ <div class="postbox">
81
+ <div class="handlediv"><br></div>
82
+ <h3 class="hndle"><span><?php _e("Advanced Custom Fields v",'acf'); ?><?php echo $this->version; ?></span></h3>
83
+ <div class="inside">
84
+ <div class="field">
85
+ <h4><?php _e("Changelog",'acf'); ?></h4>
86
+ <p><?php _e("See what's new in",'acf'); ?> <a class="thickbox" href="<?php bloginfo('url'); ?>/wp-admin/plugin-install.php?tab=plugin-information&plugin=advanced-custom-fields&section=changelog&TB_iframe=true&width=640&height=559">v<?php echo $this->version; ?></a>
87
+ </div>
88
+ <div class="field">
89
+ <h4><?php _e("Resources",'acf'); ?></h4>
90
+ <p><?php _e("Watch tutorials, read documentation, learn the API code and find some tips &amp; tricks for your next web project.",'acf'); ?><br />
91
+ <a href="http://plugins.elliotcondon.com/advanced-custom-fields/"><?php _e("View the plugins website",'acf'); ?></a></p>
92
+ </div>
93
+ <!-- <div class="field">
94
+ <h4><?php _e("Support",'acf'); ?></h4>
95
+ <p><?php _e("Join the growing community over at the support forum to share ideas, report bugs and keep up to date with ACF",'acf'); ?><br />
96
+ <a href="http://support.plugins.elliotcondon.com/categories/advanced-custom-fields/"><?php _e("View the Support Forum",'acf'); ?></a></p>
97
+ </div> -->
98
+ <div class="field">
99
+ <h4><?php _e("Developed by",'acf'); ?> Elliot Condon</h4>
100
+ <p><a href="http://wordpress.org/extend/plugins/advanced-custom-fields/"><?php _e("Vote for ACF",'acf'); ?></a> | <a href="http://twitter.com/elliotcondon"><?php _e("Twitter",'acf'); ?></a> | <a href="http://blog.elliotcondon.com"><?php _e("Blog",'acf'); ?></a></p>
101
+ </div>
102
+
103
+
104
+ </div>
105
+ </div>
106
+ </div>
core/admin/meta_box_fields.php ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // vars
4
+ global $post;
5
+ $fields_names = array();
6
+
7
+ // get fields
8
+ $fields = $this->get_acf_fields($post->ID);
9
+
10
+ // add clone
11
+ $fields[999] = array(
12
+ 'label' => __("New Field",'acf'),
13
+ 'name' => 'new_field',
14
+ 'type' => 'text',
15
+ 'order_no' => '1',
16
+ 'instructions' => '',
17
+ );
18
+
19
+ // get name of all fields for use in field type drop down
20
+ foreach($this->fields as $field)
21
+ {
22
+ $fields_names[$field->name] = $field->title;
23
+ }
24
+
25
+ // hidden field for saving
26
+ ?>
27
+ <input type="hidden" name="save_fields" value="true" />
28
+ <div class="fields_header">
29
+ <table class="acf widefat">
30
+ <thead>
31
+ <tr>
32
+ <th class="field_order"><?php _e('Field Order','acf'); ?></th>
33
+ <th class="field_label"><?php _e('Field Label','acf'); ?></th>
34
+ <th class="field_name"><?php _e('Field Name','acf'); ?></th>
35
+ <th class="field_type"><?php _e('Field Type','acf'); ?></th>
36
+ </tr>
37
+ </thead>
38
+ </table>
39
+ </div>
40
+ <div class="fields">
41
+ <div class="no_fields_message" <?php if(sizeof($fields) > 1){ echo 'style="display:none;"'; } ?>>
42
+ <?php _e("No fields. Click the <strong>+ Add Field</strong> button to create your first field.",'acf'); ?>
43
+ </div>
44
+ <?php foreach($fields as $key => $field): ?>
45
+ <div class="<?php echo ($key == 999) ? "field_clone" : "field"; ?>">
46
+ <?php if(isset($field['key'])): ?><input type="hidden" name="fields[<?php echo $key; ?>][key]" value="<?php echo $field['key']; ?>" /><?php endif; ?>
47
+ <div class="field_meta">
48
+ <table class="acf widefat">
49
+ <tr>
50
+ <td class="field_order"><span class="circle"><?php echo (int)$field['order_no'] + 1; ?></span></td>
51
+ <td class="field_label">
52
+ <strong>
53
+ <a class="acf_edit_field row-title" title="Edit this Field" href="javascript:;"><?php echo $field['label']; ?></a>
54
+ </strong>
55
+ <div class="row_options">
56
+ <span><a class="acf_edit_field" title="Edit this Field" href="javascript:;"><?php _e("Edit",'acf'); ?></a> | </span>
57
+ <span><a title="Read documentation for this field" href="http://plugins.elliotcondon.com/advanced-custom-fields/documentation/" target="_blank"><?php _e("Docs",'acf'); ?></a> | </span>
58
+ <span><a class="acf_delete_field" title="Delete this Field" href="javascript:;"><?php _e("Delete",'acf'); ?></a>
59
+ </div>
60
+ </td>
61
+ <td class="field_name"><?php echo $field['name']; ?></td>
62
+ <td class="field_type"><?php echo $field['type']; ?></td>
63
+ </tr>
64
+ </table>
65
+ </div>
66
+ <div class="field_form_mask">
67
+ <div class="field_form">
68
+
69
+ <table class="acf_input widefat">
70
+ <tbody>
71
+ <tr class="field_label">
72
+ <td class="label">
73
+ <label><span class="required">*</span><?php _e("Field Label",'acf'); ?></label>
74
+ <p class="description"><?php _e("This is the name which will appear on the EDIT page",'acf'); ?></p>
75
+ </td>
76
+ <td>
77
+ <?php
78
+ $this->create_field(array(
79
+ 'type' => 'text',
80
+ 'name' => 'fields['.$key.'][label]',
81
+ 'value' => $field['label'],
82
+ 'class' => 'label',
83
+ ));
84
+ ?>
85
+ </td>
86
+ </tr>
87
+ <tr class="field_name">
88
+ <td class="label">
89
+ <label><span class="required">*</span><?php _e("Field Name",'acf'); ?></label>
90
+ <p class="description"><?php _e("Single word, no spaces. Underscores and dashes allowed",'acf'); ?></p>
91
+ </td>
92
+ <td>
93
+ <?php
94
+ $this->create_field(array(
95
+ 'type' => 'text',
96
+ 'name' => 'fields['.$key.'][name]',
97
+ 'value' => $field['name'],
98
+ 'class' => 'name',
99
+ ));
100
+ ?>
101
+ </td>
102
+ </tr>
103
+ <tr class="field_type">
104
+ <td class="label"><label><span class="required">*</span><?php _e("Field Type",'acf'); ?></label></td>
105
+ <td>
106
+ <?php
107
+ $this->create_field(array(
108
+ 'type' => 'select',
109
+ 'name' => 'fields['.$key.'][type]',
110
+ 'value' => $field['type'],
111
+ 'choices' => $fields_names,
112
+ ));
113
+ ?>
114
+ </td>
115
+ </tr>
116
+ <tr class="field_instructions">
117
+ <td class="label"><label><?php _e("Field Instructions",'acf'); ?></label>
118
+ <p class="description"><?php _e("Instructions for authors. Shown when submitting data",'acf'); ?></p></td>
119
+ <td>
120
+ <?php
121
+ $this->create_field(array(
122
+ 'type' => 'textarea',
123
+ 'name' => 'fields['.$key.'][instructions]',
124
+ 'value' => $field['instructions'],
125
+ ));
126
+ ?>
127
+ </td>
128
+ </tr>
129
+ <?php
130
+ foreach($fields_names as $field_name => $field_title){
131
+ $this->fields[$field_name]->create_options($key, $field);
132
+ }
133
+ ?>
134
+ <tr class="field_save">
135
+ <td class="label">
136
+ <label><?php _e("Save Field",'acf'); ?></label>
137
+ </td>
138
+ <td><input type="submit" value="Save Field" class="button-primary" name="save" />
139
+ <?php _e("or",'acf'); ?> <a class="acf_edit_field" title="<?php _e("Hide this edit screen",'acf'); ?>" href="javascript:;"><?php _e("continue editing ACF",'acf'); ?></a>
140
+ </td>
141
+ </tr>
142
+ </tbody>
143
+ </table>
144
+ </div>
145
+ </div>
146
+ </div>
147
+ <?php endforeach; ?>
148
+ </div>
149
+ <div class="table_footer">
150
+ <div class="order_message"></div>
151
+ <a href="javascript:;" id="add_field" class="button-primary"><?php _e('+ Add Field','acf'); ?></a>
152
+ </div>
core/admin/meta_box_input.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // vars
4
+ $fields = isset($args['args']['fields']) ? $args['args']['fields'] : false ;
5
+ $options = isset($args['args']['options']) ? $args['args']['options'] : false;
6
+ $show = isset($args['args']['show']) ? $args['args']['show'] : "false";
7
+
8
+ // defaults
9
+ if(!$options)
10
+ {
11
+ $options = array(
12
+ 'layout' => 'default'
13
+ );
14
+ }
15
+ $post_id = $post ? $post->ID : 999999999;
16
+
17
+ if($fields)
18
+ {
19
+ echo '<input type="hidden" name="save_input" value="true" />';
20
+ echo '<div class="options" data-layout="' . $options['layout'] . '" data-show="' . $show . '"></div>';
21
+ foreach($fields as $field)
22
+ {
23
+ // if they didn't select a type, skip this field
24
+ if($field['type'] == 'null') continue;
25
+
26
+ // set value
27
+ $field['value'] = $this->get_value($post_id, $field);
28
+
29
+ echo '<div class="field">';
30
+
31
+ echo '<label for="fields[' . $field['key'] . '][value]">' . $field['label'] . '</label>';
32
+ if($field['instructions']) echo '<p class="instructions">' . $field['instructions'] . '</p>';
33
+
34
+ $field['name'] = 'fields[' . $field['key'] . ']';
35
+ $this->create_field($field);
36
+
37
+ echo '</div>';
38
+
39
+ }
40
+ }
41
+
42
+ ?>
core/admin/meta_box_location.php ADDED
@@ -0,0 +1,347 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // vars
4
+ global $post;
5
+
6
+ // get location data
7
+ $location = $this->get_acf_location($post->ID);
8
+
9
+ if(empty($location['rules']))
10
+ {
11
+ $location['rules'] = array(
12
+ array(
13
+ 'param' => '',
14
+ 'operator' => '',
15
+ 'value' => '',
16
+ )
17
+ );
18
+ }
19
+
20
+ ?>
21
+ <table class="acf_input widefat" id="acf_location">
22
+ <tbody>
23
+ <tr>
24
+ <td class="label">
25
+ <label for="post_type"><?php _e("Rules",'acf'); ?></label>
26
+ <p class="description"><?php _e("Create a set of rules to determine which edit screens will use these advanced custom fields",'acf'); ?></p>
27
+ </td>
28
+ <td>
29
+ <div class="location_rules">
30
+ <table class="acf_input widefat" id="location_rules">
31
+ <tbody>
32
+ <?php foreach($location['rules'] as $k => $rule): ?>
33
+ <tr>
34
+ <td class="param">
35
+ <?php
36
+ $args = array(
37
+ 'type' => 'select',
38
+ 'name' => 'location[rules]['.$k.'][param]',
39
+ 'value' => $rule['param'],
40
+ 'choices' => array(
41
+ 'post_type' => 'Post Type',
42
+ 'page' => 'Page',
43
+ 'page_type' => 'Page Type',
44
+ 'page_parent' => 'Page Parent',
45
+ 'page_template' => 'Page Template',
46
+ 'post' => 'Post',
47
+ 'post_category' => 'Post Category',
48
+ 'post_format' => 'Post Format',
49
+ 'user_type' => 'User Type',
50
+ 'taxonomy' => 'Taxonomy'
51
+ )
52
+ );
53
+
54
+ // validate
55
+ if($this->is_field_unlocked('options_page'))
56
+ {
57
+ $args['choices']['options_page'] = "Options Page";
58
+ }
59
+
60
+ $this->create_field($args);
61
+ ?>
62
+ </td>
63
+ <td class="operator">
64
+ <?php
65
+ $this->create_field(array(
66
+ 'type' => 'select',
67
+ 'name' => 'location[rules]['.$k.'][operator]',
68
+ 'value' => $rule['operator'],
69
+ 'choices' => array(
70
+ '==' => 'is equal to',
71
+ '!=' => 'is not equal to',
72
+ )
73
+ ));
74
+ ?>
75
+ </td>
76
+ <td class="value">
77
+ <div rel="post_type">
78
+ <?php
79
+ $choices = get_post_types(array('public' => true));
80
+ unset($choices['attachment']);
81
+
82
+
83
+ $this->create_field(array(
84
+ 'type' => 'select',
85
+ 'name' => 'location[rules]['.$k.'][value]',
86
+ 'value' => $rule['value'],
87
+ 'choices' => $choices,
88
+ ));
89
+ ?>
90
+ </div>
91
+ <div rel="page">
92
+ <?php
93
+ $choices = array();
94
+
95
+ foreach(get_pages('sort_column=menu_order&sort_order=desc') as $page)
96
+ {
97
+ $value = '';
98
+ $ancestors = get_ancestors($page->ID, 'page');
99
+ if($ancestors)
100
+ {
101
+ foreach($ancestors as $a)
102
+ {
103
+ $value .= '– ';
104
+ }
105
+ }
106
+ $value .= get_the_title($page->ID);
107
+
108
+ $choices[$page->ID] = $value;
109
+
110
+ }
111
+
112
+ $this->create_field(array(
113
+ 'type' => 'select',
114
+ 'name' => 'location[rules]['.$k.'][value]',
115
+ 'value' => $rule['value'],
116
+ 'choices' => $choices,
117
+ ));
118
+
119
+ ?>
120
+ </div>
121
+ <div rel="page_type">
122
+ <?php
123
+ $this->create_field(array(
124
+ 'type' => 'select',
125
+ 'name' => 'location[rules]['.$k.'][value]',
126
+ 'value' => $rule['value'],
127
+ 'choices' => array(
128
+ 'parent' => 'Parent Page',
129
+ 'child' => 'Child Page'
130
+ ),
131
+ ));
132
+ ?>
133
+ </div>
134
+ <div rel="page_parent">
135
+ <?php
136
+
137
+ $choices = array();
138
+
139
+ foreach(get_pages('sort_column=menu_order&sort_order=desc') as $page)
140
+ {
141
+ $value = '';
142
+ $ancestors = get_ancestors($page->ID, 'page');
143
+ if($ancestors)
144
+ {
145
+ foreach($ancestors as $a)
146
+ {
147
+ $value .= '– ';
148
+ }
149
+ }
150
+ $value .= get_the_title($page->ID);
151
+
152
+ $choices[$page->ID] = $value;
153
+
154
+ }
155
+
156
+ $this->create_field(array(
157
+ 'type' => 'select',
158
+ 'name' => 'location[rules]['.$k.'][value]',
159
+ 'value' => $rule['value'],
160
+ 'choices' => $choices,
161
+ ));
162
+
163
+ ?>
164
+ </div>
165
+ <div rel="page_template">
166
+ <?php
167
+
168
+ $choices = array(
169
+ 'default' => 'Default Template',
170
+ );
171
+ foreach(get_page_templates() as $tk => $tv)
172
+ {
173
+ $choices[$tv] = $tk;
174
+ }
175
+
176
+ $this->create_field(array(
177
+ 'type' => 'select',
178
+ 'name' => 'location[rules]['.$k.'][value]',
179
+ 'value' => $rule['value'],
180
+ 'choices' => $choices,
181
+ ));
182
+
183
+ ?>
184
+ </div>
185
+ <div rel="post">
186
+ <?php
187
+
188
+ $choices = array();
189
+ foreach(get_posts(array('numberposts'=>'-1')) as $v)
190
+ {
191
+ $choices[$v->ID] = $v->post_title;
192
+ }
193
+
194
+ $this->create_field(array(
195
+ 'type' => 'select',
196
+ 'name' => 'location[rules]['.$k.'][value]',
197
+ 'value' => $rule['value'],
198
+ 'choices' => $choices,
199
+ ));
200
+
201
+ ?>
202
+ </div>
203
+ <div rel="post_category">
204
+ <?php
205
+
206
+ $choices = array();
207
+ $category_ids = get_all_category_ids();
208
+
209
+ foreach($category_ids as $cat_id)
210
+ {
211
+ $cat_name = get_cat_name($cat_id);
212
+ $choices[$cat_id] = $cat_name;
213
+ }
214
+
215
+ $this->create_field(array(
216
+ 'type' => 'select',
217
+ 'name' => 'location[rules]['.$k.'][value]',
218
+ 'value' => $rule['value'],
219
+ 'choices' => $choices,
220
+ ));
221
+
222
+ ?>
223
+ </div>
224
+ <div rel="post_format">
225
+ <?php
226
+
227
+ $this->create_field(array(
228
+ 'type' => 'select',
229
+ 'name' => 'location[rules]['.$k.'][value]',
230
+ 'value' => $rule['value'],
231
+ 'choices' => array(
232
+ '0' => 'Standard',
233
+ 'aside' => 'Aside',
234
+ 'link' => 'Link',
235
+ 'gallery' => 'Gallery',
236
+ 'status' => 'Status',
237
+ 'quote' => 'Quote',
238
+ 'image' => 'Image',
239
+ ),
240
+ ));
241
+
242
+ ?>
243
+ </div>
244
+ <div rel="user_type">
245
+ <?php
246
+
247
+ $this->create_field(array(
248
+ 'type' => 'select',
249
+ 'name' => 'location[rules]['.$k.'][value]',
250
+ 'value' => $rule['value'],
251
+ 'choices' => array(
252
+ 'administrator' => 'Administrator',
253
+ 'editor' => 'Editor',
254
+ 'author' => 'Author',
255
+ 'contributor' => 'contributor'
256
+ )
257
+ ));
258
+
259
+ ?>
260
+ </div>
261
+ <div rel="options_page">
262
+ <?php
263
+
264
+ $this->create_field(array(
265
+ 'type' => 'select',
266
+ 'name' => 'location[rules]['.$k.'][value]',
267
+ 'value' => $rule['value'],
268
+ 'choices' => array(
269
+ 'Options' => 'Options',
270
+ ),
271
+ ));
272
+
273
+ ?>
274
+ </div>
275
+ <div rel="taxonomy">
276
+
277
+ <?php
278
+
279
+ $post_types = get_post_types();
280
+
281
+ //unset($post_types['attachment']);
282
+ //unset($post_types['nav_menu_item']);
283
+ //unset($post_types['revision']);
284
+ //unset($post_types['acf']);
285
+
286
+ $choices = array();
287
+
288
+ if($post_types)
289
+ {
290
+ foreach($post_types as $post_type)
291
+ {
292
+ $taxonomies = get_object_taxonomies($post_type);
293
+ if($taxonomies)
294
+ {
295
+ foreach($taxonomies as $taxonomy)
296
+ {
297
+ $terms = get_terms($taxonomy, array('hide_empty' => false));
298
+ if($terms)
299
+ {
300
+ foreach($terms as $term)
301
+ {
302
+ $choices[$post_type . ': ' . $taxonomy][$term->term_id] = $term->name;
303
+ }
304
+ }
305
+ }
306
+ }
307
+ }
308
+ }
309
+
310
+ $this->create_field(array(
311
+ 'type' => 'select',
312
+ 'name' => 'location[rules]['.$k.'][value]',
313
+ 'value' => $rule['value'],
314
+ 'choices' => $choices,
315
+ 'optgroup' => true,
316
+ ));
317
+
318
+ ?>
319
+ </div>
320
+ </td>
321
+ <td class="buttons">
322
+ <a href="javascript:;" class="remove"></a>
323
+ <a href="javascript:;" class="add"></a>
324
+ </td>
325
+ </tr>
326
+ <?php endforeach; ?>
327
+ </tbody>
328
+
329
+ </table>
330
+ <p>match <?php $this->create_field(array(
331
+ 'type' => 'select',
332
+ 'name' => 'location[allorany]',
333
+ 'value' => $location['allorany'],
334
+ 'choices' => array(
335
+ 'all' => 'all',
336
+ 'any' => 'any',
337
+ ),
338
+ )); ?> of the above</p>
339
+ </div>
340
+
341
+
342
+ </td>
343
+
344
+ </tr>
345
+
346
+ </tbody>
347
+ </table>
core/admin/meta_box_options.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // vars
4
+ global $post;
5
+
6
+ // get options
7
+ $options = $this->get_acf_options($post->ID);
8
+
9
+ ?>
10
+ <table class="acf_input widefat" id="acf_options">
11
+ <tr>
12
+ <td class="label">
13
+ <label for=""><?php _e("Order No.",'acf'); ?></label>
14
+ <p class="description"><?php _e("Field groups are created in order <br />from lowest to highest.",'acf'); ?></p>
15
+ </td>
16
+ <td>
17
+ <?php
18
+
19
+ $this->create_field(array(
20
+ 'type' => 'text',
21
+ 'name' => 'menu_order',
22
+ 'value' => $post->menu_order,
23
+ ));
24
+
25
+ ?>
26
+ </td>
27
+ </tr>
28
+ <tr>
29
+ <td class="label">
30
+ <label for=""><?php _e("Position",'acf'); ?></label>
31
+ </td>
32
+ <td>
33
+ <?php
34
+
35
+ $this->create_field(array(
36
+ 'type' => 'radio',
37
+ 'name' => 'options[position]',
38
+ 'value' => $options['position'],
39
+ 'choices' => array(
40
+ 'normal' => 'Normal',
41
+ 'side' => 'Side',
42
+ )
43
+ ));
44
+
45
+ ?>
46
+ </td>
47
+ </tr>
48
+ <tr>
49
+ <td class="label">
50
+ <label for="post_type"><?php _e("Style",'acf'); ?></label>
51
+ </td>
52
+ <td>
53
+ <?php
54
+
55
+ $this->create_field(array(
56
+ 'type' => 'radio',
57
+ 'name' => 'options[layout]',
58
+ 'value' => $options['layout'],
59
+ 'choices' => array(
60
+ 'default' => 'Standard Metabox',
61
+ 'no_box' => 'No Metabox',
62
+ )
63
+ ));
64
+
65
+ ?>
66
+ </td>
67
+ </tr>
68
+ <tr>
69
+ <td class="label">
70
+ <label for="post_type"><?php _e("Show on page",'acf'); ?></label>
71
+ <p class="description"><?php _e("Deselect items to hide them on the edit page",'acf'); ?></p>
72
+ <p class="description"><?php _e("If multiple ACF groups appear on an edit page, the first ACF group's options will be used. The first ACF group is the one with the lowest order number.",'acf'); ?></p>
73
+ </td>
74
+ <td>
75
+ <?php
76
+
77
+ $this->create_field(array(
78
+ 'type' => 'checkbox',
79
+ 'name' => 'options[show_on_page]',
80
+ 'value' => $options['show_on_page'],
81
+ 'choices' => array(
82
+ 'the_content' => 'Content Editor',
83
+ 'custom_fields' => 'Custom Fields',
84
+ 'discussion' => 'Discussion',
85
+ 'comments' => 'Comments',
86
+ 'slug' => 'Slug',
87
+ 'author' => 'Author'
88
+ )
89
+ ));
90
+
91
+ ?>
92
+ </td>
93
+ </tr>
94
+
95
+ </table>
core/admin/options_meta_box.php DELETED
@@ -1,73 +0,0 @@
1
- <?php
2
-
3
- global $post;
4
-
5
- // get options
6
- $options = $this->get_acf_options($post->ID);
7
-
8
- // create temp field from creating inputs
9
- $temp_field = new stdClass();
10
- ?>
11
-
12
- <input type="hidden" name="options_meta_box" value="true" />
13
- <input type="hidden" name="ei_noncename" id="ei_noncename" value="<?php echo wp_create_nonce('ei-n'); ?>" />
14
-
15
- <table class="acf_input widefat" id="acf_options">
16
- <tr>
17
- <td class="label">
18
- <label for="post_type"><?php _e("Show on page",'acf'); ?></label>
19
- <p class="description"><?php _e("Deselect items to hide them on the edit page",'acf'); ?></p>
20
- <p class="description"><?php _e("If multiple ACF groups appear on an edit page, the first ACF group's options will be used. The first ACF group is the one with the lowest order number.",'acf'); ?></p>
21
- </td>
22
- <td>
23
- <?php
24
-
25
- $temp_field->type = 'checkbox';
26
- $temp_field->input_name = 'acf[options][show_on_page]';
27
- $temp_field->input_class = '';
28
- $temp_field->value = $options->show_on_page;
29
- $temp_field->options = array(
30
- 'choices' => array(
31
- 'the_content' => 'Content Editor',
32
- 'custom_fields' => 'Custom Fields',
33
- 'discussion' => 'Discussion',
34
- 'comments' => 'Comments',
35
- 'slug' => 'Slug',
36
- 'author' => 'Author'
37
- )
38
- );
39
-
40
- $this->create_field($temp_field);
41
-
42
- ?>
43
-
44
-
45
- </td>
46
- </tr>
47
- <tr>
48
- <td class="label">
49
- <label for="post_type"><?php _e("Field Group Layout",'acf'); ?></label>
50
- <p class="description"><?php _e("Display your field group with or without a box",'acf'); ?></p>
51
- </td>
52
- <td>
53
- <?php
54
-
55
- $temp_field->type = 'select';
56
- $temp_field->input_name = 'acf[options][field_group_layout]';
57
- $temp_field->input_class = '';
58
- $temp_field->value = $options->field_group_layout;
59
- $temp_field->options = array(
60
- 'choices' => array(
61
- 'in_box' => 'In a postbox',
62
- 'default' => 'No box',
63
- )
64
- );
65
-
66
- $this->create_field($temp_field);
67
-
68
- ?>
69
-
70
-
71
- </td>
72
- </tr>
73
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
core/admin/options_page.php DELETED
@@ -1,498 +0,0 @@
1
- <?php
2
-
3
- /*--------------------------------------------------------------------------
4
- *
5
- * Acf_options_page
6
- *
7
- * @author Elliot Condon
8
- * @since 2.0.4
9
- *
10
- *-------------------------------------------------------------------------*/
11
-
12
-
13
- class Acf_options_page
14
- {
15
-
16
- var $parent;
17
- var $dir;
18
-
19
- var $menu_name;
20
- var $menu_heading;
21
-
22
-
23
- /*--------------------------------------------------------------------------------------
24
- *
25
- * Acf_options_page
26
- *
27
- * @author Elliot Condon
28
- * @since 2.0.4
29
- *
30
- *-------------------------------------------------------------------------------------*/
31
- function Acf_options_page($parent)
32
- {
33
- // vars
34
- $this->parent = $parent;
35
- $this->dir = $parent->dir;
36
-
37
-
38
- // Customize the Labels here
39
- $this->menu_name = __('Options','acf');
40
- $this->menu_heading = __('Options','acf');
41
-
42
-
43
- // actions
44
- add_action('admin_menu', array($this,'admin_menu'));
45
-
46
- }
47
-
48
-
49
- /*--------------------------------------------------------------------------------------
50
- *
51
- * create_menu
52
- *
53
- * @author Elliot Condon
54
- * @since 2.0.4
55
- *
56
- *-------------------------------------------------------------------------------------*/
57
- function admin_menu()
58
- {
59
-
60
- if(!array_key_exists('options_page', $this->parent->activated_fields)){
61
- return true;
62
- }
63
-
64
-
65
- // add page
66
- $options_page = add_menu_page('acf_options', $this->menu_name, 'edit_posts', 'acf-options',array($this, 'options_page'));
67
-
68
-
69
- // some fields require js + css
70
- add_action('admin_print_scripts-'.$options_page, array($this, 'admin_print_scripts'));
71
- add_action('admin_print_styles-'.$options_page, array($this, 'admin_print_styles'));
72
-
73
-
74
- // Add admin head
75
- add_action('admin_head-'.$options_page, array($this,'admin_head'));
76
- add_action('admin_footer-'.$options_page, array($this,'admin_footer'));
77
-
78
- }
79
-
80
-
81
- /*--------------------------------------------------------------------------------------
82
- *
83
- * admin_head
84
- *
85
- * @author Elliot Condon
86
- * @since 2.0.4
87
- *
88
- *-------------------------------------------------------------------------------------*/
89
- function admin_head()
90
- {
91
- if(!array_key_exists('options_page', $this->parent->activated_fields)){exit;}
92
-
93
-
94
- // save
95
- if(isset($_POST['update_options']))
96
- {
97
- $this->update_options();
98
- }
99
-
100
-
101
- // create tyn mce instance for wysiwyg
102
- wp_tiny_mce();
103
-
104
-
105
- // add these acf's to the page
106
- echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/style.global.css" />';
107
- echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/style.input.css" />';
108
- echo '<script type="text/javascript" src="'.$this->dir.'/js/functions.input.js" ></script>';
109
-
110
-
111
- // date picker!
112
- echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/core/fields/date_picker/style.date_picker.css" />';
113
- echo '<script type="text/javascript" src="'.$this->dir.'/core/fields/date_picker/jquery.ui.datepicker.js" ></script>';
114
- }
115
-
116
-
117
- /*--------------------------------------------------------------------------------------
118
- *
119
- * admin_footer
120
- *
121
- * @author Elliot Condon
122
- * @since 2.0.4
123
- *
124
- *-------------------------------------------------------------------------------------*/
125
- function admin_footer()
126
- {
127
- wp_preload_dialogs( array( 'plugins' => 'safari,inlinepopups,spellchecker,paste,wordpress,media,fullscreen,wpeditimage,wpgallery,tabfocus' ) );
128
- }
129
-
130
-
131
- /*---------------------------------------------------------------------------------------------
132
- * admin_print_scripts / admin_print_styles
133
- *
134
- * @author Elliot Condon
135
- * @since 2.0.4
136
- *
137
- ---------------------------------------------------------------------------------------------*/
138
- function admin_print_scripts() {
139
-
140
- wp_enqueue_script(array(
141
- 'jquery',
142
- 'jquery-ui-core',
143
-
144
- // wysiwyg
145
- 'editor',
146
- 'thickbox',
147
- 'media-upload',
148
- 'word-count',
149
- 'post',
150
- 'editor-functions',
151
-
152
- // repeater
153
- 'jquery-ui-sortable'
154
-
155
- ));
156
-
157
- }
158
-
159
- function admin_print_styles() {
160
- wp_enqueue_style('thickbox');
161
- }
162
-
163
-
164
- /*--------------------------------------------------------------------------------------
165
- *
166
- * options_page
167
- *
168
- * @author Elliot Condon
169
- * @since 2.0.4
170
- *
171
- *-------------------------------------------------------------------------------------*/
172
- function options_page()
173
- {
174
- if(!array_key_exists('options_page', $this->parent->activated_fields)){exit;}
175
-
176
- // load acf's
177
- $acfs = get_pages(array(
178
- 'numberposts' => -1,
179
- 'post_type' => 'acf',
180
- 'sort_column' => 'menu_order',
181
- ));
182
-
183
- // blank array to hold acfs
184
- $add_acf = array();
185
-
186
- if($acfs)
187
- {
188
- foreach($acfs as $acf)
189
- {
190
- $add_box = false;
191
- $location = $this->parent->get_acf_location($acf->ID);
192
-
193
-
194
- if($location->allorany == 'all')
195
- {
196
- // ALL
197
-
198
- $add_box = true;
199
-
200
- if($location->rules)
201
- {
202
- foreach($location->rules as $rule)
203
- {
204
- // if any rules dont return true, dont add this acf
205
- if(!$this->parent->match_location_rule(false, $rule))
206
- {
207
- $add_box = false;
208
- }
209
- }
210
- }
211
-
212
- }
213
- elseif($location->allorany == 'any')
214
- {
215
- // ANY
216
-
217
- $add_box = false;
218
-
219
- if($location->rules)
220
- {
221
- foreach($location->rules as $rule)
222
- {
223
- // if any rules return true, add this acf
224
- if($this->parent->match_location_rule(false, $rule))
225
- {
226
- $add_box = true;
227
- }
228
- }
229
- }
230
- }
231
-
232
- if($add_box == true)
233
- {
234
- $add_acf[] = $acf;
235
- }
236
- }
237
- }
238
-
239
- ?>
240
-
241
- <div class="wrap no_move">
242
-
243
- <div class="icon32" id="icon-options-general"><br></div>
244
- <h2><?php echo $this->menu_heading; ?></h2>
245
-
246
- <?php if(isset($_POST['update_options'])): ?>
247
- <div class="updated settings-error" id="setting-error-settings_updated"><p><strong><?php _e("Settings saved",'acf'); ?></strong></p></div>
248
- <?php endif; ?>
249
-
250
- <form id="post" method="post" name="post">
251
-
252
- <div class="metabox-holder has-right-sidebar" id="poststuff">
253
-
254
- <div class="inner-sidebar" id="side-info-column">
255
-
256
- <?php if($add_acf): ?>
257
- <div class="postbox">
258
- <h3 class="hndle"><span><?php _e("Save",'acf'); ?></span></h3>
259
- <div class="inside">
260
-
261
- <input type="submit" class="button-primary" value="Save Options" name="update_options">
262
-
263
- </div>
264
- </div>
265
- <?php endif; ?>
266
-
267
- </div>
268
-
269
-
270
-
271
- <div id="post-body">
272
- <div id="post-body-content">
273
- <div id="acf_input" class="postbox">
274
- <div class="acf_fields_input" id="acf_fields_ajax">
275
- <?php
276
-
277
- if($add_acf)
278
- {
279
- foreach($add_acf as $acf)
280
- {
281
-
282
- // load acf data
283
- $options = $this->parent->get_acf_options($acf->ID);
284
- $fields = $this->parent->get_fields($acf->ID);
285
- $html = '';
286
-
287
-
288
- if($options->field_group_layout == "in_box")
289
- {
290
- echo '<div class="acf_ajax_fields postbox" data-acf_id="'.$acf->ID.'"><h3><span>'.$acf->post_title.'</span></h3><div class="inside">';
291
- }
292
- else
293
- {
294
- echo '<div class="acf_ajax_fields" data-acf_id="'.$acf->ID.'">';
295
- }
296
-
297
-
298
- foreach($fields as $field)
299
- {
300
-
301
- // if they didn't select a type, skip this field
302
- if($field->type == 'null')
303
- {
304
- continue;
305
- }
306
-
307
-
308
- // set value, id and name for field
309
- $field->value = $this->parent->load_value_for_input(0, $field);
310
- $field->input_name = isset($field->input_name) ? $field->input_name : '';
311
-
312
- $temp_field = new stdClass();
313
-
314
-
315
- echo '<div class="field">';
316
-
317
- echo '<input type="hidden" name="acf['.$field->id.'][field_id]" value="'.$field->id.'" />';
318
- echo '<input type="hidden" name="acf['.$field->id.'][field_type]" value="'.$field->type.'" />';
319
- echo '<input type="hidden" name="acf['.$field->id.'][field_name]" value="'.$field->name.'" />';
320
-
321
- if($field->type != 'repeater')
322
- {
323
- echo '<input type="hidden" name="acf['.$field->id.'][value_id]" value="'.$field->value->value_id.'" />';
324
- echo '<input type="hidden" name="acf['.$field->id.'][meta_id]" value="'.$field->value->meta_id.'" />';
325
-
326
- $temp_field->value = $field->value->value;
327
- }
328
- else
329
- {
330
- $temp_field->value = $field->value;
331
- }
332
-
333
-
334
- echo '<label for="'.$field->input_name.'">'.$field->label.'</label>';
335
-
336
-
337
- if($field->instructions)
338
- {
339
- echo '<p class="instructions">'.$field->instructions.'</p>';
340
- }
341
-
342
- $temp_field->type = $field->type;
343
- $temp_field->input_name = 'acf['.$field->id.'][value]';
344
- $temp_field->input_class = $field->type;
345
- $temp_field->options = $field->options;
346
-
347
- $this->parent->create_field($temp_field);
348
-
349
-
350
- echo '</div>';
351
-
352
-
353
- }
354
-
355
-
356
- if($options->field_group_layout == "in_box")
357
- {
358
- echo '</div></div>';
359
- }
360
- else
361
- {
362
- echo '</div>';
363
- }
364
- }
365
- }
366
- else
367
- {
368
- ?>
369
-
370
- <div class="postbox">
371
- <div title="Click to toggle" class="handlediv"><br></div>
372
- <h3 class="hndle"><span><?php _e("No Options",'acf'); ?></span></h3>
373
-
374
- <div class="inside">
375
- <div class="field">
376
- <p><?php _e("Sorry, it seems there are no fields for this options page.",'acf'); ?></p>
377
- </div>
378
- </div>
379
- </div>
380
-
381
- <?php
382
- }
383
-
384
-
385
-
386
- ?>
387
- </div>
388
- </div>
389
- </div>
390
- </div>
391
- </div>
392
- </form>
393
- </div>
394
- <script type="text/javascript">
395
- (function($){
396
- $(document).ready(function(){
397
- $('body').setup_acf();
398
- });
399
- })(jQuery);
400
- </script>
401
- <?php
402
- }
403
-
404
-
405
- /*--------------------------------------------------------------------------------------
406
- *
407
- * options_page
408
- *
409
- * @author Elliot Condon
410
- * @since 2.0.4
411
- *
412
- *-------------------------------------------------------------------------------------*/
413
- function update_options()
414
- {
415
- // tables
416
- global $wpdb;
417
- $acf_values = $wpdb->prefix.'acf_values';
418
- $wp_postmeta = $wpdb->prefix.'postmeta';
419
- $post_id = 0;
420
-
421
-
422
- // add the new values to the database
423
- foreach($_POST['acf'] as $field)
424
- {
425
-
426
- // remove all old values from the database
427
- $field_id = $field['field_id'];
428
- $values = $wpdb->get_results("SELECT v.id, m.meta_id FROM $acf_values v LEFT JOIN $wp_postmeta m ON v.value = m.meta_id WHERE v.field_id = '$field_id' AND m.post_id = '$post_id'");
429
-
430
-
431
- if($values)
432
- {
433
- foreach($values as $value)
434
- {
435
- $wpdb->query("DELETE FROM $acf_values WHERE id = '$value->id'");
436
- $wpdb->query("DELETE FROM $wp_postmeta WHERE meta_id = '$value->meta_id'");
437
- }
438
- }
439
-
440
- //var_dump($field);
441
-
442
- if(method_exists($this->parent->fields[$field['field_type']], 'save_input'))
443
- {
444
- $this->parent->fields[$field['field_type']]->save_input($post_id, $field);
445
- }
446
- else
447
- {
448
- //$field = apply_filters('wp_insert_post_data', $field);
449
- $field = stripslashes_deep( $field );
450
-
451
-
452
- // if select is a multiple (multiple select value), you need to save it as an array!
453
- if(is_array($field['value']))
454
- {
455
- $field['value'] = serialize($field['value']);
456
- }
457
-
458
-
459
- // create data: wp_postmeta
460
- $data1 = array(
461
- 'meta_id' => isset($field['meta_id']) ? $field['meta_id'] : null,
462
- 'post_id' => $post_id,
463
- 'meta_key' => $field['field_name'],
464
- 'meta_value' => $field['value']
465
- );
466
-
467
- $wpdb->insert($wp_postmeta, $data1);
468
-
469
- $new_id = $wpdb->insert_id;
470
-
471
- // create data: acf_values
472
- if($new_id && $new_id != 0)
473
- {
474
-
475
- $data2 = array(
476
- 'id' => isset($field['value_id']) ? $field['value_id'] : null,
477
- 'field_id' => $field['field_id'],
478
- 'value' => $new_id,
479
- 'post_id' => $post_id,
480
- );
481
-
482
- $wpdb->insert($acf_values, $data2);
483
-
484
- }
485
-
486
- }
487
-
488
-
489
- }
490
- //foreach($_POST['acf'] as $field)
491
- //die;
492
- }
493
-
494
-
495
-
496
- }
497
-
498
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
core/admin/upgrade.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*--------------------------------------------------------------------------------------
4
+ *
5
+ * Update - Ajax Functions
6
+ *
7
+ * @author Elliot Condon
8
+ * @since 3.0.0
9
+ *
10
+ *-------------------------------------------------------------------------------------*/
11
+
12
+ $version = get_option('acf_version','1.0.5');
13
+ $next = false;
14
+
15
+ // list of starting points
16
+ if(version_compare($version,'3.0.0') < 0)
17
+ {
18
+ $next = '3.0.0';
19
+ }
20
+ ?>
21
+
22
+ <script type="text/javascript">
23
+ (function($){
24
+
25
+ function add_message(messaage)
26
+ {
27
+ $('#wpbody-content').append('<p>' + messaage + '</p>');
28
+ }
29
+
30
+ function run_upgrade(version)
31
+ {
32
+ $.ajax({
33
+ url: ajaxurl,
34
+ data: { action : 'acf_upgrade', version : version },
35
+ type: 'post',
36
+ dataType: 'json',
37
+ success: function(json){
38
+
39
+ if(json)
40
+ {
41
+ if(json.status)
42
+ {
43
+ add_message(json.message);
44
+
45
+ // next update?
46
+ if(json.next)
47
+ {
48
+ run_upgrade(json.next);
49
+ }
50
+ else
51
+ {
52
+ // all done
53
+ add_message('Upgrade Complete! <a href="<?php echo admin_url(); ?>edit.php?post_type=acf">Continue to ACF &raquo;</a>');
54
+ }
55
+ }
56
+ else
57
+ {
58
+ // error!
59
+ add_message('Error: ' + json.message);
60
+ }
61
+ }
62
+ else
63
+ {
64
+ // major error!
65
+ add_message('Sorry. Something went wrong during the upgrade process. Please report this on the support forum');
66
+ }
67
+ }
68
+ });
69
+ }
70
+
71
+ <?php if($next){ echo 'run_upgrade("' . $next . '");'; } ?>
72
+
73
+ })(jQuery);
74
+ </script>
75
+ <style type="text/css">
76
+ #message {
77
+ display: none;
78
+ }
79
+ </style>
80
+ <?php
81
+
82
+ if(!$next)
83
+ {
84
+ echo '<p>No Upgrade Required</p>';
85
+ }
86
+
87
+ ?>
core/admin/upgrade_ajax.php ADDED
@@ -0,0 +1,387 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ global $wpdb;
4
+
5
+ // tables
6
+ $acf_fields = $wpdb->prefix.'acf_fields';
7
+ $acf_values = $wpdb->prefix.'acf_values';
8
+ $acf_rules = $wpdb->prefix.'acf_rules';
9
+ $wp_postmeta = $wpdb->prefix.'postmeta';
10
+
11
+ // vars
12
+ $return = array(
13
+ 'status' => false,
14
+ 'message' => "",
15
+ 'next' => false,
16
+ );
17
+
18
+ // versions
19
+ switch($_POST['version'])
20
+ {
21
+
22
+ /*---------------------
23
+ *
24
+ * 3.0.0
25
+ *
26
+ *--------------------*/
27
+
28
+ case '3.0.0':
29
+
30
+ // upgrade options first as "field_group_layout" will cause get_fields to fail!
31
+
32
+ // get acf's
33
+ $acfs = get_pages(array(
34
+ 'numberposts' => -1,
35
+ 'post_type' => 'acf',
36
+ 'sort_column' => 'menu_order',
37
+ 'order' => 'ASC',
38
+ ));
39
+
40
+ if($acfs)
41
+ {
42
+ foreach($acfs as $acf)
43
+ {
44
+ // position
45
+ update_post_meta($acf->ID, 'position', 'normal');
46
+
47
+ //layout
48
+ $layout = get_post_meta($acf->ID, 'field_group_layout', true) ? get_post_meta($acf->ID, 'field_group_layout', true) : 'in_box';
49
+ if($layout == 'in_box')
50
+ {
51
+ $layout = 'default';
52
+ }
53
+ else
54
+ {
55
+ $layout = 'no_box';
56
+ }
57
+ update_post_meta($acf->ID, 'layout', $layout);
58
+ delete_post_meta($acf->ID, 'field_group_layout');
59
+
60
+ // show_on_page
61
+ $show_on_page = get_post_meta($acf->ID, 'show_on_page', true) ? get_post_meta($acf->ID, 'show_on_page', true) : array();
62
+ if($show_on_page)
63
+ {
64
+ $show_on_page = unserialize($show_on_page);
65
+ }
66
+ update_post_meta($acf->ID, 'show_on_page', $show_on_page);
67
+
68
+ }
69
+ }
70
+
71
+ $return = array(
72
+ 'status' => true,
73
+ 'message' => "Migrating Options...",
74
+ 'next' => '3.0.0 (step 2)',
75
+ );
76
+
77
+ break;
78
+
79
+ /*---------------------
80
+ *
81
+ * 3.0.0
82
+ *
83
+ *--------------------*/
84
+
85
+ case '3.0.0 (step 2)':
86
+
87
+ // get acf's
88
+ $acfs = get_pages(array(
89
+ 'numberposts' => -1,
90
+ 'post_type' => 'acf',
91
+ 'sort_column' => 'menu_order',
92
+ 'order' => 'ASC',
93
+ ));
94
+
95
+ if($acfs)
96
+ {
97
+ foreach($acfs as $acf)
98
+ {
99
+ // allorany doesn't need to change!
100
+
101
+ $rules = $wpdb->get_results("SELECT * FROM $acf_rules WHERE acf_id = '$acf->ID' ORDER BY order_no ASC", ARRAY_A);
102
+
103
+ if($rules)
104
+ {
105
+ foreach($rules as $rule)
106
+ {
107
+ // options rule has changed
108
+ if($rule['param'] == 'options_page')
109
+ {
110
+ $rule['value'] = 'Options';
111
+ }
112
+
113
+ add_post_meta($acf->ID, 'rule', $rule);
114
+ }
115
+ }
116
+
117
+ }
118
+ }
119
+
120
+ $return = array(
121
+ 'status' => true,
122
+ 'message' => "Migrating Location Rules...",
123
+ 'next' => '3.0.0 (step 3)',
124
+ );
125
+
126
+ break;
127
+
128
+ /*---------------------
129
+ *
130
+ * 3.0.0
131
+ *
132
+ *--------------------*/
133
+
134
+ case '3.0.0 (step 3)':
135
+
136
+ $message = "Migrating Fields…";
137
+
138
+ $parent_id = 0;
139
+ $fields = $wpdb->get_results("SELECT * FROM $acf_fields WHERE parent_id = $parent_id ORDER BY order_no, name", ARRAY_A);
140
+
141
+ if($fields)
142
+ {
143
+ // loop through fields
144
+ foreach($fields as $field)
145
+ {
146
+
147
+ // unserialize options
148
+ if(@unserialize($field['options']))
149
+ {
150
+ $field['options'] = unserialize($field['options']);
151
+ }
152
+ else
153
+ {
154
+ $field['options'] = array();
155
+ }
156
+
157
+
158
+ // sub fields
159
+ if($field['type'] == 'repeater')
160
+ {
161
+ $field['options']['sub_fields'] = array();
162
+
163
+ $parent_id = $field['id'];
164
+ $sub_fields = $wpdb->get_results("SELECT * FROM $acf_fields WHERE parent_id = $parent_id ORDER BY order_no, name", ARRAY_A);
165
+
166
+
167
+ // if fields are empty, this must be a new or broken acf.
168
+ if(empty($sub_fields))
169
+ {
170
+ $field['options']['sub_fields'] = array();
171
+ }
172
+ else
173
+ {
174
+ // loop through fields
175
+ foreach($sub_fields as $sub_field)
176
+ {
177
+ // unserialize options
178
+ if(@unserialize($sub_field['options']))
179
+ {
180
+ $sub_field['options'] = @unserialize($sub_field['options']);
181
+ }
182
+ else
183
+ {
184
+ $sub_field['options'] = array();
185
+ }
186
+
187
+ // merge options with field
188
+ $sub_field = array_merge($sub_field, $sub_field['options']);
189
+
190
+ unset($sub_field['options']);
191
+
192
+ // each field has a unique id!
193
+ if(!isset($sub_field['key'])) $sub_field['key'] = 'field_' . $sub_field['id'];
194
+
195
+ $field['options']['sub_fields'][] = $sub_field;
196
+ }
197
+ }
198
+
199
+ }
200
+ // end if sub field
201
+
202
+
203
+ // merge options with field
204
+ $field = array_merge($field, $field['options']);
205
+
206
+ unset($field['options']);
207
+
208
+ // each field has a unique id!
209
+ if(!isset($field['key'])) $field['key'] = 'field_' . $field['id'];
210
+
211
+ // update field
212
+ update_post_meta($field['post_id'], $field['key'], $field);
213
+ //$this->update_field($field['post_id'], $field);
214
+
215
+
216
+ // create field name (field_rand)
217
+ //$message .= print_r($field, true) . '<br /><br />';
218
+ }
219
+ // end foreach $fields
220
+ }
221
+
222
+
223
+ $return = array(
224
+ 'status' => true,
225
+ 'message' => $message,
226
+ 'next' => '3.0.0 (step 4)',
227
+ );
228
+
229
+ break;
230
+
231
+ /*---------------------
232
+ *
233
+ * 3.0.0
234
+ *
235
+ *--------------------*/
236
+
237
+ case '3.0.0 (step 4)':
238
+
239
+ $message = "Migrating Values...";
240
+
241
+ // update normal values
242
+ $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);
243
+ if($values)
244
+ {
245
+ foreach($values as $value)
246
+ {
247
+ // options page
248
+ if($value['post_id'] == 0) $value['post_id'] = 999999999;
249
+
250
+ // unserialize value (relationship, multi select, etc)
251
+ if(@unserialize($value['meta_value']))
252
+ {
253
+ $value['meta_value'] = unserialize($value['meta_value']);
254
+ }
255
+
256
+ update_post_meta($value['post_id'], $value['meta_key'], $value['meta_value']);
257
+ update_post_meta($value['post_id'], '_' . $value['meta_key'], 'field_' . $value['field_id']);
258
+ }
259
+ }
260
+
261
+ // update repeater values
262
+ $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);
263
+ if($values)
264
+ {
265
+ $rows = array();
266
+
267
+ foreach($values as $value)
268
+ {
269
+ // update row count
270
+ $row = (int) $value['order_no'] + 1;
271
+
272
+ // options page
273
+ if($value['post_id'] == 0) $value['post_id'] = 999999999;
274
+
275
+ // unserialize value (relationship, multi select, etc)
276
+ if(@unserialize($value['meta_value']))
277
+ {
278
+ $value['meta_value'] = unserialize($value['meta_value']);
279
+ }
280
+
281
+ // current row
282
+ $current_row = isset($rows[$value['post_id']][$value['field_id']]) ? $rows[$value['post_id']][$value['field_id']] : 0;
283
+ if($row > $current_row) $rows[$value['post_id']][$value['field_id']] = (int) $row;
284
+
285
+ // get field name
286
+ $field_name = $wpdb->get_var($wpdb->prepare("SELECT name FROM $acf_fields WHERE id = %d", $value['field_id']));
287
+
288
+ // get sub field name
289
+ $sub_field_name = $wpdb->get_var($wpdb->prepare("SELECT name FROM $acf_fields WHERE id = %d", $value['sub_field_id']));
290
+
291
+ // save new value
292
+ $new_meta_key = $field_name . '_' . $value['order_no'] . '_' . $sub_field_name;
293
+ update_post_meta($value['post_id'], $new_meta_key , $value['meta_value']);
294
+
295
+ // save value hidden field id
296
+ update_post_meta($value['post_id'], '_' . $new_meta_key, 'field_' . $value['sub_field_id']);
297
+ }
298
+
299
+ foreach($rows as $post_id => $field_ids)
300
+ {
301
+ foreach($field_ids as $field_id => $row_count)
302
+ {
303
+ // get sub field name
304
+ $field_name = $wpdb->get_var($wpdb->prepare("SELECT name FROM $acf_fields WHERE id = %d", $field_id));
305
+
306
+ delete_post_meta($post_id, $field_name);
307
+ update_post_meta($post_id, $field_name, $row_count);
308
+ update_post_meta($post_id, '_' . $field_name, 'field_' . $field_id);
309
+
310
+ }
311
+ }
312
+
313
+ }
314
+
315
+ // update version (only upgrade 1 time)
316
+ update_option('acf_version','3.0.0');
317
+
318
+ $return = array(
319
+ 'status' => true,
320
+ 'message' => $message,
321
+ 'next' => false,
322
+ );
323
+
324
+ break;
325
+
326
+ /*---------------------
327
+ *
328
+ * 3.0.0 rc1
329
+ *
330
+ *--------------------
331
+
332
+ case '3.0.0 beta rc1':
333
+
334
+ $message = "Renaming ACF data...";
335
+
336
+ $acfs = get_pages(array(
337
+ 'numberposts' => -1,
338
+ 'post_type' => 'acf',
339
+ 'sort_column' => 'menu_order',
340
+ 'order' => 'ASC',
341
+ ));
342
+
343
+ if($acfs)
344
+ {
345
+ foreach($acfs as $acf)
346
+ {
347
+
348
+
349
+
350
+ $keys = get_post_custom_keys($post_id);
351
+
352
+ if($keys)
353
+ {
354
+ foreach($keys as $key)
355
+ {
356
+ if(strpos($key, 'field_') !== false)
357
+ {
358
+ $sub_field_name = $wpdb->get_var($wpdb->prepare("UPDATE meta_key %s FROM $wp_postmeta WHERE meta_key = %s", $value['sub_field_id']));
359
+
360
+ $field = $this->get_acf_field($key, $post_id);
361
+
362
+
363
+
364
+
365
+
366
+ $fields = $this->get_acf_fields($acf->ID);
367
+
368
+ if($fields)
369
+ {
370
+ foreach($acfs as $acf)
371
+ {
372
+ update_post_meta($post_id, $field['key'], $field);
373
+ }
374
+ }
375
+
376
+ }
377
+ }
378
+
379
+ break;
380
+ */
381
+ }
382
+
383
+ // return json
384
+ echo json_encode($return);
385
+ die;
386
+
387
+ ?>
core/api.php CHANGED
@@ -1,13 +1,9 @@
1
  <?php
2
 
3
- global $acf_global;
 
4
 
5
- $acf_global = array(
6
- 'field' => 0,
7
- 'order_no' => -1,
8
- );
9
 
10
-
11
  /*--------------------------------------------------------------------------------------
12
  *
13
  * get_fields
@@ -19,19 +15,8 @@ $acf_global = array(
19
 
20
  function get_fields($post_id = false)
21
  {
 
22
  global $post;
23
- global $wpdb;
24
- global $acf;
25
-
26
-
27
- $values = array();
28
-
29
-
30
- // tables
31
- $acf_values = $wpdb->prefix.'acf_values';
32
- $acf_fields = $wpdb->prefix.'acf_fields';
33
- $wp_postmeta = $wpdb->prefix.'postmeta';
34
-
35
 
36
  if(!$post_id)
37
  {
@@ -39,38 +24,37 @@ function get_fields($post_id = false)
39
  }
40
  elseif($post_id == "options")
41
  {
42
- $post_id = 0;
43
  }
44
 
 
 
45
 
46
- $sql = "SELECT f.name
47
- FROM $wp_postmeta m
48
- LEFT JOIN $acf_values v ON m.meta_id = v.value
49
- LEFT JOIN $acf_fields f ON v.field_id = f.id
50
- WHERE m.post_id = '$post_id' AND f.name != 'NULL'";
51
 
52
- $results = $wpdb->get_results($sql);
53
-
54
-
 
 
 
 
 
 
 
 
55
  // no value
56
- if(!$results)
57
  {
58
  return false;
59
  }
60
 
61
-
62
- // repeater field
63
- foreach($results as $field)
64
- {
65
- $values[$field->name] = get_field($field->name, $post_id);
66
- }
67
-
68
-
69
- return $values;
70
 
71
  }
72
 
73
 
 
74
  /*--------------------------------------------------------------------------------------
75
  *
76
  * get_field
@@ -80,20 +64,9 @@ function get_fields($post_id = false)
80
  *
81
  *-------------------------------------------------------------------------------------*/
82
 
83
- function get_field($field_name, $post_id = false, $options = array())
84
  {
85
-
86
- global $post;
87
- global $wpdb;
88
- global $acf;
89
-
90
- $return_id = isset($options['return_id']) ? $options['return_id'] : false;
91
-
92
- // tables
93
- $acf_values = $wpdb->prefix.'acf_values';
94
- $acf_fields = $wpdb->prefix.'acf_fields';
95
- $wp_postmeta = $wpdb->prefix.'postmeta';
96
-
97
 
98
  if(!$post_id)
99
  {
@@ -101,120 +74,30 @@ function get_field($field_name, $post_id = false, $options = array())
101
  }
102
  elseif($post_id == "options")
103
  {
104
- $post_id = 0;
105
  }
106
 
 
 
107
 
108
- $sql = "SELECT m.meta_value as value, v.id, f.type, f.options, v.sub_field_id, v.order_no
109
- FROM $wp_postmeta m
110
- LEFT JOIN $acf_values v ON m.meta_id = v.value
111
- LEFT JOIN $acf_fields f ON v.field_id = f.id
112
- WHERE f.name = '$field_name' AND m.post_id = '$post_id' ORDER BY v.order_no ASC";
113
-
114
- $results = $wpdb->get_results($sql);
115
-
116
 
117
- // no value
118
- if(!$results)
119
  {
120
- return false;
 
 
121
  }
122
-
123
-
124
-
125
- // normal field
126
- $field = $results[0];
127
-
128
-
129
- // repeater field
130
- if($field->type == 'repeater')
131
  {
132
- $return_array = array();
133
-
134
- foreach($results as $result)
135
- {
136
- $sql2 = "SELECT type, name, options
137
- FROM $acf_fields
138
- WHERE id = '$result->sub_field_id'";
139
-
140
- $sub_field = $wpdb->get_row($sql2);
141
-
142
-
143
- // format the sub field value
144
- if($acf->field_method_exists($sub_field->type, 'format_value_for_api'))
145
- {
146
- if(@unserialize($sub_field->options))
147
- {
148
- $sub_field->options = unserialize($sub_field->options);
149
- }
150
- else
151
- {
152
- $sub_field->options = array();
153
- }
154
-
155
- $result->value = $acf->fields[$sub_field->type]->format_value_for_api($result->value, $sub_field->options);
156
- }
157
-
158
-
159
- // only add the value if it is not null or false
160
- if($result->value != '' || $result->value != false)
161
- {
162
- if($return_id)
163
- {
164
- $return_array[$result->order_no][$sub_field->name]['id'] = (int) $result->id;
165
- $return_array[$result->order_no][$sub_field->name]['value'] = $result->value;
166
- }
167
- else
168
- {
169
- $return_array[$result->order_no][$sub_field->name] = $result->value;
170
- }
171
-
172
- }
173
-
174
- }
175
-
176
-
177
- // if empty, just return false
178
- if(empty($return_array))
179
- {
180
- $return_array = false;
181
- }
182
-
183
- return $return_array;
184
-
185
  }
186
 
187
-
188
- $value = $field->value;
189
-
190
-
191
- // format if needed
192
- if($acf->field_method_exists($field->type, 'format_value_for_api'))
193
- {
194
 
195
- if(@unserialize($field->options))
196
- {
197
- $field->options = unserialize($field->options);
198
- }
199
- else
200
- {
201
- $field->options = array();
202
- }
203
-
204
- $value = $acf->fields[$field->type]->format_value_for_api($value, $field->options);
205
- }
206
-
207
-
208
- if($return_id)
209
- {
210
- $return_array = array(
211
- 'id' => (int) $field->id,
212
- 'value' => $value,
213
- );
214
- return $return_array;
215
- }
216
-
217
-
218
  return $value;
219
 
220
  }
@@ -231,16 +114,7 @@ function get_field($field_name, $post_id = false, $options = array())
231
 
232
  function the_field($field_name, $post_id = false)
233
  {
234
-
235
- $value = get_field($field_name, $post_id);
236
-
237
- if(is_array($value))
238
- {
239
- $value = @implode(', ',$value);
240
- }
241
-
242
- echo $value;
243
-
244
  }
245
 
246
 
@@ -255,24 +129,20 @@ function the_field($field_name, $post_id = false)
255
 
256
  function the_repeater_field($field_name, $post_id = false)
257
  {
258
- global $acf_global;
259
-
260
 
261
  // if no field, create field + reset count
262
- if(!$acf_global['field'])
263
  {
264
- $acf_global['order_no'] = -1;
265
- $acf_global['field'] = get_field($field_name, $post_id);
266
  }
267
 
268
-
269
  // increase order_no
270
- $acf_global['order_no']++;
271
-
272
 
273
  // vars
274
- $field = $acf_global['field'];
275
- $i = $acf_global['order_no'];
276
 
277
  if(isset($field[$i]))
278
  {
@@ -280,13 +150,28 @@ function the_repeater_field($field_name, $post_id = false)
280
  }
281
 
282
  // no row, reset the global values
283
- $acf_global['order_no'] = -1;
284
- $acf_global['field'] = false;
285
  return false;
286
 
287
  }
288
 
289
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
290
  /*--------------------------------------------------------------------------------------
291
  *
292
  * get_sub_field
@@ -298,12 +183,10 @@ function the_repeater_field($field_name, $post_id = false)
298
 
299
  function get_sub_field($field_name)
300
  {
301
- // global
302
- global $acf_global;
303
-
304
  // vars
305
- $field = $acf_global['field'];
306
- $i = $acf_global['order_no'];
307
 
308
  // no value
309
  if(!$field) return false;
@@ -338,49 +221,29 @@ function the_sub_field($field_name, $field = false)
338
 
339
  /*--------------------------------------------------------------------------------------
340
  *
341
- * update_the_field
342
  *
343
  * @author Elliot Condon
344
- * @since 2.1.4
345
  *
346
  *-------------------------------------------------------------------------------------*/
347
 
348
- function update_the_field($field_name = false, $value = false, $post_id = false)
 
 
349
  {
350
- // checkpoint
351
- if(!$field_name || !$value || !$post_id) return false;
352
-
353
- // global
354
- global $wpdb;
355
-
356
- // tables
357
- $acf_values = $wpdb->prefix.'acf_values';
358
- $acf_fields = $wpdb->prefix.'acf_fields';
359
- $wp_postmeta = $wpdb->prefix.'postmeta';
360
-
361
- // sql
362
- $sql = "SELECT m.meta_id
363
- FROM $wp_postmeta m
364
- LEFT JOIN $acf_values v ON m.meta_id = v.value
365
- LEFT JOIN $acf_fields f ON v.field_id = f.id
366
- WHERE f.name = '$field_name' AND m.post_id = '$post_id'";
367
-
368
- $meta_id = $wpdb->get_var($sql);
369
-
370
- // no meta_value
371
- if(!$meta_id)
372
- {
373
- return false;
374
- }
375
-
376
- // update
377
- $save = $wpdb->update($wp_postmeta, array('meta_value' => $value), array('meta_id' => $meta_id));
378
-
379
- // return
380
- if($save) return true;
381
-
382
- return false;
383
 
 
384
  }
 
385
 
386
  ?>
1
  <?php
2
 
3
+ // set some globals
4
+ reset_the_repeater_field();
5
 
 
 
 
 
6
 
 
7
  /*--------------------------------------------------------------------------------------
8
  *
9
  * get_fields
15
 
16
  function get_fields($post_id = false)
17
  {
18
+ // vars
19
  global $post;
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  if(!$post_id)
22
  {
24
  }
25
  elseif($post_id == "options")
26
  {
27
+ $post_id = 999999999;
28
  }
29
 
30
+ // default
31
+ $value = array();
32
 
33
+ $keys = get_post_custom_keys($post_id);
 
 
 
 
34
 
35
+ if($keys)
36
+ {
37
+ foreach($keys as $key)
38
+ {
39
+ if(substr($key, 0, 1) != "_")
40
+ {
41
+ $value[$key] = get_field($key, $post_id);
42
+ }
43
+ }
44
+ }
45
+
46
  // no value
47
+ if(empty($value))
48
  {
49
  return false;
50
  }
51
 
52
+ return $value;
 
 
 
 
 
 
 
 
53
 
54
  }
55
 
56
 
57
+
58
  /*--------------------------------------------------------------------------------------
59
  *
60
  * get_field
64
  *
65
  *-------------------------------------------------------------------------------------*/
66
 
67
+ function get_field($field_name, $post_id = false)
68
  {
69
+ global $post, $acf;
 
 
 
 
 
 
 
 
 
 
 
70
 
71
  if(!$post_id)
72
  {
74
  }
75
  elseif($post_id == "options")
76
  {
77
+ $post_id = 999999999;
78
  }
79
 
80
+ // default
81
+ $value = "";
82
 
83
+ // get value
84
+ $field_key = get_post_meta($post_id, '_' . $field_name, true);
 
 
 
 
 
 
85
 
86
+ if($field_key != "")
 
87
  {
88
+ // we can load the field properly!
89
+ $field = $acf->get_acf_field($field_key);
90
+ $value = $acf->get_value_for_api($post_id, $field);
91
  }
92
+ else
 
 
 
 
 
 
 
 
93
  {
94
+ // just load the text version
95
+ $value = get_post_meta($post_id, $field_name, true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  }
97
 
98
+ // no value?
99
+ if($value == "") $value = false;
 
 
 
 
 
100
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  return $value;
102
 
103
  }
114
 
115
  function the_field($field_name, $post_id = false)
116
  {
117
+ echo get_field($field_name, $post_id);
 
 
 
 
 
 
 
 
 
118
  }
119
 
120
 
129
 
130
  function the_repeater_field($field_name, $post_id = false)
131
  {
 
 
132
 
133
  // if no field, create field + reset count
134
+ if(!$GLOBALS['acf_field'])
135
  {
136
+ reset_the_repeater_field();
137
+ $GLOBALS['acf_field'] = get_field($field_name, $post_id);
138
  }
139
 
 
140
  // increase order_no
141
+ $GLOBALS['acf_count']++;
 
142
 
143
  // vars
144
+ $field = $GLOBALS['acf_field'];
145
+ $i = $GLOBALS['acf_count'];
146
 
147
  if(isset($field[$i]))
148
  {
150
  }
151
 
152
  // no row, reset the global values
153
+ reset_the_repeater_field();
 
154
  return false;
155
 
156
  }
157
 
158
 
159
+ /*--------------------------------------------------------------------------------------
160
+ *
161
+ * reset_the_repeater_field
162
+ *
163
+ * @author Elliot Condon
164
+ * @since 1.0.3
165
+ *
166
+ *-------------------------------------------------------------------------------------*/
167
+
168
+ function reset_the_repeater_field()
169
+ {
170
+ $GLOBALS['acf_field'] = false;
171
+ $GLOBALS['acf_count'] = -1;
172
+ }
173
+
174
+
175
  /*--------------------------------------------------------------------------------------
176
  *
177
  * get_sub_field
183
 
184
  function get_sub_field($field_name)
185
  {
186
+
 
 
187
  // vars
188
+ $field = $GLOBALS['acf_field'];
189
+ $i = $GLOBALS['acf_count'];
190
 
191
  // no value
192
  if(!$field) return false;
221
 
222
  /*--------------------------------------------------------------------------------------
223
  *
224
+ * register_field
225
  *
226
  * @author Elliot Condon
227
+ * @since 3.0.0
228
  *
229
  *-------------------------------------------------------------------------------------*/
230
 
231
+ $GLOBALS['acf_register_field'] = array();
232
+
233
+ function register_field($class = "", $url = "")
234
  {
235
+ $GLOBALS['acf_register_field'][] = array(
236
+ 'url' => $url,
237
+ 'class' => $class,
238
+ );
239
+ }
240
+
241
+ function acf_register_field($array)
242
+ {
243
+ $array = array_merge($array, $GLOBALS['acf_register_field']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
244
 
245
+ return $array;
246
  }
247
+ add_filter('acf_register_field', 'acf_register_field');
248
 
249
  ?>
core/fields/acf_field.php ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This is the base acf field frow which
5
+ * all other fields extend. Here you can
6
+ * find every function for your field
7
+ *
8
+ */
9
+
10
+ class acf_Field
11
+ {
12
+ var $name;
13
+ var $title;
14
+ var $parent;
15
+
16
+
17
+ /*--------------------------------------------------------------------------------------
18
+ *
19
+ * Constructor
20
+ * - $parent is passed buy reference so you can play with the acf functions
21
+ *
22
+ * @author Elliot Condon
23
+ * @since 2.2.0
24
+ *
25
+ *-------------------------------------------------------------------------------------*/
26
+
27
+ function __construct($parent)
28
+ {
29
+ $this->parent = $parent;
30
+ }
31
+
32
+
33
+ /*--------------------------------------------------------------------------------------
34
+ *
35
+ * create_field
36
+ * - called in lots of places to create the html version of the field
37
+ *
38
+ * @author Elliot Condon
39
+ * @since 2.2.0
40
+ *
41
+ *-------------------------------------------------------------------------------------*/
42
+
43
+ function create_field($field)
44
+ {
45
+
46
+ }
47
+
48
+
49
+ /*--------------------------------------------------------------------------------------
50
+ *
51
+ * create_options
52
+ * - called from core/field_meta_box.php to create special options
53
+ *
54
+ * @params : $key (int) - neccessary to group field data together for saving
55
+ * $field (array) - the field data from the database
56
+ * @author Elliot Condon
57
+ * @since 2.2.0
58
+ *
59
+ *-------------------------------------------------------------------------------------*/
60
+
61
+ function create_options($key, $field)
62
+ {
63
+
64
+ }
65
+
66
+
67
+ /*--------------------------------------------------------------------------------------
68
+ *
69
+ * admin_head
70
+ *
71
+ * @author Elliot Condon
72
+ * @since 2.2.0
73
+ *
74
+ *-------------------------------------------------------------------------------------*/
75
+
76
+ function admin_head()
77
+ {
78
+
79
+ }
80
+
81
+
82
+ /*--------------------------------------------------------------------------------------
83
+ *
84
+ * admin_print_scripts / admin_print_styles
85
+ *
86
+ * @author Elliot Condon
87
+ * @since 3.0.0
88
+ *
89
+ *-------------------------------------------------------------------------------------*/
90
+
91
+ function admin_print_scripts()
92
+ {
93
+
94
+ }
95
+
96
+ function admin_print_styles()
97
+ {
98
+
99
+ }
100
+
101
+
102
+ /*--------------------------------------------------------------------------------------
103
+ *
104
+ * update_value
105
+ *
106
+ * @author Elliot Condon
107
+ * @since 2.2.0
108
+ *
109
+ *-------------------------------------------------------------------------------------*/
110
+
111
+ function update_value($post_id, $field, $value)
112
+ {
113
+ update_post_meta($post_id, $field['name'], $value);
114
+ update_post_meta($post_id, '_' . $field['name'], $field['key']);
115
+ }
116
+
117
+
118
+ /*--------------------------------------------------------------------------------------
119
+ *
120
+ * pre_save_field
121
+ * - called just before saving the field to the database.
122
+ *
123
+ * @author Elliot Condon
124
+ * @since 2.2.0
125
+ *
126
+ *-------------------------------------------------------------------------------------*/
127
+
128
+ function pre_save_field($field)
129
+ {
130
+ return $field;
131
+ }
132
+
133
+
134
+ /*--------------------------------------------------------------------------------------
135
+ *
136
+ * get_value
137
+ *
138
+ * @author Elliot Condon
139
+ * @since 2.2.0
140
+ *
141
+ *-------------------------------------------------------------------------------------*/
142
+
143
+ function get_value($post_id, $field)
144
+ {
145
+ // If this is a new acf, there will be no custom keys!
146
+ if(!get_post_custom_keys($post_id) && isset($field['default_value']))
147
+ {
148
+ return $field['default_value'];
149
+ }
150
+
151
+ return get_post_meta($post_id, $field['name'], true);
152
+ }
153
+
154
+
155
+ /*--------------------------------------------------------------------------------------
156
+ *
157
+ * get_value_for_api
158
+ *
159
+ * @author Elliot Condon
160
+ * @since 3.0.0
161
+ *
162
+ *-------------------------------------------------------------------------------------*/
163
+
164
+ function get_value_for_api($post_id, $field)
165
+ {
166
+ return $this->get_value($post_id, $field);
167
+ }
168
+
169
+
170
+ /*--------------------------------------------------------------------------------------
171
+ *
172
+ * format_value_for_input
173
+ * -
174
+ *
175
+ * @author Elliot Condon
176
+ * @since 2.2.0
177
+ *
178
+ *-------------------------------------------------------------------------------------
179
+
180
+ function format_value_for_input($value, $field)
181
+ {
182
+ return $value;
183
+ }
184
+ */
185
+
186
+ /*--------------------------------------------------------------------------------------
187
+ *
188
+ * format_value_for_api
189
+ * -
190
+ *
191
+ * @author Elliot Condon
192
+ * @since 2.2.0
193
+ *
194
+ *-------------------------------------------------------------------------------------
195
+
196
+ function format_value_for_api($value, $field)
197
+ {
198
+ return $value;
199
+ }
200
+ */
201
+ }
202
+
203
+ ?>
core/fields/checkbox.php CHANGED
@@ -1,84 +1,102 @@
1
  <?php
2
 
3
- class acf_Checkbox
4
  {
5
- var $name;
6
- var $title;
7
 
8
- function acf_Checkbox()
 
 
 
 
 
 
 
 
 
 
9
  {
10
- $this->name = 'checkbox';
11
- $this->title = __('Checkbox','acf');
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
- function html($field)
15
  {
16
- if(empty($field->value))
17
- {
18
- $field->value = array();
19
- }
20
 
21
- if(empty($field->options['choices']))
 
22
  {
23
-
24
  echo '<p>' . __("No choices to choose from",'acf') . '</p>';
25
  return false;
26
  }
27
 
28
- echo '<ul class="checkbox_list '.$field->input_class.'">';
29
- // loop through values and add them as options
 
 
 
30
 
31
- $name_extra = '[]';
32
- if(count($field->options['choices']) <= 1)
33
- {
34
- $name_extra = '';
35
- }
36
-
37
- foreach($field->options['choices'] as $key => $value)
38
  {
39
  $selected = '';
40
- if(in_array($key, $field->value))
41
  {
42
  $selected = 'checked="yes"';
43
  }
44
- echo '<li><label><input type="checkbox" class="'.$field->input_class.'" name="'.$field->input_name.$name_extra.'" value="'.$key.'" '.$selected.' />'.$value.'</label></li>';
45
  }
 
46
  echo '</ul>';
47
 
48
  }
49
 
50
 
51
- /*---------------------------------------------------------------------------------------------
52
- * Options HTML
53
- * - called from fields_meta_box.php
54
- * - displays options in html format
55
- *
56
- * @author Elliot Condon
57
- * @since 1.1
58
- *
59
- ---------------------------------------------------------------------------------------------*/
60
- function options_html($key, $field)
61
- {
62
- $options = $field->options;
 
 
63
 
64
  // implode checkboxes so they work in a textarea
65
- if(isset($options['choices']) && is_array($options['choices']))
66
  {
67
- foreach($options['choices'] as $choice_key => $choice_val)
68
  {
69
- $options['choices'][$choice_key] = $choice_key.' : '.$choice_val;
70
  }
71
- $options['choices'] = implode("\n", $options['choices']);
72
  }
73
  else
74
  {
75
- $options['choices'] = "";
76
  }
77
-
78
  ?>
79
-
80
-
81
- <tr class="field_option field_option_checkbox">
82
  <td class="label">
83
  <label for=""><?php _e("Choices",'acf'); ?></label>
84
  <p class="description"><?php _e("Enter your choices one per line<br />
@@ -92,53 +110,48 @@ class acf_Checkbox
92
  blue : Blue",'acf'); ?></p>
93
  </td>
94
  <td>
95
- <textarea rows="5" name="acf[fields][<?php echo $key; ?>][options][choices]" id=""><?php echo $options['choices']; ?></textarea>
96
  </td>
97
  </tr>
98
-
99
-
100
  <?php
101
  }
102
 
103
 
 
 
 
 
 
 
 
 
 
104
 
105
- /*---------------------------------------------------------------------------------------------
106
- * Format Options
107
- * - this is called from save_field.php, this function formats the options into a savable format
108
- *
109
- * @author Elliot Condon
110
- * @since 1.1
111
- *
112
- ---------------------------------------------------------------------------------------------*/
113
- function format_options($options)
114
- {
115
- // if no choices, dont do anything
116
- if(!$options['choices'] || is_array($options['choices']))
117
- {
118
- return $options;
119
- }
120
 
 
 
121
 
122
  // explode choices from each line
123
- if(strpos($options['choices'], "\n") !== false)
124
  {
125
  // found multiple lines, explode it
126
- $choices = explode("\n", $options['choices']);
127
  }
128
  else
129
  {
130
  // no multiple lines!
131
- $choices = array($options['choices']);
132
  }
133
 
134
-
135
-
136
- $new_choices = array();
137
- foreach($choices as $choice)
138
  {
139
  if(strpos($choice, ' : ') !== false)
140
  {
141
-
142
  $choice = explode(' : ', $choice);
143
  $new_choices[trim($choice[0])] = trim($choice[1]);
144
  }
@@ -148,42 +161,13 @@ class acf_Checkbox
148
  }
149
  }
150
 
 
 
151
 
152
- // return array containing all choices
153
- $options['choices'] = $new_choices;
154
-
155
- return $options;
156
- }
157
-
158
-
159
- /*---------------------------------------------------------------------------------------------
160
- * Format Value
161
- * - this is called from api.php
162
- *
163
- * @author Elliot Condon
164
- * @since 1.1
165
- *
166
- ---------------------------------------------------------------------------------------------*/
167
- function format_value_for_api($value, $options = null)
168
- {
169
- if(is_array(unserialize($value)))
170
- {
171
- return(unserialize($value));
172
- }
173
- }
174
-
175
- /*---------------------------------------------------------------------------------------------
176
- * Format Value for input
177
- * - this is called from acf.php
178
- *
179
- * @author Elliot Condon
180
- * @since 1.1
181
- *
182
- ---------------------------------------------------------------------------------------------*/
183
- function format_value_for_input($value)
184
- {
185
- return $this->format_value_for_api($value);
186
  }
 
187
  }
188
-
189
  ?>
1
  <?php
2
 
3
+ class acf_Checkbox extends acf_Field
4
  {
 
 
5
 
6
+ /*--------------------------------------------------------------------------------------
7
+ *
8
+ * Constructor
9
+ *
10
+ * @author Elliot Condon
11
+ * @since 1.0.0
12
+ * @updated 2.2.0
13
+ *
14
+ *-------------------------------------------------------------------------------------*/
15
+
16
+ function __construct($parent)
17
  {
18
+ parent::__construct($parent);
19
+
20
+ $this->name = 'checkbox';
21
+ $this->title = __("Checkbox",'acf');
22
+
23
+ }
24
+
25
+
26
+ /*--------------------------------------------------------------------------------------
27
+ *
28
+ * create_field
29
+ *
30
+ * @author Elliot Condon
31
+ * @since 2.0.5
32
+ * @updated 2.2.0
33
+ *
34
+ *-------------------------------------------------------------------------------------*/
35
 
36
+ function create_field($field)
37
  {
38
+ // defaults
39
+ if(empty($field['value'])) $field['value'] = array();
 
 
40
 
41
+ // no choices
42
+ if(empty($field['choices']))
43
  {
 
44
  echo '<p>' . __("No choices to choose from",'acf') . '</p>';
45
  return false;
46
  }
47
 
48
+ // html
49
+ echo '<ul class="checkbox_list '.$field['class'].'">';
50
+ echo '<input type="hidden" name="'.$field['name'].'" value="" />';
51
+ // checkbox saves an array
52
+ $field['name'] .= '[]';
53
 
54
+ // foreach choices
55
+ foreach($field['choices'] as $key => $value)
 
 
 
 
 
56
  {
57
  $selected = '';
58
+ if(in_array($key, $field['value']))
59
  {
60
  $selected = 'checked="yes"';
61
  }
62
+ echo '<li><label><input type="checkbox" class="' . $field['class'] . '" name="' . $field['name'] . '" value="' . $key . '" ' . $selected . ' />' . $value . '</label></li>';
63
  }
64
+
65
  echo '</ul>';
66
 
67
  }
68
 
69
 
70
+ /*--------------------------------------------------------------------------------------
71
+ *
72
+ * create_options
73
+ *
74
+ * @author Elliot Condon
75
+ * @since 2.0.6
76
+ * @updated 2.2.0
77
+ *
78
+ *-------------------------------------------------------------------------------------*/
79
+
80
+ function create_options($key, $field)
81
+ {
82
+ // defaults
83
+
84
 
85
  // implode checkboxes so they work in a textarea
86
+ if(isset($field['choices']) && is_array($field['choices']))
87
  {
88
+ foreach($field['choices'] as $choice_key => $choice_val)
89
  {
90
+ $field['choices'][$choice_key] = $choice_key.' : '.$choice_val;
91
  }
92
+ $field['choices'] = implode("\n", $field['choices']);
93
  }
94
  else
95
  {
96
+ $field['choices'] = "";
97
  }
 
98
  ?>
99
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
 
 
100
  <td class="label">
101
  <label for=""><?php _e("Choices",'acf'); ?></label>
102
  <p class="description"><?php _e("Enter your choices one per line<br />
110
  blue : Blue",'acf'); ?></p>
111
  </td>
112
  <td>
113
+ <textarea rows="5" name="fields[<?php echo $key; ?>][choices]" id=""><?php echo $field['choices']; ?></textarea>
114
  </td>
115
  </tr>
 
 
116
  <?php
117
  }
118
 
119
 
120
+ /*--------------------------------------------------------------------------------------
121
+ *
122
+ * pre_save_field
123
+ * - called just before saving the field to the database.
124
+ *
125
+ * @author Elliot Condon
126
+ * @since 2.2.0
127
+ *
128
+ *-------------------------------------------------------------------------------------*/
129
 
130
+ function pre_save_field($field)
131
+ {
132
+ // defaults
133
+ $field['choices'] = isset($field['choices']) ? $field['choices'] : '';
 
 
 
 
 
 
 
 
 
 
 
134
 
135
+ // vars
136
+ $new_choices = array();
137
 
138
  // explode choices from each line
139
+ if(strpos($field['choices'], "\n") !== false)
140
  {
141
  // found multiple lines, explode it
142
+ $field['choices'] = explode("\n", $field['choices']);
143
  }
144
  else
145
  {
146
  // no multiple lines!
147
+ $field['choices'] = array($field['choices']);
148
  }
149
 
150
+ // key => value
151
+ foreach($field['choices'] as $choice)
 
 
152
  {
153
  if(strpos($choice, ' : ') !== false)
154
  {
 
155
  $choice = explode(' : ', $choice);
156
  $new_choices[trim($choice[0])] = trim($choice[1]);
157
  }
161
  }
162
  }
163
 
164
+ // update choices
165
+ $field['choices'] = $new_choices;
166
 
167
+ // return updated field
168
+ return $field;
169
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  }
171
+
172
  }
 
173
  ?>
core/fields/color_picker.php ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class acf_Color_picker extends acf_Field
4
+ {
5
+
6
+ /*--------------------------------------------------------------------------------------
7
+ *
8
+ * Constructor
9
+ *
10
+ * @author Elliot Condon
11
+ * @since 1.0.0
12
+ * @updated 2.2.0
13
+ *
14
+ *-------------------------------------------------------------------------------------*/
15
+
16
+ function __construct($parent)
17
+ {
18
+ parent::__construct($parent);
19
+
20
+ $this->name = 'color_picker';
21
+ $this->title = __("Color Picker",'acf');
22
+
23
+ }
24
+
25
+
26
+ /*--------------------------------------------------------------------------------------
27
+ *
28
+ * admin_print_scripts / admin_print_styles
29
+ *
30
+ * @author Elliot Condon
31
+ * @since 3.0.0
32
+ *
33
+ *-------------------------------------------------------------------------------------*/
34
+
35
+ function admin_print_scripts()
36
+ {
37
+ wp_enqueue_script( 'farbtastic' );
38
+ }
39
+
40
+ function admin_print_styles()
41
+ {
42
+ wp_enqueue_style( 'farbtastic' );
43
+
44
+ }
45
+
46
+
47
+ /*--------------------------------------------------------------------------------------
48
+ *
49
+ * admin_head
50
+ *
51
+ * @author Elliot Condon
52
+ * @since 2.0.6
53
+ *
54
+ *-------------------------------------------------------------------------------------*/
55
+
56
+ function admin_head()
57
+ {
58
+ // add datepicker
59
+ ?>
60
+ <script type="text/javascript">
61
+ (function($){
62
+
63
+ var farbtastic;
64
+
65
+ $(document).ready(function(){
66
+
67
+ $('body').append('<div id="acf_color_picker" />');
68
+ farbtastic = $.farbtastic('#acf_color_picker');
69
+
70
+ });
71
+
72
+ $('#poststuff input.acf_color_picker').live('focus', function(){
73
+
74
+ var input = $(this);
75
+
76
+ $('#acf_color_picker').css({
77
+ left: input.offset().left,
78
+ top: input.offset().top - $('#acf_color_picker').height(),
79
+ display: 'block',
80
+ });
81
+
82
+ farbtastic.linkTo(this);
83
+
84
+ }).live('blur', function(){
85
+
86
+ $('#acf_color_picker').css({
87
+ display: 'none',
88
+ });
89
+
90
+ });
91
+
92
+ })(jQuery);
93
+ </script>
94
+ <style type="text/css">
95
+ #acf_color_picker {
96
+ position: absolute;
97
+ top: 0;
98
+ left: 0;
99
+ display: none;
100
+ background: #fff;
101
+ border: #AAAAAA solid 1px;
102
+ border-radius: 4px;
103
+ }
104
+ </style>
105
+ <?php
106
+ }
107
+
108
+
109
+ /*--------------------------------------------------------------------------------------
110
+ *
111
+ * create_field
112
+ *
113
+ * @author Elliot Condon
114
+ * @since 2.0.5
115
+ * @updated 2.2.0
116
+ *
117
+ *-------------------------------------------------------------------------------------*/
118
+
119
+ function create_field($field)
120
+ {
121
+ // defaults
122
+ if($field['value'] == "") $field['value'] = '#ffffff';
123
+
124
+ // html
125
+ echo '<input type="text" value="' . $field['value'] . '" class="acf_color_picker" name="' . $field['name'] . '" id="' . $field['name'] . '" />';
126
+
127
+ }
128
+
129
+
130
+ }
131
+
132
+ ?>
core/fields/date_picker/date_picker.php CHANGED
@@ -1,40 +1,127 @@
1
  <?php
2
 
3
- class acf_Date_picker
4
  {
5
- var $name;
6
- var $title;
7
- var $plugin_dir;
 
 
 
 
 
 
 
8
 
9
- function acf_Date_picker($plugin_dir)
10
  {
11
- $this->name = 'date_picker';
12
- $this->title = __('Date Picker','acf');
13
- $this->plugin_dir = $plugin_dir;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  }
15
 
16
- function html($field)
 
 
 
 
 
 
 
 
 
 
 
17
  {
18
- echo '<input type="text" value="'.$field->value.'" class="acf_datepicker" name="'.$field->input_name.'" data-date_format="'.$field->options['date_format'].'" />';
 
 
 
 
19
 
20
  }
21
 
22
- function options_html($key, $field)
 
 
 
 
 
 
 
 
 
 
 
23
  {
24
- $options = $field->options;
 
25
 
26
- if(!isset($options['date_format']))
27
- {
28
- $options['date_format'] = "";
29
- }
30
  ?>
31
- <tr class="field_option field_option_date_picker">
32
  <td class="label">
33
- <label for=""><?php _e("Date format",'acf'); ?></label>
34
  <p class="description"><?php _e("eg. dd/mm/yy. read more about",'acf'); ?> <a href="http://docs.jquery.com/UI/Datepicker/formatDate">formatDate</a></p>
35
  </td>
36
  <td>
37
- <input type="text" name="acf[fields][<?php echo $key; ?>][options][date_format]" id="" value="<?php echo $options['date_format']; ?>" />
38
  </td>
39
  </tr>
40
 
1
  <?php
2
 
3
+ class acf_Date_picker extends acf_Field
4
  {
5
+
6
+ /*--------------------------------------------------------------------------------------
7
+ *
8
+ * Constructor
9
+ *
10
+ * @author Elliot Condon
11
+ * @since 1.0.0
12
+ * @updated 2.2.0
13
+ *
14
+ *-------------------------------------------------------------------------------------*/
15
 
16
+ function __construct($parent)
17
  {
18
+ parent::__construct($parent);
19
+
20
+ $this->name = 'date_picker';
21
+ $this->title = __("Date Picker",'acf');
22
+
23
+ }
24
+
25
+
26
+ /*--------------------------------------------------------------------------------------
27
+ *
28
+ * admin_head
29
+ *
30
+ * @author Elliot Condon
31
+ * @since 2.0.6
32
+ *
33
+ *-------------------------------------------------------------------------------------*/
34
+
35
+ function admin_head()
36
+ {
37
+ // add datepicker
38
+ echo '<link rel="stylesheet" type="text/css" href="'.$this->parent->dir.'/core/fields/date_picker/style.date_picker.css" />';
39
+ echo '<script type="text/javascript" src="'.$this->parent->dir.'/core/fields/date_picker/jquery.ui.datepicker.js" ></script>';
40
+ ?>
41
+ <script type="text/javascript">
42
+ (function($){
43
+
44
+
45
+ $('#poststuff input.acf_datepicker').live('focus', function(){
46
+
47
+ var input = $(this);
48
+
49
+ if(!input.hasClass('active'))
50
+ {
51
+
52
+ // vars
53
+ var format = input.attr('data-date_format') ? input.attr('data-date_format') : 'dd/mm/yy';
54
+
55
+ // add date picker and refocus
56
+ input.addClass('active').datepicker({
57
+ dateFormat: format
58
+ })
59
+
60
+ // set a timeout to re focus the input (after it has the datepicker!)
61
+ setTimeout(function(){
62
+ input.trigger('blur').trigger('focus');
63
+ }, 1);
64
+
65
+ // wrap the datepicker (only if it hasn't already been wrapped)
66
+ if($('body > #ui-datepicker-div').length > 0)
67
+ {
68
+ $('#ui-datepicker-div').wrap('<div class="ui-acf" />');
69
+ }
70
+
71
+ }
72
+
73
+ });
74
+
75
+ })(jQuery);
76
+ </script>
77
+ <?php
78
  }
79
 
80
+
81
+ /*--------------------------------------------------------------------------------------
82
+ *
83
+ * create_field
84
+ *
85
+ * @author Elliot Condon
86
+ * @since 2.0.5
87
+ * @updated 2.2.0
88
+ *
89
+ *-------------------------------------------------------------------------------------*/
90
+
91
+ function create_field($field)
92
  {
93
+ // vars
94
+ $field['date_format'] = isset($field['date_format']) ? $field['date_format'] : 'dd/mm/yy';
95
+
96
+ // html
97
+ echo '<input type="text" value="' . $field['value'] . '" class="acf_datepicker" name="' . $field['name'] . '" data-date_format="' . $field['date_format'] . '" />';
98
 
99
  }
100
 
101
+
102
+ /*--------------------------------------------------------------------------------------
103
+ *
104
+ * create_options
105
+ *
106
+ * @author Elliot Condon
107
+ * @since 2.0.6
108
+ * @updated 2.2.0
109
+ *
110
+ *-------------------------------------------------------------------------------------*/
111
+
112
+ function create_options($key, $field)
113
  {
114
+ // defaults
115
+ $field['date_format'] = isset($field['date_format']) ? $field['date_format'] : '';
116
 
 
 
 
 
117
  ?>
118
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
119
  <td class="label">
120
+ <label><?php _e("Date format",'acf'); ?></label>
121
  <p class="description"><?php _e("eg. dd/mm/yy. read more about",'acf'); ?> <a href="http://docs.jquery.com/UI/Datepicker/formatDate">formatDate</a></p>
122
  </td>
123
  <td>
124
+ <input type="text" name="fields[<?php echo $key; ?>][date_format]" value="<?php echo $field['date_format']; ?>" />
125
  </td>
126
  </tr>
127
 
core/fields/date_picker/jquery.ui.datepicker.js CHANGED
File without changes
core/fields/date_picker/style.date_picker.css CHANGED
@@ -10,35 +10,35 @@
10
 
11
  /* Layout helpers
12
  ----------------------------------*/
13
- .acf_datepicker .ui-helper-hidden { display: none; }
14
- .acf_datepicker .ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); }
15
- .acf_datepicker .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
- .acf_datepicker .ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
17
- .acf_datepicker .ui-helper-clearfix { display: inline-block; }
18
  /* required comment for clearfix to work in Opera \*/
19
  * html .ui-helper-clearfix { height:1%; }
20
- .acf_datepicker .ui-helper-clearfix { display:block; }
21
  /* end clearfix */
22
- .acf_datepicker .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
- .acf_datepicker .ui-state-disabled { cursor: default !important; }
28
 
29
 
30
  /* Icons
31
  ----------------------------------*/
32
 
33
  /* states and images */
34
- .acf_datepicker .ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; }
35
 
36
 
37
  /* Misc visuals
38
  ----------------------------------*/
39
 
40
  /* Overlays */
41
- .acf_datepicker .ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
42
 
43
 
44
  /*
@@ -56,238 +56,238 @@
56
 
57
  /* Component containers
58
  ----------------------------------*/
59
- .acf_datepicker .ui-widget { font-family: Verdana,Arial,sans-serif; font-size: 1.1em; }
60
- .acf_datepicker .ui-widget .ui-widget { font-size: 1em; }
61
- .acf_datepicker .ui-widget input, .acf_datepicker .ui-widget select, .acf_datepicker .ui-widget textarea, .acf_datepicker .ui-widget button { font-family: Verdana,Arial,sans-serif; font-size: 1em; }
62
- .acf_datepicker .ui-widget-content { border: 1px solid #aaaaaa; background: #ffffff url(images/ui-bg_flat_75_ffffff_40x100.png) 50% 50% repeat-x; color: #222222; }
63
- .acf_datepicker .ui-widget-content a { color: #222222; }
64
- .acf_datepicker .ui-widget-header { border: 1px solid #000000; background: #444444 url(images/ui-bg_highlight-soft_0_444444_1x100.png) 50% 50% repeat-x; color: #e5e5e5; font-weight: bold; }
65
- .acf_datepicker .ui-widget-header a { color: #e5e5e5; }
66
 
67
  /* Interaction states
68
  ----------------------------------*/
69
- .acf_datepicker .ui-state-default, .acf_datepicker .ui-widget-content .ui-state-default, .acf_datepicker .ui-widget-header .ui-state-default { border: 1px solid #d3d3d3; background: #e6e6e6 url(images/ui-bg_glass_75_e6e6e6_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #555555; }
70
- .acf_datepicker .ui-state-default a, .acf_datepicker .ui-state-default a:link, .acf_datepicker .ui-state-default a:visited { color: #555555; text-decoration: none; }
71
- .acf_datepicker .ui-state-hover, .acf_datepicker .ui-widget-content .ui-state-hover, .acf_datepicker .ui-widget-header .ui-state-hover, .acf_datepicker .ui-state-focus, .acf_datepicker .ui-widget-content .ui-state-focus, .acf_datepicker .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; }
72
- .acf_datepicker .ui-state-hover a, .acf_datepicker .ui-state-hover a:hover { color: #212121; text-decoration: none; }
73
- .acf_datepicker .ui-state-active, .acf_datepicker .ui-widget-content .ui-state-active, .acf_datepicker .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; }
74
- .acf_datepicker .ui-state-active a, .acf_datepicker .ui-state-active a:link, .acf_datepicker .ui-state-active a:visited { color: #212121; text-decoration: none; }
75
- .acf_datepicker .ui-widget :active { outline: none; }
76
 
77
  /* Interaction Cues
78
  ----------------------------------*/
79
- .acf_datepicker .ui-state-highlight, .acf_datepicker .ui-widget-content .ui-state-highlight, .acf_datepicker .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; }
80
- .acf_datepicker .ui-state-highlight a, .acf_datepicker .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #ffffff; }
81
- .acf_datepicker .ui-state-error, .acf_datepicker .ui-widget-content .ui-state-error, .acf_datepicker .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; }
82
- .acf_datepicker .ui-state-error a, .acf_datepicker .ui-widget-content .ui-state-error a, .acf_datepicker .ui-widget-header .ui-state-error a { color: #cd0a0a; }
83
- .acf_datepicker .ui-state-error-text, .acf_datepicker .ui-widget-content .ui-state-error-text, .acf_datepicker .ui-widget-header .ui-state-error-text { color: #cd0a0a; }
84
- .acf_datepicker .ui-priority-primary, .acf_datepicker .ui-widget-content .ui-priority-primary, .acf_datepicker .ui-widget-header .ui-priority-primary { font-weight: bold; }
85
- .acf_datepicker .ui-priority-secondary, .acf_datepicker .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; }
86
- .acf_datepicker .ui-state-disabled, .acf_datepicker .ui-widget-content .ui-state-disabled, .acf_datepicker .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; }
87
 
88
  /* Icons
89
  ----------------------------------*/
90
 
91
  /* states and images */
92
- .acf_datepicker .ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_222222_256x240.png); }
93
- .acf_datepicker .ui-widget-content .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); }
94
- .acf_datepicker .ui-widget-header .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); }
95
- .acf_datepicker .ui-state-default .ui-icon { background-image: url(images/ui-icons_888888_256x240.png); }
96
- .acf_datepicker .ui-state-hover .ui-icon, .acf_datepicker .ui-state-focus .ui-icon {background-image: url(images/ui-icons_454545_256x240.png); }
97
- .acf_datepicker .ui-state-active .ui-icon {background-image: url(images/ui-icons_454545_256x240.png); }
98
- .acf_datepicker .ui-state-highlight .ui-icon {background-image: url(images/ui-icons_2e83ff_256x240.png); }
99
- .acf_datepicker .ui-state-error .ui-icon, .acf_datepicker .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_cd0a0a_256x240.png); }
100
 
101
  /* positioning */
102
- .acf_datepicker .ui-icon-carat-1-n { background-position: 0 0; }
103
- .acf_datepicker .ui-icon-carat-1-ne { background-position: -16px 0; }
104
- .acf_datepicker .ui-icon-carat-1-e { background-position: -32px 0; }
105
- .acf_datepicker .ui-icon-carat-1-se { background-position: -48px 0; }
106
- .acf_datepicker .ui-icon-carat-1-s { background-position: -64px 0; }
107
- .acf_datepicker .ui-icon-carat-1-sw { background-position: -80px 0; }
108
- .acf_datepicker .ui-icon-carat-1-w { background-position: -96px 0; }
109
- .acf_datepicker .ui-icon-carat-1-nw { background-position: -112px 0; }
110
- .acf_datepicker .ui-icon-carat-2-n-s { background-position: -128px 0; }
111
- .acf_datepicker .ui-icon-carat-2-e-w { background-position: -144px 0; }
112
- .acf_datepicker .ui-icon-triangle-1-n { background-position: 0 -16px; }
113
- .acf_datepicker .ui-icon-triangle-1-ne { background-position: -16px -16px; }
114
- .acf_datepicker .ui-icon-triangle-1-e { background-position: -32px -16px; }
115
- .acf_datepicker .ui-icon-triangle-1-se { background-position: -48px -16px; }
116
- .acf_datepicker .ui-icon-triangle-1-s { background-position: -64px -16px; }
117
- .acf_datepicker .ui-icon-triangle-1-sw { background-position: -80px -16px; }
118
- .acf_datepicker .ui-icon-triangle-1-w { background-position: -96px -16px; }
119
- .acf_datepicker .ui-icon-triangle-1-nw { background-position: -112px -16px; }
120
- .acf_datepicker .ui-icon-triangle-2-n-s { background-position: -128px -16px; }
121
- .acf_datepicker .ui-icon-triangle-2-e-w { background-position: -144px -16px; }
122
- .acf_datepicker .ui-icon-arrow-1-n { background-position: 0 -32px; }
123
- .acf_datepicker .ui-icon-arrow-1-ne { background-position: -16px -32px; }
124
- .acf_datepicker .ui-icon-arrow-1-e { background-position: -32px -32px; }
125
- .acf_datepicker .ui-icon-arrow-1-se { background-position: -48px -32px; }
126
- .acf_datepicker .ui-icon-arrow-1-s { background-position: -64px -32px; }
127
- .acf_datepicker .ui-icon-arrow-1-sw { background-position: -80px -32px; }
128
- .acf_datepicker .ui-icon-arrow-1-w { background-position: -96px -32px; }
129
- .acf_datepicker .ui-icon-arrow-1-nw { background-position: -112px -32px; }
130
- .acf_datepicker .ui-icon-arrow-2-n-s { background-position: -128px -32px; }
131
- .acf_datepicker .ui-icon-arrow-2-ne-sw { background-position: -144px -32px; }
132
- .acf_datepicker .ui-icon-arrow-2-e-w { background-position: -160px -32px; }
133
- .acf_datepicker .ui-icon-arrow-2-se-nw { background-position: -176px -32px; }
134
- .acf_datepicker .ui-icon-arrowstop-1-n { background-position: -192px -32px; }
135
- .acf_datepicker .ui-icon-arrowstop-1-e { background-position: -208px -32px; }
136
- .acf_datepicker .ui-icon-arrowstop-1-s { background-position: -224px -32px; }
137
- .acf_datepicker .ui-icon-arrowstop-1-w { background-position: -240px -32px; }
138
- .acf_datepicker .ui-icon-arrowthick-1-n { background-position: 0 -48px; }
139
- .acf_datepicker .ui-icon-arrowthick-1-ne { background-position: -16px -48px; }
140
- .acf_datepicker .ui-icon-arrowthick-1-e { background-position: -32px -48px; }
141
- .acf_datepicker .ui-icon-arrowthick-1-se { background-position: -48px -48px; }
142
- .acf_datepicker .ui-icon-arrowthick-1-s { background-position: -64px -48px; }
143
- .acf_datepicker .ui-icon-arrowthick-1-sw { background-position: -80px -48px; }
144
- .acf_datepicker .ui-icon-arrowthick-1-w { background-position: -96px -48px; }
145
- .acf_datepicker .ui-icon-arrowthick-1-nw { background-position: -112px -48px; }
146
- .acf_datepicker .ui-icon-arrowthick-2-n-s { background-position: -128px -48px; }
147
- .acf_datepicker .ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; }
148
- .acf_datepicker .ui-icon-arrowthick-2-e-w { background-position: -160px -48px; }
149
- .acf_datepicker .ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; }
150
- .acf_datepicker .ui-icon-arrowthickstop-1-n { background-position: -192px -48px; }
151
- .acf_datepicker .ui-icon-arrowthickstop-1-e { background-position: -208px -48px; }
152
- .acf_datepicker .ui-icon-arrowthickstop-1-s { background-position: -224px -48px; }
153
- .acf_datepicker .ui-icon-arrowthickstop-1-w { background-position: -240px -48px; }
154
- .acf_datepicker .ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; }
155
- .acf_datepicker .ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; }
156
- .acf_datepicker .ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; }
157
- .acf_datepicker .ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; }
158
- .acf_datepicker .ui-icon-arrowreturn-1-w { background-position: -64px -64px; }
159
- .acf_datepicker .ui-icon-arrowreturn-1-n { background-position: -80px -64px; }
160
- .acf_datepicker .ui-icon-arrowreturn-1-e { background-position: -96px -64px; }
161
- .acf_datepicker .ui-icon-arrowreturn-1-s { background-position: -112px -64px; }
162
- .acf_datepicker .ui-icon-arrowrefresh-1-w { background-position: -128px -64px; }
163
- .acf_datepicker .ui-icon-arrowrefresh-1-n { background-position: -144px -64px; }
164
- .acf_datepicker .ui-icon-arrowrefresh-1-e { background-position: -160px -64px; }
165
- .acf_datepicker .ui-icon-arrowrefresh-1-s { background-position: -176px -64px; }
166
- .acf_datepicker .ui-icon-arrow-4 { background-position: 0 -80px; }
167
- .acf_datepicker .ui-icon-arrow-4-diag { background-position: -16px -80px; }
168
- .acf_datepicker .ui-icon-extlink { background-position: -32px -80px; }
169
- .acf_datepicker .ui-icon-newwin { background-position: -48px -80px; }
170
- .acf_datepicker .ui-icon-refresh { background-position: -64px -80px; }
171
- .acf_datepicker .ui-icon-shuffle { background-position: -80px -80px; }
172
- .acf_datepicker .ui-icon-transfer-e-w { background-position: -96px -80px; }
173
- .acf_datepicker .ui-icon-transferthick-e-w { background-position: -112px -80px; }
174
- .acf_datepicker .ui-icon-folder-collapsed { background-position: 0 -96px; }
175
- .acf_datepicker .ui-icon-folder-open { background-position: -16px -96px; }
176
- .acf_datepicker .ui-icon-document { background-position: -32px -96px; }
177
- .acf_datepicker .ui-icon-document-b { background-position: -48px -96px; }
178
- .acf_datepicker .ui-icon-note { background-position: -64px -96px; }
179
- .acf_datepicker .ui-icon-mail-closed { background-position: -80px -96px; }
180
- .acf_datepicker .ui-icon-mail-open { background-position: -96px -96px; }
181
- .acf_datepicker .ui-icon-suitcase { background-position: -112px -96px; }
182
- .acf_datepicker .ui-icon-comment { background-position: -128px -96px; }
183
- .acf_datepicker .ui-icon-person { background-position: -144px -96px; }
184
- .acf_datepicker .ui-icon-print { background-position: -160px -96px; }
185
- .acf_datepicker .ui-icon-trash { background-position: -176px -96px; }
186
- .acf_datepicker .ui-icon-locked { background-position: -192px -96px; }
187
- .acf_datepicker .ui-icon-unlocked { background-position: -208px -96px; }
188
- .acf_datepicker .ui-icon-bookmark { background-position: -224px -96px; }
189
- .acf_datepicker .ui-icon-tag { background-position: -240px -96px; }
190
- .acf_datepicker .ui-icon-home { background-position: 0 -112px; }
191
- .acf_datepicker .ui-icon-flag { background-position: -16px -112px; }
192
- .acf_datepicker .ui-icon-calendar { background-position: -32px -112px; }
193
- .acf_datepicker .ui-icon-cart { background-position: -48px -112px; }
194
- .acf_datepicker .ui-icon-pencil { background-position: -64px -112px; }
195
- .acf_datepicker .ui-icon-clock { background-position: -80px -112px; }
196
- .acf_datepicker .ui-icon-disk { background-position: -96px -112px; }
197
- .acf_datepicker .ui-icon-calculator { background-position: -112px -112px; }
198
- .acf_datepicker .ui-icon-zoomin { background-position: -128px -112px; }
199
- .acf_datepicker .ui-icon-zoomout { background-position: -144px -112px; }
200
- .acf_datepicker .ui-icon-search { background-position: -160px -112px; }
201
- .acf_datepicker .ui-icon-wrench { background-position: -176px -112px; }
202
- .acf_datepicker .ui-icon-gear { background-position: -192px -112px; }
203
- .acf_datepicker .ui-icon-heart { background-position: -208px -112px; }
204
- .acf_datepicker .ui-icon-star { background-position: -224px -112px; }
205
- .acf_datepicker .ui-icon-link { background-position: -240px -112px; }
206
- .acf_datepicker .ui-icon-cancel { background-position: 0 -128px; }
207
- .acf_datepicker .ui-icon-plus { background-position: -16px -128px; }
208
- .acf_datepicker .ui-icon-plusthick { background-position: -32px -128px; }
209
- .acf_datepicker .ui-icon-minus { background-position: -48px -128px; }
210
- .acf_datepicker .ui-icon-minusthick { background-position: -64px -128px; }
211
- .acf_datepicker .ui-icon-close { background-position: -80px -128px; }
212
- .acf_datepicker .ui-icon-closethick { background-position: -96px -128px; }
213
- .acf_datepicker .ui-icon-key { background-position: -112px -128px; }
214
- .acf_datepicker .ui-icon-lightbulb { background-position: -128px -128px; }
215
- .acf_datepicker .ui-icon-scissors { background-position: -144px -128px; }
216
- .acf_datepicker .ui-icon-clipboard { background-position: -160px -128px; }
217
- .acf_datepicker .ui-icon-copy { background-position: -176px -128px; }
218
- .acf_datepicker .ui-icon-contact { background-position: -192px -128px; }
219
- .acf_datepicker .ui-icon-image { background-position: -208px -128px; }
220
- .acf_datepicker .ui-icon-video { background-position: -224px -128px; }
221
- .acf_datepicker .ui-icon-script { background-position: -240px -128px; }
222
- .acf_datepicker .ui-icon-alert { background-position: 0 -144px; }
223
- .acf_datepicker .ui-icon-info { background-position: -16px -144px; }
224
- .acf_datepicker .ui-icon-notice { background-position: -32px -144px; }
225
- .acf_datepicker .ui-icon-help { background-position: -48px -144px; }
226
- .acf_datepicker .ui-icon-check { background-position: -64px -144px; }
227
- .acf_datepicker .ui-icon-bullet { background-position: -80px -144px; }
228
- .acf_datepicker .ui-icon-radio-off { background-position: -96px -144px; }
229
- .acf_datepicker .ui-icon-radio-on { background-position: -112px -144px; }
230
- .acf_datepicker .ui-icon-pin-w { background-position: -128px -144px; }
231
- .acf_datepicker .ui-icon-pin-s { background-position: -144px -144px; }
232
- .acf_datepicker .ui-icon-play { background-position: 0 -160px; }
233
- .acf_datepicker .ui-icon-pause { background-position: -16px -160px; }
234
- .acf_datepicker .ui-icon-seek-next { background-position: -32px -160px; }
235
- .acf_datepicker .ui-icon-seek-prev { background-position: -48px -160px; }
236
- .acf_datepicker .ui-icon-seek-end { background-position: -64px -160px; }
237
- .acf_datepicker .ui-icon-seek-start { background-position: -80px -160px; }
238
  /* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */
239
- .acf_datepicker .ui-icon-seek-first { background-position: -80px -160px; }
240
- .acf_datepicker .ui-icon-stop { background-position: -96px -160px; }
241
- .acf_datepicker .ui-icon-eject { background-position: -112px -160px; }
242
- .acf_datepicker .ui-icon-volume-off { background-position: -128px -160px; }
243
- .acf_datepicker .ui-icon-volume-on { background-position: -144px -160px; }
244
- .acf_datepicker .ui-icon-power { background-position: 0 -176px; }
245
- .acf_datepicker .ui-icon-signal-diag { background-position: -16px -176px; }
246
- .acf_datepicker .ui-icon-signal { background-position: -32px -176px; }
247
- .acf_datepicker .ui-icon-battery-0 { background-position: -48px -176px; }
248
- .acf_datepicker .ui-icon-battery-1 { background-position: -64px -176px; }
249
- .acf_datepicker .ui-icon-battery-2 { background-position: -80px -176px; }
250
- .acf_datepicker .ui-icon-battery-3 { background-position: -96px -176px; }
251
- .acf_datepicker .ui-icon-circle-plus { background-position: 0 -192px; }
252
- .acf_datepicker .ui-icon-circle-minus { background-position: -16px -192px; }
253
- .acf_datepicker .ui-icon-circle-close { background-position: -32px -192px; }
254
- .acf_datepicker .ui-icon-circle-triangle-e { background-position: -48px -192px; }
255
- .acf_datepicker .ui-icon-circle-triangle-s { background-position: -64px -192px; }
256
- .acf_datepicker .ui-icon-circle-triangle-w { background-position: -80px -192px; }
257
- .acf_datepicker .ui-icon-circle-triangle-n { background-position: -96px -192px; }
258
- .acf_datepicker .ui-icon-circle-arrow-e { background-position: -112px -192px; }
259
- .acf_datepicker .ui-icon-circle-arrow-s { background-position: -128px -192px; }
260
- .acf_datepicker .ui-icon-circle-arrow-w { background-position: -144px -192px; }
261
- .acf_datepicker .ui-icon-circle-arrow-n { background-position: -160px -192px; }
262
- .acf_datepicker .ui-icon-circle-zoomin { background-position: -176px -192px; }
263
- .acf_datepicker .ui-icon-circle-zoomout { background-position: -192px -192px; }
264
- .acf_datepicker .ui-icon-circle-check { background-position: -208px -192px; }
265
- .acf_datepicker .ui-icon-circlesmall-plus { background-position: 0 -208px; }
266
- .acf_datepicker .ui-icon-circlesmall-minus { background-position: -16px -208px; }
267
- .acf_datepicker .ui-icon-circlesmall-close { background-position: -32px -208px; }
268
- .acf_datepicker .ui-icon-squaresmall-plus { background-position: -48px -208px; }
269
- .acf_datepicker .ui-icon-squaresmall-minus { background-position: -64px -208px; }
270
- .acf_datepicker .ui-icon-squaresmall-close { background-position: -80px -208px; }
271
- .acf_datepicker .ui-icon-grip-dotted-vertical { background-position: 0 -224px; }
272
- .acf_datepicker .ui-icon-grip-dotted-horizontal { background-position: -16px -224px; }
273
- .acf_datepicker .ui-icon-grip-solid-vertical { background-position: -32px -224px; }
274
- .acf_datepicker .ui-icon-grip-solid-horizontal { background-position: -48px -224px; }
275
- .acf_datepicker .ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; }
276
- .acf_datepicker .ui-icon-grip-diagonal-se { background-position: -80px -224px; }
277
 
278
 
279
  /* Misc visuals
280
  ----------------------------------*/
281
 
282
  /* Corner radius */
283
- .acf_datepicker .ui-corner-all, .acf_datepicker .ui-corner-top, .acf_datepicker .ui-corner-left, .acf_datepicker .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; }
284
- .acf_datepicker .ui-corner-all, .acf_datepicker .ui-corner-top, .acf_datepicker .ui-corner-right, .acf_datepicker .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; }
285
- .acf_datepicker .ui-corner-all, .acf_datepicker .ui-corner-bottom, .acf_datepicker .ui-corner-left, .acf_datepicker .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; }
286
- .acf_datepicker .ui-corner-all, .acf_datepicker .ui-corner-bottom, .acf_datepicker .ui-corner-right, .acf_datepicker .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; }
287
 
288
  /* Overlays */
289
- .acf_datepicker .ui-widget-overlay { background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); }
290
- .acf_datepicker .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; }/*
291
  * jQuery UI Datepicker 1.8.14
292
  *
293
  * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
@@ -296,55 +296,55 @@
296
  *
297
  * http://docs.jquery.com/UI/Datepicker#theming
298
  */
299
- .acf_datepicker .ui-datepicker { width: 17em; padding: .2em .2em 0; display: none; }
300
- .acf_datepicker .ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; }
301
- .acf_datepicker .ui-datepicker .ui-datepicker-prev, .acf_datepicker .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; }
302
- .acf_datepicker .ui-datepicker .ui-datepicker-prev-hover, .acf_datepicker .ui-datepicker .ui-datepicker-next-hover { top: 1px; }
303
- .acf_datepicker .ui-datepicker .ui-datepicker-prev { left:2px; }
304
- .acf_datepicker .ui-datepicker .ui-datepicker-next { right:2px; }
305
- .acf_datepicker .ui-datepicker .ui-datepicker-prev-hover { left:1px; }
306
- .acf_datepicker .ui-datepicker .ui-datepicker-next-hover { right:1px; }
307
- .acf_datepicker .ui-datepicker .ui-datepicker-prev span, .acf_datepicker .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; }
308
- .acf_datepicker .ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; }
309
- .acf_datepicker .ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0; }
310
- .acf_datepicker .ui-datepicker select.ui-datepicker-month-year {width: 100%;}
311
- .acf_datepicker .ui-datepicker select.ui-datepicker-month,
312
- .acf_datepicker .ui-datepicker select.ui-datepicker-year { width: 49%;}
313
- .acf_datepicker .ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; }
314
- .acf_datepicker .ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; }
315
- .acf_datepicker .ui-datepicker td { border: 0; padding: 1px; }
316
- .acf_datepicker .ui-datepicker td span, .acf_datepicker .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; }
317
- .acf_datepicker .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; }
318
- .acf_datepicker .ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; }
319
- .acf_datepicker .ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; }
320
 
321
  /* with multiple calendars */
322
- .acf_datepicker .ui-datepicker.ui-datepicker-multi { width:auto; }
323
- .acf_datepicker .ui-datepicker-multi .ui-datepicker-group { float:left; }
324
- .acf_datepicker .ui-datepicker-multi .ui-datepicker-group table { width:95%; margin:0 auto .4em; }
325
- .acf_datepicker .ui-datepicker-multi-2 .ui-datepicker-group { width:50%; }
326
- .acf_datepicker .ui-datepicker-multi-3 .ui-datepicker-group { width:33.3%; }
327
- .acf_datepicker .ui-datepicker-multi-4 .ui-datepicker-group { width:25%; }
328
- .acf_datepicker .ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header { border-left-width:0; }
329
- .acf_datepicker .ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { border-left-width:0; }
330
- .acf_datepicker .ui-datepicker-multi .ui-datepicker-buttonpane { clear:left; }
331
- .acf_datepicker .ui-datepicker-row-break { clear:both; width:100%; font-size:0em; }
332
 
333
  /* RTL support */
334
- .acf_datepicker .ui-datepicker-rtl { direction: rtl; }
335
- .acf_datepicker .ui-datepicker-rtl .ui-datepicker-prev { right: 2px; left: auto; }
336
- .acf_datepicker .ui-datepicker-rtl .ui-datepicker-next { left: 2px; right: auto; }
337
- .acf_datepicker .ui-datepicker-rtl .ui-datepicker-prev:hover { right: 1px; left: auto; }
338
- .acf_datepicker .ui-datepicker-rtl .ui-datepicker-next:hover { left: 1px; right: auto; }
339
- .acf_datepicker .ui-datepicker-rtl .ui-datepicker-buttonpane { clear:right; }
340
- .acf_datepicker .ui-datepicker-rtl .ui-datepicker-buttonpane button { float: left; }
341
- .acf_datepicker .ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current { float:right; }
342
- .acf_datepicker .ui-datepicker-rtl .ui-datepicker-group { float:right; }
343
- .acf_datepicker .ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
344
- .acf_datepicker .ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
345
 
346
  /* IE6 IFRAME FIX (taken from datepicker 1.5.3 */
347
- .acf_datepicker .ui-datepicker-cover {
348
  display: none; /*sorry for IE5*/
349
  display/**/: block; /*sorry for IE5*/
350
  position: absolute; /*must have*/
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
  /*
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 { border: 1px solid #aaaaaa; background: #ffffff url(images/ui-bg_flat_75_ffffff_40x100.png) 50% 50% repeat-x; color: #222222; }
63
+ .ui-acf .ui-widget-content a { color: #222222; }
64
+ .ui-acf .ui-widget-header { border: 1px solid #000000; background: #444444 url(images/ui-bg_highlight-soft_0_444444_1x100.png) 50% 50% repeat-x; color: #e5e5e5; font-weight: bold; }
65
+ .ui-acf .ui-widget-header a { color: #e5e5e5; }
66
 
67
  /* Interaction states
68
  ----------------------------------*/
69
+ .ui-acf .ui-state-default, .ui-acf .ui-widget-content .ui-state-default, .ui-acf .ui-widget-header .ui-state-default { border: 1px solid #d3d3d3; background: #e6e6e6 url(images/ui-bg_glass_75_e6e6e6_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #555555; }
70
+ .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; }
71
+ .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; }
72
+ .ui-acf .ui-state-hover a, .ui-acf .ui-state-hover a:hover { color: #212121; text-decoration: none; }
73
+ .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; }
74
+ .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; }
75
+ .ui-acf .ui-widget :active { outline: none; }
76
 
77
  /* Interaction Cues
78
  ----------------------------------*/
79
+ .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; }
80
+ .ui-acf .ui-state-highlight a, .ui-acf .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #ffffff; }
81
+ .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; }
82
+ .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; }
83
+ .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; }
84
+ .ui-acf .ui-priority-primary, .ui-acf .ui-widget-content .ui-priority-primary, .ui-acf .ui-widget-header .ui-priority-primary { font-weight: bold; }
85
+ .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; }
86
+ .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; }
87
 
88
  /* Icons
89
  ----------------------------------*/
90
 
91
  /* states and images */
92
+ .ui-acf .ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_222222_256x240.png); }
93
+ .ui-acf .ui-widget-content .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); }
94
+ .ui-acf .ui-widget-header .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); }
95
+ .ui-acf .ui-state-default .ui-icon { background-image: url(images/ui-icons_888888_256x240.png); }
96
+ .ui-acf .ui-state-hover .ui-icon, .ui-acf .ui-state-focus .ui-icon {background-image: url(images/ui-icons_454545_256x240.png); }
97
+ .ui-acf .ui-state-active .ui-icon {background-image: url(images/ui-icons_454545_256x240.png); }
98
+ .ui-acf .ui-state-highlight .ui-icon {background-image: url(images/ui-icons_2e83ff_256x240.png); }
99
+ .ui-acf .ui-state-error .ui-icon, .ui-acf .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_cd0a0a_256x240.png); }
100
 
101
  /* positioning */
102
+ .ui-acf .ui-icon-carat-1-n { background-position: 0 0; }
103
+ .ui-acf .ui-icon-carat-1-ne { background-position: -16px 0; }
104
+ .ui-acf .ui-icon-carat-1-e { background-position: -32px 0; }
105
+ .ui-acf .ui-icon-carat-1-se { background-position: -48px 0; }
106
+ .ui-acf .ui-icon-carat-1-s { background-position: -64px 0; }
107
+ .ui-acf .ui-icon-carat-1-sw { background-position: -80px 0; }
108
+ .ui-acf .ui-icon-carat-1-w { background-position: -96px 0; }
109
+ .ui-acf .ui-icon-carat-1-nw { background-position: -112px 0; }
110
+ .ui-acf .ui-icon-carat-2-n-s { background-position: -128px 0; }
111
+ .ui-acf .ui-icon-carat-2-e-w { background-position: -144px 0; }
112
+ .ui-acf .ui-icon-triangle-1-n { background-position: 0 -16px; }
113
+ .ui-acf .ui-icon-triangle-1-ne { background-position: -16px -16px; }
114
+ .ui-acf .ui-icon-triangle-1-e { background-position: -32px -16px; }
115
+ .ui-acf .ui-icon-triangle-1-se { background-position: -48px -16px; }
116
+ .ui-acf .ui-icon-triangle-1-s { background-position: -64px -16px; }
117
+ .ui-acf .ui-icon-triangle-1-sw { background-position: -80px -16px; }
118
+ .ui-acf .ui-icon-triangle-1-w { background-position: -96px -16px; }
119
+ .ui-acf .ui-icon-triangle-1-nw { background-position: -112px -16px; }
120
+ .ui-acf .ui-icon-triangle-2-n-s { background-position: -128px -16px; }
121
+ .ui-acf .ui-icon-triangle-2-e-w { background-position: -144px -16px; }
122
+ .ui-acf .ui-icon-arrow-1-n { background-position: 0 -32px; }
123
+ .ui-acf .ui-icon-arrow-1-ne { background-position: -16px -32px; }
124
+ .ui-acf .ui-icon-arrow-1-e { background-position: -32px -32px; }
125
+ .ui-acf .ui-icon-arrow-1-se { background-position: -48px -32px; }
126
+ .ui-acf .ui-icon-arrow-1-s { background-position: -64px -32px; }
127
+ .ui-acf .ui-icon-arrow-1-sw { background-position: -80px -32px; }
128
+ .ui-acf .ui-icon-arrow-1-w { background-position: -96px -32px; }
129
+ .ui-acf .ui-icon-arrow-1-nw { background-position: -112px -32px; }
130
+ .ui-acf .ui-icon-arrow-2-n-s { background-position: -128px -32px; }
131
+ .ui-acf .ui-icon-arrow-2-ne-sw { background-position: -144px -32px; }
132
+ .ui-acf .ui-icon-arrow-2-e-w { background-position: -160px -32px; }
133
+ .ui-acf .ui-icon-arrow-2-se-nw { background-position: -176px -32px; }
134
+ .ui-acf .ui-icon-arrowstop-1-n { background-position: -192px -32px; }
135
+ .ui-acf .ui-icon-arrowstop-1-e { background-position: -208px -32px; }
136
+ .ui-acf .ui-icon-arrowstop-1-s { background-position: -224px -32px; }
137
+ .ui-acf .ui-icon-arrowstop-1-w { background-position: -240px -32px; }
138
+ .ui-acf .ui-icon-arrowthick-1-n { background-position: 0 -48px; }
139
+ .ui-acf .ui-icon-arrowthick-1-ne { background-position: -16px -48px; }
140
+ .ui-acf .ui-icon-arrowthick-1-e { background-position: -32px -48px; }
141
+ .ui-acf .ui-icon-arrowthick-1-se { background-position: -48px -48px; }
142
+ .ui-acf .ui-icon-arrowthick-1-s { background-position: -64px -48px; }
143
+ .ui-acf .ui-icon-arrowthick-1-sw { background-position: -80px -48px; }
144
+ .ui-acf .ui-icon-arrowthick-1-w { background-position: -96px -48px; }
145
+ .ui-acf .ui-icon-arrowthick-1-nw { background-position: -112px -48px; }
146
+ .ui-acf .ui-icon-arrowthick-2-n-s { background-position: -128px -48px; }
147
+ .ui-acf .ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; }
148
+ .ui-acf .ui-icon-arrowthick-2-e-w { background-position: -160px -48px; }
149
+ .ui-acf .ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; }
150
+ .ui-acf .ui-icon-arrowthickstop-1-n { background-position: -192px -48px; }
151
+ .ui-acf .ui-icon-arrowthickstop-1-e { background-position: -208px -48px; }
152
+ .ui-acf .ui-icon-arrowthickstop-1-s { background-position: -224px -48px; }
153
+ .ui-acf .ui-icon-arrowthickstop-1-w { background-position: -240px -48px; }
154
+ .ui-acf .ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; }
155
+ .ui-acf .ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; }
156
+ .ui-acf .ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; }
157
+ .ui-acf .ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; }
158
+ .ui-acf .ui-icon-arrowreturn-1-w { background-position: -64px -64px; }
159
+ .ui-acf .ui-icon-arrowreturn-1-n { background-position: -80px -64px; }
160
+ .ui-acf .ui-icon-arrowreturn-1-e { background-position: -96px -64px; }
161
+ .ui-acf .ui-icon-arrowreturn-1-s { background-position: -112px -64px; }
162
+ .ui-acf .ui-icon-arrowrefresh-1-w { background-position: -128px -64px; }
163
+ .ui-acf .ui-icon-arrowrefresh-1-n { background-position: -144px -64px; }
164
+ .ui-acf .ui-icon-arrowrefresh-1-e { background-position: -160px -64px; }
165
+ .ui-acf .ui-icon-arrowrefresh-1-s { background-position: -176px -64px; }
166
+ .ui-acf .ui-icon-arrow-4 { background-position: 0 -80px; }
167
+ .ui-acf .ui-icon-arrow-4-diag { background-position: -16px -80px; }
168
+ .ui-acf .ui-icon-extlink { background-position: -32px -80px; }
169
+ .ui-acf .ui-icon-newwin { background-position: -48px -80px; }
170
+ .ui-acf .ui-icon-refresh { background-position: -64px -80px; }
171
+ .ui-acf .ui-icon-shuffle { background-position: -80px -80px; }
172
+ .ui-acf .ui-icon-transfer-e-w { background-position: -96px -80px; }
173
+ .ui-acf .ui-icon-transferthick-e-w { background-position: -112px -80px; }
174
+ .ui-acf .ui-icon-folder-collapsed { background-position: 0 -96px; }
175
+ .ui-acf .ui-icon-folder-open { background-position: -16px -96px; }
176
+ .ui-acf .ui-icon-document { background-position: -32px -96px; }
177
+ .ui-acf .ui-icon-document-b { background-position: -48px -96px; }
178
+ .ui-acf .ui-icon-note { background-position: -64px -96px; }
179
+ .ui-acf .ui-icon-mail-closed { background-position: -80px -96px; }
180
+ .ui-acf .ui-icon-mail-open { background-position: -96px -96px; }
181
+ .ui-acf .ui-icon-suitcase { background-position: -112px -96px; }
182
+ .ui-acf .ui-icon-comment { background-position: -128px -96px; }
183
+ .ui-acf .ui-icon-person { background-position: -144px -96px; }
184
+ .ui-acf .ui-icon-print { background-position: -160px -96px; }
185
+ .ui-acf .ui-icon-trash { background-position: -176px -96px; }
186
+ .ui-acf .ui-icon-locked { background-position: -192px -96px; }
187
+ .ui-acf .ui-icon-unlocked { background-position: -208px -96px; }
188
+ .ui-acf .ui-icon-bookmark { background-position: -224px -96px; }
189
+ .ui-acf .ui-icon-tag { background-position: -240px -96px; }
190
+ .ui-acf .ui-icon-home { background-position: 0 -112px; }
191
+ .ui-acf .ui-icon-flag { background-position: -16px -112px; }
192
+ .ui-acf .ui-icon-calendar { background-position: -32px -112px; }
193
+ .ui-acf .ui-icon-cart { background-position: -48px -112px; }
194
+ .ui-acf .ui-icon-pencil { background-position: -64px -112px; }
195
+ .ui-acf .ui-icon-clock { background-position: -80px -112px; }
196
+ .ui-acf .ui-icon-disk { background-position: -96px -112px; }
197
+ .ui-acf .ui-icon-calculator { background-position: -112px -112px; }
198
+ .ui-acf .ui-icon-zoomin { background-position: -128px -112px; }
199
+ .ui-acf .ui-icon-zoomout { background-position: -144px -112px; }
200
+ .ui-acf .ui-icon-search { background-position: -160px -112px; }
201
+ .ui-acf .ui-icon-wrench { background-position: -176px -112px; }
202
+ .ui-acf .ui-icon-gear { background-position: -192px -112px; }
203
+ .ui-acf .ui-icon-heart { background-position: -208px -112px; }
204
+ .ui-acf .ui-icon-star { background-position: -224px -112px; }
205
+ .ui-acf .ui-icon-link { background-position: -240px -112px; }
206
+ .ui-acf .ui-icon-cancel { background-position: 0 -128px; }
207
+ .ui-acf .ui-icon-plus { background-position: -16px -128px; }
208
+ .ui-acf .ui-icon-plusthick { background-position: -32px -128px; }
209
+ .ui-acf .ui-icon-minus { background-position: -48px -128px; }
210
+ .ui-acf .ui-icon-minusthick { background-position: -64px -128px; }
211
+ .ui-acf .ui-icon-close { background-position: -80px -128px; }
212
+ .ui-acf .ui-icon-closethick { background-position: -96px -128px; }
213
+ .ui-acf .ui-icon-key { background-position: -112px -128px; }
214
+ .ui-acf .ui-icon-lightbulb { background-position: -128px -128px; }
215
+ .ui-acf .ui-icon-scissors { background-position: -144px -128px; }
216
+ .ui-acf .ui-icon-clipboard { background-position: -160px -128px; }
217
+ .ui-acf .ui-icon-copy { background-position: -176px -128px; }
218
+ .ui-acf .ui-icon-contact { background-position: -192px -128px; }
219
+ .ui-acf .ui-icon-image { background-position: -208px -128px; }
220
+ .ui-acf .ui-icon-video { background-position: -224px -128px; }
221
+ .ui-acf .ui-icon-script { background-position: -240px -128px; }
222
+ .ui-acf .ui-icon-alert { background-position: 0 -144px; }
223
+ .ui-acf .ui-icon-info { background-position: -16px -144px; }
224
+ .ui-acf .ui-icon-notice { background-position: -32px -144px; }
225
+ .ui-acf .ui-icon-help { background-position: -48px -144px; }
226
+ .ui-acf .ui-icon-check { background-position: -64px -144px; }
227
+ .ui-acf .ui-icon-bullet { background-position: -80px -144px; }
228
+ .ui-acf .ui-icon-radio-off { background-position: -96px -144px; }
229
+ .ui-acf .ui-icon-radio-on { background-position: -112px -144px; }
230
+ .ui-acf .ui-icon-pin-w { background-position: -128px -144px; }
231
+ .ui-acf .ui-icon-pin-s { background-position: -144px -144px; }
232
+ .ui-acf .ui-icon-play { background-position: 0 -160px; }
233
+ .ui-acf .ui-icon-pause { background-position: -16px -160px; }
234
+ .ui-acf .ui-icon-seek-next { background-position: -32px -160px; }
235
+ .ui-acf .ui-icon-seek-prev { background-position: -48px -160px; }
236
+ .ui-acf .ui-icon-seek-end { background-position: -64px -160px; }
237
+ .ui-acf .ui-icon-seek-start { background-position: -80px -160px; }
238
  /* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */
239
+ .ui-acf .ui-icon-seek-first { background-position: -80px -160px; }
240
+ .ui-acf .ui-icon-stop { background-position: -96px -160px; }
241
+ .ui-acf .ui-icon-eject { background-position: -112px -160px; }
242
+ .ui-acf .ui-icon-volume-off { background-position: -128px -160px; }
243
+ .ui-acf .ui-icon-volume-on { background-position: -144px -160px; }
244
+ .ui-acf .ui-icon-power { background-position: 0 -176px; }
245
+ .ui-acf .ui-icon-signal-diag { background-position: -16px -176px; }
246
+ .ui-acf .ui-icon-signal { background-position: -32px -176px; }
247
+ .ui-acf .ui-icon-battery-0 { background-position: -48px -176px; }
248
+ .ui-acf .ui-icon-battery-1 { background-position: -64px -176px; }
249
+ .ui-acf .ui-icon-battery-2 { background-position: -80px -176px; }
250
+ .ui-acf .ui-icon-battery-3 { background-position: -96px -176px; }
251
+ .ui-acf .ui-icon-circle-plus { background-position: 0 -192px; }
252
+ .ui-acf .ui-icon-circle-minus { background-position: -16px -192px; }
253
+ .ui-acf .ui-icon-circle-close { background-position: -32px -192px; }
254
+ .ui-acf .ui-icon-circle-triangle-e { background-position: -48px -192px; }
255
+ .ui-acf .ui-icon-circle-triangle-s { background-position: -64px -192px; }
256
+ .ui-acf .ui-icon-circle-triangle-w { background-position: -80px -192px; }
257
+ .ui-acf .ui-icon-circle-triangle-n { background-position: -96px -192px; }
258
+ .ui-acf .ui-icon-circle-arrow-e { background-position: -112px -192px; }
259
+ .ui-acf .ui-icon-circle-arrow-s { background-position: -128px -192px; }
260
+ .ui-acf .ui-icon-circle-arrow-w { background-position: -144px -192px; }
261
+ .ui-acf .ui-icon-circle-arrow-n { background-position: -160px -192px; }
262
+ .ui-acf .ui-icon-circle-zoomin { background-position: -176px -192px; }
263
+ .ui-acf .ui-icon-circle-zoomout { background-position: -192px -192px; }
264
+ .ui-acf .ui-icon-circle-check { background-position: -208px -192px; }
265
+ .ui-acf .ui-icon-circlesmall-plus { background-position: 0 -208px; }
266
+ .ui-acf .ui-icon-circlesmall-minus { background-position: -16px -208px; }
267
+ .ui-acf .ui-icon-circlesmall-close { background-position: -32px -208px; }
268
+ .ui-acf .ui-icon-squaresmall-plus { background-position: -48px -208px; }
269
+ .ui-acf .ui-icon-squaresmall-minus { background-position: -64px -208px; }
270
+ .ui-acf .ui-icon-squaresmall-close { background-position: -80px -208px; }
271
+ .ui-acf .ui-icon-grip-dotted-vertical { background-position: 0 -224px; }
272
+ .ui-acf .ui-icon-grip-dotted-horizontal { background-position: -16px -224px; }
273
+ .ui-acf .ui-icon-grip-solid-vertical { background-position: -32px -224px; }
274
+ .ui-acf .ui-icon-grip-solid-horizontal { background-position: -48px -224px; }
275
+ .ui-acf .ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; }
276
+ .ui-acf .ui-icon-grip-diagonal-se { background-position: -80px -224px; }
277
 
278
 
279
  /* Misc visuals
280
  ----------------------------------*/
281
 
282
  /* Corner radius */
283
+ .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; }
284
+ .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; }
285
+ .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; }
286
+ .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; }
287
 
288
  /* Overlays */
289
+ .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); }
290
+ .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; }/*
291
  * jQuery UI Datepicker 1.8.14
292
  *
293
  * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
296
  *
297
  * http://docs.jquery.com/UI/Datepicker#theming
298
  */
299
+ .ui-acf .ui-datepicker { width: 17em; padding: .2em .2em 0; display: none; }
300
+ .ui-acf .ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; }
301
+ .ui-acf .ui-datepicker .ui-datepicker-prev, .ui-acf .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; }
302
+ .ui-acf .ui-datepicker .ui-datepicker-prev-hover, .ui-acf .ui-datepicker .ui-datepicker-next-hover { top: 1px; }
303
+ .ui-acf .ui-datepicker .ui-datepicker-prev { left:2px; }
304
+ .ui-acf .ui-datepicker .ui-datepicker-next { right:2px; }
305
+ .ui-acf .ui-datepicker .ui-datepicker-prev-hover { left:1px; }
306
+ .ui-acf .ui-datepicker .ui-datepicker-next-hover { right:1px; }
307
+ .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; }
308
+ .ui-acf .ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; }
309
+ .ui-acf .ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0; }
310
+ .ui-acf .ui-datepicker select.ui-datepicker-month-year {width: 100%;}
311
+ .ui-acf .ui-datepicker select.ui-datepicker-month,
312
+ .ui-acf .ui-datepicker select.ui-datepicker-year { width: 49%;}
313
+ .ui-acf .ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; }
314
+ .ui-acf .ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; }
315
+ .ui-acf .ui-datepicker td { border: 0; padding: 1px; }
316
+ .ui-acf .ui-datepicker td span, .ui-acf .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; }
317
+ .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; }
318
+ .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; }
319
+ .ui-acf .ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; }
320
 
321
  /* with multiple calendars */
322
+ .ui-acf .ui-datepicker.ui-datepicker-multi { width:auto; }
323
+ .ui-acf .ui-datepicker-multi .ui-datepicker-group { float:left; }
324
+ .ui-acf .ui-datepicker-multi .ui-datepicker-group table { width:95%; margin:0 auto .4em; }
325
+ .ui-acf .ui-datepicker-multi-2 .ui-datepicker-group { width:50%; }
326
+ .ui-acf .ui-datepicker-multi-3 .ui-datepicker-group { width:33.3%; }
327
+ .ui-acf .ui-datepicker-multi-4 .ui-datepicker-group { width:25%; }
328
+ .ui-acf .ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header { border-left-width:0; }
329
+ .ui-acf .ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { border-left-width:0; }
330
+ .ui-acf .ui-datepicker-multi .ui-datepicker-buttonpane { clear:left; }
331
+ .ui-acf .ui-datepicker-row-break { clear:both; width:100%; font-size:0em; }
332
 
333
  /* RTL support */
334
+ .ui-acf .ui-datepicker-rtl { direction: rtl; }
335
+ .ui-acf .ui-datepicker-rtl .ui-datepicker-prev { right: 2px; left: auto; }
336
+ .ui-acf .ui-datepicker-rtl .ui-datepicker-next { left: 2px; right: auto; }
337
+ .ui-acf .ui-datepicker-rtl .ui-datepicker-prev:hover { right: 1px; left: auto; }
338
+ .ui-acf .ui-datepicker-rtl .ui-datepicker-next:hover { left: 1px; right: auto; }
339
+ .ui-acf .ui-datepicker-rtl .ui-datepicker-buttonpane { clear:right; }
340
+ .ui-acf .ui-datepicker-rtl .ui-datepicker-buttonpane button { float: left; }
341
+ .ui-acf .ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current { float:right; }
342
+ .ui-acf .ui-datepicker-rtl .ui-datepicker-group { float:right; }
343
+ .ui-acf .ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
344
+ .ui-acf .ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
345
 
346
  /* IE6 IFRAME FIX (taken from datepicker 1.5.3 */
347
+ .ui-acf .ui-datepicker-cover {
348
  display: none; /*sorry for IE5*/
349
  display/**/: block; /*sorry for IE5*/
350
  position: absolute; /*must have*/
core/fields/file.php CHANGED
@@ -1,56 +1,180 @@
1
  <?php
2
 
3
- class acf_File
4
  {
5
- var $name;
6
- var $title;
7
- var $parent;
 
 
 
 
 
 
8
 
9
- function acf_File($parent)
10
  {
11
- $this->name = 'file';
 
 
12
  $this->title = __('File','acf');
13
- $this->parent = $parent;
14
 
15
  add_action('admin_head-media-upload-popup', array($this, 'popup_head'));
16
  add_filter('media_send_to_editor', array($this, 'media_send_to_editor'), 15, 2 );
17
- //add_action('admin_init', array($this, 'admin_init'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  }
20
 
21
 
22
- /*---------------------------------------------------------------------------------------------
23
- * Options HTML
24
- * - called from fields_meta_box.php
25
- * - displays options in html format
26
- *
27
- * @author Elliot Condon
28
- * @since 2.0.3
29
- *
30
- ---------------------------------------------------------------------------------------------*/
31
- function options_html($key, $field)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  {
33
  // vars
34
- $options = $field->options;
35
- $options['save_format'] = isset($options['save_format']) ? $options['save_format'] : 'url';
36
 
37
  ?>
38
- <tr class="field_option field_option_file">
39
  <td class="label">
40
  <label><?php _e("Return Value",'acf'); ?></label>
41
  </td>
42
  <td>
43
  <?php
44
- $temp_field = new stdClass();
45
- $temp_field->type = 'select';
46
- $temp_field->input_name = 'acf[fields]['.$key.'][options][save_format]';
47
- $temp_field->input_class = '';
48
- $temp_field->value = $options['save_format'];
49
- $temp_field->options = array('choices' => array(
50
  'url' => 'File URL',
51
  'id' => 'Attachment ID'
52
- ));
53
- $this->parent->create_field($temp_field);
54
  ?>
55
  </td>
56
  </tr>
@@ -163,53 +287,19 @@ class acf_File
163
 
164
  /*--------------------------------------------------------------------------------------
165
  *
166
- * html
167
  *
168
  * @author Elliot Condon
169
- * @since 2.0.6
170
  *
171
  *-------------------------------------------------------------------------------------*/
172
 
173
- function html($field)
174
  {
 
 
175
 
176
- $class = "";
177
- $file_src = "";
178
-
179
- if($field->value != '' && is_numeric($field->value))
180
- {
181
- $file_src = wp_get_attachment_url($field->value);
182
-
183
- if($file_src)
184
- {
185
- $class = " active";
186
- }
187
- }
188
-
189
-
190
- echo '<div class="acf_file_uploader'.$class.'">';
191
- echo '<p class="file"><span class="file_url">'.$file_src.'</span> <input type="button" class="button" value="'.__('Remove File','acf').'" /></p>';
192
- echo '<input class="value" type="hidden" name="'.$field->input_name.'" value="'.$field->value.'" />';
193
- echo '<p class="no_file">'.__('No File selected','acf').'. <input type="button" class="button" value="'.__('Add File','acf').'" /></p>';
194
- echo '</div>';
195
-
196
- }
197
-
198
-
199
- /*--------------------------------------------------------------------------------------
200
- *
201
- * Format Value
202
- * - this is called from api.php
203
- *
204
- * @author Elliot Condon
205
- * @since 2.0.6
206
- *
207
- *-------------------------------------------------------------------------------------*/
208
-
209
- function format_value_for_api($value, $options = null)
210
- {
211
-
212
- $format = isset($options['save_format']) ? $options['save_format'] : 'url';
213
 
214
  if($format == 'url')
215
  {
@@ -217,10 +307,8 @@ class acf_File
217
  }
218
 
219
  return $value;
220
-
221
  }
222
 
223
-
224
  }
225
 
226
  ?>
1
  <?php
2
 
3
+ class acf_File extends acf_Field
4
  {
5
+ /*--------------------------------------------------------------------------------------
6
+ *
7
+ * Constructor
8
+ *
9
+ * @author Elliot Condon
10
+ * @since 1.0.0
11
+ * @updated 2.2.0
12
+ *
13
+ *-------------------------------------------------------------------------------------*/
14
 
15
+ function __construct($parent)
16
  {
17
+ parent::__construct($parent);
18
+
19
+ $this->name = 'file';
20
  $this->title = __('File','acf');
 
21
 
22
  add_action('admin_head-media-upload-popup', array($this, 'popup_head'));
23
  add_filter('media_send_to_editor', array($this, 'media_send_to_editor'), 15, 2 );
24
+ }
25
+
26
+
27
+ /*--------------------------------------------------------------------------------------
28
+ *
29
+ * admin_print_scripts / admin_print_styles
30
+ *
31
+ * @author Elliot Condon
32
+ * @since 3.0.0
33
+ *
34
+ *-------------------------------------------------------------------------------------*/
35
+
36
+ function admin_print_scripts()
37
+ {
38
+ wp_enqueue_script(array(
39
+ 'jquery',
40
+ 'jquery-ui-core',
41
+ 'jquery-ui-tabs',
42
+
43
+ 'thickbox',
44
+ 'media-upload',
45
+ ));
46
+ }
47
+
48
+ function admin_print_styles()
49
+ {
50
+ wp_enqueue_style(array(
51
+ 'thickbox',
52
+ ));
53
+ }
54
+
55
+
56
+ /*--------------------------------------------------------------------------------------
57
+ *
58
+ * admin_head
59
+ *
60
+ * @author Elliot Condon
61
+ * @since 2.0.6
62
+ *
63
+ *-------------------------------------------------------------------------------------*/
64
+
65
+ function admin_head()
66
+ {
67
+ ?>
68
+ <script type="text/javascript">
69
 
70
+ (function($){
71
+
72
+ $(document).ready(function(){
73
+
74
+ var post_id = $('input#post_ID').val();
75
+
76
+ $('#poststuff .acf_file_uploader').each(function(){
77
+
78
+ //console.log('file setup');
79
+ var div = $(this);
80
+
81
+ div.find('p.no_file input.button').click(function(){
82
+
83
+ // set global var
84
+ window.acf_div = div;
85
+
86
+ // show the thickbox
87
+ tb_show('Add File to field', 'media-upload.php?post_id='+post_id+'&type=file&acf_type=file&TB_iframe=1');
88
+
89
+ return false;
90
+ });
91
+
92
+
93
+ div.find('p.file input.button').unbind('click').click(function()
94
+ {
95
+ div.find('input.value').val('');
96
+ div.removeClass('active');
97
+
98
+ return false;
99
+ });
100
+
101
+ });
102
+
103
+
104
+ });
105
+
106
+ })(jQuery);
107
+ </script>
108
+ <?php
109
  }
110
 
111
 
112
+ /*--------------------------------------------------------------------------------------
113
+ *
114
+ * create_field
115
+ *
116
+ * @author Elliot Condon
117
+ * @since 2.0.5
118
+ * @updated 2.2.0
119
+ *
120
+ *-------------------------------------------------------------------------------------*/
121
+
122
+ function create_field($field)
123
+ {
124
+ // vars
125
+ $class = "";
126
+ $file_src = "";
127
+
128
+ // get file url
129
+ if($field['value'] != '' && is_numeric($field['value']))
130
+ {
131
+ $file_src = wp_get_attachment_url($field['value']);
132
+ if($file_src) $class = "active";
133
+ }
134
+
135
+ // html
136
+ echo '<div class="acf_file_uploader ' . $class . '">';
137
+ echo '<p class="file"><span class="file_url">'.$file_src.'</span> <input type="button" class="button" value="'.__('Remove File','acf').'" /></p>';
138
+ echo '<input class="value" type="hidden" name="' . $field['name'] . '" value="' . $field['value'] . '" />';
139
+ echo '<p class="no_file">'.__('No File selected','acf').'. <input type="button" class="button" value="'.__('Add File','acf').'" /></p>';
140
+ echo '</div>';
141
+
142
+ }
143
+
144
+
145
+
146
+ /*--------------------------------------------------------------------------------------
147
+ *
148
+ * create_options
149
+ *
150
+ * @author Elliot Condon
151
+ * @since 2.0.6
152
+ * @updated 2.2.0
153
+ *
154
+ *-------------------------------------------------------------------------------------*/
155
+
156
+ function create_options($key, $field)
157
  {
158
  // vars
159
+ $field['save_format'] = isset($field['save_format']) ? $field['save_format'] : 'url';
 
160
 
161
  ?>
162
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
163
  <td class="label">
164
  <label><?php _e("Return Value",'acf'); ?></label>
165
  </td>
166
  <td>
167
  <?php
168
+ $this->parent->create_field(array(
169
+ 'type' => 'radio',
170
+ 'name' => 'fields['.$key.'][save_format]',
171
+ 'value' => $field['save_format'],
172
+ 'layout' => 'horizontal',
173
+ 'choices' => array(
174
  'url' => 'File URL',
175
  'id' => 'Attachment ID'
176
+ )
177
+ ));
178
  ?>
179
  </td>
180
  </tr>
287
 
288
  /*--------------------------------------------------------------------------------------
289
  *
290
+ * get_value_for_api
291
  *
292
  * @author Elliot Condon
293
+ * @since 3.0.0
294
  *
295
  *-------------------------------------------------------------------------------------*/
296
 
297
+ function get_value_for_api($post_id, $field)
298
  {
299
+ // vars
300
+ $format = isset($field['save_format']) ? $field['save_format'] : 'url';
301
 
302
+ $value = parent::get_value($post_id, $field);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
303
 
304
  if($format == 'url')
305
  {
307
  }
308
 
309
  return $value;
 
310
  }
311
 
 
312
  }
313
 
314
  ?>
core/fields/image.php CHANGED
@@ -1,77 +1,203 @@
1
  <?php
2
 
3
- class acf_Image
4
  {
5
- var $name;
6
- var $title;
7
- var $parent;
8
 
9
- function acf_Image($parent)
 
 
 
 
 
 
 
 
 
 
10
  {
11
- $this->name = 'image';
 
 
12
  $this->title = __('Image','acf');
13
- $this->parent = $parent;
14
 
15
  add_action('admin_head-media-upload-popup', array($this, 'popup_head'));
16
  add_filter('media_send_to_editor', array($this, 'media_send_to_editor'), 15, 2 );
17
- //add_action('admin_init', array($this, 'admin_init'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
 
 
 
19
  }
20
 
 
 
 
 
 
 
21
 
22
- /*---------------------------------------------------------------------------------------------
23
- * Options HTML
24
- * - called from fields_meta_box.php
25
- * - displays options in html format
26
- *
27
- * @author Elliot Condon
28
- * @since 2.0.3
29
- *
30
- ---------------------------------------------------------------------------------------------*/
31
- function options_html($key, $field)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  {
33
  // vars
34
- $options = $field->options;
35
- $options['save_format'] = isset($options['save_format']) ? $options['save_format'] : 'url';
36
- $options['preview_size'] = isset($options['preview_size']) ? $options['preview_size'] : 'thumbnail';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
  ?>
39
- <tr class="field_option field_option_image">
40
  <td class="label">
41
  <label><?php _e("Return Value",'acf'); ?></label>
42
  </td>
43
  <td>
44
  <?php
45
- $temp_field = new stdClass();
46
- $temp_field->type = 'select';
47
- $temp_field->input_name = 'acf[fields]['.$key.'][options][save_format]';
48
- $temp_field->input_class = '';
49
- $temp_field->value = $options['save_format'];
50
- $temp_field->options = array('choices' => array(
51
  'url' => 'Image URL',
52
  'id' => 'Attachment ID'
53
- ));
54
- $this->parent->create_field($temp_field);
55
  ?>
56
  </td>
57
  </tr>
58
- <tr class="field_option field_option_image">
59
  <td class="label">
60
  <label><?php _e("Preview Size",'acf'); ?></label>
61
  </td>
62
  <td>
63
  <?php
64
- $temp_field->type = 'select';
65
- $temp_field->input_name = 'acf[fields]['.$key.'][options][preview_size]';
66
- $temp_field->input_class = '';
67
- $temp_field->value = $options['preview_size'];
68
- $temp_field->options = array('choices' => array(
 
69
  'thumbnail' => 'Thumbnail',
70
  'medium' => 'Medium',
71
  'large' => 'Large',
72
  'full' => 'Full'
73
- ));
74
- $this->parent->create_field($temp_field);
75
  ?>
76
  </td>
77
  </tr>
@@ -187,50 +313,22 @@ class acf_Image
187
 
188
  }
189
 
190
-
191
- function html($field)
192
- {
193
-
194
- $class = "";
195
- $file_src = "";
196
- $preview_size = isset($field->options['preview_size']) ? $field->options['preview_size'] : 'medium';
197
-
198
- if($field->value != '' && is_numeric($field->value))
199
- {
200
- $file_src = wp_get_attachment_image_src($field->value, $preview_size);
201
- $file_src = $file_src[0];
202
-
203
- if($file_src)
204
- {
205
- $class = " active";
206
- }
207
- }
208
-
209
-
210
- echo '<div class="acf_image_uploader'.$class.'" data-preview_size="' . $preview_size . '">';
211
- echo '<a href="#" class="remove_image"></a>';
212
- echo '<img src="'.$file_src.'" alt=""/>';
213
- echo '<input class="value" type="hidden" name="'.$field->input_name.'" value="'.$field->value.'" />';
214
- echo '<p>'.__('No image selected','acf').'. <input type="button" class="button" value="'.__('Add Image','acf').'" /></p>';
215
- echo '</div>';
216
 
217
- }
218
-
219
-
220
  /*--------------------------------------------------------------------------------------
221
  *
222
- * Format Value
223
- * - this is called from api.php
224
  *
225
  * @author Elliot Condon
226
- * @since 2.0.6
227
  *
228
  *-------------------------------------------------------------------------------------*/
229
-
230
- function format_value_for_api($value, $options = null)
231
  {
 
 
232
 
233
- $format = isset($options['save_format']) ? $options['save_format'] : 'url';
234
 
235
  if($format == 'url')
236
  {
@@ -238,8 +336,9 @@ class acf_Image
238
  }
239
 
240
  return $value;
241
-
242
  }
 
 
243
 
244
  }
245
 
1
  <?php
2
 
3
+ class acf_Image extends acf_Field
4
  {
 
 
 
5
 
6
+ /*--------------------------------------------------------------------------------------
7
+ *
8
+ * Constructor
9
+ *
10
+ * @author Elliot Condon
11
+ * @since 1.0.0
12
+ * @updated 2.2.0
13
+ *
14
+ *-------------------------------------------------------------------------------------*/
15
+
16
+ function __construct($parent)
17
  {
18
+ parent::__construct($parent);
19
+
20
+ $this->name = 'image';
21
  $this->title = __('Image','acf');
 
22
 
23
  add_action('admin_head-media-upload-popup', array($this, 'popup_head'));
24
  add_filter('media_send_to_editor', array($this, 'media_send_to_editor'), 15, 2 );
25
+ }
26
+
27
+
28
+ /*--------------------------------------------------------------------------------------
29
+ *
30
+ * admin_print_scripts / admin_print_styles
31
+ *
32
+ * @author Elliot Condon
33
+ * @since 3.0.0
34
+ *
35
+ *-------------------------------------------------------------------------------------*/
36
+
37
+ function admin_print_scripts()
38
+ {
39
+ wp_enqueue_script(array(
40
+ 'jquery',
41
+ 'jquery-ui-core',
42
+ 'jquery-ui-tabs',
43
 
44
+ 'thickbox',
45
+ 'media-upload',
46
+ ));
47
  }
48
 
49
+ function admin_print_styles()
50
+ {
51
+ wp_enqueue_style(array(
52
+ 'thickbox',
53
+ ));
54
+ }
55
 
56
+
57
+ /*--------------------------------------------------------------------------------------
58
+ *
59
+ * admin_head
60
+ *
61
+ * @author Elliot Condon
62
+ * @since 2.0.6
63
+ *
64
+ *-------------------------------------------------------------------------------------*/
65
+
66
+ function admin_head()
67
+ {
68
+ ?>
69
+ <script type="text/javascript">
70
+
71
+ (function($){
72
+
73
+ $(document).ready(function(){
74
+
75
+ $('#poststuff .acf_image_uploader .button').live('click', function(){
76
+
77
+ // vars
78
+ var div = $(this).closest('.acf_image_uploader');
79
+ var post_id = $('input#post_ID').val();
80
+ var preview_size = div.attr('data-preview_size');
81
+
82
+ // set global var
83
+ window.acf_div = div;
84
+
85
+ // show the thickbox
86
+ tb_show('Add Image to field', 'media-upload.php?post_id=' + post_id + '&type=image&acf_type=image&acf_preview_size=' + preview_size + 'TB_iframe=1');
87
+
88
+ return false;
89
+ });
90
+
91
+ $('#poststuff .acf_image_uploader .remove_image').live('click', function(){
92
+
93
+ // vars
94
+ var div = $(this).closest('.acf_image_uploader');
95
+
96
+ div.find('input.value').val('');
97
+ div.removeClass('active');
98
+
99
+ return false;
100
+
101
+ });
102
+
103
+ });
104
+
105
+ })(jQuery);
106
+ </script>
107
+ <?php
108
+ }
109
+
110
+
111
+ /*--------------------------------------------------------------------------------------
112
+ *
113
+ * create_field
114
+ *
115
+ * @author Elliot Condon
116
+ * @since 2.0.5
117
+ * @updated 2.2.0
118
+ *
119
+ *-------------------------------------------------------------------------------------*/
120
+
121
+ function create_field($field)
122
  {
123
  // vars
124
+ $class = "";
125
+ $file_src = "";
126
+ $preview_size = isset($field['preview_size']) ? $field['preview_size'] : 'medium';
127
+
128
+ // get image url
129
+ if($field['value'] != '' && is_numeric($field['value']))
130
+ {
131
+ $file_src = wp_get_attachment_image_src($field['value'], $preview_size);
132
+ $file_src = $file_src[0];
133
+
134
+ if($file_src) $class = "active";
135
+ }
136
+
137
+ // html
138
+ echo '<div class="acf_image_uploader ' . $class . '" data-preview_size="' . $preview_size . '">';
139
+ echo '<a href="#" class="remove_image"></a>';
140
+ echo '<img src="' . $file_src . '" alt=""/>';
141
+ echo '<input class="value" type="hidden" name="' . $field['name'] . '" value="' . $field['value'] . '" />';
142
+ echo '<p>'.__('No image selected','acf').'. <input type="button" class="button" value="'.__('Add Image','acf').'" /></p>';
143
+ echo '</div>';
144
+ }
145
+
146
+
147
+ /*--------------------------------------------------------------------------------------
148
+ *
149
+ * create_options
150
+ *
151
+ * @author Elliot Condon
152
+ * @since 2.0.6
153
+ * @updated 2.2.0
154
+ *
155
+ *-------------------------------------------------------------------------------------*/
156
+
157
+ function create_options($key, $field)
158
+ {
159
+ // vars
160
+ $field['save_format'] = isset($field['save_format']) ? $field['save_format'] : 'url';
161
+ $field['preview_size'] = isset($field['preview_size']) ? $field['preview_size'] : 'thumbnail';
162
 
163
  ?>
164
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
165
  <td class="label">
166
  <label><?php _e("Return Value",'acf'); ?></label>
167
  </td>
168
  <td>
169
  <?php
170
+ $this->parent->create_field(array(
171
+ 'type' => 'radio',
172
+ 'name' => 'fields['.$key.'][save_format]',
173
+ 'value' => $field['save_format'],
174
+ 'layout' => 'horizontal',
175
+ 'choices' => array(
176
  'url' => 'Image URL',
177
  'id' => 'Attachment ID'
178
+ )
179
+ ));
180
  ?>
181
  </td>
182
  </tr>
183
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
184
  <td class="label">
185
  <label><?php _e("Preview Size",'acf'); ?></label>
186
  </td>
187
  <td>
188
  <?php
189
+ $this->parent->create_field(array(
190
+ 'type' => 'radio',
191
+ 'name' => 'fields['.$key.'][preview_size]',
192
+ 'value' => $field['preview_size'],
193
+ 'layout' => 'horizontal',
194
+ 'choices' => array(
195
  'thumbnail' => 'Thumbnail',
196
  'medium' => 'Medium',
197
  'large' => 'Large',
198
  'full' => 'Full'
199
+ )
200
+ ));
201
  ?>
202
  </td>
203
  </tr>
313
 
314
  }
315
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
316
 
 
 
 
317
  /*--------------------------------------------------------------------------------------
318
  *
319
+ * get_value_for_api
 
320
  *
321
  * @author Elliot Condon
322
+ * @since 3.0.0
323
  *
324
  *-------------------------------------------------------------------------------------*/
325
+
326
+ function get_value_for_api($post_id, $field)
327
  {
328
+ // vars
329
+ $format = isset($field['save_format']) ? $field['save_format'] : 'url';
330
 
331
+ $value = parent::get_value($post_id, $field);
332
 
333
  if($format == 'url')
334
  {
336
  }
337
 
338
  return $value;
 
339
  }
340
+
341
+
342
 
343
  }
344
 
core/fields/page_link.php CHANGED
@@ -1,69 +1,77 @@
1
  <?php
2
 
3
- class acf_Page_link
4
  {
5
- var $name;
6
- var $title;
7
- var $parent;
8
 
9
- function acf_Page_link($parent)
 
 
 
 
 
 
 
 
 
 
10
  {
11
- $this->name = 'page_link';
 
 
12
  $this->title = __('Page Link','acf');
13
- $this->parent = $parent;
14
- }
 
15
 
 
 
 
 
 
 
 
 
 
16
 
17
- /*---------------------------------------------------------------------------------------------
18
- * HTML
19
- * - this is called all over the shop, it creates the input html
20
- *
21
- * @author Elliot Condon
22
- * @since 1.1
23
- *
24
- ---------------------------------------------------------------------------------------------*/
25
- function html($field)
26
- {
27
- // get post types
28
- if(isset($field->options['post_type']) && is_array($field->options['post_type']) && $field->options['post_type'][0] != "")
29
- {
30
- // 1. If select has selected post types, just use them
31
- $post_types = $field->options['post_type'];
32
- }
33
- else
34
  {
35
- //2. If not post types have been selected, load all the public ones
36
- $post_types = get_post_types(array('public' => true));
37
- foreach($post_types as $key => $value)
38
  {
39
  if($value == 'attachment')
40
  {
41
- unset($post_types[$key]);
42
  }
43
  }
44
  }
45
 
46
-
47
- // start select
48
- if(isset($field->options["multiple"]) && $field->options["multiple"] == '1')
49
- {
50
- $name_extra = '[]';
51
- echo '<select id="'.$field->input_name.'" class="'.$field->input_class.'" name="'.$field->input_name.$name_extra.'" multiple="multiple" size="5" >';
52
- }
53
- else
54
  {
55
- echo '<select id="'.$field->input_name.'" class="'.$field->input_class.'" name="'.$field->input_name.'" >';
56
-
57
- // add null
58
- if(isset($field->options['allow_null']) && $field->options['allow_null'] == '1')
59
- {
60
- echo '<option value="null"> - Select - </option>';
61
- }
62
- }
63
 
 
 
64
 
 
 
 
 
 
65
 
66
- foreach($post_types as $post_type)
67
  {
68
  // get posts
69
  $posts = false;
@@ -76,8 +84,8 @@ class acf_Page_link
76
  'post_type' => $post_type,
77
  'sort_column' => 'menu_order',
78
  'order' => 'ASC',
79
- 'meta_key' => $options['meta_key'],
80
- 'meta_value' => $options['meta_value'],
81
  ));
82
  }
83
  else
@@ -88,8 +96,8 @@ class acf_Page_link
88
  'post_type' => $post_type,
89
  'orderby' => 'title',
90
  'order' => 'ASC',
91
- 'meta_key' => $options['meta_key'],
92
- 'meta_value' => $options['meta_value'],
93
  ));
94
  }
95
 
@@ -116,10 +124,10 @@ class acf_Page_link
116
  $selected = '';
117
 
118
 
119
- if(is_array($field->value))
120
  {
121
  // 2. If the value is an array (multiple select), loop through values and check if it is selected
122
- if(in_array($key, $field->value))
123
  {
124
  $selected = 'selected="selected"';
125
  }
@@ -127,7 +135,7 @@ class acf_Page_link
127
  else
128
  {
129
  // 3. this is not a multiple select, just check normaly
130
- if($key == $field->value)
131
  {
132
  $selected = 'selected="selected"';
133
  }
@@ -151,26 +159,25 @@ class acf_Page_link
151
  }
152
 
153
 
154
- /*---------------------------------------------------------------------------------------------
155
- * Options HTML
156
- * - called from fields_meta_box.php
157
- * - displays options in html format
158
- *
159
- * @author Elliot Condon
160
- * @since 1.1
161
- *
162
- ---------------------------------------------------------------------------------------------*/
163
- function options_html($key, $field)
164
- {
165
- $options = $field->options;
166
-
167
- $options['post_type'] = isset($options['post_type']) ? $options['post_type'] : '';
168
- $options['multiple'] = isset($options['multiple']) ? $options['multiple'] : '0';
169
- $options['allow_null'] = isset($options['allow_null']) ? $options['allow_null'] : '0';
170
 
171
  ?>
172
-
173
- <tr class="field_option field_option_page_link">
174
  <td class="label">
175
  <label for=""><?php _e("Post Type",'acf'); ?></label>
176
  <p class="description"><?php _e("Filter posts by selecting a post type<br />
@@ -189,48 +196,51 @@ class acf_Page_link
189
  unset($post_types['revision']);
190
  unset($post_types['acf']);
191
 
 
 
 
 
 
 
 
192
  ?>
193
- <?php
194
- $temp_field = new stdClass();
195
- $temp_field->type = 'select';
196
- $temp_field->input_name = 'acf[fields]['.$key.'][options][post_type]';
197
- $temp_field->input_class = '';
198
- $temp_field->value = $options['post_type'];
199
- $temp_field->options = array('choices' => $post_types, 'multiple' => '1');
200
- $this->parent->create_field($temp_field);
201
-
202
- ?>
203
-
204
  </td>
205
  </tr>
206
- <tr class="field_option field_option_page_link">
207
  <td class="label">
208
  <label><?php _e("Allow Null?",'acf'); ?></label>
209
  </td>
210
  <td>
211
  <?php
212
- $temp_field = new stdClass();
213
- $temp_field->type = 'true_false';
214
- $temp_field->input_name = 'acf[fields]['.$key.'][options][allow_null]';
215
- $temp_field->input_class = '';
216
- $temp_field->value = $options['allow_null'];
217
- $temp_field->options = array('message' => 'Add null value above choices');
218
- $this->parent->create_field($temp_field);
 
 
 
219
  ?>
220
  </td>
221
  </tr>
222
- <tr class="field_option field_option_page_link">
223
  <td class="label">
224
  <label><?php _e("Select multiple values?",'acf'); ?></label>
225
  </td>
226
  <td>
227
  <?php
228
- $temp_field->type = 'true_false';
229
- $temp_field->input_name = 'acf[fields]['.$key.'][options][multiple]';
230
- $temp_field->input_class = '';
231
- $temp_field->value = $options['multiple'];
232
- $temp_field->options = array('message' => 'Turn this drop-down into a multi-select');
233
- $this->parent->create_field($temp_field);
 
 
 
 
234
  ?>
235
  </td>
236
  </tr>
@@ -238,18 +248,24 @@ class acf_Page_link
238
  }
239
 
240
 
 
 
 
 
 
 
 
 
241
 
242
- /*---------------------------------------------------------------------------------------------
243
- * Format Value
244
- * - this is called from api.php
245
- *
246
- * @author Elliot Condon
247
- * @since 1.1.3
248
- *
249
- ---------------------------------------------------------------------------------------------*/
250
- function format_value_for_api($value, $options = null)
251
  {
252
- $value = $this->format_value_for_input($value);
 
 
 
 
 
 
253
 
254
  if($value == 'null')
255
  {
@@ -271,31 +287,6 @@ class acf_Page_link
271
  return $value;
272
  }
273
 
274
-
275
- /*---------------------------------------------------------------------------------------------
276
- * Format Value for input
277
- * - this is called from api.php
278
- *
279
- * @author Elliot Condon
280
- * @since 1.1.3
281
- *
282
- ---------------------------------------------------------------------------------------------*/
283
- function format_value_for_input($value)
284
- {
285
- $is_array = @unserialize($value);
286
-
287
- if($is_array)
288
- {
289
- return unserialize($value);
290
- }
291
- else
292
- {
293
- return $value;
294
- }
295
-
296
-
297
- }
298
-
299
 
300
 
301
  }
1
  <?php
2
 
3
+ class acf_Page_link extends acf_Field
4
  {
 
 
 
5
 
6
+ /*--------------------------------------------------------------------------------------
7
+ *
8
+ * Constructor
9
+ *
10
+ * @author Elliot Condon
11
+ * @since 1.0.0
12
+ * @updated 2.2.0
13
+ *
14
+ *-------------------------------------------------------------------------------------*/
15
+
16
+ function __construct($parent)
17
  {
18
+ parent::__construct($parent);
19
+
20
+ $this->name = 'page_link';
21
  $this->title = __('Page Link','acf');
22
+
23
+ }
24
+
25
 
26
+ /*--------------------------------------------------------------------------------------
27
+ *
28
+ * create_field
29
+ *
30
+ * @author Elliot Condon
31
+ * @since 2.0.5
32
+ * @updated 2.2.0
33
+ *
34
+ *-------------------------------------------------------------------------------------*/
35
 
36
+ function create_field($field)
37
+ {
38
+ // vars
39
+ $field['multiple'] = isset($field['multiple']) ? $field['multiple'] : false;
40
+ $field['post_type'] = isset($field['post_type']) ? $field['post_type'] : false;
41
+ //$field['meta_key'] = isset($field['meta_key']) ? $field['meta_key'] : false;
42
+ //$field['meta_value'] = isset($field['meta_value']) ? $field['meta_value'] : false;
43
+
44
+
45
+ if(!$field['post_type'] || !is_array($field['post_type']) || $field['post_type'][0] == "")
 
 
 
 
 
 
 
46
  {
47
+ $field['post_type'] = get_post_types(array('public' => true));
48
+ foreach($field['post_type'] as $key => $value)
 
49
  {
50
  if($value == 'attachment')
51
  {
52
+ unset($field['post_type'][$key]);
53
  }
54
  }
55
  }
56
 
57
+ // multiple select
58
+ $multiple = '';
59
+ if($field['multiple'] == '1')
 
 
 
 
 
60
  {
61
+ $multiple = ' multiple="multiple" size="5" ';
62
+ $field['name'] .= '[]';
63
+ }
 
 
 
 
 
64
 
65
+ // html
66
+ echo '<select id="' . $field['name'] . '" class="' . $field['class'] . '" name="' . $field['name'] . '" ' . $multiple . ' >';
67
 
68
+ // null
69
+ if($field['allow_null'] == '1')
70
+ {
71
+ echo '<option value="null"> - Select - </option>';
72
+ }
73
 
74
+ foreach($field['post_type'] as $post_type)
75
  {
76
  // get posts
77
  $posts = false;
84
  'post_type' => $post_type,
85
  'sort_column' => 'menu_order',
86
  'order' => 'ASC',
87
+ //'meta_key' => $field['meta_key'],
88
+ //'meta_value' => $field['meta_value'],
89
  ));
90
  }
91
  else
96
  'post_type' => $post_type,
97
  'orderby' => 'title',
98
  'order' => 'ASC',
99
+ //'meta_key' => $field['meta_key'],
100
+ //'meta_value' => $field['meta_value'],
101
  ));
102
  }
103
 
124
  $selected = '';
125
 
126
 
127
+ if(is_array($field['value']))
128
  {
129
  // 2. If the value is an array (multiple select), loop through values and check if it is selected
130
+ if(in_array($key, $field['value']))
131
  {
132
  $selected = 'selected="selected"';
133
  }
135
  else
136
  {
137
  // 3. this is not a multiple select, just check normaly
138
+ if($key == $field['value'])
139
  {
140
  $selected = 'selected="selected"';
141
  }
159
  }
160
 
161
 
162
+ /*--------------------------------------------------------------------------------------
163
+ *
164
+ * create_options
165
+ *
166
+ * @author Elliot Condon
167
+ * @since 2.0.6
168
+ * @updated 2.2.0
169
+ *
170
+ *-------------------------------------------------------------------------------------*/
171
+
172
+ function create_options($key, $field)
173
+ {
174
+ // defaults
175
+ $field['post_type'] = isset($field['post_type']) ? $field['post_type'] : '';
176
+ $field['multiple'] = isset($field['multiple']) ? $field['multiple'] : '0';
177
+ $field['allow_null'] = isset($field['allow_null']) ? $field['allow_null'] : '0';
178
 
179
  ?>
180
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
 
181
  <td class="label">
182
  <label for=""><?php _e("Post Type",'acf'); ?></label>
183
  <p class="description"><?php _e("Filter posts by selecting a post type<br />
196
  unset($post_types['revision']);
197
  unset($post_types['acf']);
198
 
199
+ $this->parent->create_field(array(
200
+ 'type' => 'select',
201
+ 'name' => 'fields['.$key.'][post_type]',
202
+ 'value' => $field['post_type'],
203
+ 'choices' => $post_types,
204
+ 'multiple' => '1',
205
+ ));
206
  ?>
 
 
 
 
 
 
 
 
 
 
 
207
  </td>
208
  </tr>
209
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
210
  <td class="label">
211
  <label><?php _e("Allow Null?",'acf'); ?></label>
212
  </td>
213
  <td>
214
  <?php
215
+ $this->parent->create_field(array(
216
+ 'type' => 'radio',
217
+ 'name' => 'fields['.$key.'][allow_null]',
218
+ 'value' => $field['allow_null'],
219
+ 'choices' => array(
220
+ '1' => 'Yes',
221
+ '0' => 'No',
222
+ ),
223
+ 'layout' => 'horizontal',
224
+ ));
225
  ?>
226
  </td>
227
  </tr>
228
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
229
  <td class="label">
230
  <label><?php _e("Select multiple values?",'acf'); ?></label>
231
  </td>
232
  <td>
233
  <?php
234
+ $this->parent->create_field(array(
235
+ 'type' => 'radio',
236
+ 'name' => 'fields['.$key.'][multiple]',
237
+ 'value' => $field['multiple'],
238
+ 'choices' => array(
239
+ '1' => 'Yes',
240
+ '0' => 'No',
241
+ ),
242
+ 'layout' => 'horizontal',
243
+ ));
244
  ?>
245
  </td>
246
  </tr>
248
  }
249
 
250
 
251
+ /*--------------------------------------------------------------------------------------
252
+ *
253
+ * get_value_for_api
254
+ *
255
+ * @author Elliot Condon
256
+ * @since 3.0.0
257
+ *
258
+ *-------------------------------------------------------------------------------------*/
259
 
260
+ function get_value_for_api($post_id, $field)
 
 
 
 
 
 
 
 
261
  {
262
+ // get value
263
+ $value = parent::get_value($post_id, $field);
264
+
265
+ if(!$value)
266
+ {
267
+ return false;
268
+ }
269
 
270
  if($value == 'null')
271
  {
287
  return $value;
288
  }
289
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
290
 
291
 
292
  }
core/fields/post_object.php CHANGED
@@ -1,72 +1,85 @@
1
  <?php
2
 
3
- class acf_Post_object
4
  {
5
- var $name;
6
- var $title;
7
- var $parent;
8
 
9
- function acf_Post_object($parent)
 
 
 
 
 
 
 
 
 
 
10
  {
11
- $this->name = 'post_object';
 
 
12
  $this->title = __("Post Object",'acf');
13
- $this->parent = $parent;
14
- }
 
 
 
 
 
 
 
 
 
 
 
15
 
16
- function html($field)
17
  {
18
- // options
19
- $options = $field->options;
20
- $options['meta_key'] = isset($options['meta_key']) ? $options['meta_key'] : '';
21
- $options['meta_value'] = isset($options['meta_value']) ? $options['meta_value'] : '';
 
 
22
 
23
- // get post types
24
- $post_types = isset($options['post_type']) ? $options['post_type'] : false;
25
- if(!$post_types || $post_types[0] == "")
26
  {
27
- $post_types = get_post_types(array('public' => true));
28
- foreach($post_types as $key => $value)
29
- {
30
- if($value == 'attachment')
31
- {
32
- unset($post_types[$key]);
33
- }
34
- }
35
  }
36
 
37
- // start select
38
- if(isset($field->options['multiple']) && $field->options['multiple'] == '1')
 
39
  {
40
- $name_extra = '[]';
41
- echo '<select id="'.$field->input_name.'" class="'.$field->input_class.'" name="'.$field->input_name.$name_extra.'" multiple="multiple" size="5" >';
42
- }
43
- else
 
 
 
 
 
44
  {
45
- echo '<select id="'.$field->input_name.'" class="'.$field->input_class.'" name="'.$field->input_name.'" >';
46
-
47
- // add null
48
- if(isset($field->options['allow_null']) && $field->options['allow_null'] == '1')
49
- {
50
- echo '<option value="null"> - Select - </option>';
51
- }
52
  }
53
 
54
- // loop through post types
55
- foreach($post_types as $post_type)
56
  {
57
  // get posts
58
  $posts = false;
59
 
60
  if(is_post_type_hierarchical($post_type))
61
- {
62
  // get pages
63
  $posts = get_pages(array(
64
  'numberposts' => -1,
65
  'post_type' => $post_type,
66
  'sort_column' => 'menu_order',
67
  'order' => 'ASC',
68
- 'meta_key' => $options['meta_key'],
69
- 'meta_value' => $options['meta_value'],
70
  ));
71
  }
72
  else
@@ -77,12 +90,11 @@ class acf_Post_object
77
  'post_type' => $post_type,
78
  'orderby' => 'title',
79
  'order' => 'ASC',
80
- 'meta_key' => $options['meta_key'],
81
- 'meta_value' => $options['meta_value'],
82
  ));
83
- }
84
-
85
-
86
  // if posts, make a group for them
87
  if($posts)
88
  {
@@ -102,14 +114,13 @@ class acf_Post_object
102
  }
103
  }
104
  $value .= get_the_title($post->ID);
105
-
106
  $selected = '';
107
 
108
 
109
- if(is_array($field->value))
110
  {
111
  // 2. If the value is an array (multiple select), loop through values and check if it is selected
112
- if(in_array($key, $field->value))
113
  {
114
  $selected = 'selected="selected"';
115
  }
@@ -117,7 +128,7 @@ class acf_Post_object
117
  else
118
  {
119
  // 3. this is not a multiple select, just check normaly
120
- if($key == $field->value)
121
  {
122
  $selected = 'selected="selected"';
123
  }
@@ -132,6 +143,7 @@ class acf_Post_object
132
  echo '</optgroup>';
133
 
134
  }// endif
 
135
  }// endforeach
136
 
137
 
@@ -139,28 +151,26 @@ class acf_Post_object
139
  }
140
 
141
 
142
- /*---------------------------------------------------------------------------------------------
143
- * Options HTML
144
- * - called from fields_meta_box.php
145
- * - displays options in html format
146
- *
147
- * @author Elliot Condon
148
- * @since 1.1
149
- *
150
- ---------------------------------------------------------------------------------------------*/
151
- function options_html($key, $field)
152
- {
153
- $options = $field->options;
154
-
155
- $options['post_type'] = isset($options['post_type']) ? $options['post_type'] : '';
156
- $options['multiple'] = isset($options['multiple']) ? $options['multiple'] : '0';
157
- $options['allow_null'] = isset($options['allow_null']) ? $options['allow_null'] : '0';
158
- $options['meta_key'] = isset($options['meta_key']) ? $options['meta_key'] : '';
159
- $options['meta_value'] = isset($options['meta_value']) ? $options['meta_value'] : '';
160
-
161
  ?>
162
-
163
- <tr class="field_option field_option_post_object">
164
  <td class="label">
165
  <label for=""><?php _e("Post Type",'acf'); ?></label>
166
  <p class="description"><?php _e("Filter posts by selecting a post type<br />
@@ -170,29 +180,21 @@ class acf_Post_object
170
  <?php
171
  $post_types = array('' => '-All-');
172
 
173
- foreach (get_post_types() as $post_type ) {
174
  $post_types[$post_type] = $post_type;
175
  }
176
 
177
- unset($post_types['attachment']);
178
- unset($post_types['nav_menu_item']);
179
- unset($post_types['revision']);
180
- unset($post_types['acf']);
181
-
182
-
183
- $temp_field = new stdClass();
184
- $temp_field->type = 'select';
185
- $temp_field->input_name = 'acf[fields]['.$key.'][options][post_type]';
186
- $temp_field->input_class = '';
187
- $temp_field->value = $options['post_type'];
188
- $temp_field->options = array('choices' => $post_types, 'multiple' => '1');
189
- $this->parent->create_field($temp_field);
190
-
191
  ?>
192
-
193
  </td>
194
  </tr>
195
- <tr class="field_option field_option_post_object">
196
  <td class="label">
197
  <label><?php _e("Filter Posts",'acf'); ?></label>
198
  <p class="description"><?php _e("Where meta_key == meta_value",'acf'); ?></p>
@@ -200,81 +202,87 @@ class acf_Post_object
200
  <td>
201
  <div style="width:45%; float:left">
202
  <?php
203
- $temp_field->type = 'text';
204
- $temp_field->input_name = 'acf[fields]['.$key.'][options][meta_key]';
205
- $temp_field->input_class = '';
206
- $temp_field->value = $options['meta_key'];
207
- $this->parent->create_field($temp_field);
208
  ?>
209
  </div>
210
  <div style="width:10%; float:left; text-align:center; padding:5px 0 0;">is equal to</div>
211
  <div style="width:45%; float:left">
212
  <?php
213
- $temp_field->type = 'text';
214
- $temp_field->input_name = 'acf[fields]['.$key.'][options][meta_value]';
215
- $temp_field->input_class = '';
216
- $temp_field->value = $options['meta_value'];
217
- $this->parent->create_field($temp_field);
218
  ?>
219
  </div>
220
  </td>
221
- </tr>
222
- <tr class="field_option field_option_post_object">
223
  <td class="label">
224
  <label><?php _e("Allow Null?",'acf'); ?></label>
225
  </td>
226
  <td>
227
  <?php
228
- $temp_field = new stdClass();
229
- $temp_field->type = 'true_false';
230
- $temp_field->input_name = 'acf[fields]['.$key.'][options][allow_null]';
231
- $temp_field->input_class = '';
232
- $temp_field->value = $options['allow_null'];
233
- $temp_field->options = array('message' => 'Add null value above choices');
234
- $this->parent->create_field($temp_field);
 
 
 
235
  ?>
236
  </td>
237
  </tr>
238
- <tr class="field_option field_option_post_object">
239
  <td class="label">
240
  <label><?php _e("Select multiple values?",'acf'); ?></label>
241
  </td>
242
  <td>
243
  <?php
244
- $temp_field->type = 'true_false';
245
- $temp_field->input_name = 'acf[fields]['.$key.'][options][multiple]';
246
- $temp_field->input_class = '';
247
- $temp_field->value = $options['multiple'];
248
- $temp_field->options = array('message' => 'Turn this drop-down into a multi-select');
249
- $this->parent->create_field($temp_field);
 
 
 
 
250
  ?>
251
  </td>
252
  </tr>
253
-
254
  <?php
255
  }
256
 
257
 
 
 
 
 
 
 
 
 
258
 
259
-
260
- /*---------------------------------------------------------------------------------------------
261
- * Format Value
262
- * - this is called from api.php
263
- *
264
- * @author Elliot Condon
265
- * @since 1.1
266
- *
267
- ---------------------------------------------------------------------------------------------*/
268
- function format_value_for_api($value, $options = null)
269
  {
270
- $value = $this->format_value_for_input($value);
 
271
 
272
- if($value == 'null')
273
  {
274
  return false;
275
  }
276
 
277
- if(!$value)
278
  {
279
  return false;
280
  }
@@ -293,31 +301,7 @@ class acf_Post_object
293
 
294
  return $value;
295
  }
296
-
297
-
298
- /*---------------------------------------------------------------------------------------------
299
- * Format Value for input
300
- * - this is called from api.php
301
- *
302
- * @author Elliot Condon
303
- * @since 1.1
304
- *
305
- ---------------------------------------------------------------------------------------------*/
306
- function format_value_for_input($value)
307
- {
308
- $is_array = @unserialize($value);
309
 
310
- if($is_array)
311
- {
312
- return unserialize($value);
313
- }
314
- else
315
- {
316
- return $value;
317
- }
318
-
319
- }
320
-
321
  }
322
 
323
  ?>
1
  <?php
2
 
3
+ class acf_Post_object extends acf_Field
4
  {
 
 
 
5
 
6
+ /*--------------------------------------------------------------------------------------
7
+ *
8
+ * Constructor
9
+ *
10
+ * @author Elliot Condon
11
+ * @since 1.0.0
12
+ * @updated 2.2.0
13
+ *
14
+ *-------------------------------------------------------------------------------------*/
15
+
16
+ function __construct($parent)
17
  {
18
+ parent::__construct($parent);
19
+
20
+ $this->name = 'post_object';
21
  $this->title = __("Post Object",'acf');
22
+
23
+ }
24
+
25
+
26
+ /*--------------------------------------------------------------------------------------
27
+ *
28
+ * create_field
29
+ *
30
+ * @author Elliot Condon
31
+ * @since 2.0.5
32
+ * @updated 2.2.0
33
+ *
34
+ *-------------------------------------------------------------------------------------*/
35
 
36
+ function create_field($field)
37
  {
38
+ // vars
39
+ $field['multiple'] = isset($field['multiple']) ? $field['multiple'] : false;
40
+ $field['post_type'] = isset($field['post_type']) ? $field['post_type'] : false;
41
+ //$field['meta_key'] = isset($field['meta_key']) ? $field['meta_key'] : false;
42
+ //$field['meta_value'] = isset($field['meta_value']) ? $field['meta_value'] : false;
43
+
44
 
45
+ if(!$field['post_type'] || !is_array($field['post_type']) || $field['post_type'][0] == "")
 
 
46
  {
47
+ $field['post_type'] = get_post_types(array('public' => true));
 
 
 
 
 
 
 
48
  }
49
 
50
+ // multiple select
51
+ $multiple = '';
52
+ if($field['multiple'] == '1')
53
  {
54
+ $multiple = ' multiple="multiple" size="5" ';
55
+ $field['name'] .= '[]';
56
+ }
57
+
58
+ // html
59
+ echo '<select id="' . $field['name'] . '" class="' . $field['class'] . '" name="' . $field['name'] . '" ' . $multiple . ' >';
60
+
61
+ // null
62
+ if($field['allow_null'] == '1')
63
  {
64
+ echo '<option value="null"> - Select - </option>';
 
 
 
 
 
 
65
  }
66
 
67
+
68
+ foreach($field['post_type'] as $post_type)
69
  {
70
  // get posts
71
  $posts = false;
72
 
73
  if(is_post_type_hierarchical($post_type))
74
+ {
75
  // get pages
76
  $posts = get_pages(array(
77
  'numberposts' => -1,
78
  'post_type' => $post_type,
79
  'sort_column' => 'menu_order',
80
  'order' => 'ASC',
81
+ //'meta_key' => $field['meta_key'],
82
+ //'meta_value' => $field['meta_value'],
83
  ));
84
  }
85
  else
90
  'post_type' => $post_type,
91
  'orderby' => 'title',
92
  'order' => 'ASC',
93
+ //'meta_key' => $field['meta_key'],
94
+ //'meta_value' => $field['meta_value'],
95
  ));
96
+ }
97
+
 
98
  // if posts, make a group for them
99
  if($posts)
100
  {
114
  }
115
  }
116
  $value .= get_the_title($post->ID);
 
117
  $selected = '';
118
 
119
 
120
+ if(is_array($field['value']))
121
  {
122
  // 2. If the value is an array (multiple select), loop through values and check if it is selected
123
+ if(in_array($key, $field['value']))
124
  {
125
  $selected = 'selected="selected"';
126
  }
128
  else
129
  {
130
  // 3. this is not a multiple select, just check normaly
131
+ if($key == $field['value'])
132
  {
133
  $selected = 'selected="selected"';
134
  }
143
  echo '</optgroup>';
144
 
145
  }// endif
146
+
147
  }// endforeach
148
 
149
 
151
  }
152
 
153
 
154
+ /*--------------------------------------------------------------------------------------
155
+ *
156
+ * create_options
157
+ *
158
+ * @author Elliot Condon
159
+ * @since 2.0.6
160
+ * @updated 2.2.0
161
+ *
162
+ *-------------------------------------------------------------------------------------*/
163
+
164
+ function create_options($key, $field)
165
+ {
166
+ // defaults
167
+ $field['post_type'] = isset($field['post_type']) ? $field['post_type'] : '';
168
+ $field['multiple'] = isset($field['multiple']) ? $field['multiple'] : '0';
169
+ $field['allow_null'] = isset($field['allow_null']) ? $field['allow_null'] : '0';
170
+ //$field['meta_key'] = isset($field['meta_key']) ? $field['meta_key'] : '';
171
+ //$field['meta_value'] = isset($field['meta_value']) ? $field['meta_value'] : '';
 
172
  ?>
173
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
 
174
  <td class="label">
175
  <label for=""><?php _e("Post Type",'acf'); ?></label>
176
  <p class="description"><?php _e("Filter posts by selecting a post type<br />
180
  <?php
181
  $post_types = array('' => '-All-');
182
 
183
+ foreach (get_post_types(array('public' => true)) as $post_type ) {
184
  $post_types[$post_type] = $post_type;
185
  }
186
 
187
+ $this->parent->create_field(array(
188
+ 'type' => 'select',
189
+ 'name' => 'fields['.$key.'][post_type]',
190
+ 'value' => $field['post_type'],
191
+ 'choices' => $post_types,
192
+ 'multiple' => '1',
193
+ ));
 
 
 
 
 
 
 
194
  ?>
 
195
  </td>
196
  </tr>
197
+ <?php /*<tr class="field_option field_option_<?php echo $this->name; ?>">
198
  <td class="label">
199
  <label><?php _e("Filter Posts",'acf'); ?></label>
200
  <p class="description"><?php _e("Where meta_key == meta_value",'acf'); ?></p>
202
  <td>
203
  <div style="width:45%; float:left">
204
  <?php
205
+ $this->parent->create_field(array(
206
+ 'type' => 'text',
207
+ 'name' => 'fields['.$key.'][meta_key]',
208
+ 'value' => $field['meta_key'],
209
+ ));
210
  ?>
211
  </div>
212
  <div style="width:10%; float:left; text-align:center; padding:5px 0 0;">is equal to</div>
213
  <div style="width:45%; float:left">
214
  <?php
215
+ $this->parent->create_field(array(
216
+ 'type' => 'text',
217
+ 'name' => 'fields['.$key.'][meta_value]',
218
+ 'value' => $field['meta_value'],
219
+ ));
220
  ?>
221
  </div>
222
  </td>
223
+ </tr>*/ ?>
224
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
225
  <td class="label">
226
  <label><?php _e("Allow Null?",'acf'); ?></label>
227
  </td>
228
  <td>
229
  <?php
230
+ $this->parent->create_field(array(
231
+ 'type' => 'radio',
232
+ 'name' => 'fields['.$key.'][allow_null]',
233
+ 'value' => $field['allow_null'],
234
+ 'choices' => array(
235
+ '1' => 'Yes',
236
+ '0' => 'No',
237
+ ),
238
+ 'layout' => 'horizontal',
239
+ ));
240
  ?>
241
  </td>
242
  </tr>
243
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
244
  <td class="label">
245
  <label><?php _e("Select multiple values?",'acf'); ?></label>
246
  </td>
247
  <td>
248
  <?php
249
+ $this->parent->create_field(array(
250
+ 'type' => 'radio',
251
+ 'name' => 'fields['.$key.'][multiple]',
252
+ 'value' => $field['multiple'],
253
+ 'choices' => array(
254
+ '1' => 'Yes',
255
+ '0' => 'No',
256
+ ),
257
+ 'layout' => 'horizontal',
258
+ ));
259
  ?>
260
  </td>
261
  </tr>
 
262
  <?php
263
  }
264
 
265
 
266
+ /*--------------------------------------------------------------------------------------
267
+ *
268
+ * get_value_for_api
269
+ *
270
+ * @author Elliot Condon
271
+ * @since 3.0.0
272
+ *
273
+ *-------------------------------------------------------------------------------------*/
274
 
275
+ function get_value_for_api($post_id, $field)
 
 
 
 
 
 
 
 
 
276
  {
277
+ // get value
278
+ $value = parent::get_value($post_id, $field);
279
 
280
+ if(!$value)
281
  {
282
  return false;
283
  }
284
 
285
+ if($value == 'null')
286
  {
287
  return false;
288
  }
301
 
302
  return $value;
303
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
304
 
 
 
 
 
 
 
 
 
 
 
 
305
  }
306
 
307
  ?>
core/fields/radio.php CHANGED
@@ -1,56 +1,63 @@
1
  <?php
2
 
3
- class acf_Radio
4
  {
5
- var $name;
6
- var $title;
7
 
8
- function acf_Radio()
 
 
 
 
 
 
 
 
 
 
9
  {
10
- $this->name = 'radio';
 
 
11
  $this->title = __('Radio Button','acf');
12
- }
13
-
14
-
 
15
  /*--------------------------------------------------------------------------------------
16
  *
17
- * HTML
18
  *
19
  * @author Elliot Condon
20
- * @since 2.0.6
 
21
  *
22
  *-------------------------------------------------------------------------------------*/
23
 
24
- function html($field)
25
  {
26
- if(empty($field->value))
27
- {
28
- $field->value = array();
29
- }
30
 
31
- if(empty($field->options['choices']))
 
32
  {
33
-
34
  echo '<p>' . __("No choices to choose from",'acf') . '</p>';
35
-
36
  return false;
37
  }
38
-
39
- $layout = isset($field->options['layout']) ? $field->options['layout'] : 'vertical';
40
-
41
-
42
- echo '<ul class="radio_list ' .$field->input_class . ' ' . $layout . '">';
43
 
44
- foreach($field->options['choices'] as $key => $value)
45
  {
46
  $selected = '';
47
 
48
- if($key == $field->value)
49
  {
50
- $selected = 'checked="checked"';
51
  }
52
 
53
- echo '<li><label><input type="radio" class="'.$field->input_class.'" name="'.$field->input_name.'" value="'.$key.'" '.$selected.' />'.$value.'</label></li>';
54
  }
55
 
56
  echo '</ul>';
@@ -60,38 +67,37 @@ class acf_Radio
60
 
61
  /*--------------------------------------------------------------------------------------
62
  *
63
- * Options HTML
64
  *
65
  * @author Elliot Condon
66
  * @since 2.0.6
 
67
  *
68
  *-------------------------------------------------------------------------------------*/
69
 
70
- function options_html($key, $field)
71
- {
72
- $options = $field->options;
73
-
74
- // layout
75
- $options['layout'] = isset($options['layout']) ? $options['layout'] : 'vertical';
76
 
77
  // implode checkboxes so they work in a textarea
78
- if(isset($options['choices']) && is_array($options['choices']))
79
  {
80
- foreach($options['choices'] as $choice_key => $choice_val)
81
  {
82
- $options['choices'][$choice_key] = $choice_key.' : '.$choice_val;
83
  }
84
- $options['choices'] = implode("\n", $options['choices']);
85
  }
86
  else
87
  {
88
- $options['choices'] = "";
89
  }
90
 
91
  ?>
92
 
93
 
94
- <tr class="field_option field_option_radio">
95
  <td class="label">
96
  <label for=""><?php _e("Choices",'acf'); ?></label>
97
  <p class="description"><?php _e("Enter your choices one per line<br />
@@ -105,22 +111,25 @@ class acf_Radio
105
  blue : Blue",'acf'); ?></p>
106
  </td>
107
  <td>
108
- <textarea rows="5" name="acf[fields][<?php echo $key; ?>][options][choices]" id=""><?php echo $options['choices']; ?></textarea>
109
  </td>
110
  </tr>
111
- <tr class="field_option field_option_radio">
112
  <td class="label">
113
  <label for=""><?php _e("Layout",'acf'); ?></label>
114
  </td>
115
  <td>
116
  <?php
117
- $temp_field = new stdClass();
118
- $temp_field->type = 'radio';
119
- $temp_field->input_name = 'acf[fields]['.$key.'][options][layout]';
120
- $temp_field->input_class = '';
121
- $temp_field->value = $options['layout'];
122
- $temp_field->options = array('layout' => 'horizontal', 'choices' => array('vertical' => 'Vertical', 'horizontal' => 'Horizontal'));
123
- $this->html($temp_field);
 
 
 
124
  ?>
125
  </td>
126
  </tr>
@@ -132,43 +141,39 @@ class acf_Radio
132
 
133
  /*--------------------------------------------------------------------------------------
134
  *
135
- * Format Options
136
- * - this is called from save_field.php, this function formats the options into a savable format
137
  *
138
  * @author Elliot Condon
139
- * @since 2.0.6
140
  *
141
  *-------------------------------------------------------------------------------------*/
142
-
143
- function format_options($options)
144
- {
145
- // if no choices, dont do anything
146
- if(!$options['choices'] || is_array($options['choices']))
147
- {
148
- return $options;
149
- }
150
 
 
 
151
 
152
  // explode choices from each line
153
- if(strpos($options['choices'], "\n") !== false)
154
  {
155
  // found multiple lines, explode it
156
- $choices = explode("\n", $options['choices']);
157
  }
158
  else
159
  {
160
  // no multiple lines!
161
- $choices = array($options['choices']);
162
  }
163
 
164
-
165
-
166
- $new_choices = array();
167
- foreach($choices as $choice)
168
  {
169
  if(strpos($choice, ' : ') !== false)
170
  {
171
-
172
  $choice = explode(' : ', $choice);
173
  $new_choices[trim($choice[0])] = trim($choice[1]);
174
  }
@@ -178,60 +183,13 @@ class acf_Radio
178
  }
179
  }
180
 
 
 
181
 
182
- // return array containing all choices
183
- $options['choices'] = $new_choices;
184
-
185
- return $options;
186
- }
187
-
188
-
189
- /*--------------------------------------------------------------------------------------
190
- *
191
- * Format Value
192
- * - this is called from api.php
193
- *
194
- * @author Elliot Condon
195
- * @since 2.0.6
196
- *
197
- *-------------------------------------------------------------------------------------*/
198
-
199
- function format_value_for_api($value, $options = null)
200
- {
201
- if(!$value)
202
- {
203
- return false;
204
- }
205
-
206
- $is_array = @unserialize($value);
207
-
208
- if($is_array)
209
- {
210
- return unserialize($value);
211
- }
212
- else
213
- {
214
- return $value;
215
- }
216
-
217
 
218
  }
219
-
220
-
221
- /*--------------------------------------------------------------------------------------
222
- *
223
- * Format Value for input
224
- * - this is called from acf.php
225
- *
226
- * @author Elliot Condon
227
- * @since 2.0.6
228
- *
229
- *-------------------------------------------------------------------------------------*/
230
-
231
- function format_value_for_input($value)
232
- {
233
- return $this->format_value_for_api($value);
234
- }
235
  }
236
 
237
  ?>
1
  <?php
2
 
3
+ class acf_Radio extends acf_Field
4
  {
 
 
5
 
6
+ /*--------------------------------------------------------------------------------------
7
+ *
8
+ * Constructor
9
+ *
10
+ * @author Elliot Condon
11
+ * @since 1.0.0
12
+ * @updated 2.2.0
13
+ *
14
+ *-------------------------------------------------------------------------------------*/
15
+
16
+ function __construct($parent)
17
  {
18
+ parent::__construct($parent);
19
+
20
+ $this->name = 'radio';
21
  $this->title = __('Radio Button','acf');
22
+
23
+ }
24
+
25
+
26
  /*--------------------------------------------------------------------------------------
27
  *
28
+ * create_field
29
  *
30
  * @author Elliot Condon
31
+ * @since 2.0.5
32
+ * @updated 2.2.0
33
  *
34
  *-------------------------------------------------------------------------------------*/
35
 
36
+ function create_field($field)
37
  {
38
+ // defaults
39
+ $field['layout'] = isset($field['layout']) ? $field['layout'] : 'vertical';
40
+ $field['choices'] = isset($field['choices']) ? $field['choices'] : array();
 
41
 
42
+ // no choices
43
+ if(empty($field['choices']))
44
  {
 
45
  echo '<p>' . __("No choices to choose from",'acf') . '</p>';
 
46
  return false;
47
  }
48
+
49
+ echo '<ul class="radio_list ' . $field['class'] . ' ' . $field['layout'] . '">';
 
 
 
50
 
51
+ foreach($field['choices'] as $key => $value)
52
  {
53
  $selected = '';
54
 
55
+ if($key == $field['value'])
56
  {
57
+ $selected = 'checked="checked" data-checked="checked"';
58
  }
59
 
60
+ echo '<li><label><input type="radio" name="' . $field['name'] . '" value="' . $key . '" ' . $selected . ' />' . $value . '</label></li>';
61
  }
62
 
63
  echo '</ul>';
67
 
68
  /*--------------------------------------------------------------------------------------
69
  *
70
+ * create_options
71
  *
72
  * @author Elliot Condon
73
  * @since 2.0.6
74
+ * @updated 2.2.0
75
  *
76
  *-------------------------------------------------------------------------------------*/
77
 
78
+ function create_options($key, $field)
79
+ {
80
+ // defaults
81
+ $field['layout'] = isset($field['layout']) ? $field['layout'] : 'vertical';
 
 
82
 
83
  // implode checkboxes so they work in a textarea
84
+ if(isset($field['choices']) && is_array($field['choices']))
85
  {
86
+ foreach($field['choices'] as $choice_key => $choice_val)
87
  {
88
+ $field['choices'][$choice_key] = $choice_key.' : '.$choice_val;
89
  }
90
+ $field['choices'] = implode("\n", $field['choices']);
91
  }
92
  else
93
  {
94
+ $field['choices'] = "";
95
  }
96
 
97
  ?>
98
 
99
 
100
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
101
  <td class="label">
102
  <label for=""><?php _e("Choices",'acf'); ?></label>
103
  <p class="description"><?php _e("Enter your choices one per line<br />
111
  blue : Blue",'acf'); ?></p>
112
  </td>
113
  <td>
114
+ <textarea rows="5" name="fields[<?php echo $key; ?>][choices]" id=""><?php echo $field['choices']; ?></textarea>
115
  </td>
116
  </tr>
117
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
118
  <td class="label">
119
  <label for=""><?php _e("Layout",'acf'); ?></label>
120
  </td>
121
  <td>
122
  <?php
123
+ $this->parent->create_field(array(
124
+ 'type' => 'radio',
125
+ 'name' => 'fields['.$key.'][layout]',
126
+ 'value' => $field['layout'],
127
+ 'layout' => 'horizontal',
128
+ 'choices' => array(
129
+ 'vertical' => 'Vertical',
130
+ 'horizontal' => 'Horizontal'
131
+ )
132
+ ));
133
  ?>
134
  </td>
135
  </tr>
141
 
142
  /*--------------------------------------------------------------------------------------
143
  *
144
+ * pre_save_field
145
+ * - called just before saving the field to the database.
146
  *
147
  * @author Elliot Condon
148
+ * @since 2.2.0
149
  *
150
  *-------------------------------------------------------------------------------------*/
151
+
152
+ function pre_save_field($field)
153
+ {
154
+ // defaults
155
+ $field['choices'] = isset($field['choices']) ? $field['choices'] : '';
 
 
 
156
 
157
+ // vars
158
+ $new_choices = array();
159
 
160
  // explode choices from each line
161
+ if(strpos($field['choices'], "\n") !== false)
162
  {
163
  // found multiple lines, explode it
164
+ $field['choices'] = explode("\n", $field['choices']);
165
  }
166
  else
167
  {
168
  // no multiple lines!
169
+ $field['choices'] = array($field['choices']);
170
  }
171
 
172
+ // key => value
173
+ foreach($field['choices'] as $choice)
 
 
174
  {
175
  if(strpos($choice, ' : ') !== false)
176
  {
 
177
  $choice = explode(' : ', $choice);
178
  $new_choices[trim($choice[0])] = trim($choice[1]);
179
  }
183
  }
184
  }
185
 
186
+ // update choices
187
+ $field['choices'] = $new_choices;
188
 
189
+ // return updated field
190
+ return $field;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
 
192
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
  }
194
 
195
  ?>
core/fields/relationship.php CHANGED
@@ -1,71 +1,317 @@
1
  <?php
2
 
3
- class acf_Relationship
4
  {
5
- var $name;
6
- var $title;
7
- var $parent;
8
 
9
- function acf_Relationship($parent)
 
 
 
 
 
 
 
 
 
 
10
  {
11
- $this->name = 'relationship';
 
 
12
  $this->title = __("Relationship",'acf');
13
- $this->parent = $parent;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  }
 
 
 
 
 
 
 
 
 
 
15
 
16
- function html($field)
17
  {
18
- $options = $field->options;
19
- //$options['min'] = isset($options['min']) ? $options['min'] : '0';
20
- $options['max'] = isset($options['max']) ? $options['max'] : '-1';
21
- $options['meta_key'] = isset($options['meta_key']) ? $options['meta_key'] : '';
22
- $options['meta_value'] = isset($options['meta_value']) ? $options['meta_value'] : '';
23
 
24
- // get post types
25
- $post_types = isset($options['post_type']) ? $options['post_type'] : false;
26
- if(!$post_types || $post_types[0] == "")
27
- {
 
 
 
28
 
29
- $post_types = get_post_types(array('public' => true));
30
- foreach($post_types as $key => $value)
31
  {
32
- if($value == 'attachment')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  {
34
- unset($post_types[$key]);
 
35
  }
36
- }
37
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
 
 
 
 
39
 
40
- // get posts for list
 
 
 
 
 
41
  $posts = get_posts(array(
42
  'numberposts' => -1,
43
- 'post_type' => $post_types,
44
  'orderby' => 'title',
45
  'order' => 'ASC',
46
- 'meta_key' => $options['meta_key'],
47
- 'meta_value' => $options['meta_value'],
48
  ));
49
 
50
-
51
  $values_array = array();
52
- if($field->value != "")
53
  {
54
- $values_array = explode(',', $field->value);
 
 
 
 
 
 
 
 
55
  }
56
 
 
 
57
  ?>
58
- <div class="acf_relationship" data-max="<?php echo $options['max']; ?>">
59
 
60
- <input type="hidden" name="<?php echo $field->input_name; ?>" value="<?php echo $field->value; ?>" />
61
 
62
  <div class="relationship_left">
63
  <table class="widefat">
64
  <thead>
65
  <tr>
66
  <th>
67
- <label class="relationship_label" for="relationship_<?php echo $field->input_name; ?>">Search...</label>
68
- <input class="relationship_search" type="text" id="relationship_<?php echo $field->input_name; ?>" />
69
  <div class="clear_relationship_search"></div>
70
  </th>
71
  </tr>
@@ -126,58 +372,49 @@ class acf_Relationship
126
  }
127
 
128
 
129
- /*---------------------------------------------------------------------------------------------
130
- * Options HTML
131
- * - called from fields_meta_box.php
132
- * - displays options in html format
133
- *
134
- * @author Elliot Condon
135
- * @since 1.1
136
- *
137
- ---------------------------------------------------------------------------------------------*/
138
- function options_html($key, $field)
139
- {
140
- $options = $field->options;
141
-
142
- $options['post_type'] = isset($options['post_type']) ? $options['post_type'] : '';
143
- $options['max'] = isset($options['max']) ? $options['max'] : '-1';
144
- $options['meta_key'] = isset($options['meta_key']) ? $options['meta_key'] : '';
145
- $options['meta_value'] = isset($options['meta_value']) ? $options['meta_value'] : '';
146
-
147
  ?>
148
-
149
- <tr class="field_option field_option_relationship">
150
  <td class="label">
151
  <label for=""><?php _e("Post Type",'acf'); ?></label>
152
- <p class="description"><?php _e("Filter posts by selecting a post type",'acf'); ?></p>
 
153
  </td>
154
  <td>
155
  <?php
156
- $post_types = array('' => '- All -');
157
 
158
- foreach (get_post_types() as $post_type ) {
159
  $post_types[$post_type] = $post_type;
160
  }
161
 
162
- unset($post_types['attachment']);
163
- unset($post_types['nav_menu_item']);
164
- unset($post_types['revision']);
165
- unset($post_types['acf']);
166
-
167
-
168
- $temp_field = new stdClass();
169
- $temp_field->type = 'select';
170
- $temp_field->input_name = 'acf[fields]['.$key.'][options][post_type]';
171
- $temp_field->input_class = '';
172
- $temp_field->value = $options['post_type'];
173
- $temp_field->options = array('choices' => $post_types, 'multiple' => '1');
174
- $this->parent->create_field($temp_field);
175
-
176
  ?>
177
-
178
  </td>
179
  </tr>
180
- <tr class="field_option field_option_relationship">
181
  <td class="label">
182
  <label><?php _e("Filter Posts",'acf'); ?></label>
183
  <p class="description"><?php _e("Where meta_key == meta_value",'acf'); ?></p>
@@ -185,37 +422,37 @@ class acf_Relationship
185
  <td>
186
  <div style="width:45%; float:left">
187
  <?php
188
- $temp_field->type = 'text';
189
- $temp_field->input_name = 'acf[fields]['.$key.'][options][meta_key]';
190
- $temp_field->input_class = '';
191
- $temp_field->value = $options['meta_key'];
192
- $this->parent->create_field($temp_field);
193
  ?>
194
  </div>
195
  <div style="width:10%; float:left; text-align:center; padding:5px 0 0;">is equal to</div>
196
  <div style="width:45%; float:left">
197
  <?php
198
- $temp_field->type = 'text';
199
- $temp_field->input_name = 'acf[fields]['.$key.'][options][meta_value]';
200
- $temp_field->input_class = '';
201
- $temp_field->value = $options['meta_value'];
202
- $this->parent->create_field($temp_field);
203
  ?>
204
  </div>
205
  </td>
206
- </tr>
207
- <tr class="field_option field_option_relationship">
208
  <td class="label">
209
  <label><?php _e("Maximum posts",'acf'); ?></label>
210
  <p class="description"><?php _e("Set to -1 for inifinit",'acf'); ?></p>
211
  </td>
212
  <td>
213
  <?php
214
- $temp_field->type = 'text';
215
- $temp_field->input_name = 'acf[fields]['.$key.'][options][max]';
216
- $temp_field->input_class = '';
217
- $temp_field->value = $options['max'];
218
- $this->parent->create_field($temp_field);
219
  ?>
220
  </td>
221
  </tr>
@@ -225,18 +462,19 @@ class acf_Relationship
225
  }
226
 
227
 
 
 
 
 
 
 
 
 
228
 
229
-
230
- /*---------------------------------------------------------------------------------------------
231
- * Format Value
232
- * - this is called from api.php
233
- *
234
- * @author Elliot Condon
235
- * @since 1.1
236
- *
237
- ---------------------------------------------------------------------------------------------*/
238
- function format_value_for_api($value, $options = null)
239
  {
 
 
240
  $return = false;
241
 
242
  if(!$value || $value == "")
@@ -251,7 +489,7 @@ class acf_Relationship
251
  $return = array();
252
  foreach($value as $v)
253
  {
254
- $return[$v] = get_post($v);
255
  }
256
  }
257
  else
1
  <?php
2
 
3
+ class acf_Relationship extends acf_Field
4
  {
 
 
 
5
 
6
+ /*--------------------------------------------------------------------------------------
7
+ *
8
+ * Constructor
9
+ *
10
+ * @author Elliot Condon
11
+ * @since 1.0.0
12
+ * @updated 2.2.0
13
+ *
14
+ *-------------------------------------------------------------------------------------*/
15
+
16
+ function __construct($parent)
17
  {
18
+ parent::__construct($parent);
19
+
20
+ $this->name = 'relationship';
21
  $this->title = __("Relationship",'acf');
22
+
23
+ }
24
+
25
+
26
+ /*--------------------------------------------------------------------------------------
27
+ *
28
+ * admin_print_scripts / admin_print_styles
29
+ *
30
+ * @author Elliot Condon
31
+ * @since 3.0.0
32
+ *
33
+ *-------------------------------------------------------------------------------------*/
34
+
35
+ function admin_print_scripts()
36
+ {
37
+ wp_enqueue_script(array(
38
+
39
+ 'jquery-ui-sortable',
40
+
41
+ ));
42
+ }
43
+
44
+ function admin_print_styles()
45
+ {
46
+
47
  }
48
+
49
+
50
+ /*--------------------------------------------------------------------------------------
51
+ *
52
+ * admin_head
53
+ *
54
+ * @author Elliot Condon
55
+ * @since 2.0.6
56
+ *
57
+ *-------------------------------------------------------------------------------------*/
58
 
59
+ function admin_head()
60
  {
61
+ ?>
62
+ <script type="text/javascript">
 
 
 
63
 
64
+ (function($){
65
+
66
+ /*----------------------------------------------------------------------
67
+ *
68
+ * update_input_val
69
+ *
70
+ *---------------------------------------------------------------------*/
71
 
72
+ $.fn.update_input_val = function()
 
73
  {
74
+ // vars
75
+ var div = $(this);
76
+ var right = div.find('.relationship_right .relationship_list');
77
+ var value = new Array();
78
+
79
+ // add id's to array
80
+ right.find('a:not(.hide)').each(function(){
81
+ value.push($(this).attr('data-post_id'));
82
+ });
83
+
84
+ // set value
85
+ div.children('input').val(value.join(','));
86
+ };
87
+
88
+
89
+ /*----------------------------------------------------------------------
90
+ *
91
+ * Add
92
+ *
93
+ *---------------------------------------------------------------------*/
94
+
95
+ $('#poststuff .acf_relationship .relationship_left .relationship_list a').live('click', function(){
96
+
97
+ // vars
98
+ var id = $(this).attr('data-post_id');
99
+ var div = $(this).closest('.acf_relationship');
100
+ var max = parseInt(div.attr('data-max')); if(max == -1){ max = 9999; }
101
+ var right = div.find('.relationship_right .relationship_list');
102
+
103
+ // max posts
104
+ if(right.find('a:not(.hide)').length >= max)
105
  {
106
+ alert('Maximum values reached ( ' + max + ' values )');
107
+ return false;
108
  }
109
+
110
+ // hide / show
111
+ $(this).addClass('hide');
112
+ right.find('a[data-post_id="' + id + '"]').removeClass('hide').appendTo(right);
113
+
114
+ // update input value
115
+ div.update_input_val();
116
+
117
+ return false;
118
+
119
+ });
120
+
121
+
122
+ /*----------------------------------------------------------------------
123
+ *
124
+ * Remove
125
+ *
126
+ *---------------------------------------------------------------------*/
127
+
128
+ $('#poststuff .acf_relationship .relationship_right .relationship_list a').live('click', function(){
129
+
130
+ // vars
131
+ var id = $(this).attr('data-post_id');
132
+ var div = $(this).closest('.acf_relationship');
133
+ var left = div.find('.relationship_left .relationship_list');
134
+
135
+ // hide / show
136
+ $(this).addClass('hide');
137
+ left.find('a[data-post_id="' + id + '"]').removeClass('hide');
138
+
139
+ // update input value
140
+ div.update_input_val();
141
+
142
+ return false;
143
+
144
+ });
145
+
146
+
147
+ /*----------------------------------------------------------------------
148
+ *
149
+ * Search Left List
150
+ *
151
+ *---------------------------------------------------------------------*/
152
+
153
+ $.expr[':'].Contains = function(a,i,m){
154
+ return (a.textContent || a.innerText || "").toUpperCase().indexOf(m[3].toUpperCase())>=0;
155
+ };
156
+
157
+ $('#poststuff .acf_relationship input.relationship_search').live('change', function()
158
+ {
159
+ // vars
160
+ var filter = $(this).val();
161
+ var div = $(this).closest('.acf_relationship');
162
+ var left = div.find('.relationship_left .relationship_list');
163
+
164
+ if(filter)
165
+ {
166
+ left.find("a:not(:Contains(" + filter + "))").addClass('filter_hide');
167
+ left.find("a:Contains(" + filter + "):not(.hide)").removeClass('filter_hide');
168
+ }
169
+ else
170
+ {
171
+ left.find("a:not(.hide)").removeClass('filter_hide');
172
+ }
173
+
174
+ return false;
175
+
176
+ })
177
+ .live('keyup', function(){
178
+ $(this).change();
179
+ })
180
+ .live('focus', function(){
181
+ $(this).siblings('label').hide();
182
+ })
183
+ .live('blur', function(){
184
+ if($(this).val() == "")
185
+ {
186
+ $(this).siblings('label').show();
187
+ }
188
+ });
189
+
190
+
191
+ /*----------------------------------------------------------------------
192
+ *
193
+ * setup_acf_relationship
194
+ *
195
+ *---------------------------------------------------------------------*/
196
+
197
+ $.fn.setup_acf_relationship = function(){
198
+
199
+ $(this).find('.acf_relationship').each(function(){
200
+
201
+ // vars
202
+ var div = $(this);
203
+
204
+ // reset search value
205
+ div.find('input.relationship_search').val('');
206
+
207
+ // make right sortable
208
+ div.find('.relationship_right .relationship_list').sortable({
209
+ axis: "y", // limit the dragging to up/down only
210
+ start: function(event, ui)
211
+ {
212
+ ui.item.addClass('sortable_active');
213
+ },
214
+ stop: function(event, ui)
215
+ {
216
+ ui.item.removeClass('sortable_active');
217
+ div.update_input_val();
218
+ }
219
+ });
220
+
221
+ });
222
+
223
+ };
224
+
225
+ $(document).ready(function(){
226
+
227
+ $('#poststuff').setup_acf_relationship();
228
+
229
+ // create wysiwyg when you add a repeater row
230
+ $('.repeater #add_field').live('click', function(){
231
+
232
+ var repeater = $(this).closest('.repeater');
233
+
234
+ // run after the repeater has added the row
235
+ setTimeout(function(){
236
+ repeater.children('table').children('tbody').children('tr:last-child').setup_acf_relationship();
237
+ }, 1);
238
+
239
+ });
240
+
241
+ });
242
+
243
+ })(jQuery);
244
+ </script>
245
+ <?php
246
+ }
247
+
248
+
249
+ /*--------------------------------------------------------------------------------------
250
+ *
251
+ * create_field
252
+ *
253
+ * @author Elliot Condon
254
+ * @since 2.0.5
255
+ * @updated 2.2.0
256
+ *
257
+ *-------------------------------------------------------------------------------------*/
258
+
259
+ function create_field($field)
260
+ {
261
+
262
+ $field['max'] = isset($field['max']) ? $field['max'] : '-1';
263
+ $field['post_type'] = isset($field['post_type']) ? $field['post_type'] : false;
264
+ //$field['meta_key'] = isset($field['meta_key']) ? $field['meta_key'] : false;
265
+ //$field['meta_value'] = isset($field['meta_value']) ? $field['meta_value'] : false;
266
 
267
+ if(!$field['post_type'] || !is_array($field['post_type']) || $field['post_type'][0] == "")
268
+ {
269
+ $field['post_type'] = get_post_types(array('public' => true));
270
+ }
271
 
272
+ // attachment doesn't work if it is the only item in an array???
273
+ if(is_array($field['post_type']) && count($field['post_type']) == 1)
274
+ {
275
+ $field['post_type'] = $field['post_type'][0];
276
+ }
277
+
278
  $posts = get_posts(array(
279
  'numberposts' => -1,
280
+ 'post_type' => $field['post_type'],
281
  'orderby' => 'title',
282
  'order' => 'ASC',
283
+ //'meta_key' => $field['meta_key'],
284
+ //'meta_value' => $field['meta_value'],
285
  ));
286
 
 
287
  $values_array = array();
288
+ if($field['value'] != "")
289
  {
290
+ $temp_array = explode(',', $field['value']);
291
+ foreach($temp_array as $p)
292
+ {
293
+ // if the post doesn't exist, continue
294
+ if(!get_the_title($p)) continue;
295
+
296
+ $values_array[] = $p;
297
+ }
298
+
299
  }
300
 
301
+
302
+
303
  ?>
304
+ <div class="acf_relationship" data-max="<?php echo $field['max']; ?>">
305
 
306
+ <input type="hidden" name="<?php echo $field['name']; ?>" value="<?php echo implode(',', $values_array); ?>" />
307
 
308
  <div class="relationship_left">
309
  <table class="widefat">
310
  <thead>
311
  <tr>
312
  <th>
313
+ <label class="relationship_label" for="relationship_<?php echo $field['name']; ?>">Search...</label>
314
+ <input class="relationship_search" type="text" id="relationship_<?php echo $field['name']; ?>" />
315
  <div class="clear_relationship_search"></div>
316
  </th>
317
  </tr>
372
  }
373
 
374
 
375
+ /*--------------------------------------------------------------------------------------
376
+ *
377
+ * create_options
378
+ *
379
+ * @author Elliot Condon
380
+ * @since 2.0.6
381
+ * @updated 2.2.0
382
+ *
383
+ *-------------------------------------------------------------------------------------*/
384
+
385
+ function create_options($key, $field)
386
+ {
387
+ // defaults
388
+ $field['post_type'] = isset($field['post_type']) ? $field['post_type'] : '';
389
+ $field['max'] = isset($field['max']) ? $field['max'] : '-1';
390
+ //$field['meta_key'] = isset($field['meta_key']) ? $field['meta_key'] : '';
391
+ //$field['meta_value'] = isset($field['meta_value']) ? $field['meta_value'] : '';
 
392
  ?>
393
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
 
394
  <td class="label">
395
  <label for=""><?php _e("Post Type",'acf'); ?></label>
396
+ <p class="description"><?php _e("Filter posts by selecting a post type<br />
397
+ Tip: deselect all post types to show all post type's posts",'acf'); ?></p>
398
  </td>
399
  <td>
400
  <?php
401
+ $post_types = array('' => '-All-');
402
 
403
+ foreach (get_post_types(array('public' => true)) as $post_type ) {
404
  $post_types[$post_type] = $post_type;
405
  }
406
 
407
+ $this->parent->create_field(array(
408
+ 'type' => 'select',
409
+ 'name' => 'fields['.$key.'][post_type]',
410
+ 'value' => $field['post_type'],
411
+ 'choices' => $post_types,
412
+ 'multiple' => '1',
413
+ ));
 
 
 
 
 
 
 
414
  ?>
 
415
  </td>
416
  </tr>
417
+ <?php /*<tr class="field_option field_option_<?php echo $this->name; ?>">
418
  <td class="label">
419
  <label><?php _e("Filter Posts",'acf'); ?></label>
420
  <p class="description"><?php _e("Where meta_key == meta_value",'acf'); ?></p>
422
  <td>
423
  <div style="width:45%; float:left">
424
  <?php
425
+ $this->parent->create_field(array(
426
+ 'type' => 'text',
427
+ 'name' => 'fields['.$key.'][meta_key]',
428
+ 'value' => $field['meta_key'],
429
+ ));
430
  ?>
431
  </div>
432
  <div style="width:10%; float:left; text-align:center; padding:5px 0 0;">is equal to</div>
433
  <div style="width:45%; float:left">
434
  <?php
435
+ $this->parent->create_field(array(
436
+ 'type' => 'text',
437
+ 'name' => 'fields['.$key.'][meta_value]',
438
+ 'value' => $field['meta_value'],
439
+ ));
440
  ?>
441
  </div>
442
  </td>
443
+ </tr>*/ ?>
444
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
445
  <td class="label">
446
  <label><?php _e("Maximum posts",'acf'); ?></label>
447
  <p class="description"><?php _e("Set to -1 for inifinit",'acf'); ?></p>
448
  </td>
449
  <td>
450
  <?php
451
+ $this->parent->create_field(array(
452
+ 'type' => 'text',
453
+ 'name' => 'fields['.$key.'][max]',
454
+ 'value' => $field['max'],
455
+ ));
456
  ?>
457
  </td>
458
  </tr>
462
  }
463
 
464
 
465
+ /*--------------------------------------------------------------------------------------
466
+ *
467
+ * get_value_for_api
468
+ *
469
+ * @author Elliot Condon
470
+ * @since 3.0.0
471
+ *
472
+ *-------------------------------------------------------------------------------------*/
473
 
474
+ function get_value_for_api($post_id, $field)
 
 
 
 
 
 
 
 
 
475
  {
476
+ // vars
477
+ $value = parent::get_value($post_id, $field);
478
  $return = false;
479
 
480
  if(!$value || $value == "")
489
  $return = array();
490
  foreach($value as $v)
491
  {
492
+ $return[] = get_post($v);
493
  }
494
  }
495
  else
core/fields/repeater.php CHANGED
@@ -1,36 +1,270 @@
1
  <?php
2
 
3
- class acf_Repeater
4
  {
5
- var $name;
6
- var $title;
7
- var $parent;
8
 
 
 
 
 
 
 
 
 
 
9
 
10
- function acf_Repeater($parent)
11
  {
12
- $this->name = 'repeater';
 
 
13
  $this->title = __("Repeater",'acf');
14
- $this->parent = $parent;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  }
16
 
 
 
 
 
17
 
18
- function html($field)
 
 
 
 
 
 
 
 
 
 
19
  {
20
- $sub_fields = $field->options['sub_fields'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
- $row_limit = 999;
23
- if(isset($field->options['row_limit']) && $field->options['row_limit'] != "")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  {
25
- $row_limit = intval($field->options['row_limit']);
26
  }
27
 
28
- $layout = 'table';
29
- if(isset($field->options['layout']) && $field->options['layout'] != "")
 
30
  {
31
- $layout = $field->options['layout'];
 
32
  }
33
-
34
  ?>
35
  <div class="repeater" data-row_limit="<?php echo $row_limit; ?>">
36
  <table class="widefat <?php if($layout == 'row'): ?>row_layout<?php endif; ?>">
@@ -42,7 +276,7 @@ class acf_Repeater
42
  <?php endif; ?>
43
 
44
  <?php foreach($sub_fields as $sub_field):?>
45
- <th class="<?php echo $sub_field->name; ?>" style="width:<?php echo 100/count($sub_fields); ?>%;"><span><?php echo $sub_field->label; ?></span></th>
46
  <?php endforeach; ?>
47
 
48
  <?php if($row_limit > 1): ?>
@@ -52,9 +286,9 @@ class acf_Repeater
52
  </thead>
53
  <?php endif; ?>
54
  <tbody>
55
- <?php foreach($field->value as $i => $value):?>
56
- <?php if(($i+1) > $row_limit){continue;} ?>
57
- <tr>
58
 
59
  <?php if($row_limit > 1): ?>
60
  <td class="order">
@@ -70,25 +304,20 @@ class acf_Repeater
70
  <?php if($layout == 'table'): ?>
71
  <td>
72
  <?php else: ?>
73
- <label><?php echo $sub_fields[$j]->label; ?></label>
74
  <?php endif; ?>
75
-
76
- <input type="hidden" name="<?php echo $field->input_name.'['.$i.']['.$j.'][meta_id]'; ?>" value="<?php echo $field->value[$i][$j]->meta_id; ?>" />
77
- <input type="hidden" name="<?php echo $field->input_name.'['.$i.']['.$j.'][value_id]'; ?>" value="<?php echo $field->value[$i][$j]->value_id; ?>" />
78
-
79
- <input type="hidden" name="<?php echo $field->input_name.'['.$i.']['.$j.'][field_id]'; ?>" value="<?php echo $sub_field->id; ?>" />
80
- <input type="hidden" name="<?php echo $field->input_name.'['.$i.']['.$j.'][field_type]' ?>" value="<?php echo $sub_field->type; ?>" />
81
 
82
- <?php
83
- $temp_field = new stdClass();
84
- $temp_field->type = $sub_field->type;
85
- $temp_field->input_name = $field->input_name.'['.$i.']['.$j.'][value]';
86
- $temp_field->input_class = $sub_field->type;
87
- $temp_field->options = $sub_field->options;
88
- $temp_field->value = $field->value[$i][$j]->value;
89
- $this->parent->create_field($temp_field);
90
 
 
 
91
  ?>
 
92
  <?php if($layout == 'table'): ?>
93
  </td>
94
  <?php else: ?>
@@ -117,549 +346,386 @@ class acf_Repeater
117
  }
118
 
119
 
120
- /*---------------------------------------------------------------------------------------------
121
- * Options HTML
122
- * - called from fields_meta_box.php
123
- * - displays options in html format
124
- *
125
- * @author Elliot Condon
126
- * @since 1.1
127
- *
128
- ---------------------------------------------------------------------------------------------*/
129
- function options_html($key, $field)
 
 
130
  {
131
- $options = $field->options;
 
 
 
 
132
 
133
- if(isset($options['sub_fields']))
134
- {
135
- $fields = $options['sub_fields'];
136
- }
137
- else
138
- {
139
- $fields = array();
140
- }
141
-
142
-
143
- // add clone
144
- $field = new stdClass();
145
- $field->label = 'New Field';
146
- $field->name = 'new_field';
147
- $field->type = 'text';
148
- $field->options = array();
149
- $fields[999] = $field;
150
-
151
 
152
  // get name of all fields for use in field type
153
- $fields_names = array();
154
- foreach($this->parent->fields as $field)
155
  {
156
- $fields_names[$field->name] = $field->title;
157
  }
158
  unset($fields_names['repeater']);
159
 
160
  ?>
161
- <tr class="field_option field_option_repeater">
162
- <td class="label">
163
- <label for=""><?php _e("Repeater Fields",'acf'); ?></label>
164
- </td>
165
- <td>
166
- <div class="repeater">
167
- <div class="fields_header">
168
- <table class="acf widefat">
169
- <thead>
170
- <tr>
171
- <th class="field_order"><?php _e('Field Order','acf'); ?></th>
172
- <th class="field_label"><?php _e('Field Label','acf'); ?></th>
173
- <th class="field_name"><?php _e('Field Name','acf'); ?></th>
174
- <th class="field_type"><?php _e('Field Type','acf'); ?></th>
175
- </tr>
176
- </thead>
177
- </table>
178
- </div>
179
- <div class="fields">
180
-
181
- <div class="no_fields_message" <?php if(sizeof($fields) > 1){ echo 'style="display:none;"'; } ?>>
182
- <?php _e("No fields. Click the \"+ Add Field button\" to create your first field.",'acf'); ?>
183
  </div>
 
184
 
185
-
186
- <?php foreach($fields as $key2 => $field): ?>
187
- <div class="<?php if($key2 == 999){echo "field_clone";}else{echo "field";} ?> sub_field">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
 
189
- <input type="hidden" name="acf[fields][<?php echo $key; ?>][sub_fields][<?php echo $key2; ?>][id]'" value="<?php echo $field->id; ?>" />
 
190
 
191
- <div class="field_meta">
192
- <table class="acf widefat">
193
- <tr>
194
- <td class="field_order"><span class="circle"><?php echo ($key2+1); ?></span></td>
195
- <td class="field_label">
196
- <strong>
197
- <a class="acf_edit_field" title="Edit this Field" href="javascript:;"><?php echo $field->label; ?></a>
198
- </strong>
199
- <div class="row_options">
200
- <span><a class="acf_edit_field" title="Edit this Field" href="javascript:;">Edit</a> | </span>
201
- <span><a class="acf_delete_field" title="Delete this Field" href="javascript:;">Delete</a>
202
- </div>
203
- </td>
204
- <td class="field_name"><?php echo $field->name; ?></td>
205
- <td class="field_type"><?php echo $field->type; ?></td>
206
- </tr>
207
- </table>
208
  </div>
209
-
210
- <div class="field_form_mask">
211
- <div class="field_form">
212
-
213
- <table class="acf_input widefat">
214
- <tbody>
215
- <tr class="field_label">
216
- <td class="label">
217
- <label><span class="required">*</span>Field Label</label>
218
- <p class="description">This is the name which will appear on the EDIT page</p>
219
- </td>
220
- <td>
221
- <?php
222
- $temp_field = new stdClass();
223
-
224
- $temp_field->type = 'text';
225
- $temp_field->input_name = 'acf[fields]['.$key.'][sub_fields]['.$key2.'][label]';
226
- $temp_field->input_class = 'label';
227
- $temp_field->value = $field->label;
228
-
229
- $this->parent->create_field($temp_field);
230
-
231
- ?>
232
-
233
- </td>
234
- </tr>
235
- <tr class="field_name">
236
- <td class="label"><label><span class="required">*</span>Field Name</label>
237
- <p class="description">Single word, no spaces. Underscores and dashes allowed</p>
238
- </td>
239
- <td>
240
- <?php
241
-
242
- $temp_field->type = 'text';
243
- $temp_field->input_name = 'acf[fields]['.$key.'][sub_fields]['.$key2.'][name]';
244
- $temp_field->input_class = 'name';
245
- $temp_field->value = $field->name;
246
-
247
- $this->parent->create_field($temp_field);
248
-
249
- ?>
250
-
251
- </td>
252
- </tr>
253
- <tr class="field_type">
254
- <td class="label"><label><span class="required">*</span>Field Type</label></td>
255
- <td>
256
- <?php
257
-
258
- $temp_field->type = 'select';
259
- $temp_field->input_name = 'acf[fields]['.$key.'][sub_fields]['.$key2.'][type]';
260
- $temp_field->input_class = 'type';
261
- $temp_field->value = $field->type;
262
- $temp_field->options = array('choices' => $fields_names);
263
-
264
- $this->parent->create_field($temp_field);
265
-
266
- ?>
267
-
268
- </td>
269
- </tr>
270
- <?php foreach($fields_names as $field_name => $field_title): ?>
271
- <?php if(method_exists($this->parent->fields[$field_name], 'options_html')): ?>
272
-
273
- <?php $this->parent->fields[$field_name]->options_html($key.'][sub_fields]['.$key2, $field); ?>
274
-
275
- <?php endif; ?>
276
- <?php endforeach; ?>
277
- <tr class="field_save">
278
- <td class="label"><label>Save Field</label>
279
- <p class="description">This will save your data and reload the page</p>
280
- </td>
281
- <td><input type="submit" value="Save Field" class="button-primary" name="save" />
282
- or <a class="acf_edit_field" title="Hide this edit screen" href="javascript:;">continue editing ACF</a>
283
- </td>
284
-
285
- </tr>
286
- </tbody>
287
- </table>
288
-
289
- </div><!-- End Form -->
290
- </div><!-- End Form Mask -->
291
-
292
- </div>
293
- <?php endforeach; ?>
294
- </div>
295
- <div class="table_footer">
296
- <!-- <div class="order_message"></div> -->
297
- <a href="javascript:;" id="add_field" class="button-primary">+ Add Field</a>
298
  </div>
299
- </div>
300
- </td>
301
  </tr>
302
- <tr class="field_option field_option_repeater">
 
303
  <td class="label">
304
- <label for="acf[fields][<?php echo $key; ?>][options][row_limit]"><?php _e("Row Limit",'acf'); ?></label>
305
  </td>
306
  <td>
307
- <input type="text" name="acf[fields][<?php echo $key; ?>][options][row_limit]" id="acf[fields][<?php echo $key; ?>][options][row_limit]" value="<?php echo $options['row_limit']; ?>" />
308
-
 
 
 
 
 
309
  </td>
310
  </tr>
311
- <tr class="field_option field_option_repeater">
312
  <td class="label">
313
- <label for="acf[fields][<?php echo $key; ?>][options][layout]"><?php _e("Layout",'acf'); ?></label>
314
  </td>
315
  <td>
316
-
317
  <?php
318
-
319
- $temp_field->type = 'select';
320
- $temp_field->input_name = 'acf[fields]['.$key.'][options][layout]';
321
- $temp_field->input_class = 'type';
322
- $temp_field->value = $options['layout'];
323
- $temp_field->options = array('choices' => array(
324
- 'table' => 'Table (default)',
325
- 'row' => 'Row'
 
326
  ));
327
-
328
- $this->parent->create_field($temp_field);
329
-
330
  ?>
331
-
332
  </td>
333
  </tr>
334
- <?php
335
- }
336
-
337
 
 
 
 
 
 
 
 
 
 
 
338
 
339
- /*---------------------------------------------------------------------------------------------
340
- * Save Field
341
- * - called from fields_save.php
342
- *
343
- * @author Elliot Condon
344
- * @since 1.1.5
345
- *
346
- ---------------------------------------------------------------------------------------------*/
347
- function save_field($post_id, $parent_id, $field)
348
  {
349
- $i = 0;
350
-
351
- // set table name
352
- global $wpdb;
353
- $table_name = $wpdb->prefix.'acf_fields';
354
-
355
-
356
  if($field['sub_fields'])
357
  {
358
- foreach($field['sub_fields'] as $key => $field)
359
- {
360
- if($key == 999)
361
- {
362
- continue;
363
- }
364
-
365
-
366
- // defaults
367
- if(!isset($field['label'])) { $field['label'] = ""; }
368
- if(!isset($field['name'])) { $field['label'] = ""; }
369
- if(!isset($field['type'])) { $field['label'] = "text"; }
370
- if(!isset($field['options'])) { $field['options'] = array(); }
371
- if(!isset($field['instructions'])) { $field['instructions'] = ""; }
372
- if(!isset($field['default_value'])) { $field['default_value'] = ""; }
373
-
374
 
375
- // clean field
376
- $field = stripslashes_deep($field);
377
 
 
378
 
379
- // format options if needed
380
- if(method_exists($this->parent->fields[$field['type']], 'format_options'))
381
  {
382
- $field['options'] = $this->parent->fields[$field['type']]->format_options($field['options']);
383
- }
384
-
385
-
386
- // create data
387
- $data = array(
388
- 'order_no' => $i,
389
- 'post_id' => $post_id,
390
- 'parent_id' => $parent_id,
391
- 'label' => $field['label'],
392
- 'name' => $field['name'],
393
- 'type' => $field['type'],
394
- 'default_value' => $field['default_value'],
395
- 'options' => serialize($field['options']),
396
 
397
- );
398
-
399
-
400
- // options does save. Choices is being overriden by other field options that use the same key name
401
- // update js to disable all other options
402
-
403
-
404
- // if there is an id, this field already exists, so save it in the same ID spot
405
- if($field['id'])
406
- {
407
- $data['id'] = (int) $field['id'];
408
  }
409
 
410
-
411
- // save field as row in database
412
- $new_id = $wpdb->insert($table_name, $data);
413
-
414
-
415
- // increase order_no
416
- $i++;
417
- }
418
  }
419
 
 
 
 
420
  }
421
 
422
 
423
- /*---------------------------------------------------------------------------------------------
424
- * save_input
425
- * - called from input_save.php
426
- *
427
- * @author Elliot Condon
428
- * @since 1.1.5
429
- *
430
- ---------------------------------------------------------------------------------------------*/
431
- function save_input($post_id, $field)
 
432
  {
433
- //echo 'saving repeater';
434
 
435
- // set table name
436
- global $wpdb;
437
- $acf_values = $wpdb->prefix.'acf_values';
438
- $wp_postmeta = $wpdb->prefix.'postmeta';
439
-
440
-
441
- $field = stripslashes_deep( $field );
442
-
443
-
444
- if($field['value'])
445
  {
 
 
446
 
447
- $i = 0;
448
- foreach($field['value'] as $row)
449
- {
450
- // $i = row number
451
- foreach($row as $j => $cell)
452
- {
453
-
454
-
455
- // if select is a multiple (multiple select value), you need to save it as an array!
456
- if(isset($cell['value']) && $cell['value'] != "")
457
- {
458
- if(is_array($cell['value']))
459
- {
460
- $cell['value'] = serialize($cell['value']);
461
- }
462
- }
463
- else
464
- {
465
- $cell['value'] = "";
466
- //continue;
467
- }
468
-
469
-
470
- // create data: wp_postmeta
471
- $data1 = array(
472
- 'post_id' => (int) $post_id,
473
- 'meta_key' => $field['field_name'],
474
- 'meta_value' => $cell['value']
475
- );
476
- if(isset($cell['meta_id']) && $cell['meta_id'] != "")
477
- {
478
- $data1['meta_id'] = (int) $cell['meta_id'];
479
- }
480
-
481
-
482
 
483
- // get the new id
484
- $wpdb->insert($wp_postmeta, $data1);
485
- if(isset($cell['meta_id']) && $cell['meta_id'] != "")
486
- {
487
- $new_id = $cell['meta_id'];
488
- }
489
- else
490
- {
491
- $new_id = $wpdb->insert_id;
492
- }
493
 
 
 
494
 
 
 
495
 
496
- // create data: acf_values
497
- if($new_id && $new_id != 0)
498
- {
499
-
500
- $data2 = array(
501
- 'field_id' => $field['field_id'],
502
- 'post_id' => (int) $post_id,
503
- 'sub_field_id' => (int) $cell['field_id'],
504
- 'value' => $new_id,
505
- 'order_no' => $i,
506
- );
507
- if(isset($cell['value_id']) && $cell['value_id'] != "")
508
- {
509
- $data2['id'] = (int) $cell['value_id'];
510
- }
511
-
512
-
513
- $wpdb->insert($acf_values, $data2);
514
-
515
- }
516
-
517
-
518
  }
519
- //foreach($row as $j => $cell)
520
-
521
- $i++;
522
  }
523
- //foreach($field['value'] as $i => $row)
524
  }
525
- //if($field['value'])
 
526
 
527
  }
528
 
529
- /*---------------------------------------------------------------------------------------------
530
- * load_value_for_input
531
- * - called from acf.php - load_value_for_input
532
- *
533
- * @author Elliot Condon
534
- * @since 1.1.5
535
- *
536
- ---------------------------------------------------------------------------------------------*/
537
- function load_value_for_input($post_id, $field)
 
 
538
  {
539
-
540
- $sub_fields = $field->options['sub_fields'];
541
  $values = array();
 
542
 
543
-
544
- // set table name
545
- global $wpdb;
546
- $acf_values = $wpdb->prefix.'acf_values';
547
- $wp_postmeta = $wpdb->prefix.'postmeta';
548
-
549
-
550
- foreach($sub_fields as $sub_field)
551
- {
552
- // get var
553
- $db_values = $wpdb->get_results("SELECT m.meta_id, m.meta_value as value, v.order_no, v.id as value_id FROM $wp_postmeta m LEFT JOIN $acf_values v ON m.meta_id = v.value WHERE v.sub_field_id = '$sub_field->id' AND m.post_id = '$post_id' ORDER BY v.order_no ASC");
554
-
555
- //$db_values = $wpdb->get_results("SELECT * FROM $table_name WHERE field_id = '$sub_field->id' AND post_id = '$post_id' ORDER BY order_no ASC");
556
-
557
- if($db_values)
558
- {
559
- foreach($db_values as $db_value)
560
- {
561
-
562
- // format if needed
563
- if(method_exists($this->parent->fields[$sub_field->type], 'format_value_for_input'))
564
- {
565
- $db_value->value = $this->parent->fields[$sub_field->type]->format_value_for_input($db_value->value);
566
- }
567
-
568
- $values[$db_value->order_no][$sub_field->order_no] = $db_value;
569
- }
570
-
571
- }
572
- else
573
- {
574
- $value = new stdClass();
575
- $value->value = false;
576
-
577
-
578
- // override with default value
579
- if($post_id != 0)
580
  {
581
- $post_meta = get_post_custom($post_id);
582
- if(empty($post_meta) && isset($sub_field->default_value) && !empty($sub_field->default_value))
583
- {
584
- $value->value = $sub_field->default_value;
585
- }
586
-
 
587
  }
588
-
589
- $values[0][$sub_field->order_no] = $value;
590
-
591
- }
592
-
593
- }
594
-
595
-
596
- //print_r($values);
597
- return $values;
598
-
599
 
 
600
  }
601
 
 
 
 
 
 
 
 
 
602
 
603
- /*---------------------------------------------------------------------------------------------
604
- * load_value_for_api
605
- * - called from acf.php - load_value_for_api
606
- *
607
- * @author Elliot Condon
608
- * @since 1.1.5
609
- *
610
- ---------------------------------------------------------------------------------------------*/
611
- function load_value_for_api($post_id, $field)
612
  {
613
- // get sub fields
614
-
615
-
616
- $sub_fields = $field->options['sub_fields'];
617
  $values = array();
 
618
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
619
 
620
- // set table name
621
- global $wpdb;
622
- $table_name = $wpdb->prefix.'acf_values';
623
-
624
- if(is_array($sub_fields) && count($sub_fields) > 0)
625
- {
626
- foreach($sub_fields as $sub_field)
627
- {
628
- // get var
629
- $db_values = $wpdb->get_results("SELECT value, order_no FROM $table_name WHERE field_id = '$sub_field->id' AND post_id = '$post_id' ORDER BY order_no ASC");
630
-
631
- if($db_values)
632
- {
633
- foreach($db_values as $db_value)
634
- {
635
-
636
- $value = $db_value->value;
637
- // format if needed
638
- if(method_exists($this->parent->fields[$sub_field->type], 'format_value_for_api'))
639
- {
640
- $value = $this->parent->fields[$sub_field->type]->format_value_for_api($value, $sub_field->options);
641
- }
642
-
643
- //echo 'db order no = '.$db_value->order_no;
644
- $values[$db_value->order_no][$sub_field->name] = $value;
645
- }
646
-
647
- }
648
- else
649
- {
650
- $values[0][$sub_field->name] = false;
651
- }
652
-
653
- }
654
- }
655
-
656
- if(empty($values))
657
- {
658
- $values = false;
659
- }
660
-
661
- return $values;
662
  }
 
663
  }
664
 
665
  ?>
1
  <?php
2
 
3
+ class acf_Repeater extends acf_Field
4
  {
 
 
 
5
 
6
+ /*--------------------------------------------------------------------------------------
7
+ *
8
+ * Constructor
9
+ *
10
+ * @author Elliot Condon
11
+ * @since 1.0.0
12
+ * @updated 2.2.0
13
+ *
14
+ *-------------------------------------------------------------------------------------*/
15
 
16
+ function __construct($parent)
17
  {
18
+ parent::__construct($parent);
19
+
20
+ $this->name = 'repeater';
21
  $this->title = __("Repeater",'acf');
22
+
23
+ }
24
+
25
+
26
+ /*--------------------------------------------------------------------------------------
27
+ *
28
+ * admin_print_scripts / admin_print_styles
29
+ *
30
+ * @author Elliot Condon
31
+ * @since 3.0.0
32
+ *
33
+ *-------------------------------------------------------------------------------------*/
34
+
35
+ function admin_print_scripts()
36
+ {
37
+ wp_enqueue_script(array(
38
+
39
+ 'jquery-ui-sortable',
40
+
41
+ ));
42
  }
43
 
44
+ function admin_print_styles()
45
+ {
46
+
47
+ }
48
 
49
+
50
+ /*--------------------------------------------------------------------------------------
51
+ *
52
+ * admin_head
53
+ *
54
+ * @author Elliot Condon
55
+ * @since 2.0.6
56
+ *
57
+ *-------------------------------------------------------------------------------------*/
58
+
59
+ function admin_head()
60
  {
61
+ ?>
62
+ <script type="text/javascript">
63
+ (function($){
64
+
65
+
66
+ /*----------------------------------------------------------------------
67
+ *
68
+ * Update Order Numbers
69
+ *
70
+ *---------------------------------------------------------------------*/
71
+
72
+ $.fn.update_order_numbers = function(){
73
+
74
+ $(this).children('table').children('tbody').children('tr').each(function(i){
75
+ $(this).children('td.order').html(i+1);
76
+ });
77
+
78
+ };
79
+
80
+
81
+ /*----------------------------------------------------------------------
82
+ *
83
+ * Sortable
84
+ *
85
+ *---------------------------------------------------------------------*/
86
+ $.fn.make_sortable = function(){
87
+
88
+ var r = $(this);
89
+
90
+ var fixHelper = function(e, ui) {
91
+ ui.children().each(function() {
92
+ $(this).width($(this).width());
93
+ });
94
+ return ui;
95
+ };
96
+
97
+ r.children('table').children('tbody').unbind('sortable').sortable({
98
+ update: function(event, ui){
99
+ r.update_order_numbers();
100
+ //r.setup_wysiwyg();
101
+ //r.setup_relationship();
102
+ //r.setup_datepicker();
103
+ //r.setup_image();
104
+ //r.setup_file();
105
+ },
106
+ handle: 'td.order',
107
+ helper: fixHelper,
108
+ start: function(event, ui)
109
+ {
110
 
111
+ },
112
+ stop: function(event, ui)
113
+ {
114
+ //ui.item.setup_wysiwyg();
115
+ }
116
+ });
117
+ };
118
+
119
+
120
+ $(document).ready(function(){
121
+
122
+ $('#poststuff .repeater').each(function(){
123
+
124
+ var r = $(this);
125
+ var row_limit = parseInt(r.attr('data-row_limit'));
126
+ var row_count = r.children('table').children('tbody').children('tr.row').length;
127
+
128
+ // has limit been reached?
129
+ if(row_count >= row_limit) r.find('#add_field').attr('disabled','true');
130
+
131
+ // sortable
132
+ if(row_limit > 1){
133
+ r.make_sortable();
134
+ }
135
+
136
+ });
137
+
138
+
139
+ // add field
140
+ $('#poststuff .repeater #add_field').live('click', function(){
141
+
142
+ var r = $(this).closest('.repeater');
143
+ var row_limit = parseInt(r.attr('data-row_limit'));
144
+ var row_count = r.children('table').children('tbody').children('tr.row').length;
145
+
146
+ // row limit
147
+ if(row_count >= row_limit)
148
+ {
149
+ // reached row limit!
150
+ r.find('#add_field').attr('disabled','true');
151
+ return false;
152
+ }
153
+
154
+ // create and add the new field
155
+ var new_field = r.children('table').children('tbody').children('tr.row_clone').clone(false);
156
+ new_field.attr('class', 'row');
157
+ r.children('table').children('tbody').append(new_field);
158
+
159
+ // update names
160
+ new_field.find('[name]').each(function(){
161
+
162
+ var name = $(this).attr('name').replace('[999]','['+row_count+']');
163
+ $(this).attr('name', name);
164
+ $(this).attr('id', name);
165
+
166
+ });
167
+
168
+ // reset values
169
+ //if(!shift_is_down)
170
+ //{
171
+ //new_field.reset_values();
172
+ //}
173
+
174
+ // setup sub fields
175
+ //new_field.setup_wysiwyg();
176
+ //new_field.setup_relationship();
177
+ //new_field.setup_datepicker();
178
+ //new_field.setup_image();
179
+ //new_field.setup_file();
180
+
181
+ r.update_order_numbers();
182
+
183
+ // there is now 1 more row
184
+ row_count ++;
185
+
186
+ // disable the add field button if row limit is reached
187
+ if((row_count+1) >= row_limit)
188
+ {
189
+ r.find('#add_field').attr('disabled','true');
190
+ }
191
+
192
+ return false;
193
+
194
+ });
195
+
196
+
197
+ // remove field
198
+ $('#poststuff .repeater a.remove_field').die('click');
199
+ $('#poststuff .repeater a.remove_field').live('click', function(){
200
+
201
+ var r = $(this).closest('.repeater');
202
+ var tr = $(this).closest('tr');
203
+
204
+ tr.find('td').animate({'opacity':'0', 'height' : '0px'}, 300,function(){
205
+ tr.remove();
206
+ r.update_order_numbers();
207
+ });
208
+
209
+ r.find('#add_field').removeAttr('disabled');
210
+
211
+ return false;
212
+
213
+ });
214
+
215
+
216
+ // Update Order Numbers
217
+ $.fn.update_order_numbers = function(){
218
+
219
+ $(this).children('table').children('tbody').children('tr.row').each(function(i){
220
+ $(this).children('td.order').html(i+1);
221
+ });
222
+
223
+ };
224
+ });
225
+
226
+ })(jQuery);
227
+ </script>
228
+ <style type="text/css">
229
+ .repeater tr.row_clone {
230
+ display: none;
231
+ }
232
+ </style>
233
+ <?php
234
+ }
235
+
236
+
237
+ /*--------------------------------------------------------------------------------------
238
+ *
239
+ * create_field
240
+ *
241
+ * @author Elliot Condon
242
+ * @since 2.0.5
243
+ * @updated 2.2.0
244
+ *
245
+ *-------------------------------------------------------------------------------------*/
246
+
247
+ function create_field($field)
248
+ {
249
+ // vars
250
+ $row_limit = ( isset($field['row_limit']) && is_numeric($field['row_limit']) ) ? $field['row_limit'] : 999;
251
+ $layout = isset($field['layout']) ? $field['layout'] : 'table';
252
+ $sub_fields = isset($field['sub_fields']) ? $field['sub_fields'] : array();
253
+
254
+ // add clone field
255
+ if($row_limit == 1 && count($field['value']) == 0)
256
  {
257
+ $field['value'][] = array();
258
  }
259
 
260
+ // setup values for row clone
261
+ $field['value'][999] = array();
262
+ foreach($sub_fields as $sub_field)
263
  {
264
+ $sub_value = isset($sub_field['default_value']) ? $sub_field['default_value'] : '';
265
+ $field['value'][999][$sub_field['name']] = $sub_value;
266
  }
267
+
268
  ?>
269
  <div class="repeater" data-row_limit="<?php echo $row_limit; ?>">
270
  <table class="widefat <?php if($layout == 'row'): ?>row_layout<?php endif; ?>">
276
  <?php endif; ?>
277
 
278
  <?php foreach($sub_fields as $sub_field):?>
279
+ <th class="<?php echo $sub_field['name']; ?>" style="width:<?php echo 100/count($sub_fields); ?>%;"><span><?php echo $sub_field['label']; ?></span></th>
280
  <?php endforeach; ?>
281
 
282
  <?php if($row_limit > 1): ?>
286
  </thead>
287
  <?php endif; ?>
288
  <tbody>
289
+ <?php foreach($field['value'] as $i => $value):?>
290
+ <?php //if(($i+1) > $row_limit){continue;} ?>
291
+ <tr class="<?php echo ($i == 999) ? "row_clone" : "row"; ?>">
292
 
293
  <?php if($row_limit > 1): ?>
294
  <td class="order">
304
  <?php if($layout == 'table'): ?>
305
  <td>
306
  <?php else: ?>
307
+ <label><?php echo $sub_field['label']; ?></label>
308
  <?php endif; ?>
 
 
 
 
 
 
309
 
310
+ <?php
311
+ // add value
312
+ $sub_field['value'] = isset($value[$sub_field['name']]) ? $value[$sub_field['name']] : '';
313
+
314
+ // add name
315
+ $sub_field['name'] = $field['name'] . '[' . $i . '][' . $sub_field['key'] . ']';
 
 
316
 
317
+ // create field
318
+ $this->parent->create_field($sub_field);
319
  ?>
320
+
321
  <?php if($layout == 'table'): ?>
322
  </td>
323
  <?php else: ?>
346
  }
347
 
348
 
349
+
350
+ /*--------------------------------------------------------------------------------------
351
+ *
352
+ * create_options
353
+ *
354
+ * @author Elliot Condon
355
+ * @since 2.0.6
356
+ * @updated 2.2.0
357
+ *
358
+ *-------------------------------------------------------------------------------------*/
359
+
360
+ function create_options($key, $field)
361
  {
362
+ // vars
363
+ $fields_names = array();
364
+ $field['row_limit'] = isset($field['row_limit']) ? $field['row_limit'] : '';
365
+ $field['layout'] = isset($field['layout']) ? $field['layout'] : 'table';
366
+ $field['sub_fields'] = isset($field['sub_fields']) ? $field['sub_fields'] : array();
367
 
368
+ // add clone field
369
+ $field['sub_fields'][999] = array(
370
+ 'label' => __("New Field",'acf'),
371
+ 'name' => 'new_field',
372
+ 'type' => 'text',
373
+ 'order_no' => '1',
374
+ 'instructions' => '',
375
+ );
 
 
 
 
 
 
 
 
 
 
376
 
377
  // get name of all fields for use in field type
378
+ foreach($this->parent->fields as $f)
 
379
  {
380
+ $fields_names[$f->name] = $f->title;
381
  }
382
  unset($fields_names['repeater']);
383
 
384
  ?>
385
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
386
+ <td class="label">
387
+ <label><?php _e("Repeater Fields",'acf'); ?></label>
388
+ </td>
389
+ <td>
390
+ <div class="repeater">
391
+ <div class="fields_header">
392
+ <table class="acf widefat">
393
+ <thead>
394
+ <tr>
395
+ <th class="field_order"><?php _e('Field Order','acf'); ?></th>
396
+ <th class="field_label"><?php _e('Field Label','acf'); ?></th>
397
+ <th class="field_name"><?php _e('Field Name','acf'); ?></th>
398
+ <th class="field_type"><?php _e('Field Type','acf'); ?></th>
399
+ </tr>
400
+ </thead>
401
+ </table>
 
 
 
 
 
402
  </div>
403
+ <div class="fields">
404
 
405
+ <div class="no_fields_message" <?php if(count($field['sub_fields']) > 1){ echo 'style="display:none;"'; } ?>>
406
+ <?php _e("No fields. Click the \"+ Add Field button\" to create your first field.",'acf'); ?>
407
+ </div>
408
+
409
+ <?php foreach($field['sub_fields'] as $key2 => $sub_field): ?>
410
+ <div class="<?php if($key2 == 999){echo "field_clone";}else{echo "field";} ?> sub_field">
411
+
412
+ <?php if(isset($sub_field['key'])): ?>
413
+ <input type="hidden" name="fields[<?php echo $key; ?>][sub_fields][<?php echo $key2; ?>][key]" value="<?php echo $sub_field['key']; ?>" />
414
+ <?php endif; ?>
415
+ <div class="field_meta">
416
+ <table class="acf widefat">
417
+ <tr>
418
+ <td class="field_order"><span class="circle"><?php echo ($key2+1); ?></span></td>
419
+ <td class="field_label">
420
+ <strong>
421
+ <a class="acf_edit_field" title="Edit this Field" href="javascript:;"><?php echo $sub_field['label']; ?></a>
422
+ </strong>
423
+ <div class="row_options">
424
+ <span><a class="acf_edit_field" title="Edit this Field" href="javascript:;">Edit</a> | </span>
425
+ <span><a class="acf_delete_field" title="Delete this Field" href="javascript:;">Delete</a>
426
+ </div>
427
+ </td>
428
+ <td class="field_name"><?php echo $sub_field['name']; ?></td>
429
+ <td class="field_type"><?php echo $sub_field['type']; ?></td>
430
+ </tr>
431
+ </table>
432
+ </div>
433
+
434
+ <div class="field_form_mask">
435
+ <div class="field_form">
436
+
437
+ <table class="acf_input widefat">
438
+ <tbody>
439
+ <tr class="field_label">
440
+ <td class="label">
441
+ <label><span class="required">*</span><?php _e("Field Label",'acf'); ?></label>
442
+ <p class="description"><?php _e("This is the name which will appear on the EDIT page",'acf'); ?></p>
443
+ </td>
444
+ <td>
445
+ <?php
446
+ $this->parent->create_field(array(
447
+ 'type' => 'text',
448
+ 'name' => 'fields['.$key.'][sub_fields]['.$key2.'][label]',
449
+ 'value' => $sub_field['label'],
450
+ 'class' => 'label',
451
+ ));
452
+ ?>
453
+ </td>
454
+ </tr>
455
+ <tr class="field_name">
456
+ <td class="label">
457
+ <label><span class="required">*</span><?php _e("Field Name",'acf'); ?></label>
458
+ <p class="description"><?php _e("Single word, no spaces. Underscores and dashes allowed",'acf'); ?></p>
459
+ </td>
460
+ <td>
461
+ <?php
462
+ $this->parent->create_field(array(
463
+ 'type' => 'text',
464
+ 'name' => 'fields['.$key.'][sub_fields]['.$key2.'][name]',
465
+ 'value' => $sub_field['name'],
466
+ 'class' => 'name',
467
+ ));
468
+ ?>
469
+ </td>
470
+ </tr>
471
+ <tr class="field_type">
472
+ <td class="label"><label><span class="required">*</span><?php _e("Field Type",'acf'); ?></label></td>
473
+ <td>
474
+ <?php
475
+ $this->parent->create_field(array(
476
+ 'type' => 'select',
477
+ 'name' => 'fields['.$key.'][sub_fields]['.$key2.'][type]',
478
+ 'value' => $sub_field['type'],
479
+ 'class' => 'type',
480
+ 'choices' => $fields_names
481
+ ));
482
+ ?>
483
+ </td>
484
+ </tr>
485
+ <?php
486
+ foreach($fields_names as $field_name => $field_title){
487
+ $this->parent->fields[$field_name]->create_options($key.'][sub_fields]['.$key2, $sub_field);
488
+ }
489
+ ?>
490
+ <tr class="field_save">
491
+ <td class="label">
492
+ <label><?php _e("Save Field",'acf'); ?></label>
493
+ </td>
494
+ <td><input type="submit" value="Save Field" class="button-primary" name="save" />
495
+ <?php _e("or",'acf'); ?> <a class="acf_edit_field" title="<?php _e("Hide this edit screen",'acf'); ?>" href="javascript:;"><?php _e("continue editing ACF",'acf'); ?></a>
496
+ </td>
497
+ </tr>
498
+ </tbody>
499
+ </table>
500
 
501
+ </div><!-- End Form -->
502
+ </div><!-- End Form Mask -->
503
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
504
  </div>
505
+ <?php endforeach; ?>
506
+ </div>
507
+ <div class="table_footer">
508
+ <div class="order_message"></div>
509
+ <a href="javascript:;" id="add_field" class="button-primary"><?php _e('+ Add Field','acf'); ?></a>
510
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
511
  </div>
512
+ </td>
 
513
  </tr>
514
+
515
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
516
  <td class="label">
517
+ <label><?php _e("Row Limit",'acf'); ?></label>
518
  </td>
519
  <td>
520
+ <?php
521
+ $this->parent->create_field(array(
522
+ 'type' => 'text',
523
+ 'name' => 'fields['.$key.'][row_limit]',
524
+ 'value' => $field['row_limit'],
525
+ ));
526
+ ?>
527
  </td>
528
  </tr>
529
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
530
  <td class="label">
531
+ <label><?php _e("Layout",'acf'); ?></label>
532
  </td>
533
  <td>
 
534
  <?php
535
+ $this->parent->create_field(array(
536
+ 'type' => 'radio',
537
+ 'name' => 'fields['.$key.'][layout]',
538
+ 'value' => $field['layout'],
539
+ 'layout' => 'horizontal',
540
+ 'choices' => array(
541
+ 'table' => 'Table (default)',
542
+ 'row' => 'Row'
543
+ )
544
  ));
 
 
 
545
  ?>
 
546
  </td>
547
  </tr>
548
+ <?php
549
+ }
 
550
 
551
+
552
+ /*--------------------------------------------------------------------------------------
553
+ *
554
+ * pre_save_field
555
+ * - called just before saving the field to the database.
556
+ *
557
+ * @author Elliot Condon
558
+ * @since 2.2.0
559
+ *
560
+ *-------------------------------------------------------------------------------------*/
561
 
562
+ function pre_save_field($field)
 
 
 
 
 
 
 
 
563
  {
564
+ // format sub_fields
 
 
 
 
 
 
565
  if($field['sub_fields'])
566
  {
567
+ // remove dummy field
568
+ unset($field['sub_fields'][999]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
569
 
570
+ // loop through and save fields
571
+ $i = -1;
572
 
573
+ $sub_fields = array();
574
 
575
+ foreach($field['sub_fields'] as $f)
 
576
  {
577
+ $i++;
 
 
 
 
 
 
 
 
 
 
 
 
 
578
 
579
+ // each field has a unique id!
580
+ if(!isset($f['key'])) $f['key'] = 'field_' . uniqid();
581
+
582
+ // order
583
+ $f['order_no'] = $i;
584
+
585
+ // format
586
+ $f = $this->parent->pre_save_field($f);
587
+
588
+ $sub_fields[] = $f;
 
589
  }
590
 
591
+ $field['sub_fields'] = $sub_fields;
 
 
 
 
 
 
 
592
  }
593
 
594
+ // return updated repeater field
595
+ return $field;
596
+
597
  }
598
 
599
 
600
+ /*--------------------------------------------------------------------------------------
601
+ *
602
+ * update_value
603
+ *
604
+ * @author Elliot Condon
605
+ * @since 2.2.0
606
+ *
607
+ *-------------------------------------------------------------------------------------*/
608
+
609
+ function update_value($post_id, $field, $value)
610
  {
611
+ $total = 0;
612
 
613
+ if($value)
 
 
 
 
 
 
 
 
 
614
  {
615
+ // remove dummy field
616
+ unset($value[999]);
617
 
618
+ $i = -1;
619
+
620
+ // loop through rows
621
+ foreach($value as $row)
622
+ {
623
+ $i++;
624
+
625
+ // increase total
626
+ $total++;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
627
 
628
+ // loop through sub fields
629
+ foreach($field['sub_fields'] as $sub_field)
630
+ {
631
+ // get sub field data
632
+ $v = isset($row[$sub_field['key']]) ? $row[$sub_field['key']] : '';
 
 
 
 
 
633
 
634
+ // add to parent value
635
+ //$parent_value[$i][$sub_field['name']] = $v;
636
 
637
+ // update full name
638
+ $sub_field['name'] = $field['name'] . '_' . $i . '_' . $sub_field['name'];
639
 
640
+ // save sub field value
641
+ $this->parent->update_value($post_id, $sub_field, $v);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
642
  }
 
 
 
643
  }
 
644
  }
645
+
646
+ parent::update_value($post_id, $field, $total);
647
 
648
  }
649
 
650
+
651
+ /*--------------------------------------------------------------------------------------
652
+ *
653
+ * get_value
654
+ *
655
+ * @author Elliot Condon
656
+ * @since 2.2.0
657
+ *
658
+ *-------------------------------------------------------------------------------------*/
659
+
660
+ function get_value($post_id, $field)
661
  {
662
+ // vars
 
663
  $values = array();
664
+ $total = (int) get_post_meta($post_id, $field['name'], true);
665
 
666
+ if($total > 0)
667
+ {
668
+ // loop through rows
669
+ for($i = 0; $i < $total; $i++)
670
+ {
671
+ // loop through sub fields
672
+ foreach($field['sub_fields'] as $sub_field)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
673
  {
674
+ // store name
675
+ $field_name = $sub_field['name'];
676
+
677
+ // update full name
678
+ $sub_field['name'] = $field['name'] . '_' . $i . '_' . $field_name;
679
+
680
+ $values[$i][$field_name] = $this->parent->get_value($post_id, $sub_field);
681
  }
682
+ }
683
+
684
+ return $values;
685
+ }
 
 
 
 
 
 
 
686
 
687
+ return array();
688
  }
689
 
690
+ /*--------------------------------------------------------------------------------------
691
+ *
692
+ * get_value_for_api
693
+ *
694
+ * @author Elliot Condon
695
+ * @since 3.0.0
696
+ *
697
+ *-------------------------------------------------------------------------------------*/
698
 
699
+ function get_value_for_api($post_id, $field)
 
 
 
 
 
 
 
 
700
  {
701
+ // vars
 
 
 
702
  $values = array();
703
+ $total = (int) get_post_meta($post_id, $field['name'], true);
704
 
705
+ if($total > 0)
706
+ {
707
+ // loop through rows
708
+ for($i = 0; $i < $total; $i++)
709
+ {
710
+ // loop through sub fields
711
+ foreach($field['sub_fields'] as $sub_field)
712
+ {
713
+ // store name
714
+ $field_name = $sub_field['name'];
715
+
716
+ // update full name
717
+ $sub_field['name'] = $field['name'] . '_' . $i . '_' . $field_name;
718
+
719
+ $values[$i][$field_name] = $this->parent->get_value_for_api($post_id, $sub_field);
720
+ }
721
+ }
722
+
723
+ return $values;
724
+ }
725
 
726
+ return array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
727
  }
728
+
729
  }
730
 
731
  ?>
core/fields/select.php CHANGED
@@ -1,101 +1,161 @@
1
  <?php
2
 
3
- class acf_Select
4
  {
5
- var $name;
6
- var $title;
7
- var $parent;
 
 
 
 
 
 
 
8
 
9
- function acf_Select($parent)
10
  {
11
- $this->name = 'select';
 
 
12
  $this->title = __("Select",'acf');
13
- $this->parent = $parent;
14
- }
 
 
15
 
16
- function html($field)
 
 
 
 
 
 
 
 
 
 
17
  {
18
- if(isset($field->options['multiple']) && $field->options['multiple'] == '1')
 
 
 
 
 
 
 
 
19
  {
20
- $name_extra = '[]';
21
- if(count($field->options['choices']) <= 1)
22
- {
23
- $name_extra = '';
24
- }
25
- echo '<select id="'.$field->input_name.'" class="'.$field->input_class.'" name="'.$field->input_name.$name_extra.'" multiple="multiple" size="5" >';
26
  }
27
- else
 
 
 
28
  {
29
- echo '<select id="'.$field->input_name.'" class="'.$field->input_class.'" name="'.$field->input_name.'" >';
30
- // add top option
31
-
32
- if(isset($field->options['allow_null']) && $field->options['allow_null'] == '1')
33
- {
34
- echo '<option value="null"> - Select - </option>';
35
- }
36
-
37
- }
38
 
39
- if(empty($field->options['choices']))
 
40
  {
41
-
42
- echo '<p>' . __("No choices to choose from",'acf') . '</p>';
43
- return false;
44
  }
45
 
46
  // loop through values and add them as options
47
- foreach($field->options['choices'] as $key => $value)
48
  {
49
- $selected = '';
50
- if(is_array($field->value))
51
  {
52
- // 2. If the value is an array (multiple select), loop through values and check if it is selected
53
- if(in_array($key, $field->value))
 
54
  {
55
- $selected = 'selected="selected"';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  }
 
57
  }
58
  else
59
  {
60
- // 3. this is not a multiple select, just check normaly
61
- if($key == $field->value)
62
  {
 
63
  $selected = 'selected="selected"';
64
  }
65
- }
66
-
 
 
 
 
 
 
 
 
 
 
67
 
68
- echo '<option value="'.$key.'" '.$selected.'>'.$value.'</option>';
69
  }
70
 
71
  echo '</select>';
72
  }
73
 
74
 
75
- function options_html($key, $field)
76
- {
77
- $options = $field->options;
 
 
 
 
 
 
 
 
 
 
 
 
78
 
79
  // implode selects so they work in a textarea
80
- if(isset($options['choices']) && is_array($options['choices']))
81
  {
82
- foreach($options['choices'] as $choice_key => $choice_val)
83
  {
84
- $options['choices'][$choice_key] = $choice_key.' : '.$choice_val;
85
  }
86
- $options['choices'] = implode("\n", $options['choices']);
87
  }
88
  else
89
  {
90
- $options['choices'] = "";
91
  }
92
-
93
- $options['multiple'] = isset($options['multiple']) ? $options['multiple'] : '0';
94
- $options['allow_null'] = isset($options['allow_null']) ? $options['allow_null'] : '0';
95
 
96
  ?>
97
-
98
- <tr class="field_option field_option_select">
99
  <td class="label">
100
  <label for=""><?php _e("Choices",'acf'); ?></label>
101
  <p class="description"><?php _e("Enter your choices one per line<br />
@@ -109,83 +169,87 @@ class acf_Select
109
  blue : Blue",'acf'); ?></p>
110
  </td>
111
  <td>
112
- <textarea rows="5" name="acf[fields][<?php echo $key; ?>][options][choices]" id=""><?php echo $options['choices']; ?></textarea>
113
- <p class="description"></p>
114
  </td>
115
  </tr>
116
- <tr class="field_option field_option_select">
117
  <td class="label">
118
  <label><?php _e("Allow Null?",'acf'); ?></label>
119
  </td>
120
  <td>
121
  <?php
122
- $temp_field = new stdClass();
123
- $temp_field->type = 'true_false';
124
- $temp_field->input_name = 'acf[fields]['.$key.'][options][allow_null]';
125
- $temp_field->input_class = '';
126
- $temp_field->value = $options['allow_null'];
127
- $temp_field->options = array('message' => 'Add null value above choices');
128
- $this->parent->create_field($temp_field);
 
 
 
129
  ?>
130
  </td>
131
  </tr>
132
- <tr class="field_option field_option_select">
133
  <td class="label">
134
  <label><?php _e("Select multiple values?",'acf'); ?></label>
135
  </td>
136
  <td>
137
  <?php
138
- $temp_field->type = 'true_false';
139
- $temp_field->input_name = 'acf[fields]['.$key.'][options][multiple]';
140
- $temp_field->input_class = '';
141
- $temp_field->value = $options['multiple'];
142
- $temp_field->options = array('message' => 'Turn this drop-down into a multi-select');
143
- $this->parent->create_field($temp_field);
 
 
 
 
144
  ?>
145
  </td>
146
  </tr>
147
 
148
  <?php
149
  }
150
-
151
 
152
- /*---------------------------------------------------------------------------------------------
153
- * Format Options
154
- * - this is called from save_field.php, this function formats the options into a savable format
155
- *
156
- * @author Elliot Condon
157
- * @since 1.1
158
- *
159
- ---------------------------------------------------------------------------------------------*/
160
- function format_options($options)
161
- {
162
- // if no choices, dont do anything
163
- if(!$options['choices'] || is_array($options['choices']))
164
- {
165
- return $options;
166
- }
167
 
 
 
168
 
169
  // explode choices from each line
170
- if(strpos($options['choices'], "\n") !== false)
171
  {
172
  // found multiple lines, explode it
173
- $choices = explode("\n", $options['choices']);
174
  }
175
  else
176
  {
177
  // no multiple lines!
178
- $choices = array($options['choices']);
179
  }
180
 
181
-
182
-
183
- $new_choices = array();
184
- foreach($choices as $choice)
185
  {
186
  if(strpos($choice, ' : ') !== false)
187
  {
188
-
189
  $choice = explode(' : ', $choice);
190
  $new_choices[trim($choice[0])] = trim($choice[1]);
191
  }
@@ -195,59 +259,15 @@ class acf_Select
195
  }
196
  }
197
 
 
 
198
 
199
- // return array containing all choices
200
- $options['choices'] = $new_choices;
201
-
202
- return $options;
203
- }
204
-
205
-
206
- /*---------------------------------------------------------------------------------------------
207
- * Format Value
208
- * - this is called from api.php
209
- *
210
- * @author Elliot Condon
211
- * @since 1.1
212
- *
213
- ---------------------------------------------------------------------------------------------*/
214
- function format_value_for_api($value, $options = null)
215
- {
216
- $value = $this->format_value_for_input($value);
217
-
218
- if($value == 'null')
219
- {
220
- return false;
221
- }
222
-
223
- return $value;
224
- }
225
-
226
-
227
- /*---------------------------------------------------------------------------------------------
228
- * Format Value for input
229
- * - this is called from api.php
230
- *
231
- * @author Elliot Condon
232
- * @since 1.1
233
- *
234
- ---------------------------------------------------------------------------------------------*/
235
- function format_value_for_input($value)
236
- {
237
- $is_array = @unserialize($value);
238
-
239
- if($is_array)
240
- {
241
- return unserialize($value);
242
- }
243
- else
244
- {
245
- return $value;
246
- }
247
  }
248
 
249
 
250
-
251
  }
252
 
253
  ?>
1
  <?php
2
 
3
+ class acf_Select extends acf_Field
4
  {
5
+
6
+ /*--------------------------------------------------------------------------------------
7
+ *
8
+ * Constructor
9
+ *
10
+ * @author Elliot Condon
11
+ * @since 1.0.0
12
+ * @updated 2.2.0
13
+ *
14
+ *-------------------------------------------------------------------------------------*/
15
 
16
+ function __construct($parent)
17
  {
18
+ parent::__construct($parent);
19
+
20
+ $this->name = 'select';
21
  $this->title = __("Select",'acf');
22
+
23
+ }
24
+
25
+
26
 
27
+ /*--------------------------------------------------------------------------------------
28
+ *
29
+ * create_field
30
+ *
31
+ * @author Elliot Condon
32
+ * @since 2.0.5
33
+ * @updated 2.2.0
34
+ *
35
+ *-------------------------------------------------------------------------------------*/
36
+
37
+ function create_field($field)
38
  {
39
+ // defaults
40
+ $field['value'] = isset($field['value']) ? $field['value'] : array();
41
+ $field['multiple'] = isset($field['multiple']) ? $field['multiple'] : false;
42
+ $field['allow_null'] = isset($field['allow_null']) ? $field['allow_null'] : false;
43
+ $field['choices'] = isset($field['choices']) ? $field['choices'] : array();
44
+ $field['optgroup'] = isset($field['optgroup']) ? $field['optgroup'] : false;
45
+
46
+ // no choices
47
+ if(empty($field['choices']))
48
  {
49
+ echo '<p>' . __("No choices to choose from",'acf') . '</p>';
50
+ return false;
 
 
 
 
51
  }
52
+
53
+ // multiple select
54
+ $multiple = '';
55
+ if($field['multiple'] == '1')
56
  {
57
+ $multiple = ' multiple="multiple" size="5" ';
58
+ $field['name'] .= '[]';
59
+ }
60
+
61
+ // html
62
+ echo '<select id="' . $field['name'] . '" class="' . $field['class'] . '" name="' . $field['name'] . '" ' . $multiple . ' >';
 
 
 
63
 
64
+ // null
65
+ if($field['allow_null'] == '1')
66
  {
67
+ echo '<option value="null"> - Select - </option>';
 
 
68
  }
69
 
70
  // loop through values and add them as options
71
+ foreach($field['choices'] as $key => $value)
72
  {
73
+ if($field['optgroup'])
 
74
  {
75
+ // this select is grouped with optgroup
76
+ echo '<optgroup label="'.$key.'">';
77
+ if($value)
78
  {
79
+ foreach($value as $id => $label)
80
+ {
81
+ $selected = '';
82
+ if(is_array($field['value']) && in_array($id, $field['value']))
83
+ {
84
+ // 2. If the value is an array (multiple select), loop through values and check if it is selected
85
+ $selected = 'selected="selected"';
86
+ }
87
+ else
88
+ {
89
+ // 3. this is not a multiple select, just check normaly
90
+ if($id == $field['value'])
91
+ {
92
+ $selected = 'selected="selected"';
93
+ }
94
+ }
95
+ echo '<option value="'.$id.'" '.$selected.'>'.$label.'</option>';
96
+ }
97
  }
98
+ echo '</optgroup>';
99
  }
100
  else
101
  {
102
+ $selected = '';
103
+ if(is_array($field['value']) && in_array($key, $field['value']))
104
  {
105
+ // 2. If the value is an array (multiple select), loop through values and check if it is selected
106
  $selected = 'selected="selected"';
107
  }
108
+ else
109
+ {
110
+ // 3. this is not a multiple select, just check normaly
111
+ if($key == $field['value'])
112
+ {
113
+ $selected = 'selected="selected"';
114
+ }
115
+ }
116
+ echo '<option value="'.$key.'" '.$selected.'>'.$value.'</option>';
117
+ }
118
+
119
+
120
 
 
121
  }
122
 
123
  echo '</select>';
124
  }
125
 
126
 
127
+ /*--------------------------------------------------------------------------------------
128
+ *
129
+ * create_options
130
+ *
131
+ * @author Elliot Condon
132
+ * @since 2.0.6
133
+ * @updated 2.2.0
134
+ *
135
+ *-------------------------------------------------------------------------------------*/
136
+
137
+ function create_options($key, $field)
138
+ {
139
+ // defaults
140
+ $field['multiple'] = isset($field['multiple']) ? $field['multiple'] : '0';
141
+ $field['allow_null'] = isset($field['allow_null']) ? $field['allow_null'] : '0';
142
 
143
  // implode selects so they work in a textarea
144
+ if(isset($field['choices']) && is_array($field['choices']))
145
  {
146
+ foreach($field['choices'] as $choice_key => $choice_val)
147
  {
148
+ $field['choices'][$choice_key] = $choice_key.' : '.$choice_val;
149
  }
150
+ $field['choices'] = implode("\n", $field['choices']);
151
  }
152
  else
153
  {
154
+ $field['choices'] = "";
155
  }
 
 
 
156
 
157
  ?>
158
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
 
159
  <td class="label">
160
  <label for=""><?php _e("Choices",'acf'); ?></label>
161
  <p class="description"><?php _e("Enter your choices one per line<br />
169
  blue : Blue",'acf'); ?></p>
170
  </td>
171
  <td>
172
+ <textarea rows="5" name="fields[<?php echo $key; ?>][choices]" id=""><?php echo $field['choices']; ?></textarea>
 
173
  </td>
174
  </tr>
175
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
176
  <td class="label">
177
  <label><?php _e("Allow Null?",'acf'); ?></label>
178
  </td>
179
  <td>
180
  <?php
181
+ $this->parent->create_field(array(
182
+ 'type' => 'radio',
183
+ 'name' => 'fields['.$key.'][allow_null]',
184
+ 'value' => $field['allow_null'],
185
+ 'choices' => array(
186
+ '1' => 'Yes',
187
+ '0' => 'No',
188
+ ),
189
+ 'layout' => 'horizontal',
190
+ ));
191
  ?>
192
  </td>
193
  </tr>
194
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
195
  <td class="label">
196
  <label><?php _e("Select multiple values?",'acf'); ?></label>
197
  </td>
198
  <td>
199
  <?php
200
+ $this->parent->create_field(array(
201
+ 'type' => 'radio',
202
+ 'name' => 'fields['.$key.'][multiple]',
203
+ 'value' => $field['multiple'],
204
+ 'choices' => array(
205
+ '1' => 'Yes',
206
+ '0' => 'No',
207
+ ),
208
+ 'layout' => 'horizontal',
209
+ ));
210
  ?>
211
  </td>
212
  </tr>
213
 
214
  <?php
215
  }
 
216
 
217
+
218
+ /*--------------------------------------------------------------------------------------
219
+ *
220
+ * pre_save_field
221
+ * - called just before saving the field to the database.
222
+ *
223
+ * @author Elliot Condon
224
+ * @since 2.2.0
225
+ *
226
+ *-------------------------------------------------------------------------------------*/
227
+
228
+ function pre_save_field($field)
229
+ {
230
+ // defaults
231
+ $field['choices'] = isset($field['choices']) ? $field['choices'] : '';
232
 
233
+ // vars
234
+ $new_choices = array();
235
 
236
  // explode choices from each line
237
+ if(strpos($field['choices'], "\n") !== false)
238
  {
239
  // found multiple lines, explode it
240
+ $field['choices'] = explode("\n", $field['choices']);
241
  }
242
  else
243
  {
244
  // no multiple lines!
245
+ $field['choices'] = array($field['choices']);
246
  }
247
 
248
+ // key => value
249
+ foreach($field['choices'] as $choice)
 
 
250
  {
251
  if(strpos($choice, ' : ') !== false)
252
  {
 
253
  $choice = explode(' : ', $choice);
254
  $new_choices[trim($choice[0])] = trim($choice[1]);
255
  }
259
  }
260
  }
261
 
262
+ // update choices
263
+ $field['choices'] = $new_choices;
264
 
265
+ // return updated field
266
+ return $field;
267
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
268
  }
269
 
270
 
 
271
  }
272
 
273
  ?>
core/fields/text.php CHANGED
@@ -1,48 +1,91 @@
1
  <?php
2
 
3
- class acf_Text
4
  {
5
- var $name;
6
- var $title;
7
- var $parent;
8
 
9
- function acf_Text($parent)
 
 
 
 
 
 
 
 
 
 
10
  {
11
- $this->name = 'text';
 
 
12
  $this->title = __("Text",'acf');
13
- $this->parent = $parent;
14
- }
 
 
 
 
 
 
 
 
 
 
 
15
 
16
- function html($field)
17
  {
18
- echo '<input type="text" value="'.$field->value.'" id="'.$field->input_name.'" class="'.$field->input_class.'" name="'.$field->input_name.'" />';
19
  }
20
 
21
 
22
  /*--------------------------------------------------------------------------------------
23
  *
24
- * Options HTML
25
  *
26
  * @author Elliot Condon
27
  * @since 2.0.6
 
28
  *
29
  *-------------------------------------------------------------------------------------*/
30
 
31
- function options_html($key, $field)
32
  {
 
 
 
 
33
  ?>
34
- <tr class="field_option field_option_text">
35
  <td class="label">
36
  <label><?php _e("Default Value",'acf'); ?></label>
37
  </td>
38
  <td>
39
  <?php
40
- $temp_field = new stdClass();
41
- $temp_field->type = 'text';
42
- $temp_field->input_name = 'acf[fields]['.$key.'][default_value]';
43
- $temp_field->input_class = 'default_value';
44
- $temp_field->value = $field->default_value;
45
- $this->parent->create_field($temp_field);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  ?>
47
  </td>
48
  </tr>
@@ -50,9 +93,50 @@ class acf_Text
50
  }
51
 
52
 
53
- function format_value_for_input($value)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  {
55
- return htmlspecialchars($value, ENT_QUOTES);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  }
57
 
58
  }
1
  <?php
2
 
3
+ class acf_Text extends acf_Field
4
  {
 
 
 
5
 
6
+ /*--------------------------------------------------------------------------------------
7
+ *
8
+ * Constructor
9
+ *
10
+ * @author Elliot Condon
11
+ * @since 1.0.0
12
+ * @updated 2.2.0
13
+ *
14
+ *-------------------------------------------------------------------------------------*/
15
+
16
+ function __construct($parent)
17
  {
18
+ parent::__construct($parent);
19
+
20
+ $this->name = 'text';
21
  $this->title = __("Text",'acf');
22
+
23
+ }
24
+
25
+
26
+ /*--------------------------------------------------------------------------------------
27
+ *
28
+ * create_field
29
+ *
30
+ * @author Elliot Condon
31
+ * @since 2.0.5
32
+ * @updated 2.2.0
33
+ *
34
+ *-------------------------------------------------------------------------------------*/
35
 
36
+ function create_field($field)
37
  {
38
+ echo '<input type="text" value="' . $field['value'] . '" id="' . $field['name'] . '" class="' . $field['class'] . '" name="' . $field['name'] . '" />';
39
  }
40
 
41
 
42
  /*--------------------------------------------------------------------------------------
43
  *
44
+ * create_options
45
  *
46
  * @author Elliot Condon
47
  * @since 2.0.6
48
+ * @updated 2.2.0
49
  *
50
  *-------------------------------------------------------------------------------------*/
51
 
52
+ function create_options($key, $field)
53
  {
54
+ // defaults
55
+ $field['default_value'] = isset($field['default_value']) ? $field['default_value'] : '';
56
+ $field['formatting'] = isset($field['formatting']) ? $field['formatting'] : 'html';
57
+
58
  ?>
59
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
60
  <td class="label">
61
  <label><?php _e("Default Value",'acf'); ?></label>
62
  </td>
63
  <td>
64
  <?php
65
+ $this->parent->create_field(array(
66
+ 'type' => 'text',
67
+ 'name' => 'fields['.$key.'][default_value]',
68
+ 'value' => $field['default_value'],
69
+ ));
70
+ ?>
71
+ </td>
72
+ </tr>
73
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
74
+ <td class="label">
75
+ <label><?php _e("Formatting",'acf'); ?></label>
76
+ <p class="description"><?php _e("Define how to render html tags",'acf'); ?></p>
77
+ </td>
78
+ <td>
79
+ <?php
80
+ $this->parent->create_field(array(
81
+ 'type' => 'select',
82
+ 'name' => 'fields['.$key.'][formatting]',
83
+ 'value' => $field['formatting'],
84
+ 'choices' => array(
85
+ 'none' => 'None',
86
+ 'html' => 'HTML'
87
+ )
88
+ ));
89
  ?>
90
  </td>
91
  </tr>
93
  }
94
 
95
 
96
+ /*--------------------------------------------------------------------------------------
97
+ *
98
+ * get_value
99
+ *
100
+ * @author Elliot Condon
101
+ * @since 2.2.0
102
+ *
103
+ *-------------------------------------------------------------------------------------*/
104
+
105
+ function get_value($post_id, $field)
106
+ {
107
+ $value = parent::get_value($post_id, $field);
108
+
109
+ $value = htmlspecialchars($value, ENT_QUOTES);
110
+
111
+ return $value;
112
+ }
113
+
114
+ /*--------------------------------------------------------------------------------------
115
+ *
116
+ * get_value_for_api
117
+ *
118
+ * @author Elliot Condon
119
+ * @since 3.0.0
120
+ *
121
+ *-------------------------------------------------------------------------------------*/
122
+
123
+ function get_value_for_api($post_id, $field)
124
  {
125
+ // vars
126
+ $format = isset($field['formatting']) ? $field['formatting'] : 'html';
127
+
128
+ $value = parent::get_value($post_id, $field);
129
+
130
+ if($format == 'none')
131
+ {
132
+ $value = htmlspecialchars($value, ENT_QUOTES);
133
+ }
134
+ elseif($format == 'html')
135
+ {
136
+ $value = html_entity_decode($value);
137
+ }
138
+
139
+ return $value;
140
  }
141
 
142
  }
core/fields/textarea.php CHANGED
@@ -1,66 +1,130 @@
1
  <?php
2
 
3
- class acf_Textarea
4
  {
5
- var $name;
6
- var $title;
7
- var $parent;
 
 
 
 
 
 
 
8
 
9
- function acf_Textarea($parent)
10
  {
11
- $this->name = 'textarea';
 
 
12
  $this->title = __("Text Area",'acf');
13
- $this->parent = $parent;
14
- }
 
 
 
 
 
 
 
 
 
 
 
15
 
16
- function html($field)
17
  {
18
  // remove unwanted <br /> tags
19
- $field->value = str_replace('<br />','',$field->value);
20
- echo '<textarea id="'.$field->input_name.'" rows="4" class="'.$field->input_class.'" name="'.$field->input_name.'" >'.$field->value.'</textarea>';
21
  }
22
 
23
 
24
  /*--------------------------------------------------------------------------------------
25
  *
26
- * Options HTML
27
  *
28
  * @author Elliot Condon
29
  * @since 2.0.6
30
  *
31
  *-------------------------------------------------------------------------------------*/
32
 
33
- function options_html($key, $field)
34
  {
35
-
 
 
 
36
  ?>
37
- <tr class="field_option field_option_textarea">
38
  <td class="label">
39
  <label><?php _e("Default Value",'acf'); ?></label>
40
  </td>
41
  <td>
42
  <?php
43
- $temp_field = new stdClass();
44
- $temp_field->type = 'textarea';
45
- $temp_field->input_name = 'acf[fields]['.$key.'][default_value]';
46
- $temp_field->input_class = 'default_value';
47
- $temp_field->value = $field->default_value;
48
- $this->parent->create_field($temp_field);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  ?>
50
  </td>
51
  </tr>
52
  <?php
53
  }
54
 
55
- function format_value_for_input($value)
56
- {
57
- $value = htmlspecialchars($value, ENT_QUOTES);
58
- return $value;
59
- }
60
 
61
- function format_value_for_api($value, $options = null)
 
 
 
 
 
 
 
 
 
62
  {
63
- $value = nl2br($value);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  return $value;
65
  }
66
  }
1
  <?php
2
 
3
+ class acf_Textarea extends acf_Field
4
  {
5
+
6
+ /*--------------------------------------------------------------------------------------
7
+ *
8
+ * Constructor
9
+ *
10
+ * @author Elliot Condon
11
+ * @since 1.0.0
12
+ * @updated 2.2.0
13
+ *
14
+ *-------------------------------------------------------------------------------------*/
15
 
16
+ function __construct($parent)
17
  {
18
+ parent::__construct($parent);
19
+
20
+ $this->name = 'textarea';
21
  $this->title = __("Text Area",'acf');
22
+
23
+ }
24
+
25
+
26
+ /*--------------------------------------------------------------------------------------
27
+ *
28
+ * create_field
29
+ *
30
+ * @author Elliot Condon
31
+ * @since 2.0.5
32
+ * @updated 2.2.0
33
+ *
34
+ *-------------------------------------------------------------------------------------*/
35
 
36
+ function create_field($field)
37
  {
38
  // remove unwanted <br /> tags
39
+ $field['value'] = str_replace('<br />','',$field['value']);
40
+ echo '<textarea id="' . $field['name'] . '" rows="4" class="' . $field['class'] . '" name="' . $field['name'] . '" >' . $field['value'] . '</textarea>';
41
  }
42
 
43
 
44
  /*--------------------------------------------------------------------------------------
45
  *
46
+ * create_options
47
  *
48
  * @author Elliot Condon
49
  * @since 2.0.6
50
  *
51
  *-------------------------------------------------------------------------------------*/
52
 
53
+ function create_options($key, $field)
54
  {
55
+ // defaults
56
+ $field['default_value'] = isset($field['default_value']) ? $field['default_value'] : '';
57
+ $field['formatting'] = isset($field['formatting']) ? $field['formatting'] : 'br';
58
+
59
  ?>
60
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
61
  <td class="label">
62
  <label><?php _e("Default Value",'acf'); ?></label>
63
  </td>
64
  <td>
65
  <?php
66
+ $this->parent->create_field(array(
67
+ 'type' => 'textarea',
68
+ 'name' => 'fields['.$key.'][default_value]',
69
+ 'value' => $field['default_value'],
70
+ ));
71
+ ?>
72
+ </td>
73
+ </tr>
74
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
75
+ <td class="label">
76
+ <label><?php _e("Formatting",'acf'); ?></label>
77
+ <p class="description"><?php _e("Define how to render html tags / new lines",'acf'); ?></p>
78
+ </td>
79
+ <td>
80
+ <?php
81
+ $this->parent->create_field(array(
82
+ 'type' => 'select',
83
+ 'name' => 'fields['.$key.'][formatting]',
84
+ 'value' => $field['formatting'],
85
+ 'choices' => array(
86
+ 'none' => 'None',
87
+ 'br' => 'auto &lt;br /&gt;',
88
+ 'html' => 'HTML',
89
+ )
90
+ ));
91
  ?>
92
  </td>
93
  </tr>
94
  <?php
95
  }
96
 
 
 
 
 
 
97
 
98
+ /*--------------------------------------------------------------------------------------
99
+ *
100
+ * get_value_for_api
101
+ *
102
+ * @author Elliot Condon
103
+ * @since 3.0.0
104
+ *
105
+ *-------------------------------------------------------------------------------------*/
106
+
107
+ function get_value_for_api($post_id, $field)
108
  {
109
+ // vars
110
+ $format = isset($field['formatting']) ? $field['formatting'] : 'br';
111
+
112
+ $value = parent::get_value($post_id, $field);
113
+
114
+ if($format == 'none')
115
+ {
116
+ $value = htmlspecialchars($value, ENT_QUOTES);
117
+ }
118
+ elseif($format == 'html')
119
+ {
120
+ $value = html_entity_decode($value);
121
+ }
122
+ elseif($format == 'br')
123
+ {
124
+ $value = htmlspecialchars($value, ENT_QUOTES);
125
+ $value = nl2br($value);
126
+ }
127
+
128
  return $value;
129
  }
130
  }
core/fields/true_false.php CHANGED
@@ -1,74 +1,81 @@
1
  <?php
2
 
3
- class acf_True_false
4
  {
5
- var $name;
6
- var $title;
7
 
8
- function acf_True_false()
 
 
 
 
 
 
 
 
 
 
9
  {
10
- $this->name = 'true_false';
 
 
11
  $this->title = __("True / False",'acf');
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
- function html($field)
15
  {
16
- // set default message
17
- if(empty($field->options['message']))
18
- {
19
- $field->options['message'] = "";
20
- }
21
-
22
- // set choices
23
- $field->options['choices'] = array(
24
- '1' => $field->options['message']
25
- );
26
-
27
- // echo html
28
- echo '<ul class="checkbox_list '.$field->input_class.'">';
29
 
30
- foreach($field->options['choices'] as $key => $value)
31
- {
32
- $selected = '';
33
- if($key == $field->value)
34
- {
35
- $selected = 'checked="yes"';
36
- }
37
- echo '<li><label><input type="checkbox" class="'.$field->input_class.'" name="'.$field->input_name.'" value="'.$key.'" '.$selected.' />'.$value.'</label></li>';
38
- }
39
 
40
  echo '</ul>';
41
 
42
  }
43
 
44
 
45
- /*---------------------------------------------------------------------------------------------
46
- * Options HTML
47
- * - called from fields_meta_box.php
48
- * - displays options in html format
49
- *
50
- * @author Elliot Condon
51
- * @since 1.1
52
- *
53
- ---------------------------------------------------------------------------------------------*/
54
- function options_html($key, $field)
55
- {
56
- $options = $field->options;
57
-
58
- if(!isset($options['message']))
59
- {
60
- $options['message'] = "";
61
- }
62
  ?>
63
-
64
- <tr class="field_option field_option_true_false">
65
  <td class="label">
66
- <label for="acf[fields][<?php echo $key; ?>][options][message]"><?php _e("Message",'acf'); ?></label>
67
  <p class="description"><?php _e("eg. Show extra content",'acf'); ?></a></p>
68
  </td>
69
  <td>
70
- <input type="text" name="acf[fields][<?php echo $key; ?>][options][message]" id="acf[fields][<?php echo $key; ?>][options][message]" value="<?php echo $options['message']; ?>" />
71
-
 
 
 
 
 
72
  </td>
73
  </tr>
74
 
@@ -76,30 +83,20 @@ class acf_True_false
76
  }
77
 
78
 
79
- /*---------------------------------------------------------------------------------------------
80
- * Format Value
81
- * - this is called from api.php
82
- *
83
- * @author Elliot Condon
84
- * @since 1.1
85
- *
86
- ---------------------------------------------------------------------------------------------*/
87
- function format_value_for_api($value, $options = null)
88
- {
89
- return $this->format_value_for_input($value);
90
- }
91
-
92
 
93
- /*---------------------------------------------------------------------------------------------
94
- * Format Value for input
95
- * - this is called from api.php
96
- *
97
- * @author Elliot Condon
98
- * @since 1.1
99
- *
100
- ---------------------------------------------------------------------------------------------*/
101
- function format_value_for_input($value)
102
  {
 
 
 
103
  if($value == '1')
104
  {
105
  return true;
@@ -109,8 +106,7 @@ class acf_True_false
109
  return false;
110
  }
111
  }
112
-
113
-
114
  }
115
 
116
  ?>
1
  <?php
2
 
3
+ class acf_True_false extends acf_Field
4
  {
 
 
5
 
6
+ /*--------------------------------------------------------------------------------------
7
+ *
8
+ * Constructor
9
+ *
10
+ * @author Elliot Condon
11
+ * @since 1.0.0
12
+ * @updated 2.2.0
13
+ *
14
+ *-------------------------------------------------------------------------------------*/
15
+
16
+ function __construct($parent)
17
  {
18
+ parent::__construct($parent);
19
+
20
+ $this->name = 'true_false';
21
  $this->title = __("True / False",'acf');
22
+
23
+ }
24
+
25
+
26
+ /*--------------------------------------------------------------------------------------
27
+ *
28
+ * create_field
29
+ *
30
+ * @author Elliot Condon
31
+ * @since 2.0.5
32
+ * @updated 2.2.0
33
+ *
34
+ *-------------------------------------------------------------------------------------*/
35
 
36
+ function create_field($field)
37
  {
38
+ // vars
39
+ $field['message'] = isset($field['message']) ? $field['message'] : '';
 
 
 
 
 
 
 
 
 
 
 
40
 
41
+ // html
42
+ echo '<ul class="checkbox_list ' . $field['class'] . '">';
43
+ echo '<input type="hidden" name="'.$field['name'].'" value="0" />';
44
+ $selected = ($field['value'] == 1) ? 'checked="yes"' : '';
45
+ echo '<li><label><input type="checkbox" name="'.$field['name'].'" value="1" ' . $selected . ' />' . $field['message'] . '</label></li>';
 
 
 
 
46
 
47
  echo '</ul>';
48
 
49
  }
50
 
51
 
52
+ /*--------------------------------------------------------------------------------------
53
+ *
54
+ * create_options
55
+ *
56
+ * @author Elliot Condon
57
+ * @since 2.0.6
58
+ * @updated 2.2.0
59
+ *
60
+ *-------------------------------------------------------------------------------------*/
61
+
62
+ function create_options($key, $field)
63
+ {
64
+ $field['message'] = isset($field['message']) ? $field['message'] : '';
 
 
 
 
65
  ?>
66
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
 
67
  <td class="label">
68
+ <label><?php _e("Message",'acf'); ?></label>
69
  <p class="description"><?php _e("eg. Show extra content",'acf'); ?></a></p>
70
  </td>
71
  <td>
72
+ <?php
73
+ $this->parent->create_field(array(
74
+ 'type' => 'text',
75
+ 'name' => 'fields['.$key.'][message]',
76
+ 'value' => $field['message'],
77
+ ));
78
+ ?>
79
  </td>
80
  </tr>
81
 
83
  }
84
 
85
 
86
+ /*--------------------------------------------------------------------------------------
87
+ *
88
+ * get_value_for_api
89
+ *
90
+ * @author Elliot Condon
91
+ * @since 3.0.0
92
+ *
93
+ *-------------------------------------------------------------------------------------*/
 
 
 
 
 
94
 
95
+ function get_value_for_api($post_id, $field)
 
 
 
 
 
 
 
 
96
  {
97
+ // get value
98
+ $value = parent::get_value($post_id, $field);
99
+
100
  if($value == '1')
101
  {
102
  return true;
106
  return false;
107
  }
108
  }
109
+
 
110
  }
111
 
112
  ?>
core/fields/wysiwyg.php CHANGED
@@ -1,36 +1,312 @@
1
  <?php
2
 
3
- class acf_Wysiwyg
4
  {
5
- var $name;
6
- var $title;
7
 
8
- function acf_Wysiwyg()
 
 
 
 
 
 
 
 
 
 
9
  {
10
- $this->name = 'wysiwyg';
 
 
11
  $this->title = __("Wysiwyg Editor",'acf');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  }
13
 
14
- function html($field)
15
  {
16
- echo '<div class="acf_wysiwyg">';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  ?>
18
- <div id="editor-toolbar" style="display:none;">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
- <div id="media-buttons">
21
- Upload/Insert <a title="Add an Image" class="thickbox" id="add_image" href="media-upload.php?post_id=1802&amp;type=image&amp;TB_iframe=1&amp;width=640&amp;height=314"><img onclick="return false;" alt="Add an Image" src="http://localhost:8888/acf/wp-admin/images/media-button-image.gif?ver=20100531"></a><a title="Add Video" class="thickbox" id="add_video" href="media-upload.php?post_id=1802&amp;type=video&amp;TB_iframe=1&amp;width=640&amp;height=314"><img onclick="return false;" alt="Add Video" src="http://localhost:8888/acf/wp-admin/images/media-button-video.gif?ver=20100531"></a><a title="Add Audio" class="thickbox" id="add_audio" href="media-upload.php?post_id=1802&amp;type=audio&amp;TB_iframe=1&amp;width=640&amp;height=314"><img onclick="return false;" alt="Add Audio" src="http://localhost:8888/acf/wp-admin/images/media-button-music.gif?ver=20100531"></a><a title="Add Media" class="thickbox" id="add_media" href="media-upload.php?post_id=1802&amp;TB_iframe=1&amp;width=640&amp;height=314"><img onclick="return false;" alt="Add Media" src="http://localhost:8888/acf/wp-admin/images/media-button-other.gif?ver=20100531"></a> </div>
22
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  <?php
24
- echo '<div id="editorcontainer"><textarea name="'.$field->input_name.'" >';
25
- echo wp_richedit_pre($field->value);
26
- echo '</textarea></div></div>';
27
  }
28
 
29
- function format_value_for_api($value, $options = null)
 
 
 
 
 
 
 
 
 
 
30
  {
 
 
 
31
  $value = apply_filters('the_content',$value);
 
32
  return $value;
33
  }
 
 
34
  }
35
 
36
  ?>
1
  <?php
2
 
3
+ class acf_Wysiwyg extends acf_Field
4
  {
 
 
5
 
6
+ /*--------------------------------------------------------------------------------------
7
+ *
8
+ * Constructor
9
+ *
10
+ * @author Elliot Condon
11
+ * @since 1.0.0
12
+ * @updated 2.2.0
13
+ *
14
+ *-------------------------------------------------------------------------------------*/
15
+
16
+ function __construct($parent)
17
  {
18
+ parent::__construct($parent);
19
+
20
+ $this->name = 'wysiwyg';
21
  $this->title = __("Wysiwyg Editor",'acf');
22
+
23
+ }
24
+
25
+
26
+ /*--------------------------------------------------------------------------------------
27
+ *
28
+ * admin_print_scripts / admin_print_styles
29
+ *
30
+ * @author Elliot Condon
31
+ * @since 3.0.0
32
+ *
33
+ *-------------------------------------------------------------------------------------*/
34
+
35
+ function admin_print_scripts()
36
+ {
37
+ wp_enqueue_script(array(
38
+
39
+ 'jquery',
40
+ 'jquery-ui-core',
41
+ 'jquery-ui-tabs',
42
+
43
+ // wysiwyg
44
+ 'editor',
45
+ 'thickbox',
46
+ 'media-upload',
47
+ 'word-count',
48
+ 'post',
49
+ 'editor-functions',
50
+ 'tiny_mce',
51
+
52
+ ));
53
  }
54
 
55
+ function admin_print_styles()
56
  {
57
+ wp_enqueue_style(array(
58
+ 'thickbox',
59
+ ));
60
+ }
61
+
62
+
63
+ /*--------------------------------------------------------------------------------------
64
+ *
65
+ * admin_head
66
+ *
67
+ * @author Elliot Condon
68
+ * @since 2.0.6
69
+ *
70
+ *-------------------------------------------------------------------------------------*/
71
+
72
+ function admin_head()
73
+ {
74
+ ?>
75
+ <script type="text/javascript">
76
+ (function($){
77
+
78
+ $.fn.setup_wysiwyg = function(){
79
+
80
+ // tinymce must exist
81
+ if(!typeof(tinyMCE) == "object")
82
+ {
83
+ return false;
84
+ }
85
+
86
+ // vars
87
+ var orig_row_1 = tinyMCE.settings.theme_advanced_buttons1;
88
+ var orig_row_2 = tinyMCE.settings.theme_advanced_buttons2;
89
+
90
+ // add tinymce to all wysiwyg fields
91
+ $(this).find('.acf_wysiwyg textarea').each(function(){
92
+
93
+ // if this is a repeater clone field, don't set it up!
94
+ if(!$(this).closest('tr').hasClass('row_clone'))
95
+ {
96
+ var toolbar = $(this).closest('.acf_wysiwyg').attr('data-toolbar');
97
+
98
+ if(toolbar == 'basic')
99
+ {
100
+ tinyMCE.settings.theme_advanced_buttons1 = "bold,italic,formatselect,|,link,unlink,|,bullist,numlist,|,undo,redo";
101
+ tinyMCE.settings.theme_advanced_buttons2 = "";
102
+ }
103
+ else
104
+ {
105
+ // add images + code buttons
106
+ tinyMCE.settings.theme_advanced_buttons2 += ",code";
107
+ }
108
+ tinyMCE.execCommand('mceAddControl', false, $(this).attr('id'));
109
+ }
110
+
111
+ // restor rows
112
+ tinyMCE.settings.theme_advanced_buttons1 = orig_row_1;
113
+ tinyMCE.settings.theme_advanced_buttons2 = orig_row_2;
114
+
115
+ });
116
+
117
+
118
+
119
+ };
120
+
121
+
122
+ $(document).ready(function(){
123
+
124
+ $('#poststuff').setup_wysiwyg();
125
+
126
+ // create wysiwyg when you add a repeater row
127
+ $('.repeater #add_field').live('click', function(){
128
+ //alert('click');
129
+ var repeater = $(this).closest('.repeater');
130
+
131
+ // run after the repeater has added the row
132
+ setTimeout(function(){
133
+ repeater.children('table').children('tbody').children('tr:last-child').setup_wysiwyg();
134
+ }, 1);
135
+
136
+ });
137
+
138
+ });
139
+
140
+ // Sortable: Start
141
+ $('#poststuff .repeater > table > tbody').live( "sortstart", function(event, ui) {
142
+
143
+ $(ui.item).find('.acf_wysiwyg textarea').each(function(){
144
+ tinyMCE.execCommand("mceRemoveControl", false, $(this).attr('id'));
145
+ });
146
+
147
+ });
148
+
149
+ // Sortable: End
150
+ $('#poststuff .repeater > table > tbody').live( "sortstop", function(event, ui) {
151
+
152
+ $(ui.item).find('.acf_wysiwyg textarea').each(function(){
153
+ tinyMCE.execCommand("mceAddControl", false, $(this).attr('id'));
154
+ });
155
+
156
+ });
157
+
158
+
159
+ })(jQuery);
160
+ </script>
161
+ <style type="text/css">
162
+ .acf_wysiwyg iframe{
163
+ min-height: 250px;
164
+ }
165
+
166
+ #post-body .acf_wysiwyg .wp_themeSkin .mceStatusbar a.mceResize {
167
+ top: -2px !important;
168
+ }
169
+
170
+ .acf_wysiwyg .editor-toolbar {
171
+ display: none;
172
+ }
173
+
174
+ .acf_wysiwyg #editorcontainer {
175
+ background: #fff;
176
+ }
177
+ </style>
178
+ <?php
179
+ }
180
+
181
+
182
+ /*--------------------------------------------------------------------------------------
183
+ *
184
+ * create_options
185
+ *
186
+ * @author Elliot Condon
187
+ * @since 2.0.6
188
+ * @updated 2.2.0
189
+ *
190
+ *-------------------------------------------------------------------------------------*/
191
+
192
+ function create_options($key, $field)
193
+ {
194
+ // vars
195
+ $field['toolbar'] = isset($field['toolbar']) ? $field['toolbar'] : 'full';
196
+ $field['media_upload'] = isset($field['media_upload']) ? $field['media_upload'] : 'yes';
197
+
198
  ?>
199
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
200
+ <td class="label">
201
+ <label><?php _e("Toolbar",'acf'); ?></label>
202
+ </td>
203
+ <td>
204
+ <?php
205
+ $this->parent->create_field(array(
206
+ 'type' => 'radio',
207
+ 'name' => 'fields['.$key.'][toolbar]',
208
+ 'value' => $field['toolbar'],
209
+ 'layout' => 'horizontal',
210
+ 'choices' => array(
211
+ 'full' => 'Full',
212
+ 'basic' => 'Basic'
213
+ )
214
+ ));
215
+ ?>
216
+ </td>
217
+ </tr>
218
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
219
+ <td class="label">
220
+ <label><?php _e("Show Media Upload Buttons?",'acf'); ?></label>
221
+ </td>
222
+ <td>
223
+ <?php
224
+ $this->parent->create_field(array(
225
+ 'type' => 'radio',
226
+ 'name' => 'fields['.$key.'][media_upload]',
227
+ 'value' => $field['media_upload'],
228
+ 'layout' => 'horizontal',
229
+ 'choices' => array(
230
+ 'yes' => 'Yes',
231
+ 'no' => 'No',
232
+ )
233
+ ));
234
+ ?>
235
+ </td>
236
+ </tr>
237
+ <?php
238
+ }
239
+
240
+
241
+ /*--------------------------------------------------------------------------------------
242
+ *
243
+ * create_field
244
+ *
245
+ * @author Elliot Condon
246
+ * @since 2.0.5
247
+ * @updated 2.2.0
248
+ *
249
+ *-------------------------------------------------------------------------------------*/
250
+
251
+ function create_field($field)
252
+ {
253
+ // vars
254
+ $field['toolbar'] = isset($field['toolbar']) ? $field['toolbar'] : 'full';
255
+ $field['media_upload'] = isset($field['media_upload']) ? $field['media_upload'] : 'yes';
256
+
257
+ $id = 'wysiwyg_' . uniqid();
258
+
259
 
260
+ ?>
261
+ <div class="acf_wysiwyg" data-toolbar="<?php echo $field['toolbar']; ?>">
262
+ <?php if($field['media_upload'] == 'yes'): ?>
263
+ <div id="editor-toolbar" class="hide-if-no-js">
264
+ <div id="media-buttons" class="hide-if-no-js">
265
+ Upload/Insert
266
+ <a title="Add an Image" class="thickbox" id="add_image" href="media-upload.php?post_id=1802&amp;type=image&amp;TB_iframe=1&amp;width=640&amp;height=314">
267
+ <img onclick="return false;" alt="Add an Image" src="<?php echo $this->parent->wpadminurl ?>/images/media-button-image.gif?ver=20100531">
268
+ </a>
269
+ <a title="Add Video" class="thickbox" id="add_video" href="media-upload.php?post_id=1802&amp;type=video&amp;TB_iframe=1&amp;width=640&amp;height=314">
270
+ <img onclick="return false;" alt="Add Video" src="<?php echo $this->parent->wpadminurl ?>/images/media-button-video.gif?ver=20100531">
271
+ </a>
272
+ <a title="Add Audio" class="thickbox" id="add_audio" href="media-upload.php?post_id=1802&amp;type=audio&amp;TB_iframe=1&amp;width=640&amp;height=314">
273
+ <img onclick="return false;" alt="Add Audio" src="<?php echo $this->parent->wpadminurl ?>/images/media-button-music.gif?ver=20100531">
274
+ </a>
275
+ <a title="Add Media" class="thickbox" id="add_media" href="media-upload.php?post_id=1802&amp;TB_iframe=1&amp;width=640&amp;height=314">
276
+ <img onclick="return false;" alt="Add Media" src="<?php echo $this->parent->wpadminurl ?>/images/media-button-other.gif?ver=20100531">
277
+ </a>
278
+ </div>
279
+ </div>
280
+ <?php endif; ?>
281
+ <div id="editorcontainer">
282
+ <textarea id="<?php echo $field['name']; ?>" name="<?php echo $field['name']; ?>" ><?php echo wp_richedit_pre($field['value']); ?></textarea>
283
+ </div>
284
+ </div>
285
  <?php
286
+
 
 
287
  }
288
 
289
+
290
+ /*--------------------------------------------------------------------------------------
291
+ *
292
+ * get_value_for_api
293
+ *
294
+ * @author Elliot Condon
295
+ * @since 3.0.0
296
+ *
297
+ *-------------------------------------------------------------------------------------*/
298
+
299
+ function get_value_for_api($post_id, $field)
300
  {
301
+ // vars
302
+ $value = parent::get_value($post_id, $field);
303
+
304
  $value = apply_filters('the_content',$value);
305
+
306
  return $value;
307
  }
308
+
309
+
310
  }
311
 
312
  ?>
core/import.php DELETED
@@ -1,235 +0,0 @@
1
- <?php
2
-
3
- /*----------------------------------------------------------------------
4
- *
5
- * import
6
- *
7
- *---------------------------------------------------------------------*/
8
-
9
- require_once( ABSPATH . 'wp-admin/includes/import.php');
10
- require_once( ABSPATH . 'wp-admin/includes/file.php');
11
-
12
-
13
-
14
-
15
- // Checkpoint: Upload directory errors
16
- $upload_dir = wp_upload_dir();
17
- if (!empty($upload_dir['error']))
18
- {
19
- $this->admin_error($upload_dir['error']);
20
- return;
21
- }
22
-
23
-
24
- // get file
25
- $file = wp_import_handle_upload();
26
-
27
-
28
- // Checkpoint: File Error
29
- if(isset($file['error']))
30
- {
31
- $this->admin_error($file['error']);
32
- return;
33
- }
34
-
35
- // Checkpoint: File Type
36
- $pos = strpos($file['file'], '.xml');
37
- if($pos === false)
38
- {
39
- $this->admin_error('File uploaded is not a valid ACF export .xml file');
40
- return;
41
- }
42
-
43
-
44
- // Start Importing!
45
- $posts = simplexml_load_file($file['file']);
46
-
47
-
48
- // Checkpoint: Import File must not be empty
49
- if(!$posts)
50
- {
51
- $this->admin_error("Error: File is empty");
52
- return;
53
- }
54
-
55
-
56
- foreach($posts as $post)
57
- {
58
- $new_post = array(
59
- 'post_type' => 'acf',
60
- 'post_title' => $post->title,
61
- 'post_status' => $post->post_status,
62
- 'post_author' => get_current_user_id(),
63
- 'menu_order' => $post->menu_order,
64
- 'post_parent' => $post->post_parent,
65
- );
66
-
67
- $post_id = wp_insert_post( $new_post, false );
68
-
69
- $_POST = array(
70
- 'fields_meta_box' => 'true',
71
- 'location_meta_box' => 'true',
72
- 'options_meta_box' => 'true',
73
- 'ei_noncename' => wp_create_nonce('ei-n'),
74
- );
75
-
76
- if($post_id != 0)
77
- {
78
-
79
- if($post->fields[0]->children())
80
- {
81
- $i = -1;
82
-
83
- foreach($post->fields[0]->children() as $field)
84
- {
85
- $i++;
86
-
87
- $post_field = array(
88
- 'label' => isset($field->label) ? the_xml_value($field->label) : '',
89
- 'name' => isset($field->name) ? the_xml_value($field->name) : '',
90
- 'type' => isset($field->type) ? the_xml_value($field->type) : '',
91
- 'default_value' => isset($field->default_value) ? the_xml_value($field->default_value) : '',
92
- 'options' => array(),
93
- 'instructions' => isset($field->instructions) ? the_xml_value($field->instructions) : '',
94
- );
95
-
96
- if($field->options[0]->children())
97
- {
98
- foreach($field->options[0]->children() as $k => $v)
99
- {
100
- if($k == 'sub_fields')
101
- {
102
- $sub_fields = array();
103
- $j = -1;
104
-
105
- foreach($v->children() as $sub_field)
106
- {
107
- $j++;
108
-
109
- $post_sub_field = array(
110
- 'label' => isset($sub_field->label) ? the_xml_value($sub_field->label) : '',
111
- 'name' => isset($sub_field->name) ? the_xml_value($sub_field->name) : '',
112
- 'type' => isset($sub_field->type) ? the_xml_value($sub_field->type) : '',
113
- 'default_value' => isset($sub_field->default_value) ? the_xml_value($sub_field->default_value) : '',
114
- 'options' => array(),
115
- );
116
-
117
- if($sub_field->options[0]->children())
118
- {
119
- foreach($sub_field->options[0]->children() as $k2 => $v2)
120
- {
121
- $post_sub_field['options'][$k2] = the_xml_value($v2);
122
- }
123
- }
124
-
125
- $sub_fields[$j] = $post_sub_field;
126
- }
127
- // foreach($v->children() as $sub_field)
128
-
129
- $post_field[$k] = $sub_fields;
130
- }
131
- else
132
- {
133
- $post_field['options'][$k] = the_xml_value($v);
134
- }
135
- }
136
- // foreach($field->options[0]->children() as $k => $v)
137
-
138
- }
139
- // if($field->options[0]->children())
140
-
141
- $_POST['acf']['fields'][$i] = $post_field;
142
-
143
- }
144
- // foreach($post->fields[0]->children() as $field)
145
-
146
-
147
-
148
- }
149
- // if($post->fields[0]->children())
150
-
151
-
152
- // add location
153
- if($post->location[0]->children())
154
- {
155
- $i = -1;
156
-
157
- foreach($post->location[0]->rule as $rule)
158
- {
159
- $i++;
160
-
161
- $_POST['acf']['location']['rules'][$i] = array(
162
- 'param' => the_xml_value($rule->param),
163
- 'operator' => the_xml_value($rule->operator),
164
- 'value' => the_xml_value($rule->value),
165
- );
166
-
167
-
168
- }
169
-
170
- $_POST['acf']['location']['allorany'] = the_xml_value($post->location[0]->allorany);
171
- }
172
-
173
- // ad options
174
- if($post->options[0]->children())
175
- {
176
-
177
- foreach($post->options[0]->children() as $k => $v)
178
- {
179
-
180
- $_POST['acf']['options'][$k] = the_xml_value($v);
181
- }
182
-
183
- }
184
-
185
- $this->save_post($post_id);
186
- }
187
- // if($post_id != 0)
188
-
189
- unset($_POST);
190
-
191
- }
192
- // foreach($posts as $post)
193
-
194
-
195
- if(count($posts) == 1)
196
- {
197
- $this->admin_message('Imported 1 Advanced Custom Field Groups');
198
- }
199
- else
200
- {
201
- $this->admin_message('Imported '.count($posts).' Advanced Custom Field Groups');
202
- }
203
-
204
-
205
-
206
-
207
-
208
- function the_xml_value($value)
209
- {
210
- if(isset($value->array[0]))
211
- {
212
- $array = array();
213
- foreach($value->array[0]->children() as $v)
214
- {
215
- $att = $v->attributes();
216
- if(isset($att['key']))
217
- {
218
- $key = (string) $att['key'];
219
- $array[$key] = (string) $v;
220
- }
221
- else
222
- {
223
- $array[] = (string) $v;
224
- }
225
-
226
- }
227
- return $array;
228
- }
229
- else
230
- {
231
- return (string) $value;
232
- }
233
- }
234
-
235
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
core/options_page.php ADDED
@@ -0,0 +1,302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*--------------------------------------------------------------------------
4
+ *
5
+ * Acf_options_page
6
+ *
7
+ * @author Elliot Condon
8
+ * @since 2.0.4
9
+ *
10
+ *-------------------------------------------------------------------------*/
11
+
12
+
13
+ class Options_page
14
+ {
15
+
16
+ var $parent;
17
+ var $dir;
18
+
19
+ var $menu_name;
20
+ var $menu_heading;
21
+ var $data;
22
+
23
+ /*--------------------------------------------------------------------------------------
24
+ *
25
+ * Acf_options_page
26
+ *
27
+ * @author Elliot Condon
28
+ * @since 2.0.4
29
+ *
30
+ *-------------------------------------------------------------------------------------*/
31
+
32
+ function __construct($parent)
33
+ {
34
+ // vars
35
+ $this->parent = $parent;
36
+ $this->dir = $parent->dir;
37
+
38
+ // Customize the Labels here
39
+ $this->menu_name = __('acf_options','acf');
40
+ $this->menu_heading = __('Options','acf');
41
+
42
+ // data for passing variables
43
+ $this->data = array();
44
+
45
+ // actions
46
+ add_action('admin_menu', array($this,'admin_menu'));
47
+
48
+ }
49
+
50
+
51
+ /*--------------------------------------------------------------------------------------
52
+ *
53
+ * admin_menu
54
+ *
55
+ * @author Elliot Condon
56
+ * @since 2.0.4
57
+ *
58
+ *-------------------------------------------------------------------------------------*/
59
+
60
+ function admin_menu()
61
+ {
62
+ // validate
63
+ if(!$this->parent->is_field_unlocked('options_page'))
64
+ {
65
+ return true;
66
+ }
67
+
68
+ // add page
69
+ $options_page = add_menu_page($this->menu_heading, $this->menu_heading, 'edit_posts', 'acf-options',array($this, 'html'));
70
+
71
+
72
+ // some fields require js + css
73
+ add_action('admin_print_scripts-'.$options_page, array($this, 'admin_print_scripts'));
74
+ add_action('admin_print_styles-'.$options_page, array($this, 'admin_print_styles'));
75
+
76
+
77
+ // Add admin head
78
+ add_action('admin_head-'.$options_page, array($this,'admin_head'));
79
+ add_action('admin_footer-'.$options_page, array($this,'admin_footer'));
80
+
81
+ }
82
+
83
+
84
+ /*--------------------------------------------------------------------------------------
85
+ *
86
+ * admin_init
87
+ *
88
+ * @author Elliot Condon
89
+ * @since 2.0.4
90
+ *
91
+ *-------------------------------------------------------------------------------------*/
92
+
93
+ function admin_init()
94
+ {
95
+
96
+
97
+ }
98
+
99
+
100
+
101
+
102
+ /*--------------------------------------------------------------------------------------
103
+ *
104
+ * admin_head
105
+ *
106
+ * @author Elliot Condon
107
+ * @since 2.0.4
108
+ *
109
+ *-------------------------------------------------------------------------------------*/
110
+
111
+ function admin_head()
112
+ {
113
+ // save
114
+ if(isset($_POST['update_options']))
115
+ {
116
+ // post_id = 0 for options page
117
+ $post_id = 999999999;
118
+
119
+ // strip slashes
120
+ $_POST = array_map('stripslashes_deep', $_POST);
121
+
122
+ // save fields
123
+ $fields = isset($_POST['fields']) ? $_POST['fields'] : false;
124
+
125
+ if($fields)
126
+ {
127
+ foreach($fields as $key => $value)
128
+ {
129
+ // get field
130
+ $field = $this->parent->get_acf_field($key);
131
+
132
+ $this->parent->update_value($post_id, $field, $value);
133
+ }
134
+ }
135
+
136
+ $this->data['admin_message'] = 'Options Updated';
137
+
138
+ }
139
+
140
+ $include = $this->parent->get_input_metabox_ids(array('post_id' => 999999999), false);
141
+ if(empty($include))
142
+ {
143
+ $this->data['no_fields'] = true;
144
+ return false;
145
+ }
146
+
147
+ // create tyn mce instance for wysiwyg
148
+ wp_tiny_mce();
149
+
150
+ // add css + javascript
151
+ echo '<link rel="stylesheet" type="text/css" href="'.$this->parent->dir.'/css/global.css" />';
152
+ echo '<link rel="stylesheet" type="text/css" href="'.$this->parent->dir.'/css/input.css" />';
153
+ //echo '<script type="text/javascript" src="'.$this->parent->dir.'/js/input.js" ></script>';
154
+
155
+ // fields admin_head
156
+ foreach($this->parent->fields as $field)
157
+ {
158
+ $this->parent->fields[$field->name]->admin_head();
159
+ }
160
+
161
+ // get acf's
162
+ $acfs = get_pages(array(
163
+ 'numberposts' => -1,
164
+ 'post_type' => 'acf',
165
+ 'sort_column' => 'menu_order',
166
+ 'order' => 'ASC',
167
+ 'include' => $include
168
+ ));
169
+ if($acfs)
170
+ {
171
+ foreach($acfs as $acf)
172
+ {
173
+
174
+ // load
175
+ $options = $this->parent->get_acf_options($acf->ID);
176
+ $fields = $this->parent->get_acf_fields($acf->ID);
177
+
178
+ // add meta box
179
+ add_meta_box(
180
+ 'acf_' . $acf->ID,
181
+ $acf->post_title,
182
+ array($this->parent, 'meta_box_input'),
183
+ 'acf_options_page',
184
+ $options['position'],
185
+ 'high',
186
+ array( 'fields' => $fields )
187
+ );
188
+ }
189
+
190
+ }
191
+ }
192
+
193
+
194
+ /*--------------------------------------------------------------------------------------
195
+ *
196
+ * admin_footer
197
+ *
198
+ * @author Elliot Condon
199
+ * @since 2.0.4
200
+ *
201
+ *-------------------------------------------------------------------------------------*/
202
+ function admin_footer()
203
+ {
204
+ wp_preload_dialogs( array( 'plugins' => 'safari,inlinepopups,spellchecker,paste,wordpress,media,fullscreen,wpeditimage,wpgallery,tabfocus' ) );
205
+ }
206
+
207
+
208
+ /*---------------------------------------------------------------------------------------------
209
+ * admin_print_scripts / admin_print_styles
210
+ *
211
+ * @author Elliot Condon
212
+ * @since 2.0.4
213
+ *
214
+ ---------------------------------------------------------------------------------------------*/
215
+ function admin_print_scripts() {
216
+
217
+ foreach($this->parent->fields as $field)
218
+ {
219
+ $this->parent->fields[$field->name]->admin_print_scripts();
220
+ }
221
+
222
+ }
223
+
224
+ function admin_print_styles() {
225
+
226
+ foreach($this->parent->fields as $field)
227
+ {
228
+ $this->parent->fields[$field->name]->admin_print_styles();
229
+ }
230
+
231
+ }
232
+
233
+
234
+ /*--------------------------------------------------------------------------------------
235
+ *
236
+ * options_page
237
+ *
238
+ * @author Elliot Condon
239
+ * @since 2.0.4
240
+ *
241
+ *-------------------------------------------------------------------------------------*/
242
+ function html()
243
+ {
244
+ ?>
245
+ <div class="wrap no_move">
246
+
247
+ <div class="icon32" id="icon-options-general"><br></div>
248
+ <h2><?php echo $this->menu_heading; ?></h2>
249
+
250
+ <?php if(isset($this->data['admin_message'])): ?>
251
+ <div id="message" class="updated"><p><?php echo $this->data['admin_message']; ?></p></div>
252
+ <?php endif; ?>
253
+
254
+ <?php if(isset($this->data['no_fields'])): ?>
255
+ <div id="message" class="updated"><p>No Custom Field Group found for the options page. <a href="<?php echo admin_url(); ?>post-new.php?post_type=acf">Create a Custom Field Group</a></p></div>
256
+ <?php else: ?>
257
+
258
+ <form id="post" method="post" name="post">
259
+ <div class="metabox-holder has-right-sidebar" id="poststuff">
260
+
261
+ <!-- Sidebar -->
262
+ <div class="inner-sidebar" id="side-info-column">
263
+
264
+ <!-- Update -->
265
+ <div class="postbox">
266
+ <h3 class="hndle"><span><?php _e("Save",'acf'); ?></span></h3>
267
+ <div class="inside">
268
+ <input type="hidden" name="HTTP_REFERER" value="<?php echo $_SERVER['HTTP_REFERER'] ?>" />
269
+ <input type="submit" class="button-primary" value="Save Options" name="update_options" />
270
+ </div>
271
+ </div>
272
+
273
+ </div>
274
+
275
+ <!-- Main -->
276
+ <div id="post-body">
277
+ <div id="post-body-content">
278
+ <?php $meta_boxes = do_meta_boxes('acf_options_page', 'normal', null); ?>
279
+ <script type="text/javascript">
280
+ (function($){
281
+
282
+ $('#poststuff .postbox[id*="acf_"]').addClass('acf_postbox');
283
+
284
+ })(jQuery);
285
+ </script>
286
+ </div>
287
+ </div>
288
+
289
+ </div>
290
+ </form>
291
+
292
+ <?php endif; ?>
293
+
294
+ </div>
295
+
296
+ <?php
297
+
298
+ }
299
+
300
+ }
301
+
302
+ ?>
core/screen_extra.php DELETED
@@ -1,44 +0,0 @@
1
- <?php include('screen_extra_activate.php'); ?>
2
- <?php include('screen_extra_export.php'); ?>
3
-
4
- <?php
5
- // get current page
6
- $currentFile = $_SERVER["SCRIPT_NAME"];
7
- $parts = Explode('/', $currentFile);
8
- $currentFile = $parts[count($parts) - 1];
9
-
10
- if($currentFile == 'edit.php'):
11
- ?>
12
-
13
-
14
- <div class="acf_col_right hidden metabox-holder" id="poststuff" >
15
-
16
- <div class="postbox">
17
- <div class="handlediv"><br></div>
18
- <h3 class="hndle"><span><?php _e("Advanced Custom Fields v",'acf'); ?><?php echo $this->version; ?></span></h3>
19
- <div class="inside">
20
- <div class="field">
21
- <h4><?php _e("Changelog",'acf'); ?></h4>
22
- <p><?php _e("See what's new in",'acf'); ?> <a class="thickbox" href="<?php bloginfo('url'); ?>/wp-admin/plugin-install.php?tab=plugin-information&plugin=advanced-custom-fields&section=changelog&TB_iframe=true&width=640&height=559">v<?php echo $this->version; ?></a>
23
- </div>
24
- <div class="field">
25
- <h4><?php _e("Resources",'acf'); ?></h4>
26
- <p><?php _e("Watch tutorials, read documentation, learn the API code and find some tips &amp; tricks for your next web project.",'acf'); ?><br />
27
- <a href="http://plugins.elliotcondon.com/advanced-custom-fields/"><?php _e("View the plugins website",'acf'); ?></a></p>
28
- </div>
29
- <!-- <div class="field">
30
- <h4><?php _e("Support",'acf'); ?></h4>
31
- <p><?php _e("Join the growing community over at the support forum to share ideas, report bugs and keep up to date with ACF",'acf'); ?><br />
32
- <a href="http://support.plugins.elliotcondon.com/categories/advanced-custom-fields/"><?php _e("View the Support Forum",'acf'); ?></a></p>
33
- </div> -->
34
- <div class="field">
35
- <h4><?php _e("Developed by",'acf'); ?> Elliot Condon</h4>
36
- <p><a href="http://wordpress.org/extend/plugins/advanced-custom-fields/"><?php _e("Vote for ACF",'acf'); ?></a> | <a href="http://twitter.com/elliotcondon"><?php _e("Twitter",'acf'); ?></a> | <a href="http://blog.elliotcondon.com"><?php _e("Blog",'acf'); ?></a></p>
37
- </div>
38
-
39
-
40
- </div>
41
- </div>
42
- </div>
43
-
44
- <?php endif; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
core/screen_extra_activate.php DELETED
@@ -1,85 +0,0 @@
1
- <div id="screen-meta-activate-acf-wrap" class="screen-meta-wrap hidden acf">
2
- <div class="screen-meta-content">
3
-
4
- <h5><?php _e("Unlock Special Fields.",'acf'); ?></h5>
5
- <p><?php _e("Special Fields can be unlocked by purchasing an activation code. Each activation code can be used on multiple sites.",'acf'); ?> <a href="http://plugins.elliotcondon.com/shop/"><?php _e("Visit the Plugin Store",'acf'); ?></a></p>
6
- <table class="acf_activate widefat">
7
- <thead>
8
- <tr>
9
- <th><?php _e("Field Type",'acf'); ?></th>
10
- <th><?php _e("Status",'acf'); ?></th>
11
- <th><?php _e("Activation Code",'acf'); ?></th>
12
- </tr>
13
- </thead>
14
- <tbody>
15
- <?php
16
- /*--------------------------------------------------------------------------------------
17
- *
18
- * Repeater Field
19
- *
20
- *-------------------------------------------------------------------------------------*/
21
- ?>
22
- <tr>
23
- <td><?php _e("Repeater",'acf'); ?></td>
24
- <td><?php if(array_key_exists('repeater', $this->activated_fields)){
25
- _e("Active",'acf');
26
- }
27
- else
28
- {
29
- _e("Inactive",'acf');
30
- } ?></td>
31
- <td>
32
- <form action="" method="post">
33
- <?php if(array_key_exists('repeater', $this->activated_fields)){
34
- echo '<span class="activation_code">XXXX-XXXX-XXXX-'.substr($this->activated_fields['repeater'],-4) .'</span>';
35
- echo '<input type="hidden" name="acf_field_deactivate" value="repeater" />';
36
- echo '<input type="submit" class="button" value="Deactivate" />';
37
- }
38
- else
39
- {
40
- echo '<input type="text" name="acf_ac" value="" />';
41
- echo '<input type="hidden" name="acf_field_activate" value="repeater" />';
42
- echo '<input type="submit" class="button" value="Activate" />';
43
- } ?>
44
- </form>
45
- </td>
46
- </tr>
47
- <?php
48
- /*--------------------------------------------------------------------------------------
49
- *
50
- * Options Page
51
- *
52
- *-------------------------------------------------------------------------------------*/
53
- ?>
54
- <tr>
55
- <td><?php _e("Options Page",'acf'); ?></td>
56
- <td><?php if(array_key_exists('options_page', $this->activated_fields)){
57
- _e("Active",'acf');
58
- }
59
- else
60
- {
61
- _e("Inactive",'acf');
62
- } ?></td>
63
- <td>
64
- <form action="" method="post">
65
- <?php if(array_key_exists('options_page', $this->activated_fields)){
66
- echo '<span class="activation_code">XXXX-XXXX-XXXX-'.substr($this->activated_fields['options_page'],-4) .'</span>';
67
- echo '<input type="hidden" name="acf_field_deactivate" value="options_page" />';
68
- echo '<input type="submit" class="button" value="Deactivate" />';
69
- }
70
- else
71
- {
72
- echo '<input type="text" name="acf_ac" value="" />';
73
- echo '<input type="hidden" name="acf_field_activate" value="options_page" />';
74
- echo '<input type="submit" class="button" value="Activate" />';
75
- } ?>
76
- </form>
77
- </td>
78
- </tr>
79
- </tbody>
80
- </table>
81
- </div>
82
- </div>
83
- <div id="screen-meta-activate-acf-link-wrap" class="hide-if-no-js screen-meta-toggle acf">
84
- <a href="#screen-meta-activate-acf" id="screen-meta-activate-acf-link" class="show-settings"><?php _e("Unlock Fields",'acf'); ?></a>
85
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
core/screen_extra_export.php DELETED
@@ -1,54 +0,0 @@
1
- <div id="screen-meta-export-acf-wrap" class="screen-meta-wrap hidden acf">
2
- <div class="screen-meta-content">
3
- <form enctype="multipart/form-data" method="post" >
4
- <h5><?php _e("Import",'acf'); ?></h5>
5
-
6
- <p><?php _e("Have an ACF export file? Import it here.",'acf'); ?></p>
7
-
8
- <input type="file" id="file" name="import" />
9
- <input type="submit" class="button" name="acf_import" value="Import" />
10
-
11
-
12
- <p><br /></p>
13
- <h5><?php _e("Export",'acf'); ?></h5>
14
- <p><?php _e("Want to create an ACF export file? Just select the desired ACF's and hit Export",'acf'); ?></p>
15
-
16
- <?php
17
-
18
- $acfs = get_pages(array(
19
- 'numberposts' => -1,
20
- 'post_type' => 'acf',
21
- 'sort_column' => 'menu_order',
22
- ));
23
-
24
- // blank array to hold acfs
25
- $acf_objects = array();
26
-
27
- if($acfs)
28
- {
29
- foreach($acfs as $acf)
30
- {
31
- $acf_objects[$acf->ID] = $acf->post_title;
32
- }
33
- }
34
-
35
- $temp_field = new stdClass();
36
-
37
- $temp_field->type = 'select';
38
- $temp_field->input_name = 'acf_objects';
39
- $temp_field->input_class = '';
40
- $temp_field->value = '';
41
- $temp_field->options = array('choices' => $acf_objects, 'multiple' => 1);
42
-
43
- $this->create_field($temp_field);
44
-
45
- ?>
46
- <input type="submit" name="acf_export" value="Export" />
47
-
48
- </form>
49
-
50
- </div>
51
- </div>
52
- <div id="screen-meta-export-acf-link-wrap" class="hide-if-no-js screen-meta-toggle acf">
53
- <a href="#screen-meta-export-acf" id="screen-meta-export-acf-link" class="show-settings"><?php _e("Import / Export",'acf'); ?></a>
54
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
core/third_party.php DELETED
@@ -1,166 +0,0 @@
1
- <?php
2
-
3
- /*--------------------------------------------------------------------------------------
4
- *
5
- * Integrate with Duplicate Posts plugin
6
- *
7
- * @author unknownnf - thanks mate
8
- * @since 2.0.6
9
- *
10
- *-------------------------------------------------------------------------------------*/
11
- function acf_duplicate($newId, $post)
12
- {
13
- // global
14
- global $wpdb;
15
-
16
- // tables
17
- $acf_fields = $wpdb->prefix.'acf_fields';
18
- $acf_values = $wpdb->prefix.'acf_values';
19
- $acf_rules = $wpdb->prefix.'acf_rules';
20
- $wp_postmeta = $wpdb->prefix.'postmeta';
21
-
22
- if($post->post_type == 'acf')
23
- {
24
-
25
- // save fields
26
- $sql = "SELECT *
27
- FROM $acf_fields
28
- WHERE post_id = '$post->ID'
29
- ORDER BY parent_id ASC";
30
-
31
- $rows = $wpdb->get_results($sql);
32
-
33
- if($rows)
34
- {
35
- $repeater_fields = array();
36
-
37
- foreach ($rows as $row) {
38
-
39
- // save postmeta
40
- $data = array(
41
- 'post_id' => $newId,
42
- 'label' => $row->label,
43
- 'name' => $row->name,
44
- 'type' => $row->type,
45
- 'parent_id' => $row->parent_id,
46
- 'options' => $row->options,
47
- 'order_no' => $row->order_no,
48
- 'instructions' => $row->instructions,
49
- 'default_value' => $row->default_value,
50
- );
51
-
52
- // override parent_id
53
- if( (int) $row->parent_id != 0 )
54
- {
55
- $data['parent_id'] = (int) $repeater_fields[$row->parent_id];
56
- }
57
-
58
- // insert
59
- $wpdb->insert($acf_fields, $data);
60
-
61
- // update repeater id
62
- if($row->type == 'repeater')
63
- {
64
- $repeater_fields[$row->id] = $wpdb->insert_id;
65
- }
66
-
67
- }
68
-
69
- }
70
-
71
- // save rules
72
- $sql = "SELECT *
73
- FROM $acf_rules
74
- WHERE acf_id = '$post->ID'";
75
-
76
- $rows = $wpdb->get_results($sql);
77
-
78
- if($rows)
79
- {
80
- foreach ($rows as $row) {
81
-
82
- // save postmeta
83
- $data = array(
84
- 'acf_id' => $newId,
85
- 'param' => $row->param,
86
- 'operator' => $row->operator,
87
- 'value' => $row->value,
88
- 'order_no' => $row->order_no,
89
- );
90
-
91
- $wpdb->insert($acf_rules, $data);
92
-
93
- }
94
- }
95
-
96
- }
97
- else
98
- {
99
-
100
- // deletes duplicated acf postmeta
101
- $sql = "SELECT f.name
102
- FROM $wp_postmeta m
103
- LEFT JOIN $acf_values v ON m.meta_id = v.value
104
- LEFT JOIN $acf_fields f ON v.field_id = f.id
105
- WHERE m.post_id = '$post->ID' AND f.name != 'NULL'";
106
-
107
- $results = $wpdb->get_results($sql);
108
-
109
- if($results)
110
- {
111
- foreach($results as $result)
112
- {
113
- $wpdb->query("DELETE FROM $wp_postmeta WHERE meta_key = '$result->name' AND post_id = '$newId'");
114
- }
115
- }
116
-
117
-
118
- // duplicate postmen + values
119
- $sql = "SELECT m.meta_key, m.meta_value, v.value, v.field_id, v.sub_field_id, v.order_no
120
- FROM $wp_postmeta m
121
- LEFT JOIN $acf_values v ON m.meta_id = v.value
122
- LEFT JOIN $acf_fields f ON v.field_id = f.id
123
- WHERE m.post_id = '$post->ID' AND f.name != 'NULL'";
124
-
125
- $rows = $wpdb->get_results($sql);
126
- if($rows)
127
- {
128
-
129
- foreach ($rows as $row) {
130
-
131
- // save postmeta
132
- $data = array(
133
- 'post_id' => $newId,
134
- 'meta_key' => $row->meta_key,
135
- 'meta_value' => $row->meta_value,
136
- );
137
-
138
- $wpdb->insert($wp_postmeta, $data);
139
-
140
- $new_value_id = $wpdb->insert_id;
141
-
142
- if($new_value_id && $new_value_id != 0)
143
- {
144
- // create data object to save
145
- $data2 = array(
146
- 'post_id' => $newId,
147
- 'order_no' => $row->order_no,
148
- 'field_id' => $row->field_id,
149
- 'sub_field_id' => $row->sub_field_id,
150
- 'value' => $new_value_id,
151
- );
152
-
153
- $wpdb->insert($acf_values, $data2);
154
- }
155
-
156
- }
157
- }
158
-
159
- }
160
-
161
- }
162
-
163
- add_action('dp_duplicate_page', 'acf_duplicate', 10, 2);
164
- add_action('dp_duplicate_post', 'acf_duplicate', 10, 2);
165
-
166
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
core/upgrade.php DELETED
@@ -1,248 +0,0 @@
1
- <?php
2
-
3
- /*--------------------------------------------------------------------------------------
4
- *
5
- * Update - run on update
6
- *
7
- * @author Elliot Condon
8
- * @since 1.0.6
9
- *
10
- *-------------------------------------------------------------------------------------*/
11
-
12
- require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
13
- global $wpdb;
14
-
15
-
16
- // tables
17
- $acf_fields = $wpdb->prefix.'acf_fields';
18
- $acf_values = $wpdb->prefix.'acf_values';
19
- $acf_rules = $wpdb->prefix.'acf_rules';
20
- $wp_postmeta = $wpdb->prefix.'postmeta';
21
-
22
- // get current version
23
- $version = get_option('acf_version','1.0.5');
24
- $acf_update_msg = false;
25
-
26
-
27
- /*--------------------------------------------------------------------------------------
28
- *
29
- * 1.1.0
30
- *
31
- *-------------------------------------------------------------------------------------*/
32
-
33
- if(version_compare($version,'1.1.0') < 0)
34
- {
35
-
36
-
37
- // create acf_fields table
38
- $sql = "CREATE TABLE " . $acf_fields . " (
39
- id bigint(20) NOT NULL AUTO_INCREMENT,
40
- order_no int(9) NOT NULL DEFAULT '0',
41
- post_id bigint(20) NOT NULL DEFAULT '0',
42
- parent_id bigint(20) NOT NULL DEFAULT '0',
43
- label text NOT NULL,
44
- name text NOT NULL,
45
- instructions text NOT NULL,
46
- default_value text NOT NULL,
47
- type text NOT NULL,
48
- options text NOT NULL,
49
- UNIQUE KEY id (id)
50
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
51
- dbDelta($sql);
52
-
53
-
54
- // create acf_values table
55
- $sql = "CREATE TABLE " . $acf_values . " (
56
- id bigint(20) NOT NULL AUTO_INCREMENT,
57
- post_id bigint(20) NOT NULL DEFAULT '0',
58
- order_no int(9) NOT NULL DEFAULT '0',
59
- field_id bigint(20) NOT NULL DEFAULT '0',
60
- sub_field_id bigint(20) NOT NULL DEFAULT '0',
61
- value bigint(20) NOT NULL DEFAULT '0',
62
- UNIQUE KEY id (id)
63
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
64
- dbDelta($sql);
65
-
66
-
67
- // create acf_rules table
68
- $sql = "CREATE TABLE " . $acf_rules . " (
69
- id bigint(20) NOT NULL AUTO_INCREMENT,
70
- acf_id bigint(20) NOT NULL DEFAULT '0',
71
- order_no int(9) NOT NULL DEFAULT '0',
72
- param text NOT NULL,
73
- operator text NOT NULL,
74
- value text NOT NULL,
75
- UNIQUE KEY id (id)
76
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
77
- dbDelta($sql);
78
-
79
-
80
-
81
- update_option('acf_version','1.1.0');
82
- $version = '1.1.0';
83
- }
84
-
85
-
86
- /*--------------------------------------------------------------------------------------
87
- *
88
- * 2.1.0
89
- *
90
- *-------------------------------------------------------------------------------------*/
91
-
92
- if(version_compare($version,'2.1.0') < 0)
93
- {
94
-
95
- // add default_value to fields table
96
- $sql = "CREATE TABLE " . $acf_fields . " (
97
- id bigint(20) NOT NULL AUTO_INCREMENT,
98
- order_no int(9) NOT NULL DEFAULT '0',
99
- post_id bigint(20) NOT NULL DEFAULT '0',
100
- parent_id bigint(20) NOT NULL DEFAULT '0',
101
- label text NOT NULL,
102
- name text NOT NULL,
103
- instructions text NOT NULL,
104
- default_value text NOT NULL,
105
- type text NOT NULL,
106
- options text NOT NULL,
107
- UNIQUE KEY id (id)
108
- ) DEFAULT CHARSET=utf8;";
109
- dbDelta($sql);
110
-
111
-
112
- // images and files are all now saved as id's
113
- $fields = $wpdb->get_results("SELECT id FROM $acf_fields WHERE type = 'image' OR type = 'file'");
114
- $postmeta = $wpdb->prefix.'postmeta';
115
-
116
- if($fields)
117
- {
118
- foreach($fields as $field)
119
- {
120
- $values = $wpdb->get_results("SELECT id,value FROM $acf_values WHERE field_id = '$field->id'");
121
- if($values)
122
- {
123
- foreach($values as $value)
124
- {
125
- if(!empty($value->value) && !is_numeric($value->value))
126
- {
127
- $find_value = str_replace(get_bloginfo('url') . '/wp-content/uploads/', '', $value->value);
128
- $attachment_id = $wpdb->get_var("SELECT post_id FROM $postmeta WHERE meta_value = '$find_value'");
129
-
130
- // update value
131
- $wpdb->query("UPDATE $acf_values SET value = '$attachment_id' WHERE id = '$value->id'");
132
- }
133
- }
134
- }
135
- }
136
- }
137
-
138
-
139
- // values are now stored as custom fields
140
- $values = $wpdb->get_results("SELECT v.id, v.value, v.post_id, f.name FROM $acf_values v LEFT JOIN $acf_fields f ON v.field_id = f.id ORDER BY v.id ASC");
141
- if($values)
142
- {
143
- foreach($values as $value)
144
- {
145
- if($value->value == ""){continue;}
146
-
147
- $data = array(
148
- 'post_id' => $value->post_id,
149
- 'meta_key' => $value->name,
150
- 'meta_value' => $value->value,
151
- );
152
-
153
- $wpdb->insert($wp_postmeta, $data);
154
-
155
- $new_id = $wpdb->insert_id;
156
-
157
- if($new_id && $new_id != 0)
158
- {
159
- $wpdb->query("UPDATE $acf_values SET value = '$new_id' WHERE id = '$value->id'");
160
- }
161
-
162
-
163
- }
164
- }
165
-
166
-
167
- // value is now an int
168
- $sql = "CREATE TABLE " . $acf_values . " (
169
- id bigint(20) NOT NULL AUTO_INCREMENT,
170
- post_id bigint(20) NOT NULL DEFAULT '0',
171
- order_no int(9) NOT NULL DEFAULT '0',
172
- field_id bigint(20) NOT NULL DEFAULT '0',
173
- sub_field_id bigint(20) NOT NULL DEFAULT '0',
174
- value bigint(20) NOT NULL DEFAULT '0',
175
- UNIQUE KEY id (id)
176
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
177
- dbDelta($sql);
178
-
179
-
180
- // now set sub_field_if values
181
- $values = $wpdb->get_results("SELECT v.id, f.id as sub_field_id, f.parent_id as field_id FROM $acf_values v LEFT JOIN $acf_fields f ON v.field_id = f.id WHERE f.parent_id != '0' ORDER BY v.id ASC");
182
- if($values)
183
- {
184
- foreach($values as $value)
185
- {
186
- $wpdb->query("UPDATE $acf_values SET field_id = '$value->field_id', sub_field_id = '$value->sub_field_id' WHERE id = '$value->id'");
187
- }
188
- }
189
-
190
-
191
- // set version
192
- update_option('acf_version','2.0.6');
193
- $version = '2.0.6';
194
-
195
- }
196
-
197
-
198
- /*--------------------------------------------------------------------------------------
199
- *
200
- * 2.1.4
201
- *
202
- *-------------------------------------------------------------------------------------*/
203
-
204
- if(version_compare($version,'2.1.4') < 0)
205
- {
206
-
207
- // add back in post_id to values table (useful for duplicate posts / third party stuff)
208
- $sql = "CREATE TABLE " . $acf_values . " (
209
- id bigint(20) NOT NULL AUTO_INCREMENT,
210
- post_id bigint(20) NOT NULL DEFAULT '0',
211
- order_no int(9) NOT NULL DEFAULT '0',
212
- field_id bigint(20) NOT NULL DEFAULT '0',
213
- sub_field_id bigint(20) NOT NULL DEFAULT '0',
214
- value bigint(20) NOT NULL DEFAULT '0',
215
- UNIQUE KEY id (id)
216
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
217
- dbDelta($sql);
218
-
219
-
220
- // copy across post_id
221
- $sql2 = "SELECT m.post_id, v.id
222
- FROM $wp_postmeta m
223
- LEFT JOIN $acf_values v ON m.meta_id = v.value";
224
-
225
- $values = $wpdb->get_results($sql2);
226
- if($values)
227
- {
228
- foreach($values as $value)
229
- {
230
- $wpdb->query("UPDATE $acf_values SET post_id = '$value->post_id' WHERE id = '$value->id'");
231
- }
232
- }
233
-
234
- // set version
235
- update_option('acf_version','2.1.4');
236
- $version = '2.1.4';
237
- }
238
- /*--------------------------------------------------------------------------------------
239
- *
240
- * Finish
241
- *
242
- *-------------------------------------------------------------------------------------*/
243
-
244
- $this->admin_message('Advanced Custom Fields successfully upgraded to ' . $this->version . '! <a href="' . get_bloginfo('url') . '/wp-admin/plugin-install.php?tab=plugin-information&plugin=advanced-custom-fields&section=changelog&TB_iframe=true&width=640&height=559" class="thickbox">See what\'s new</a>');
245
-
246
- update_option('acf_version',$this->version);
247
-
248
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
css/{style.screen_extra.css → acf.css} RENAMED
@@ -86,11 +86,13 @@
86
  background-color: #F9F9F9;
87
  border: #DFDFDF solid 1px;
88
  border-top: 0 none;
89
- margin: 0 15px;
90
  padding: 8px 12px 12px;
91
  border-radius: 0 0 4px 4px;
92
  }
93
 
 
 
94
  .screen-meta-wrap p {
95
  margin-top: 0px;
96
  }
@@ -131,21 +133,16 @@ table.acf_activate tr td:last-child {
131
  border-right: 0 none;
132
  }
133
 
 
 
 
 
 
134
  table.acf_activate input[type="submit"] {
135
  margin-left: 5px;
136
  margin-right: 5px;
137
  }
138
 
139
-
140
- /*--------------------------------------------------------------------------------------------
141
- Import / Export
142
- --------------------------------------------------------------------------------------------*/
143
- #wpcontent select[multiple="multiple"] {
144
- height: auto;
145
- min-width: 150px;
146
- }
147
-
148
-
149
  /*--------------------------------------------------------------------------------------------
150
  Columns
151
  --------------------------------------------------------------------------------------------*/
86
  background-color: #F9F9F9;
87
  border: #DFDFDF solid 1px;
88
  border-top: 0 none;
89
+ margin: 0 20px 0 0;
90
  padding: 8px 12px 12px;
91
  border-radius: 0 0 4px 4px;
92
  }
93
 
94
+
95
+
96
  .screen-meta-wrap p {
97
  margin-top: 0px;
98
  }
133
  border-right: 0 none;
134
  }
135
 
136
+ table.acf_activate input[type="text"] {
137
+ padding: 7px;
138
+ width: 200px;
139
+ }
140
+
141
  table.acf_activate input[type="submit"] {
142
  margin-left: 5px;
143
  margin-right: 5px;
144
  }
145
 
 
 
 
 
 
 
 
 
 
 
146
  /*--------------------------------------------------------------------------------------------
147
  Columns
148
  --------------------------------------------------------------------------------------------*/
css/{style.fields.css → fields.css} RENAMED
@@ -5,6 +5,10 @@
5
  background: url(../images/acf-icon-32.png) 0 0 no-repeat !important;
6
  }
7
 
 
 
 
 
8
  .postbox#acf_fields {
9
  border: 0 none;
10
  }
@@ -126,10 +130,13 @@ table.widefat.acf td {
126
  #acf_fields .field .field_meta strong {
127
  display: block;
128
  padding-bottom: 6px;
 
 
129
  }
130
 
131
  #acf_fields .field .field_meta .row_options {
132
- font-size: 11px;
 
133
  visibility: hidden;
134
  }
135
 
@@ -141,10 +148,10 @@ table.widefat.acf td {
141
  background: #6e6e6e url(../images/backgrounds.png) 0 0 repeat-x;
142
  color: #fff;
143
  text-shadow: #000 0 1px 0;
144
- border-bottom: #565656 solid 1px;
145
- border-top: #565656 solid 1px;
146
  border-left:0 none;
147
- border-right:0 none;
148
 
149
  }
150
 
@@ -345,3 +352,142 @@ table.acf_input tr td .acf tr td {
345
  .field_form .field_option {
346
  display: none;
347
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  background: url(../images/acf-icon-32.png) 0 0 no-repeat !important;
6
  }
7
 
8
+ #message p a {
9
+ display: none;
10
+ }
11
+
12
  .postbox#acf_fields {
13
  border: 0 none;
14
  }
130
  #acf_fields .field .field_meta strong {
131
  display: block;
132
  padding-bottom: 6px;
133
+ font-size: 13px;
134
+ line-height: 13px;
135
  }
136
 
137
  #acf_fields .field .field_meta .row_options {
138
+ font-size: 12px;
139
+ line-height: 12px;
140
  visibility: hidden;
141
  }
142
 
148
  background: #6e6e6e url(../images/backgrounds.png) 0 0 repeat-x;
149
  color: #fff;
150
  text-shadow: #000 0 1px 0;
151
+ border: #565656 solid 1px;
152
+ /*border-top: #565656 solid 1px;
153
  border-left:0 none;
154
+ border-right:0 none;*/
155
 
156
  }
157
 
352
  .field_form .field_option {
353
  display: none;
354
  }
355
+
356
+
357
+ /*---------------------------------------------------------------------------------------------
358
+ Location
359
+ ---------------------------------------------------------------------------------------------*/
360
+
361
+ .postbox#acf_location .inside {
362
+ margin: 0;
363
+ padding: 0;
364
+ }
365
+
366
+ .postbox#acf_location .widefat {
367
+ border: 0 none;
368
+ }
369
+
370
+ .postbox#acf_location h3 span.description {
371
+ font-size: 11px;
372
+ color: #666;
373
+ font-weight: normal;
374
+ font-style: normal;
375
+ padding-left: 4px;
376
+ }
377
+
378
+ table.acf_input > tbody > tr > td > select[multiple="multiple"] {
379
+ height: auto !important;
380
+ }
381
+
382
+ td.param {
383
+ width: 40%;
384
+ }
385
+ td.operator {
386
+ width: 20%;
387
+ }
388
+
389
+ /*---------------------------------------------------------------------------------------------
390
+ Location Rules
391
+ ---------------------------------------------------------------------------------------------*/
392
+ .location_rules {
393
+
394
+ }
395
+
396
+ table#location_rules {
397
+
398
+ }
399
+
400
+ table#location_rules tr {
401
+
402
+ }
403
+
404
+ table#location_rules tr td {
405
+ padding: 4px;
406
+ border: 0 none;
407
+ }
408
+
409
+ table#location_rules tr td:first-child {
410
+ padding-left: 0;
411
+ }
412
+
413
+ table#location_rules tr td:last-child {
414
+ padding-right: 0;
415
+ }
416
+
417
+ table#location_rules tr td.buttons {
418
+ width: 40px;
419
+ vertical-align: middle;
420
+ }
421
+
422
+ table#location_rules a.remove {
423
+ display: block;
424
+ width: 16px;
425
+ height: 16px;
426
+ background: url(../images/button_remove.png) 0 0 no-repeat;
427
+ float: left;
428
+ margin-right: 4px;
429
+ }
430
+
431
+ table#location_rules a.remove:hover {
432
+ background-position: 0 100%;
433
+ }
434
+
435
+ table#location_rules a.remove.disabled {
436
+ opacity: 0.4;
437
+ background-position: 0 0 !important;
438
+ cursor: default;
439
+ }
440
+
441
+ table#location_rules a.add {
442
+ display: block;
443
+ width: 16px;
444
+ height: 16px;
445
+ background: url(../images/button_add.png) 0 0 no-repeat;
446
+ float: left;
447
+ }
448
+
449
+ table#location_rules a.add:hover {
450
+ background-position: 0 100%;
451
+ }
452
+
453
+ .location_rules p select {
454
+ width: 50px;
455
+ }
456
+
457
+ table#location_rules tr td.value div {
458
+ display: none;
459
+ }
460
+
461
+
462
+ /*---------------------------------------------------------------------------------------------
463
+ Options
464
+ ---------------------------------------------------------------------------------------------*/
465
+
466
+ .postbox#acf_options .inside {
467
+ margin: 0;
468
+ padding: 0;
469
+ }
470
+
471
+ .postbox#acf_options h3 span.description {
472
+ font-size: 11px;
473
+ color: #666;
474
+ font-weight: normal;
475
+ font-style: normal;
476
+ padding-left: 4px;
477
+ }
478
+
479
+ .postbox#acf_options ul.checkbox_list {
480
+ display: block;
481
+ float: left;
482
+ width: 300px;
483
+ }
484
+
485
+ .postbox#acf_options ul.checkbox_list li {
486
+ display: block;
487
+ }
488
+
489
+ ul.checkbox_list li input {
490
+ margin: 2px 5px 0 0;
491
+ vertical-align: top;
492
+ }
493
+
css/{style.global.css → global.css} RENAMED
@@ -81,6 +81,10 @@ ul.radio_list.horizontal li {
81
  margin-right: 20px;
82
  }
83
 
 
 
 
 
84
  ul.checkbox_list input[type="checkbox"] {
85
  margin-right: 5px;
86
  }
81
  margin-right: 20px;
82
  }
83
 
84
+ ul.checkbox_list {
85
+ background: transparent !important;
86
+ }
87
+
88
  ul.checkbox_list input[type="checkbox"] {
89
  margin-right: 5px;
90
  }
css/{style.input.css → input.css} RENAMED
@@ -1,45 +1,24 @@
1
- .postbox#acf_input {
2
- border: #EAEAEA solid 0px;
3
- background: transparent;
4
- position: relative;
5
- overflow: visible;
6
- border: 0 none !important;
7
-
8
- }
9
-
10
- .postbox#acf_input.loading {
11
- min-height: 50px;
12
- }
13
-
14
- .postbox#acf_input #acf_loading {
15
- position: absolute;
16
- top: 50%;
17
- left: 50%;
18
- height: 50px;
19
- width: 50px;
20
- margin-left: -25px;
21
- margin-top: -25px;
22
- background: #5a5a5a url(../images/loading.gif) 50% 50% no-repeat;
23
- -moz-border-radius: 5px; -webkit-border-radius: 5px; -khtml-border-radius: 5px; border-radius: 5px;
24
- display: none;
25
- z-index: 3;
26
- }
27
 
28
- .postbox#acf_input.loading #acf_loading {
29
- display: block;
 
30
  }
31
 
32
- #acf_fields_ajax {
33
  position: relative;
 
 
 
34
  }
35
 
36
- #acf_fields_ajax .field {
37
- position: relative;
38
- padding: 10px 2px;
39
- border-top: 1px solid #eaeaea;
40
  }
41
 
42
- #acf_fields_ajax .field > label {
43
  display: block;
44
  color: #21759B;
45
  font-size: 12px;
@@ -48,50 +27,48 @@
48
  text-shadow: 0 1px 0 #FFFFFF;
49
  }
50
 
51
- .postbox#acf_input > h3.hndle{
52
- display: none;
 
 
 
53
  }
54
 
55
- .postbox#acf_input > .inside {
56
- margin: 0;
57
- padding: 0;
 
58
  }
59
 
60
- .postbox#acf_input > .handlediv {
 
61
  display: none;
62
- height: 0;
63
- width: 0;
64
  }
65
 
66
- #acf_fields_ajax .postbox h3 {
67
- cursor: default;
68
  }
69
 
70
- .acf_wysiwyg {
71
- overflow: hidden;
72
- background: #fff;
73
- }
74
 
75
- .acf_wysiwyg textarea{
76
- height: 320px;
77
- }
78
 
79
- #post-body .acf_wysiwyg .wp_themeSkin .mceStatusbar a.mceResize {
80
- top: -2px !important;
 
 
 
 
 
81
  }
82
 
83
- #acf_fields_ajax .field input[type="text"],
84
- #acf_fields_ajax .field textarea,
85
- #acf_fields_ajax .field select{
86
- width: 99.8%;
87
- }
88
 
89
- #poststuff .inside p.instructions {
90
- font-size: 11px;
91
- margin: -6px 0 10px;
92
- padding: 0;
93
- color: #999;
94
- }
95
 
96
 
97
  /*---------------------------------------------------------------------------------------------
@@ -298,7 +275,6 @@ a.remove_field:hover {
298
  float: right;
299
  margin: 0;
300
  text-align: center;
301
- width: 70px;
302
  }
303
 
304
  #acf_input .wp_themeSkin tr.mceFirst td.mceToolbar {
@@ -331,32 +307,6 @@ ul.checkbox_list {
331
  In Box
332
  ---------------------------------------------------------------------------------------------*/
333
 
334
- #acf_input #acf_fields_ajax {
335
-
336
- }
337
-
338
- #acf_input #acf_fields_ajax .postbox {
339
-
340
- }
341
-
342
- #acf_input #acf_fields_ajax .postbox .inside {
343
- margin: 0;
344
- padding: 0;
345
- }
346
-
347
- #acf_input #acf_fields_ajax .postbox .inside .field {
348
- padding: 10px 10px;
349
- border-top: 1px solid #fff;
350
- border-bottom: #DFDFDF solid 1px;
351
- }
352
-
353
- #acf_input #acf_fields_ajax .postbox .inside .field:last-child {
354
- border-bottom: none;
355
- }
356
-
357
- .no_move .postbox .hndle {
358
- cursor: default !important;
359
- }
360
 
361
  /*---------------------------------------------------------------------------------------------
362
  relationship
1
+ /*---------------------------------------------------------------------------------------------
2
+ Post Box
3
+ ---------------------------------------------------------------------------------------------*/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
+ #poststuff .acf_postbox .inside {
6
+ margin: 0;
7
+ padding: 0;
8
  }
9
 
10
+ .acf_postbox .field {
11
  position: relative;
12
+ padding: 10px 10px;
13
+ border-top: 1px solid #fff;
14
+ border-bottom: #e8e8e8 solid 1px;
15
  }
16
 
17
+ .acf_postbox .field:last-child {
18
+ border-bottom: none;
 
 
19
  }
20
 
21
+ #poststuff .acf_postbox .field > label {
22
  display: block;
23
  color: #21759B;
24
  font-size: 12px;
27
  text-shadow: 0 1px 0 #FFFFFF;
28
  }
29
 
30
+ #poststuff .acf_postbox p.instructions {
31
+ font-size: 11px;
32
+ margin: -6px 0 10px;
33
+ padding: 0;
34
+ color: #999;
35
  }
36
 
37
+ /* no box style */
38
+ #poststuff .acf_postbox.no_box {
39
+ border: 0 none;
40
+ background: transparent;
41
  }
42
 
43
+ #poststuff .acf_postbox.no_box > h3,
44
+ #poststuff .acf_postbox.no_box > .handlediv {
45
  display: none;
 
 
46
  }
47
 
48
+ #poststuff .acf_postbox.no_box .field {
49
+ border-bottom: 1px solid #F4F4F4;
50
  }
51
 
 
 
 
 
52
 
53
+ /*---------------------------------------------------------------------------------------------
54
+ Basic Field Styles
55
+ ---------------------------------------------------------------------------------------------*/
56
 
57
+ .acf_postbox .field input[type="text"],
58
+ .acf_postbox .field input[type="password"],
59
+ .acf_postbox .field textarea,
60
+ .acf_postbox .field select{
61
+ width: 100%;
62
+ padding: 5px;
63
+ resize: none;
64
  }
65
 
66
+ /*---------------------------------------------------------------------------------------------
67
+ Field: WYSIWYG
68
+ ---------------------------------------------------------------------------------------------*/
69
+
70
+
71
 
 
 
 
 
 
 
72
 
73
 
74
  /*---------------------------------------------------------------------------------------------
275
  float: right;
276
  margin: 0;
277
  text-align: center;
 
278
  }
279
 
280
  #acf_input .wp_themeSkin tr.mceFirst td.mceToolbar {
307
  In Box
308
  ---------------------------------------------------------------------------------------------*/
309
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
 
311
  /*---------------------------------------------------------------------------------------------
312
  relationship
css/style.location.css DELETED
@@ -1,99 +0,0 @@
1
- .postbox#acf_location .inside {
2
- margin: 0;
3
- padding: 0;
4
- }
5
-
6
- .postbox#acf_location .widefat {
7
- border: 0 none;
8
- }
9
-
10
- .postbox#acf_location h3 span.description {
11
- font-size: 11px;
12
- color: #666;
13
- font-weight: normal;
14
- font-style: normal;
15
- padding-left: 4px;
16
- }
17
-
18
- table.acf_input > tbody > tr > td > select[multiple="multiple"] {
19
- height: auto !important;
20
- }
21
-
22
- td.param {
23
- width: 40%;
24
- }
25
- td.operator {
26
- width: 20%;
27
- }
28
-
29
- /*---------------------------------------------------------------------------------------------
30
- Location Rules
31
- ---------------------------------------------------------------------------------------------*/
32
- .location_rules {
33
-
34
- }
35
-
36
- table#location_rules {
37
-
38
- }
39
-
40
- table#location_rules tr {
41
-
42
- }
43
-
44
- table#location_rules tr td {
45
- padding: 4px;
46
- border: 0 none;
47
- }
48
-
49
- table#location_rules tr td:first-child {
50
- padding-left: 0;
51
- }
52
-
53
- table#location_rules tr td:last-child {
54
- padding-right: 0;
55
- }
56
-
57
- table#location_rules tr td.buttons {
58
- width: 40px;
59
- vertical-align: middle;
60
- }
61
-
62
- table#location_rules a.remove {
63
- display: block;
64
- width: 16px;
65
- height: 16px;
66
- background: url(../images/button_remove.png) 0 0 no-repeat;
67
- float: left;
68
- margin-right: 4px;
69
- }
70
-
71
- table#location_rules a.remove:hover {
72
- background-position: 0 100%;
73
- }
74
-
75
- table#location_rules a.remove.disabled {
76
- opacity: 0.4;
77
- background-position: 0 0 !important;
78
- cursor: default;
79
- }
80
-
81
- table#location_rules a.add {
82
- display: block;
83
- width: 16px;
84
- height: 16px;
85
- background: url(../images/button_add.png) 0 0 no-repeat;
86
- float: left;
87
- }
88
-
89
- table#location_rules a.add:hover {
90
- background-position: 0 100%;
91
- }
92
-
93
- .location_rules p select {
94
- width: 50px;
95
- }
96
-
97
- table#location_rules tr td.value div {
98
- display: none;
99
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
css/style.options.css DELETED
@@ -1,27 +0,0 @@
1
- .postbox#acf_options .inside {
2
- margin: 0;
3
- padding: 0;
4
- }
5
-
6
- .postbox#acf_options h3 span.description {
7
- font-size: 11px;
8
- color: #666;
9
- font-weight: normal;
10
- font-style: normal;
11
- padding-left: 4px;
12
- }
13
-
14
- .postbox#acf_options ul.checkbox_list {
15
- display: block;
16
- float: left;
17
- width: 300px;
18
- }
19
-
20
- .postbox#acf_options ul.checkbox_list li {
21
- display: block;
22
- }
23
-
24
- ul.checkbox_list li input {
25
- margin: 2px 5px 0 0;
26
- vertical-align: top;
27
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/{functions.screen_extra.js → acf.js} RENAMED
File without changes
js/{functions.fields.js → fields.js} RENAMED
@@ -29,13 +29,13 @@
29
  var name = $(this).attr('name');
30
  var id = $(this).attr('id');
31
 
32
- if(name && name.indexOf("[fields][999]") != -1)
33
  {
34
- name = name.replace('[fields][999]','[fields]['+new_no+']');
35
  }
36
- if(id && id.indexOf("[fields][999]") != -1)
37
  {
38
- id = id.replace('[fields][999]','[fields]['+new_no+']');
39
  }
40
 
41
  if($(this).closest('.sub_field').hasClass('field_clone'))
@@ -110,16 +110,28 @@
110
 
111
  var field = $(this).closest('.field');
112
  var fields = field.closest('.fields');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
 
114
- field.remove();
115
- update_order_numbers();
116
 
117
- if(!fields.children('.field').exists())
118
- {
119
- // no more fields, show the message
120
- fields.children('.no_fields_message').show();
121
- }
122
-
123
  });
124
 
125
 
@@ -149,6 +161,13 @@
149
  tr.insertAfter(tr_top);
150
  tr.show();
151
 
 
 
 
 
 
 
 
152
 
153
  }).trigger('change');
154
 
@@ -209,7 +228,7 @@
209
 
210
  // update order numbers
211
  update_order_numbers();
212
-
213
  return false;
214
 
215
 
@@ -217,9 +236,8 @@
217
 
218
 
219
  // Auto complete field name
220
- $('.field_form tr.field_label input.label').live('blur', function()
221
  {
222
- //console.log('blur');
223
  var label = $(this);
224
  var name = $(this).closest('tr').siblings('tr.field_name').find('input.name');
225
 
@@ -257,39 +275,129 @@
257
  });
258
 
259
  }
260
-
 
261
  /*----------------------------------------------------------------------
262
  *
263
- * Document Ready
264
  *
265
  *---------------------------------------------------------------------*/
266
 
267
- $(document).ready(function(){
 
 
268
 
269
- // firefox radio button bug
270
- if($.browser.mozilla) $("form").attr("autocomplete", "off");
271
-
272
 
273
- // add active to Settings Menu
274
- $('#adminmenu #menu-settings').addClass('current');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
275
 
276
- // setup fields
277
- setup_fields();
278
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
279
 
280
- $('#acf_fields input[type="radio"]').each(function(){
 
 
 
 
 
 
 
 
281
 
282
- if($(this).is(':checked'))
 
 
 
 
283
  {
284
- $(this).removeAttr('checked').attr('checked', 'checked');
 
 
285
  }
286
  else
287
  {
288
-
 
 
289
  }
290
 
291
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
292
 
293
  });
294
 
 
295
  })(jQuery);
29
  var name = $(this).attr('name');
30
  var id = $(this).attr('id');
31
 
32
+ if(name && name.indexOf("fields[999]") != -1)
33
  {
34
+ name = name.replace('fields[999]','fields['+new_no+']');
35
  }
36
+ if(id && id.indexOf("fields[999]") != -1)
37
  {
38
+ id = id.replace('fields[999]','fields['+new_no+']');
39
  }
40
 
41
  if($(this).closest('.sub_field').hasClass('field_clone'))
110
 
111
  var field = $(this).closest('.field');
112
  var fields = field.closest('.fields');
113
+ var temp = $('<div style="height:' + field.height() + 'px"></div>');
114
+ //field.css({'-moz-transform' : 'translate(50px, 0)', 'opacity' : 0, '-moz-transition' : 'all 250ms ease-out'});
115
+ field.animate({'left' : '50px', 'opacity' : 0}, 250, function(){
116
+ field.before(temp);
117
+ field.remove();
118
+
119
+ temp.animate({'height' : 0 }, 250, function(){
120
+ temp.remove();
121
+ })
122
+
123
+ update_order_numbers();
124
+
125
+ if(!fields.children('.field').exists())
126
+ {
127
+ // no more fields, show the message
128
+ fields.children('.no_fields_message').show();
129
+ }
130
+
131
+ });
132
+
133
 
 
 
134
 
 
 
 
 
 
 
135
  });
136
 
137
 
161
  tr.insertAfter(tr_top);
162
  tr.show();
163
 
164
+ // firefox radio button fix
165
+ tr.find('input[type="radio"][data-checked="checked"]').each(function(){
166
+
167
+ $(this).removeAttr('checked').attr('checked', 'checked');
168
+
169
+ });
170
+
171
 
172
  }).trigger('change');
173
 
228
 
229
  // update order numbers
230
  update_order_numbers();
231
+
232
  return false;
233
 
234
 
236
 
237
 
238
  // Auto complete field name
239
+ $('#acf_fields tr.field_label input.label').live('blur', function()
240
  {
 
241
  var label = $(this);
242
  var name = $(this).closest('tr').siblings('tr.field_name').find('input.name');
243
 
275
  });
276
 
277
  }
278
+
279
+
280
  /*----------------------------------------------------------------------
281
  *
282
+ * setup_rules
283
  *
284
  *---------------------------------------------------------------------*/
285
 
286
+ function setup_rules()
287
+ {
288
+ var tbody = $('table#location_rules tbody');
289
 
 
 
 
290
 
291
+ // show field type options
292
+ tbody.find('td.param select').live('change', function(){
293
+
294
+ var tr = $(this).closest('tr');
295
+ var val = $(this).val();
296
+
297
+
298
+ // does it have options?
299
+ if(!$(this).find('option[value="options_page"]').exists())
300
+ {
301
+ //console.log('select: '+type+'. parent length: '+$(this).closest('.repeater').length);
302
+ $(this).append('<option value="options_page" disabled="true">Options Page (Unlock field with activation code)</option>');
303
+
304
+ }
305
+
306
+
307
+ tr.find('td.value div').hide();
308
+ tr.find('td.value div [name]').attr('disabled', 'true');
309
+
310
+ tr.find('td.value div[rel="'+val+'"]').show();
311
+ tr.find('td.value div[rel="'+val+'"] [name]').removeAttr('disabled');
312
+
313
+ }).trigger('change');
314
 
 
 
315
 
316
+ // Add Button
317
+ tbody.find('td.buttons a.add').live('click',function(){
318
+
319
+ var tr_count = $(this).closest('tbody').children('tr').length;
320
+ var tr = $(this).closest('tr').clone();
321
+
322
+ tr.insertAfter($(this).closest('tr'));
323
+
324
+ update_names();
325
+
326
+ can_remove_more();
327
+
328
+ return false;
329
+
330
+ });
331
 
332
+
333
+ // Remove Button
334
+ tbody.find('td.buttons a.remove').live('click',function(){
335
+
336
+ var tr = $(this).closest('tr').remove();
337
+
338
+ can_remove_more();
339
+
340
+ return false;
341
 
342
+ });
343
+
344
+ function can_remove_more()
345
+ {
346
+ if(tbody.children('tr').length == 1)
347
  {
348
+ tbody.children('tr').each(function(){
349
+ $(this).find('td.buttons a.remove').addClass('disabled');
350
+ });
351
  }
352
  else
353
  {
354
+ tbody.children('tr').each(function(){
355
+ $(this).find('td.buttons a.remove').removeClass('disabled');
356
+ });
357
  }
358
 
359
+ }
360
+
361
+ can_remove_more();
362
+
363
+ function update_names()
364
+ {
365
+ tbody.children('tr').each(function(i){
366
+
367
+ $(this).find('[name]').each(function(){
368
+
369
+ var name = $(this).attr('name').split("][");
370
+
371
+ var new_name = name[0] + "][" + i + "][" + name[2];
372
+
373
+ $(this).attr('name', new_name).attr('id', new_name);
374
+ });
375
+
376
+ })
377
+ }
378
+
379
+ }
380
+
381
+ /*----------------------------------------------------------------------
382
+ *
383
+ * Document Ready
384
+ *
385
+ *---------------------------------------------------------------------*/
386
+
387
+ $(document).ready(function(){
388
+
389
+ // firefox radio button bug (fixed on line 152)
390
+ //if($.browser.mozilla) $("form").attr("autocomplete", "off");
391
+
392
+
393
+ // add active to Settings Menu
394
+ $('#adminmenu #menu-settings').addClass('current');
395
+
396
+ // setup fields
397
+ setup_fields();
398
+ setup_rules();
399
 
400
  });
401
 
402
+
403
  })(jQuery);
js/functions.input.js DELETED
@@ -1,689 +0,0 @@
1
- window.acf_div = null;
2
-
3
- (function($){
4
-
5
- /*----------------------------------------------------------------------
6
- *
7
- * vars
8
- *
9
- *---------------------------------------------------------------------*/
10
- var shift_is_down = false;
11
-
12
- /*----------------------------------------------------------------------
13
- *
14
- * Exists
15
- *
16
- *---------------------------------------------------------------------*/
17
-
18
- $.fn.exists = function()
19
- {
20
- return $(this).length>0;
21
- };
22
-
23
-
24
-
25
- /*----------------------------------------------------------------------
26
- *
27
- * WYSIWYG
28
- *
29
- *---------------------------------------------------------------------*/
30
- var wysiwyg_count = 0;
31
-
32
- $.fn.setup_wysiwyg = function()
33
- {
34
-
35
- $(this).find('.acf_wysiwyg').each(function(){
36
-
37
- var tiny_1_old = '';
38
- var tiny_2_old = '';
39
-
40
- // setup extra tinymce buttons
41
- if(tinyMCE.settings.theme_advanced_buttons1)
42
- {
43
- tiny_1_old = tinyMCE.settings.theme_advanced_buttons1;
44
- tinyMCE.settings.theme_advanced_buttons1 += ",|,add_image,add_video,add_audio,add_media";
45
- }
46
-
47
- if(tinyMCE.settings.theme_advanced_buttons2)
48
- {
49
- tiny_2_old = tinyMCE.settings.theme_advanced_buttons2;
50
- tinyMCE.settings.theme_advanced_buttons2 += ",code";
51
- }
52
-
53
-
54
-
55
- if($(this).find('table').exists())
56
- {
57
- //alert('had wysiwyg')
58
- $(this).children('#editorcontainer').children('span').remove();
59
- $(this).children('#editorcontainer').children('textarea').removeAttr('aria-hidden').removeAttr('style');
60
- }
61
-
62
- // get a unique id
63
- wysiwyg_count = wysiwyg_count + 1;
64
-
65
- // add id
66
- var id = 'acf_wysiwyg_'+wysiwyg_count;
67
- $(this).find('textarea').attr('id',id);
68
-
69
- // create wysiwyg
70
- tinyMCE.execCommand('mceAddControl', false, id);
71
-
72
-
73
- // restore old tinymce buttons
74
- if(tinyMCE.settings.theme_advanced_buttons1)
75
- {
76
- tinyMCE.settings.theme_advanced_buttons1 = tiny_1_old;
77
- }
78
-
79
- if(tinyMCE.settings.theme_advanced_buttons2)
80
- {
81
- tinyMCE.settings.theme_advanced_buttons2 = tiny_2_old;
82
- }
83
-
84
- });
85
-
86
- };
87
-
88
-
89
- /*----------------------------------------------------------------------
90
- *
91
- * Relationship
92
- *
93
- *---------------------------------------------------------------------*/
94
-
95
- $.fn.setup_relationship = function()
96
- {
97
- $(this).find('.acf_relationship').each(function(){
98
-
99
- //console.log('setup');
100
-
101
- var div = $(this);
102
- //var min = parseInt(div.attr('data-min'));
103
- var max = parseInt(div.attr('data-max')); if(max == -1){max = 9999;}
104
- var input = div.children('input');
105
- var left = div.find('.relationship_left .relationship_list');
106
- var right = div.find('.relationship_right .relationship_list');
107
- var search = div.find('input.relationship_search');
108
-
109
-
110
- left.find('a').unbind('click').click(function(){
111
-
112
- if(right.find('a:not(.hide)').length >= max)
113
- {
114
- alert('Maximum values reached ( ' + max + ' values )');
115
- return false;
116
- }
117
-
118
- var id = $(this).attr('data-post_id');
119
-
120
- $(this).addClass('hide');
121
- right.find('a[data-post_id="' + id + '"]').removeClass('hide').appendTo(right);
122
-
123
- update_input_val();
124
-
125
- return false;
126
-
127
- });
128
-
129
-
130
- right.find('a').unbind('click').click(function(){
131
-
132
- var id = $(this).attr('data-post_id');
133
-
134
- $(this).addClass('hide');
135
- left.find('a[data-post_id="' + id + '"]').removeClass('hide');
136
-
137
- update_input_val();
138
-
139
- return false;
140
-
141
- });
142
-
143
-
144
- right.unbind('sortable').sortable({
145
- axis: "y", // limit the dragging to up/down only
146
- start: function(event, ui)
147
- {
148
- ui.item.addClass('sortable_active');
149
- },
150
- stop: function(event, ui)
151
- {
152
- ui.item.removeClass('sortable_active');
153
- update_input_val();
154
- }
155
- });
156
-
157
-
158
- $.expr[':'].Contains = function(a,i,m){
159
- return (a.textContent || a.innerText || "").toUpperCase().indexOf(m[3].toUpperCase())>=0;
160
- };
161
-
162
- search.val('');
163
- search.change(function ()
164
- {
165
- var filter = $(this).val();
166
- if(filter)
167
- {
168
- left.find("a:not(:Contains(" + filter + "))").addClass('filter_hide');
169
- left.find("a:Contains(" + filter + "):not(.hide)").removeClass('filter_hide');
170
- }
171
- else
172
- {
173
- left.find("a:not(.hide)").removeClass('filter_hide');
174
- }
175
-
176
- return false;
177
-
178
- })
179
- .keyup( function () {
180
- $(this).change();
181
- });
182
-
183
- search.focus(function(){
184
- $(this).siblings('label').hide();
185
- })
186
- .blur(function(){
187
- if($(this).val() == "")
188
- {
189
- $(this).siblings('label').show();
190
- }
191
- });
192
-
193
-
194
- function update_input_val()
195
- {
196
- var value = new Array();
197
- right.find('a:not(.hide)').each(function(){
198
- value.push($(this).attr('data-post_id'));
199
- });
200
- input.val(value.join(','));
201
- }
202
-
203
- });
204
- };
205
-
206
-
207
- /*----------------------------------------------------------------------
208
- *
209
- * Datepicker
210
- *
211
- *---------------------------------------------------------------------*/
212
-
213
- $.fn.setup_datepicker = function()
214
- {
215
- $(this).find('.acf_datepicker').each(function(){
216
-
217
- var format = $(this).attr('data-date_format') ? $(this).attr('data-date_format') : 'dd/mm/yy';
218
-
219
- $(this).datepicker({
220
- dateFormat: format
221
- });
222
-
223
- $('#ui-datepicker-div').wrap('<div class="acf_datepicker" />');
224
-
225
- });
226
- };
227
-
228
-
229
- /*----------------------------------------------------------------------
230
- *
231
- * Image
232
- *
233
- *---------------------------------------------------------------------*/
234
-
235
- $.fn.setup_image = function(){
236
-
237
- var post_id = $('input#post_ID').val();
238
-
239
- $(this).find('.acf_image_uploader').each(function(){
240
-
241
- var div = $(this);
242
- var preview_size = div.attr('data-preview_size');
243
-
244
- div.find('input.button').unbind('click').click(function(){
245
-
246
- // set global var
247
- window.acf_div = div;
248
-
249
- // show the thickbox
250
- tb_show('Add Image to field', 'media-upload.php?post_id=' + post_id + '&type=image&acf_type=image&acf_preview_size=' + preview_size + 'TB_iframe=1');
251
-
252
- return false;
253
- });
254
-
255
-
256
- div.find('a.remove_image').unbind('click').click(function()
257
- {
258
- div.find('input.value').val('');
259
- div.removeClass('active');
260
-
261
- return false;
262
- });
263
-
264
- });
265
-
266
- };
267
-
268
-
269
- /*----------------------------------------------------------------------
270
- *
271
- * File
272
- *
273
- *---------------------------------------------------------------------*/
274
-
275
- $.fn.setup_file = function(){
276
-
277
- var post_id = $('input#post_ID').val();
278
-
279
- $(this).find('.acf_file_uploader').each(function(){
280
-
281
- //console.log('file setup');
282
- var div = $(this);
283
-
284
- div.find('p.no_file input.button').click(function(){
285
-
286
- // set global var
287
- window.acf_div = div;
288
-
289
- // show the thickbox
290
- tb_show('Add File to field', 'media-upload.php?post_id='+post_id+'&type=file&acf_type=file&TB_iframe=1');
291
-
292
- return false;
293
- });
294
-
295
-
296
- div.find('p.file input.button').unbind('click').click(function()
297
- {
298
- div.find('input.value').val('');
299
- div.removeClass('active');
300
-
301
- return false;
302
- });
303
-
304
- });
305
-
306
- };
307
-
308
-
309
- /*----------------------------------------------------------------------
310
- *
311
- * Repeater
312
- *
313
- *---------------------------------------------------------------------*/
314
-
315
- $.fn.setup_repeater = function(){
316
-
317
- $(this).find('.repeater').each(function(){
318
-
319
- var r = $(this);
320
- var row_limit = parseInt(r.attr('data-row_limit'));
321
- var row_count = r.children('table').children('tbody').children('tr').length;
322
-
323
- // has limit been reached?
324
- if(row_count >= row_limit)
325
- {
326
- r.find('#add_field').attr('disabled','true');
327
- //return false;
328
- }
329
-
330
- // sortable
331
- if(row_limit > 1){
332
- r.make_sortable();
333
- }
334
-
335
- if(row_count == 1)
336
- {
337
- r.addClass('hide_remove_buttons');
338
- }
339
- });
340
-
341
-
342
- // add field
343
- $('.repeater #add_field').die('click');
344
- $('.repeater #add_field').live('click', function(){
345
-
346
- var r = $(this).closest('.repeater');
347
- var row_limit = parseInt(r.attr('data-row_limit'));
348
- var row_count = r.children('table').children('tbody').children('tr').length;
349
-
350
- // row limit
351
- if(row_count >= row_limit)
352
- {
353
- // reached row limit!
354
- r.find('#add_field').attr('disabled','true');
355
- return false;
356
- }
357
-
358
- // create and add the new field
359
- var new_field = r.children('table').children('tbody').children('tr:last-child').clone(false);
360
- r.children('table').children('tbody').append(new_field);
361
-
362
- // update names
363
- new_field.find('[name]').each(function(){
364
-
365
- var name = $(this).attr('name').replace('[value]['+(row_count-1)+']','[value]['+(row_count)+']');
366
- $(this).attr('name', name);
367
- $(this).attr('id', name);
368
-
369
- if(name.indexOf("[value_id]") != -1 || name.indexOf("[meta_id]") != -1)
370
- {
371
- $(this).val('');
372
- }
373
-
374
- });
375
-
376
- // reset values
377
- if(!shift_is_down)
378
- {
379
- new_field.reset_values();
380
- }
381
-
382
- // setup sub fields
383
- new_field.setup_wysiwyg();
384
- new_field.setup_relationship();
385
- new_field.setup_datepicker();
386
- new_field.setup_image();
387
- new_field.setup_file();
388
-
389
- r.update_order_numbers();
390
-
391
- // there is now 1 more row
392
- row_count ++;
393
-
394
- // hide remove buttons if only 1 field
395
- if(row_count > 1)
396
- {
397
- r.removeClass('hide_remove_buttons');
398
- }
399
-
400
- // disable the add field button if row limit is reached
401
- if((row_count+1) >= row_limit)
402
- {
403
- r.find('#add_field').attr('disabled','true');
404
- }
405
-
406
- return false;
407
-
408
- });
409
-
410
-
411
- // remove field
412
- $('.repeater a.remove_field').die('click');
413
- $('.repeater a.remove_field').live('click', function(){
414
-
415
- var r = $(this).closest('.repeater');
416
- var row_count = r.children('table').children('tbody').children('tr').length;
417
-
418
- // needs at least one
419
- if(row_count <= 1)
420
- {
421
- return false;
422
- }
423
- else if(row_count == 2)
424
- {
425
- // total fields will be 1 after the tr is removed
426
- r.addClass('hide_remove_buttons');
427
- }
428
-
429
- var tr = $(this).closest('tr');
430
-
431
- tr.find('td').animate({'opacity':'0', 'height' : '0px'}, 300,function(){
432
- tr.remove();
433
- r.update_order_numbers();
434
- });
435
-
436
-
437
- r.find('#add_field').removeAttr('disabled');
438
-
439
- return false;
440
-
441
- });
442
-
443
-
444
- };
445
-
446
-
447
- /*----------------------------------------------------------------------
448
- *
449
- * Update Order Numbers
450
- *
451
- *---------------------------------------------------------------------*/
452
-
453
- $.fn.update_order_numbers = function(){
454
-
455
- $(this).children('table').children('tbody').children('tr').each(function(i){
456
- $(this).children('td.order').html(i+1);
457
- });
458
-
459
- };
460
-
461
-
462
- /*----------------------------------------------------------------------
463
- *
464
- * Sortable
465
- *
466
- *---------------------------------------------------------------------*/
467
- $.fn.make_sortable = function(){
468
-
469
- var r = $(this);
470
-
471
- var fixHelper = function(e, ui) {
472
- ui.children().each(function() {
473
- $(this).width($(this).width());
474
- });
475
- return ui;
476
- };
477
-
478
- r.children('table').children('tbody').unbind('sortable').sortable({
479
- update: function(event, ui){
480
- r.update_order_numbers();
481
- r.setup_wysiwyg();
482
- r.setup_relationship();
483
- r.setup_datepicker();
484
- r.setup_image();
485
- r.setup_file();
486
- },
487
- handle: 'td.order',
488
- helper: fixHelper,
489
- start: function(event, ui)
490
- {
491
-
492
- },
493
- stop: function(event, ui)
494
- {
495
- ui.item.setup_wysiwyg();
496
- }
497
- });
498
- };
499
-
500
-
501
-
502
-
503
- /*----------------------------------------------------------------------
504
- *
505
- * reset_values
506
- *
507
- *---------------------------------------------------------------------*/
508
-
509
- $.fn.reset_values = function(){
510
-
511
- var div = $(this);
512
-
513
-
514
- // wysiwyg
515
- if(div.find('.acf_wysiwyg').exists())
516
- {
517
- div.find('.acf_wysiwyg').each(function(){
518
-
519
- var name = $(this).find('textarea').first().attr('name');
520
- $(this).html('<div id="editorcontainer"><textarea name="'+name+'"></textarea></div>');
521
-
522
- });
523
-
524
- }
525
-
526
-
527
- // relationship
528
- if(div.find('.acf_relationship').exists())
529
- {
530
- div.find('.acf_relationship').each(function(){
531
-
532
- $(this).find('.relationship_left .relationship_list a').each(function(){
533
- $(this).removeClass('hide');
534
- });
535
-
536
- $(this).find('.relationship_right .relationship_list a').each(function(){
537
- $(this).addClass('hide');
538
- });
539
-
540
- });
541
- }
542
-
543
-
544
- // image upload
545
- div.find('.acf_image_uploader').each(function(){
546
- $(this).removeClass('active');
547
- });
548
-
549
-
550
- // file upload
551
- div.find('.acf_file_uploader').each(function(){
552
- $(this).removeClass('active');
553
- });
554
-
555
-
556
- // date picker
557
- div.find('.acf_datepicker').each(function(){
558
- $(this).removeClass('hasDatepicker');
559
- });
560
-
561
-
562
-
563
- // reset all values
564
- $(this).find('[name]').each(function()
565
- {
566
- var name = $(this).attr('name');
567
-
568
- if(name.indexOf("[field_id]") != -1)
569
- {
570
- // do nothing, we want to keep this hidden field with it's current values
571
- }
572
- else if(name.indexOf("[field_type]") != -1)
573
- {
574
- // do nothing, we want to keep this hidden field with it's current values
575
- }
576
- else if(name.indexOf("date_format") != -1)
577
- {
578
- // do nothing, we want to keep this hidden field with it's current values
579
- }
580
- else
581
- {
582
- $(this).val('');
583
- }
584
-
585
- // selected / ticked
586
- if($(this).is(':selected'))
587
- {
588
- $(this).removeAttr('selected');
589
-
590
- }
591
- else if($(this).is(':checked'))
592
- {
593
- $(this).removeAttr('checked');
594
- }
595
-
596
- });
597
-
598
-
599
- };
600
-
601
-
602
- /*----------------------------------------------------------------------
603
- *
604
- * Setup Validation
605
- *
606
- *---------------------------------------------------------------------*/
607
-
608
- $.fn.setup_validation = function()
609
- {
610
- /*var div = $(this);
611
-
612
- $('#publish').click(function(){
613
-
614
-
615
- // relationship
616
- div.find('.acf_relationship').each(function(){
617
-
618
- var r = $(this);
619
- var min = parseInt(r.attr('data-min'));
620
-
621
- if(r.find('.relationship_right .relationship_list a:not(.hide)').length < min)
622
- {
623
- alert('Minimum values not reached ( ' + max + ' values )');
624
- return false;
625
- }
626
-
627
- });
628
-
629
- console.log('setup');
630
-
631
- var div = $(this);
632
-
633
-
634
-
635
- });*/
636
- }
637
-
638
- /*----------------------------------------------------------------------
639
- *
640
- * Setup ACF
641
- *
642
- *---------------------------------------------------------------------*/
643
-
644
- $.fn.setup_acf = function()
645
- {
646
-
647
- var div = $('#acf_fields_ajax');
648
-
649
-
650
- div.setup_wysiwyg();
651
- div.setup_relationship();
652
- div.setup_datepicker();
653
- div.setup_image();
654
- div.setup_file();
655
- div.setup_repeater();
656
- div.setup_validation();
657
-
658
- };
659
-
660
-
661
-
662
- /*----------------------------------------------------------------------
663
- *
664
- * Document Ready
665
- *
666
- *---------------------------------------------------------------------*/
667
-
668
- $(document).ready(function(){
669
-
670
- // add shift key trigger for duplicating repeater field
671
-
672
- $(window).keydown(function(evt){
673
- if(evt.which == 16)
674
- {
675
- shift_is_down = true;
676
- }
677
- }).keyup(function(evt) {
678
- if(evt.which == 16)
679
- {
680
- shift_is_down = false;
681
- }
682
- });
683
-
684
-
685
- });
686
-
687
-
688
-
689
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/functions.location.js DELETED
@@ -1,112 +0,0 @@
1
- (function($){
2
-
3
-
4
-
5
- /*--------------------------------------------------------------------------
6
- setup_fields
7
- --------------------------------------------------------------------------*/
8
- function setup_rules()
9
- {
10
- var tbody = $('table#location_rules tbody');
11
-
12
-
13
- // show field type options
14
- tbody.find('td.param select').live('change', function(){
15
-
16
- var tr = $(this).closest('tr');
17
- var val = $(this).val();
18
-
19
-
20
- // does it have options?
21
- if(!$(this).find('option[value="options_page"]').exists())
22
- {
23
- //console.log('select: '+type+'. parent length: '+$(this).closest('.repeater').length);
24
- $(this).append('<option value="options_page" disabled="true">Options Page (Unlock field with activation code)</option>');
25
-
26
- }
27
-
28
-
29
- tr.find('td.value div').hide();
30
- tr.find('td.value div [name]').attr('disabled', 'true');
31
-
32
- tr.find('td.value div[rel="'+val+'"]').show();
33
- tr.find('td.value div[rel="'+val+'"] [name]').removeAttr('disabled');
34
-
35
- }).trigger('change');
36
-
37
-
38
- // Add Button
39
- tbody.find('td.buttons a.add').live('click',function(){
40
-
41
- var tr_count = $(this).closest('tbody').children('tr').length;
42
- var tr = $(this).closest('tr').clone();
43
-
44
- tr.insertAfter($(this).closest('tr'));
45
-
46
- update_names();
47
-
48
- can_remove_more();
49
-
50
- return false;
51
-
52
- });
53
-
54
-
55
- // Remove Button
56
- tbody.find('td.buttons a.remove').live('click',function(){
57
-
58
- var tr = $(this).closest('tr').remove();
59
-
60
- can_remove_more();
61
-
62
- return false;
63
-
64
- });
65
-
66
- function can_remove_more()
67
- {
68
- if(tbody.children('tr').length == 1)
69
- {
70
- tbody.children('tr').each(function(){
71
- $(this).find('td.buttons a.remove').addClass('disabled');
72
- });
73
- }
74
- else
75
- {
76
- tbody.children('tr').each(function(){
77
- $(this).find('td.buttons a.remove').removeClass('disabled');
78
- });
79
- }
80
-
81
- }
82
-
83
- can_remove_more();
84
-
85
- function update_names()
86
- {
87
- tbody.children('tr').each(function(i){
88
-
89
- $(this).find('[name]').each(function(){
90
-
91
- var name = $(this).attr('name').split("][");
92
-
93
- var new_name = name[0] + "][" + name[1] + "][" + i + "][" + name[3];
94
-
95
- $(this).attr('name', new_name);
96
- });
97
-
98
- })
99
- }
100
-
101
- }
102
-
103
- /*--------------------------------------------------------------------------
104
- Document Ready
105
- --------------------------------------------------------------------------*/
106
- $(document).ready(function(){
107
-
108
- setup_rules();
109
-
110
- });
111
-
112
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/input.js ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function($){
2
+
3
+ /*----------------------------------------------------------------------
4
+ *
5
+ * vars
6
+ *
7
+ *---------------------------------------------------------------------*/
8
+ var shift_is_down = false;
9
+ var data = {
10
+ action : 'get_input_metabox_ids',
11
+ post_id : false,
12
+ page_template : false,
13
+ page_parent : false,
14
+ page_type : false,
15
+ page : false,
16
+ post : false,
17
+ post_category : false,
18
+ post_format : false,
19
+ };
20
+
21
+
22
+ /*----------------------------------------------------------------------
23
+ *
24
+ * Exists
25
+ *
26
+ *---------------------------------------------------------------------*/
27
+
28
+ $.fn.exists = function()
29
+ {
30
+ return $(this).length>0;
31
+ };
32
+
33
+
34
+ /*----------------------------------------------------------------------
35
+ *
36
+ * Document Ready
37
+ *
38
+ *---------------------------------------------------------------------*/
39
+
40
+ $(document).ready(function(){
41
+
42
+ // vars
43
+ var post_id = $('input#post_ID').val();
44
+
45
+ // show metaboxes for this post
46
+ data = {
47
+ action : 'get_input_metabox_ids',
48
+ post_id : post_id,
49
+ page_template : false,
50
+ page_parent : false,
51
+ page_type : false,
52
+ page : post_id,
53
+ post : post_id,
54
+ post_category : false,
55
+ post_format : false,
56
+ taxonomy : false
57
+ };
58
+
59
+ // update fields from ajax response
60
+ function update_fields()
61
+ {
62
+ $.ajax({
63
+ url: ajaxurl,
64
+ data: data,
65
+ type: 'post',
66
+ dataType: 'json',
67
+ success: function(result){
68
+
69
+ // hide all metaboxes
70
+ $('#poststuff .acf_postbox').hide();
71
+ $('#adv-settings .acf_hide_label').hide();
72
+
73
+ // show the new postboxes
74
+ $.each(result, function(k, v) {
75
+ $('#poststuff #acf_' + v).show();
76
+ $('#adv-settings .acf_hide_label[for="acf_' + v + '-hide"]').show();
77
+ });
78
+
79
+ // load style
80
+ $.ajax({
81
+ url: ajaxurl,
82
+ data: {
83
+ action : 'get_input_style',
84
+ acf_id : result[0]
85
+ },
86
+ type: 'post',
87
+ dataType: 'html',
88
+ success: function(result){
89
+
90
+ $('#acf_style').html(result);
91
+
92
+ }
93
+ });
94
+
95
+ }
96
+ });
97
+ }
98
+ //update_fields();
99
+
100
+ // hide acf stuff
101
+ /*$('#poststuff .acf_postbox').hide();
102
+ $('#adv-settings .acf_hide_label').hide();
103
+
104
+ // show acf?
105
+ $('#poststuff .acf_postbox').each(function(){
106
+
107
+ // vars
108
+ var show = $(this).children('.inside').children('.options').attr('data-show');
109
+ var id = $(this).attr('id').replace('acf_', '');
110
+
111
+ if(show == 'true')
112
+ {
113
+ $(this).show();
114
+ $('#adv-settings .acf_hide_label[for="acf_' + id + '-hide"]').show();
115
+ }
116
+
117
+ });*/
118
+
119
+
120
+ // on save, delete all unused metaboxes
121
+ $('input#publish').click(function(){
122
+
123
+ // do validation?
124
+ $('#post-body .acf_postbox:hidden').remove();
125
+
126
+ return true;
127
+ });
128
+
129
+ /*--------------------------------------------------------------------------------------
130
+ *
131
+ * Change
132
+ *
133
+ *-------------------------------------------------------------------------------------*/
134
+
135
+ $('#page_template').change(function(){
136
+
137
+ data.page_template = $(this).val();
138
+ update_fields();
139
+
140
+ });
141
+
142
+ $('#parent_id').change(function(){
143
+
144
+ var page_parent = $(this).val();
145
+
146
+ if($(this).val() != "")
147
+ {
148
+ data.page_type = 'child';
149
+ }
150
+ else
151
+ {
152
+ data.page_type = 'parent';
153
+ }
154
+
155
+ update_fields();
156
+
157
+ });
158
+
159
+ $('#categorychecklist input[type="checkbox"]').change(function(){
160
+
161
+ data.post_category = ['0'];
162
+
163
+ $('#categorychecklist :checked').each(function(){
164
+ data.post_category.push($(this).val())
165
+ });
166
+
167
+ //console.log(data.post_category);
168
+
169
+ update_fields();
170
+
171
+ });
172
+
173
+
174
+ $('#post-formats-select input[type="radio"]').change(function(){
175
+
176
+ data.post_format = $(this).val();
177
+ update_fields();
178
+
179
+ });
180
+
181
+ // taxonomy
182
+ $('div[id*="taxonomy-"] input[type="checkbox"]').change(function(){
183
+
184
+ data.taxonomy = ['0'];
185
+
186
+ $(this).closest('ul').find('input[type="checkbox"]:checked').each(function(){
187
+ data.taxonomy.push($(this).val())
188
+ });
189
+
190
+ update_fields();
191
+
192
+ });
193
+
194
+ });
195
+
196
+
197
+
198
+ })(jQuery);
lang/{advanced-custom-fields-nl_NL.mo → acf-nl_NL.mo} RENAMED
File without changes
lang/{advanced-custom-fields-ru-RU.mo → acf-ru-RU.mo} RENAMED
File without changes
lang/{advanced-custom-fields.pot → acf.pot} RENAMED
File without changes
readme.txt CHANGED
@@ -33,6 +33,8 @@ Advanced Custom Fields is the perfect solution for any wordpress website which n
33
  * Date Picker (jquery date picker, options for format, api returns string)
34
  * True / False (tick box with message, api returns true or false)
35
  * Repeater (ability to create repeatable blocks of fields!)
 
 
36
 
37
  = Tested on =
38
  * Mac Firefox :)
@@ -75,9 +77,6 @@ Your votes really make a difference! Thanks.
75
  = Q. I can't see the "Select Image" button for my image field! =
76
  A. For Image uploads to work, your post type must support "editor"
77
 
78
- = Q. ACF uses custom database tables, can I still query posts based on meta_key / value? =
79
- A. Yes, meta_key and meta_value act as usual. All field data is stored as a normal custom field, but is attached to a row in the acf_values table for extra functionality!
80
-
81
  = Q. I have a question =
82
  A. Chances are, someone else has asked it. Check out the support forum at:
83
  http://support.plugins.elliotcondon.com/categories/advanced-custom-fields/
@@ -95,6 +94,18 @@ http://support.plugins.elliotcondon.com/categories/advanced-custom-fields/
95
 
96
  == Changelog ==
97
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  = 2.1.4 =
99
  * Fixed add image tinymce error for options Page WYSIWYG
100
  * API: added new function: update_the_field($field_name, $value, $post_id)
@@ -264,5 +275,8 @@ http://support.plugins.elliotcondon.com/categories/advanced-custom-fields/
264
 
265
  == Upgrade Notice ==
266
 
 
 
 
267
  = 2.1.4 =
268
  * Adds post_id column back into acf_values
33
  * Date Picker (jquery date picker, options for format, api returns string)
34
  * True / False (tick box with message, api returns true or false)
35
  * Repeater (ability to create repeatable blocks of fields!)
36
+ * Relationship (select and order post objects with a tidy interface)
37
+ * Color Picker (Farbtastic!)
38
 
39
  = Tested on =
40
  * Mac Firefox :)
77
  = Q. I can't see the "Select Image" button for my image field! =
78
  A. For Image uploads to work, your post type must support "editor"
79
 
 
 
 
80
  = Q. I have a question =
81
  A. Chances are, someone else has asked it. Check out the support forum at:
82
  http://support.plugins.elliotcondon.com/categories/advanced-custom-fields/
94
 
95
  == Changelog ==
96
 
97
+ = 3.0.0 =
98
+ * ACF doesn't use any custom tables anymore! All data is saved as post_meta!
99
+ * Faster and more stable across different servers
100
+ * Drag-able / order-able metaboxes
101
+ * Fields extend from a parent object! Now you can create you own field types!
102
+ * New location rule: Taxonomy
103
+ * New function: register_field($class, $url);
104
+ * New Field: Color Picker
105
+ * New Option: Text + Textarea formatting
106
+ * New Option: WYSIWYG Show / Hide media buttons, Full / Basic Toolbar buttons (Great for a basic wysiwyg inside a repeater for your clients)
107
+ * Lots of bug fixes
108
+
109
  = 2.1.4 =
110
  * Fixed add image tinymce error for options Page WYSIWYG
111
  * API: added new function: update_the_field($field_name, $value, $post_id)
275
 
276
  == Upgrade Notice ==
277
 
278
+ = 3.0.0 =
279
+ * Editor is broken in WordPress 3.3
280
+
281
  = 2.1.4 =
282
  * Adds post_id column back into acf_values