Advanced Custom Fields - Version 3.5.4

Version Description

  • [Added] Add new filter for ACF settings - http://www.advancedcustomfields.com/docs/filters/acf_settings/
  • [Updated] Updated field keys to look nicer. eg field_12
  • [Added] Update admin_head to use hooks / enque all scripts / styles
  • [Added] Add duplicate function for flexible content layouts
  • [Fixed] Fix $post_id bug - http://support.advancedcustomfields.com/discussion/3852/acf_form-uses-global-post_id-instead-of-argument
  • [Fixed] Fix WYSIWYG JS issue - http://support.advancedcustomfields.com/discussion/3644/flexible-layout-field-reordering-breaks-when-visual-editor-disabled
  • [Fixed] Fix Gallery PHP error - http://support.advancedcustomfields.com/discussion/3856/undefined-index-error-gallery-on-options-page
  • [Added] Add compatibility for Shopp categories - http://support.advancedcustomfields.com/discussion/3647/custom-fields-not-showing-up-in-shopp-catalog-categories
  • [Fixed] Fix "Parent Page" location rule - http://support.advancedcustomfields.com/discussion/3885/parent-page-type-check
  • [Fixed] Fix options page backwards compatibility - support.advancedcustomfields.com/discussion/3908/acf-options-page-groups-are-not-backward-compatible
  • [Fixed] Fix update_field for content - http://support.advancedcustomfields.com/discussion/3916/add-flexible-layout-row-with-update_field
  • [Added] Add new filter for acf_defaults! - http://support.advancedcustomfields.com/discussion/3947/options-page-plugin-user-capabilites-limitation
  • [Fixed] Fix gallery detail update after edit - http://support.advancedcustomfields.com/discussion/3899/gallery-image-attributes-not-updating-after-change
  • [Fixed] Fix front end uploading issue - http://support.advancedcustomfields.com/discussion/comment/10502#Comment_10502
Download this release

Release Info

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

Code changes from version 3.5.3 to 3.5.4

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.3.1
7
  Author: Elliot Condon
8
  Author URI: http://www.elliotcondon.com/
9
  License: GPL
@@ -22,6 +22,8 @@ class Acf
22
  $upgrade_version,
23
  $fields,
24
  $cache,
 
 
25
 
26
  // controllers
27
  $upgrade,
@@ -42,15 +44,28 @@ class Acf
42
  * @created: 23/06/12
43
  */
44
 
45
- function Acf()
46
  {
47
 
48
  // vars
49
  $this->path = plugin_dir_path(__FILE__);
50
  $this->dir = plugins_url('',__FILE__);
51
- $this->version = '3.5.3.1';
52
  $this->upgrade_version = '3.4.1'; // this is the latest version which requires an upgrade
53
  $this->cache = array(); // basic array cache to hold data throughout the page load
 
 
 
 
 
 
 
 
 
 
 
 
 
54
 
55
 
56
  // set text domain
@@ -63,14 +78,15 @@ class Acf
63
 
64
  // actions
65
  add_action('init', array($this, 'init'));
66
- add_filter('post_updated_messages', array($this, 'post_updated_messages'));
67
- add_filter('manage_edit-acf_columns', array($this, 'acf_columns_filter'));
68
-
69
  add_action('admin_menu', array($this,'admin_menu'));
70
  add_action('admin_head', array($this,'admin_head'));
71
  add_action('acf_save_post', array($this, 'acf_save_post'), 10); // save post, called from many places (api, input, everything, options)
72
 
 
 
73
  add_filter('acf_load_field', array($this, 'acf_load_field_defaults'), 5);
 
 
74
 
75
  // ajax
76
  add_action('wp_ajax_get_input_metabox_ids', array($this, 'get_input_metabox_ids'));
@@ -80,6 +96,90 @@ class Acf
80
  }
81
 
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  /*
84
  * get_cache
85
  *
@@ -139,10 +239,6 @@ class Acf
139
 
140
  function setup_fields()
141
  {
142
- // vars
143
- $return = array();
144
-
145
-
146
  // include parent field
147
  include_once('core/fields/acf_field.php');
148
 
@@ -167,29 +263,29 @@ class Acf
167
 
168
 
169
  // add child fields
170
- $return['none'] = new acf_Field($this);
171
- $return['text'] = new acf_Text($this);
172
- $return['textarea'] = new acf_Textarea($this);
173
- $return['wysiwyg'] = new acf_Wysiwyg($this);
174
- $return['image'] = new acf_Image($this);
175
- $return['file'] = new acf_File($this);
176
- $return['number'] = new acf_Number($this);
177
- $return['select'] = new acf_Select($this);
178
- $return['checkbox'] = new acf_Checkbox($this);
179
- $return['radio'] = new acf_Radio($this);
180
- $return['true_false'] = new acf_True_false($this);
181
- $return['page_link'] = new acf_Page_link($this);
182
- $return['post_object'] = new acf_Post_object($this);
183
- $return['relationship'] = new acf_Relationship($this);
184
- $return['date_picker'] = new acf_Date_picker($this);
185
- $return['color_picker'] = new acf_Color_picker($this);
186
 
187
 
188
  // add repeater
189
  if($this->is_field_unlocked('repeater'))
190
  {
191
  include_once('core/fields/repeater.php');
192
- $return['repeater'] = new acf_Repeater($this);
193
  }
194
 
195
 
@@ -197,7 +293,7 @@ class Acf
197
  if($this->is_field_unlocked('flexible_content'))
198
  {
199
  include_once('core/fields/flexible_content.php');
200
- $return['flexible_content'] = new acf_Flexible_content($this);
201
  }
202
 
203
 
@@ -205,7 +301,7 @@ class Acf
205
  if($this->is_field_unlocked('gallery'))
206
  {
207
  include_once('core/fields/gallery.php');
208
- $return['gallery'] = new acf_Gallery($this);
209
  }
210
 
211
 
@@ -219,13 +315,10 @@ class Acf
219
  include($v['url']);
220
  $name = $v['class'];
221
  $custom_field = new $name($this);
222
- $return[$custom_field->name] = $custom_field;
223
  }
224
  }
225
 
226
-
227
- // set all the fields
228
- $this->fields = $return;
229
  }
230
 
231
 
@@ -296,52 +389,6 @@ class Acf
296
  }
297
 
298
 
299
- /*
300
- * Init
301
- *
302
- * @description:
303
- * @since 1.0.0
304
- * @created: 23/06/12
305
- */
306
-
307
- function init()
308
- {
309
- // setup fields
310
- $this->setup_fields();
311
-
312
-
313
- // Create ACF post type
314
- $labels = array(
315
- 'name' => __( 'Field Groups', 'acf' ),
316
- 'singular_name' => __( 'Advanced Custom Fields', 'acf' ),
317
- 'add_new' => __( 'Add New' , 'acf' ),
318
- 'add_new_item' => __( 'Add New Field Group' , 'acf' ),
319
- 'edit_item' => __( 'Edit Field Group' , 'acf' ),
320
- 'new_item' => __( 'New Field Group' , 'acf' ),
321
- 'view_item' => __('View Field Group', 'acf'),
322
- 'search_items' => __('Search Field Groups', 'acf'),
323
- 'not_found' => __('No Field Groups found', 'acf'),
324
- 'not_found_in_trash' => __('No Field Groups found in Trash', 'acf'),
325
- );
326
-
327
- register_post_type('acf', array(
328
- 'labels' => $labels,
329
- 'public' => false,
330
- 'show_ui' => true,
331
- '_builtin' => false,
332
- 'capability_type' => 'page',
333
- 'hierarchical' => true,
334
- 'rewrite' => false,
335
- 'query_var' => "acf",
336
- 'supports' => array(
337
- 'title',
338
- ),
339
- 'show_in_menu' => false,
340
- ));
341
-
342
- }
343
-
344
-
345
  /*
346
  * post_updated_messages
347
  *
@@ -370,26 +417,7 @@ class Acf
370
  );
371
 
372
  return $messages;
373
- }
374
-
375
-
376
- /*
377
- * acf_columns_filter
378
- *
379
- * @description: Custom Columns for ACF
380
- * @since 1.0.0
381
- * @created: 23/06/12
382
- */
383
-
384
- function acf_columns_filter($columns)
385
- {
386
- $columns = array(
387
- 'cb' => '<input type="checkbox" />',
388
- 'title' => __("Title"),
389
- );
390
- return $columns;
391
- }
392
-
393
 
394
 
395
  /*--------------------------------------------------------------------------------------
@@ -403,10 +431,6 @@ class Acf
403
 
404
  function admin_head()
405
  {
406
- // vars
407
- global $post, $pagenow;
408
-
409
-
410
  // hide upgrade page from nav
411
  echo '<style type="text/css">
412
  #toplevel_page_edit-post_type-acf a[href="edit.php?post_type=acf&page=acf-upgrade"]{ display:none; }
@@ -414,7 +438,6 @@ class Acf
414
  #toplevel_page_edit-post_type-acf:hover .wp-menu-image { background-position: 0 -1px; }
415
  #toplevel_page_edit-post_type-acf .wp-menu-image img { display:none; }
416
  </style>';
417
-
418
  }
419
 
420
 
@@ -604,7 +627,7 @@ class Acf
604
 
605
 
606
  // hook to load in registered field groups
607
- $acfs = apply_filters('acf_register_field_group', array());
608
 
609
  if($acfs)
610
  {
@@ -954,28 +977,6 @@ class Acf
954
  }
955
 
956
 
957
- /*--------------------------------------------------------------------------------------
958
- *
959
- * update_field
960
- *
961
- * @author Elliot Condon
962
- * @since 3.0.0
963
- *
964
- *-------------------------------------------------------------------------------------*/
965
-
966
- function update_field($post_id, $field)
967
- {
968
- // apply filters
969
- $field = apply_filters('acf_save_field', $field );
970
- $field = apply_filters('acf_save_field-' . $field['type'], $field );
971
-
972
- // format the field (select, repeater, etc)
973
- //$field = $this->pre_save_field($field);
974
-
975
- // save it!
976
- update_post_meta($post_id, $field['key'], $field);
977
- }
978
-
979
 
980
  /*--------------------------------------------------------------------------------------
981
  *
@@ -1028,7 +1029,11 @@ class Acf
1028
 
1029
 
1030
  // set value
1031
- $field['value'] = $this->get_value($post_id, $field);
 
 
 
 
1032
 
1033
  $required_class = "";
1034
  $required_label = "";
@@ -1331,22 +1336,22 @@ class Acf
1331
 
1332
  if( $rule['value'] == 'parent')
1333
  {
1334
- $post_parent = $post->post_parent;
1335
- if( isset($overrides['page_parent']) )
1336
- {
1337
- $post_parent = (int) $overrides['page_parent'];
1338
- }
1339
 
1340
  if( $rule['operator'] == "==" )
1341
  {
1342
- if( $post_parent == 0 )
1343
  {
1344
  return true;
1345
  }
1346
  }
1347
  elseif( $rule['operator'] == "!=" )
1348
  {
1349
- if( $post_parent != 0 )
1350
  {
1351
  return true;
1352
  }
@@ -1544,7 +1549,14 @@ class Acf
1544
  global $plugin_page;
1545
 
1546
 
1547
- // value has changed in 3.5.1 to a acf-options-$title
 
 
 
 
 
 
 
1548
  if( substr($rule['value'], 0, 11) != 'acf-options' )
1549
  {
1550
  $rule['value'] = 'acf-options-' . sanitize_title( $rule['value'] );
@@ -1804,7 +1816,19 @@ class Acf
1804
 
1805
  function get_license_key($field_name)
1806
  {
1807
- return get_option('acf_' . $field_name . '_ac');
 
 
 
 
 
 
 
 
 
 
 
 
1808
  }
1809
 
1810
 
@@ -1992,4 +2016,4 @@ class Acf
1992
  return ' (' . $lang . ')';
1993
  }*/
