Advanced Custom Fields - Version 3.1.4

Version Description

  • New Feature: Front end form (Please read documentation on website for usage)
  • Performance: compiled all field script / style into 1 .js file
  • Bug Fix: Editor now remembers mode (Visual / HTML) without causing errors when loading in HTML mode
  • Improvement: Added draft / private labels to post objects in relationship, post object and page link fields
Download this release

Release Info

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

Code changes from version 3.1.3 to 3.1.4

acf.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Advanced Custom Fields
4
  Plugin URI: http://www.advancedcustomfields.com/
5
  Description: Fully customise WordPress edit screens with powerful fields. Boasting a professional interface and a powerfull API, it’s a must have for any web developer working with WordPress.Field types include: Wysiwyg, text, textarea, image, file, select, checkbox, page link, post object, date picker, color picker and more!
6
- Version: 3.1.3
7
  Author: Elliot Condon
8
  Author URI: http://www.elliotcondon.com/
9
  License: GPL
@@ -45,7 +45,7 @@ class Acf
45
  $this->dir = plugins_url('',__FILE__);
46
  $this->siteurl = get_bloginfo('url');
47
  $this->wpadminurl = admin_url();
48
- $this->version = '3.1.3';
49
  $this->upgrade_version = '3.0.0'; // this is the latest version which requires an upgrade
50
 
51
 
@@ -387,12 +387,24 @@ class Acf
387
  $this->fields[$field->name]->admin_head();
388
  }
389
 
390
- // add css + javascript
391
  echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/global.css" />';
392
  echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/input.css" />';
393
- echo '<script type="text/javascript" src="'.$this->dir.'/js/input.js" ></script>';
394
  echo '<style type="text/css">.acf_postbox, .postbox[id*="acf_"] { display: none; }</style>';
395
- echo '<script type="text/javascript">acf.validation_message = "' . __("Validation Failed. One or more fields below are required.",'acf') . '";</script>';
 
 
 
 
 
 
 
 
 
 
 
 
 
396
 
397
  // get acf's
398
  $acfs = $this->get_field_groups();
@@ -410,7 +422,7 @@ class Acf
410
  array($this, 'meta_box_input'),
411
  $post_type,
412
  $acf['options']['position'],
413
- 'default',
414
  array( 'fields' => $acf['fields'], 'options' => $acf['options'], 'show' => $show )
415
  );
416
  }
@@ -499,49 +511,7 @@ class Acf
499
  {
500
  include('core/admin/page_acf.php');
501
  }
502
-
503
- // input meta boxes
504
- if(in_array($GLOBALS['pagenow'], array('post.php', 'post-new.php')) && $GLOBALS['post_type'] != 'acf')
505
- {
506
- //wp_preload_dialogs( array( 'plugins' => 'safari,inlinepopups,spellchecker,paste,wordpress,media,fullscreen,wpeditimage,wpgallery,tabfocus' ) );
507
- ?>
508
- <script type="text/javascript">
509
- (function($){
510
-
511
- // add classes
512
- $('#poststuff .postbox[id*="acf_"]').addClass('acf_postbox');
513
- $('#adv-settings label[for*="acf_"]').addClass('acf_hide_label');
514
-
515
- // hide acf stuff
516
- $('#poststuff .acf_postbox').hide();
517
- $('#adv-settings .acf_hide_label').hide();
518
-
519
- // loop through acf metaboxes
520
- $('#poststuff .postbox.acf_postbox').each(function(){
521
-
522
- // vars
523
- var options = $(this).find('.inside > .options');
524
- var show = options.attr('data-show');
525
- var layout = options.attr('data-layout');
526
- var id = $(this).attr('id').replace('acf_', '');
527
-
528
- // layout
529
- $(this).addClass('acf_postbox').addClass(layout);
530
-
531
- // show / hide
532
- if(show == 'true')
533
- {
534
- $(this).show();
535
- $('#adv-settings .acf_hide_label[for="acf_' + id + '-hide"]').show();
536
- }
537
-
538
- });
539
 
540
- })(jQuery);
541
- </script>
542
- <?php
543
- }
544
-
545
  }
546
 
547
 
@@ -1489,6 +1459,11 @@ class Acf
1489
  // Options Page
1490
  case "options_page":
1491
 
 
 
 
 
 
1492
  if($rule['operator'] == "==")
1493
  {
1494
  if(get_admin_page_title() == $rule['value'])
3
  Plugin Name: Advanced Custom Fields
4
  Plugin URI: http://www.advancedcustomfields.com/
5
  Description: Fully customise WordPress edit screens with powerful fields. Boasting a professional interface and a powerfull API, it’s a must have for any web developer working with WordPress.Field types include: Wysiwyg, text, textarea, image, file, select, checkbox, page link, post object, date picker, color picker and more!
6
+ Version: 3.1.4
7
  Author: Elliot Condon
8
  Author URI: http://www.elliotcondon.com/
9
  License: GPL
45
  $this->dir = plugins_url('',__FILE__);
46
  $this->siteurl = get_bloginfo('url');
47
  $this->wpadminurl = admin_url();
48
+ $this->version = '3.1.4';
49
  $this->upgrade_version = '3.0.0'; // this is the latest version which requires an upgrade
50
 
51
 
387
  $this->fields[$field->name]->admin_head();
388
  }
389
 
390
+ // Style
391
  echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/global.css" />';
392
  echo '<link rel="stylesheet" type="text/css" href="'.$this->dir.'/css/input.css" />';
 
393
  echo '<style type="text/css">.acf_postbox, .postbox[id*="acf_"] { display: none; }</style>';
394
+
395
+ // find user editor setting
396
+ $user = wp_get_current_user();
397
+ $editor_mode = get_user_setting('editor', 'tinymce');
398
+
399
+ // Javascript
400
+ echo '<script type="text/javascript" src="'.$this->dir.'/js/input-actions.js" ></script>';
401
+ echo '<script type="text/javascript" src="'.$this->dir.'/js/input-ajax.js" ></script>';
402
+ echo '<script type="text/javascript">
403
+ acf.validation_message = "' . __("Validation Failed. One or more fields below are required.",'acf') . '";
404
+ acf.post_id = ' . $post->ID . ';
405
+ acf.editor_mode = "' . $editor_mode . '";
406
+ acf.admin_url = "' . admin_url() . '";
407
+ </script>';
408
 
409
  // get acf's
410
  $acfs = $this->get_field_groups();
422
  array($this, 'meta_box_input'),
423
  $post_type,
424
  $acf['options']['position'],
425
+ 'high',
426
  array( 'fields' => $acf['fields'], 'options' => $acf['options'], 'show' => $show )
427
  );
428
  }
511
  {
512
  include('core/admin/page_acf.php');
513
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
514
 
 
 
 
 
 
515
  }
516
 
517
 
1459
  // Options Page
1460
  case "options_page":
1461
 
1462
+ if(!function_exists('get_admin_page_title'))
1463
+ {
1464
+ return false;
1465
+ }
1466
+
1467
  if($rule['operator'] == "==")
1468
  {
1469
  if(get_admin_page_title() == $rule['value'])
core/admin/meta_box_fields.php CHANGED
@@ -19,6 +19,7 @@ $fields[999] = array(
19
  'type' => 'text',
20
  'order_no' => '1',
21
  'instructions' => '',
 
22
  );
23
 
24
  // get name of all fields for use in field type drop down
19
  'type' => 'text',
20
  'order_no' => '1',
21
  'instructions' => '',
22
+ 'required' => '0',
23
  );
24
 
25
  // get name of all fields for use in field type drop down
core/admin/meta_box_input.php CHANGED
@@ -29,7 +29,7 @@ if($fields)
29
  // required
30
  if(!isset($field['required']))
31
  {
32
- $field['required'] == "0";
33
  }
34
 
35
  $required_class = "";
29
  // required
30
  if(!isset($field['required']))
31
  {
32
+ $field['required'] = "0";
33
  }
34
 
35
  $required_class = "";
core/api.php CHANGED
@@ -388,4 +388,255 @@ function acf_shortcode( $atts )
388
  }
389
  add_shortcode( 'acf', 'acf_shortcode' );
390
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
391
  ?>
388
  }
389
  add_shortcode( 'acf', 'acf_shortcode' );
390
 
391
+
392
+ /*--------------------------------------------------------------------------------------
393
+ *
394
+ * Front end form Head
395
+ *
396
+ * @author Elliot Condon
397
+ * @since 1.1.4
398
+ *
399
+ *-------------------------------------------------------------------------------------*/
400
+
401
+ function acf_form_head()
402
+ {
403
+ // global vars
404
+ global $acf;
405
+
406
+
407
+
408
+ // run database save first
409
+ if(isset($_POST) && isset($_POST['acf_save']))
410
+ {
411
+ $post_id = $_POST['post_id'];
412
+
413
+ // save
414
+ // strip slashes
415
+ $_POST = array_map('stripslashes_deep', $_POST);
416
+
417
+ // save fields
418
+ $fields = $_POST['fields'];
419
+
420
+ if($fields)
421
+ {
422
+ foreach($fields as $key => $value)
423
+ {
424
+ // get field
425
+ $field = $acf->get_acf_field($key);
426
+
427
+ $acf->update_value($post_id, $field, $value);
428
+ }
429
+ }
430
+
431
+
432
+ // redirect
433
+ if(isset($_POST['return']))
434
+ {
435
+ wp_redirect($_POST['return']);
436
+ exit;
437
+ }
438
+
439
+ }
440
+
441
+
442
+ // register css / javascript
443
+ foreach($acf->fields as $field)
444
+ {
445
+ $acf->fields[$field->name]->admin_print_scripts();
446
+ $acf->fields[$field->name]->admin_print_styles();
447
+ }
448
+ wp_enqueue_style(array(
449
+ 'colors-fresh'
450
+ ));
451
+
452
+
453
+ // form was not posted, load js head stuff
454
+ add_action('wp_head', 'acf_form_wp_head');
455
+
456
+ }
457
+
458
+ function acf_form_wp_head()
459
+ {
460
+ // global vars
461
+ global $post, $acf;
462
+
463
+
464
+ // fields admin_head
465
+ foreach($acf->fields as $field)
466
+ {
467
+ $acf->fields[$field->name]->admin_head();
468
+ }
469
+
470
+
471
+ // Style
472
+ echo '<link rel="stylesheet" type="text/css" href="'.$acf->dir.'/css/global.css" />';
473
+ echo '<link rel="stylesheet" type="text/css" href="'.$acf->dir.'/css/input.css" />';
474
+
475
+
476
+ // Javascript
477
+ echo '<script type="text/javascript" src="'.$acf->dir.'/js/input-actions.js" ></script>';
478
+ echo '<script type="text/javascript">
479
+ acf.validation_message = "' . __("Validation Failed. One or more fields below are required.",'acf') . '";
480
+ acf.post_id = ' . $post->ID . ';
481
+ acf.editor_mode = "wysiwyg";
482
+ acf.admin_url = "' . admin_url() . '";
483
+ </script>';
484
+ }
485
+
486
+
487
+ /*--------------------------------------------------------------------------------------
488
+ *
489
+ * Front end form
490
+ *
491
+ * @author Elliot Condon
492
+ * @since 1.1.4
493
+ *
494
+ *-------------------------------------------------------------------------------------*/
495
+
496
+ function acf_form($options = null)
497
+ {
498
+ global $post, $acf;
499
+
500
+
501
+ // defaults
502
+ $defaults = array(
503
+ 'post_id' => $post->ID, // post id to get field groups from and save data to
504
+ 'field_groups' => array(), // this will find the field groups for this post
505
+ 'form_attributes' => array( // attributes will be added to the form element
506
+ 'class' => ''
507
+ ),
508
+ 'return' => add_query_arg( 'updated', 'true', get_permalink() ), // return url
509
+ 'html_field_open' => '<div class="field">', // field wrapper open
510
+ 'html_field_close' => '</div>', // field wrapper close
511
+ 'html_before_fields' => '', // html inside form before fields
512
+ 'html_after_fields' => '', // html inside form after fields
513
+ 'submit_value' => 'Update', // vale for submit field
514
+ 'updated_message' => 'Post updated.', // default updated message. Can be false
515
+ );
516
+
517
+
518
+ // merge defaults with options
519
+ if($options && is_array($options))
520
+ {
521
+ $options = array_merge($defaults, $options);
522
+ }
523
+ else
524
+ {
525
+ $options = $defaults;
526
+ }
527
+
528
+
529
+ // post_id for options page
530
+ if($options['post_id'] == "options")
531
+ {
532
+ $options['post_id'] = 999999999;
533
+ }
534
+
535
+
536
+ // register post box
537
+ if(!$options['field_groups'])
538
+ {
539
+ $options['field_groups'] = $acf->get_input_metabox_ids(array('post_id' => $options['post_id']), false);
540
+ }
541
+
542
+
543
+ // updated message
544
+ if(isset($_GET['updated']) && $_GET['updated'] == 'true' && $options['updated_message'])
545
+ {
546
+ echo '<div id="message" class="updated"><p>' . $options['updated_message'] . '</p></div>';
547
+ }
548
+
549
+ // display form
550
+ ?>
551
+ <form action="" id="post" method="post" <?php if($options['form_attributes']){foreach($options['form_attributes'] as $k => $v){echo $k . '="' . $v .'" '; }} ?>>
552
+ <div style="display:none">
553
+ <input type="hidden" name="acf_save" value="true" />
554
+ <input type="hidden" name="post_id" value="<?php echo $options['post_id']; ?>" />
555
+ <input type="hidden" name="return" value="<?php echo $options['return']; ?>" />
556
+ <?php wp_editor('', 'acf-temp-editor'); ?>
557
+ </div>
558
+
559
+ <div id="poststuff">
560
+ <div class="acf_postbox">
561
+ <?php
562
+
563
+ // html before fields
564
+ echo $defaults['html_before_fields'];
565
+
566
+ $field_groups = $acf->get_field_groups();
567
+ if($field_groups):
568
+ foreach($field_groups as $field_group):
569
+
570
+ if(!in_array($field_group['id'], $options['field_groups'])) continue;
571
+
572
+
573
+ // defaults
574
+ if(!$field_group['options'])
575
+ {
576
+ $field_group['options'] = array(
577
+ 'layout' => 'default'
578
+ );
579
+ }
580
+
581
+
582
+ if($field_group['fields'])
583
+ {
584
+
585
+ echo '<div class="options" data-layout="' . $field_group['options']['layout'] . '"></div>';
586
+ foreach($field_group['fields'] as $field)
587
+ {
588
+ // if they didn't select a type, skip this field
589
+ if($field['type'] == 'null') continue;
590
+
591
+ // set value
592
+ $field['value'] = $acf->get_value($options['post_id'], $field);
593
+
594
+ // required
595
+ if(!isset($field['required']))
596
+ {
597
+ $field['required'] == "0";
598
+ }
599
+
600
+ $required_class = "";
601
+ $required_label = "";
602
+
603
+ if($field['required'] == "1")
604
+ {
605
+ $required_class = ' required';
606
+ $required_label = ' <span class="required">*</span>';
607
+ }
608
+
609
+ echo '<div class="field field-' . $field['type'] . $required_class . '">';
610
+
611
+ echo '<label class="field_label" for="fields[' . $field['key'] . ']">' . $field['label'] . $required_label . '</label>';
612
+ if($field['instructions']) echo '<p class="instructions">' . $field['instructions'] . '</p>';
613
+
614
+ $field['name'] = 'fields[' . $field['key'] . ']';
615
+ $acf->create_field($field);
616
+
617
+ echo '</div>';
618
+
619
+ }
620
+ }
621
+
622
+ endforeach;
623
+ endif;
624
+
625
+ // html after fields
626
+ echo $defaults['html_after_fields'];
627
+
628
+ ?>
629
+ <div class="field">
630
+ <input type="submit" value="<?php echo $options['submit_value']; ?>" />
631
+ </div>
632
+ </div>
633
+ </div>
634
+ </form>
635
+
636
+
637
+ <?php
638
+
639
+ }
640
+
641
+
642
  ?>
