Advanced Custom Fields - Version 3.4.0

Version Description

  • [Fixed] Fix validation rules for multiple select - http://support.advancedcustomfields.com/discussion/2858/multiple-select-validation-doesnt-work
  • [Added] Add support for options page toggle open / close metabox
  • [Fixed] Fix special characters in registered options page - http://support.advancedcustomfields.com/discussion/comment/7500#Comment_7500
  • [Updated] CSS tweak for relationship field - http://support.advancedcustomfields.com/discussion/2877/relation-field-with-multiple-post-types-css-styling-problem-
  • [Fixed] Fix datepicker blank option bug - http://support.advancedcustomfields.com/discussion/2896/3-3-9-date-picker-not-popping-up
  • [Added] Add new function get_field_object to API - http://support.advancedcustomfields.com/discussion/290/field-label-on-frontend
  • [Fixed] Fix field groups not showing for Shopp add new product - http://support.advancedcustomfields.com/discussion/3005/acf-shopp
  • [Fixed] Move acf.data outside of the doc.ready in input-ajax.js
  • [Fixed] Fix IE7 JS bug - http://support.advancedcustomfields.com/discussion/3020/ie7-fix-on-is_clone_field-function
  • [Fixed] Fix relationship search - Only search title, not content
  • [Updated] Update function update_field to use field_key or field_name
  • [Added] Add field group screen option to show field keys (to use in save_field / update field)
  • [Added] Add actions on all save events (action is called "acf_save_post", 1 param
Download this release

Release Info

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

Code changes from version 3.3.9 to 3.4.0

acf.php CHANGED
@@ -3,7 +3,7 @@
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.3.9
7
  Author: Elliot Condon
8
  Author URI: http://www.elliotcondon.com/
9
  License: GPL
@@ -47,7 +47,7 @@ class Acf
47
  // vars
48
  $this->path = plugin_dir_path(__FILE__);
49
  $this->dir = plugins_url('',__FILE__);
50
- $this->version = '3.3.9';
51
  $this->upgrade_version = '3.3.3'; // this is the latest version which requires an upgrade
52
  $this->cache = array(); // basic array cache to hold data throughout the page load
53
 
@@ -67,9 +67,13 @@ class Acf
67
 
68
  add_action('admin_menu', array($this,'admin_menu'));
69
  add_action('admin_head', array($this,'admin_head'));
 
70
 
 
 
71
  add_action('wp_ajax_get_input_metabox_ids', array($this, 'get_input_metabox_ids'));
72
-
 
73
 
74
  return true;
75
  }
@@ -908,16 +912,28 @@ class Acf
908
  // overrides
909
  if(isset($_POST))
910
  {
911
- if(isset($_POST['post_id']) && $_POST['post_id'] != 'false') $overrides['post_id'] = $_POST['post_id'];
912
- if(isset($_POST['page_template']) && $_POST['page_template'] != 'false') $overrides['page_template'] = $_POST['page_template'];
913
- if(isset($_POST['page_parent']) && $_POST['page_parent'] != 'false') $overrides['page_parent'] = $_POST['page_parent'];
914
- if(isset($_POST['page_type']) && $_POST['page_type'] != 'false') $overrides['page_type'] = $_POST['page_type'];
915
- if(isset($_POST['page']) && $_POST['page'] != 'false') $overrides['page'] = $_POST['page'];
916
- if(isset($_POST['post']) && $_POST['post'] != 'false') $overrides['post'] = $_POST['post'];
917
- if(isset($_POST['post_category']) && $_POST['post_category'] != 'false') $overrides['post_category'] = $_POST['post_category'];
918
- if(isset($_POST['post_format']) && $_POST['post_format'] != 'false') $overrides['post_format'] = $_POST['post_format'];
919
- if(isset($_POST['taxonomy']) && $_POST['taxonomy'] != 'false') $overrides['taxonomy'] = $_POST['taxonomy'];
920
- if(isset($_POST['lang']) && $_POST['lang'] != 'false') $overrides['lang'] = $_POST['lang'];
 
 
 
 
 
 
 
 
 
 
 
 
921
  }
922
 
923
 
@@ -1029,6 +1045,7 @@ class Acf
1029
  'ef_taxonomy',
1030
  'ef_user',
1031
  'ef_media',
 
1032
  );
1033
 
1034
  if( !in_array($rule['param'], $exceptions) )
@@ -1298,11 +1315,11 @@ class Acf
1298
  // value has changed in 3.2.6 to a sanitized string
1299
  if( strpos( $rule['value'] ,'options-') === false )
1300
  {
1301
- $rule['value'] = 'options-' . sanitize_title_with_dashes( $rule['value'] );
1302
  }
1303
 
1304
  // generate the page title to match against
1305
- $page_title = 'options-' . sanitize_title_with_dashes( get_admin_page_title() );
1306
 
1307
  if($rule['operator'] == "==")
1308
  {
@@ -1678,6 +1695,42 @@ class Acf
1678
  }
1679
 