1994
  }
1995
- ?>
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.4.1
7
  Author: Elliot Condon
8
  Author URI: http://www.elliotcondon.com/
9
  License: GPL
22
  $upgrade_version,
23
  $fields,
24
  $cache,
25
+ $defaults,
26
+
27
 
28
  // controllers
29
  $upgrade,
44
  * @created: 23/06/12
45
  */
46
 
47
+ function __construct()
48
  {
49
 
50
  // vars
51
  $this->path = plugin_dir_path(__FILE__);
52
  $this->dir = plugins_url('',__FILE__);
53
+ $this->version = '3.5.4.1';
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(
57
+ 'options_page' => array(
58
+ 'capability' => 'edit_posts', // capability to view options page
59
+ 'title' => __('Options','acf'), // title / menu name ('Site Options')
60
+ 'pages' => array(), // an array of sub pages ('Header, Footer, Home, etc')
61
+ ),
62
+ 'activation_codes' => array(
63
+ 'repeater' => '', // activation code for the repeater add-on (XXXX-XXXX-XXXX-XXXX)
64
+ 'options_page' => '', // activation code for the options page add-on (XXXX-XXXX-XXXX-XXXX)
65
+ 'flexible_content' => '', // activation code for the flexible content add-on (XXXX-XXXX-XXXX-XXXX)
66
+ 'gallery' => '', // activation code for the gallery add-on (XXXX-XXXX-XXXX-XXXX)
67
+ ),
68
+ );
69
 
70
 
71
  // set text domain
78
 
79
  // actions
80
  add_action('init', array($this, 'init'));
 
 
 
81
  add_action('admin_menu', array($this,'admin_menu'));
82
  add_action('admin_head', array($this,'admin_head'));
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
+ // filters
87
  add_filter('acf_load_field', array($this, 'acf_load_field_defaults'), 5);
88
+ add_filter('post_updated_messages', array($this, 'post_updated_messages'));
89
+
90
 
91
  // ajax
92
  add_action('wp_ajax_get_input_metabox_ids', array($this, 'get_input_metabox_ids'));
96
  }
97
 
98
 
99
+ /*
100
+ * Init
101
+ *
102
+ * @description:
103
+ * @since 1.0.0
104
+ * @created: 23/06/12
105
+ */
106
+
107
+ function init()
108
+ {
109
+ // setup defaults
110
+ $this->defaults = apply_filters('acf_settings', $this->defaults);
111
+
112
+
113
+ // allow for older filters
114
+ $this->defaults['options_page']['title'] = apply_filters('acf_options_page_title', $this->defaults['options_page']['title']);
115
+
116
+
117
+ // setup fields
118
+ $this->setup_fields();
119
+
120
+
121
+ // Create ACF post type
122
+ $labels = array(
123
+ 'name' => __( 'Field&nbsp;Groups', 'acf' ),
124
+ 'singular_name' => __( 'Advanced Custom Fields', 'acf' ),
125
+ 'add_new' => __( 'Add New' , 'acf' ),
126
+ 'add_new_item' => __( 'Add New Field Group' , 'acf' ),
127
+ 'edit_item' => __( 'Edit Field Group' , 'acf' ),
128
+ 'new_item' => __( 'New Field Group' , 'acf' ),
129
+ 'view_item' => __('View Field Group', 'acf'),
130
+ 'search_items' => __('Search Field Groups', 'acf'),
131
+ 'not_found' => __('No Field Groups found', 'acf'),
132
+ 'not_found_in_trash' => __('No Field Groups found in Trash', 'acf'),
133
+ );
134
+
135
+ register_post_type('acf', array(
136
+ 'labels' => $labels,
137
+ 'public' => false,
138
+ 'show_ui' => true,
139
+ '_builtin' => false,
140
+ 'capability_type' => 'page',
141
+ 'hierarchical' => true,
142
+ 'rewrite' => false,
143
+ 'query_var' => "acf",
144
+ 'supports' => array(
145
+ 'title',
146
+ ),
147
+ 'show_in_menu' => false,
148
+ ));
149
+
150
+
151
+ // register acf scripts
152
+ $scripts = array(
153
+ 'acf-fields' => $this->dir . '/js/fields.js',
154
+ 'acf-input-actions' => $this->dir . '/js/input-actions.js',
155
+ 'acf-input-ajax' => $this->dir . '/js/input-ajax.js',
156
+ 'acf-datepicker' => $this->dir . '/core/fields/date_picker/jquery.ui.datepicker.js',
157
+ );
158
+
159
+ foreach( $scripts as $k => $v )
160
+ {
161
+ wp_register_script( $k, $v, array('jquery'), $this->version );
162
+ }
163
+
164
+
165
+ // register acf styles
166
+ $styles = array(
167
+ 'acf' => $this->dir . '/css/acf.css',
168
+ 'acf-fields' => $this->dir . '/css/fields.css',
169
+ 'acf-global' => $this->dir . '/css/global.css',
170
+ 'acf-input' => $this->dir . '/css/input.css',
171
+ 'acf-datepicker' => $this->dir . '/core/fields/date_picker/style.date_picker.css',
172
+ );
173
+
174
+ foreach( $styles as $k => $v )
175
+ {
176
+ wp_register_style( $k, $v, false, $this->version );
177
+ }
178
+
179
+
180
+ }
181
+
182
+
183
  /*
184
  * get_cache
185
  *
239
 
240
  function setup_fields()
241
  {
 
 
 
 
242
  // include parent field
243
  include_once('core/fields/acf_field.php');
244
 
263
 
264
 
265
  // add child fields
266
+ $this->fields['none'] = new acf_Field($this);
267
+ $this->fields['text'] = new acf_Text($this);
268
+ $this->fields['textarea'] = new acf_Textarea($this);
269
+ $this->fields['wysiwyg'] = new acf_Wysiwyg($this);
270
+ $this->fields['image'] = new acf_Image($this);
271
+ $this->fields['file'] = new acf_File($this);
272
+ $this->fields['number'] = new acf_Number($this);
273
+ $this->fields['select'] = new acf_Select($this);
274
+ $this->fields['checkbox'] = new acf_Checkbox($this);
275
+ $this->fields['radio'] = new acf_Radio($this);
276
+ $this->fields['true_false'] = new acf_True_false($this);
277
+ $this->fields['page_link'] = new acf_Page_link($this);
278
+ $this->fields['post_object'] = new acf_Post_object($this);
279
+ $this->fields['relationship'] = new acf_Relationship($this);
280
+ $this->fields['date_picker'] = new acf_Date_picker($this);
281
+ $this->fields['color_picker'] = new acf_Color_picker($this);
282
 
283
 
284
  // add repeater
285
  if($this->is_field_unlocked('repeater'))
286
  {
287
  include_once('core/fields/repeater.php');
288
+ $this->fields['repeater'] = new acf_Repeater($this);
289
  }
290
 
291
 
293
  if($this->is_field_unlocked('flexible_content'))
294
  {
295
  include_once('core/fields/flexible_content.php');
296
+ $this->fields['flexible_content'] = new acf_Flexible_content($this);
297
  }
298
 
299
 
301
  if($this->is_field_unlocked('gallery'))
302
  {
303
  include_once('core/fields/gallery.php');
304
+ $this->fields['gallery'] = new acf_Gallery($this);
305
  }
306
 
307
 
315
  include($v['url']);
316
  $name = $v['class'];
317
  $custom_field = new $name($this);
318
+ $this->fields[$custom_field->name] = $custom_field;
319
  }
320
  }
321
 
 
 
 
322
  }
323
 
324
 
389
  }
390
 
391
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
392
  /*
393
  * post_updated_messages
394
  *
417
  );
418
 
419
  return $messages;
420
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
421
 
422
 
423
  /*--------------------------------------------------------------------------------------
431
 
432
  function admin_head()
433
  {
 
 
 
 
434
  // hide upgrade page from nav
435
  echo '<style type="text/css">
436
  #toplevel_page_edit-post_type-acf a[href="edit.php?post_type=acf&page=acf-upgrade"]{ display:none; }
438
  #toplevel_page_edit-post_type-acf:hover .wp-menu-image { background-position: 0 -1px; }
439
  #toplevel_page_edit-post_type-acf .wp-menu-image img { display:none; }
440
  </style>';
 
441
  }
442
 
443
 
627
 
628
 
629
  // hook to load in registered field groups
630
+ $acfs = $this->get_field_groups();
631
 
632
  if($acfs)
633
  {
977
  }
978
 
979
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
980
 
981
  /*--------------------------------------------------------------------------------------
982
  *
1029
 
1030
 
1031
  // set value
1032
+ if( ! isset($field['value']) )
1033
+ {
1034
+ $field['value'] = $this->get_value($post_id, $field);
1035
+ }
1036
+
1037
 
1038
  $required_class = "";
1039
  $required_label = "";
1336
 
1337
  if( $rule['value'] == 'parent')
1338
  {
1339
+ $children = get_pages(array(
1340
+ 'post_type' => $post->post_type,
1341
+ 'child_of' => $post->ID,
1342
+ ));
1343
+
1344
 
1345
  if( $rule['operator'] == "==" )
1346
  {
1347
+ if( count($children) > 0 )
1348
  {
1349
  return true;
1350
  }
1351
  }
1352
  elseif( $rule['operator'] == "!=" )
1353
  {
1354
+ if( count($children) == 0 )
1355
  {
1356
  return true;
1357
  }
1549
  global $plugin_page;
1550
 
1551
 
1552
+ // older location rules may be "options-pagename"
1553
+ if( substr($rule['value'], 0, 8) == 'options-' )
1554
+ {
1555
+ $rule['value'] = 'acf-' . $rule['value'];
1556
+ }
1557
+
1558
+
1559
+ // older location ruels may be "Pagename"
1560
  if( substr($rule['value'], 0, 11) != 'acf-options' )
1561
  {
1562
  $rule['value'] = 'acf-options-' . sanitize_title( $rule['value'] );
1816
 
1817
  function get_license_key($field_name)
1818
  {
1819
+ $value = '';
1820
+
1821
+ if( isset( $this->defaults['activation_codes'][ $field_name ] ) )
1822
+ {
1823
+ $value = $this->defaults['activation_codes'][ $field_name ];
1824
+ }
1825
+
1826
+ if( !$value )
1827
+ {
1828
+ $value = get_option('acf_' . $field_name . '_ac');
1829
+ }
1830
+
1831
+ return $value;
1832
  }
1833
 
1834
 
2016
  return ' (' . $lang . ')';
2017
  }*/
2018
  }
2019
+ ?>
core/api.php CHANGED
@@ -465,26 +465,23 @@ add_filter('acf_register_field_group', 'acf_register_field_group');
465
  *
466
  *-------------------------------------------------------------------------------------*/
467
 
468
- $GLOBALS['acf_register_options_page'] = array();
469
 
470
- function register_options_page($title = "")
471
  {
472
- $GLOBALS['acf_register_options_page'][] = $title;
473
  }
474
 
475
- function acf_register_options_page($array)
 
476
  {
477
- if( empty($GLOBALS['acf_register_options_page']) )
478
- {
479
- return $array;
480
- }
481
 
482
- $array = array_merge($array, $GLOBALS['acf_register_options_page']);
483
-
484
- return $array;
485
- }
486
- add_filter('acf_register_options_page', 'acf_register_options_page');
487
 
 
 
 
488
 
489
 
