Advanced Custom Fields - Version 3.5.6

Version Description

  • [Fixed] Fix content editor double in webkit browser - http://support.advancedcustomfields.com/discussion/4223/duplicate-editor-box-safari-bug-has-returned
  • [Fixed] Fix bug with post format location rule not working - http://support.advancedcustomfields.com/discussion/4264/not-recognizing-post-type-formats-following-upgrade-to-version-3-5-5
  • [Fixed] Fix conditional logic with tabs - http://support.advancedcustomfields.com/discussion/4201/tabs-and-logical-condition
  • [Fixed] Fix missing icons for conditional logic / menu in older WP
  • [Added] Add PHP fix for new lines in field key - http://support.advancedcustomfields.com/discussion/4087/can039t-add-new-field
Download this release

Release Info

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

Code changes from version 3.5.5 to 3.5.6

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.5.5
7
  Author: Elliot Condon
8
  Author URI: http://www.elliotcondon.com/
9
  License: GPL
@@ -50,7 +50,7 @@ class Acf
50
  // vars
51
  $this->path = plugin_dir_path(__FILE__);
52
  $this->dir = plugins_url('',__FILE__);
53
- $this->version = '3.5.5';
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(
@@ -133,6 +133,7 @@ class Acf
133
  'not_found_in_trash' => __('No Field Groups found in Trash', 'acf'),
134
  );
135
 
 
136
  register_post_type('acf', array(
137
  'labels' => $labels,
138
  'public' => false,
@@ -782,6 +783,7 @@ class Acf
782
  $id = $field['name'];
783
  $id = str_replace('][', '_', $id);
784
  $id = str_replace('fields[', '', $id);
 
785
  $id = str_replace(']', '', $id);
786
 
787
 
@@ -821,11 +823,11 @@ class Acf
821
  ?>
822
  if(<?php echo implode( $join, $if ); ?>)
823
  {
824
- field.show();
825
  }
826
  else
827
  {
828
- field.hide();
829
  }
830
 
831
  });
@@ -1659,10 +1661,15 @@ class Acf
1659
  // Post Format
1660
  case "post_format":
1661
 
1662
-
1663
  $post_format = isset($overrides['post_format']) ? $overrides['post_format'] : get_post_format( $post->ID );
1664
- if($post_format == 0) $post_format = "standard";
1665
-
 
 
 
 
 
1666
  if($rule['operator'] == "==")
1667
  {
1668
  if($post_format == $rule['value'])
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.6.3
7
  Author: Elliot Condon
8
  Author URI: http://www.elliotcondon.com/
9
  License: GPL
50
  // vars
51
  $this->path = plugin_dir_path(__FILE__);
52
  $this->dir = plugins_url('',__FILE__);
53
+ $this->version = '3.5.6.3';
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(
133
  'not_found_in_trash' => __('No Field Groups found in Trash', 'acf'),
134
  );
135
 
136
+
137
  register_post_type('acf', array(
138
  'labels' => $labels,
139
  'public' => false,
783
  $id = $field['name'];
784
  $id = str_replace('][', '_', $id);
785
  $id = str_replace('fields[', '', $id);
786
+ $id = str_replace('[', '-', $id); // location rules (select) does'nt have "fields[" in it
787
  $id = str_replace(']', '', $id);
788
 
789
 
823
  ?>
824
  if(<?php echo implode( $join, $if ); ?>)
825
  {
826
+ field.removeClass('acf-conditional_logic-hide').addClass('acf-conditional_logic-show');
827
  }
828
  else
829
  {
830
+ field.removeClass('acf-conditional_logic-show').addClass('acf-conditional_logic-hide');
831
  }
832
 
833
  });
1661
  // Post Format
1662
  case "post_format":
1663
 
1664
+
1665
  $post_format = isset($overrides['post_format']) ? $overrides['post_format'] : get_post_format( $post->ID );
1666
+
1667
+ if( is_numeric($post_format) && $post_format == 0 )
1668
+ {
1669
+ $post_format = "standard";
1670
+ }
1671
+
1672
+
1673
  if($rule['operator'] == "==")
1674
  {
1675
  if($post_format == $rule['value'])
core/api.php CHANGED
@@ -672,9 +672,13 @@ function acf_form($options = null)
672
  echo '<div id="message" class="updated"><p>' . $options['updated_message'] . '</p></div>';
673
  }
674
 
 
 
 
 
 
675
  // display form
676
  ?>
677
- <script type="text/javascript">acf.post_id = <?php echo $options['post_id']; ?>;</script>
678
  <form action="" id="post" method="post" <?php if($options['form_attributes']){foreach($options['form_attributes'] as $k => $v){echo $k . '="' . $v .'" '; }} ?>>
679
  <div style="display:none">
680
  <input type="hidden" name="acf_save" value="true" />
@@ -710,7 +714,7 @@ function acf_form($options = null)
710
  echo '<div id="acf_' . $field_group['id'] . '" class="postbox acf_postbox">';
711
  echo '<h3 class="hndle"><span>' . $field_group['title'] . '</span></h3>';
712
  echo '<div class="inside">';
713
- echo '<div class="options" data-layout="' . $field_group['options']['layout'] . '" data-show="true"></div>';
714
  $acf->render_fields_for_input($field_group['fields'], $options['post_id']);
715
  echo '</div></div>';
716
  }