1680
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1681
  /*
1682
  * get_post_language
1683
  *
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.4.0
7
  Author: Elliot Condon
8
  Author URI: http://www.elliotcondon.com/
9
  License: GPL
47
  // vars
48
  $this->path = plugin_dir_path(__FILE__);
49
  $this->dir = plugins_url('',__FILE__);
50
+ $this->version = '3.4.0';
51
  $this->upgrade_version = '3.3.3'; // this is the latest version which requires an upgrade
52
  $this->cache = array(); // basic array cache to hold data throughout the page load
53
 
67
 
68
  add_action('admin_menu', array($this,'admin_menu'));
69
  add_action('admin_head', array($this,'admin_head'));
70
+ add_action('acf_save_post', array($this, 'acf_save_post'), 1); // save post, called from many places (api, input, everything, options)
71
 
72
+
73
+ // ajax
74
  add_action('wp_ajax_get_input_metabox_ids', array($this, 'get_input_metabox_ids'));
75
+
76
+
77
 
78
  return true;
79
  }
912
  // overrides
913
  if(isset($_POST))
914
  {
915
+ $override_keys = array(
916
+ 'post_id',
917
+ 'post_type',
918
+ 'page_template',
919
+ 'page_parent',
920
+ 'page_type',
921
+ 'page',
922
+ 'post',
923
+ 'post_category',
924
+ 'post_format',
925
+ 'taxonomy',
926
+ 'lang',
927
+ );
928
+
929
+ foreach( $override_keys as $override_key )
930
+ {
931
+ if( isset($_POST[ $override_key ]) && $_POST[ $override_key ] != 'false' )
932
+ {
933
+ $overrides[ $override_key ] = $_POST[ $override_key ];
934
+ }
935
+ }
936
+
937
  }
938
 
939
 
1045
  'ef_taxonomy',
1046
  'ef_user',
1047
  'ef_media',
1048
+ 'post_type',
1049
  );
1050
 
1051
  if( !in_array($rule['param'], $exceptions) )
1315
  // value has changed in 3.2.6 to a sanitized string
1316
  if( strpos( $rule['value'] ,'options-') === false )
1317
  {
1318
+ $rule['value'] = 'options-' . sanitize_title( $rule['value'] );
1319
  }
1320
 
1321
  // generate the page title to match against
1322
+ $page_title = 'options-' . sanitize_title( get_admin_page_title() );
1323
 
1324
  if($rule['operator'] == "==")
1325
  {
1695
  }
1696
 
1697
 
1698
+ /*
1699
+ * acf_save_post
1700
+ *
1701
+ * @description:
1702
+ * @created: 4/09/12
1703
+ */
1704
+
1705
+ function acf_save_post( $post_id )
1706
+ {
1707
+ // vars
1708
+ $fields = false;
1709
+
1710
+
1711
+ // load from post
1712
+ if( isset($_POST['fields']) )
1713
+ {
1714
+ $fields = $_POST['fields'];
1715
+ }
1716
+
1717
+
1718
+ // loop through and save
1719
+ if($fields)
1720
+ {
1721
+ foreach($fields as $key => $value)
1722
+ {
1723
+ // get field
1724
+ $field = $this->get_acf_field($key);
1725
+
1726
+ $this->update_value($post_id, $field, $value);
1727
+ }
1728
+ // foreach($fields as $key => $value)
1729
+ }
1730
+ // if($fields)
1731
+ }
1732
+
1733
+
1734
  /*
1735
  * get_post_language
1736
  *
core/api.php CHANGED
@@ -398,7 +398,7 @@ function register_options_page($title = "")
398
  {
399
  $GLOBALS['acf_register_options_page'][] = array(
400
  'title' => $title,
401
- 'slug' => 'options-' . sanitize_title_with_dashes( $title ),
402
  );
403
  }
404
 
@@ -489,22 +489,11 @@ function acf_form_head()
489
  // run database save first
490
  if(isset($_POST) && isset($_POST['acf_save']))
491
  {
 
492
  $post_id = $_POST['post_id'];
493
 
494
- // save fields
495
- $fields = $_POST['fields'];
496
-
497
- if($fields)
498
- {
499
- foreach($fields as $key => $value)
500
- {
501
- // get field
502
- $field = $acf->get_acf_field($key);
503
 
504
- $acf->update_value($post_id, $field, $value);
505
- }
506
- }
507
-
508
 
509
  // redirect
510
  if(isset($_POST['return']))
@@ -676,7 +665,7 @@ function acf_form($options = null)
676
  *
677
  *-------------------------------------------------------------------------------------*/
678
 
679
- function update_field($field_name, $value, $post_id = false)
680
  {
681
  global $post, $acf;
682
 
@@ -691,31 +680,31 @@ function update_field($field_name, $value, $post_id = false)
691
  {
692
  $post_id = "options";
693
  }
694
-
695
-
696
- // get value
697
- $field_key = "";
698
- if( is_numeric($post_id) )
699
- {
700
- $field_key = get_post_meta($post_id, '_' . $field_name, true);
701
- }
702
- else
703
  {
704
- $field_key = get_option('_' . $post_id . '_' . $field_name);
 
 
 
 
 
 
 
 
705
  }
706
-
707
 
708
- // create default field to save the data as plain text
709
- $field = array(
710
- 'type' => 'text',
711
- 'name' => $field_name,
712
- 'key' => ''
713
- );
714
 
715
- if($field_key != "")
716
- {
717
- // we can load the field properly!
718
- $field = $acf->get_acf_field($field_key);
 
 
 
 
719
  }
720
 
721
 
@@ -762,10 +751,107 @@ function update_field($field_name, $value, $post_id = false)
762
 
763
  }