490
  /*--------------------------------------------------------------------------------------
@@ -614,7 +611,7 @@ function acf_form_wp_head()
614
 
615
  // Javascript
616
  echo '<script type="text/javascript" src="'.$acf->dir.'/js/input-actions.js?ver=' . $acf->version . '" ></script>';
617
- echo '<script type="text/javascript">acf.post_id = ' . $post->ID . ';</script>';
618
 
619
 
620
  // add user js + css
@@ -677,6 +674,7 @@ function acf_form($options = null)
677
 
678
  // display form
679
  ?>
 
680
  <form action="" id="post" method="post" <?php if($options['form_attributes']){foreach($options['form_attributes'] as $k => $v){echo $k . '="' . $v .'" '; }} ?>>
681
  <div style="display:none">
682
  <input type="hidden" name="acf_save" value="true" />
@@ -790,15 +788,34 @@ function update_field($field_key, $value, $post_id = false)
790
  // backup if no field was found, save as a text field
791
  if( !$field )
792
  {
793
- return false;
 
 
 
794
  }
795
 
796
-
797
  // sub fields? They need formatted data
798
- $value = acf_convert_field_names_to_keys( $value, $field );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
799
 
 
800
  $acf->update_value($post_id, $field, $value);
801
 
 
802
  return true;
803
 
804
  }
465
  *
466
  *-------------------------------------------------------------------------------------*/
467
 
468
+ $GLOBALS['acf_options_pages'] = array();
469
 
470
+ function register_options_page( $title = "" )
471
  {
472
+ $GLOBALS['acf_options_pages'][] = $title;
473
  }
474
 
475
+
476
+ function acf_settings_options_pages( $options )
477
  {
478
+ // merge in options pages
479
+ $options['options_page']['pages'] = array_merge( $options['options_page']['pages'], $GLOBALS['acf_options_pages'] );
 
 
480
 
 
 
 
 
 
481
 
482
+ return $options;
483
+ }
484
+ add_filter('acf_settings', 'acf_settings_options_pages');
485
 
486
 
487
  /*--------------------------------------------------------------------------------------
611
 
612
  // Javascript
613
  echo '<script type="text/javascript" src="'.$acf->dir.'/js/input-actions.js?ver=' . $acf->version . '" ></script>';
614
+
615
 
616
 
617
  // add user js + css
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" />
788
  // backup if no field was found, save as a text field
789
  if( !$field )
790
  {
791
+ $field = array(
792
+ 'type' => 'none',
793
+ 'name' => $field_key
794
+ );
795
  }
796
 
797
+
798
  // sub fields? They need formatted data
799
+ if( $field['type'] == 'repeater' )
800
+ {
801
+ $value = acf_convert_field_names_to_keys( $value, $field );
802
+ }
803
+ elseif( $field['type'] == 'flexible_content' )
804
+ {
805
+ if( $field['layouts'] )
806
+ {
807
+ foreach( $field['layouts'] as $layout )
808
+ {
809
+ $value = acf_convert_field_names_to_keys( $value, $layout );
810
+ }
811
+ }
812
+ }
813
+
814
 
815
+ // save
816
  $acf->update_value($post_id, $field, $value);
817
 
818
+
819
  return true;
820
 
821
  }
core/controllers/everything_fields.php CHANGED
@@ -1,15 +1,5 @@
1
  <?php
2
 
3
- /*--------------------------------------------------------------------------
4
- *
5
- * Everything_fields
6
- *
7
- * @author Elliot Condon
8
- * @since 3.1.8
9
- *
10
- *-------------------------------------------------------------------------*/
11
-
12
-
13
  class acf_everything_fields
14
  {
15
 
@@ -59,6 +49,45 @@ class acf_everything_fields
59
 
60
  add_filter("attachment_fields_to_save", array($this, 'save_attachment'), null , 2);
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  }
63
 
64
 
@@ -76,16 +105,30 @@ class acf_everything_fields
76
 
77
  global $pagenow;
78
 
79
- // we dont want to waste php memory, only check for pages we care about
80
- if( !in_array( $pagenow, array( 'edit-tags.php', 'profile.php', 'user-new.php', 'user-edit.php', 'media.php' ) ) )
81
- {
82
- return false;
83
- }
84
 
85
 
86
  // set page type
87
  $options = array();
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  if( $pagenow == "edit-tags.php" && isset($_GET['taxonomy']) )
90
  {
91
 
@@ -163,11 +206,10 @@ class acf_everything_fields
163
  // some fields require js + css
164
  do_action('acf_print_scripts-input');
165
  do_action('acf_print_styles-input');
166
-
167
 
168
  // Add admin head
169
- add_action('admin_head-'.$pagenow, array($this,'admin_head'));
170
- //add_action('admin_footer-'.$pagenow, array($this,'admin_footer'));
171
 
172
 
173
  }
@@ -187,16 +229,6 @@ class acf_everything_fields
187
  global $pagenow;
188
 
189
 
190
- // Style
191
- echo '<link rel="stylesheet" type="text/css" href="'.$this->parent->dir.'/css/global.css?ver=' . $this->parent->version . '" />';
192
- echo '<link rel="stylesheet" type="text/css" href="'.$this->parent->dir.'/css/input.css?ver=' . $this->parent->version . '" />';
193
-
194
-
195
- // Javascript
196
- echo '<script type="text/javascript" src="'.$this->parent->dir.'/js/input-actions.js?ver=' . $this->parent->version . '" ></script>';
197
- echo '<script type="text/javascript">acf.post_id = 0;</script>';
198
-
199
-
200
  // add user js + css
201
  do_action('acf_head-input');
202
 
@@ -234,6 +266,10 @@ class acf_everything_fields
234
  echo "$('#your-profile > p.submit').before( html );";
235
  }
236
  }
 
 
 
 
237
  elseif($this->data['page_type'] == "taxonomy")
238
  {
239
  if($this->data['page_action'] == "add")
@@ -335,6 +371,23 @@ class acf_everything_fields
335
  }
336
 
337
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
338
  /*--------------------------------------------------------------------------------------
339
  *
340
  * acf_everything_fields
@@ -368,6 +421,18 @@ class acf_everything_fields
368
  $acfs = $this->parent->get_field_groups();
369
 
370
 
 
 
 
 
 
 
 
 
 
 
 
 
371
  if($acfs)
372
  {
373
  foreach($acfs as $acf)
@@ -385,21 +450,30 @@ class acf_everything_fields
385
  continue;
386
  }
387
 
 
 
 
 
 
 
 
 
 
 
388
 
389
  // title
390
- if( $options['page_action'] == "edit" && $options['page_type'] != "media")
391
  {
392
- if ( is_numeric( $acf['id'] ) )
393
- {
394
- echo '<h3>' . get_the_title( $acf['id'] ) . '</h3>';
395
- }
396
- else
397
- {
398
- echo '<h3>' . apply_filters( 'the_title', $acf['title'] ) . '</h3>';
399
- }
400
  echo '<table class="form-table">';
401
  }
402
-
 
 
 
 
 
 
403
 
404
  // render
405
  foreach($acf['fields'] as $field)
@@ -426,7 +500,22 @@ class acf_everything_fields
426
  $required_label = ' <span class="required">*</span>';
427
  }
428
 
429
- if( $options['page_type'] == "taxonomy" && $options['page_action'] == "add")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
430
  {
431
  echo '<div id="acf-' . $field['name'] . '" class="form-field field field-' . $field['type'] . ' field-'.$field['key'] . $required_class . '">';
432
  echo '<label for="fields[' . $field['key'] . ']">' . $field['label'] . $required_label . '</label>';
@@ -443,7 +532,7 @@ class acf_everything_fields
443
  $field['name'] = 'fields[' . $field['key'] . ']';
444
  $this->parent->create_field($field);
445
 
446
- if($field['instructions']) echo '<span class="description">' . $field['instructions'] . '</span>';
447
  echo '</td>';
448
  echo '</tr>';
449
 
@@ -459,6 +548,10 @@ class acf_everything_fields
459
  {
460
  echo '</table>';
461
  }
 
 
 
 
462
  }
463
  // foreach($acfs as $acf)
464
  }
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
3
  class acf_everything_fields
4
  {
5
 
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
+
57
+ /*
58
+ * validate_page
59
+ *
60
+ * @description: returns true | false. Used to stop a function from continuing
61
+ * @since 3.2.6
62
+ * @created: 23/06/12
63
+ */
64
+
65
+ function validate_page()
66
+ {
67
+ // global
68
+ global $pagenow;
69
+
70
+
71
+ // vars
72
+ $return = false;
73
+
74
+
75
+ // validate page
76
+ if( in_array( $pagenow, array( 'edit-tags.php', 'profile.php', 'user-new.php', 'user-edit.php', 'media.php' ) ) )
77
+ {
78
+ $return = true;
79
+ }
80
+
81
+
82
+ // validate page (Shopp)
83
+ if( $pagenow == "admin.php" && isset( $_GET['page'], $_GET['id'] ) && $_GET['page'] == "shopp-categories" )
84
+ {
85
+ $return = true;
86
+ }
87
+
88
+
89
+ // return
90
+ return $return;
91
  }
92
 
93
 
105
 
106
  global $pagenow;
107
 
108
+
109
+ // validate page
110
+ if( ! $this->validate_page() ) return;
 
 
111
 
112
 
113
  // set page type
114
  $options = array();
115
 
116
+ if( $pagenow == "admin.php" && isset( $_GET['page'], $_GET['id'] ) && $_GET['page'] == "shopp-categories" )
117
+ {
118
+
119
+ $this->data['page_type'] = "shopp_category";
120
+ $options['ef_taxonomy'] = "shopp_category";
121
+
122
+ $this->data['page_action'] = "add";
123
+ $this->data['option_name'] = "";
124
+
125
+ if( $_GET['id'] != "new" )
126
+ {
127
+ $this->data['page_action'] = "edit";
128
+ $this->data['option_name'] = "shopp_category_" . $_GET['id'];
129
+ }
130
+
131
+ }
132
  if( $pagenow == "edit-tags.php" && isset($_GET['taxonomy']) )
133
  {
134
 
206
  // some fields require js + css
207
  do_action('acf_print_scripts-input');
208
  do_action('acf_print_styles-input');
209
+
210
 
211
  // Add admin head
212
+ add_action('admin_head', array($this,'admin_head'));
 
213
 
214
 
215
  }
229
  global $pagenow;
230
 
231
 
 
 
 
 
 
 
 
 
 
 
232
  // add user js + css
233
  do_action('acf_head-input');
234
 
266
  echo "$('#your-profile > p.submit').before( html );";
267
  }
268
  }
269
+ elseif($this->data['page_type'] == "shopp_category")
270
+ {
271
+ echo "$('#post-body-content').append( html );";
272
+ }
273
  elseif($this->data['page_type'] == "taxonomy")
274
  {
275
  if($this->data['page_action'] == "add")
371
  }
372
 
373
 