core/fields/color_picker.php CHANGED
@@ -34,78 +34,20 @@ class acf_Color_picker extends acf_Field
34
 
35
  function admin_print_scripts()
36
  {
37
- wp_enqueue_script( 'farbtastic' );
 
 
38
  }
39
 
40
  function admin_print_styles()
41
  {
42
- wp_enqueue_style( 'farbtastic' );
 
 
43
 
44
  }
45
 
46
 
47
- /*--------------------------------------------------------------------------------------
48
- *
49
- * admin_head
50
- *
51
- * @author Elliot Condon
52
- * @since 2.0.6
53
- *
54
- *-------------------------------------------------------------------------------------*/
55
-
56
- function admin_head()
57
- {
58
- // add datepicker
59
- ?>
60
- <script type="text/javascript">
61
- (function($){
62
-
63
- var farbtastic;
64
-
65
- $(document).ready(function(){
66
-
67
- $('body').append('<div id="acf_color_picker" />');
68
- farbtastic = $.farbtastic('#acf_color_picker');
69
-
70
- });
71
-
72
- $('#poststuff input.acf_color_picker').live('focus', function(){
73
-
74
- var input = $(this);
75
-
76
- $('#acf_color_picker').css({
77
- left: input.offset().left,
78
- top: input.offset().top - $('#acf_color_picker').height(),
79
- display: 'block'
80
- });
81
-
82
- farbtastic.linkTo(this);
83
-
84
- }).live('blur', function(){
85
-
86
- $('#acf_color_picker').css({
87
- display: 'none'
88
- });
89
-
90
- });
91
-
92
- })(jQuery);
93
- </script>
94
- <style type="text/css">
95
- #acf_color_picker {
96
- position: absolute;
97
- top: 0;
98
- left: 0;
99
- display: none;
100
- background: #fff;
101
- border: #AAAAAA solid 1px;
102
- border-radius: 4px;
103
- }
104
- </style>
105
- <?php
106
- }
107
-
108
-
109
  /*--------------------------------------------------------------------------------------
110
  *
111
  * create_field
34
 
35
  function admin_print_scripts()
36
  {
37
+ wp_enqueue_script(array(
38
+ 'farbtastic'
39
+ ));
40
  }
41
 
42
  function admin_print_styles()
43
  {
44
+ wp_enqueue_style(array(
45
+ 'farbtastic'
46
+ ));
47
 
48
  }
49
 
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  /*--------------------------------------------------------------------------------------
52
  *
53
  * create_field
core/fields/date_picker/date_picker.php CHANGED
@@ -37,44 +37,6 @@ class acf_Date_picker extends acf_Field
37
  // add datepicker
38
  echo '<link rel="stylesheet" type="text/css" href="'.$this->parent->dir.'/core/fields/date_picker/style.date_picker.css" />';
39
  echo '<script type="text/javascript" src="'.$this->parent->dir.'/core/fields/date_picker/jquery.ui.datepicker.js" ></script>';
40
- ?>
41
- <script type="text/javascript">
42
- (function($){
43
-
44
-
45
- $('#poststuff input.acf_datepicker').live('focus', function(){
46
-
47
- var input = $(this);
48
-
49
- if(!input.hasClass('active'))
50
- {
51
-
52
- // vars
53
- var format = input.attr('data-date_format') ? input.attr('data-date_format') : 'dd/mm/yy';
54
-
55
- // add date picker and refocus
56
- input.addClass('active').datepicker({
57
- dateFormat: format
58
- })
59
-
60
- // set a timeout to re focus the input (after it has the datepicker!)
61
- setTimeout(function(){
62
- input.trigger('blur').trigger('focus');
63
- }, 1);
64
-
65
- // wrap the datepicker (only if it hasn't already been wrapped)
66
- if($('body > #ui-datepicker-div').length > 0)
67
- {
68
- $('#ui-datepicker-div').wrap('<div class="ui-acf" />');
69
- }
70
-
71
- }
72
-
73
- });
74
-
75
- })(jQuery);
76
- </script>
77
- <?php
78
  }
79
 
80
 
37
  // add datepicker
38
  echo '<link rel="stylesheet" type="text/css" href="'.$this->parent->dir.'/core/fields/date_picker/style.date_picker.css" />';
39
  echo '<script type="text/javascript" src="'.$this->parent->dir.'/core/fields/date_picker/jquery.ui.datepicker.js" ></script>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  }
41
 
42
 
core/fields/file.php CHANGED
@@ -70,56 +70,6 @@ class acf_File extends acf_Field
70
  }
71
 
72
 
73
- /*--------------------------------------------------------------------------------------
74
- *
75
- * admin_head
76
- *
77
- * @author Elliot Condon
78
- * @since 2.0.6
79
- *
80
- *-------------------------------------------------------------------------------------*/
81
-
82
- function admin_head()
83
- {
84
- ?>
85
- <script type="text/javascript">
86
-
87
- (function($){
88
-
89
- $('#poststuff .acf_file_uploader .no_file .button').live('click', function(){
90
-
91
- // vars
92
- var div = $(this).closest('.acf_file_uploader');
93
- var post_id = $('input#post_ID').val();
94
-
95
- // set global var
96
- window.acf_div = div;
97
-
98
- // show the thickbox
99
- tb_show('Add Image to field', 'media-upload.php?post_id=' + post_id + '&type=file&acf_type=file&TB_iframe=1');
100
-
101
- return false;
102
- });
103
-
104
- $('#poststuff .acf_file_uploader .file .button').live('click', function(){
105
-
106
- // vars
107
- var div = $(this).closest('.acf_file_uploader');
108
-
109
- div.find('input.value').val('');
110
- div.removeClass('active');
111
-
112
- return false;
113
-
114
- });
115
-
116
-
117
- })(jQuery);
118
- </script>
119
- <?php
120
- }
121
-
122
-
123
  /*--------------------------------------------------------------------------------------
124
  *
125
  * create_field
70
  }
71
 
72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  /*--------------------------------------------------------------------------------------
74
  *
75
  * create_field
core/fields/flexible_content.php CHANGED
@@ -19,8 +19,7 @@ class acf_Flexible_content extends acf_Field
19
 
20
  $this->name = 'flexible_content';
21
  $this->title = __("Flexible Content",'acf');
22
-
23
- add_action('admin_head', array($this,'admin_head_field'));
24
  }
25
 
26
 
@@ -390,393 +389,6 @@ class acf_Flexible_content extends acf_Field
390
  }
391
 
392
 
393
- /*--------------------------------------------------------------------------------------
394
- *
395
- * admin_head
396
- *
397
- * @author Elliot Condon
398
- * @since 2.2.0
399
- *
400
- *-------------------------------------------------------------------------------------*/
401
-
402
- function admin_head()
403
- {
404
- ?>
405
- <script type="text/javascript">
406
- (function($){
407
-
408
- function uniqid()
409
- {
410
- var newDate = new Date();
411
- return newDate.getTime();
412
- }
413
-
414
- /*----------------------------------------------------------------------
415
- *
416
- * Update Order Numbers
417
- *
418
- *---------------------------------------------------------------------*/
419
-
420
- function update_order_numbers(div)
421
- {
422
- div.children('.values').children('table').each(function(i){
423
- $(this).children('tbody').children('tr').children('td.order').html(i+1);
424
- });
425
-
426
- }
427
-
428
-
429
- /*----------------------------------------------------------------------
430
- *
431
- * Make Sortable
432
- *
433
- *---------------------------------------------------------------------*/
434
- function make_sortable(div){
435
-
436
- div.children('.values').unbind('sortable').sortable({
437
- update: function(event, ui){
438
- update_order_numbers(div);
439
- },
440
- handle: 'td.order'
441
- });
442
- }
443
-
444
-
445
- /*----------------------------------------------------------------------
446
- *
447
- * Add Row
448
- *
449
- *---------------------------------------------------------------------*/
450
-
451
- $('#poststuff .acf_flexible_content #fc_add_row').live('click', function(){
452
-
453
- if($(this).hasClass('active'))
454
- {
455
- $(this).removeClass('active');
456
- $(this).siblings('.acf_popup').animate({ opacity : 0, bottom : '35px' }, 250);
457
- }
458
- else
459
- {
460
- $(this).addClass('active');
461
- $(this).siblings('.acf_popup').css({display : 'block', opacity : 0, bottom : '15px'}).animate({ opacity : 1, bottom : '25px' }, 250);
462
- }
463
- });
464
-
465
-
466
- /*----------------------------------------------------------------------
467
- *
468
- * Delete Row
469
- *
470
- *---------------------------------------------------------------------*/
471
-
472
- $('#poststuff .acf_flexible_content #fc_remove_row').live('click', function(){
473
-
474
- var div = $(this).closest('.acf_flexible_content');
475
- var table = $(this).closest('table');
476
- var temp = $('<div style="height:' + table.height() + 'px"></div>');
477
-
478
- table.animate({'left' : '50px', 'opacity' : 0}, 250, function(){
479
- table.before(temp).remove();
480
-
481
- temp.animate({'height' : 0 }, 250, function(){
482
- temp.remove();
483
- });
484
-
485
- update_order_numbers(div);
486
-
487
- if(!div.children('.values').children('table').exists())
488
- {
489
- div.children('.no_value_message').show();
490
- }
491
-
492
- });
493
-
494
- return false;
495
-
496
- });
497
-
498
-
499
- /*----------------------------------------------------------------------
500
- *
501
- * Add Layout
502
- *
503
- *---------------------------------------------------------------------*/
504
-
505
- $('#poststuff .acf_flexible_content .table_footer .acf_popup ul li a').live('click', function(){
506
-
507
- // vars
508
- var layout = $(this).attr('data-layout');
509
- var div = $(this).closest('.acf_flexible_content');
510
-
511
- // deactivate any wysiwygs
512
- div.children('.clones').acf_deactivate_wysiwyg();
513
-
514
- // create new field
515
- var new_field = div.children('.clones').children('table[data-layout="' + layout + '"]').clone(false);
516
-
517
- // update names
518
- var new_id = uniqid();
519
- new_field.find('[name]').each(function(){
520
-
521
- var name = $(this).attr('name').replace('[999]','[' + new_id + ']');
522
- $(this).attr('name', name);
523
- $(this).attr('id', name);
524
-
525
- });
526
-
527
- // hide no values message
528
- div.children('.no_value_message').hide();
529
-
530
- // add row
531
- div.children('.values').append(new_field);
532
-
533
- // activate wysiwyg
534
- new_field.acf_activate_wysiwyg();
535
-
536
- update_order_numbers(div);
537
-
538
- // hide acf popup
539
- $(this).closest('.table_footer').find('#fc_add_row').removeClass('active');
540
- $(this).closest('.acf_popup').hide();
541
-
542
- // validation
543
- div.closest('.field').removeClass('error');
544
-
545
- return false;
546
-
547
- });
548
-
549
-
550
- $(document).ready(function(){
551
-
552
- $('#poststuff .acf_flexible_content').each(function(){
553
-
554
- // sortable
555
- make_sortable($(this));
556
- });
557
-
558
- });
559
-
560
-
561
- // validation
562
- $('form#post').live("submit", function(){
563
-
564
- // flexible content
565
- $('#post-body .acf_postbox:visible .field.required .acf_flexible_content').each(function(){
566
-
567
- if(!$(this).find('.values table').exists())
568
- {
569
- acf.valdation = false;
570
- $(this).closest('.field').addClass('error');
571
- }
572
-
573
- });
574
-
575
- });
576
-
577
- })(jQuery);
578
- </script>
579
- <?php
580
- }
581
-
582
-
583
- /*--------------------------------------------------------------------------------------
584
- *
585
- * admin_head_field
586
- * - add extra script / style to field edit page
587
- *
588
- * @author Elliot Condon
589
- * @since 2.2.0
590
- *
591
- *-------------------------------------------------------------------------------------*/
592
-
593
- function admin_head_field()
594
- {
595
- // only add to edit pages
596
- if(in_array($GLOBALS['pagenow'], array('post.php', 'post-new.php')))
597
- {
598
-
599
- if($GLOBALS['post_type'] == 'acf')
600
- {
601
- ?>
602
- <style type="text/css">
603
- table.acf_input table.acf_cf_meta {
604
- width: 100%;
605
- border: 0 none;
606
- }
607
-
608
- table.acf_input table.acf_cf_meta td {
609
- border: 0 none;
610
- width: 33%;
611
- }
612
-
613
- table.acf_input table.acf_cf_meta label {
614
- width: 20%;
615
- color: #333333;
616
- font-weight: bold;
617
- }
618
-
619
- table.acf_input table.acf_cf_meta input {
620
- width: 80%;
621
- }
622
-
623
- table.acf_input table.acf_cf_meta select {
624
- width: 75%;
625
- }
626
-
627
- .acf_fc_reorder {
628
- cursor: move;
629
- }
630
-
631
- .ui-state-highlight {
632
- height: 40px;
633
- }
634
-
635
- .field_form table.acf_input .field_option_flexible_content > td {
636
- background: #f9f9f9;
637
- }
638
- </style>
639
- <script type="text/javascript">
640
- (function($){
641
-
642
- /*----------------------------------------------------------------------
643
- *
644
- * uniqid
645
- *
646
- *---------------------------------------------------------------------*/
647
-
648
- function uniqid()
649
- {
650
- var newDate = new Date;
651
- return newDate.getTime();
652
- }
653
-
654
-
655
- /*----------------------------------------------------------------------
656
- *
657
- * Add Layout Option
658
- *
659
- *---------------------------------------------------------------------*/
660
-
661
- $('#acf_fields .acf_fc_add').live('click', function(){
662
-
663
- // vars
664
- var tr = $(this).closest('tr.field_option_flexible_content');
665
- var new_tr = $(this).closest('.field_form').find('tr.field_option_flexible_content:first').clone(false);
666
-
667
- // remove sub fields
668
- new_tr.find('.sub_field.field').remove();
669
-
670
- // show add new message
671
- new_tr.find('.no_fields_message').show();
672
-
673
- // reset layout meta values
674
- new_tr.find('.acf_cf_meta input[type="text"]').val('');
675
- new_tr.find('.acf_cf_meta select').val('table');
676
-
677
- // update id / names
678
- var new_id = uniqid();
679
-
680
- new_tr.find('[name]').each(function(){
681
-
682
- var name = $(this).attr('name').replace('[layouts][0]','[layouts]['+new_id+']');
683
- $(this).attr('name', name);
684
- $(this).attr('id', name);
685
-
686
- });
687
-
688
- // add new tr
689
- tr.after(new_tr);
690
-
691
- // add drag / drop
692
- new_tr.find('.fields').sortable({
693
- handle: 'td.field_order'
694
- });
695
-
696
- return false;
697
- });
698
-
699
-
700
- /*----------------------------------------------------------------------
701
- *
702
- * Delete Layout Option
703
- *
704
- *---------------------------------------------------------------------*/
705
-
706
- $('#acf_fields .acf_fc_delete').live('click', function(){
707
-
708
- var tr = $(this).closest('tr.field_option_flexible_content');
709
- var tr_count = tr.siblings('tr.field_option.field_option_flexible_content').length;
710
-
711
- if(tr_count == 0)
712
- {
713
- alert('Flexible Content requires at least 1 layout');
714
- return false;
715
- }
716
-
717
- tr.animate({'left' : '50px', 'opacity' : 0}, 250, function(){
718
- tr.remove();
719
- });
720
-
721
- });
722
-
723
-
724
- /*----------------------------------------------------------------------
725
- *
726
- * Sortable Layout Option
727
- *
728
- *---------------------------------------------------------------------*/
729
-
730
- $('#acf_fields .acf_fc_reorder').live('mouseover', function(){
731
-
732
- var table = $(this).closest('table.acf_field_form_table');
733
-
734
- if(table.hasClass('sortable')) return false;
735
-
736
- var fixHelper = function(e, ui) {
737
- ui.children().each(function() {
738
- $(this).width($(this).width());
739
- });
740
- return ui;
741
- };
742
-
743
- table.addClass('sortable').children('tbody').sortable({
744
- items: ".field_option_flexible_content",
745
- handle: 'a.acf_fc_reorder',
746
- helper: fixHelper,
747
- placeholder: "ui-state-highlight"
748
- });
749
-
750
- });
751
-
752
-
753
- /*----------------------------------------------------------------------
754
- *
755
- * Label update name
756
- *
757
- *---------------------------------------------------------------------*/
758
-
759
- $('#acf_fields .acf_fc_label input[type="text"]').live('blur', function(){
760
-
761
- var label = $(this);
762
- var name = $(this).parents('td').siblings('td.acf_fc_name').find('input[type="text"]');
763
-
764
- if(name.val() == '')
765
- {
766
- var val = label.val().toLowerCase().split(' ').join('_').split('\'').join('');
767
- name.val(val);
768
- name.trigger('keyup');
769
- }
770
-
771
- });
772
-
773
- })(jQuery);
774
- </script>
775
- <?php
776
- }
777
- }
778
- }
779
-
780
 