764
 
 
 
765
 
 
766
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
767
 
768
- $acf->update_value($post_id, $field, $value);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
769
  }
770
 
771
 
398
  {
399
  $GLOBALS['acf_register_options_page'][] = array(
400
  'title' => $title,
401
+ 'slug' => 'options-' . sanitize_title( $title ),
402
  );
403
  }
404
 
489
  // run database save first
490
  if(isset($_POST) && isset($_POST['acf_save']))
491
  {
492
+ // $post_id to save against
493
  $post_id = $_POST['post_id'];
494
 
495
+ do_action('acf_save_post', $post_id);
 
 
 
 
 
 
 
 
496
 
 
 
 
 
497
 
498
  // redirect
499
  if(isset($_POST['return']))
665
  *
666
  *-------------------------------------------------------------------------------------*/
667
 
668
+ function update_field($field_key, $value, $post_id = false)
669
  {
670
  global $post, $acf;
671
 
680
  {
681
  $post_id = "options";
682
  }
683
+
684
+
685
+ // is $field_name a name? pre 3.4.0
686
+ if( strpos($field_key, "field_") === false )
 
 
 
 
 
687
  {
688
+ // get field key
689
+ if( is_numeric($post_id) )
690
+ {
691
+ $field_key = get_post_meta($post_id, '_' . $field_key, true);
692
+ }
693
+ else
694
+ {
695
+ $field_key = get_option('_' . $post_id . '_' . $field_key);
696
+ }
697
  }
 
698
 
 
 
 
 
 
 
699
 
700
+ // get field
701
+ $field = $acf->get_acf_field($field_key);
702
+
703
+
704
+ // backup if no field was found, save as a text field
705
+ if( !$field )
706
+ {
707
+ return false;
708
  }
709
 
710
 
751
 
752
  }
753
 
754
+
755
+ $acf->update_value($post_id, $field, $value);
756
 
757
+ return true;
758
 
759
+ }
760
+
761
+
762
+ /*--------------------------------------------------------------------------------------
763
+ *
764
+ * get_field_object
765
+ *
766
+ * @description: returns an array containing all the field data for a given field_name.
767
+ * @created: 3/09/12
768
+ * @author Elliot Condon
769
+ * @since 3.4.0
770
+ *
771
+ * @return: Array in this format
772
+
773
+ Array
774
+ (
775
+ [key] => field_5043fe0e3c58f
776
+ [label] => Select
777
+ [name] => select
778
+ [type] => select
779
+ [instructions] =>
780
+ [required] => 1
781
+ [choices] => Array
782
+ (
783
+ [yes] => Yes
784
+ [no] => No
785
+ [maybe] => Maybe
786
+ )
787
+
788
+ [default_value] =>
789
+ [allow_null] => 1
790
+ [multiple] => 1
791
+ [order_no] => 4
792
+ [value] => Array
793
+ (
794
+ [0] => Yes
795
+ [1] => Maybe
796
+ )
797
+
798
+ )
799
 
800
+ *-------------------------------------------------------------------------------------*/
801
+
802
+ function get_field_object($field_name,$post_id = false)
803
+ {
804
+ global $post, $acf;
805
+
806
+ if(!$post_id)
807
+ {
808
+ $post_id = $post->ID;
809
+ }
810
+
811
+
812
+ // allow for option == options
813
+ if( $post_id == "option" )
814
+ {
815
+ $post_id = "options";
816
+ }
817
+
818
+
819
+ // return cache
820
+ $cache = wp_cache_get('acf_get_field_object_' . $post_id . '_' . $field_name);
821
+ if($cache)
822
+ {
823
+ return $cache;
824
+ }
825
+
826
+
827
+ // get value
828
+ $field_key = "";
829
+ if( is_numeric($post_id) )
830
+ {
831
+ $field_key = get_post_meta($post_id, '_' . $field_name, true);
832
+ }
833
+ else
834
+ {
835
+ $field_key = get_option('_' . $post_id . '_' . $field_name);
836
+ }
837
+
838
+
839
+ // default return vaue
840
+ $field = false;
841
+
842
+ if($field_key != "")
843
+ {
844
+ // we can load the field properly!
845
+ $field = $acf->get_acf_field($field_key);
846
+ $field['value'] = $acf->get_value_for_api($post_id, $field);
847
+ }
848
+
849
+
850
+ // update cache
851
+ wp_cache_set('acf_get_field_object_' . $post_id . '_' . $field_name, $field);
852
+
853
+ return $field;
854
+
855
  }
856
 
857
 
core/controllers/everything_fields.php CHANGED
@@ -282,28 +282,10 @@ class acf_everything_fields
282
 
283
  function save_taxonomy( $term_id )
284
  {
285
- // validate
286
- if( !isset( $_POST['fields'] ) )
287
- {
288
- return;
289
- }
290
-
291
-
292
- // options name to save against
293
- $option_name = $_POST['taxonomy'] . '_' . $term_id;
294
-
295
-
296
- // save fields
297
- $fields = $_POST['fields'];
298
-
299
- foreach($fields as $key => $value)
300
- {
301
- // get field
302
- $field = $this->parent->get_acf_field($key);
303
-
304
- $this->parent->update_value( $option_name , $field, $value );
305
- }
306
 
 
307
  }