374
+ /*
375
+ * shopp_category_saved
376
+ *
377
+ * @description:
378
+ * @since 3.5.2
379
+ * @created: 27/11/12
380
+ */
381
+
382
+ function shopp_category_saved( $category )
383
+ {
384
+ // $post_id to save against
385
+ $post_id = 'shopp_category_' . $category->id;
386
+
387
+ do_action('acf_save_post', $post_id);
388
+ }
389
+
390
+
391
  /*--------------------------------------------------------------------------------------
392
  *
393
  * acf_everything_fields
421
  $acfs = $this->parent->get_field_groups();
422
 
423
 
424
+ // layout
425
+ $layout = 'tr';
426
+ if( $options['page_type'] == "taxonomy" && $options['page_action'] == "add")
427
+ {
428
+ $layout = 'div';
429
+ }
430
+ if( $options['page_type'] == "shopp_category")
431
+ {
432
+ $layout = 'metabox';
433
+ }
434
+
435
+
436
  if($acfs)
437
  {
438
  foreach($acfs as $acf)
450
  continue;
451
  }
452
 
453
+ $title = "";
454
+ if ( is_numeric( $acf['id'] ) )
455
+ {
456
+ $title = get_the_title( $acf['id'] );
457
+ }
458
+ else
459
+ {
460
+ $title = apply_filters( 'the_title', $acf['title'] );
461
+ }
462
+
463
 
464
  // title
465
+ if( $options['page_action'] == "edit" && !in_array($options['page_type'], array('media', 'shopp_category')) )
466
  {
467
+ echo '<h3>' .$title . '</h3>';
 
 
 
 
 
 
 
468
  echo '<table class="form-table">';
469
  }
470
+ elseif( $layout == 'metabox' )
471
+ {
472
+ echo '<div class="postbox acf_postbox" id="acf_'. $acf['id'] .'">';
473
+ echo '<div title="Click to toggle" class="handlediv"><br></div><h3 class="hndle"><span>' . $title . '</span></h3>';
474
+ echo '<div class="inside">';
475
+ }
476
+
477
 
478
  // render
479
  foreach($acf['fields'] as $field)
500
  $required_label = ' <span class="required">*</span>';
501
  }
502
 
503
+
504
+ if( $layout == 'metabox' )
505
+ {
506
+ echo '<div id="acf-' . $field['name'] . '" class="field field-' . $field['type'] . ' field-'.$field['key'] . $required_class . '">';
507
+
508
+ echo '<p class="label">';
509
+ echo '<label for="fields[' . $field['key'] . ']">' . $field['label'] . $required_label . '</label>';
510
+ echo $field['instructions'];
511
+ echo '</p>';
512
+
513
+ $field['name'] = 'fields[' . $field['key'] . ']';
514
+ $this->parent->create_field($field);
515
+
516
+ echo '</div>';
517
+ }
518
+ elseif( $layout == 'div' )
519
  {
520
  echo '<div id="acf-' . $field['name'] . '" class="form-field field field-' . $field['type'] . ' field-'.$field['key'] . $required_class . '">';
521
  echo '<label for="fields[' . $field['key'] . ']">' . $field['label'] . $required_label . '</label>';
532
  $field['name'] = 'fields[' . $field['key'] . ']';
533
  $this->parent->create_field($field);
534
 
535
+ if($field['instructions']) echo '<p class="description">' . $field['instructions'] . '</p>';
536
  echo '</td>';
537
  echo '</tr>';
538
 
548
  {
549
  echo '</table>';
550
  }
551
+ elseif( $options['page_type'] == 'shopp_category' )
552
+ {
553
+ echo '</div></div>';
554
+ }
555
  }
556
  // foreach($acfs as $acf)
557
  }
core/controllers/field_group.php CHANGED
@@ -31,10 +31,6 @@ class acf_field_group
31
  $this->parent = $parent;
32
 
33
 
34
- // filters
35
- add_filter('name_save_pre', array($this, 'save_name'));
36
-
37
-
38
  // actions
39
  add_action('admin_print_scripts', array($this,'admin_print_scripts'));
40
  add_action('admin_print_styles', array($this,'admin_print_styles'));
@@ -42,9 +38,15 @@ class acf_field_group
42
  add_action('save_post', array($this, 'save_post'));
43
 
44
 
 
 
 
 
 
45
  // ajax
46
  add_action('wp_ajax_acf_field_options', array($this, 'ajax_acf_field_options'));
47
  add_action('wp_ajax_acf_location', array($this, 'ajax_acf_location'));
 
48
  }
49
 
50
 
@@ -82,8 +84,7 @@ class acf_field_group
82
  // return
83
  return $return;
84
  }
85
-
86
-
87
 
88
  /*
89
  * admin_print_scripts
@@ -98,7 +99,17 @@ class acf_field_group
98
  // validate page
99
  if( ! $this->validate_page() ) return;
100
 
 
 
101
  wp_dequeue_script( 'autosave' );
 
 
 
 
 
 
 
 
102
  do_action('acf_print_scripts-fields');
103
  }
104
 
@@ -116,7 +127,16 @@ class acf_field_group
116
  // validate page
117
  if( ! $this->validate_page() ) return;
118
 
 
 
 
 
 
 
 
 
119
  do_action('acf_print_styles-fields');
 
120
  }
121
 
122
 
@@ -134,13 +154,10 @@ class acf_field_group
134
  if( ! $this->validate_page() ) return;
135
 
136
 
137
- // add acf fields js + css
138
- echo '<script type="text/javascript" src="' . $this->parent->dir . '/js/fields.js?ver=' . $this->parent->version . '" ></script>';
139
- echo '<link rel="stylesheet" type="text/css" href="' . $this->parent->dir . '/css/global.css?ver=' . $this->parent->version . '" />';
140
- echo '<link rel="stylesheet" type="text/css" href="' . $this->parent->dir . '/css/fields.css?ver=' . $this->parent->version . '" />';
141
 
142
 
143
- // add user js + css
144
  do_action('acf_head-fields');
145
 
146
 
@@ -467,12 +484,13 @@ class acf_field_group
467
 
468
  case "options_page" :
469
 
 
 
470
  $choices = array(
471
- 'acf-options' => apply_filters( 'acf_options_page_title', __('Options','acf') )
472
  );
473
 
474
-
475
- $titles = apply_filters( 'acf_register_options_page', array() );
476
  if( !empty($titles) )
477
  {
478
  $choices = array();
@@ -599,34 +617,46 @@ class acf_field_group
599
  */
600
 
601
 
602
- // get all keys to find fields
603
  $dont_delete = array();
604
 
 
 
605
  if( $_POST['fields'] )
606
  {
607
  $i = -1;
608
 
 
609
  // remove clone field
610
  unset( $_POST['fields']['field_clone'] );
611
 
 
612
  // loop through and save fields
613
  foreach( $_POST['fields'] as $key => $field )
614
  {
615
  $i++;
616
 
617
- // add to dont delete array
618
- $dont_delete[] = $key;
619
 
620
- // order
621
  $field['order_no'] = $i;
622
  $field['key'] = $key;
623
 
624
 
625
- // update field
626
- $this->parent->update_field($post_id, $field);
 
 
 
 
 
 
 
 
 
627
  }
628
  }
629
 
 
630
  // delete all other field
631
  $keys = get_post_custom_keys($post_id);
632
  foreach( $keys as $key )
@@ -644,11 +674,6 @@ class acf_field_group
644
  */
645
 
646
  $location = $_POST['location'];
647
-
648
- if( ! isset($location['allorany']) )
649
- {
650
- $location['allorany'] = 'all';
651
- }
652
  update_post_meta($post_id, 'allorany', $location['allorany']);
653
 
654
  delete_post_meta($post_id, 'rule');
@@ -679,8 +704,43 @@ class acf_field_group
679
 
680
 
681
  }
 
682
 
 
 
 
 
 
 
 
683
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
684
 
685
  }
686
 
31
  $this->parent = $parent;
32
 
33
 
 
 
 
 
34
  // actions
35
  add_action('admin_print_scripts', array($this,'admin_print_scripts'));
36
  add_action('admin_print_styles', array($this,'admin_print_styles'));
38
  add_action('save_post', array($this, 'save_post'));
39
 
40
 
41
+ // filters
42
+ add_filter('name_save_pre', array($this, 'save_name'));
43
+ //add_filter('acf_save_field', array($this, 'acf_save_field'));
44
+
45
+
46
  // ajax
47
  add_action('wp_ajax_acf_field_options', array($this, 'ajax_acf_field_options'));
48
  add_action('wp_ajax_acf_location', array($this, 'ajax_acf_location'));
49
+ add_action('wp_ajax_acf_next_field_id', array($this, 'ajax_acf_next_field_id'));
50
  }
51
 
52
 
84
  // return
85
  return $return;
86
  }
87
+
 
88
 
89
  /*
90
  * admin_print_scripts
99
  // validate page
100
  if( ! $this->validate_page() ) return;
101
 
102
+
103
+ // no autosave
104
  wp_dequeue_script( 'autosave' );
105
+
106
+
107
+ // custom scripts
108
+ wp_enqueue_script(array(
109
+ 'acf-fields',
110
+ ));
111
+
112
+
113
  do_action('acf_print_scripts-fields');
114
  }
115
 
127
  // validate page
128
  if( ! $this->validate_page() ) return;
129
 
130
+
131
+ // custom styles
132
+ wp_enqueue_style(array(
133
+ 'acf-global',
134
+ 'acf-fields',
135
+ ));
136
+
137
+
138
  do_action('acf_print_styles-fields');
139
+
140
  }
141
 
142
 
154
  if( ! $this->validate_page() ) return;
155
 
156
 
157
+ // add js vars
158
+ echo '<script type="text/javascript">acf.nonce = "' . wp_create_nonce( 'acf_nonce' ) . '";</script>';
 
 
159
 
160
 
 
161
  do_action('acf_head-fields');
162
 
163
 
484
 
485
  case "options_page" :
486
 
487
+ $defaults = $this->parent->defaults['options_page'];
488
+
489
  $choices = array(
490
+ 'acf-options' => $defaults['title']
491
  );
492
 
493
+ $titles = $defaults['pages'];
 
494
  if( !empty($titles) )
495
  {
496
  $choices = array();
617
  */
618
 
619
 
620
+ // vars
621
  $dont_delete = array();
622
 
623
+
624
+
625
  if( $_POST['fields'] )
626
  {
627
  $i = -1;
628
 
629
+
630
  // remove clone field
631
  unset( $_POST['fields']['field_clone'] );
632
 
633
+
634
  // loop through and save fields
635
  foreach( $_POST['fields'] as $key => $field )
636
  {
637
  $i++;
638
 
 
 
639
 
640
+ // order + key
641
  $field['order_no'] = $i;
642
  $field['key'] = $key;
643
 
644
 
645
+ // apply filters
646
+ $field = apply_filters('acf_save_field', $field );
647
+ $field = apply_filters('acf_save_field-' . $field['type'], $field );
648
+
649
+
650
+ // save it!
651
+ update_post_meta($post_id, $field['key'], $field);
652
+
653
+
654
+ // add to dont delete array
655
+ $dont_delete[] = $field['key'];
656
  }
657
  }
658
 
659
+
660
  // delete all other field
661
  $keys = get_post_custom_keys($post_id);
662
  foreach( $keys as $key )
674
  */
675
 
676
  $location = $_POST['location'];
 
 
 
 
 
677
  update_post_meta($post_id, 'allorany', $location['allorany']);
678
 
679
  delete_post_meta($post_id, 'rule');
704
 
705
 
706
  }
707
+
708
 
709
+ /*
710
+ * ajax_next_field_id
711
+ *
712
+ * @description:
713
+ * @since: 2.0.4
714
+ * @created: 5/12/12
715
+ */
716
 
717
+ function ajax_acf_next_field_id()
718
+ {
719
+ // vars
720
+ $options = array(
721
+ 'nonce' => '',
722
+ );
723
+ $options = array_merge($options, $_POST);
724
+
725
+
726
+ // verify nonce
727
+ if( ! wp_verify_nonce($options['nonce'], 'acf_nonce') )
728
+ {
729
+ die('0');
730
+ }
731
+
732
+
733
+ // get next id
734
+ $next_id = (int) get_option('acf_next_field_id', 1);
735
+
736
+
737
+ // update the acf_next_field_id
738
+ update_option('acf_next_field_id', ($next_id + 1) );
739
+
740
+
741
+ // return id
742
+ die('field_' . $next_id);
743
+ }
744
 
745
  }
746
 
core/controllers/field_groups.php CHANGED
@@ -1,15 +1,5 @@
1
  <?php
2
 
3
- /*--------------------------------------------------------------------------
4
- *
5
- * Field_groups
6
- *
7
- * @author Elliot Condon
8
- * @since 3.2.6
9
- *
10
- *-------------------------------------------------------------------------*/
11
-
12
-
13
  class acf_field_groups