672
  echo '<div id="message" class="updated"><p>' . $options['updated_message'] . '</p></div>';
673
  }
674
 
675
+
676
+ // Javascript
677
+ echo '<script type="text/javascript">acf.post_id = ' . $options['post_id'] . '; acf.nonce = "' . wp_create_nonce( 'acf_nonce' ) . '";</script>';
678
+
679
+
680
  // display form
681
  ?>
 
682
  <form action="" id="post" method="post" <?php if($options['form_attributes']){foreach($options['form_attributes'] as $k => $v){echo $k . '="' . $v .'" '; }} ?>>
683
  <div style="display:none">
684
  <input type="hidden" name="acf_save" value="true" />
714
  echo '<div id="acf_' . $field_group['id'] . '" class="postbox acf_postbox">';
715
  echo '<h3 class="hndle"><span>' . $field_group['title'] . '</span></h3>';
716
  echo '<div class="inside">';
717
+ echo '<div class="options" data-layout="' . $field_group['options']['layout'] . '" data-show="1"></div>';
718
  $acf->render_fields_for_input($field_group['fields'], $options['post_id']);
719
  echo '</div></div>';
720
  }
core/controllers/field_group.php CHANGED
@@ -655,6 +655,10 @@ class acf_field_group
655
  $field['key'] = $key;
656
 
657
 
 
 
 
 
658
  // save
659
  $this->parent->update_field( $post_id, $field);
660
 
655
  $field['key'] = $key;
656
 
657
 
658
+ // trim key
659
+ $field['key'] = preg_replace('/\s+/' , '' , $field['key']);
660
+
661
+
662
  // save
663
  $this->parent->update_field( $post_id, $field);
664
 
core/controllers/input.php CHANGED
@@ -211,13 +211,14 @@ class acf_input
211
  foreach($acfs as $acf)