308
 
309
 
@@ -318,30 +300,10 @@ class acf_everything_fields
318
 
319
  function save_user( $user_id )
320
  {
 
 
321
 
322
- // validate
323
- if( !isset( $_POST['fields'] ) )
324
- {
325
- return;
326
- }
327
-
328
-
329
- // options name to save against
330
- $option_name = 'user_' . $user_id;
331
-
332
-
333
- // save fields
334
- $fields = $_POST['fields'];
335
-
336
- foreach($fields as $key => $value)
337
- {
338
- // get field
339
- $field = $this->parent->get_acf_field($key);
340
-
341
- $this->parent->update_value( $option_name , $field, $value );
342
- }
343
-
344
-
345
  }
346
 
347
 
@@ -356,28 +318,12 @@ class acf_everything_fields
356
 
357
  function save_attachment( $post, $attachment )
358
  {
359
-
360
- // validate
361
- if( !isset( $_POST['fields'] ) )
362
- {
363
- return $post;
364
- }
365
-
366
 
367
- // save fields
368
- $fields = $_POST['fields'];
369
-
370
- foreach($fields as $key => $value)
371
- {
372
- // get field
373
- $field = $this->parent->get_acf_field($key);
374
-
375
- $this->parent->update_value( $post['ID'] , $field, $value );
376
- }
377
 
378
  return $post;
379
-
380
-
381
  }
382
 
383
 
282
 
283
  function save_taxonomy( $term_id )
284
  {
285
+ // $post_id to save against
286
+ $post_id = $_POST['taxonomy'] . '_' . $term_id;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
287
 
288
+ do_action('acf_save_post', $post_id);
289
  }
290
 
291
 
300
 
301
  function save_user( $user_id )
302
  {
303
+ // $post_id to save against
304
+ $post_id = 'user_' . $user_id;
305
 
306
+ do_action('acf_save_post', $post_id);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
307
  }
308
 
309
 
318
 
319
  function save_attachment( $post, $attachment )
320
  {
321
+ // $post_id to save against
322
+ $post_id = $post['ID'];
 
 
 
 
 
323
 
324
+ do_action('acf_save_post', $post_id);
 
 
 
 
 
 
 
 
 
325
 
326
  return $post;
 
 
327
  }
328
 
329
 
core/controllers/field_group.php CHANGED
@@ -146,8 +146,32 @@ class acf_field_group
146
 
147
  // add metaboxes
148
  add_meta_box('acf_fields', __("Fields",'acf'), array($this, 'meta_box_fields'), 'acf', 'normal', 'high');
149
- add_meta_box('acf_location', __("Location",'acf') . ' </span><span class="description">- ' . __("Add Fields to Edit Screens",'acf'), array($this, 'meta_box_location'), 'acf', 'normal', 'high');
150
- add_meta_box('acf_options', __("Options",'acf') . '</span><span class="description">- ' . __("Customise the edit page",'acf'), array($this, 'meta_box_options'), 'acf', 'normal', 'high');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  }
152
 
153
 
146
 
147
  // add metaboxes
148
  add_meta_box('acf_fields', __("Fields",'acf'), array($this, 'meta_box_fields'), 'acf', 'normal', 'high');
149
+ add_meta_box('acf_location', __("Location",'acf'), array($this, 'meta_box_location'), 'acf', 'normal', 'high');
150
+ add_meta_box('acf_options', __("Options",'acf'), array($this, 'meta_box_options'), 'acf', 'normal', 'high');
151
+
152
+
153
+ // add screen settings
154
+ add_filter('screen_settings', array($this, 'screen_settings'), 10, 1);
155
+ }
156
+
157
+
158
+ /*
159
+ * screen_settings
160
+ *
161
+ * @description:
162
+ * @created: 4/09/12
163
+ */
164
+
165
+ function screen_settings( $current )
166
+ {
167
+ $current .= '<h5>' . __("Fields",'acf') . '</h5>';
168
+
169
+ $current .= '<div class="show-field_key">Show Field Key:';
170
+ $current .= '<label class="show-field_key-no"><input checked="checked" type="radio" value="0" name="show-field_key" /> No</label>';
171
+ $current .= '<label class="show-field_key-yes"><input type="radio" value="1" name="show-field_key" /> Yes</label>';
172
+ $current .= '</div>';
173
+
174
+ return $current;
175
  }
176
 
177
 
core/controllers/input.php CHANGED
@@ -149,15 +149,27 @@ class acf_input
149
 
150
 
151
  // globals
152
- global $post;
 
 
 
 
 
 
 
153
 
154
 
155
  // vars
156
- $post_type = get_post_type($post);
157
-
 
 
 
 
 
158
 
159
  // get style for page
160
- $metabox_ids = $this->parent->get_input_metabox_ids( array( 'post_id' => $post->ID ), false);
161
  $style = isset($metabox_ids[0]) ? $this->get_input_style($metabox_ids[0]) : '';
162
  echo '<style type="text/css" id="acf_style" >' .$style . '</style>';
163
 
