Advanced Custom Fields - Version 4.1.5

Version Description

  • WYSIWYG Field: Fixed WYSIWYG the_content / shortcode issues - http://support.advancedcustomfields.com/discussion/5939/inconsistencies-between-standard-wysiwyg-and-acf-wysiwyg
  • Image field: Added option for library restriction - http://support.advancedcustomfields.com/discussion/6102/making-uploaded-to-this-post-default-state-for-image-upload
  • File field: Added option for library restriction
  • File field: Field UI refresh
  • Checkbox field: Added horizontal option - http://support.advancedcustomfields.com/discussion/5925/horizontal-select-boxes
  • Image field: fixed UI bug when image is deleted in file system - http://support.advancedcustomfields.com/discussion/5988/provide-a-fallback-if-
  • Validation: Added support for email field - http://support.advancedcustomfields.com/discussion/6125/email-field-required-validation-on-submit
  • Validation: Added support for taxonomy field - http://support.advancedcustomfields.com/discussion/6169/validation-of-taxonomy-field
  • Language: Added Chinese Translation - https://github.com/elliotcondon/acf/pull/63
  • General: Added changelog message to update plugin screen
  • General: Lots of minor improvements
Download this release

Release Info

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

Code changes from version 4.1.4 to 4.1.5

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: 4.1.4
7
  Author: Elliot Condon
8
  Author URI: http://www.elliotcondon.com/
9
  License: GPL
@@ -66,13 +66,14 @@ class Acf
66
  $this->settings = array(
67
  'path' => apply_filters('acf/helpers/get_path', __FILE__),
68
  'dir' => apply_filters('acf/helpers/get_dir', __FILE__),
69
- 'version' => '4.1.4',
 
70
  'upgrade_version' => '3.4.1',
71
  );
72
 
73
 
74
  // set text domain
75
- load_plugin_textdomain('acf', false, basename(dirname(__FILE__)).'/lang' );
76
 
77
 
78
  // actions
@@ -87,6 +88,7 @@ class Acf
87
  add_filter('acf/get_taxonomies_for_select', array($this, 'get_taxonomies_for_select'), 1, 2);
88
  add_filter('acf/get_image_sizes', array($this, 'get_image_sizes'), 1, 1);
89
  add_action('acf/create_fields', array($this, 'create_fields'), 1, 2);
 
90
 
91
 
92
  // admin only
@@ -160,6 +162,65 @@ class Acf
160
  }
161
 
162
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
  /*
164
  * get_info
165
  *
@@ -590,7 +651,6 @@ class Acf
590
  // set value
591
  if( !isset($field['value']) )
592
  {
593
-
594
  $field['value'] = apply_filters('acf/load_value', false, $post_id, $field);
595
  $field['value'] = apply_filters('acf/format_value', $field['value'], $post_id, $field);
596
  }
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: 4.1.5.1
7
  Author: Elliot Condon
8
  Author URI: http://www.elliotcondon.com/
9
  License: GPL
66
  $this->settings = array(
67
  'path' => apply_filters('acf/helpers/get_path', __FILE__),
68
  'dir' => apply_filters('acf/helpers/get_dir', __FILE__),
69
+ 'hook' => basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ),
70
+ 'version' => '4.1.5.1',
71
  'upgrade_version' => '3.4.1',
72
  );
73
 
74
 
75
  // set text domain
76
+ load_plugin_textdomain('acf', false, basename(dirname(__FILE__)) . '/lang' );
77
 
78
 
79
  // actions
88
  add_filter('acf/get_taxonomies_for_select', array($this, 'get_taxonomies_for_select'), 1, 2);
89
  add_filter('acf/get_image_sizes', array($this, 'get_image_sizes'), 1, 1);
90
  add_action('acf/create_fields', array($this, 'create_fields'), 1, 2);
91
+ add_action('acf/get_post_id', array($this, 'get_post_id'), 1, 1);
92
 
93
 
94
  // admin only
162
  }
163
 
164
 
165
+ /*
166
+ * acf/get_post_id
167
+ *
168
+ * A helper function to filter the post_id variable.
169
+ *
170
+ * @type filter
171
+ * @date 27/05/13
172
+ *
173
+ * @param {mixed} $post_id
174
+ * @return {mixed} $post_id
175
+ */
176
+
177
+ function get_post_id( $post_id )
178
+ {
179
+ // set post_id to global
180
+ if( !$post_id )
181
+ {
182
+ global $post;
183
+
184
+ if( $post )
185
+ {
186
+ $post_id = intval( $post->ID );
187
+ }
188
+ }
189
+
190
+
191
+ // allow for option == options
192
+ if( $post_id == "option" )
193
+ {
194
+ $post_id = "options";
195
+ }
196
+
197
+
198
+ /*
199
+ * Override for preview
200
+ *
201
+ * If the $_GET['preview_id'] is set, then the user wants to see the preview data.
202
+ * There is also the case of previewing a page with post_id = 1, but using get_field
203
+ * to load data from another post_id.
204
+ * In this case, we need to make sure that the autosave revision is actually related
205
+ * to the $post_id variable. If they match, then the autosave data will be used, otherwise,
206
+ * the user wants to load data from a completely different post_id
207
+ */
208
+
209
+ if( isset($_GET['preview_id']) )
210
+ {
211
+ $autosave = wp_get_post_autosave( $_GET['preview_id'] );
212
+ if( $autosave->post_parent == $post_id )
213
+ {
214
+ $post_id = intval( $autosave->ID );
215
+ }
216
+ }
217
+
218
+
219
+ // return
220
+ return $post_id;
221
+ }
222
+
223
+
224
  /*
225
  * get_info
226
  *
651
  // set value
652
  if( !isset($field['value']) )
653
  {
 
654
  $field['value'] = apply_filters('acf/load_value', false, $post_id, $field);
655
  $field['value'] = apply_filters('acf/format_value', $field['value'], $post_id, $field);
656
  }
core/api.php CHANGED
@@ -142,7 +142,7 @@ function get_field_objects( $post_id = false, $options = array() )
142
 
143
 
144
  // filter post_id
145
- $post_id = acf_filter_post_id( $post_id );
146
 
147
 
148
  // vars
@@ -302,7 +302,7 @@ function get_field( $field_key, $post_id = false, $format_value = true )
302
  function get_field_object( $field_key, $post_id = false, $options = array() )
303
  {
304
  // filter post_id
305
- $post_id = acf_filter_post_id( $post_id );
306
  $field = false;
307
  $orig_field_key = $field_key;
308
 
@@ -411,7 +411,7 @@ function has_sub_field( $field_name, $post_id = false )
411
  {
412
 
413
  // filter post_id
414
- $post_id = acf_filter_post_id( $post_id );
415
 
416
 
417
  // empty?
@@ -1080,13 +1080,16 @@ function acf_form( $options = false )
1080
  'field_groups' => array(),
1081
  'form' => true,
1082
  'form_attributes' => array(
1083
- 'class' => ''
 
 
 
1084
  ),
1085
  'return' => add_query_arg( 'updated', 'true', get_permalink() ),
1086
  'html_before_fields' => '',
1087
  'html_after_fields' => '',
1088
- 'submit_value' => 'Update',
1089
- 'updated_message' => 'Post updated.',
1090
  );
1091
 
1092
 
@@ -1102,7 +1105,14 @@ function acf_form( $options = false )
1102
 
1103
 
1104
  // filter post_id
1105
- $options['post_id'] = acf_filter_post_id( $options['post_id'] );
 
 
 
 
 
 
 
1106
 
1107
 
1108
  // register post box
@@ -1142,14 +1152,9 @@ function acf_form( $options = false )
1142
  }
1143
 
1144
 
1145
- // Javascript
1146
- $script_post_id = is_numeric($options['post_id']) ? $options['post_id'] : 0;
1147
- echo '<script type="text/javascript">acf.post_id = ' . $script_post_id . '; </script>';
1148
-
1149
-
1150
  // display form
1151
  if( $options['form'] ): ?>
1152
- <form action="" id="post" method="post" <?php if($options['form_attributes']){foreach($options['form_attributes'] as $k => $v){echo $k . '="' . $v .'" '; }} ?>>
1153
  <?php endif; ?>
1154
 
1155
  <div style="display:none">
@@ -1185,10 +1190,9 @@ function acf_form( $options = false )
1185
  $fields = apply_filters('acf/field_group/get_fields', array(), $acf['id']);
1186
 
1187
 
1188
- echo '<div id="acf_' . $acf['id'] . '" class="postbox acf_postbox">';
1189
  echo '<h3 class="hndle"><span>' . $acf['title'] . '</span></h3>';
1190
  echo '<div class="inside">';
1191
- echo '<div class="options" data-layout="' . $acf['options']['layout'] . '" data-show="1"></div>';
1192
 
1193
  do_action('acf/create_fields', $fields, $options['post_id']);
1194
 
@@ -1237,7 +1241,7 @@ function acf_form( $options = false )
1237
  function update_field( $field_key, $value, $post_id = false )
1238
  {
1239
  // filter post_id
1240
- $post_id = acf_filter_post_id( $post_id );
1241
 
1242
 
1243
  // vars
142
 
143
 
144
  // filter post_id
145
+ $post_id = apply_filters('acf/get_post_id', $post_id );
146
 
147
 
148
  // vars
302
  function get_field_object( $field_key, $post_id = false, $options = array() )
303
  {
304
  // filter post_id
305
+ $post_id = apply_filters('acf/get_post_id', $post_id );
306
  $field = false;
307
  $orig_field_key = $field_key;
308
 
411
  {
412
 
413
  // filter post_id
414
+ $post_id = apply_filters('acf/get_post_id', $post_id );
415
 
416
 
417
  // empty?
1080
  'field_groups' => array(),
1081
  'form' => true,
1082
  'form_attributes' => array(
1083
+ 'id' => 'post',
1084
+ 'class' => '',
1085
+ 'action' => '',
1086
+ 'method' => 'post',
1087
  ),
1088
  'return' => add_query_arg( 'updated', 'true', get_permalink() ),
1089
  'html_before_fields' => '',
1090
  'html_after_fields' => '',
1091
+ 'submit_value' => __("Update", 'acf'),
1092
+ 'updated_message' => __("Post updated", 'acf'),
1093
  );
1094
 
1095
 
1105
 
1106
 
1107
  // filter post_id
1108
+ $options['post_id'] = apply_filters('acf/get_post_id', $options['post_id'] );
1109
+
1110
+
1111
+ // attributes
1112
+ if( empty($options['form_attributes']['class']) )
1113
+ {
1114
+ $options['form_attributes']['class'] = 'acf-form acf-form-' . $options['post_id'];
1115
+ }
1116
 
1117
 
1118
  // register post box
1152
  }
1153
 
1154
 
 
 
 
 
 
1155
  // display form
1156
  if( $options['form'] ): ?>
1157
+ <form <?php if($options['form_attributes']){foreach($options['form_attributes'] as $k => $v){echo $k . '="' . $v .'" '; }} ?>>
1158
  <?php endif; ?>
1159
 
1160
  <div style="display:none">
1190
  $fields = apply_filters('acf/field_group/get_fields', array(), $acf['id']);
1191
 
1192
 
1193
+ echo '<div id="acf_' . $acf['id'] . '" class="postbox acf_postbox ' . $acf['options']['layout'] . '">';
1194
  echo '<h3 class="hndle"><span>' . $acf['title'] . '</span></h3>';
1195
  echo '<div class="inside">';
 
1196
 
1197
  do_action('acf/create_fields', $fields, $options['post_id']);
1198
 
1241
  function update_field( $field_key, $value, $post_id = false )
1242
  {
1243
  // filter post_id
1244
+ $post_id = apply_filters('acf/get_post_id', $post_id );
1245
 
1246
 
1247
  // vars
core/controllers/input.php CHANGED
@@ -170,7 +170,6 @@ class acf_input
170
 
171
  // Style
172
  echo '<style type="text/css" id="acf_style" >' . $style . '</style>';
173
- echo '<style type="text/css">.acf_postbox, .postbox[id*="acf_"] { display: none; }</style>';
174
 
175
 
176
  // add user js + css
@@ -216,6 +215,61 @@ class acf_input
216
  }
217
 
218
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
219
  /*
220
  * get_style
221
  *
@@ -326,35 +380,6 @@ class acf_input
326
  }
327
 
328
 
329
- /*
330
- * meta_box_input
331
- *
332
- * @description:
333
- * @since 1.0.0
334
- * @created: 23/06/12
335
- */
336
-
337
- function meta_box_input( $post, $args )
338
- {
339
- // vars
340
- $options = $args['args'];
341
-
342
- echo '<input type="hidden" name="acf_nonce" value="' . wp_create_nonce( 'input' ) . '" />';
343
- echo '<div class="options" data-layout="' . $options['field_group']['options']['layout'] . '" data-show="' . $options['show'] . '" style="display:none"></div>';
344
-
345
- if( $options['show'] )
346
- {
347
- $fields = apply_filters('acf/field_group/get_fields', array(), $options['field_group']['id']);
348
-
349
- do_action('acf/create_fields', $fields, $options['post_id']);
350
- }
351
- else
352
- {
353
- echo '<div class="acf-replace-with-fields"><div class="acf-loading"></div></div>';
354
- }
355
- }
356
-
357
-
358
  /*
359
  * ajax_render_fields
360
  *
@@ -439,17 +464,17 @@ class acf_input
439
  }
440
 
441
 
442
-
443
- /*--------------------------------------------------------------------------------------
444
  *
445
- * input_admin_head
446
  *
447
- * This is fired from an action: acf/input/admin_head
 
448
  *
449
- * @author Elliot Condon
450
- * @since 3.0.6
451
- *
452
- *-------------------------------------------------------------------------------------*/
453
 
454
  function input_admin_head()
455
  {
@@ -462,57 +487,68 @@ class acf_input
462
  $post_id = 0;
463
  if( $post )
464
  {
465
- $post_id = $post->ID;
466
  }
467
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
468
  ?>
469
  <script type="text/javascript">
470
 
471
  // vars
472
- acf.post_id = <?php echo $post_id; ?>;
473
  acf.nonce = "<?php echo wp_create_nonce( 'acf_nonce' ); ?>";
474
  acf.admin_url = "<?php echo admin_url(); ?>";
475
  acf.ajaxurl = "<?php echo admin_url( 'admin-ajax.php' ); ?>";
476
  acf.wp_version = "<?php echo $wp_version; ?>";
477
-
478
-
479
- // text
480
- acf.validation.text.error = "<?php _e("Validation Failed. One or more fields below are required.",'acf'); ?>";
481
-
482
- acf.fields.relationship.max = "<?php _e("Maximum values reached ( {max} values )",'acf'); ?>";
483
 
484
- acf.fields.image.text.title_add = "Select Image";
485
- acf.fields.image.text.title_edit = "Edit Image";
486
- acf.fields.image.text.button_add = "Select Image";
487
 
488
- acf.fields.file.text.title_add = "Select File";
489
- acf.fields.file.text.title_edit = "Edit File";
490
- acf.fields.file.text.button_add = "Select File";
 
491
 
492
-
493
- // WYSIWYG
494
- <?php
495
-
496
- if( is_array($toolbars) ):
497
- foreach( $toolbars as $label => $rows ):
498
- $name = sanitize_title( $label );
499
- $name = str_replace('-', '_', $name);
500
- ?>
501
- acf.fields.wysiwyg.toolbars.<?php echo $name; ?> = {};
502
- <?php if( is_array($rows) ):
503
- foreach( $rows as $k => $v ): ?>
504
- acf.fields.wysiwyg.toolbars.<?php echo $name; ?>.theme_advanced_buttons<?php echo $k; ?> = '<?php echo implode(',', $v); ?>';
505
- <?php endforeach;
506
- endif;
507
- endforeach;
508
- endif;
509
-
510
- ?>
511
  </script>
512
  <?php
513
  }
514
 
515
 
 
516
  /*
517
  * input_admin_enqueue_scripts
518
  *
170
 
171
  // Style
172
  echo '<style type="text/css" id="acf_style" >' . $style . '</style>';
 
173
 
174
 
175
  // add user js + css
215
  }
216
 
217
 
218
+ /*
219
+ * meta_box_input
220
+ *
221
+ * @description:
222
+ * @since 1.0.0
223
+ * @created: 23/06/12
224
+ */
225
+
226
+ function meta_box_input( $post, $args )
227
+ {
228
+ // extract $args
229
+ extract( $args );
230
+
231
+
232
+ // classes
233
+ $class = 'acf_postbox ' . $args['field_group']['options']['layout'];
234
+ $toggle_class = 'acf_postbox-toggle';
235
+
236
+
237
+ if( ! $args['show'] )
238
+ {
239
+ $class .= ' acf-hidden';
240
+ $toggle_class .= ' acf-hidden';
241
+ }
242
+
243
+ ?>
244
+ <script type="text/javascript">
245
+ (function($) {
246
+
247
+ $('#<?php echo $id; ?>').addClass('<?php echo $class; ?>').removeClass('hide-if-js');
248
+ $('#adv-settings label[for="<?php echo $id; ?>-hide"]').addClass('<?php echo $toggle_class; ?>');
249
+
250
+ })(jQuery);
251
+ </script>
252
+ <?php
253
+
254
+
255
+ // nonce
256
+ echo '<input type="hidden" name="acf_nonce" value="' . wp_create_nonce( 'input' ) . '" />';
257
+
258
+
259
+ // HTML
260
+ if( $args['show'] )
261
+ {
262
+ $fields = apply_filters('acf/field_group/get_fields', array(), $args['field_group']['id']);
263
+
264
+ do_action('acf/create_fields', $fields, $args['post_id']);
265
+ }
266
+ else
267
+ {
268
+ echo '<div class="acf-replace-with-fields"><div class="acf-loading"></div></div>';
269
+ }
270
+ }
271
+
272
+
273
  /*
274
  * get_style
275
  *
380
  }
381
 
382
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
383
  /*
384
  * ajax_render_fields
385
  *
464
  }
465
 
466
 
467
+ /*
468
+ * input_admin_head
469
  *
470
+ * action called when rendering the head of an admin screen. Used primarily for passing PHP to JS
471
  *
472
+ * @type action
473
+ * @date 27/05/13
474
  *
475
+ * @param N/A
476
+ * @return N/A
477
+ */
 
478
 
479
  function input_admin_head()
480
  {
487
  $post_id = 0;
488
  if( $post )
489
  {
490
+ $post_id = intval( $post->ID );
491
  }
492
 
493
+
494
+ // l10n
495
+ $l10n = apply_filters( 'acf/input/admin_l10n', array(
496
+ 'validation' => array(
497
+ 'error' => __("Validation Failed. One or more fields below are required.",'acf')
498
+ )
499
+ ));
500
+
501
+
502
+ // options
503
+ $o = array(
504
+ 'post_id' => $post_id,
505
+ 'nonce' => wp_create_nonce( 'acf_nonce' ),
506
+ 'admin_url' => admin_url(),
507
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
508
+ 'wp_version' => $wp_version
509
+ );
510
+
511
+
512
+ // toolbars
513
+ $t = array();
514
+
515
+ if( is_array($toolbars) ){ foreach( $toolbars as $label => $rows ){
516
+
517
+ $label = sanitize_title( $label );
518
+ $label = str_replace('-', '_', $label);
519
+
520
+ $t[ $label ] = array();
521
+
522
+ if( is_array($rows) ){ foreach( $rows as $k => $v ){
523
+
524
+ $t[ $label ][ 'theme_advanced_buttons' . $k ] = implode(',', $v);
525
+
526
+ }}
527
+ }}
528
+
529
+
530
  ?>
531
  <script type="text/javascript">
532
 
533
  // vars
534
+ acf.post_id = <?php echo is_numeric($post_id) ? $post_id : '"' . $post_id . '"'; ?>;
535
  acf.nonce = "<?php echo wp_create_nonce( 'acf_nonce' ); ?>";
536
  acf.admin_url = "<?php echo admin_url(); ?>";
537
  acf.ajaxurl = "<?php echo admin_url( 'admin-ajax.php' ); ?>";
538
  acf.wp_version = "<?php echo $wp_version; ?>";
 
 
 
 
 
 
539
 
 
 
 
540
 
541
+ // new vars
542
+ acf.o = <?php echo json_encode( $o ); ?>;
543
+ acf.l10n = <?php echo json_encode( $l10n ); ?>;
544
+ acf.fields.wysiwyg.toolbars = <?php echo json_encode( $t ); ?>;
545
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
546
  </script>
547
  <?php
548
  }