14
  {
15
 
@@ -113,8 +103,10 @@ class acf_field_groups
113
 
114
  function admin_print_scripts()
115
  {
116
- wp_enqueue_script( 'jquery' );
117
- wp_enqueue_script( 'thickbox' );
 
 
118
  }
119
 
120
 
@@ -128,7 +120,11 @@ class acf_field_groups
128
 
129
  function admin_print_styles()
130
  {
131
- wp_enqueue_style( 'thickbox' );
 
 
 
 
132
  }
133
 
134
 
@@ -141,7 +137,11 @@ class acf_field_groups
141
 
142
  function acf_edit_columns( $columns )
143
  {
144
- $columns['fields'] = __("Fields", 'acf');
 
 
 
 
145
 
146
  return $columns;
147
  }
@@ -225,45 +225,41 @@ class acf_field_groups
225
  function admin_footer()
226
  {
227
  ?>
228
- <link rel="stylesheet" type="text/css" href="<?php echo $this->parent->dir; ?>/css/global.css" />
229
- <link rel="stylesheet" type="text/css" href="<?php echo $this->parent->dir; ?>/css/acf.css" />
230
- <div id="acf-col-right" class="hidden">
231
-
232
- <div class="wp-box">
233
- <div class="inner">
234
- <h3 class="h2"><?php _e("Advanced Custom Fields",'acf'); ?> <span>v<?php echo $this->parent->version; ?></span></h3>
235
-
236
- <h3><?php _e("Changelog",'acf'); ?></h3>
237
- <p><?php _e("See what's new in",'acf'); ?> <a class="thickbox" href="<?php bloginfo('url'); ?>/wp-admin/plugin-install.php?tab=plugin-information&plugin=advanced-custom-fields&section=changelog&TB_iframe=true&width=640&height=559">v<?php echo $this->parent->version; ?></a>
238
-
239
- <h3><?php _e("Resources",'acf'); ?></h3>
240
- <p><?php _e("Read documentation, learn the functions and find some tips &amp; tricks for your next web project.",'acf'); ?><br />
241
- <a href="http://www.advancedcustomfields.com/" target="_blank"><?php _e("Visit the ACF website",'acf'); ?></a></p>
242
-
243
- </div>
244
- <div class="footer footer-blue">
245
- <ul class="left hl">
246
- <li><?php _e("Created by",'acf'); ?> Elliot Condon</li>
247
- </ul>
248
- <ul class="right hl">
249
- <li><a href="http://wordpress.org/extend/plugins/advanced-custom-fields/"><?php _e("Vote",'acf'); ?></a></li>
250
- <li><a href="http://twitter.com/elliotcondon"><?php _e("Follow",'acf'); ?></a></li>
251
- </ul>
252
- </div>
253
- </div>
254
- </div>
255
- <script type="text/javascript">
256
- (function($){
257
-
258
- //$('#screen-meta-links').remove();
259
- $('#wpbody .wrap').wrapInner('<div id="acf-col-left" />');
260
- $('#wpbody .wrap').wrapInner('<div id="acf-cols" />');
261
- $('#acf-col-right').removeClass('hidden').prependTo('#acf-cols');
262
 
263
- $('#acf-col-left > .icon32').insertBefore('#acf-cols');
264
- $('#acf-col-left > h2').insertBefore('#acf-cols');
265
- })(jQuery);
266
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
267
  <?php
268
  }
269
 
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
3
  class acf_field_groups
4
  {
5
 
103
 
104
  function admin_print_scripts()
105
  {
106
+ wp_enqueue_script(array(
107
+ 'jquery',
108
+ 'thickbox',
109
+ ));
110
  }
111
 
112
 
120
 
121
  function admin_print_styles()
122
  {
123
+ wp_enqueue_style(array(
124
+ 'thickbox',
125
+ 'acf-global',
126
+ 'acf',
127
+ ));
128
  }
129
 
130
 
137
 
138
  function acf_edit_columns( $columns )
139
  {
140
+ $columns = array(
141
+ 'cb' => '<input type="checkbox" />',
142
+ 'title' => __("Title"),
143
+ 'fields' => __("Fields", 'acf')
144
+ );
145
 
146
  return $columns;
147
  }
225
  function admin_footer()
226
  {
227
  ?>
228
+ <div id="acf-col-right" class="hidden">
229
+
230
+ <div class="wp-box">
231
+ <div class="inner">
232
+ <h3 class="h2"><?php _e("Advanced Custom Fields",'acf'); ?> <span>v<?php echo $this->parent->version; ?></span></h3>
233
+
234
+ <h3><?php _e("Changelog",'acf'); ?></h3>
235
+ <p><?php _e("See what's new in",'acf'); ?> <a class="thickbox" href="<?php echo admin_url('plugin-install.php'); ?>?tab=plugin-information&plugin=advanced-custom-fields&section=changelog&TB_iframe=true&width=640&height=559">v<?php echo $this->parent->version; ?></a>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
 
237
+ <h3><?php _e("Resources",'acf'); ?></h3>
238
+ <p><?php _e("Read documentation, learn the functions and find some tips &amp; tricks for your next web project.",'acf'); ?><br />
239
+ <a href="http://www.advancedcustomfields.com/" target="_blank"><?php _e("Visit the ACF website",'acf'); ?></a></p>
240
+
241
+ </div>
242
+ <div class="footer footer-blue">
243
+ <ul class="left hl">
244
+ <li><?php _e("Created by",'acf'); ?> Elliot Condon</li>
245
+ </ul>
246
+ <ul class="right hl">
247
+ <li><a href="http://wordpress.org/extend/plugins/advanced-custom-fields/"><?php _e("Vote",'acf'); ?></a></li>
248
+ <li><a href="http://twitter.com/elliotcondon"><?php _e("Follow",'acf'); ?></a></li>
249
+ </ul>
250
+ </div>
251
+ </div>
252
+ </div>
253
+ <script type="text/javascript">
254
+ (function($){
255
+ $('#wpbody .wrap').wrapInner('<div id="acf-col-left" />');
256
+ $('#wpbody .wrap').wrapInner('<div id="acf-cols" />');
257
+ $('#acf-col-right').removeClass('hidden').prependTo('#acf-cols');
258
+
259
+ $('#acf-col-left > .icon32').insertBefore('#acf-cols');
260
+ $('#acf-col-left > h2').insertBefore('#acf-cols');
261
+ })(jQuery);
262
+ </script>
263
  <?php
264
  }
265
 
core/controllers/input.php CHANGED
@@ -123,7 +123,14 @@ class acf_input
123
  // validate page
124
  if( ! $this->validate_page() ) return;
125
 
 
126
  do_action('acf_print_scripts-input');
 
 
 
 
 
 
127
  }
128
 
129
 
@@ -185,15 +192,11 @@ class acf_input
185
 
186
 
187
  // Style
188
- echo '<link rel="stylesheet" type="text/css" href="' . $this->parent->dir . '/css/global.css?ver=' . $this->parent->version . '" />';
189
- echo '<link rel="stylesheet" type="text/css" href="' . $this->parent->dir . '/css/input.css?ver=' . $this->parent->version . '" />';
190
  echo '<style type="text/css">.acf_postbox, .postbox[id*="acf_"] { display: none; }</style>';
191
 
192
 
193
  // Javascript
194
- echo '<script type="text/javascript" src="' . $this->parent->dir . '/js/input-actions.js?ver=' . $this->parent->version . '" ></script>';
195
- echo '<script type="text/javascript" src="' . $this->parent->dir . '/js/input-ajax.js?ver=' . $this->parent->version . '" ></script>';
196
- echo '<script type="text/javascript">acf.post_id = ' . $post_id . ';</script>';
197
 
198
 
199
  // add user js + css
@@ -569,9 +572,6 @@ acf.text.gallery_tb_title_edit = "<?php _e("Edit Image",'acf'); ?>";
569
 
570
  function acf_print_scripts_input()
571
  {
572
-
573
- wp_register_script('acf-datepicker', $this->parent->dir . '/core/fields/date_picker/jquery.ui.datepicker.js', false, $this->parent->version);
574
-
575
  wp_enqueue_script(array(
576
  'jquery',
577
  'jquery-ui-core',
@@ -580,6 +580,7 @@ acf.text.gallery_tb_title_edit = "<?php _e("Edit Image",'acf'); ?>";
580
  'farbtastic',
581
  'thickbox',
582
  'media-upload',
 
583
  'acf-datepicker',
584
  ));
585
 
@@ -602,11 +603,11 @@ acf.text.gallery_tb_title_edit = "<?php _e("Edit Image",'acf'); ?>";
602
 
603
  function acf_print_styles_input()
604
  {
605
- wp_register_style('acf-datepicker', $this->parent->dir . '/core/fields/date_picker/style.date_picker.css', false, $this->parent->version);
606
-
607
  wp_enqueue_style(array(
608
  'thickbox',
609
  'farbtastic',
 
 
610
  'acf-datepicker',
611
  ));
612
 
123
  // validate page
124
  if( ! $this->validate_page() ) return;
125
 
126
+
127
  do_action('acf_print_scripts-input');
128
+
129
+
130
+ // only "edit post" input pages need the ajax
131
+ wp_enqueue_script(array(
132
+ 'acf-input-ajax',
133
+ ));
134
  }
135
 
136
 
192
 
193
 
194
  // Style
 
 
195
  echo '<style type="text/css">.acf_postbox, .postbox[id*="acf_"] { display: none; }</style>';
196
 
197
 
198
  // Javascript
199
+ echo '<script type="text/javascript">acf.post_id = ' . $post_id . '; acf.nonce = "' . wp_create_nonce( 'acf_nonce' ) . '";</script>';
 
 
200
 
201
 
202
  // add user js + css
572
 
573
  function acf_print_scripts_input()
574
  {
 
 
 
575
  wp_enqueue_script(array(
576
  'jquery',
577
  'jquery-ui-core',
580
  'farbtastic',
581
  'thickbox',
582
  'media-upload',
583
+ 'acf-input-actions',
584
  'acf-datepicker',
585
  ));
586
 
603
 
604
  function acf_print_styles_input()
605
  {
 
 
606
  wp_enqueue_style(array(
607
  'thickbox',
608
  'farbtastic',
609
+ 'acf-global',
610
+ 'acf-input',
611
  'acf-datepicker',
612
  ));
613
 
core/controllers/options_page.php CHANGED
@@ -1,89 +1,80 @@
1
  <?php
2
 
3
- /*--------------------------------------------------------------------------
4
- *
5
- * Acf_options_page
6
- *
7
- * @author Elliot Condon
8
- * @since 2.0.4
9
- *
10
- *-------------------------------------------------------------------------*/
11
-
12
-
13
  class acf_options_page
14
  {
15
-
16
- var $parent;
17
- var $dir;
18
- var $data;
19
 
20
- /*--------------------------------------------------------------------------------------
21
- *
22
- * Acf_options_page
23
  *
24
- * @author Elliot Condon
25
- * @since 2.0.4
26
- *
27
- *-------------------------------------------------------------------------------------*/
 
 
 
 
28
 
 
 
 
 
 
 
 
 
 
29
  function __construct($parent)
30
  {
31
  // vars
32
  $this->parent = $parent;
33
  $this->dir = $parent->dir;
34
 
 
35
  // data for passing variables
36
  $this->data = array();
37
 
 
38
  // actions
39
  add_action('admin_menu', array($this,'admin_menu'));
40
 
41
  }
42
 
43
 
44
- /*--------------------------------------------------------------------------------------
45
- *
46
- * admin_menu
47
  *
48
- * @author Elliot Condon
49
- * @since 2.0.4
50
- *
51
- *-------------------------------------------------------------------------------------*/
52
 
53
  function admin_menu()
54
  {
55
  // validate
56
- if(!$this->parent->is_field_unlocked('options_page'))
57
  {
58
  return true;
59
  }
60
 
61
 
62
  // vars
 
63
  $parent_slug = 'acf-options';
64
- $parent_title = __('Options','acf');
65
- $parent_menu = __('Options','acf');
66
 
67
 
68
  // redirect to first child
69
- $custom = apply_filters( 'acf_register_options_page',array() );
70
- if( !empty($custom) )
71
  {
72
- $parent_title = $custom[0];
73
  $parent_slug = 'acf-options-' . sanitize_title( $parent_title );
74
  }
75
- else
76
- {
77
- $parent_title = apply_filters('acf_options_page_title', $parent_title);
78
- }
79
-
80
-
81
- // allow override of title
82
- $parent_menu = apply_filters('acf_options_page_title', $parent_menu);
83
 
84
 
85
  // Parent
86
- $parent_page = add_menu_page($parent_title, $parent_menu, 'edit_posts', $parent_slug, array($this, 'html'));
87
 
88
 
89
  // some fields require js + css
@@ -96,14 +87,14 @@ class acf_options_page
96
  add_action('admin_footer-'.$parent_page, array($this,'admin_footer'));
97
 
98
 
99
- if(!empty($custom))
100
  {
101
- foreach($custom as $c)
102
  {
103
  $sub_title = $c;
104
  $sub_slug = 'acf-options-' . sanitize_title( $sub_title );
105
 
106
- $child_page = add_submenu_page($parent_slug, $sub_title, $sub_title, 'edit_posts', $sub_slug, array($this, 'html'));
107
 
108
  // some fields require js + css
109
  add_action('admin_print_scripts-'.$child_page, array($this, 'admin_print_scripts'));
@@ -118,27 +109,29 @@ class acf_options_page
118
  }
119
 
120
 
121
-
122
- /*--------------------------------------------------------------------------------------
123
- *
124
- * admin_head
125
  *
126
- * @author Elliot Condon
127
- * @since 2.0.4
128
- *
129
- *-------------------------------------------------------------------------------------*/
130
 
131
  function admin_head()
132
  {
133
 
134
  // save
135
- if(isset($_POST['update_options']))
136
  {
137
- do_action('acf_save_post', 'options');
 
 
138
 
139
- $this->data['admin_message'] = __("Options Updated",'acf');
 
140
  }
141
 
 
142
  $metabox_ids = $this->parent->get_input_metabox_ids(false, false);
143
 
144
 
@@ -149,13 +142,7 @@ class acf_options_page
149
  }
150
 
151
  // Style
152
- echo '<link rel="stylesheet" type="text/css" href="'.$this->parent->dir.'/css/global.css?ver=' . $this->parent->version . '" />';
153
- echo '<link rel="stylesheet" type="text/css" href="'.$this->parent->dir.'/css/input.css?ver=' . $this->parent->version . '" />';
154
  echo '<style type="text/css">#side-sortables.empty-container { border: 0 none; }</style>';
155
-
156
- // Javascript
157
- echo '<script type="text/javascript" src="'.$this->parent->dir.'/js/input-actions.js?ver=' . $this->parent->version . '" ></script>';
158
- echo '<script type="text/javascript">acf.post_id = 0; </script>';
159
 
160
 
161
  // add user js + css
@@ -189,14 +176,14 @@ class acf_options_page
189
  }
190
 
191
 
192
- /*--------------------------------------------------------------------------------------
193
- *
194
- * admin_footer
195
  *
196
- * @author Elliot Condon
197
- * @since 2.0.4
198
- *
199
- *-------------------------------------------------------------------------------------*/
 
200
  function admin_footer()
201
  {
202
  // add togle open / close postbox
@@ -225,34 +212,42 @@ class acf_options_page
225
  }
226
 
227
 
228
- /*---------------------------------------------------------------------------------------------
229
- * admin_print_scripts / admin_print_styles
230
- *
231
- * @author Elliot Condon
232
- * @since 2.0.4
233
- *
234
- ---------------------------------------------------------------------------------------------*/
235
- function admin_print_scripts() {
236
-
 
237
  do_action('acf_print_scripts-input');
238
-
239
  }
240
 
241
- function admin_print_styles() {
242
-
 
 
 
 
 
 
 
 
 
243
  do_action('acf_print_styles-input');
244
-
245
  }
246
 
247
 
248
- /*--------------------------------------------------------------------------------------
 
249
  *
250
- * options_page
251
- *
252
- * @author Elliot Condon
253
- * @since 2.0.4
254
- *
255
- *-------------------------------------------------------------------------------------*/
256
  function html()
257
  {
258
  ?>
@@ -280,7 +275,8 @@ class acf_options_page
280
  <h3 class="hndle"><span><?php _e("Publish",'acf'); ?></span></h3>
281
  <div class="inside">
282
  <input type="hidden" name="HTTP_REFERER" value="<?php echo $_SERVER['HTTP_REFERER'] ?>" />
283
- <input type="submit" class="acf-button" value="<?php _e("Save Options",'acf'); ?>" name="update_options" />
 
284
  </div>
285
  </div>
286
 
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
3
  class acf_options_page
4
  {
 
 
 
 
5
 
6
+ /*
7
+ * Vars
 
8
  *
9
+ * @description:
10
+ * @since: 2.0.4
11
+ * @created: 5/12/12
12
+ */
13
+
14
+ var $parent,
15
+ $dir,
16
+ $data;
17
 
18
+
19
+ /*
20
+ * construct
21
+ *
22
+ * @description:
23
+ * @since: 2.0.4
24
+ * @created: 5/12/12
25
+ */
26
+
27
  function __construct($parent)
28
  {
29
  // vars
30
  $this->parent = $parent;
31
  $this->dir = $parent->dir;
32
 
33
+
34
  // data for passing variables
35
  $this->data = array();
36
 
37
+
38
  // actions
39
  add_action('admin_menu', array($this,'admin_menu'));
40
 
41
  }
42
 
43
 
44
+ /*
45
+ * admin_menu
 
46
  *
47
+ * @description:
48
+ * @since: 2.0.4
49
+ * @created: 5/12/12
50
+ */
51
 
52
  function admin_menu()
53
  {
54
  // validate
55
+ if( !$this->parent->is_field_unlocked('options_page') )
56
  {
57
  return true;
58
  }
59
 
60
 
61
  // vars
62
+ $defaults = $this->parent->defaults['options_page'];
63
  $parent_slug = 'acf-options';
64
+ $parent_title = $defaults['title'];
65
+ $parent_menu = $defaults['title'];
66
 
67
 
68
  // redirect to first child
69
+ if( !empty($defaults['pages']) )
 
70
  {
71
+ $parent_title = $defaults['pages'][0];
72
  $parent_slug = 'acf-options-' . sanitize_title( $parent_title );
73
  }
 
 
 
 
 
 
 
 
74
 
75
 
76
  // Parent
77
+ $parent_page = add_menu_page($parent_title, $parent_menu, $defaults['capability'], $parent_slug, array($this, 'html'));
78
 
79
 
80
  // some fields require js + css
87
  add_action('admin_footer-'.$parent_page, array($this,'admin_footer'));
88
 
89
 
90
+ if( !empty($defaults['pages']) )
91
  {
92
+ foreach($defaults['pages'] as $c)
93
  {
94
  $sub_title = $c;
95
  $sub_slug = 'acf-options-' . sanitize_title( $sub_title );
96
 
97
+ $child_page = add_submenu_page($parent_slug, $sub_title, $sub_title, $defaults['capability'], $sub_slug, array($this, 'html'));
98
 
99
  // some fields require js + css
100
  add_action('admin_print_scripts-'.$child_page, array($this, 'admin_print_scripts'));
109
  }
110
 
111
 
112
+ /*
113
+ * admin_head
 
 
114
  *
115
+ * @description:
116
+ * @since: 2.0.4
117
+ * @created: 5/12/12
118
+ */
119
 
120
  function admin_head()
121
  {
122
 
123
  // save
124
+ if( isset($_POST['acf_options_page']) )
125
  {
126
+ if( wp_verify_nonce($_POST['acf_options_page'], 'acf_options_page') )
127
+ {
128
+ do_action('acf_save_post', 'options');
129
 
130
+ $this->data['admin_message'] = __("Options Updated",'acf');
131
+ }
132
  }
133
 
134
+
135
  $metabox_ids = $this->parent->get_input_metabox_ids(false, false);
136
 
137
 
142
  }
143
 
144
  // Style
 
 
145
  echo '<style type="text/css">#side-sortables.empty-container { border: 0 none; }</style>';
 
 
 
 
146
 
147
 
148
  // add user js + css
176
  }
177
 
178
 
179
+ /*
180
+ * admin_footer
 
181
  *
182
+ * @description:
183
+ * @since: 2.0.4
184
+ * @created: 5/12/12
185
+ */
186
+
187
  function admin_footer()
188
  {
189
  // add togle open / close postbox
212
  }
213
 
214
 
215
+ /*
216
+ * admin_print_scripts
217
+ *
218
+ * @description:
219
+ * @since: 2.0.4
220
+ * @created: 5/12/12
221
+ */
222
+
223
+ function admin_print_scripts()
224
+ {
225
  do_action('acf_print_scripts-input');
 
226
  }
227
 
228
+
229
+ /*
230
+ * admin_print_styles
231
+ *
232
+ * @description:
233
+ * @since: 2.0.4
234
+ * @created: 5/12/12
235
+ */
236
+
237
+ function admin_print_styles()
238
+ {
239
  do_action('acf_print_styles-input');
 
240
  }
241
 
242
 
243
+ /*
244
+ * html
245
  *
246
+ * @description:
247
+ * @since: 2.0.4
248
+ * @created: 5/12/12
249
+ */
250
+
 
251
  function html()
252
  {
253
  ?>
275
  <h3 class="hndle"><span><?php _e("Publish",'acf'); ?></span></h3>
276
  <div class="inside">
277
  <input type="hidden" name="HTTP_REFERER" value="<?php echo $_SERVER['HTTP_REFERER'] ?>" />
278
+ <input type="hidden" name="acf_options_page" value="<?php echo wp_create_nonce( 'acf_options_page' ); ?>" />
279
+ <input type="submit" class="acf-button" value="<?php _e("Save Options",'acf'); ?>" />
280
  </div>
281
  </div>
282
 
core/controllers/upgrade.php CHANGED
@@ -760,7 +760,7 @@ class acf_upgrade
760
 
761
  if( $option_rows )
762
  {
763
- foreach( $option_rows as $k => &$row)
764
  {
765
  preg_match('/user_([0-9]+)_(.*)/', $row['option_name'], $matches);
766
 
760
 
761
  if( $option_rows )
762
  {
763
+ foreach( $option_rows as $k => $row)
764
  {
765
  preg_match('/user_([0-9]+)_(.*)/', $row['option_name'], $matches);
766
 
core/fields/flexible_content.php CHANGED
@@ -382,8 +382,12 @@ class acf_Flexible_content extends acf_Field
382
  <label><?php _e("Layout",'acf'); ?></label>
383
  <p class="desription">
384
  <span><a class="acf_fc_reorder" title="<?php _e("Reorder Layout",'acf'); ?>" href="javascript:;"><?php _e("Reorder",'acf'); ?></a> | </span>
385
- <span><a class="acf_fc_add" title="<?php _e("Add New Layout",'acf'); ?>" href="javascript:;"><?php _e("Add New",'acf'); ?></a> | </span>
386
  <span><a class="acf_fc_delete" title="<?php _e("Delete Layout",'acf'); ?>" href="javascript:;"><?php _e("Delete",'acf'); ?></a>
 
 
 
 
 
387
  </p>
388
  </td>
389
  <td>
@@ -688,28 +692,38 @@ class acf_Flexible_content extends acf_Field
688
  // loop through and save fields
689
  foreach($field['layouts'] as $layout_key => $layout)
690
  {
691
- // remove dummy field
692
- unset( $layout['sub_fields']['field_clone'] );
693
-
694
- // loop through and save fields
695
- $i = -1;
696
-
697
  if( $layout['sub_fields'] )
698
  {
 
 
 
 
 
 
 
 
 
699
  foreach( $layout['sub_fields'] as $key => $f )
700
  {
701
  $i++;
702
 
 
703
  // order
704
  $f['order_no'] = $i;
705
  $f['key'] = $key;
706
 
 
707
  // apply filters
708
  $f = apply_filters('acf_save_field', $f );
709
  $f = apply_filters('acf_save_field-' . $f['type'], $f );
710
 
711
- $layout['sub_fields'][ $key ] = $f;
 
 
712
  }
 
 
713
  }
714
 
715
  // update $layout
382
  <label><?php _e("Layout",'acf'); ?></label>
383
  <p class="desription">
384
  <span><a class="acf_fc_reorder" title="<?php _e("Reorder Layout",'acf'); ?>" href="javascript:;"><?php _e("Reorder",'acf'); ?></a> | </span>
 
385
  <span><a class="acf_fc_delete" title="<?php _e("Delete Layout",'acf'); ?>" href="javascript:;"><?php _e("Delete",'acf'); ?></a>
386
+
387
+ <br />
388
+
389
+ <span><a class="acf_fc_add" title="<?php _e("Add New Layout",'acf'); ?>" href="javascript:;"><?php _e("Add New",'acf'); ?></a> | </span>
390
+ <span><a class="acf_fc_duplicate" title="<?php _e("Duplicate Layout",'acf'); ?>" href="javascript:;"><?php _e("Duplicate",'acf'); ?></a></span>
391
  </p>
392
  </td>
393
  <td>
692
  // loop through and save fields
693
  foreach($field['layouts'] as $layout_key => $layout)
694
  {
695
+
 
 
 
 
 
696
  if( $layout['sub_fields'] )
697
  {
698
+ // remove dummy field
699
+ unset( $layout['sub_fields']['field_clone'] );
700
+
701
+
702
+ // loop through and save fields
703
+ $i = -1;
704
+ $sub_fields = array();
705
+
706
+
707
  foreach( $layout['sub_fields'] as $key => $f )
708
  {
709
  $i++;
710
 
711
+
712
  // order
713
  $f['order_no'] = $i;
714
  $f['key'] = $key;
715
 
716
+
717
  // apply filters
718
  $f = apply_filters('acf_save_field', $f );
719
  $f = apply_filters('acf_save_field-' . $f['type'], $f );
720
 
721
+
722
+ $sub_fields[ $f['key'] ] = $f;
723
+
724
  }
725
+
726
+ $layout['sub_fields'] = $sub_fields;
727
  }
728
 
729
  // update $layout
core/fields/gallery.php CHANGED
@@ -145,34 +145,10 @@ class acf_Gallery extends acf_Field
145
  (function($){
146
 
147
  // vars
148
- var div = self.parent.acf_edit_attachment,
149
- attachment_id = div.attr('data-id');
150
-
151
-
152
- // ajax find new list data
153
- $.ajax({
154
- url: ajaxurl,
155
- data : {
156
- 'action' : 'acf_get_gallery_list_data',
157
- 'attachment_id' : attachment_id
158
- },
159
- cache: false,
160
- dataType: "html",
161
- success: function( html ) {
162
-
163
-
164
- // validate
165
- if(!html)
166
- {
167
- return false;
168
- }
169
-
170
-
171
- // update list-item html
172
- div.find('.list-data').html( html );
173
-
174
- }
175
- });
176
 
177
 
178
  // add message
@@ -309,6 +285,7 @@ class acf_Gallery extends acf_Field
309
  {
310
  // get value
311
  $value = parent::get_value($post_id, $field);
 
312
 
313
 
314
  // empty?
@@ -341,9 +318,12 @@ class acf_Gallery extends acf_Field
341
 
342
 
343
  // override value array with attachments
344
- foreach( $value as $k => $v)
345
  {
346
- $value[ $k ] = $ordered_attachments[ $v ];
 
 
 
347
  }
348
 
349
 
@@ -375,7 +355,7 @@ class acf_Gallery extends acf_Field
375
  */
376
 
377
  // return value
378
- return $value;
379
  }
380
 
381
 
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
285
  {
286
  // get value
287
  $value = parent::get_value($post_id, $field);
288
+ $new_value = array();
289
 
290
 
291
  // empty?
318
 
319
 
320
  // override value array with attachments
321
+ foreach( $value as $v)
322
  {
323
+ if( isset($ordered_attachments[ $v ]) )
324
+ {
325
+ $new_value[] = $ordered_attachments[ $v ];
326
+ }
327
  }
328
 
329
 
355
  */
356
 
357
  // return value
358
+ return $new_value;
359
  }
360
 
361
 
core/fields/post_object.php CHANGED
@@ -55,12 +55,18 @@ class acf_Post_object extends acf_Field
55
 
56
  $field = array_merge($defaults, $field);
57
 
 
 
 
 
 
58
 
59
  // load all post types by default
60
  if( !$field['post_type'] || !is_array($field['post_type']) || $field['post_type'][0] == "" )
61
  {
62
  $field['post_type'] = get_post_types( array('public' => true) );
63
  }
 
64
 
65
 
66
  // create tax queries
55
 
56
  $field = array_merge($defaults, $field);
57
 
58
+ // validate taxonomy
59
+ if( !is_array($field['taxonomy']) )
60
+ {
61
+ $field['taxonomy'] = array('all');
62
+ }
63
 
64
  // load all post types by default
65
  if( !$field['post_type'] || !is_array($field['post_type']) || $field['post_type'][0] == "" )
66
  {
67
  $field['post_type'] = get_post_types( array('public' => true) );
68
  }
69
+
70
 
71
 
72
  // create tax queries
core/fields/relationship.php CHANGED
@@ -362,6 +362,14 @@ class acf_Relationship extends acf_Field
362
 
363
  $field = array_merge($defaults, $field);
364
 
 
 
 
 
 
 
 
 
365
  ?>
366
  <tr class="field_option field_option_<?php echo $this->name; ?>">
367
  <td class="label">
362
 
363
  $field = array_merge($defaults, $field);
364
 
365
+
366
+ // validate taxonomy
367
+ if( !is_array($field['taxonomy']) )
368
+ {
369
+ $field['taxonomy'] = array('all');
370
+ }
371
+
372
+
373
  ?>
374
  <tr class="field_option field_option_<?php echo $this->name; ?>">
375
  <td class="label">
core/fields/repeater.php CHANGED
@@ -564,25 +564,37 @@ class acf_Repeater extends acf_Field
564
  // remove dummy field
565
  unset( $field['sub_fields']['field_clone'] );
566
 
 
567
  // loop through and save fields
568
  $i = -1;
569
-
 
 
570
  foreach( $field['sub_fields'] as $key => $f )
571
  {
572
  $i++;
573
 
 
574
  // order
575
  $f['order_no'] = $i;
576
  $f['key'] = $key;
577
 
 
578
  // apply filters
579
  $f = apply_filters('acf_save_field', $f );
580
  $f = apply_filters('acf_save_field-' . $f['type'], $f );
581
 
582
- $field['sub_fields'][ $key ] = $f;
 
 
583
  }
 
 
 
 
584
  }
585
 
 
586
  // return updated repeater field
587
  return $field;
588
 
564
  // remove dummy field
565
  unset( $field['sub_fields']['field_clone'] );
566
 
567
+
568
  // loop through and save fields
569
  $i = -1;
570
+ $sub_fields = array();
571
+
572
+
573
  foreach( $field['sub_fields'] as $key => $f )
574
  {
575
  $i++;
576
 
577
+
578
  // order
579
  $f['order_no'] = $i;
580
  $f['key'] = $key;
581
 
582
+
583
  // apply filters
584
  $f = apply_filters('acf_save_field', $f );
585
  $f = apply_filters('acf_save_field-' . $f['type'], $f );
586
 
587
+
588
+ // add
589
+ $sub_fields[ $f['key'] ] = $f;
590
  }
591
+
592
+
593
+ // update sub fields
594
+ $field['sub_fields'] = $sub_fields;
595
  }
596
 
597
+
598
  // return updated repeater field
599
  return $field;
600
 
css/input.css CHANGED
@@ -363,6 +363,10 @@ ul.checkbox_list {
363
  background: transparent !important;
364
  }
365
 
 
 
 
 
366
 
367
  /*---------------------------------------------------------------------------------------------
368
  *
363
  background: transparent !important;
364
  }
365
 
366
+ #createuser ul.checkbox_list input {
367
+ width: auto;
368
+ }
369
+
370
 
371
  /*---------------------------------------------------------------------------------------------
372
  *
js/fields.js CHANGED
@@ -6,7 +6,8 @@ var acf = {
6
  'conditional_no_fields' : 'No "toggle" fields avilable'
7
  },
8
  fields : [],
9
- sortable_helper : null
 
10
 
11
  };
12
 
@@ -97,8 +98,8 @@ var acf = {
97
  return retId;
98
 
99
  }
100
-
101
-
102
  /*
103
  * Place Confirm message on Publish trash button
104
  *
@@ -191,44 +192,58 @@ var acf = {
191
  $.fn.update_names = function()
192
  {
193
  var field = $(this),
194
- old_id = field.attr('data-id'),
195
- new_id = 'field_' + uniqid();
196
-
197
-
198
- // give field a new id
199
- field.attr('data-id', new_id);
200
-
201
 
202
- // update class
203
- var new_class = field.attr('class');
204
- new_class = new_class.replace(old_id, new_id);
205
- field.attr('class', new_class);
206
-
207
-
208
- // update field key column
209
- field.find('.field_meta td.field_key').text( new_id );
210
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
 
212
- // update inputs
213
- field.find('[name]').each(function()
214
- {
215
-
216
- var name = $(this).attr('name');
217
- var id = $(this).attr('id');
 
 
 
 
 
 
 
218
 
219
- if(name && name.indexOf('[' + old_id + ']') != -1)
220
- {
221
- name = name.replace('[' + old_id + ']','[' + new_id + ']');
222
  }
223
- if(id && id.indexOf('[' + old_id + ']') != -1)
224
- {
225
- id = id.replace('[' + old_id + ']','[' + new_id + ']');
226
- }
227
-
228
- $(this).attr('name', name);
229
- $(this).attr('id', id);
230
-
231
  });
 
232
  }
233
 
234
 
@@ -345,7 +360,7 @@ var acf = {
345
 
346
  // update names
347
  new_field.update_names();
348
-
349
 
350
  // add new field
351
  field.after( new_field );
@@ -384,6 +399,10 @@ var acf = {
384
  new_field.update_names();
385
 
386
 
 
 
 
 
387
  // append to table
388
  fields.children('.field-field_clone').before(new_field);
389
 
@@ -663,7 +682,8 @@ var acf = {
663
  // vars
664
  var tr = $(this).closest('tr.field_option_flexible_content'),
665
  new_tr = tr.clone(false),
666
- id = new_tr.attr('data-id');
 
667
 
668
 
669
  // remove sub fields
@@ -674,11 +694,9 @@ var acf = {
674
 
675
  // reset layout meta values
676
  new_tr.find('.acf_cf_meta input[type="text"]').val('');
677
- new_tr.find('.acf_cf_meta select').val('table');
678
 
679
  // update id / names
680
- var new_id = uniqid();
681
-
682
  new_tr.find('[name]').each(function(){
683
 
684
  var name = $(this).attr('name').replace('[layouts]['+id+']','[layouts]['+new_id+']');
@@ -698,6 +716,48 @@ var acf = {
698
  });
699
 
700
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
701
  /*----------------------------------------------------------------------
702
  *
703
  * Delete Layout Option
6
  'conditional_no_fields' : 'No "toggle" fields avilable'
7
  },
8
  fields : [],
9
+ sortable_helper : null,
10
+ nonce : ''
11
 
12
  };
13
 
98
  return retId;
99
 
100
  }
101
+
102
+
103
  /*
104
  * Place Confirm message on Publish trash button
105
  *
192
  $.fn.update_names = function()
193
  {
194
  var field = $(this),
195
+ old_id = field.attr('data-id');
 
 
 
 
 
 
196
 
 
 
 
 
 
 
 
 
197
 
198
+ // load location html
199
+ $.ajax({
200
+ url: ajaxurl,
201
+ data: {
202
+ 'action' : 'acf_next_field_id',
203
+ 'nonce' : acf.nonce
204
+ },
205
+ type: 'post',
206
+ dataType: 'html',
207
+ success: function( new_id ){
208
+
209
+ // give field a new id
210
+ field.attr('data-id', new_id);
211
+
212
+
213
+ // update class
214
+ var new_class = field.attr('class');
215
+ new_class = new_class.replace(old_id, new_id);
216
+ field.attr('class', new_class);
217
+
218
+
219
+ // update field key column
220
+ field.find('.field_meta td.field_key').text( new_id );
221
+
222
+
223
+ // update inputs
224
+ field.find('[name]').each(function()
225
+ {
226
+
227
+ var name = $(this).attr('name');
228
+ var id = $(this).attr('id');
229
 
230
+ if(name && name.indexOf('[' + old_id + ']') != -1)
231
+ {
232
+ name = name.replace('[' + old_id + ']','[' + new_id + ']');
233
+ }
234
+ if(id && id.indexOf('[' + old_id + ']') != -1)
235
+ {
236
+ id = id.replace('[' + old_id + ']','[' + new_id + ']');
237
+ }
238
+
239
+ $(this).attr('name', name);
240
+ $(this).attr('id', id);
241
+
242
+ });
243
 
 
 
 
244
  }
 
 
 
 
 
 
 
 
245
  });
246
+
247
  }
248
 
249
 
360
 
361
  // update names
362
  new_field.update_names();
363
+
364
 
365
  // add new field
366
  field.after( new_field );
399
  new_field.update_names();
400
 
401
 
402
+ // show (update_names will remove the field_clone field, but not for a few seconds)
403
+ new_field.show();
404
+
405
+
406
  // append to table
407
  fields.children('.field-field_clone').before(new_field);
408
 
682
  // vars
683
  var tr = $(this).closest('tr.field_option_flexible_content'),
684
  new_tr = tr.clone(false),
685
+ id = new_tr.attr('data-id'),
686
+ new_id = uniqid();
687
 
688
 
689
  // remove sub fields
694
 
695
  // reset layout meta values
696
  new_tr.find('.acf_cf_meta input[type="text"]').val('');
697
+ new_tr.find('.acf_cf_meta select').val('row').trigger('change');
698
 
699
  // update id / names
 
 
700
  new_tr.find('[name]').each(function(){
701
 
702
  var name = $(this).attr('name').replace('[layouts]['+id+']','[layouts]['+new_id+']');
716
  });
717
 
718
 
719
+ /*----------------------------------------------------------------------
720
+ *
721
+ * Duplicate Layout
722
+ *
723
+ *---------------------------------------------------------------------*/
724
+
725
+ $('#acf_fields .acf_fc_duplicate').live('click', function(){
726
+
727
+ // vars
728
+ var tr = $(this).closest('tr.field_option_flexible_content'),
729
+ new_tr = tr.clone(false),
730
+ id = new_tr.attr('data-id'),
731
+ new_id = uniqid();
732
+
733
+
734
+ // reset layout meta values
735
+ new_tr.find('.acf_cf_meta input[type="text"]').val('');
736
+ new_tr.find('.acf_cf_meta select').val('row').trigger('change');
737
+
738
+
739
+ // update id / names
740
+ new_tr.find('[name]').each(function(){
741
+
742
+ var name = $(this).attr('name').replace('[layouts]['+id+']','[layouts]['+new_id+']');
743
+ $(this).attr('name', name);
744
+ $(this).attr('id', name);
745
+
746
+ });
747
+
748
+
749
+ // update data-id
750
+ new_tr.attr('data-id', new_id);
751
+
752
+
753
+ // add new tr
754
+ tr.after(new_tr);
755
+
756
+
757
+ return false;
758
+ });
759
+
760
+
761
  /*----------------------------------------------------------------------
762
  *
763
  * Delete Layout Option
js/input-actions.js CHANGED
@@ -387,7 +387,7 @@ var acf = {
387
  window.acf_div = div;
388
 
389
  // show the thickbox
390
- tb_show( acf.text.file_tb_title_add , acf.admin_url + 'media-upload.php?post_id=' + acf.post_id + '&type=file&acf_type=file&TB_iframe=1');
391
 
392
  return false;
393
  });
@@ -443,7 +443,7 @@ var acf = {
443
  window.acf_div = div;
444
 
445
  // show the thickbox
446
- tb_show( acf.text.image_tb_title_add , acf.admin_url + 'media-upload.php?post_id=' + acf.post_id + '&type=image&acf_type=image&acf_preview_size=' + preview_size + 'TB_iframe=1');
447
 
448
  return false;
449
  });
@@ -894,6 +894,12 @@ var acf = {
894
 
895
  //console.log( 'sortstart' );
896
 
 
 
 
 
 
 
897
  $(div).find('.acf_wysiwyg textarea').each(function(){
898
 
899
  // vars
@@ -930,6 +936,12 @@ var acf = {
930
 
931
  //console.log( 'sortstop' );
932
 
 
 
 
 
 
 
933
  $(div).find('.acf_wysiwyg textarea').each(function(){
934
 
935
  // vars
@@ -1759,6 +1771,42 @@ var acf = {
1759
  });
1760
 
1761
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1762
  /*
1763
  * Conditional Logic Calculate
1764
  *
387
  window.acf_div = div;
388
 
389
  // show the thickbox
390
+ 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');
391
 
392
  return false;
393
  });
443
  window.acf_div = div;
444
 
445
  // show the thickbox
446
+ 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');
447
 
448
  return false;
449
  });
894
 
895
  //console.log( 'sortstart' );
896
 
897
+ // validate tinymce
898
+ if( typeof(tinyMCE) != "object" )
899
+ {
900
+ return;
901
+ }
902
+
903
  $(div).find('.acf_wysiwyg textarea').each(function(){
904
 
905
  // vars
936
 
937
  //console.log( 'sortstop' );
938
 
939
+ // validate tinymce
940
+ if( typeof(tinyMCE) != "object" )
941
+ {
942
+ return;
943
+ }
944
+
945
  $(div).find('.acf_wysiwyg textarea').each(function(){
946
 
947
  // vars
1771
  });
1772
 
1773
 
1774
+ // gallery ajax
1775
+ acf.gallery_update_tile = function(){
1776
+
1777
+ // vars
1778
+ var div = window.acf_edit_attachment,
1779
+ attachment_id = div.attr('data-id');
1780
+
1781
+
1782
+ // ajax find new list data
1783
+ $.ajax({
1784
+ url: ajaxurl,
1785
+ data : {
1786
+ 'action' : 'acf_get_gallery_list_data',
1787
+ 'attachment_id' : attachment_id
1788
+ },
1789
+ cache: false,
1790
+ dataType: "html",
1791
+ success: function( html ) {
1792
+
1793
+
1794
+ // validate
1795
+ if(!html)
1796
+ {
1797
+ return false;
1798
+ }
1799
+
1800
+
1801
+ // update list-item html
1802
+ div.find('.list-data').html( html );
1803
+
1804
+ }
1805
+ });
1806
+
1807
+ };
1808
+
1809
+
1810
  /*
1811
  * Conditional Logic Calculate
1812
  *
readme.txt CHANGED
@@ -13,7 +13,7 @@ Fully customise WordPress edit screens with powerful fields. Boasting a professi
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, repeater, 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
@@ -31,9 +31,11 @@ Advanced Custom Fields is the perfect solution for any wordpress website which n
31
  * Post Object (select 1 or more page, post or custom post types, api returns post objects)
32
  * Date Picker (jquery date picker, options for format, api returns string)
33
  * True / False (tick box with message, api returns true or false)
34
- * Repeater (ability to create repeatable blocks of fields!)
35
  * Relationship (select and order post objects with a tidy interface)
36
  * Color Picker (Farbtastic!)
 
 
 
37
 
38
  = Tested on =
39
  * Mac Firefox :)
@@ -87,6 +89,25 @@ http://support.advancedcustomfields.com/
87
 
88
  == Changelog ==
89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  = 3.5.3.1 =
91
  * Minor bug fixes for 3.5.3
92
 
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
31
  * Post Object (select 1 or more page, post or custom post types, api returns post objects)
32
  * Date Picker (jquery date picker, options for format, api returns string)
33
  * True / False (tick box with message, api returns true or false)
 
34
  * Relationship (select and order post objects with a tidy interface)
35
  * Color Picker (Farbtastic!)
36
+ * Repeater (ability to create repeatable blocks of fields!)
37
+ * Flexible Content (ability to create flexible blocks of fields!)
38
+ * Gallery (Add, edit and order multiple images in 1 simple field)
39
 
40
  = Tested on =
41
  * Mac Firefox :)
89
 
90
  == Changelog ==
91
 
92
+ = 3.5.4.1 =
93
+ * [Fixed] Fix bug preventing options pages from appearing in the field group's location rules
94
+
95
+ = 3.5.4 =
96
+ * [Added] Add new filter for ACF settings - http://www.advancedcustomfields.com/docs/filters/acf_settings/
97
+ * [Updated] Updated field keys to look nicer. eg field_12
98
+ * [Added] Update admin_head to use hooks / enque all scripts / styles
99
+ * [Added] Add duplicate function for flexible content layouts
100
+ * [Fixed] Fix $post_id bug - http://support.advancedcustomfields.com/discussion/3852/acf_form-uses-global-post_id-instead-of-argument
101
+ * [Fixed] Fix WYSIWYG JS issue - http://support.advancedcustomfields.com/discussion/3644/flexible-layout-field-reordering-breaks-when-visual-editor-disabled
102
+ * [Fixed] Fix Gallery PHP error - http://support.advancedcustomfields.com/discussion/3856/undefined-index-error-gallery-on-options-page
103
+ * [Added] Add compatibility for Shopp categories - http://support.advancedcustomfields.com/discussion/3647/custom-fields-not-showing-up-in-shopp-catalog-categories
104
+ * [Fixed] Fix "Parent Page" location rule - http://support.advancedcustomfields.com/discussion/3885/parent-page-type-check
105
+ * [Fixed] Fix options page backwards compatibility - support.advancedcustomfields.com/discussion/3908/acf-options-page-groups-are-not-backward-compatible
106
+ * [Fixed] Fix update_field for content - http://support.advancedcustomfields.com/discussion/3916/add-flexible-layout-row-with-update_field
107
+ * [Added] Add new filter for acf_defaults! - http://support.advancedcustomfields.com/discussion/3947/options-page-plugin-user-capabilites-limitation
108
+ * [Fixed] Fix gallery detail update after edit - http://support.advancedcustomfields.com/discussion/3899/gallery-image-attributes-not-updating-after-change
109
+ * [Fixed] Fix front end uploading issue - http://support.advancedcustomfields.com/discussion/comment/10502#Comment_10502
110
+
111
  = 3.5.3.1 =
112
  * Minor bug fixes for 3.5.3
113