@@ -171,7 +183,7 @@ class acf_input
171
  // Javascript
172
  echo '<script type="text/javascript" src="' . $this->parent->dir . '/js/input-actions.js?ver=' . $this->parent->version . '" ></script>';
173
  echo '<script type="text/javascript" src="' . $this->parent->dir . '/js/input-ajax.js?ver=' . $this->parent->version . '" ></script>';
174
- echo '<script type="text/javascript">acf.post_id = ' . $post->ID . ';</script>';
175
 
176
 
177
  // add user js + css
@@ -193,7 +205,7 @@ class acf_input
193
  'acf_' . $acf['id'],
194
  $acf['title'],
195
  array($this, 'meta_box_input'),
196
- $post_type,
197
  $acf['options']['position'],
198
  'core',
199
  array( 'fields' => $acf['fields'], 'options' => $acf['options'], 'show' => $show, 'post_id' => $post->ID )
@@ -408,21 +420,7 @@ class acf_input
408
  }
409
 
410
 
411
- // save fields
412
- $fields = $_POST['fields'];
413
-
414
- if($fields)
415
- {
416
- foreach($fields as $key => $value)
417
- {
418
- // get field
419
- $field = $this->parent->get_acf_field($key);
420
-
421
- $this->parent->update_value($post_id, $field, $value);
422
- }
423
- // foreach($fields as $key => $value)
424
- }
425
- // if($fields)
426
  }
427
 
428
 
149
 
150
 
151
  // globals
152
+ global $post, $pagenow, $typenow;
153
+
154
+
155
+ // shopp
156
+ if( $pagenow == "admin.php" && isset( $_GET['page'] ) && $_GET['page'] == "shopp-products" && isset( $_GET['id'] ) && $_GET['id'] == "new" )
157
+ {
158
+ $typenow = "shopp_product";
159
+ }
160
 
161
 
162
  // vars
163
+ $post_id = 0;
164
+
165
+ if( $post )
166
+ {
167
+ $post_id = $post->ID;
168
+ }
169
+
170
 
171
  // get style for page
172
+ $metabox_ids = $this->parent->get_input_metabox_ids( array( 'post_id' => $post_id, 'post_type' => $typenow ), false);
173
  $style = isset($metabox_ids[0]) ? $this->get_input_style($metabox_ids[0]) : '';
174
  echo '<style type="text/css" id="acf_style" >' .$style . '</style>';
175
 
183
  // Javascript
184
  echo '<script type="text/javascript" src="' . $this->parent->dir . '/js/input-actions.js?ver=' . $this->parent->version . '" ></script>';
185
  echo '<script type="text/javascript" src="' . $this->parent->dir . '/js/input-ajax.js?ver=' . $this->parent->version . '" ></script>';
186
+ echo '<script type="text/javascript">acf.post_id = ' . $post_id . ';</script>';
187
 
188
 
189
  // add user js + css
205
  'acf_' . $acf['id'],
206
  $acf['title'],
207
  array($this, 'meta_box_input'),
208
+ $typenow,
209
  $acf['options']['position'],
210
  'core',
211
  array( 'fields' => $acf['fields'], 'options' => $acf['options'], 'show' => $show, 'post_id' => $post->ID )
420
  }
421
 
422
 
423
+ do_action('acf_save_post', $post_id);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
424
  }
425
 
426
 
core/controllers/options_page.php CHANGED
@@ -116,29 +116,9 @@ class acf_options_page
116
  // save
117
  if(isset($_POST['update_options']))
118
  {
119
-
120
- // options name to save against
121
- $option_name = 'options';
122
-
123
-
124
- // save fields
125
- $fields = isset($_POST['fields']) ? $_POST['fields'] : false;
126
-
127
- if($fields)
128
- {
129
- foreach($fields as $key => $value)
130
- {
131
- // get field
132
- $field = $this->parent->get_acf_field($key);
133
-
134
- $this->parent->update_value( $option_name , $field, $value );
135
-
136
- }
137
- }
138
-
139
 
140
  $this->data['admin_message'] = __("Options Updated",'acf');
141
-
142
  }
143
 
144
  $metabox_ids = $this->parent->get_input_metabox_ids(false, false);
@@ -157,7 +137,7 @@ class acf_options_page
157
 
158
  // Javascript
159
  echo '<script type="text/javascript" src="'.$this->parent->dir.'/js/input-actions.js?ver=' . $this->parent->version . '" ></script>';
160
- echo '<script type="text/javascript">acf.post_id = 0;</script>';
161
 
162
 
163
  // add user js + css
@@ -201,7 +181,29 @@ class acf_options_page
201
  *-------------------------------------------------------------------------------------*/
202
  function admin_footer()
203
  {
204
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
205
  }
206
 
207
 
116
  // save
117
  if(isset($_POST['update_options']))
118
  {
119
+ do_action('acf_save_post', 'options');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
 
121
  $this->data['admin_message'] = __("Options Updated",'acf');
 
122
  }
123
 
124
  $metabox_ids = $this->parent->get_input_metabox_ids(false, false);
137
 
138
  // Javascript
139
  echo '<script type="text/javascript" src="'.$this->parent->dir.'/js/input-actions.js?ver=' . $this->parent->version . '" ></script>';