781
  /*--------------------------------------------------------------------------------------
782
  *
19
 
20
  $this->name = 'flexible_content';
21
  $this->title = __("Flexible Content",'acf');
22
+
 
23
  }
24
 
25
 
389
  }
390
 
391
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
392
 
393
  /*--------------------------------------------------------------------------------------
394
  *
core/fields/image.php CHANGED
@@ -71,56 +71,6 @@ class acf_Image extends acf_Field
71
  }
72
 
73
 
74
- /*--------------------------------------------------------------------------------------
75
- *
76
- * admin_head
77
- *
78
- * @author Elliot Condon
79
- * @since 2.0.6
80
- *
81
- *-------------------------------------------------------------------------------------*/
82
-
83
- function admin_head()
84
- {
85
- ?>
86
- <script type="text/javascript">
87
-
88
- (function($){
89
-
90
- $('#poststuff .acf_image_uploader .button').live('click', function(){
91
-
92
- // vars
93
- var div = $(this).closest('.acf_image_uploader');
94
- var post_id = $('input#post_ID').val();
95
- var preview_size = div.attr('data-preview_size');
96
-
97
- // set global var
98
- window.acf_div = div;
99
-
100
- // show the thickbox
101
- tb_show('Add Image to field', 'media-upload.php?post_id=' + post_id + '&type=image&acf_type=image&acf_preview_size=' + preview_size + 'TB_iframe=1');
102
-
103
- return false;
104
- });
105
-
106
- $('#poststuff .acf_image_uploader .remove_image').live('click', function(){
107
-
108
- // vars
109
- var div = $(this).closest('.acf_image_uploader');
110
-
111
- div.find('input.value').val('');
112
- div.removeClass('active');
113
-
114
- return false;
115
-
116
- });
117
-
118
- })(jQuery);
119
- </script>
120
- <?php
121
- }
122
-
123
-
124
  /*--------------------------------------------------------------------------------------
125
  *
126
  * create_field
71
  }
72
 
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  /*--------------------------------------------------------------------------------------
75
  *
76
  * create_field
core/fields/page_link.php CHANGED
@@ -84,6 +84,7 @@ class acf_Page_link extends acf_Field
84
  'post_type' => $post_type,
85
  'sort_column' => 'menu_order',
86
  'order' => 'ASC',
 
87
  //'meta_key' => $field['meta_key'],
88
  //'meta_value' => $field['meta_value'],
89
  ));
@@ -96,6 +97,7 @@ class acf_Page_link extends acf_Field
96
  'post_type' => $post_type,
97
  'orderby' => 'title',
98
  'order' => 'ASC',
 
99
  //'meta_key' => $field['meta_key'],
100
  //'meta_value' => $field['meta_value'],
101
  ));
@@ -124,6 +126,13 @@ class acf_Page_link extends acf_Field
124
  }
125
  }
126
  $value .= get_the_title($post->ID);
 
 
 
 
 
 
 
127
  $selected = '';
128
 
129
 
84
  'post_type' => $post_type,
85
  'sort_column' => 'menu_order',
86
  'order' => 'ASC',
87
+ 'post_status' => array('publish', 'private', 'draft'),
88
  //'meta_key' => $field['meta_key'],
89
  //'meta_value' => $field['meta_value'],
90
  ));
97
  'post_type' => $post_type,
98
  'orderby' => 'title',
99
  'order' => 'ASC',
100
+ 'post_status' => array('publish', 'private', 'draft'),
101
  //'meta_key' => $field['meta_key'],
102
  //'meta_value' => $field['meta_value'],
103
  ));
126
  }
127
  }
128
  $value .= get_the_title($post->ID);
129
+
130
+ // status
131
+ if($post->post_status == "private" || $post->post_status == "draft")
132
+ {
133
+ $value .= " ($post->post_status)";
134
+ }
135
+
136
  $selected = '';
137
 
138
 
core/fields/post_object.php CHANGED
@@ -78,6 +78,7 @@ class acf_Post_object extends acf_Field
78
  'post_type' => $post_type,
79
  'sort_column' => 'menu_order',
80
  'order' => 'ASC',
 
81
  //'meta_key' => $field['meta_key'],
82
  //'meta_value' => $field['meta_value'],
83
  ));
@@ -90,6 +91,7 @@ class acf_Post_object extends acf_Field
90
  'post_type' => $post_type,
91
  'orderby' => 'title',
92
  'order' => 'ASC',
 
93
  //'meta_key' => $field['meta_key'],
94
  //'meta_value' => $field['meta_value'],
95
  ));
@@ -137,6 +139,14 @@ class acf_Post_object extends acf_Field
137
  }
138
  }
139
  $value .= get_the_title($post->ID);
 
 
 
 
 
 
 
 
140
  $selected = '';
141
 
142
 
78
  'post_type' => $post_type,
79
  'sort_column' => 'menu_order',
80
  'order' => 'ASC',
81
+ 'post_status' => array('publish', 'private', 'draft'),
82
  //'meta_key' => $field['meta_key'],
83
  //'meta_value' => $field['meta_value'],
84
  ));
91
  'post_type' => $post_type,
92
  'orderby' => 'title',
93
  'order' => 'ASC',
94
+ 'post_status' => array('publish', 'private', 'draft'),
95
  //'meta_key' => $field['meta_key'],
96
  //'meta_value' => $field['meta_value'],
97
  ));
139
  }
140
  }
141
  $value .= get_the_title($post->ID);
142
+
143
+ // status
144
+ if($post->post_status == "private" || $post->post_status == "draft")
145
+ {
146
+ $value .= " ($post->post_status)";
147
+ }
148
+
149
+
150
  $selected = '';
151
 
152
 
core/fields/relationship.php CHANGED
@@ -35,9 +35,7 @@ class acf_Relationship extends acf_Field
35
  function admin_print_scripts()
36
  {
37
  wp_enqueue_script(array(
38
-
39
  'jquery-ui-sortable',
40
-
41
  ));
42
  }
43
 
@@ -47,208 +45,6 @@ class acf_Relationship extends acf_Field
47
  }
48
 
49
 
50
- /*--------------------------------------------------------------------------------------
51
- *
52
- * admin_head
53
- *
54
- * @author Elliot Condon
55
- * @since 2.0.6
56
- *
57
- *-------------------------------------------------------------------------------------*/
58
-
59
- function admin_head()
60
- {
61
- ?>
62
- <script type="text/javascript">
63
-
64
- (function($){
65
-
66
- /*----------------------------------------------------------------------
67
- *
68
- * update_input_val
69
- *
70
- *---------------------------------------------------------------------*/
71
-
72
- $.fn.update_input_val = function()
73
- {
74
- // vars
75
- var div = $(this);
76
- var right = div.find('.relationship_right .relationship_list');
77
- var value = new Array();
78
-
79
- // add id's to array
80
- right.find('a:not(.hide)').each(function(){
81
- value.push($(this).attr('data-post_id'));
82
- });
83
-
84
- // set value
85
- div.children('input').val(value.join(','));
86
- };
87
-
88
-
89
- /*----------------------------------------------------------------------
90
- *
91
- * Add
92
- *
93
- *---------------------------------------------------------------------*/
94
-
95
- $('#poststuff .acf_relationship .relationship_left .relationship_list a').live('click', function(){
96
-
97
- // vars
98
- var id = $(this).attr('data-post_id');
99
- var div = $(this).closest('.acf_relationship');
100
- var max = parseInt(div.attr('data-max')); if(max == -1){ max = 9999; }
101
- var right = div.find('.relationship_right .relationship_list');
102
-
103
- // max posts
104
- if(right.find('a:not(.hide)').length >= max)
105
- {
106
- alert('Maximum values reached ( ' + max + ' values )');
107
- return false;
108
- }
109
-
110
- // hide / show
111
- $(this).addClass('hide');
112
- right.find('a[data-post_id="' + id + '"]').removeClass('hide').appendTo(right);
113
-
114
- // update input value
115
- div.update_input_val();
116
-
117
- // validation
118
- div.closest('.field').removeClass('error');
119
-
120
- return false;
121
-
122
- });
123
-
124
-
125
- /*----------------------------------------------------------------------
126
- *
127
- * Remove
128
- *
129
- *---------------------------------------------------------------------*/
130
-
131
- $('#poststuff .acf_relationship .relationship_right .relationship_list a').live('click', function(){
132
-
133
- // vars
134
- var id = $(this).attr('data-post_id');
135
- var div = $(this).closest('.acf_relationship');
136
- var left = div.find('.relationship_left .relationship_list');
137
-
138
- // hide / show
139
- $(this).addClass('hide');
140
- left.find('a[data-post_id="' + id + '"]').removeClass('hide');
141
-
142
- // update input value
143
- div.update_input_val();
144
-
145
- return false;
146
-
147
- });
148
-
149
-
150
- /*----------------------------------------------------------------------
151
- *
152
- * Search Left List
153
- *
154
- *---------------------------------------------------------------------*/
155
-
156
- $.expr[':'].Contains = function(a,i,m){
157
- return (a.textContent || a.innerText || "").toUpperCase().indexOf(m[3].toUpperCase())>=0;
158
- };
159
-
160
- $('#poststuff .acf_relationship input.relationship_search').live('change', function()
161
- {
162
- // vars
163
- var filter = $(this).val();
164
- var div = $(this).closest('.acf_relationship');
165
- var left = div.find('.relationship_left .relationship_list');
166
-
167
- if(filter)
168
- {
169
- left.find("a:not(:Contains(" + filter + "))").addClass('filter_hide');
170
- left.find("a:Contains(" + filter + "):not(.hide)").removeClass('filter_hide');
171
- }
172
- else
173
- {
174
- left.find("a:not(.hide)").removeClass('filter_hide');
175
- }
176
-
177
- return false;
178
-
179
- })
180
- .live('keyup', function(){
181
- $(this).change();
182
- })
183
- .live('focus', function(){
184
- $(this).siblings('label').hide();
185
- })
186
- .live('blur', function(){
187
- if($(this).val() == "")
188
- {
189
- $(this).siblings('label').show();
190
- }
191
- });
192
-
193
-
194
- /*----------------------------------------------------------------------
195
- *
196
- * setup_acf_relationship
197
- *
198
- *---------------------------------------------------------------------*/
199
-
200
- $.fn.setup_acf_relationship = function(){
201
-
202
- $(this).find('.acf_relationship').each(function(){
203
-
204
- // vars
205
- var div = $(this);
206
-
207
- // reset search value
208
- div.find('input.relationship_search').val('');
209
-
210
- // make right sortable
211
- div.find('.relationship_right .relationship_list').sortable({
212
- axis: "y", // limit the dragging to up/down only
213
- start: function(event, ui)
214
- {
215
- ui.item.addClass('sortable_active');
216
- },
217
- stop: function(event, ui)
218
- {
219
- ui.item.removeClass('sortable_active');
220
- div.update_input_val();
221
- }
222
- });
223
-
224
- });
225
-
226
- };
227
-
228
- $(document).ready(function(){
229
-
230
- $('#poststuff').setup_acf_relationship();
231
-
232
- // create wysiwyg when you add a repeater row
233
- $('.repeater #add_field').live('click', function(){
234
-
235
- var repeater = $(this).closest('.repeater');
236
-
237
- // run after the repeater has added the row
238
- setTimeout(function(){
239
- repeater.children('table').children('tbody').children('tr:last-child').setup_acf_relationship();
240
- }, 1);
241
-
242
- });
243
-
244
- });
245
-
246
- })(jQuery);
247
- </script>
248
- <?php
249
- }
250
-
251
-
252
  /*--------------------------------------------------------------------------------------
253
  *
254
  * create_field
@@ -284,6 +80,7 @@ class acf_Relationship extends acf_Field
284
  'post_type' => $field['post_type'],
285
  'orderby' => 'title',
286
  'order' => 'ASC',
 
287
  //'meta_key' => $field['meta_key'],
288
  //'meta_value' => $field['meta_value'],
289
  ));
@@ -350,7 +147,15 @@ class acf_Relationship extends acf_Field
350
  if(!get_the_title($post->ID)) continue;
351
 
352
  $class = in_array($post->ID, $values_array) ? 'hide' : '';
353
- echo '<a href="javascript:;" class="' . $class . '" data-post_id="' . $post->ID . '">' . get_the_title($post->ID) . '<span class="add"></span></a>';
 
 
 
 
 
 
 
 
354
  }
355
  }
356
  ?>
@@ -374,13 +179,29 @@ class acf_Relationship extends acf_Field
374
  {
375
  foreach($values_array as $value)
376
  {
377
- echo '<a href="javascript:;" class="" data-post_id="' . $temp_posts[$value]->ID . '">' . get_the_title($temp_posts[$value]->ID) . '<span class="remove"></span></a>';
 
 
 
 
 
 
 
 
 
378
  unset($temp_posts[$value]);
379
  }
380
 
381
  foreach($temp_posts as $id => $post)
382
  {
383
- echo '<a href="javascript:;" class="hide" data-post_id="' . $post->ID . '">' . get_the_title($post->ID) . '<span class="remove"></span></a>';
 
 
 
 
 
 
 
384
  }
385
  }
386
 
35
  function admin_print_scripts()
36
  {
37
  wp_enqueue_script(array(
 
38
  'jquery-ui-sortable',
 
39
  ));
40
  }
41
 
45
  }
46
 
47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  /*--------------------------------------------------------------------------------------
49
  *
50
  * create_field
80
  'post_type' => $field['post_type'],
81
  'orderby' => 'title',
82
  'order' => 'ASC',
83
+ 'post_status' => array('publish', 'private', 'draft'),
84
  //'meta_key' => $field['meta_key'],
85
  //'meta_value' => $field['meta_value'],
86
  ));
147
  if(!get_the_title($post->ID)) continue;
148
 
149
  $class = in_array($post->ID, $values_array) ? 'hide' : '';
150
+
151
+ $title = get_the_title($post->ID);
152
+ // status
153
+ if($post->post_status == "private" || $post->post_status == "draft")
154
+ {
155
+ $title .= " ($post->post_status)";
156
+ }
157
+
158
+ echo '<a href="javascript:;" class="' . $class . '" data-post_id="' . $post->ID . '">' . $title . '<span class="add"></span></a>';
159
  }
160
  }
161
  ?>
179
  {
180
  foreach($values_array as $value)
181
  {
182
+ $post = $temp_posts[$value];
183
+
184
+ $title = get_the_title($post->ID);
185
+ // status
186
+ if($post->post_status == "private" || $post->post_status == "draft")
187
+ {
188
+ $title .= " ($post->post_status)";
189
+ }
190
+
191
+ echo '<a href="javascript:;" class="" data-post_id="' . $temp_posts[$value]->ID . '">' . $title . '<span class="remove"></span></a>';
192
  unset($temp_posts[$value]);
193
  }
194
 
195
  foreach($temp_posts as $id => $post)
196
  {
197
+ $title = get_the_title($post->ID);
198
+ // status
199
+ if($post->post_status == "private" || $post->post_status == "draft")
200
+ {
201
+ $title .= " ($post->post_status)";
202
+ }
203
+
204
+ echo '<a href="javascript:;" class="hide" data-post_id="' . $post->ID . '">' . $title . '<span class="remove"></span></a>';
205
  }
206
  }
207
 
core/fields/repeater.php CHANGED
@@ -35,9 +35,7 @@ class acf_Repeater extends acf_Field
35
  function admin_print_scripts()
36
  {
37
  wp_enqueue_script(array(
38
-
39
  'jquery-ui-sortable',
40
-
41
  ));
42
  }
43
 
@@ -47,166 +45,6 @@ class acf_Repeater extends acf_Field
47
  }
48
 
49
 
50
- /*--------------------------------------------------------------------------------------
51
- *
52
- * admin_head
53
- *
54
- * @author Elliot Condon
55
- * @since 2.0.6
56
- *
57
- *-------------------------------------------------------------------------------------*/
58
-
59
- function admin_head()
60
- {
61
- ?>
62
- <script type="text/javascript">
63
- (function($){
64
-
65
-
66
- function uniqid()
67
- {
68
- var newDate = new Date;
69
- return newDate.getTime();
70
- }
71
-
72
- /*----------------------------------------------------------------------
73
- *
74
- * Update Order Numbers
75
- *
76
- *---------------------------------------------------------------------*/
77
-
78
- function update_order_numbers(div)
79
- {
80
- div.children('table').children('tbody').children('tr.row').each(function(i){
81
- $(this).children('td.order').html(i+1);
82
- });
83
-
84
- };
85
-
86
-
87
- /*----------------------------------------------------------------------
88
- *
89
- * Make Sortable
90
- *
91
- *---------------------------------------------------------------------*/
92
- function make_sortable(div){
93
-
94
- var fixHelper = function(e, ui) {
95
- ui.children().each(function() {
96
- $(this).width($(this).width());
97
- });
98
- return ui;
99
- };
100
-
101
- div.children('table').children('tbody').unbind('sortable').sortable({
102
- update: function(event, ui){
103
- update_order_numbers(div);
104
- },
105
- handle: 'td.order',
106
- helper: fixHelper
107
- });
108
- };
109
-
110
-
111
- $(document).ready(function(){
112
-
113
- $('#poststuff .repeater').each(function(){
114
-
115
- var div = $(this);
116
- var row_limit = parseInt(div.attr('data-row_limit'));
117
- var row_count = div.children('table').children('tbody').children('tr.row').length;
118
-
119
- // has limit been reached?
120
- if(row_count >= row_limit) div.find('#add_field').attr('disabled','true');
121
-
122
- // sortable
123
- if(row_limit > 1){
124
- make_sortable(div);
125
- }
126
-
127
- });
128
-
129
- });
130
-
131
- // add field
132
- $('#poststuff .repeater #r_add_row').live('click', function(){
133
-
134
- var div = $(this).closest('.repeater');
135
- var row_limit = parseInt(div.attr('data-row_limit'));
136
- var row_count = div.children('table').children('tbody').children('tr.row').length;
137
-
138
- // row limit
139
- if(row_count >= row_limit)
140
- {
141
- // reached row limit!
142
- div.find('#r_add_row').attr('disabled','true');
143
- return false;
144
- }
145
-
146
- // deactivate any wysiwygs
147
- div.children('table').children('tbody').children('tr.row_clone').acf_deactivate_wysiwyg();
148
-
149
- // create and add the new field
150
- var new_field = div.children('table').children('tbody').children('tr.row_clone').clone(false);
151
- new_field.attr('class', 'row');
152
-
153
- // update names
154
- var new_id = uniqid();
155
- new_field.find('[name]').each(function(){
156
-
157
- var name = $(this).attr('name').replace('[999]','[' + new_id + ']');
158
- $(this).attr('name', name);
159
- $(this).attr('id', name);
160
-
161
- });
162
-
163
- // add row
164
- div.children('table').children('tbody').append(new_field);
165
-
166
- // activate wysiwyg
167
- new_field.acf_activate_wysiwyg();
168
-
169
- update_order_numbers(div);
170
-
171
- // there is now 1 more row
172
- row_count ++;
173
-
174
- // disable the add field button if row limit is reached
175
- if((row_count+1) >= row_limit)
176
- {
177
- div.find('#r_add_row').attr('disabled','true');
178
- }
179
-
180
- // validation
181
- div.closest('.field').removeClass('error');
182
-
183
- return false;
184
-
185
- });
186
-
187
-
188
- // remove field
189
- $('#poststuff .repeater a#r_remove_row').live('click', function(){
190
-
191
- var div = $(this).closest('.repeater');
192
- var tr = $(this).closest('tr');
193
-
194
- tr.animate({'left' : '50px', 'opacity' : 0}, 250,function(){
195
- tr.remove();
196
- update_order_numbers(div);
197
- });
198
-
199
- div.find('#r_add_row').removeAttr('disabled');
200
-
201
- return false;
202
-
203
- });
204
-
205
- })(jQuery);
206
- </script>
207
- <?php
208
- }
209
-
210
 