212
  {
213
  // hide / show
214
- $show = in_array($acf['id'], $metabox_ids) ? "true" : "false";
215
  $priority = 'high';
216
  if( $acf['options']['position'] == 'side' )
217
  {
218
  $priority = 'core';
219
  }
220
 
 
221
  // add meta box
222
  add_meta_box(
223
  'acf_' . $acf['id'],
@@ -355,34 +356,32 @@ class acf_input
355
  function meta_box_input($post, $args)
356
  {
357
  // vars
358
- $fields = isset($args['args']['fields']) ? $args['args']['fields'] : false ;
359
- $options = isset($args['args']['options']) ? $args['args']['options'] : false;
360
- $show = isset($args['args']['show']) ? $args['args']['show'] : "false";
361
- $post_id = isset($args['args']['post_id']) ? $args['args']['post_id'] : false;
362
-
363
-
364
- // defaults
365
- if(!$options)
366
- {
367
- $options = array(
368
  'layout' => 'default'
369
- );
370
- }
 
 
 
 
371
 
372
- if($fields)
 
373
  {
374
  echo '<input type="hidden" name="save_input" value="true" />';
375
- echo '<div class="options" data-layout="' . $options['layout'] . '" data-show="' . $show . '" style="display:none"></div>';
376
 
377
- if($show == "false")
378
  {
379
- // don't create fields
380
- echo '<div class="acf-replace-with-fields"><div class="acf-loading"></div></div>';
381
  }
382
  else
383
  {
384
- $this->parent->render_fields_for_input($fields, $post_id);
385
  }
 
386
  }
387
  }
388
 
211
  foreach($acfs as $acf)
212
  {
213
  // hide / show
214
+ $show = in_array($acf['id'], $metabox_ids) ? 1 : 0;
215
  $priority = 'high';
216
  if( $acf['options']['position'] == 'side' )
217
  {
218
  $priority = 'core';
219
  }
220
 
221
+
222
  // add meta box
223
  add_meta_box(
224
  'acf_' . $acf['id'],
356
  function meta_box_input($post, $args)
357
  {
358
  // vars
359
+ $options = array(
360
+ 'fields' => array(),
361
+ 'options' => array(
 
 
 
 
 
 
 
362
  'layout' => 'default'
363
+ ),
364
+ 'show' => 0,
365
+ 'post_id' => 0,
366
+ );
367
+ $options = array_merge( $options, $args['args'] );
368
+
369
 
370
+ // needs fields
371
+ if( $options['fields'] )
372
  {
373
  echo '<input type="hidden" name="save_input" value="true" />';
374
+ echo '<div class="options" data-layout="' . $options['options']['layout'] . '" data-show="' . $options['show'] . '" style="display:none"></div>';
375
 
376
+ if( $options['show'] )
377
  {
378
+ $this->parent->render_fields_for_input( $options['fields'], $options['post_id'] );
 
379
  }
380
  else
381
  {
382
+ echo '<div class="acf-replace-with-fields"><div class="acf-loading"></div></div>';
383
  }
384
+
385
  }
386
  }
387
 
core/controllers/options_page.php CHANGED
@@ -156,8 +156,9 @@ class acf_options_page
156
  foreach($acfs as $acf)
157
  {
158
  // hide / show
159
- $show = in_array($acf['id'], $metabox_ids) ? "true" : "false";
160
- if($show == "true")
 
161
  {
162
  // add meta box
163
  add_meta_box(
156
  foreach($acfs as $acf)
157
  {
158
  // hide / show
159
+ $show = in_array($acf['id'], $metabox_ids) ? 1 : 0;
160
+
161
+ if( $show )
162
  {
163
  // add meta box
164
  add_meta_box(
core/fields/flexible_content.php CHANGED
@@ -568,7 +568,10 @@ class acf_Flexible_content extends acf_Field
568
  </tr>
569
  <?php
570
 
571
- $this->parent->fields[$sub_field['type']]->create_options($key.'][layouts][' . $layout_key . '][sub_fields]['.$sub_field['key'], $sub_field);
 
 
 
572
 
573
  ?>
574
  <tr class="field_save">
568
  </tr>
569
  <?php
570
 
571
+ if( isset($this->parent->fields[ $sub_field['type'] ]) )
572
+ {
573
+ $this->parent->fields[$sub_field['type']]->create_options($key.'][layouts][' . $layout_key . '][sub_fields]['.$sub_field['key'], $sub_field);
574
+ }
575
 
576
  ?>
577
  <tr class="field_save">
core/fields/repeater.php CHANGED
@@ -449,7 +449,10 @@ class acf_Repeater extends acf_Field
449
  </tr>
450
  <?php
451
 
452
- $this->parent->fields[$sub_field['type']]->create_options($key.'][sub_fields]['.$sub_field['key'], $sub_field);
 
 
 
453
 
454
  ?>
455
  <tr class="field_save">
449
  </tr>
450
  <?php
451
 
452
+ if( isset($this->parent->fields[ $sub_field['type'] ]) )
453
+ {
454
+ $this->parent->fields[$sub_field['type']]->create_options($key.'][sub_fields]['.$sub_field['key'], $sub_field);
455
+ }
456
 
457
  ?>
458
  <tr class="field_save">
core/views/meta_box_fields.php CHANGED
@@ -199,7 +199,10 @@ $conditional_logic_rule = array(
199
  </tr>
200
  <?php
201
 
202
- $this->parent->fields[$field['type']]->create_options($field['key'], $field);
 
 
 
203
 
204
  ?>
205
  <tr class="conditional-logic" data-field_name="<?php echo $field['key']; ?>">
199
  </tr>
200
  <?php
201
 
202
+ if( isset($this->parent->fields[ $field['type'] ]) )
203
+ {
204
+ $this->parent->fields[$field['type']]->create_options($field['key'], $field);
205
+ }
206
 
207
  ?>
208
  <tr class="conditional-logic" data-field_name="<?php echo $field['key']; ?>">
css/input.css CHANGED
@@ -1269,6 +1269,52 @@ td.acf_input-wrap {
1269
  }
1270
 
1271
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1272
  /*--------------------------------------------------------------------------
1273
  *
1274
  * Retina
1269
  }
1270
 
1271
 
1272
+ /*--------------------------------------------------------------------------
1273
+ *
1274
+ * Tab Group
1275
+ *
1276
+ *-------------------------------------------------------------------------*/
1277
+
1278
+ .acf-tab_group-show {
1279
+ display: block;
1280
+ }
1281
+ tr.acf-tab_group-show {
1282
+ display: table-row;
1283
+ }
1284
+ .acf-tab_group-hide {
1285
+ display: none;
1286
+ }
1287
+
1288
+
1289
+ /*--------------------------------------------------------------------------
1290
+ *
1291
+ * Conditional Logic
1292
+ *
1293
+ *-------------------------------------------------------------------------*/
1294
+
1295
+ .acf-conditional_logic-show {
1296
+ display: block;
1297
+ }
1298
+ tr.acf-conditional_logic-show {
1299
+ display: table-row;
1300
+ }
1301
+ .acf-conditional_logic-hide {
1302
+ display: none;
1303
+ }
1304
+
1305
+
1306
+ /*--------------------------------------------------------------------------
1307
+ *
1308
+ * Conditional Logic + Tabs
1309
+ *
1310
+ *-------------------------------------------------------------------------*/
1311
+
1312
+ .acf-tab_group-hide.acf-conditional_logic-show {
1313
+ display: none;
1314
+ }
1315
+
1316
+
1317
+
1318
  /*--------------------------------------------------------------------------
1319
  *
1320
  * Retina
js/input-actions.js CHANGED
@@ -73,7 +73,7 @@ var acf = {
73
  $(this).addClass(layout);
74
 
75
  // show / hide
76
- if( show == 'true' )
77
  {
78
  $(this).removeClass('acf-hidden');
79
  $('#adv-settings .acf_hide_label[for="acf_' + id + '-hide"]').show();
@@ -949,33 +949,65 @@ var acf = {
949
  });
950
 
951
 
 
 
 
 
 
 
 
 
952
  $(window).load(function(){
953
 
954
- // trigger click on hidden wysiwyg (to get in HTML mode)
955
- if( $('#wp-acf_settings-wrap').exists() )
956
- {
957
- $('#acf_settings-tmce').trigger('click');
958
- }
959
-
960
-
961
- // setup fields
962
- $(document).trigger('acf/setup_fields', $('#poststuff'));
963
 
964
 
965
- // trigger html mode for people who want to stay in HTML mode
966
- if( $('#wp-content-wrap').hasClass('html-active') )
967
  {
968
- $('#wp-content-wrap #content-html').trigger('click');
 
 
 
 
969
  }
970
 
971
 
972
- // add wysiwyg events to standard editor
973
- if( $('#wp-content-wrap').exists() )
974
- {
975
- acf.add_wysiwyg_events( 'content' );
976
- }
 
 
 
 
977
 
978
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
979
  });
980
 
981
 
@@ -1969,7 +2001,7 @@ var acf = {
1969
  // create tab group if it doesnt exist
1970
  if( ! inside.children('.acf-tab-group').exists() )
1971
  {
1972
- inside.prepend('<ul class="hl clearfix acf-tab-group"></ul>');
1973
  }
1974
 
1975
 
@@ -2015,10 +2047,21 @@ var acf = {
2015
 
2016
 
2017
  // hide / show
2018
- inside.children('.field').hide();
2019
- field.nextUntil('.field-tab').show();
2020
-
2021
-
 
 
 
 
 
 
 
 
 
 
 
2022
  $(this).trigger('blur');
2023
 
2024
  return false;
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();
949
  });
950
 
951
 
952
+ /*
953
+ * window load
954
+ *
955
+ * @description:
956
+ * @since: 3.5.5
957
+ * @created: 22/12/12
958
+ */
959
+
960
  $(window).load(function(){
961
 
962
+ // vars
963
+ var wp_content = $('#wp-content-wrap').exists(),
964
+ wp_acf_settings = $('#wp-acf_settings-wrap').exists()
965
+ mode = 'tmce';
 
 
 
 
 
966
 
967
 
968
+ // has_editor
969
+ if( wp_content )
970
  {
971
+ // html_mode
972
+ if( $('#wp-content-wrap').hasClass('html-active') )
973
+ {
974
+ mode = 'html';
975
+ }
976
  }
977
 
978
 
979
+ setTimeout(function(){
980
+
981
+ // trigger click on hidden wysiwyg (to get in HTML mode)
982
+ if( wp_acf_settings && mode == 'html' )
983
+ {
984
+ $('#acf_settings-tmce').trigger('click');
985
+ }
986
+
987
+ }, 1);
988
 
989
 
990
+ setTimeout(function(){
991
+
992
+ // setup fields
993
+ $(document).trigger('acf/setup_fields', $('#poststuff'));
994
+
995
+
996
+ // trigger html mode for people who want to stay in HTML mode
997
+ if( wp_acf_settings && mode == 'html' )
998
+ {
999
+ $('#acf_settings-html').trigger('click');
1000
+ }
1001
+
1002
+ // Add events to content editor
1003
+ if( wp_content )
1004
+ {
1005
+ acf.add_wysiwyg_events( 'content' );
1006
+ }
1007
+
1008
+
1009
+ }, 10);
1010
+
1011
  });
1012
 
1013
 
2001
  // create tab group if it doesnt exist
2002
  if( ! inside.children('.acf-tab-group').exists() )
2003
  {
2004
+ inside.children('.field-tab:first').before('<ul class="hl clearfix acf-tab-group"></ul>');
2005
  }
2006
 
2007
 
2047
 
2048
 
2049
  // hide / show
2050
+ inside.children('.field-tab').each(function(){
2051
+
2052
+ var tab = $(this);
2053
+
2054
+ if( tab.attr('id') == field.attr('id') )
2055
+ {
2056
+ tab.nextUntil('.field-tab').removeClass('acf-tab_group-hide').addClass('acf-tab_group-show');
2057
+ }
2058
+ else
2059
+ {
2060
+ tab.nextUntil('.field-tab').removeClass('acf-tab_group-show').addClass('acf-tab_group-hide');
2061
+ }
2062
+
2063
+ });
2064
+
2065
  $(this).trigger('blur');
2066
 
2067
  return false;
readme.txt CHANGED
@@ -90,6 +90,22 @@ http://support.advancedcustomfields.com/
90
 
91
  == Changelog ==
92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  = 3.5.5 =
94
  * [Added] Add new Tab field
95
  * [Fixed] Improve WYSIWYG code for better compatibility
90
 
91
  == Changelog ==
92
 
93
+ = 3.5.6.3 =
94
+ * [Fixed] Fix bug with 3.5.6 not showing front end form
95
+
96
+ = 3.5.6.2 =
97
+ * [Fixed] Fix WYSIWYG webkit browser issues.
98
+
99
+ = 3.5.6.1 =
100
+ * [Fixed] Fix bug causing field groups to not display on the options page.
101
+
102
+ = 3.5.6 =
103
+ * [Fixed] Fix content editor double in webkit browser - http://support.advancedcustomfields.com/discussion/4223/duplicate-editor-box-safari-bug-has-returned
104
+ * [Fixed] Fix bug with post format location rule not working - http://support.advancedcustomfields.com/discussion/4264/not-recognizing-post-type-formats-following-upgrade-to-version-3-5-5
105
+ * [Fixed] Fix conditional logic with tabs - http://support.advancedcustomfields.com/discussion/4201/tabs-and-logical-condition
106
+ * [Fixed] Fix missing icons for conditional logic / menu in older WP
107
+ * [Added] Add PHP fix for new lines in field key - http://support.advancedcustomfields.com/discussion/4087/can039t-add-new-field
108
+
109
  = 3.5.5 =
110
  * [Added] Add new Tab field
111
  * [Fixed] Improve WYSIWYG code for better compatibility