140
+ echo '<script type="text/javascript">acf.post_id = 0; </script>';
141
 
142
 
143
  // add user js + css
181
  *-------------------------------------------------------------------------------------*/
182
  function admin_footer()
183
  {
184
+ // add togle open / close postbox
185
+ ?>
186
+ <script type="text/javascript">
187
+ (function($){
188
+
189
+ $('.postbox .handlediv').live('click', function(){
190
+
191
+ var postbox = $(this).closest('.postbox');
192
+
193
+ if( postbox.hasClass('closed') )
194
+ {
195
+ postbox.removeClass('closed');
196
+ }
197
+ else
198
+ {
199
+ postbox.addClass('closed');
200
+ }
201
+
202
+ });
203
+
204
+ })(jQuery);
205
+ </script>
206
+ <?php
207
  }
208
 
209
 
core/fields/relationship.php CHANGED
@@ -24,6 +24,25 @@ class acf_Relationship extends acf_Field
24
  }
25
 
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  /*--------------------------------------------------------------------------------------
28
  *
29
  * acf_get_relationship_results
@@ -129,6 +148,17 @@ class acf_Relationship extends acf_Field
129
  unset( $options['taxonomy'] );
130
 
131
 
 
 
 
 
 
 
 
 
 
 
 
132
  // load the posts
133
  $posts = get_posts( $options );
134
 
@@ -137,7 +167,7 @@ class acf_Relationship extends acf_Field
137
  foreach( $posts as $post )
138
  {
139
  // right aligned info
140
- $title = '<span class="info">';
141
 
142
  $title .= $post->post_type;
143
 
@@ -158,7 +188,7 @@ class acf_Relationship extends acf_Field
158
  $title .= " ($post->post_status)";
159
  }
160
 
161
- echo '<li><a href="javascript:;" data-post_id="' . $post->ID . '">' . $title . '<span class="add"></span></a></li>';
162
  }
163
  }
164
 
@@ -281,7 +311,7 @@ class acf_Relationship extends acf_Field
281
  {
282
 
283
  // right aligned info
284
- $title = '<span class="info">';
285
 
286
  $title .= $post->post_type;
287
 
@@ -303,7 +333,7 @@ class acf_Relationship extends acf_Field
303
  }
304
 
305
  echo '<li>
306
- <a href="javascript:;" class="" data-post_id="' . $post->ID . '">' . $title . '<span class="remove"></span></a>
307
  <input type="hidden" name="' . $field['name'] . '[]" value="' . $post->ID . '" />
308
  </li>';
309
 
24
  }
25
 
26
 
27
+ /*
28
+ * my_posts_where
29
+ *
30
+ * @description:
31
+ * @created: 3/09/12
32
+ */
33
+ function posts_where( $where, &$wp_query )
34
+ {
35
+ global $wpdb;
36
+
37
+ if ( $title = $wp_query->get('like_title') )
38
+ {
39
+ $where .= " AND " . $wpdb->posts . ".post_title LIKE '%" . esc_sql( like_escape( $title ) ) . "%'";
40
+ }
41
+
42
+ return $where;
43
+ }
44
+
45
+
46
  /*--------------------------------------------------------------------------------------
47
  *
48
  * acf_get_relationship_results
148
  unset( $options['taxonomy'] );
149
 
150
 
151
+ // search
152
+ if( $options['s'] )
153
+ {
154
+ $options['like_title'] = $options['s'];
155
+
156
+ add_filter( 'posts_where', array($this, 'posts_where'), 10, 2 );
157
+ }
158
+
159
+ unset( $options['s'] );
160
+
161
+
162
  // load the posts
163
  $posts = get_posts( $options );
164
 
167
  foreach( $posts as $post )
168
  {
169
  // right aligned info
170
+ $title = '<span class="relationship-item-info">';
171
 
172
  $title .= $post->post_type;
173
 
188
  $title .= " ($post->post_status)";
189
  }
190
 
191
+ echo '<li><a href="' . get_permalink($post->ID) . '" data-post_id="' . $post->ID . '">' . $title . '<span class="add"></span></a></li>';
192
  }
193
  }
194
 
311
  {
312
 
313
  // right aligned info
314
+ $title = '<span class="relationship-item-info">';
315
 
316
  $title .= $post->post_type;
317
 
333
  }
334
 
335
  echo '<li>
336
+ <a href="' . get_permalink($post->ID) . '" class="" data-post_id="' . $post->ID . '">' . $title . '<span class="remove"></span></a>
337
  <input type="hidden" name="' . $field['name'] . '[]" value="' . $post->ID . '" />
338
  </li>';
339
 
core/views/meta_box_fields.php CHANGED
@@ -61,6 +61,7 @@ foreach( $this->parent->fields as $field )
61
  <th class="field_label"><?php _e('Field Label','acf'); ?></th>
62
  <th class="field_name"><?php _e('Field Name','acf'); ?></th>
63
  <th class="field_type"><?php _e('Field Type','acf'); ?></th>
 
64
  </tr>
65
  </thead>
66
  </table>
@@ -92,6 +93,7 @@ foreach( $this->parent->fields as $field )
92
  </td>
93
  <td class="field_name"><?php echo $field['name']; ?></td>
94
  <td class="field_type"><?php echo $fields_names[$field['type']]; ?></td>
 
95
  </tr>
96
  </table>
97
  </div>
61
  <th class="field_label"><?php _e('Field Label','acf'); ?></th>
62
  <th class="field_name"><?php _e('Field Name','acf'); ?></th>
63
  <th class="field_type"><?php _e('Field Type','acf'); ?></th>
64
+ <th class="field_key"><?php _e('Field Key','acf'); ?></th>
65
  </tr>
66
  </thead>
67
  </table>
93
  </td>
94
  <td class="field_name"><?php echo $field['name']; ?></td>
95
  <td class="field_type"><?php echo $fields_names[$field['type']]; ?></td>
96
+ <td class="field_key"><?php echo $field['key']; ?></td>
97
  </tr>
98
  </table>
99
  </div>
css/fields.css CHANGED
@@ -81,23 +81,38 @@ table.widefat.acf td {
81
  }
82
 
83
  .acf tr td.field_order,
84
- .acf tr th.field_order {
 
 
 
 
 
 
85
  width: 25%;
86
  }
87
 
88
- .acf tr td.field_label,
89
- .acf tr th.field_label {
90
- width: 25%;
 
 
 
 
 
 
 
 
 
91
  }
92
 
93
- .acf tr td.field_name,
94
- .acf tr th.field_name {
95
- width: 25%;
96
  }
97
 
98
- .acf tr td.field_type,
99
- .acf tr th.field_type {
100
- width: 25%;
101
  }
102
 
103
  .acf tr td {
@@ -108,6 +123,10 @@ table.widefat.acf td {
108
  }
109
 
110
 
 
 
 
 
111
 
112
 
113
  /*---------------------------------------------------------------------------------------------
81
  }
82
 
83
  .acf tr td.field_order,
84
+ .acf tr th.field_order,
85
+ .acf tr td.field_label,
86
+ .acf tr th.field_label,
87
+ .acf tr td.field_name,
88
+ .acf tr th.field_name,
89
+ .acf tr td.field_type,
90
+ .acf tr th.field_type {
91
  width: 25%;
92
  }
93
 
94
+
95
+ .acf.show-field_key tr td.field_order,
96
+ .acf.show-field_key tr th.field_order,
97
+ .acf.show-field_key tr td.field_label,
98
+ .acf.show-field_key tr th.field_label,
99
+ .acf.show-field_key tr td.field_name,
100
+ .acf.show-field_key tr th.field_name,
101
+ .acf.show-field_key tr td.field_type,
102
+ .acf.show-field_key tr th.field_type,
103
+ .acf.show-field_key tr td.field_key,
104
+ .acf.show-field_key tr th.field_key {
105
+ width: 20%;
106
  }
107
 
108
+ .acf tr td.field_key,
109
+ .acf tr th.field_key {
110
+ display: none;
111
  }
112
 
113
+ .acf.show-field_key tr td.field_key,
114
+ .acf.show-field_key tr th.field_key {
115
+ display: table-cell;
116
  }
117
 
118
  .acf tr td {
123
  }
124
 
125
 
126
+ /* Screen Options */
127
+ .show-field_key label {
128
+ padding: 0 2px 0 8px;
129
+ }
130
 