211
  /*--------------------------------------------------------------------------------------
212
  *
35
  function admin_print_scripts()
36
  {
37
  wp_enqueue_script(array(
 
38
  'jquery-ui-sortable',
 
39
  ));
40
  }
41
 
45
  }
46
 
47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
 
49
  /*--------------------------------------------------------------------------------------
50
  *
core/fields/wysiwyg.php CHANGED
@@ -42,8 +42,8 @@ class acf_Wysiwyg extends acf_Field
42
  {
43
  return 'tinymce'; // html or tinymce
44
  }
45
-
46
-
47
  /*--------------------------------------------------------------------------------------
48
  *
49
  * add_tiny_mce
@@ -68,7 +68,7 @@ class acf_Wysiwyg extends acf_Field
68
  }
69
 
70
  }
71
-
72
 
73
  /*--------------------------------------------------------------------------------------
74
  *
@@ -108,127 +108,6 @@ class acf_Wysiwyg extends acf_Field
108
  }
109
 
110
 
111
- /*--------------------------------------------------------------------------------------
112
- *
113
- * admin_head
114
- *
115
- * @author Elliot Condon
116
- * @since 2.0.6
117
- *
118
- *-------------------------------------------------------------------------------------*/
119
-
120
- function admin_head()
121
- {
122
- ?>
123
- <script type="text/javascript">
124
- (function($){
125
-
126
- // store wysiwyg buttons
127
- $.acf_wysiwyg_buttons = {};
128
-
129
-
130
- $.fn.acf_deactivate_wysiwyg = function(){
131
-
132
- $(this).find('.acf_wysiwyg textarea').each(function(){
133
-
134
- tinyMCE.execCommand("mceRemoveControl", false, $(this).attr('id'));
135
-
136
- });
137
-
138
- };
139
-
140
-
141
- $.fn.acf_activate_wysiwyg = function(){
142
-
143
- // tinymce must exist
144
- if(typeof(tinyMCE) != "object")
145
- {
146
- return false;
147
- }
148
-
149
-
150
- // add tinymce to all wysiwyg fields
151
- $(this).find('.acf_wysiwyg textarea').each(function(){
152
-
153
- if(tinyMCE != undefined && tinyMCE.settings != undefined)
154
- {
155
- // reset buttons
156
- tinyMCE.settings.theme_advanced_buttons1 = $.acf_wysiwyg_buttons.theme_advanced_buttons1;
157
- tinyMCE.settings.theme_advanced_buttons2 = $.acf_wysiwyg_buttons.theme_advanced_buttons2;
158
-
159
- var toolbar = $(this).closest('.acf_wysiwyg').attr('data-toolbar');
160
-
161
- if(toolbar == 'basic')
162
- {
163
- tinyMCE.settings.theme_advanced_buttons1 = "bold,italic,formatselect,|,link,unlink,|,bullist,numlist,|,undo,redo";
164
- tinyMCE.settings.theme_advanced_buttons2 = "";
165
- }
166
- else
167
- {
168
- // add images + code buttons
169
- tinyMCE.settings.theme_advanced_buttons2 += ",code";
170
- }
171
- }
172
-
173
- tinyMCE.execCommand('mceAddControl', false, $(this).attr('id'));
174
-
175
- });
176
-
177
- };
178
-
179
-
180
- $(window).load(function(){
181
-
182
- // timout seems to fix duplicate editors
183
- setTimeout(function(){
184
-
185
- // store variables
186
- if(tinyMCE != undefined && tinyMCE.settings != undefined)
187
- {
188
- $.acf_wysiwyg_buttons.theme_advanced_buttons1 = tinyMCE.settings.theme_advanced_buttons1;
189
- $.acf_wysiwyg_buttons.theme_advanced_buttons2 = tinyMCE.settings.theme_advanced_buttons2;
190
-
191
- }
192
-
193
- $('#poststuff').acf_activate_wysiwyg();
194
-
195
- }, 10);
196
-
197
-
198
- });
199
-
200
- // Sortable: Start
201
- $('#poststuff .repeater > table > tbody, #poststuff .acf_flexible_content > .values').live( "sortstart", function(event, ui) {
202
-
203
- $(ui.item).find('.acf_wysiwyg textarea').each(function(){
204
- tinyMCE.execCommand("mceRemoveControl", false, $(this).attr('id'));
205
- });
206
-
207
- });
208
-
209
- // Sortable: End
210
- $('#poststuff .repeater > table > tbody, #poststuff .acf_flexible_content > .values').live( "sortstop", function(event, ui) {
211
-
212
- $(ui.item).find('.acf_wysiwyg textarea').each(function(){
213
- tinyMCE.execCommand("mceAddControl", false, $(this).attr('id'));
214
- });
215
-
216
- });
217
-
218
- // Delete
219
- $('#poststuff .repeater a.remove_field').live('click', function(event){
220
-
221
- var tr = $(event.target).closest('tr').find('.acf_wysiwyg textarea').each(function(){
222
- tinyMCE.execCommand("mceRemoveControl", false, $(this).attr('id'));
223
- });
224
- });
225
-
226
-
227
- })(jQuery);
228
- </script>
229
- <?php
230
- }
231
-
232
 
