diff --git a/acf.php b/acf.php index 990d0d4..c03d557 100644 --- a/acf.php +++ b/acf.php @@ -3,7 +3,7 @@ Plugin Name: Advanced Custom Fields Pro Plugin URI: http://www.advancedcustomfields.com/ Description: Customise WordPress with powerful, professional and intuitive fields -Version: 5.3.5 +Version: 5.3.6.1 Author: elliot condon Author URI: http://www.elliotcondon.com/ Copyright: Elliot Condon @@ -17,9 +17,6 @@ if( ! class_exists('acf') ) : class acf { - // vars - var $settings; - /* * __construct @@ -61,7 +58,7 @@ class acf { // basic 'name' => __('Advanced Custom Fields', 'acf'), - 'version' => '5.3.5', + 'version' => '5.3.6.1', // urls 'basename' => plugin_basename( __FILE__ ), @@ -82,9 +79,7 @@ class acf { 'uploader' => 'wp', 'autoload' => false, 'l10n' => true, - 'l10n_textdomain' => '', - 'l10n_field' => array('label', 'instructions'), - 'l10n_field_group' => array('title'), + 'l10n_textdomain' => '' ); @@ -103,9 +98,11 @@ class acf { acf_include('core/ajax.php'); acf_include('core/field.php'); acf_include('core/input.php'); + acf_include('core/validation.php'); acf_include('core/json.php'); acf_include('core/local.php'); acf_include('core/location.php'); + acf_include('core/loop.php'); acf_include('core/media.php'); acf_include('core/revisions.php'); acf_include('core/compatibility.php'); diff --git a/admin/field-group.php b/admin/field-group.php index e2d04ca..1b3ef7a 100644 --- a/admin/field-group.php +++ b/admin/field-group.php @@ -638,14 +638,18 @@ if( typeof acf !== 'undefined' ) { */ case "post_type" : + + // get post types + $choices = acf_get_pretty_post_types(); - // all post types except attachment - $exclude = array('attachment'); - $choices = acf_get_post_types( $exclude ); - $choices = acf_get_pretty_post_types( $choices ); - + + // remove attachments + unset( $choices['attachment'] ); + + + // end break; - + case "post" : @@ -802,9 +806,10 @@ if( typeof acf !== 'undefined' ) { case "page_template" : $choices = array( - 'default' => __("Default Template",'acf'), + 'default' => apply_filters( 'default_page_template_title', __('Default Template', 'acf') ), ); + $templates = get_page_templates(); foreach( $templates as $k => $v ) { @@ -900,8 +905,17 @@ if( typeof acf !== 'undefined' ) { case "comment" : - $choices = array('all' => __('All', 'acf')); - + // vars + $choices = array( + 'all' => __('All', 'acf') + ); + + + // append post types + $choices = array_merge( $choices, acf_get_pretty_post_types() ); + + + // end break; diff --git a/admin/field-groups.php b/admin/field-groups.php index 82ffc08..fbc52db 100644 --- a/admin/field-groups.php +++ b/admin/field-groups.php @@ -619,7 +619,7 @@ class acf_admin_field_groups {
diff --git a/api/api-field-group.php b/api/api-field-group.php
index 240e474..d531dcf 100644
--- a/api/api-field-group.php
+++ b/api/api-field-group.php
@@ -70,14 +70,53 @@ function acf_get_valid_field_group( $field_group = false ) {
));
- // translate
- $field_group = acf_translate_keys( $field_group, acf_get_setting('l10n_field_group') );
-
-
// filter
$field_group = apply_filters('acf/get_valid_field_group', $field_group);
+ // translate
+ $field_group = acf_translate_field_group( $field_group );
+
+
+ // return
+ return $field_group;
+
+}
+
+
+/*
+* acf_translate_field_group
+*
+* This function will translate field group's settings
+*
+* @type function
+* @date 8/03/2016
+* @since 5.3.2
+*
+* @param $field_group (array)
+* @return $field_group
+*/
+
+function acf_translate_field_group( $field_group ) {
+
+ // vars
+ $l10n = acf_get_setting('l10n');
+ $l10n_textdomain = acf_get_setting('l10n_textdomain');
+
+
+ // if
+ if( $l10n && $l10n_textdomain ) {
+
+ // translate
+ $field_group['title'] = acf_translate( $field_group['title'] );
+
+
+ // filters
+ $field_group = apply_filters( "acf/translate_field_group", $field_group );
+
+ }
+
+
// return
return $field_group;
diff --git a/api/api-field.php b/api/api-field.php
index 0795860..060ace1 100644
--- a/api/api-field.php
+++ b/api/api-field.php
@@ -177,10 +177,6 @@ function acf_get_valid_field( $field = false ) {
$field['_name'] = $field['name'];
- // translate
- $field = acf_translate_keys( $field, acf_get_setting('l10n_field') );
-
-
// field specific defaults
$field = apply_filters( "acf/get_valid_field", $field );
$field = apply_filters( "acf/get_valid_field/type={$field['type']}", $field );
@@ -190,11 +186,58 @@ function acf_get_valid_field( $field = false ) {
$field['_valid'] = 1;
+ // translate
+ $field = acf_translate_field( $field );
+
+
// return
return $field;
}
+
+
+/*
+* acf_translate_field
+*
+* This function will translate field's settings
+*
+* @type function
+* @date 8/03/2016
+* @since 5.3.2
+*
+* @param $field (array)
+* @return $field
+*/
+
+function acf_translate_field( $field ) {
+
+ // vars
+ $l10n = acf_get_setting('l10n');
+ $l10n_textdomain = acf_get_setting('l10n_textdomain');
+
+
+ // if
+ if( $l10n && $l10n_textdomain ) {
+
+ // translate
+ $field['label'] = acf_translate( $field['label'] );
+ $field['instructions'] = acf_translate( $field['instructions'] );
+
+
+ // filters
+ $field = apply_filters( "acf/translate_field", $field );
+ $field = apply_filters( "acf/translate_field/type={$field['type']}", $field );
+
+ }
+
+
+ // return
+ return $field;
+
+}
+
+
/*
* acf_prepare_field
*
@@ -1855,4 +1898,5 @@ function acf_get_sub_field( $selector, $field ) {
}
+
?>
diff --git a/api/api-helpers.php b/api/api-helpers.php
index 59e2d02..9a64a2e 100644
--- a/api/api-helpers.php
+++ b/api/api-helpers.php
@@ -574,6 +574,34 @@ function acf_extract_vars( &$array, $keys ) {
}
+/*
+* acf_get_sub_array
+*
+* This function will return a sub array of data
+*
+* @type function
+* @date 15/03/2016
+* @since 5.3.2
+*
+* @param $post_id (int)
+* @return $post_id (int)
+*/
+
+function acf_get_sub_array( $array, $keys ) {
+
+ $r = array();
+
+ foreach( $keys as $key ) {
+
+ $r[ $key ] = $array[ $key ];
+
+ }
+
+ return $r;
+
+}
+
+
/*
* acf_get_post_types
*
@@ -2325,7 +2353,7 @@ function acf_encode_choices( $array = array(), $show_keys = true ) {
}
-function acf_decode_choices( $string = '' ) {
+function acf_decode_choices( $string = '', $array_keys = false ) {
// bail early if already array
if( is_array($string) ) {
@@ -2383,6 +2411,14 @@ function acf_decode_choices( $string = '' ) {
}
+ // return only array keys? (good for checkbox default_value)
+ if( $array_keys ) {
+
+ return array_keys($array);
+
+ }
+
+
// return
return $array;
@@ -2649,18 +2685,19 @@ function acf_in_array( $value, $array ) {
function acf_get_valid_post_id( $post_id = 0 ) {
- // set post_id to global
+ // if not $post_id, load queried object
if( !$post_id ) {
-
+
+ // try for global post (needed for setup_postdata)
$post_id = (int) get_the_ID();
- }
-
-
- // allow for option == options
- if( $post_id == 'option' ) {
-
- $post_id = 'options';
+
+ // try for current screen
+ if( !$post_id ) {
+
+ $post_id = get_queried_object();
+
+ }
}
@@ -2668,27 +2705,44 @@ function acf_get_valid_post_id( $post_id = 0 ) {
// $post_id may be an object
if( is_object($post_id) ) {
+ // user
if( isset($post_id->roles, $post_id->ID) ) {
$post_id = 'user_' . $post_id->ID;
-
+
+ // term
} elseif( isset($post_id->taxonomy, $post_id->term_id) ) {
$post_id = $post_id->taxonomy . '_' . $post_id->term_id;
-
+
+ // comment
} elseif( isset($post_id->comment_ID) ) {
$post_id = 'comment_' . $post_id->comment_ID;
-
+
+ // post
} elseif( isset($post_id->ID) ) {
$post_id = $post_id->ID;
+
+ // default
+ } else {
+
+ $post_id = 0;
}
}
+ // allow for option == options
+ if( $post_id === 'option' ) {
+
+ $post_id = 'options';
+
+ }
+
+
// append language code
if( $post_id == 'options' ) {
@@ -3658,6 +3712,7 @@ function _acf_settings_uploader( $uploader ) {
* @return $post_id (int)
*/
+/*
function acf_translate_keys( $array, $keys ) {
// bail early if no keys
@@ -3681,6 +3736,7 @@ function acf_translate_keys( $array, $keys ) {
return $array;
}
+*/
/*
@@ -3767,6 +3823,49 @@ function acf_maybe_add_action( $tag, $function_to_add, $priority = 10, $accepted
}
+/*
+* acf_is_row_collapsed
+*
+* This function will return true if the field's row is collapsed
+*
+* @type function
+* @date 2/03/2016
+* @since 5.3.2
+*
+* @param $post_id (int)
+* @return $post_id (int)
+*/
+
+function acf_is_row_collapsed( $field_key = '', $row_index = 0 ) {
+
+ // collapsed
+ $collapsed = acf_get_user_setting('collapsed_' . $field_key, '');
+
+
+ // cookie fallback ( version < 5.3.2 )
+ if( $collapsed === '' ) {
+
+ $collapsed = acf_extract_var($_COOKIE, "acf_collapsed_{$field_key}", '');
+ $collapsed = str_replace('|', ',', $collapsed);
+
+
+ // update
+ acf_update_user_setting( 'collapsed_' . $field_key, $collapsed );
+
+ }
+
+
+ // explode
+ $collapsed = explode(',', $collapsed);
+ $collapsed = array_filter($collapsed, 'is_numeric');
+
+
+ // collapsed class
+ return in_array($row_index, $collapsed);
+
+}
+
+
/*
* Hacks
*
diff --git a/api/api-template.php b/api/api-template.php
index b1c5e9b..613b567 100644
--- a/api/api-template.php
+++ b/api/api-template.php
@@ -22,35 +22,6 @@ function acf_get_field_reference( $field_name, $post_id ) {
}
-/*
-* the_field()
-*
-* This function is the same as echo get_field().
-*
-* @type function
-* @since 1.0.3
-* @date 29/01/13
-*
-* @param $selector (string) the field name or key
-* @param $post_id (mixed) the post_id of which the value is saved against
-* @return n/a
-*/
-
-function the_field( $selector, $post_id = false, $format_value = true ) {
-
- $value = get_field($selector, $post_id, $format_value);
-
- if( is_array($value) ) {
-
- $value = @implode( ', ', $value );
-
- }
-
- echo $value;
-
-}
-
-
/*
* get_field()
*
@@ -113,6 +84,35 @@ function get_field( $selector, $post_id = false, $format_value = true ) {
}
+/*
+* the_field()
+*
+* This function is the same as echo get_field().
+*
+* @type function
+* @since 1.0.3
+* @date 29/01/13
+*
+* @param $selector (string) the field name or key
+* @param $post_id (mixed) the post_id of which the value is saved against
+* @return n/a
+*/
+
+function the_field( $selector, $post_id = false, $format_value = true ) {
+
+ $value = get_field($selector, $post_id, $format_value);
+
+ if( is_array($value) ) {
+
+ $value = @implode( ', ', $value );
+
+ }
+
+ echo $value;
+
+}
+
+
/*
* get_field_object()
*
@@ -132,11 +132,7 @@ function get_field( $selector, $post_id = false, $format_value = true ) {
function get_field_object( $selector, $post_id = false, $format_value = true, $load_value = true ) {
// compatibilty
- if( is_array($format_value) ) {
-
- extract( $format_value );
-
- }
+ if( is_array($format_value) ) extract( $format_value );
// get valid post_id
@@ -148,11 +144,7 @@ function get_field_object( $selector, $post_id = false, $format_value = true, $l
// bail early if no field found
- if( !$field ) {
-
- return false;
-
- }
+ if( !$field ) return false;
// load value
@@ -197,23 +189,24 @@ function get_fields( $post_id = false, $format_value = true ) {
// vars
$fields = get_field_objects( $post_id, $format_value );
- $return = array();
+ $meta = array();
+
+
+ // bail early
+ if( !$fields ) return false;
// populate
- if( is_array($fields) ) {
+ foreach( $fields as $k => $field ) {
- foreach( $fields as $k => $field ) {
-
- $return[ $k ] = $field['value'];
-
- }
+ $meta[ $k ] = $field['value'];
}
// return
- return $return;
+ return $meta;
+
}
@@ -287,30 +280,18 @@ function get_field_objects( $post_id = false, $format_value = true, $load_value
// bail early if no meta
- if( empty($meta) ) {
-
- return false;
-
- }
+ if( empty($meta) ) return false;
// populate vars
foreach( $meta as $k => $v ) {
// Hopefuly improve efficiency: bail early if $k does start with an '_'
- if( $k[0] === '_' ) {
-
- continue;
-
- }
+ if( $k[0] === '_' ) continue;
// does a field key exist for this value?
- if( !array_key_exists("_{$k}", $meta) ) {
-
- continue;
-
- }
+ if( !array_key_exists("_{$k}", $meta) ) continue;
// get field
@@ -319,11 +300,7 @@ function get_field_objects( $post_id = false, $format_value = true, $load_value
// bail early if not a parent field
- if( !$field || acf_is_sub_field($field) ) {
-
- continue;
-
- }
+ if( !$field || acf_is_sub_field($field) ) continue;
// load value
@@ -350,11 +327,7 @@ function get_field_objects( $post_id = false, $format_value = true, $load_value
// no value
- if( empty($fields) ) {
-
- return false;
-
- }
+ if( empty($fields) ) return false;
// return
@@ -380,11 +353,13 @@ function get_field_objects( $post_id = false, $format_value = true, $load_value
function have_rows( $selector, $post_id = false ) {
// vars
- $row = array();
+ $active_loop = acf_get_loop('active');
+ $previous_loop = acf_get_loop('previous');
$new_parent_loop = false;
$new_child_loop = false;
$sub_field = false;
$sub_exists = false;
+ $change = false;
// reference
@@ -396,29 +371,19 @@ function have_rows( $selector, $post_id = false ) {
// empty?
- if( empty($GLOBALS['acf_field']) ) {
-
- // reset
- reset_rows( true );
-
+ if( !$active_loop ) {
// create a new loop
$new_parent_loop = true;
} else {
- // vars
- $row = end( $GLOBALS['acf_field'] );
- $prev = prev( $GLOBALS['acf_field'] );
- $change = false;
-
-
// detect change
- if( $post_id != $row['post_id'] ) {
+ if( $post_id != $active_loop['post_id'] ) {
$change = 'post_id';
- } elseif( $selector != $row['selector'] ) {
+ } elseif( $selector != $active_loop['selector'] ) {
$change = 'selector';
@@ -428,11 +393,11 @@ function have_rows( $selector, $post_id = false ) {
// attempt to find sub field
if( $change ) {
- $sub_field = acf_get_sub_field($selector, $row['field']);
+ $sub_field = acf_get_sub_field($selector, $active_loop['field']);
if( $sub_field ) {
- $sub_exists = isset($row['value'][ $row['i'] ][ $sub_field['key'] ]);
+ $sub_exists = isset( $active_loop['value'][ $active_loop['i'] ][ $sub_field['key'] ] );
}
@@ -448,11 +413,11 @@ function have_rows( $selector, $post_id = false ) {
// action: move down one level into a new loop
$new_child_loop = true;
- } elseif( $prev && $prev['post_id'] == $post_id ) {
+ } elseif( $previous_loop && $previous_loop['post_id'] == $post_id ) {
// case: Change in $post_id was due to a nested loop ending
// action: move up one level through the loops
- reset_rows();
+ acf_remove_loop('active');
} else {
@@ -464,11 +429,11 @@ function have_rows( $selector, $post_id = false ) {
} elseif( $change == 'selector' ) {
- if( $prev && $prev['selector'] == $selector && $prev['post_id'] == $post_id ) {
+ if( $previous_loop && $previous_loop['selector'] == $selector && $previous_loop['post_id'] == $post_id ) {
// case: Change in $field_name was due to a nested loop ending
// action: move up one level through the loops
- reset_rows();
+ acf_remove_loop('active');
} elseif( $sub_exists ) {
@@ -489,6 +454,7 @@ function have_rows( $selector, $post_id = false ) {
}
+ // add parent loop
if( $new_parent_loop ) {
// vars
@@ -496,40 +462,42 @@ function have_rows( $selector, $post_id = false ) {
$value = acf_extract_var( $field, 'value' );
- // add row
- $GLOBALS['acf_field'][] = array(
+ // add loop
+ acf_add_loop(array(
'selector' => $selector,
'name' => $field['name'], // used by update_sub_field
'value' => $value,
'field' => $field,
'i' => -1,
'post_id' => $post_id,
- );
-
+ ));
+
+ // add child loop
} elseif( $new_child_loop ) {
// vars
- $value = $row['value'][ $row['i'] ][ $sub_field['key'] ];
+ $value = $active_loop['value'][ $active_loop['i'] ][ $sub_field['key'] ];
- $GLOBALS['acf_field'][] = array(
+
+ // add loop
+ acf_add_loop(array(
'selector' => $selector,
- 'name' => $row['name'] . '_' . $row['i'], // used by update_sub_field
+ 'name' => $active_loop['name'] . '_' . $active_loop['i'], // used by update_sub_field
'value' => $value,
'field' => $sub_field,
'i' => -1,
'post_id' => $post_id,
- );
+ ));
}
// update vars
- $row = end( $GLOBALS['acf_field'] );
-
+ $active_loop = acf_get_loop('active');
// return true if next row exists
- if( is_array($row['value']) && array_key_exists($row['i']+1, $row['value']) ) {
+ if( $active_loop && is_array($active_loop['value']) && isset($active_loop['value'][ $active_loop['i']+1 ]) ) {
return true;
@@ -537,7 +505,7 @@ function have_rows( $selector, $post_id = false ) {
// no next row!
- reset_rows();
+ acf_remove_loop('active');
// return
@@ -562,11 +530,15 @@ function have_rows( $selector, $post_id = false ) {
function the_row( $format = false ) {
// vars
- $depth = count($GLOBALS['acf_field']) - 1;
-
+ $i = acf_get_loop('active', 'i');
- // increase i of current row
- $GLOBALS['acf_field'][ $depth ]['i']++;
+
+ // increase
+ $i++;
+
+
+ // update
+ acf_update_loop('active', 'i', $i);
// return
@@ -577,19 +549,15 @@ function the_row( $format = false ) {
function get_row( $format = false ) {
// vars
- $row = acf_get_row();
+ $loop = acf_get_loop('active');
- // bail early if no row
- if( !$row ) {
-
- return false;
-
- }
+ // bail early if no loop
+ if( !$loop ) return false;
// get value
- $value = $row['value'][ $row['i'] ];
+ $value = $loop['value'][ $loop['i'] ];
// format
@@ -598,8 +566,10 @@ function get_row( $format = false ) {
// temp wrap value in array
$value = array( $value );
+
// format the value (1 row of data)
- $value = acf_format_value( $value, $row['post_id'], $row['field'] );
+ $value = acf_format_value( $value, $loop['post_id'], $loop['field'] );
+
// extract value from array
$value = $value[0];
@@ -612,33 +582,14 @@ function get_row( $format = false ) {
}
-function acf_get_row() {
-
- // check and return row
- if( !empty($GLOBALS['acf_field']) ) {
-
- return end( $GLOBALS['acf_field'] );
-
- }
-
-
- // return
- return false;
-
-}
-
function get_row_index() {
// vars
- $row = acf_get_row();
-
-
- // bail early if no row
- if( !$row ) return 0;
+ $i = acf_get_loop('active', 'i');
// return
- return $row['i'] + 1;
+ return $i + 1;
}
@@ -657,34 +608,15 @@ function get_row_index() {
* @return (boolean)
*/
-function reset_rows( $hard_reset = false ) {
+function reset_rows() {
- // completely destroy?
- if( $hard_reset ) {
-
- $GLOBALS['acf_field'] = array();
-
-
- // reset current row
- } else {
-
- // vars
- $depth = count( $GLOBALS['acf_field'] ) - 1;
-
-
- // remove
- unset( $GLOBALS['acf_field'][$depth] );
-
-
- // refresh index
- $GLOBALS['acf_field'] = array_values($GLOBALS['acf_field']);
- }
+ // remove last loop
+ acf_remove_loop('active');
// return
return true;
-
}
@@ -746,7 +678,7 @@ function has_sub_fields( $field_name, $post_id = false ) {
function get_sub_field( $selector, $format_value = true ) {
// vars
- $row = acf_get_row();
+ $row = acf_get_loop('active');
// bail early if no row
@@ -842,7 +774,7 @@ function the_sub_field( $field_name, $format_value = true ) {
function get_sub_field_object( $selector, $format_value = true, $load_value = true ) {
// vars
- $row = acf_get_row();
+ $row = acf_get_loop('active');
// bail early if no row
@@ -975,6 +907,11 @@ function acf_form_head() {
// verify nonce
if( acf_verify_nonce('acf_form') ) {
+ // add actions
+ add_action('acf/validate_save_post', '_validate_save_post');
+ add_filter('acf/pre_save_post', '_acf_pre_save_post', 5, 2);
+
+
// validate data
if( acf_validate_save_post(true) ) {
@@ -1041,8 +978,6 @@ function acf_form_head() {
* @return $post_id (int)
*/
-add_action('acf/validate_save_post', '_validate_save_post');
-
function _validate_save_post() {
// save post_title
@@ -1086,8 +1021,6 @@ function _validate_save_post() {
* @return $post_id (int)
*/
-add_filter('acf/pre_save_post', '_acf_pre_save_post', 5, 2);
-
function _acf_pre_save_post( $post_id, $form ) {
// vars
@@ -1491,7 +1424,7 @@ function update_sub_field( $selector, $value, $post_id = false ) {
if( is_string($selector) ) {
// get current row
- $row = acf_get_row();
+ $row = acf_get_loop('active');
// override $post_id
@@ -1828,139 +1761,6 @@ function delete_row( $selector, $row = 1, $post_id = false ) {
}
-/*
-* create_field()
-*
-* This function will creat the HTML for a field
-*
-* @type function
-* @since 4.0.0
-* @date 17/03/13
-*
-* @param array $field - an array containing all the field attributes
-*
-* @return N/A
-*/
-
-function create_field( $field ) {
-
- acf_render_field( $field );
-}
-
-function render_field( $field ) {
-
- acf_render_field( $field );
-}
-
-
-/*
-* acf_convert_field_names_to_keys()
-*
-* Helper for the update_field function
-*
-* @type function
-* @since 4.0.0
-* @date 17/03/13
-*
-* @param array $value: the value returned via get_field
-* @param array $field: the field or layout to find sub fields from
-*
-* @return N/A
-*/
-
-function acf_convert_field_names_to_keys( $value, $field ) {
-
- // only if $field has sub fields
- if( !isset($field['sub_fields']) ) {
-
- return $value;
-
- }
-
-
- // define sub field keys
- $sub_fields = array();
- if( $field['sub_fields'] ) {
-
- foreach( $field['sub_fields'] as $sub_field ) {
-
- $sub_fields[ $sub_field['name'] ] = $sub_field;
-
- }
-
- }
-
-
- // loop through the values and format the array to use sub field keys
- if( is_array($value) ) {
-
- foreach( $value as $row_i => $row) {
-
- if( $row ) {
-
- foreach( $row as $sub_field_name => $sub_field_value ) {
-
- // sub field must exist!
- if( !isset($sub_fields[ $sub_field_name ]) ) {
-
- continue;
-
- }
-
-
- // vars
- $sub_field = $sub_fields[ $sub_field_name ];
- $sub_field_value = acf_convert_field_names_to_keys( $sub_field_value, $sub_field );
-
-
- // set new value
- $value[$row_i][ $sub_field['key'] ] = $sub_field_value;
-
-
- // unset old value
- unset( $value[$row_i][$sub_field_name] );
-
-
- }
- // foreach( $row as $sub_field_name => $sub_field_value )
-
- }
- // if( $row )
-
- }
- // foreach( $value as $row_i => $row)
-
- }
- // if( $value )
-
-
- // return
- return $value;
-
-}
-
-
-/*
-* register_field_group
-*
-* description
-*
-* @type function
-* @date 11/03/2014
-* @since 5.0.0
-*
-* @param $post_id (int)
-* @return $post_id (int)
-*/
-
-function register_field_group( $field_group ) {
-
- // add local
- acf_add_local_field_group( $field_group );
-
-}
-
-
/*
* Depreceated Functions
*
@@ -1974,6 +1774,24 @@ function register_field_group( $field_group ) {
* @return n/a
*/
+function register_field_group( $field_group ) {
+
+ acf_add_local_field_group( $field_group );
+
+}
+
+function create_field( $field ) {
+
+ acf_render_field( $field );
+
+}
+
+function render_field( $field ) {
+
+ acf_render_field( $field );
+
+}
+
function reset_the_repeater_field() {
return reset_rows();
diff --git a/assets/css/acf-global.css b/assets/css/acf-global.css
index 33981ef..f7fd849 100644
--- a/assets/css/acf-global.css
+++ b/assets/css/acf-global.css
@@ -575,32 +575,44 @@ a.acf-icon.-cancel.grey:hover {
position: relative;
display: block;
background: #F55E4F;
- border-radius: 3px;
margin: 5px 0 15px;
- padding: 1px 10px;
+ padding: 1px 12px;
min-height: 0px;
+ border-left: #dd4232 solid 4px;
}
.acf-error-message p {
font-size: 13px !important;
- line-height: 1.4;
- margin: 8px 0;
- padding: 0;
+ line-height: 1.5;
+ margin: 0.5em 0;
+ padding: 2px;
text-shadow: none;
color: #fff;
- text-shadow: 0 1px 0 #DD4232;
}
.acf-error-message .acf-icon {
position: absolute;
- top: 8px;
- right: 10px;
+ top: 9px;
+ right: 12px;
background-color: #dd4232;
border-color: transparent;
color: #fff;
}
-.acf-error-message .acf-icon:hover {
- background-color: #F1F1F1;
+/* important to include .-cancel to override .acf-icon.-cancel class */
+.acf-error-message .acf-icon.-cancel:hover {
+ background-color: #191e23;
color: #F55E4F;
}
+/* success */
+.acf-error-message.-success {
+ background-color: #46b450;
+ border-color: #32973b;
+}
+.acf-error-message.-success .acf-icon {
+ background-color: #32973b;
+}
+.acf-error-message.-success .acf-icon.-cancel:hover {
+ background-color: #191e23;
+ color: #46b450;
+}
/*--------------------------------------------------------------------------------------------
*
* acf-table
diff --git a/assets/css/acf-input.css b/assets/css/acf-input.css
index cfb37a5..4993915 100644
--- a/assets/css/acf-input.css
+++ b/assets/css/acf-input.css
@@ -47,6 +47,8 @@
color: #fff;
margin: 0 0 10px;
display: inline-block;
+ border-radius: 3px;
+ border-left: none;
}
.acf-field .acf-error-message:after {
content: "";
@@ -1347,6 +1349,7 @@ html[dir="rtl"] .acf-image-uploader .view {
display: block;
padding: 0;
margin: 0;
+ max-width: 48px;
}
.acf-file-uploader .file-info {
padding: 10px;
@@ -1361,21 +1364,19 @@ html[dir="rtl"] .acf-image-uploader .view {
.acf-file-uploader .file-info a {
text-decoration: none;
}
-/*
-* Hover
-*/
-.acf-file-uploader .acf-soh-target {
+.acf-file-uploader .file-info ul {
position: absolute;
top: 5px;
right: 5px;
+ /* rtl */
}
-html[dir="rtl"] .acf-file-uploader .acf-soh-target {
+.acf-file-uploader .file-info ul li {
+ margin: 0 0 0 4px;
+}
+html[dir="rtl"] .acf-file-uploader .file-info ul {
right: auto;
left: 5px;
}
-.acf-file-uploader .acf-soh-target li {
- margin: 0 0 0 4px;
-}
/*---------------------------------------------------------------------------------------------
*
* Date Picker
diff --git a/assets/js/acf-input.js b/assets/js/acf-input.js
index 82bbc95..7b66f3a 100644
--- a/assets/js/acf-input.js
+++ b/assets/js/acf-input.js
@@ -15,7 +15,8 @@
addFilter : addFilter,
removeAction : removeAction,
doAction : doAction,
- addAction : addAction
+ addAction : addAction,
+ storage : getStorage
};
/**
@@ -26,7 +27,13 @@
actions : {},
filters : {}
};
-
+
+ function getStorage() {
+
+ return STORAGE;
+
+ };
+
/**
* Adds an action to the event manager.
*
@@ -397,17 +404,38 @@ var acf;
add_action: function() {
- // allow multiple action parameters such as 'ready append'
- var actions = arguments[0].split(' ');
+ // vars
+ var a = arguments[0].split(' '),
+ l = a.length;
- for( k in actions ) {
- // prefix action
- arguments[0] = 'acf.' + actions[ k ];
+ // loop
+ for( var i = 0; i < l; i++) {
+/*
+ // allow for special actions
+ if( a[i].indexOf('initialize') !== -1 ) {
+
+ a.push( a[i].replace('initialize', 'ready') );
+ a.push( a[i].replace('initialize', 'append') );
+ l = a.length;
+
+ continue;
+ }
+*/
+
+
+ // prefix action
+ arguments[0] = 'acf/' + a[i];
+
+
+ // add
wp.hooks.addAction.apply(this, arguments);
+
}
+
+ // return
return this;
},
@@ -429,7 +457,7 @@ var acf;
remove_action: function() {
// prefix action
- arguments[0] = 'acf.' + arguments[0];
+ arguments[0] = 'acf/' + arguments[0];
wp.hooks.removeAction.apply(this, arguments);
@@ -451,10 +479,10 @@ var acf;
* @return
*/
- do_action: function() {
+ do_action: function() { //console.log('acf.do_action(%o)', arguments);
// prefix action
- arguments[0] = 'acf.' + arguments[0];
+ arguments[0] = 'acf/' + arguments[0];
wp.hooks.doAction.apply(this, arguments);
@@ -479,7 +507,7 @@ var acf;
add_filter: function() {
// prefix action
- arguments[0] = 'acf.' + arguments[0];
+ arguments[0] = 'acf/' + arguments[0];
wp.hooks.addFilter.apply(this, arguments);
@@ -504,7 +532,7 @@ var acf;
remove_filter: function() {
// prefix action
- arguments[0] = 'acf.' + arguments[0];
+ arguments[0] = 'acf/' + arguments[0];
wp.hooks.removeFilter.apply(this, arguments);
@@ -526,10 +554,10 @@ var acf;
* @return
*/
- apply_filters: function() {
+ apply_filters: function() { //console.log('acf.apply_filters(%o)', arguments);
// prefix action
- arguments[0] = 'acf.' + arguments[0];
+ arguments[0] = 'acf/' + arguments[0];
return wp.hooks.applyFilters.apply(this, arguments);
@@ -770,7 +798,7 @@ var acf;
get_field_key: function( $field ){
- return this.get_data( $field, 'key' );
+ return $field.data('key');
},
@@ -790,7 +818,7 @@ var acf;
get_field_type: function( $field ){
- return this.get_data( $field, 'type' );
+ return $field.data('type');
},
@@ -902,22 +930,14 @@ var acf;
* @since 5.0.0
*
* @param $el (jQuery selection)
- * @param prefix (string)
* @return $post_id (int)
*/
- serialize_form : function( $el, prefix ){
-
- // defaults
- prefix = prefix || '';
-
+ serialize_form : function( $el ){
// vars
var data = {},
- names = {},
- prelen = prefix.length,
- _prefix = '_' + prefix,
- _prelen = _prefix.length;
+ names = {};
// selector
@@ -927,14 +947,6 @@ var acf;
// populate data
$.each( $selector.serializeArray(), function( i, pair ) {
- // bail early if name does not start with acf or _acf
- if( prefix && pair.name.substring(0, prelen) != prefix && pair.name.substring(0, _prelen) != _prefix ) {
-
- return;
-
- }
-
-
// initiate name
if( pair.name.slice(-2) === '[]' ) {
@@ -966,6 +978,13 @@ var acf;
// return
return data;
+
+ },
+
+ serialize: function( $el ){
+
+ return this.serialize_form( $el );
+
},
@@ -1510,40 +1529,6 @@ var acf;
},
- update_cookie : function( name, value, days ) {
-
- // defaults
- days = days || 31;
-
- if (days) {
- var date = new Date();
- date.setTime(date.getTime()+(days*24*60*60*1000));
- var expires = "; expires="+date.toGMTString();
- }
- else var expires = "";
- document.cookie = name+"="+value+expires+"; path=/";
-
- },
-
- get_cookie : function( name ) {
-
- var nameEQ = name + "=";
- var ca = document.cookie.split(';');
- for(var i=0;i < ca.length;i++) {
- var c = ca[i];
- while (c.charAt(0)==' ') c = c.substring(1,c.length);
- if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
- }
- return null;
-
- },
-
- delete_cookie : function( name ) {
-
- this.update_cookie(name,"",-1);
-
- },
-
/*
* is_in_view
@@ -2243,8 +2228,8 @@ var acf;
},
_prepare_field: function( $el ){
-
- acf.do_action('prepare_field/type=' + acf.get_field_type($el), $el);
+
+ acf.do_action('prepare_field/type=' + $el.data('type'), $el);
},
@@ -2260,8 +2245,8 @@ var acf;
},
_ready_field: function( $el ){
-
- acf.do_action('ready_field/type=' + acf.get_field_type($el), $el);
+
+ acf.do_action('ready_field/type=' + $el.data('type'), $el);
},
@@ -2278,7 +2263,7 @@ var acf;
_append_field: function( $el ){
- acf.do_action('append_field/type=' + acf.get_field_type($el), $el);
+ acf.do_action('append_field/type=' + $el.data('type'), $el);
},
@@ -2295,7 +2280,7 @@ var acf;
_load_field: function( $el ){
- acf.do_action('load_field/type=' + acf.get_field_type($el), $el);
+ acf.do_action('load_field/type=' + $el.data('type'), $el);
},
@@ -2312,7 +2297,7 @@ var acf;
_remove_field: function( $el ){
- acf.do_action('remove_field/type=' + acf.get_field_type($el), $el);
+ acf.do_action('remove_field/type=' + $el.data('type'), $el);
},
@@ -2329,7 +2314,7 @@ var acf;
_sortstart_field: function( $el, $placeholder ){
- acf.do_action('sortstart_field/type=' + acf.get_field_type($el), $el, $placeholder);
+ acf.do_action('sortstart_field/type=' + $el.data('type'), $el, $placeholder);
},
@@ -2346,7 +2331,7 @@ var acf;
_sortstop_field: function( $el, $placeholder ){
- acf.do_action('sortstop_field/type=' + acf.get_field_type($el), $el, $placeholder);
+ acf.do_action('sortstop_field/type=' + $el.data('type'), $el, $placeholder);
},
@@ -2364,7 +2349,7 @@ var acf;
_hide_field: function( $el, context ){
- acf.do_action('hide_field/type=' + acf.get_field_type($el), $el, context);
+ acf.do_action('hide_field/type=' + $el.data('type'), $el, context);
},
@@ -2381,7 +2366,7 @@ var acf;
_show_field: function( $el, context ){
- acf.do_action('show_field/type=' + acf.get_field_type($el), $el, context);
+ acf.do_action('show_field/type=' + $el.data('type'), $el, context);
}
@@ -2986,25 +2971,25 @@ var acf;
});
+/*
- /*
- //console.time("acf_test_ready");
- //console.time("acf_test_load");
+
+ console.time("acf_test_ready");
+ console.time("acf_test_load");
acf.add_action('ready', function(){
- //console.timeEnd("acf_test_ready");
+ console.timeEnd("acf_test_ready");
}, 999);
acf.add_action('load', function(){
- //console.timeEnd("acf_test_load");
+ console.timeEnd("acf_test_load");
}, 999);
*/
-
})(jQuery);
(function($){
@@ -3429,7 +3414,8 @@ var acf;
acf.fields.color_picker = acf.field.extend({
type: 'color_picker',
- timeout: null,
+ $input: null,
+ $hidden: null,
actions: {
'ready': 'initialize',
@@ -3439,59 +3425,53 @@ var acf;
focus: function(){
this.$input = this.$field.find('input[type="text"]');
+ this.$hidden = this.$field.find('input[type="hidden"]');
},
initialize: function(){
// reference
- var self = this;
+ var $input = this.$input,
+ $hidden = this.$hidden;
- // vars
- var $hidden = this.$input.clone();
+ // trigger change function
+ var change_hidden = function(){
+
+ // timeout is required to ensure the $input val is correct
+ setTimeout(function(){
+
+ acf.val( $hidden, $input.val() );
+
+ }, 1);
+
+ }
- // modify hidden
- $hidden.attr({
- 'type' : 'hidden',
- 'class' : '',
- 'id' : '',
- 'value' : ''
- });
-
-
- // append hidden
- this.$input.before( $hidden );
+ // args
+ var args = {
+
+ defaultColor: false,
+ palettes: true,
+ hide: true,
+ change: change_hidden,
+ clear: change_hidden
+
+ }
+ // filter
+ var args = acf.apply_filters('color_picker_args', args, this.$field);
+
+
// iris
- this.$input.wpColorPicker({
-
- change: function( event, ui ){
-
- if( self.timeout ) {
-
- clearTimeout( self.timeout );
-
- }
-
-
- self.timeout = setTimeout(function(){
-
- $hidden.trigger('change');
-
- }, 1000);
-
- }
-
- });
+ this.$input.wpColorPicker(args);
}
});
-
})(jQuery);
(function($){
@@ -4198,7 +4178,7 @@ var acf;
title: acf._e('file', 'select'),
mode: 'select',
type: '',
- field: acf.get_field_key($field),
+ field: $field.data('key'),
multiple: $repeater.exists(),
library: this.o.library,
mime_types: this.o.mime_types,
@@ -4210,7 +4190,7 @@ var acf;
if( i > 0 ) {
// vars
- var key = acf.get_field_key( $field ),
+ var key = $field.data('key'),
$tr = $field.closest('.acf-row');
@@ -5198,7 +5178,7 @@ var acf;
title: acf._e('image', 'select'),
mode: 'select',
type: 'image',
- field: acf.get_field_key($field),
+ field: $field.data('key'),
multiple: $repeater.exists(),
library: this.o.library,
mime_types: this.o.mime_types,
@@ -5209,7 +5189,7 @@ var acf;
if( i > 0 ) {
// vars
- var key = acf.get_field_key( $field ),
+ var key = $field.data('key'),
$tr = $field.closest('.acf-row');
@@ -5580,7 +5560,9 @@ var acf;
// populate above vars making sure to allow for failure
try {
- var filters = frame.content.get().toolbar.get('filters');
+ var toolbar = frame.content.get().toolbar,
+ filters = toolbar.get('filters'),
+ search = toolbar.get('search');
} catch(e) {
@@ -5692,6 +5674,10 @@ var acf;
});
+ // add _acfuplaoder to search
+ search.model.attributes._acfuploader = args.field;
+
+
// render
if( typeof filters.refresh === 'function' ) {
@@ -8763,7 +8749,7 @@ var acf;
events: {
'click #save-post': 'click_ignore',
- 'click input[type="submit"]': 'click_publish',
+ 'click [type="submit"]': 'click_publish',
'submit form': 'submit_form',
'click .acf-error-message a': 'click_message'
},
@@ -9093,11 +9079,7 @@ var acf;
fetch: function( $form ){
// bail aelry if already busy
- if( this.busy ) {
-
- return false;
-
- }
+ if( this.busy ) return false;
// reference
@@ -9105,7 +9087,7 @@ var acf;
// vars
- var data = acf.serialize_form( $form, 'acf' );
+ var data = acf.serialize_form($form);
// append AJAX action
@@ -9189,7 +9171,7 @@ var acf;
if( $message.exists() ) {
- $message.removeClass('error');
+ $message.addClass('-success');
$message.children('p').html( acf._e('validation_successful') );
}
@@ -9650,7 +9632,7 @@ var acf;
toolbars: {},
actions: {
- 'ready': 'initialize',
+ 'load': 'initialize',
'append': 'initialize',
'remove': 'disable',
'sortstart': 'disable',
diff --git a/assets/js/acf-input.min.js b/assets/js/acf-input.min.js
index 85bacba..460907a 100644
--- a/assets/js/acf-input.min.js
+++ b/assets/js/acf-input.min.js
@@ -1,3 +1,3 @@
-!function(e,t){"use strict";var i=function(){function e(e,t,i,a){return"string"==typeof e&&"function"==typeof t&&(i=parseInt(i||10,10),r("actions",e,t,i,a)),d}function t(){var e=Array.prototype.slice.call(arguments),t=e.shift();return"string"==typeof t&&c("actions",t,e),d}function i(e,t){return"string"==typeof e&&o("actions",e,t),d}function a(e,t,i,a){return"string"==typeof e&&"function"==typeof t&&(i=parseInt(i||10,10),r("filters",e,t,i,a)),d}function n(){var e=Array.prototype.slice.call(arguments),t=e.shift();return"string"==typeof t?c("filters",t,e):d}function s(e,t){return"string"==typeof e&&o("filters",e,t),d}function o(e,t,i,a){if(f[e][t])if(i){var n=f[e][t],s;if(a)for(s=n.length;s--;){var o=n[s];o.callback===i&&o.context===a&&n.splice(s,1)}else for(s=n.length;s--;)n[s].callback===i&&n.splice(s,1)}else f[e][t]=[]}function r(e,t,i,a,n){var s={callback:i,priority:a,context:n},o=f[e][t];o?(o.push(s),o=l(o)):o=[s],f[e][t]=o}function l(e){for(var t,i,a,n=1,s=e.length;s>n;n++){for(t=e[n],i=n;(a=e[i-1])&&a.priority>t.priority;)e[i]=e[i-1],--i;e[i]=t}return e}function c(e,t,i){var a=f[e][t];if(!a)return"filters"===e?i[0]:!1;var n=0,s=a.length;if("filters"===e)for(;s>n;n++)i[0]=a[n].callback.apply(a[n].context,i);else for(;s>n;n++)a[n].callback.apply(a[n].context,i);return"filters"===e?i[0]:!0}var d={removeFilter:s,applyFilters:n,addFilter:a,removeAction:i,doAction:t,addAction:e},f={actions:{},filters:{}};return d};e.wp=e.wp||{},e.wp.hooks=new i}(window);var acf;!function($){$.fn.exists=function(){return $(this).length>0},$.fn.outerHTML=function(){return $(this).get(0).outerHTML},acf={l10n:{},o:{},update:function(e,t){this.o[e]=t},get:function(e){return"undefined"!=typeof this.o[e]?this.o[e]:null},_e:function(e,t){t=t||!1;var i=this.l10n[e]||"";return t&&(i=i[t]||""),i},add_action:function(){var e=arguments[0].split(" ");for(k in e)arguments[0]="acf."+e[k],wp.hooks.addAction.apply(this,arguments);return this},remove_action:function(){return arguments[0]="acf."+arguments[0],wp.hooks.removeAction.apply(this,arguments),this},do_action:function(){return arguments[0]="acf."+arguments[0],wp.hooks.doAction.apply(this,arguments),this},add_filter:function(){return arguments[0]="acf."+arguments[0],wp.hooks.addFilter.apply(this,arguments),this},remove_filter:function(){return arguments[0]="acf."+arguments[0],wp.hooks.removeFilter.apply(this,arguments),this},apply_filters:function(){return arguments[0]="acf."+arguments[0],wp.hooks.applyFilters.apply(this,arguments)},get_selector:function(e){e=e||"";var t=".acf-field";if($.isPlainObject(e))if($.isEmptyObject(e))e="";else for(k in e){e=e[k];break}return e&&(t+="-"+e,t=t.split("_").join("-"),t=t.split("field-field-").join("field-")),t},get_fields:function(e,t,i){e=e||"",t=t||!1,i=i||!1;var a=this.get_selector(e),n=$(a,t);return t!==!1&&t.each(function(){$(this).is(a)&&(n=n.add($(this)))}),i||(n=acf.apply_filters("get_fields",n)),n},get_field:function(e,t){e=e||"",t=t||!1;var i=this.get_fields(e,t,!0);return i.exists()?i.first():!1},get_closest_field:function(e,t){return t=t||"",e.closest(this.get_selector(t))},get_field_wrap:function(e){return e.closest(this.get_selector())},get_field_key:function(e){return this.get_data(e,"key")},get_field_type:function(e){return this.get_data(e,"type")},get_data:function(e,t){return"undefined"==typeof t?e.data():e.data(t)},get_uniqid:function(e,t){"undefined"==typeof e&&(e="");var i,a=function(e,t){return e=parseInt(e,10).toString(16),t '+acf._e("relationship","loading")+" "+acf._e("relationship","empty")+" '+acf._e("relationship","loading")+" "+acf._e("relationship","empty")+"'),e.children("td").animate({height:0},250,function(){e.remove(),"function"==typeof t&&t()})},250)},remove_el:function(e,t,i){i=i||0,e.css({height:e.height(),width:e.width(),position:"absolute"}),e.wrap(''),e.animate({opacity:0},250),e.parent(".acf-temp-wrap").animate({height:i},250,function(){$(this).remove(),"function"==typeof t&&t()})},isset:function(){var e=arguments,t=e.length,a=null,n;if(0===t)throw new Error("Empty isset");for(a=e[0],i=1;i '))}),acf.add_action("before_duplicate",function(e){e.find("select option:selected").addClass("selected")}),acf.add_action("after_duplicate",function(e,t){e.find("select option.selected").removeClass("selected"),t.find("select").each(function(){var e=[];$(this).find("option.selected").each(function(){e.push($(this).val()),$(this).removeClass("selected")}),$(this).val(e)})})}(jQuery),function($){acf.ajax=acf.model.extend({actions:{ready:"ready"},events:{"change #page_template":"_change_template","change #parent_id":"_change_parent","change #post-formats-select input":"_change_format","change .categorychecklist input":"_change_term",'change .acf-taxonomy-field[data-save="1"] input':"_change_term",'change .acf-taxonomy-field[data-save="1"] select':"_change_term"},o:{},xhr:null,update:function(e,t){return this.o[e]=t,this},get:function(e){return this.o[e]||null},ready:function(){this.update("post_id",acf.get("post_id"))},fetch:function(){if(acf.get("ajax")){this.xhr&&this.xhr.abort();var e=this,t=this.o;t.action="acf/post/get_field_groups",t.exists=[],$(".acf-postbox").not(".acf-hidden").each(function(){t.exists.push($(this).attr("id").substr(4))}),this.xhr=$.ajax({url:acf.get("ajaxurl"),data:acf.prepare_for_ajax(t),type:"post",dataType:"json",success:function(t){acf.is_ajax_success(t)&&e.render(t.data)}})}},render:function(e){$(".acf-postbox").addClass("acf-hidden"),$(".acf-postbox-toggle").addClass("acf-hidden"),$.each(e,function(e,t){var i=$("#acf-"+t.key),a=$("#acf-"+t.key+"-hide"),n=a.parent();i.removeClass("acf-hidden hide-if-js").show(),n.removeClass("acf-hidden hide-if-js").show(),a.prop("checked",!0);var s=i.find(".acf-replace-with-fields");s.exists()&&(s.replaceWith(t.html),acf.do_action("append",i)),0===e&&$("#acf-style").html(t.style),i.find(".acf-hidden-by-postbox").prop("disabled",!1)}),$(".acf-postbox.acf-hidden").find("select, textarea, input").not(":disabled").each(function(){$(this).addClass("acf-hidden-by-postbox").prop("disabled",!0)})},sync_taxonomy_terms:function(){var e=[""];$(".categorychecklist, .acf-taxonomy-field").each(function(){var t=$(this),i=t.find('input[type="checkbox"]').not(":disabled"),a=t.find('input[type="radio"]').not(":disabled"),n=t.find("select").not(":disabled"),s=t.find('input[type="hidden"]').not(":disabled");t.is(".acf-taxonomy-field")&&"1"!=t.attr("data-save")||t.closest(".media-frame").exists()||(i.exists()?i.filter(":checked").each(function(){e.push($(this).val())}):a.exists()?a.filter(":checked").each(function(){e.push($(this).val())}):n.exists()?n.find("option:selected").each(function(){e.push($(this).val())}):s.exists()&&s.each(function(){$(this).val()&&e.push($(this).val())}))}),e=e.filter(function(e,t,i){return i.indexOf(e)==t}),this.update("post_taxonomy",e).fetch()},_change_template:function(e){var t=e.$el.val();this.update("page_template",t).fetch()},_change_parent:function(e){var t="parent",i=0;""!=e.$el.val()&&(t="child",i=e.$el.val()),this.update("page_type",t).update("page_parent",i).fetch()},_change_format:function(e){var t=e.$el.val();"0"==t&&(t="standard"),this.update("post_format",t).fetch()},_change_term:function(e){var t=this;e.$el.closest(".media-frame").exists()||setTimeout(function(){t.sync_taxonomy_terms()},1)}})}(jQuery),function($){acf.fields.checkbox=acf.field.extend({type:"checkbox",events:{"change input":"change"},change:function(e){var t=e.$el.closest("ul"),i=t.find("input[name]"),a=e.$el.is(":checked");if(e.$el.hasClass("acf-checkbox-toggle"))return void i.prop("checked",a);if(t.find(".acf-checkbox-toggle").exists()){var a=0==i.not(":checked").length;t.find(".acf-checkbox-toggle").prop("checked",a)}}})}(jQuery),function($){acf.fields.color_picker=acf.field.extend({type:"color_picker",timeout:null,actions:{ready:"initialize",append:"initialize"},focus:function(){this.$input=this.$field.find('input[type="text"]')},initialize:function(){var e=this,t=this.$input.clone();t.attr({type:"hidden","class":"",id:"",value:""}),this.$input.before(t),this.$input.wpColorPicker({change:function(i,a){e.timeout&&clearTimeout(e.timeout),e.timeout=setTimeout(function(){t.trigger("change")},1e3)}})}})}(jQuery),function($){acf.conditional_logic=acf.model.extend({actions:{"prepare 20":"render","append 20":"render"},events:{"change .acf-field input":"change","change .acf-field textarea":"change","change .acf-field select":"change"},items:{},triggers:{},add:function(e,t){for(var i in t){var a=t[i];for(var n in a){var s=a[n],o=s.field,r=this.triggers[o]||{};r[e]=e,this.triggers[o]=r}}this.items[e]=t},render:function(e){e=e||!1;var t=acf.get_fields("",e,!0);this.render_fields(t),acf.do_action("refresh",e)},change:function(e){var t=e.$el,i=acf.get_field_wrap(t),a=i.data("key");if("undefined"==typeof this.triggers[a])return!1;$parent=i.parent();for(var n in this.triggers[a]){var s=this.triggers[a][n],o=acf.get_fields(s,$parent,!0);this.render_fields(o)}acf.do_action("refresh",$parent)},render_fields:function(e){var t=this;e.each(function(){t.render_field($(this))})},render_field:function(e){var t=e.data("key");if("undefined"==typeof this.items[t])return!1;var i=!1,a=this.items[t];for(var n in a){var s=a[n],o=!0;for(var r in s){var l=s[r],c=this.get_trigger(e,l.field);if(!this.calculate(l,c,e)){o=!1;break}}if(o){i=!0;break}}i?this.show_field(e):this.hide_field(e)},show_field:function(e){e.removeClass("hidden-by-conditional-logic"),e.find(".acf-clhi").not(".hidden-by-conditional-logic .acf-clhi").removeClass("acf-clhi").prop("disabled",!1),acf.do_action("show_field",e,"conditional_logic")},hide_field:function(e){e.addClass("hidden-by-conditional-logic"),e.find("input, textarea, select").not(".acf-disabled").addClass("acf-clhi").prop("disabled",!0),acf.do_action("hide_field",e,"conditional_logic")},get_trigger:function(e,t){var i=acf.get_selector(t),a=e.siblings(i);if(!a.exists()){var n=acf.get_selector();e.parents(n).each(function(){return a=$(this).siblings(i),a.exists()?!1:void 0})}return a.exists()?a:!1},calculate:function(e,t,i){if(!t||!i)return!1;var a=t.data("type");if("true_false"==a||"checkbox"==a||"radio"==a){var n=t.find('input[value="'+e.value+'"]:checked').exists();if("=="==e.operator&&n)return!0;if("!="==e.operator&&!n)return!0}else if("select"==a){var s=t.find("select"),o=acf.get_data(s),r=[];if(o.multiple&&o.ui){r=s.val();var l=s.siblings(".select2-container");l.exists()&&(r=[],l.find(".select2-search-choice-hidden").each(function(){r.push($(this).val())}))}else o.multiple?r=s.val():o.ui?r.push(s.siblings("input").val()):r.push(s.val());if("=="==e.operator){if($.inArray(e.value,r)>-1)return!0}else if($.inArray(e.value,r)<0)return!0}return!1}})}(jQuery),function($){acf.fields.date_picker=acf.field.extend({type:"date_picker",$el:null,$input:null,$hidden:null,o:{},actions:{ready:"initialize",append:"initialize"},events:{'blur input[type="text"]':"blur"},focus:function(){this.$el=this.$field.find(".acf-date_picker"),this.$input=this.$el.find('input[type="text"]'),this.$hidden=this.$el.find('input[type="hidden"]'),this.o=acf.get_data(this.$el)},initialize:function(){this.$input.val(this.$hidden.val());var e=$.extend({},acf.l10n.date_picker,{dateFormat:"yymmdd",altField:this.$hidden,altFormat:"yymmdd",changeYear:!0,yearRange:"-100:+100",changeMonth:!0,showButtonPanel:!0,firstDay:this.o.first_day});e=acf.apply_filters("date_picker_args",e,this.$field),this.$input.addClass("active").datepicker(e),this.$input.datepicker("option","dateFormat",this.o.display_format),$("body > #ui-datepicker-div").exists()&&$("body > #ui-datepicker-div").wrap('')},blur:function(){this.$input.val()||this.$hidden.val("")}})}(jQuery),function($){acf.fields.file=acf.field.extend({type:"file",$el:null,actions:{ready:"initialize",append:"initialize"},events:{'click a[data-name="add"]':"add",'click a[data-name="edit"]':"edit",'click a[data-name="remove"]':"remove",'change input[type="file"]':"change"},focus:function(){this.$el=this.$field.find(".acf-file-uploader"),this.o=acf.get_data(this.$el)},initialize:function(){"basic"==this.o.uploader&&this.$el.closest("form").attr("enctype","multipart/form-data")},add:function(){var e=this,t=this.$field,i=acf.get_closest_field(t,"repeater"),a=acf.media.popup({title:acf._e("file","select"),mode:"select",type:"",field:acf.get_field_key(t),multiple:i.exists(),library:this.o.library,mime_types:this.o.mime_types,select:function(a,n){if(n>0){var s=acf.get_field_key(t),o=t.closest(".acf-row");if(t=!1,o.nextAll(".acf-row:visible").each(function(){return(t=acf.get_field(s,$(this)))?t.find(".acf-file-uploader.has-value").exists()?void(t=!1):!1:void 0}),!t){if(o=acf.fields.repeater.doFocus(i).add(),!o)return!1;t=acf.get_field(s,o)}}e.doFocus(t),e.render(e.prepare(a))}})},prepare:function(e){var t={id:e.id,title:e.attributes.title,name:e.attributes.filename,url:e.attributes.url,icon:e.attributes.icon,size:e.attributes.filesize};return t},render:function(e){this.$el.find('[data-name="icon"]').attr("src",e.icon),this.$el.find('[data-name="title"]').text(e.title),this.$el.find('[data-name="name"]').text(e.name).attr("href",e.url),this.$el.find('[data-name="size"]').text(e.size),this.$el.find('[data-name="id"]').val(e.id).trigger("change"),this.$el.addClass("has-value")},edit:function(){var e=this,t=this.$field,i=this.$el.find('[data-name="id"]').val(),a=acf.media.popup({title:acf._e("file","edit"),button:acf._e("file","update"),mode:"edit",id:i,select:function(i,a){e.doFocus(t),e.render(e.prepare(i))}})},remove:function(){var e={id:"",title:"",name:"",url:"",icon:"",size:""};this.render(e),this.$el.removeClass("has-value")},change:function(e){this.$el.find('[data-name="id"]').val(e.$el.val())}})}(jQuery),function($){acf.fields.google_map=acf.field.extend({type:"google_map",$el:null,$search:null,timeout:null,status:"",geocoder:!1,map:!1,maps:{},pending:$(),actions:{ready:"initialize",append:"initialize",show:"show"},events:{'click a[data-name="clear"]':"_clear",'click a[data-name="locate"]':"_locate",'click a[data-name="search"]':"_search","keydown .search":"_keydown","keyup .search":"_keyup","focus .search":"_focus","blur .search":"_blur","mousedown .acf-google-map":"_mousedown"},focus:function(){this.$el=this.$field.find(".acf-google-map"),this.$search=this.$el.find(".search"),this.o=acf.get_data(this.$el),this.maps[this.o.id]&&(this.map=this.maps[this.o.id])},is_ready:function(){var e=this;return"ready"==this.status?!0:"loading"==this.status?!1:acf.isset(window,"google","load")?acf.isset(window,"google","maps","places")?(this.status="ready",!0):(e.status="loading",google.load("maps","3",{other_params:"sensor=false&libraries=places",callback:function(){e.status="ready",e.initialize_pending()}}),!1):(e.status="loading",$.getScript("https://www.google.com/jsapi",function(){google.load("maps","3",{other_params:"sensor=false&libraries=places",callback:function(){e.status="ready",e.initialize_pending()}})}),!1)},initialize_pending:function(){var e=this;this.pending.each(function(){e.doFocus($(this)).initialize()}),this.pending=$()},initialize:function(){if(!this.is_ready())return this.pending=this.pending.add(this.$field),!1;this.geocoder||(this.geocoder=new google.maps.Geocoder);var e=this,t=this.$field,i=this.$el,a=this.$search;a.val(this.$el.find(".input-address").val());var n=acf.apply_filters("google_map_args",{zoom:parseInt(this.o.zoom),center:new google.maps.LatLng(this.o.lat,this.o.lng),mapTypeId:google.maps.MapTypeId.ROADMAP},this.$field);this.map=new google.maps.Map(this.$el.find(".canvas")[0],n);var s=new google.maps.places.Autocomplete(this.$search[0]);s.bindTo("bounds",this.map),this.map.autocomplete=s;var o=acf.apply_filters("google_map_marker_args",{draggable:!0,raiseOnDrag:!0,map:this.map},this.$field);this.map.marker=new google.maps.Marker(o),this.map.$el=i,this.map.$field=t;var r=i.find(".input-lat").val(),l=i.find(".input-lng").val();r&&l&&this.update(r,l).center(),google.maps.event.addListener(s,"place_changed",function(t){var i=this.getPlace();e.search(i)}),google.maps.event.addListener(this.map.marker,"dragend",function(){var t=this.map.marker.getPosition(),i=t.lat(),a=t.lng();e.update(i,a).sync()}),google.maps.event.addListener(this.map,"click",function(t){var i=t.latLng.lat(),a=t.latLng.lng();e.update(i,a).sync()}),this.maps[this.o.id]=this.map},search:function(e){var t=this,i=this.$search.val();if(!i)return!1;this.$el.find(".input-address").val(i);var a=i.split(",");if(2==a.length){var n=a[0],s=a[1];if($.isNumeric(n)&&$.isNumeric(s))return n=parseFloat(n),s=parseFloat(s),void t.update(n,s).center()}if(e&&e.geometry){var n=e.geometry.location.lat(),s=e.geometry.location.lng();return void t.update(n,s).center()}this.$el.addClass("-loading"),t.geocoder.geocode({address:i},function(i,a){if(t.$el.removeClass("-loading"),a!=google.maps.GeocoderStatus.OK)return void console.log("Geocoder failed due to: "+a);if(!i[0])return void console.log("No results found");e=i[0];var n=e.geometry.location.lat(),s=e.geometry.location.lng();t.update(n,s).center()})},update:function(e,t){var i=new google.maps.LatLng(e,t);return acf.val(this.$el.find(".input-lat"),e),acf.val(this.$el.find(".input-lng"),t),this.map.marker.setPosition(i),this.map.marker.setVisible(!0),this.$el.addClass("-value"),this.$field.removeClass("error"),acf.do_action("google_map_change",i,this.map,this.$field),this.$search.blur(),this},center:function(){var e=this.map.marker.getPosition(),t=this.o.lat,i=this.o.lng;e&&(t=e.lat(),i=e.lng());var a=new google.maps.LatLng(t,i);this.map.setCenter(a)},sync:function(){var e=this,t=this.map.marker.getPosition(),i=new google.maps.LatLng(t.lat(),t.lng());return this.$el.addClass("-loading"),this.geocoder.geocode({latLng:i},function(t,i){if(e.$el.removeClass("-loading"),i!=google.maps.GeocoderStatus.OK)return void console.log("Geocoder failed due to: "+i);if(!t[0])return void console.log("No results found");var a=t[0];e.$search.val(a.formatted_address),acf.val(e.$el.find(".input-address"),a.formatted_address)}),this},refresh:function(){return this.is_ready()?(google.maps.event.trigger(this.map,"resize"),void this.center()):!1},show:function(){var e=this,t=this.$field;setTimeout(function(){e.set("$field",t).refresh()},10)},_clear:function(e){this.$el.removeClass("-value -loading -search"),this.$search.val(""),acf.val(this.$el.find(".input-address"),""),acf.val(this.$el.find(".input-lat"),""),acf.val(this.$el.find(".input-lng"),""),this.map.marker.setVisible(!1)},_locate:function(e){var t=this;return navigator.geolocation?(this.$el.addClass("-loading"),void navigator.geolocation.getCurrentPosition(function(e){t.$el.removeClass("-loading");var i=e.coords.latitude,a=e.coords.longitude;t.update(i,a).sync().center()})):(alert(acf._e("google_map","browser_support")),this)},_search:function(e){this.search()},_focus:function(e){this.$el.removeClass("-value"),this._keyup()},_blur:function(e){var t=this,i=this.$el.find(".input-address").val();i&&(this.timeout=setTimeout(function(){t.$el.addClass("-value"),t.$search.val(i)},100))},_keydown:function(e){13==e.which&&e.preventDefault()},_keyup:function(e){var t=this.$search.val();t?this.$el.addClass("-search"):this.$el.removeClass("-search")},_mousedown:function(e){var t=this;setTimeout(function(){clearTimeout(t.timeout)},1)}})}(jQuery),function($){acf.fields.image=acf.field.extend({type:"image",$el:null,$input:null,$img:null,actions:{ready:"initialize",append:"initialize"},events:{'click a[data-name="add"]':"add",'click a[data-name="edit"]':"edit",'click a[data-name="remove"]':"remove",
-'change input[type="file"]':"change"},focus:function(){this.$el=this.$field.find(".acf-image-uploader"),this.$input=this.$field.find('[data-name="id"]'),this.$img=this.$field.find('[data-name="image"]'),this.o=acf.get_data(this.$el)},initialize:function(){"basic"==this.o.uploader&&this.$el.closest("form").attr("enctype","multipart/form-data")},add:function(){var e=this,t=this.$field,i=acf.get_closest_field(this.$field,"repeater"),a=acf.media.popup({title:acf._e("image","select"),mode:"select",type:"image",field:acf.get_field_key(t),multiple:i.exists(),library:this.o.library,mime_types:this.o.mime_types,select:function(a,n){if(n>0){var s=acf.get_field_key(t),o=t.closest(".acf-row");if(t=!1,o.nextAll(".acf-row:visible").each(function(){return(t=acf.get_field(s,$(this)))?t.find(".acf-image-uploader.has-value").exists()?void(t=!1):!1:void 0}),!t){if(o=acf.fields.repeater.doFocus(i).add(),!o)return!1;t=acf.get_field(s,o)}}e.doFocus(t),e.render(e.prepare(a))}})},prepare:function(e){var t={id:e.id,alt:e.attributes.alt,url:e.attributes.url};return acf.isset(e.attributes,"sizes",this.o.preview_size,"url")&&(t.url=e.attributes.sizes[this.o.preview_size].url),t},render:function(e){this.$img.attr("src",e.url),this.$img.attr("alt",e.alt),this.$input.val(e.id).trigger("change"),this.$el.addClass("has-value")},edit:function(){var e=this,t=this.$field,i=this.$input.val(),a=acf.media.popup({title:acf._e("image","edit"),button:acf._e("image","update"),mode:"edit",id:i,select:function(i,a){e.doFocus(t),e.render(e.prepare(i))}})},remove:function(){var e={id:"",alt:"",url:""};this.render(e),this.$el.removeClass("has-value")},change:function(e){this.$input.val(e.$el.val())}})}(jQuery),function($){acf.media=acf.model.extend({frames:[],mime_types:{},actions:{ready:"ready"},frame:function(){var e=this.frames.length-1;return 0>e?!1:this.frames[e]},popup:function(e){var t=this,i=acf.get("post_id");$.isNumeric(i)||(i=0);var a={mode:"select",title:"",button:"",type:"",field:"",mime_types:"",library:"all",multiple:!1};e=$.extend({},a,e);var n={title:e.title,multiple:e.multiple,library:{},states:[]};e.type&&(n.library.type=e.type),"edit"==e.mode&&(n.library.post__in=[e.id]),"uploadedTo"==e.library&&(n.library.uploadedTo=i),e.button&&(n.button={text:e.button});var s=wp.media.query(n.library);acf.isset(s,"mirroring","args")&&(s.mirroring.args._acfuploader=e.field),n.states=[new wp.media.controller.Library({library:s,multiple:n.multiple,title:n.title,priority:20,filterable:"all",editable:!0,allowLocalEdits:!0})],acf.isset(wp,"media","controller","EditImage")&&n.states.push(new wp.media.controller.EditImage);var o=wp.media(n);return acf.isset(_wpPluploadSettings,"defaults","multipart_params")&&(_wpPluploadSettings.defaults.multipart_params._acfuploader=e.field,o.on("open",function(){delete _wpPluploadSettings.defaults.multipart_params._acfuploader})),o.on("content:render:edit-image",function(){var e=this.state().get("image"),t=new wp.media.view.EditImage({model:e,controller:this}).render();this.content.set(t),t.loadEditor()},o),o.on("content:activate:browse",function(){try{var a=o.content.get().toolbar.get("filters")}catch(n){return}if("image"==e.type&&(a.filters.all.text=acf._e("image","all"),delete a.filters.audio,delete a.filters.video,$.each(a.filters,function(e,t){null===t.props.type&&(t.props.type="image")})),e.mime_types){var s=e.mime_types.split(" ").join("").split(".").join("").split(",");$.each(s,function(e,i){$.each(t.mime_types,function(e,t){if(-1!==e.indexOf(i)){var n={text:i,props:{status:null,type:t,uploadedTo:null,orderby:"date",order:"DESC"},priority:20};a.filters[t]=n}})})}"uploadedTo"==e.library&&(delete a.filters.unattached,delete a.filters.uploaded,a.$el.parent().append(''+acf._e("image","uploadedTo")+""),$.each(a.filters,function(e,t){t.props.uploadedTo=i})),$.each(a.filters,function(t,i){i.props._acfuploader=e.field}),"function"==typeof a.refresh&&a.refresh()}),"function"==typeof e.select&&o.on("select",function(){var t=this,i=-1,a=o.state().get("selection");a&&a.each(function(a){i++,e.select.apply(t,[a,i])})}),o.on("close",function(){setTimeout(function(){o.detach(),o.dispose(),o=null,t.frames.pop()},500)}),"edit"==e.mode&&(o.on("open",function(){"browse"!=this.content.mode()&&this.content.mode("browse"),this.$el.closest(".media-modal").addClass("acf-media-modal acf-expanded");var t=this.state(),i=t.get("selection"),a=wp.media.attachment(e.id);i.add(a)},o),o.on("close",function(){o.$el.closest(".media-modal").removeClass("acf-media-modal")})),e.button&&o.on("toolbar:create:select",function(t){n={text:e.button,controller:this},t.view=new wp.media.view.Toolbar.Select(n)},o),setTimeout(function(){o.open()},1),o.acf=e,this.frames.push(o),o},ready:function(){var e=acf.get("wp_version"),t=acf.get("post_id");acf.isset(window,"wp","media","view","settings","post")&&$.isNumeric(t)&&(wp.media.view.settings.post.id=t),e&&("string"==typeof e&&(e=e.substr(0,1)),$("body").addClass("acf-wp-"+e)),acf.isset(window,"wp","media","view")&&(this.customize_Attachment(),this.customize_AttachmentFiltersAll(),this.customize_AttachmentCompat())},customize_Attachment:function(){var e=wp.media.view.Attachment.Library;wp.media.view.Attachment.Library=e.extend({render:function(){var t=acf.media.frame(),i=acf.maybe_get(this,"model.attributes.acf_errors");return t&&i&&this.$el.addClass("acf-disabled"),e.prototype.render.apply(this,arguments)},toggleSelection:function(t){var i=acf.media.frame(),a=acf.maybe_get(this,"model.attributes.acf_errors"),n=this.controller.$el.find(".media-frame-content .media-sidebar");if(n.children(".acf-selection-error").remove(),n.children().removeClass("acf-hidden"),i&&a){var s=acf.maybe_get(this,"model.attributes.filename","");n.children().addClass("acf-hidden"),n.prepend([' ',t+=this.walker(e.children),t+="
':''),o.append(a))}a.append(s)}}),$("#acf-popup #term_parent").each(function(){var t=$('");e.term_parent?$(this).children('option[value="'+e.term_parent+'"]').after(t):$(this).append(t)}),this.o.type){case"select":this.$el.children("input").select2("data",t);break;case"multi_select":var i=this.$el.children("input"),a=i.select2("data")||[];a.push(t),i.select2("data",a);break;case"checkbox":case"radio":var n=this.$el.find(".categorychecklist-holder"),s=n.find('li[data-id="'+e.term_id+'"]'),o=n.get(0).scrollTop+(s.offset().top-n.offset().top);s.find("input").prop("checked",!0),n.animate({scrollTop:o},"250")}}})}(jQuery),function($){acf.fields.url=acf.field.extend({type:"url",$input:null,actions:{ready:"render",append:"render"},events:{'keyup input[type="url"]':"render"},focus:function(){this.$input=this.$field.find('input[type="url"]')},is_valid:function(){var e=this.$input.val();if(-1!==e.indexOf("://"));else if(0!==e.indexOf("//"))return!1;return!0},render:function(){this.is_valid()?this.$input.parent().addClass("valid"):this.$input.parent().removeClass("valid")}})}(jQuery),function($){acf.validation=acf.model.extend({actions:{ready:"ready",append:"ready"},filters:{validation_complete:"validation_complete"},events:{"click #save-post":"click_ignore",'click input[type="submit"]':"click_publish","submit form":"submit_form","click .acf-error-message a":"click_message"},active:1,ignore:0,busy:0,valid:!0,errors:[],error_class:"acf-error",message_class:"acf-error-message",$trigger:null,ready:function(e){e.find(".acf-field input").filter('[type="number"], [type="email"], [type="url"]').on("invalid",function(e){e.preventDefault(),acf.validation.errors.push({input:$(this).attr("name"),message:e.target.validationMessage}),acf.validation.fetch($(this).closest("form"))})},validation_complete:function(e,t){return this.errors&&this.errors.length>0&&(e.valid=0,e.errors=e.errors||[],e.errors=e.errors.concat(this.errors)),this.errors=[],e},click_message:function(e){e.preventDefault(),acf.remove_el(e.$el.parent())},click_ignore:function(e){this.ignore=1,this.$trigger=e.$el},click_publish:function(e){this.$trigger=e.$el},submit_form:function(e){if(!this.active)return!0;if(this.ignore)return this.ignore=0,!0;if(!e.$el.find("#acf-form-data").exists())return!0;var t=e.$el.find("#wp-preview");return t.exists()&&t.val()?(this.toggle(e.$el,"unlock"),!0):(e.preventDefault(),void this.fetch(e.$el))},toggle:function(e,t){t=t||"unlock";var i=null,a=null,n=$("#submitdiv");n.exists()||(n=$("#submitpost")),n.exists()||(n=e.find("p.submit").last()),n.exists()||(n=e.find(".acf-form-submit")),n.exists()||(n=e),i=n.find('input[type="submit"], .button'),a=n.find(".spinner, .acf-spinner"),this.hide_spinner(a),"unlock"==t?this.enable_submit(i):"lock"==t&&(this.disable_submit(i),this.show_spinner(a.last()))},fetch:function(e){if(this.busy)return!1;var t=this,i=acf.serialize_form(e,"acf");i.action="acf/validate_save_post",this.busy=1,this.toggle(e,"lock"),$.ajax({url:acf.get("ajaxurl"),data:i,type:"post",dataType:"json",success:function(i){acf.is_ajax_success(i)&&t.fetch_success(e,i.data)},complete:function(){t.fetch_complete(e)}})},fetch_complete:function(e){if(this.busy=0,this.toggle(e,"unlock"),this.valid){this.ignore=1;var t=e.children(".acf-error-message");t.exists()&&(t.removeClass("error"),t.children("p").html(acf._e("validation_successful"))),e.find(".acf-postbox.acf-hidden").remove(),acf.do_action("submit",e),this.$trigger?this.$trigger.click():e.submit(),this.toggle(e,"lock")}},fetch_success:function(e,t){if(t=acf.apply_filters("validation_complete",t,e),!t||t.valid||!t.errors)return void(this.valid=!0);this.valid=!1,this.$trigger=null;var i=null,a=0,n=acf._e("validation_failed");if(t.errors&&t.errors.length>0){for(var s in t.errors){var o=t.errors[s];if(o.input){var r=e.find('[name="'+o.input+'"]').first();if(r.exists()||(r=e.find('[name^="'+o.input+'"]').first()),r.exists()){a++;var l=acf.get_field_wrap(r);this.add_error(l,o.message),null===i&&(i=l)}}else n+=". "+o.message}1==a?n+=". "+acf._e("validation_failed_1"):a>1&&(n+=". "+acf._e("validation_failed_2").replace("%d",a))}var c=e.children(".acf-error-message");c.exists()||(c=$(''),e.prepend(c)),c.children("p").html(n),null===i&&(i=c),setTimeout(function(){$("html, body").animate({scrollTop:i.offset().top-$(window).height()/2},500)},1)},add_error:function(e,t){var i=this;e.addClass(this.error_class),void 0!==t&&(e.children(".acf-input").children("."+this.message_class).remove(),e.children(".acf-input").prepend('"));var a=function(){i.remove_error(e),e.off("focus change","input, textarea, select",a)};e.on("focus change","input, textarea, select",a),acf.do_action("add_field_error",e)},remove_error:function(e){$message=e.children(".acf-input").children("."+this.message_class),e.removeClass(this.error_class),setTimeout(function(){acf.remove_el($message)},250),acf.do_action("remove_field_error",e)},add_warning:function(e,t){this.add_error(e,t),setTimeout(function(){acf.validation.remove_error(e)},1e3)},show_spinner:function(e){if(e.exists()){var t=acf.get("wp_version");parseFloat(t)>=4.2?e.addClass("is-active"):e.css("display","inline-block")}},hide_spinner:function(e){if(e.exists()){var t=acf.get("wp_version");parseFloat(t)>=4.2?e.removeClass("is-active"):e.css("display","none")}},disable_submit:function(e){e.exists()&&e.addClass("disabled button-disabled button-primary-disabled")},enable_submit:function(e){e.exists()&&e.removeClass("disabled button-disabled button-primary-disabled")}})}(jQuery),function($){acf.fields.wysiwyg=acf.field.extend({type:"wysiwyg",$el:null,$textarea:null,toolbars:{},actions:{ready:"initialize",append:"initialize",remove:"disable",sortstart:"disable",sortstop:"enable"},focus:function(){this.$el=this.$field.find(".wp-editor-wrap").last(),this.$textarea=this.$el.find("textarea"),this.o=acf.get_data(this.$el),this.o.id=this.$textarea.attr("id");
-},initialize:function(){if("undefined"==typeof tinyMCEPreInit||"undefined"==typeof tinymce)return!1;var e=this.o.id,t=acf.get_uniqid("acf-editor-"),i=this.$el.outerHTML();i=acf.str_replace(e,t,i),this.$el.replaceWith(i),this.o.id=t;var a=this.get_mceInit(),n=this.get_qtInit();if(tinyMCEPreInit.mceInit[a.id]=a,tinyMCEPreInit.qtInit[n.id]=n,this.$el.hasClass("tmce-active"))try{tinymce.init(a)}catch(s){}try{var o=quicktags(n);this._buttonsInit(o)}catch(s){}},get_mceInit:function(){var e=this.$field,t=this.get_toolbar(this.o.toolbar),i=$.extend({},tinyMCEPreInit.mceInit.acf_content);if(i.selector="#"+this.o.id,i.id=this.o.id,i.elements=this.o.id,t)for(var a=tinymce.majorVersion<4?"theme_advanced_buttons":"toolbar",n=1;5>n;n++)i[a+n]=acf.isset(t,n)?t[n]:"";return tinymce.majorVersion<4?i.setup=function(t){t.onInit.add(function(t,i){$(t.getBody()).on("focus",function(){acf.validation.remove_error(e)}),$(t.getBody()).on("blur",function(){t.save(),e.find("textarea").trigger("change")})})}:i.setup=function(t){t.on("focus",function(t){acf.validation.remove_error(e)}),t.on("blur",function(i){t.save(),e.find("textarea").trigger("change")})},i.wp_autoresize_on=!1,i=acf.apply_filters("wysiwyg_tinymce_settings",i,i.id)},get_qtInit:function(){var e=$.extend({},tinyMCEPreInit.qtInit.acf_content);return e.id=this.o.id,e=acf.apply_filters("wysiwyg_quicktags_settings",e,e.id)},disable:function(){try{var e=tinyMCE.get(this.o.id);e.save(),e.destroy()}catch(t){}},enable:function(){this.$el.hasClass("tmce-active")&&acf.isset(window,"switchEditors")&&switchEditors.go(this.o.id,"tmce")},get_toolbar:function(e){return"undefined"!=typeof this.toolbars[e]?this.toolbars[e]:!1},_buttonsInit:function(e){var t=",strong,em,link,block,del,ins,img,ul,ol,li,code,more,close,";canvas=e.canvas,name=e.name,settings=e.settings,html="",theButtons={},use="",settings.buttons&&(use=","+settings.buttons+",");for(i in edButtons)edButtons[i]&&(id=edButtons[i].id,use&&-1!==t.indexOf(","+id+",")&&-1===use.indexOf(","+id+",")||edButtons[i].instance&&edButtons[i].instance!==inst||(theButtons[id]=edButtons[i],edButtons[i].html&&(html+=edButtons[i].html(name+"_"))));use&&-1!==use.indexOf(",fullscreen,")&&(theButtons.fullscreen=new qt.FullscreenButton,html+=theButtons.fullscreen.html(name+"_")),"rtl"===document.getElementsByTagName("html")[0].dir&&(theButtons.textdirection=new qt.TextDirectionButton,html+=theButtons.textdirection.html(name+"_")),e.toolbar.innerHTML=html,e.theButtons=theButtons}}),$(document).ready(function(){$("#wp-acf_content-wrap").exists()&&$("#wp-acf_content-wrap").parent().appendTo("body")})}(jQuery);
+!function(e,t){"use strict";var i=function(){function e(){return u}function t(e,t,i,a){return"string"==typeof e&&"function"==typeof t&&(i=parseInt(i||10,10),l("actions",e,t,i,a)),f}function i(){var e=Array.prototype.slice.call(arguments),t=e.shift();return"string"==typeof t&&d("actions",t,e),f}function a(e,t){return"string"==typeof e&&r("actions",e,t),f}function n(e,t,i,a){return"string"==typeof e&&"function"==typeof t&&(i=parseInt(i||10,10),l("filters",e,t,i,a)),f}function s(){var e=Array.prototype.slice.call(arguments),t=e.shift();return"string"==typeof t?d("filters",t,e):f}function o(e,t){return"string"==typeof e&&r("filters",e,t),f}function r(e,t,i,a){if(u[e][t])if(i){var n=u[e][t],s;if(a)for(s=n.length;s--;){var o=n[s];o.callback===i&&o.context===a&&n.splice(s,1)}else for(s=n.length;s--;)n[s].callback===i&&n.splice(s,1)}else u[e][t]=[]}function l(e,t,i,a,n){var s={callback:i,priority:a,context:n},o=u[e][t];o?(o.push(s),o=c(o)):o=[s],u[e][t]=o}function c(e){for(var t,i,a,n=1,s=e.length;s>n;n++){for(t=e[n],i=n;(a=e[i-1])&&a.priority>t.priority;)e[i]=e[i-1],--i;e[i]=t}return e}function d(e,t,i){var a=u[e][t];if(!a)return"filters"===e?i[0]:!1;var n=0,s=a.length;if("filters"===e)for(;s>n;n++)i[0]=a[n].callback.apply(a[n].context,i);else for(;s>n;n++)a[n].callback.apply(a[n].context,i);return"filters"===e?i[0]:!0}var f={removeFilter:o,applyFilters:s,addFilter:n,removeAction:a,doAction:i,addAction:t,storage:e},u={actions:{},filters:{}};return f};e.wp=e.wp||{},e.wp.hooks=new i}(window);var acf;!function($){$.fn.exists=function(){return $(this).length>0},$.fn.outerHTML=function(){return $(this).get(0).outerHTML},acf={l10n:{},o:{},update:function(e,t){this.o[e]=t},get:function(e){return"undefined"!=typeof this.o[e]?this.o[e]:null},_e:function(e,t){t=t||!1;var i=this.l10n[e]||"";return t&&(i=i[t]||""),i},add_action:function(){for(var e=arguments[0].split(" "),t=e.length,i=0;t>i;i++)arguments[0]="acf/"+e[i],wp.hooks.addAction.apply(this,arguments);return this},remove_action:function(){return arguments[0]="acf/"+arguments[0],wp.hooks.removeAction.apply(this,arguments),this},do_action:function(){return arguments[0]="acf/"+arguments[0],wp.hooks.doAction.apply(this,arguments),this},add_filter:function(){return arguments[0]="acf/"+arguments[0],wp.hooks.addFilter.apply(this,arguments),this},remove_filter:function(){return arguments[0]="acf/"+arguments[0],wp.hooks.removeFilter.apply(this,arguments),this},apply_filters:function(){return arguments[0]="acf/"+arguments[0],wp.hooks.applyFilters.apply(this,arguments)},get_selector:function(e){e=e||"";var t=".acf-field";if($.isPlainObject(e))if($.isEmptyObject(e))e="";else for(k in e){e=e[k];break}return e&&(t+="-"+e,t=t.split("_").join("-"),t=t.split("field-field-").join("field-")),t},get_fields:function(e,t,i){e=e||"",t=t||!1,i=i||!1;var a=this.get_selector(e),n=$(a,t);return t!==!1&&t.each(function(){$(this).is(a)&&(n=n.add($(this)))}),i||(n=acf.apply_filters("get_fields",n)),n},get_field:function(e,t){e=e||"",t=t||!1;var i=this.get_fields(e,t,!0);return i.exists()?i.first():!1},get_closest_field:function(e,t){return t=t||"",e.closest(this.get_selector(t))},get_field_wrap:function(e){return e.closest(this.get_selector())},get_field_key:function(e){return e.data("key")},get_field_type:function(e){return e.data("type")},get_data:function(e,t){return"undefined"==typeof t?e.data():e.data(t)},get_uniqid:function(e,t){"undefined"==typeof e&&(e="");var i,a=function(e,t){return e=parseInt(e,10).toString(16),t
'),e.children("td").animate({height:0},250,function(){e.remove(),"function"==typeof t&&t()})},250)},remove_el:function(e,t,i){i=i||0,e.css({height:e.height(),width:e.width(),position:"absolute"}),e.wrap(''),e.animate({opacity:0},250),e.parent(".acf-temp-wrap").animate({height:i},250,function(){$(this).remove(),"function"==typeof t&&t()})},isset:function(){var e=arguments,t=e.length,a=null,n;if(0===t)throw new Error("Empty isset");for(a=e[0],i=1;i '))}),acf.add_action("before_duplicate",function(e){e.find("select option:selected").addClass("selected")}),acf.add_action("after_duplicate",function(e,t){e.find("select option.selected").removeClass("selected"),t.find("select").each(function(){var e=[];$(this).find("option.selected").each(function(){e.push($(this).val()),$(this).removeClass("selected")}),$(this).val(e)})})}(jQuery),function($){acf.ajax=acf.model.extend({actions:{ready:"ready"},events:{"change #page_template":"_change_template","change #parent_id":"_change_parent","change #post-formats-select input":"_change_format","change .categorychecklist input":"_change_term",'change .acf-taxonomy-field[data-save="1"] input':"_change_term",'change .acf-taxonomy-field[data-save="1"] select':"_change_term"},o:{},xhr:null,update:function(e,t){return this.o[e]=t,this},get:function(e){return this.o[e]||null},ready:function(){this.update("post_id",acf.get("post_id"))},fetch:function(){if(acf.get("ajax")){this.xhr&&this.xhr.abort();var e=this,t=this.o;t.action="acf/post/get_field_groups",t.exists=[],$(".acf-postbox").not(".acf-hidden").each(function(){t.exists.push($(this).attr("id").substr(4))}),this.xhr=$.ajax({url:acf.get("ajaxurl"),data:acf.prepare_for_ajax(t),type:"post",dataType:"json",success:function(t){acf.is_ajax_success(t)&&e.render(t.data)}})}},render:function(e){$(".acf-postbox").addClass("acf-hidden"),$(".acf-postbox-toggle").addClass("acf-hidden"),$.each(e,function(e,t){var i=$("#acf-"+t.key),a=$("#acf-"+t.key+"-hide"),n=a.parent();i.removeClass("acf-hidden hide-if-js").show(),n.removeClass("acf-hidden hide-if-js").show(),a.prop("checked",!0);var s=i.find(".acf-replace-with-fields");s.exists()&&(s.replaceWith(t.html),acf.do_action("append",i)),0===e&&$("#acf-style").html(t.style),i.find(".acf-hidden-by-postbox").prop("disabled",!1)}),$(".acf-postbox.acf-hidden").find("select, textarea, input").not(":disabled").each(function(){$(this).addClass("acf-hidden-by-postbox").prop("disabled",!0)})},sync_taxonomy_terms:function(){var e=[""];$(".categorychecklist, .acf-taxonomy-field").each(function(){var t=$(this),i=t.find('input[type="checkbox"]').not(":disabled"),a=t.find('input[type="radio"]').not(":disabled"),n=t.find("select").not(":disabled"),s=t.find('input[type="hidden"]').not(":disabled");t.is(".acf-taxonomy-field")&&"1"!=t.attr("data-save")||t.closest(".media-frame").exists()||(i.exists()?i.filter(":checked").each(function(){e.push($(this).val())}):a.exists()?a.filter(":checked").each(function(){e.push($(this).val())}):n.exists()?n.find("option:selected").each(function(){e.push($(this).val())}):s.exists()&&s.each(function(){$(this).val()&&e.push($(this).val())}))}),e=e.filter(function(e,t,i){return i.indexOf(e)==t}),this.update("post_taxonomy",e).fetch()},_change_template:function(e){var t=e.$el.val();this.update("page_template",t).fetch()},_change_parent:function(e){var t="parent",i=0;""!=e.$el.val()&&(t="child",i=e.$el.val()),this.update("page_type",t).update("page_parent",i).fetch()},_change_format:function(e){var t=e.$el.val();"0"==t&&(t="standard"),this.update("post_format",t).fetch()},_change_term:function(e){var t=this;e.$el.closest(".media-frame").exists()||setTimeout(function(){t.sync_taxonomy_terms()},1)}})}(jQuery),function($){acf.fields.checkbox=acf.field.extend({type:"checkbox",events:{"change input":"change"},change:function(e){var t=e.$el.closest("ul"),i=t.find("input[name]"),a=e.$el.is(":checked");if(e.$el.hasClass("acf-checkbox-toggle"))return void i.prop("checked",a);if(t.find(".acf-checkbox-toggle").exists()){var a=0==i.not(":checked").length;t.find(".acf-checkbox-toggle").prop("checked",a)}}})}(jQuery),function($){acf.fields.color_picker=acf.field.extend({type:"color_picker",$input:null,$hidden:null,actions:{ready:"initialize",append:"initialize"},focus:function(){this.$input=this.$field.find('input[type="text"]'),this.$hidden=this.$field.find('input[type="hidden"]')},initialize:function(){var e=this.$input,t=this.$hidden,i=function(){setTimeout(function(){acf.val(t,e.val())},1)},a={defaultColor:!1,palettes:!0,hide:!0,change:i,clear:i},a=acf.apply_filters("color_picker_args",a,this.$field);this.$input.wpColorPicker(a)}})}(jQuery),function($){acf.conditional_logic=acf.model.extend({actions:{"prepare 20":"render","append 20":"render"},events:{"change .acf-field input":"change","change .acf-field textarea":"change","change .acf-field select":"change"},items:{},triggers:{},add:function(e,t){for(var i in t){var a=t[i];for(var n in a){var s=a[n],o=s.field,r=this.triggers[o]||{};r[e]=e,this.triggers[o]=r}}this.items[e]=t},render:function(e){e=e||!1;var t=acf.get_fields("",e,!0);this.render_fields(t),acf.do_action("refresh",e)},change:function(e){var t=e.$el,i=acf.get_field_wrap(t),a=i.data("key");if("undefined"==typeof this.triggers[a])return!1;$parent=i.parent();for(var n in this.triggers[a]){var s=this.triggers[a][n],o=acf.get_fields(s,$parent,!0);this.render_fields(o)}acf.do_action("refresh",$parent)},render_fields:function(e){var t=this;e.each(function(){t.render_field($(this))})},render_field:function(e){var t=e.data("key");if("undefined"==typeof this.items[t])return!1;var i=!1,a=this.items[t];for(var n in a){var s=a[n],o=!0;for(var r in s){var l=s[r],c=this.get_trigger(e,l.field);if(!this.calculate(l,c,e)){o=!1;break}}if(o){i=!0;break}}i?this.show_field(e):this.hide_field(e)},show_field:function(e){e.removeClass("hidden-by-conditional-logic"),e.find(".acf-clhi").not(".hidden-by-conditional-logic .acf-clhi").removeClass("acf-clhi").prop("disabled",!1),acf.do_action("show_field",e,"conditional_logic")},hide_field:function(e){e.addClass("hidden-by-conditional-logic"),e.find("input, textarea, select").not(".acf-disabled").addClass("acf-clhi").prop("disabled",!0),acf.do_action("hide_field",e,"conditional_logic")},get_trigger:function(e,t){var i=acf.get_selector(t),a=e.siblings(i);if(!a.exists()){var n=acf.get_selector();e.parents(n).each(function(){return a=$(this).siblings(i),a.exists()?!1:void 0})}return a.exists()?a:!1},calculate:function(e,t,i){if(!t||!i)return!1;var a=t.data("type");if("true_false"==a||"checkbox"==a||"radio"==a){var n=t.find('input[value="'+e.value+'"]:checked').exists();if("=="==e.operator&&n)return!0;if("!="==e.operator&&!n)return!0}else if("select"==a){var s=t.find("select"),o=acf.get_data(s),r=[];if(o.multiple&&o.ui){r=s.val();var l=s.siblings(".select2-container");l.exists()&&(r=[],l.find(".select2-search-choice-hidden").each(function(){r.push($(this).val())}))}else o.multiple?r=s.val():o.ui?r.push(s.siblings("input").val()):r.push(s.val());if("=="==e.operator){if($.inArray(e.value,r)>-1)return!0}else if($.inArray(e.value,r)<0)return!0}return!1}})}(jQuery),function($){acf.fields.date_picker=acf.field.extend({type:"date_picker",$el:null,$input:null,$hidden:null,o:{},actions:{ready:"initialize",append:"initialize"},events:{'blur input[type="text"]':"blur"},focus:function(){this.$el=this.$field.find(".acf-date_picker"),this.$input=this.$el.find('input[type="text"]'),this.$hidden=this.$el.find('input[type="hidden"]'),this.o=acf.get_data(this.$el)},initialize:function(){this.$input.val(this.$hidden.val());var e=$.extend({},acf.l10n.date_picker,{dateFormat:"yymmdd",altField:this.$hidden,altFormat:"yymmdd",changeYear:!0,yearRange:"-100:+100",changeMonth:!0,showButtonPanel:!0,firstDay:this.o.first_day});e=acf.apply_filters("date_picker_args",e,this.$field),this.$input.addClass("active").datepicker(e),this.$input.datepicker("option","dateFormat",this.o.display_format),$("body > #ui-datepicker-div").exists()&&$("body > #ui-datepicker-div").wrap('')},blur:function(){this.$input.val()||this.$hidden.val("")}})}(jQuery),function($){acf.fields.file=acf.field.extend({type:"file",$el:null,actions:{ready:"initialize",append:"initialize"},events:{'click a[data-name="add"]':"add",'click a[data-name="edit"]':"edit",'click a[data-name="remove"]':"remove",'change input[type="file"]':"change"},focus:function(){this.$el=this.$field.find(".acf-file-uploader"),this.o=acf.get_data(this.$el)},initialize:function(){"basic"==this.o.uploader&&this.$el.closest("form").attr("enctype","multipart/form-data")},add:function(){var e=this,t=this.$field,i=acf.get_closest_field(t,"repeater"),a=acf.media.popup({title:acf._e("file","select"),mode:"select",type:"",field:t.data("key"),multiple:i.exists(),library:this.o.library,mime_types:this.o.mime_types,select:function(a,n){if(n>0){var s=t.data("key"),o=t.closest(".acf-row");if(t=!1,o.nextAll(".acf-row:visible").each(function(){return(t=acf.get_field(s,$(this)))?t.find(".acf-file-uploader.has-value").exists()?void(t=!1):!1:void 0}),!t){if(o=acf.fields.repeater.doFocus(i).add(),!o)return!1;t=acf.get_field(s,o)}}e.doFocus(t),e.render(e.prepare(a))}})},prepare:function(e){var t={id:e.id,title:e.attributes.title,name:e.attributes.filename,url:e.attributes.url,icon:e.attributes.icon,size:e.attributes.filesize};return t},render:function(e){this.$el.find('[data-name="icon"]').attr("src",e.icon),this.$el.find('[data-name="title"]').text(e.title),this.$el.find('[data-name="name"]').text(e.name).attr("href",e.url),this.$el.find('[data-name="size"]').text(e.size),this.$el.find('[data-name="id"]').val(e.id).trigger("change"),this.$el.addClass("has-value")},edit:function(){var e=this,t=this.$field,i=this.$el.find('[data-name="id"]').val(),a=acf.media.popup({title:acf._e("file","edit"),button:acf._e("file","update"),mode:"edit",id:i,select:function(i,a){e.doFocus(t),e.render(e.prepare(i))}})},remove:function(){var e={id:"",title:"",name:"",url:"",icon:"",size:""};this.render(e),this.$el.removeClass("has-value")},change:function(e){this.$el.find('[data-name="id"]').val(e.$el.val())}})}(jQuery),function($){acf.fields.google_map=acf.field.extend({type:"google_map",$el:null,$search:null,timeout:null,status:"",geocoder:!1,map:!1,maps:{},pending:$(),actions:{ready:"initialize",append:"initialize",show:"show"},events:{'click a[data-name="clear"]':"_clear",'click a[data-name="locate"]':"_locate",'click a[data-name="search"]':"_search","keydown .search":"_keydown","keyup .search":"_keyup","focus .search":"_focus","blur .search":"_blur","mousedown .acf-google-map":"_mousedown"},focus:function(){this.$el=this.$field.find(".acf-google-map"),this.$search=this.$el.find(".search"),this.o=acf.get_data(this.$el),this.maps[this.o.id]&&(this.map=this.maps[this.o.id])},is_ready:function(){var e=this;return"ready"==this.status?!0:"loading"==this.status?!1:acf.isset(window,"google","load")?acf.isset(window,"google","maps","places")?(this.status="ready",!0):(e.status="loading",google.load("maps","3",{other_params:"sensor=false&libraries=places",callback:function(){e.status="ready",e.initialize_pending()}}),!1):(e.status="loading",$.getScript("https://www.google.com/jsapi",function(){google.load("maps","3",{other_params:"sensor=false&libraries=places",callback:function(){e.status="ready",e.initialize_pending()}})}),!1)},initialize_pending:function(){var e=this;this.pending.each(function(){e.doFocus($(this)).initialize()}),this.pending=$()},initialize:function(){if(!this.is_ready())return this.pending=this.pending.add(this.$field),!1;this.geocoder||(this.geocoder=new google.maps.Geocoder);var e=this,t=this.$field,i=this.$el,a=this.$search;a.val(this.$el.find(".input-address").val());var n=acf.apply_filters("google_map_args",{zoom:parseInt(this.o.zoom),center:new google.maps.LatLng(this.o.lat,this.o.lng),mapTypeId:google.maps.MapTypeId.ROADMAP},this.$field);this.map=new google.maps.Map(this.$el.find(".canvas")[0],n);var s=new google.maps.places.Autocomplete(this.$search[0]);s.bindTo("bounds",this.map),this.map.autocomplete=s;var o=acf.apply_filters("google_map_marker_args",{draggable:!0,raiseOnDrag:!0,map:this.map},this.$field);this.map.marker=new google.maps.Marker(o),this.map.$el=i,this.map.$field=t;var r=i.find(".input-lat").val(),l=i.find(".input-lng").val();r&&l&&this.update(r,l).center(),google.maps.event.addListener(s,"place_changed",function(t){var i=this.getPlace();e.search(i)}),google.maps.event.addListener(this.map.marker,"dragend",function(){var t=this.map.marker.getPosition(),i=t.lat(),a=t.lng();e.update(i,a).sync()}),google.maps.event.addListener(this.map,"click",function(t){var i=t.latLng.lat(),a=t.latLng.lng();e.update(i,a).sync()}),this.maps[this.o.id]=this.map},search:function(e){var t=this,i=this.$search.val();if(!i)return!1;this.$el.find(".input-address").val(i);var a=i.split(",");if(2==a.length){var n=a[0],s=a[1];if($.isNumeric(n)&&$.isNumeric(s))return n=parseFloat(n),s=parseFloat(s),void t.update(n,s).center()}if(e&&e.geometry){var n=e.geometry.location.lat(),s=e.geometry.location.lng();return void t.update(n,s).center()}this.$el.addClass("-loading"),t.geocoder.geocode({address:i},function(i,a){if(t.$el.removeClass("-loading"),a!=google.maps.GeocoderStatus.OK)return void console.log("Geocoder failed due to: "+a);if(!i[0])return void console.log("No results found");e=i[0];var n=e.geometry.location.lat(),s=e.geometry.location.lng();t.update(n,s).center()})},update:function(e,t){var i=new google.maps.LatLng(e,t);return acf.val(this.$el.find(".input-lat"),e),acf.val(this.$el.find(".input-lng"),t),this.map.marker.setPosition(i),this.map.marker.setVisible(!0),this.$el.addClass("-value"),this.$field.removeClass("error"),acf.do_action("google_map_change",i,this.map,this.$field),this.$search.blur(),this},center:function(){var e=this.map.marker.getPosition(),t=this.o.lat,i=this.o.lng;e&&(t=e.lat(),i=e.lng());var a=new google.maps.LatLng(t,i);this.map.setCenter(a)},sync:function(){var e=this,t=this.map.marker.getPosition(),i=new google.maps.LatLng(t.lat(),t.lng());return this.$el.addClass("-loading"),this.geocoder.geocode({latLng:i},function(t,i){if(e.$el.removeClass("-loading"),i!=google.maps.GeocoderStatus.OK)return void console.log("Geocoder failed due to: "+i);if(!t[0])return void console.log("No results found");var a=t[0];e.$search.val(a.formatted_address),acf.val(e.$el.find(".input-address"),a.formatted_address)}),this},refresh:function(){return this.is_ready()?(google.maps.event.trigger(this.map,"resize"),void this.center()):!1},show:function(){var e=this,t=this.$field;setTimeout(function(){e.set("$field",t).refresh()},10)},_clear:function(e){this.$el.removeClass("-value -loading -search"),this.$search.val(""),acf.val(this.$el.find(".input-address"),""),acf.val(this.$el.find(".input-lat"),""),acf.val(this.$el.find(".input-lng"),""),this.map.marker.setVisible(!1)},_locate:function(e){var t=this;return navigator.geolocation?(this.$el.addClass("-loading"),void navigator.geolocation.getCurrentPosition(function(e){t.$el.removeClass("-loading");var i=e.coords.latitude,a=e.coords.longitude;t.update(i,a).sync().center()})):(alert(acf._e("google_map","browser_support")),this)},_search:function(e){this.search()},_focus:function(e){this.$el.removeClass("-value"),this._keyup()},_blur:function(e){var t=this,i=this.$el.find(".input-address").val();i&&(this.timeout=setTimeout(function(){t.$el.addClass("-value"),t.$search.val(i)},100))},_keydown:function(e){13==e.which&&e.preventDefault()},_keyup:function(e){var t=this.$search.val();t?this.$el.addClass("-search"):this.$el.removeClass("-search")},_mousedown:function(e){var t=this;setTimeout(function(){clearTimeout(t.timeout)},1)}})}(jQuery),function($){acf.fields.image=acf.field.extend({type:"image",$el:null,$input:null,$img:null,actions:{ready:"initialize",append:"initialize"},events:{'click a[data-name="add"]':"add",'click a[data-name="edit"]':"edit",'click a[data-name="remove"]':"remove",'change input[type="file"]':"change"},focus:function(){this.$el=this.$field.find(".acf-image-uploader"),this.$input=this.$field.find('[data-name="id"]'),this.$img=this.$field.find('[data-name="image"]'),this.o=acf.get_data(this.$el)},initialize:function(){"basic"==this.o.uploader&&this.$el.closest("form").attr("enctype","multipart/form-data")},add:function(){var e=this,t=this.$field,i=acf.get_closest_field(this.$field,"repeater"),a=acf.media.popup({title:acf._e("image","select"),
+mode:"select",type:"image",field:t.data("key"),multiple:i.exists(),library:this.o.library,mime_types:this.o.mime_types,select:function(a,n){if(n>0){var s=t.data("key"),o=t.closest(".acf-row");if(t=!1,o.nextAll(".acf-row:visible").each(function(){return(t=acf.get_field(s,$(this)))?t.find(".acf-image-uploader.has-value").exists()?void(t=!1):!1:void 0}),!t){if(o=acf.fields.repeater.doFocus(i).add(),!o)return!1;t=acf.get_field(s,o)}}e.doFocus(t),e.render(e.prepare(a))}})},prepare:function(e){var t={id:e.id,alt:e.attributes.alt,url:e.attributes.url};return acf.isset(e.attributes,"sizes",this.o.preview_size,"url")&&(t.url=e.attributes.sizes[this.o.preview_size].url),t},render:function(e){this.$img.attr("src",e.url),this.$img.attr("alt",e.alt),this.$input.val(e.id).trigger("change"),this.$el.addClass("has-value")},edit:function(){var e=this,t=this.$field,i=this.$input.val(),a=acf.media.popup({title:acf._e("image","edit"),button:acf._e("image","update"),mode:"edit",id:i,select:function(i,a){e.doFocus(t),e.render(e.prepare(i))}})},remove:function(){var e={id:"",alt:"",url:""};this.render(e),this.$el.removeClass("has-value")},change:function(e){this.$input.val(e.$el.val())}})}(jQuery),function($){acf.media=acf.model.extend({frames:[],mime_types:{},actions:{ready:"ready"},frame:function(){var e=this.frames.length-1;return 0>e?!1:this.frames[e]},popup:function(e){var t=this,i=acf.get("post_id");$.isNumeric(i)||(i=0);var a={mode:"select",title:"",button:"",type:"",field:"",mime_types:"",library:"all",multiple:!1};e=$.extend({},a,e);var n={title:e.title,multiple:e.multiple,library:{},states:[]};e.type&&(n.library.type=e.type),"edit"==e.mode&&(n.library.post__in=[e.id]),"uploadedTo"==e.library&&(n.library.uploadedTo=i),e.button&&(n.button={text:e.button});var s=wp.media.query(n.library);acf.isset(s,"mirroring","args")&&(s.mirroring.args._acfuploader=e.field),n.states=[new wp.media.controller.Library({library:s,multiple:n.multiple,title:n.title,priority:20,filterable:"all",editable:!0,allowLocalEdits:!0})],acf.isset(wp,"media","controller","EditImage")&&n.states.push(new wp.media.controller.EditImage);var o=wp.media(n);return acf.isset(_wpPluploadSettings,"defaults","multipart_params")&&(_wpPluploadSettings.defaults.multipart_params._acfuploader=e.field,o.on("open",function(){delete _wpPluploadSettings.defaults.multipart_params._acfuploader})),o.on("content:render:edit-image",function(){var e=this.state().get("image"),t=new wp.media.view.EditImage({model:e,controller:this}).render();this.content.set(t),t.loadEditor()},o),o.on("content:activate:browse",function(){try{var a=o.content.get().toolbar,n=a.get("filters"),s=a.get("search")}catch(r){return}if("image"==e.type&&(n.filters.all.text=acf._e("image","all"),delete n.filters.audio,delete n.filters.video,$.each(n.filters,function(e,t){null===t.props.type&&(t.props.type="image")})),e.mime_types){var l=e.mime_types.split(" ").join("").split(".").join("").split(",");$.each(l,function(e,i){$.each(t.mime_types,function(e,t){if(-1!==e.indexOf(i)){var a={text:i,props:{status:null,type:t,uploadedTo:null,orderby:"date",order:"DESC"},priority:20};n.filters[t]=a}})})}"uploadedTo"==e.library&&(delete n.filters.unattached,delete n.filters.uploaded,n.$el.parent().append(''+acf._e("image","uploadedTo")+""),$.each(n.filters,function(e,t){t.props.uploadedTo=i})),$.each(n.filters,function(t,i){i.props._acfuploader=e.field}),s.model.attributes._acfuploader=e.field,"function"==typeof n.refresh&&n.refresh()}),"function"==typeof e.select&&o.on("select",function(){var t=this,i=-1,a=o.state().get("selection");a&&a.each(function(a){i++,e.select.apply(t,[a,i])})}),o.on("close",function(){setTimeout(function(){o.detach(),o.dispose(),o=null,t.frames.pop()},500)}),"edit"==e.mode&&(o.on("open",function(){"browse"!=this.content.mode()&&this.content.mode("browse"),this.$el.closest(".media-modal").addClass("acf-media-modal acf-expanded");var t=this.state(),i=t.get("selection"),a=wp.media.attachment(e.id);i.add(a)},o),o.on("close",function(){o.$el.closest(".media-modal").removeClass("acf-media-modal")})),e.button&&o.on("toolbar:create:select",function(t){n={text:e.button,controller:this},t.view=new wp.media.view.Toolbar.Select(n)},o),setTimeout(function(){o.open()},1),o.acf=e,this.frames.push(o),o},ready:function(){var e=acf.get("wp_version"),t=acf.get("post_id");acf.isset(window,"wp","media","view","settings","post")&&$.isNumeric(t)&&(wp.media.view.settings.post.id=t),e&&("string"==typeof e&&(e=e.substr(0,1)),$("body").addClass("acf-wp-"+e)),acf.isset(window,"wp","media","view")&&(this.customize_Attachment(),this.customize_AttachmentFiltersAll(),this.customize_AttachmentCompat())},customize_Attachment:function(){var e=wp.media.view.Attachment.Library;wp.media.view.Attachment.Library=e.extend({render:function(){var t=acf.media.frame(),i=acf.maybe_get(this,"model.attributes.acf_errors");return t&&i&&this.$el.addClass("acf-disabled"),e.prototype.render.apply(this,arguments)},toggleSelection:function(t){var i=acf.media.frame(),a=acf.maybe_get(this,"model.attributes.acf_errors"),n=this.controller.$el.find(".media-frame-content .media-sidebar");if(n.children(".acf-selection-error").remove(),n.children().removeClass("acf-hidden"),i&&a){var s=acf.maybe_get(this,"model.attributes.filename","");n.children().addClass("acf-hidden"),n.prepend([' ',t+=this.walker(e.children),t+="
':''),o.append(a))}a.append(s)}}),$("#acf-popup #term_parent").each(function(){var t=$('");e.term_parent?$(this).children('option[value="'+e.term_parent+'"]').after(t):$(this).append(t)}),this.o.type){case"select":this.$el.children("input").select2("data",t);break;case"multi_select":var i=this.$el.children("input"),a=i.select2("data")||[];a.push(t),i.select2("data",a);break;case"checkbox":case"radio":var n=this.$el.find(".categorychecklist-holder"),s=n.find('li[data-id="'+e.term_id+'"]'),o=n.get(0).scrollTop+(s.offset().top-n.offset().top);s.find("input").prop("checked",!0),n.animate({scrollTop:o},"250")}}})}(jQuery),function($){acf.fields.url=acf.field.extend({type:"url",$input:null,actions:{ready:"render",append:"render"},events:{'keyup input[type="url"]':"render"},focus:function(){this.$input=this.$field.find('input[type="url"]')},is_valid:function(){var e=this.$input.val();if(-1!==e.indexOf("://"));else if(0!==e.indexOf("//"))return!1;return!0},render:function(){this.is_valid()?this.$input.parent().addClass("valid"):this.$input.parent().removeClass("valid")}})}(jQuery),function($){acf.validation=acf.model.extend({actions:{ready:"ready",append:"ready"},filters:{validation_complete:"validation_complete"},events:{"click #save-post":"click_ignore",'click [type="submit"]':"click_publish","submit form":"submit_form","click .acf-error-message a":"click_message"},active:1,ignore:0,busy:0,valid:!0,errors:[],error_class:"acf-error",message_class:"acf-error-message",$trigger:null,ready:function(e){e.find(".acf-field input").filter('[type="number"], [type="email"], [type="url"]').on("invalid",function(e){e.preventDefault(),acf.validation.errors.push({input:$(this).attr("name"),message:e.target.validationMessage}),acf.validation.fetch($(this).closest("form"))})},validation_complete:function(e,t){return this.errors&&this.errors.length>0&&(e.valid=0,e.errors=e.errors||[],e.errors=e.errors.concat(this.errors)),this.errors=[],e},click_message:function(e){e.preventDefault(),acf.remove_el(e.$el.parent())},click_ignore:function(e){this.ignore=1,this.$trigger=e.$el},click_publish:function(e){this.$trigger=e.$el},submit_form:function(e){if(!this.active)return!0;if(this.ignore)return this.ignore=0,!0;if(!e.$el.find("#acf-form-data").exists())return!0;var t=e.$el.find("#wp-preview");return t.exists()&&t.val()?(this.toggle(e.$el,"unlock"),!0):(e.preventDefault(),void this.fetch(e.$el))},toggle:function(e,t){t=t||"unlock";var i=null,a=null,n=$("#submitdiv");n.exists()||(n=$("#submitpost")),n.exists()||(n=e.find("p.submit").last()),n.exists()||(n=e.find(".acf-form-submit")),n.exists()||(n=e),i=n.find('input[type="submit"], .button'),a=n.find(".spinner, .acf-spinner"),this.hide_spinner(a),"unlock"==t?this.enable_submit(i):"lock"==t&&(this.disable_submit(i),this.show_spinner(a.last()))},fetch:function(e){if(this.busy)return!1;var t=this,i=acf.serialize_form(e);i.action="acf/validate_save_post",this.busy=1,this.toggle(e,"lock"),$.ajax({url:acf.get("ajaxurl"),data:i,type:"post",dataType:"json",success:function(i){acf.is_ajax_success(i)&&t.fetch_success(e,i.data)},complete:function(){t.fetch_complete(e)}})},fetch_complete:function(e){if(this.busy=0,this.toggle(e,"unlock"),this.valid){this.ignore=1;var t=e.children(".acf-error-message");t.exists()&&(t.addClass("-success"),t.children("p").html(acf._e("validation_successful"))),e.find(".acf-postbox.acf-hidden").remove(),acf.do_action("submit",e),this.$trigger?this.$trigger.click():e.submit(),this.toggle(e,"lock")}},fetch_success:function(e,t){if(t=acf.apply_filters("validation_complete",t,e),!t||t.valid||!t.errors)return void(this.valid=!0);this.valid=!1,this.$trigger=null;var i=null,a=0,n=acf._e("validation_failed");if(t.errors&&t.errors.length>0){for(var s in t.errors){var o=t.errors[s];if(o.input){var r=e.find('[name="'+o.input+'"]').first();if(r.exists()||(r=e.find('[name^="'+o.input+'"]').first()),r.exists()){a++;var l=acf.get_field_wrap(r);this.add_error(l,o.message),null===i&&(i=l)}}else n+=". "+o.message}1==a?n+=". "+acf._e("validation_failed_1"):a>1&&(n+=". "+acf._e("validation_failed_2").replace("%d",a))}var c=e.children(".acf-error-message");c.exists()||(c=$(''),e.prepend(c)),c.children("p").html(n),null===i&&(i=c),setTimeout(function(){$("html, body").animate({scrollTop:i.offset().top-$(window).height()/2},500)},1)},add_error:function(e,t){var i=this;e.addClass(this.error_class),void 0!==t&&(e.children(".acf-input").children("."+this.message_class).remove(),e.children(".acf-input").prepend('"));var a=function(){i.remove_error(e),e.off("focus change","input, textarea, select",a)};e.on("focus change","input, textarea, select",a),acf.do_action("add_field_error",e)},remove_error:function(e){$message=e.children(".acf-input").children("."+this.message_class),e.removeClass(this.error_class),setTimeout(function(){acf.remove_el($message)},250),acf.do_action("remove_field_error",e)},add_warning:function(e,t){this.add_error(e,t),setTimeout(function(){acf.validation.remove_error(e)},1e3)},show_spinner:function(e){if(e.exists()){var t=acf.get("wp_version");parseFloat(t)>=4.2?e.addClass("is-active"):e.css("display","inline-block")}},hide_spinner:function(e){if(e.exists()){var t=acf.get("wp_version");parseFloat(t)>=4.2?e.removeClass("is-active"):e.css("display","none")}},disable_submit:function(e){e.exists()&&e.addClass("disabled button-disabled button-primary-disabled")},enable_submit:function(e){e.exists()&&e.removeClass("disabled button-disabled button-primary-disabled")}})}(jQuery),function($){acf.fields.wysiwyg=acf.field.extend({type:"wysiwyg",$el:null,$textarea:null,toolbars:{},actions:{load:"initialize",append:"initialize",remove:"disable",sortstart:"disable",sortstop:"enable"},focus:function(){this.$el=this.$field.find(".wp-editor-wrap").last(),this.$textarea=this.$el.find("textarea"),this.o=acf.get_data(this.$el),this.o.id=this.$textarea.attr("id")},initialize:function(){if("undefined"==typeof tinyMCEPreInit||"undefined"==typeof tinymce)return!1;var e=this.o.id,t=acf.get_uniqid("acf-editor-"),i=this.$el.outerHTML();i=acf.str_replace(e,t,i),this.$el.replaceWith(i),this.o.id=t;var a=this.get_mceInit(),n=this.get_qtInit();if(tinyMCEPreInit.mceInit[a.id]=a,tinyMCEPreInit.qtInit[n.id]=n,this.$el.hasClass("tmce-active"))try{tinymce.init(a)}catch(s){}try{var o=quicktags(n);
+this._buttonsInit(o)}catch(s){}},get_mceInit:function(){var e=this.$field,t=this.get_toolbar(this.o.toolbar),i=$.extend({},tinyMCEPreInit.mceInit.acf_content);if(i.selector="#"+this.o.id,i.id=this.o.id,i.elements=this.o.id,t)for(var a=tinymce.majorVersion<4?"theme_advanced_buttons":"toolbar",n=1;5>n;n++)i[a+n]=acf.isset(t,n)?t[n]:"";return tinymce.majorVersion<4?i.setup=function(t){t.onInit.add(function(t,i){$(t.getBody()).on("focus",function(){acf.validation.remove_error(e)}),$(t.getBody()).on("blur",function(){t.save(),e.find("textarea").trigger("change")})})}:i.setup=function(t){t.on("focus",function(t){acf.validation.remove_error(e)}),t.on("blur",function(i){t.save(),e.find("textarea").trigger("change")})},i.wp_autoresize_on=!1,i=acf.apply_filters("wysiwyg_tinymce_settings",i,i.id)},get_qtInit:function(){var e=$.extend({},tinyMCEPreInit.qtInit.acf_content);return e.id=this.o.id,e=acf.apply_filters("wysiwyg_quicktags_settings",e,e.id)},disable:function(){try{var e=tinyMCE.get(this.o.id);e.save(),e.destroy()}catch(t){}},enable:function(){this.$el.hasClass("tmce-active")&&acf.isset(window,"switchEditors")&&switchEditors.go(this.o.id,"tmce")},get_toolbar:function(e){return"undefined"!=typeof this.toolbars[e]?this.toolbars[e]:!1},_buttonsInit:function(e){var t=",strong,em,link,block,del,ins,img,ul,ol,li,code,more,close,";canvas=e.canvas,name=e.name,settings=e.settings,html="",theButtons={},use="",settings.buttons&&(use=","+settings.buttons+",");for(i in edButtons)edButtons[i]&&(id=edButtons[i].id,use&&-1!==t.indexOf(","+id+",")&&-1===use.indexOf(","+id+",")||edButtons[i].instance&&edButtons[i].instance!==inst||(theButtons[id]=edButtons[i],edButtons[i].html&&(html+=edButtons[i].html(name+"_"))));use&&-1!==use.indexOf(",fullscreen,")&&(theButtons.fullscreen=new qt.FullscreenButton,html+=theButtons.fullscreen.html(name+"_")),"rtl"===document.getElementsByTagName("html")[0].dir&&(theButtons.textdirection=new qt.TextDirectionButton,html+=theButtons.textdirection.html(name+"_")),e.toolbar.innerHTML=html,e.theButtons=theButtons}}),$(document).ready(function(){$("#wp-acf_content-wrap").exists()&&$("#wp-acf_content-wrap").parent().appendTo("body")})}(jQuery);
diff --git a/core/field.php b/core/field.php
index 00ac25d..2b7fd17 100644
--- a/core/field.php
+++ b/core/field.php
@@ -45,6 +45,7 @@ class acf_field {
$this->add_action("acf/render_field/type={$this->name}", array($this, 'render_field'), 10, 1);
$this->add_action("acf/render_field_settings/type={$this->name}", array($this, 'render_field_settings'), 10, 1);
$this->add_action("acf/prepare_field/type={$this->name}", array($this, 'prepare_field'), 10, 1);
+ $this->add_action("acf/translate_field/type={$this->name}", array($this, 'translate_field'), 10, 1);
// input actions
diff --git a/core/input.php b/core/input.php
index d8bfb2f..07ff25c 100644
--- a/core/input.php
+++ b/core/input.php
@@ -1,30 +1,23 @@
admin_enqueue_scripts = 'admin_enqueue_scripts';
$this->admin_head = 'admin_head';
$this->admin_footer = 'admin_footer';
+ $this->enqueued = false;
+ $this->data = array();
// actions
- add_action('acf/save_post', array($this, 'save_post'), 10, 1);
- add_action('acf/input/admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'), 10, 0);
- add_action('acf/input/admin_footer', array($this, 'admin_footer'), 10, 0);
-
-
- // ajax
- add_action( 'wp_ajax_acf/validate_save_post', array($this, 'ajax_validate_save_post') );
- add_action( 'wp_ajax_nopriv_acf/validate_save_post', array($this, 'ajax_validate_save_post') );
+ add_action('acf/save_post', array($this, 'save_post'), 10, 1);
}
/*
- * init
+ * get_data
+ *
+ * This function will return form data
+ *
+ * @type function
+ * @date 4/03/2016
+ * @since 5.3.2
+ *
+ * @param $key (mixed)
+ * @return (mixed)
+ */
+
+ function get_data( $key = false ) {
+
+ // vars
+ $data = $this->data;
+
+
+ // key
+ if( $key && isset($data[ $key ]) ) {
+
+ $data = $data[ $key ];
+
+ }
+
+
+ // return
+ return $data;
+
+ }
+
+
+ /*
+ * set_data
+ *
+ * This function will se the form data
+ *
+ * @type function
+ * @date 4/03/2016
+ * @since 5.3.2
+ *
+ * @param $data (array)
+ * @return (array)
+ */
+
+ function set_data( $data ) {
+
+ // defaults
+ $data = acf_parse_args($data, array(
+ 'post_id' => 0, // ID of current post
+ 'nonce' => 'post', // nonce used for $_POST validation
+ 'validation' => 1, // runs AJAX validation
+ 'ajax' => 0, // fetches new field groups via AJAX
+ ));
+
+
+ // update
+ $this->data = $data;
+
+
+ // enqueue uploader if page allows AJAX fields to appear
+ if( $data['ajax'] ) {
+
+ add_action($this->admin_footer, 'acf_enqueue_uploader', 1);
+
+ }
+
+
+ // return
+ return $data;
+
+ }
+
+
+ /*
+ * enqueue
*
* This function will determin the actions to use for different pages
*
@@ -61,7 +124,15 @@ class acf_input {
* @return n/a
*/
- function init() {
+ function enqueue() {
+
+ // bail ealry if already enqueued
+ if( $this->enqueued ) return;
+
+
+ // update setting
+ $this->enqueued = true;
+
// global
global $pagenow;
@@ -89,84 +160,28 @@ class acf_input {
// actions
- acf_maybe_add_action($this->admin_enqueue_scripts, array($this, 'do_admin_enqueue_scripts'), 20 );
- acf_maybe_add_action($this->admin_head, array($this, 'do_admin_head'), 20 );
- acf_maybe_add_action($this->admin_footer, array($this, 'do_admin_footer'), 20 );
+ acf_maybe_add_action($this->admin_enqueue_scripts, array($this, 'admin_enqueue_scripts'), 20 );
+ acf_maybe_add_action($this->admin_head, array($this, 'admin_head'), 20 );
+ acf_maybe_add_action($this->admin_footer, array($this, 'admin_footer'), 20 );
}
- function do_admin_enqueue_scripts() {
-
- do_action('acf/input/admin_enqueue_scripts');
-
- }
-
- function do_admin_head() {
-
- do_action('acf/input/admin_head');
-
- }
-
- function do_admin_footer() {
-
- do_action('acf/input/admin_footer');
-
- }
-
-
- /*
- * save_post
- *
- * This function will save the $_POST data
- *
- * @type function
- * @date 24/10/2014
- * @since 5.0.9
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- function save_post( $post_id = 0 ) {
-
- // bai learly if empty
- if( empty($_POST['acf']) ) return;
-
-
- // save $_POST data
- foreach( $_POST['acf'] as $k => $v ) {
-
- // get field
- $field = acf_get_field( $k );
-
-
- // continue if no field
- if( !$field ) continue;
-
-
- // update
- acf_update_value( $v, $post_id, $field );
-
- }
-
- }
-
/*
* admin_enqueue_scripts
*
- * This function will enqueue all the required scripts / styles for ACF
+ * The acf input screen admin_enqueue_scripts
*
- * @type action (acf/input/admin_enqueue_scripts)
- * @date 6/10/13
- * @since 5.0.0
+ * @type function
+ * @date 4/03/2016
+ * @since 5.3.2
*
- * @param n/a
+ * @param n/a
* @return n/a
*/
function admin_enqueue_scripts() {
-
+
// scripts
wp_enqueue_script('acf-input');
@@ -174,41 +189,63 @@ class acf_input {
// styles
wp_enqueue_style('acf-input');
+
+ // do action
+ do_action('acf/input/admin_enqueue_scripts');
+
}
-
+
+ /*
+ * admin_head
+ *
+ * The acf input screen admin_head
+ *
+ * @type function
+ * @date 4/03/2016
+ * @since 5.3.2
+ *
+ * @param n/a
+ * @return n/a
+ */
+
+ function admin_head() {
+
+ // do action
+ do_action('acf/input/admin_head');
+
+ }
+
+
/*
* admin_footer
*
- * description
+ * The acf input screen admin_footer
*
* @type function
- * @date 7/10/13
- * @since 5.0.0
+ * @date 4/03/2016
+ * @since 5.3.2
*
- * @param $post_id (int)
- * @return $post_id (int)
+ * @param n/a
+ * @return n/a
*/
function admin_footer() {
- // vars
- $args = acf_get_setting('form_data');
-
-
// global
global $wp_version;
// options
$o = array(
- 'post_id' => $args['post_id'],
+ 'post_id' => acf_get_form_data('post_id'),
'nonce' => wp_create_nonce( 'acf_nonce' ),
'admin_url' => admin_url(),
'ajaxurl' => admin_url( 'admin-ajax.php' ),
- 'ajax' => $args['ajax'],
- 'validation' => $args['validation'],
- 'wp_version' => $wp_version
+ 'ajax' => acf_get_form_data('ajax'),
+ 'validation' => acf_get_form_data('validation'),
+ 'wp_version' => $wp_version,
+ 'acf_version' => acf_get_setting('version')
);
@@ -240,77 +277,64 @@ class acf_input {
/* ]]> */
$v ) {
- wp_send_json_error();
+ // get field
+ $field = acf_get_field( $k );
+
+
+ // continue if no field
+ if( !$field ) continue;
+
+
+ // update
+ acf_update_value( $v, $post_id, $field );
}
-
-
- // vars
- $json = array(
- 'valid' => 1,
- 'errors' => 0
- );
-
-
- // success
- if( acf_validate_save_post() ) {
-
- wp_send_json_success($json);
-
- }
-
-
- // update vars
- $json['valid'] = 0;
- $json['errors'] = acf_get_validation_errors();
-
-
- // return
- wp_send_json_success($json);
-
+
}
}
-
-// global
-global $acf_input;
-
-
// initialize
-$acf_input = new acf_input();
+acf()->input = new acf_input();
+endif; // class_exists check
-// class_exists check
-endif;
/*
* acf_enqueue_scripts
*
-* This function is used to setup all actions / functionality for an admin page which will contain ACF inputs
+* alias of acf()->form->enqueue()
*
* @type function
* @date 6/10/13
@@ -322,13 +346,48 @@ endif;
function acf_enqueue_scripts() {
- // globals
- global $acf_input;
+ return acf()->input->enqueue();
+}
+
+
+/*
+* acf_get_form_data
+*
+* alias of acf()->form->get_data()
+*
+* @type function
+* @date 6/10/13
+* @since 5.0.0
+*
+* @param n/a
+* @return n/a
+*/
+
+function acf_get_form_data( $key = false ) {
- // init
- $acf_input->init();
+ return acf()->input->get_data( $key );
+
+}
+
+
+/*
+* acf_set_form_data
+*
+* alias of acf()->form->set_data()
+*
+* @type function
+* @date 6/10/13
+* @since 5.0.0
+*
+* @param n/a
+* @return n/a
+*/
+
+function acf_set_form_data( $data = array() ) {
+ return acf()->input->set_data( $data );
+
}
@@ -389,26 +448,10 @@ function acf_form_data( $args = array() ) {
acf_enqueue_scripts();
- // defaults
- $args = acf_parse_args($args, array(
- 'post_id' => 0, // ID of current post
- 'nonce' => 'post', // nonce used for $_POST validation
- 'validation' => 1, // runs AJAX validation
- 'ajax' => 0, // fetches new field groups via AJAX
- ));
+ // set form data
+ $args = acf_set_form_data( $args );
- // save form_data for later actions
- acf_update_setting('form_data', $args);
-
-
- // enqueue uploader if page allows AJAX fields to appear
- if( $args['ajax'] ) {
-
- add_action('admin_footer', 'acf_enqueue_uploader', 1);
-
- }
-
?>
Validation failed
';
-
- foreach( $errors as $error ) {
-
- $message .= '
';
-
- wp_die( $message, 'Validation failed' );
-
- }
-
- return false;
-
- }
-
-
- // return
- return true;
-
-}
-
-
-/*
-* acf_validate_value
-*
-* This function will validate a value for a field
-*
-* @type function
-* @date 27/10/2014
-* @since 5.0.9
-*
-* @param $value (mixed)
-* @param $field (array)
-* @param $input (string) name attribute of DOM elmenet
-* @return (boolean)
-*/
-
-function acf_validate_value( $value, $field, $input ) {
-
- // vars
- $valid = true;
- $message = sprintf( __( '%s value is required', 'acf' ), $field['label'] );
-
-
- // valid
- if( $field['required'] ) {
-
- // valid is set to false if the value is empty, but allow 0 as a valid value
- if( empty($value) && !is_numeric($value) ) {
-
- $valid = false;
-
- }
-
- }
-
-
- // filter for 3rd party customization
- $valid = apply_filters( "acf/validate_value", $valid, $value, $field, $input );
- $valid = apply_filters( "acf/validate_value/type={$field['type']}", $valid, $value, $field, $input );
- $valid = apply_filters( "acf/validate_value/name={$field['name']}", $valid, $value, $field, $input );
- $valid = apply_filters( "acf/validate_value/key={$field['key']}", $valid, $value, $field, $input );
-
-
- // allow $valid to be a custom error message
- if( !empty($valid) && is_string($valid) ) {
-
- $message = $valid;
- $valid = false;
-
- }
-
-
- if( !$valid ) {
-
- acf_add_validation_error( $input, $message );
- return false;
-
- }
-
-
- // return
- return true;
-
-}
-
-
-/*
-* acf_add_validation_error
-*
-* This function will add an error message for a field
-*
-* @type function
-* @date 25/11/2013
-* @since 5.0.0
-*
-* @param $input (string) name attribute of DOM elmenet
-* @param $message (string) error message
-* @return $post_id (int)
-*/
-
-function acf_add_validation_error( $input, $message = '' ) {
-
- // instantiate array if empty
- if( empty($GLOBALS['acf_validation_errors']) ) {
-
- $GLOBALS['acf_validation_errors'] = array();
-
- }
-
-
- // add to array
- $GLOBALS['acf_validation_errors'][] = array(
- 'input' => $input,
- 'message' => $message
- );
-
-}
-
-
-/*
-* acf_add_validation_error
-*
-* This function will return any validation errors
-*
-* @type function
-* @date 25/11/2013
-* @since 5.0.0
-*
-* @param n/a
-* @return (array|boolean)
-*/
-
-function acf_get_validation_errors() {
-
- // bail early if no errors
- if( empty($GLOBALS['acf_validation_errors']) ) return false;
-
-
- // return
- return $GLOBALS['acf_validation_errors'];
-
-}
-
-?>
diff --git a/core/location.php b/core/location.php
index 56171fd..cf55d6d 100644
--- a/core/location.php
+++ b/core/location.php
@@ -1060,39 +1060,25 @@ class acf_location {
// validate
- if( ! $comment ) {
-
- return false;
-
- }
+ if( !$comment ) return false;
- // compare
- if( $rule['operator'] == "==" ) {
-
- $match = ( $comment == $rule['value'] );
-
- // override for "all"
- if( $rule['value'] == "all" ) {
-
- $match = true;
-
- }
-
- } elseif( $rule['operator'] == "!=" ) {
-
- $match = ( $comment != $rule['value'] );
-
- // override for "all"
- if( $rule['value'] == "all" ) {
-
- $match = false;
-
- }
-
+ // match
+ $match = ( $comment === $rule['value'] );
+
+
+ // override for "all"
+ if( $rule['value'] == "all" ) $match = true;
+
+
+ // reverse if 'not equal to'
+ if( $rule['operator'] === '!=' ) {
+
+ $match = !$match;
+
}
-
+
// return
return $match;
diff --git a/core/loop.php b/core/loop.php
new file mode 100644
index 0000000..3e04460
--- /dev/null
+++ b/core/loop.php
@@ -0,0 +1,333 @@
+loops = array();
+
+ }
+
+
+ /*
+ * is_empty
+ *
+ * This function will return true if no loops exist
+ *
+ * @type function
+ * @date 3/03/2016
+ * @since 5.3.2
+ *
+ * @param n/a
+ * @return (boolean)
+ */
+
+ function is_empty() {
+
+ return empty( $this->loops );
+
+ }
+
+
+ /*
+ * is_loop
+ *
+ * This function will return true if a loop exists for the given array index
+ *
+ * @type function
+ * @date 3/03/2016
+ * @since 5.3.2
+ *
+ * @param $i (int)
+ * @return (boolean)
+ */
+
+ function is_loop( $i = 0 ) {
+
+ return isset( $this->loops[ $i ] );
+
+ }
+
+
+ /*
+ * get_i
+ *
+ * This function will return a valid array index for the given $i
+ *
+ * @type function
+ * @date 3/03/2016
+ * @since 5.3.2
+ *
+ * @param $i (mixed)
+ * @return (int)
+ */
+
+ function get_i( $i = 0 ) {
+
+ // 'active'
+ if( $i === 'active' ) $i = -1;
+
+
+ // 'previous'
+ if( $i === 'previous' ) $i = -2;
+
+
+ // allow negative to look at end of loops
+ if( $i < 0 ) {
+
+ $i = count($this->loops) + $i;
+
+ }
+
+
+ // return
+ return $i;
+
+ }
+
+
+ /*
+ * add_loop
+ *
+ * This function will add a new loop
+ *
+ * @type function
+ * @date 3/03/2016
+ * @since 5.3.2
+ *
+ * @param $loop (array)
+ * @return n/a
+ */
+
+ function add_loop( $loop = array() ) {
+
+ // defaults
+ $loop = wp_parse_args( $loop, array(
+ 'selector' => '',
+ 'name' => '',
+ 'value' => false,
+ 'field' => false,
+ 'i' => -1,
+ 'post_id' => 0,
+ ));
+
+
+ // append
+ $this->loops[] = $loop;
+
+ }
+
+
+ /*
+ * update_loop
+ *
+ * This function will update a loop's setting
+ *
+ * @type function
+ * @date 3/03/2016
+ * @since 5.3.2
+ *
+ * @param $i (mixed)
+ * @param $key (string) the loop setting name
+ * @param $value (mixed) the loop setting value
+ * @return (boolean) true on success
+ */
+
+ function update_loop( $i = 'active', $key = null, $value = null ) {
+
+ // i
+ $i = $this->get_i( $i );
+
+
+ // bail early if no set
+ if( !$this->is_loop($i) ) return false;
+
+
+ // set
+ $this->loops[ $i ][ $key ] = $value;
+
+
+ // return
+ return true;
+
+ }
+
+
+ /*
+ * get_loop
+ *
+ * This function will return a loop, or loop's setting for a given index & key
+ *
+ * @type function
+ * @date 3/03/2016
+ * @since 5.3.2
+ *
+ * @param $i (mixed)
+ * @param $key (string) the loop setting name
+ * @return (mixed) false on failure
+ */
+
+ function get_loop( $i = 'active', $key = null ) {
+
+ // i
+ $i = $this->get_i( $i );
+
+
+ // bail early if no set
+ if( !$this->is_loop($i) ) return false;
+
+
+ // check for key
+ if( $key !== null ) {
+
+ return $this->loops[ $i ][ $key ];
+
+ }
+
+
+ // return
+ return $this->loops[ $i ];
+
+ }
+
+
+ /*
+ * remove_loop
+ *
+ * This function will remove a loop
+ *
+ * @type function
+ * @date 3/03/2016
+ * @since 5.3.2
+ *
+ * @param $i (mixed)
+ * @return (boolean) true on success
+ */
+
+ function remove_loop( $i = 'active' ) {
+
+ // i
+ $i = $this->get_i( $i );
+
+
+ // bail early if no set
+ if( !$this->is_loop($i) ) return false;
+
+
+ // remove
+ unset($this->loops[ $i ]);
+
+
+ // reset keys
+ $this->loops = array_values( $this->loops );
+
+ }
+
+}
+
+// initialize
+acf()->loop = new acf_loop();
+
+endif; // class_exists check
+
+
+
+/*
+* acf_add_loop
+*
+* alias of acf()->loop->add_loop()
+*
+* @type function
+* @date 6/10/13
+* @since 5.0.0
+*
+* @param n/a
+* @return n/a
+*/
+
+function acf_add_loop( $loop = array() ) {
+
+ return acf()->loop->add_loop( $loop );
+
+}
+
+
+/*
+* acf_update_loop
+*
+* alias of acf()->loop->update_loop()
+*
+* @type function
+* @date 6/10/13
+* @since 5.0.0
+*
+* @param n/a
+* @return n/a
+*/
+
+function acf_update_loop( $i = 'active', $key = null, $value = null ) {
+
+ return acf()->loop->update_loop( $i, $key, $value );
+
+}
+
+
+/*
+* acf_get_loop
+*
+* alias of acf()->loop->get_loop()
+*
+* @type function
+* @date 6/10/13
+* @since 5.0.0
+*
+* @param n/a
+* @return n/a
+*/
+
+function acf_get_loop( $i = 'active', $key = null ) {
+
+ return acf()->loop->get_loop( $i, $key );
+
+}
+
+
+/*
+* acf_remove_loop
+*
+* alias of acf()->loop->remove_loop()
+*
+* @type function
+* @date 6/10/13
+* @since 5.0.0
+*
+* @param n/a
+* @return n/a
+*/
+
+function acf_remove_loop( $i = 'active' ) {
+
+ return acf()->loop->remove_loop( $i );
+
+}
+
+?>
diff --git a/core/validation.php b/core/validation.php
new file mode 100644
index 0000000..b8cefd6
--- /dev/null
+++ b/core/validation.php
@@ -0,0 +1,434 @@
+errors = array();
+
+
+ // ajax
+ add_action('wp_ajax_acf/validate_save_post', array($this, 'ajax_validate_save_post'));
+ add_action('wp_ajax_nopriv_acf/validate_save_post', array($this, 'ajax_validate_save_post'));
+
+ }
+
+
+ /*
+ * add_error
+ *
+ * This function will add an error message for a field
+ *
+ * @type function
+ * @date 25/11/2013
+ * @since 5.0.0
+ *
+ * @param $input (string) name attribute of DOM elmenet
+ * @param $message (string) error message
+ * @return $post_id (int)
+ */
+
+ function add_error( $input, $message ) {
+
+ // add to array
+ $this->errors[] = array(
+ 'input' => $input,
+ 'message' => $message
+ );
+
+ }
+
+
+ /*
+ * get_error
+ *
+ * This function will return an error for a given input
+ *
+ * @type function
+ * @date 5/03/2016
+ * @since 5.3.2
+ *
+ * @param $input (string) name attribute of DOM elmenet
+ * @return (mixed)
+ */
+
+ function get_error( $input ) {
+
+ // bail early if no errors
+ if( empty($this->errors) ) return false;
+
+
+ // loop
+ foreach( $this->errors as $error ) {
+
+ if( $error['input'] === $input ) return $error;
+
+ }
+
+
+ // return
+ return false;
+
+ }
+
+
+ /*
+ * get_errors
+ *
+ * This function will return validation errors
+ *
+ * @type function
+ * @date 25/11/2013
+ * @since 5.0.0
+ *
+ * @param n/a
+ * @return (array|boolean)
+ */
+
+ function get_errors() {
+
+ // bail early if no errors
+ if( empty($this->errors) ) return false;
+
+
+ // return
+ return $this->errors;
+
+ }
+
+
+ /*
+ * reset_errors
+ *
+ * This function will remove all errors
+ *
+ * @type function
+ * @date 4/03/2016
+ * @since 5.3.2
+ *
+ * @param n/a
+ * @return n/a
+ */
+
+ function reset_errors() {
+
+ $this->errors = array();
+
+ }
+
+
+ /*
+ * ajax_validate_save_post
+ *
+ * This function will validate the $_POST data via AJAX
+ *
+ * @type function
+ * @date 27/10/2014
+ * @since 5.0.9
+ *
+ * @param n/a
+ * @return n/a
+ */
+
+ function ajax_validate_save_post() {
+
+ // bail early if _acfnonce is missing
+ if( !isset($_POST['_acfnonce']) ) {
+
+ wp_send_json_error();
+
+ }
+
+
+ // vars
+ $json = array(
+ 'valid' => 1,
+ 'errors' => 0
+ );
+
+
+ // success
+ if( acf_validate_save_post() ) {
+
+ wp_send_json_success($json);
+
+ }
+
+
+ // update vars
+ $json['valid'] = 0;
+ $json['errors'] = acf_get_validation_errors();
+
+
+ // return
+ wp_send_json_success($json);
+
+ }
+
+
+ /*
+ * validate_value
+ *
+ * This function will validate a field's value
+ *
+ * @type function
+ * @date 27/10/2014
+ * @since 5.0.9
+ *
+ * @param $value (mixed)
+ * @param $field (array)
+ * @param $input (string) name attribute of DOM elmenet
+ * @return (boolean)
+ */
+
+ function validate_value( $value, $field, $input ) {
+
+ // vars
+ $valid = true;
+ $message = sprintf( __( '%s value is required', 'acf' ), $field['label'] );
+
+
+ // valid
+ if( $field['required'] ) {
+
+ // valid is set to false if the value is empty, but allow 0 as a valid value
+ if( empty($value) && !is_numeric($value) ) {
+
+ $valid = false;
+
+ }
+
+ }
+
+
+ // filter for 3rd party customization
+ $valid = apply_filters( "acf/validate_value", $valid, $value, $field, $input );
+ $valid = apply_filters( "acf/validate_value/type={$field['type']}", $valid, $value, $field, $input );
+ $valid = apply_filters( "acf/validate_value/name={$field['name']}", $valid, $value, $field, $input );
+ $valid = apply_filters( "acf/validate_value/key={$field['key']}", $valid, $value, $field, $input );
+
+
+ // allow $valid to be a custom error message
+ if( !empty($valid) && is_string($valid) ) {
+
+ $message = $valid;
+ $valid = false;
+
+ }
+
+
+ if( !$valid ) {
+
+ acf_add_validation_error( $input, $message );
+ return false;
+
+ }
+
+
+ // return
+ return true;
+
+ }
+
+
+ /*
+ * validate_save_post
+ *
+ * This function will validate $_POST data and add errors
+ *
+ * @type function
+ * @date 25/11/2013
+ * @since 5.0.0
+ *
+ * @param $show_errors (boolean) if true, errors will be shown via a wp_die screen
+ * @return (boolean)
+ */
+
+ function validate_save_post( $show_errors = false ) {
+
+ // validate fields
+ if( !empty($_POST['acf']) ) {
+
+ // loop
+ foreach( $_POST['acf'] as $field_key => $value ) {
+
+ // get field
+ $field = acf_get_field( $field_key );
+ $input = 'acf[' . $field_key . ']';
+
+
+ // bail early if not found
+ if( !$field ) continue;
+
+
+ // validate
+ acf_validate_value( $value, $field, $input );
+
+ }
+
+ }
+
+
+ // action for 3rd party customization
+ do_action('acf/validate_save_post');
+
+
+ // vars
+ $errors = acf_get_validation_errors();
+
+
+ // bail ealry if no errors
+ if( !$errors ) return true;
+
+
+ // show errors
+ if( $show_errors ) {
+
+ $message = 'Validation failed
';
+ $message .= '';
+ foreach( $errors as $error ) {
+
+ $message .= '
';
+
+
+ // die
+ wp_die( $message, 'Validation failed' );
+
+ }
+
+
+ // return
+ return false;
+
+ }
+
+}
+
+// initialize
+acf()->validation = new acf_validation();
+
+endif; // class_exists check
+
+
+
+
+/*
+* acf_add_validation_error
+*
+* alias of acf()->validation->add_error()
+*
+* @type function
+* @date 6/10/13
+* @since 5.0.0
+*
+* @param n/a
+* @return n/a
+*/
+
+function acf_add_validation_error( $input, $message = '' ) {
+
+ return acf()->validation->add_error( $input, $message );
+
+}
+
+
+/*
+* acf_get_validation_errors
+*
+* alias of acf()->validation->get_errors()
+*
+* @type function
+* @date 6/10/13
+* @since 5.0.0
+*
+* @param n/a
+* @return n/a
+*/
+
+function acf_get_validation_errors() {
+
+ return acf()->validation->get_errors();
+
+}
+
+
+/*
+* acf_reset_validation_errors
+*
+* alias of acf()->validation->reset_errors()
+*
+* @type function
+* @date 6/10/13
+* @since 5.0.0
+*
+* @param n/a
+* @return n/a
+*/
+
+function acf_reset_validation_errors() {
+
+ return acf()->validation->reset_errors();
+
+}
+
+
+/*
+* acf_validate_save_post
+*
+* alias of acf()->validation->validate_save_post()
+*
+* @type function
+* @date 6/10/13
+* @since 5.0.0
+*
+* @param n/a
+* @return n/a
+*/
+
+function acf_validate_save_post( $show_errors = false ) {
+
+ return acf()->validation->validate_save_post( $show_errors );
+
+}
+
+
+/*
+* acf_validate_value
+*
+* alias of acf()->validation->validate_value()
+*
+* @type function
+* @date 6/10/13
+* @since 5.0.0
+*
+* @param n/a
+* @return n/a
+*/
+
+function acf_validate_value( $value, $field, $input ) {
+
+ return acf()->validation->validate_value( $value, $field, $input );
+
+}
diff --git a/fields/checkbox.php b/fields/checkbox.php
index 80f6f9a..156d822 100644
--- a/fields/checkbox.php
+++ b/fields/checkbox.php
@@ -271,11 +271,7 @@ class acf_field_checkbox extends acf_field {
// decode choices (convert to array)
$field['choices'] = acf_decode_choices($field['choices']);
- $field['default_value'] = acf_decode_choices($field['default_value']);
-
-
- // use only keys for default value
- $field['default_value'] = array_keys($field['default_value']);
+ $field['default_value'] = acf_decode_choices($field['default_value'], true);
// return
@@ -322,6 +318,31 @@ class acf_field_checkbox extends acf_field {
return $value;
}
+
+ /*
+ * translate_field
+ *
+ * This function will translate field settings
+ *
+ * @type function
+ * @date 8/03/2016
+ * @since 5.3.2
+ *
+ * @param $field (array)
+ * @return $field
+ */
+
+ function translate_field( $field ) {
+
+ // translate
+ $field['choices'] = acf_translate( $field['choices'] );
+
+
+ // return
+ return $field;
+
+ }
+
}
new acf_field_checkbox();
diff --git a/fields/color_picker.php b/fields/color_picker.php
index 270102e..5e40828 100644
--- a/fields/color_picker.php
+++ b/fields/color_picker.php
@@ -112,26 +112,18 @@ class acf_field_color_picker extends acf_field {
function render_field( $field ) {
// vars
- $atts = array();
+ $text = acf_get_sub_array( $field, array('id', 'class', 'name', 'value') );
+ $hidden = acf_get_sub_array( $field, array('name', 'value') );
$e = '';
- // populate atts
- foreach( array( 'id', 'class', 'name', 'value' ) as $k ) {
-
- $atts[ $k ] = $field[ $k ];
-
- }
-
-
// render
- $e .= '