131
 
132
  /*---------------------------------------------------------------------------------------------
css/input.css CHANGED
@@ -628,19 +628,19 @@ ul.checkbox_list {
628
  text-decoration: none;
629
  }
630
 
631
- .acf_relationship .relationship_list li a .info {
632
  color: #CCC;
633
  text-transform: uppercase;
634
  float: right;
635
  font-size: 11px;
636
  }
637
 
638
- .acf_relationship .relationship_list li:hover a .info {
639
  padding-right: 24px;
640
  color: #999;
641
  }
642
 
643
- .acf_relationship .relationship_list li.hide:hover a .info {
644
  padding-right: 0;
645
  color: #CCC;
646
  }
628
  text-decoration: none;
629
  }
630
 
631
+ .acf_relationship .relationship_list li a .relationship-item-info {
632
  color: #CCC;
633
  text-transform: uppercase;
634
  float: right;
635
  font-size: 11px;
636
  }
637
 
638
+ .acf_relationship .relationship_list li:hover a .relationship-item-info {
639
  padding-right: 24px;
640
  color: #999;
641
  }
642
 
643
+ .acf_relationship .relationship_list li.hide:hover a .relationship-item-info {
644
  padding-right: 0;
645
  color: #CCC;
646
  }
js/fields.js CHANGED
@@ -634,6 +634,27 @@
634
  }
635
 
636
  });
637
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
638
 
639
  })(jQuery);
634
  }
635
 
636
  });
637
+
638
+
639
+ /*
640
+ * Screen Options
641
+ *
642
+ * @description:
643
+ * @created: 4/09/12
644
+ */
645
+
646
+ $('#adv-settings input[name="show-field_key"]').live('change', function(){
647
+
648
+ if( $(this).val() == 1 )
649
+ {
650
+ $('#acf_fields table.acf').addClass('show-field_key');
651
+ }
652
+ else
653
+ {
654
+ $('#acf_fields table.acf').removeClass('show-field_key');
655
+ }
656
+
657
+ });
658
+
659
 
660
  })(jQuery);