549
 
550
 
551
+
552
  /*
553
  * input_admin_enqueue_scripts
554
  *
core/controllers/upgrade.php CHANGED
@@ -8,7 +8,6 @@
8
  * @created: 23/06/12
9
  */
10
 
11
-
12
  class acf_upgrade
13
  {
14
 
@@ -24,8 +23,10 @@ class acf_upgrade
24
  {
25
  // actions
26
  add_action('admin_menu', array($this,'admin_menu'), 11);
 
 
 
27
  add_action('wp_ajax_acf_upgrade', array($this, 'upgrade_ajax'));
28
- //add_action('admin_footer', array($this, 'admin_footer'), 99);
29
  }
30
 
31
 
@@ -68,31 +69,98 @@ class acf_upgrade
68
  }
69
  }
70
 
71
-
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  add_submenu_page('edit.php?post_type=acf', __('Upgrade','acf'), __('Upgrade','acf'), 'manage_options','acf-upgrade', array($this,'html') );
73
  }
74
 
 
 
75
 
76
  /*
77
- * admin_footer
78
  *
79
- * @description:
80
- * @since: 3.6
81
- * @created: 3/04/13
 
 
 
 
 
82
  */
83
 
84
- function admin_footer()
85
  {
86
- // Mesages
87
- $dismissed = get_option('acf_dismissed', array());
 
 
 
 
 
 
 
 
 
 
 
88
 
89
- if( !in_array('download_addons', $dismissed) )
 
 
 
 
90
  {
91
- // update db
92
- //$dismissed[] = 'download_addons';
93
- //update_option('acf_dismissed', $dismissed );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
 
 
95
  }
 
 
 
 
96
  }
97
 
98
 
8
  * @created: 23/06/12
9
  */
10
 
 
11
  class acf_upgrade
12
  {
13
 
23
  {
24
  // actions
25
  add_action('admin_menu', array($this,'admin_menu'), 11);
26
+
27
+
28
+ // ajax
29
  add_action('wp_ajax_acf_upgrade', array($this, 'upgrade_ajax'));
 
30
  }
31
 
32
 
69
  }
70
  }
71
 
72
+
73
+ // update info
74
+ global $pagenow;
75
+
76
+ if( $pagenow == 'plugins.php' )
77
+ {
78
+ $hook = apply_filters('acf/get_info', 'hook');
79
+
80
+ wp_enqueue_style( 'acf-global' );
81
+ add_action( 'in_plugin_update_message-' . $hook, array($this, 'in_plugin_update_message'), 10, 2 );
82
+ }
83
+
84
+
85
+ // update admin page
86
  add_submenu_page('edit.php?post_type=acf', __('Upgrade','acf'), __('Upgrade','acf'), 'manage_options','acf-upgrade', array($this,'html') );
87
  }
88
 
89
+
90
+
91
 
92
  /*
93
+ * in_plugin_update_message
94
  *
95
+ * Displays an update message for plugin list screens.
96
+ * Shows only the version updates from the current until the newest version
97
+ *
98
+ * @type function
99
+ * @date 5/06/13
100
+ *
101
+ * @param {array} $plugin_data
102
+ * @param {object} $r
103
  */
104
 
105
+ function in_plugin_update_message( $plugin_data, $r )
106
  {
107
+ // vars
108
+ $version = apply_filters('acf/get_info', 'version');
109
+ $readme = file_get_contents( 'http://plugins.svn.wordpress.org/advanced-custom-fields/trunk/readme.txt' );
110
+ $regexp = '/== Changelog ==(.*)= 4.1.5 =/sm';
111
+ $o = '';
112
+
113
+
114
+ // validate
115
+ if( !$readme )
116
+ {
117
+ return;
118
+ }
119
+
120
 
121
+ // regexp
122
+ preg_match( $regexp, $readme, $matches );
123
+
124
+
125
+ if( ! isset($matches[1]) )
126
  {
127
+ return;
128
+ }
129
+
130
+
131
+ // render changelog
132
+ $changelog = explode('*', $matches[1]);
133
+ array_shift( $changelog );
134
+
135
+
136
+ if( !empty($changelog) )
137
+ {
138
+ $o .= '<div class="acf-plugin-update-info">';
139
+ $o .= '<h3>' . __("What's new", 'acf') . '</h3>';
140
+ $o .= '<ul>';
141
+
142
+ foreach( $changelog as $item )
143
+ {
144
+ $item = explode('http', $item);
145
+
146
+ $o .= '<li>' . $item[0];
147
+
148
+ if( isset($item[1]) )
149
+ {
150
+ $o .= '<a href="http' . $item[1] . '" target="_blank">' . __("credits",'acf') . '</a>';
151
+ }
152
+
153
+ $o .= '</li>';
154
+
155
+
156
+ }
157
 
158
+ $o .= '</ul></div>';
159
  }
160
+
161
+ echo $o;
162
+
163
+
164
  }
165
 
166
 
core/fields/_base.php CHANGED
@@ -20,7 +20,9 @@ class acf_field
20
 
21
  var $name,
22
  $title,
23
- $category;
 
 
24
 
25
 
26
  /*
@@ -36,6 +38,7 @@ class acf_field
36
  {
37
  // register field
38
  add_filter('acf/registered_fields', array($this, 'registered_fields'), 10, 1);
 
39
 
40
 
41
  // value
@@ -55,6 +58,7 @@ class acf_field
55
  // input actions
56
  $this->add_action('acf/input/admin_enqueue_scripts', array($this, 'input_admin_enqueue_scripts'), 10, 0);
57
  $this->add_action('acf/input/admin_head', array($this, 'input_admin_head'), 10, 0);
 
58
 
59
 
60
  // field group actions
@@ -130,6 +134,54 @@ class acf_field
130
  }
131
 
132
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  }
134
 
135
  ?>
20
 
21
  var $name,
22
  $title,
23
+ $category,
24
+ $defaults,
25
+ $l10n;
26
 
27
 
28
  /*
38
  {
39
  // register field
40
  add_filter('acf/registered_fields', array($this, 'registered_fields'), 10, 1);
41
+ add_filter('acf/load_field_defaults/type=' . $this->name, array($this, 'load_field_defaults'), 10, 1);
42
 
43
 
44
  // value
58
  // input actions
59
  $this->add_action('acf/input/admin_enqueue_scripts', array($this, 'input_admin_enqueue_scripts'), 10, 0);
60
  $this->add_action('acf/input/admin_head', array($this, 'input_admin_head'), 10, 0);
61
+ $this->add_filter('acf/input/admin_l10n', array($this, 'input_admin_l10n'), 10, 1);
62
 
63
 
64
  // field group actions
134
  }
135
 
136
 
137
+ /*
138
+ * load_field_defaults
139
+ *
140
+ * action called when rendering the head of an admin screen. Used primarily for passing PHP to JS
141
+ *
142
+ * @type filer
143
+ * @date 1/06/13
144
+ *
145
+ * @param $field {array}
146
+ * @return $field {array}
147
+ */
148
+
149
+ function load_field_defaults( $field )
150
+ {
151
+ if( !empty($this->defaults) )
152
+ {
153
+ $field = array_merge( $this->defaults, $field );
154
+ }
155
+
156
+ return $field;
157
+ }
158
+
159
+
160
+ /*
161
+ * admin_l10n
162
+ *
163
+ * filter is called to load all l10n text translations into the admin head script tag
164
+ *
165
+ * @type filer
166
+ * @date 1/06/13
167
+ *
168
+ * @param $field {array}
169
+ * @return $field {array}
170
+ */
171
+
172
+ function input_admin_l10n( $l10n )
173
+ {
174
+ if( !empty($this->l10n) )
175
+ {
176
+ $l10n[ $this->name ] = $this->l10n;
177
+
178
+
179
+ }
180
+
181
+ return $l10n;
182
+ }
183
+
184
+
185
  }
186
 
187
  ?>
core/fields/_functions.php CHANGED
@@ -400,6 +400,10 @@ class acf_field_functions
400
  $field = apply_filters( 'acf/parse_types', $field );
401
 
402
 
 
 
 
 
403
  // class
404
  if( !$field['class'] )