233
  /*--------------------------------------------------------------------------------------
234
  *
@@ -305,37 +184,52 @@ class acf_Wysiwyg extends acf_Field
305
  $field['toolbar'] = isset($field['toolbar']) ? $field['toolbar'] : 'full';
306
  $field['media_upload'] = isset($field['media_upload']) ? $field['media_upload'] : 'yes';
307
 
308
- $id = 'wysiwyg_' . uniqid();
309
 
310
- $version = get_bloginfo('version');
311
 
312
- ?>
313
- <?php if(version_compare($version,'3.2.1') > 0): ?>
314
-
315
- <?php else: ?>
316
-
317
- <?php endif; ?>
318
 
319
- <div class="acf_wysiwyg wp-editor-wrap" data-toolbar="<?php echo $field['toolbar']; ?>">
 
320
  <?php if($field['media_upload'] == 'yes'): ?>
321
- <?php if(version_compare($version,'3.2.1') > 0): ?>
322
- <div id="wp-content-editor-tools" class="wp-editor-tools">
323
- <div class="hide-if-no-js wp-media-buttons">
324
  <?php do_action( 'media_buttons' ); ?>
325
  </div>
326
  </div>
327
  <?php else: ?>
328
- <div id="editor-toolbar">
329
- <div id="media-buttons" class="hide-if-no-js">
 
 
330
  <?php do_action( 'media_buttons' ); ?>
331
  </div>
332
  </div>
333
  <?php endif; ?>
334
  <?php endif; ?>
335
- <div id="editorcontainer" class="wp-editor-container">
336
- <textarea id="<?php echo $id; ?>" name="<?php echo $field['name']; ?>" ><?php echo wp_richedit_pre($field['value']); ?></textarea>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
337
  </div>
338
  </div>
 
 
339
  <?php
340
 
341
  }
42
  {
43
  return 'tinymce'; // html or tinymce
44
  }
45
+
46
+
47
  /*--------------------------------------------------------------------------------------
48
  *
49
  * add_tiny_mce
68
  }
69
 
70
  }
71
+
72
 
73
  /*--------------------------------------------------------------------------------------
74
  *
108
  }
109
 
110
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
 
112
  /*--------------------------------------------------------------------------------------
113
  *
184
  $field['toolbar'] = isset($field['toolbar']) ? $field['toolbar'] : 'full';
185
  $field['media_upload'] = isset($field['media_upload']) ? $field['media_upload'] : 'yes';
186
 
187
+ $id = 'wysiwyg-' . $field['name'];
188
 
 
189
 
 
 
 
 
 
 
190
 
191
+ ?>
192
+ <div id="wp-<?php echo $id; ?>-wrap" class="acf_wysiwyg wp-editor-wrap" data-toolbar="<?php echo $field['toolbar']; ?>">
193
  <?php if($field['media_upload'] == 'yes'): ?>
194
+ <?php if(get_bloginfo('version') < "3.3"): ?>
195
+ <div id="editor-toolbar">
196
+ <div id="media-buttons" class="hide-if-no-js">
197
  <?php do_action( 'media_buttons' ); ?>
198
  </div>
199
  </div>
200
  <?php else: ?>
201
+ <div id="wp-<?php echo $id; ?>-editor-tools" class="wp-editor-tools">
202
+ <?php /*<a onclick="switchEditors.switchto(this);" class="hide-if-no-js wp-switch-editor switch-html active" id="<?php echo $id; ?>-html">HTML</a>
203
+ <a onclick="switchEditors.switchto(this);" class="hide-if-no-js wp-switch-editor switch-tmce" id="<?php echo $id; ?>-tmce">Visual</a>*/ ?>
204
+ <div id="wp-<?php echo $id; ?>-media-buttons" class="hide-if-no-js wp-media-buttons">
205
  <?php do_action( 'media_buttons' ); ?>
206
  </div>
207
  </div>
208
  <?php endif; ?>
209
  <?php endif; ?>
210
+ <div id="wp-<?php echo $id; ?>-editor-container" class="wp-editor-container">
211
+ <?php /*<div id="qt_<?php echo $id; ?>_toolbar" class="quicktags-toolbar">
212
+ <input type="button" value="b" title="" class="ed_button" accesskey="b" id="qt_<?php echo $id; ?>_strong">
213
+ <input type="button" value="i" title="" class="ed_button" accesskey="i" id="qt_<?php echo $id; ?>_em">
214
+ <input type="button" value="link" title="" class="ed_button" accesskey="a" id="qt_<?php echo $id; ?>_link">
215
+ <input type="button" value="b-quote" title="" class="ed_button" accesskey="q" id="qt_<?php echo $id; ?>_block">
216
+ <input type="button" value="del" title="" class="ed_button" accesskey="d" id="qt_<?php echo $id; ?>_del">
217
+ <input type="button" value="ins" title="" class="ed_button" accesskey="s" id="qt_<?php echo $id; ?>_ins">
218
+ <input type="button" value="img" title="" class="ed_button" accesskey="m" id="qt_<?php echo $id; ?>_img">
219
+ <input type="button" value="ul" title="" class="ed_button" accesskey="u" id="qt_<?php echo $id; ?>_ul">
220
+ <input type="button" value="ol" title="" class="ed_button" accesskey="o" id="qt_<?php echo $id; ?>_ol">
221
+ <input type="button" value="li" title="" class="ed_button" accesskey="l" id="qt_<?php echo $id; ?>_li">
222
+ <input type="button" value="code" title="" class="ed_button" accesskey="c" id="qt_<?php echo $id; ?>_code">
223
+ <input type="button" value="more" title="" class="ed_button" accesskey="t" id="qt_<?php echo $id; ?>_more">
224
+ <input type="button" value="lookup" title="Dictionary lookup" class="ed_button" id="qt_<?php echo $id; ?>_spell">
225
+ <input type="button" value="close tags" title="Close all open tags" class="ed_button" id="qt_<?php echo $id; ?>_close">
226
+ <input type="button" value="fullscreen" title="Toggle fullscreen mode" class="ed_button" accesskey="f" id="qt_<?php echo $id; ?>_fullscreen">
227
+ </div>*/ ?>
228
+ <textarea id="<?php echo $id; ?>" class="wp-editor-area" name="<?php echo $field['name']; ?>" ><?php echo wp_richedit_pre($field['value']); ?></textarea>
229
  </div>
230
  </div>
231
+ <?php //wp_editor('', $id); ?>
232
+
233
  <?php
234
 
235
  }
core/options_page.php CHANGED
@@ -129,6 +129,7 @@ class Options_page
129
 
130
  function admin_head()
131
  {
 
132
  // save
133
  if(isset($_POST['update_options']))
134
  {
@@ -157,8 +158,8 @@ class Options_page
157
  }
158
 
159
  $metabox_ids = $this->parent->get_input_metabox_ids(array('post_id' => 999999999), false);
160
- $style = isset($metabox_ids[0]) ? $this->parent->get_input_style($metabox_ids[0]) : '';
161
- echo '<style type="text/css" id="acf_style" >' .$style . '</style>';
162
 
163
  if(empty($metabox_ids))
164
  {
@@ -172,12 +173,20 @@ class Options_page
172
  $this->parent->fields[$field->name]->admin_head();
173
  }
174
 
175
- // add css + javascript
 
176
  echo '<link rel="stylesheet" type="text/css" href="'.$this->parent->dir.'/css/global.css" />';
177
  echo '<link rel="stylesheet" type="text/css" href="'.$this->parent->dir.'/css/input.css" />';
178
- echo '<script type="text/javascript" src="'.$this->parent->dir.'/js/input.js" ></script>';
179
- echo '<script type="text/javascript">acf.validation_message = "' . __("Validation Failed. One or more fields below are required.",'acf') . '";</script>';
180
-
 
 
 
 
 
 
 
181
 
182
  // get acf's
183
  $acfs = $this->parent->get_field_groups();
129
 
130
  function admin_head()
131
  {
132
+
133
  // save
134
  if(isset($_POST['update_options']))
135
  {
158
  }
159
 
160
  $metabox_ids = $this->parent->get_input_metabox_ids(array('post_id' => 999999999), false);
161
+ /*$style = isset($metabox_ids[0]) ? $this->parent->get_input_style($metabox_ids[0]) : '';
162
+ echo '<style type="text/css" id="acf_style" >' .$style . '</style>';*/
163
 
164
  if(empty($metabox_ids))
165
  {
173
  $this->parent->fields[$field->name]->admin_head();
174
  }
175
 
176
+
177
+ // Style
178
  echo '<link rel="stylesheet" type="text/css" href="'.$this->parent->dir.'/css/global.css" />';
179
  echo '<link rel="stylesheet" type="text/css" href="'.$this->parent->dir.'/css/input.css" />';
180
+
181
+ // Javascript
182
+ echo '<script type="text/javascript" src="'.$this->parent->dir.'/js/input-actions.js" ></script>';
183
+ echo '<script type="text/javascript">
184
+ acf.validation_message = "' . __("Validation Failed. One or more fields below are required.",'acf') . '";
185
+ acf.post_id = 999999999;
186
+ acf.editor_mode = "tinymce";
187
+ acf.admin_url = "' . admin_url() . '";
188
+ </script>';
189
+
190
 
191
  // get acf's
192
  $acfs = $this->parent->get_field_groups();
css/fields.css CHANGED
@@ -463,8 +463,10 @@ table#location_rules tr td.value div {
463
 
464
 
465
  /*---------------------------------------------------------------------------------------------
466
- Options
467
- ---------------------------------------------------------------------------------------------*/
 
 
468
 
469
  .postbox#acf_options .inside {
470
  margin: 0;
@@ -494,3 +496,44 @@ ul.checkbox_list li input {
494
  vertical-align: top;
495
  }
496
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
463
 
464
 
465
  /*---------------------------------------------------------------------------------------------
466
+ *
467
+ * Options
468
+ *
469
+ *---------------------------------------------------------------------------------------------*/
470
 
471
  .postbox#acf_options .inside {
472
  margin: 0;
496
  vertical-align: top;
497
  }
498
 
499
+
500
+ /*---------------------------------------------------------------------------------------------
501
+ *
502
+ * Flexible Content
503
+ *
504
+ *---------------------------------------------------------------------------------------------*/
505
+ table.acf_input table.acf_cf_meta {
506
+ width: 100%;
507
+ border: 0 none;
508
+ }
509
+
510
+ table.acf_input table.acf_cf_meta td {
511
+ border: 0 none;
512
+ width: 33%;
513
+ }
514
+
515
+ table.acf_input table.acf_cf_meta label {
516
+ width: 20%;
517
+ color: #333333;
518
+ font-weight: bold;
519
+ }
520
+
521
+ table.acf_input table.acf_cf_meta input {
522
+ width: 80%;
523
+ }
524
+
525
+ table.acf_input table.acf_cf_meta select {
526
+ width: 75%;
527
+ }
528
+
529
+ .acf_fc_reorder {
530
+ cursor: move;
531
+ }
532
+
533
+ .ui-state-highlight {
534
+ height: 40px;
535
+ }
536
+
537
+ .field_form table.acf_input .field_option_flexible_content > td {
538
+ background: #f9f9f9;
539
+ }
css/input.css CHANGED
@@ -109,12 +109,16 @@
109
  top: -2px !important;
110
  }
111
 
112
- .acf_wysiwyg .editor-toolbar {
113
  display: none;
114
- }
115
 
116
- .acf_wysiwyg #editorcontainer {
117
  background: #fff;
 
 
 
 
118
  }
119
 
120
 
@@ -530,7 +534,7 @@ ul.checkbox_list {
530
  border-right: 0 none;
531
  }
532
 
533
- .acf_flexible_content > .values > table > tbody > tr:hover a.remove_row {
534
  visibility: visible;
535
  }
536
 
@@ -678,3 +682,13 @@ ul.checkbox_list {
678
  border: #ccc dashed 1px;
679
  text-align: center;
680
  }
 
 
 
 
 
 
 
 
 
 
109
  top: -2px !important;
110
  }
111
 
112
+ /*.acf_wysiwyg .editor-toolbar {
113
  display: none;
114
+ }*/
115
 
116
+ .acf_wysiwyg .wp-editor-container {
117
  background: #fff;
118
+ border-color: #CCCCCC #CCCCCC #DFDFDF;
119
+ border-style: solid;
120
+ border-radius: 3px 3px 0 0;
121
+ border-width: 1px;
122
  }
123
 
124
 
534
  border-right: 0 none;
535
  }
536
 
537
+ .acf_flexible_content > .values > table > tbody > tr:hover > td > a.remove_row {
538
  visibility: visible;
539
  }
540
 
682
  border: #ccc dashed 1px;
683
  text-align: center;
684
  }
685
+
686
+ #acf_color_picker {
687
+ position: absolute;
688
+ top: 0;
689
+ left: 0;
690
+ display: none;
691
+ background: #fff;
692
+ border: #AAAAAA solid 1px;
693
+ border-radius: 4px;
694
+ }
js/fields.js CHANGED
@@ -11,7 +11,11 @@
11
  return $(this).length>0;
12
  };
13
 
14
-
 
 
 
 
15
 
16
  /*----------------------------------------------------------------------
17
  *
@@ -82,17 +86,10 @@
82
  * setup_fields
83
  *
84
  *---------------------------------------------------------------------*/
85
-
86
  function setup_fields()
87
  {
88
 
89
- function uniqid()
90
- {
91
- var newDate = new Date;
92
- return newDate.getTime();
93
- }
94
-
95
-
96
  // add edit button functionality
97
  $('#acf_fields a.acf_edit_field').live('click', function(){
98
 
@@ -412,6 +409,139 @@
412
  setup_rules();
413
 
414
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
415
 
416
 
417
  })(jQuery);
11
  return $(this).length>0;
12
  };
13
 
14
+ function uniqid()
15
+ {
16
+ var newDate = new Date;
17
+ return newDate.getTime();
18
+ }
19
 
20
  /*----------------------------------------------------------------------
21
  *
86
  * setup_fields
87
  *
88
  *---------------------------------------------------------------------*/
89
+
90
  function setup_fields()