js/input-actions.js CHANGED
@@ -136,14 +136,17 @@ var acf = {
136
  validation = false;
137
  }
138
 
 
139
  // select
140
  if($(this).find('select').exists())
141
  {
 
142
  if($(this).find('select').val() == "null" || !$(this).find('select').val())
143
  {
144
  validation = false;
145
  }
146
  }
 
147
 
148
  // checkbox
149
  if($(this).find('input[type="checkbox"]:checked').exists())
@@ -1263,7 +1266,7 @@ var acf = {
1263
 
1264
  acf.is_clone_field = function( input )
1265
  {
1266
- if( input.attr('name').indexOf('[999]') != -1 )
1267
  {
1268
  return true;
1269
  }
136
  validation = false;
137
  }
138
 
139
+
140
  // select
141
  if($(this).find('select').exists())
142
  {
143
+ validation = true;
144
  if($(this).find('select').val() == "null" || !$(this).find('select').val())
145
  {
146
  validation = false;
147
  }
148
  }
149
+
150
 
151
  // checkbox
152
  if($(this).find('input[type="checkbox"]:checked').exists())
1266
 
1267
  acf.is_clone_field = function( input )
1268
  {
1269
+ if( input.attr('name') && input.attr('name').indexOf('[999]') != -1 )
1270
  {
1271
  return true;
1272
  }
js/input-ajax.js CHANGED
@@ -21,6 +21,27 @@
21
  return $(this).length>0;
22
  };
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  /*
26
  * Document Ready
@@ -30,20 +51,12 @@
30
  */
31
 
32
  $(document).ready(function(){
33
-
34
- // show metaboxes for this post
35
- acf.data = {
36
- action : 'get_input_metabox_ids',
37
- post_id : acf.post_id,
38
- page_template : false,
39
- page_parent : false,
40
- page_type : false,
41
- page : acf.post_id,
42
- post : acf.post_id,
43
- post_category : false,
44
- post_format : false,
45
- taxonomy : false
46
- };
47
 
48
 
49
  // MPML
21
  return $(this).length>0;
22
  };
23
 
24
+
25
+ /*
26
+ * Vars
27
+ *
28
+ * @description:
29
+ * @created: 3/09/12
30
+ */
31
+
32
+ acf.data = {
33
+ action : 'get_input_metabox_ids',
34
+ post_id : 0,
35
+ page_template : false,
36
+ page_parent : false,
37
+ page_type : false,
38
+ page : 0,
39
+ post : 0,
40
+ post_category : false,
41
+ post_format : false,
42
+ taxonomy : false
43
+ };
44
+
45
 
46
  /*
47
  * Document Ready
51
  */
52
 
53
  $(document).ready(function(){
54
+
55
+
56
+ // update post_id
57
+ acf.data.post_id = acf.post_id;
58
+ acf.data.page = acf.post_id;
59
+ acf.data.post = acf.post_id;
 
 
 
 
 
 
 
 
60
 
61
 
62
  // MPML
readme.txt CHANGED
@@ -85,6 +85,21 @@ http://support.advancedcustomfields.com/
85
 
86
  == Changelog ==
87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  = 3.3.9 =
89
  * [Added] Add basic support for WPML - duplicate field groups, pages and posts for each language without corrupting ACF data!
90
  * [Fixed] Fix date picker save null - http://support.advancedcustomfields.com/discussion/2844/bug-with-the-date-picker
85
 
86
  == Changelog ==
87
 
88
+ = 3.4.0 =
89
+ * [Fixed] Fix validation rules for multiple select - http://support.advancedcustomfields.com/discussion/2858/multiple-select-validation-doesnt-work
90
+ * [Added] Add support for options page toggle open / close metabox
91
+ * [Fixed] Fix special characters in registered options page - http://support.advancedcustomfields.com/discussion/comment/7500#Comment_7500
92
+ * [Updated] CSS tweak for relationship field - http://support.advancedcustomfields.com/discussion/2877/relation-field-with-multiple-post-types-css-styling-problem-
93
+ * [Fixed] Fix datepicker blank option bug - http://support.advancedcustomfields.com/discussion/2896/3-3-9-date-picker-not-popping-up
94
+ * [Added] Add new function get_field_object to API - http://support.advancedcustomfields.com/discussion/290/field-label-on-frontend
95
+ * [Fixed] Fix field groups not showing for Shopp add new product - http://support.advancedcustomfields.com/discussion/3005/acf-shopp
96
+ * [Fixed] Move acf.data outside of the doc.ready in input-ajax.js
97
+ * [Fixed] Fix IE7 JS bug - http://support.advancedcustomfields.com/discussion/3020/ie7-fix-on-is_clone_field-function
98
+ * [Fixed] Fix relationship search - Only search title, not content
99
+ * [Updated] Update function update_field to use field_key or field_name
100
+ * [Added] Add field group screen option to show field keys (to use in save_field / update field)
101
+ * [Added] Add actions on all save events (action is called "acf_save_post", 1 param = $post_id)
102
+
103
  = 3.3.9 =
104
  * [Added] Add basic support for WPML - duplicate field groups, pages and posts for each language without corrupting ACF data!
105
  * [Fixed] Fix date picker save null - http://support.advancedcustomfields.com/discussion/2844/bug-with-the-date-picker