405
  {
@@ -568,6 +572,10 @@ foreach( $field['conditional_logic']['rules'] as $rule ):
568
 
569
  function create_field_options($field)
570
  {
 
 
 
 
571
  do_action('acf/create_field_options/type=' . $field['type'], $field);
572
  }
573
 
400
  $field = apply_filters( 'acf/parse_types', $field );
401
 
402
 
403
+ // field specific defaults
404
+ $field = apply_filters('acf/load_field_defaults/type=' . $field['type'] , $field);
405
+
406
+
407
  // class
408
  if( !$field['class'] )
409
  {
572
 
573
  function create_field_options($field)
574
  {
575
+ // load standard + field specific defaults
576
+ $field = apply_filters('acf/load_field_defaults', $field);
577
+
578
+ // render HTML
579
  do_action('acf/create_field_options/type=' . $field['type'], $field);
580
  }
581
 
core/fields/checkbox.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  class acf_field_checkbox extends acf_field
4
  {
5
-
6
  /*
7
  * __construct
8
  *
@@ -18,6 +18,11 @@ class acf_field_checkbox extends acf_field
18
  $this->name = 'checkbox';
19
  $this->label = __("Checkbox",'acf');
20
  $this->category = __("Choice",'acf');
 
 
 
 
 
21
 
22
 
23
  // do not delete!
@@ -39,15 +44,6 @@ class acf_field_checkbox extends acf_field
39
 
40
  function create_field( $field )
41
  {
42
- // vars
43
- $defaults = array(
44
- 'layout' => 'vertical',
45
- 'choices' => array(),
46
- );
47
-
48
- $field = array_merge($defaults, $field);
49
-
50
-
51
  // value must be array
52
  if( !is_array($field['value']) )
53
  {
@@ -69,7 +65,7 @@ class acf_field_checkbox extends acf_field
69
 
70
 
71
  echo '<input type="hidden" name="' . $field['name'] . '" value="" />';
72
- echo '<ul class="checkbox_list ' . $field['class'] . '">';
73
 
74
 
75
  // checkbox saves an array
@@ -122,12 +118,6 @@ class acf_field_checkbox extends acf_field
122
  function create_options( $field )
123
  {
124
  // vars
125
- $defaults = array(
126
- 'default_value' => '',
127
- 'choices' => '',
128
- );
129
-
130
- $field = array_merge($defaults, $field);
131
  $key = $field['name'];
132
 
133
 
@@ -179,6 +169,27 @@ class acf_field_checkbox extends acf_field
179
  ?>
180
  </td>
181
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
  <?php
183
 
184
  }
2
 
3
  class acf_field_checkbox extends acf_field
4
  {
5
+
6
  /*
7
  * __construct
8
  *
18
  $this->name = 'checkbox';
19
  $this->label = __("Checkbox",'acf');
20
  $this->category = __("Choice",'acf');
21
+ $this->defaults = array(
22
+ 'layout' => 'vertical',
23
+ 'choices' => array(),
24
+ 'default_value' => '',
25
+ );
26
 
27
 
28
  // do not delete!
44
 
45
  function create_field( $field )
46
  {
 
 
 
 
 
 
 
 
 
47
  // value must be array
48
  if( !is_array($field['value']) )
49
  {
65
 
66
 
67
  echo '<input type="hidden" name="' . $field['name'] . '" value="" />';
68
+ echo '<ul class="checkbox_list ' . $field['class'] . ' ' . $field['layout'] . '">';
69
 
70
 
71
  // checkbox saves an array
118
  function create_options( $field )
119
  {
120
  // vars
 
 
 
 
 
 
121
  $key = $field['name'];
122
 
123
 
169
  ?>
170
  </td>
171
  </tr>
172
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
173
+ <td class="label">
174
+ <label for=""><?php _e("Layout",'acf'); ?></label>
175
+ </td>
176
+ <td>
177
+ <?php
178
+
179
+ do_action('acf/create_field', array(
180
+ 'type' => 'radio',
181
+ 'name' => 'fields['.$key.'][layout]',
182
+ 'value' => $field['layout'],
183
+ 'layout' => 'horizontal',
184
+ 'choices' => array(
185
+ 'vertical' => __("Vertical",'acf'),
186
+ 'horizontal' => __("Horizontal",'acf')
187
+ )
188
+ ));
189
+
190
+ ?>
191
+ </td>
192
+ </tr>
193
  <?php
194
 
195
  }
core/fields/color_picker.php CHANGED
@@ -18,6 +18,9 @@ class acf_field_color_picker extends acf_field
18
  $this->name = 'color_picker';
19
  $this->label = __("Color Picker",'acf');
20
  $this->category = __("jQuery",'acf');
 
 
 
21
 
22
 
23
  // do not delete!
@@ -40,7 +43,9 @@ class acf_field_color_picker extends acf_field
40
 
41
  function create_field( $field )
42
  {
43
- echo '<input type="text" value="' . $field['value'] . '" id="' . $field['id'] . '" class="acf_color_picker" name="' . $field['name'] . '" />';
 
 
44
  }
45
 
46
 
@@ -60,11 +65,6 @@ class acf_field_color_picker extends acf_field
60
  function create_options( $field )
61
  {
62
  // vars
63
- $defaults = array(
64
- 'default_value' => '',
65
- );
66
-
67
- $field = array_merge($defaults, $field);
68
  $key = $field['name'];
69
 
70
  ?>
18
  $this->name = 'color_picker';
19
  $this->label = __("Color Picker",'acf');
20
  $this->category = __("jQuery",'acf');
21
+ $this->defaults = array(
22
+ 'default_value' => '',
23
+ );
24
 
25
 
26
  // do not delete!
43
 
44
  function create_field( $field )
45
  {
46
+ echo '<div class="acf-color_picker">';
47
+ echo '<input type="text" value="' . $field['value'] . '" id="' . $field['id'] . '" class="input" name="' . $field['name'] . '" />';
48
+ echo '</div>';
49
  }
50
 
51
 
65
  function create_options( $field )
66
  {
67
  // vars
 
 
 
 
 
68
  $key = $field['name'];
69
 
70
  ?>
core/fields/date_picker/date_picker.php CHANGED
@@ -14,6 +14,9 @@ class acf_field_date_picker extends acf_field
14
 
15
  function __construct()
16
  {
 
 
 
17
  // vars
18
  $this->name = 'date_picker';
19
  $this->label = __("Date Picker",'acf');
@@ -23,33 +26,8 @@ class acf_field_date_picker extends acf_field
23
  'display_format' => 'dd/mm/yy',
24
  'first_day' => 1, // monday
25
  );
26
-
27
-
28
- // do not delete!
29
- parent::__construct();
30
- }
31
-
32
-
33
- /*
34
- * input_admin_head()
35
- *
36
- * This action is called in the admin_head action on the edit screen where your field is created.
37
- * Use this action to add css and javascript to assist your create_field() action.
38
- *
39
- * @info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_head
40
- * @type action
41
- * @since 3.6
42
- * @date 23/01/13
43
- */
44
-
45
- function input_admin_head()
46
- {
47
- global $wp_locale;
48
-
49
-
50
- // localize strings
51
- $l10n = array(
52
- 'closeText' => __( 'Done', 'acf' ),
53
  'currentText' => __( 'Today', 'acf' ),
54
  'monthNames' => array_values( $wp_locale->month ),
55
  'monthNamesShort' => array_values( $wp_locale->month_abbrev ),
@@ -58,13 +36,11 @@ class acf_field_date_picker extends acf_field
58
  'dayNamesShort' => array_values( $wp_locale->weekday_abbrev ),
59
  'dayNamesMin' => array_values( $wp_locale->weekday_initial ),
60
  'isRTL' => isset($wp_locale->is_rtl) ? $wp_locale->is_rtl : false,
61
- );
62
-
63
- ?>
64
- <script type="text/javascript">
65
- acf.fields.date_picker.text = <?php echo json_encode( $l10n ); ?>;
66
- </script>
67
- <?php
68
  }
69
 
70
 
@@ -82,10 +58,6 @@ acf.fields.date_picker.text = <?php echo json_encode( $l10n ); ?>;
82
 
83
  function create_field( $field )
84
  {
85
- // defaults
86
- $field = array_merge($this->defaults, $field);
87
-
88
-
89
  // make sure it's not blank
90
  if( !$field['date_format'] )
91
  {
@@ -98,9 +70,10 @@ acf.fields.date_picker.text = <?php echo json_encode( $l10n ); ?>;
98
 
99
 
100
  // html
101
- echo '<input type="hidden" value="' . $field['value'] . '" name="' . $field['name'] . '" class="acf-hidden-datepicker" />';
102
- echo '<input type="text" value="" class="acf_datepicker" data-save_format="' . $field['date_format'] . '" data-display_format="' . $field['display_format'] . '" data-first_day="' . $field['first_day'] . '" />';
103
-
 
104
  }
105
 
106
 
@@ -120,25 +93,7 @@ acf.fields.date_picker.text = <?php echo json_encode( $l10n ); ?>;
120
  function create_options( $field )
121
  {
122
  // vars
123
- $field = array_merge($this->defaults, $field);
124
  $key = $field['name'];
125
-
126
-
127
- global $wp_locale;
128
-
129
-
130
- // localize strings
131
- $l10n = array(
132
- 'closeText' => __( 'Done', 'acf' ),
133
- 'currentText' => __( 'Today', 'acf' ),
134
- 'monthNames' => array_values( $wp_locale->month ),
135
- 'monthNamesShort' => array_values( $wp_locale->month_abbrev ),
136
- 'monthStatus' => __( 'Show a different month', 'acf' ),
137
- 'dayNames' => array_values( $wp_locale->weekday ),
138
- 'dayNamesShort' => array_values( $wp_locale->weekday_abbrev ),
139
- 'dayNamesMin' => array_values( $wp_locale->weekday_initial ),
140
- 'isRTL' => isset($wp_locale->is_rtl) ? $wp_locale->is_rtl : false,
141
- );
142
 
143
  ?>
144
  <tr class="field_option field_option_<?php echo $this->name; ?>">
14
 
15
  function __construct()
16
  {
17
+ global $wp_locale;
18
+
19
+
20
  // vars
21
  $this->name = 'date_picker';
22
  $this->label = __("Date Picker",'acf');
26
  'display_format' => 'dd/mm/yy',
27
  'first_day' => 1, // monday
28
  );
29
+ $this->l10n = array(
30
+ 'closeText' => __( 'Done', 'acf' ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  'currentText' => __( 'Today', 'acf' ),
32
  'monthNames' => array_values( $wp_locale->month ),
33
  'monthNamesShort' => array_values( $wp_locale->month_abbrev ),
36
  'dayNamesShort' => array_values( $wp_locale->weekday_abbrev ),
37
  'dayNamesMin' => array_values( $wp_locale->weekday_initial ),
38
  'isRTL' => isset($wp_locale->is_rtl) ? $wp_locale->is_rtl : false,
39
+ );
40
+
41
+
42
+ // do not delete!
43
+ parent::__construct();
 
 
44
  }
45
 
46
 
58
 
59
  function create_field( $field )
60
  {
 
 
 
 
61
  // make sure it's not blank
62
  if( !$field['date_format'] )
63
  {
70
 
71
 
72
  // html
73
+ echo '<div class="acf-date_picker" data-save_format="' . $field['date_format'] . '" data-display_format="' . $field['display_format'] . '" data-first_day="' . $field['first_day'] . '">';
74
+ echo '<input type="hidden" value="' . $field['value'] . '" name="' . $field['name'] . '" class="input-alt" />';
75
+ echo '<input type="text" value="" class="input" />';
76
+ echo '</div>';
77
  }
78
 
79
 
93
  function create_options( $field )
94
  {
95
  // vars
 
96
  $key = $field['name'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
 
98
  ?>
99
  <tr class="field_option field_option_<?php echo $this->name; ?>">
core/fields/email.php CHANGED
@@ -17,6 +17,9 @@ class acf_field_email extends acf_field
17
  // vars
18
  $this->name = 'email';
19
  $this->label = __("Email",'acf');
 
 
 
20
 
21
 
22
  // do not delete!
@@ -58,11 +61,6 @@ class acf_field_email extends acf_field
58
  function create_options( $field )
59
  {
60
  // vars
61
- $defaults = array(
62
- 'default_value' => '',
63
- );
64
-
65
- $field = array_merge($defaults, $field);
66
  $key = $field['name'];
67
 
68
  ?>
17
  // vars
18
  $this->name = 'email';
19
  $this->label = __("Email",'acf');
20
+ $this->defaults = array(
21
+ 'default_value' => '',
22
+ );
23
 
24
 
25
  // do not delete!
61
  function create_options( $field )
62
  {
63
  // vars
 
 
 
 
 
64
  $key = $field['name'];
65
 
66
  ?>
core/fields/file.php CHANGED
@@ -18,6 +18,15 @@ class acf_field_file extends acf_field
18
  $this->name = 'file';
19
  $this->label = __("File",'acf');
20
  $this->category = __("Content",'acf');
 
 
 
 
 
 
 
 
 
21
 
22
 
23
  // do not delete!
@@ -29,6 +38,7 @@ class acf_field_file extends acf_field
29
  add_action('acf_head-update_attachment-' . $this->name, array($this, 'acf_head_update_attachment'));
30
  add_action('wp_ajax_acf/fields/file/get_files', array($this, 'ajax_get_files'));
31
  add_action('admin_head-media-upload-popup', array($this, 'popup_head'));
 
32
  }
33
 
34
 
@@ -47,34 +57,58 @@ class acf_field_file extends acf_field
47
  function create_field( $field )
48
  {
49
  // vars
50
- $options = array(
51
- 'class' => '',
52
- 'icon' => '',
53
- 'file_name' => ''
 
 
 
54
  );
55
 
56
- if( $field['value'] )
57
  {
58
- $file_src = wp_get_attachment_url( $field['value'] );
59
- preg_match("~[^/]*$~", $file_src, $file_name);
60
-
61
- $options['class'] = 'active';
62
- $options['icon'] = wp_mime_type_icon( $field['value'] );
63
- $options['file_name'] = $file_name[0];
 
 
 
 
 
64
  }
65
 
 
66
  ?>
67
- <div class="acf-file-uploader <?php echo $options['class']; ?>">
68
  <input class="acf-file-value" type="hidden" name="<?php echo $field['name']; ?>" value="<?php echo $field['value']; ?>" />
69
  <div class="has-file">
70
  <ul class="hl clearfix">
71
  <li>
72
- <img class="acf-file-icon" src="<?php echo $options['icon']; ?>" alt=""/>
 
 
 
 
 
 
73
  </li>
74
  <li>
75
- <span class="acf-file-name"><?php echo $options['file_name']; ?></span><br />
76
- <a href="#" class="edit-file"><?php _e('Edit','acf'); ?></a>
77
- <a href="#" class="remove-file"><?php _e('Remove','acf'); ?></a>
 
 
 
 
 
 
 
 
 
78
  </li>
79
  </ul>
80
  </div>
@@ -106,11 +140,6 @@ class acf_field_file extends acf_field
106
  function create_options( $field )
107
  {
108
  // vars
109
- $defaults = array(
110
- 'save_format' => 'id',
111
- );
112
-
113
- $field = array_merge($defaults, $field);
114
  $key = $field['name'];
115
 
116
  ?>
@@ -136,6 +165,27 @@ class acf_field_file extends acf_field
136
  ?>
137
  </td>
138
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  <?php
140
 
141
  }
@@ -159,14 +209,7 @@ class acf_field_file extends acf_field
159
 
160
  function format_value_for_api( $value, $post_id, $field )
161
  {
162
- // vars
163
- $defaults = array(
164
- 'save_format' => 'url',
165
- );
166
-
167
- $field = array_merge($defaults, $field);
168
-
169
-
170
  // validate
171
  if( !$value )
172
  {
@@ -282,16 +325,17 @@ class acf_field_file extends acf_field
282
  {
283
  foreach( $options['files'] as $id )
284
  {
285
- $file_src = wp_get_attachment_url( $id );
286
- preg_match("~[^/]*$~", $file_src, $file_name);
287
 
288
-
289
- // vars
290
- $return[] = array(
291
- 'id' => $id,
292
- 'icon' => wp_mime_type_icon( $id ),
293
- 'name' => $file_name[0]
294
- );
 
295
  }
296
  }
297
 
@@ -743,6 +787,40 @@ class acf_field_file extends acf_field
743
  return $value;
744
  }
745
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
746
  }
747
 
748
  new acf_field_file();
18
  $this->name = 'file';
19
  $this->label = __("File",'acf');
20
  $this->category = __("Content",'acf');
21
+ $this->defaults = array(
22
+ 'save_format' => 'object',
23
+ 'library' => 'all'
24
+ );
25
+ $this->l10n = array(
26
+ 'select' => __("Select File",'acf'),
27
+ 'edit' => __("Edit File",'acf'),
28
+ 'uploadedTo' => __("uploaded to this post",'acf'),
29
+ );
30
 
31
 
32
  // do not delete!
38
  add_action('acf_head-update_attachment-' . $this->name, array($this, 'acf_head_update_attachment'));
39
  add_action('wp_ajax_acf/fields/file/get_files', array($this, 'ajax_get_files'));
40
  add_action('admin_head-media-upload-popup', array($this, 'popup_head'));
41
+ add_action('wp_prepare_attachment_for_js', array($this, 'wp_prepare_attachment_for_js'), 10, 3);
42
  }
43
 
44
 
57
  function create_field( $field )
58
  {
59
  // vars
60
+ $o = array(
61
+ 'class' => '',
62
+ 'icon' => '',
63
+ 'title' => '',
64
+ 'size' => '',
65
+ 'url' => '',
66
+ 'name' => '',
67
  );
68
 
69
+ if( $field['value'] && is_numeric($field['value']) )
70
  {
71
+ $file = get_post( $field['value'] );
72
+
73
+ if( $file )
74
+ {
75
+ $o['class'] = 'active';
76
+ $o['icon'] = wp_mime_type_icon( $file->ID );
77
+ $o['title'] = $file->post_title;
78
+ $o['size'] = size_format(filesize( get_attached_file( $file->ID ) ));
79
+ $o['url'] = wp_get_attachment_url( $file->ID );
80
+ $o['name'] = end(explode('/', $o['url']));
81
+ }
82
  }
83
 
84
+
85
  ?>
86
+ <div class="acf-file-uploader clearfix <?php echo $o['class']; ?>" data-library="<?php echo $field['library']; ?>">
87
  <input class="acf-file-value" type="hidden" name="<?php echo $field['name']; ?>" value="<?php echo $field['value']; ?>" />
88
  <div class="has-file">
89
  <ul class="hl clearfix">
90
  <li>
91
+ <img class="acf-file-icon" src="<?php echo $o['icon']; ?>" alt=""/>
92
+ <div class="hover">
93
+ <ul class="bl">
94
+ <li><a href="#" class="acf-button-delete ir">Remove</a></li>
95
+ <li><a href="#" class="acf-button-edit ir">Edit</a></li>
96
+ </ul>
97
+ </div>
98
  </li>
99
  <li>
100
+ <p>
101
+ <strong class="acf-file-title"><?php echo $o['title']; ?></strong>
102
+ </p>
103
+ <p>
104
+ <strong>Name:</strong>
105
+ <a class="acf-file-name" href="<?php echo $o['url']; ?>" target="_blank"><?php echo $o['name']; ?></a>
106
+ </p>
107
+ <p>
108
+ <strong>Size:</strong>
109
+ <span class="acf-file-size"><?php echo $o['size']; ?></span>
110
+ </p>
111
+
112
  </li>
113
  </ul>
114
  </div>
140
  function create_options( $field )
141
  {
142
  // vars
 
 
 
 
 
143
  $key = $field['name'];
144
 
145
  ?>
165
  ?>
166
  </td>
167
  </tr>
168
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
169
+ <td class="label">
170
+ <label><?php _e("Library",'acf'); ?></label>
171
+ </td>
172
+ <td>
173
+ <?php
174
+
175
+ do_action('acf/create_field', array(
176
+ 'type' => 'radio',
177
+ 'name' => 'fields['.$key.'][library]',
178
+ 'value' => $field['library'],
179
+ 'layout' => 'horizontal',
180
+ 'choices' => array(
181
+ 'all' => __('All', 'acf'),
182
+ 'uploadedTo' => __('Uploaded to post', 'acf')
183
+ )
184
+ ));
185
+
186
+ ?>
187
+ </td>
188
+ </tr>
189
  <?php
190
 
191
  }
209
 
210
  function format_value_for_api( $value, $post_id, $field )
211
  {
212
+
 
 
 
 
 
 
 
213
  // validate
214
  if( !$value )
215
  {
325
  {
326
  foreach( $options['files'] as $id )
327
  {
328
+ $o = array();
329
+ $file = get_post( $id );
330
 
331
+ $o['id'] = $file->ID;
332
+ $o['icon'] = wp_mime_type_icon( $file->ID );
333
+ $o['title'] = $file->post_title;
334
+ $o['size'] = size_format(filesize( get_attached_file( $file->ID ) ));
335
+ $o['url'] = wp_get_attachment_url( $file->ID );
336
+ $o['name'] = end(explode('/', $o['url']));
337
+
338
+ $return[] = $o;
339
  }
340
  }
341
 
787
  return $value;
788
  }
789
 
790
+
791
+ /*
792
+ * wp_prepare_attachment_for_js
793
+ *
794
+ * this filter allows ACF to add in extra data to an attachment JS object
795
+ *
796
+ * @type function
797
+ * @date 1/06/13
798
+ *
799
+ * @param {int} $post_id
800
+ * @return {int} $post_id
801
+ */
802
+
803
+ function wp_prepare_attachment_for_js( $response, $attachment, $meta )
804
+ {
805
+ // default
806
+ $fs = '0 kb';
807
+
808
+
809
+ // supress PHP warnings caused by corrupt images
810
+ if( $i = @filesize( get_attached_file( $attachment->ID ) ) )
811
+ {
812
+ $fs = size_format( $i );
813
+ }
814
+
815
+
816
+ // update JSON
817
+ $response['filesize'] = $fs;
818
+
819
+
820
+ // return
821
+ return $response;
822
+ }
823
+
824
  }
825
 
826
  new acf_field_file();
core/fields/image.php CHANGED
@@ -18,6 +18,16 @@ class acf_field_image extends acf_field
18
  $this->name = 'image';
19
  $this->label = __("Image",'acf');
20
  $this->category = __("Content",'acf');
 
 
 
 
 
 
 
 
 
 
21
 
22
 
23
  // do not delete!
@@ -50,24 +60,21 @@ class acf_field_image extends acf_field
50
  function create_field( $field )
51
  {
52
  // vars
53
- $class = "";
54
- $file_src = "";
55
- $preview_size = isset($field['preview_size']) ? $field['preview_size'] : 'thumbnail';
 
56
 
57
- // get image url
58
- if($field['value'] != '' && is_numeric($field['value']))
59
  {
60
- $file_src = wp_get_attachment_image_src($field['value'], $preview_size);
61
- $file_src = $file_src[0];
62
 
63
- if($file_src)
64
- {
65
- $class = "active";
66
- }
67
  }
68
 
69
  ?>
70
- <div class="acf-image-uploader clearfix <?php echo $class; ?>" data-preview_size="<?php echo $preview_size; ?>">
71
  <input class="acf-image-value" type="hidden" name="<?php echo $field['name']; ?>" value="<?php echo $field['value']; ?>" />
72
  <div class="has-image">
73
  <div class="hover">
@@ -76,7 +83,7 @@ class acf_field_image extends acf_field
76
  <li><a class="acf-button-edit ir" href="#"><?php _e("Edit",'acf'); ?></a></li>
77
  </ul>
78
  </div>
79
- <img src="<?php echo $file_src; ?>" alt=""/>
80
  </div>
81
  <div class="no-image">
82
  <p><?php _e('No image selected','acf'); ?> <input type="button" class="button add-image" value="<?php _e('Add Image','acf'); ?>" />
@@ -102,53 +109,68 @@ class acf_field_image extends acf_field
102
  function create_options( $field )
103
  {
104
  // vars
105
- $defaults = array(
106
- 'save_format' => 'id',
107
- 'preview_size' => 'thumbnail',
108
- );
109
-
110
- $field = array_merge($defaults, $field);
111
  $key = $field['name'];
112
 
113
  ?>
114
- <tr class="field_option field_option_<?php echo $this->name; ?>">
115
- <td class="label">
116
- <label><?php _e("Return Value",'acf'); ?></label>
117
- </td>
118
- <td>
119
- <?php
120
- do_action('acf/create_field', array(
121
- 'type' => 'radio',
122
- 'name' => 'fields['.$key.'][save_format]',
123
- 'value' => $field['save_format'],
124
- 'layout' => 'horizontal',
125
- 'choices' => array(
126
- 'object' => __("Image Object",'acf'),
127
- 'url' => __("Image URL",'acf'),
128
- 'id' => __("Image ID",'acf')
129
- )
130
- ));
131
- ?>
132
- </td>
133
- </tr>
134
- <tr class="field_option field_option_<?php echo $this->name; ?>">
135
- <td class="label">
136
- <label><?php _e("Preview Size",'acf'); ?></label>
137
- </td>
138
- <td>
139
- <?php
140
-
141
- do_action('acf/create_field', array(
142
- 'type' => 'radio',
143
- 'name' => 'fields['.$key.'][preview_size]',
144
- 'value' => $field['preview_size'],
145
- 'layout' => 'horizontal',
146
- 'choices' => apply_filters('acf/get_image_sizes', array())
147
- ));
148
 
149
- ?>
150
- </td>
151
- </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  <?php
153
 
154
  }
@@ -323,12 +345,12 @@ class acf_field_image extends acf_field
323
  {
324
  foreach( $options['images'] as $id )
325
  {
326
- $src = wp_get_attachment_image_src( $id, $options['preview_size'] );
327
 
328
 
329
  $return[] = array(
330
  'id' => $id,
331
- 'src' => $src[0],
332
  );
333
  }
334
  }
18
  $this->name = 'image';
19
  $this->label = __("Image",'acf');
20
  $this->category = __("Content",'acf');
21
+ $this->defaults = array(
22
+ 'save_format' => 'object',
23
+ 'preview_size' => 'thumbnail',
24
+ 'library' => 'all'
25
+ );
26
+ $this->l10n = array(
27
+ 'select' => __("Select Image",'acf'),
28
+ 'edit' => __("Edit Image",'acf'),
29
+ 'uploadedTo' => __("uploaded to this post",'acf'),
30
+ );
31
 
32
 
33
  // do not delete!
60
  function create_field( $field )
61
  {
62
  // vars
63
+ $o = array(
64
+ 'class' => '',
65
+ 'url' => '',
66
+ );
67
 
68
+ if( $field['value'] && is_numeric($field['value']) )
 
69
  {
70
+ $url = wp_get_attachment_image_src($field['value'], $field['preview_size']);
 
71
 
72
+ $o['class'] = 'active';
73
+ $o['url'] = $url[0];
 
 
74
  }
75
 
76
  ?>
77
+ <div class="acf-image-uploader clearfix <?php echo $o['class']; ?>" data-preview_size="<?php echo $field['preview_size']; ?>" data-library="<?php echo $field['library']; ?>" >
78
  <input class="acf-image-value" type="hidden" name="<?php echo $field['name']; ?>" value="<?php echo $field['value']; ?>" />
79
  <div class="has-image">
80
  <div class="hover">
83
  <li><a class="acf-button-edit ir" href="#"><?php _e("Edit",'acf'); ?></a></li>
84
  </ul>
85
  </div>
86
+ <img class="acf-image-image" src="<?php echo $o['url']; ?>" alt=""/>
87
  </div>
88
  <div class="no-image">
89
  <p><?php _e('No image selected','acf'); ?> <input type="button" class="button add-image" value="<?php _e('Add Image','acf'); ?>" />
109
  function create_options( $field )
110
  {
111
  // vars
 
 
 
 
 
 
112
  $key = $field['name'];
113
 
114
  ?>
115
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
116
+ <td class="label">
117
+ <label><?php _e("Return Value",'acf'); ?></label>
118
+ </td>
119
+ <td>
120
+ <?php
121
+ do_action('acf/create_field', array(
122
+ 'type' => 'radio',
123
+ 'name' => 'fields['.$key.'][save_format]',
124
+ 'value' => $field['save_format'],
125
+ 'layout' => 'horizontal',
126
+ 'choices' => array(
127
+ 'object' => __("Image Object",'acf'),
128
+ 'url' => __("Image URL",'acf'),
129
+ 'id' => __("Image ID",'acf')
130
+ )
131
+ ));
132
+ ?>
133
+ </td>
134
+ </tr>
135
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
136
+ <td class="label">
137
+ <label><?php _e("Preview Size",'acf'); ?></label>
138
+ </td>
139
+ <td>
140
+ <?php
141
+
142
+ do_action('acf/create_field', array(
143
+ 'type' => 'radio',
144
+ 'name' => 'fields['.$key.'][preview_size]',
145
+ 'value' => $field['preview_size'],
146
+ 'layout' => 'horizontal',
147
+ 'choices' => apply_filters('acf/get_image_sizes', array())
148
+ ));
149
 
150
+ ?>
151
+ </td>
152
+ </tr>
153
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
154
+ <td class="label">
155
+ <label><?php _e("Library",'acf'); ?></label>
156
+ </td>
157
+ <td>
158
+ <?php
159
+
160
+ do_action('acf/create_field', array(
161
+ 'type' => 'radio',
162
+ 'name' => 'fields['.$key.'][library]',
163
+ 'value' => $field['library'],
164
+ 'layout' => 'horizontal',
165
+ 'choices' => array(
166
+ 'all' => __('All', 'acf'),
167
+ 'uploadedTo' => __('Uploaded to post', 'acf')
168
+ )
169
+ ));
170
+
171
+ ?>
172
+ </td>
173
+ </tr>
174
  <?php
175
 
176
  }
345
  {
346
  foreach( $options['images'] as $id )
347
  {
348
+ $url = wp_get_attachment_image_src( $id, $options['preview_size'] );
349
 
350
 
351
  $return[] = array(
352
  'id' => $id,
353
+ 'url' => $url[0],
354
  );
355
  }
356
  }
core/fields/message.php CHANGED
@@ -18,6 +18,10 @@ class acf_field_message extends acf_field
18
  $this->name = 'message';
19
  $this->label = __("Message",'acf');
20
  $this->category = __("Layout",'acf');
 
 
 
 
21
 
22
  // do not delete!
23
  parent::__construct();
@@ -58,11 +62,6 @@ class acf_field_message extends acf_field
58
  function create_options( $field )
59
  {
60
  // vars
61
- $defaults = array(
62
- 'message' => '',
63
- );
64
-
65
- $field = array_merge($defaults, $field);
66
  $key = $field['name'];
67
 
68
  ?>
18
  $this->name = 'message';
19
  $this->label = __("Message",'acf');
20
  $this->category = __("Layout",'acf');
21
+ $this->defaults = array(
22
+ 'message' => '',
23
+ );
24
+
25
 
26
  // do not delete!
27
  parent::__construct();
62
  function create_options( $field )
63
  {
64
  // vars
 
 
 
 
 
65
  $key = $field['name'];
66
 
67
  ?>
core/fields/number.php CHANGED
@@ -17,6 +17,9 @@ class acf_field_number extends acf_field
17
  // vars
18
  $this->name = 'number';
19
  $this->label = __("Number",'acf');
 
 
 
20
 
21
 
22
  // do not delete!
@@ -58,11 +61,6 @@ class acf_field_number extends acf_field
58
  function create_options( $field )
59
  {
60
  // vars
61
- $defaults = array(
62
- 'default_value' => '',
63
- );
64
-
65
- $field = array_merge($defaults, $field);
66
  $key = $field['name'];
67
 
68
  ?>
17
  // vars
18
  $this->name = 'number';
19
  $this->label = __("Number",'acf');
20
+ $this->defaults = array(
21
+ 'default_value' => '',
22
+ );
23
 
24
 
25
  // do not delete!
61
  function create_options( $field )
62
  {
63
  // vars
 
 
 
 
 
64
  $key = $field['name'];
65
 
66
  ?>
core/fields/page_link.php CHANGED
@@ -2,10 +2,6 @@
2
 
3
  class acf_field_page_link extends acf_field
4
  {
5
- // vars
6
- var $defaults;
7
-
8
-
9
  /*
10
  * __construct
11
  *
@@ -50,10 +46,7 @@ class acf_field_page_link extends acf_field
50
 
51
  function load_field( $field )
52
  {
53
- // defaults
54
- $field = array_merge($this->defaults, $field);
55
-
56
-
57
  // validate post_type
58
  if( !$field['post_type'] || !is_array($field['post_type']) || in_array('', $field['post_type']) )
59
  {
@@ -102,8 +95,6 @@ class acf_field_page_link extends acf_field
102
 
103
  function create_options( $field )
104
  {
105
- // defaults
106
- $field = array_merge($this->defaults, $field);
107
  $key = $field['name'];
108
 
109
  ?>
2
 
3
  class acf_field_page_link extends acf_field
4
  {
 
 
 
 
5
  /*
6
  * __construct
7
  *
46
 
47
  function load_field( $field )
48
  {
49
+
 
 
 
50
  // validate post_type
51
  if( !$field['post_type'] || !is_array($field['post_type']) || in_array('', $field['post_type']) )
52
  {
95
 
96
  function create_options( $field )
97
  {
 
 
98
  $key = $field['name'];
99
 
100
  ?>
core/fields/post_object.php CHANGED
@@ -2,10 +2,6 @@
2
 
3
  class acf_field_post_object extends acf_field
4
  {
5
- // vars
6
- var $defaults;
7
-
8
-
9
  /*
10
  * __construct
11
  *
@@ -51,10 +47,6 @@ class acf_field_post_object extends acf_field
51
 
52
  function load_field( $field )
53
  {
54
- // defaults
55
- $field = array_merge($this->defaults, $field);
56
-
57
-
58
  // validate post_type
59
  if( !$field['post_type'] || !is_array($field['post_type']) || in_array('', $field['post_type']) )
60
  {
@@ -88,10 +80,6 @@ class acf_field_post_object extends acf_field
88
 
89
  function create_field( $field )
90
  {
91
- // defaults
92
- $field = array_merge($this->defaults, $field);
93
-
94
-
95
  // global
96
  global $post;
97
 
@@ -272,7 +260,6 @@ class acf_field_post_object extends acf_field
272
  function create_options( $field )
273
  {
274
  // vars
275
- $field = array_merge($this->defaults, $field);
276
  $key = $field['name'];
277
 
278
  ?>
2
 
3
  class acf_field_post_object extends acf_field
4
  {
 
 
 
 
5
  /*
6
  * __construct
7
  *
47
 
48
  function load_field( $field )
49
  {
 
 
 
 
50
  // validate post_type
51
  if( !$field['post_type'] || !is_array($field['post_type']) || in_array('', $field['post_type']) )
52
  {
80
 
81
  function create_field( $field )
82
  {
 
 
 
 
83
  // global
84
  global $post;
85
 
260
  function create_options( $field )
261
  {
262
  // vars
 
263
  $key = $field['name'];
264
 
265
  ?>
core/fields/radio.php CHANGED
@@ -2,7 +2,6 @@
2
 
3
  class acf_field_radio extends acf_field
4
  {
5
-
6
  /*
7
  * __construct
8
  *
@@ -18,6 +17,11 @@ class acf_field_radio extends acf_field
18
  $this->name = 'radio';
19
  $this->label = __("Radio Button",'acf');
20
  $this->category = __("Choice",'acf');
 
 
 
 
 
21
 
22
 
23
  // do not delete!
@@ -41,14 +45,6 @@ class acf_field_radio extends acf_field
41
  function create_field( $field )
42
  {
43
  // vars
44
- $defaults = array(
45
- 'layout' => 'vertical',
46
- 'choices' => array(),
47
- );
48
-
49
- $field = array_merge($defaults, $field);
50
-
51
-
52
  echo '<ul class="radio_list ' . $field['class'] . ' ' . $field['layout'] . '">';
53
 
54
  $i = 0;
@@ -58,9 +54,9 @@ class acf_field_radio extends acf_field
58
  {
59
  $i++;
60
 
61
- // if there is no value and this is the first of the choices and there is no "0" choice, select this on by default
62
- // the 0 choice would normally match a no value. This needs to remain possible for the create new field to work.
63
- if(!$field['value'] && $i == 1 && !isset($field['choices'][0]))
64
  {
65
  $field['value'] = $key;
66
  }
@@ -96,13 +92,6 @@ class acf_field_radio extends acf_field
96
  function create_options( $field )
97
  {
98
  // vars
99
- $defaults = array(
100
- 'layout' => 'vertical',
101
- 'default_value' => '',
102
- 'choices' => '',
103
- );
104
-
105
- $field = array_merge($defaults, $field);
106
  $key = $field['name'];
107
 
108
  // implode checkboxes so they work in a textarea
2
 
3
  class acf_field_radio extends acf_field
4
  {
 
5
  /*
6
  * __construct
7
  *
17
  $this->name = 'radio';
18
  $this->label = __("Radio Button",'acf');
19
  $this->category = __("Choice",'acf');
20
+ $this->defaults = array(
21
+ 'layout' => 'vertical',
22
+ 'choices' => array(),
23
+ 'default_value' => '',
24
+ );
25
 
26
 
27
  // do not delete!
45
  function create_field( $field )
46
  {
47
  // vars
 
 
 
 
 
 
 
 
48
  echo '<ul class="radio_list ' . $field['class'] . ' ' . $field['layout'] . '">';
49
 
50
  $i = 0;
54
  {
55
  $i++;
56
 
57
+ // if there is no value and this is the first of the choices, select this on by default
58
+ // also make sure we dont match if the value is 0. Sometimes the value is 0!
59
+ if( $field['value'] !== 0 && !$field['value'] && $i == 1 )
60
  {
61
  $field['value'] = $key;
62
  }
92
  function create_options( $field )
93
  {
94
  // vars
 
 
 
 
 
 
 
95
  $key = $field['name'];
96
 
97
  // implode checkboxes so they work in a textarea
core/fields/relationship.php CHANGED
@@ -2,10 +2,6 @@
2
 
3
  class acf_field_relationship extends acf_field
4
  {
5
- // vars
6
- var $defaults;
7
-
8
-
9
  /*
10
  * __construct
11
  *
@@ -28,6 +24,9 @@ class acf_field_relationship extends acf_field
28
  'filters' => array('search'),
29
  'result_elements' => array('post_title', 'post_type')
30
  );
 
 
 
31
 
32
 
33
  // do not delete!
@@ -56,10 +55,6 @@ class acf_field_relationship extends acf_field
56
 
57
  function load_field( $field )
58
  {
59
- // defaults
60
- $field = array_merge($this->defaults, $field);
61
-
62
-
63
  // validate post_type
64
  if( !$field['post_type'] || !is_array($field['post_type']) || in_array('', $field['post_type']) )
65
  {
@@ -544,7 +539,6 @@ class acf_field_relationship extends acf_field
544
  function create_options( $field )
545
  {
546
  // vars
547
- $field = array_merge($this->defaults, $field);
548
  $key = $field['name'];
549
 
550
  ?>
2
 
3
  class acf_field_relationship extends acf_field
4
  {
 
 
 
 
5
  /*
6
  * __construct
7
  *
24
  'filters' => array('search'),
25
  'result_elements' => array('post_title', 'post_type')
26
  );
27
+ $this->l10n = array(
28
+ 'max' => __("Maximum values reached ( {max} values )",'acf')
29
+ );
30
 
31
 
32
  // do not delete!
55
 
56
  function load_field( $field )
57
  {
 
 
 
 
58
  // validate post_type
59
  if( !$field['post_type'] || !is_array($field['post_type']) || in_array('', $field['post_type']) )
60
  {
539
  function create_options( $field )
540
  {
541
  // vars
 
542
  $key = $field['name'];
543
 
544
  ?>
core/fields/select.php CHANGED
@@ -2,10 +2,6 @@
2
 
3
  class acf_field_select extends acf_field
4
  {
5
- // vars
6
- var $defaults;
7
-
8
-
9
  /*
10
  * __construct
11
  *
@@ -55,7 +51,6 @@ class acf_field_select extends acf_field
55
  function create_field( $field )
56
  {
57
  // vars
58
- $field = array_merge($this->defaults, $field);
59
  $optgroup = false;
60
 
61
 
@@ -163,7 +158,6 @@ class acf_field_select extends acf_field
163
 
164
  function create_options( $field )
165
  {
166
- $field = array_merge($this->defaults, $field);
167
  $key = $field['name'];
168
 
169
 
@@ -303,9 +297,6 @@ class acf_field_select extends acf_field
303
 
304
  function update_field( $field, $post_id )
305
  {
306
- // vars
307
- $field = array_merge($this->defaults, $field);
308
-
309
 
310
  // check if is array. Normal back end edit posts a textarea, but a user might use update_field from the front end
311
  if( is_array( $field['choices'] ))
2
 
3
  class acf_field_select extends acf_field
4
  {
 
 
 
 
5
  /*
6
  * __construct
7
  *
51
  function create_field( $field )
52
  {
53
  // vars
 
54
  $optgroup = false;
55
 
56
 
158
 
159
  function create_options( $field )
160
  {
 
161
  $key = $field['name'];
162
 
163
 
297
 
298
  function update_field( $field, $post_id )
299
  {
 
 
 
300
 
301
  // check if is array. Normal back end edit posts a textarea, but a user might use update_field from the front end
302
  if( is_array( $field['choices'] ))
core/fields/tab.php CHANGED
@@ -19,6 +19,7 @@ class acf_field_tab extends acf_field
19
  $this->label = __("Tab",'acf');
20
  $this->category = __("Layout",'acf');
21
 
 
22
  // do not delete!
23
  parent::__construct();
24
  }
19
  $this->label = __("Tab",'acf');
20
  $this->category = __("Layout",'acf');
21
 
22
+
23
  // do not delete!
24
  parent::__construct();
25
  }
core/fields/taxonomy.php CHANGED
@@ -2,10 +2,6 @@
2
 
3
  class acf_field_taxonomy extends acf_field
4
  {
5
-
6
- var $defaults;
7
-
8
-
9
  /*
10
  * __construct
11
  *
@@ -21,9 +17,6 @@ class acf_field_taxonomy extends acf_field
21
  $this->name = 'taxonomy';
22
  $this->label = __("Taxonomy",'acf');
23
  $this->category = __("Relational",'acf');
24
-
25
-
26
- // settings
27
  $this->defaults = array(
28
  'taxonomy' => 'category',
29
  'field_type' => 'checkbox',
@@ -58,10 +51,6 @@ class acf_field_taxonomy extends acf_field
58
 
59
  function load_value( $value, $post_id, $field )
60
  {
61
- // vars
62
- $field = array_merge($this->defaults, $field);
63
-
64
-
65
  if( $field['load_save_terms'] )
66
  {
67
  $value = array();
@@ -100,7 +89,6 @@ class acf_field_taxonomy extends acf_field
100
  function update_value( $value, $post_id, $field )
101
  {
102
  // vars
103
- $field = array_merge($this->defaults, $field);
104
  if( is_array($value) )
105
  {
106
  $value = array_filter($value);
@@ -138,8 +126,11 @@ class acf_field_taxonomy extends acf_field
138
 
139
  function format_value_for_api( $value, $post_id, $field )
140
  {
141
- // defaults
142
- $field = array_merge($this->defaults, $field);
 
 
 
143
 
144
 
145
  // temp convert to array
@@ -188,7 +179,6 @@ class acf_field_taxonomy extends acf_field
188
  function create_field( $field )
189
  {
190
  // vars
191
- $field = array_merge($this->defaults, $field);
192
  $single_name = $field['name'];
193
 
194
 
@@ -278,7 +268,6 @@ class acf_field_taxonomy extends acf_field
278
  function create_options( $field )
279
  {
280
  // vars
281
- $field = array_merge($this->defaults, $field);
282
  $key = $field['name'];
283
 
284
  ?>
2
 
3
  class acf_field_taxonomy extends acf_field
4
  {
 
 
 
 
5
  /*
6
  * __construct
7
  *
17
  $this->name = 'taxonomy';
18
  $this->label = __("Taxonomy",'acf');
19
  $this->category = __("Relational",'acf');
 
 
 
20
  $this->defaults = array(
21
  'taxonomy' => 'category',
22
  'field_type' => 'checkbox',
51
 
52
  function load_value( $value, $post_id, $field )
53
  {
 
 
 
 
54
  if( $field['load_save_terms'] )
55
  {
56
  $value = array();
89
  function update_value( $value, $post_id, $field )
90
  {
91
  // vars
 
92
  if( is_array($value) )
93
  {
94
  $value = array_filter($value);
126
 
127
  function format_value_for_api( $value, $post_id, $field )
128
  {
129
+ // no value?
130
+ if( !$value )
131
+ {
132
+ return $value;
133
+ }
134
 
135
 
136
  // temp convert to array
179
  function create_field( $field )
180
  {
181
  // vars
 
182
  $single_name = $field['name'];
183
 
184
 
268
  function create_options( $field )
269
  {
270
  // vars
 
271
  $key = $field['name'];
272
 
273
  ?>
core/fields/text.php CHANGED
@@ -17,6 +17,10 @@ class acf_field_text extends acf_field
17
  // vars
18
  $this->name = 'text';
19
  $this->label = __("Text",'acf');
 
 
 
 
20
 
21
 
22
  // do not delete!
@@ -59,12 +63,6 @@ class acf_field_text extends acf_field
59
  function create_options( $field )
60
  {
61
  // vars
62
- $defaults = array(
63
- 'default_value' => '',
64
- 'formatting' => 'html',
65
- );
66
-
67
- $field = array_merge($defaults, $field);
68
  $key = $field['name'];
69
 
70
  ?>
@@ -148,14 +146,6 @@ class acf_field_text extends acf_field
148
 
149
  function format_value_for_api( $value, $post_id, $field )
150
  {
151
- // vars
152
- $defaults = array(
153
- 'formatting' => 'html',
154
- );
155
-
156
- $field = array_merge($defaults, $field);
157
-
158
-
159
  // validate type
160
  if( !is_string($value) )
161
  {
17
  // vars
18
  $this->name = 'text';
19
  $this->label = __("Text",'acf');
20
+ $this->defaults = array(
21
+ 'default_value' => '',
22
+ 'formatting' => 'html',
23
+ );
24
 
25
 
26
  // do not delete!
63
  function create_options( $field )
64
  {
65
  // vars
 
 
 
 
 
 
66
  $key = $field['name'];
67
 
68
  ?>
146
 
147
  function format_value_for_api( $value, $post_id, $field )
148
  {
 
 
 
 
 
 
 
 
149
  // validate type
150
  if( !is_string($value) )
151
  {
core/fields/textarea.php CHANGED
@@ -17,6 +17,10 @@ class acf_field_textarea extends acf_field
17
  // vars
18
  $this->name = 'textarea';
19
  $this->label = __("Text Area",'acf');
 
 
 
 
20
 
21
 
22
  // do not delete!
@@ -59,12 +63,6 @@ class acf_field_textarea extends acf_field
59
  function create_options( $field )
60
  {
61
  // vars
62
- $defaults = array(
63
- 'default_value' => '',
64
- 'formatting' => 'br',
65
- );
66
-
67
- $field = array_merge($defaults, $field);
68
  $key = $field['name'];
69
 
70
  ?>
@@ -125,14 +123,6 @@ class acf_field_textarea extends acf_field
125
 
126
  function format_value_for_api( $value, $post_id, $field )
127
  {
128
- // vars
129
- $defaults = array(
130
- 'formatting' => 'br',
131
- );
132
-
133
- $field = array_merge($defaults, $field);
134
-
135
-
136
  // validate type
137
  if( !is_string($value) )
138
  {
17
  // vars
18
  $this->name = 'textarea';
19
  $this->label = __("Text Area",'acf');
20
+ $this->defaults = array(
21
+ 'default_value' => '',
22
+ 'formatting' => 'br',
23
+ );
24
 
25
 
26
  // do not delete!
63
  function create_options( $field )
64
  {
65
  // vars
 
 
 
 
 
 
66
  $key = $field['name'];
67
 
68
  ?>
123
 
124
  function format_value_for_api( $value, $post_id, $field )
125
  {
 
 
 
 
 
 
 
 
126
  // validate type
127
  if( !is_string($value) )
128
  {
core/fields/true_false.php CHANGED
@@ -18,6 +18,10 @@ class acf_field_true_false extends acf_field
18
  $this->name = 'true_false';
19
  $this->label = __("True / False",'acf');
20
  $this->category = __("Choice",'acf');
 
 
 
 
21
 
22
 
23
  // do not delete!
@@ -40,14 +44,6 @@ class acf_field_true_false extends acf_field
40
 
41
  function create_field( $field )
42
  {
43
- // vars
44
- $defaults = array(
45
- 'message' => '',
46
- );
47
-
48
- $field = array_merge($defaults, $field);
49
-
50
-
51
  // html
52
  echo '<ul class="checkbox_list ' . $field['class'] . '">';
53
  echo '<input type="hidden" name="'.$field['name'].'" value="0" />';
@@ -74,12 +70,6 @@ class acf_field_true_false extends acf_field
74
  function create_options( $field )
75
  {
76
  // vars
77
- $defaults = array(
78
- 'default_value' => 0,
79
- 'message' => '',
80
- );
81
-
82
- $field = array_merge($defaults, $field);
83
  $key = $field['name'];
84
 
85
 
18
  $this->name = 'true_false';
19
  $this->label = __("True / False",'acf');
20
  $this->category = __("Choice",'acf');
21
+ $this->defaults = array(
22
+ 'default_value' => 0,
23
+ 'message' => '',
24
+ );
25
 
26
 
27
  // do not delete!
44
 
45
  function create_field( $field )
46
  {
 
 
 
 
 
 
 
 
47
  // html
48
  echo '<ul class="checkbox_list ' . $field['class'] . '">';
49
  echo '<input type="hidden" name="'.$field['name'].'" value="0" />';
70
  function create_options( $field )
71
  {
72
  // vars
 
 
 
 
 
 
73
  $key = $field['name'];
74
 
75
 
core/fields/user.php CHANGED
@@ -2,10 +2,6 @@
2
 
3
  class acf_field_user extends acf_field
4
  {
5
-
6
- var $defaults;
7
-
8
-
9
  /*
10
  * __construct
11
  *
@@ -21,9 +17,6 @@ class acf_field_user extends acf_field
21
  $this->name = 'user';
22
  $this->label = __("User",'acf');
23
  $this->category = __("Relational",'acf');
24
-
25
-
26
- // settings
27
  $this->defaults = array(
28
  'role' => 'all',
29
  'field_type' => 'select',
@@ -150,7 +143,6 @@ class acf_field_user extends acf_field
150
  function create_field( $field )
151
  {
152
  // vars
153
- $field = array_merge($this->defaults, $field);
154
  $field['choices'] = array();
155
  $args = array();
156
  $editable_roles = get_editable_roles();
@@ -224,7 +216,6 @@ class acf_field_user extends acf_field
224
  function create_options( $field )
225
  {
226
  // vars
227
- $field = array_merge($this->defaults, $field);
228
  $key = $field['name'];
229
 
230
  ?>
2
 
3
  class acf_field_user extends acf_field
4
  {
 
 
 
 
5
  /*
6
  * __construct
7
  *
17
  $this->name = 'user';
18
  $this->label = __("User",'acf');
19
  $this->category = __("Relational",'acf');
 
 
 
20
  $this->defaults = array(
21
  'role' => 'all',
22
  'field_type' => 'select',
143
  function create_field( $field )
144
  {
145
  // vars
 
146
  $field['choices'] = array();
147
  $args = array();
148
  $editable_roles = get_editable_roles();
216
  function create_options( $field )
217
  {
218
  // vars
 
219
  $key = $field['name'];
220
 
221
  ?>
core/fields/wysiwyg.php CHANGED
@@ -18,6 +18,11 @@ class acf_field_wysiwyg extends acf_field
18
  $this->name = 'wysiwyg';
19
  $this->label = __("Wysiwyg Editor",'acf');
20
  $this->category = __("Content",'acf');
 
 
 
 
 
21
 
22
 
23
  // do not delete!
@@ -113,12 +118,6 @@ class acf_field_wysiwyg extends acf_field
113
 
114
 
115
  // vars
116
- $defaults = array(
117
- 'toolbar' => 'full',
118
- 'media_upload' => 'yes',
119
- );
120
- $field = array_merge($defaults, $field);
121
-
122
  $id = 'wysiwyg-' . $field['id'] . '-' . uniqid();
123
 
124
 
@@ -164,13 +163,6 @@ class acf_field_wysiwyg extends acf_field
164
  function create_options( $field )
165
  {
166
  // vars
167
- $defaults = array(
168
- 'toolbar' => 'full',
169
- 'media_upload' => 'yes',
170
- 'default_value' => '',
171
- );
172
-
173
- $field = array_merge($defaults, $field);
174
  $key = $field['name'];
175
 
176
  ?>
@@ -261,21 +253,31 @@ class acf_field_wysiwyg extends acf_field
261
 
262
  function format_value_for_api( $value, $post_id, $field )
263
  {
264
- // wp_embed convert urls to videos
 
265
  if( isset($GLOBALS['wp_embed']) )
266
  {
267
- $embed = $GLOBALS['wp_embed'];
268
- $value = $embed->run_shortcode( $value );
269
- $value = $embed->autoembed( $value );
270
  }
271
 
272
 
273
- // auto p
274
- $value = wpautop( $value );
 
 
 
 
 
 
275
 
276
 
277
- // run all normal shortcodes
278
- $value = do_shortcode( $value );
 
 
 
 
279
 
280
 
281
  return $value;
@@ -283,6 +285,8 @@ class acf_field_wysiwyg extends acf_field
283
 
284
  }
285
 
 
 
286
  new acf_field_wysiwyg();
287
 
288
  ?>
18
  $this->name = 'wysiwyg';
19
  $this->label = __("Wysiwyg Editor",'acf');
20
  $this->category = __("Content",'acf');
21
+ $this->defaults = array(
22
+ 'toolbar' => 'full',
23
+ 'media_upload' => 'yes',
24
+ 'default_value' => '',
25
+ );
26
 
27
 
28
  // do not delete!
118
 
119
 
120
  // vars
 
 
 
 
 
 
121
  $id = 'wysiwyg-' . $field['id'] . '-' . uniqid();
122
 
123
 
163
  function create_options( $field )
164
  {
165
  // vars
 
 
 
 
 
 
 
166
  $key = $field['name'];
167
 
168
  ?>
253
 
254
  function format_value_for_api( $value, $post_id, $field )
255
  {
256
+
257
+ // shortcode / wp_embed
258
  if( isset($GLOBALS['wp_embed']) )
259
  {
260
+ add_filter( 'acf_the_content', array( $GLOBALS['wp_embed'], 'run_shortcode' ), 8 );
261
+ add_filter( 'acf_the_content', array( $GLOBALS['wp_embed'], 'autoembed' ), 8 );
 
262
  }
263
 
264
 
265
+ // the_content filters
266
+ add_filter( 'acf_the_content', 'capital_P_dangit', 11 );
267
+ add_filter( 'acf_the_content', 'wptexturize' );
268
+ add_filter( 'acf_the_content', 'convert_smilies' );
269
+ add_filter( 'acf_the_content', 'convert_chars' );
270
+ add_filter( 'acf_the_content', 'wpautop' );
271
+ add_filter( 'acf_the_content', 'shortcode_unautop' );
272
+ add_filter( 'acf_the_content', 'do_shortcode', 11);
273
 
274
 
275
+ // apply filters
276
+ $value = apply_filters( 'acf_the_content', $value );
277
+
278
+
279
+ // follow the_content function in /wp-includes/post-template.php
280
+ $value = str_replace(']]>', ']]&gt;', $value);
281
 
282
 
283
  return $value;
285
 
286
  }
287
 
288
+
289
+
290
  new acf_field_wysiwyg();
291
 
292
  ?>
css/global.css CHANGED
@@ -314,29 +314,29 @@ table.acf_input select:focus {
314
  }
315
 
316
 
317
- ul.radio_list {
 
 
318
  position: relative;
319
  display: block;
320
  padding: 1px;
321
  margin: 0;
322
  }
323
 
324
- ul.radio_list.horizontal {
 
325
  overflow: hidden;
326
  }
327
 
328
- ul.radio_list.horizontal li {
 
329
  float: left;
330
  margin-right: 20px;
331
  }
332
 
333
- ul.checkbox_list {
334
- background: transparent !important;
335
- margin: 0;
336
- }
337
-
338
  ul.radio_list li input,
339
  ul.checkbox_list li input {
 
340
  margin-right: 5px !important;
341
  width: auto !important;
342
  }
@@ -496,6 +496,34 @@ a.acf-button-big {
496
  }
497
 
498
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
499
 
500
  /*--------------------------------------------------------------------------
501
  *
314
  }
315
 
316
 
317
+ ul.radio_list,
318
+ ul.checkbox_list {
319
+ background: transparent !important;
320
  position: relative;
321
  display: block;
322
  padding: 1px;
323
  margin: 0;
324
  }
325
 
326
+ ul.radio_list.horizontal,
327
+ ul.checkbox_list.horizontal {
328
  overflow: hidden;
329
  }
330
 
331
+ ul.radio_list.horizontal li,
332
+ ul.checkbox_list.horizontal li {
333
  float: left;
334
  margin-right: 20px;
335
  }
336
 
 
 
 
 
 
337
  ul.radio_list li input,
338
  ul.checkbox_list li input {
339
+ margin-top: -1px;
340
  margin-right: 5px !important;
341
  width: auto !important;
342
  }
496
  }
497
 
498
 
499
+ /*--------------------------------------------------------------------------
500
+ *
501
+ * Plugin Update Info
502
+ *
503
+ *-------------------------------------------------------------------------*/
504
+
505
+ .plugins #advanced-custom-fields + .plugin-update-tr .update-message {
506
+ background: #EAF2FA;
507
+ border: #C7D7E2 solid 1px;
508
+ padding: 10px;
509
+ }
510
+
511
+ .acf-plugin-update-info {
512
+ font-weight: normal;
513
+ }
514
+
515
+ .acf-plugin-update-info h3 {
516
+ font-size: 12px;
517
+ line-height: 1em;
518
+ margin: 15px 0 10px;
519
+ }
520
+
521
+ .acf-plugin-update-info ul {
522
+ list-style: disc outside;
523
+ padding-left: 14px;
524
+ margin: 0;
525
+ }
526
+
527
 
528
  /*--------------------------------------------------------------------------
529
  *
css/input.css CHANGED
@@ -4,35 +4,34 @@
4
  *
5
  *---------------------------------------------------------------------------------------------*/
6
 
7
- #poststuff .acf_postbox {
8
- display: block;
9
- }
10
-
11
- #poststuff .acf_postbox.acf-hidden {
12
  display: none !important;
13
  }
14
 
15
- #poststuff .acf_postbox .widefat th,
16
- #poststuff .acf_postbox .widefat td {
17
- overflow: visible;
18
-
19
  }
20
 
21
- #poststuff .acf_postbox .inside {
22
  margin: 0;
23
  padding: 0;
24
  }
25
 
26
- #poststuff .acf_postbox.no_box {
27
  border: 0 none;
28
  background: transparent;
29
  }
30
 
31
- #poststuff .acf_postbox.no_box > h3,
32
- #poststuff .acf_postbox.no_box > .handlediv {
33
  display: none;
34
  }
35
 
 
 
 
 
 
36
 
37
  /*---------------------------------------------------------------------------------------------
38
  *
@@ -130,6 +129,7 @@
130
  width: 100%;
131
  padding: 5px;
132
  resize: none;
 
133
  }
134
 
135
  .acf_postbox .field textarea {
@@ -221,10 +221,14 @@
221
 
222
 
223
  .acf-image-uploader img {
224
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
225
  width:100%;
226
  height: auto;
227
  display: block;
 
 
 
 
228
  }
229
 
230
  .acf-image-uploader .no-image p {
@@ -476,6 +480,7 @@
476
 
477
  .acf-file-uploader .has-file {
478
  display: none;
 
479
  }
480
 
481
  .acf-file-uploader .no-file {
@@ -490,14 +495,70 @@
490
  display: none;
491
  }
492
 
 
 
 
 
 
493
  .acf-file-uploader img {
494
- margin: 0 5px 0 0;
 
 
 
 
495
  }
496
 
497
  .acf-file-uploader input.button {
498
  width: auto;
499
  }
500
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
501
 
502
  /*---------------------------------------------------------------------------------------------
503
  *
@@ -586,9 +647,8 @@ table.acf-input-table > tbody > tr > td:last-child {
586
  border-right: 0 none;
587
  }
588
 
589
-
590
  td.acf_input-wrap {
591
- padding: 0 !important;;
592
  }
593
 
594
  .sub-field-instructions {
@@ -709,6 +769,7 @@ td.acf_input-wrap {
709
  .acf_relationship .relationship_right .relationship_list {
710
  margin-left: 10px;
711
  height: 193px;
 
712
  border-top-width:1px;
713
  }
714
 
@@ -948,14 +1009,24 @@ tr.acf-conditional_logic-show {
948
  }
949
 
950
 
951
- #acf_color_picker {
 
 
 
 
 
 
952
  position: absolute;
953
  top: 0;
954
  left: 0;
955
  display: none;
956
- background: #fff;
957
- border: #AAAAAA solid 1px;
958
- border-radius: 4px;
 
 
 
 
959
  }
960
 
961
 
4
  *
5
  *---------------------------------------------------------------------------------------------*/
6
 
7
+ .acf-hidden {
 
 
 
 
8
  display: none !important;
9
  }
10
 
11
+ .acf_postbox {
12
+ display: block;
 
 
13
  }
14
 
15
+ .acf_postbox .inside {
16
  margin: 0;
17
  padding: 0;
18
  }
19
 
20
+ .acf_postbox.no_box {
21
  border: 0 none;
22
  background: transparent;
23
  }
24
 
25
+ .acf_postbox.no_box > h3,
26
+ .acf_postbox.no_box > .handlediv {
27
  display: none;
28
  }
29
 
30
+ .acf_postbox .widefat th,
31
+ .acf_postbox .widefat td {
32
+ overflow: visible;
33
+ }
34
+
35
 
36
  /*---------------------------------------------------------------------------------------------
37
  *
129
  width: 100%;
130
  padding: 5px;
131
  resize: none;
132
+ margin: 0;
133
  }
134
 
135
  .acf_postbox .field textarea {
221
 
222
 
223
  .acf-image-uploader img {
224
+ box-shadow: 0 0 2px rgba(0, 0, 0, 0.2);
225
  width:100%;
226
  height: auto;
227
  display: block;
228
+ min-width: 30px;
229
+ min-height: 30px;
230
+ background: #f1f1f1;
231
+ margin: 0 0 0 2px;
232
  }
233
 
234
  .acf-image-uploader .no-image p {
480
 
481
  .acf-file-uploader .has-file {
482
  display: none;
483
+ float: left;
484
  }
485
 
486
  .acf-file-uploader .no-file {
495
  display: none;
496
  }
497
 
498
+ .acf-file-uploader li {
499
+ position: relative;
500
+ margin: 0 10px 0 0;
501
+ }
502
+
503
  .acf-file-uploader img {
504
+ min-height: 60px;
505
+ min-width: 46px;
506
+ box-shadow: 0 0 2px rgba(0, 0, 0, 0.2);
507
+ display: block;
508
+ background: #f1f1f1;
509
  }
510
 
511
  .acf-file-uploader input.button {
512
  width: auto;
513
  }
514
 
515
+ .acf-file-uploader a {
516
+ text-decoration: none;
517
+ }
518
+
519
+ .acf-file-uploader p {
520
+ margin: 0 0 4px;
521
+ }
522
+
523
+
524
+ /*
525
+ * Hover
526
+ */
527
+
528
+ .acf-file-uploader .hover {
529
+ position: absolute;
530
+ top: -10px;
531
+ right: -10px;
532
+
533
+ -webkit-transition: opacity 0.25s 0s ease-in-out, visibility 0s linear 0.25s;
534
+ -moz-transition: opacity 0.25s 0s ease-in-out, visibility 0s linear 0.25s;
535
+ -o-transition: opacity 0.25s 0s ease-in-out, visibility 0s linear 0.25s;
536
+ transition: opacity 0.25s 0s ease-in-out, visibility 0s linear 0.25s;
537
+
538
+ visibility: hidden;
539
+ opacity: 0;
540
+ }
541
+
542
+ .acf-file-uploader .has-file:hover .hover {
543
+ -webkit-transition-delay:0s;
544
+ -moz-transition-delay:0s;
545
+ -o-transition-delay:0s;
546
+ transition-delay:0s;
547
+
548
+ visibility: visible;
549
+ opacity: 1;
550
+ }
551
+
552
+ .acf-file-uploader .hover ul {
553
+ display: block;
554
+ margin: 0;
555
+ padding: 0;
556
+ }
557
+
558
+ .acf-file-uploader .hover ul li {
559
+ margin: 0 0 3px 0;
560
+ }
561
+
562
 
563
  /*---------------------------------------------------------------------------------------------
564
  *
647
  border-right: 0 none;
648
  }
649
 
 
650
  td.acf_input-wrap {
651
+ padding: 0 !important;
652
  }
653
 
654
  .sub-field-instructions {
769
  .acf_relationship .relationship_right .relationship_list {
770
  margin-left: 10px;
771
  height: 193px;
772
+ min-height: 193px;
773
  border-top-width:1px;
774
  }
775
 
1009
  }
1010
 
1011
 
1012
+ /*--------------------------------------------------------------------------
1013
+ *
1014
+ * Field: Color picker
1015
+ *
1016
+ *-------------------------------------------------------------------------*/
1017
+
1018
+ #acf-farbtastic {
1019
  position: absolute;
1020
  top: 0;
1021
  left: 0;
1022
  display: none;
1023
+
1024
+ background: #FFFFFF;
1025
+ border: 1px solid #E1E1E1;
1026
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
1027
+
1028
+ border-radius: 3px;
1029
+ margin: -2px 0 0;
1030
  }
1031
 
1032
 
js/input/actions.js CHANGED
@@ -20,6 +20,7 @@ var acf = {
20
  }
21
  },
22
  helpers : {
 
23
  version_compare : function(){},
24
  uniqid : function(){},
25
  sortable : function(){},
@@ -35,30 +36,10 @@ var acf = {
35
  type : function(){}
36
  },
37
  fields : {
38
- date_picker : {
39
- text : {}
40
- },
41
- color_picker : {
42
- farbtastic : null
43
- },
44
- image : {
45
- add : function(){},
46
- edit : function(){},
47
- remove : function(){},
48
- text : {
49
- title_add : "Select Image",
50
- title_edit : "Edit Image"
51
- }
52
- },
53
- file : {
54
- add : function(){},
55
- edit : function(){},
56
- remove : function(){},
57
- text : {
58
- title_add : "Select File",
59
- title_edit : "Edit File"
60
- }
61
- },
62
  wysiwyg : {
63
  toolbars : {},
64
  has_tinymce : function(){},
@@ -89,6 +70,35 @@ var acf = {
89
  (function($){
90
 
91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  /**
93
  * Simply compares two string version values.
94
  *
@@ -222,49 +232,6 @@ var acf = {
222
  return type;
223
 
224
  };
225
-
226
-
227
-
228
- /*
229
- * Document Ready
230
- *
231
- * @description:
232
- * @since: 3.5.8
233
- * @created: 17/01/13
234
- */
235
-
236
- $(document).ready(function(){
237
-
238
- // add classes
239
- $('#poststuff .postbox[id*="acf_"]').addClass('acf_postbox');
240
- $('#adv-settings label[for*="acf_"]').addClass('acf_hide_label');
241
-
242
- // hide acf stuff
243
- $('#poststuff .acf_postbox').addClass('acf-hidden');
244
- $('#adv-settings .acf_hide_label').hide();
245
-
246
- // loop through acf metaboxes
247
- $('#poststuff .postbox.acf_postbox').each(function(){
248
-
249
- // vars
250
- var options = $(this).find('> .inside > .options'),
251
- show = options.attr('data-show'),
252
- layout = options.attr('data-layout'),
253
- id = $(this).attr('id').replace('acf_', '');
254
-
255
- // layout
256
- $(this).addClass(layout);
257
-
258
- // show / hide
259
- if( show == "1" )
260
- {
261
- $(this).removeClass('acf-hidden');
262
- $('#adv-settings .acf_hide_label[for="acf_' + id + '-hide"]').show();
263
- }
264
-
265
- });
266
-
267
- });
268
 
269
 
270
  /*
@@ -456,6 +423,26 @@ var acf = {
456
  }
457
 
458
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
459
  /*
460
  * window load
461
  *
20
  }
21
  },
22
  helpers : {
23
+ get_atts : function(){},
24
  version_compare : function(){},
25
  uniqid : function(){},
26
  sortable : function(){},
36
  type : function(){}
37
  },
38
  fields : {
39
+ date_picker : {},
40
+ color_picker : {},
41
+ image : {},
42
+ file : {},
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  wysiwyg : {
44
  toolbars : {},
45
  has_tinymce : function(){},
70
  (function($){
71
 
72
 
73
+ /*
74
+ * acf.helpers.get_atts
75
+ *
76
+ * description
77
+ *
78
+ * @type function
79
+ * @date 1/06/13
80
+ *
81
+ * @param {el} $el
82
+ * @return {object} atts
83
+ */
84
+
85
+ acf.helpers.get_atts = function( $el ){
86
+
87
+ var atts = {};
88
+
89
+ $.each( $el[0].attributes, function( index, attr ) {
90
+
91
+ if( attr.name.substr(0, 5) == 'data-' )
92
+ {
93
+ atts[ attr.name.replace('data-', '') ] = attr.value;
94
+ }
95
+ });
96
+
97
+ return atts;
98
+
99
+ };
100
+
101
+
102
  /**
103
  * Simply compares two string version values.
104
  *
232
  return type;
233
 
234
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
 
236
 
237
  /*
423
  }
424
 
425
 
426
+ /*
427
+ * Document Ready
428
+ *
429
+ * @description:
430
+ * @since: 3.5.8
431
+ * @created: 17/01/13
432
+ */
433
+
434
+ $(document).ready(function(){
435
+
436
+ // fix for older options page add-on
437
+ $('.acf_postbox > .inside > .options').each(function(){
438
+
439
+ $(this).closest('.acf_postbox').addClass( $(this).attr('data-layout') );
440
+
441
+ });
442
+
443
+ });
444
+
445
+
446
  /*
447
  * window load
448
  *
js/input/ajax.js CHANGED
@@ -1,73 +1,59 @@
1
- /*
2
- * Input Ajax
3
- *
4
- * @description: show / hide metaboxes from changing category / tempalte / etc
5
- * @author: Elliot Condon
6
- * @since: 3.1.4
7
- */
8
-
9
  (function($){
10
 
11
-
12
- /*
13
- * Exists
14
- *
15
- * @description: returns true / false
16
- * @created: 1/03/2011
17
- */
18
-
19
- $.fn.exists = function()
20
- {
21
- return $(this).length>0;
22
- };
23
-
24
 
25
  /*
26
- * Vars
27
  *
28
- * @description:
29
- * @created: 3/09/12
 
 
30
  */
31
 
32
- acf.data = {
33
- 'action' : 'acf/location/match_field_groups_ajax',
34
- 'post_id' : 0,
35
- 'page_template' : 0,
36
- 'page_parent' : 0,
37
- 'page_type' : 0,
38
- 'post_category' : 0,
39
- 'post_format' : 0,
40
- 'taxonomy' : 0,
41
- 'lang' : 0,
42
- 'nonce' : 0,
43
- 'return' : 'json'
44
  };
45
 
46
-
47
  /*
48
  * Document Ready
49
  *
50
- * @description: adds ajax data
51
- * @created: 1/03/2011
 
 
 
 
 
52
  */
53
 
54
  $(document).ready(function(){
55
 
56
 
57
  // update post_id
58
- acf.data.post_id = acf.post_id;
59
- acf.data.nonce = acf.nonce;
60
 
61
 
62
  // MPML
63
- if( $('#icl-als-first').exists() )
64
  {
65
  var href = $('#icl-als-first').children('a').attr('href'),
66
  regex = new RegExp( "lang=([^&#]*)" ),
67
  results = regex.exec( href );
68
 
69
  // lang
70
- acf.data.lang = results[1];
71
 
72
  }
73
 
@@ -85,7 +71,7 @@
85
 
86
  $.ajax({
87
  url: ajaxurl,
88
- data: acf.data,
89
  type: 'post',
90
  dataType: 'json',
91
  success: function(result){
@@ -98,9 +84,9 @@
98
 
99
 
100
  // hide all metaboxes
101
- $('#poststuff .acf_postbox').addClass('acf-hidden');
102
- $('#adv-settings .acf_hide_label').hide();
103
-
104
 
105
  // dont bother loading style or html for inputs
106
  if( result.length == 0 )
@@ -113,31 +99,37 @@
113
  $.each(result, function(k, v) {
114
 
115
 
116
- var postbox = $('#poststuff #acf_' + v);
 
 
 
 
 
 
 
 
117
 
118
- postbox.removeClass('acf-hidden');
119
- $('#adv-settings .acf_hide_label[for="acf_' + v + '-hide"]').show();
120
 
121
  // load fields if needed
122
- postbox.find('.acf-replace-with-fields').each(function(){
123
 
124
- var div = $(this);
125
 
126
  $.ajax({
127
- url: ajaxurl,
128
- data: {
129
- action : 'acf/input/render_fields',
130
- acf_id : v,
131
- post_id : acf.post_id,
132
- nonce : acf.nonce
133
  },
134
- type: 'post',
135
- dataType: 'html',
136
- success: function(html){
137
 
138
- div.replaceWith(html);
139
 
140
- $(document).trigger('acf/setup_fields', postbox);
141
 
142
  }
143
  });
@@ -145,23 +137,26 @@
145
  });
146
  });
147
 
 
148
  // load style
149
  $.ajax({
150
- url: ajaxurl,
151
- data: {
152
- action : 'acf/input/get_style',
153
- acf_id : result[0],
154
- nonce : acf.nonce
155
  },
156
- type: 'post',
157
- dataType: 'html',
158
- success: function(result){
159
 
160
- $('#acf_style').html(result);
161
 
162
  }
163
  });
164
 
 
 
165
  }
166
  });
167
  });
@@ -176,7 +171,7 @@
176
 
177
  $('#page_template').live('change', function(){
178
 
179
- acf.data.page_template = $(this).val();
180
 
181
  $(document).trigger('acf/update_field_groups');
182
 
@@ -191,13 +186,13 @@
191
  // set page_type / page_parent
192
  if( val != "" )
193
  {
194
- acf.data.page_type = 'child';
195
- acf.data.page_parent = val;
196
  }
197
  else
198
  {
199
- acf.data.page_type = 'parent';
200
- acf.data.page_parent = 0;
201
  }
202
 
203
 
@@ -215,7 +210,7 @@
215
  val = 'standard';
216
  }
217
 
218
- acf.data.post_format = val;
219
 
220
  $(document).trigger('acf/update_field_groups');
221
 
@@ -235,8 +230,8 @@
235
  });
236
 
237
 
238
- acf.data.post_category = values;
239
- acf.data.taxonomy = values;
240
 
241
 
242
  $(document).trigger('acf/update_field_groups');
 
 
 
 
 
 
 
 
1
  (function($){
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
  /*
5
+ * acf.screen
6
  *
7
+ * description
8
+ *
9
+ * @type object
10
+ * @date 3/09/12
11
  */
12
 
13
+ acf.screen = {
14
+ action : 'acf/location/match_field_groups_ajax',
15
+ post_id : 0,
16
+ page_template : 0,
17
+ page_parent : 0,
18
+ page_type : 0,
19
+ post_category : 0,
20
+ post_format : 0,
21
+ taxonomy : 0,
22
+ lang : 0,
23
+ nonce : 0,
24
+ return : 'json'
25
  };
26
 
27
+
28
  /*
29
  * Document Ready
30
  *
31
+ * Updates acf.screen with more data
32
+ *
33
+ * @type function
34
+ * @date 1/03/2011
35
+ *
36
+ * @param N/A
37
+ * @return N/A
38
  */
39
 
40
  $(document).ready(function(){
41
 
42
 
43
  // update post_id
44
+ acf.screen.post_id = acf.o.post_id;
45
+ acf.screen.nonce = acf.o.nonce;
46
 
47
 
48
  // MPML
49
+ if( $('#icl-als-first').length > 0 )
50
  {
51
  var href = $('#icl-als-first').children('a').attr('href'),
52
  regex = new RegExp( "lang=([^&#]*)" ),
53
  results = regex.exec( href );
54
 
55
  // lang
56
+ acf.screen.lang = results[1];
57
 
58
  }
59
 
71
 
72
  $.ajax({
73
  url: ajaxurl,
74
+ data: acf.screen,
75
  type: 'post',
76
  dataType: 'json',
77
  success: function(result){
84
 
85
 
86
  // hide all metaboxes
87
+ $('.acf_postbox').addClass('acf-hidden');
88
+ $('.acf_postbox-toggle').addClass('acf-hidden');
89
+
90
 
91
  // dont bother loading style or html for inputs
92
  if( result.length == 0 )
99
  $.each(result, function(k, v) {
100
 
101
 
102
+ // vars
103
+ var $el = $('#acf_' + v),
104
+ $toggle = $('#adv-settings .acf_postbox-toggle[for="acf_' + v + '-hide"]');
105
+
106
+
107
+ // classes
108
+ $el.removeClass('acf-hidden hide-if-js');
109
+ $toggle.removeClass('acf-hidden');
110
+ $toggle.find('input[type="checkbox"]').attr('checked', 'checked');
111
 
 
 
112
 
113
  // load fields if needed
114
+ $el.find('.acf-replace-with-fields').each(function(){
115
 
116
+ var $replace = $(this);
117
 
118
  $.ajax({
119
+ url : ajaxurl,
120
+ data : {
121
+ action : 'acf/input/render_fields',
122
+ acf_id : v,
123
+ post_id : acf.o.post_id,
124
+ nonce : acf.o.nonce
125
  },
126
+ type : 'post',
127
+ dataType : 'html',
128
+ success : function( html ){
129
 
130
+ $replace.replaceWith( html );
131
 
132
+ $(document).trigger('acf/setup_fields', $el);
133
 
134
  }
135
  });
137
  });
138
  });
139
 
140
+
141
  // load style
142
  $.ajax({
143
+ url : ajaxurl,
144
+ data : {
145
+ action : 'acf/input/get_style',
146
+ acf_id : result[0],
147
+ nonce : acf.o.nonce
148
  },
149
+ type : 'post',
150
+ dataType : 'html',
151
+ success : function( result ){
152
 
153
+ $('#acf_style').html( result );
154
 
155
  }
156
  });
157
 
158
+
159
+
160
  }
161
  });
162
  });
171
 
172
  $('#page_template').live('change', function(){
173
 
174
+ acf.screen.page_template = $(this).val();
175
 
176
  $(document).trigger('acf/update_field_groups');
177
 
186
  // set page_type / page_parent
187
  if( val != "" )
188
  {
189
+ acf.screen.page_type = 'child';
190
+ acf.screen.page_parent = val;
191
  }
192
  else
193
  {
194
+ acf.screen.page_type = 'parent';
195
+ acf.screen.page_parent = 0;
196
  }
197
 
198
 
210
  val = 'standard';
211
  }
212
 
213
+ acf.screen.post_format = val;
214
 
215
  $(document).trigger('acf/update_field_groups');
216
 
230
  });
231
 
232
 
233
+ acf.screen.post_category = values;
234
+ acf.screen.taxonomy = values;
235
 
236
 
237
  $(document).trigger('acf/update_field_groups');
js/input/color-picker.js CHANGED
@@ -1,144 +1,147 @@
1
- /*
2
- * Color Picker
3
- *
4
- * @description:
5
- * @since: 3.5.8
6
- * @created: 17/01/13
7
- */
8
-
9
  (function($){
10
 
11
- _cp = acf.fields.color_picker;
12
-
13
  /*
14
- * acf/setup_fields
 
 
 
 
 
15
  *
16
- * @description:
17
- * @since: 3.5.8
18
- * @created: 17/01/13
19
  */
20
 
21
- $(document).live('acf/setup_fields', function(e, postbox){
22
 
23
- // validate
24
- if( ! $.farbtastic )
25
- {
26
- return;
27
- }
28
 
29
-
30
- $(postbox).find('input.acf_color_picker').each(function(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
- // vars
33
- var input = $(this);
34
-
35
 
36
  // is clone field?
37
- if( acf.helpers.is_clone_field(input) )
38
  {
39
  return;
40
  }
41
 
42
 
43
- if( input.val() )
44
  {
45
- $.farbtastic( input ).setColor( input.val() ).hsl[2] > 0.5 ? color = '#000' : color = '#fff';
46
 
47
- input.css({
48
- backgroundColor : input.val(),
49
  color : color
50
  });
51
  }
52
 
53
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
 
55
- });
56
-
57
 
58
  /*
59
- * Input Focus
 
 
 
 
 
60
  *
61
- * @description:
62
- * @since: 3.5.8
63
- * @created: 17/01/13
64
  */
65
-
66
- $('input.acf_color_picker').live('focus', function(){
67
 
68
- var input = $(this);
69
 
70
- if( ! input.val() )
 
71
  {
72
- input.val( '#FFFFFF' );
73
  }
74
 
75
- $('#acf_color_picker').css({
76
- left: input.offset().left,
77
- top: input.offset().top - $('#acf_color_picker').height(),
78
- display: 'block'
 
79
  });
80
 
81
- _cp.farbtastic.linkTo(this);
82
-
83
  });
84
 
85
 
86
  /*
87
- * Input Blur
88
  *
89
- * @description:
90
- * @since: 3.5.8
91
- * @created: 17/01/13
92
- */
93
-
94
- $('input.acf_color_picker').live('blur', function(){
95
-
96
- var input = $(this);
97
-
98
-
99
- // reset the css
100
- if( ! input.val() )
101
- {
102
- input.css({
103
- backgroundColor : '#fff',
104
- color : '#000'
105
- });
106
-
107
- }
108
-
109
-
110
- $('#acf_color_picker').css({
111
- display: 'none'
112
- });
113
-
114
- });
115
-
116
-
117
- /*
118
- * Document Ready
119
  *
120
- * @description:
121
- * @since: 3.5.8
122
- * @created: 17/01/13
123
  */
124
 
125
- $(document).ready(function(){
126
 
 
127
 
128
- /*
129
- * Color Picker
130
- */
131
-
132
- if( $.farbtastic )
133
- {
134
- if( !_cp.farbtastic )
135
- {
136
- $('body').append('<div id="acf_color_picker" />');
137
-
138
- _cp.farbtastic = $.farbtastic('#acf_color_picker');
139
- }
140
- }
141
 
 
 
142
  });
143
 
144
 
 
 
 
 
 
 
 
 
1
  (function($){
2
 
 
 
3
  /*
4
+ * Color Picker
5
+ *
6
+ * static model and events for this field
7
+ *
8
+ * @type event
9
+ * @date 1/06/13
10
  *
 
 
 
11
  */
12
 
13
+ _cp = acf.fields.color_picker = {
14
 
15
+ $el : null,
16
+ $input : null,
17
+ farbtastic : null,
 
 
18
 
19
+ set : function( o ){
20
+
21
+ // merge in new option
22
+ $.extend( this, o );
23
+
24
+
25
+ // find input
26
+ this.$input = this.$el.find('input[type="text"]');
27
+
28
+
29
+ // return this for chaining
30
+ return this;
31
+
32
+ },
33
+ init : function(){
34
+
35
+ // instantiate farbtastic
36
+ if( ! this.farbtastic )
37
+ {
38
+ $('body').append('<div id="acf-farbtastic" />');
39
+
40
+ this.farbtastic = $.farbtastic('#acf-farbtastic');
41
+ }
42
 
 
 
 
43
 
44
  // is clone field?
45
+ if( acf.helpers.is_clone_field(this.$input) )
46
  {
47
  return;
48
  }
49
 
50
 
51
+ if( this.$input.val() )
52
  {
53
+ $.farbtastic( this.$input ).setColor( this.$input.val() ).hsl[2] > 0.5 ? color = '#000' : color = '#fff';
54
 
55
+ this.$input.css({
56
+ backgroundColor : this.$input.val(),
57
  color : color
58
  });
59
  }
60
 
61
+ },
62
+ focus : function(){
63
+
64
+ if( ! this.$input.val() )
65
+ {
66
+ this.$input.val( '#FFFFFF' );
67
+ }
68
+
69
+ $('#acf-farbtastic').css({
70
+ left : this.$input.offset().left,
71
+ top : this.$input.offset().top - $('#acf-farbtastic').height(),
72
+ display : 'block'
73
+ });
74
+
75
+ this.farbtastic.linkTo( this.$input );
76
+
77
+ },
78
+ blur : function(){
79
+
80
+ // reset the css
81
+ if( ! this.$input.val() )
82
+ {
83
+ this.$input.css({
84
+ backgroundColor : '#fff',
85
+ color : '#000'
86
+ });
87
+
88
+ }
89
+
90
+
91
+ $('#acf-farbtastic').css({
92
+ display: 'none'
93
+ });
94
+
95
+ }
96
 
97
+ };
 
98
 
99
  /*
100
+ * acf/setup_fields
101
+ *
102
+ * run init function on all elements for this field
103
+ *
104
+ * @type event
105
+ * @date 1/06/13
106
  *
 
 
 
107
  */
 
 
108
 
109
+ $(document).live('acf/setup_fields', function(e, postbox){
110
 
111
+ // validate
112
+ if( ! $.farbtastic )
113
  {
114
+ return;
115
  }
116
 
117
+
118
+ $(postbox).find('.acf-color_picker').each(function(){
119
+
120
+ _cp.set({ $el : $(this) }).init();
121
+
122
  });
123
 
 
 
124
  });
125
 
126
 
127
  /*
128
+ * Events
129
  *
130
+ * live events for the color picker field
131
+ *
132
+ * @type event
133
+ * @date 1/06/13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  *
 
 
 
135
  */
136
 
137
+ $('.acf-color_picker input[type="text"]').live('focus', function(){
138
 
139
+ _cp.set({ $el : $(this).parent() }).focus();
140
 
141
+ }).live('blur', function(){
 
 
 
 
 
 
 
 
 
 
 
 
142
 
143
+ _cp.set({ $el : $(this).parent() }).blur();
144
+
145
  });
146
 
147
 
js/input/date-picker.js CHANGED
@@ -1,88 +1,136 @@
1
- /*
2
- * Date Picker
3
- *
4
- * @description:
5
- * @since: 3.5.8
6
- * @created: 17/01/13
7
- */
8
-
9
  (function($){
10
-
11
- var _date_picker = acf.fields.date_picker;
12
-
13
 
14
  /*
15
- * acf/setup_fields
 
 
 
 
 
16
  *
17
- * @description:
18
- * @since: 3.5.8
19
- * @created: 17/01/13
20
  */
21
 
22
- $(document).live('acf/setup_fields', function(e, postbox){
 
 
 
 
 
 
23
 
24
- $(postbox).find('input.acf_datepicker').each(function(){
 
 
 
 
 
 
 
 
25
 
26
- // vars
27
- var input = $(this),
28
- alt_field = input.siblings('.acf-hidden-datepicker'),
29
- save_format = input.attr('data-save_format'),
30
- display_format = input.attr('data-display_format'),
31
- first_day = input.attr('data-first_day');
32
 
 
 
33
 
 
 
 
 
 
 
 
34
  // is clone field?
35
- if( acf.helpers.is_clone_field(alt_field) )
36
  {
37
  return;
38
  }
39
 
40
 
41
  // get and set value from alt field
42
- input.val( alt_field.val() );
43
 
44
 
45
  // create options
46
- var options = $.extend( {}, _date_picker.text, {
47
- dateFormat : save_format,
48
- altField : alt_field,
49
- altFormat : save_format,
50
- changeYear: true,
51
- yearRange: "-100:+100",
52
- changeMonth: true,
53
- showButtonPanel : true,
54
- firstDay: first_day
55
  });
56
 
57
 
58
- // add date picker and refocus
59
- input.addClass('active').datepicker(options);
60
 
61
 
62
  // now change the format back to how it should be.
63
- input.datepicker( "option", "dateFormat", display_format );
64
 
65
 
66
  // wrap the datepicker (only if it hasn't already been wrapped)
67
- if($('body > #ui-datepicker-div').length > 0)
68
  {
69
  $('#ui-datepicker-div').wrap('<div class="ui-acf" />');
70
  }
71
 
 
 
 
72
 
73
- // allow null
74
- input.blur(function(){
75
-
76
- if( !input.val() )
77
- {
78
- alt_field.val('');
79
- }
80
-
81
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
 
83
  });
84
 
85
  });
86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
 
88
  })(jQuery);
 
 
 
 
 
 
 
 
1
  (function($){
 
 
 
2
 
3
  /*
4
+ * Date Picker
5
+ *
6
+ * static model for this field
7
+ *
8
+ * @type event
9
+ * @date 1/06/13
10
  *
 
 
 
11
  */
12
 
13
+ acf.fields.date_picker = {
14
+
15
+ $el : null,
16
+ $input : null,
17
+ $hidden : null,
18
+
19
+ o : {},
20
 
21
+ set : function( o ){
22
+
23
+ // merge in new option
24
+ $.extend( this, o );
25
+
26
+
27
+ // find input
28
+ this.$input = this.$el.find('input[type="text"]');
29
+ this.$hidden = this.$el.find('input[type="hidden"]');
30
 
 
 
 
 
 
 
31
 
32
+ // get options
33
+ this.o = acf.helpers.get_atts( this.$el );
34
 
35
+
36
+ // return this for chaining
37
+ return this;
38
+
39
+ },
40
+ init : function(){
41
+
42
  // is clone field?
43
+ if( acf.helpers.is_clone_field(this.$hidden) )
44
  {
45
  return;
46
  }
47
 
48
 
49
  // get and set value from alt field
50
+ this.$input.val( this.$hidden.val() );
51
 
52
 
53
  // create options
54
+ var options = $.extend( {}, acf.l10n.date_picker, {
55
+ dateFormat : this.o.save_format,
56
+ altField : this.$hidden,
57
+ altFormat : this.o.save_format,
58
+ changeYear : true,
59
+ yearRange : "-100:+100",
60
+ changeMonth : true,
61
+ showButtonPanel : true,
62
+ firstDay : this.o.first_day
63
  });
64
 
65
 
66
+ // add date picker
67
+ this.$input.addClass('active').datepicker( options );
68
 
69
 
70
  // now change the format back to how it should be.
71
+ this.$input.datepicker( "option", "dateFormat", this.o.display_format );
72
 
73
 
74
  // wrap the datepicker (only if it hasn't already been wrapped)
75
+ if( $('body > #ui-datepicker-div').length > 0 )
76
  {
77
  $('#ui-datepicker-div').wrap('<div class="ui-acf" />');
78
  }
79
 
80
+ },
81
+ focus : function(){
82
+
83
 
84
+
85
+ },
86
+ blur : function(){
87
+
88
+ if( !this.$input.val() )
89
+ {
90
+ this.$hidden.val('');
91
+ }
92
+
93
+ }
94
+
95
+ };
96
+
97
+
98
+ /*
99
+ * acf/setup_fields
100
+ *
101
+ * run init function for this field
102
+ *
103
+ * @type event
104
+ * @date 1/06/13
105
+ *
106
+ */
107
+
108
+ $(document).live('acf/setup_fields', function(e, postbox){
109
+
110
+ $(postbox).find('.acf-date_picker').each(function(){
111
+
112
+ acf.fields.date_picker.set({ $el : $(this) }).init();
113
 
114
  });
115
 
116
  });
117
 
118
+
119
+ /*
120
+ * Events
121
+ *
122
+ * live events for this field
123
+ *
124
+ * @type event
125
+ * @date 1/06/13
126
+ *
127
+ */
128
+
129
+ $('.acf-date_picker input[type="text"]').live('blur', function(){
130
+
131
+ acf.fields.date_picker.set({ $el : $(this).parent() }).blur();
132
+
133
+ });
134
+
135
 
136
  })(jQuery);
js/input/file.js CHANGED
@@ -1,249 +1,307 @@
1
- /*
2
- * File
3
- *
4
- * @description:
5
- * @since: 3.5.8
6
- * @created: 17/01/13
7
- */
8
-
9
  (function($){
10
 
11
- var _file = acf.fields.file,
12
- _media = acf.media;
13
-
14
-
15
  /*
16
- * Add
17
  *
18
- * @description:
19
- * @since: 3.5.8
20
- * @created: 17/01/13
21
- */
22
-
23
- _file.add = function( file )
24
- {
25
-
26
- // vars
27
- var div = _media.div;
28
-
29
- // set atts
30
- div.find('.acf-file-value').val( file.id ).trigger('change');
31
- div.find('.acf-file-icon').attr( 'src', file.icon );
32
- div.find('.acf-file-name').text( file.name );
33
-
34
-
35
- // set div class
36
- div.addClass('active');
37
-
38
-
39
- // validation
40
- div.closest('.field').removeClass('error');
41
-
42
- };
43
-
44
-
45
- /*
46
- * Edit
47
  *
48
- * @description:
49
- * @since: 3.5.8
50
- * @created: 17/01/13
51
  */
52
 
53
- _file.edit = function(){
54
-
55
- // vars
56
- var div = _media.div,
57
- id = div.find('.acf-file-value').val();
58
-
59
-
60
- // show edit attachment
61
- tb_show( _file.text.title_edit , acf.admin_url + 'media.php?attachment_id=' + id + '&action=edit&acf_action=edit_attachment&acf_field=file&TB_iframe=1');
62
-
63
- };
64
 
 
 
65
 
66
- /*
67
- * Remove
68
- *
69
- * @description:
70
- * @since: 3.5.8
71
- * @created: 17/01/13
72
- */
73
 
74
- _file.remove = function()
75
- {
76
- // vars
77
- var div = _media.div;
78
 
 
 
79
 
80
- // remove atts
81
- div.find('.acf-file-value').val( '' ).trigger('change');
82
- div.find('.acf-file-icon').attr( 'src', '' );
83
- div.find('.acf-file-name').text( '' );
84
 
85
-
86
- // remove class
87
- div.removeClass('active');
88
-
89
- };
90
-
91
-
92
- /*
93
- * Add Button
94
- *
95
- * @description:
96
- * @since: 3.5.8
97
- * @created: 17/01/13
98
- */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
 
100
- $('.acf-file-uploader .add-file').live('click', function(){
101
-
102
- // vars
103
- var div = _media.div = $(this).closest('.acf-file-uploader'),
104
- multiple = div.closest('.repeater').exists() ? true : false;
105
 
106
 
107
- // show the thickbox
108
- if( _media.type() == 'backbone' )
 
 
 
109
  {
110
- // clear the frame
111
- _media.clear_frame();
112
 
 
 
 
 
 
 
113
 
114
- // Create the media frame. Leave options blank for defaults
115
- _media.frame = wp.media({
116
- title : _file.text.title_add,
117
- multiple : multiple
118
- });
119
 
 
 
120
 
121
- /*
122
- _media.frame.on('all', function( e ){
123
- console.log( e );
124
- });
125
- */
126
 
127
 
128
- // add filter by overriding the option when the title is being created. This is an evet fired before the rendering / creating of the library content so it works but is a bit of a hack. In the future, this should be changed to an init / options event
129
- _media.frame.on('title:create', function(){
130
- var state = _media.frame.state();
131
- state.set('filterable', 'uploaded');
132
- });
133
-
134
 
135
- // When an image is selected, run a callback.
136
- _media.frame.on( 'select', function() {
 
 
 
 
 
137
 
138
- // get selected images
139
- selection = _media.frame.state().get('selection');
 
 
 
 
 
 
 
 
 
 
140
 
141
- if( selection )
142
- {
143
- var i = 0;
 
 
 
144
 
145
- selection.each(function(attachment){
146
-
147
- // counter
148
- i++;
149
-
150
-
151
- // select / add another file field?
152
- if( i > 1 )
153
- {
154
- var tr = _media.div.closest('tr'),
155
- repeater = tr.closest('.repeater');
156
 
 
157
 
158
- if( tr.next('.row').exists() )
159
- {
160
- _media.div = tr.next('.row').find('.acf-file-uploader');
161
- }
162
- else
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
  {
164
- // add row
165
- repeater.find('.add-row-end').trigger('click');
166
-
167
- // set acf_div to new row file
168
- _media.div = repeater.find('> table > tbody > tr.row:last .acf-file-uploader');
 
 
 
 
 
 
 
 
 
 
 
169
  }
170
- }
171
-
172
-
173
- // vars
174
- var file = {
175
- id : attachment.id,
176
- name : attachment.attributes.filename,
177
- icon : attachment.attributes.icon
178
- };
179
-
180
-
181
- // add file to field
182
- _file.add( file );
183
-
184
-
185
- });
186
- // selection.each(function(attachment){
187
- }
188
- // if( selection )
189
- });
190
- // _media.frame.on( 'select', function() {
191
-
 
 
 
 
 
 
192
 
193
- // Finally, open the modal
194
- _media.frame.open();
195
-
196
- var state = _media.frame.state();
 
197
 
 
198
  }
199
- else
200
- {
201
- tb_show( _file.text.title_add , acf.admin_url + 'media-upload.php?post_id=' + acf.post_id + '&post_ID=' + acf.post_id + '&type=file&acf_type=file&TB_iframe=1');
202
- }
203
-
204
- return false;
205
-
206
- });
207
 
 
 
208
 
209
  /*
210
- * Edit Button
211
  *
212
- * @description:
213
- * @since: 3.5.8
214
- * @created: 17/01/13
215
- */
 
 
216
 
217
- $('.acf-file-uploader .edit-file').live('click', function(){
218
-
219
- // vars
220
- _media.div = $(this).closest('.acf-file-uploader');
221
 
222
- _file.edit();
223
 
224
- return false;
 
 
225
 
 
 
226
  });
227
 
 
 
228
 
229
  /*
230
- * Remove Button
 
 
 
 
 
231
  *
232
- * @description:
233
- * @since: 3.5.8
234
- * @created: 17/01/13
235
  */
236
 
237
- $('.acf-file-uploader .remove-file').live('click', function(){
 
238
 
239
- // vars
240
- _media.div = $(this).closest('.acf-file-uploader');
241
-
242
- _file.remove();
243
 
244
  return false;
245
 
246
  });
 
 
247
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248
 
249
  })(jQuery);
 
 
 
 
 
 
 
 
1
  (function($){
2
 
 
 
 
 
3
  /*
4
+ * File
5
  *
6
+ * static model for this field
7
+ *
8
+ * @type event
9
+ * @date 1/06/13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  *
 
 
 
11
  */
12
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
+ // reference
15
+ var _media = acf.media;
16
 
 
 
 
 
 
 
 
17
 
18
+ acf.fields.file = {
 
 
 
19
 
20
+ $el : null,
21
+ $input : null,
22
 
23
+ o : {},
 
 
 
24
 
25
+ set : function( o ){
26
+
27
+ // merge in new option
28
+ $.extend( this, o );
29
+
30
+
31
+ // find input
32
+ this.$input = this.$el.find('input[type="hidden"]');
33
+
34
+
35
+ // get options
36
+ this.o = acf.helpers.get_atts( this.$el );
37
+
38
+
39
+ // multiple?
40
+ this.o.multiple = this.$el.closest('.repeater').exists() ? true : false;
41
+
42
+
43
+ // wp library query
44
+ this.o.query = {};
45
+
46
+
47
+ // library
48
+ if( this.o.library == 'uploadedTo' )
49
+ {
50
+ this.o.query.uploadedTo = acf.o.post_id;
51
+ }
52
+
53
+
54
+ // return this for chaining
55
+ return this;
56
+
57
+ },
58
+ init : function(){
59
+
60
+ // is clone field?
61
+ if( acf.helpers.is_clone_field(this.$input) )
62
+ {
63
+ return;
64
+ }
65
+
66
+ },
67
+ add : function( file ){
68
+
69
+ // this function must reference a global div variable due to the pre WP 3.5 uploader
70
+ // vars
71
+ var div = _media.div;
72
+
73
+
74
+ // set atts
75
+ div.find('.acf-file-icon').attr( 'src', file.icon );
76
+ div.find('.acf-file-title').text( file.title );
77
+ div.find('.acf-file-name').text( file.name ).attr( 'href', file.url );
78
+ div.find('.acf-file-size').text( file.size );
79
+ div.find('.acf-file-value').val( file.id ).trigger('change');
80
+
81
+
82
+ // set div class
83
+ div.addClass('active');
84
+
85
+
86
+ // validation
87
+ div.closest('.field').removeClass('error');
88
 
89
+ },
90
+ edit : function(){
91
+
92
+ // set global var
93
+ _media.div = this.$el;
94
 
95
 
96
+ // show tb - to be removed in 4.2.0
97
+ tb_show( acf.l10n.file.edit, acf.o.admin_url + 'media.php?attachment_id=' + this.$input.val() + '&action=edit&acf_action=edit_attachment&acf_field=file&TB_iframe=1');
98
+
99
+ },
100
+ remove : function()
101
  {
 
 
102
 
103
+ // set atts
104
+ this.$el.find('.acf-file-icon').attr( 'src', '' );
105
+ this.$el.find('.acf-file-title').text( '' );
106
+ this.$el.find('.acf-file-name').text( '' ).attr( 'href', '' );
107
+ this.$el.find('.acf-file-size').text( '' );
108
+ this.$el.find('.acf-file-value').val( '' ).trigger('change');
109
 
 
 
 
 
 
110
 
111
+ // remove class
112
+ this.$el.removeClass('active');
113
 
114
+ },
115
+ popup : function()
116
+ {
117
+ // reference
118
+ var t = this;
119
 
120
 
121
+ // set global var
122
+ _media.div = this.$el;
 
 
 
 
123
 
124
+
125
+ // show the uploader
126
+ if( _media.type() == 'backbone' )
127
+ {
128
+ // clear the frame
129
+ _media.clear_frame();
130
+
131
 
132
+ // Create the media frame
133
+ _media.frame = wp.media({
134
+ states : [
135
+ new wp.media.controller.Library({
136
+ library : wp.media.query( t.o.query ),
137
+ multiple : t.o.multiple,
138
+ title : acf.l10n.file.select,
139
+ priority : 20,
140
+ filterable : 'all'
141
+ })
142
+ ]
143
+ });
144
 
145
+
146
+ // customize model / view
147
+ acf.media.frame.on('open', function(){
148
+
149
+ var content = acf.media.frame.content.get(),
150
+ filters = content.toolbar._views.filters;
151
 
152
+
153
+ // no need for 'uploaded' filter
154
+ if( t.o.library == 'uploadedTo' )
155
+ {
156
+ filters.$el.find('option[value="uploaded"]').remove();
157
+ filters.$el.after('<span>' + acf.l10n.file.uploadedTo + '</span>')
158
+
159
+ $.each( filters.filters, function( k, v ){
 
 
 
160
 
161
+ v.props.uploadedTo = acf.o.post_id;
162
 
163
+ });
164
+ }
165
+
166
+ });
167
+
168
+
169
+ // When an image is selected, run a callback.
170
+ acf.media.frame.on( 'select', function() {
171
+
172
+ // get selected images
173
+ selection = _media.frame.state().get('selection');
174
+
175
+ if( selection )
176
+ {
177
+ var i = 0;
178
+
179
+ selection.each(function(attachment){
180
+
181
+ // counter
182
+ i++;
183
+
184
+
185
+ // select / add another file field?
186
+ if( i > 1 )
187
  {
188
+ var tr = _media.div.closest('tr'),
189
+ repeater = tr.closest('.repeater');
190
+
191
+
192
+ if( tr.next('.row').exists() )
193
+ {
194
+ _media.div = tr.next('.row').find('.acf-file-uploader');
195
+ }
196
+ else
197
+ {
198
+ // add row
199
+ repeater.find('.add-row-end').trigger('click');
200
+
201
+ // set acf_div to new row file
202
+ _media.div = repeater.find('> table > tbody > tr.row:last .acf-file-uploader');
203
+ }
204
  }
205
+
206
+
207
+ // vars
208
+ var file = {
209
+ id : attachment.id,
210
+ title : attachment.attributes.title,
211
+ name : attachment.attributes.filename,
212
+ url : attachment.attributes.url,
213
+ icon : attachment.attributes.icon,
214
+ size : attachment.attributes.filesize
215
+ };
216
+
217
+
218
+ // add file to field
219
+ acf.fields.file.add( file );
220
+
221
+
222
+ });
223
+ // selection.each(function(attachment){
224
+ }
225
+ // if( selection )
226
+
227
+ });
228
+ // acf.media.frame.on( 'select', function() {
229
+
230
+
231
+ // Finally, open the modal
232
+ acf.media.frame.open();
233
 
234
+ }
235
+ else
236
+ {
237
+ tb_show( acf.l10n.file.select , acf.admin_url + 'media-upload.php?post_id=' + acf.o.post_id + '&post_ID=' + acf.post_id + '&type=file&acf_type=file&TB_iframe=1');
238
+ }
239
 
240
+ return false;
241
  }
 
 
 
 
 
 
 
 
242
 
243
+ };
244
+
245
 
246
  /*
247
+ * acf/setup_fields
248
  *
249
+ * run init function for this field
250
+ *
251
+ * @type event
252
+ * @date 1/06/13
253
+ *
254
+ * @note Currenlty no need for init
255
 
 
 
 
 
256
 
257
+ $(document).live('acf/setup_fields', function(e, postbox){
258
 
259
+ $(postbox).find('.acf-file-uploader').each(function(){
260
+
261
+ acf.fields.file.set({ $el : $(this) }).init();
262
 
263
+ });
264
+
265
  });
266
 
267
+ */
268
+
269
 
270
  /*
271
+ * Events
272
+ *
273
+ * live events for this field
274
+ *
275
+ * @type event
276
+ * @date 1/06/13
277
  *
 
 
 
278
  */
279
 
280
+
281
+ $('.acf-file-uploader .acf-button-edit').live('click', function(){
282
 
283
+ acf.fields.file.set({ $el : $(this).closest('.acf-file-uploader') }).edit();
 
 
 
284
 
285
  return false;
286
 
287
  });
288
+
289
+ $('.acf-file-uploader .acf-button-delete').live('click', function(){
290
 
291
+ acf.fields.file.set({ $el : $(this).closest('.acf-file-uploader') }).remove();
292
+
293
+ return false;
294
+
295
+ });
296
+
297
+
298
+ $('.acf-file-uploader .add-file').live('click', function(){
299
+
300
+ acf.fields.file.set({ $el : $(this).closest('.acf-file-uploader') }).popup();
301
+
302
+ return false;
303
+
304
+ });
305
+
306
 
307
  })(jQuery);
js/input/image.js CHANGED
@@ -1,247 +1,349 @@
1
- /*
2
- * Image
3
- *
4
- * @description:
5
- * @since: 3.5.8
6
- * @created: 17/01/13
7
- */
8
-
9
  (function($){
10
 
11
- var _image = acf.fields.image,
12
- _media = acf.media;
13
-
14
-
15
  /*
16
- * Add
17
  *
18
- * @description:
19
- * @since: 3.5.8
20
- * @created: 17/01/13
21
- */
22
-
23
- _image.add = function( image )
24
- {
25
- // vars
26
- var div = _media.div;
27
-
28
- // set atts
29
- div.find('.acf-image-value').val( image.id ).trigger('change');
30
- div.find('img').attr( 'src', image.src );
31
-
32
-
33
- // set div class
34
- div.addClass('active');
35
-
36
-
37
- // validation
38
- div.closest('.field').removeClass('error');
39
-
40
- };
41
-
42
-
43
- /*
44
- * Edit
45
  *
46
- * @description:
47
- * @since: 3.5.8
48
- * @created: 17/01/13
49
  */
50
 
51
- _image.edit = function(){
52
-
53
- // vars
54
- var div = _media.div,
55
- id = div.find('.acf-image-value').val();
56
-
57
-
58
- // show edit attachment
59
- tb_show( _image.text.title_edit , acf.admin_url + 'media.php?attachment_id=' + id + '&action=edit&acf_action=edit_attachment&acf_field=image&TB_iframe=1');
60
-
61
- };
62
 
 
 
63
 
64
- /*
65
- * Remove
66
- *
67
- * @description:
68
- * @since: 3.5.8
69
- * @created: 17/01/13
70
- */
71
 
72
- _image.remove = function()
73
- {
74
- // vars
75
- var div = _media.div;
76
-
77
-
78
- // remove atts
79
- div.find('.acf-image-value').val('').trigger('change');
80
- div.find('img').attr('src', '');
81
 
 
 
82
 
83
- // remove class
84
- div.removeClass('active');
85
 
86
- };
87
-
88
-
89
- /*
90
- * Add Button
91
- *
92
- * @description:
93
- * @since: 3.5.8
94
- * @created: 17/01/13
95
- */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
 
97
- $('.acf-image-uploader .add-image').live('click', function(){
98
-
99
- // vars
100
- var div = _media.div = $(this).closest('.acf-image-uploader'),
101
- preview_size = div.attr('data-preview_size'),
102
- multiple = div.closest('.repeater').exists() ? true : false;
103
 
104
 
105
- // show the thickbox
106
- if( _media.type() == 'backbone' )
 
 
 
107
  {
108
- // clear the frame
109
- _media.clear_frame();
110
-
111
-
112
- // Create the media frame. Leave options blank for defaults
113
- _media.frame = wp.media({
114
- title : _image.text.title_add,
115
- multiple : multiple,
116
- library : {
117
- type : 'image'
118
- }
119
- });
120
-
121
 
122
- // add filter by overriding the option when the title is being created. This is an evet fired before the rendering / creating of the library content so it works but is a bit of a hack. In the future, this should be changed to an init / options event
123
- _media.frame.on('title:create', function(){
124
- var state = _media.frame.state();
125
- state.set('filterable', 'uploaded');
126
- });
127
 
 
 
 
 
 
 
 
 
128
 
129
- // When an image is selected, run a callback.
130
- _media.frame.on( 'select', function() {
 
 
 
 
 
 
 
 
131
 
132
- // get selected images
133
- selection = _media.frame.state().get('selection');
134
 
135
- if( selection )
136
- {
137
- var i = 0;
138
-
139
- selection.each(function(attachment){
140
-
141
- // counter
142
- i++;
143
-
144
-
145
- // select / add another file field?
146
- if( i > 1 )
147
- {
148
- var tr = _media.div.closest('tr'),
149
- repeater = tr.closest('.repeater');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
 
 
151
 
152
- if( tr.next('.row').exists() )
153
- {
154
- _media.div = tr.next('.row').find('.acf-image-uploader');
155
- }
156
- else
157
- {
158
- // add row
159
- repeater.find('.add-row-end').trigger('click');
160
-
161
- // set acf_div to new row file
162
- _media.div = repeater.find('> table > tbody > tr.row:last .acf-image-uploader');
163
- }
 
 
 
164
  }
165
 
 
 
 
 
166
 
167
- // vars
168
- var image = {
169
- id : attachment.id,
170
- src : attachment.attributes.url
171
- };
172
-
 
173
 
174
- // is preview size available?
175
- if( attachment.attributes.sizes && attachment.attributes.sizes[ preview_size ] )
176
- {
177
- image.src = attachment.attributes.sizes[ preview_size ].url;
178
- }
179
-
180
-
181
- // add image to field
182
- _image.add( image );
183
-
184
-
185
- });
186
- // selection.each(function(attachment){
187
- }
188
- // if( selection )
189
- });
190
- // _media.frame.on( 'select', function() {
191
-
192
 
193
- // Finally, open the modal
194
- _media.frame.open();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
195
 
196
- }
197
- else
198
- {
199
- tb_show( _image.text.title_add , acf.admin_url + 'media-upload.php?post_id=' + acf.post_id + '&post_ID=' + acf.post_id + '&type=image&acf_type=image&acf_preview_size=' + preview_size + 'TB_iframe=1');
 
 
 
 
 
 
 
 
 
200
  }
201
 
 
202
 
203
- return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
  });
205
 
 
 
206
 
207
  /*
208
- * Edit Button
 
 
 
 
 
209
  *
210
- * @description:
211
- * @since: 3.5.8
212
- * @created: 17/01/13
213
  */
214
 
 
215
  $('.acf-image-uploader .acf-button-edit').live('click', function(){
216
 
217
- // vars
218
- _media.div = $(this).closest('.acf-image-uploader');
219
-
220
- _image.edit();
221
 
222
  return false;
223
 
224
  });
225
 
226
-
227
- /*
228
- * Remove Button
229
- *
230
- * @description:
231
- * @since: 3.5.8
232
- * @created: 17/01/13
233
- */
234
-
235
  $('.acf-image-uploader .acf-button-delete').live('click', function(){
236
 
237
- // vars
238
- _media.div = $(this).closest('.acf-image-uploader');
239
-
240
- _image.remove();
241
 
242
  return false;
243
 
244
  });
245
 
 
 
 
 
 
 
 
 
 
246
 
247
  })(jQuery);
 
 
 
 
 
 
 
 
1
  (function($){
2
 
 
 
 
 
3
  /*
4
+ * Image
5
  *
6
+ * static model for this field
7
+ *
8
+ * @type event
9
+ * @date 1/06/13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  *
 
 
 
11
  */
12
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
+ // reference
15
+ var _media = acf.media;
16
 
 
 
 
 
 
 
 
17
 
18
+ acf.fields.image = {
 
 
 
 
 
 
 
 
19
 
20
+ $el : null,
21
+ $input : null,
22
 
23
+ o : {},
 
24
 
25
+ set : function( o ){
26
+
27
+ // merge in new option
28
+ $.extend( this, o );
29
+
30
+
31
+ // find input
32
+ this.$input = this.$el.find('input[type="hidden"]');
33
+
34
+
35
+ // get options
36
+ this.o = acf.helpers.get_atts( this.$el );
37
+
38
+
39
+ // multiple?
40
+ this.o.multiple = this.$el.closest('.repeater').exists() ? true : false;
41
+
42
+
43
+ // wp library query
44
+ this.o.query = {
45
+ type : 'image'
46
+ };
47
+
48
+
49
+ // library
50
+ if( this.o.library == 'uploadedTo' )
51
+ {
52
+ this.o.query.uploadedTo = acf.o.post_id;
53
+ }
54
+
55
+
56
+ // return this for chaining
57
+ return this;
58
+
59
+ },
60
+ init : function(){
61
+
62
+ // is clone field?
63
+ if( acf.helpers.is_clone_field(this.$input) )
64
+ {
65
+ return;
66
+ }
67
+
68
+ },
69
+ add : function( image ){
70
+
71
+ // this function must reference a global div variable due to the pre WP 3.5 uploader
72
+ // vars
73
+ var div = _media.div;
74
+
75
+
76
+ // set atts
77
+ div.find('.acf-image-image').attr( 'src', image.url );
78
+ div.find('.acf-image-value').val( image.id ).trigger('change');
79
+
80
+
81
+ // set div class
82
+ div.addClass('active');
83
+
84
+
85
+ // validation
86
+ div.closest('.field').removeClass('error');
87
 
88
+ },
89
+ edit : function(){
90
+
91
+ // set global var
92
+ _media.div = this.$el;
 
93
 
94
 
95
+ // show tb - to be removed in 4.2.0
96
+ tb_show( acf.l10n.image.edit, acf.o.admin_url + 'media.php?attachment_id=' + this.$input.val() + '&action=edit&acf_action=edit_attachment&acf_field=image&TB_iframe=1');
97
+
98
+ },
99
+ remove : function()
100
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
101
 
102
+ // set atts
103
+ this.$el.find('.acf-image-image').attr( 'src', '' );
104
+ this.$el.find('.acf-image-value').val( '' ).trigger('change');
105
+
 
106
 
107
+ // remove class
108
+ this.$el.removeClass('active');
109
+
110
+ },
111
+ popup : function()
112
+ {
113
+ // reference
114
+ var t = this;
115
 
116
+
117
+ // set global var
118
+ _media.div = this.$el;
119
+
120
+
121
+ // show the uploader
122
+ if( _media.type() == 'backbone' )
123
+ {
124
+ // clear the frame
125
+ _media.clear_frame();
126
 
 
 
127
 
128
+ // Create the media frame
129
+ _media.frame = wp.media({
130
+ states : [
131
+ new wp.media.controller.Library({
132
+ library : wp.media.query( t.o.query ),
133
+ multiple : t.o.multiple,
134
+ title : acf.l10n.image.select,
135
+ priority : 20,
136
+ filterable : 'all'
137
+ })
138
+ ]
139
+ });
140
+
141
+ /*
142
+ acf.media.frame.on('all', function(e){
143
+
144
+ console.log( e );
145
+
146
+ });
147
+ */
148
+
149
+ // customize model / view
150
+ acf.media.frame.on('open', function(){
151
+
152
+ var content = acf.media.frame.content.get(),
153
+ filters = content.toolbar._views.filters;
154
+
155
+
156
+ // filter only images
157
+ $.each( filters.filters, function( k, v ){
158
+
159
+ v.props.type = 'image';
160
+
161
+ });
162
+
163
+
164
+ // no need for 'uploaded' filter
165
+ if( t.o.library == 'uploadedTo' )
166
+ {
167
+ filters.$el.find('option[value="uploaded"]').remove();
168
+ filters.$el.after('<span>' + acf.l10n.image.uploadedTo + '</span>')
169
+
170
+ $.each( filters.filters, function( k, v ){
171
 
172
+ v.props.uploadedTo = acf.o.post_id;
173
 
174
+ });
175
+ }
176
+
177
+
178
+ // remove non image options from filter list
179
+ filters.$el.find('option').each(function(){
180
+
181
+ // vars
182
+ var v = $(this).attr('value');
183
+
184
+
185
+ // don't remove the 'uploadedTo' if the library option is 'all'
186
+ if( v == 'uploaded' && t.o.library == 'all' )
187
+ {
188
+ return;
189
  }
190
 
191
+ if( v.indexOf('image') === -1 )
192
+ {
193
+ $(this).remove();
194
+ }
195
 
196
+ });
197
+
198
+
199
+ // set default filter
200
+ filters.$el.val('image').trigger('change');
201
+
202
+ });
203
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
 
205
+ // When an image is selected, run a callback.
206
+ acf.media.frame.on( 'select', function() {
207
+
208
+ // get selected images
209
+ selection = _media.frame.state().get('selection');
210
+
211
+ if( selection )
212
+ {
213
+ var i = 0;
214
+
215
+ selection.each(function(attachment){
216
+
217
+ // counter
218
+ i++;
219
+
220
+
221
+ // select / add another image field?
222
+ if( i > 1 )
223
+ {
224
+ var tr = _media.div.closest('tr'),
225
+ repeater = tr.closest('.repeater');
226
+
227
+
228
+ if( tr.next('.row').exists() )
229
+ {
230
+ _media.div = tr.next('.row').find('.acf-image-uploader');
231
+ }
232
+ else
233
+ {
234
+ // add row
235
+ repeater.find('.add-row-end').trigger('click');
236
+
237
+ // set acf_div to new row image
238
+ _media.div = repeater.find('> table > tbody > tr.row:last .acf-image-uploader');
239
+ }
240
+ }
241
+
242
+
243
+ // vars
244
+ var image = {
245
+ id : attachment.id,
246
+ url : attachment.attributes.url
247
+ };
248
+
249
+ // is preview size available?
250
+ if( attachment.attributes.sizes && attachment.attributes.sizes[ t.o.preview_size ] )
251
+ {
252
+ image.url = attachment.attributes.sizes[ t.o.preview_size ].url;
253
+ }
254
+
255
+ // add image to field
256
+ acf.fields.image.add( image );
257
+
258
+
259
+ });
260
+ // selection.each(function(attachment){
261
+ }
262
+ // if( selection )
263
+
264
+ });
265
+ // acf.media.frame.on( 'select', function() {
266
+
267
+
268
+ // Finally, open the modal
269
+ acf.media.frame.open();
270
 
271
+ }
272
+ else
273
+ {
274
+ tb_show( acf.l10n.image.select , acf.admin_url + 'media-upload.php?post_id=' + acf.o.post_id + '&post_ID=' + acf.o.post_id + '&type=image&acf_type=image&acf_preview_size=' + t.o.preview_size + '&TB_iframe=1');
275
+ }
276
+
277
+ return false;
278
+ },
279
+
280
+ // temporary gallery fix
281
+ text : {
282
+ title_add : "Select Image",
283
+ title_edit : "Edit Image"
284
  }
285
 
286
+ };
287
 
288
+
289
+ /*
290
+ * acf/setup_fields
291
+ *
292
+ * run init function for this field
293
+ *
294
+ * @type event
295
+ * @date 1/06/13
296
+ *
297
+ * @note Currenlty no need for init
298
+
299
+ $(document).live('acf/setup_fields', function(e, postbox){
300
+
301
+ $(postbox).find('.acf-image-uploader').each(function(){
302
+
303
+ acf.fields.image.set({ $el : $(this) }).init();
304
+
305
+ });
306
+
307
  });
308
 
309
+ */
310
+
311
 
312
  /*
313
+ * Events
314
+ *
315
+ * live events for this field
316
+ *
317
+ * @type event
318
+ * @date 1/06/13
319
  *
 
 
 
320
  */
321
 
322
+
323
  $('.acf-image-uploader .acf-button-edit').live('click', function(){
324
 
325
+ acf.fields.image.set({ $el : $(this).closest('.acf-image-uploader') }).edit();
 
 
 
326
 
327
  return false;
328
 
329
  });
330
 
 
 
 
 
 
 
 
 
 
331
  $('.acf-image-uploader .acf-button-delete').live('click', function(){
332
 
333
+ acf.fields.image.set({ $el : $(this).closest('.acf-image-uploader') }).remove();
 
 
 
334
 
335
  return false;
336
 
337
  });
338
 
339
+
340
+ $('.acf-image-uploader .add-image').live('click', function(){
341
+
342
+ acf.fields.image.set({ $el : $(this).closest('.acf-image-uploader') }).popup();
343
+
344
+ return false;
345
+
346
+ });
347
+
348
 
349
  })(jQuery);
js/input/validation.js CHANGED
@@ -41,7 +41,7 @@
41
 
42
 
43
  // text / textarea
44
- if( div.find('input[type="text"], input[type="number"], input[type="hidden"], textarea').val() == "" )
45
  {
46
  div.data('validation', false);
47
  }
@@ -75,13 +75,30 @@
75
  }
76
 
77
 
78
- // checkbox
79
- if( div.find('input[type="checkbox"]:checked').exists() )
80
  {
81
- div.data('validation', true);
 
 
 
 
 
82
  }
83
 
84
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  // relationship
86
  if( div.find('.acf_relationship').exists() )
87
  {
41
 
42
 
43
  // text / textarea
44
+ if( div.find('input[type="text"], input[type="email"], input[type="number"], input[type="hidden"], textarea').val() == "" )
45
  {
46
  div.data('validation', false);
47
  }
75
  }
76
 
77
 
78
+ // radio
79
+ if( div.find('input[type="radio"]').exists() )
80
  {
81
+ div.data('validation', false);
82
+
83
+ if( div.find('input[type="radio"]:checked').exists() )
84
+ {
85
+ div.data('validation', true);
86
+ }
87
  }
88
 
89
 
90
+ // checkbox
91
+ if( div.find('input[type="checkbox"]').exists() )
92
+ {
93
+ div.data('validation', false);
94
+
95
+ if( div.find('input[type="checkbox"]:checked').exists() )
96
+ {
97
+ div.data('validation', true);
98
+ }
99
+ }
100
+
101
+
102
  // relationship
103
  if( div.find('.acf_relationship').exists() )
104
  {
readme.txt CHANGED
@@ -101,6 +101,25 @@ http://support.advancedcustomfields.com/
101
 
102
  == Changelog ==
103
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  = 4.1.4 =
105
  * [Fixed] Page Link: Fixed errors produced by recent changes to post object field - http://support.advancedcustomfields.com/discussion/6044/page-links-hierarchy-broken-and-does-not-order-correctly
106
 
101
 
102
  == Changelog ==
103
 
104
+ = 4.1.5.1 =
105
+ * Image field: Fixed JS error causing uploader to not work correctly
106
+ * File field: Fixed JS error causing uploader to not work correctly
107
+ * Gallery field: Fixed JS error causing uploader to not work correctly
108
+ * General: Fixed JS error causing field groups to not appear when dynamically loaded
109
+
110
+ = 4.1.5 =
111
+ * WYSIWYG Field: Fixed WYSIWYG the_content / shortcode issues - http://support.advancedcustomfields.com/discussion/5939/inconsistencies-between-standard-wysiwyg-and-acf-wysiwyg
112
+ * Image field: Added option for library restriction - http://support.advancedcustomfields.com/discussion/6102/making-uploaded-to-this-post-default-state-for-image-upload
113
+ * File field: Added option for library restriction
114
+ * File field: Field UI refresh
115
+ * Checkbox field: Added horizontal option - http://support.advancedcustomfields.com/discussion/5925/horizontal-select-boxes
116
+ * Image field: fixed UI bug when image is deleted in file system - http://support.advancedcustomfields.com/discussion/5988/provide-a-fallback-if-
117
+ * Validation: Added support for email field - http://support.advancedcustomfields.com/discussion/6125/email-field-required-validation-on-submit
118
+ * Validation: Added support for taxonomy field - http://support.advancedcustomfields.com/discussion/6169/validation-of-taxonomy-field
119
+ * Language: Added Chinese Translation - https://github.com/elliotcondon/acf/pull/63
120
+ * General: Added changelog message to update plugin screen
121
+ * General: Lots of minor improvements
122
+
123
  = 4.1.4 =
124
  * [Fixed] Page Link: Fixed errors produced by recent changes to post object field - http://support.advancedcustomfields.com/discussion/6044/page-links-hierarchy-broken-and-does-not-order-correctly
125