91
  {
92
 
 
 
 
 
 
 
 
93
  // add edit button functionality
94
  $('#acf_fields a.acf_edit_field').live('click', function(){
95
 
409
  setup_rules();
410
 
411
  });
412
+
413
+
414
+ /*
415
+ * Flexible Content
416
+ *
417
+ * @description: extra javascript for the flexible content field
418
+ * @created: 3/03/2011
419
+ */
420
+
421
+ function uniqid()
422
+ {
423
+ var newDate = new Date;
424
+ return newDate.getTime();
425
+ }
426
+
427
+
428
+ /*----------------------------------------------------------------------
429
+ *
430
+ * Add Layout Option
431
+ *
432
+ *---------------------------------------------------------------------*/
433
+
434
+ $('#acf_fields .acf_fc_add').live('click', function(){
435
+
436
+ // vars
437
+ var tr = $(this).closest('tr.field_option_flexible_content');
438
+ var new_tr = $(this).closest('.field_form').find('tr.field_option_flexible_content:first').clone(false);
439
+
440
+ // remove sub fields
441
+ new_tr.find('.sub_field.field').remove();
442
+
443
+ // show add new message
444
+ new_tr.find('.no_fields_message').show();
445
+
446
+ // reset layout meta values
447
+ new_tr.find('.acf_cf_meta input[type="text"]').val('');
448
+ new_tr.find('.acf_cf_meta select').val('table');
449
+
450
+ // update id / names
451
+ var new_id = uniqid();
452
+
453
+ new_tr.find('[name]').each(function(){
454
+
455
+ var name = $(this).attr('name').replace('[layouts][0]','[layouts]['+new_id+']');
456
+ $(this).attr('name', name);
457
+ $(this).attr('id', name);
458
+
459
+ });
460
+
461
+ // add new tr
462
+ tr.after(new_tr);
463
+
464
+ // add drag / drop
465
+ new_tr.find('.fields').sortable({
466
+ handle: 'td.field_order'
467
+ });
468
+
469
+ return false;
470
+ });
471
+
472
+
473
+ /*----------------------------------------------------------------------
474
+ *
475
+ * Delete Layout Option
476
+ *
477
+ *---------------------------------------------------------------------*/
478
+
479
+ $('#acf_fields .acf_fc_delete').live('click', function(){
480
+
481
+ var tr = $(this).closest('tr.field_option_flexible_content');
482
+ var tr_count = tr.siblings('tr.field_option.field_option_flexible_content').length;
483
+
484
+ if(tr_count == 0)
485
+ {
486
+ alert('Flexible Content requires at least 1 layout');
487
+ return false;
488
+ }
489
+
490
+ tr.animate({'left' : '50px', 'opacity' : 0}, 250, function(){
491
+ tr.remove();
492
+ });
493
+
494
+ });
495
+
496
+
497
+ /*----------------------------------------------------------------------
498
+ *
499
+ * Sortable Layout Option
500
+ *
501
+ *---------------------------------------------------------------------*/
502
+
503
+ $('#acf_fields .acf_fc_reorder').live('mouseover', function(){
504
+
505
+ var table = $(this).closest('table.acf_field_form_table');
506
+
507
+ if(table.hasClass('sortable')) return false;
508
+
509
+ var fixHelper = function(e, ui) {
510
+ ui.children().each(function() {
511
+ $(this).width($(this).width());
512
+ });
513
+ return ui;
514
+ };
515
+
516
+ table.addClass('sortable').children('tbody').sortable({
517
+ items: ".field_option_flexible_content",
518
+ handle: 'a.acf_fc_reorder',
519
+ helper: fixHelper,
520
+ placeholder: "ui-state-highlight"
521
+ });
522
+
523
+ });
524
+
525
+
526
+ /*----------------------------------------------------------------------
527
+ *
528
+ * Label update name
529
+ *
530
+ *---------------------------------------------------------------------*/
531
+
532
+ $('#acf_fields .acf_fc_label input[type="text"]').live('blur', function(){
533
+
534
+ var label = $(this);
535
+ var name = $(this).parents('td').siblings('td.acf_fc_name').find('input[type="text"]');
536
+
537
+ if(name.val() == '')
538
+ {
539
+ var val = label.val().toLowerCase().split(' ').join('_').split('\'').join('');
540
+ name.val(val);
541
+ name.trigger('keyup');
542
+ }
543
+
544
+ });
545
 
546
 
547
  })(jQuery);
