Advanced Custom Fields - Version 3.5.8

Version Description

  • [Fixed] Fix bug preventing fields to load on user / taxonomy front end form - http://support.advancedcustomfields.com/discussion/4393/front-end-user-profile-field-form-causes-referenceerror
  • [Added] Added 'acf/fields/wysiwyg/toolbars' filter to customize WYSIWYG toolbars - http://support.advancedcustomfields.com/discussion/2205/can-we-change-wysiwyg-basic-editor-buttons
  • [Fixed] Fix acf_load_filters as they are not working! - http://support.advancedcustomfields.com/discussion/comment/12770#Comment_12770
  • [Added] Clean up wp_options after term delete - http://support.advancedcustomfields.com/discussion/4396/delete-taxonomy-term-custom-fields-after-term-delete
  • [Fixed] Fix location rule - category / taxonomy on new post - http://support.advancedcustomfields.com/discussion/3635/show-custom-fields-on-post-adding
  • [Added] Added 'acf/create_field' action for third party usage - docs to come soon
  • [Added] Add support for new media uploader in WP 3.5!
  • [Fixed] Fix conditional logic error - http://support.advancedcustomfields.com/discussion/4502/conditional-logic-script-output-causes-events-to-fire-multiple-times
  • [Fixed] Fix Uploader not working on taxonomy edit screens - http://support.advancedcustomfields.com/discussion/4536/media-upload-button-for-wysiwyg-does-not-work-when-used-on-a-taxonomy-term
  • [Added] Add data cleanup after removing a repeater / flexible content row - http://support.advancedcustomfields.com/discussion/1994/deleting-single-repeater-fields-does-not-remove-entry-from-database
Download this release

Release Info

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

Code changes from version 3.5.7 to 3.5.8

Files changed (55) hide show
  1. acf.php +56 -53
  2. core/api.php +142 -67
  3. core/controllers/everything_fields.php +29 -8
  4. core/controllers/field_group.php +3 -3
  5. core/controllers/input.php +66 -36
  6. core/controllers/location.php +146 -84
  7. core/controllers/options_page.php +1 -1
  8. core/controllers/settings.php +2 -2
  9. core/controllers/third_party.php +1 -1
  10. core/fields/acf_field.php +47 -6
  11. core/fields/checkbox.php +52 -31
  12. core/fields/color_picker.php +1 -1
  13. core/fields/date_picker/date_picker.php +1 -1
  14. core/fields/file.php +196 -169
  15. core/fields/flexible_content.php +123 -33
  16. core/fields/gallery.php +92 -120
  17. core/fields/image.php +227 -131
  18. core/fields/number.php +4 -2
  19. core/fields/page_link.php +12 -7
  20. core/fields/post_object.php +21 -15
  21. core/fields/radio.php +35 -24
  22. core/fields/relationship.php +52 -43
  23. core/fields/repeater.php +89 -26
  24. core/fields/select.php +4 -4
  25. core/fields/text.php +21 -9
  26. core/fields/textarea.php +20 -6
  27. core/fields/true_false.php +40 -17
  28. core/fields/wysiwyg.php +56 -10
  29. core/views/meta_box_fields.php +8 -8
  30. core/views/meta_box_location.php +3 -3
  31. core/views/meta_box_options.php +4 -4
  32. css/{fields.css → field-group.css} +0 -0
  33. css/input.css +16 -0
  34. images/brand-hero-default.png +0 -0
  35. images/button_add.png +0 -0
  36. images/button_remove.png +0 -0
  37. js/{fields.js → field-group.js} +51 -25
  38. js/input-actions.js +0 -2081
  39. js/input.php +51 -0
  40. js/input/actions.js +467 -0
  41. js/{input-ajax.js → input/ajax.js} +13 -11
  42. js/input/color-picker.js +145 -0
  43. js/input/date-picker.js +81 -0
  44. js/input/file.js +249 -0
  45. js/input/flexible-content.js +261 -0
  46. js/input/gallery.js +530 -0
  47. js/input/image.js +247 -0
  48. js/input/relationship.js +299 -0
  49. js/input/repeater.js +388 -0
  50. js/input/tab.js +110 -0
  51. js/input/validation.js +167 -0
  52. js/input/wysiwyg.js +363 -0
  53. lang/acf-it_IT.mo +0 -0
  54. lang/acf-it_IT.po +164 -200
  55. readme.txt +48 -25
acf.php CHANGED
@@ -2,8 +2,8 @@
2
  /*
3
  Plugin Name: Advanced Custom Fields
4
  Plugin URI: http://www.advancedcustomfields.com/
5
- Description: Fully customise WordPress edit screens with powerful fields. Boasting a professional interface and a powerfull API, it’s a must have for any web developer working with WordPress. Field types include: Wysiwyg, text, textarea, image, file, select, checkbox, page link, post object, date picker, color picker, repeater, flexible content, gallery and more!
6
- Version: 3.5.7.2
7
  Author: Elliot Condon
8
  Author URI: http://www.elliotcondon.com/
9
  License: GPL
@@ -47,11 +47,10 @@ class Acf
47
 
48
  function __construct()
49
  {
50
-
51
  // vars
52
- $this->path = plugin_dir_path(__FILE__);
53
- $this->dir = plugins_url('',__FILE__);
54
- $this->version = '3.5.7.2';
55
  $this->upgrade_version = '3.4.1'; // this is the latest version which requires an upgrade
56
  $this->cache = array(); // basic array cache to hold data throughout the page load
57
  $this->defaults = array(
@@ -84,8 +83,14 @@ class Acf
84
  add_action('acf_save_post', array($this, 'acf_save_post'), 10); // save post, called from many places (api, input, everything, options)
85
 
86
 
 
 
 
 
 
 
87
  // filters
88
- add_filter('acf_load_field', array($this, 'acf_load_field'), 5);
89
  add_filter('post_updated_messages', array($this, 'post_updated_messages'));
90
  add_filter('acf_parse_value', array($this, 'acf_parse_value'));
91
 
@@ -149,10 +154,10 @@ class Acf
149
 
150
  // register acf scripts
151
  $scripts = array(
152
- 'acf-fields' => $this->dir . '/js/fields.js',
153
- 'acf-input-actions' => $this->dir . '/js/input-actions.js',
154
- 'acf-input-ajax' => $this->dir . '/js/input-ajax.js',
155
- 'acf-datepicker' => $this->dir . '/core/fields/date_picker/jquery.ui.datepicker.js',
156
  );
157
 
158
  foreach( $scripts as $k => $v )
@@ -163,11 +168,11 @@ class Acf
163
 
164
  // register acf styles
165
  $styles = array(
166
- 'acf' => $this->dir . '/css/acf.css',
167
- 'acf-fields' => $this->dir . '/css/fields.css',
168
- 'acf-global' => $this->dir . '/css/global.css',
169
- 'acf-input' => $this->dir . '/css/input.css',
170
- 'acf-datepicker' => $this->dir . '/core/fields/date_picker/style.date_picker.css',
171
  );
172
 
173
  foreach( $styles as $k => $v )
@@ -446,30 +451,23 @@ class Acf
446
  </style>';
447
  }
448
 
449
-
450
- /*--------------------------------------------------------------------------------------
451
- *
452
- * get_field_groups
453
- *
454
- * This function returns an array of post objects found in the get_posts and the
455
- * register_field_group calls.
456
  *
457
- * @author Elliot Condon
458
- * @since 3.0.6
459
- *
460
- *-------------------------------------------------------------------------------------*/
461
 
462
- function get_field_groups()
463
  {
464
- // return cache
465
- $cache = $this->get_cache('acf_field_groups');
466
- if($cache != false)
467
  {
468
- return $cache;
469
  }
470
 
471
- // vars
472
- $acfs = array();
473
 
474
  // get acf's
475
  $result = get_posts(array(
@@ -486,7 +484,7 @@ class Acf
486
  {
487
  foreach($result as $acf)
488
  {
489
- $acfs[] = array(
490
  'id' => $acf->ID,
491
  'title' => get_the_title($acf->ID),
492
  'fields' => $this->get_acf_fields($acf->ID),
@@ -498,19 +496,9 @@ class Acf
498
  }
499
 
500
  // hook to load in registered field groups
501
- $acfs = apply_filters('acf_register_field_group', $acfs);
502
 
503
- // update cache
504
- $this->set_cache('acf_field_groups', $acfs);
505
-
506
- // return
507
- if(empty($acfs))
508
- {
509
- return false;
510
- }
511
-
512
-
513
- return $acfs;
514
  }
515
 
516
 
@@ -618,7 +606,7 @@ class Acf
618
  {
619
  if( isset($field[ $key ]) )
620
  {
621
- $value = apply_filters('acf_load_field-' . $field[ $key ], $field);
622
  }
623
  }
624
 
@@ -633,7 +621,7 @@ class Acf
633
 
634
 
635
  // hook to load in registered field groups
636
- $acfs = $this->get_field_groups();
637
 
638
  if($acfs)
639
  {
@@ -655,7 +643,7 @@ class Acf
655
  {
656
  if( isset($field[ $key ]) )
657
  {
658
- $value = apply_filters('acf_load_field-' . $field[ $key ], $field);
659
  }
660
  }
661
 
@@ -811,7 +799,7 @@ class Acf
811
  // conditional logic
812
  // - isset is needed for the edit field group page where fields are created without many parameters
813
  if( isset($field['conditional_logic']['status']) && $field['conditional_logic']['status'] ):
814
-
815
  $join = ' && ';
816
  if( $field['conditional_logic']['allorany'] == "any" )
817
  {
@@ -848,7 +836,22 @@ class Acf
848
 
849
 
850
  // add change events to all fields
851
- <?php foreach( $field['conditional_logic']['rules'] as $rule ): ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
852
  $('.field-<?php echo $rule['field']; ?> *[name]').live('change', function(){
853
  $(document).trigger('acf/conditional_logic/<?php echo $field['key']; ?>');
854
  });
@@ -1194,7 +1197,7 @@ class Acf
1194
 
1195
 
1196
  // find all acf objects
1197
- $acfs = $this->get_field_groups();
1198
 
1199
 
1200
  // blank array to hold acfs
2
  /*
3
  Plugin Name: Advanced Custom Fields
4
  Plugin URI: http://www.advancedcustomfields.com/
5
+ Description: Fully customise WordPress edit screens with powerful fields. Boasting a professional interface and a powerful API, it’s a must-have for any web developer working with WordPress. Field types include: WYSIWYG, text, textarea, image, file, select, checkbox, page link, post object, date picker, color picker, repeater, flexible content, gallery, and more!
6
+ Version: 3.5.8.2
7
  Author: Elliot Condon
8
  Author URI: http://www.elliotcondon.com/
9
  License: GPL
47
 
48
  function __construct()
49
  {
 
50
  // vars
51
+ $this->path = plugin_dir_path( __FILE__ );
52
+ $this->dir = plugin_dir_url( __FILE__ );
53
+ $this->version = '3.5.8.2';
54
  $this->upgrade_version = '3.4.1'; // this is the latest version which requires an upgrade
55
  $this->cache = array(); // basic array cache to hold data throughout the page load
56
  $this->defaults = array(
83
  add_action('acf_save_post', array($this, 'acf_save_post'), 10); // save post, called from many places (api, input, everything, options)
84
 
85
 
86
+ // action functions
87
+ add_action('acf/create_field', array($this, 'create_field'), 1, 1);
88
+ add_filter('acf/get_field_groups', array($this, 'get_field_groups'), 1, 1);
89
+ //add_filter('acf/get_field', array($this, 'get_field'), 10, 1);
90
+
91
+
92
  // filters
93
+ add_filter('acf_load_field', array($this, 'acf_load_field'), 1, 1);
94
  add_filter('post_updated_messages', array($this, 'post_updated_messages'));
95
  add_filter('acf_parse_value', array($this, 'acf_parse_value'));
96
 
154
 
155
  // register acf scripts
156
  $scripts = array(
157
+ 'acf-field-group' => $this->dir . 'js/field-group.js',
158
+ 'acf-input' => $this->dir . 'js/input.php',
159
+ 'acf-input-ajax' => $this->dir . 'js/input/ajax.js',
160
+ 'acf-datepicker' => $this->dir . 'core/fields/date_picker/jquery.ui.datepicker.js',
161
  );
162
 
163
  foreach( $scripts as $k => $v )
168
 
169
  // register acf styles
170
  $styles = array(
171
+ 'acf' => $this->dir . 'css/acf.css',
172
+ 'acf-field-group' => $this->dir . 'css/field-group.css',
173
+ 'acf-global' => $this->dir . 'css/global.css',
174
+ 'acf-input' => $this->dir . 'css/input.css',
175
+ 'acf-datepicker' => $this->dir . 'core/fields/date_picker/style.date_picker.css',
176
  );
177
 
178
  foreach( $styles as $k => $v )
451
  </style>';
452
  }
453
 
454
+
455
+ /*
456
+ * get_field_groups
 
 
 
 
457
  *
458
+ * @description:
459
+ * @since: 3.5.7
460
+ * @created: 12/01/13
461
+ */
462
 
463
+ function get_field_groups( $return )
464
  {
465
+ // return must be an array
466
+ if( !is_array($return) )
 
467
  {
468
+ $return = array();
469
  }
470
 
 
 
471
 
472
  // get acf's
473
  $result = get_posts(array(
484
  {
485
  foreach($result as $acf)
486
  {
487
+ $return[] = array(
488
  'id' => $acf->ID,
489
  'title' => get_the_title($acf->ID),
490
  'fields' => $this->get_acf_fields($acf->ID),
496
  }
497
 
498
  // hook to load in registered field groups
499
+ //$return = apply_filters('acf_register_field_group', $return);
500
 
501
+ return $return;
 
 
 
 
 
 
 
 
 
 
502
  }
503
 
504
 
606
  {
607
  if( isset($field[ $key ]) )
608
  {
609
+ $field = apply_filters('acf_load_field-' . $field[ $key ], $field);
610
  }
611
  }
612
 
621
 
622
 
623
  // hook to load in registered field groups
624
+ $acfs = apply_filters('acf/get_field_groups', false);
625
 
626
  if($acfs)
627
  {
643
  {
644
  if( isset($field[ $key ]) )
645
  {
646
+ $field = apply_filters('acf_load_field-' . $field[ $key ], $field);
647
  }
648
  }
649
 
799
  // conditional logic
800
  // - isset is needed for the edit field group page where fields are created without many parameters
801
  if( isset($field['conditional_logic']['status']) && $field['conditional_logic']['status'] ):
802
+
803
  $join = ' && ';
804
  if( $field['conditional_logic']['allorany'] == "any" )
805
  {
836
 
837
 
838
  // add change events to all fields
839
+ <?php
840
+
841
+ $already_added = array();
842
+
843
+ foreach( $field['conditional_logic']['rules'] as $rule ):
844
+
845
+ if( in_array( $rule['field'], $already_added) )
846
+ {
847
+ continue;
848
+ }
849
+ else
850
+ {
851
+ $already_added[] = $rule['field'];
852
+ }
853
+
854
+ ?>
855
  $('.field-<?php echo $rule['field']; ?> *[name]').live('change', function(){
856
  $(document).trigger('acf/conditional_logic/<?php echo $field['key']; ?>');
857
  });
1197
 
1198
 
1199
  // find all acf objects
1200
+ $acfs = apply_filters('acf/get_field_groups', false);
1201
 
1202
 
1203
  // blank array to hold acfs
core/api.php CHANGED
@@ -4,6 +4,66 @@
4
  $GLOBALS['acf_field'] = array();
5
 
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  /*--------------------------------------------------------------------------------------
8
  *
9
  * get_fields
@@ -18,17 +78,9 @@ function get_fields($post_id = false)
18
  // vars
19
  global $post, $wpdb;
20
 
21
- if(!$post_id)
22
- {
23
- $post_id = $post->ID;
24
- }
25
-
26
 
27
- // allow for option == options
28
- if( $post_id == "option" )
29
- {
30
- $post_id = "options";
31
- }
32
 
33
 
34
  // vars
@@ -97,18 +149,10 @@ function get_field($field_key, $post_id = false, $format_value = true)
97
  {
98
  global $post, $acf;
99
 
100
- if(!$post_id)
101
- {
102
- $post_id = $post->ID;
103
- }
104
-
105
-
106
- // allow for option == options
107
- if( $post_id == "option" )
108
- {
109
- $post_id = "options";
110
- }
111
-
112
 
113
  // return cache
114
  $cache = wp_cache_get('acf_get_field_' . $post_id . '_' . $field_key);
@@ -121,7 +165,8 @@ function get_field($field_key, $post_id = false, $format_value = true)
121
  $value = "";
122
  $field = array(
123
  'type' => 'text',
124
- 'name' => $field_key
 
125
  );
126
 
127
 
@@ -157,11 +202,12 @@ function get_field($field_key, $post_id = false, $format_value = true)
157
  {
158
  $field = array(
159
  'type' => 'none',
160
- 'name' => $field_key
 
161
  );
162
  }
163
 
164
-
165
  // load value
166
  $value = $acf->get_value_for_api($post_id, $field);
167
 
@@ -218,10 +264,11 @@ function has_sub_field($field_name, $post_id = false)
218
  // needs a post_id
219
  global $post;
220
 
221
- if( !$post_id )
222
- {
223
- $post_id = $post->ID;
224
- }
 
225
 
226
  // empty?
227
  if( empty($GLOBALS['acf_field']) )
@@ -247,7 +294,13 @@ function has_sub_field($field_name, $post_id = false)
247
  if( $post_id != $id )
248
  {
249
  // reset
250
- $GLOBALS['acf_field'] = array();
 
 
 
 
 
 
251
  return has_sub_field($field_name, $post_id);
252
  }
253
 
@@ -426,34 +479,46 @@ function register_field_group($array)
426
  $GLOBALS['acf_register_field_group'][] = $array;
427
  }
428
 
429
- function acf_register_field_group($array)
 
 
430
  {
431
- $array = array_merge($array, $GLOBALS['acf_register_field_group']);
432
-
433
  if( empty($GLOBALS['acf_register_field_group']) )
434
  {
435
- return $array;
436
  }
437
 
 
 
 
 
 
 
 
 
 
 
438
 
439
  // order field groups based on menu_order, title
440
  // Obtain a list of columns
441
- foreach ($array as $key => $row) {
442
- $menu_order[$key] = $row['menu_order'];
443
- $title[$key] = $row['title'];
 
444
  }
445
 
446
  // Sort the array with menu_order ascending
447
  // Add $array as the last parameter, to sort by the common key
448
  if(isset($menu_order))
449
  {
450
- array_multisort($menu_order, SORT_ASC, $title, SORT_ASC, $array);
451
  }
452
 
453
-
454
- return $array;
455
  }
456
- add_filter('acf_register_field_group', 'acf_register_field_group');
457
 
458
 
459
  /*--------------------------------------------------------------------------------------
@@ -622,8 +687,9 @@ function acf_form($options = null)
622
 
623
  // defaults
624
  $defaults = array(
625
- 'post_id' => $post->ID, // post id to get field groups from and save data to
626
  'field_groups' => array(), // this will find the field groups for this post
 
627
  'form_attributes' => array( // attributes will be added to the form element
628
  'class' => ''
629
  ),
@@ -646,13 +712,30 @@ function acf_form($options = null)
646
  }
647
 
648
 
 
 
 
 
649
  // register post box
650
- if( !$options['field_groups'] )
651
  {
652
  // get field groups
653
  $filter = array(
654
  'post_id' => $options['post_id']
655
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
656
  $options['field_groups'] = array();
657
  $options['field_groups'] = apply_filters( 'acf/location/match_field_groups', $options['field_groups'], $filter );
658
  }
@@ -666,12 +749,14 @@ function acf_form($options = null)
666
 
667
 
668
  // Javascript
669
- echo '<script type="text/javascript">acf.post_id = ' . $options['post_id'] . '; acf.nonce = "' . wp_create_nonce( 'acf_nonce' ) . '";</script>';
 
670
 
671
 
672
  // display form
673
- ?>
674
  <form action="" id="post" method="post" <?php if($options['form_attributes']){foreach($options['form_attributes'] as $k => $v){echo $k . '="' . $v .'" '; }} ?>>
 
675
  <div style="display:none">
676
  <input type="hidden" name="acf_save" value="true" />
677
  <input type="hidden" name="post_id" value="<?php echo $options['post_id']; ?>" />
@@ -685,7 +770,8 @@ function acf_form($options = null)
685
  // html before fields
686
  echo $options['html_before_fields'];
687
 
688
- $field_groups = $acf->get_field_groups();
 
689
  if($field_groups):
690
  foreach($field_groups as $field_group):
691
 
@@ -718,15 +804,20 @@ function acf_form($options = null)
718
  echo $options['html_after_fields'];
719
 
720
  ?>
 
 
721
  <!-- Submit -->
722
  <div class="field">
723
  <input type="submit" value="<?php echo $options['submit_value']; ?>" />
724
  </div>
725
  <!-- / Submit -->
 
726
 
727
  </div><!-- <div id="poststuff"> -->
 
 
728
  </form>
729
- <?php
730
 
731
  }
732
 
@@ -743,18 +834,10 @@ function acf_form($options = null)
743
  function update_field($field_key, $value, $post_id = false)
744
  {
745
  global $post, $acf;
746
-
747
- if(!$post_id)
748
- {
749
- $post_id = $post->ID;
750
- }
751
 
752
 
753
- // allow for option == options
754
- if( $post_id == "option" )
755
- {
756
- $post_id = "options";
757
- }
758
 
759
 
760
  // is $field_name a name? pre 3.4.0
@@ -946,17 +1029,9 @@ function get_field_object($field_key, $post_id = false, $options = array())
946
  // vars
947
  global $post, $acf;
948
 
949
- if(!$post_id)
950
- {
951
- $post_id = $post->ID;
952
- }
953
 
954
-
955
- // allow for option == options
956
- if( $post_id == "option" )
957
- {
958
- $post_id = "options";
959
- }
960
 
961
 
962
  // is $field_name a name? pre 3.4.0
4
  $GLOBALS['acf_field'] = array();
5
 
6
 
7
+ /*
8
+ * acf_filter_post_id()
9
+ *
10
+ * A helper function to filter the post_id variable.
11
+ *
12
+ * @type function
13
+ * @since 3.6
14
+ * @date 29/01/13
15
+ *
16
+ * @param $post_id
17
+ *
18
+ * @return $post_id
19
+ */
20
+
21
+ function acf_filter_post_id( $post_id )
22
+ {
23
+ // set post_id to global
24
+ if( !$post_id )
25
+ {
26
+ global $post;
27
+
28
+ if( $post )
29
+ {
30
+ $post_id = $post->ID;
31
+ }
32
+ }
33
+
34
+
35
+ // allow for option == options
36
+ if( $post_id == "option" )
37
+ {
38
+ $post_id = "options";
39
+ }
40
+
41
+
42
+ /*
43
+ * Override for preview
44
+ *
45
+ * If the $_GET['preview_id'] is set, then the user wants to see the preview data.
46
+ * There is also the case of previewing a page with post_id = 1, but using get_field
47
+ * to load data from another post_id.
48
+ * In this case, we need to make sure that the autosave revision is actually related
49
+ * to the $post_id variable. If they match, then the autosave data will be used, otherwise,
50
+ * the user wants to load data from a completely different post_id
51
+ */
52
+
53
+ if( isset($_GET['preview_id']) )
54
+ {
55
+ $autosave = wp_get_post_autosave( $_GET['preview_id'] );
56
+ if( $autosave->post_parent == $post_id )
57
+ {
58
+ $post_id = $autosave->ID;
59
+ }
60
+ }
61
+
62
+
63
+ // return
64
+ return $post_id;
65
+ }
66
+
67
  /*--------------------------------------------------------------------------------------
68
  *
69
  * get_fields
78
  // vars
79
  global $post, $wpdb;
80
 
 
 
 
 
 
81
 
82
+ // filter post_id
83
+ $post_id = acf_filter_post_id( $post_id );
 
 
 
84
 
85
 
86
  // vars
149
  {
150
  global $post, $acf;
151
 
152
+
153
+ // filter post_id
154
+ $post_id = acf_filter_post_id( $post_id );
155
+
 
 
 
 
 
 
 
 
156
 
157
  // return cache
158
  $cache = wp_cache_get('acf_get_field_' . $post_id . '_' . $field_key);
165
  $value = "";
166
  $field = array(
167
  'type' => 'text',
168
+ 'name' => $field_key,
169
+ 'key' => 'temp_key_for_' . $field_key
170
  );
171
 
172
 
202
  {
203
  $field = array(
204
  'type' => 'none',
205
+ 'name' => $field_key,
206
+ 'key' => 'temp_key_for_' . $field_key
207
  );
208
  }
209
 
210
+
211
  // load value
212
  $value = $acf->get_value_for_api($post_id, $field);
213
 
264
  // needs a post_id
265
  global $post;
266
 
267
+
268
+ // filter post_id
269
+ $post_id = acf_filter_post_id( $post_id );
270
+
271
+
272
 
273
  // empty?
274
  if( empty($GLOBALS['acf_field']) )
294
  if( $post_id != $id )
295
  {
296
  // reset
297
+ $GLOBALS['acf_field'][] = array(
298
+ 'name' => $field_name,
299
+ 'value' => get_field($field_name, $post_id),
300
+ 'row' => -1,
301
+ 'post_id' => $post_id,
302
+ );
303
+
304
  return has_sub_field($field_name, $post_id);
305
  }
306
 
479
  $GLOBALS['acf_register_field_group'][] = $array;
480
  }
481
 
482
+
483
+ add_filter('acf/get_field_groups', 'acf_register_field_group', 10, 1);
484
+ function acf_register_field_group( $return )
485
  {
486
+
487
+ // validate
488
  if( empty($GLOBALS['acf_register_field_group']) )
489
  {
490
+ return $return;
491
  }
492
 
493
+ // ensure $return is an array
494
+ if( ! is_array( $return ) )
495
+ {
496
+ $return = array();
497
+ }
498
+
499
+ // merge in custom
500
+ $return = array_merge($return, $GLOBALS['acf_register_field_group']);
501
+
502
+
503
 
504
  // order field groups based on menu_order, title
505
  // Obtain a list of columns
506
+ foreach ($return as $key => $row)
507
+ {
508
+ $menu_order[ $key ] = $row['menu_order'];
509
+ $title[ $key ] = $row['title'];
510
  }
511
 
512
  // Sort the array with menu_order ascending
513
  // Add $array as the last parameter, to sort by the common key
514
  if(isset($menu_order))
515
  {
516
+ array_multisort($menu_order, SORT_ASC, $title, SORT_ASC, $return);
517
  }
518
 
519
+ return $return;
 
520
  }
521
+
522
 
523
 
524
  /*--------------------------------------------------------------------------------------
687
 
688
  // defaults
689
  $defaults = array(
690
+ 'post_id' => false, // post id to get field groups from and save data to
691
  'field_groups' => array(), // this will find the field groups for this post
692
+ 'form' => true,
693
  'form_attributes' => array( // attributes will be added to the form element
694
  'class' => ''
695
  ),
712
  }
713
 
714
 
715
+ // filter post_id
716
+ $options['post_id'] = acf_filter_post_id( $options['post_id'] );
717
+
718
+
719
  // register post box
720
+ if( empty($options['field_groups']) )
721
  {
722
  // get field groups
723
  $filter = array(
724
  'post_id' => $options['post_id']
725
  );
726
+
727
+ if( strpos($options['post_id'], 'user_') !== false )
728
+ {
729
+ $user_id = str_replace('user_', '', $options['post_id']);
730
+ $filter['ef_user'] = $user_id;
731
+ }
732
+ elseif( strpos($options['post_id'], 'taxonomy_') !== false )
733
+ {
734
+ $taxonomy_id = str_replace('taxonomy_', '', $options['post_id']);
735
+ $filter['ef_taxonomy'] = $taxonomy_id;
736
+ }
737
+
738
+
739
  $options['field_groups'] = array();
740
  $options['field_groups'] = apply_filters( 'acf/location/match_field_groups', $options['field_groups'], $filter );
741
  }
749
 
750
 
751
  // Javascript
752
+ $script_post_id = is_numeric($options['post_id']) ? $options['post_id'] : 0;
753
+ echo '<script type="text/javascript">acf.post_id = ' . $script_post_id . '; </script>';
754
 
755
 
756
  // display form
757
+ if( $options['form'] ): ?>
758
  <form action="" id="post" method="post" <?php if($options['form_attributes']){foreach($options['form_attributes'] as $k => $v){echo $k . '="' . $v .'" '; }} ?>>
759
+ <?php endif; ?>
760
  <div style="display:none">
761
  <input type="hidden" name="acf_save" value="true" />
762
  <input type="hidden" name="post_id" value="<?php echo $options['post_id']; ?>" />
770
  // html before fields
771
  echo $options['html_before_fields'];
772
 
773
+ $field_groups = apply_filters('acf/get_field_groups', false);
774
+
775
  if($field_groups):
776
  foreach($field_groups as $field_group):
777
 
804
  echo $options['html_after_fields'];
805
 
806
  ?>
807
+
808
+ <?php if( $options['form'] ): ?>
809
  <!-- Submit -->
810
  <div class="field">
811
  <input type="submit" value="<?php echo $options['submit_value']; ?>" />
812
  </div>
813
  <!-- / Submit -->
814
+ <?php endif; ?>
815
 
816
  </div><!-- <div id="poststuff"> -->
817
+
818
+ <?php if( $options['form'] ): ?>
819
  </form>
820
+ <?php endif;
821
 
822
  }
823
 
834
  function update_field($field_key, $value, $post_id = false)
835
  {
836
  global $post, $acf;
 
 
 
 
 
837
 
838
 
839
+ // filter post_id
840
+ $post_id = acf_filter_post_id( $post_id );
 
 
 
841
 
842
 
843
  // is $field_name a name? pre 3.4.0
1029
  // vars
1030
  global $post, $acf;
1031
 
 
 
 
 
1032
 
1033
+ // filter post_id
1034
+ $post_id = acf_filter_post_id( $post_id );
 
 
 
 
1035
 
1036
 
1037
  // is $field_name a name? pre 3.4.0
core/controllers/everything_fields.php CHANGED
@@ -41,16 +41,18 @@ class acf_everything_fields
41
  // save
42
  add_action('create_term', array($this, 'save_taxonomy'));
43
  add_action('edited_term', array($this, 'save_taxonomy'));
44
-
45
  add_action('edit_user_profile_update', array($this, 'save_user'));
46
  add_action('personal_options_update', array($this, 'save_user'));
47
  add_action('user_register', array($this, 'save_user'));
48
-
49
-
50
  add_filter("attachment_fields_to_save", array($this, 'save_attachment'), null , 2);
51
 
 
52
  // shopp
53
  add_action('shopp_category_saved', array($this, 'shopp_category_saved'));
 
 
 
 
54
  }
55
 
56
 
@@ -419,8 +421,8 @@ class acf_everything_fields
419
 
420
 
421
  // get acfs
422
- $acfs = $this->parent->get_field_groups();
423
-
424
 
425
  // layout
426
  $layout = 'tr';
@@ -512,7 +514,7 @@ class acf_everything_fields
512
  echo '</p>';
513
 
514
  $field['name'] = 'fields[' . $field['key'] . ']';
515
- $this->parent->create_field($field);
516
 
517
  echo '</div>';
518
  }
@@ -521,7 +523,7 @@ class acf_everything_fields
521
  echo '<div id="acf-' . $field['name'] . '" class="form-field field field-' . $field['type'] . ' field-'.$field['key'] . $required_class . '">';
522
  echo '<label for="fields[' . $field['key'] . ']">' . $field['label'] . $required_label . '</label>';
523
  $field['name'] = 'fields[' . $field['key'] . ']';
524
- $this->parent->create_field($field);
525
  if($field['instructions']) echo '<p class="description">' . $field['instructions'] . '</p>';
526
  echo '</div>';
527
  }
@@ -531,7 +533,7 @@ class acf_everything_fields
531
  echo '<th valign="top" scope="row"><label for="fields[' . $field['key'] . ']">' . $field['label'] . $required_label . '</label></th>';
532
  echo '<td>';
533
  $field['name'] = 'fields[' . $field['key'] . ']';
534
- $this->parent->create_field($field);
535
 
536
  if($field['instructions']) echo '<p class="description">' . $field['instructions'] . '</p>';
537
  echo '</td>';
@@ -563,6 +565,25 @@ class acf_everything_fields
563
 
564
  }
565
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
566
 
567
  }
568
 
41
  // save
42
  add_action('create_term', array($this, 'save_taxonomy'));
43
  add_action('edited_term', array($this, 'save_taxonomy'));
 
44
  add_action('edit_user_profile_update', array($this, 'save_user'));
45
  add_action('personal_options_update', array($this, 'save_user'));
46
  add_action('user_register', array($this, 'save_user'));
 
 
47
  add_filter("attachment_fields_to_save", array($this, 'save_attachment'), null , 2);
48
 
49
+
50
  // shopp
51
  add_action('shopp_category_saved', array($this, 'shopp_category_saved'));
52
+
53
+
54
+ // delete
55
+ add_action('delete_term', array($this, 'delete_term'), 10, 4);
56
  }
57
 
58
 
421
 
422
 
423
  // get acfs
424
+ $acfs = apply_filters('acf/get_field_groups', false);
425
+
426
 
427
  // layout
428
  $layout = 'tr';
514
  echo '</p>';
515
 
516
  $field['name'] = 'fields[' . $field['key'] . ']';
517
+ do_action('acf/create_field', $field);
518
 
519
  echo '</div>';
520
  }
523
  echo '<div id="acf-' . $field['name'] . '" class="form-field field field-' . $field['type'] . ' field-'.$field['key'] . $required_class . '">';
524
  echo '<label for="fields[' . $field['key'] . ']">' . $field['label'] . $required_label . '</label>';
525
  $field['name'] = 'fields[' . $field['key'] . ']';
526
+ do_action('acf/create_field', $field );
527
  if($field['instructions']) echo '<p class="description">' . $field['instructions'] . '</p>';
528
  echo '</div>';
529
  }
533
  echo '<th valign="top" scope="row"><label for="fields[' . $field['key'] . ']">' . $field['label'] . $required_label . '</label></th>';
534
  echo '<td>';
535
  $field['name'] = 'fields[' . $field['key'] . ']';
536
+ do_action('acf/create_field', $field );
537
 
538
  if($field['instructions']) echo '<p class="description">' . $field['instructions'] . '</p>';
539
  echo '</td>';
565
 
566
  }
567
 
568
+
569
+ /*
570
+ * delete_term
571
+ *
572
+ * @description:
573
+ * @since: 3.5.7
574
+ * @created: 12/01/13
575
+ */
576
+
577
+ function delete_term( $term, $tt_id, $taxonomy, $deleted_term )
578
+ {
579
+ global $wpdb;
580
+
581
+ $values = $wpdb->query($wpdb->prepare(
582
+ "DELETE FROM $wpdb->options WHERE option_name LIKE %s",
583
+ '%' . $taxonomy . '_' . $term . '%'
584
+ ));
585
+ }
586
+
587
 
588
  }
589
 
core/controllers/field_group.php CHANGED
@@ -105,7 +105,7 @@ class acf_field_group
105
 
106
  // custom scripts
107
  wp_enqueue_script(array(
108
- 'acf-fields',
109
  ));
110
 
111
 
@@ -130,7 +130,7 @@ class acf_field_group
130
  // custom styles
131
  wp_enqueue_style(array(
132
  'acf-global',
133
- 'acf-fields',
134
  ));
135
 
136
 
@@ -565,7 +565,7 @@ class acf_field_group
565
 
566
 
567
  // create field
568
- $this->parent->create_field(array(
569
  'type' => 'select',
570
  'name' => 'location[rules][' . $options['key'] . '][value]',
571
  'value' => $options['value'],
105
 
106
  // custom scripts
107
  wp_enqueue_script(array(
108
+ 'acf-field-group',
109
  ));
110
 
111
 
130
  // custom styles
131
  wp_enqueue_style(array(
132
  'acf-global',
133
+ 'acf-field-group',
134
  ));
135
 
136
 
565
 
566
 
567
  // create field
568
+ do_action('acf/create_field', array(
569
  'type' => 'select',
570
  'name' => 'location[rules][' . $options['key'] . '][value]',
571
  'value' => $options['value'],
core/controllers/input.php CHANGED
@@ -37,13 +37,7 @@ class acf_input
37
 
38
 
39
  // save
40
- $save_priority = 20;
41
-
42
- if( isset($_POST['post_type']) )
43
- {
44
- if( $_POST['post_type'] == "tribe_events" ){ $save_priority = 15; }
45
- }
46
- add_action('save_post', array($this, 'save_post'), $save_priority); // save later to avoid issues with 3rd party plugins
47
 
48
 
49
  // custom actions (added in 3.1.8)
@@ -177,12 +171,7 @@ class acf_input
177
 
178
 
179
  // vars
180
- $post_id = 0;
181
-
182
- if( $post )
183
- {
184
- $post_id = $post->ID;
185
- }
186
 
187
 
188
  // get field groups
@@ -207,16 +196,13 @@ class acf_input
207
  echo '<style type="text/css">.acf_postbox, .postbox[id*="acf_"] { display: none; }</style>';
208
 
209
 
210
- // Javascript
211
- echo '<script type="text/javascript">acf.post_id = ' . $post_id . '; acf.nonce = "' . wp_create_nonce( 'acf_nonce' ) . '";</script>';
212
-
213
-
214
  // add user js + css
215
  do_action('acf_head-input');
216
 
217
 
218
  // get acf's
219
- $acfs = $this->parent->get_field_groups();
 
220
 
221
  if($acfs)
222
  {
@@ -260,7 +246,7 @@ class acf_input
260
  function get_input_style($acf_id = false)
261
  {
262
  // vars
263
- $acfs = $this->parent->get_field_groups();
264
  $html = "";
265
 
266
  // find acf
@@ -426,7 +412,7 @@ class acf_input
426
  }
427
 
428
  // get acfs
429
- $acfs = $this->parent->get_field_groups();
430
  if( $acfs )
431
  {
432
  foreach( $acfs as $acf )
@@ -545,26 +531,67 @@ class acf_input
545
 
546
  function acf_head_input()
547
  {
 
 
 
 
 
 
 
 
 
 
 
548
 
549
  ?>
550
  <script type="text/javascript">
551
 
552
- // admin url
 
 
553
  acf.admin_url = "<?php echo admin_url(); ?>";
 
 
554
 
555
- // messages
556
- acf.text.validation_error = "<?php _e("Validation Failed. One or more fields below are required.",'acf'); ?>";
557
- acf.text.file_tb_title_add = "<?php _e("Add File to Field",'acf'); ?>";
558
- acf.text.file_tb_title_edit = "<?php _e("Edit File",'acf'); ?>";
559
- acf.text.image_tb_title_add = "<?php _e("Add Image to Field",'acf'); ?>";
560
- acf.text.image_tb_title_edit = "<?php _e("Edit Image",'acf'); ?>";
561
- acf.text.relationship_max_alert = "<?php _e("Maximum values reached ( {max} values )",'acf'); ?>";
562
- acf.text.gallery_tb_title_add = "<?php _e("Add Image to Gallery",'acf'); ?>";
563
- acf.text.gallery_tb_title_edit = "<?php _e("Edit Image",'acf'); ?>";
 
 
 
 
 
 
 
 
 
 
564
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
565
  </script>
566
  <?php
567
 
 
568
  foreach($this->parent->fields as $field)
569
  {
570
  $field->admin_head();
@@ -591,7 +618,7 @@ acf.text.gallery_tb_title_edit = "<?php _e("Edit Image",'acf'); ?>";
591
  'farbtastic',
592
  'thickbox',
593
  'media-upload',
594
- 'acf-input-actions',
595
  'acf-datepicker',
596
  ));
597
 
@@ -600,6 +627,13 @@ acf.text.gallery_tb_title_edit = "<?php _e("Edit Image",'acf'); ?>";
600
  {
601
  $field->admin_print_scripts();
602
  }
 
 
 
 
 
 
 
603
  }
604
 
605
 
@@ -661,9 +695,6 @@ acf.text.gallery_tb_title_edit = "<?php _e("Edit Image",'acf'); ?>";
661
  ?>
662
  <script type="text/javascript">
663
 
664
- // reset global
665
- self.parent.acf_edit_attachment = null;
666
-
667
  // remove tb
668
  self.parent.tb_remove();
669
 
@@ -671,8 +702,6 @@ acf.text.gallery_tb_title_edit = "<?php _e("Edit Image",'acf'); ?>";
671
  </head>
672
  <body>
673
 
674
- <div class="updated" id="message"><p><?php _e("Attachment updated",'acf'); ?>.</div>
675
-
676
  </body>
677
  </html
678
  <?php
@@ -713,6 +742,7 @@ acf.text.gallery_tb_title_edit = "<?php _e("Edit Image",'acf'); ?>";
713
  #adminmenuback,
714
  #adminmenuwrap,
715
  #footer,
 
716
  #media-single-form > .submit:first-child,
717
  #media-single-form td.savesend,
718
  .add-new-h2 {
37
 
38
 
39
  // save
40
+ add_action('save_post', array($this, 'save_post'), 10, 1);
 
 
 
 
 
 
41
 
42
 
43
  // custom actions (added in 3.1.8)
171
 
172
 
173
  // vars
174
+ $post_id = $post ? $post->ID : 0;
 
 
 
 
 
175
 
176
 
177
  // get field groups
196
  echo '<style type="text/css">.acf_postbox, .postbox[id*="acf_"] { display: none; }</style>';
197
 
198
 
 
 
 
 
199
  // add user js + css
200
  do_action('acf_head-input');
201
 
202
 
203
  // get acf's
204
+ $acfs = apply_filters('acf/get_field_groups', false);
205
+
206
 
207
  if($acfs)
208
  {
246
  function get_input_style($acf_id = false)
247
  {
248
  // vars
249
+ $acfs = apply_filters('acf/get_field_groups', false);
250
  $html = "";
251
 
252
  // find acf
412
  }
413
 
414
  // get acfs
415
+ $acfs = apply_filters('acf/get_field_groups', false);
416
  if( $acfs )
417
  {
418
  foreach( $acfs as $acf )
531
 
532
  function acf_head_input()
533
  {
534
+ // global
535
+ global $wp_version, $post;
536
+
537
+
538
+ // vars
539
+ $toolbars = apply_filters( 'acf/fields/wysiwyg/toolbars', array() );
540
+ $post_id = 0;
541
+ if( $post )
542
+ {
543
+ $post_id = $post->ID;
544
+ }
545
 
546
  ?>
547
  <script type="text/javascript">
548
 
549
+ // vars
550
+ acf.post_id = <?php echo $post_id; ?>;
551
+ acf.nonce = "<?php echo wp_create_nonce( 'acf_nonce' ); ?>";
552
  acf.admin_url = "<?php echo admin_url(); ?>";
553
+ acf.wp_version = "<?php echo $wp_version; ?>";
554
+
555
 
556
+ // text
557
+ acf.validation.text.error = "<?php _e("Validation Failed. One or more fields below are required.",'acf'); ?>";
558
+
559
+ acf.fields.relationship.max = "<?php _e("Maximum values reached ( {max} values )",'acf'); ?>";
560
+
561
+ acf.fields.image.text.title_add = "Select Image";
562
+ acf.fields.image.text.title_edit = "Edit Image";
563
+ acf.fields.image.text.button_add = "Select Image";
564
+
565
+ acf.fields.file.text.title_add = "Select File";
566
+ acf.fields.file.text.title_edit = "Edit File";
567
+ acf.fields.file.text.button_add = "Select File";
568
+
569
+ acf.fields.gallery.title_add = "<?php _e("Add Image to Gallery",'acf'); ?>";
570
+ acf.fields.gallery.title_edit = "<?php _e("Edit Image",'acf'); ?>";
571
+
572
+
573
+ // WYSIWYG
574
+ <?php
575
 
576
+ if( is_array($toolbars) ):
577
+ foreach( $toolbars as $label => $rows ):
578
+ $name = sanitize_title( $label );
579
+ $name = str_replace('-', '_', $name);
580
+ ?>
581
+ acf.fields.wysiwyg.toolbars.<?php echo $name; ?> = {};
582
+ <?php if( is_array($rows) ):
583
+ foreach( $rows as $k => $v ): ?>
584
+ acf.fields.wysiwyg.toolbars.<?php echo $name; ?>.theme_advanced_buttons<?php echo $k; ?> = '<?php echo implode(',', $v); ?>';
585
+ <?php endforeach;
586
+ endif;
587
+ endforeach;
588
+ endif;
589
+
590
+ ?>
591
  </script>
592
  <?php
593
 
594
+
595
  foreach($this->parent->fields as $field)
596
  {
597
  $field->admin_head();
618
  'farbtastic',
619
  'thickbox',
620
  'media-upload',
621
+ 'acf-input',
622
  'acf-datepicker',
623
  ));
624
 
627
  {
628
  $field->admin_print_scripts();
629
  }
630
+
631
+
632
+ // 3.5 media gallery
633
+ if( function_exists('wp_enqueue_media') && !did_action( 'wp_enqueue_media' ))
634
+ {
635
+ wp_enqueue_media();
636
+ }
637
  }
638
 
639
 
695
  ?>
696
  <script type="text/javascript">
697
 
 
 
 
698
  // remove tb
699
  self.parent.tb_remove();
700
 
702
  </head>
703
  <body>
704
 
 
 
705
  </body>
706
  </html
707
  <?php
742
  #adminmenuback,
743
  #adminmenuwrap,
744
  #footer,
745
+ #wpfooter,
746
  #media-single-form > .submit:first-child,
747
  #media-single-form td.savesend,
748
  .add-new-h2 {
core/controllers/location.php CHANGED
@@ -79,7 +79,7 @@ class acf_location
79
  // vars
80
  $options = array(
81
  'nonce' => '',
82
- 'return' => 'json'
83
  );
84
 
85
 
@@ -131,7 +131,7 @@ class acf_location
131
  'ef_user' => 0,
132
  'ef_media' => 0,
133
  'lang' => 0,
134
- 'return' => 'php'
135
  );
136
 
137
 
@@ -176,7 +176,7 @@ class acf_location
176
  }
177
 
178
 
179
- if( $acf['location']['rules'] )
180
  {
181
  // defaults
182
  $rule_defaults = array(
@@ -239,17 +239,22 @@ class acf_location
239
 
240
  if( !$post_type )
241
  {
 
 
 
 
 
242
  $post_type = get_post_type( $options['post_id'] );
243
  }
244
 
245
 
246
  if( $rule['operator'] == "==" )
247
  {
248
- $match = ( $post_type == $rule['value'] );
249
  }
250
  elseif( $rule['operator'] == "!=" )
251
  {
252
- $match = ( $post_type != $rule['value'] );
253
  }
254
 
255
 
@@ -410,18 +415,24 @@ class acf_location
410
 
411
  // vars
412
  $post = get_post( $options['post_id'] );
413
- $page_parent = $post->post_parent;
 
 
 
 
 
414
 
415
 
416
  if($rule['operator'] == "==")
417
  {
418
- $match = ( $page_parent == $rule['value'] );
419
  }
420
  elseif($rule['operator'] == "!=")
421
  {
422
- $match = ( $page_parent != $rule['value'] );
423
  }
424
-
 
425
  return $match;
426
 
427
  }
@@ -463,11 +474,11 @@ class acf_location
463
 
464
  if($rule['operator'] == "==")
465
  {
466
- $match = ( $page_template == $rule['value'] );
467
  }
468
  elseif($rule['operator'] == "!=")
469
  {
470
- $match = ( $page_template != $rule['value'] );
471
  }
472
 
473
  return $match;
@@ -485,47 +496,61 @@ class acf_location
485
 
486
  function rule_match_post_category( $match, $rule, $options )
487
  {
488
- $cats = $options['post_category'];
489
-
490
- if( empty($cats) )
491
  {
492
- if( !$options['post_id'] )
493
- {
494
- return false;
495
- }
496
-
497
- $all_cats = get_the_category( $options['post_id'] );
498
- foreach( $all_cats as $cat )
499
- {
500
- $cats[] = $cat->term_id;
501
- }
502
  }
503
-
504
- $post_type = $options['post_type'];
505
 
506
- if( !$post_type )
 
 
507
  {
508
- $post_type = get_post_type( $options['post_id'] );
509
  }
510
 
511
- $taxonomies = get_object_taxonomies( $post_type );
512
-
513
-
514
 
515
- // If no $cats, this is a new post and should be treated as if it has the "Uncategorized" (1) category ticked
516
- if( in_array('category', $taxonomies) && empty($cats) )
 
 
 
 
 
517
  {
518
- $cats[] = '1';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
519
  }
520
-
521
 
 
522
  if($rule['operator'] == "==")
523
  {
524
  $match = false;
525
 
526
- if($cats)
527
  {
528
- if( in_array($rule['value'], $cats) )
529
  {
530
  $match = true;
531
  }
@@ -536,18 +561,19 @@ class acf_location
536
  {
537
  $match = true;
538
 
539
- if($cats)
540
  {
541
- if( in_array($rule['value'], $cats) )
542
  {
543
  $match = false;
544
  }
545
  }
546
 
547
  }
 
548
 
549
  return $match;
550
-
551
  }
552
 
553
 
@@ -610,11 +636,11 @@ class acf_location
610
 
611
  if($rule['operator'] == "==")
612
  {
613
- $match = ( $plugin_page == $rule['value'] );
614
  }
615
  elseif($rule['operator'] == "!=")
616
  {
617
- $match = ( $plugin_page != $rule['value'] );
618
  }
619
 
620
 
@@ -635,24 +661,49 @@ class acf_location
635
  {
636
  // vars
637
  $post_format = $options['post_format'];
638
- if( ! $post_format )
639
- {
640
- $post_format = get_post_format( $options['post_id'] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
641
  }
642
-
643
 
644
  if($rule['operator'] == "==")
645
  {
646
- $match = ( $post_format == $rule['value'] );
 
647
  }
648
  elseif($rule['operator'] == "!=")
649
  {
650
- $match = ( $post_format != $rule['value'] );
651
  }
652
-
653
 
654
  return $match;
655
 
 
656
  }
657
 
658
 
@@ -666,46 +717,57 @@ class acf_location
666
 
667
  function rule_match_taxonomy( $match, $rule, $options )
668
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
669
  $terms = $options['taxonomy'];
670
 
671
 
672
- if( empty($terms) )
 
673
  {
674
- if( !$options['post_id'] )
 
675
  {
676
- return false;
677
- }
678
-
679
- $post_type = $options['post_type'];
680
-
681
- if( !$post_type )
682
- {
683
- $post_type = get_post_type( $options['post_id'] );
684
- }
685
-
686
- $taxonomies = get_object_taxonomies( $post_type );
687
-
688
- if($taxonomies)
689
- {
690
- foreach($taxonomies as $tax)
691
- {
692
- $all_terms = get_the_terms( $options['post_id'], $tax );
693
- if($all_terms)
694
  {
695
- foreach($all_terms as $all_term)
 
696
  {
697
- $terms[] = $all_term->term_id;
 
 
 
698
  }
699
  }
700
  }
701
  }
702
- }
703
-
704
-
705
- // If no $cats, this is a new post and should be treated as if it has the "Uncategorized" (1) category ticked
706
- if( in_array('category', $taxonomies) && empty($terms) )
707
- {
708
- $terms[] = '1';
 
 
 
 
709
  }
710
 
711
 
@@ -763,7 +825,7 @@ class acf_location
763
  $match = ( $ef_taxonomy == $rule['value'] );
764
 
765
  // override for "all"
766
- if( $rule['value'] == "all" )
767
  {
768
  $match = true;
769
  }
@@ -774,7 +836,7 @@ class acf_location
774
  $match = ( $ef_taxonomy != $rule['value'] );
775
 
776
  // override for "all"
777
- if( $rule['value'] == "all" )
778
  {
779
  $match = false;
780
  }
@@ -813,12 +875,12 @@ class acf_location
813
  $match = ( user_can($ef_user, $rule['value']) );
814
 
815
  // override for "all"
816
- if( $rule['value'] == "all" )
817
  {
818
  $match = true;
819
  }
820
  }
821
- elseif($rule['operator'] == "!=")
822
  {
823
  $match = ( !user_can($ef_user, $rule['value']) );
824
 
@@ -866,7 +928,7 @@ class acf_location
866
  if($rule['operator'] == "==")
867
  {
868
  // override for "all"
869
- if( $rule['value'] == "all" )
870
  {
871
  $match = true;
872
  }
@@ -874,7 +936,7 @@ class acf_location
874
  elseif($rule['operator'] == "!=")
875
  {
876
  // override for "all"
877
- if( $rule['value'] == "all" )
878
  {
879
  $match = false;
880
  }
79
  // vars
80
  $options = array(
81
  'nonce' => '',
82
+ 'ajax' => true
83
  );
84
 
85
 
131
  'ef_user' => 0,
132
  'ef_media' => 0,
133
  'lang' => 0,
134
+ 'ajax' => false
135
  );
136
 
137
 
176
  }
177
 
178
 
179
+ if( is_array($acf['location']['rules']) )
180
  {
181
  // defaults
182
  $rule_defaults = array(
239
 
240
  if( !$post_type )
241
  {
242
+ if( !$options['post_id'] )
243
+ {
244
+ return false;
245
+ }
246
+
247
  $post_type = get_post_type( $options['post_id'] );
248
  }
249
 
250
 
251
  if( $rule['operator'] == "==" )
252
  {
253
+ $match = ( $post_type === $rule['value'] );
254
  }
255
  elseif( $rule['operator'] == "!=" )
256
  {
257
+ $match = ( $post_type !== $rule['value'] );
258
  }
259
 
260
 
415
 
416
  // vars
417
  $post = get_post( $options['post_id'] );
418
+
419
+ $post_parent = $post->post_parent;
420
+ if( $options['page_parent'] )
421
+ {
422
+ $post_parent = $options['page_parent'];
423
+ }
424
 
425
 
426
  if($rule['operator'] == "==")
427
  {
428
+ $match = ( $post_parent == $rule['value'] );
429
  }
430
  elseif($rule['operator'] == "!=")
431
  {
432
+ $match = ( $post_parent != $rule['value'] );
433
  }
434
+
435
+
436
  return $match;
437
 
438
  }
474
 
475
  if($rule['operator'] == "==")
476
  {
477
+ $match = ( $page_template === $rule['value'] );
478
  }
479
  elseif($rule['operator'] == "!=")
480
  {
481
+ $match = ( $page_template !== $rule['value'] );
482
  }
483
 
484
  return $match;
496
 
497
  function rule_match_post_category( $match, $rule, $options )
498
  {
499
+ // validate
500
+ if( !$options['post_id'] )
 
501
  {
502
+ return false;
 
 
 
 
 
 
 
 
 
503
  }
 
 
504
 
505
+
506
+ // post type
507
+ if( !$options['post_type'] )
508
  {
509
+ $options['post_type'] = get_post_type( $options['post_id'] );
510
  }
511
 
 
 
 
512
 
513
+ // vars
514
+ $taxonomies = get_object_taxonomies( $options['post_type'] );
515
+ $terms = $options['post_category'];
516
+
517
+
518
+ // not AJAX
519
+ if( !$options['ajax'] )
520
  {
521
+ // no terms? Load them from the post_id
522
+ if( empty($terms) )
523
+ {
524
+ $all_terms = get_the_terms( $options['post_id'], 'category' );
525
+ if($all_terms)
526
+ {
527
+ foreach($all_terms as $all_term)
528
+ {
529
+ $terms[] = $all_term->term_id;
530
+ }
531
+ }
532
+ }
533
+
534
+
535
+ // no terms at all?
536
+ if( empty($terms) )
537
+ {
538
+ // If no ters, this is a new post and should be treated as if it has the "Uncategorized" (1) category ticked
539
+ if( is_array($taxonomies) && in_array('category', $taxonomies) )
540
+ {
541
+ $terms[] = '1';
542
+ }
543
+ }
544
  }
 
545
 
546
+
547
  if($rule['operator'] == "==")
548
  {
549
  $match = false;
550
 
551
+ if($terms)
552
  {
553
+ if( in_array($rule['value'], $terms) )
554
  {
555
  $match = true;
556
  }
561
  {
562
  $match = true;
563
 
564
+ if($terms)
565
  {
566
+ if( in_array($rule['value'], $terms) )
567
  {
568
  $match = false;
569
  }
570
  }
571
 
572
  }
573
+
574
 
575
  return $match;
576
+
577
  }
578
 
579
 
636
 
637
  if($rule['operator'] == "==")
638
  {
639
+ $match = ( $plugin_page === $rule['value'] );
640
  }
641
  elseif($rule['operator'] == "!=")
642
  {
643
+ $match = ( $plugin_page !== $rule['value'] );
644
  }
645
 
646
 
661
  {
662
  // vars
663
  $post_format = $options['post_format'];
664
+ if( !$post_format )
665
+ {
666
+ // validate
667
+ if( !$options['post_id'] )
668
+ {
669
+ return false;
670
+ }
671
+
672
+
673
+ // post type
674
+ if( !$options['post_type'] )
675
+ {
676
+ $options['post_type'] = get_post_type( $options['post_id'] );
677
+ }
678
+
679
+
680
+ // does post_type support 'post-format'
681
+ if( post_type_supports( $options['post_type'], 'post-formats' ) )
682
+ {
683
+ $post_format = get_post_format( $options['post_id'] );
684
+
685
+ if( $post_format === false )
686
+ {
687
+ $post_format = 'standard';
688
+ }
689
+ }
690
  }
691
+
692
 
693
  if($rule['operator'] == "==")
694
  {
695
+ $match = ( $post_format === $rule['value'] );
696
+
697
  }
698
  elseif($rule['operator'] == "!=")
699
  {
700
+ $match = ( $post_format !== $rule['value'] );
701
  }
702
+
703
 
704
  return $match;
705
 
706
+
707
  }
708
 
709
 
717
 
718
  function rule_match_taxonomy( $match, $rule, $options )
719
  {
720
+ // validate
721
+ if( !$options['post_id'] )
722
+ {
723
+ return false;
724
+ }
725
+
726
+
727
+ // post type
728
+ if( !$options['post_type'] )
729
+ {
730
+ $options['post_type'] = get_post_type( $options['post_id'] );
731
+ }
732
+
733
+
734
+ // vars
735
+ $taxonomies = get_object_taxonomies( $options['post_type'] );
736
  $terms = $options['taxonomy'];
737
 
738
 
739
+ // not AJAX
740
+ if( !$options['ajax'] )
741
  {
742
+ // no terms? Load them from the post_id
743
+ if( empty($terms) )
744
  {
745
+ if( is_array($taxonomies) )
746
+ {
747
+ foreach( $taxonomies as $tax )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
748
  {
749
+ $all_terms = get_the_terms( $options['post_id'], $tax );
750
+ if($all_terms)
751
  {
752
+ foreach($all_terms as $all_term)
753
+ {
754
+ $terms[] = $all_term->term_id;
755
+ }
756
  }
757
  }
758
  }
759
  }
760
+
761
+
762
+ // no terms at all?
763
+ if( empty($terms) )
764
+ {
765
+ // If no ters, this is a new post and should be treated as if it has the "Uncategorized" (1) category ticked
766
+ if( is_array($taxonomies) && in_array('category', $taxonomies) )
767
+ {
768
+ $terms[] = '1';
769
+ }
770
+ }
771
  }
772
 
773
 
825
  $match = ( $ef_taxonomy == $rule['value'] );
826
 
827
  // override for "all"
828
+ if( $rule['value'] === "all" )
829
  {
830
  $match = true;
831
  }
836
  $match = ( $ef_taxonomy != $rule['value'] );
837
 
838
  // override for "all"
839
+ if( $rule['value'] === "all" )
840
  {
841
  $match = false;
842
  }
875
  $match = ( user_can($ef_user, $rule['value']) );
876
 
877
  // override for "all"
878
+ if( $rule['value'] === "all" )
879
  {
880
  $match = true;
881
  }
882
  }
883
+ elseif($rule['operator'] === "!=")
884
  {
885
  $match = ( !user_can($ef_user, $rule['value']) );
886
 
928
  if($rule['operator'] == "==")
929
  {
930
  // override for "all"
931
+ if( $rule['value'] === "all" )
932
  {
933
  $match = true;
934
  }
936
  elseif($rule['operator'] == "!=")
937
  {
938
  // override for "all"
939
+ if( $rule['value'] === "all" )
940
  {
941
  $match = false;
942
  }
core/controllers/options_page.php CHANGED
@@ -153,7 +153,7 @@ class acf_options_page
153
 
154
 
155
  // get acf's
156
- $acfs = $this->parent->get_field_groups();
157
  if($acfs)
158
  {
159
  foreach($acfs as $acf)
153
 
154
 
155
  // get acf's
156
+ $acfs = apply_filters('acf/get_field_groups', false);
157
  if($acfs)
158
  {
159
  foreach($acfs as $acf)
core/controllers/settings.php CHANGED
@@ -357,7 +357,7 @@ class acf_settings
357
  <input type="hidden" name="action" value="export_xml" />
358
  <?php
359
 
360
- $this->parent->create_field(array(
361
  'type' => 'select',
362
  'name' => 'acf_posts',
363
  'value' => '',
@@ -394,7 +394,7 @@ class acf_settings
394
  <input type="hidden" name="action" value="export_php" />
395
  <?php
396
 
397
- $this->parent->create_field(array(
398
  'type' => 'select',
399
  'name' => 'acf_posts',
400
  'value' => '',
357
  <input type="hidden" name="action" value="export_xml" />
358
  <?php
359
 
360
+ do_action('acf/create_field', array(
361
  'type' => 'select',
362
  'name' => 'acf_posts',
363
  'value' => '',
394
  <input type="hidden" name="action" value="export_php" />
395
  <?php
396
 
397
+ do_action('acf/create_field', array(
398
  'type' => 'select',
399
  'name' => 'acf_posts',
400
  'value' => '',
core/controllers/third_party.php CHANGED
@@ -127,7 +127,7 @@ class acf_third_party
127
  function tabify_add_meta_boxes( $post_type )
128
  {
129
  // get acf's
130
- $acfs = $this->parent->get_field_groups();
131
 
132
  if($acfs)
133
  {
127
  function tabify_add_meta_boxes( $post_type )
128
  {
129
  // get acf's
130
+ $acfs = apply_filters('acf/get_field_groups', false);
131
 
132
  if($acfs)
133
  {
core/fields/acf_field.php CHANGED
@@ -112,7 +112,11 @@ class acf_Field
112
  function update_value($post_id, $field, $value)
113
  {
114
  // strip slashes
115
- $value = stripslashes_deep($value);
 
 
 
 
116
 
117
 
118
  // apply filters
@@ -131,17 +135,23 @@ class acf_Field
131
  // if $post_id is a string, then it is used in the everything fields and can be found in the options table
132
  if( is_numeric($post_id) )
133
  {
134
- update_post_meta($post_id, $field['name'], $value);
135
- update_post_meta($post_id, '_' . $field['name'], $field['key']);
 
136
  }
137
  elseif( strpos($post_id, 'user_') !== false )
138
  {
139
- $post_id = str_replace('user_', '', $post_id);
140
- update_user_meta($post_id, $field['name'], $value);
141
- update_user_meta($post_id, '_' . $field['name'], $field['key']);
142
  }
143
  else
144
  {
 
 
 
 
 
145
  update_option( $post_id . '_' . $field['name'], $value );
146
  update_option( '_' . $post_id . '_' . $field['name'], $field['key'] );
147
  }
@@ -153,6 +163,37 @@ class acf_Field
153
  }
154
 
155
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
 
157
  /*--------------------------------------------------------------------------------------
158
  *
112
  function update_value($post_id, $field, $value)
113
  {
114
  // strip slashes
115
+ // - not needed? http://support.advancedcustomfields.com/discussion/3168/backslashes-stripped-in-wysiwyg-filed
116
+ if( get_magic_quotes_gpc() )
117
+ {
118
+ $value = stripslashes_deep($value);
119
+ }
120
 
121
 
122
  // apply filters
135
  // if $post_id is a string, then it is used in the everything fields and can be found in the options table
136
  if( is_numeric($post_id) )
137
  {
138
+ // allow ACF to save to revision!
139
+ update_metadata('post', $post_id, $field['name'], $value );
140
+ update_metadata('post', $post_id, '_' . $field['name'], $field['key']);
141
  }
142
  elseif( strpos($post_id, 'user_') !== false )
143
  {
144
+ $user_id = str_replace('user_', '', $post_id);
145
+ update_metadata('user', $user_id, $field['name'], $value);
146
+ update_metadata('user', $user_id, '_' . $field['name'], $field['key']);
147
  }
148
  else
149
  {
150
+ // for some reason, update_option does not use stripslashes_deep.
151
+ // update_metadata -> http://core.trac.wordpress.org/browser/tags/3.4.2/wp-includes/meta.php#L82: line 101 (does use stripslashes_deep)
152
+ // update_option -> http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/option.php#L0: line 215 (does not use stripslashes_deep)
153
+ $value = stripslashes_deep($value);
154
+
155
  update_option( $post_id . '_' . $field['name'], $value );
156
  update_option( '_' . $post_id . '_' . $field['name'], $field['key'] );
157
  }
163
  }
164
 
165
 
166
+ /*
167
+ * delete_value
168
+ *
169
+ * @description:
170
+ * @since: 3.5.8
171
+ * @created: 19/01/13
172
+ */
173
+
174
+ function delete_value($post_id, $key)
175
+ {
176
+ // if $post_id is a string, then it is used in the everything fields and can be found in the options table
177
+ if( is_numeric($post_id) )
178
+ {
179
+ delete_post_meta( $post_id, $key );
180
+ delete_post_meta( $post_id, '_' . $key );
181
+ }
182
+ elseif( strpos($post_id, 'user_') !== false )
183
+ {
184
+ $post_id = str_replace('user_', '', $post_id);
185
+ delete_user_meta( $post_id, $key );
186
+ delete_user_meta( $post_id, '_' . $key );
187
+ }
188
+ else
189
+ {
190
+ delete_option( $post_id . '_' . $key );
191
+ delete_option( '_' . $post_id . '_' . $key );
192
+ }
193
+
194
+ }
195
+
196
+
197
 
198
  /*--------------------------------------------------------------------------------------
199
  *
core/fields/checkbox.php CHANGED
@@ -91,46 +91,67 @@ class acf_Checkbox extends acf_Field
91
 
92
  function create_options($key, $field)
93
  {
94
- // defaults
 
 
 
 
 
 
95
 
96
 
97
  // implode checkboxes so they work in a textarea
98
- if(isset($field['choices']) && is_array($field['choices']))
99
  {
100
- foreach($field['choices'] as $choice_key => $choice_val)
101
  {
102
- $field['choices'][$choice_key] = $choice_key.' : '.$choice_val;
103
  }
104
  $field['choices'] = implode("\n", $field['choices']);
105
  }
106
- else
107
- {
108
- $field['choices'] = "";
109
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  ?>
111
- <tr class="field_option field_option_<?php echo $this->name; ?>">
112
- <td class="label">
113
- <label for=""><?php _e("Choices",'acf'); ?></label>
114
- <p class="description"><?php _e("Enter your choices one per line",'acf'); ?><br />
115
- <br />
116
- <?php _e("Red",'acf'); ?><br />
117
- <?php _e("Blue",'acf'); ?><br />
118
- <br />
119
- <?php _e("red : Red",'acf'); ?><br />
120
- <?php _e("blue : Blue",'acf'); ?><br />
121
- </p>
122
- </td>
123
- <td>
124
- <?php
125
- $this->parent->create_field(array(
126
- 'type' => 'textarea',
127
- 'class' => 'textarea field_option-choices',
128
- 'name' => 'fields['.$key.'][choices]',
129
- 'value' => $field['choices'],
130
- ));
131
- ?>
132
- </td>
133
- </tr>
134
  <?php
135
  }
136
 
91
 
92
  function create_options($key, $field)
93
  {
94
+ // vars
95
+ $defaults = array(
96
+ 'default_value' => '',
97
+ 'choices' => '',
98
+ );
99
+
100
+ $field = array_merge($defaults, $field);
101
 
102
 
103
  // implode checkboxes so they work in a textarea
104
+ if( is_array($field['choices']) )
105
  {
106
+ foreach( $field['choices'] as $k => $v )
107
  {
108
+ $field['choices'][ $k ] = $k . ' : ' . $v;
109
  }
110
  $field['choices'] = implode("\n", $field['choices']);
111
  }
112
+
113
+ ?>
114
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
115
+ <td class="label">
116
+ <label for=""><?php _e("Choices",'acf'); ?></label>
117
+ <p class="description"><?php _e("Enter your choices one per line",'acf'); ?><br />
118
+ <br />
119
+ <?php _e("Red",'acf'); ?><br />
120
+ <?php _e("Blue",'acf'); ?><br />
121
+ <br />
122
+ <?php _e("red : Red",'acf'); ?><br />
123
+ <?php _e("blue : Blue",'acf'); ?><br />
124
+ </p>
125
+ </td>
126
+ <td>
127
+ <?php
128
+
129
+ do_action('acf/create_field', array(
130
+ 'type' => 'textarea',
131
+ 'class' => 'textarea field_option-choices',
132
+ 'name' => 'fields['.$key.'][choices]',
133
+ 'value' => $field['choices'],
134
+ ));
135
+
136
+ ?>
137
+ </td>
138
+ </tr>
139
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
140
+ <td class="label">
141
+ <label><?php _e("Default Value",'acf'); ?></label>
142
+ </td>
143
+ <td>
144
+ <?php
145
+
146
+ do_action('acf/create_field', array(
147
+ 'type' => 'text',
148
+ 'name' => 'fields['.$key.'][default_value]',
149
+ 'value' => $field['default_value'],
150
+ ));
151
+
152
  ?>
153
+ </td>
154
+ </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  <?php
156
  }
157
 
core/fields/color_picker.php CHANGED
@@ -69,7 +69,7 @@ class acf_Color_picker extends acf_Field
69
  </td>
70
  <td>
71
  <?php
72
- $this->parent->create_field(array(
73
  'type' => 'text',
74
  'name' => 'fields['.$key.'][default_value]',
75
  'value' => $field['default_value'],
69
  </td>
70
  <td>
71
  <?php
72
+ do_action('acf/create_field', array(
73
  'type' => 'text',
74
  'name' => 'fields['.$key.'][default_value]',
75
  'value' => $field['default_value'],
core/fields/date_picker/date_picker.php CHANGED
@@ -98,7 +98,7 @@ class acf_Date_picker extends acf_Field
98
  <td class="label">
99
  <label><?php _e("Display format",'acf'); ?></label>
100
  <p class="description"><?php _e("This format will be seen by the user when entering a value",'acf'); ?></p>
101
- <p><?php _e("\"dd/mm/yy\" or \"mm/dd/yy\" are the most used display formats. Read more about",'acf'); ?> <a href="http://docs.jquery.com/UI/Datepicker/formatDate"><?php _e("jQuery date formats",'acf'); ?></a></p>
102
  </td>
103
  <td>
104
  <input type="text" name="fields[<?php echo $key; ?>][display_format]" value="<?php echo $field['display_format']; ?>" />
98
  <td class="label">
99
  <label><?php _e("Display format",'acf'); ?></label>
100
  <p class="description"><?php _e("This format will be seen by the user when entering a value",'acf'); ?></p>
101
+ <p><?php _e("\"dd/mm/yy\" or \"mm/dd/yy\" are the most used display formats. Read more about",'acf'); ?> <a href="http://docs.jquery.com/UI/Datepicker/formatDate" target="_blank"><?php _e("jQuery date formats",'acf'); ?></a></p>
102
  </td>
103
  <td>
104
  <input type="text" name="fields[<?php echo $key; ?>][display_format]" value="<?php echo $field['display_format']; ?>" />
core/fields/file.php CHANGED
@@ -22,8 +22,9 @@ class acf_File extends acf_Field
22
 
23
  add_action('admin_head-media-upload-popup', array($this, 'popup_head'));
24
  add_filter('get_media_item_args', array($this, 'allow_file_insertion'));
25
- add_action('wp_ajax_acf_select_file', array($this, 'ajax_select_file'));
26
  add_action('acf_head-update_attachment-file', array($this, 'acf_head_update_attachment'));
 
 
27
  }
28
 
29
 
@@ -42,11 +43,11 @@ class acf_File extends acf_Field
42
  (function($){
43
 
44
  // vars
45
- var div = self.parent.acf_edit_attachment;
46
 
47
 
48
  // add message
49
- self.parent.acf.add_message("<?php _e("File Updated.",'acf'); ?>", div);
50
 
51
 
52
  })(jQuery);
@@ -55,71 +56,57 @@ class acf_File extends acf_Field
55
  }
56
 
57
 
58
- /*--------------------------------------------------------------------------------------
59
- *
60
- * render_file
61
- *
62
- * @description : Renders the file html from an ID
63
- * @author Elliot Condon
64
- * @since 3.1.6
65
- *
66
- *-------------------------------------------------------------------------------------*/
67
 
68
- function render_file($id = null)
69
  {
70
- if(!$id)
71
- {
72
- echo "";
73
- return;
74
- }
75
-
76
-
77
  // vars
78
- $file_src = wp_get_attachment_url($id);
79
- preg_match("~[^/]*$~", $file_src, $file_name);
80
- $class = "active";
81
-
82
-
83
- ?>
84
- <ul class="hl clearfix">
85
- <li data-mime="<?php echo get_post_mime_type( $id ) ; ?>">
86
- <img class="acf-file-icon" src="<?php echo wp_mime_type_icon( $id ); ?>" alt=""/>
87
- </li>
88
- <li>
89
- <span class="acf-file-name"><?php echo $file_name[0]; ?></span><br />
90
- <a href="#" class="edit-file"><?php _e('Edit','acf'); ?></a>
91
- <a href="#" class="remove-file"><?php _e('Remove','acf'); ?></a>
92
- </li>
93
- </ul>
94
- <?php
95
-
96
- }
97
-
98
- /*--------------------------------------------------------------------------------------
99
- *
100
- * ajax_select_file
101
- *
102
- * @description ajax function to provide url of selected file
103
- * @author Elliot Condon
104
- * @since 3.1.5
105
- *
106
- *-------------------------------------------------------------------------------------*/
107
-
108
- function ajax_select_file()
109
- {
110
- $id = isset($_POST['id']) ? $_POST['id'] : false;
111
-
112
-
113
- // attachment ID is required
114
- if(!$id)
115
- {
116
- echo "";
117
- die();
118
- }
119
-
120
- $this->render_file($id);
121
-
122
- die();
123
  }
124
 
125
 
@@ -153,18 +140,41 @@ class acf_File extends acf_Field
153
  {
154
 
155
  // vars
156
- $class = $field['value'] ? "active" : "";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
 
158
  ?>
159
- <div class="acf-file-uploader <?php echo $class; ?>">
160
- <input class="value" type="hidden" name="<?php echo $field['name']; ?>" value="<?php echo $field['value']; ?>" />
161
  <div class="has-file">
162
- <?php $this->render_file( $field['value'] ); ?>
 
 
 
 
 
 
 
 
 
163
  </div>
164
  <div class="no-file">
165
  <ul class="hl clearfix">
166
  <li>
167
- <span class="acf-file-name"><?php _e('No File Selected','acf'); ?></span>. <a href="#" class="button add-file"><?php _e('Add File','acf'); ?></a>
168
  </li>
169
  </ul>
170
  </div>
@@ -200,18 +210,20 @@ class acf_File extends acf_Field
200
  <label><?php _e("Return Value",'acf'); ?></label>
201
  </td>
202
  <td>
203
- <?php
204
- $this->parent->create_field(array(
205
- 'type' => 'radio',
206
- 'name' => 'fields['.$key.'][save_format]',
207
- 'value' => $field['save_format'],
 
208
  'layout' => 'horizontal',
209
- 'choices' => array(
210
  'object' => __("File Object",'acf'),
211
  'url' => __("File URL",'acf'),
212
  'id' => __("File ID",'acf')
213
  )
214
  ));
 
215
  ?>
216
  </td>
217
  </tr>
@@ -333,83 +345,6 @@ class acf_File extends acf_Field
333
  <script type="text/javascript">
334
  (function($){
335
 
336
- /*
337
- * Vars
338
- *
339
- * @description:
340
- * @since: 2.0.4
341
- * @created: 11/12/12
342
- */
343
-
344
- var options = {
345
- id : []
346
- };
347
-
348
-
349
- /*
350
- * add_next_file
351
- *
352
- * @description:
353
- * @since: 2.0.4
354
- * @created: 11/12/12
355
- */
356
-
357
- function add_next_file()
358
- {
359
- // vars
360
- var next_id = options.id[0],
361
- ajax_data = {
362
- action : 'acf_select_file',
363
- id : next_id
364
- };
365
-
366
-
367
- // ajax
368
- $.post( ajaxurl, ajax_data, function( html ){
369
-
370
- // validate
371
- if( !html )
372
- {
373
- return false;
374
- }
375
-
376
-
377
- // add file to acf_div
378
- self.parent.acf_div.find('input.value').val( next_id ).trigger('change');
379
- self.parent.acf_div.find('.has-file').html(html);
380
- self.parent.acf_div.addClass('active');
381
-
382
-
383
- // validation
384
- self.parent.acf_div.closest('.field').removeClass('error');
385
-
386
-
387
- // remove first id from array
388
- options.id.splice(0, 1);
389
-
390
-
391
- // are there more id's to add? (multiple selection for repeater)
392
- if( options.id.length > 0 )
393
- {
394
- // add row
395
- self.parent.acf_div.closest('.repeater').find('.add-row-end').trigger('click');
396
-
397
- // set acf_div to new row file
398
- self.parent.acf_div = self.parent.acf_div.closest('.repeater').find('> table > tbody > tr.row:last .acf-file-uploader');
399
-
400
- // add the next file
401
- add_next_file();
402
- }
403
- else
404
- {
405
- // reset acf_div and return false
406
- self.parent.acf_div = null;
407
- self.parent.tb_remove();
408
- }
409
-
410
- });
411
- }
412
-
413
 
414
  /*
415
  * Select File
@@ -421,25 +356,49 @@ class acf_File extends acf_Field
421
 
422
  $('#media-items .media-item a.acf-select').live('click', function(){
423
 
424
- // vars
425
- var new_id = $(this).attr('href');
426
 
427
 
428
  // IE7 Fix
429
- if( new_id.indexOf("/") != -1 )
430
  {
431
- var split = new_id.split("/");
432
- new_id = split[ split.length-1 ];
433
  }
434
 
435
 
436
- // add to id array
437
- options.id.push( new_id );
 
 
 
 
438
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
439
 
440
- // add the next file
441
- add_next_file();
442
-
443
 
444
  return false;
445
  });
@@ -463,17 +422,85 @@ class acf_File extends acf_Field
463
  return false;
464
  }
465
 
 
 
 
 
 
 
 
466
 
467
  // add to id array
468
  $('#media-items .media-item .acf-checkbox:checked').each(function(){
 
 
 
 
 
469
 
470
- options.id.push( $(this).val() );
 
 
 
 
 
 
 
471
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
472
  });
473
-
474
-
475
- // add the next file
476
- add_next_file();
477
 
478
 
479
  return false;
@@ -526,7 +553,7 @@ class acf_File extends acf_Field
526
  function add_buttons()
527
  {
528
  // vars
529
- var is_sub_field = (self.parent.acf_div && self.parent.acf_div.closest('.repeater').length > 0) ? true : false;
530
 
531
 
532
  // add submit after media items (on for sub fields)
22
 
23
  add_action('admin_head-media-upload-popup', array($this, 'popup_head'));
24
  add_filter('get_media_item_args', array($this, 'allow_file_insertion'));
 
25
  add_action('acf_head-update_attachment-file', array($this, 'acf_head_update_attachment'));
26
+
27
+ add_action('wp_ajax_acf/fields/file/get_files', array($this, 'ajax_get_files'));
28
  }
29
 
30
 
43
  (function($){
44
 
45
  // vars
46
+ var div = self.parent.acf.media.div;
47
 
48
 
49
  // add message
50
+ self.parent.acf.helpers.add_message("<?php _e("File Updated.",'acf'); ?>", div);
51
 
52
 
53
  })(jQuery);
56
  }
57
 
58
 
59
+ /*
60
+ * ajax_get_files
61
+ *
62
+ * @description:
63
+ * @since: 3.5.7
64
+ * @created: 13/01/13
65
+ */
 
 
66
 
67
+ function ajax_get_files()
68
  {
 
 
 
 
 
 
 
69
  // vars
70
+ $options = array(
71
+ 'nonce' => '',
72
+ 'files' => array()
73
+ );
74
+ $return = array();
75
+
76
+
77
+ // load post options
78
+ $options = array_merge($options, $_POST);
79
+
80
+
81
+ // verify nonce
82
+ if( ! wp_verify_nonce($options['nonce'], 'acf_nonce') )
83
+ {
84
+ die(0);
85
+ }
86
+
87
+
88
+ if( $options['files'] )
89
+ {
90
+ foreach( $options['files'] as $id )
91
+ {
92
+ $file_src = wp_get_attachment_url( $id );
93
+ preg_match("~[^/]*$~", $file_src, $file_name);
94
+
95
+
96
+ // vars
97
+ $return[] = array(
98
+ 'id' => $id,
99
+ 'icon' => wp_mime_type_icon( $id ),
100
+ 'name' => $file_name[0]
101
+ );
102
+ }
103
+ }
104
+
105
+
106
+ // return json
107
+ echo json_encode( $return );
108
+ die;
109
+
 
 
 
 
 
110
  }
111
 
112
 
140
  {
141
 
142
  // vars
143
+ $options = array(
144
+ 'class' => '',
145
+ 'icon' => '',
146
+ 'file_name' => ''
147
+ );
148
+
149
+ if( $field['value'] )
150
+ {
151
+ $file_src = wp_get_attachment_url( $field['value'] );
152
+ preg_match("~[^/]*$~", $file_src, $file_name);
153
+
154
+ $options['class'] = 'active';
155
+ $options['icon'] = wp_mime_type_icon( $field['value'] );
156
+ $options['file_name'] = $file_name[0];
157
+ }
158
 
159
  ?>
160
+ <div class="acf-file-uploader <?php echo $options['class']; ?>">
161
+ <input class="acf-file-value" type="hidden" name="<?php echo $field['name']; ?>" value="<?php echo $field['value']; ?>" />
162
  <div class="has-file">
163
+ <ul class="hl clearfix">
164
+ <li>
165
+ <img class="acf-file-icon" src="<?php echo $options['icon']; ?>" alt=""/>
166
+ </li>
167
+ <li>
168
+ <span class="acf-file-name"><?php echo $options['file_name']; ?></span><br />
169
+ <a href="#" class="edit-file"><?php _e('Edit','acf'); ?></a>
170
+ <a href="#" class="remove-file"><?php _e('Remove','acf'); ?></a>
171
+ </li>
172
+ </ul>
173
  </div>
174
  <div class="no-file">
175
  <ul class="hl clearfix">
176
  <li>
177
+ <span><?php _e('No File Selected','acf'); ?></span>. <a href="#" class="button add-file"><?php _e('Add File','acf'); ?></a>
178
  </li>
179
  </ul>
180
  </div>
210
  <label><?php _e("Return Value",'acf'); ?></label>
211
  </td>
212
  <td>
213
+ <?php
214
+
215
+ do_action('acf/create_field', array(
216
+ 'type' => 'radio',
217
+ 'name' => 'fields['.$key.'][save_format]',
218
+ 'value' => $field['save_format'],
219
  'layout' => 'horizontal',
220
+ 'choices' => array(
221
  'object' => __("File Object",'acf'),
222
  'url' => __("File URL",'acf'),
223
  'id' => __("File ID",'acf')
224
  )
225
  ));
226
+
227
  ?>
228
  </td>
229
  </tr>
345
  <script type="text/javascript">
346
  (function($){
347
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
348
 
349
  /*
350
  * Select File
356
 
357
  $('#media-items .media-item a.acf-select').live('click', function(){
358
 
359
+ var id = $(this).attr('href');
 
360
 
361
 
362
  // IE7 Fix
363
+ if( id.indexOf("/") != -1 )
364
  {
365
+ var split = id.split("/");
366
+ id = split[split.length-1];
367
  }
368
 
369
 
370
+ var ajax_data = {
371
+ action : 'acf/fields/file/get_files',
372
+ nonce : self.parent.acf.nonce,
373
+ files : [ id ]
374
+ };
375
+
376
 
377
+ // ajax
378
+ $.ajax({
379
+ url: ajaxurl,
380
+ type: 'post',
381
+ data : ajax_data,
382
+ cache: false,
383
+ dataType: "json",
384
+ success: function( json ) {
385
+
386
+ // validate
387
+ if( !json )
388
+ {
389
+ return false;
390
+ }
391
+
392
+
393
+ // add file
394
+ self.parent.acf.fields.file.add( json[0] );
395
+
396
+ self.parent.tb_remove();
397
+
398
+
399
+ }
400
+ });
401
 
 
 
 
402
 
403
  return false;
404
  });
422
  return false;
423
  }
424
 
425
+
426
+ var ajax_data = {
427
+ action : 'acf/fields/file/get_files',
428
+ nonce : self.parent.acf.nonce,
429
+ files : []
430
+ };
431
+
432
 
433
  // add to id array
434
  $('#media-items .media-item .acf-checkbox:checked').each(function(){
435
+
436
+ ajax_data.files.push( $(this).val() );
437
+
438
+ });
439
+
440
 
441
+ // ajax
442
+ $.ajax({
443
+ url: ajaxurl,
444
+ type: 'post',
445
+ data : ajax_data,
446
+ cache: false,
447
+ dataType: "json",
448
+ success: function( json ) {
449
 
450
+ // validate
451
+ if( !json )
452
+ {
453
+ return false;
454
+ }
455
+
456
+
457
+
458
+ var selection = json,
459
+ i = 0;
460
+
461
+
462
+ $.each( json, function( k, file ){
463
+
464
+ // counter
465
+ i++;
466
+
467
+
468
+ // vars
469
+ var div = self.parent.acf.media.div;
470
+
471
+
472
+ // add image to field
473
+ self.parent.acf.fields.file.add( file );
474
+
475
+
476
+ // select / add another file field?
477
+ if( i < selection.length )
478
+ {
479
+ var tr = div.closest('tr'),
480
+ repeater = tr.closest('.repeater');
481
+
482
+
483
+ if( tr.next('.row').exists() )
484
+ {
485
+ self.parent.acf.media.div = tr.next('.row').find('.acf-file-uploader');
486
+ }
487
+ else
488
+ {
489
+ // add row
490
+ repeater.find('.add-row-end').trigger('click');
491
+
492
+ // set div to new row file
493
+ self.parent.acf.media.div = repeater.find('> table > tbody > tr.row:last .acf-file-uploader');
494
+ }
495
+ }
496
+
497
+ });
498
+
499
+
500
+ self.parent.tb_remove();
501
+
502
+ }
503
  });
 
 
 
 
504
 
505
 
506
  return false;
553
  function add_buttons()
554
  {
555
  // vars
556
+ var is_sub_field = (self.parent.acf.media.div.closest('.repeater').length > 0) ? true : false;
557
 
558
 
559
  // add submit after media items (on for sub fields)
core/fields/flexible_content.php CHANGED
@@ -23,8 +23,70 @@ class acf_Flexible_content extends acf_Field
23
 
24
  // filters
25
  add_filter('acf_save_field-' . $this->name, array($this, 'acf_save_field'));
 
26
  }
27
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  /*--------------------------------------------------------------------------------------
30
  *
@@ -67,7 +129,7 @@ class acf_Flexible_content extends acf_Field
67
  <?php if( $layout['display'] == 'table' ): ?>
68
  <thead>
69
  <tr>
70
- <?php foreach( $layout['sub_fields'] as $sub_field_i => $sub_field):
71
 
72
  // add width attr
73
  $attr = "";
@@ -104,7 +166,7 @@ class acf_Flexible_content extends acf_Field
104
 
105
  // loop though sub fields
106
 
107
- foreach( $layout['sub_fields'] as $j => $sub_field ): ?>
108
 
109
  <?php
110
 
@@ -130,7 +192,7 @@ class acf_Flexible_content extends acf_Field
130
  $sub_field['name'] = $field['name'] . '[acfcloneindex][' . $sub_field['key'] . ']';
131
 
132
  // create field
133
- $this->parent->create_field($sub_field);
134
 
135
  ?>
136
  </td>
@@ -193,7 +255,7 @@ class acf_Flexible_content extends acf_Field
193
  <?php if( $layout['display'] == 'table' ): ?>
194
  <thead>
195
  <tr>
196
- <?php foreach( $layout['sub_fields'] as $sub_field_i => $sub_field):
197
 
198
  // add width attr
199
  $attr = "";
@@ -230,7 +292,7 @@ class acf_Flexible_content extends acf_Field
230
 
231
  // loop though sub fields
232
 
233
- foreach( $layout['sub_fields'] as $j => $sub_field ): ?>
234
 
235
  <?php
236
 
@@ -250,13 +312,13 @@ class acf_Flexible_content extends acf_Field
250
  <?php
251
 
252
  // add value
253
- $sub_field['value'] = isset($value[$sub_field['name']]) ? $value[$sub_field['name']] : false;
254
 
255
  // add name
256
  $sub_field['name'] = $field['name'] . '[' . $i . '][' . $sub_field['key'] . ']';
257
 
258
  // create field
259
- $this->parent->create_field($sub_field);
260
 
261
  ?>
262
  </td>
@@ -399,7 +461,7 @@ class acf_Flexible_content extends acf_Field
399
  <td class="acf_fc_label" style="padding-left:0;">
400
  <label><?php _e('Label','acf'); ?></label>
401
  <?php
402
- $this->parent->create_field(array(
403
  'type' => 'text',
404
  'name' => 'fields['.$key.'][layouts][' . $layout_key . '][label]',
405
  'value' => $layout['label'],
@@ -409,7 +471,7 @@ class acf_Flexible_content extends acf_Field
409
  <td class="acf_fc_name">
410
  <label><?php _e('Name','acf'); ?></label>
411
  <?php
412
- $this->parent->create_field(array(
413
  'type' => 'text',
414
  'name' => 'fields['.$key.'][layouts][' . $layout_key . '][name]',
415
  'value' => $layout['name'],
@@ -419,7 +481,7 @@ class acf_Flexible_content extends acf_Field
419
  <td class="acf_fc_display" style="padding-right:0;">
420
  <label><?php _e('Display','acf'); ?></label>
421
  <?php
422
- $this->parent->create_field(array(
423
  'type' => 'select',
424
  'name' => 'fields['.$key.'][layouts][' . $layout_key . '][display]',
425
  'value' => $layout['display'],
@@ -486,7 +548,7 @@ class acf_Flexible_content extends acf_Field
486
  </td>
487
  <td>
488
  <?php
489
- $this->parent->create_field(array(
490
  'type' => 'text',
491
  'name' => 'fields['.$key.'][layouts][' . $layout_key . '][sub_fields]['.$sub_field['key'].'][label]',
492
  'value' => $sub_field['label'],
@@ -502,7 +564,7 @@ class acf_Flexible_content extends acf_Field
502
  </td>
503
  <td>
504
  <?php
505
- $this->parent->create_field(array(
506
  'type' => 'text',
507
  'name' => 'fields['.$key.'][layouts][' . $layout_key . '][sub_fields]['.$sub_field['key'].'][name]',
508
  'value' => $sub_field['name'],
@@ -515,7 +577,7 @@ class acf_Flexible_content extends acf_Field
515
  <td class="label"><label><span class="required">*</span><?php _e("Field Type",'acf'); ?></label></td>
516
  <td>
517
  <?php
518
- $this->parent->create_field(array(
519
  'type' => 'select',
520
  'name' => 'fields['.$key.'][layouts][' . $layout_key . '][sub_fields]['.$sub_field['key'].'][type]',
521
  'value' => $sub_field['type'],
@@ -535,7 +597,7 @@ class acf_Flexible_content extends acf_Field
535
  $sub_field['instructions'] = "";
536
  }
537
 
538
- $this->parent->create_field(array(
539
  'type' => 'text',
540
  'name' => 'fields['.$key.'][layouts][' . $layout_key . '][sub_fields]['.$sub_field['key'].'][instructions]',
541
  'value' => $sub_field['instructions'],
@@ -557,7 +619,7 @@ class acf_Flexible_content extends acf_Field
557
  $sub_field['column_width'] = "";
558
  }
559
 
560
- $this->parent->create_field(array(
561
  'type' => 'number',
562
  'name' => 'fields['.$key.'][layouts][' . $layout_key . '][sub_fields]['.$sub_field['key'].'][column_width]',
563
  'value' => $sub_field['column_width'],
@@ -607,7 +669,7 @@ class acf_Flexible_content extends acf_Field
607
  </td>
608
  <td>
609
  <?php
610
- $this->parent->create_field(array(
611
  'type' => 'text',
612
  'name' => 'fields['.$key.'][button_label]',
613
  'value' => $field['button_label'],
@@ -658,7 +720,7 @@ class acf_Flexible_content extends acf_Field
658
  unset($row['acf_fc_layout']);
659
 
660
  // loop through sub fields
661
- foreach($row as $field_key => $value)
662
  {
663
  $sub_field = $sub_fields[$field_key];
664
 
@@ -666,7 +728,29 @@ class acf_Flexible_content extends acf_Field
666
  $sub_field['name'] = $field['name'] . '_' . $i . '_' . $sub_field['name'];
667
 
668
  // save sub field value
669
- $this->parent->update_value($post_id, $sub_field, $value);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
670
  }
671
  }
672
  }
@@ -688,10 +772,12 @@ class acf_Flexible_content extends acf_Field
688
 
689
  function acf_save_field( $field )
690
  {
691
-
692
  // format sub_fields
693
- if($field['layouts'])
694
  {
 
 
695
  // loop through and save fields
696
  foreach($field['layouts'] as $layout_key => $layout)
697
  {
@@ -710,9 +796,9 @@ class acf_Flexible_content extends acf_Field
710
  foreach( $layout['sub_fields'] as $key => $f )
711
  {
712
  $i++;
713
-
714
-
715
- // order
716
  $f['order_no'] = $i;
717
  $f['key'] = $key;
718
 
@@ -722,19 +808,26 @@ class acf_Flexible_content extends acf_Field
722
  $f = apply_filters('acf_save_field-' . $f['type'], $f );
723
 
724
 
725
- $sub_fields[ $f['key'] ] = $f;
726
 
727
  }
728
 
 
 
729
  $layout['sub_fields'] = $sub_fields;
 
730
  }
731
 
732
- // update $layout
733
- $field['layouts'][ $layout_key ] = $layout;
734
 
735
  }
 
 
 
 
736
  }
737
-
 
738
  // return updated repeater field
739
  return $field;
740
 
@@ -783,13 +876,10 @@ class acf_Flexible_content extends acf_Field
783
  // loop through sub fields
784
  foreach($layouts[$layout]['sub_fields'] as $sub_field)
785
  {
786
- // store name
787
- $field_name = $sub_field['name'];
788
-
789
  // update full name
790
- $sub_field['name'] = $field['name'] . '_' . $i . '_' . $field_name;
791
 
792
- $values[$i][$field_name] = $this->parent->get_value($post_id, $sub_field);
793
  }
794
  }
795
  }
23
 
24
  // filters
25
  add_filter('acf_save_field-' . $this->name, array($this, 'acf_save_field'));
26
+ add_filter('acf_load_field-' . $this->name, array($this, 'acf_load_field'));
27
  }
28
+
29
+
30
+ /*
31
+ * acf_load_field
32
+ *
33
+ * @description:
34
+ * @since: 3.6
35
+ * @created: 21/02/13
36
+ */
37
+
38
+ function acf_load_field( $field )
39
+ {
40
+ // apply_load field to all sub fields
41
+ if( isset($field['layouts']) && is_array($field['layouts']) )
42
+ {
43
+ foreach( $field['layouts'] as $k => $layout )
44
+ {
45
+ if( isset($layout['sub_fields']) && is_array($layout['sub_fields']) )
46
+ {
47
+ foreach( $layout['sub_fields'] as $i => $sub_field )
48
+ {
49
+ // apply filters
50
+ $sub_field = apply_filters('acf_load_field', $sub_field);
51
+
52
+
53
+ $keys = array('type', 'name', 'key');
54
+ $called = array(); // field[type] && field[name] may be the same! Don't run the same filter twice!
55
+ foreach( $keys as $key )
56
+ {
57
+ // validate
58
+ if( !isset($field[ $key ]) ){ continue; }
59
+ if( in_array($field[ $key ], $called) ){ continue; }
60
+
61
+
62
+ // add to $called
63
+ $action = $field[ $key ] . '-' . $layout['name'] . '-' . $sub_field[ $key ];
64
+ $called[] = $action;
65
+
66
+
67
+ // run filters
68
+ $sub_field = apply_filters('acf_load_field-' . $action, $sub_field); // old filter
69
+
70
+ }
71
+
72
+
73
+ // update sub field
74
+ $field['layouts'][ $k ]['sub_fields'][ $i ] = $sub_field;
75
+
76
+ }
77
+ // foreach( $layout['sub_fields'] as $i => $sub_field )
78
+ }
79
+ // if( isset($layout['sub_fields']) && is_array($layout['sub_fields']) )
80
+ }
81
+ // foreach( $field['layouts'] as $k => $layout )
82
+ }
83
+ // if( isset($field['layouts']) && is_array($field['layouts']) )
84
+
85
+ return $field;
86
+
87
+ return $field;
88
+ }
89
+
90
 
91
  /*--------------------------------------------------------------------------------------
92
  *
129
  <?php if( $layout['display'] == 'table' ): ?>
130
  <thead>
131
  <tr>
132
+ <?php foreach( $layout['sub_fields'] as $sub_field):
133
 
134
  // add width attr
135
  $attr = "";
166
 
167
  // loop though sub fields
168
 
169
+ foreach( $layout['sub_fields'] as $sub_field ): ?>
170
 
171
  <?php
172
 
192
  $sub_field['name'] = $field['name'] . '[acfcloneindex][' . $sub_field['key'] . ']';
193
 
194
  // create field
195
+ do_action('acf/create_field', $sub_field);
196
 
197
  ?>
198
  </td>
255
  <?php if( $layout['display'] == 'table' ): ?>
256
  <thead>
257
  <tr>
258
+ <?php foreach( $layout['sub_fields'] as $sub_field):
259
 
260
  // add width attr
261
  $attr = "";
292
 
293
  // loop though sub fields
294
 
295
+ foreach( $layout['sub_fields'] as $sub_field ): ?>
296
 
297
  <?php
298
 
312
  <?php
313
 
314
  // add value
315
+ $sub_field['value'] = isset($value[$sub_field['key']]) ? $value[$sub_field['key']] : false;
316
 
317
  // add name
318
  $sub_field['name'] = $field['name'] . '[' . $i . '][' . $sub_field['key'] . ']';
319
 
320
  // create field
321
+ do_action('acf/create_field', $sub_field);
322
 
323
  ?>
324
  </td>
461
  <td class="acf_fc_label" style="padding-left:0;">
462
  <label><?php _e('Label','acf'); ?></label>
463
  <?php
464
+ do_action('acf/create_field', array(
465
  'type' => 'text',
466
  'name' => 'fields['.$key.'][layouts][' . $layout_key . '][label]',
467
  'value' => $layout['label'],
471
  <td class="acf_fc_name">
472
  <label><?php _e('Name','acf'); ?></label>
473
  <?php
474
+ do_action('acf/create_field', array(
475
  'type' => 'text',
476
  'name' => 'fields['.$key.'][layouts][' . $layout_key . '][name]',
477
  'value' => $layout['name'],
481
  <td class="acf_fc_display" style="padding-right:0;">
482
  <label><?php _e('Display','acf'); ?></label>
483
  <?php
484
+ do_action('acf/create_field', array(
485
  'type' => 'select',
486
  'name' => 'fields['.$key.'][layouts][' . $layout_key . '][display]',
487
  'value' => $layout['display'],
548
  </td>
549
  <td>
550
  <?php
551
+ do_action('acf/create_field', array(
552
  'type' => 'text',
553
  'name' => 'fields['.$key.'][layouts][' . $layout_key . '][sub_fields]['.$sub_field['key'].'][label]',
554
  'value' => $sub_field['label'],
564
  </td>
565
  <td>
566
  <?php
567
+ do_action('acf/create_field', array(
568
  'type' => 'text',
569
  'name' => 'fields['.$key.'][layouts][' . $layout_key . '][sub_fields]['.$sub_field['key'].'][name]',
570
  'value' => $sub_field['name'],
577
  <td class="label"><label><span class="required">*</span><?php _e("Field Type",'acf'); ?></label></td>
578
  <td>
579
  <?php
580
+ do_action('acf/create_field', array(
581
  'type' => 'select',
582
  'name' => 'fields['.$key.'][layouts][' . $layout_key . '][sub_fields]['.$sub_field['key'].'][type]',
583
  'value' => $sub_field['type'],
597
  $sub_field['instructions'] = "";
598
  }
599
 
600
+ do_action('acf/create_field', array(
601
  'type' => 'text',
602
  'name' => 'fields['.$key.'][layouts][' . $layout_key . '][sub_fields]['.$sub_field['key'].'][instructions]',
603
  'value' => $sub_field['instructions'],
619
  $sub_field['column_width'] = "";
620
  }
621
 
622
+ do_action('acf/create_field', array(
623
  'type' => 'number',
624
  'name' => 'fields['.$key.'][layouts][' . $layout_key . '][sub_fields]['.$sub_field['key'].'][column_width]',
625
  'value' => $sub_field['column_width'],
669
  </td>
670
  <td>
671
  <?php
672
+ do_action('acf/create_field', array(
673
  'type' => 'text',
674
  'name' => 'fields['.$key.'][button_label]',
675
  'value' => $field['button_label'],
720
  unset($row['acf_fc_layout']);
721
 
722
  // loop through sub fields
723
+ foreach($row as $field_key => $v)
724
  {
725
  $sub_field = $sub_fields[$field_key];
726
 
728
  $sub_field['name'] = $field['name'] . '_' . $i . '_' . $sub_field['name'];
729
 
730
  // save sub field value
731
+ $this->parent->update_value($post_id, $sub_field, $v);
732
+ }
733
+ }
734
+ }
735
+
736
+
737
+ /*
738
+ * Remove Old Data
739
+ *
740
+ * @credit: http://support.advancedcustomfields.com/discussion/1994/deleting-single-repeater-fields-does-not-remove-entry-from-database
741
+ */
742
+
743
+ $old_total = parent::get_value($post_id, $field);
744
+ $old_total = count( $old_total );
745
+ $new_total = count( $total );
746
+
747
+ if( $old_total > $new_total )
748
+ {
749
+ foreach( $sub_fields as $sub_field )
750
+ {
751
+ for ( $j = $new_total; $j < $old_total; $j++ )
752
+ {
753
+ parent::delete_value( $post_id, $field['name'] . '_' . $j . '_' . $sub_field['name'] );
754
  }
755
  }
756
  }
772
 
773
  function acf_save_field( $field )
774
  {
775
+
776
  // format sub_fields
777
+ if( $field['layouts'] )
778
  {
779
+ $layouts = array();
780
+
781
  // loop through and save fields
782
  foreach($field['layouts'] as $layout_key => $layout)
783
  {
796
  foreach( $layout['sub_fields'] as $key => $f )
797
  {
798
  $i++;
799
+
800
+
801
+ // order + key
802
  $f['order_no'] = $i;
803
  $f['key'] = $key;
804
 
808
  $f = apply_filters('acf_save_field-' . $f['type'], $f );
809
 
810
 
811
+ $sub_fields[] = $f;
812
 
813
  }
814
 
815
+
816
+ // update sub fields
817
  $layout['sub_fields'] = $sub_fields;
818
+
819
  }
820
 
821
+ $layouts[] = $layout;
 
822
 
823
  }
824
+
825
+ // clean array keys
826
+ $field['layouts'] = $layouts;
827
+
828
  }
829
+
830
+
831
  // return updated repeater field
832
  return $field;
833
 
876
  // loop through sub fields
877
  foreach($layouts[$layout]['sub_fields'] as $sub_field)
878
  {
 
 
 
879
  // update full name
880
+ $sub_field['name'] = $field['name'] . '_' . $i . '_' . $sub_field['name'];
881
 
882
+ $values[$i][ $sub_field['key'] ] = $this->parent->get_value($post_id, $sub_field);
883
  }
884
  }
885
  }
core/fields/gallery.php CHANGED
@@ -28,62 +28,58 @@ class acf_Gallery extends acf_Field
28
  // actions
29
  add_action('admin_head-media-upload-popup', array($this, 'popup_head'));
30
  add_action('acf_head-update_attachment-gallery', array($this, 'acf_head_update_attachment'));
31
- add_action('wp_ajax_acf_get_gallery_list_data', array($this, 'acf_get_gallery_list_data'));
32
  }
33
 
34
 
35
  /*
36
- * acf_get_gallery_list_data
37
  *
38
- * @description: AJAX call to get updated list data after an image is edited
39
- * @created: 5/07/12
 
40
  */
41
 
42
- function acf_get_gallery_list_data()
43
  {
 
44
  // vars
45
- $defaults = array(
46
- 'attachment_id' => false,
 
 
47
  );
 
48
 
49
- $options = array_merge($defaults, $_GET);
 
 
 
 
 
 
 
 
 
50
 
51
 
52
  // get attachment object
53
- $attachment = get_post( $options['attachment_id'] );
54
 
 
55
 
56
- // get fields
57
- $alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);
58
- $image_title = $attachment->post_title;
59
- $caption = $attachment->post_excerpt;
60
- $description = $attachment->post_content;
 
 
 
61
 
62
- ?>
63
- <table>
64
- <tbody>
65
- <tr>
66
- <th><label><?php _e("Title",'acf'); ?>:</label></th>
67
- <td><?php echo $image_title; ?></td>
68
- </tr>
69
- <tr>
70
- <th><label><?php _e("Alternate Text",'acf'); ?>:</label></th>
71
- <td><?php echo $alt; ?></td>
72
- </tr>
73
- <tr>
74
- <th><label><?php _e("Caption",'acf'); ?>:</label></th>
75
- <td><?php echo $caption; ?></td>
76
- </tr>
77
- <tr>
78
- <th><label><?php _e("Description",'acf'); ?>:</label></th>
79
- <td><?php echo $description; ?></td>
80
- </tr>
81
- </tbody>
82
- </table>
83
- <?php
84
 
85
- // end ajax
86
- die();
87
  }
88
 
89
 
@@ -122,7 +118,7 @@ class acf_Gallery extends acf_Field
122
 
123
  $image_sizes = $this->parent->get_all_image_sizes();
124
 
125
- $this->parent->create_field(array(
126
  'type' => 'radio',
127
  'name' => 'fields['.$key.'][preview_size]',
128
  'value' => $field['preview_size'],
@@ -143,16 +139,16 @@ class acf_Gallery extends acf_Field
143
  ?>
144
  <script type="text/javascript">
145
  (function($){
146
-
147
  // vars
148
- var div = self.parent.acf_edit_attachment;
149
 
150
 
151
- self.parent.acf.gallery_update_tile();
152
 
153
 
154
  // add message
155
- self.parent.acf.add_message('<?php _e("Image Updated",'acf'); ?>.', div);
156
 
157
 
158
  })(jQuery);
@@ -195,7 +191,7 @@ class acf_Gallery extends acf_Field
195
 
196
  ?>
197
  <div class="thumbnail" data-id="<?php echo $attachment['id']; ?>">
198
- <input type="hidden" name="<?php echo $field['name']; ?>[]" value="<?php echo $attachment['id']; ?>" />
199
  <div class="inner clearfix">
200
  <img src="<?php echo $src; ?>" alt="" />
201
  <div class="list-data">
@@ -245,11 +241,32 @@ class acf_Gallery extends acf_Field
245
  </div>
246
 
247
  <script type="text/html" class="tmpl-thumbnail">
248
- <div class="thumbnail" data-id="0">
249
- <input type="hidden" name="<?php echo $field['name']; ?>[]" value="" />
250
  <div class="inner clearfix">
251
- <img src="" alt="" />
252
- <div class="list-data"><!-- Generated by AJAX --></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
  </div>
254
  <div class="hover">
255
  <ul class="bl">
@@ -389,7 +406,10 @@ class acf_Gallery extends acf_Field
389
  foreach( $value as $k => $v )
390
  {
391
  // full url
392
- $value[$k]['url'] = wp_get_attachment_url( $v['id'] );
 
 
 
393
 
394
  // sizes
395
  if( $image_sizes )
@@ -402,7 +422,10 @@ class acf_Gallery extends acf_Field
402
  $src = wp_get_attachment_image_src( $v['id'], $image_size );
403
 
404
  // add src
405
- $value[$k]['sizes'][$image_size] = $src[0];
 
 
 
406
  }
407
  // foreach( $image_sizes as $image_size )
408
  }
@@ -596,7 +619,6 @@ class acf_Gallery extends acf_Field
596
 
597
 
598
  // show added message
599
- //self.parent.acf.add_message('<?php _e("Image Added",'acf'); ?>.', div);
600
  disable_image( div );
601
 
602
 
@@ -691,7 +713,7 @@ class acf_Gallery extends acf_Field
691
  $(document).ready(function(){
692
 
693
  // vars
694
- gallery = self.parent.acf_div;
695
  tmpl_thumbnail = gallery.find('.tmpl-thumbnail').html();
696
 
697
 
@@ -729,88 +751,38 @@ class acf_Gallery extends acf_Field
729
  * @created: 2/07/12
730
  */
731
 
732
- function add_image( attachment_id )
733
  {
734
-
 
 
 
 
 
 
 
 
735
  $.ajax({
736
  url: ajaxurl,
737
- data : {
738
- action: 'acf_get_preview_image',
739
- id: attachment_id,
740
- preview_size : "<?php echo $options['acf_preview_size']; ?>"
741
- },
742
  cache: false,
743
  dataType: "json",
744
- success: function( json ) {
745
-
746
 
747
  // validate
748
- if(!json)
749
  {
750
- return;
751
  }
752
 
753
 
754
- // get item
755
- var item = json[0];
756
-
757
-
758
- // create thumbnail div
759
- var div = $(tmpl_thumbnail);
760
-
761
-
762
- // add id refernece to later replace this div with the image
763
- div.attr('data-id', item.id);
764
- div.find('input[type="hidden"]').val(item.id);
765
-
766
-
767
- // add image src
768
- div.find('img').attr('src', item.url);
769
-
770
-
771
- // replace loading with thumbnail
772
- gallery.find('.thumbnails > .inner').append( div );
773
-
774
-
775
- // update gallery count
776
- self.parent.acf.update_gallery_count( gallery );
777
-
778
 
779
- // validation
780
- div.closest('.field').removeClass('error');
781
-
782
-
783
- // ajax find new list data
784
- $.ajax({
785
- url: ajaxurl,
786
- data : {
787
- 'action' : 'acf_get_gallery_list_data',
788
- 'attachment_id' : item.id
789
- },
790
- cache: false,
791
- dataType: "html",
792
- success: function( html ) {
793
-
794
-
795
- // validate
796
- if(!html)
797
- {
798
- return false;
799
- }
800
-
801
-
802
- // update list-item html
803
- div.find('.list-data').html( html );
804
-
805
- }
806
- // success: function( html ) {
807
-
808
- });
809
- // $.ajax({
810
  }
811
- // success: function( json ) {
812
  });
813
- // $.ajax({
814
  }
815
 
816
 
28
  // actions
29
  add_action('admin_head-media-upload-popup', array($this, 'popup_head'));
30
  add_action('acf_head-update_attachment-gallery', array($this, 'acf_head_update_attachment'));
31
+ add_action('wp_ajax_acf/fields/gallery/get_image', array($this, 'get_image'));
32
  }
33
 
34
 
35
  /*
36
+ * get_image
37
  *
38
+ * @description:
39
+ * @since: 3.5.8
40
+ * @created: 18/01/13
41
  */
42
 
43
+ function get_image()
44
  {
45
+
46
  // vars
47
+ $options = array(
48
+ 'nonce' => '',
49
+ 'id' => '',
50
+ 'preview_size' => 'full'
51
  );
52
+ $return = array();
53
 
54
+
55
+ // load post options
56
+ $options = array_merge($options, $_POST);
57
+
58
+
59
+ // verify nonce
60
+ if( ! wp_verify_nonce($options['nonce'], 'acf_nonce') )
61
+ {
62
+ die(0);
63
+ }
64
 
65
 
66
  // get attachment object
67
+ $attachment = get_post( $options['id'] );
68
 
69
+ $src = wp_get_attachment_image_src( $attachment->ID, $options['preview_size'] );
70
 
71
+ $return = array(
72
+ 'id' => $attachment->ID,
73
+ 'src' => $src[0],
74
+ 'title'=> $attachment->post_title,
75
+ 'caption'=> $attachment->post_excerpt,
76
+ 'alt'=> get_post_meta($attachment->ID, '_wp_attachment_image_alt', true),
77
+ 'description'=> $attachment->post_content,
78
+ );
79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
 
81
+ echo json_encode($return);
82
+ die;
83
  }
84
 
85
 
118
 
119
  $image_sizes = $this->parent->get_all_image_sizes();
120
 
121
+ do_action('acf/create_field', array(
122
  'type' => 'radio',
123
  'name' => 'fields['.$key.'][preview_size]',
124
  'value' => $field['preview_size'],
139
  ?>
140
  <script type="text/javascript">
141
  (function($){
142
+
143
  // vars
144
+ var div = self.parent.acf.media.div;
145
 
146
 
147
+ self.parent.acf.fields.gallery.update_image();
148
 
149
 
150
  // add message
151
+ self.parent.acf.helpers.add_message('<?php _e("Image Updated",'acf'); ?>.', div);
152
 
153
 
154
  })(jQuery);
191
 
192
  ?>
193
  <div class="thumbnail" data-id="<?php echo $attachment['id']; ?>">
194
+ <input class="acf-image-value" type="hidden" name="<?php echo $field['name']; ?>[]" value="<?php echo $attachment['id']; ?>" />
195
  <div class="inner clearfix">
196
  <img src="<?php echo $src; ?>" alt="" />
197
  <div class="list-data">
241
  </div>
242
 
243
  <script type="text/html" class="tmpl-thumbnail">
244
+ <div class="thumbnail" data-id="{id}">
245
+ <input type="hidden" class="acf-image-value" name="<?php echo $field['name']; ?>[]" value="{id}" />
246
  <div class="inner clearfix">
247
+ <img src="{src}" alt="{alt}" />
248
+ <div class="list-data">
249
+ <table>
250
+ <tbody>
251
+ <tr>
252
+ <th><label><?php _e("Title",'acf'); ?>:</label></th>
253
+ <td class="td-title">{title}</td>
254
+ </tr>
255
+ <tr>
256
+ <th><label><?php _e("Alternate Text",'acf'); ?>:</label></th>
257
+ <td class="td-alt">{alt}</td>
258
+ </tr>
259
+ <tr>
260
+ <th><label><?php _e("Caption",'acf'); ?>:</label></th>
261
+ <td class="td-caption">{caption}</td>
262
+ </tr>
263
+ <tr>
264
+ <th><label><?php _e("Description",'acf'); ?>:</label></th>
265
+ <td class="td-description">{description}</td>
266
+ </tr>
267
+ </tbody>
268
+ </table>
269
+ </div>
270
  </div>
271
  <div class="hover">
272
  <ul class="bl">
406
  foreach( $value as $k => $v )
407
  {
408
  // full url
409
+ $src = wp_get_attachment_image_src( $v['id'], 'full' );
410
+ $value[$k]['url'] = $src[0];
411
+ $value[$k]['width'] = $src[1];
412
+ $value[$k]['height'] = $src[2];
413
 
414
  // sizes
415
  if( $image_sizes )
422
  $src = wp_get_attachment_image_src( $v['id'], $image_size );
423
 
424
  // add src
425
+ $value[$k]['sizes'][ $image_size ] = $src[0];
426
+ $value[$k]['sizes'][ $image_size . '-width' ] = $src[1];
427
+ $value[$k]['sizes'][ $image_size . '-height' ] = $src[2];
428
+
429
  }
430
  // foreach( $image_sizes as $image_size )
431
  }
619
 
620
 
621
  // show added message
 
622
  disable_image( div );
623
 
624
 
713
  $(document).ready(function(){
714
 
715
  // vars
716
+ gallery = self.parent.acf.media.div;
717
  tmpl_thumbnail = gallery.find('.tmpl-thumbnail').html();
718
 
719
 
751
  * @created: 2/07/12
752
  */
753
 
754
+ function add_image( id )
755
  {
756
+ var ajax_data = {
757
+ action : 'acf/fields/gallery/get_image',
758
+ nonce : self.parent.acf.nonce,
759
+ id : id,
760
+ preview_size : "<?php echo $options['acf_preview_size']; ?>"
761
+ };
762
+
763
+
764
+ // ajax
765
  $.ajax({
766
  url: ajaxurl,
767
+ type: 'post',
768
+ data : ajax_data,
 
 
 
769
  cache: false,
770
  dataType: "json",
771
+ success: function( json ) {
 
772
 
773
  // validate
774
+ if( !json )
775
  {
776
+ return false;
777
  }
778
 
779
 
780
+ // add file
781
+ self.parent.acf.fields.gallery.add( json );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
782
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
783
  }
 
784
  });
785
+
786
  }
787
 
788
 
core/fields/image.php CHANGED
@@ -22,8 +22,12 @@ class acf_Image extends acf_Field
22
 
23
  add_action('admin_head-media-upload-popup', array($this, 'popup_head'));
24
  add_filter('get_media_item_args', array($this, 'allow_img_insertion'));
25
- add_action('wp_ajax_acf_get_preview_image', array($this, 'acf_get_preview_image'));
26
  add_action('acf_head-update_attachment-image', array($this, 'acf_head_update_attachment'));
 
 
 
 
 
27
  }
28
 
29
 
@@ -42,11 +46,11 @@ class acf_Image extends acf_Field
42
  (function($){
43
 
44
  // vars
45
- var div = self.parent.acf_edit_attachment;
46
 
47
 
48
  // add message
49
- self.parent.acf.add_message("<?php _e("Image Updated.",'acf'); ?>", div);
50
 
51
 
52
  })(jQuery);
@@ -54,59 +58,56 @@ class acf_Image extends acf_Field
54
  <?php
55
  }
56
 
57
- /*--------------------------------------------------------------------------------------
58
- *
59
- * acf_get_preview_image
60
- *
61
- * @description Returns a json array of preview sized urls
62
- * @author Elliot Condon
63
- * @since 3.1.7
64
- *
65
- *-------------------------------------------------------------------------------------*/
66
 
67
- function acf_get_preview_image()
 
 
 
 
 
 
 
 
68
  {
69
- $options = array(
70
- 'id' => false,
71
- 'preview_size' => 'thumbnail'
72
- );
73
- $options = array_merge($options, $_GET);
74
-
75
-
76
-
77
  // vars
 
 
 
 
 
78
  $return = array();
79
 
80
 
81
- // validate
82
- if( ! $options['id'] )
83
- {
84
- die( 0 );
85
- }
86
 
87
 
88
- // convert id_string into an array
89
- $ids = explode(',' , $options['id']);
90
- if( ! is_array($ids) )
91
  {
92
- $ids = array( $options['id'] );
93
  }
94
 
95
 
96
- // find image preview url for each image
97
- foreach( $ids as $k => $v )
98
  {
99
- $url = wp_get_attachment_image_src( $v, $options['preview_size'] );
100
- $return[] = array(
101
- 'id' => $v,
102
- 'url' => $url[0],
103
- );
 
 
 
 
 
104
  }
105
-
106
-
107
  // return json
108
  echo json_encode( $return );
109
- die();
 
110
  }
111
 
112
 
@@ -157,7 +158,7 @@ class acf_Image extends acf_Field
157
 
158
  ?>
159
  <div class="acf-image-uploader clearfix <?php echo $class; ?>" data-preview_size="<?php echo $preview_size; ?>">
160
- <input class="value" type="hidden" name="<?php echo $field['name']; ?>" value="<?php echo $field['value']; ?>" />
161
  <div class="has-image">
162
  <div class="hover">
163
  <ul class="bl">
@@ -201,13 +202,13 @@ class acf_Image extends acf_Field
201
  <label><?php _e("Return Value",'acf'); ?></label>
202
  </td>
203
  <td>
204
- <?php
205
- $this->parent->create_field(array(
206
- 'type' => 'radio',
207
- 'name' => 'fields['.$key.'][save_format]',
208
- 'value' => $field['save_format'],
209
  'layout' => 'horizontal',
210
- 'choices' => array(
211
  'object' => __("Image Object",'acf'),
212
  'url' => __("Image URL",'acf'),
213
  'id' => __("Image ID",'acf')
@@ -225,14 +226,14 @@ class acf_Image extends acf_Field
225
 
226
  $image_sizes = $this->parent->get_all_image_sizes();
227
 
228
- $this->parent->create_field(array(
229
- 'type' => 'radio',
230
- 'name' => 'fields['.$key.'][preview_size]',
231
- 'value' => $field['preview_size'],
232
  'layout' => 'horizontal',
233
- 'choices' => $image_sizes
234
  ));
235
-
236
  ?>
237
  </td>
238
  </tr>
@@ -346,7 +347,7 @@ class acf_Image extends acf_Field
346
  </style>
347
  <script type="text/javascript">
348
  (function($){
349
-
350
  /*
351
  * Select Image
352
  *
@@ -368,9 +369,10 @@ class acf_Image extends acf_Field
368
  }
369
 
370
 
371
- var data = {
372
- action: 'acf_get_preview_image',
373
- id: id,
 
374
  preview_size : "<?php echo $options['acf_preview_size']; ?>"
375
  };
376
 
@@ -378,47 +380,34 @@ class acf_Image extends acf_Field
378
  // ajax
379
  $.ajax({
380
  url: ajaxurl,
381
- data : data,
 
382
  cache: false,
383
  dataType: "json",
384
- success: function( json ) {
385
-
386
 
387
  // validate
388
- if(!json)
389
  {
390
  return false;
391
  }
392
 
393
 
394
- // get item
395
- var item = json[0],
396
- div = self.parent.acf_div;
397
 
398
-
399
- // update acf_div
400
- div.find('input.value').val( item.id ).trigger('change');
401
- div.find('img').attr( 'src', item.url );
402
- div.addClass('active');
403
-
404
-
405
- // validation
406
- div.closest('.field').removeClass('error');
407
-
408
-
409
- // reset acf_div and return false
410
- self.parent.acf_div = null;
411
  self.parent.tb_remove();
412
 
413
 
414
  }
415
  });
416
 
 
417
  return false;
418
-
419
  });
420
 
421
 
 
422
  /*
423
  * Select Images
424
  *
@@ -437,68 +426,92 @@ class acf_Image extends acf_Field
437
  return false;
438
  }
439
 
440
-
441
- // generate id's
442
- var attachment_ids = [];
443
- $('#media-items .media-item .acf-checkbox:checked').each(function(){
444
- attachment_ids.push( $(this).val() );
445
- });
446
-
447
-
448
- // creae json data
449
- var data = {
450
- action: 'acf_get_preview_image',
451
- id: attachment_ids.join(','),
452
  preview_size : "<?php echo $options['acf_preview_size']; ?>"
453
  };
454
 
455
 
456
- // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
457
- $.getJSON(ajaxurl, data, function( json ) {
458
 
459
- // validate
460
- if(!json)
461
- {
462
- return false;
463
- }
464
 
465
- $.each(json, function(i ,item){
 
 
 
 
 
 
 
 
 
 
466
 
467
- // update acf_div
468
- self.parent.acf_div.find('input.value').val( item.id ).trigger('change');
469
- self.parent.acf_div.find('img').attr('src', item.url );
470
- self.parent.acf_div.addClass('active');
471
-
472
-
473
- // validation
474
- self.parent.acf_div.closest('.field').removeClass('error');
475
-
476
-
477
- if((i+1) < total)
478
- {
479
- // add row
480
- self.parent.acf_div.closest('.repeater').find('.add-row-end').trigger('click');
481
-
482
- // set acf_div to new row image
483
- self.parent.acf_div = self.parent.acf_div.closest('.repeater').find('> table > tbody > tr.row:last .acf-image-uploader');
484
- }
485
- else
486
- {
487
- // reset acf_div and return false
488
- self.parent.acf_div = null;
489
- self.parent.tb_remove();
490
- }
491
 
492
- });
 
 
 
 
 
493
 
494
-
495
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
496
  });
497
-
498
- return false;
 
499
 
500
  });
501
-
502
 
503
  /*
504
  * Edit Attachment Toggle
@@ -545,7 +558,7 @@ class acf_Image extends acf_Field
545
  function add_buttons()
546
  {
547
  // vars
548
- var is_sub_field = (self.parent.acf_div && self.parent.acf_div.closest('.repeater').length > 0) ? true : false;
549
 
550
 
551
  // add submit after media items (on for sub fields)
@@ -684,15 +697,20 @@ class acf_Image extends acf_Field
684
 
685
 
686
  // create array to hold value data
 
 
687
  $value = array(
688
  'id' => $attachment->ID,
689
  'alt' => get_post_meta($attachment->ID, '_wp_attachment_image_alt', true),
690
  'title' => $attachment->post_title,
691
  'caption' => $attachment->post_excerpt,
692
  'description' => $attachment->post_content,
693
- 'url' => wp_get_attachment_url( $attachment->ID ),
 
 
694
  'sizes' => array(),
695
  );
 
696
 
697
  // find all image sizes
698
  $image_sizes = get_intermediate_image_sizes();
@@ -705,7 +723,9 @@ class acf_Image extends acf_Field
705
  $src = wp_get_attachment_image_src( $attachment->ID, $image_size );
706
 
707
  // add src
708
- $value['sizes'][$image_size] = $src[0];
 
 
709
  }
710
  // foreach( $image_sizes as $image_size )
711
  }
@@ -717,6 +737,82 @@ class acf_Image extends acf_Field
717
  }
718
 
719
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
720
 
721
  }
722
 
22
 
23
  add_action('admin_head-media-upload-popup', array($this, 'popup_head'));
24
  add_filter('get_media_item_args', array($this, 'allow_img_insertion'));
 
25
  add_action('acf_head-update_attachment-image', array($this, 'acf_head_update_attachment'));
26
+
27
+ add_action('wp_ajax_acf/fields/image/get_images', array($this, 'ajax_get_images'));
28
+ //add_filter('image_size_names_choose', array($this, 'image_size_names_choose'));
29
+ add_action('wp_prepare_attachment_for_js', array($this, 'wp_prepare_attachment_for_js'), 10, 3);
30
+
31
  }
32
 
33
 
46
  (function($){
47
 
48
  // vars
49
+ var div = self.parent.acf.media.div;
50
 
51
 
52
  // add message
53
+ self.parent.acf.helpers.add_message("<?php _e("Image Updated.",'acf'); ?>", div);
54
 
55
 
56
  })(jQuery);
58
  <?php
59
  }
60
 
 
 
 
 
 
 
 
 
 
61
 
62
+ /*
63
+ * ajax_get_images
64
+ *
65
+ * @description:
66
+ * @since: 3.5.7
67
+ * @created: 13/01/13
68
+ */
69
+
70
+ function ajax_get_images()
71
  {
 
 
 
 
 
 
 
 
72
  // vars
73
+ $options = array(
74
+ 'nonce' => '',
75
+ 'images' => array(),
76
+ 'preview_size' => 'thumbnail'
77
+ );
78
  $return = array();
79
 
80
 
81
+ // load post options
82
+ $options = array_merge($options, $_POST);
 
 
 
83
 
84
 
85
+ // verify nonce
86
+ if( ! wp_verify_nonce($options['nonce'], 'acf_nonce') )
 
87
  {
88
+ die(0);
89
  }
90
 
91
 
92
+ if( $options['images'] )
 
93
  {
94
+ foreach( $options['images'] as $id )
95
+ {
96
+ $src = wp_get_attachment_image_src( $id, $options['preview_size'] );
97
+
98
+
99
+ $return[] = array(
100
+ 'id' => $id,
101
+ 'src' => $src[0],
102
+ );
103
+ }
104
  }
105
+
106
+
107
  // return json
108
  echo json_encode( $return );
109
+ die;
110
+
111
  }
112
 
113
 
158
 
159
  ?>
160
  <div class="acf-image-uploader clearfix <?php echo $class; ?>" data-preview_size="<?php echo $preview_size; ?>">
161
+ <input class="acf-image-value" type="hidden" name="<?php echo $field['name']; ?>" value="<?php echo $field['value']; ?>" />
162
  <div class="has-image">
163
  <div class="hover">
164
  <ul class="bl">
202
  <label><?php _e("Return Value",'acf'); ?></label>
203
  </td>
204
  <td>
205
+ <?php
206
+ do_action('acf/create_field', array(
207
+ 'type' => 'radio',
208
+ 'name' => 'fields['.$key.'][save_format]',
209
+ 'value' => $field['save_format'],
210
  'layout' => 'horizontal',
211
+ 'choices' => array(
212
  'object' => __("Image Object",'acf'),
213
  'url' => __("Image URL",'acf'),
214
  'id' => __("Image ID",'acf')
226
 
227
  $image_sizes = $this->parent->get_all_image_sizes();
228
 
229
+ do_action('acf/create_field', array(
230
+ 'type' => 'radio',
231
+ 'name' => 'fields['.$key.'][preview_size]',
232
+ 'value' => $field['preview_size'],
233
  'layout' => 'horizontal',
234
+ 'choices' => $image_sizes
235
  ));
236
+
237
  ?>
238
  </td>
239
  </tr>
347
  </style>
348
  <script type="text/javascript">
349
  (function($){
350
+
351
  /*
352
  * Select Image
353
  *
369
  }
370
 
371
 
372
+ var ajax_data = {
373
+ action : 'acf/fields/image/get_images',
374
+ nonce : self.parent.acf.nonce,
375
+ images : [ id ],
376
  preview_size : "<?php echo $options['acf_preview_size']; ?>"
377
  };
378
 
380
  // ajax
381
  $.ajax({
382
  url: ajaxurl,
383
+ type: 'post',
384
+ data : ajax_data,
385
  cache: false,
386
  dataType: "json",
387
+ success: function( json ) {
 
388
 
389
  // validate
390
+ if( !json )
391
  {
392
  return false;
393
  }
394
 
395
 
396
+ // add file
397
+ self.parent.acf.fields.image.add( json[0] );
 
398
 
 
 
 
 
 
 
 
 
 
 
 
 
 
399
  self.parent.tb_remove();
400
 
401
 
402
  }
403
  });
404
 
405
+
406
  return false;
 
407
  });
408
 
409
 
410
+
411
  /*
412
  * Select Images
413
  *
426
  return false;
427
  }
428
 
429
+
430
+ var ajax_data = {
431
+ action : 'acf/fields/image/get_images',
432
+ nonce : self.parent.acf.nonce,
433
+ images : [],
 
 
 
 
 
 
 
434
  preview_size : "<?php echo $options['acf_preview_size']; ?>"
435
  };
436
 
437
 
438
+ // add to id array
439
+ $('#media-items .media-item .acf-checkbox:checked').each(function(){
440
 
441
+ ajax_data.images.push( $(this).val() );
 
 
 
 
442
 
443
+ });
444
+
445
+
446
+ // ajax
447
+ $.ajax({
448
+ url: ajaxurl,
449
+ type: 'post',
450
+ data : ajax_data,
451
+ cache: false,
452
+ dataType: "json",
453
+ success: function( json ) {
454
 
455
+ // validate
456
+ if( !json )
457
+ {
458
+ return false;
459
+ }
460
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
461
 
462
+
463
+ var selection = json,
464
+ i = 0;
465
+
466
+
467
+ $.each( json, function( k, image ){
468
 
469
+ // counter
470
+ i++;
471
+
472
+
473
+ // vars
474
+ var div = self.parent.acf.media.div;
475
+
476
+
477
+ // add image to field
478
+ self.parent.acf.fields.image.add( image );
479
+
480
+
481
+ // select / add another file field?
482
+ if( i < selection.length )
483
+ {
484
+ var tr = div.closest('tr'),
485
+ repeater = tr.closest('.repeater');
486
+
487
+
488
+ if( tr.next('.row').exists() )
489
+ {
490
+ self.parent.acf.media.div = tr.next('.row').find('.acf-image-uploader');
491
+ }
492
+ else
493
+ {
494
+ // add row
495
+ repeater.find('.add-row-end').trigger('click');
496
+
497
+ // set div to new row file
498
+ self.parent.acf.media.div = repeater.find('> table > tbody > tr.row:last .acf-image-uploader');
499
+ }
500
+ }
501
+
502
+ });
503
+
504
+
505
+ self.parent.tb_remove();
506
+
507
+ }
508
  });
509
+
510
+
511
+ return false;
512
 
513
  });
514
+
515
 
516
  /*
517
  * Edit Attachment Toggle
558
  function add_buttons()
559
  {
560
  // vars
561
+ var is_sub_field = (self.parent.acf.media.div.closest('.repeater').length > 0) ? true : false;
562
 
563
 
564
  // add submit after media items (on for sub fields)
697
 
698
 
699
  // create array to hold value data
700
+ $src = wp_get_attachment_image_src( $attachment->ID, 'full' );
701
+
702
  $value = array(
703
  'id' => $attachment->ID,
704
  'alt' => get_post_meta($attachment->ID, '_wp_attachment_image_alt', true),
705
  'title' => $attachment->post_title,
706
  'caption' => $attachment->post_excerpt,
707
  'description' => $attachment->post_content,
708
+ 'url' => $src[0],
709
+ 'width' => $src[1],
710
+ 'height' => $src[2],
711
  'sizes' => array(),
712
  );
713
+
714
 
715
  // find all image sizes
716
  $image_sizes = get_intermediate_image_sizes();
723
  $src = wp_get_attachment_image_src( $attachment->ID, $image_size );
724
 
725
  // add src
726
+ $value[ 'sizes' ][ $image_size ] = $src[0];
727
+ $value[ 'sizes' ][ $image_size . '-width' ] = $src[1];
728
+ $value[ 'sizes' ][ $image_size . '-height' ] = $src[2];
729
  }
730
  // foreach( $image_sizes as $image_size )
731
  }
737
  }
738
 
739
 
740
+ /*
741
+ * image_size_names_choose
742
+ *
743
+ * @description:
744
+ * @since: 3.5.7
745
+ * @created: 13/01/13
746
+ */
747
+
748
+ function image_size_names_choose( $sizes )
749
+ {
750
+ global $_wp_additional_image_sizes;
751
+
752
+ if( $_wp_additional_image_sizes )
753
+ {
754
+ foreach( $_wp_additional_image_sizes as $k => $v )
755
+ {
756
+ $title = $k;
757
+ $title = str_replace('-', ' ', $title);
758
+ $title = str_replace('_', ' ', $title);
759
+ $title = ucwords( $title );
760
+
761
+ $sizes[ $k ] = $title;
762
+ }
763
+ // foreach( $image_sizes as $image_size )
764
+ }
765
+
766
+ return $sizes;
767
+ }
768
+
769
+
770
+ /*
771
+ * wp_prepare_attachment_for_js
772
+ *
773
+ * @description: This sneaky hook adds the missing sizes to each attachment in the 3.5 uploader. It would be a lot easier to add all the sizes to the 'image_size_names_choose' filter but then it will show up on the normal the_content editor
774
+ * @since: 3.5.7
775
+ * @created: 13/01/13
776
+ */
777
+
778
+ function wp_prepare_attachment_for_js( $response, $attachment, $meta )
779
+ {
780
+ // only for image
781
+ if( $response['type'] != 'image' )
782
+ {
783
+ return $response;
784
+ }
785
+
786
+
787
+ // make sure sizes exist. Perhaps they dont?
788
+ if( !isset($meta['sizes']) )
789
+ {
790
+ return $response;
791
+ }
792
+
793
+
794
+ $attachment_url = $response['url'];
795
+ $base_url = str_replace( wp_basename( $attachment_url ), '', $attachment_url );
796
+
797
+ if( isset($meta['sizes']) && is_array($meta['sizes']) )
798
+ {
799
+ foreach( $meta['sizes'] as $k => $v )
800
+ {
801
+ if( !isset($response['sizes'][ $k ]) )
802
+ {
803
+ $response['sizes'][ $k ] = array(
804
+ 'height' => $v['height'],
805
+ 'width' => $v['width'],
806
+ 'url' => $base_url . $v['file'],
807
+ 'orientation' => $v['height'] > $v['width'] ? 'portrait' : 'landscape',
808
+ );
809
+ }
810
+ }
811
+ }
812
+
813
+ return $response;
814
+ }
815
+
816
 
817
  }
818
 
core/fields/number.php CHANGED
@@ -65,12 +65,14 @@ class acf_Number extends acf_Field
65
  <label><?php _e("Default Value",'acf'); ?></label>
66
  </td>
67
  <td>
68
- <?php
69
- $this->parent->create_field(array(
 
70
  'type' => 'text',
71
  'name' => 'fields['.$key.'][default_value]',
72
  'value' => $field['default_value'],
73
  ));
 
74
  ?>
75
  </td>
76
  </tr>
65
  <label><?php _e("Default Value",'acf'); ?></label>
66
  </td>
67
  <td>
68
+ <?php
69
+
70
+ do_action('acf/create_field', array(
71
  'type' => 'text',
72
  'name' => 'fields['.$key.'][default_value]',
73
  'value' => $field['default_value'],
74
  ));
75
+
76
  ?>
77
  </td>
78
  </tr>
core/fields/page_link.php CHANGED
@@ -38,7 +38,7 @@ class acf_Page_link extends acf_Field
38
  // let post_object create the field
39
  $field['type'] = 'post_object';
40
 
41
- $this->parent->create_field( $field );
42
 
43
  }
44
 
@@ -75,16 +75,17 @@ class acf_Page_link extends acf_Field
75
  $choices = array(
76
  '' => __("All",'acf')
77
  );
 
78
 
79
- $choices = $this->parent->get_post_types();
80
 
81
- $this->parent->create_field(array(
82
  'type' => 'select',
83
  'name' => 'fields['.$key.'][post_type]',
84
  'value' => $field['post_type'],
85
  'choices' => $choices,
86
  'multiple' => 1,
87
  ));
 
88
  ?>
89
  </td>
90
  </tr>
@@ -93,8 +94,9 @@ class acf_Page_link extends acf_Field
93
  <label><?php _e("Allow Null?",'acf'); ?></label>
94
  </td>
95
  <td>
96
- <?php
97
- $this->parent->create_field(array(
 
98
  'type' => 'radio',
99
  'name' => 'fields['.$key.'][allow_null]',
100
  'value' => $field['allow_null'],
@@ -104,6 +106,7 @@ class acf_Page_link extends acf_Field
104
  ),
105
  'layout' => 'horizontal',
106
  ));
 
107
  ?>
108
  </td>
109
  </tr>
@@ -112,8 +115,9 @@ class acf_Page_link extends acf_Field
112
  <label><?php _e("Select multiple values?",'acf'); ?></label>
113
  </td>
114
  <td>
115
- <?php
116
- $this->parent->create_field(array(
 
117
  'type' => 'radio',
118
  'name' => 'fields['.$key.'][multiple]',
119
  'value' => $field['multiple'],
@@ -123,6 +127,7 @@ class acf_Page_link extends acf_Field
123
  ),
124
  'layout' => 'horizontal',
125
  ));
 
126
  ?>
127
  </td>
128
  </tr>
38
  // let post_object create the field
39
  $field['type'] = 'post_object';
40
 
41
+ do_action('acf/create_field', $field );
42
 
43
  }
44
 
75
  $choices = array(
76
  '' => __("All",'acf')
77
  );
78
+ $choices = array_merge( $choices, $this->parent->get_post_types() );
79
 
 
80
 
81
+ do_action('acf/create_field', array(
82
  'type' => 'select',
83
  'name' => 'fields['.$key.'][post_type]',
84
  'value' => $field['post_type'],
85
  'choices' => $choices,
86
  'multiple' => 1,
87
  ));
88
+
89
  ?>
90
  </td>
91
  </tr>
94
  <label><?php _e("Allow Null?",'acf'); ?></label>
95
  </td>
96
  <td>
97
+ <?php
98
+
99
+ do_action('acf/create_field', array(
100
  'type' => 'radio',
101
  'name' => 'fields['.$key.'][allow_null]',
102
  'value' => $field['allow_null'],
106
  ),
107
  'layout' => 'horizontal',
108
  ));
109
+
110
  ?>
111
  </td>
112
  </tr>
115
  <label><?php _e("Select multiple values?",'acf'); ?></label>
116
  </td>
117
  <td>
118
+ <?php
119
+
120
+ do_action('acf/create_field', array(
121
  'type' => 'radio',
122
  'name' => 'fields['.$key.'][multiple]',
123
  'value' => $field['multiple'],
127
  ),
128
  'layout' => 'horizontal',
129
  ));
130
+
131
  ?>
132
  </td>
133
  </tr>
core/fields/post_object.php CHANGED
@@ -55,6 +55,7 @@ class acf_Post_object extends acf_Field
55
 
56
  $field = array_merge($defaults, $field);
57
 
 
58
  // validate taxonomy
59
  if( !is_array($field['taxonomy']) )
60
  {
@@ -67,7 +68,6 @@ class acf_Post_object extends acf_Field
67
  $field['post_type'] = $this->parent->get_post_types();
68
  }
69
 
70
-
71
 
72
  // create tax queries
73
  if( ! in_array('all', $field['taxonomy']) )
@@ -189,7 +189,7 @@ class acf_Post_object extends acf_Field
189
 
190
 
191
  // create field
192
- $this->parent->create_field( $field );
193
 
194
 
195
  }
@@ -228,21 +228,17 @@ class acf_Post_object extends acf_Field
228
  $choices = array(
229
  '' => __("All",'acf')
230
  );
 
231
 
232
- $post_types = $this->parent->get_post_types();
233
-
234
- foreach( $post_types as $post_type )
235
- {
236
- $choices[$post_type] = $post_type;
237
- }
238
 
239
- $this->parent->create_field(array(
240
  'type' => 'select',
241
  'name' => 'fields['.$key.'][post_type]',
242
  'value' => $field['post_type'],
243
  'choices' => $choices,
244
  'multiple' => 1,
245
  ));
 
246
  ?>
247
  </td>
248
  </tr>
@@ -258,7 +254,8 @@ class acf_Post_object extends acf_Field
258
  )
259
  );
260
  $choices = array_merge($choices, $this->parent->get_taxonomies_for_select());
261
- $this->parent->create_field(array(
 
262
  'type' => 'select',
263
  'name' => 'fields['.$key.'][taxonomy]',
264
  'value' => $field['taxonomy'],
@@ -266,6 +263,7 @@ class acf_Post_object extends acf_Field
266
  'optgroup' => true,
267
  'multiple' => 1,
268
  ));
 
269
  ?>
270
  </td>
271
  </tr>
@@ -274,8 +272,9 @@ class acf_Post_object extends acf_Field
274
  <label><?php _e("Allow Null?",'acf'); ?></label>
275
  </td>
276
  <td>
277
- <?php
278
- $this->parent->create_field(array(
 
279
  'type' => 'radio',
280
  'name' => 'fields['.$key.'][allow_null]',
281
  'value' => $field['allow_null'],
@@ -285,6 +284,7 @@ class acf_Post_object extends acf_Field
285
  ),
286
  'layout' => 'horizontal',
287
  ));
 
288
  ?>
289
  </td>
290
  </tr>
@@ -293,8 +293,9 @@ class acf_Post_object extends acf_Field
293
  <label><?php _e("Select multiple values?",'acf'); ?></label>
294
  </td>
295
  <td>
296
- <?php
297
- $this->parent->create_field(array(
 
298
  'type' => 'radio',
299
  'name' => 'fields['.$key.'][multiple]',
300
  'value' => $field['multiple'],
@@ -304,6 +305,7 @@ class acf_Post_object extends acf_Field
304
  ),
305
  'layout' => 'horizontal',
306
  ));
 
307
  ?>
308
  </td>
309
  </tr>
@@ -364,7 +366,11 @@ class acf_Post_object extends acf_Field
364
  foreach( $value as $k => $v)
365
  {
366
  // check that post exists (my have been trashed)
367
- if( isset($ordered_posts[ $v ]) )
 
 
 
 
368
  {
369
  $value[ $k ] = $ordered_posts[ $v ];
370
  }
55
 
56
  $field = array_merge($defaults, $field);
57
 
58
+
59
  // validate taxonomy
60
  if( !is_array($field['taxonomy']) )
61
  {
68
  $field['post_type'] = $this->parent->get_post_types();
69
  }
70
 
 
71
 
72
  // create tax queries
73
  if( ! in_array('all', $field['taxonomy']) )
189
 
190
 
191
  // create field
192
+ do_action('acf/create_field', $field );
193
 
194
 
195
  }
228
  $choices = array(
229
  '' => __("All",'acf')
230
  );
231
+ $choices = array_merge( $choices, $this->parent->get_post_types() );
232
 
 
 
 
 
 
 
233
 
234
+ do_action('acf/create_field', array(
235
  'type' => 'select',
236
  'name' => 'fields['.$key.'][post_type]',
237
  'value' => $field['post_type'],
238
  'choices' => $choices,
239
  'multiple' => 1,
240
  ));
241
+
242
  ?>
243
  </td>
244
  </tr>
254
  )
255
  );
256
  $choices = array_merge($choices, $this->parent->get_taxonomies_for_select());
257
+
258
+ do_action('acf/create_field', array(
259
  'type' => 'select',
260
  'name' => 'fields['.$key.'][taxonomy]',
261
  'value' => $field['taxonomy'],
263
  'optgroup' => true,
264
  'multiple' => 1,
265
  ));
266
+
267
  ?>
268
  </td>
269
  </tr>
272
  <label><?php _e("Allow Null?",'acf'); ?></label>
273
  </td>
274
  <td>
275
+ <?php
276
+
277
+ do_action('acf/create_field', array(
278
  'type' => 'radio',
279
  'name' => 'fields['.$key.'][allow_null]',
280
  'value' => $field['allow_null'],
284
  ),
285
  'layout' => 'horizontal',
286
  ));
287
+
288
  ?>
289
  </td>
290
  </tr>
293
  <label><?php _e("Select multiple values?",'acf'); ?></label>
294
  </td>
295
  <td>
296
+ <?php
297
+
298
+ do_action('acf/create_field', array(
299
  'type' => 'radio',
300
  'name' => 'fields['.$key.'][multiple]',
301
  'value' => $field['multiple'],
305
  ),
306
  'layout' => 'horizontal',
307
  ));
308
+
309
  ?>
310
  </td>
311
  </tr>
366
  foreach( $value as $k => $v)
367
  {
368
  // check that post exists (my have been trashed)
369
+ if( !isset($ordered_posts[ $v ]) )
370
+ {
371
+ unset( $value[ $k ] );
372
+ }
373
+ else
374
  {
375
  $value[ $k ] = $ordered_posts[ $v ];
376
  }
core/fields/radio.php CHANGED
@@ -35,16 +35,22 @@ class acf_Radio extends acf_Field
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
 
@@ -86,29 +92,28 @@ class acf_Radio extends acf_Field
86
  *-------------------------------------------------------------------------------------*/
87
 
88
  function create_options($key, $field)
89
- {
90
- // defaults
91
- $field['layout'] = isset($field['layout']) ? $field['layout'] : 'vertical';
92
- $field['default_value'] = isset($field['default_value']) ? $field['default_value'] : '';
93
-
 
 
 
 
 
94
 
95
  // implode checkboxes so they work in a textarea
96
- if(isset($field['choices']) && is_array($field['choices']))
97
  {
98
- foreach($field['choices'] as $choice_key => $choice_val)
99
  {
100
- $field['choices'][$choice_key] = $choice_key.' : '.$choice_val;
101
  }
102
  $field['choices'] = implode("\n", $field['choices']);
103
  }
104
- else
105
- {
106
- $field['choices'] = "";
107
- }
108
 
109
  ?>
110
-
111
-
112
  <tr class="field_option field_option_<?php echo $this->name; ?>">
113
  <td class="label">
114
  <label for=""><?php _e("Choices",'acf'); ?></label>
@@ -122,13 +127,15 @@ class acf_Radio extends acf_Field
122
  </p>
123
  </td>
124
  <td>
125
- <?php
126
- $this->parent->create_field(array(
 
127
  'type' => 'textarea',
128
  'class' => 'textarea field_option-choices',
129
  'name' => 'fields['.$key.'][choices]',
130
  'value' => $field['choices'],
131
  ));
 
132
  ?>
133
  </td>
134
  </tr>
@@ -137,12 +144,14 @@ class acf_Radio extends acf_Field
137
  <label><?php _e("Default Value",'acf'); ?></label>
138
  </td>
139
  <td>
140
- <?php
141
- $this->parent->create_field(array(
 
142
  'type' => 'text',
143
  'name' => 'fields['.$key.'][default_value]',
144
  'value' => $field['default_value'],
145
  ));
 
146
  ?>
147
  </td>
148
  </tr>
@@ -151,8 +160,9 @@ class acf_Radio extends acf_Field
151
  <label for=""><?php _e("Layout",'acf'); ?></label>
152
  </td>
153
  <td>
154
- <?php
155
- $this->parent->create_field(array(
 
156
  'type' => 'radio',
157
  'name' => 'fields['.$key.'][layout]',
158
  'value' => $field['layout'],
@@ -162,6 +172,7 @@ class acf_Radio extends acf_Field
162
  'horizontal' => __("Horizontal",'acf')
163
  )
164
  ));
 
165
  ?>
166
  </td>
167
  </tr>
35
 
36
  function create_field($field)
37
  {
38
+ // vars
39
+ $defaults = array(
40
+ 'layout' => 'vertical',
41
+ 'choices' => array(),
42
+ );
43
+
44
+ $field = array_merge($defaults, $field);
45
+
46
 
47
  // no choices
48
+ if( empty($field['choices']) )
49
  {
50
  echo '<p>' . __("No choices to choose from",'acf') . '</p>';
51
  return false;
52
  }
53
+
54
 
55
  echo '<ul class="radio_list ' . $field['class'] . ' ' . $field['layout'] . '">';
56
 
92
  *-------------------------------------------------------------------------------------*/
93
 
94
  function create_options($key, $field)
95
+ {
96
+ // vars
97
+ $defaults = array(
98
+ 'layout' => 'vertical',
99
+ 'default_value' => '',
100
+ 'choices' => '',
101
+ );
102
+
103
+ $field = array_merge($defaults, $field);
104
+
105
 
106
  // implode checkboxes so they work in a textarea
107
+ if( is_array($field['choices']) )
108
  {
109
+ foreach( $field['choices'] as $k => $v )
110
  {
111
+ $field['choices'][ $k ] = $k . ' : ' . $v;
112
  }
113
  $field['choices'] = implode("\n", $field['choices']);
114
  }
 
 
 
 
115
 
116
  ?>
 
 
117
  <tr class="field_option field_option_<?php echo $this->name; ?>">
118
  <td class="label">
119
  <label for=""><?php _e("Choices",'acf'); ?></label>
127
  </p>
128
  </td>
129
  <td>
130
+ <?php
131
+
132
+ do_action('acf/create_field', array(
133
  'type' => 'textarea',
134
  'class' => 'textarea field_option-choices',
135
  'name' => 'fields['.$key.'][choices]',
136
  'value' => $field['choices'],
137
  ));
138
+
139
  ?>
140
  </td>
141
  </tr>
144
  <label><?php _e("Default Value",'acf'); ?></label>
145
  </td>
146
  <td>
147
+ <?php
148
+
149
+ do_action('acf/create_field', array(
150
  'type' => 'text',
151
  'name' => 'fields['.$key.'][default_value]',
152
  'value' => $field['default_value'],
153
  ));
154
+
155
  ?>
156
  </td>
157
  </tr>
160
  <label for=""><?php _e("Layout",'acf'); ?></label>
161
  </td>
162
  <td>
163
+ <?php
164
+
165
+ do_action('acf/create_field', array(
166
  'type' => 'radio',
167
  'name' => 'fields['.$key.'][layout]',
168
  'value' => $field['layout'],
172
  'horizontal' => __("Horizontal",'acf')
173
  )
174
  ));
175
+
176
  ?>
177
  </td>
178
  </tr>
core/fields/relationship.php CHANGED
@@ -23,6 +23,7 @@ class acf_Relationship extends acf_Field
23
 
24
  // actions
25
  add_action('wp_ajax_acf_get_relationship_results', array($this, 'acf_get_relationship_results'));
 
26
 
27
  }
28
 
@@ -167,60 +168,57 @@ class acf_Relationship extends acf_Field
167
 
168
 
169
  // filters
170
- $options = apply_filters('acf_relationship_query', $options);
171
- $options = apply_filters('acf_relationship_query-' . $options['field_name'] , $options);
172
- $options = apply_filters('acf_relationship_query-' . $options['field_key'], $options);
173
 
174
 
175
- $results = false;
176
- $results = apply_filters('acf_relationship_results', $results, $options);
177
- $results = apply_filters('acf_relationship_results-' . $options['field_name'] , $results, $options);
178
- $results = apply_filters('acf_relationship_results-' . $options['field_key'], $results, $options);
179
 
180
 
181
- if( ! $results )
 
 
 
182
  {
183
- // load the posts
184
- $posts = get_posts( $options );
185
-
186
- if( $posts )
187
  {
188
- foreach( $posts as $post )
189
- {
190
- // right aligned info
191
- $title = '<span class="relationship-item-info">';
192
-
193
- $title .= $post->post_type;
194
-
195
- // WPML
196
- if( $options['lang'] )
197
- {
198
- $title .= ' (' . $options['lang'] . ')';
199
- }
200
-
201
- $title .= '</span>';
202
 
203
- // find title. Could use get_the_title, but that uses get_post(), so I think this uses less Memory
204
- $title .= apply_filters( 'the_title', $post->post_title, $post->ID );
205
-
206
- // status
207
- if($post->post_status != "publish")
208
  {
209
- $title .= " ($post->post_status)";
210
  }
211
 
212
-
213
- $title = apply_filters('acf_relationship_result', $title);
214
- $title = apply_filters('acf_relationship_result-' . $options['field_name'] , $title);
215
- $title = apply_filters('acf_relationship_result-' . $options['field_key'], $title);
216
-
217
-
218
- echo '<li><a href="' . get_permalink($post->ID) . '" data-post_id="' . $post->ID . '">' . $title . '<span class="acf-button-add"></span></a></li>';
 
 
219
  }
 
 
 
 
 
 
 
 
220
  }
221
  }
222
 
223
 
 
 
 
224
  // die?
225
  if( $ajax )
226
  {
@@ -344,6 +342,13 @@ class acf_Relationship extends acf_Field
344
  $title .= " ($post->post_status)";
345
  }
346
 
 
 
 
 
 
 
 
347
  echo '<li>
348
  <a href="' . get_permalink($post->ID) . '" class="" data-post_id="' . $post->ID . '">' . $title . '<span class="acf-button-remove"></span></a>
349
  <input type="hidden" name="' . $field['name'] . '[]" value="' . $post->ID . '" />
@@ -413,7 +418,7 @@ class acf_Relationship extends acf_Field
413
  $choices[$post_type] = $post_type;
414
  }
415
 
416
- $this->parent->create_field(array(
417
  'type' => 'select',
418
  'name' => 'fields['.$key.'][post_type]',
419
  'value' => $field['post_type'],
@@ -436,7 +441,7 @@ class acf_Relationship extends acf_Field
436
  )
437
  );
438
  $choices = array_merge($choices, $this->parent->get_taxonomies_for_select());
439
- $this->parent->create_field(array(
440
  'type' => 'select',
441
  'name' => 'fields['.$key.'][taxonomy]',
442
  'value' => $field['taxonomy'],
@@ -453,7 +458,7 @@ class acf_Relationship extends acf_Field
453
  </td>
454
  <td>
455
  <?php
456
- $this->parent->create_field(array(
457
  'type' => 'text',
458
  'name' => 'fields['.$key.'][max]',
459
  'value' => $field['max'],
@@ -522,7 +527,11 @@ class acf_Relationship extends acf_Field
522
  foreach( $value as $k => $v)
523
  {
524
  // check that post exists (my have been trashed)
525
- if( isset($ordered_posts[ $v ]) )
 
 
 
 
526
  {
527
  $value[ $k ] = $ordered_posts[ $v ];
528
  }
23
 
24
  // actions
25
  add_action('wp_ajax_acf_get_relationship_results', array($this, 'acf_get_relationship_results'));
26
+ add_action('wp_ajax_nopriv_acf_get_relationship_results', array($this, 'acf_get_relationship_results'));
27
 
28
  }
29
 
168
 
169
 
170
  // filters
171
+ $options = apply_filters('acf/fields/relationship/query', $options);
172
+ $options = apply_filters('acf/fields/relationship/query/name=' . $options['field_name'] , $options);
173
+ $options = apply_filters('acf/fields/relationship/query/key=' . $options['field_key'], $options);
174
 
175
 
176
+ $results = '';
 
 
 
177
 
178
 
179
+ // load the posts
180
+ $posts = get_posts( $options );
181
+
182
+ if( $posts )
183
  {
184
+ foreach( $posts as $post )
 
 
 
185
  {
186
+ // right aligned info
187
+ $title = '<span class="relationship-item-info">';
188
+
189
+ $title .= $post->post_type;
 
 
 
 
 
 
 
 
 
 
190
 
191
+ // WPML
192
+ if( $options['lang'] )
 
 
 
193
  {
194
+ $title .= ' (' . $options['lang'] . ')';
195
  }
196
 
197
+ $title .= '</span>';
198
+
199
+ // find title. Could use get_the_title, but that uses get_post(), so I think this uses less Memory
200
+ $title .= apply_filters( 'the_title', $post->post_title, $post->ID );
201
+
202
+ // status
203
+ if($post->post_status != "publish")
204
+ {
205
+ $title .= " ($post->post_status)";
206
  }
207
+
208
+ // filters
209
+ $title = apply_filters('acf/fields/relationship/result', $title, $post);
210
+ $title = apply_filters('acf/fields/relationship/result/name=' . $options['field_name'] , $title, $post);
211
+ $title = apply_filters('acf/fields/relationship/result/key=' . $options['field_key'], $title, $post);
212
+
213
+
214
+ $results .= '<li><a href="' . get_permalink($post->ID) . '" data-post_id="' . $post->ID . '">' . $title . '<span class="acf-button-add"></span></a></li>';
215
  }
216
  }
217
 
218
 
219
+ echo $results;
220
+
221
+
222
  // die?
223
  if( $ajax )
224
  {
342
  $title .= " ($post->post_status)";
343
  }
344
 
345
+
346
+ // filters
347
+ $title = apply_filters('acf/fields/relationship/result', $title, $post);
348
+ $title = apply_filters('acf/fields/relationship/result/name=' . $field['name'] , $title, $post);
349
+ $title = apply_filters('acf/fields/relationship/result/key=' . $field['key'], $title, $post);
350
+
351
+
352
  echo '<li>
353
  <a href="' . get_permalink($post->ID) . '" class="" data-post_id="' . $post->ID . '">' . $title . '<span class="acf-button-remove"></span></a>
354
  <input type="hidden" name="' . $field['name'] . '[]" value="' . $post->ID . '" />
418
  $choices[$post_type] = $post_type;
419
  }
420
 
421
+ do_action('acf/create_field', array(
422
  'type' => 'select',
423
  'name' => 'fields['.$key.'][post_type]',
424
  'value' => $field['post_type'],
441
  )
442
  );
443
  $choices = array_merge($choices, $this->parent->get_taxonomies_for_select());
444
+ do_action('acf/create_field', array(
445
  'type' => 'select',
446
  'name' => 'fields['.$key.'][taxonomy]',
447
  'value' => $field['taxonomy'],
458
  </td>
459
  <td>
460
  <?php
461
+ do_action('acf/create_field', array(
462
  'type' => 'text',
463
  'name' => 'fields['.$key.'][max]',
464
  'value' => $field['max'],
527
  foreach( $value as $k => $v)
528
  {
529
  // check that post exists (my have been trashed)
530
+ if( !isset($ordered_posts[ $v ]) )
531
+ {
532
+ unset( $value[ $k ] );
533
+ }
534
+ else
535
  {
536
  $value[ $k ] = $ordered_posts[ $v ];
537
  }
core/fields/repeater.php CHANGED
@@ -23,9 +23,56 @@ class acf_Repeater extends acf_Field
23
 
24
  // filters
25
  add_filter('acf_save_field-' . $this->name, array($this, 'acf_save_field'));
 
26
  }
27
 
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
  /*--------------------------------------------------------------------------------------
31
  *
@@ -51,7 +98,7 @@ class acf_Repeater extends acf_Field
51
 
52
  $field = array_merge($defaults, $field);
53
 
54
-
55
  // validate types
56
  $field['row_limit'] = (int) $field['row_limit'];
57
  $field['row_min'] = (int) $field['row_min'];
@@ -89,7 +136,7 @@ class acf_Repeater extends acf_Field
89
  foreach( $field['sub_fields'] as $sub_field)
90
  {
91
  $sub_value = isset($sub_field['default_value']) ? $sub_field['default_value'] : false;
92
- $field['value'][$i][ $sub_field['name'] ] = $sub_value;
93
  }
94
 
95
  }
@@ -114,7 +161,7 @@ class acf_Repeater extends acf_Field
114
  foreach( $field['sub_fields'] as $sub_field)
115
  {
116
  $sub_value = isset($sub_field['default_value']) ? $sub_field['default_value'] : false;
117
- $field['value']['acfcloneindex'][ $sub_field['name'] ] = $sub_value;
118
  }
119
 
120
  ?>
@@ -207,13 +254,13 @@ class acf_Repeater extends acf_Field
207
  <?php
208
 
209
  // add value
210
- $sub_field['value'] = isset($value[$sub_field['name']]) ? $value[$sub_field['name']] : '';
211
 
212
  // add name
213
  $sub_field['name'] = $field['name'] . '[' . $i . '][' . $sub_field['key'] . ']';
214
 
215
  // create field
216
- $this->parent->create_field($sub_field);
217
 
218
  ?>
219
  </td>
@@ -378,7 +425,7 @@ class acf_Repeater extends acf_Field
378
  </td>
379
  <td>
380
  <?php
381
- $this->parent->create_field(array(
382
  'type' => 'text',
383
  'name' => 'fields['.$key.'][sub_fields]['.$sub_field['key'].'][label]',
384
  'value' => $sub_field['label'],
@@ -394,7 +441,7 @@ class acf_Repeater extends acf_Field
394
  </td>
395
  <td>
396
  <?php
397
- $this->parent->create_field(array(
398
  'type' => 'text',
399
  'name' => 'fields['.$key.'][sub_fields]['.$sub_field['key'].'][name]',
400
  'value' => $sub_field['name'],
@@ -407,7 +454,7 @@ class acf_Repeater extends acf_Field
407
  <td class="label"><label><span class="required">*</span><?php _e("Field Type",'acf'); ?></label></td>
408
  <td>
409
  <?php
410
- $this->parent->create_field(array(
411
  'type' => 'select',
412
  'name' => 'fields['.$key.'][sub_fields]['.$sub_field['key'].'][type]',
413
  'value' => $sub_field['type'],
@@ -427,7 +474,7 @@ class acf_Repeater extends acf_Field
427
  $sub_field['instructions'] = "";
428
  }
429
 
430
- $this->parent->create_field(array(
431
  'type' => 'text',
432
  'name' => 'fields['.$key.'][sub_fields]['.$sub_field['key'].'][instructions]',
433
  'value' => $sub_field['instructions'],
@@ -449,7 +496,7 @@ class acf_Repeater extends acf_Field
449
  $sub_field['column_width'] = "";
450
  }
451
 
452
- $this->parent->create_field(array(
453
  'type' => 'number',
454
  'name' => 'fields['.$key.'][sub_fields]['.$sub_field['key'].'][column_width]',
455
  'value' => $sub_field['column_width'],
@@ -500,7 +547,7 @@ class acf_Repeater extends acf_Field
500
  </td>
501
  <td>
502
  <?php
503
- $this->parent->create_field(array(
504
  'type' => 'text',
505
  'name' => 'fields['.$key.'][row_min]',
506
  'value' => $field['row_min'],
@@ -514,7 +561,7 @@ class acf_Repeater extends acf_Field
514
  </td>
515
  <td>
516
  <?php
517
- $this->parent->create_field(array(
518
  'type' => 'text',
519
  'name' => 'fields['.$key.'][row_limit]',
520
  'value' => $field['row_limit'],
@@ -528,7 +575,7 @@ class acf_Repeater extends acf_Field
528
  </td>
529
  <td>
530
  <?php
531
- $this->parent->create_field(array(
532
  'type' => 'radio',
533
  'name' => 'fields['.$key.'][layout]',
534
  'value' => $field['layout'],
@@ -547,7 +594,7 @@ class acf_Repeater extends acf_Field
547
  </td>
548
  <td>
549
  <?php
550
- $this->parent->create_field(array(
551
  'type' => 'text',
552
  'name' => 'fields['.$key.'][button_label]',
553
  'value' => $field['button_label'],
@@ -599,14 +646,14 @@ class acf_Repeater extends acf_Field
599
 
600
 
601
  // add
602
- $sub_fields[ $f['key'] ] = $f;
603
  }
604
 
605
 
606
  // update sub fields
607
  $field['sub_fields'] = $sub_fields;
608
  }
609
-
610
 
611
  // return updated repeater field
612
  return $field;
@@ -627,7 +674,7 @@ class acf_Repeater extends acf_Field
627
  {
628
  $total = 0;
629
 
630
- if($value)
631
  {
632
  // remove dummy field
633
  unset($value['acfcloneindex']);
@@ -643,14 +690,11 @@ class acf_Repeater extends acf_Field
643
  $total++;
644
 
645
  // loop through sub fields
646
- foreach($field['sub_fields'] as $sub_field)
647
  {
648
  // get sub field data
649
  $v = isset($row[$sub_field['key']]) ? $row[$sub_field['key']] : '';
650
 
651
- // add to parent value
652
- //$parent_value[$i][$sub_field['name']] = $v;
653
-
654
  // update full name
655
  $sub_field['name'] = $field['name'] . '_' . $i . '_' . $sub_field['name'];
656
 
@@ -660,6 +704,28 @@ class acf_Repeater extends acf_Field
660
  }
661
  }
662
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
663
  parent::update_value($post_id, $field, $total);
664
 
665
  }
@@ -693,13 +759,10 @@ class acf_Repeater extends acf_Field
693
  // loop through sub fields
694
  foreach($field['sub_fields'] as $sub_field)
695
  {
696
- // store name
697
- $field_name = $sub_field['name'];
698
-
699
  // update full name
700
- $sub_field['name'] = $field['name'] . '_' . $i . '_' . $field_name;
701
 
702
- $values[$i][$field_name] = $this->parent->get_value($post_id, $sub_field);
703
  }
704
  }
705
 
23
 
24
  // filters
25
  add_filter('acf_save_field-' . $this->name, array($this, 'acf_save_field'));
26
+ add_filter('acf_load_field-' . $this->name, array($this, 'acf_load_field'));
27
  }
28
 
29
 
30
+ /*
31
+ * acf_load_field
32
+ *
33
+ * @description:
34
+ * @since: 3.6
35
+ * @created: 21/02/13
36
+ */
37
+
38
+ function acf_load_field( $field )
39
+ {
40
+ // apply_load field to all sub fields
41
+ if( isset($field['sub_fields']) && is_array($field['sub_fields']) )
42
+ {
43
+ foreach( $field['sub_fields'] as $k => $sub_field )
44
+ {
45
+ // apply filters
46
+ $sub_field = apply_filters('acf_load_field', $sub_field);
47
+
48
+
49
+ $keys = array('type', 'name', 'key');
50
+ $called = array(); // field[type] && field[name] may be the same! Don't run the same filter twice!
51
+ foreach( $keys as $key )
52
+ {
53
+ // validate
54
+ if( !isset($field[ $key ]) ){ continue; }
55
+ if( in_array($field[ $key ], $called) ){ continue; }
56
+
57
+
58
+ // add to $called
59
+ $action = $field[ $key ] . '-' . $sub_field[ $key ];
60
+ $called[] = $action;
61
+
62
+
63
+ // run filters
64
+ $sub_field = apply_filters('acf_load_field-' . $action, $sub_field); // old filter
65
+
66
+ }
67
+
68
+
69
+ // update sub field
70
+ $field['sub_fields'][ $k ] = $sub_field;
71
+ }
72
+ }
73
+
74
+ return $field;
75
+ }
76
 
77
  /*--------------------------------------------------------------------------------------
78
  *
98
 
99
  $field = array_merge($defaults, $field);
100
 
101
+
102
  // validate types
103
  $field['row_limit'] = (int) $field['row_limit'];
104
  $field['row_min'] = (int) $field['row_min'];
136
  foreach( $field['sub_fields'] as $sub_field)
137
  {
138
  $sub_value = isset($sub_field['default_value']) ? $sub_field['default_value'] : false;
139
+ $field['value'][$i][ $sub_field['key'] ] = $sub_value;
140
  }
141
 
142
  }
161
  foreach( $field['sub_fields'] as $sub_field)
162
  {
163
  $sub_value = isset($sub_field['default_value']) ? $sub_field['default_value'] : false;
164
+ $field['value']['acfcloneindex'][ $sub_field['key'] ] = $sub_value;
165
  }
166
 
167
  ?>
254
  <?php
255
 
256
  // add value
257
+ $sub_field['value'] = isset($value[$sub_field['key']]) ? $value[$sub_field['key']] : '';
258
 
259
  // add name
260
  $sub_field['name'] = $field['name'] . '[' . $i . '][' . $sub_field['key'] . ']';
261
 
262
  // create field
263
+ do_action('acf/create_field', $sub_field);
264
 
265
  ?>
266
  </td>
425
  </td>
426
  <td>
427
  <?php
428
+ do_action('acf/create_field', array(
429
  'type' => 'text',
430
  'name' => 'fields['.$key.'][sub_fields]['.$sub_field['key'].'][label]',
431
  'value' => $sub_field['label'],
441
  </td>
442
  <td>
443
  <?php
444
+ do_action('acf/create_field', array(
445
  'type' => 'text',
446
  'name' => 'fields['.$key.'][sub_fields]['.$sub_field['key'].'][name]',
447
  'value' => $sub_field['name'],
454
  <td class="label"><label><span class="required">*</span><?php _e("Field Type",'acf'); ?></label></td>
455
  <td>
456
  <?php
457
+ do_action('acf/create_field', array(
458
  'type' => 'select',
459
  'name' => 'fields['.$key.'][sub_fields]['.$sub_field['key'].'][type]',
460
  'value' => $sub_field['type'],
474
  $sub_field['instructions'] = "";
475
  }
476
 
477
+ do_action('acf/create_field', array(
478
  'type' => 'text',
479
  'name' => 'fields['.$key.'][sub_fields]['.$sub_field['key'].'][instructions]',
480
  'value' => $sub_field['instructions'],
496
  $sub_field['column_width'] = "";
497
  }
498
 
499
+ do_action('acf/create_field', array(
500
  'type' => 'number',
501
  'name' => 'fields['.$key.'][sub_fields]['.$sub_field['key'].'][column_width]',
502
  'value' => $sub_field['column_width'],
547
  </td>
548
  <td>
549
  <?php
550
+ do_action('acf/create_field', array(
551
  'type' => 'text',
552
  'name' => 'fields['.$key.'][row_min]',
553
  'value' => $field['row_min'],
561
  </td>
562
  <td>
563
  <?php
564
+ do_action('acf/create_field', array(
565
  'type' => 'text',
566
  'name' => 'fields['.$key.'][row_limit]',
567
  'value' => $field['row_limit'],
575
  </td>
576
  <td>
577
  <?php
578
+ do_action('acf/create_field', array(
579
  'type' => 'radio',
580
  'name' => 'fields['.$key.'][layout]',
581
  'value' => $field['layout'],
594
  </td>
595
  <td>
596
  <?php
597
+ do_action('acf/create_field', array(
598
  'type' => 'text',
599
  'name' => 'fields['.$key.'][button_label]',
600
  'value' => $field['button_label'],
646
 
647
 
648
  // add
649
+ $sub_fields[] = $f;
650
  }
651
 
652
 
653
  // update sub fields
654
  $field['sub_fields'] = $sub_fields;
655
  }
656
+
657
 
658
  // return updated repeater field
659
  return $field;
674
  {
675
  $total = 0;
676
 
677
+ if( is_array( $value ) )
678
  {
679
  // remove dummy field
680
  unset($value['acfcloneindex']);
690
  $total++;
691
 
692
  // loop through sub fields
693
+ foreach( $field['sub_fields'] as $sub_field )
694
  {
695
  // get sub field data
696
  $v = isset($row[$sub_field['key']]) ? $row[$sub_field['key']] : '';
697
 
 
 
 
698
  // update full name
699
  $sub_field['name'] = $field['name'] . '_' . $i . '_' . $sub_field['name'];
700
 
704
  }
705
  }
706
 
707
+
708
+ /*
709
+ * Remove Old Data
710
+ *
711
+ * @credit: http://support.advancedcustomfields.com/discussion/1994/deleting-single-repeater-fields-does-not-remove-entry-from-database
712
+ */
713
+
714
+ $old_total = (int) parent::get_value($post_id, $field);
715
+
716
+ if( $old_total > $total )
717
+ {
718
+ foreach( $field['sub_fields'] as $sub_field )
719
+ {
720
+ for ( $j = $total; $j < $old_total; $j++ )
721
+ {
722
+ parent::delete_value( $post_id, $field['name'] . '_' . $j . '_' . $sub_field['name'] );
723
+ }
724
+ }
725
+ }
726
+
727
+
728
+ // update repeater count
729
  parent::update_value($post_id, $field, $total);
730
 
731
  }
759
  // loop through sub fields
760
  foreach($field['sub_fields'] as $sub_field)
761
  {
 
 
 
762
  // update full name
763
+ $sub_field['name'] = $field['name'] . '_' . $i . '_' . $sub_field['name'];
764
 
765
+ $values[$i][ $sub_field['key'] ] = $this->parent->get_value($post_id, $sub_field);
766
  }
767
  }
768
 
core/fields/select.php CHANGED
@@ -194,7 +194,7 @@ class acf_Select extends acf_Field
194
  </td>
195
  <td>
196
  <?php
197
- $this->parent->create_field(array(
198
  'type' => 'textarea',
199
  'class' => 'textarea field_option-choices',
200
  'name' => 'fields['.$key.'][choices]',
@@ -209,7 +209,7 @@ class acf_Select extends acf_Field
209
  </td>
210
  <td>
211
  <?php
212
- $this->parent->create_field(array(
213
  'type' => 'text',
214
  'name' => 'fields['.$key.'][default_value]',
215
  'value' => $field['default_value'],
@@ -223,7 +223,7 @@ class acf_Select extends acf_Field
223
  </td>
224
  <td>
225
  <?php
226
- $this->parent->create_field(array(
227
  'type' => 'radio',
228
  'name' => 'fields['.$key.'][allow_null]',
229
  'value' => $field['allow_null'],
@@ -242,7 +242,7 @@ class acf_Select extends acf_Field
242
  </td>
243
  <td>
244
  <?php
245
- $this->parent->create_field(array(
246
  'type' => 'radio',
247
  'name' => 'fields['.$key.'][multiple]',
248
  'value' => $field['multiple'],
194
  </td>
195
  <td>
196
  <?php
197
+ do_action('acf/create_field', array(
198
  'type' => 'textarea',
199
  'class' => 'textarea field_option-choices',
200
  'name' => 'fields['.$key.'][choices]',
209
  </td>
210
  <td>
211
  <?php
212
+ do_action('acf/create_field', array(
213
  'type' => 'text',
214
  'name' => 'fields['.$key.'][default_value]',
215
  'value' => $field['default_value'],
223
  </td>
224
  <td>
225
  <?php
226
+ do_action('acf/create_field', array(
227
  'type' => 'radio',
228
  'name' => 'fields['.$key.'][allow_null]',
229
  'value' => $field['allow_null'],
242
  </td>
243
  <td>
244
  <?php
245
+ do_action('acf/create_field', array(
246
  'type' => 'radio',
247
  'name' => 'fields['.$key.'][multiple]',
248
  'value' => $field['multiple'],
core/fields/text.php CHANGED
@@ -35,7 +35,7 @@ class acf_Text extends acf_Field
35
 
36
  function create_field($field)
37
  {
38
- echo '<input type="text" value="' . $field['value'] . '" id="' . $field['id'] . '" class="' . $field['class'] . '" name="' . $field['name'] . '" />';
39
  }
40
 
41
 
@@ -66,7 +66,7 @@ class acf_Text extends acf_Field
66
  </td>
67
  <td>
68
  <?php
69
- $this->parent->create_field(array(
70
  'type' => 'text',
71
  'name' => 'fields['.$key.'][default_value]',
72
  'value' => $field['default_value'],
@@ -81,7 +81,7 @@ class acf_Text extends acf_Field
81
  </td>
82
  <td>
83
  <?php
84
- $this->parent->create_field(array(
85
  'type' => 'select',
86
  'name' => 'fields['.$key.'][formatting]',
87
  'value' => $field['formatting'],
@@ -127,19 +127,31 @@ class acf_Text extends acf_Field
127
  function get_value_for_api($post_id, $field)
128
  {
129
  // vars
130
- $format = isset($field['formatting']) ? $field['formatting'] : 'html';
131
-
 
 
 
 
 
 
132
  $value = parent::get_value($post_id, $field);
133
 
134
- if($format == 'none')
 
 
 
 
 
 
 
 
135
  {
136
  $value = htmlspecialchars($value, ENT_QUOTES);
137
  }
138
- elseif($format == 'html')
139
  {
140
- //$value = html_entity_decode($value);
141
  $value = nl2br($value);
142
-
143
  }
144
 
145
  return $value;
35
 
36
  function create_field($field)
37
  {
38
+ echo '<input type="text" value="' . esc_attr( $field['value'] ) . '" id="' . esc_attr( $field['id'] ) . '" class="' . esc_attr( $field['class'] ) . '" name="' . esc_attr( $field['name'] ) . '" />';
39
  }
40
 
41
 
66
  </td>
67
  <td>
68
  <?php
69
+ do_action('acf/create_field', array(
70
  'type' => 'text',
71
  'name' => 'fields['.$key.'][default_value]',
72
  'value' => $field['default_value'],
81
  </td>
82
  <td>
83
  <?php
84
+ do_action('acf/create_field', array(
85
  'type' => 'select',
86
  'name' => 'fields['.$key.'][formatting]',
87
  'value' => $field['formatting'],
127
  function get_value_for_api($post_id, $field)
128
  {
129
  // vars
130
+ $defaults = array(
131
+ 'formatting' => 'html',
132
+ );
133
+
134
+ $field = array_merge($defaults, $field);
135
+
136
+
137
+ // load value
138
  $value = parent::get_value($post_id, $field);
139
 
140
+
141
+ // validate type
142
+ if( !is_string($value) )
143
+ {
144
+ return $value;
145
+ }
146
+
147
+
148
+ if( $field['formatting'] == 'none' )
149
  {
150
  $value = htmlspecialchars($value, ENT_QUOTES);
151
  }
152
+ elseif( $field['formatting'] == 'html' )
153
  {
 
154
  $value = nl2br($value);
 
155
  }
156
 
157
  return $value;
core/fields/textarea.php CHANGED
@@ -65,7 +65,7 @@ class acf_Textarea extends acf_Field
65
  </td>
66
  <td>
67
  <?php
68
- $this->parent->create_field(array(
69
  'type' => 'textarea',
70
  'name' => 'fields['.$key.'][default_value]',
71
  'value' => $field['default_value'],
@@ -80,7 +80,7 @@ class acf_Textarea extends acf_Field
80
  </td>
81
  <td>
82
  <?php
83
- $this->parent->create_field(array(
84
  'type' => 'select',
85
  'name' => 'fields['.$key.'][formatting]',
86
  'value' => $field['formatting'],
@@ -109,20 +109,34 @@ class acf_Textarea extends acf_Field
109
  function get_value_for_api($post_id, $field)
110
  {
111
  // vars
112
- $format = isset($field['formatting']) ? $field['formatting'] : 'br';
 
 
113
 
 
 
 
 
114
  $value = parent::get_value($post_id, $field);
115
 
116
- if($format == 'none')
 
 
 
 
 
 
 
 
117
  {
118
  $value = htmlspecialchars($value, ENT_QUOTES);
119
  }
120
- elseif($format == 'html')
121
  {
122
  //$value = html_entity_decode($value);
123
  //$value = nl2br($value);
124
  }
125
- elseif($format == 'br')
126
  {
127
  $value = htmlspecialchars($value, ENT_QUOTES);
128
  $value = nl2br($value);
65
  </td>
66
  <td>
67
  <?php
68
+ do_action('acf/create_field', array(
69
  'type' => 'textarea',
70
  'name' => 'fields['.$key.'][default_value]',
71
  'value' => $field['default_value'],
80
  </td>
81
  <td>
82
  <?php
83
+ do_action('acf/create_field', array(
84
  'type' => 'select',
85
  'name' => 'fields['.$key.'][formatting]',
86
  'value' => $field['formatting'],
109
  function get_value_for_api($post_id, $field)
110
  {
111
  // vars
112
+ $defaults = array(
113
+ 'formatting' => 'br',
114
+ );
115
 
116
+ $field = array_merge($defaults, $field);
117
+
118
+
119
+ // load value
120
  $value = parent::get_value($post_id, $field);
121
 
122
+
123
+ // validate type
124
+ if( !is_string($value) )
125
+ {
126
+ return $value;
127
+ }
128
+
129
+
130
+ if($field['formatting'] == 'none')
131
  {
132
  $value = htmlspecialchars($value, ENT_QUOTES);
133
  }
134
+ elseif($field['formatting'] == 'html')
135
  {
136
  //$value = html_entity_decode($value);
137
  //$value = nl2br($value);
138
  }
139
+ elseif($field['formatting'] == 'br')
140
  {
141
  $value = htmlspecialchars($value, ENT_QUOTES);
142
  $value = nl2br($value);
core/fields/true_false.php CHANGED
@@ -61,24 +61,47 @@ class acf_True_false extends acf_Field
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
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  <?php
83
  }
84
 
61
 
62
  function create_options($key, $field)
63
  {
64
+ // vars
65
+ $defaults = array(
66
+ 'default_value' => 0,
67
+ 'message' => '',
68
+ );
69
+
70
+ $field = array_merge($defaults, $field);
71
+
72
+
73
  ?>
74
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
75
+ <td class="label">
76
+ <label><?php _e("Message",'acf'); ?></label>
77
+ <p class="description"><?php _e("eg. Show extra content",'acf'); ?></a></p>
78
+ </td>
79
+ <td>
80
+ <?php
81
+ do_action('acf/create_field', array(
82
+ 'type' => 'text',
83
+ 'name' => 'fields['.$key.'][message]',
84
+ 'value' => $field['message'],
85
+ ));
86
+ ?>
87
+ </td>
88
+ </tr>
89
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
90
+ <td class="label">
91
+ <label><?php _e("Default Value",'acf'); ?></label>
92
+ </td>
93
+ <td>
94
+ <?php
95
+
96
+ do_action('acf/create_field', array(
97
+ 'type' => 'true_false',
98
+ 'name' => 'fields['.$key.'][default_value]',
99
+ 'value' => $field['default_value'],
100
+ ));
101
+
102
+ ?>
103
+ </td>
104
+ </tr>
105
  <?php
106
  }
107
 
core/fields/wysiwyg.php CHANGED
@@ -21,9 +21,42 @@ class acf_Wysiwyg extends acf_Field
21
  $this->title = __("Wysiwyg Editor",'acf');
22
 
23
  add_action( 'acf_head-input', array( $this, 'acf_head') );
 
 
24
 
25
  }
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
 
29
  /*--------------------------------------------------------------------------------------
@@ -82,7 +115,7 @@ class acf_Wysiwyg extends acf_Field
82
  </td>
83
  <td>
84
  <?php
85
- $this->parent->create_field(array(
86
  'type' => 'textarea',
87
  'name' => 'fields['.$key.'][default_value]',
88
  'value' => $field['default_value'],
@@ -95,16 +128,29 @@ class acf_Wysiwyg extends acf_Field
95
  <label><?php _e("Toolbar",'acf'); ?></label>
96
  </td>
97
  <td>
98
- <?php
99
- $this->parent->create_field(array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  'type' => 'radio',
101
  'name' => 'fields['.$key.'][toolbar]',
102
  'value' => $field['toolbar'],
103
  'layout' => 'horizontal',
104
- 'choices' => array(
105
- 'full' => __("Full",'acf'),
106
- 'basic' => __("Basic",'acf')
107
- )
108
  ));
109
  ?>
110
  </td>
@@ -115,7 +161,7 @@ class acf_Wysiwyg extends acf_Field
115
  </td>
116
  <td>
117
  <?php
118
- $this->parent->create_field(array(
119
  'type' => 'radio',
120
  'name' => 'fields['.$key.'][media_upload]',
121
  'value' => $field['media_upload'],
@@ -136,7 +182,7 @@ class acf_Wysiwyg extends acf_Field
136
  </td>
137
  <td>
138
  <?php
139
- $this->parent->create_field(array(
140
  'type' => 'radio',
141
  'name' => 'fields['.$key.'][the_content]',
142
  'value' => $field['the_content'],
@@ -179,7 +225,7 @@ class acf_Wysiwyg extends acf_Field
179
 
180
 
181
  ?>
182
- <div id="wp-<?php echo $id; ?>-wrap" class="acf_wysiwyg wp-editor-wrap" data-toolbar="<?php echo $field['toolbar']; ?>">
183
  <?php if($field['media_upload'] == 'yes'): ?>
184
  <?php if( version_compare($wp_version, '3.3', '<') ): ?>
185
  <div id="editor-toolbar">
21
  $this->title = __("Wysiwyg Editor",'acf');
22
 
23
  add_action( 'acf_head-input', array( $this, 'acf_head') );
24
+
25
+ add_filter( 'acf/fields/wysiwyg/toolbars', array( $this, 'toolbars'), 1, 1 );
26
 
27
  }
28
 
29
+
30
+ /*
31
+ * get_toolbars
32
+ *
33
+ * @description:
34
+ * @since: 3.5.7
35
+ * @created: 10/01/13
36
+ */
37
+
38
+ function toolbars( $toolbars )
39
+ {
40
+ $editor_id = 'acf_settings';
41
+
42
+ // Full
43
+ $toolbars['Full'] = array();
44
+ $toolbars['Full'][1] = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', 'bullist', 'numlist', 'blockquote', 'justifyleft', 'justifycenter', 'justifyright', 'link', 'unlink', 'wp_more', 'spellchecker', 'fullscreen', 'wp_adv' ), $editor_id);
45
+ $toolbars['Full'][2] = apply_filters('mce_buttons_2', array( 'formatselect', 'underline', 'justifyfull', 'forecolor', 'pastetext', 'pasteword', 'removeformat', 'charmap', 'outdent', 'indent', 'undo', 'redo', 'wp_help', 'code' ), $editor_id);
46
+ $toolbars['Full'][3] = apply_filters('mce_buttons_3', array(), $editor_id);
47
+ $toolbars['Full'][4] = apply_filters('mce_buttons_4', array(), $editor_id);
48
+
49
+
50
+ // Basic
51
+ $toolbars['Basic'] = array();
52
+ $toolbars['Basic'][1] = apply_filters( 'teeny_mce_buttons', array('bold', 'italic', 'underline', 'blockquote', 'strikethrough', 'bullist', 'numlist', 'justifyleft', 'justifycenter', 'justifyright', 'undo', 'redo', 'link', 'unlink', 'fullscreen'), $editor_id );
53
+
54
+
55
+ // Custom - can be added with acf/fields/wysiwyg/toolbars filter
56
+
57
+ return $toolbars;
58
+ }
59
+
60
 
61
 
62
  /*--------------------------------------------------------------------------------------
115
  </td>
116
  <td>
117
  <?php
118
+ do_action('acf/create_field', array(
119
  'type' => 'textarea',
120
  'name' => 'fields['.$key.'][default_value]',
121
  'value' => $field['default_value'],
128
  <label><?php _e("Toolbar",'acf'); ?></label>
129
  </td>
130
  <td>
131
+ <?php
132
+
133
+ $toolbars = apply_filters( 'acf/fields/wysiwyg/toolbars', array() );
134
+ $choices = array();
135
+
136
+ if( is_array($toolbars) )
137
+ {
138
+ foreach( $toolbars as $k => $v )
139
+ {
140
+ $label = $k;
141
+ $name = sanitize_title( $label );
142
+ $name = str_replace('-', '_', $name);
143
+
144
+ $choices[ $name ] = $label;
145
+ }
146
+ }
147
+
148
+ do_action('acf/create_field', array(
149
  'type' => 'radio',
150
  'name' => 'fields['.$key.'][toolbar]',
151
  'value' => $field['toolbar'],
152
  'layout' => 'horizontal',
153
+ 'choices' => $choices
 
 
 
154
  ));
155
  ?>
156
  </td>
161
  </td>
162
  <td>
163
  <?php
164
+ do_action('acf/create_field', array(
165
  'type' => 'radio',
166
  'name' => 'fields['.$key.'][media_upload]',
167
  'value' => $field['media_upload'],
182
  </td>
183
  <td>
184
  <?php
185
+ do_action('acf/create_field', array(
186
  'type' => 'radio',
187
  'name' => 'fields['.$key.'][the_content]',
188
  'value' => $field['the_content'],
225
 
226
 
227
  ?>
228
+ <div id="wp-<?php echo $id; ?>-wrap" class="acf_wysiwyg wp-editor-wrap" data-toolbar="<?php echo $field['toolbar']; ?>" data-upload="<?php echo $field['media_upload']; ?>">
229
  <?php if($field['media_upload'] == 'yes'): ?>
230
  <?php if( version_compare($wp_version, '3.3', '<') ): ?>
231
  <div id="editor-toolbar">
core/views/meta_box_fields.php CHANGED
@@ -129,7 +129,7 @@ $conditional_logic_rule = array(
129
  </td>
130
  <td>
131
  <?php
132
- $this->parent->create_field(array(
133
  'type' => 'text',
134
  'name' => 'fields['.$field['key'].'][label]',
135
  'value' => $field['label'],
@@ -145,7 +145,7 @@ $conditional_logic_rule = array(
145
  </td>
146
  <td>
147
  <?php
148
- $this->parent->create_field(array(
149
  'type' => 'text',
150
  'name' => 'fields['.$field['key'].'][name]',
151
  'value' => $field['name'],
@@ -158,7 +158,7 @@ $conditional_logic_rule = array(
158
  <td class="label"><label><span class="required">*</span><?php _e("Field Type",'acf'); ?></label></td>
159
  <td>
160
  <?php
161
- $this->parent->create_field(array(
162
  'type' => 'select',
163
  'name' => 'fields['.$field['key'].'][type]',
164
  'value' => $field['type'],
@@ -172,7 +172,7 @@ $conditional_logic_rule = array(
172
  <p class="description"><?php _e("Instructions for authors. Shown when submitting data",'acf'); ?></p></td>
173
  <td>
174
  <?php
175
- $this->parent->create_field(array(
176
  'type' => 'textarea',
177
  'name' => 'fields['.$field['key'].'][instructions]',
178
  'value' => $field['instructions'],
@@ -184,7 +184,7 @@ $conditional_logic_rule = array(
184
  <td class="label"><label><?php _e("Required?",'acf'); ?></label></td>
185
  <td>
186
  <?php
187
- $this->parent->create_field(array(
188
  'type' => 'radio',
189
  'name' => 'fields['.$field['key'].'][required]',
190
  'value' => $field['required'],
@@ -209,7 +209,7 @@ $conditional_logic_rule = array(
209
  <td class="label"><label><?php _e("Conditional Logic",'acf'); ?></label></td>
210
  <td>
211
  <?php
212
- $this->parent->create_field(array(
213
  'type' => 'radio',
214
  'name' => 'fields['.$field['key'].'][conditional_logic][status]',
215
  'value' => $field['conditional_logic']['status'],
@@ -252,7 +252,7 @@ $conditional_logic_rule = array(
252
  </td>
253
  <td width="25%">
254
  <?php
255
- $this->parent->create_field(array(
256
  'type' => 'select',
257
  'name' => 'fields['.$field['key'].'][conditional_logic][rules][' . $rule_i . '][operator]',
258
  'value' => $rule['operator'],
@@ -277,7 +277,7 @@ $conditional_logic_rule = array(
277
 
278
  <ul class="hl clearfix">
279
  <li style="padding:4px 4px 0 0;"><?php _e("Show this field when",'acf'); ?></li>
280
- <li><?php $this->parent->create_field(array(
281
  'type' => 'select',
282
  'name' => 'fields['.$field['key'].'][conditional_logic][allorany]',
283
  'value' => $field['conditional_logic']['allorany'],
129
  </td>
130
  <td>
131
  <?php
132
+ do_action('acf/create_field', array(
133
  'type' => 'text',
134
  'name' => 'fields['.$field['key'].'][label]',
135
  'value' => $field['label'],
145
  </td>
146
  <td>
147
  <?php
148
+ do_action('acf/create_field', array(
149
  'type' => 'text',
150
  'name' => 'fields['.$field['key'].'][name]',
151
  'value' => $field['name'],
158
  <td class="label"><label><span class="required">*</span><?php _e("Field Type",'acf'); ?></label></td>
159
  <td>
160
  <?php
161
+ do_action('acf/create_field', array(
162
  'type' => 'select',
163
  'name' => 'fields['.$field['key'].'][type]',
164
  'value' => $field['type'],
172
  <p class="description"><?php _e("Instructions for authors. Shown when submitting data",'acf'); ?></p></td>
173
  <td>
174
  <?php
175
+ do_action('acf/create_field', array(
176
  'type' => 'textarea',
177
  'name' => 'fields['.$field['key'].'][instructions]',
178
  'value' => $field['instructions'],
184
  <td class="label"><label><?php _e("Required?",'acf'); ?></label></td>
185
  <td>
186
  <?php
187
+ do_action('acf/create_field', array(
188
  'type' => 'radio',
189
  'name' => 'fields['.$field['key'].'][required]',
190
  'value' => $field['required'],
209
  <td class="label"><label><?php _e("Conditional Logic",'acf'); ?></label></td>
210
  <td>
211
  <?php
212
+ do_action('acf/create_field', array(
213
  'type' => 'radio',
214
  'name' => 'fields['.$field['key'].'][conditional_logic][status]',
215
  'value' => $field['conditional_logic']['status'],
252
  </td>
253
  <td width="25%">
254
  <?php
255
+ do_action('acf/create_field', array(
256
  'type' => 'select',
257
  'name' => 'fields['.$field['key'].'][conditional_logic][rules][' . $rule_i . '][operator]',
258
  'value' => $rule['operator'],
277
 
278
  <ul class="hl clearfix">
279
  <li style="padding:4px 4px 0 0;"><?php _e("Show this field when",'acf'); ?></li>
280
+ <li><?php do_action('acf/create_field', array(
281
  'type' => 'select',
282
  'name' => 'fields['.$field['key'].'][conditional_logic][allorany]',
283
  'value' => $field['conditional_logic']['allorany'],
core/views/meta_box_location.php CHANGED
@@ -88,7 +88,7 @@ if( empty($location['rules']) )
88
  'optgroup' => true,
89
  );
90
 
91
- $this->parent->create_field($args);
92
 
93
  ?></td>
94
  <td class="operator"><?php
@@ -104,7 +104,7 @@ if( empty($location['rules']) )
104
 
105
 
106
  // create field
107
- $this->parent->create_field(array(
108
  'type' => 'select',
109
  'name' => 'location[rules]['.$k.'][operator]',
110
  'value' => $rule['operator'],
@@ -134,7 +134,7 @@ if( empty($location['rules']) )
134
  </table>
135
  <ul class="hl clearfix">
136
  <li style="padding:4px 4px 0 0;"><?php _e("match",'acf'); ?></li>
137
- <li><?php $this->parent->create_field(array(
138
  'type' => 'select',
139
  'name' => 'location[allorany]',
140
  'value' => $location['allorany'],
88
  'optgroup' => true,
89
  );
90
 
91
+ do_action('acf/create_field', $args);
92
 
93
  ?></td>
94
  <td class="operator"><?php
104
 
105
 
106
  // create field
107
+ do_action('acf/create_field', array(
108
  'type' => 'select',
109
  'name' => 'location[rules]['.$k.'][operator]',
110
  'value' => $rule['operator'],
134
  </table>
135
  <ul class="hl clearfix">
136
  <li style="padding:4px 4px 0 0;"><?php _e("match",'acf'); ?></li>
137
+ <li><?php do_action('acf/create_field', array(
138
  'type' => 'select',
139
  'name' => 'location[allorany]',
140
  'value' => $location['allorany'],
core/views/meta_box_options.php CHANGED
@@ -26,7 +26,7 @@ $options = $this->parent->get_acf_options($post->ID);
26
  <td>
27
  <?php
28
 
29
- $this->parent->create_field(array(
30
  'type' => 'text',
31
  'name' => 'menu_order',
32
  'value' => $post->menu_order,
@@ -42,7 +42,7 @@ $options = $this->parent->get_acf_options($post->ID);
42
  <td>
43
  <?php
44
 
45
- $this->parent->create_field(array(
46
  'type' => 'radio',
47
  'name' => 'options[position]',
48
  'value' => $options['position'],
@@ -62,7 +62,7 @@ $options = $this->parent->get_acf_options($post->ID);
62
  <td>
63
  <?php
64
 
65
- $this->parent->create_field(array(
66
  'type' => 'radio',
67
  'name' => 'options[layout]',
68
  'value' => $options['layout'],
@@ -84,7 +84,7 @@ $options = $this->parent->get_acf_options($post->ID);
84
  <td>
85
  <?php
86
 
87
- $this->parent->create_field(array(
88
  'type' => 'checkbox',
89
  'name' => 'options[hide_on_screen]',
90
  'value' => $options['hide_on_screen'],
26
  <td>
27
  <?php
28
 
29
+ do_action('acf/create_field', array(
30
  'type' => 'text',
31
  'name' => 'menu_order',
32
  'value' => $post->menu_order,
42
  <td>
43
  <?php
44
 
45
+ do_action('acf/create_field', array(
46
  'type' => 'radio',
47
  'name' => 'options[position]',
48
  'value' => $options['position'],
62
  <td>
63
  <?php
64
 
65
+ do_action('acf/create_field', array(
66
  'type' => 'radio',
67
  'name' => 'options[layout]',
68
  'value' => $options['layout'],
84
  <td>
85
  <?php
86
 
87
+ do_action('acf/create_field', array(
88
  'type' => 'checkbox',
89
  'name' => 'options[hide_on_screen]',
90
  'value' => $options['hide_on_screen'],
css/{fields.css → field-group.css} RENAMED
File without changes
css/input.css CHANGED
@@ -294,6 +294,8 @@
294
  }
295
 
296
 
 
 
297
  /*---------------------------------------------------------------------------------------------
298
  *
299
  * Field: File
@@ -1164,6 +1166,7 @@ td.acf_input-wrap {
1164
  width: 110px;
1165
  }
1166
 
 
1167
  /*
1168
  * Edit Image Message
1169
  */
@@ -1191,6 +1194,19 @@ td.acf_input-wrap {
1191
  }
1192
 
1193
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1194
  /*---------------------------------------------------------------------------------------------
1195
  *
1196
  * Tab
294
  }
295
 
296
 
297
+
298
+
299
  /*---------------------------------------------------------------------------------------------
300
  *
301
  * Field: File
1166
  width: 110px;
1167
  }
1168
 
1169
+
1170
  /*
1171
  * Edit Image Message
1172
  */
1194
  }
1195
 
1196
 
1197
+ /*
1198
+ * 3.5 Media Selected images
1199
+ */
1200
+
1201
+ .attachment.acf-selected {
1202
+ opacity: 0.3;
1203
+ }
1204
+
1205
+ .attachment.acf-selected .check {
1206
+ display: block;
1207
+ }
1208
+
1209
+
1210
  /*---------------------------------------------------------------------------------------------
1211
  *
1212
  * Tab
images/brand-hero-default.png ADDED
Binary file
images/button_add.png ADDED
Binary file
images/button_remove.png ADDED
Binary file
js/{fields.js → field-group.js} RENAMED
@@ -175,7 +175,40 @@ var acf = {
175
  $.fn.update_names = function()
176
  {
177
  var field = $(this),
178
- old_id = field.attr('data-id');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
 
180
 
181
  // load location html
@@ -198,34 +231,22 @@ var acf = {
198
 
199
 
200
  // update class
201
- var new_class = field.attr('class');
202
- new_class = new_class.replace(old_id, new_id);
203
- field.attr('class', new_class);
204
 
205
 
206
  // update field key column
207
  field.find('.field_meta td.field_key').text( new_id );
208
 
209
 
210
- // update inputs
211
- field.find('[name]').each(function()
212
  {
213
-
214
- var name = $(this).attr('name');
215
- var id = $(this).attr('id');
216
-
217
- if(name && name.indexOf('[' + old_id + ']') != -1)
218
- {
219
- name = name.replace('[' + old_id + ']','[' + new_id + ']');
220
- }
221
- if(id && id.indexOf('[' + old_id + ']') != -1)
222
- {
223
- id = id.replace('[' + old_id + ']','[' + new_id + ']');
224
- }
225
-
226
- $(this).attr('name', name);
227
- $(this).attr('id', id);
228
-
229
  });
230
 
231
  }
@@ -340,7 +361,6 @@ var acf = {
340
  // vars
341
  var a = $(this),
342
  field = a.closest('.field'),
343
- orig_type = field.find('tr.field_type select').val(),
344
  new_field = field.clone();
345
 
346
 
@@ -354,8 +374,14 @@ var acf = {
354
 
355
 
356
  // open up form
357
- new_field.find('a.acf_edit_field').first().trigger('click');
358
- new_field.find('tr.field_type select').first().val( orig_type ).trigger('change');
 
 
 
 
 
 
359
 
360
 
361
  // update order numbers
175
  $.fn.update_names = function()
176
  {
177
  var field = $(this),
178
+ old_id = field.attr('data-id'),
179
+ new_id = uniqid();
180
+
181
+
182
+ // temp give field unique ID for id / name.
183
+ // Because this is an AJAX call, it will take some time to get back the new_id.
184
+ // in this time, the new field will be added and the origional, and duplicate field
185
+ // will both use the same ID! This will cause browsers to remove the input settings on the first field
186
+
187
+ field.attr('data-id', new_id);
188
+
189
+
190
+ // update class
191
+ field.attr('class', field.attr('class').replace(old_id, new_id) );
192
+
193
+
194
+ // update field key column
195
+ field.find('.field_meta td.field_key').text( new_id );
196
+
197
+
198
+ // update attributes
199
+ field.find('[id*="' + old_id + '"]').each(function()
200
+ {
201
+ $(this).attr('id', $(this).attr('id').replace(old_id, new_id) );
202
+ });
203
+
204
+ field.find('[name*="' + old_id + '"]').each(function()
205
+ {
206
+ $(this).attr('name', $(this).attr('name').replace(old_id, new_id) );
207
+ });
208
+
209
+
210
+ // onld_id is now the unique_id() value
211
+ old_id = new_id;
212
 
213
 
214
  // load location html
231
 
232
 
233
  // update class
234
+ field.attr('class', field.attr('class').replace(old_id, new_id) );
 
 
235
 
236
 
237
  // update field key column
238
  field.find('.field_meta td.field_key').text( new_id );
239
 
240
 
241
+ // update attributes
242
+ field.find('[id*="' + old_id + '"]').each(function()
243
  {
244
+ $(this).attr('id', $(this).attr('id').replace(old_id, new_id) );
245
+ });
246
+
247
+ field.find('[name*="' + old_id + '"]').each(function()
248
+ {
249
+ $(this).attr('name', $(this).attr('name').replace(old_id, new_id) );
 
 
 
 
 
 
 
 
 
 
250
  });
251
 
252
  }
361
  // vars
362
  var a = $(this),
363
  field = a.closest('.field'),
 
364
  new_field = field.clone();
365
 
366
 
374
 
375
 
376
  // open up form
377
+ if( field.hasClass('form_open') )
378
+ {
379
+ field.find('.acf_edit_field').first().trigger('click');
380
+ }
381
+ else
382
+ {
383
+ new_field.find('.acf_edit_field').first().trigger('click');
384
+ }
385
 
386
 
387
  // update order numbers
js/input-actions.js DELETED
@@ -1,2081 +0,0 @@
1
- /*
2
- * Input Actions
3
- *
4
- * @description: javascript for fields functionality
5
- * @author: Elliot Condon
6
- * @since: 3.1.4
7
- */
8
-
9
- var acf = {
10
- admin_url : '',
11
- post_id : 0,
12
- validation : false,
13
- text : {
14
- 'validation_error' : "Validation Failed. One or more fields below are required.",
15
- 'file_tb_title_add' : "Add File to Field",
16
- 'file_tb_title_edit' : "Edit File",
17
- 'image_tb_title_add' : "Add Image to Field",
18
- 'image_tb_title_edit' : "Edit Image",
19
- 'relationship_max_alert' : "Maximum values reached ( {max} values )",
20
- 'gallery_tb_title_add' : "Add Image to Gallery",
21
- 'gallery_tb_title_edit' : "Edit Image",
22
- 'repeater_min_alert' : "Minimum rows reached ( {min} rows )",
23
- 'repeater_max_alert' : "Maximum rows reached ( {max} rows )"
24
- },
25
- conditional_logic : {},
26
- sortable_helper : null,
27
- tinyMCE_settings : null
28
- };
29
-
30
- (function($){
31
-
32
-
33
- /*
34
- * Exists
35
- *
36
- * @description: returns true / false
37
- * @created: 1/03/2011
38
- */
39
-
40
- $.fn.exists = function()
41
- {
42
- return $(this).length>0;
43
- };
44
-
45
-
46
- /*
47
- * Document Ready
48
- *
49
- * @description: adds ajax data
50
- * @created: 1/03/2011
51
- */
52
-
53
- $(document).ready(function(){
54
-
55
- // add classes
56
- $('#poststuff .postbox[id*="acf_"]').addClass('acf_postbox');
57
- $('#adv-settings label[for*="acf_"]').addClass('acf_hide_label');
58
-
59
- // hide acf stuff
60
- $('#poststuff .acf_postbox').addClass('acf-hidden');
61
- $('#adv-settings .acf_hide_label').hide();
62
-
63
- // loop through acf metaboxes
64
- $('#poststuff .postbox.acf_postbox').each(function(){
65
-
66
- // vars
67
- var options = $(this).find('> .inside > .options'),
68
- show = options.attr('data-show'),
69
- layout = options.attr('data-layout'),
70
- id = $(this).attr('id').replace('acf_', '');
71
-
72
- // layout
73
- $(this).addClass(layout);
74
-
75
- // show / hide
76
- if( show == "1" )
77
- {
78
- $(this).removeClass('acf-hidden');
79
- $('#adv-settings .acf_hide_label[for="acf_' + id + '-hide"]').show();
80
- }
81
-
82
- });
83
-
84
- });
85
-
86
-
87
- /*
88
- * Save Draft
89
- *
90
- * @description:
91
- * @created: 18/09/12
92
- */
93
- var save_post = false;
94
- $('#save-post').live('click', function(){
95
-
96
- save_post = true;
97
-
98
- });
99
-
100
-
101
- /*
102
- * Submit form
103
- *
104
- * @description: does validation, deletes all hidden metaboxes (otherwise, post data will be overriden by hidden inputs)
105
- * @created: 1/03/2011
106
- */
107
-
108
- $('form#post').live("submit", function(){
109
-
110
- if( ! save_post )
111
- {
112
- // do validation
113
- do_validation();
114
-
115
-
116
- if( ! acf.validation )
117
- {
118
- // show message
119
- $(this).siblings('#message').remove();
120
- $(this).before('<div id="message" class="error"><p>' + acf.text.validation_error + '</p></div>');
121
-
122
-
123
- // hide ajax stuff on submit button
124
- $('#publish').removeClass('button-primary-disabled');
125
- $('#ajax-loading').attr('style','');
126
- $('#publishing-action .spinner').hide();
127
-
128
- return false;
129
- }
130
- }
131
-
132
-
133
- // remove hidden postboxes
134
- $('.acf_postbox.acf-hidden').remove();
135
-
136
-
137
- // submit the form
138
- return true;
139
-
140
- });
141
-
142
-
143
- /*
144
- * do_validation
145
- *
146
- * @description: checks fields for required input
147
- * @created: 1/03/2011
148
- */
149
-
150
- function do_validation(){
151
-
152
- acf.validation = true;
153
-
154
- $('.postbox:not(.acf-hidden) .field.required, .form-field.required').each(function(){
155
-
156
- // vars
157
- var div = $(this);
158
-
159
-
160
- // set validation data
161
- div.data('validation', true);
162
-
163
-
164
- // if is hidden by conditional logic, ignore
165
- if( div.hasClass('acf-conditional_logic-hide') )
166
- {
167
- return;
168
- }
169
-
170
-
171
- // text / textarea
172
- if( div.find('input[type="text"], input[type="number"], input[type="hidden"], textarea').val() == "" )
173
- {
174
- div.data('validation', false);
175
- }
176
-
177
-
178
- // wysiwyg
179
- if( div.find('.acf_wysiwyg').exists() && typeof(tinyMCE) == "object")
180
- {
181
- div.data('validation', true);
182
-
183
- var id = div.find('.wp-editor-area').attr('id'),
184
- editor = tinyMCE.get( id );
185
-
186
- if( ! editor.getContent() )
187
- {
188
- div.data('validation', false);
189
- }
190
- }
191
-
192
-
193
- // select
194
- if( div.find('select').exists() )
195
- {
196
- div.data('validation', true);
197
-
198
- if( div.find('select').val() == "null" || ! div.find('select').val() )
199
- {
200
- div.data('validation', false);
201
- }
202
- }
203
-
204
-
205
- // checkbox
206
- if( div.find('input[type="checkbox"]:checked').exists() )
207
- {
208
- div.data('validation', true);
209
- }
210
-
211
-
212
- // relationship
213
- if( div.find('.acf_relationship').exists() )
214
- {
215
- div.data('validation', false);
216
-
217
- if( div.find('.acf_relationship .relationship_right input').exists() )
218
- {
219
- div.data('validation', true);
220
- }
221
- }
222
-
223
-
224
- // repeater
225
- if( div.find('.repeater').exists() )
226
- {
227
- div.data('validation', false);
228
-
229
- if( div.find('.repeater tr.row').exists() )
230
- {
231
- div.data('validation', true);
232
- }
233
- }
234
-
235
-
236
- // flexible content
237
- if( div.find('.acf_flexible_content').exists() )
238
- {
239
- div.data('validation', false);
240
- if( div.find('.acf_flexible_content .values table').exists() )
241
- {
242
- div.data('validation', true);
243
- }
244
- }
245
-
246
-
247
- // gallery
248
- if( div.find('.acf-gallery').exists() )
249
- {
250
- div.data('validation', false);
251
-
252
- if( div.find('.acf-gallery .thumbnail').exists())
253
- {
254
- div.data('validation', true);
255
- }
256
- }
257
-
258
-
259
- // hook for custom validation
260
- $(document).trigger('acf/validate_field', div );
261
-
262
-
263
- // set validation
264
- if( ! div.data('validation') )
265
- {
266
- acf.validation = false;
267
- div.closest('.field').addClass('error');
268
- }
269
-
270
- });
271
-
272
-
273
- }
274
-
275
-
276
- /*
277
- * Remove error class on focus
278
- *
279
- * @description:
280
- * @created: 1/03/2011
281
- */
282
-
283
- // inputs / textareas
284
- $('.field.required input, .field.required textarea, .field.required select').live('focus', function(){
285
- $(this).closest('.field').removeClass('error');
286
- });
287
-
288
- // checkbox
289
- $('.field.required input:checkbox').live('click', function(){
290
- $(this).closest('.field').removeClass('error');
291
- });
292
-
293
-
294
- /*
295
- * Field: Color Picker
296
- *
297
- * @description:
298
- * @created: 1/03/2011
299
- */
300
-
301
- $(document).ready(function(){
302
-
303
- // validate
304
- if( ! $.farbtastic )
305
- {
306
- return;
307
- }
308
-
309
- $('body').append('<div id="acf_color_picker" />');
310
-
311
- acf.farbtastic = $.farbtastic('#acf_color_picker');
312
-
313
- });
314
-
315
-
316
- // update colors
317
- $(document).live('acf/setup_fields', function(e, postbox){
318
-
319
- // validate
320
- if( ! $.farbtastic )
321
- {
322
- return;
323
- }
324
-
325
-
326
- $(postbox).find('input.acf_color_picker').each(function(){
327
-
328
- // vars
329
- var input = $(this);
330
-
331
-
332
- // is clone field?
333
- if( acf.is_clone_field(input) )
334
- {
335
- return;
336
- }
337
-
338
-
339
- if( input.val() )
340
- {
341
- $.farbtastic( input ).setColor( input.val() ).hsl[2] > 0.5 ? color = '#000' : color = '#fff';
342
-
343
- input.css({
344
- backgroundColor : input.val(),
345
- color : color
346
- });
347
- }
348
-
349
- });
350
-
351
- });
352
-
353
-
354
- $('input.acf_color_picker').live('focus', function(){
355
-
356
- var input = $(this);
357
-
358
- if( ! input.val() )
359
- {
360
- input.val( '#FFFFFF' );
361
- }
362
-
363
- $('#acf_color_picker').css({
364
- left: input.offset().left,
365
- top: input.offset().top - $('#acf_color_picker').height(),
366
- display: 'block'
367
- });
368
-
369
- acf.farbtastic.linkTo(this);
370
-
371
- }).live('blur', function(){
372
-
373
- var input = $(this);
374
-
375
-
376
- // reset the css
377
- if( ! input.val() )
378
- {
379
- input.css({
380
- backgroundColor : '#fff',
381
- color : '#000'
382
- });
383
-
384
- }
385
-
386
-
387
- $('#acf_color_picker').css({
388
- display: 'none'
389
- });
390
-
391
- });
392
-
393
-
394
- /*
395
- * Field: File
396
- *
397
- * @description:
398
- * @created: 1/03/2011
399
- */
400
-
401
- // add file
402
- $('.acf-file-uploader .add-file').live('click', function(){
403
-
404
- // vars
405
- var div = $(this).closest('.acf-file-uploader');
406
-
407
- // set global var
408
- window.acf_div = div;
409
-
410
- // show the thickbox
411
- tb_show( acf.text.file_tb_title_add , acf.admin_url + 'media-upload.php?post_id=' + acf.post_id + '&post_ID=' + acf.post_id + '&type=file&acf_type=file&TB_iframe=1');
412
-
413
- return false;
414
- });
415
-
416
- // remove file
417
- $('.acf-file-uploader .remove-file').live('click', function(){
418
-
419
- // vars
420
- var div = $(this).closest('.acf-file-uploader');
421
-
422
- div.removeClass('active').find('input.value').val('').trigger('change');
423
-
424
- return false;
425
-
426
- });
427
-
428
- // edit file
429
- $('.acf-file-uploader .edit-file').live('click', function(){
430
-
431
- // vars
432
- var div = $(this).closest('.acf-file-uploader'),
433
- id = div.find('input.value').val();
434
-
435
-
436
- // set global var
437
- window.acf_edit_attachment = div;
438
-
439
-
440
- // show edit attachment
441
- tb_show( acf.text.file_tb_title_edit , acf.admin_url + 'media.php?attachment_id=' + id + '&action=edit&acf_action=edit_attachment&acf_field=file&TB_iframe=1');
442
-
443
-
444
- return false;
445
-
446
- });
447
-
448
-
449
- /*
450
- * Field: Image
451
- *
452
- * @description:
453
- * @created: 1/03/2011
454
- */
455
-
456
- // add image
457
- $('.acf-image-uploader .add-image').live('click', function(){
458
-
459
- // vars
460
- var div = $(this).closest('.acf-image-uploader'),
461
- preview_size = div.attr('data-preview_size');
462
-
463
- // set global var
464
- window.acf_div = div;
465
-
466
- // show the thickbox
467
- tb_show( acf.text.image_tb_title_add , acf.admin_url + 'media-upload.php?post_id=' + acf.post_id + '&post_ID=' + acf.post_id + '&type=image&acf_type=image&acf_preview_size=' + preview_size + 'TB_iframe=1');
468
-
469
- return false;
470
- });
471
-
472
- // remove image
473
- $('.acf-image-uploader .acf-button-delete').live('click', function(){
474
-
475
- // vars
476
- var div = $(this).closest('.acf-image-uploader');
477
-
478
- div.removeClass('active');
479
- div.find('input.value').val('').trigger('change');
480
- div.find('img').attr('src', '');
481
-
482
- return false;
483
-
484
- });
485
-
486
- // edit image
487
- $('.acf-image-uploader .acf-button-edit').live('click', function(){
488
-
489
- // vars
490
- var div = $(this).closest('.acf-image-uploader'),
491
- id = div.find('input.value').val();
492
-
493
-
494
- // set global var
495
- window.acf_edit_attachment = div;
496
-
497
-
498
- // show edit attachment
499
- tb_show( acf.text.image_tb_title_edit , acf.admin_url + 'media.php?attachment_id=' + id + '&action=edit&acf_action=edit_attachment&acf_field=image&TB_iframe=1');
500
-
501
-
502
- return false;
503
-
504
- });
505
-
506
-
507
- /*
508
- * Field: Relationship
509
- *
510
- * @description:
511
- * @since: 2.0.4
512
- * @created: 11/12/12
513
- */
514
-
515
- // add sortable
516
- $(document).live('acf/setup_fields', function(e, postbox){
517
-
518
- $(postbox).find('.acf_relationship').each(function(){
519
-
520
- // is clone field?
521
- if( acf.is_clone_field($(this).children('input[type="hidden"]')) )
522
- {
523
- return;
524
- }
525
-
526
-
527
- $(this).find('.relationship_right .relationship_list').sortable({
528
- axis: "y", // limit the dragging to up/down only
529
- items: '> li',
530
- forceHelperSize: true,
531
- forcePlaceholderSize: true,
532
- scroll: true
533
- });
534
-
535
-
536
- // load more
537
- $(this).find('.relationship_left .relationship_list').scrollTop(0).scroll( function(){
538
-
539
- // vars
540
- var div = $(this).closest('.acf_relationship');
541
-
542
-
543
- // validate
544
- if( div.hasClass('loading') )
545
- {
546
- return;
547
- }
548
-
549
-
550
- // Scrolled to bottom
551
- if( $(this).scrollTop() + $(this).innerHeight() >= $(this).get(0).scrollHeight )
552
- {
553
- var paged = parseInt( div.attr('data-paged') );
554
-
555
- div.attr('data-paged', (paged + 1) );
556
-
557
- acf.relationship_update_results( div );
558
- }
559
-
560
- });
561
-
562
-
563
- // ajax fetch values for left side
564
- acf.relationship_update_results( $(this) );
565
-
566
- });
567
-
568
- });
569
-
570
-
571
- // add from left to right
572
- $('.acf_relationship .relationship_left .relationship_list a').live('click', function(){
573
-
574
- // vars
575
- var id = $(this).attr('data-post_id'),
576
- title = $(this).html(),
577
- div = $(this).closest('.acf_relationship'),
578
- max = parseInt(div.attr('data-max')),
579
- right = div.find('.relationship_right .relationship_list');
580
-
581
-
582
- // max posts
583
- if( right.find('a').length >= max )
584
- {
585
- alert( acf.text.relationship_max_alert.replace('{max}', max) );
586
- return false;
587
- }
588
-
589
-
590
- // can be added?
591
- if( $(this).parent().hasClass('hide') )
592
- {
593
- return false;
594
- }
595
-
596
-
597
- // hide / show
598
- $(this).parent().addClass('hide');
599
-
600
-
601
- // create new li for right side
602
- var new_li = div.children('.tmpl-li').html()
603
- .replace( /\{post_id}/gi, id )
604
- .replace( /\{title}/gi, title );
605
-
606
-
607
-
608
- // add new li
609
- right.append( new_li );
610
-
611
-
612
- // validation
613
- div.closest('.field').removeClass('error');
614
-
615
- return false;
616
-
617
- });
618
-
619
-
620
- // remove from right to left
621
- $('.acf_relationship .relationship_right .relationship_list a').live('click', function(){
622
-
623
- // vars
624
- var id = $(this).attr('data-post_id'),
625
- div = $(this).closest('.acf_relationship'),
626
- left = div.find('.relationship_left .relationship_list');
627
-
628
-
629
- // hide
630
- $(this).parent().remove();
631
-
632
-
633
- // show
634
- left.find('a[data-post_id="' + id + '"]').parent('li').removeClass('hide');
635
-
636
-
637
- return false;
638
-
639
- });
640
-
641
-
642
- // search
643
- $('.acf_relationship input.relationship_search').live('keyup', function()
644
- {
645
- // vars
646
- var val = $(this).val(),
647
- div = $(this).closest('.acf_relationship');
648
-
649
-
650
- // update data-s
651
- div.attr('data-s', val);
652
-
653
-
654
- // new search, reset paged
655
- div.attr('data-paged', 1);
656
-
657
-
658
- // ajax
659
- clearTimeout( acf.relationship_timeout );
660
- acf.relationship_timeout = setTimeout(function(){
661
- acf.relationship_update_results( div );
662
- }, 250);
663
-
664
- return false;
665
-
666
- })
667
- .live('focus', function(){
668
- $(this).siblings('label').hide();
669
- })
670
- .live('blur', function(){
671
- if($(this).val() == "")
672
- {
673
- $(this).siblings('label').show();
674
- }
675
- });
676
-
677
-
678
- // hide results
679
- acf.relationship_hide_results = function( div ){
680
-
681
- // vars
682
- var left = div.find('.relationship_left .relationship_list'),
683
- right = div.find('.relationship_right .relationship_list');
684
-
685
-
686
- // apply .hide to left li's
687
- left.find('a').each(function(){
688
-
689
- var id = $(this).attr('data-post_id');
690
-
691
- if( right.find('a[data-post_id="' + id + '"]').exists() )
692
- {
693
- $(this).parent().addClass('hide');
694
- }
695
-
696
- });
697
-
698
- }
699
-
700
-
701
- // update results
702
- acf.relationship_update_results = function( div ){
703
-
704
-
705
- // add loading class, stops scroll loading
706
- div.addClass('loading');
707
-
708
-
709
- // vars
710
- var s = div.attr('data-s'),
711
- paged = parseInt( div.attr('data-paged') ),
712
- taxonomy = div.attr('data-taxonomy'),
713
- post_type = div.attr('data-post_type'),
714
- lang = div.attr('data-lang'),
715
- left = div.find('.relationship_left .relationship_list'),
716
- right = div.find('.relationship_right .relationship_list');
717
-
718
-
719
- // get results
720
- $.ajax({
721
- url: ajaxurl,
722
- type: 'post',
723
- dataType: 'html',
724
- data: {
725
- 'action' : 'acf_get_relationship_results',
726
- 's' : s,
727
- 'paged' : paged,
728
- 'taxonomy' : taxonomy,
729
- 'post_type' : post_type,
730
- 'lang' : lang,
731
- 'field_name' : div.parent().attr('data-field_name'),
732
- 'field_key' : div.parent().attr('data-field_key')
733
- },
734
- success: function( html ){
735
-
736
- div.removeClass('no-results').removeClass('loading');
737
-
738
- // new search?
739
- if( paged == 1 )
740
- {
741
- left.find('li:not(.load-more)').remove();
742
- }
743
-
744
-
745
- // no results?
746
- if( !html )
747
- {
748
- div.addClass('no-results');
749
- return;
750
- }
751
-
752
-
753
- // append new results
754
- left.find('.load-more').before( html );
755
-
756
-
757
- // less than 10 results?
758
- var ul = $('<ul>' + html + '</ul>');
759
- if( ul.find('li').length < 10 )
760
- {
761
- div.addClass('no-results');
762
- }
763
-
764
-
765
- // hide values
766
- acf.relationship_hide_results( div );
767
-
768
- }
769
- });
770
- };
771
-
772
-
773
- /*
774
- * acf/wysiwyg_activate
775
- *
776
- * @description:
777
- * @created: 3/03/2011
778
- */
779
-
780
- $(document).live('acf/wysiwyg_activate', function(e, div){
781
-
782
- // validate tinymce
783
- if( typeof(tinyMCE) != "object" )
784
- {
785
- return;
786
- }
787
-
788
-
789
- // store settings
790
- if( ! acf.tinyMCE_settings )
791
- {
792
- acf.tinyMCE_settings = $.extend( {}, tinyMCE.settings );
793
- }
794
-
795
-
796
- // activate
797
- $(div).find('.acf_wysiwyg textarea').each(function(){
798
-
799
- // vars
800
- var textarea = $(this),
801
- id = textarea.attr('id'),
802
- toolbar = textarea.closest('.acf_wysiwyg').attr('data-toolbar');
803
-
804
-
805
- // is clone field?
806
- if( acf.is_clone_field(textarea) )
807
- {
808
- return;
809
- }
810
-
811
-
812
- // reset tinyMCE settings
813
- tinyMCE.settings = $.extend( {}, acf.tinyMCE_settings );
814
-
815
-
816
- // Set toolbar
817
- if( toolbar == 'basic' )
818
- {
819
- tinyMCE.settings.theme_advanced_buttons1 = "bold, italic, underline, blockquote, |, strikethrough, bullist, numlist, justifyleft, justifycenter, justifyright, undo, redo, link, unlink, fullscreen";
820
- tinyMCE.settings.theme_advanced_buttons2 = "";
821
- }
822
- else
823
- {
824
- tinyMCE.settings.theme_advanced_buttons2 += ",code";
825
- }
826
-
827
-
828
- // add functionality back in
829
- tinyMCE.execCommand("mceAddControl", false, id);
830
-
831
-
832
- // events - load
833
- $(document).trigger('acf/wysiwyg/load', id);
834
-
835
-
836
- // add events (click, focus, blur) for inserting image into correct editor
837
- acf.add_wysiwyg_events( id );
838
-
839
- });
840
-
841
-
842
- wpActiveEditor = null;
843
-
844
- });
845
-
846
-
847
- /*
848
- * add_wysiwyg_events
849
- *
850
- * @description:
851
- * @since: 2.0.4
852
- * @created: 16/12/12
853
- */
854
-
855
- acf.add_wysiwyg_events = function( id ){
856
-
857
- // validate tinymce
858
- if( typeof(tinyMCE) != "object" )
859
- {
860
- return;
861
- }
862
-
863
-
864
- var editor = tinyMCE.get( id );
865
-
866
- if( !editor )
867
- {
868
- return;
869
- }
870
-
871
-
872
- var container = $('#wp-' + id + '-wrap'),
873
- body = $( editor.getBody() );
874
-
875
-
876
- container.click(function(){
877
- $(document).trigger('acf/wysiwyg/click', id);
878
- });
879
-
880
- body.focus(function(){
881
- $(document).trigger('acf/wysiwyg/focus', id);
882
- }).blur(function(){
883
- $(document).trigger('acf/wysiwyg/blur', id);
884
- });
885
-
886
- };
887
-
888
-
889
- /*
890
- * acf/wysiwyg_deactivate
891
- *
892
- * @description:
893
- * @created: 3/03/2011
894
- */
895
-
896
- $(document).live('acf/wysiwyg_deactivate', function(e, div){
897
-
898
- // validate tinymce
899
- if( typeof(tinyMCE) != "object" )
900
- {
901
- return;
902
- }
903
-
904
-
905
- $(div).find('.acf_wysiwyg textarea').each(function(){
906
-
907
- // vars
908
- var textarea = $(this),
909
- id = textarea.attr('id'),
910
- wysiwyg = tinyMCE.get( id );
911
-
912
-
913
- // if wysiwyg was found (should be always...), remove its functionality and set the value (to keep line breaks)
914
- if( wysiwyg )
915
- {
916
- var val = wysiwyg.getContent();
917
-
918
- tinyMCE.execCommand("mceRemoveControl", false, id);
919
-
920
- textarea.val( val );
921
- }
922
-
923
- });
924
-
925
-
926
- wpActiveEditor = null;
927
-
928
- });
929
-
930
-
931
- // set active wysiwyg
932
- $(document).live('acf/wysiwyg/click', function(e, id){
933
-
934
- wpActiveEditor = id;
935
-
936
- container = $('#wp-' + id + '-wrap').closest('.field').removeClass('error');
937
-
938
- }).live('acf/wysiwyg/focus', function(e, id){
939
-
940
- wpActiveEditor = id;
941
-
942
- container = $('#wp-' + id + '-wrap').closest('.field').removeClass('error');
943
-
944
- }).live('acf/wysiwyg/blur', function(e, id){
945
-
946
- wpActiveEditor = null;
947
-
948
- });
949
-
950
-
951
- // create wysiwygs
952
- $(document).live('acf/setup_fields', function(e, div){
953
-
954
- $(document).trigger('acf/wysiwyg_activate', div);
955
-
956
- });
957
-
958
-
959
- /*
960
- * window load
961
- *
962
- * @description:
963
- * @since: 3.5.5
964
- * @created: 22/12/12
965
- */
966
-
967
- $(window).load(function(){
968
-
969
- // vars
970
- var wp_content = $('#wp-content-wrap').exists(),
971
- wp_acf_settings = $('#wp-acf_settings-wrap').exists()
972
- mode = 'tmce';
973
-
974
-
975
- // has_editor
976
- if( wp_content )
977
- {
978
- // html_mode
979
- if( $('#wp-content-wrap').hasClass('html-active') )
980
- {
981
- mode = 'html';
982
- }
983
- }
984
-
985
-
986
- setTimeout(function(){
987
-
988
- // trigger click on hidden wysiwyg (to get in HTML mode)
989
- if( wp_acf_settings && mode == 'html' )
990
- {
991
- $('#acf_settings-tmce').trigger('click');
992
- }
993
-
994
- }, 1);
995
-
996
-
997
- setTimeout(function(){
998
-
999
- // setup fields
1000
- $(document).trigger('acf/setup_fields', $('#poststuff'));
1001
-
1002
-
1003
- // trigger html mode for people who want to stay in HTML mode
1004
- if( wp_acf_settings && mode == 'html' )
1005
- {
1006
- $('#acf_settings-html').trigger('click');
1007
- }
1008
-
1009
- // Add events to content editor
1010
- if( wp_content )
1011
- {
1012
- acf.add_wysiwyg_events( 'content' );
1013
- }
1014
-
1015
-
1016
- }, 10);
1017
-
1018
- });
1019
-
1020
-
1021
- /*
1022
- * Sortable Helper
1023
- *
1024
- * @description: keeps widths of td's inside a tr
1025
- * @since 3.5.1
1026
- * @created: 10/11/12
1027
- */
1028
-
1029
- acf.sortable_helper = function(e, ui)
1030
- {
1031
- ui.children().each(function(){
1032
- $(this).width($(this).width());
1033
- });
1034
- return ui;
1035
- };
1036
-
1037
-
1038
- /*
1039
- * acf/sortable_start
1040
- *
1041
- * @description:
1042
- * @since 3.5.1
1043
- * @created: 10/11/12
1044
- */
1045
-
1046
- $(document).live('acf/sortable_start', function(e, div) {
1047
-
1048
- $(document).trigger('acf/wysiwyg_deactivate', div);
1049
-
1050
- });
1051
-
1052
-
1053
- /*
1054
- * acf/sortable_stop
1055
- *
1056
- * @description:
1057
- * @since 3.5.1
1058
- * @created: 10/11/12
1059
- */
1060
-
1061
- $(document).live('acf/sortable_stop', function(e, div) {
1062
-
1063
- $(document).trigger('acf/wysiwyg_activate', div);
1064
-
1065
- });
1066
-
1067
-
1068
- /*
1069
- * Field: Repeater
1070
- *
1071
- * @description:
1072
- * @created: 3/03/2011
1073
- */
1074
-
1075
- // create a unique id
1076
- function uniqid()
1077
- {
1078
- var newDate = new Date;
1079
- return newDate.getTime();
1080
- }
1081
-
1082
-
1083
- // update order
1084
- function repeater_update_order( repeater )
1085
- {
1086
- repeater.find('> table > tbody > tr.row').each(function(i){
1087
- $(this).children('td.order').html( i+1 );
1088
- });
1089
-
1090
- };
1091
-
1092
-
1093
- // setup repeater fields
1094
- $(document).live('acf/setup_fields', function(e, postbox){
1095
-
1096
- $(postbox).find('.repeater').each(function(){
1097
-
1098
- var repeater = $(this)
1099
-
1100
-
1101
- // set column widths
1102
- repeater_set_column_widths( repeater );
1103
-
1104
-
1105
- // update classes based on row count
1106
- repeater_update_classes( repeater );
1107
-
1108
-
1109
- // add sortable
1110
- repeater_add_sortable( repeater );
1111
-
1112
- });
1113
-
1114
- });
1115
-
1116
-
1117
- /*
1118
- * repeater_set_column_widths
1119
- *
1120
- * @description:
1121
- * @since 3.5.1
1122
- * @created: 11/11/12
1123
- */
1124
-
1125
- function repeater_set_column_widths( repeater )
1126
- {
1127
- // validate
1128
- if( repeater.children('.acf-input-table').hasClass('row_layout') )
1129
- {
1130
- return;
1131
- }
1132
-
1133
-
1134
- // accomodate for order / remove
1135
- var column_width = 100;
1136
- if( repeater.find('> .acf-input-table > thead > tr > th.order').exists() )
1137
- {
1138
- column_width = 93;
1139
- }
1140
-
1141
-
1142
- // find columns that already have a width and remove these amounts from the column_width var
1143
- repeater.find('> .acf-input-table > thead > tr > th[width]').each(function( i ){
1144
-
1145
- column_width -= parseInt( $(this).attr('width') );
1146
- });
1147
-
1148
-
1149
- var ths = repeater.find('> .acf-input-table > thead > tr > th').not('[width]').has('span');
1150
- if( ths.length > 1 )
1151
- {
1152
- column_width = column_width / ths.length;
1153
-
1154
- ths.each(function( i ){
1155
-
1156
- // dont add width to last th
1157
- if( (i+1) == ths.length )
1158
- {
1159
- return;
1160
- }
1161
-
1162
- $(this).attr('width', column_width + '%');
1163
-
1164
- });
1165
- }
1166
-
1167
- }
1168
-
1169
-
1170
- /*
1171
- * repeater_update_classes
1172
- *
1173
- * @description:
1174
- * @since 3.5.2
1175
- * @created: 11/11/12
1176
- */
1177
-
1178
- function repeater_update_classes( repeater )
1179
- {
1180
- // vars
1181
- var max_rows = parseFloat( repeater.attr('data-max_rows') ),
1182
- row_count = repeater.find('> table > tbody > tr.row').length;
1183
-
1184
-
1185
- // empty?
1186
- if( row_count == 0 )
1187
- {
1188
- repeater.addClass('empty');
1189
- }
1190
- else
1191
- {
1192
- repeater.removeClass('empty');
1193
- }
1194
-
1195
-
1196
- // row limit reached
1197
- if( row_count >= max_rows )
1198
- {
1199
- repeater.addClass('disabled');
1200
- repeater.find('> .repeater-footer .acf-button').addClass('disabled');
1201
- }
1202
- else
1203
- {
1204
- repeater.removeClass('disabled');
1205
- repeater.find('> .repeater-footer .acf-button').removeClass('disabled');
1206
- }
1207
-
1208
- }
1209
-
1210
-
1211
- /*
1212
- * repeater_add_sortable
1213
- *
1214
- * @description:
1215
- * @since 3.5.2
1216
- * @created: 11/11/12
1217
- */
1218
-
1219
- function repeater_add_sortable( repeater ){
1220
-
1221
- // vars
1222
- var max_rows = parseFloat( repeater.attr('data-max_rows') );
1223
-
1224
-
1225
- // validate
1226
- if( max_rows <= 1 )
1227
- {
1228
- return;
1229
- }
1230
-
1231
- repeater.find('> table > tbody').unbind('sortable').sortable({
1232
- items : '> tr.row',
1233
- handle : '> td.order',
1234
- helper : acf.sortable_helper,
1235
- forceHelperSize : true,
1236
- forcePlaceholderSize : true,
1237
- scroll : true,
1238
- start : function (event, ui) {
1239
-
1240
- $(document).trigger('acf/sortable_start', ui.item);
1241
- $(document).trigger('acf/sortable_start_repeater', ui.item);
1242
-
1243
- // add markup to the placeholder
1244
- var td_count = ui.item.children('td').length;
1245
- ui.placeholder.html('<td colspan="' + td_count + '"></td>');
1246
-
1247
- },
1248
- stop : function (event, ui) {
1249
-
1250
- $(document).trigger('acf/sortable_stop', ui.item);
1251
- $(document).trigger('acf/sortable_stop_repeater', ui.item);
1252
-
1253
- // update order numbers
1254
- repeater_update_order( repeater );
1255
-
1256
- }
1257
- });
1258
- };
1259
-
1260
-
1261
- // add field
1262
- function repeater_add_field( repeater, before )
1263
- {
1264
- // vars
1265
- var max_rows = parseInt( repeater.attr('data-max_rows') ),
1266
- row_count = repeater.find('> table > tbody > tr.row').length;
1267
-
1268
-
1269
- // validate
1270
- if( row_count >= max_rows )
1271
- {
1272
- alert( acf.text.repeater_max_alert.replace('{max}', max_rows) );
1273
- return false;
1274
- }
1275
-
1276
-
1277
- // create and add the new field
1278
- var new_id = uniqid(),
1279
- new_field_html = repeater.find('> table > tbody > tr.row-clone').html().replace(/(=["]*[\w-\[\]]*?)(acfcloneindex)/g, '$1' + new_id),
1280
- new_field = $('<tr class="row"></tr>').append( new_field_html );
1281
-
1282
-
1283
- // add row
1284
- if( !before )
1285
- {
1286
- before = repeater.find('> table > tbody > .row-clone');
1287
- }
1288
-
1289
- before.before( new_field );
1290
-
1291
-
1292
- // trigger mouseenter on parent repeater to work out css margin on add-row button
1293
- repeater.closest('tr').trigger('mouseenter');
1294
-
1295
-
1296
- // update order
1297
- repeater_update_order( repeater );
1298
-
1299
-
1300
- // update classes based on row count
1301
- repeater_update_classes( repeater );
1302
-
1303
-
1304
- // setup fields
1305
- $(document).trigger('acf/setup_fields', new_field);
1306
-
1307
-
1308
- // validation
1309
- repeater.closest('.field').removeClass('error');
1310
- }
1311
-
1312
-
1313
- // add row - end
1314
- $('.repeater .repeater-footer .add-row-end').live('click', function(){
1315
-
1316
- var repeater = $(this).closest('.repeater');
1317
-
1318
-
1319
- repeater_add_field( repeater, false );
1320
-
1321
-
1322
- return false;
1323
- });
1324
-
1325
-
1326
- // add row - before
1327
- $('.repeater td.remove .add-row-before').live('click', function(){
1328
-
1329
- var repeater = $(this).closest('.repeater'),
1330
- before = $(this).closest('tr');
1331
-
1332
-
1333
- repeater_add_field( repeater, before );
1334
-
1335
-
1336
- return false;
1337
- });
1338
-
1339
-
1340
- function repeater_remove_row( tr )
1341
- {
1342
- // vars
1343
- var repeater = tr.closest('.repeater'),
1344
- min_rows = parseInt( repeater.attr('data-min_rows') ),
1345
- row_count = repeater.find('> table > tbody > tr.row').length,
1346
- column_count = tr.children('tr.row').length,
1347
- row_height = tr.height();
1348
-
1349
-
1350
- // validate
1351
- if( row_count <= min_rows )
1352
- {
1353
- alert( acf.text.repeater_min_alert.replace('{min}', row_count) );
1354
- return false;
1355
- }
1356
-
1357
-
1358
- // animate out tr
1359
- tr.addClass('acf-remove-item');
1360
- setTimeout(function(){
1361
-
1362
- tr.remove();
1363
-
1364
-
1365
- // trigger mouseenter on parent repeater to work out css margin on add-row button
1366
- repeater.closest('tr').trigger('mouseenter');
1367
-
1368
-
1369
- // update order
1370
- repeater_update_order( repeater );
1371
-
1372
-
1373
- // update classes based on row count
1374
- repeater_update_classes( repeater );
1375
-
1376
- }, 400);
1377
-
1378
- }
1379
-
1380
-
1381
- // remove field
1382
- $('.repeater td.remove .acf-button-remove').live('click', function(){
1383
- var tr = $(this).closest('tr');
1384
- repeater_remove_row( tr );
1385
- return false;
1386
- });
1387
-
1388
-
1389
- // hover over tr, align add-row button to top
1390
- $('.repeater tr').live('mouseenter', function(){
1391
-
1392
- var button = $(this).find('> td.remove > a.acf-button-add');
1393
- var margin = ( button.parent().height() / 2 ) + 9; // 9 = padding + border
1394
-
1395
- button.css('margin-top', '-' + margin + 'px' );
1396
-
1397
- });
1398
-
1399
-
1400
-
1401
- /*-----------------------------------------------------------------------------
1402
- *
1403
- * Flexible Content
1404
- *
1405
- *----------------------------------------------------------------------------*/
1406
-
1407
-
1408
- /*
1409
- * flexible_content_add_sortable
1410
- *
1411
- * @description:
1412
- * @created: 25/05/12
1413
- */
1414
-
1415
- function flexible_content_add_sortable( div )
1416
- {
1417
-
1418
- // remove (if clone) and add sortable
1419
- div.children('.values').unbind('sortable').sortable({
1420
- items : '> .layout',
1421
- handle : '> .menu-item-handle',
1422
- forceHelperSize : true,
1423
- forcePlaceholderSize : true,
1424
- scroll : true,
1425
- start : function (event, ui) {
1426
-
1427
- $(document).trigger('acf/sortable_start', ui.item);
1428
- $(document).trigger('acf/sortable_start_flexible_content', ui.item);
1429
-
1430
- },
1431
- stop : function (event, ui) {
1432
-
1433
- $(document).trigger('acf/sortable_stop', ui.item);
1434
- $(document).trigger('acf/sortable_stop_flexible_content', ui.item);
1435
-
1436
- // update order numbers
1437
- flexible_content_update_order( div );
1438
- }
1439
- });
1440
-
1441
- };
1442
-
1443
-
1444
- /*
1445
- * Show Popup
1446
- *
1447
- * @description:
1448
- * @created: 25/05/12
1449
- */
1450
-
1451
- $('.acf_flexible_content .flexible-footer .add-row-end').live('click', function()
1452
- {
1453
- $(this).trigger('focus');
1454
-
1455
- }).live('focus', function()
1456
- {
1457
- $(this).siblings('.acf-popup').addClass('active');
1458
-
1459
- }).live('blur', function()
1460
- {
1461
- var button = $(this);
1462
- setTimeout(function(){
1463
- button.siblings('.acf-popup').removeClass('active');
1464
- }, 250);
1465
-
1466
- });
1467
-
1468
-
1469
- /*
1470
- * flexible_content_remove_row
1471
- *
1472
- * @description:
1473
- * @created: 25/05/12
1474
- */
1475
-
1476
- function flexible_content_remove_layout( layout )
1477
- {
1478
- // vars
1479
- var div = layout.closest('.acf_flexible_content');
1480
- var temp = $('<div style="height:' + layout.height() + 'px"></div>');
1481
-
1482
-
1483
- // animate out tr
1484
- layout.addClass('acf-remove-item');
1485
- setTimeout(function(){
1486
-
1487
- layout.before(temp).remove();
1488
-
1489
- temp.animate({'height' : 0 }, 250, function(){
1490
- temp.remove();
1491
- });
1492
-
1493
- if(!div.children('.values').children('.layout').exists())
1494
- {
1495
- div.children('.no_value_message').show();
1496
- }
1497
-
1498
- }, 400);
1499
-
1500
- }
1501
-
1502
-
1503
- $('.acf_flexible_content .fc-delete-layout').live('click', function(){
1504
- var layout = $(this).closest('.layout');
1505
- flexible_content_remove_layout( layout );
1506
- return false;
1507
- });
1508
-
1509
-
1510
-
1511
- // update order
1512
- function flexible_content_update_order( div )
1513
- {
1514
- div.find('> .values .layout').each(function(i){
1515
- $(this).find('> .menu-item-handle .fc-layout-order').html(i+1);
1516
- });
1517
-
1518
- };
1519
-
1520
-
1521
- // add layout
1522
- $('.acf_flexible_content .acf-popup ul li a').live('click', function(){
1523
-
1524
- // vars
1525
- var layout = $(this).attr('data-layout');
1526
- var div = $(this).closest('.acf_flexible_content');
1527
-
1528
-
1529
- // create new field
1530
- var new_id = uniqid(),
1531
-
1532
- new_field_html = div.find('> .clones > .layout[data-layout="' + layout + '"]').html().replace(/(=["]*[\w-\[\]]*?)(acfcloneindex)/g, '$1' + new_id),
1533
- new_field = $('<div class="layout" data-layout="' + layout + '"></div>').append( new_field_html );
1534
-
1535
-
1536
- // hide no values message
1537
- div.children('.no_value_message').hide();
1538
-
1539
-
1540
- // add row
1541
- div.children('.values').append(new_field);
1542
-
1543
-
1544
- // acf/setup_fields
1545
- $(document).trigger('acf/setup_fields',new_field);
1546
-
1547
-
1548
- // update order numbers
1549
- flexible_content_update_order( div );
1550
-
1551
-
1552
- // validation
1553
- div.closest('.field').removeClass('error');
1554
-
1555
- return false;
1556
-
1557
- });
1558
-
1559
-
1560
- $(document).live('acf/setup_fields', function(e, postbox){
1561
-
1562
- $(postbox).find('.acf_flexible_content').each(function(){
1563
-
1564
- var div = $(this);
1565
-
1566
- // sortable
1567
- flexible_content_add_sortable( div );
1568
-
1569
-
1570
- // set column widths
1571
- $(div).find('.layout').each(function(){
1572
- repeater_set_column_widths( $(this) );
1573
- });
1574
-
1575
-
1576
- });
1577
-
1578
- });
1579
-
1580
-
1581
- /*
1582
- * Hide Show Flexible Content
1583
- *
1584
- * @description:
1585
- * @since 3.5.2
1586
- * @created: 11/11/12
1587
- */
1588
-
1589
- $('.acf_flexible_content .layout .menu-item-handle').live('click', function(){
1590
-
1591
- // vars
1592
- var layout = $(this).closest('.layout');
1593
-
1594
-
1595
- if( layout.attr('data-toggle') == 'closed' )
1596
- {
1597
- layout.attr('data-toggle', 'open');
1598
- layout.children('.acf-input-table').show();
1599
- }
1600
- else
1601
- {
1602
- layout.attr('data-toggle', 'closed');
1603
- layout.children('.acf-input-table').hide();
1604
- }
1605
-
1606
- });
1607
-
1608
-
1609
- /*
1610
- * is_clone_field
1611
- *
1612
- * @description: returns true|false for an input element
1613
- * @created: 19/08/12
1614
- */
1615
-
1616
- acf.is_clone_field = function( input )
1617
- {
1618
- if( input.attr('name') && input.attr('name').indexOf('[acfcloneindex]') != -1 )
1619
- {
1620
- return true;
1621
- }
1622
-
1623
- return false;
1624
- }
1625
-
1626
-
1627
- /*
1628
- * Field: Datepicker
1629
- *
1630
- * @description:
1631
- * @created: 4/03/2011
1632
- */
1633
-
1634
- $(document).live('acf/setup_fields', function(e, postbox){
1635
-
1636
- $(postbox).find('input.acf_datepicker').each(function(){
1637
-
1638
- // vars
1639
- var input = $(this),
1640
- alt_field = input.siblings('.acf-hidden-datepicker'),
1641
- save_format = input.attr('data-save_format'),
1642
- display_format = input.attr('data-display_format');
1643
-
1644
-
1645
- // is clone field?
1646
- if( acf.is_clone_field(alt_field) )
1647
- {
1648
- return;
1649
- }
1650
-
1651
-
1652
- // get and set value from alt field
1653
- input.val( alt_field.val() );
1654
-
1655
-
1656
- // add date picker and refocus
1657
- input.addClass('active').datepicker({
1658
- dateFormat : save_format,
1659
- altField : alt_field,
1660
- altFormat : save_format,
1661
- changeYear: true,
1662
- yearRange: "-100:+100",
1663
- changeMonth: true,
1664
- showButtonPanel : true
1665
- });
1666
-
1667
-
1668
- // now change the format back to how it should be.
1669
- input.datepicker( "option", "dateFormat", display_format );
1670
-
1671
-
1672
- // wrap the datepicker (only if it hasn't already been wrapped)
1673
- if($('body > #ui-datepicker-div').length > 0)
1674
- {
1675
- $('#ui-datepicker-div').wrap('<div class="ui-acf" />');
1676
- }
1677
-
1678
-
1679
- // allow null
1680
- input.blur(function(){
1681
-
1682
- if( !input.val() )
1683
- {
1684
- alt_field.val('');
1685
- }
1686
-
1687
- });
1688
-
1689
- });
1690
-
1691
- });
1692
-
1693
-
1694
- /*
1695
- * acf.add_message
1696
- *
1697
- * @description:
1698
- * @since: 3.2.7
1699
- * @created: 10/07/2012
1700
- */
1701
-
1702
- acf.add_message = function( message, div ){
1703
-
1704
- var message = $('<div class="acf-message-wrapper"><div class="message updated"><p>' + message + '</p></div></div>');
1705
-
1706
- div.prepend( message );
1707
-
1708
- setTimeout(function(){
1709
-
1710
- message.animate({
1711
- opacity : 0
1712
- }, 250, function(){
1713
- message.remove();
1714
- });
1715
-
1716
- }, 1500);
1717
-
1718
- };
1719
-
1720
-
1721
- /*
1722
- * Field: Gallery
1723
- *
1724
- * @description:
1725
- * @since: 3.2.7
1726
- * @created: 10/07/2012
1727
- */
1728
-
1729
- acf.update_gallery_count = function( div )
1730
- {
1731
- // vars
1732
- var count = div.find('.thumbnails .thumbnail').length,
1733
- max_count = ( count > 2 ) ? 2 : count,
1734
- span = div.find('.toolbar .count');
1735
-
1736
-
1737
- span.html( span.attr('data-' + max_count).replace('{count}', count) );
1738
-
1739
- }
1740
-
1741
-
1742
- // view: Grid
1743
- $('.acf-gallery .toolbar .view-grid').live('click', function(){
1744
-
1745
- // vars
1746
- var gallery = $(this).closest('.acf-gallery');
1747
-
1748
-
1749
- // active class
1750
- $(this).parent().addClass('active').siblings('.view-list-li').removeClass('active');
1751
-
1752
-
1753
- // gallery class
1754
- gallery.removeClass('view-list');
1755
-
1756
-
1757
- return false;
1758
-
1759
- });
1760
-
1761
-
1762
- // view: Grid
1763
- $('.acf-gallery .toolbar .view-list').live('click', function(){
1764
-
1765
- // vars
1766
- var gallery = $(this).closest('.acf-gallery');
1767
-
1768
-
1769
- // active class
1770
- $(this).parent().addClass('active').siblings('.view-grid-li').removeClass('active');
1771
-
1772
-
1773
- // gallery class
1774
- gallery.addClass('view-list');
1775
-
1776
-
1777
- return false;
1778
-
1779
- });
1780
-
1781
-
1782
- // remove image
1783
- $('.acf-gallery .thumbnail .acf-button-delete').live('click', function(){
1784
-
1785
- // vars
1786
- var thumbnail = $(this).closest('.thumbnail'),
1787
- gallery = thumbnail.closest('.acf-gallery');
1788
-
1789
-
1790
- thumbnail.animate({
1791
- opacity : 0
1792
- }, 250, function(){
1793
-
1794
- thumbnail.remove();
1795
-
1796
- acf.update_gallery_count( gallery );
1797
-
1798
- });
1799
-
1800
- return false;
1801
-
1802
- });
1803
-
1804
-
1805
- // remove image
1806
- $('.acf-gallery .thumbnail .acf-button-edit').live('click', function(){
1807
-
1808
- // vars
1809
- var div = $(this).closest('.thumbnail'),
1810
- id = div.attr('data-id');
1811
-
1812
-
1813
- // set global var
1814
- window.acf_edit_attachment = div;
1815
-
1816
-
1817
- // show edit attachment
1818
- tb_show( acf.text.gallery_tb_title_edit , acf.admin_url + 'media.php?attachment_id=' + id + '&action=edit&acf_action=edit_attachment&acf_field=gallery&TB_iframe=1');
1819
-
1820
-
1821
- return false;
1822
-
1823
- });
1824
-
1825
-
1826
- // add image
1827
- $('.acf-gallery .toolbar .add-image').live('click', function(){
1828
-
1829
- // vars
1830
- var gallery = $(this).closest('.acf-gallery'),
1831
- preview_size = gallery.attr('data-preview_size');
1832
-
1833
-
1834
- // set global var
1835
- window.acf_div = gallery;
1836
-
1837
-
1838
- // show the thickbox
1839
- tb_show( acf.text.gallery_tb_title_add , acf.admin_url + 'media-upload.php?post_id=' + acf.post_id + '&post_ID=' + acf.post_id + '&type=image&acf_type=gallery&acf_preview_size=' + preview_size + 'TB_iframe=1');
1840
-
1841
-
1842
- return false;
1843
-
1844
- });
1845
-
1846
-
1847
- $(document).live('acf/setup_fields', function(e, postbox){
1848
-
1849
- $(postbox).find('.acf-gallery').each(function(i){
1850
-
1851
- // is clone field?
1852
- if( acf.is_clone_field($(this).children('input[type="hidden"]')) )
1853
- {
1854
- return;
1855
- }
1856
-
1857
-
1858
- // vars
1859
- var div = $(this),
1860
- thumbnails = div.find('.thumbnails');
1861
-
1862
-
1863
- // update count
1864
- acf.update_gallery_count( div );
1865
-
1866
-
1867
- // sortable
1868
- thumbnails.find('> .inner').sortable({
1869
- items : '> .thumbnail',
1870
- /* handle: '> td.order', */
1871
- forceHelperSize: true,
1872
- forcePlaceholderSize: true,
1873
- scroll: true,
1874
- start: function (event, ui) {
1875
-
1876
- // alter width / height to allow for 2px border
1877
- ui.placeholder.width( ui.placeholder.width() - 4 );
1878
- ui.placeholder.height( ui.placeholder.height() - 4 );
1879
- }
1880
- });
1881
-
1882
-
1883
- });
1884
-
1885
- });
1886
-
1887
-
1888
- // gallery ajax
1889
- acf.gallery_update_tile = function(){
1890
-
1891
- // vars
1892
- var div = window.acf_edit_attachment,
1893
- attachment_id = div.attr('data-id');
1894
-
1895
-
1896
- // ajax find new list data
1897
- $.ajax({
1898
- url: ajaxurl,
1899
- data : {
1900
- 'action' : 'acf_get_gallery_list_data',
1901
- 'attachment_id' : attachment_id
1902
- },
1903
- cache: false,
1904
- dataType: "html",
1905
- success: function( html ) {
1906
-
1907
-
1908
- // validate
1909
- if(!html)
1910
- {
1911
- return false;
1912
- }
1913
-
1914
-
1915
- // update list-item html
1916
- div.find('.list-data').html( html );
1917
-
1918
- }
1919
- });
1920
-
1921
- };
1922
-
1923
-
1924
- /*
1925
- * Conditional Logic Calculate
1926
- *
1927
- * @description:
1928
- * @since 3.5.1
1929
- * @created: 15/10/12
1930
- */
1931
-
1932
- acf.conditional_logic.calculate = function( options )
1933
- {
1934
- // vars
1935
- var field = $('.field-' + options.field),
1936
- toggle = $('.field-' + options.toggle),
1937
- r = false;
1938
-
1939
-
1940
- // compare values
1941
- if( toggle.hasClass('field-true_false') || toggle.hasClass('field-checkbox') || toggle.hasClass('field-radio') )
1942
- {
1943
- if( options.operator == "==" )
1944
- {
1945
- if( toggle.find('input[value="' + options.value + '"]:checked').exists() )
1946
- {
1947
- r = true;
1948
- }
1949
- }
1950
- else
1951
- {
1952
- if( !toggle.find('input[value="' + options.value + '"]:checked').exists() )
1953
- {
1954
- r = true;
1955
- }
1956
- }
1957
-
1958
- }
1959
- else
1960
- {
1961
- if( options.operator == "==" )
1962
- {
1963
- if( toggle.find('*[name]').val() == options.value )
1964
- {
1965
- r = true;
1966
- }
1967
- }
1968
- else
1969
- {
1970
- if( toggle.find('*[name]').val() != options.value )
1971
- {
1972
- r = true;
1973
- }
1974
- }
1975
-
1976
- }
1977
-
1978
- return r;
1979
- }
1980
-
1981
-
1982
- /*
1983
- * Field: Tab
1984
- *
1985
- * @description:
1986
- * @since: 2.0.4
1987
- * @created: 14/12/12
1988
- */
1989
-
1990
- $(document).live('acf/setup_fields', function(e, postbox){
1991
-
1992
- $(postbox).find('.acf-tab').each(function(){
1993
-
1994
- // vars
1995
- var tab = $(this),
1996
- id = tab.attr('data-id'),
1997
- label = tab.html(),
1998
- postbox = tab.closest('.acf_postbox'),
1999
- inside = postbox.children('.inside');
2000
-
2001
-
2002
-
2003
- // only run once for each tab
2004
- if( tab.hasClass('acf-tab-added') )
2005
- {
2006
- return;
2007
- }
2008
- tab.addClass('acf-tab-added');
2009
-
2010
-
2011
- // create tab group if it doesnt exist
2012
- if( ! inside.children('.acf-tab-group').exists() )
2013
- {
2014
- inside.children('.field-tab:first').before('<ul class="hl clearfix acf-tab-group"></ul>');
2015
- }
2016
-
2017
-
2018
- // add tab
2019
- inside.children('.acf-tab-group').append('<li><a class="acf-tab-button" href="#" data-id="' + id + '">' + label + '</a></li>');
2020
-
2021
-
2022
- });
2023
-
2024
-
2025
- // trigger
2026
- $(postbox).find('.acf-tab-group').each(function(){
2027
-
2028
- $(this).find('li:first a').trigger('click');
2029
-
2030
- });
2031
-
2032
-
2033
- });
2034
-
2035
-
2036
- /*
2037
- * Tab group click
2038
- *
2039
- * @description:
2040
- * @since: 2.0.4
2041
- * @created: 14/12/12
2042
- */
2043
-
2044
- $('.acf-tab-button').live('click', function(){
2045
-
2046
- // vars
2047
- var a = $(this),
2048
- id = a.attr('data-id'),
2049
- ul = a.closest('ul'),
2050
- inside = ul.closest('.acf_postbox').children('.inside');
2051
-
2052
-
2053
- // classes
2054
- ul.find('li').removeClass('active');
2055
- a.parent('li').addClass('active');
2056
-
2057
-
2058
- // hide / show
2059
- inside.children('.field-tab').each(function(){
2060
-
2061
- var tab = $(this);
2062
-
2063
- if( tab.hasClass('field-' + id) )
2064
- {
2065
- tab.nextUntil('.field-tab').removeClass('acf-tab_group-hide').addClass('acf-tab_group-show');
2066
- }
2067
- else
2068
- {
2069
- tab.nextUntil('.field-tab').removeClass('acf-tab_group-show').addClass('acf-tab_group-hide');
2070
- }
2071
-
2072
- });
2073
-
2074
- $(this).trigger('blur');
2075
-
2076
- return false;
2077
-
2078
- });
2079
-
2080
-
2081
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/input.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // vars
4
+ $expires_offset = 31536000; // 1 year
5
+ $out = '';
6
+ $prefix = 'input/';
7
+ $files = array(
8
+ 'actions.js',
9
+ 'color-picker.js',
10
+ 'date-picker.js',
11
+ 'file.js',
12
+ 'flexible-content.js',
13
+ 'gallery.js',
14
+ 'image.js',
15
+ 'relationship.js',
16
+ 'repeater.js',
17
+ 'tab.js',
18
+ 'validation.js',
19
+ 'wysiwyg.js'
20
+ );
21
+
22
+
23
+ // helpers
24
+ function get_file($path)
25
+ {
26
+ if ( function_exists('realpath') )
27
+ $path = realpath($path);
28
+
29
+ if ( ! $path || ! @is_file($path) )
30
+ return '';
31
+
32
+ return @file_get_contents($path);
33
+ }
34
+
35
+ if( $files )
36
+ {
37
+ foreach( $files as $file ) {
38
+ $out .= get_file( $prefix . $file ) . "\n";
39
+ }
40
+ }
41
+
42
+
43
+ // set headers to return a JS file
44
+ header('Content-Type: application/x-javascript; charset=UTF-8');
45
+ header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');
46
+ header("Cache-Control: public, max-age=$expires_offset");
47
+
48
+ echo $out;
49
+ exit;
50
+
51
+ ?>
js/input/actions.js ADDED
@@ -0,0 +1,467 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Input Actions
3
+ *
4
+ * @description: javascript for fields functionality
5
+ * @author: Elliot Condon
6
+ * @since: 3.1.4
7
+ */
8
+
9
+ var acf = {
10
+ admin_url : '',
11
+ wp_version : '0',
12
+ post_id : 0,
13
+ nonce : '',
14
+ validation : {
15
+ status : true,
16
+ run : function(){},
17
+ text : {
18
+ error : "Validation Failed. One or more fields below are required."
19
+ }
20
+ },
21
+ helpers : {
22
+ version_compare : function(){},
23
+ uniqid : function(){},
24
+ sortable : function(){},
25
+ add_message : function(){},
26
+ is_clone_field : function(){}
27
+ },
28
+ conditional_logic : {},
29
+ media : {
30
+ div : null,
31
+ frame : null,
32
+ clear_frame : function(){},
33
+ type : function(){}
34
+ },
35
+ fields : {
36
+ color_picker : {
37
+ farbtastic : null
38
+ },
39
+ image : {
40
+ add : function(){},
41
+ edit : function(){},
42
+ remove : function(){},
43
+ text : {
44
+ title_add : "Select Image",
45
+ title_edit : "Edit Image"
46
+ }
47
+ },
48
+ file : {
49
+ add : function(){},
50
+ edit : function(){},
51
+ remove : function(){},
52
+ text : {
53
+ title_add : "Select File",
54
+ title_edit : "Edit File"
55
+ }
56
+ },
57
+ wysiwyg : {
58
+ toolbars : {},
59
+ add_events : function(){},
60
+ has_tinymce : function(){}
61
+ },
62
+ gallery : {
63
+ add : function(){},
64
+ edit : function(){},
65
+ update_count : function(){},
66
+ hide_selected_items : function(){},
67
+ text : {
68
+ title_add : "Select Images"
69
+ }
70
+ },
71
+ relationship : {
72
+ timeout : null,
73
+ update_results : function(){},
74
+ hide_results : function(){},
75
+ text : {
76
+ max : "Maximum values reached ( {max} values )"
77
+ }
78
+ },
79
+ repeater : {
80
+ update_order : function(){},
81
+ set_column_widths : function(){},
82
+ add_sortable : function(){},
83
+ update_classes : function(){},
84
+ add_row : function(){},
85
+ remove_row : function(){},
86
+ text : {
87
+ min : "Minimum rows reached ( {min} rows )",
88
+ max : "Maximum rows reached ( {max} rows )"
89
+ }
90
+ },
91
+ flexible_content : {
92
+ add_sortable : function(){},
93
+ update_order : function(){},
94
+ add_layout : function(){},
95
+ remove_layout : function(){}
96
+ }
97
+ }
98
+ };
99
+
100
+ (function($){
101
+
102
+
103
+ /**
104
+ * Simply compares two string version values.
105
+ *
106
+ * Example:
107
+ * versionCompare('1.1', '1.2') => -1
108
+ * versionCompare('1.1', '1.1') => 0
109
+ * versionCompare('1.2', '1.1') => 1
110
+ * versionCompare('2.23.3', '2.22.3') => 1
111
+ *
112
+ * Returns:
113
+ * -1 = left is LOWER than right
114
+ * 0 = they are equal
115
+ * 1 = left is GREATER = right is LOWER
116
+ * And FALSE if one of input versions are not valid
117
+ *
118
+ * @function
119
+ * @param {String} left Version #1
120
+ * @param {String} right Version #2
121
+ * @return {Integer|Boolean}
122
+ * @author Alexey Bass (albass)
123
+ * @since 2011-07-14
124
+ */
125
+
126
+ acf.helpers.version_compare = function(left, right)
127
+ {
128
+ if (typeof left + typeof right != 'stringstring')
129
+ return false;
130
+
131
+ var a = left.split('.')
132
+ , b = right.split('.')
133
+ , i = 0, len = Math.max(a.length, b.length);
134
+
135
+ for (; i < len; i++) {
136
+ if ((a[i] && !b[i] && parseInt(a[i]) > 0) || (parseInt(a[i]) > parseInt(b[i]))) {
137
+ return 1;
138
+ } else if ((b[i] && !a[i] && parseInt(b[i]) > 0) || (parseInt(a[i]) < parseInt(b[i]))) {
139
+ return -1;
140
+ }
141
+ }
142
+
143
+ return 0;
144
+ };
145
+
146
+
147
+ /*
148
+ * Helper uniqid
149
+ *
150
+ * @description:
151
+ * @since: 3.5.8
152
+ * @created: 17/01/13
153
+ */
154
+
155
+ acf.helpers.uniqid = function()
156
+ {
157
+ var newDate = new Date;
158
+ return newDate.getTime();
159
+ }
160
+
161
+
162
+ /*
163
+ * Exists
164
+ *
165
+ * @description: returns true / false
166
+ * @created: 1/03/2011
167
+ */
168
+
169
+ $.fn.exists = function()
170
+ {
171
+ return $(this).length>0;
172
+ };
173
+
174
+
175
+ /*
176
+ * 3.5 Media
177
+ *
178
+ * @description:
179
+ * @since: 3.5.7
180
+ * @created: 16/01/13
181
+ */
182
+
183
+ acf.media.clear_frame = function()
184
+ {
185
+ // validate
186
+ if( !acf.media.frame )
187
+ {
188
+ return;
189
+ }
190
+
191
+
192
+ acf.media.frame.detach();
193
+ acf.media.frame.dispose();
194
+ acf.media.frame = null;
195
+
196
+ };
197
+
198
+ acf.media.type = function(){
199
+
200
+ var type = 'thickbox';
201
+
202
+ if( typeof(wp) == "object" )
203
+ {
204
+ type = 'backbone';
205
+ }
206
+
207
+ return type;
208
+
209
+ };
210
+
211
+
212
+
213
+ /*
214
+ * Document Ready
215
+ *
216
+ * @description:
217
+ * @since: 3.5.8
218
+ * @created: 17/01/13
219
+ */
220
+
221
+ $(document).ready(function(){
222
+
223
+ // add classes
224
+ $('#poststuff .postbox[id*="acf_"]').addClass('acf_postbox');
225
+ $('#adv-settings label[for*="acf_"]').addClass('acf_hide_label');
226
+
227
+ // hide acf stuff
228
+ $('#poststuff .acf_postbox').addClass('acf-hidden');
229
+ $('#adv-settings .acf_hide_label').hide();
230
+
231
+ // loop through acf metaboxes
232
+ $('#poststuff .postbox.acf_postbox').each(function(){
233
+
234
+ // vars
235
+ var options = $(this).find('> .inside > .options'),
236
+ show = options.attr('data-show'),
237
+ layout = options.attr('data-layout'),
238
+ id = $(this).attr('id').replace('acf_', '');
239
+
240
+ // layout
241
+ $(this).addClass(layout);
242
+
243
+ // show / hide
244
+ if( show == "1" )
245
+ {
246
+ $(this).removeClass('acf-hidden');
247
+ $('#adv-settings .acf_hide_label[for="acf_' + id + '-hide"]').show();
248
+ }
249
+
250
+ });
251
+
252
+ });
253
+
254
+
255
+ /*
256
+ * Save Draft
257
+ *
258
+ * @description:
259
+ * @since: 3.5.8
260
+ * @created: 17/01/13
261
+ */
262
+
263
+ var save_post = false;
264
+ $('#save-post').live('click', function(){
265
+
266
+ save_post = true;
267
+
268
+ });
269
+
270
+
271
+ /*
272
+ * Submit form
273
+ *
274
+ * @description: does validation, deletes all hidden metaboxes (otherwise, post data will be overriden by hidden inputs)
275
+ * @since: 3.5.8
276
+ * @created: 17/01/13
277
+ */
278
+
279
+ $('form#post').live("submit", function(){
280
+
281
+ if( ! save_post )
282
+ {
283
+ // do validation
284
+ acf.validation.run();
285
+
286
+
287
+ if( ! acf.validation.status )
288
+ {
289
+ // show message
290
+ $(this).siblings('#message').remove();
291
+ $(this).before('<div id="message" class="error"><p>' + acf.validation.text.error + '</p></div>');
292
+
293
+
294
+ // hide ajax stuff on submit button
295
+ $('#publish').removeClass('button-primary-disabled');
296
+ $('#ajax-loading').attr('style','');
297
+ $('#publishing-action .spinner').hide();
298
+
299
+ return false;
300
+ }
301
+ }
302
+
303
+
304
+ // remove hidden postboxes
305
+ $('.acf_postbox.acf-hidden').remove();
306
+
307
+
308
+ // submit the form
309
+ return true;
310
+
311
+ });
312
+
313
+
314
+ /*
315
+ * Sortable Helper
316
+ *
317
+ * @description: keeps widths of td's inside a tr
318
+ * @since 3.5.1
319
+ * @created: 10/11/12
320
+ */
321
+
322
+ acf.helpers.sortable = function(e, ui)
323
+ {
324
+ ui.children().each(function(){
325
+ $(this).width($(this).width());
326
+ });
327
+ return ui;
328
+ };
329
+
330
+
331
+ /*
332
+ * is_clone_field
333
+ *
334
+ * @description:
335
+ * @since: 3.5.8
336
+ * @created: 17/01/13
337
+ */
338
+
339
+ acf.helpers.is_clone_field = function( input )
340
+ {
341
+ if( input.attr('name') && input.attr('name').indexOf('[acfcloneindex]') != -1 )
342
+ {
343
+ return true;
344
+ }
345
+
346
+ return false;
347
+ }
348
+
349
+
350
+ /*
351
+ * acf.helpers.add_message
352
+ *
353
+ * @description:
354
+ * @since: 3.2.7
355
+ * @created: 10/07/2012
356
+ */
357
+
358
+ acf.helpers.add_message = function( message, div ){
359
+
360
+ var message = $('<div class="acf-message-wrapper"><div class="message updated"><p>' + message + '</p></div></div>');
361
+
362
+ div.prepend( message );
363
+
364
+ setTimeout(function(){
365
+
366
+ message.animate({
367
+ opacity : 0
368
+ }, 250, function(){
369
+ message.remove();
370
+ });
371
+
372
+ }, 1500);
373
+
374
+ };
375
+
376
+
377
+
378
+ /*
379
+ * Conditional Logic Calculate
380
+ *
381
+ * @description:
382
+ * @since 3.5.1
383
+ * @created: 15/10/12
384
+ */
385
+
386
+ acf.conditional_logic.calculate = function( options )
387
+ {
388
+ // vars
389
+ var field = $('.field-' + options.field),
390
+ toggle = $('.field-' + options.toggle),
391
+ r = false;
392
+
393
+
394
+ // compare values
395
+ if( toggle.hasClass('field-true_false') || toggle.hasClass('field-checkbox') || toggle.hasClass('field-radio') )
396
+ {
397
+ if( options.operator == "==" )
398
+ {
399
+ if( toggle.find('input[value="' + options.value + '"]:checked').exists() )
400
+ {
401
+ r = true;
402
+ }
403
+ }
404
+ else
405
+ {
406
+ if( !toggle.find('input[value="' + options.value + '"]:checked').exists() )
407
+ {
408
+ r = true;
409
+ }
410
+ }
411
+
412
+ }
413
+ else
414
+ {
415
+ if( options.operator == "==" )
416
+ {
417
+ if( toggle.find('*[name]').val() == options.value )
418
+ {
419
+ r = true;
420
+ }
421
+ }
422
+ else
423
+ {
424
+ if( toggle.find('*[name]').val() != options.value )
425
+ {
426
+ r = true;
427
+ }
428
+ }
429
+
430
+ }
431
+
432
+ return r;
433
+ }
434
+
435
+
436
+ /*
437
+ * window load
438
+ *
439
+ * @description:
440
+ * @since: 3.5.5
441
+ * @created: 22/12/12
442
+ */
443
+
444
+ $(window).load(function(){
445
+
446
+ setTimeout(function(){
447
+
448
+ // Hack for CPT without a content editor
449
+ try
450
+ {
451
+ wp.media.view.settings.post.id = acf.post_id;
452
+ }
453
+ catch(e)
454
+ {
455
+ // one of the objects was 'undefined'...
456
+ }
457
+
458
+
459
+ // setup fields
460
+ $(document).trigger('acf/setup_fields', $('#poststuff'));
461
+
462
+ }, 10);
463
+
464
+ });
465
+
466
+
467
+ })(jQuery);
js/{input-ajax.js → input/ajax.js} RENAMED
@@ -75,15 +75,14 @@
75
 
76
 
77
  /*
78
- * update_fields
79
  *
80
  * @description: finds the new id's for metaboxes and show's hides metaboxes
81
  * @created: 1/03/2011
82
  */
83
 
84
- function update_fields()
85
- {
86
-
87
  $.ajax({
88
  url: ajaxurl,
89
  data: acf.data,
@@ -163,23 +162,25 @@
163
 
164
  }
165
  });
166
- }
167
 
168
 
169
  /*
170
- * update_fields (Live change events)
171
  *
172
- * @description: call the update_fields function on live events
173
  * @created: 1/03/2011
174
  */
175
 
176
  $('#page_template').live('change', function(){
177
 
178
  acf.data.page_template = $(this).val();
179
- update_fields();
 
180
 
181
  });
182
 
 
183
  $('#parent_id').live('change', function(){
184
 
185
  var val = $(this).val();
@@ -197,7 +198,8 @@
197
  acf.data.page_parent = 0;
198
  }
199
 
200
- update_fields();
 
201
 
202
  });
203
 
@@ -213,7 +215,7 @@
213
 
214
  acf.data.post_format = val;
215
 
216
- update_fields();
217
 
218
  });
219
 
@@ -235,7 +237,7 @@
235
  acf.data.taxonomy = values;
236
 
237
 
238
- update_fields();
239
 
240
  });
241
 
75
 
76
 
77
  /*
78
+ * update_field_groups
79
  *
80
  * @description: finds the new id's for metaboxes and show's hides metaboxes
81
  * @created: 1/03/2011
82
  */
83
 
84
+ $(document).live('acf/update_field_groups', function(){
85
+
 
86
  $.ajax({
87
  url: ajaxurl,
88
  data: acf.data,
162
 
163
  }
164
  });
165
+ });
166
 
167
 
168
  /*
169
+ * $(document).trigger('acf/update_field_groups'); (Live change events)
170
  *
171
+ * @description: call the $(document).trigger('acf/update_field_groups'); event on live events
172
  * @created: 1/03/2011
173
  */
174
 
175
  $('#page_template').live('change', function(){
176
 
177
  acf.data.page_template = $(this).val();
178
+
179
+ $(document).trigger('acf/update_field_groups');
180
 
181
  });
182
 
183
+
184
  $('#parent_id').live('change', function(){
185
 
186
  var val = $(this).val();
198
  acf.data.page_parent = 0;
199
  }
200
 
201
+
202
+ $(document).trigger('acf/update_field_groups');
203
 
204
  });
205
 
215
 
216
  acf.data.post_format = val;
217
 
218
+ $(document).trigger('acf/update_field_groups');
219
 
220
  });
221
 
237
  acf.data.taxonomy = values;
238
 
239
 
240
+ $(document).trigger('acf/update_field_groups');
241
 
242
  });
243
 
js/input/color-picker.js ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Color Picker
3
+ *
4
+ * @description:
5
+ * @since: 3.5.8
6
+ * @created: 17/01/13
7
+ */
8
+
9
+ (function($){
10
+
11
+ _cp = acf.fields.color_picker;
12
+
13
+ /*
14
+ * acf/setup_fields
15
+ *
16
+ * @description:
17
+ * @since: 3.5.8
18
+ * @created: 17/01/13
19
+ */
20
+
21
+ $(document).live('acf/setup_fields', function(e, postbox){
22
+
23
+ // validate
24
+ if( ! $.farbtastic )
25
+ {
26
+ return;
27
+ }
28
+
29
+
30
+ $(postbox).find('input.acf_color_picker').each(function(){
31
+
32
+ // vars
33
+ var input = $(this);
34
+
35
+
36
+ // is clone field?
37
+ if( acf.helpers.is_clone_field(input) )
38
+ {
39
+ return;
40
+ }
41
+
42
+
43
+ if( input.val() )
44
+ {
45
+ $.farbtastic( input ).setColor( input.val() ).hsl[2] > 0.5 ? color = '#000' : color = '#fff';
46
+
47
+ input.css({
48
+ backgroundColor : input.val(),
49
+ color : color
50
+ });
51
+ }
52
+
53
+ });
54
+
55
+ });
56
+
57
+
58
+ /*
59
+ * Input Focus
60
+ *
61
+ * @description:
62
+ * @since: 3.5.8
63
+ * @created: 17/01/13
64
+ */
65
+
66
+ $('input.acf_color_picker').live('focus', function(){
67
+
68
+ var input = $(this);
69
+
70
+ if( ! input.val() )
71
+ {
72
+ input.val( '#FFFFFF' );
73
+ }
74
+
75
+ $('#acf_color_picker').css({
76
+ left: input.offset().left,
77
+ top: input.offset().top - $('#acf_color_picker').height(),
78
+ display: 'block'
79
+ });
80
+
81
+ _cp.farbtastic.linkTo(this);
82
+
83
+ });
84
+
85
+
86
+ /*
87
+ * Input Blur
88
+ *
89
+ * @description:
90
+ * @since: 3.5.8
91
+ * @created: 17/01/13
92
+ */
93
+
94
+ $('input.acf_color_picker').live('blur', function(){
95
+
96
+ var input = $(this);
97
+
98
+
99
+ // reset the css
100
+ if( ! input.val() )
101
+ {
102
+ input.css({
103
+ backgroundColor : '#fff',
104
+ color : '#000'
105
+ });
106
+
107
+ }
108
+
109
+
110
+ $('#acf_color_picker').css({
111
+ display: 'none'
112
+ });
113
+
114
+ });
115
+
116
+
117
+ /*
118
+ * Document Ready
119
+ *
120
+ * @description:
121
+ * @since: 3.5.8
122
+ * @created: 17/01/13
123
+ */
124
+
125
+ $(document).ready(function(){
126
+
127
+
128
+ /*
129
+ * Color Picker
130
+ */
131
+
132
+ if( $.farbtastic )
133
+ {
134
+ if( !_cp.farbtastic )
135
+ {
136
+ $('body').append('<div id="acf_color_picker" />');
137
+
138
+ _cp.farbtastic = $.farbtastic('#acf_color_picker');
139
+ }
140
+ }
141
+
142
+ });
143
+
144
+
145
+ })(jQuery);
js/input/date-picker.js ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Date Picker
3
+ *
4
+ * @description:
5
+ * @since: 3.5.8
6
+ * @created: 17/01/13
7
+ */
8
+
9
+ (function($){
10
+
11
+
12
+ /*
13
+ * acf/setup_fields
14
+ *
15
+ * @description:
16
+ * @since: 3.5.8
17
+ * @created: 17/01/13
18
+ */
19
+
20
+ $(document).live('acf/setup_fields', function(e, postbox){
21
+
22
+ $(postbox).find('input.acf_datepicker').each(function(){
23
+
24
+ // vars
25
+ var input = $(this),
26
+ alt_field = input.siblings('.acf-hidden-datepicker'),
27
+ save_format = input.attr('data-save_format'),
28
+ display_format = input.attr('data-display_format');
29
+
30
+
31
+ // is clone field?
32
+ if( acf.helpers.is_clone_field(alt_field) )
33
+ {
34
+ return;
35
+ }
36
+
37
+
38
+ // get and set value from alt field
39
+ input.val( alt_field.val() );
40
+
41
+
42
+ // add date picker and refocus
43
+ input.addClass('active').datepicker({
44
+ dateFormat : save_format,
45
+ altField : alt_field,
46
+ altFormat : save_format,
47
+ changeYear: true,
48
+ yearRange: "-100:+100",
49
+ changeMonth: true,
50
+ showButtonPanel : true,
51
+ firstDay: 1
52
+ });
53
+
54
+
55
+ // now change the format back to how it should be.
56
+ input.datepicker( "option", "dateFormat", display_format );
57
+
58
+
59
+ // wrap the datepicker (only if it hasn't already been wrapped)
60
+ if($('body > #ui-datepicker-div').length > 0)
61
+ {
62
+ $('#ui-datepicker-div').wrap('<div class="ui-acf" />');
63
+ }
64
+
65
+
66
+ // allow null
67
+ input.blur(function(){
68
+
69
+ if( !input.val() )
70
+ {
71
+ alt_field.val('');
72
+ }
73
+
74
+ });
75
+
76
+ });
77
+
78
+ });
79
+
80
+
81
+ })(jQuery);
js/input/file.js ADDED
@@ -0,0 +1,249 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * File
3
+ *
4
+ * @description:
5
+ * @since: 3.5.8
6
+ * @created: 17/01/13
7
+ */
8
+
9
+ (function($){
10
+
11
+ var _file = acf.fields.file,
12
+ _media = acf.media;
13
+
14
+
15
+ /*
16
+ * Add
17
+ *
18
+ * @description:
19
+ * @since: 3.5.8
20
+ * @created: 17/01/13
21
+ */
22
+
23
+ _file.add = function( file )
24
+ {
25
+
26
+ // vars
27
+ var div = _media.div;
28
+
29
+ // set atts
30
+ div.find('.acf-file-value').val( file.id ).trigger('change');
31
+ div.find('.acf-file-icon').attr( 'src', file.icon );
32
+ div.find('.acf-file-name').text( file.name );
33
+
34
+
35
+ // set div class
36
+ div.addClass('active');
37
+
38
+
39
+ // validation
40
+ div.closest('.field').removeClass('error');
41
+
42
+ };
43
+
44
+
45
+ /*
46
+ * Edit
47
+ *
48
+ * @description:
49
+ * @since: 3.5.8
50
+ * @created: 17/01/13
51
+ */
52
+
53
+ _file.edit = function(){
54
+
55
+ // vars
56
+ var div = _media.div,
57
+ id = div.find('.acf-file-value').val();
58
+
59
+
60
+ // show edit attachment
61
+ tb_show( _file.text.title_edit , acf.admin_url + 'media.php?attachment_id=' + id + '&action=edit&acf_action=edit_attachment&acf_field=file&TB_iframe=1');
62
+
63
+ };
64
+
65
+
66
+ /*
67
+ * Remove
68
+ *
69
+ * @description:
70
+ * @since: 3.5.8
71
+ * @created: 17/01/13
72
+ */
73
+
74
+ _file.remove = function()
75
+ {
76
+ // vars
77
+ var div = _media.div;
78
+
79
+
80
+ // remove atts
81
+ div.find('.acf-file-value').val( '' ).trigger('change');
82
+ div.find('.acf-file-icon').attr( 'src', '' );
83
+ div.find('.acf-file-name').text( '' );
84
+
85
+
86
+ // remove class
87
+ div.removeClass('active');
88
+
89
+ };
90
+
91
+
92
+ /*
93
+ * Add Button
94
+ *
95
+ * @description:
96
+ * @since: 3.5.8
97
+ * @created: 17/01/13
98
+ */
99
+
100
+ $('.acf-file-uploader .add-file').live('click', function(){
101
+
102
+ // vars
103
+ var div = _media.div = $(this).closest('.acf-file-uploader'),
104
+ multiple = div.closest('.repeater').exists() ? true : false;
105
+
106
+
107
+ // show the thickbox
108
+ if( _media.type() == 'backbone' )
109
+ {
110
+ // clear the frame
111
+ _media.clear_frame();
112
+
113
+
114
+ // Create the media frame. Leave options blank for defaults
115
+ _media.frame = wp.media({
116
+ title : _file.text.title_add,
117
+ multiple : multiple
118
+ });
119
+
120
+
121
+ /*
122
+ _media.frame.on('all', function( e ){
123
+ console.log( e );
124
+ });
125
+ */
126
+
127
+
128
+ // add filter by overriding the option when the title is being created. This is an evet fired before the rendering / creating of the library content so it works but is a bit of a hack. In the future, this should be changed to an init / options event
129
+ _media.frame.on('title:create', function(){
130
+ var state = _media.frame.state();
131
+ state.set('filterable', 'uploaded');
132
+ });
133
+
134
+
135
+ // When an image is selected, run a callback.
136
+ _media.frame.on( 'select', function() {
137
+
138
+ // get selected images
139
+ selection = _media.frame.state().get('selection');
140
+
141
+ if( selection )
142
+ {
143
+ var i = 0;
144
+
145
+ selection.each(function(attachment){
146
+
147
+ // counter
148
+ i++;
149
+
150
+
151
+ // select / add another file field?
152
+ if( i > 1 )
153
+ {
154
+ var tr = _media.div.closest('tr'),
155
+ repeater = tr.closest('.repeater');
156
+
157
+
158
+ if( tr.next('.row').exists() )
159
+ {
160
+ _media.div = tr.next('.row').find('.acf-file-uploader');
161
+ }
162
+ else
163
+ {
164
+ // add row
165
+ repeater.find('.add-row-end').trigger('click');
166
+
167
+ // set acf_div to new row file
168
+ _media.div = repeater.find('> table > tbody > tr.row:last .acf-file-uploader');
169
+ }
170
+ }
171
+
172
+
173
+ // vars
174
+ var file = {
175
+ id : attachment.id,
176
+ name : attachment.attributes.filename,
177
+ icon : attachment.attributes.icon
178
+ };
179
+
180
+
181
+ // add file to field
182
+ _file.add( file );
183
+
184
+
185
+ });
186
+ // selection.each(function(attachment){
187
+ }
188
+ // if( selection )
189
+ });
190
+ // _media.frame.on( 'select', function() {
191
+
192
+
193
+ // Finally, open the modal
194
+ _media.frame.open();
195
+
196
+ var state = _media.frame.state();
197
+
198
+ }
199
+ else
200
+ {
201
+ tb_show( _file.text.title_add , acf.admin_url + 'media-upload.php?post_id=' + acf.post_id + '&post_ID=' + acf.post_id + '&type=file&acf_type=file&TB_iframe=1');
202
+ }
203
+
204
+ return false;
205
+
206
+ });
207
+
208
+
209
+ /*
210
+ * Edit Button
211
+ *
212
+ * @description:
213
+ * @since: 3.5.8
214
+ * @created: 17/01/13
215
+ */
216
+
217
+ $('.acf-file-uploader .edit-file').live('click', function(){
218
+
219
+ // vars
220
+ _media.div = $(this).closest('.acf-file-uploader');
221
+
222
+ _file.edit();
223
+
224
+ return false;
225
+
226
+ });
227
+
228
+
229
+ /*
230
+ * Remove Button
231
+ *
232
+ * @description:
233
+ * @since: 3.5.8
234
+ * @created: 17/01/13
235
+ */
236
+
237
+ $('.acf-file-uploader .remove-file').live('click', function(){
238
+
239
+ // vars
240
+ _media.div = $(this).closest('.acf-file-uploader');
241
+
242
+ _file.remove();
243
+
244
+ return false;
245
+
246
+ });
247
+
248
+
249
+ })(jQuery);
js/input/flexible-content.js ADDED
@@ -0,0 +1,261 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Flexible Content
3
+ *
4
+ * @description:
5
+ * @since: 3.5.8
6
+ * @created: 17/01/13
7
+ */
8
+
9
+ (function($){
10
+
11
+ var _flex = acf.fields.flexible_content;
12
+
13
+
14
+ /*
15
+ * Add Sortable
16
+ *
17
+ * @description:
18
+ * @since: 3.5.8
19
+ * @created: 17/01/13
20
+ */
21
+
22
+ _flex.add_sortable = function( div )
23
+ {
24
+
25
+ // remove (if clone) and add sortable
26
+ div.children('.values').unbind('sortable').sortable({
27
+ items : '> .layout',
28
+ handle : '> .menu-item-handle',
29
+ forceHelperSize : true,
30
+ forcePlaceholderSize : true,
31
+ scroll : true,
32
+ start : function (event, ui) {
33
+
34
+ $(document).trigger('acf/sortable_start', ui.item);
35
+ $(document).trigger('acf/sortable_start_flex', ui.item);
36
+
37
+ },
38
+ stop : function (event, ui) {
39
+
40
+ $(document).trigger('acf/sortable_stop', ui.item);
41
+ $(document).trigger('acf/sortable_stop_flex', ui.item);
42
+
43
+ // update order numbers
44
+ _flex.update_order( div );
45
+ }
46
+ });
47
+
48
+ };
49
+
50
+
51
+ /*
52
+ * Update Order
53
+ *
54
+ * @description:
55
+ * @since: 3.5.8
56
+ * @created: 17/01/13
57
+ */
58
+
59
+ _flex.update_order = function( div )
60
+ {
61
+ div.find('> .values .layout').each(function(i){
62
+ $(this).find('> .menu-item-handle .fc-layout-order').html(i+1);
63
+ });
64
+
65
+ };
66
+
67
+
68
+ /*
69
+ * Add Layout
70
+ *
71
+ * @description:
72
+ * @since: 3.5.8
73
+ * @created: 17/01/13
74
+ */
75
+
76
+ _flex.add_layout = function( layout, div )
77
+ {
78
+ // vars
79
+ var new_id = acf.helpers.uniqid(),
80
+ new_field_html = div.find('> .clones > .layout[data-layout="' + layout + '"]').html().replace(/(=["]*[\w-\[\]]*?)(acfcloneindex)/g, '$1' + new_id),
81
+ new_field = $('<div class="layout" data-layout="' + layout + '"></div>').append( new_field_html );
82
+
83
+
84
+ // hide no values message
85
+ div.children('.no_value_message').hide();
86
+
87
+
88
+ // add row
89
+ div.children('.values').append(new_field);
90
+
91
+
92
+ // acf/setup_fields
93
+ $(document).trigger('acf/setup_fields',new_field);
94
+
95
+
96
+ // update order numbers
97
+ _flex.update_order( div );
98
+
99
+
100
+ // validation
101
+ div.closest('.field').removeClass('error');
102
+ }
103
+
104
+
105
+ /*
106
+ * Remove Layout
107
+ *
108
+ * @description:
109
+ * @since: 3.5.8
110
+ * @created: 17/01/13
111
+ */
112
+
113
+ _flex.remove_layout = function( layout )
114
+ {
115
+ // vars
116
+ var div = layout.closest('.acf_flexible_content');
117
+ var temp = $('<div style="height:' + layout.height() + 'px"></div>');
118
+
119
+
120
+ // animate out tr
121
+ layout.addClass('acf-remove-item');
122
+ setTimeout(function(){
123
+
124
+ layout.before(temp).remove();
125
+
126
+ temp.animate({'height' : 0 }, 250, function(){
127
+ temp.remove();
128
+ });
129
+
130
+ if( !div.children('.values').children('.layout').exists() )
131
+ {
132
+ div.children('.no_value_message').show();
133
+ }
134
+
135
+ }, 400);
136
+
137
+ }
138
+
139
+
140
+ /*
141
+ * acf/setup_fields
142
+ *
143
+ * @description:
144
+ * @since: 3.5.8
145
+ * @created: 17/01/13
146
+ */
147
+
148
+ $(document).live('acf/setup_fields', function(e, postbox){
149
+
150
+ $(postbox).find('.acf_flexible_content').each(function(){
151
+
152
+ var div = $(this);
153
+
154
+ // sortable
155
+ _flex.add_sortable( div );
156
+
157
+
158
+ // set column widths
159
+ $(div).find('.layout').each(function(){
160
+ acf.fields.repeater.set_column_widths( $(this) );
161
+ });
162
+
163
+
164
+ });
165
+
166
+ });
167
+
168
+
169
+ /*
170
+ * Show / Hide popup
171
+ *
172
+ * @description:
173
+ * @since: 3.5.8
174
+ * @created: 17/01/13
175
+ */
176
+
177
+ $('.acf_flexible_content .flexible-footer .add-row-end').live('click', function()
178
+ {
179
+ $(this).trigger('focus');
180
+
181
+ }).live('focus', function()
182
+ {
183
+ $(this).siblings('.acf-popup').addClass('active');
184
+
185
+ }).live('blur', function()
186
+ {
187
+ var button = $(this);
188
+ setTimeout(function(){
189
+ button.siblings('.acf-popup').removeClass('active');
190
+ }, 250);
191
+
192
+ });
193
+
194
+
195
+ /*
196
+ * Delete Layout Button
197
+ *
198
+ * @description:
199
+ * @since: 3.5.8
200
+ * @created: 17/01/13
201
+ */
202
+
203
+ $('.acf_flexible_content .fc-delete-layout').live('click', function(){
204
+
205
+ var layout = $(this).closest('.layout');
206
+
207
+ _flex.remove_layout( layout );
208
+
209
+ return false;
210
+ });
211
+
212
+
213
+ /*
214
+ * Add Layout Button
215
+ *
216
+ * @description:
217
+ * @since: 3.5.8
218
+ * @created: 17/01/13
219
+ */
220
+
221
+ $('.acf_flexible_content .acf-popup ul li a').live('click', function(){
222
+
223
+ var layout = $(this).attr('data-layout'),
224
+ div = $(this).closest('.acf_flexible_content');
225
+
226
+ _flex.add_layout( layout, div );
227
+
228
+ return false;
229
+
230
+ });
231
+
232
+
233
+ /*
234
+ * Hide Show Flexible Content
235
+ *
236
+ * @description:
237
+ * @since 3.5.2
238
+ * @created: 11/11/12
239
+ */
240
+
241
+ $('.acf_flexible_content .layout .menu-item-handle').live('click', function(){
242
+
243
+ // vars
244
+ var layout = $(this).closest('.layout');
245
+
246
+
247
+ if( layout.attr('data-toggle') == 'closed' )
248
+ {
249
+ layout.attr('data-toggle', 'open');
250
+ layout.children('.acf-input-table').show();
251
+ }
252
+ else
253
+ {
254
+ layout.attr('data-toggle', 'closed');
255
+ layout.children('.acf-input-table').hide();
256
+ }
257
+
258
+ });
259
+
260
+
261
+ })(jQuery);
js/input/gallery.js ADDED
@@ -0,0 +1,530 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Gallery
3
+ *
4
+ * @description:
5
+ * @since: 3.5.8
6
+ * @created: 17/01/13
7
+ */
8
+
9
+ (function($){
10
+
11
+ var _gallery = acf.fields.gallery,
12
+ _media = acf.media;
13
+
14
+
15
+ /*
16
+ * Add
17
+ *
18
+ * @description:
19
+ * @since: 3.5.8
20
+ * @created: 17/01/13
21
+ */
22
+
23
+ _gallery.add = function( image ){
24
+
25
+
26
+ // vars
27
+ var gallery = _media.div,
28
+ tpml = gallery.find('.tmpl-thumbnail').html();
29
+
30
+
31
+
32
+ // update vars on tmpl
33
+ $.each(image, function( k, v ){
34
+ var regex = new RegExp('{' + k + '}', 'g');
35
+ tpml = tpml.replace(regex, v);
36
+ });
37
+
38
+
39
+ // add div
40
+ gallery.find('.thumbnails > .inner').append( tpml );
41
+
42
+
43
+ // update gallery count
44
+ _gallery.update_count( gallery );
45
+
46
+
47
+ // validation
48
+ gallery.closest('.field').removeClass('error');
49
+
50
+ };
51
+
52
+
53
+ /*
54
+ * Edit
55
+ *
56
+ * @description:
57
+ * @since: 3.5.8
58
+ * @created: 17/01/13
59
+ */
60
+
61
+ _gallery.edit_image = function(){
62
+
63
+
64
+ // vars
65
+ var div = _media.div,
66
+ id = div.attr('data-id');
67
+
68
+
69
+ // show edit attachment
70
+ tb_show( acf.fields.image.text.title_edit , acf.admin_url + 'media.php?attachment_id=' + id + '&action=edit&acf_action=edit_attachment&acf_field=gallery&TB_iframe=1');
71
+
72
+
73
+ };
74
+
75
+
76
+ /*
77
+ * Update Image
78
+ *
79
+ * @description:
80
+ * @since: 3.5.8
81
+ * @created: 17/01/13
82
+ */
83
+
84
+ _gallery.update_image = function(){
85
+
86
+
87
+ // vars
88
+ var div = acf.media.div,
89
+ id = div.attr('data-id'),
90
+ ajax_data = {
91
+ action : 'acf/fields/gallery/get_metadata',
92
+ id : id,
93
+ nonce : acf.nonce
94
+ };
95
+
96
+
97
+ // ajax find new list data
98
+ $.ajax({
99
+ url: ajaxurl,
100
+ type: 'post',
101
+ data : ajax_data,
102
+ cache: false,
103
+ dataType: "json",
104
+ success: function( json ) {
105
+
106
+
107
+ // validate
108
+ if( !json )
109
+ {
110
+ return false;
111
+ }
112
+
113
+
114
+ // update list-item html
115
+ $.each(json, function( k, v ){
116
+ if( div.find('.td-' + k).exists() )
117
+ {
118
+ div.find('.td-' + k).text( v );
119
+ }
120
+ });
121
+
122
+ }
123
+ });
124
+
125
+
126
+ };
127
+
128
+
129
+ /*
130
+ * Update Count
131
+ *
132
+ * @description:
133
+ * @since: 3.5.8
134
+ * @created: 17/01/13
135
+ */
136
+
137
+ _gallery.update_count = function( div )
138
+ {
139
+ // vars
140
+ var count = div.find('.thumbnails .thumbnail').length,
141
+ max_count = ( count > 2 ) ? 2 : count,
142
+ span = div.find('.toolbar .count');
143
+
144
+
145
+ span.html( span.attr('data-' + max_count).replace('{count}', count) );
146
+
147
+ }
148
+
149
+
150
+ /*
151
+ * View: Grid
152
+ *
153
+ * @description:
154
+ * @since: 3.5.8
155
+ * @created: 17/01/13
156
+ */
157
+
158
+ $('.acf-gallery .toolbar .view-grid').live('click', function(){
159
+
160
+ // vars
161
+ var gallery = $(this).closest('.acf-gallery');
162
+
163
+
164
+ // active class
165
+ $(this).parent().addClass('active').siblings('.view-list-li').removeClass('active');
166
+
167
+
168
+ // gallery class
169
+ gallery.removeClass('view-list');
170
+
171
+
172
+ return false;
173
+
174
+ });
175
+
176
+
177
+ /*
178
+ * View: List
179
+ *
180
+ * @description:
181
+ * @since: 3.5.8
182
+ * @created: 17/01/13
183
+ */
184
+
185
+ $('.acf-gallery .toolbar .view-list').live('click', function(){
186
+
187
+ // vars
188
+ var gallery = $(this).closest('.acf-gallery');
189
+
190
+
191
+ // active class
192
+ $(this).parent().addClass('active').siblings('.view-grid-li').removeClass('active');
193
+
194
+
195
+ // gallery class
196
+ gallery.addClass('view-list');
197
+
198
+
199
+ return false;
200
+
201
+ });
202
+
203
+
204
+ /*
205
+ * Add Button
206
+ *
207
+ * @description:
208
+ * @since: 3.5.8
209
+ * @created: 17/01/13
210
+ */
211
+
212
+ // add image
213
+ $('.acf-gallery .toolbar .add-image').live('click', function(){
214
+
215
+ // vars
216
+ var div = _media.div = $(this).closest('.acf-gallery'),
217
+ preview_size = div.attr('data-preview_size');
218
+
219
+
220
+ // show the thickbox
221
+ // show the thickbox
222
+ if( _media.type() == 'backbone' )
223
+ {
224
+ // clear the frame
225
+ _media.clear_frame();
226
+
227
+
228
+ // acf.media.frame.content.get().options.filters=true;
229
+
230
+ // Create the media frame. Leave options blank for defaults
231
+ _media.frame = wp.media({
232
+ title : _gallery.text.title_add,
233
+ multiple : true,
234
+ library : {
235
+ //type : 'image'
236
+ }
237
+ });
238
+
239
+
240
+ // add filter by overriding the option when the title is being created. This is an evet fired before the rendering / creating of the library content so it works but is a bit of a hack. In the future, this should be changed to an init / options event
241
+ _media.frame.on('title:create', function(){
242
+ var state = _media.frame.state();
243
+ state.set('filterable', 'uploaded');
244
+ });
245
+
246
+
247
+ // When an image is selected, run a callback.
248
+ _media.frame.on( 'select', function() {
249
+
250
+ // get selected images
251
+ selection = _media.frame.state().get('selection');
252
+
253
+ if( selection )
254
+ {
255
+ selection.each(function(attachment){
256
+
257
+ // is image already in gallery?
258
+ if( div.find('.thumbnails .thumbnail[data-id="' + attachment.id + '"]').exists() )
259
+ {
260
+ return;
261
+ }
262
+
263
+
264
+ var image = {
265
+ id : attachment.id,
266
+ src : attachment.attributes.url,
267
+ title : attachment.attributes.title,
268
+ caption : attachment.attributes.caption,
269
+ alt : attachment.attributes.alt,
270
+ description : attachment.attributes.description
271
+ };
272
+
273
+
274
+ // file?
275
+ if( attachment.attributes.type != 'image' )
276
+ {
277
+ image.src = attachment.attributes.icon;
278
+ }
279
+
280
+
281
+ // is preview size available?
282
+ if( attachment.attributes.sizes && attachment.attributes.sizes[ preview_size ] )
283
+ {
284
+ image.src = attachment.attributes.sizes[ preview_size ].url;
285
+ }
286
+
287
+
288
+ // add image to field
289
+ _gallery.add( image );
290
+
291
+ });
292
+ // selection.each(function(attachment){
293
+ }
294
+ // if( selection )
295
+ });
296
+ // _media.frame.on( 'select', function() {
297
+
298
+ _media.frame.on('content:create:browse', function( e ){
299
+
300
+ /*
301
+ acf.media.frame.content.get().collection.on( 'all', function( e ){
302
+ console.log( 'collection: ' + e );
303
+ });
304
+ */
305
+
306
+ });
307
+
308
+ // log all events
309
+ _media.frame.on('all', function( e ){
310
+
311
+ //console.log( 'frame: ' + e );
312
+ });
313
+
314
+ _media.frame.on('content:activate:browse', function(){
315
+
316
+ _gallery.hide_selected_items();
317
+
318
+ acf.media.frame.content.get().collection.on( 'reset add', function(){
319
+
320
+ _gallery.hide_selected_items();
321
+
322
+ });
323
+
324
+ // event fired after a search
325
+
326
+ /*
327
+ acf.media.frame.content.get().collection.on( 'all', function( e ){
328
+ console.log( 'collection: ' + e );
329
+ });
330
+ */
331
+
332
+
333
+
334
+ });
335
+
336
+ // Finally, open the modal
337
+ _media.frame.open();
338
+
339
+
340
+ /* // event fired when viewing "Media Library"
341
+
342
+
343
+
344
+
345
+
346
+ // event fired when viewing "Upload Files"
347
+ acf.media.frame.on('content:activate:upload', function(){
348
+ $(document).trigger('acf/media/upload');
349
+ });
350
+
351
+ // event fired when opening the media popup
352
+ acf.media.frame.on('open', function( e ){
353
+
354
+ acf.media.frame.content.get().attachments.render();
355
+ acf.media.frame.reset();
356
+ $(document).trigger('acf/media/open');
357
+
358
+
359
+ });
360
+
361
+ acf.media.frame.on('reset', function( e ){
362
+ $(document).trigger('acf/media/reset');
363
+
364
+ console.log('main reset');
365
+ });
366
+
367
+
368
+ // event fired when closing the media popup
369
+ acf.media.frame.on('close', function( e ){
370
+
371
+ // clear the div
372
+ $(document).trigger('acf/media/close');
373
+ });
374
+
375
+
376
+ // When an image is selected, run a callback.
377
+ acf.media.frame.on('select', function()
378
+ {
379
+ $(document).trigger('acf/media/select', [acf.media.frame.state().get('selection')]);
380
+ }); */
381
+ }
382
+ else
383
+ {
384
+ tb_show( _gallery.text.title_add , acf.admin_url + 'media-upload.php?post_id=' + acf.post_id + '&post_ID=' + acf.post_id + '&type=image&acf_type=gallery&acf_preview_size=' + preview_size + 'TB_iframe=1');
385
+ }
386
+
387
+
388
+ return false;
389
+
390
+ });
391
+
392
+
393
+ /*
394
+ * Edit Button
395
+ *
396
+ * @description:
397
+ * @since: 3.5.8
398
+ * @created: 17/01/13
399
+ */
400
+
401
+ $('.acf-gallery .thumbnail .acf-button-edit').live('click', function(){
402
+
403
+ // vars
404
+ _media.div = $(this).closest('.thumbnail');
405
+
406
+ _gallery.edit_image();
407
+
408
+ return false;
409
+
410
+ });
411
+
412
+
413
+ /*
414
+ * Remove Button
415
+ *
416
+ * @description:
417
+ * @since: 3.5.8
418
+ * @created: 17/01/13
419
+ */
420
+
421
+ $('.acf-gallery .thumbnail .acf-button-delete').live('click', function(){
422
+
423
+ // vars
424
+ var thumbnail = $(this).closest('.thumbnail'),
425
+ gallery = thumbnail.closest('.acf-gallery');
426
+
427
+
428
+ thumbnail.animate({
429
+ opacity : 0
430
+ }, 250, function(){
431
+
432
+ thumbnail.remove();
433
+
434
+ _gallery.update_count( gallery );
435
+
436
+ });
437
+
438
+ return false;
439
+
440
+ });
441
+
442
+
443
+
444
+ _gallery.hide_selected_items = function(){
445
+
446
+ // set timeout for 0, then it will always run last after the add event
447
+ setTimeout(function(){
448
+
449
+
450
+ // vars
451
+ var gallery = _media.div,
452
+ div = _media.frame.content.get().$el;
453
+ collection = _media.frame.content.get().collection || null,
454
+ i = -1;
455
+
456
+
457
+ if( collection )
458
+ {
459
+ collection.each(function( item ){
460
+
461
+ i++;
462
+
463
+ var attachment = div.find('.attachments > .attachment:eq(' + i + ')');
464
+
465
+
466
+ // if image is already inside the gallery, disable it!
467
+ if( gallery.find('.thumbnails .thumbnail[data-id="' + item.id + '"]').exists() )
468
+ {
469
+ item.off('selection:single');
470
+ attachment.addClass('acf-selected');
471
+ }
472
+
473
+ });
474
+ }
475
+
476
+
477
+ }, 0);
478
+
479
+ }
480
+
481
+
482
+ /*
483
+ * acf/setup_fields
484
+ *
485
+ * @description:
486
+ * @since: 3.5.8
487
+ * @created: 17/01/13
488
+ */
489
+
490
+ $(document).live('acf/setup_fields', function(e, postbox){
491
+
492
+ $(postbox).find('.acf-gallery').each(function(i){
493
+
494
+ // is clone field?
495
+ if( acf.helpers.is_clone_field($(this).children('input[type="hidden"]')) )
496
+ {
497
+ return;
498
+ }
499
+
500
+
501
+ // vars
502
+ var div = $(this),
503
+ thumbnails = div.find('.thumbnails');
504
+
505
+
506
+ // update count
507
+ _gallery.update_count( div );
508
+
509
+
510
+ // sortable
511
+ thumbnails.find('> .inner').sortable({
512
+ items : '> .thumbnail',
513
+ /* handle: '> td.order', */
514
+ forceHelperSize: true,
515
+ forcePlaceholderSize: true,
516
+ scroll: true,
517
+ start: function (event, ui) {
518
+
519
+ // alter width / height to allow for 2px border
520
+ ui.placeholder.width( ui.placeholder.width() - 4 );
521
+ ui.placeholder.height( ui.placeholder.height() - 4 );
522
+ }
523
+ });
524
+
525
+
526
+ });
527
+
528
+ });
529
+
530
+ })(jQuery);
js/input/image.js ADDED
@@ -0,0 +1,247 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Image
3
+ *
4
+ * @description:
5
+ * @since: 3.5.8
6
+ * @created: 17/01/13
7
+ */
8
+
9
+ (function($){
10
+
11
+ var _image = acf.fields.image,
12
+ _media = acf.media;
13
+
14
+
15
+ /*
16
+ * Add
17
+ *
18
+ * @description:
19
+ * @since: 3.5.8
20
+ * @created: 17/01/13
21
+ */
22
+
23
+ _image.add = function( image )
24
+ {
25
+ // vars
26
+ var div = _media.div;
27
+
28
+ // set atts
29
+ div.find('.acf-image-value').val( image.id ).trigger('change');
30
+ div.find('img').attr( 'src', image.src );
31
+
32
+
33
+ // set div class
34
+ div.addClass('active');
35
+
36
+
37
+ // validation
38
+ div.closest('.field').removeClass('error');
39
+
40
+ };
41
+
42
+
43
+ /*
44
+ * Edit
45
+ *
46
+ * @description:
47
+ * @since: 3.5.8
48
+ * @created: 17/01/13
49
+ */
50
+
51
+ _image.edit = function(){
52
+
53
+ // vars
54
+ var div = _media.div,
55
+ id = div.find('.acf-image-value').val();
56
+
57
+
58
+ // show edit attachment
59
+ tb_show( _image.text.title_edit , acf.admin_url + 'media.php?attachment_id=' + id + '&action=edit&acf_action=edit_attachment&acf_field=image&TB_iframe=1');
60
+
61
+ };
62
+
63
+
64
+ /*
65
+ * Remove
66
+ *
67
+ * @description:
68
+ * @since: 3.5.8
69
+ * @created: 17/01/13
70
+ */
71
+
72
+ _image.remove = function()
73
+ {
74
+ // vars
75
+ var div = _media.div;
76
+
77
+
78
+ // remove atts
79
+ div.find('.acf-image-value').val('').trigger('change');
80
+ div.find('img').attr('src', '');
81
+
82
+
83
+ // remove class
84
+ div.removeClass('active');
85
+
86
+ };
87
+
88
+
89
+ /*
90
+ * Add Button
91
+ *
92
+ * @description:
93
+ * @since: 3.5.8
94
+ * @created: 17/01/13
95
+ */
96
+
97
+ $('.acf-image-uploader .add-image').live('click', function(){
98
+
99
+ // vars
100
+ var div = _media.div = $(this).closest('.acf-image-uploader'),
101
+ preview_size = div.attr('data-preview_size'),
102
+ multiple = div.closest('.repeater').exists() ? true : false;
103
+
104
+
105
+ // show the thickbox
106
+ if( _media.type() == 'backbone' )
107
+ {
108
+ // clear the frame
109
+ _media.clear_frame();
110
+
111
+
112
+ // Create the media frame. Leave options blank for defaults
113
+ _media.frame = wp.media({
114
+ title : _image.text.title_add,
115
+ multiple : multiple,
116
+ library : {
117
+ type : 'image'
118
+ }
119
+ });
120
+
121
+
122
+ // add filter by overriding the option when the title is being created. This is an evet fired before the rendering / creating of the library content so it works but is a bit of a hack. In the future, this should be changed to an init / options event
123
+ _media.frame.on('title:create', function(){
124
+ var state = _media.frame.state();
125
+ state.set('filterable', 'uploaded');
126
+ });
127
+
128
+
129
+ // When an image is selected, run a callback.
130
+ _media.frame.on( 'select', function() {
131
+
132
+ // get selected images
133
+ selection = _media.frame.state().get('selection');
134
+
135
+ if( selection )
136
+ {
137
+ var i = 0;
138
+
139
+ selection.each(function(attachment){
140
+
141
+ // counter
142
+ i++;
143
+
144
+
145
+ // select / add another file field?
146
+ if( i > 1 )
147
+ {
148
+ var tr = _media.div.closest('tr'),
149
+ repeater = tr.closest('.repeater');
150
+
151
+
152
+ if( tr.next('.row').exists() )
153
+ {
154
+ _media.div = tr.next('.row').find('.acf-image-uploader');
155
+ }
156
+ else
157
+ {
158
+ // add row
159
+ repeater.find('.add-row-end').trigger('click');
160
+
161
+ // set acf_div to new row file
162
+ _media.div = repeater.find('> table > tbody > tr.row:last .acf-image-uploader');
163
+ }
164
+ }
165
+
166
+
167
+ // vars
168
+ var image = {
169
+ id : attachment.id,
170
+ src : attachment.attributes.url
171
+ };
172
+
173
+
174
+ // is preview size available?
175
+ if( attachment.attributes.sizes && attachment.attributes.sizes[ preview_size ] )
176
+ {
177
+ image.src = attachment.attributes.sizes[ preview_size ].url;
178
+ }
179
+
180
+
181
+ // add image to field
182
+ _image.add( image );
183
+
184
+
185
+ });
186
+ // selection.each(function(attachment){
187
+ }
188
+ // if( selection )
189
+ });
190
+ // _media.frame.on( 'select', function() {
191
+
192
+
193
+ // Finally, open the modal
194
+ _media.frame.open();
195
+
196
+ }
197
+ else
198
+ {
199
+ tb_show( _image.text.title_add , acf.admin_url + 'media-upload.php?post_id=' + acf.post_id + '&post_ID=' + acf.post_id + '&type=image&acf_type=image&acf_preview_size=' + preview_size + 'TB_iframe=1');
200
+ }
201
+
202
+
203
+ return false;
204
+ });
205
+
206
+
207
+ /*
208
+ * Edit Button
209
+ *
210
+ * @description:
211
+ * @since: 3.5.8
212
+ * @created: 17/01/13
213
+ */
214
+
215
+ $('.acf-image-uploader .acf-button-edit').live('click', function(){
216
+
217
+ // vars
218
+ _media.div = $(this).closest('.acf-image-uploader');
219
+
220
+ _image.edit();
221
+
222
+ return false;
223
+
224
+ });
225
+
226
+
227
+ /*
228
+ * Remove Button
229
+ *
230
+ * @description:
231
+ * @since: 3.5.8
232
+ * @created: 17/01/13
233
+ */
234
+
235
+ $('.acf-image-uploader .acf-button-delete').live('click', function(){
236
+
237
+ // vars
238
+ _media.div = $(this).closest('.acf-image-uploader');
239
+
240
+ _image.remove();
241
+
242
+ return false;
243
+
244
+ });
245
+
246
+
247
+ })(jQuery);
js/input/relationship.js ADDED
@@ -0,0 +1,299 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Relationship
3
+ *
4
+ * @description:
5
+ * @since: 3.5.8
6
+ * @created: 17/01/13
7
+ */
8
+
9
+ (function($){
10
+
11
+ var _relationship = acf.fields.relationship;
12
+
13
+
14
+ /*
15
+ * acf/setup_fields
16
+ *
17
+ * @description:
18
+ * @since: 3.5.8
19
+ * @created: 17/01/13
20
+ */
21
+
22
+ $(document).live('acf/setup_fields', function(e, postbox){
23
+
24
+ $(postbox).find('.acf_relationship').each(function(){
25
+
26
+ // is clone field?
27
+ if( acf.helpers.is_clone_field($(this).children('input[type="hidden"]')) )
28
+ {
29
+ return;
30
+ }
31
+
32
+
33
+ $(this).find('.relationship_right .relationship_list').sortable({
34
+ axis: "y", // limit the dragging to up/down only
35
+ items: '> li',
36
+ forceHelperSize: true,
37
+ forcePlaceholderSize: true,
38
+ scroll: true
39
+ });
40
+
41
+
42
+ // load more
43
+ $(this).find('.relationship_left .relationship_list').scrollTop(0).scroll( function(){
44
+
45
+ // vars
46
+ var div = $(this).closest('.acf_relationship');
47
+
48
+
49
+ // validate
50
+ if( div.hasClass('loading') )
51
+ {
52
+ return;
53
+ }
54
+
55
+
56
+ // Scrolled to bottom
57
+ if( $(this).scrollTop() + $(this).innerHeight() >= $(this).get(0).scrollHeight )
58
+ {
59
+ var paged = parseInt( div.attr('data-paged') );
60
+
61
+ div.attr('data-paged', (paged + 1) );
62
+
63
+ _relationship.update_results( div );
64
+ }
65
+
66
+ });
67
+
68
+
69
+ // ajax fetch values for left side
70
+ _relationship.update_results( $(this) );
71
+
72
+ });
73
+
74
+ });
75
+
76
+
77
+ /*
78
+ * Button Add
79
+ *
80
+ * @description:
81
+ * @since: 3.5.8
82
+ * @created: 17/01/13
83
+ */
84
+
85
+ $('.acf_relationship .relationship_left .relationship_list a').live('click', function(){
86
+
87
+ // vars
88
+ var id = $(this).attr('data-post_id'),
89
+ title = $(this).html(),
90
+ div = $(this).closest('.acf_relationship'),
91
+ max = parseInt(div.attr('data-max')),
92
+ right = div.find('.relationship_right .relationship_list');
93
+
94
+
95
+ // max posts
96
+ if( right.find('a').length >= max )
97
+ {
98
+ alert( _relationship.text.max.replace('{max}', max) );
99
+ return false;
100
+ }
101
+
102
+
103
+ // can be added?
104
+ if( $(this).parent().hasClass('hide') )
105
+ {
106
+ return false;
107
+ }
108
+
109
+
110
+ // hide / show
111
+ $(this).parent().addClass('hide');
112
+
113
+
114
+ // create new li for right side
115
+ var new_li = div.children('.tmpl-li').html()
116
+ .replace( /\{post_id}/gi, id )
117
+ .replace( /\{title}/gi, title );
118
+
119
+
120
+
121
+ // add new li
122
+ right.append( new_li );
123
+
124
+
125
+ // validation
126
+ div.closest('.field').removeClass('error');
127
+
128
+ return false;
129
+
130
+ });
131
+
132
+
133
+ /*
134
+ * Button Remove
135
+ *
136
+ * @description:
137
+ * @since: 3.5.8
138
+ * @created: 17/01/13
139
+ */
140
+
141
+ $('.acf_relationship .relationship_right .relationship_list a').live('click', function(){
142
+
143
+ // vars
144
+ var id = $(this).attr('data-post_id'),
145
+ div = $(this).closest('.acf_relationship'),
146
+ left = div.find('.relationship_left .relationship_list');
147
+
148
+
149
+ // hide
150
+ $(this).parent().remove();
151
+
152
+
153
+ // show
154
+ left.find('a[data-post_id="' + id + '"]').parent('li').removeClass('hide');
155
+
156
+
157
+ return false;
158
+
159
+ });
160
+
161
+
162
+ /*
163
+ * Search on keyup
164
+ *
165
+ * @description:
166
+ * @since: 3.5.8
167
+ * @created: 17/01/13
168
+ */
169
+
170
+ $('.acf_relationship input.relationship_search').live('keyup', function()
171
+ {
172
+ // vars
173
+ var val = $(this).val(),
174
+ div = $(this).closest('.acf_relationship');
175
+
176
+
177
+ // update data-s
178
+ div.attr('data-s', val);
179
+
180
+
181
+ // new search, reset paged
182
+ div.attr('data-paged', 1);
183
+
184
+
185
+ // ajax
186
+ clearTimeout( _relationship.timeout );
187
+ _relationship.timeout = setTimeout(function(){
188
+ _relationship.update_results( div );
189
+ }, 250);
190
+
191
+ return false;
192
+
193
+ })
194
+ .live('focus', function(){
195
+ $(this).siblings('label').hide();
196
+ })
197
+ .live('blur', function(){
198
+ if($(this).val() == "")
199
+ {
200
+ $(this).siblings('label').show();
201
+ }
202
+ });
203
+
204
+
205
+ // hide results
206
+ _relationship.hide_results = function( div ){
207
+
208
+ // vars
209
+ var left = div.find('.relationship_left .relationship_list'),
210
+ right = div.find('.relationship_right .relationship_list');
211
+
212
+
213
+ // apply .hide to left li's
214
+ left.find('a').each(function(){
215
+
216
+ var id = $(this).attr('data-post_id');
217
+
218
+ if( right.find('a[data-post_id="' + id + '"]').exists() )
219
+ {
220
+ $(this).parent().addClass('hide');
221
+ }
222
+
223
+ });
224
+
225
+ }
226
+
227
+
228
+ // update results
229
+ _relationship.update_results = function( div ){
230
+
231
+
232
+ // add loading class, stops scroll loading
233
+ div.addClass('loading');
234
+
235
+
236
+ // vars
237
+ var s = div.attr('data-s'),
238
+ paged = parseInt( div.attr('data-paged') ),
239
+ taxonomy = div.attr('data-taxonomy'),
240
+ post_type = div.attr('data-post_type'),
241
+ lang = div.attr('data-lang'),
242
+ left = div.find('.relationship_left .relationship_list'),
243
+ right = div.find('.relationship_right .relationship_list');
244
+
245
+
246
+ // get results
247
+ $.ajax({
248
+ url: ajaxurl,
249
+ type: 'post',
250
+ dataType: 'html',
251
+ data: {
252
+ 'action' : 'acf_get_relationship_results',
253
+ 's' : s,
254
+ 'paged' : paged,
255
+ 'taxonomy' : taxonomy,
256
+ 'post_type' : post_type,
257
+ 'lang' : lang,
258
+ 'field_name' : div.parent().attr('data-field_name'),
259
+ 'field_key' : div.parent().attr('data-field_key')
260
+ },
261
+ success: function( html ){
262
+
263
+ div.removeClass('no-results').removeClass('loading');
264
+
265
+ // new search?
266
+ if( paged == 1 )
267
+ {
268
+ left.find('li:not(.load-more)').remove();
269
+ }
270
+
271
+
272
+ // no results?
273
+ if( !html )
274
+ {
275
+ div.addClass('no-results');
276
+ return;
277
+ }
278
+
279
+
280
+ // append new results
281
+ left.find('.load-more').before( html );
282
+
283
+
284
+ // less than 10 results?
285
+ var ul = $('<ul>' + html + '</ul>');
286
+ if( ul.find('li').length < 10 )
287
+ {
288
+ div.addClass('no-results');
289
+ }
290
+
291
+
292
+ // hide values
293
+ _relationship.hide_results( div );
294
+
295
+ }
296
+ });
297
+ };
298
+
299
+ })(jQuery);
js/input/repeater.js ADDED
@@ -0,0 +1,388 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Repeater
3
+ *
4
+ * @description:
5
+ * @since: 3.5.8
6
+ * @created: 17/01/13
7
+ */
8
+
9
+ (function($){
10
+
11
+ var _repeater = acf.fields.repeater;
12
+
13
+
14
+ /*
15
+ * update_order
16
+ *
17
+ * @description:
18
+ * @since: 3.5.8
19
+ * @created: 17/01/13
20
+ */
21
+
22
+ _repeater.update_order = function( repeater )
23
+ {
24
+ repeater.find('> table > tbody > tr.row').each(function(i){
25
+ $(this).children('td.order').html( i+1 );
26
+ });
27
+
28
+ };
29
+
30
+
31
+ /*
32
+ * set_column_widths
33
+ *
34
+ * @description:
35
+ * @since: 3.5.8
36
+ * @created: 17/01/13
37
+ */
38
+
39
+ _repeater.set_column_widths = function( repeater )
40
+ {
41
+ // validate
42
+ if( repeater.children('.acf-input-table').hasClass('row_layout') )
43
+ {
44
+ return;
45
+ }
46
+
47
+
48
+ // accomodate for order / remove
49
+ var column_width = 100;
50
+ if( repeater.find('> .acf-input-table > thead > tr > th.order').exists() )
51
+ {
52
+ column_width = 93;
53
+ }
54
+
55
+
56
+ // find columns that already have a width and remove these amounts from the column_width var
57
+ repeater.find('> .acf-input-table > thead > tr > th[width]').each(function( i ){
58
+
59
+ column_width -= parseInt( $(this).attr('width') );
60
+ });
61
+
62
+
63
+ var ths = repeater.find('> .acf-input-table > thead > tr > th').not('[width]').has('span');
64
+ if( ths.length > 1 )
65
+ {
66
+ column_width = column_width / ths.length;
67
+
68
+ ths.each(function( i ){
69
+
70
+ // dont add width to last th
71
+ if( (i+1) == ths.length )
72
+ {
73
+ return;
74
+ }
75
+
76
+ $(this).attr('width', column_width + '%');
77
+
78
+ });
79
+ }
80
+
81
+ }
82
+
83
+
84
+ /*
85
+ * add_sortable
86
+ *
87
+ * @description:
88
+ * @since 3.5.2
89
+ * @created: 11/11/12
90
+ */
91
+
92
+ _repeater.add_sortable = function( repeater ){
93
+
94
+ // vars
95
+ var max_rows = parseFloat( repeater.attr('data-max_rows') );
96
+
97
+
98
+ // validate
99
+ if( max_rows <= 1 )
100
+ {
101
+ return;
102
+ }
103
+
104
+ repeater.find('> table > tbody').unbind('sortable').sortable({
105
+ items : '> tr.row',
106
+ handle : '> td.order',
107
+ helper : acf.helpers.sortable,
108
+ forceHelperSize : true,
109
+ forcePlaceholderSize : true,
110
+ scroll : true,
111
+ start : function (event, ui) {
112
+
113
+ $(document).trigger('acf/sortable_start', ui.item);
114
+ $(document).trigger('acf/sortable_start_repeater', ui.item);
115
+
116
+ // add markup to the placeholder
117
+ var td_count = ui.item.children('td').length;
118
+ ui.placeholder.html('<td colspan="' + td_count + '"></td>');
119
+
120
+ },
121
+ stop : function (event, ui) {
122
+
123
+ $(document).trigger('acf/sortable_stop', ui.item);
124
+ $(document).trigger('acf/sortable_stop_repeater', ui.item);
125
+
126
+ // update order numbers
127
+ _repeater.update_order( repeater );
128
+
129
+ }
130
+ });
131
+ };
132
+
133
+
134
+ /*
135
+ * update_classes
136
+ *
137
+ * @description:
138
+ * @since 3.5.2
139
+ * @created: 11/11/12
140
+ */
141
+
142
+ _repeater.update_classes = function( repeater )
143
+ {
144
+ // vars
145
+ var max_rows = parseFloat( repeater.attr('data-max_rows') ),
146
+ row_count = repeater.find('> table > tbody > tr.row').length;
147
+
148
+
149
+ // empty?
150
+ if( row_count == 0 )
151
+ {
152
+ repeater.addClass('empty');
153
+ }
154
+ else
155
+ {
156
+ repeater.removeClass('empty');
157
+ }
158
+
159
+
160
+ // row limit reached
161
+ if( row_count >= max_rows )
162
+ {
163
+ repeater.addClass('disabled');
164
+ repeater.find('> .repeater-footer .acf-button').addClass('disabled');
165
+ }
166
+ else
167
+ {
168
+ repeater.removeClass('disabled');
169
+ repeater.find('> .repeater-footer .acf-button').removeClass('disabled');
170
+ }
171
+
172
+ }
173
+
174
+
175
+ /*
176
+ * acf/setup_fields
177
+ *
178
+ * @description:
179
+ * @since 3.5.2
180
+ * @created: 11/11/12
181
+ */
182
+
183
+ $(document).live('acf/setup_fields', function(e, postbox){
184
+
185
+ $(postbox).find('.repeater').each(function(){
186
+
187
+ var repeater = $(this)
188
+
189
+
190
+ // set column widths
191
+ _repeater.set_column_widths( repeater );
192
+
193
+
194
+ // update classes based on row count
195
+ _repeater.update_classes( repeater );
196
+
197
+
198
+ // add sortable
199
+ _repeater.add_sortable( repeater );
200
+
201
+ });
202
+
203
+ });
204
+
205
+
206
+
207
+ /*
208
+ * Add Row
209
+ *
210
+ * @description:
211
+ * @since: 3.5.8
212
+ * @created: 17/01/13
213
+ */
214
+
215
+ _repeater.add_row = function( repeater, before )
216
+ {
217
+ // vars
218
+ var max_rows = parseInt( repeater.attr('data-max_rows') ),
219
+ row_count = repeater.find('> table > tbody > tr.row').length;
220
+
221
+
222
+ // validate
223
+ if( row_count >= max_rows )
224
+ {
225
+ alert( _repeater.text.max.replace('{max}', max_rows) );
226
+ return false;
227
+ }
228
+
229
+
230
+ // create and add the new field
231
+ var new_id = acf.helpers.uniqid(),
232
+ new_field_html = repeater.find('> table > tbody > tr.row-clone').html().replace(/(=["]*[\w-\[\]]*?)(acfcloneindex)/g, '$1' + new_id),
233
+ new_field = $('<tr class="row"></tr>').append( new_field_html );
234
+
235
+
236
+ // add row
237
+ if( !before )
238
+ {
239
+ before = repeater.find('> table > tbody > .row-clone');
240
+ }
241
+
242
+ before.before( new_field );
243
+
244
+
245
+ // trigger mouseenter on parent repeater to work out css margin on add-row button
246
+ repeater.closest('tr').trigger('mouseenter');
247
+
248
+
249
+ // update order
250
+ _repeater.update_order( repeater );
251
+
252
+
253
+ // update classes based on row count
254
+ _repeater.update_classes( repeater );
255
+
256
+
257
+ // setup fields
258
+ $(document).trigger('acf/setup_fields', new_field);
259
+
260
+
261
+ // validation
262
+ repeater.closest('.field').removeClass('error');
263
+ }
264
+
265
+
266
+ /*
267
+ * Add Button
268
+ *
269
+ * @description:
270
+ * @since: 3.5.8
271
+ * @created: 17/01/13
272
+ */
273
+
274
+ $('.repeater .repeater-footer .add-row-end').live('click', function(){
275
+
276
+ var repeater = $(this).closest('.repeater');
277
+
278
+ _repeater.add_row( repeater, false );
279
+
280
+ return false;
281
+ });
282
+
283
+
284
+ /*
285
+ * Add Before Button
286
+ *
287
+ * @description:
288
+ * @since: 3.5.8
289
+ * @created: 17/01/13
290
+ */
291
+
292
+ $('.repeater td.remove .add-row-before').live('click', function(){
293
+
294
+ var repeater = $(this).closest('.repeater'),
295
+ before = $(this).closest('tr');
296
+
297
+ _repeater.add_row( repeater, before );
298
+
299
+ return false;
300
+ });
301
+
302
+
303
+ /*
304
+ * Remove Row
305
+ *
306
+ * @description:
307
+ * @since: 3.5.8
308
+ * @created: 17/01/13
309
+ */
310
+
311
+ _repeater.remove_row = function( tr )
312
+ {
313
+ // vars
314
+ var repeater = tr.closest('.repeater'),
315
+ min_rows = parseInt( repeater.attr('data-min_rows') ),
316
+ row_count = repeater.find('> table > tbody > tr.row').length,
317
+ column_count = tr.children('tr.row').length,
318
+ row_height = tr.height();
319
+
320
+
321
+ // validate
322
+ if( row_count <= min_rows )
323
+ {
324
+ alert( _repeater.text.min.replace('{min}', row_count) );
325
+ return false;
326
+ }
327
+
328
+
329
+ // animate out tr
330
+ tr.addClass('acf-remove-item');
331
+ setTimeout(function(){
332
+
333
+ tr.remove();
334
+
335
+
336
+ // trigger mouseenter on parent repeater to work out css margin on add-row button
337
+ repeater.closest('tr').trigger('mouseenter');
338
+
339
+
340
+ // update order
341
+ _repeater.update_order( repeater );
342
+
343
+
344
+ // update classes based on row count
345
+ _repeater.update_classes( repeater );
346
+
347
+ }, 400);
348
+
349
+ }
350
+
351
+
352
+ /*
353
+ * Remove Row
354
+ *
355
+ * @description:
356
+ * @since: 3.5.8
357
+ * @created: 17/01/13
358
+ */
359
+
360
+ $('.repeater td.remove .acf-button-remove').live('click', function(){
361
+
362
+ var tr = $(this).closest('tr');
363
+
364
+ _repeater.remove_row( tr );
365
+
366
+ return false;
367
+ });
368
+
369
+
370
+ /*
371
+ * hover over tr, align add-row button to top
372
+ *
373
+ * @description:
374
+ * @since: 3.5.8
375
+ * @created: 17/01/13
376
+ */
377
+
378
+ $('.repeater tr').live('mouseenter', function(){
379
+
380
+ var button = $(this).find('> td.remove > a.acf-button-add');
381
+ var margin = ( button.parent().height() / 2 ) + 9; // 9 = padding + border
382
+
383
+ button.css('margin-top', '-' + margin + 'px' );
384
+
385
+ });
386
+
387
+
388
+ })(jQuery);
js/input/tab.js ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Tab
3
+ *
4
+ * @description:
5
+ * @since: 3.5.8
6
+ * @created: 17/01/13
7
+ */
8
+
9
+ (function($){
10
+
11
+ /*
12
+ * acf/setup_fields
13
+ *
14
+ * @description:
15
+ * @since: 3.5.8
16
+ * @created: 17/01/13
17
+ */
18
+
19
+ $(document).live('acf/setup_fields', function(e, postbox){
20
+
21
+ $(postbox).find('.acf-tab').each(function(){
22
+
23
+ // vars
24
+ var tab = $(this),
25
+ id = tab.attr('data-id'),
26
+ label = tab.html(),
27
+ postbox = tab.closest('.acf_postbox'),
28
+ inside = postbox.children('.inside');
29
+
30
+
31
+
32
+ // only run once for each tab
33
+ if( tab.hasClass('acf-tab-added') )
34
+ {
35
+ return;
36
+ }
37
+ tab.addClass('acf-tab-added');
38
+
39
+
40
+ // create tab group if it doesnt exist
41
+ if( ! inside.children('.acf-tab-group').exists() )
42
+ {
43
+ inside.children('.field-tab:first').before('<ul class="hl clearfix acf-tab-group"></ul>');
44
+ }
45
+
46
+
47
+ // add tab
48
+ inside.children('.acf-tab-group').append('<li><a class="acf-tab-button" href="#" data-id="' + id + '">' + label + '</a></li>');
49
+
50
+
51
+ });
52
+
53
+
54
+ // trigger
55
+ $(postbox).find('.acf-tab-group').each(function(){
56
+
57
+ $(this).find('li:first a').trigger('click');
58
+
59
+ });
60
+
61
+
62
+ });
63
+
64
+
65
+ /*
66
+ * Tab group click
67
+ *
68
+ * @description:
69
+ * @since: 2.0.4
70
+ * @created: 14/12/12
71
+ */
72
+
73
+ $('.acf-tab-button').live('click', function(){
74
+
75
+ // vars
76
+ var a = $(this),
77
+ id = a.attr('data-id'),
78
+ ul = a.closest('ul'),
79
+ inside = ul.closest('.acf_postbox').children('.inside');
80
+
81
+
82
+ // classes
83
+ ul.find('li').removeClass('active');
84
+ a.parent('li').addClass('active');
85
+
86
+
87
+ // hide / show
88
+ inside.children('.field-tab').each(function(){
89
+
90
+ var tab = $(this);
91
+
92
+ if( tab.hasClass('field-' + id) )
93
+ {
94
+ tab.nextUntil('.field-tab').removeClass('acf-tab_group-hide').addClass('acf-tab_group-show');
95
+ }
96
+ else
97
+ {
98
+ tab.nextUntil('.field-tab').removeClass('acf-tab_group-show').addClass('acf-tab_group-hide');
99
+ }
100
+
101
+ });
102
+
103
+ $(this).trigger('blur');
104
+
105
+ return false;
106
+
107
+ });
108
+
109
+
110
+ })(jQuery);
js/input/validation.js ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Validation
3
+ *
4
+ * @description:
5
+ * @since: 3.5.8
6
+ * @created: 17/01/13
7
+ */
8
+
9
+ (function($){
10
+
11
+
12
+ var _validation = acf.validation;
13
+
14
+
15
+ /*
16
+ * do_validation
17
+ *
18
+ * @description: checks fields for required input
19
+ * @created: 1/03/2011
20
+ */
21
+
22
+ _validation.run = function(){
23
+
24
+ _validation.status = true;
25
+
26
+ $('.postbox:not(.acf-hidden) .field.required, .form-field.required').each(function(){
27
+
28
+ // vars
29
+ var div = $(this);
30
+
31
+
32
+ // set validation data
33
+ div.data('validation', true);
34
+
35
+
36
+ // if is hidden by conditional logic, ignore
37
+ if( div.hasClass('acf-conditional_logic-hide') )
38
+ {
39
+ return;
40
+ }
41
+
42
+
43
+ // text / textarea
44
+ if( div.find('input[type="text"], input[type="number"], input[type="hidden"], textarea').val() == "" )
45
+ {
46
+ div.data('validation', false);
47
+ }
48
+
49
+
50
+ // wysiwyg
51
+ if( div.find('.acf_wysiwyg').exists() && typeof(tinyMCE) == "object")
52
+ {
53
+ div.data('validation', true);
54
+
55
+ var id = div.find('.wp-editor-area').attr('id'),
56
+ editor = tinyMCE.get( id );
57
+
58
+ if( editor && !editor.getContent() )
59
+ {
60
+ div.data('validation', false);
61
+ }
62
+ }
63
+
64
+
65
+ // select
66
+ if( div.find('select').exists() )
67
+ {
68
+ div.data('validation', true);
69
+
70
+ if( div.find('select').val() == "null" || ! div.find('select').val() )
71
+ {
72
+ div.data('validation', false);
73
+ }
74
+ }
75
+
76
+
77
+ // checkbox
78
+ if( div.find('input[type="checkbox"]:checked').exists() )
79
+ {
80
+ div.data('validation', true);
81
+ }
82
+
83
+
84
+ // relationship
85
+ if( div.find('.acf_relationship').exists() )
86
+ {
87
+ div.data('validation', false);
88
+
89
+ if( div.find('.acf_relationship .relationship_right input').exists() )
90
+ {
91
+ div.data('validation', true);
92
+ }
93
+ }
94
+
95
+
96
+ // repeater
97
+ if( div.find('.repeater').exists() )
98
+ {
99
+ div.data('validation', false);
100
+
101
+ if( div.find('.repeater tr.row').exists() )
102
+ {
103
+ div.data('validation', true);
104
+ }
105
+ }
106
+
107
+
108
+ // flexible content
109
+ if( div.find('.acf_flexible_content').exists() )
110
+ {
111
+ div.data('validation', false);
112
+ if( div.find('.acf_flexible_content .values table').exists() )
113
+ {
114
+ div.data('validation', true);
115
+ }
116
+ }
117
+
118
+
119
+ // gallery
120
+ if( div.find('.acf-gallery').exists() )
121
+ {
122
+ div.data('validation', false);
123
+
124
+ if( div.find('.acf-gallery .thumbnail').exists())
125
+ {
126
+ div.data('validation', true);
127
+ }
128
+ }
129
+
130
+
131
+ // hook for custom validation
132
+ $(document).trigger('acf/validate_field', div );
133
+
134
+
135
+ // set validation
136
+ if( ! div.data('validation') )
137
+ {
138
+ _validation.status = false;
139
+ div.closest('.field').addClass('error');
140
+ }
141
+
142
+
143
+ });
144
+
145
+
146
+ }
147
+
148
+
149
+ /*
150
+ * Remove error class on focus
151
+ *
152
+ * @description:
153
+ * @since: 3.5.8
154
+ * @created: 17/01/13
155
+ */
156
+
157
+ // inputs / textareas
158
+ $('.field.required input, .field.required textarea, .field.required select').live('focus', function(){
159
+ $(this).closest('.field').removeClass('error');
160
+ });
161
+
162
+ // checkbox
163
+ $('.field.required input:checkbox').live('click', function(){
164
+ $(this).closest('.field').removeClass('error');
165
+ });
166
+
167
+ })(jQuery);
js/input/wysiwyg.js ADDED
@@ -0,0 +1,363 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * WYSIWYG
3
+ *
4
+ * @description:
5
+ * @since: 3.5.8
6
+ * @created: 17/01/13
7
+ */
8
+
9
+ (function($){
10
+
11
+ var _wysiwyg = acf.fields.wysiwyg;
12
+
13
+
14
+ /*
15
+ * has_tinymce
16
+ *
17
+ * @description:
18
+ * @since: 3.5.8
19
+ * @created: 17/01/13
20
+ */
21
+
22
+ _wysiwyg.has_tinymce = function(){
23
+
24
+ var r = false;
25
+
26
+ if( typeof(tinyMCE) == "object" )
27
+ {
28
+ r = true;
29
+ }
30
+
31
+ return r;
32
+
33
+ }
34
+
35
+ /*
36
+ * acf/wysiwyg_activate
37
+ *
38
+ * @description:
39
+ * @since: 3.5.8
40
+ * @created: 17/01/13
41
+ */
42
+
43
+ $(document).live('acf/wysiwyg_activate', function(e, div){
44
+
45
+ // validate tinymce
46
+ if( ! _wysiwyg.has_tinymce() )
47
+ {
48
+ return;
49
+ }
50
+
51
+
52
+ // activate
53
+ $(div).find('.acf_wysiwyg textarea').each(function(){
54
+
55
+ // vars
56
+ var textarea = $(this),
57
+ id = textarea.attr('id'),
58
+ toolbar = textarea.closest('.acf_wysiwyg').attr('data-toolbar');
59
+
60
+
61
+ // is clone field?
62
+ if( acf.helpers.is_clone_field(textarea) )
63
+ {
64
+ return;
65
+ }
66
+
67
+
68
+ // reset tinyMCE settings
69
+ tinyMCE.settings.theme_advanced_buttons1 = '';
70
+ tinyMCE.settings.theme_advanced_buttons2 = '';
71
+ tinyMCE.settings.theme_advanced_buttons3 = '';
72
+ tinyMCE.settings.theme_advanced_buttons4 = '';
73
+
74
+ if( _wysiwyg.toolbars[ toolbar ] )
75
+ {
76
+ $.each( _wysiwyg.toolbars[ toolbar ], function( k, v ){
77
+ tinyMCE.settings[ k ] = v;
78
+ })
79
+ }
80
+
81
+
82
+ // add functionality back in
83
+ tinyMCE.execCommand("mceAddControl", false, id);
84
+
85
+
86
+ // events - load
87
+ $(document).trigger('acf/wysiwyg/load', id);
88
+
89
+
90
+ // add events (click, focus, blur) for inserting image into correct editor
91
+ _wysiwyg.add_events( id );
92
+
93
+ });
94
+
95
+
96
+ wpActiveEditor = null;
97
+
98
+ });
99
+
100
+
101
+ /*
102
+ * add_wysiwyg_events
103
+ *
104
+ * @description:
105
+ * @since: 2.0.4
106
+ * @created: 16/12/12
107
+ */
108
+
109
+ _wysiwyg.add_events = function( id ){
110
+
111
+ // validate tinymce
112
+ if( ! _wysiwyg.has_tinymce() )
113
+ {
114
+ return;
115
+ }
116
+
117
+
118
+ var editor = tinyMCE.get( id );
119
+
120
+ if( !editor )
121
+ {
122
+ return;
123
+ }
124
+
125
+
126
+ var container = $('#wp-' + id + '-wrap'),
127
+ body = $( editor.getBody() );
128
+
129
+
130
+ container.click(function(){
131
+ $(document).trigger('acf/wysiwyg/click', id);
132
+ });
133
+
134
+ body.focus(function(){
135
+ $(document).trigger('acf/wysiwyg/focus', id);
136
+ }).blur(function(){
137
+ $(document).trigger('acf/wysiwyg/blur', id);
138
+ });
139
+
140
+ };
141
+
142
+
143
+ /*
144
+ * acf/wysiwyg_deactivate
145
+ *
146
+ * @description:
147
+ * @since: 3.5.8
148
+ * @created: 17/01/13
149
+ */
150
+
151
+ $(document).live('acf/wysiwyg_deactivate', function(e, div){
152
+
153
+ // validate tinymce
154
+ if( ! _wysiwyg.has_tinymce() )
155
+ {
156
+ return;
157
+ }
158
+
159
+
160
+ $(div).find('.acf_wysiwyg textarea').each(function(){
161
+
162
+ // vars
163
+ var textarea = $(this),
164
+ id = textarea.attr('id'),
165
+ wysiwyg = tinyMCE.get( id );
166
+
167
+
168
+ // if wysiwyg was found (should be always...), remove its functionality and set the value (to keep line breaks)
169
+ if( wysiwyg )
170
+ {
171
+ var val = wysiwyg.getContent();
172
+
173
+ tinyMCE.execCommand("mceRemoveControl", false, id);
174
+
175
+ textarea.val( val );
176
+ }
177
+
178
+ });
179
+
180
+
181
+ wpActiveEditor = null;
182
+
183
+ });
184
+
185
+
186
+ /*
187
+ * acf/wysiwyg/click
188
+ *
189
+ * @description:
190
+ * @since: 3.5.8
191
+ * @created: 17/01/13
192
+ */
193
+
194
+ $(document).live('acf/wysiwyg/click', function(e, id){
195
+
196
+ wpActiveEditor = id;
197
+
198
+ container = $('#wp-' + id + '-wrap').closest('.field').removeClass('error');
199
+
200
+ });
201
+
202
+
203
+ /*
204
+ * acf/wysiwyg/focus
205
+ *
206
+ * @description:
207
+ * @since: 3.5.8
208
+ * @created: 17/01/13
209
+ */
210
+
211
+ $(document).live('acf/wysiwyg/focus', function(e, id){
212
+
213
+ wpActiveEditor = id;
214
+
215
+ container = $('#wp-' + id + '-wrap').closest('.field').removeClass('error');
216
+
217
+ });
218
+
219
+ /*
220
+ * acf/wysiwyg/blur
221
+ *
222
+ * @description:
223
+ * @since: 3.5.8
224
+ * @created: 17/01/13
225
+ */
226
+
227
+ $(document).live('acf/wysiwyg/blur', function(e, id){
228
+
229
+ wpActiveEditor = null;
230
+
231
+ // update the hidden textarea
232
+ // - This fixes a but when adding a taxonomy term as the form is not posted and the hidden tetarea is never populated!
233
+ tinyMCE.get( id ).save();
234
+
235
+ });
236
+
237
+
238
+ /*
239
+ * acf/setup_fields
240
+ *
241
+ * @description:
242
+ * @since: 3.5.8
243
+ * @created: 17/01/13
244
+ */
245
+
246
+ $(document).live('acf/setup_fields', function(e, div){
247
+
248
+ $(document).trigger('acf/wysiwyg_activate', div);
249
+
250
+ });
251
+
252
+
253
+ /*
254
+ * acf/sortable_start
255
+ *
256
+ * @description:
257
+ * @since 3.5.1
258
+ * @created: 10/11/12
259
+ */
260
+
261
+ $(document).live('acf/sortable_start', function(e, div) {
262
+
263
+ $(document).trigger('acf/wysiwyg_deactivate', div);
264
+
265
+ });
266
+
267
+
268
+ /*
269
+ * acf/sortable_stop
270
+ *
271
+ * @description:
272
+ * @since 3.5.1
273
+ * @created: 10/11/12
274
+ */
275
+
276
+ $(document).live('acf/sortable_stop', function(e, div) {
277
+
278
+ $(document).trigger('acf/wysiwyg_activate', div);
279
+
280
+ });
281
+
282
+
283
+ /*
284
+ * window load
285
+ *
286
+ * @description:
287
+ * @since: 3.5.5
288
+ * @created: 22/12/12
289
+ */
290
+
291
+ $(window).load(function(){
292
+
293
+ // vars
294
+ var wp_content = $('#wp-content-wrap').exists(),
295
+ wp_acf_settings = $('#wp-acf_settings-wrap').exists()
296
+ mode = 'tmce';
297
+
298
+
299
+ // has_editor
300
+ if( wp_acf_settings )
301
+ {
302
+ // html_mode
303
+ if( $('#wp-acf_settings-wrap').hasClass('html-active') )
304
+ {
305
+ mode = 'html';
306
+ }
307
+ }
308
+
309
+
310
+ setTimeout(function(){
311
+
312
+ // trigger click on hidden wysiwyg (to get in HTML mode)
313
+ if( wp_acf_settings && mode == 'html' )
314
+ {
315
+ $('#acf_settings-tmce').trigger('click');
316
+ }
317
+
318
+ }, 1);
319
+
320
+
321
+ setTimeout(function(){
322
+
323
+ // trigger html mode for people who want to stay in HTML mode
324
+ if( wp_acf_settings && mode == 'html' )
325
+ {
326
+ $('#acf_settings-html').trigger('click');
327
+ }
328
+
329
+ // Add events to content editor
330
+ if( wp_content )
331
+ {
332
+ _wysiwyg.add_events( 'content' );
333
+ }
334
+
335
+
336
+ }, 11);
337
+
338
+ });
339
+
340
+
341
+ /*
342
+ * Full screen
343
+ *
344
+ * @description: this hack will hide the 'image upload' button in the wysiwyg full screen mode if the field has disabled image uploads!
345
+ * @since: 3.6
346
+ * @created: 26/02/13
347
+ */
348
+
349
+ $('.acf_wysiwyg a.mce_fullscreen').live('click', function(){
350
+
351
+ // vars
352
+ var wysiwyg = $(this).closest('.acf_wysiwyg'),
353
+ upload = wysiwyg.attr('data-upload');
354
+
355
+ if( upload == 'no' )
356
+ {
357
+ $('#mce_fullscreen_container td.mceToolbar .mce_add_media').hide();
358
+ }
359
+
360
+ });
361
+
362
+
363
+ })(jQuery);
lang/acf-it_IT.mo CHANGED
Binary file
lang/acf-it_IT.po CHANGED
@@ -8,17 +8,16 @@ msgstr ""
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
- "PO-Revision-Date: 2012-06-15 10:19+0100\n"
12
  "Last-Translator: ale <alala@asdasda.it>\n"
13
  "Language-Team: <a.mignogna@asernet.it>\n"
14
- "X-Poedit-Language: Italian\n"
15
- "X-Poedit-Country: ITALY\n"
16
  "X-Poedit-SourceCharset: utf-8\n"
 
 
17
 
18
- #: acf.php:289
19
- #: core/admin/meta_box_options.php:83
20
  msgid "Custom Fields"
21
- msgstr "Campi personalizzati"
22
 
23
  #: acf.php:290
24
  msgid "Settings"
@@ -40,9 +39,7 @@ msgstr "Location"
40
  msgid "Add Fields to Edit Screens"
41
  msgstr "Aggiungi campi alle schermate di modifica"
42
 
43
- #: acf.php:505
44
- #: core/admin/meta_box_location.php:133
45
- #: core/options_page.php:62
46
  #: core/options_page.php:74
47
  msgid "Options"
48
  msgstr "Opzioni"
@@ -51,9 +48,7 @@ msgstr "Opzioni"
51
  msgid "Customise the edit page"
52
  msgstr "Personalizza la pagina di modifica"
53
 
54
- #: acf.php:533
55
- #: core/api.php:503
56
- #: core/everything_fields.php:202
57
  #: core/options_page.php:182
58
  msgid "Validation Failed. One or more fields below are required."
59
  msgstr "Validazione fallita. Uno o più campi sono obbligatori."
@@ -82,8 +77,7 @@ msgstr "Template di default"
82
  msgid "No ACF groups selected"
83
  msgstr "Nessun gruppo ACF selezionato"
84
 
85
- #: core/actions/init.php:21
86
- #: core/actions/init.php:116
87
  #: core/admin/page_acf.php:14
88
  msgid "Advanced Custom Fields"
89
  msgstr "Advanced Custom Fields"
@@ -150,10 +144,9 @@ msgstr "Licenza non riconosciuta"
150
 
151
  #: core/actions/init.php:115
152
  msgid "Field&nbsp;Groups"
153
- msgstr "Field&nbsp;Groups"
154
 
155
- #: core/actions/init.php:117
156
- #: core/fields/flexible_content.php:257
157
  msgid "Add New"
158
  msgstr "Aggiungi nuovo"
159
 
@@ -185,8 +178,7 @@ msgstr "Nessun gruppo di campi trovato"
185
  msgid "No Field Groups found in Trash"
186
  msgstr "Nessun gruppo di campi trovato nel cestino"
187
 
188
- #: core/actions/init.php:153
189
- #: core/actions/init.php:156
190
  msgid "Field group updated."
191
  msgstr "Gruppo di campi aggiornato."
192
 
@@ -227,8 +219,7 @@ msgstr "Bozza del gruppo di campi aggiornata."
227
  msgid "Title"
228
  msgstr "Titolo"
229
 
230
- #: core/admin/meta_box_fields.php:17
231
- #: core/fields/flexible_content.php:245
232
  #: core/fields/repeater.php:218
233
  msgid "New Field"
234
  msgstr "Nuovo campo"
@@ -237,104 +228,85 @@ msgstr "Nuovo campo"
237
  msgid "Move to trash. Are you sure?"
238
  msgstr "Sei sicuro di spostarlo nel cestino?"
239
 
240
- #: core/admin/meta_box_fields.php:50
241
- #: core/fields/flexible_content.php:309
242
  #: core/fields/repeater.php:244
243
  msgid "Field Order"
244
  msgstr "Ordine del campo"
245
 
246
- #: core/admin/meta_box_fields.php:51
247
- #: core/admin/meta_box_fields.php:92
248
- #: core/fields/flexible_content.php:310
249
- #: core/fields/flexible_content.php:357
250
- #: core/fields/repeater.php:245
251
- #: core/fields/repeater.php:292
252
  msgid "Field Label"
253
  msgstr "Etichetta del campo"
254
 
255
- #: core/admin/meta_box_fields.php:52
256
- #: core/admin/meta_box_fields.php:108
257
- #: core/fields/flexible_content.php:311
258
- #: core/fields/flexible_content.php:373
259
- #: core/fields/repeater.php:246
260
- #: core/fields/repeater.php:308
261
  msgid "Field Name"
262
  msgstr "Nome del campo"
263
 
264
- #: core/admin/meta_box_fields.php:53
265
- #: core/admin/meta_box_fields.php:123
266
- #: core/admin/page_settings.php:44
267
- #: core/fields/flexible_content.php:312
268
- #: core/fields/flexible_content.php:388
269
- #: core/fields/repeater.php:247
270
  #: core/fields/repeater.php:323
271
  msgid "Field Type"
272
  msgstr "Tipo del campo"
273
 
274
  #: core/admin/meta_box_fields.php:60
275
- msgid "No fields. Click the <strong>+ Add Field</strong> button to create your first field."
276
- msgstr "Nessun campo. Clicca sul pulsante <strong> + Aggiungi campo</strong> per creare il tuo primo campo."
277
-
278
- #: core/admin/meta_box_fields.php:71
279
- #: core/admin/meta_box_fields.php:74
280
- #: core/fields/flexible_content.php:336
281
- #: core/fields/flexible_content.php:339
282
- #: core/fields/repeater.php:270
283
- #: core/fields/repeater.php:273
 
284
  msgid "Edit this Field"
285
  msgstr "Modifica questo campo"
286
 
287
- #: core/admin/meta_box_fields.php:74
288
- #: core/fields/flexible_content.php:339
289
  #: core/fields/repeater.php:273
290
  msgid "Edit"
291
  msgstr "Modifica"
292
 
293
- #: core/admin/meta_box_fields.php:75
294
- #: core/fields/flexible_content.php:340
295
  #: core/fields/repeater.php:274
296
  msgid "Read documentation for this field"
297
  msgstr "Leggi la documentazione per questo campo"
298
 
299
- #: core/admin/meta_box_fields.php:75
300
- #: core/fields/flexible_content.php:340
301
  #: core/fields/repeater.php:274
302
  msgid "Docs"
303
  msgstr "Docs"
304
 
305
- #: core/admin/meta_box_fields.php:76
306
- #: core/fields/flexible_content.php:341
307
  #: core/fields/repeater.php:275
308
  msgid "Duplicate this Field"
309
  msgstr "Duplica questo campo"
310
 
311
- #: core/admin/meta_box_fields.php:76
312
- #: core/fields/flexible_content.php:341
313
  #: core/fields/repeater.php:275
314
  msgid "Duplicate"
315
  msgstr "Duplica"
316
 
317
- #: core/admin/meta_box_fields.php:77
318
- #: core/fields/flexible_content.php:342
319
  #: core/fields/repeater.php:276
320
  msgid "Delete this Field"
321
  msgstr "Cancella questo campo"
322
 
323
- #: core/admin/meta_box_fields.php:77
324
- #: core/fields/flexible_content.php:258
325
- #: core/fields/flexible_content.php:342
326
- #: core/fields/repeater.php:276
327
  msgid "Delete"
328
  msgstr "Cancella"
329
 
330
- #: core/admin/meta_box_fields.php:93
331
- #: core/fields/flexible_content.php:358
332
  #: core/fields/repeater.php:293
333
  msgid "This is the name which will appear on the EDIT page"
334
  msgstr "Questo è il nome che apparirà nella pagina di modifica"
335
 
336
- #: core/admin/meta_box_fields.php:109
337
- #: core/fields/flexible_content.php:374
338
  #: core/fields/repeater.php:309
339
  msgid "Single word, no spaces. Underscores and dashes allowed"
340
  msgstr "Una parola, senza spazi. \"_\" e trattini permessi"
@@ -345,26 +317,24 @@ msgstr "Istruzioni del campo"
345
 
346
  #: core/admin/meta_box_fields.php:137
347
  msgid "Instructions for authors. Shown when submitting data"
348
- msgstr "Istruzioni per gli autori. Visualizzate quando si inseriscono dati"
 
349
 
350
  #: core/admin/meta_box_fields.php:149
351
  msgid "Required?"
352
  msgstr "Obbligatorio?"
353
 
354
- #: core/admin/meta_box_fields.php:172
355
- #: core/fields/flexible_content.php:408
356
  #: core/fields/repeater.php:343
357
  msgid "Save Field"
358
  msgstr "Salva campo"
359
 
360
- #: core/admin/meta_box_fields.php:177
361
- #: core/fields/flexible_content.php:413
362
  #: core/fields/repeater.php:348
363
  msgid "Close Field"
364
  msgstr "Chiudi campo"
365
 
366
- #: core/admin/meta_box_fields.php:190
367
- #: core/fields/flexible_content.php:427
368
  #: core/fields/repeater.php:363
369
  msgid "Drag and drop to reorder"
370
  msgstr "Trascina e rilascia per riordinare"
@@ -375,21 +345,22 @@ msgstr "+ Aggiungi campo"
375
 
376
  #: core/admin/meta_box_location.php:25
377
  msgid "Rules"
378
- msgstr "Regole"
379
 
380
  #: core/admin/meta_box_location.php:26
381
- msgid "Create a set of rules to determine which edit screens will use these advanced custom fields"
382
- msgstr "Crea un insieme di regole per determinare quali schermate di modifica dovranno usare questi campi personalizzati"
 
 
 
 
383
 
384
- #: core/admin/meta_box_location.php:37
385
- #: core/fields/wysiwyg.php:142
386
  msgid "Basic"
387
  msgstr "Basic"
388
 
389
- #: core/admin/meta_box_location.php:38
390
- #: core/fields/page_link.php:194
391
- #: core/fields/post_object.php:209
392
- #: core/fields/relationship.php:246
393
  msgid "Post Type"
394
  msgstr "Post Type"
395
 
@@ -453,8 +424,7 @@ msgstr "Utente (Aggiungi / Modifica)"
453
  msgid "Media (Edit)"
454
  msgstr "Media (Aggiungi/Modifica)"
455
 
456
- #: core/admin/meta_box_location.php:64
457
- #: core/admin/page_settings.php:92
458
  msgid "Options Page"
459
  msgstr "Pagina delle opzioni"
460
 
@@ -468,19 +438,19 @@ msgstr "non è uguale a"
468
 
469
  #: core/admin/meta_box_location.php:111
470
  msgid "match"
471
- msgstr "unisci"
472
 
473
  #: core/admin/meta_box_location.php:117
474
  msgid "all"
475
- msgstr "tutti"
476
 
477
  #: core/admin/meta_box_location.php:118
478
  msgid "any"
479
- msgstr "alcuni"
480
 
481
  #: core/admin/meta_box_location.php:121
482
  msgid "of the above"
483
- msgstr "di sopra"
484
 
485
  #: core/admin/meta_box_location.php:134
486
  msgid "Unlock options add-on with an activation code"
@@ -527,8 +497,13 @@ msgid "Deselect items to hide them on the edit page"
527
  msgstr "Deseleziona gli elementi per nasconderli nella pagina di modifica"
528
 
529
  #: core/admin/meta_box_options.php:72
530
- msgid "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."
531
- msgstr "SE più gruppi ACF appaiono in una pagina di modifica, verrano utilizzate le opzioni del primo gruppo ACF. Il primo gruppo è quello con il numero d'oridne pià basso."
 
 
 
 
 
532
 
533
  #: core/admin/meta_box_options.php:82
534
  msgid "Content Editor"
@@ -563,8 +538,12 @@ msgid "Resources"
563
  msgstr "Risorse"
564
 
565
  #: core/admin/page_acf.php:20
566
- msgid "Read documentation, learn the functions and find some tips &amp; tricks for your next web project."
567
- msgstr "Leggi la documentazione, impara le funzioni e scopri alcuni trucchi per il tuo prossimo progetto web."
 
 
 
 
568
 
569
  #: core/admin/page_acf.php:21
570
  msgid "View the ACF website"
@@ -602,14 +581,12 @@ msgstr "Codice di Attivazione"
602
  msgid "Repeater Field"
603
  msgstr "Repeater Field"
604
 
605
- #: core/admin/page_settings.php:53
606
- #: core/admin/page_settings.php:73
607
  #: core/admin/page_settings.php:93
608
  msgid "Active"
609
  msgstr "Attivo"
610
 
611
- #: core/admin/page_settings.php:53
612
- #: core/admin/page_settings.php:73
613
  #: core/admin/page_settings.php:93
614
  msgid "Inactive"
615
  msgstr "Inattivo"
@@ -619,8 +596,12 @@ msgid "Flexible Content Field"
619
  msgstr "Flexible Content Field"
620
 
621
  #: core/admin/page_settings.php:115
622
- msgid "Add-ons can be unlocked by purchasing a license key. Each key can be used on multiple sites."
623
- msgstr "Gli Add-ons possono essere sbloccati comprando una lienza. Ogni chiave può essere usata su più siti."
 
 
 
 
624
 
625
  #: core/admin/page_settings.php:115
626
  msgid "Find Add-ons"
@@ -631,8 +612,12 @@ msgid "Export Field Groups to XML"
631
  msgstr "Esporta i gruppi di campi in XML"
632
 
633
  #: core/admin/page_settings.php:166
634
- msgid "ACF will create a .xml export file which is compatible with the native WP import plugin."
635
- msgstr "ACF creerà un file di export XML che è compatibile con tutti i pulugin di importazione nativi."
 
 
 
 
636
 
637
  #: core/admin/page_settings.php:169
638
  msgid "Export XML"
@@ -682,25 +667,22 @@ msgstr "ACF genererà il codice PHP da includere nel tuo tema"
682
  msgid "Create PHP"
683
  msgstr "Genera PHP"
684
 
685
- #: core/admin/page_settings.php:242
686
- #: core/admin/page_settings.php:270
687
  msgid "Register Field Groups with PHP"
688
  msgstr "Registra i gruppi di campi con PHP"
689
 
690
- #: core/admin/page_settings.php:244
691
- #: core/admin/page_settings.php:272
692
  msgid "Copy the PHP code generated"
693
  msgstr "Copia il codice PHP generato"
694
 
695
- #: core/admin/page_settings.php:245
696
- #: core/admin/page_settings.php:273
697
  msgid "Paste into your functions.php file"
698
  msgstr "Incolla nel tuo file functions.php"
699
 
700
- #: core/admin/page_settings.php:246
701
- #: core/admin/page_settings.php:274
702
  msgid "To activate any Add-ons, edit and use the code in the first few lines."
703
- msgstr "Per attivare qualsiasi add-ons, modifica e usa il codice nelle prime linee."
 
704
 
705
  #: core/admin/page_settings.php:267
706
  msgid "Back to settings"
@@ -710,34 +692,47 @@ msgstr "Torna alle impostazioni"
710
  msgid ""
711
  "/**\n"
712
  " * Activate Add-ons\n"
713
- " * Here you can enter your activation codes to unlock Add-ons to use in your theme. \n"
714
- " * Since all activation codes are multi-site licenses, you are allowed to include your key in premium themes. \n"
715
- " * Use the commented out code to update the database with your activation code. \n"
716
- " * You may place this code inside an IF statement that only runs on theme activation.\n"
 
 
 
 
717
  " */"
718
  msgstr ""
719
  "/**\n"
720
  " * Attiva Add-ons\n"
721
- " * Qui puoi digitare il tuo codice di attivazione per sbloccare gli add-ons da utilizzare nel tuo tema. \n"
722
- " * Visto che tutti i codici d'attivazione sono multisito, puoi includere la tua chiave nei temi premium. \n"
723
- " * Usa il codice commentato per aggiornare il database con il tuo codice di attivazione. \n"
724
- " * Puoi inserire questo codice all'interno di una condizione IF relativa all'attivazione del tema.\n"
 
 
 
 
725
  " */"
726
 
727
  #: core/admin/page_settings.php:308
728
  msgid ""
729
  "/**\n"
730
  " * Register field groups\n"
731
- " * The register_field_group function accepts 1 array which holds the relevant data to register a field group\n"
732
- " * You may edit the array as you see fit. However, this may result in errors if the array is not compatible with ACF\n"
 
 
733
  " * This code must run every time the functions.php file is read\n"
734
  " */"
735
  msgstr ""
736
  "/**\n"
737
  " * Registra i gruppi di campi\n"
738
- " * La funzione register_field_group function accetta 1 array che contiene le informazioni necessarie per registrare un gruppo di campi\n"
739
- " * Puoi modificare questo array. Tuttavia, potresti generare degli errori se l'array non è compatibile con ACF\n"
740
- " * Questo codice deve essere eseguito ogni qual volta viene letto il file functions.php\n"
 
 
 
741
  " */"
742
 
743
  #: core/admin/page_settings.php:336
@@ -748,44 +743,37 @@ msgstr "Nessun gruppo di campi è stato selezionato"
748
  msgid "Checkbox"
749
  msgstr "Checkbox"
750
 
751
- #: core/fields/checkbox.php:44
752
- #: core/fields/radio.php:45
753
  #: core/fields/select.php:50
754
  msgid "No choices to choose from"
755
  msgstr "Nessuna opzione da scegliere da"
756
 
757
- #: core/fields/checkbox.php:102
758
- #: core/fields/radio.php:114
759
  #: core/fields/select.php:164
760
  msgid "Choices"
761
  msgstr "Opzioni"
762
 
763
- #: core/fields/checkbox.php:103
764
- #: core/fields/radio.php:115
765
  #: core/fields/select.php:165
766
  msgid "Enter your choices one per line"
767
  msgstr "Inserisci una opzione per linea"
768
 
769
- #: core/fields/checkbox.php:105
770
- #: core/fields/radio.php:117
771
  #: core/fields/select.php:167
772
  msgid "Red"
773
  msgstr "Rosso"
774
 
775
- #: core/fields/checkbox.php:106
776
- #: core/fields/radio.php:118
777
  #: core/fields/select.php:168
778
  msgid "Blue"
779
  msgstr "Blu"
780
 
781
- #: core/fields/checkbox.php:108
782
- #: core/fields/radio.php:120
783
  #: core/fields/select.php:170
784
  msgid "red : Red"
785
  msgstr "rosso : Rosso"
786
 
787
- #: core/fields/checkbox.php:109
788
- #: core/fields/radio.php:121
789
  #: core/fields/select.php:171
790
  msgid "blue : Blue"
791
  msgstr "blu : Blu"
@@ -822,8 +810,7 @@ msgstr "Nessun file selezionato"
822
  msgid "Add File"
823
  msgstr "Aggiungi file"
824
 
825
- #: core/fields/file.php:194
826
- #: core/fields/image.php:177
827
  msgid "Return Value"
828
  msgstr "Restituisci valore"
829
 
@@ -843,15 +830,12 @@ msgstr "Seleziona file"
843
  msgid "Flexible Content"
844
  msgstr "Contenuto flessibile"
845
 
846
- #: core/fields/flexible_content.php:38
847
- #: core/fields/flexible_content.php:218
848
- #: core/fields/repeater.php:65
849
- #: core/fields/repeater.php:213
850
  msgid "+ Add Row"
851
  msgstr "+ Aggiungi riga"
852
 
853
- #: core/fields/flexible_content.php:254
854
- #: core/fields/radio.php:144
855
  #: core/fields/repeater.php:386
856
  msgid "Layout"
857
  msgstr "Layout"
@@ -888,28 +872,26 @@ msgstr "Display"
888
  msgid "Table"
889
  msgstr "Tabella"
890
 
891
- #: core/fields/flexible_content.php:296
892
- #: core/fields/repeater.php:397
893
  msgid "Row"
894
  msgstr "Riga"
895
 
896
- #: core/fields/flexible_content.php:320
897
- #: core/fields/repeater.php:255
898
- msgid "No fields. Click the \"+ Add Sub Field button\" to create your first field."
899
- msgstr "Nessun campo. Clicca su \"+ Aggiungi un campo\" per creare il tuo primo campo."
 
 
900
 
901
- #: core/fields/flexible_content.php:413
902
- #: core/fields/repeater.php:348
903
  msgid "Close Sub Field"
904
  msgstr "Chiudi il campo"
905
 
906
- #: core/fields/flexible_content.php:428
907
- #: core/fields/repeater.php:364
908
  msgid "+ Add Sub Field"
909
  msgstr "+ Aggiungi campo"
910
 
911
- #: core/fields/flexible_content.php:435
912
- #: core/fields/repeater.php:405
913
  msgid "Button Label"
914
  msgstr "Etichetta del bottone"
915
 
@@ -949,8 +931,7 @@ msgstr "Media"
949
  msgid "Large"
950
  msgstr "Grande"
951
 
952
- #: core/fields/image.php:209
953
- #: core/fields/wysiwyg.php:141
954
  msgid "Full"
955
  msgstr "Dimensione reale"
956
 
@@ -970,11 +951,10 @@ msgstr "Seleziona immagine"
970
  msgid "Page Link"
971
  msgstr "Link a pagina"
972
 
973
- #: core/fields/page_link.php:71
974
- #: core/fields/post_object.php:64
975
  #: core/fields/select.php:21
976
  msgid "Select"
977
- msgstr "Seleziona"
978
 
979
  #: core/fields/page_link.php:195
980
  msgid ""
@@ -982,44 +962,35 @@ msgid ""
982
  "\t\t\t\tTip: deselect all post types to show all post type's posts"
983
  msgstr ""
984
  "Filtra i contenuti selezionato un tipo di contenuto<br />\n"
985
- "\t\t\t\tTrucco: deleziona tutti i tipi di contenuto per visualizzarne tutti i tipi"
 
986
 
987
- #: core/fields/page_link.php:200
988
- #: core/fields/post_object.php:213
989
- #: core/fields/post_object.php:237
990
- #: core/fields/relationship.php:250
991
  #: core/fields/relationship.php:301
992
  msgid "All"
993
  msgstr "Tutti"
994
 
995
- #: core/fields/page_link.php:223
996
- #: core/fields/post_object.php:281
997
  #: core/fields/select.php:194
998
  msgid "Allow Null?"
999
  msgstr "Campo nullo permesso?"
1000
 
1001
- #: core/fields/page_link.php:232
1002
- #: core/fields/page_link.php:251
1003
- #: core/fields/post_object.php:290
1004
- #: core/fields/post_object.php:309
1005
- #: core/fields/select.php:203
1006
- #: core/fields/select.php:222
1007
  #: core/fields/wysiwyg.php:160
1008
  msgid "Yes"
1009
  msgstr "Si"
1010
 
1011
- #: core/fields/page_link.php:233
1012
- #: core/fields/page_link.php:252
1013
- #: core/fields/post_object.php:291
1014
- #: core/fields/post_object.php:310
1015
- #: core/fields/select.php:204
1016
- #: core/fields/select.php:223
1017
  #: core/fields/wysiwyg.php:161
1018
  msgid "No"
1019
  msgstr "No"
1020
 
1021
- #: core/fields/page_link.php:242
1022
- #: core/fields/post_object.php:300
1023
  #: core/fields/select.php:213
1024
  msgid "Select multiple values?"
1025
  msgstr "E' possibile selezionare più valori?"
@@ -1028,8 +999,7 @@ msgstr "E' possibile selezionare più valori?"
1028
  msgid "Post Object"
1029
  msgstr "Post Object"
1030
 
1031
- #: core/fields/post_object.php:231
1032
- #: core/fields/relationship.php:295
1033
  msgid "Filter from Taxonomy"
1034
  msgstr "Filtro da Tassonomia"
1035
 
@@ -1037,10 +1007,8 @@ msgstr "Filtro da Tassonomia"
1037
  msgid "Radio Button"
1038
  msgstr "Radio Button"
1039
 
1040
- #: core/fields/radio.php:130
1041
- #: core/fields/select.php:180
1042
- #: core/fields/text.php:61
1043
- #: core/fields/textarea.php:62
1044
  msgid "Default Value"
1045
  msgstr "Valore di default"
1046
 
@@ -1088,22 +1056,19 @@ msgstr "Tabella (default)"
1088
  msgid "Text"
1089
  msgstr "Testo"
1090
 
1091
- #: core/fields/text.php:75
1092
- #: core/fields/textarea.php:76
1093
  msgid "Formatting"
1094
  msgstr "Formattazione"
1095
 
1096
  #: core/fields/text.php:76
1097
  msgid "Define how to render html tags"
1098
- msgstr "Definisci come renderizzare i tag html"
1099
 
1100
- #: core/fields/text.php:85
1101
- #: core/fields/textarea.php:86
1102
  msgid "None"
1103
  msgstr "Niente"
1104
 
1105
- #: core/fields/text.php:86
1106
- #: core/fields/textarea.php:88
1107
  msgid "HTML"
1108
  msgstr "HTML"
1109
 
@@ -1158,4 +1123,3 @@ msgstr "Crea un gruppo di campi"
1158
  #: core/options_page.php:286
1159
  msgid "Publish"
1160
  msgstr "Pubblica"
1161
-
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
+ "PO-Revision-Date: 2013-03-01 12:15+0100\n"
12
  "Last-Translator: ale <alala@asdasda.it>\n"
13
  "Language-Team: <a.mignogna@asernet.it>\n"
 
 
14
  "X-Poedit-SourceCharset: utf-8\n"
15
+ "Language: it_IT\n"
16
+ "X-Generator: Poedit 1.5.5\n"
17
 
18
+ #: acf.php:289 core/admin/meta_box_options.php:83
 
19
  msgid "Custom Fields"
20
+ msgstr "Advanced Custom Fields"
21
 
22
  #: acf.php:290
23
  msgid "Settings"
39
  msgid "Add Fields to Edit Screens"
40
  msgstr "Aggiungi campi alle schermate di modifica"
41
 
42
+ #: acf.php:505 core/admin/meta_box_location.php:133 core/options_page.php:62
 
 
43
  #: core/options_page.php:74
44
  msgid "Options"
45
  msgstr "Opzioni"
48
  msgid "Customise the edit page"
49
  msgstr "Personalizza la pagina di modifica"
50
 
51
+ #: acf.php:533 core/api.php:503 core/everything_fields.php:202
 
 
52
  #: core/options_page.php:182
53
  msgid "Validation Failed. One or more fields below are required."
54
  msgstr "Validazione fallita. Uno o più campi sono obbligatori."
77
  msgid "No ACF groups selected"
78
  msgstr "Nessun gruppo ACF selezionato"
79
 
80
+ #: core/actions/init.php:21 core/actions/init.php:116
 
81
  #: core/admin/page_acf.php:14
82
  msgid "Advanced Custom Fields"
83
  msgstr "Advanced Custom Fields"
144
 
145
  #: core/actions/init.php:115
146
  msgid "Field&nbsp;Groups"
147
+ msgstr "Gruppo di custom field"
148
 
149
+ #: core/actions/init.php:117 core/fields/flexible_content.php:257
 
150
  msgid "Add New"
151
  msgstr "Aggiungi nuovo"
152
 
178
  msgid "No Field Groups found in Trash"
179
  msgstr "Nessun gruppo di campi trovato nel cestino"
180
 
181
+ #: core/actions/init.php:153 core/actions/init.php:156
 
182
  msgid "Field group updated."
183
  msgstr "Gruppo di campi aggiornato."
184
 
219
  msgid "Title"
220
  msgstr "Titolo"
221
 
222
+ #: core/admin/meta_box_fields.php:17 core/fields/flexible_content.php:245
 
223
  #: core/fields/repeater.php:218
224
  msgid "New Field"
225
  msgstr "Nuovo campo"
228
  msgid "Move to trash. Are you sure?"
229
  msgstr "Sei sicuro di spostarlo nel cestino?"
230
 
231
+ #: core/admin/meta_box_fields.php:50 core/fields/flexible_content.php:309
 
232
  #: core/fields/repeater.php:244
233
  msgid "Field Order"
234
  msgstr "Ordine del campo"
235
 
236
+ #: core/admin/meta_box_fields.php:51 core/admin/meta_box_fields.php:92
237
+ #: core/fields/flexible_content.php:310 core/fields/flexible_content.php:357
238
+ #: core/fields/repeater.php:245 core/fields/repeater.php:292
 
 
 
239
  msgid "Field Label"
240
  msgstr "Etichetta del campo"
241
 
242
+ #: core/admin/meta_box_fields.php:52 core/admin/meta_box_fields.php:108
243
+ #: core/fields/flexible_content.php:311 core/fields/flexible_content.php:373
244
+ #: core/fields/repeater.php:246 core/fields/repeater.php:308
 
 
 
245
  msgid "Field Name"
246
  msgstr "Nome del campo"
247
 
248
+ #: core/admin/meta_box_fields.php:53 core/admin/meta_box_fields.php:123
249
+ #: core/admin/page_settings.php:44 core/fields/flexible_content.php:312
250
+ #: core/fields/flexible_content.php:388 core/fields/repeater.php:247
 
 
 
251
  #: core/fields/repeater.php:323
252
  msgid "Field Type"
253
  msgstr "Tipo del campo"
254
 
255
  #: core/admin/meta_box_fields.php:60
256
+ msgid ""
257
+ "No fields. Click the <strong>+ Add Field</strong> button to create your "
258
+ "first field."
259
+ msgstr ""
260
+ "Non hai inserito nessun custom field. Clicca sul pulsante <strong> + "
261
+ "Aggiungi campo</strong> per creare il tuo primo campo personalizzato."
262
+
263
+ #: core/admin/meta_box_fields.php:71 core/admin/meta_box_fields.php:74
264
+ #: core/fields/flexible_content.php:336 core/fields/flexible_content.php:339
265
+ #: core/fields/repeater.php:270 core/fields/repeater.php:273
266
  msgid "Edit this Field"
267
  msgstr "Modifica questo campo"
268
 
269
+ #: core/admin/meta_box_fields.php:74 core/fields/flexible_content.php:339
 
270
  #: core/fields/repeater.php:273
271
  msgid "Edit"
272
  msgstr "Modifica"
273
 
274
+ #: core/admin/meta_box_fields.php:75 core/fields/flexible_content.php:340
 
275
  #: core/fields/repeater.php:274
276
  msgid "Read documentation for this field"
277
  msgstr "Leggi la documentazione per questo campo"
278
 
279
+ #: core/admin/meta_box_fields.php:75 core/fields/flexible_content.php:340
 
280
  #: core/fields/repeater.php:274
281
  msgid "Docs"
282
  msgstr "Docs"
283
 
284
+ #: core/admin/meta_box_fields.php:76 core/fields/flexible_content.php:341
 
285
  #: core/fields/repeater.php:275
286
  msgid "Duplicate this Field"
287
  msgstr "Duplica questo campo"
288
 
289
+ #: core/admin/meta_box_fields.php:76 core/fields/flexible_content.php:341
 
290
  #: core/fields/repeater.php:275
291
  msgid "Duplicate"
292
  msgstr "Duplica"
293
 
294
+ #: core/admin/meta_box_fields.php:77 core/fields/flexible_content.php:342
 
295
  #: core/fields/repeater.php:276
296
  msgid "Delete this Field"
297
  msgstr "Cancella questo campo"
298
 
299
+ #: core/admin/meta_box_fields.php:77 core/fields/flexible_content.php:258
300
+ #: core/fields/flexible_content.php:342 core/fields/repeater.php:276
 
 
301
  msgid "Delete"
302
  msgstr "Cancella"
303
 
304
+ #: core/admin/meta_box_fields.php:93 core/fields/flexible_content.php:358
 
305
  #: core/fields/repeater.php:293
306
  msgid "This is the name which will appear on the EDIT page"
307
  msgstr "Questo è il nome che apparirà nella pagina di modifica"
308
 
309
+ #: core/admin/meta_box_fields.php:109 core/fields/flexible_content.php:374
 
310
  #: core/fields/repeater.php:309
311
  msgid "Single word, no spaces. Underscores and dashes allowed"
312
  msgstr "Una parola, senza spazi. \"_\" e trattini permessi"
317
 
318
  #: core/admin/meta_box_fields.php:137
319
  msgid "Instructions for authors. Shown when submitting data"
320
+ msgstr ""
321
+ "Istruzioni per gli autori. Vengono visualizzate al di sopra del custom field"
322
 
323
  #: core/admin/meta_box_fields.php:149
324
  msgid "Required?"
325
  msgstr "Obbligatorio?"
326
 
327
+ #: core/admin/meta_box_fields.php:172 core/fields/flexible_content.php:408
 
328
  #: core/fields/repeater.php:343
329
  msgid "Save Field"
330
  msgstr "Salva campo"
331
 
332
+ #: core/admin/meta_box_fields.php:177 core/fields/flexible_content.php:413
 
333
  #: core/fields/repeater.php:348
334
  msgid "Close Field"
335
  msgstr "Chiudi campo"
336
 
337
+ #: core/admin/meta_box_fields.php:190 core/fields/flexible_content.php:427
 
338
  #: core/fields/repeater.php:363
339
  msgid "Drag and drop to reorder"
340
  msgstr "Trascina e rilascia per riordinare"
345
 
346
  #: core/admin/meta_box_location.php:25
347
  msgid "Rules"
348
+ msgstr "Condizioni"
349
 
350
  #: core/admin/meta_box_location.php:26
351
+ msgid ""
352
+ "Create a set of rules to determine which edit screens will use these "
353
+ "advanced custom fields"
354
+ msgstr ""
355
+ "Crea una o pi&ugrave; condizioni per determinare quali post type faranno uso "
356
+ "di questi campi personalizzati"
357
 
358
+ #: core/admin/meta_box_location.php:37 core/fields/wysiwyg.php:142
 
359
  msgid "Basic"
360
  msgstr "Basic"
361
 
362
+ #: core/admin/meta_box_location.php:38 core/fields/page_link.php:194
363
+ #: core/fields/post_object.php:209 core/fields/relationship.php:246
 
 
364
  msgid "Post Type"
365
  msgstr "Post Type"
366
 
424
  msgid "Media (Edit)"
425
  msgstr "Media (Aggiungi/Modifica)"
426
 
427
+ #: core/admin/meta_box_location.php:64 core/admin/page_settings.php:92
 
428
  msgid "Options Page"
429
  msgstr "Pagina delle opzioni"
430
 
438
 
439
  #: core/admin/meta_box_location.php:111
440
  msgid "match"
441
+ msgstr "combina le condizioni di sopra con "
442
 
443
  #: core/admin/meta_box_location.php:117
444
  msgid "all"
445
+ msgstr "AND"
446
 
447
  #: core/admin/meta_box_location.php:118
448
  msgid "any"
449
+ msgstr "OR"
450
 
451
  #: core/admin/meta_box_location.php:121
452
  msgid "of the above"
453
+ msgstr "operatore logico"
454
 
455
  #: core/admin/meta_box_location.php:134
456
  msgid "Unlock options add-on with an activation code"
497
  msgstr "Deseleziona gli elementi per nasconderli nella pagina di modifica"
498
 
499
  #: core/admin/meta_box_options.php:72
500
+ msgid ""
501
+ "If multiple ACF groups appear on an edit page, the first ACF group's options "
502
+ "will be used. The first ACF group is the one with the lowest order number."
503
+ msgstr ""
504
+ "SE più gruppi ACF appaiono in una pagina di modifica, verrano utilizzate le "
505
+ "opzioni del primo gruppo ACF. Il primo gruppo è quello con il numero "
506
+ "d'oridne pià basso."
507
 
508
  #: core/admin/meta_box_options.php:82
509
  msgid "Content Editor"
538
  msgstr "Risorse"
539
 
540
  #: core/admin/page_acf.php:20
541
+ msgid ""
542
+ "Read documentation, learn the functions and find some tips &amp; tricks for "
543
+ "your next web project."
544
+ msgstr ""
545
+ "Leggi la documentazione, impara le funzioni e scopri alcuni trucchi per il "
546
+ "tuo prossimo progetto web."
547
 
548
  #: core/admin/page_acf.php:21
549
  msgid "View the ACF website"
581
  msgid "Repeater Field"
582
  msgstr "Repeater Field"
583
 
584
+ #: core/admin/page_settings.php:53 core/admin/page_settings.php:73
 
585
  #: core/admin/page_settings.php:93
586
  msgid "Active"
587
  msgstr "Attivo"
588
 
589
+ #: core/admin/page_settings.php:53 core/admin/page_settings.php:73
 
590
  #: core/admin/page_settings.php:93
591
  msgid "Inactive"
592
  msgstr "Inattivo"
596
  msgstr "Flexible Content Field"
597
 
598
  #: core/admin/page_settings.php:115
599
+ msgid ""
600
+ "Add-ons can be unlocked by purchasing a license key. Each key can be used on "
601
+ "multiple sites."
602
+ msgstr ""
603
+ "Gli Add-ons possono essere sbloccati comprando una lienza. Ogni chiave può "
604
+ "essere usata su più siti."
605
 
606
  #: core/admin/page_settings.php:115
607
  msgid "Find Add-ons"
612
  msgstr "Esporta i gruppi di campi in XML"
613
 
614
  #: core/admin/page_settings.php:166
615
+ msgid ""
616
+ "ACF will create a .xml export file which is compatible with the native WP "
617
+ "import plugin."
618
+ msgstr ""
619
+ "ACF creerà un file di export XML che è compatibile con tutti i pulugin di "
620
+ "importazione nativi."
621
 
622
  #: core/admin/page_settings.php:169
623
  msgid "Export XML"
667
  msgid "Create PHP"
668
  msgstr "Genera PHP"
669
 
670
+ #: core/admin/page_settings.php:242 core/admin/page_settings.php:270
 
671
  msgid "Register Field Groups with PHP"
672
  msgstr "Registra i gruppi di campi con PHP"
673
 
674
+ #: core/admin/page_settings.php:244 core/admin/page_settings.php:272
 
675
  msgid "Copy the PHP code generated"
676
  msgstr "Copia il codice PHP generato"
677
 
678
+ #: core/admin/page_settings.php:245 core/admin/page_settings.php:273
 
679
  msgid "Paste into your functions.php file"
680
  msgstr "Incolla nel tuo file functions.php"
681
 
682
+ #: core/admin/page_settings.php:246 core/admin/page_settings.php:274
 
683
  msgid "To activate any Add-ons, edit and use the code in the first few lines."
684
+ msgstr ""
685
+ "Per attivare qualsiasi add-ons, modifica e usa il codice nelle prime linee."
686
 
687
  #: core/admin/page_settings.php:267
688
  msgid "Back to settings"
692
  msgid ""
693
  "/**\n"
694
  " * Activate Add-ons\n"
695
+ " * Here you can enter your activation codes to unlock Add-ons to use in your "
696
+ "theme. \n"
697
+ " * Since all activation codes are multi-site licenses, you are allowed to "
698
+ "include your key in premium themes. \n"
699
+ " * Use the commented out code to update the database with your activation "
700
+ "code. \n"
701
+ " * You may place this code inside an IF statement that only runs on theme "
702
+ "activation.\n"
703
  " */"
704
  msgstr ""
705
  "/**\n"
706
  " * Attiva Add-ons\n"
707
+ " * Qui puoi digitare il tuo codice di attivazione per sbloccare gli add-ons "
708
+ "da utilizzare nel tuo tema. \n"
709
+ " * Visto che tutti i codici d'attivazione sono multisito, puoi includere la "
710
+ "tua chiave nei temi premium. \n"
711
+ " * Usa il codice commentato per aggiornare il database con il tuo codice di "
712
+ "attivazione. \n"
713
+ " * Puoi inserire questo codice all'interno di una condizione IF relativa "
714
+ "all'attivazione del tema.\n"
715
  " */"
716
 
717
  #: core/admin/page_settings.php:308
718
  msgid ""
719
  "/**\n"
720
  " * Register field groups\n"
721
+ " * The register_field_group function accepts 1 array which holds the "
722
+ "relevant data to register a field group\n"
723
+ " * You may edit the array as you see fit. However, this may result in errors "
724
+ "if the array is not compatible with ACF\n"
725
  " * This code must run every time the functions.php file is read\n"
726
  " */"
727
  msgstr ""
728
  "/**\n"
729
  " * Registra i gruppi di campi\n"
730
+ " * La funzione register_field_group function accetta 1 array che contiene le "
731
+ "informazioni necessarie per registrare un gruppo di campi\n"
732
+ " * Puoi modificare questo array. Tuttavia, potresti generare degli errori se "
733
+ "l'array non è compatibile con ACF\n"
734
+ " * Questo codice deve essere eseguito ogni qual volta viene letto il file "
735
+ "functions.php\n"
736
  " */"
737
 
738
  #: core/admin/page_settings.php:336
743
  msgid "Checkbox"
744
  msgstr "Checkbox"
745
 
746
+ #: core/fields/checkbox.php:44 core/fields/radio.php:45
 
747
  #: core/fields/select.php:50
748
  msgid "No choices to choose from"
749
  msgstr "Nessuna opzione da scegliere da"
750
 
751
+ #: core/fields/checkbox.php:102 core/fields/radio.php:114
 
752
  #: core/fields/select.php:164
753
  msgid "Choices"
754
  msgstr "Opzioni"
755
 
756
+ #: core/fields/checkbox.php:103 core/fields/radio.php:115
 
757
  #: core/fields/select.php:165
758
  msgid "Enter your choices one per line"
759
  msgstr "Inserisci una opzione per linea"
760
 
761
+ #: core/fields/checkbox.php:105 core/fields/radio.php:117
 
762
  #: core/fields/select.php:167
763
  msgid "Red"
764
  msgstr "Rosso"
765
 
766
+ #: core/fields/checkbox.php:106 core/fields/radio.php:118
 
767
  #: core/fields/select.php:168
768
  msgid "Blue"
769
  msgstr "Blu"
770
 
771
+ #: core/fields/checkbox.php:108 core/fields/radio.php:120
 
772
  #: core/fields/select.php:170
773
  msgid "red : Red"
774
  msgstr "rosso : Rosso"
775
 
776
+ #: core/fields/checkbox.php:109 core/fields/radio.php:121
 
777
  #: core/fields/select.php:171
778
  msgid "blue : Blue"
779
  msgstr "blu : Blu"
810
  msgid "Add File"
811
  msgstr "Aggiungi file"
812
 
813
+ #: core/fields/file.php:194 core/fields/image.php:177
 
814
  msgid "Return Value"
815
  msgstr "Restituisci valore"
816
 
830
  msgid "Flexible Content"
831
  msgstr "Contenuto flessibile"
832
 
833
+ #: core/fields/flexible_content.php:38 core/fields/flexible_content.php:218
834
+ #: core/fields/repeater.php:65 core/fields/repeater.php:213
 
 
835
  msgid "+ Add Row"
836
  msgstr "+ Aggiungi riga"
837
 
838
+ #: core/fields/flexible_content.php:254 core/fields/radio.php:144
 
839
  #: core/fields/repeater.php:386
840
  msgid "Layout"
841
  msgstr "Layout"
872
  msgid "Table"
873
  msgstr "Tabella"
874
 
875
+ #: core/fields/flexible_content.php:296 core/fields/repeater.php:397
 
876
  msgid "Row"
877
  msgstr "Riga"
878
 
879
+ #: core/fields/flexible_content.php:320 core/fields/repeater.php:255
880
+ msgid ""
881
+ "No fields. Click the \"+ Add Sub Field button\" to create your first field."
882
+ msgstr ""
883
+ "Nessun campo. Clicca su \"+ Aggiungi un campo\" per creare il tuo primo "
884
+ "campo."
885
 
886
+ #: core/fields/flexible_content.php:413 core/fields/repeater.php:348
 
887
  msgid "Close Sub Field"
888
  msgstr "Chiudi il campo"
889
 
890
+ #: core/fields/flexible_content.php:428 core/fields/repeater.php:364
 
891
  msgid "+ Add Sub Field"
892
  msgstr "+ Aggiungi campo"
893
 
894
+ #: core/fields/flexible_content.php:435 core/fields/repeater.php:405
 
895
  msgid "Button Label"
896
  msgstr "Etichetta del bottone"
897
 
931
  msgid "Large"
932
  msgstr "Grande"
933
 
934
+ #: core/fields/image.php:209 core/fields/wysiwyg.php:141
 
935
  msgid "Full"
936
  msgstr "Dimensione reale"
937
 
951
  msgid "Page Link"
952
  msgstr "Link a pagina"
953
 
954
+ #: core/fields/page_link.php:71 core/fields/post_object.php:64
 
955
  #: core/fields/select.php:21
956
  msgid "Select"
957
+ msgstr "Select HTML"
958
 
959
  #: core/fields/page_link.php:195
960
  msgid ""
962
  "\t\t\t\tTip: deselect all post types to show all post type's posts"
963
  msgstr ""
964
  "Filtra i contenuti selezionato un tipo di contenuto<br />\n"
965
+ "\t\t\t\tTrucco: deleziona tutti i tipi di contenuto per visualizzarne tutti "
966
+ "i tipi"
967
 
968
+ #: core/fields/page_link.php:200 core/fields/post_object.php:213
969
+ #: core/fields/post_object.php:237 core/fields/relationship.php:250
 
 
970
  #: core/fields/relationship.php:301
971
  msgid "All"
972
  msgstr "Tutti"
973
 
974
+ #: core/fields/page_link.php:223 core/fields/post_object.php:281
 
975
  #: core/fields/select.php:194
976
  msgid "Allow Null?"
977
  msgstr "Campo nullo permesso?"
978
 
979
+ #: core/fields/page_link.php:232 core/fields/page_link.php:251
980
+ #: core/fields/post_object.php:290 core/fields/post_object.php:309
981
+ #: core/fields/select.php:203 core/fields/select.php:222
 
 
 
982
  #: core/fields/wysiwyg.php:160
983
  msgid "Yes"
984
  msgstr "Si"
985
 
986
+ #: core/fields/page_link.php:233 core/fields/page_link.php:252
987
+ #: core/fields/post_object.php:291 core/fields/post_object.php:310
988
+ #: core/fields/select.php:204 core/fields/select.php:223
 
 
 
989
  #: core/fields/wysiwyg.php:161
990
  msgid "No"
991
  msgstr "No"
992
 
993
+ #: core/fields/page_link.php:242 core/fields/post_object.php:300
 
994
  #: core/fields/select.php:213
995
  msgid "Select multiple values?"
996
  msgstr "E' possibile selezionare più valori?"
999
  msgid "Post Object"
1000
  msgstr "Post Object"
1001
 
1002
+ #: core/fields/post_object.php:231 core/fields/relationship.php:295
 
1003
  msgid "Filter from Taxonomy"
1004
  msgstr "Filtro da Tassonomia"
1005
 
1007
  msgid "Radio Button"
1008
  msgstr "Radio Button"
1009
 
1010
+ #: core/fields/radio.php:130 core/fields/select.php:180
1011
+ #: core/fields/text.php:61 core/fields/textarea.php:62
 
 
1012
  msgid "Default Value"
1013
  msgstr "Valore di default"
1014
 
1056
  msgid "Text"
1057
  msgstr "Testo"
1058
 
1059
+ #: core/fields/text.php:75 core/fields/textarea.php:76
 
1060
  msgid "Formatting"
1061
  msgstr "Formattazione"
1062
 
1063
  #: core/fields/text.php:76
1064
  msgid "Define how to render html tags"
1065
+ msgstr "Definisci come gestire i tag html"
1066
 
1067
+ #: core/fields/text.php:85 core/fields/textarea.php:86
 
1068
  msgid "None"
1069
  msgstr "Niente"
1070
 
1071
+ #: core/fields/text.php:86 core/fields/textarea.php:88
 
1072
  msgid "HTML"
1073
  msgstr "HTML"
1074
 
1123
  #: core/options_page.php:286
1124
  msgid "Publish"
1125
  msgstr "Pubblica"
 
readme.txt CHANGED
@@ -1,42 +1,42 @@
1
  === Advanced Custom Fields ===
2
  Contributors: Elliot Condon
3
  Tags: custom, field, custom field, advanced, simple fields, magic fields, more fields, repeater, matrix, post, type, text, textarea, file, image, edit, admin
4
- Requires at least: 3.0.0
5
- Tested up to: 3.5.0
6
  License: GPLv2 or later
7
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
 
9
- Fully customise WordPress edit screens with powerful fields. Boasting a professional interface and a powerfull API, it’s a must have for any web developer working with WordPress.Field types include: Wysiwyg, text, textarea, image, file, select, checkbox, page link, post object, date picker, color picker and more!
10
 
11
  == Description ==
12
 
13
- Advanced Custom Fields is the perfect solution for any wordpress website which needs more flexible data like other Content Management Systems.
14
 
15
- * Visually create your Fields
16
- * Select from multiple input types (text, textarea, wysiwyg, image, file, page link, post object, relationship, select, checkbox, radio buttons, date picker, true / false, repeater, flexible content, gallery and more to come!)
17
  * Assign your fields to multiple edit pages (via custom location rules)
18
- * Easily load data through a simple and friendly API
19
  * Uses the native WordPress custom post type for ease of use and fast processing
20
- * Uses the native WordPress metadata for ease of use and fast processing
21
 
22
  = Field Types =
23
- * Tab (Group fields into tabs)
24
- * Text (type text, api returns text)
25
- * Text Area (type text, api returns text with `<br />` tags)
26
- * WYSIWYG (a wordpress wysiwyg editor, api returns html)
27
- * Image (upload an image, api returns the url)
28
- * File (upload a file, api returns the url)
29
- * Select (drop down list of choices, api returns chosen item)
30
- * Checkbox (tick for a list of choices, api returns array of choices)
31
- * Page Link (select 1 or more page, post or custom post types, api returns the url)
32
- * Post Object (select 1 or more page, post or custom post types, api returns post objects)
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
  * Relationship (select and order post objects with a tidy interface)
36
  * Color Picker (Farbtastic!)
37
- * Repeater (ability to create repeatable blocks of fields!)
38
- * Flexible Content (ability to create flexible blocks of fields!)
39
- * Gallery (Add, edit and order multiple images in 1 simple field)
40
 
41
  = Tested on =
42
  * Mac Firefox :)
@@ -72,7 +72,7 @@ Your votes really make a difference! Thanks.
72
 
73
  == Frequently Asked Questions ==
74
 
75
- = Q. I have a question =
76
  A. Chances are, someone else has asked it. Check out the support forum at:
77
  http://support.advancedcustomfields.com/
78
 
@@ -90,6 +90,29 @@ http://support.advancedcustomfields.com/
90
 
91
  == Changelog ==
92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  = 3.5.7.2 =
94
  * [Fixed] Fix fields not showing on attachment edit page in WP 3.5 - http://support.advancedcustomfields.com/discussion/4261/after-upgrading-to-3-5-acf-fields-assigned-to-show-on-attachments-media-edit-are-not-showing
95
  * [Fixed] Fix sub repeater css bug - http://support.advancedcustomfields.com/discussion/4361/repeater-add-button-inappropriately-disabled
@@ -697,4 +720,4 @@ http://support.advancedcustomfields.com/
697
  * Editor is broken in WordPress 3.3
698
 
699
  = 2.1.4 =
700
- * Adds post_id column back into acf_values
1
  === Advanced Custom Fields ===
2
  Contributors: Elliot Condon
3
  Tags: custom, field, custom field, advanced, simple fields, magic fields, more fields, repeater, matrix, post, type, text, textarea, file, image, edit, admin
4
+ Requires at least: 3.3.0
5
+ Tested up to: 3.5.1
6
  License: GPLv2 or later
7
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
 
9
+ Fully customise WordPress edit screens with powerful fields. Boasting a professional interface and a powerful API, it’s a must-have for any web developer working with WordPress. Field types include: WYSIWYG, text, textarea, image, file, select, checkbox, page link, post object, date picker, color picker, and more!
10
 
11
  == Description ==
12
 
13
+ Advanced Custom Fields is the perfect solution for any WordPress website that needs more flexible data types, like other content management systems.
14
 
15
+ * Visually create your fields
16
+ * Select from multiple input types (text, textarea, WYSIWYG, image, file, page link, post object, relationship, select, checkbox, radio buttons, date picker, true / false, repeater, flexible content, gallery, and more to come!)
17
  * Assign your fields to multiple edit pages (via custom location rules)
18
+ * Easily load data through a simple, friendly API
19
  * Uses the native WordPress custom post type for ease of use and fast processing
20
+ * Uses native WordPress metadata for ease of use and fast processing
21
 
22
  = Field Types =
23
+ * Tab (group fields into tabs)
24
+ * Text (enter text, API returns the text)
25
+ * Text Area (enter text, API returns the text with `<br />` tags)
26
+ * WYSIWYG (the WordPress WYSIWYG editor, API returns HTML)
27
+ * Image (upload an image, API returns its URL)
28
+ * File (upload a file, API returns its URL)
29
+ * Select (drop-down list of choices, API returns the chosen item)
30
+ * Checkbox (check for a list of choices, API returns an array of choices)
31
+ * Page Link (select 1 or more page, post, or custom post type, API returns the URLs)
32
+ * Post Object (select 1 or more page, post, or custom post type, API returns post objects)
33
+ * Date Picker (jQuery date picker, options for formatting, API returns string)
34
+ * True / False (check box with message, API returns true or false)
35
  * Relationship (select and order post objects with a tidy interface)
36
  * Color Picker (Farbtastic!)
37
+ * Repeater (ability to create repeatable blocks of fields)
38
+ * Flexible Content (ability to create flexible blocks of fields)
39
+ * Gallery (add, edit, and order multiple images in 1 simple field)
40
 
41
  = Tested on =
42
  * Mac Firefox :)
72
 
73
  == Frequently Asked Questions ==
74
 
75
+ = Q. I have a question. =
76
  A. Chances are, someone else has asked it. Check out the support forum at:
77
  http://support.advancedcustomfields.com/
78
 
90
 
91
  == Changelog ==
92
 
93
+ = 3.5.8.2 =
94
+ * [Fixed] Fix field data not saving caused by Types 1.2
95
+ * [Fixed] Fix featured image issue - http://support.advancedcustomfields.com/discussion/5032/featured-image-broken
96
+ * [Fixed] Fix WP 3.5 uploader not attaching images to posts - http://support.advancedcustomfields.com/discussion/4960/image-photo039s-uploaded-through-image-field-not-attached-to-post
97
+ * [Added] Add filter 'acf_load_field' for sub field - http://support.advancedcustomfields.com/discussion/4153/select-an-image-from-a-drop-down-list
98
+ * [Fixed] Fix WYSWYG field showing the upload image button in full screen - http://support.advancedcustomfields.com/discussion/4981/media-button-on-fullscreen-wysiwyg-editor
99
+
100
+ = 3.5.8.1 =
101
+ * [Fixed] Fix PHP error in text / textarea fields
102
+
103
+ = 3.5.8 =
104
+ * [Fixed] Fix bug preventing fields to load on user / taxonomy front end form - http://support.advancedcustomfields.com/discussion/4393/front-end-user-profile-field-form-causes-referenceerror
105
+ * [Added] Added 'acf/fields/wysiwyg/toolbars' filter to customize WYSIWYG toolbars - http://support.advancedcustomfields.com/discussion/2205/can-we-change-wysiwyg-basic-editor-buttons
106
+ * [Fixed] Fix acf_load_filters as they are not working! - http://support.advancedcustomfields.com/discussion/comment/12770#Comment_12770
107
+ * [Added] Clean up wp_options after term delete - http://support.advancedcustomfields.com/discussion/4396/delete-taxonomy-term-custom-fields-after-term-delete
108
+ * [Fixed] Fix location rule - category / taxonomy on new post - http://support.advancedcustomfields.com/discussion/3635/show-custom-fields-on-post-adding
109
+ * [Added] Added 'acf/create_field' action for third party usage - docs to come soon
110
+ * [Added] Add support for new media uploader in WP 3.5!
111
+ * [Fixed] Fix conditional logic error - http://support.advancedcustomfields.com/discussion/4502/conditional-logic-script-output-causes-events-to-fire-multiple-times
112
+ * [Fixed] Fix Uploader not working on taxonomy edit screens - http://support.advancedcustomfields.com/discussion/4536/media-upload-button-for-wysiwyg-does-not-work-when-used-on-a-taxonomy-term
113
+ * [Added] Add data cleanup after removing a repeater / flexible content row - http://support.advancedcustomfields.com/discussion/1994/deleting-single-repeater-fields-does-not-remove-entry-from-database
114
+
115
+
116
  = 3.5.7.2 =
117
  * [Fixed] Fix fields not showing on attachment edit page in WP 3.5 - http://support.advancedcustomfields.com/discussion/4261/after-upgrading-to-3-5-acf-fields-assigned-to-show-on-attachments-media-edit-are-not-showing
118
  * [Fixed] Fix sub repeater css bug - http://support.advancedcustomfields.com/discussion/4361/repeater-add-button-inappropriately-disabled
720
  * Editor is broken in WordPress 3.3
721
 
722
  = 2.1.4 =
723
+ * Adds post_id column back into acf_values