js/input-actions.js ADDED
@@ -0,0 +1,833 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Input Actions
3
+ *
4
+ * @description: javascript for fields functionality
5
+ * @author: Elliot Condon
6
+ * @since: 3.1.4
7
+ */
8
+
9
+ var acf = {
10
+ validation : false,
11
+ validation_message : "Validation Failed. One or more fields below are required.", // this is overriden by a script tag generated in admin_head for translation
12
+ editor_mode : 'visual'
13
+ };
14
+
15
+ (function($){
16
+
17
+
18
+ /*
19
+ * Exists
20
+ *
21
+ * @description: returns true / false
22
+ * @created: 1/03/2011
23
+ */
24
+
25
+ $.fn.exists = function()
26
+ {
27
+ return $(this).length>0;
28
+ };
29
+
30
+
31
+ /*
32
+ * Submit form
33
+ *
34
+ * @description: does validation, deletes all hidden metaboxes (otherwise, post data will be overriden by hidden inputs)
35
+ * @created: 1/03/2011
36
+ */
37
+
38
+ $('form#post').live("submit", function(){
39
+
40
+ // do validation
41
+ do_validation();
42
+
43
+ if(acf.valdation == false)
44
+ {
45
+ // reset validation for next time
46
+ acf.valdation = true;
47
+
48
+ // show message
49
+ $('#post').siblings('#message').remove();
50
+ $('#post').before('<div id="message" class="error"><p>' + acf.validation_message + '</p></div>');
51
+
52
+
53
+ // hide ajax stuff on submit button
54
+ $('#publish').removeClass('button-primary-disabled');
55
+ $('#ajax-loading').attr('style','');
56
+
57
+ return false;
58
+ }
59
+
60
+ $('.acf_postbox:hidden').remove();
61
+
62
+ // submit the form
63
+ return true;
64
+
65
+ });
66
+
67
+
68
+ /*
69
+ * do_validation
70
+ *
71
+ * @description: checks fields for required input
72
+ * @created: 1/03/2011
73
+ */
74
+
75
+ function do_validation(){
76
+
77
+ $('.acf_postbox:visible .field.required').each(function(){
78
+
79
+ var validation = true;
80
+
81
+ // text / textarea
82
+ if($(this).find('input[type="text"], input[type="hidden"], textarea').val() == "")
83
+ {
84
+ validation = false;
85
+ }
86
+
87
+ // select
88
+ if($(this).find('select').exists())
89
+ {
90
+ if($(this).find('select').val() == "null" || !$(this).find('select').val())
91
+ {
92
+ validation = false;
93
+ }
94
+ }
95
+
96
+ // checkbox
97
+ if($(this).find('input[type="checkbox"]:checked').exists())
98
+ {
99
+ validation = true;
100
+ }
101
+
102
+ // checkbox
103
+ if($(this).find('.acf_relationship').exists() && $(this).find('input[type="hidden"]').val() != "")
104
+ {
105
+ validation = true;
106
+ }
107
+
108
+ // repeater
109
+ if($(this).find('.repeater').exists())
110
+ {
111
+
112
+ if($(this).find('.repeater tr.row').exists())
113
+ {
114
+ validation = true;
115
+ }
116
+ else
117
+ {
118
+ validation = false;
119
+ }
120
+ console.log(validation);
121
+
122
+ }
123
+
124
+
125
+ // flexible content
126
+ if($(this).find('.acf_flexible_content').exists())
127
+ {
128
+ if($(this).find('.acf_flexible_content .values table').exists())
129
+ {
130
+ validation = true;
131
+ }
132
+ else
133
+ {
134
+ validation = false;
135
+ }
136
+
137
+ }
138
+
139
+ // set validation
140
+ if(!validation)
141
+ {
142
+ acf.valdation = false;
143
+ $(this).closest('.field').addClass('error');
144
+ }
145
+
146
+ });
147
+
148
+
149
+ }
150
+
151
+
152
+ /*
153
+ * Remove error class on focus
154
+ *
155
+ * @description:
156
+ * @created: 1/03/2011
157
+ */
158
+
159
+ // inputs / textareas
160
+ $('.acf_postbox .field.required input, .acf_postbox .field.required textarea, .acf_postbox .field.required select').live('focus', function(){
161
+ $(this).closest('.field').removeClass('error');
162
+ });
163
+
164
+ // checkbox
165
+ $('.acf_postbox .field.required input:checkbox').live('click', function(){
166
+ $(this).closest('.field').removeClass('error');
167
+ });
168
+
169
+ // wysiwyg
170
+ $('.acf_postbox .field.required .acf_wysiwyg').live('mousedown', function(){
171
+ $(this).closest('.field').removeClass('error');
172
+ });
173
+
174
+
175
+ /*
176
+ * Field: Color Picker
177
+ *
178
+ * @description:
179
+ * @created: 1/03/2011
180
+ */
181
+
182
+ var farbtastic;
183
+
184
+ $(document).ready(function(){
185
+
186
+ $('body').append('<div id="acf_color_picker" />');
187
+ if($.farbtastic)
188
+ {
189
+ farbtastic = $.farbtastic('#acf_color_picker');
190
+ }
191
+
192
+
193
+ });
194
+
195
+ $('#poststuff input.acf_color_picker').live('focus', function(){
196
+
197
+ var input = $(this);
198
+
199
+ $('#acf_color_picker').css({
200
+ left: input.offset().left,
201
+ top: input.offset().top - $('#acf_color_picker').height(),
202
+ display: 'block'
203
+ });
204
+
205
+ farbtastic.linkTo(this);
206
+
207
+ }).live('blur', function(){
208
+
209
+ $('#acf_color_picker').css({
210
+ display: 'none'
211
+ });
212
+
213
+ });
214
+
215
+
216
+ /*
217
+ * Field: File
218
+ *
219
+ * @description:
220
+ * @created: 1/03/2011
221
+ */
222
+
223
+ $('#poststuff .acf_file_uploader .no_file .button').live('click', function(){
224
+
225
+ // vars
226
+ var div = $(this).closest('.acf_file_uploader');
227
+
228
+ // set global var
229
+ window.acf_div = div;
230
+
231
+ // show the thickbox
232
+ tb_show('Add Image to field', acf.admin_url + 'media-upload.php?post_id=' + acf.post_id + '&type=file&acf_type=file&TB_iframe=1');
233
+
234
+ return false;
235
+ });
236
+
237
+ $('#poststuff .acf_file_uploader .file .button').live('click', function(){
238
+
239
+ // vars
240
+ var div = $(this).closest('.acf_file_uploader');
241
+
242
+ div.removeClass('active').find('input.value').val('');
243
+
244
+ return false;
245
+
246
+ });
247
+
248
+
249
+ /*
250
+ * Field: Image
251
+ *
252
+ * @description:
253
+ * @created: 1/03/2011
254
+ */
255
+
256
+ $('#poststuff .acf_image_uploader .button').live('click', function(){
257
+
258
+ // vars
259
+ var div = $(this).closest('.acf_image_uploader');
260
+ var preview_size = div.attr('data-preview_size');
261
+
262
+ // set global var
263
+ window.acf_div = div;
264
+
265
+ // show the thickbox
266
+ tb_show('Add Image to field', acf.admin_url + 'media-upload.php?post_id=' + acf.post_id + '&type=image&acf_type=image&acf_preview_size=' + preview_size + 'TB_iframe=1');
267
+
268
+ return false;
269
+ });
270
+
271
+ $('#poststuff .acf_image_uploader .remove_image').live('click', function(){
272
+
273
+ // vars
274
+ var div = $(this).closest('.acf_image_uploader');
275
+
276
+ div.removeClass('active').find('input.value').val('');
277
+
278
+ return false;
279
+
280
+ });
281
+
282
+
283
+ /*
284
+ * Field: Relationship
285
+ *
286
+ * @description:
287
+ * @created: 3/03/2011
288
+ */
289
+
290
+ // on mouse over, make list sortable
291
+ $('.acf_relationship').live('mouseenter', function(){
292
+
293
+ if($(this).attr('data-is_setup')) return false;
294
+
295
+ $(this).attr('data-is_setup','true');
296
+
297
+ $(this).find('.relationship_right .relationship_list').sortable({
298
+ axis: "y", // limit the dragging to up/down only
299
+ start: function(event, ui)
300
+ {
301
+ ui.item.addClass('sortable_active');
302
+ },
303
+ stop: function(event, ui)
304
+ {
305
+ ui.item.removeClass('sortable_active');
306
+ ui.item.closest('.acf_relationship').update_acf_relationship_value();
307
+ }
308
+ });
309
+
310
+ });
311
+
312
+ // updates the input value of a relationship field
313
+ $.fn.update_acf_relationship_value = function(){
314
+
315
+ // vars
316
+ var div = $(this);
317
+ var value = "";
318
+
319
+ // add id's to array
320
+ div.find('.relationship_right .relationship_list a:not(.hide)').each(function(){
321
+ value += $(this).attr('data-post_id') + ",";
322
+ });
323
+
324
+ // remove last ","
325
+ value = value.slice(0, -1);
326
+
327
+ // set value
328
+ div.children('input').val(value);
329
+
330
+ };
331
+
332
+ // add from left to right
333
+ $('#poststuff .acf_relationship .relationship_left .relationship_list a').live('click', function(){
334
+
335
+ // vars
336
+ var id = $(this).attr('data-post_id');
337
+ var div = $(this).closest('.acf_relationship');
338
+ var max = parseInt(div.attr('data-max')); if(max == -1){ max = 9999; }
339
+ var right = div.find('.relationship_right .relationship_list');
340
+
341
+ // max posts
342
+ if(right.find('a:not(.hide)').length >= max)
343
+ {
344
+ alert('Maximum values reached ( ' + max + ' values )');
345
+ return false;
346
+ }
347
+
348
+ // hide / show
349
+ $(this).addClass('hide');
350
+ right.find('a[data-post_id="' + id + '"]').removeClass('hide').appendTo(right);
351
+
352
+ // update input value
353
+ div.update_acf_relationship_value();
354
+
355
+ // validation
356
+ div.closest('.field').removeClass('error');
357
+
358
+ return false;
359
+
360
+ });
361
+
362
+ // remove from right to left
363
+ $('#poststuff .acf_relationship .relationship_right .relationship_list a').live('click', function(){
364
+
365
+ // vars
366
+ var id = $(this).attr('data-post_id');
367
+ var div = $(this).closest('.acf_relationship');
368
+ var left = div.find('.relationship_left .relationship_list');
369
+
370
+ // hide / show
371
+ $(this).addClass('hide');
372
+ left.find('a[data-post_id="' + id + '"]').removeClass('hide');
373
+
374
+ // update input value
375
+ div.update_acf_relationship_value();
376
+
377
+ return false;
378
+
379
+ });
380
+
381
+
382
+ // search left
383
+ $.expr[':'].Contains = function(a,i,m){
384
+ return (a.textContent || a.innerText || "").toUpperCase().indexOf(m[3].toUpperCase())>=0;
385
+ };
386
+ $('#poststuff .acf_relationship input.relationship_search').live('change', function()
387
+ {
388
+ // vars
389
+ var filter = $(this).val();
390
+ var div = $(this).closest('.acf_relationship');
391
+ var left = div.find('.relationship_left .relationship_list');
392
+
393
+ if(filter)
394
+ {
395
+ left.find("a:not(:Contains(" + filter + "))").addClass('filter_hide');
396
+ left.find("a:Contains(" + filter + "):not(.hide)").removeClass('filter_hide');
397
+ }
398
+ else
399
+ {
400
+ left.find("a:not(.hide)").removeClass('filter_hide');
401
+ }
402
+
403
+ return false;
404
+
405
+ })
406
+ .live('keyup', function(){
407
+ $(this).change();
408
+ })
409
+ .live('focus', function(){
410
+ $(this).siblings('label').hide();
411
+ })
412
+ .live('blur', function(){
413
+ if($(this).val() == "")
414
+ {
415
+ $(this).siblings('label').show();
416
+ }
417
+ });
418
+
419
+
420
+
421
+ /*
422
+ * Field: WYSIWYG
423
+ *
424
+ * @description:
425
+ * @created: 3/03/2011
426
+ */
427
+
428
+ // store wysiwyg buttons
429
+ var acf_wysiwyg_buttons = {};
430
+
431
+ // destroy wysiwyg
432
+ $.fn.acf_deactivate_wysiwyg = function(){
433
+
434
+ $(this).find('.acf_wysiwyg textarea').each(function(){
435
+
436
+ tinyMCE.execCommand("mceRemoveControl", false, $(this).attr('id'));
437
+
438
+ });
439
+
440
+ };
441
+
442
+ // create wysiwyg
443
+ $.fn.acf_activate_wysiwyg = function(){
444
+
445
+
446
+ // add tinymce to all wysiwyg fields
447
+ $(this).find('.acf_wysiwyg textarea').each(function(){
448
+
449
+ if(tinyMCE != undefined && tinyMCE.settings != undefined)
450
+ {
451
+ // reset buttons
452
+ tinyMCE.settings.theme_advanced_buttons1 = acf_wysiwyg_buttons.theme_advanced_buttons1;
453
+ tinyMCE.settings.theme_advanced_buttons2 = acf_wysiwyg_buttons.theme_advanced_buttons2;
454
+
455
+ var toolbar = $(this).closest('.acf_wysiwyg').attr('data-toolbar');
456
+
457
+ if(toolbar == 'basic')
458
+ {
459
+ tinyMCE.settings.theme_advanced_buttons1 = "bold,italic,formatselect,|,link,unlink,|,bullist,numlist,|,undo,redo";
460
+ tinyMCE.settings.theme_advanced_buttons2 = "";
461
+ }
462
+ else
463
+ {
464
+ // add images + code buttons
465
+ tinyMCE.settings.theme_advanced_buttons2 += ",code";
466
+ }
467
+ }
468
+
469
+ //tinyMCE.init(tinyMCEPreInit.mceInit);
470
+ tinyMCE.execCommand('mceAddControl', false, $(this).attr('id'));
471
+
472
+ });
473
+
474
+ };
475
+
476
+
477
+ $(window).load(function(){
478
+
479
+ if(typeof(tinyMCE) != "object")
480
+ {
481
+ return false;
482
+ }
483
+
484
+ // store variables
485
+ if(tinyMCE != undefined && tinyMCE.settings != undefined)
486
+ {
487
+ acf_wysiwyg_buttons.theme_advanced_buttons1 = tinyMCE.settings.theme_advanced_buttons1;
488
+ acf_wysiwyg_buttons.theme_advanced_buttons2 = tinyMCE.settings.theme_advanced_buttons2;
489
+ }
490
+
491
+ $('#poststuff').acf_activate_wysiwyg();
492
+
493
+ // if editor_mode == html, toggle the html mode button on the default editor
494
+ if(acf.editor_mode && acf.editor_mode == "html")
495
+ {
496
+ // click html tab after the wysiwyg has been initialed to prevent dual editor buttons
497
+ setTimeout(function(){
498
+ $('#poststuff #postdivrich #content-html').trigger('click');
499
+ }, 1);
500
+
501
+ }
502
+
503
+ });
504
+
505
+ // Sortable: Start
506
+ $('#poststuff .repeater > table > tbody, #poststuff .acf_flexible_content > .values').live( "sortstart", function(event, ui) {
507
+
508
+ $(ui.item).find('.acf_wysiwyg textarea').each(function(){
509
+ tinyMCE.execCommand("mceRemoveControl", false, $(this).attr('id'));
510
+ });
511
+
512
+ });
513
+
514
+ // Sortable: End
515
+ $('#poststuff .repeater > table > tbody, #poststuff .acf_flexible_content > .values').live( "sortstop", function(event, ui) {
516
+
517
+ $(ui.item).find('.acf_wysiwyg textarea').each(function(){
518
+ tinyMCE.execCommand("mceAddControl", false, $(this).attr('id'));
519
+ });
520
+
521
+ });
522
+
523
+
524
+ /*
525
+ * Field: Repeater
526
+ *
527
+ * @description:
528
+ * @created: 3/03/2011
529
+ */
530
+
531
+ // create a unique id
532
+ function uniqid()
533
+ {
534
+ var newDate = new Date;
535
+ return newDate.getTime();
536
+ }
537
+
538
+ // update order numbers
539
+ function update_r_order_numbers(div)
540
+ {
541
+ div.children('table').children('tbody').children('tr.row').each(function(i){
542
+ $(this).children('td.order').html(i+1);
543
+ });
544
+
545
+ };
546
+
547
+
548
+ // make sortable
549
+ function make_r_sortable(div){
550
+
551
+ var fixHelper = function(e, ui) {
552
+ ui.children().each(function() {
553
+ $(this).width($(this).width());
554
+ });
555
+ return ui;
556
+ };
557
+
558
+ div.children('table').children('tbody').unbind('sortable').sortable({
559
+ update: function(event, ui){
560
+ update_r_order_numbers(div);
561
+ },
562
+ handle: 'td.order',
563
+ helper: fixHelper
564
+ });
565
+ };
566
+
567
+
568
+ $(document).ready(function(){
569
+
570
+ $('#poststuff .repeater').each(function(){
571
+
572
+ var div = $(this);
573
+ var row_limit = parseInt(div.attr('data-row_limit'));
574
+ var row_count = div.children('table').children('tbody').children('tr.row').length;
575
+
576
+ // has limit been reached?
577
+ if(row_count >= row_limit) div.find('#r_add_row').attr('disabled','true');
578
+
579
+ // sortable
580
+ if(row_limit > 1){
581
+ make_r_sortable(div);
582
+ }
583
+
584
+ });
585
+
586
+ });
587
+
588
+ // add field
589
+ $('#poststuff .repeater #r_add_row').live('click', function(){
590
+
591
+ var div = $(this).closest('.repeater');
592
+ var row_limit = parseInt(div.attr('data-row_limit'));
593
+ var row_count = div.children('table').children('tbody').children('tr.row').length;
594
+
595
+ // row limit
596
+ if(row_count >= row_limit)
597
+ {
598
+ // reached row limit!
599
+ div.find('#r_add_row').attr('disabled','true');
600
+ return false;
601
+ }
602
+
603
+ // deactivate any wysiwygs
604
+ div.children('table').children('tbody').children('tr.row_clone').acf_deactivate_wysiwyg();
605
+
606
+ // create and add the new field
607
+ var new_field = div.children('table').children('tbody').children('tr.row_clone').clone(false);
608
+ new_field.attr('class', 'row');
609
+
610
+ // update names
611
+ var new_id = uniqid();
612
+ new_field.find('[name]').each(function(){
613
+
614
+ var name = $(this).attr('name').replace('[999]','[' + new_id + ']');
615
+ $(this).attr('name', name);
616
+ $(this).attr('id', name);
617
+
618
+ });
619
+
620
+ // add row
621
+ div.children('table').children('tbody').append(new_field);
622
+
623
+ // activate wysiwyg
624
+ new_field.acf_activate_wysiwyg();
625
+
626
+ update_r_order_numbers(div);
627
+
628
+ // there is now 1 more row
629
+ row_count ++;
630
+
631
+ // disable the add field button if row limit is reached
632
+ if((row_count+1) >= row_limit)
633
+ {
634
+ div.find('#r_add_row').attr('disabled','true');
635
+ }
636
+
637
+ // validation
638
+ div.closest('.field').removeClass('error');
639
+
640
+ return false;
641
+
642
+ });
643
+
644
+
645
+ // remove field
646
+ $('#poststuff .repeater a#r_remove_row').live('click', function(){
647
+
648
+ var div = $(this).closest('.repeater');
649
+ var tr = $(this).closest('tr');
650
+
651
+ tr.animate({'left' : '50px', 'opacity' : 0}, 250,function(){
652
+ tr.remove();
653
+ update_r_order_numbers(div);
654
+ });
655
+
656
+ div.find('#r_add_row').removeAttr('disabled');
657
+
658
+ return false;
659
+
660
+ });
661
+
662
+
663
+ /*
664
+ * Field: Flexible Content
665
+ *
666
+ * @description:
667
+ * @created: 3/03/2011
668
+ */
669
+
670
+ // update order numbers
671
+ function update_fc_order_numbers(div)
672
+ {
673
+ div.children('.values').children('table').each(function(i){
674
+ $(this).children('tbody').children('tr').children('td.order').html(i+1);
675
+ });
676
+
677
+ }
678
+
679
+
680
+ // make sortable
681
+ function make_fc_sortable(div){
682
+
683
+ div.children('.values').unbind('sortable').sortable({
684
+ update: function(event, ui){
685
+ update_fc_order_numbers(div);
686
+ },
687
+ handle: 'td.order'
688
+ });
689
+ }
690
+
691
+
692
+ // add row
693
+ $('#poststuff .acf_flexible_content #fc_add_row').live('click', function(){
694
+
695
+ if($(this).hasClass('active'))
696
+ {
697
+ $(this).removeClass('active');
698
+ $(this).siblings('.acf_popup').animate({ opacity : 0, bottom : '35px' }, 250);
699
+ }
700
+ else
701
+ {
702
+ $(this).addClass('active');
703
+ $(this).siblings('.acf_popup').css({display : 'block', opacity : 0, bottom : '15px'}).animate({ opacity : 1, bottom : '25px' }, 250);
704
+ }
705
+ });
706
+
707
+
708
+ // remove row
709
+ $('#poststuff .acf_flexible_content #fc_remove_row').live('click', function(){
710
+
711
+ var div = $(this).closest('.acf_flexible_content');
712
+ var table = $(this).closest('table');
713
+ var temp = $('<div style="height:' + table.height() + 'px"></div>');
714
+
715
+ table.animate({'left' : '50px', 'opacity' : 0}, 250, function(){
716
+ table.before(temp).remove();
717
+
718
+ temp.animate({'height' : 0 }, 250, function(){
719
+ temp.remove();
720
+ });
721
+
722
+ update_fc_order_numbers(div);
723
+
724
+ if(!div.children('.values').children('table').exists())
725
+ {
726
+ div.children('.no_value_message').show();
727
+ }
728
+
729
+ });
730
+
731
+ return false;
732
+
733
+ });
734
+
735
+
736
+ // add layout
737
+ $('#poststuff .acf_flexible_content .table_footer .acf_popup ul li a').live('click', function(){
738
+
739
+ // vars
740
+ var layout = $(this).attr('data-layout');
741
+ var div = $(this).closest('.acf_flexible_content');
742
+
743
+ // deactivate any wysiwygs
744
+ div.children('.clones').acf_deactivate_wysiwyg();
745
+
746
+ // create new field
747
+ var new_field = div.children('.clones').children('table[data-layout="' + layout + '"]').clone(false);
748
+
749
+ // update names
750
+ var new_id = uniqid();
751
+ new_field.find('[name]').each(function(){
752
+
753
+ var name = $(this).attr('name').replace('[999]','[' + new_id + ']');
754
+ $(this).attr('name', name);
755
+ $(this).attr('id', name);
756
+
757
+ });
758
+
759
+ // hide no values message
760
+ div.children('.no_value_message').hide();
761
+
762
+ // add row
763
+ div.children('.values').append(new_field);
764
+
765
+ // activate wysiwyg
766
+ new_field.acf_activate_wysiwyg();
767
+
768
+ update_fc_order_numbers(div);
769
+
770
+ // hide acf popup
771
+ $(this).closest('.table_footer').find('#fc_add_row').removeClass('active');
772
+ $(this).closest('.acf_popup').hide();
773
+
774
+ // validation
775
+ div.closest('.field').removeClass('error');
776
+
777
+ return false;
778
+
779
+ });
780
+
781
+
782
+ $(document).ready(function(){
783
+
784
+ $('#poststuff .acf_flexible_content').each(function(){
785
+
786
+ // sortable
787
+ make_fc_sortable($(this));
788
+ });
789
+
790
+ });
791
+
792
+
793
+ /*
794
+ * Field: Datepicker
795
+ *
796
+ * @description:
797
+ * @created: 4/03/2011
798
+ */
799
+
800
+ $('#poststuff input.acf_datepicker').live('focus', function(){
801
+
802
+ var input = $(this);
803
+
804
+ if(!input.hasClass('active'))
805
+ {
806
+
807
+ // vars
808
+ var format = input.attr('data-date_format') ? input.attr('data-date_format') : 'dd/mm/yy';
809
+
810
+ // add date picker and refocus
811
+ input.addClass('active').datepicker({
812
+ dateFormat: format
813
+ })
814
+
815
+ // set a timeout to re focus the input (after it has the datepicker!)
816
+ setTimeout(function(){
817
+ input.trigger('blur').trigger('focus');
818
+ }, 1);
819
+
820
+ // wrap the datepicker (only if it hasn't already been wrapped)
821
+ if($('body > #ui-datepicker-div').length > 0)
822
+ {
823
+ $('#ui-datepicker-div').wrap('<div class="ui-acf" />');
824
+ }
825
+
826
+ }
827
+
828
+ });
829
+
830
+
831
+
832
+
833
+ })(jQuery);
js/input-ajax.js ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * Document Ready
27
+ *
28
+ * @description: adds ajax data
29
+ * @created: 1/03/2011
30
+ */
31
+
32
+ $(document).ready(function(){
33
+
34
+ // show metaboxes for this post
35
+ acf.data = {
36
+ action : 'get_input_metabox_ids',
37
+ post_id : acf.post_id,
38
+ page_template : false,
39
+ page_parent : false,
40
+ page_type : false,
41
+ page : acf.post_id,
42
+ post : acf.post_id,
43
+ post_category : false,
44
+ post_format : false,
45
+ taxonomy : false
46
+ };
47
+
48
+
49
+ // add classes
50
+ $('#poststuff .postbox[id*="acf_"]').addClass('acf_postbox');
51
+ $('#adv-settings label[for*="acf_"]').addClass('acf_hide_label');
52
+
53
+ // hide acf stuff
54
+ $('#poststuff .acf_postbox').hide();
55
+ $('#adv-settings .acf_hide_label').hide();
56
+
57
+ // loop through acf metaboxes
58
+ $('#poststuff .postbox.acf_postbox').each(function(){
59
+
60
+ // vars
61
+ var options = $(this).find('.inside > .options');
62
+ var show = options.attr('data-show');
63
+ var layout = options.attr('data-layout');
64
+ var id = $(this).attr('id').replace('acf_', '');
65
+
66
+ // layout
67
+ $(this).addClass('acf_postbox').addClass(layout);
68
+
69
+ // show / hide
70
+ if(show == 'true')
71
+ {
72
+ $(this).show();
73
+ $('#adv-settings .acf_hide_label[for="acf_' + id + '-hide"]').show();
74
+ }
75
+
76
+ });
77
+
78
+ });
79
+
80
+
81
+ /*
82
+ * update_fields
83
+ *
84
+ * @description: finds the new id's for metaboxes and show's hides metaboxes
85
+ * @created: 1/03/2011
86
+ */
87
+
88
+ function update_fields()
89
+ {
90
+ $.ajax({
91
+ url: ajaxurl,
92
+ data: acf.data,
93
+ type: 'post',
94
+ dataType: 'json',
95
+ success: function(result){
96
+
97
+ // hide all metaboxes
98
+ $('#poststuff .acf_postbox').hide();
99
+ $('#adv-settings .acf_hide_label').hide();
100
+
101
+ // show the new postboxes
102
+ $.each(result, function(k, v) {
103
+ $('#poststuff #acf_' + v).show();
104
+ $('#adv-settings .acf_hide_label[for="acf_' + v + '-hide"]').show();
105
+ });
106
+
107
+ // load style
108
+ $.ajax({
109
+ url: ajaxurl,
110
+ data: {
111
+ action : 'get_input_style',
112
+ acf_id : result[0]
113
+ },
114
+ type: 'post',
115
+ dataType: 'html',
116
+ success: function(result){
117
+
118
+ $('#acf_style').html(result);
119
+
120
+ }
121
+ });
122
+
123
+ }
124
+ });
125
+ }
126
+
127
+
128
+ /*
129
+ * update_fields (Live change events)
130
+ *
131
+ * @description: call the update_fields function on live events
132
+ * @created: 1/03/2011
133
+ */
134
+
135
+ $('#page_template').live('change', function(){
136
+
137
+ acf.data.page_template = $(this).val();
138
+ update_fields();
139
+
140
+ });
141
+
142
+ $('#parent_id').live('change', function(){
143
+
144
+ var page_parent = $(this).val();
145
+
146
+ if($(this).val() != "")
147
+ {
148
+ acf.data.page_type = 'child';
149
+ }
150
+ else
151
+ {
152
+ acf.data.page_type = 'parent';
153
+ }
154
+
155
+ update_fields();
156
+
157
+ });
158
+
159
+ $('#categorychecklist input[type="checkbox"]').live('change', function(){
160
+
161
+ acf.data.post_category = ['0'];
162
+
163
+ $('#categorychecklist :checked').each(function(){
164
+ acf.data.post_category.push($(this).val())
165
+ });
166
+
167
+ //console.log(data.post_category);
168
+
169
+ update_fields();
170
+
171
+ });
172
+
173
+
174
+ $('#post-formats-select input[type="radio"]').live('change', function(){
175
+
176
+ acf.data.post_format = $(this).val();
177
+ update_fields();
178
+
179
+ });
180
+
181
+ // taxonomy
182
+ $('div[id*="taxonomy-"] input[type="checkbox"]').live('change', function(){
183
+
184
+ acf.data.taxonomy = ['0'];
185
+
186
+ $(this).closest('ul').find('input[type="checkbox"]:checked').each(function(){
187
+ acf.data.taxonomy.push($(this).val())
188
+ });
189
+
190
+ update_fields();
191
+
192
+ });
193
+
194
+
195
+ })(jQuery);
js/input.js DELETED
@@ -1,326 +0,0 @@
1
- /*----------------------------------------------------------------------
2
- *
3
- * vars
4
- *
5
- *---------------------------------------------------------------------*/
6
-
7
- var acf = {
8
- validation : false,
9
- validation_message : "Validation error", // this is overriden by a script tag generated in admin_head for translation
10
- data : {
11
- action : 'get_input_metabox_ids',
12
- post_id : false,
13
- page_template : false,
14
- page_parent : false,
15
- page_type : false,
16
- page : false,
17
- post : false,
18
- post_category : false,
19
- post_format : false
20
- }
21
- };
22
-
23
-
24
- (function($){
25
-
26
-
27
- /*----------------------------------------------------------------------
28
- *
29
- * Exists
30
- *
31
- *---------------------------------------------------------------------*/
32
-
33
- $.fn.exists = function()
34
- {
35
- return $(this).length>0;
36
- };
37
-
38
-
39
- /*----------------------------------------------------------------------
40
- *
41
- * Document Ready
42
- *
43
- *---------------------------------------------------------------------*/
44
-
45
- $(document).ready(function(){
46
-
47
- // vars
48
- var post_id = $('input#post_ID').val();
49
-
50
- // show metaboxes for this post
51
- acf.data = {
52
- action : 'get_input_metabox_ids',
53
- post_id : post_id,
54
- page_template : false,
55
- page_parent : false,
56
- page_type : false,
57
- page : post_id,
58
- post : post_id,
59
- post_category : false,
60
- post_format : false,
61
- taxonomy : false
62
- };
63
-
64
- // update fields from ajax response
65
- function update_fields()
66
- {
67
- $.ajax({
68
- url: ajaxurl,
69
- data: acf.data,
70
- type: 'post',
71
- dataType: 'json',
72
- success: function(result){
73
-
74
- // hide all metaboxes
75
- $('#poststuff .acf_postbox').hide();
76
- $('#adv-settings .acf_hide_label').hide();
77
-
78
- // show the new postboxes
79
- $.each(result, function(k, v) {
80
- $('#poststuff #acf_' + v).show();
81
- $('#adv-settings .acf_hide_label[for="acf_' + v + '-hide"]').show();
82
- });
83
-
84
- // load style
85
- $.ajax({
86
- url: ajaxurl,
87
- data: {
88
- action : 'get_input_style',
89
- acf_id : result[0]
90
- },
91
- type: 'post',
92
- dataType: 'html',
93
- success: function(result){
94
-
95
- $('#acf_style').html(result);
96
-
97
- }
98
- });
99
-
100
- }
101
- });
102
- }
103
- //update_fields();
104
-
105
- // hide acf stuff
106
- /*$('#poststuff .acf_postbox').hide();
107
- $('#adv-settings .acf_hide_label').hide();
108
-
109
- // show acf?
110
- $('#poststuff .acf_postbox').each(function(){
111
-
112
- // vars
113
- var show = $(this).children('.inside').children('.options').attr('data-show');
114
- var id = $(this).attr('id').replace('acf_', '');
115
-
116
- if(show == 'true')
117
- {
118
- $(this).show();
119
- $('#adv-settings .acf_hide_label[for="acf_' + id + '-hide"]').show();
120
- }
121
-
122
- });*/
123
-
124
-
125
-
126
-
127
- /*--------------------------------------------------------------------------------------
128
- *
129
- * Change
130
- *
131
- *-------------------------------------------------------------------------------------*/
132
-
133
- $('#page_template').change(function(){
134
-
135
- acf.data.page_template = $(this).val();
136
- update_fields();
137
-
138
- });
139
-
140
- $('#parent_id').change(function(){
141
-
142
- var page_parent = $(this).val();
143
-
144
- if($(this).val() != "")
145
- {
146
- acf.data.page_type = 'child';
147
- }
148
- else
149
- {
150
- acf.data.page_type = 'parent';
151
- }
152
-
153
- update_fields();
154
-
155
- });
156
-
157
- $('#categorychecklist input[type="checkbox"]').change(function(){
158
-
159
- acf.data.post_category = ['0'];
160
-
161
- $('#categorychecklist :checked').each(function(){
162
- acf.data.post_category.push($(this).val())
163
- });
164
-
165
- //console.log(data.post_category);
166
-
167
- update_fields();
168
-
169
- });
170
-
171
-
172
- $('#post-formats-select input[type="radio"]').change(function(){
173
-
174
- acf.data.post_format = $(this).val();
175
- update_fields();
176
-
177
- });
178
-
179
- // taxonomy
180
- $('div[id*="taxonomy-"] input[type="checkbox"]').change(function(){
181
-
182
- acf.data.taxonomy = ['0'];
183
-
184
- $(this).closest('ul').find('input[type="checkbox"]:checked').each(function(){
185
- acf.data.taxonomy.push($(this).val())
186
- });
187
-
188
- update_fields();
189
-
190
- });
191
-
192
- });
193
-
194
-
195
- /*----------------------------------------------------------------------
196
- *
197
- * Save
198
- *
199
- *---------------------------------------------------------------------*/
200
-
201
- // on save, delete all unused metaboxes
202
- $('form#post').live("submit", function(){
203
-
204
- // do validation
205
- do_validation()
206
-
207
- if(acf.valdation == false)
208
- {
209
- // reset validation for next time
210
- acf.valdation = true;
211
-
212
- // show message
213
- $('#post').siblings('#message').remove();
214
- $('#post').before('<div id="message" class="error"><p>' + acf.validation_message + '</p></div>');
215
-
216
-
217
- // hide ajax stuff on submit button
218
- $('#publish').removeClass('button-primary-disabled');
219
- $('#ajax-loading').attr('style','');
220
-
221
- return false;
222
- }
223
-
224
- $('#post-body .acf_postbox:hidden').remove();
225
-
226
-
227
- return true;
228
- });
229
-
230
-
231
- /*----------------------------------------------------------------------
232
- *
233
- * Validation
234
- *
235
- *---------------------------------------------------------------------*/
236
-
237
- function do_validation(){
238
-
239
- $('#post-body .acf_postbox:visible .field.required').each(function(){
240
-
241
- var validation = true;
242
-
243
- // text / textarea
244
- if($(this).find('input[type="text"], input[type="hidden"], textarea').val() == "")
245
- {
246
- validation = false;
247
- }
248
-
249
- // select
250
- if($(this).find('select').exists())
251
- {
252
- if($(this).find('select').val() == "null" || !$(this).find('select').val())
253
- {
254
- validation = false;
255
- }
256
- }
257
-
258
- // checkbox
259
- if($(this).find('input[type="checkbox"]:checked').exists())
260
- {
261
- validation = true;
262
- }
263
-
264
- // checkbox
265
- if($(this).find('.acf_relationship').exists() && $(this).find('input[type="hidden"]').val() != "")
266
- {
267
- validation = true;
268
- }
269
-
270
- // repeater
271
- if($(this).find('.repeater').exists())
272
- {
273
- if($(this).find('.repeater tr.row').exists())
274
- {
275
- validation = true;
276
- }
277
- else
278
- {
279
- validation = false;
280
- }
281
-
282
- }
283
-
284
-
285
-
286
-
287
- // set validation
288
- if(!validation)
289
- {
290
- acf.valdation = false;
291
- $(this).closest('.field').addClass('error');
292
- }
293
-
294
- });
295
-
296
-
297
- }
298
-
299
-
300
- /*----------------------------------------------------------------------
301
- *
302
- * Add simple events to remove error class on field
303
- *
304
- *---------------------------------------------------------------------*/
305
-
306
- // inputs / textareas
307
- $('#post-body .acf_postbox .field.required input, #post-body .acf_postbox .field.required textarea, .acf_postbox .field.required select').live('focus', function(){
308
- $(this).closest('.field').removeClass('error');
309
- });
310
-
311
- // checkbox
312
- $('#post-body .acf_postbox .field.required input:checkbox').live('click', function(){
313
- $(this).closest('.field').removeClass('error');
314
- });
315
-
316
- // wysiwyg
317
- $('#post-body .acf_postbox .field.required .acf_wysiwyg').live('mousedown', function(){
318
- $(this).closest('.field').removeClass('error');
319
- });
320
-
321
-
322
-
323
-
324
-
325
-
326
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -87,7 +87,13 @@ http://www.advancedcustomfields.com/support/
87
 
88
  == Changelog ==
89
 
90
- = 3.1.2 =
 
 
 
 
 
 
91
  * Bug Fix: Options page fields were rendered invisible in v3.1.2 (now fixed)
92
  * Updated POT file with new texts
93
 
87
 
88
  == Changelog ==
89
 
90
+ = 3.1.4 =
91
+ * New Feature: Front end form (Please read documentation on website for usage)
92
+ * Performance: compiled all field script / style into 1 .js file
93
+ * Bug Fix: Editor now remembers mode (Visual / HTML) without causing errors when loading in HTML mode
94
+ * Improvement: Added draft / private labels to post objects in relationship, post object and page link fields
95
+
96
+ = 3.1.3 =
97
  * Bug Fix: Options page fields were rendered invisible in v3.1.2 (now fixed)
98
  * Updated POT file with new texts
99