diff --git a/admin/views/settings-tools-export.php b/admin/views/settings-tools-export.php
index 3da5216..af69a7f 100644
--- a/admin/views/settings-tools-export.php
+++ b/admin/views/settings-tools-export.php
@@ -6,10 +6,10 @@ $field_groups = acf_extract_var( $args, 'field_groups');
// replace
$str_replace = array(
- " " => "\t",
- "!!\'" => "'",
- "'!!" => "",
- "!!'" => ""
+ " " => "\t",
+ "'!!__(!!\'" => "__('",
+ "!!\', !!\'" => "', '",
+ "!!\')!!'" => "')"
);
$preg_replace = array(
diff --git a/api/api-field-group.php b/api/api-field-group.php
index aa95e5a..af39f06 100644
--- a/api/api-field-group.php
+++ b/api/api-field-group.php
@@ -71,7 +71,7 @@ function acf_get_valid_field_group( $field_group = false ) {
// filter
- $field_group = apply_filters('acf/get_valid_field_group', $field_group);
+ $field_group = apply_filters('acf/validate_field_group', $field_group);
// translate
@@ -335,6 +335,10 @@ function acf_get_field_group( $selector = null ) {
if( !$field_group ) return false;
+ // validate
+ $field_group = acf_get_valid_field_group( $field_group );
+
+
// filter for 3rd party customization
$field_group = apply_filters('acf/get_field_group', $field_group);
@@ -375,11 +379,7 @@ function _acf_get_field_group_by_id( $post_id = 0 ) {
// bail early if no post, or is not a field group
- if( empty($post) || $post->post_type != 'acf-field-group' ) {
-
- return false;
-
- }
+ if( empty($post) || $post->post_type != 'acf-field-group' ) return false;
// modify post_status (new field-group starts as auto-draft)
@@ -406,22 +406,22 @@ function _acf_get_field_group_by_id( $post_id = 0 ) {
$field_group['active'] = ($post->post_status === 'publish') ? 1 : 0;
- // is JSON
+ // override with JSON
if( acf_is_local_field_group( $field_group['key'] ) ) {
- // override
- $field_group = acf_get_local_field_group( $field_group['key'] );
+ // load JSON field
+ $local = acf_get_local_field_group( $field_group['key'] );
// restore ID
- $field_group['ID'] = $post->ID;
+ $local['ID'] = $post->ID;
+
+
+ // return
+ return $local;
}
-
- // validate
- $field_group = acf_get_valid_field_group( $field_group );
-
// return
return $field_group;
@@ -444,23 +444,43 @@ function _acf_get_field_group_by_id( $post_id = 0 ) {
function _acf_get_field_group_by_key( $key = '' ) {
- // vars
- $field_group = false;
-
-
// try JSON before DB to save query time
if( acf_is_local_field_group( $key ) ) {
- $field_group = acf_get_local_field_group( $key );
-
- // validate
- $field_group = acf_get_valid_field_group( $field_group );
-
- // return
- return $field_group;
+ return acf_get_local_field_group( $key );
}
+
+
+ // vars
+ $post_id = acf_get_field_group_id( $key );
+
+
+ // bail early if no post_id
+ if( !$post_id ) return false;
+
+
+ // return
+ return _acf_get_field_group_by_id( $post_id );
+
+}
+
+/*
+* acf_get_field_group_id
+*
+* This function will lookup a field group's ID from the DB
+* Useful for local fields to find DB sibling
+*
+* @type function
+* @date 25/06/2015
+* @since 5.5.8
+*
+* @param $key (string)
+* @return $post_id (int)
+*/
+
+function acf_get_field_group_id( $key = '' ) {
// vars
$args = array(
@@ -479,19 +499,11 @@ function _acf_get_field_group_by_key( $key = '' ) {
// validate
- if( empty($posts[0]) ) {
-
- return $field_group;
-
- }
-
-
- // load from ID
- $field_group = _acf_get_field_group_by_id( $posts[0]->ID );
+ if( empty($posts) ) return 0;
// return
- return $field_group;
+ return $posts[0]->ID;
}
@@ -1153,8 +1165,11 @@ function acf_import_field_group( $field_group ) {
function acf_prepare_field_group_for_export( $field_group ) {
- // extract field group ID
- $id = acf_extract_var( $field_group, 'ID' );
+ // extract some args
+ $extract = acf_extract_vars($field_group, array(
+ 'ID',
+ 'local' // local may have added 'php' or 'json'
+ ));
// prepare fields
diff --git a/api/api-field.php b/api/api-field.php
index 462bbc9..8eb9031 100644
--- a/api/api-field.php
+++ b/api/api-field.php
@@ -28,7 +28,7 @@ function acf_is_field_key( $key = '' ) {
// special - allow local field key to be any string
- if( acf_is_local_field($key) ) return true;
+ if( acf_is_local_field_key($key) ) return true;
// return
@@ -76,16 +76,18 @@ function acf_get_valid_field( $field = false ) {
'class' => '',
'conditional_logic' => 0,
'parent' => 0,
- 'wrapper' => array(
- 'width' => '',
- 'class' => '',
- 'id' => ''
- ),
+ 'wrapper' => array(),
'_name' => '',
'_prepare' => 0,
'_valid' => 0,
));
+ $field['wrapper'] = wp_parse_args($field['wrapper'], array(
+ 'width' => '',
+ 'class' => '',
+ 'id' => ''
+ ));
+
// _name
$field['_name'] = $field['name'];
@@ -96,8 +98,8 @@ function acf_get_valid_field( $field = false ) {
// field specific defaults
- $field = apply_filters( "acf/get_valid_field", $field );
- $field = apply_filters( "acf/get_valid_field/type={$field['type']}", $field );
+ $field = apply_filters( "acf/validate_field", $field );
+ $field = apply_filters( "acf/validate_field/type={$field['type']}", $field );
// translate
@@ -973,6 +975,14 @@ function _acf_get_field_by_key( $key = '', $db_only = false ) {
function _acf_get_field_by_name( $name = '', $db_only = false ) {
+ // try JSON before DB to save query time
+ if( !$db_only && acf_is_local_field( $name ) ) {
+
+ return acf_get_local_field( $name );
+
+ }
+
+
// vars
$args = array(
'posts_per_page' => 1,
@@ -1657,6 +1667,7 @@ function acf_prepare_field_for_export( $field ) {
// filter for 3rd party customization
$field = apply_filters( "acf/prepare_field_for_export", $field );
+ $field = apply_filters( "acf/prepare_field_for_export/type={$field['type']}", $field );
// return
@@ -1755,6 +1766,7 @@ function acf_prepare_field_for_import( $field ) {
// filter for 3rd party customization
$field = apply_filters( "acf/prepare_field_for_import", $field );
+ $field = apply_filters( "acf/prepare_field_for_import/type={$field['type']}", $field );
// return
@@ -1847,6 +1859,7 @@ function acf_maybe_get_sub_field( $selectors, $post_id = false, $strict = true )
// vars
+ $offset = acf_get_setting('row_index_offset');
$selector = acf_extract_var( $selectors, 0 );
$selectors = array_values( $selectors ); // reset keys
@@ -1866,7 +1879,7 @@ function acf_maybe_get_sub_field( $selectors, $post_id = false, $strict = true )
$sub_i = $selectors[ $j ];
$sub_s = $selectors[ $j+1 ];
$field_name = $field['name'];
-
+
// find sub field
$field = acf_get_sub_field( $sub_s, $field );
@@ -1877,7 +1890,7 @@ function acf_maybe_get_sub_field( $selectors, $post_id = false, $strict = true )
// add to name
- $field['name'] = $field_name . '_' . ($sub_i-1) . '_' . $field['name'];
+ $field['name'] = $field_name . '_' . ($sub_i-$offset) . '_' . $field['name'];
}
diff --git a/api/api-helpers.php b/api/api-helpers.php
index b4b4eeb..d2c5bfc 100644
--- a/api/api-helpers.php
+++ b/api/api-helpers.php
@@ -238,6 +238,73 @@ function acf_include( $file ) {
}
+/*
+* acf_get_external_path
+*
+* This function will return the path to a file within an external folder
+*
+* @type function
+* @date 22/2/17
+* @since 5.5.8
+*
+* @param $file (string)
+* @param $path (string)
+* @return (string)
+*/
+
+function acf_get_external_path( $file, $path = '' ) {
+
+ return trailingslashit( dirname( $file ) ) . $path;
+
+}
+
+
+/*
+* acf_get_external_dir
+*
+* This function will return the url to a file within an external folder
+*
+* @type function
+* @date 22/2/17
+* @since 5.5.8
+*
+* @param $file (string)
+* @param $path (string)
+* @return (string)
+*/
+
+function acf_get_external_dir( $file, $path = '' ) {
+
+ // vars
+ $external_url = '';
+ $external_path = acf_get_external_path( $file, $path );
+ $wp_plugin_path = wp_normalize_path(WP_PLUGIN_DIR);
+ $wp_content_path = wp_normalize_path(WP_CONTENT_DIR);
+ $wp_path = wp_normalize_path(ABSPATH);
+
+
+ // wp-content/plugins
+ if( strpos($external_path, $wp_plugin_path) === 0 ) {
+
+ return str_replace($wp_plugin_path, plugins_url(), $external_path);
+
+ }
+
+
+ // wp-content
+ if( strpos($external_path, $wp_content_path) === 0 ) {
+
+ return str_replace($wp_content_path, content_url(), $external_path);
+
+ }
+
+
+ // return
+ return str_replace($wp_path, home_url(), $external_path);
+
+}
+
+
/*
* acf_parse_args
*
@@ -626,7 +693,7 @@ function acf_get_post_types( $args = array() ) {
$exclude[] = 'acf-field';
$exclude[] = 'acf-field-group';
-
+
// loop
foreach( $post_types as $i => $post_type ) {
@@ -1339,7 +1406,7 @@ function acf_decode_taxonomy_terms( $strings = false ) {
/*
* acf_decode_taxonomy_term
*
-* This function will convert a term string into an array of term data
+* This function will return the taxonomy and term slug for a given value
*
* @type function
* @date 31/03/2014
@@ -1349,34 +1416,71 @@ function acf_decode_taxonomy_terms( $strings = false ) {
* @return (array)
*/
-function acf_decode_taxonomy_term( $string ) {
+function acf_decode_taxonomy_term( $value ) {
// vars
- $r = array();
+ $data = array(
+ 'taxonomy' => '',
+ 'term' => ''
+ );
- // vars
- $data = explode(':', $string);
- $taxonomy = 'category';
- $term = '';
-
-
- // check data
- if( isset($data[1]) ) {
+ // int
+ if( is_numeric($value) ) {
- $taxonomy = $data[0];
- $term = $data[1];
+ $data['term'] = $value;
+
+ // string
+ } elseif( is_string($value) ) {
+
+ $value = explode(':', $value);
+ $data['taxonomy'] = isset($value[0]) ? $value[0] : '';
+ $data['term'] = isset($value[1]) ? $value[1] : '';
+
+ // error
+ } else {
+
+ return false;
}
- // add data to $r
- $r['taxonomy'] = $taxonomy;
- $r['term'] = $term;
+ // allow for term_id (Used by ACF v4)
+ if( is_numeric($data['term']) ) {
+
+ // global
+ global $wpdb;
+
+
+ // find taxonomy
+ if( !$data['taxonomy'] ) {
+
+ $data['taxonomy'] = $wpdb->get_var( $wpdb->prepare("SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d LIMIT 1", $data['term']) );
+
+ }
+
+
+ // find term (may have numeric slug '123')
+ $term = get_term_by( 'slug', $data['term'], $data['taxonomy'] );
+
+
+ // attempt get term via ID (ACF4 uses ID)
+ if( !$term ) $term = get_term( $data['term'], $data['taxonomy'] );
+
+
+ // bail early if no term
+ if( !$term ) return false;
+
+
+ // update
+ $data['taxonomy'] = $term->taxonomy;
+ $data['term'] = $term->slug;
+
+ }
// return
- return $r;
+ return $data;
}
@@ -1490,9 +1594,11 @@ function acf_get_posts( $args = array() ) {
// defaults
// leave suppress_filters as true becuase we don't want any plugins to modify the query as we know exactly what
$args = wp_parse_args( $args, array(
- 'posts_per_page' => -1,
- 'post_type' => '',
- 'post_status' => 'any'
+ 'posts_per_page' => -1,
+ 'post_type' => '',
+ 'post_status' => 'any',
+ 'update_post_meta_cache' => false,
+ 'update_post_term_cache' => false
));
@@ -2145,7 +2251,7 @@ function acf_json_encode( $json ) {
// PHP at least 5.4
if( version_compare(PHP_VERSION, '5.4.0', '>=') ) {
- return json_encode($json, JSON_PRETTY_PRINT);
+ return json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
}
@@ -2837,6 +2943,10 @@ function acf_in_array( $value = '', $array = false ) {
function acf_get_valid_post_id( $post_id = 0 ) {
+ // vars
+ $_post_id = $post_id;
+
+
// if not $post_id, load queried object
if( !$post_id ) {
@@ -2869,8 +2979,8 @@ function acf_get_valid_post_id( $post_id = 0 ) {
// term
} elseif( isset($post_id->taxonomy, $post_id->term_id) ) {
-
- $post_id = 'term_' . $post_id->term_id;
+
+ $post_id = acf_get_term_post_id( $post_id->taxonomy, $post_id->term_id );
// comment
} elseif( isset($post_id->comment_ID) ) {
@@ -2910,43 +3020,9 @@ function acf_get_valid_post_id( $post_id = 0 ) {
}
- /*
- * Override for preview
- *
- * If the $_GET['preview_id'] is set, then the user wants to see the preview data.
- * There is also the case of previewing a page with post_id = 1, but using get_field
- * to load data from another post_id.
- * In this case, we need to make sure that the autosave revision is actually related
- * to the $post_id variable. If they match, then the autosave data will be used, otherwise,
- * the user wants to load data from a completely different post_id
- */
-
- if( isset($_GET['preview_id']) ) {
-
- $autosave = wp_get_post_autosave( $_GET['preview_id'] );
-
- if( $autosave && $autosave->post_parent == $post_id ) {
-
- $post_id = (int) $autosave->ID;
-
- }
-
- } elseif( isset($_GET['p']) && isset($_GET['preview']) ) {
-
- $revision = acf_get_post_latest_revision( $_GET['p'] );
-
- // save
- if( $revision && $revision->post_parent == $post_id) {
-
- $post_id = (int) $revision->ID;
-
- }
-
- }
-
// filter for 3rd party
- $post_id = apply_filters('acf/get_valid_post_id', $post_id);
+ $post_id = apply_filters('acf/validate_post_id', $post_id, $_post_id);
// return
@@ -3001,7 +3077,7 @@ function acf_get_post_id_info( $post_id = 0 ) {
$type = explode($glue, $post_id);
$id = array_pop($type);
$type = implode($glue, $type);
- $meta = array('post', 'user', 'comment', 'term'); // add in 'term'
+ $meta = array('post', 'user', 'comment', 'term');
// check if is taxonomy (ACF < 5.5)
@@ -3035,6 +3111,7 @@ function acf_get_post_id_info( $post_id = 0 ) {
}
+
/*
acf_log( acf_get_post_id_info(4) );
@@ -3088,6 +3165,36 @@ function acf_isset_termmeta( $taxonomy = '' ) {
}
+/*
+* acf_get_term_post_id
+*
+* This function will return a valid post_id string for a given term and taxonomy
+*
+* @type function
+* @date 6/2/17
+* @since 5.5.6
+*
+* @param $taxonomy (string)
+* @param $term_id (int)
+* @return (string)
+*/
+
+function acf_get_term_post_id( $taxonomy, $term_id ) {
+
+ // WP < 4.4
+ if( !acf_isset_termmeta() ) {
+
+ return $taxonomy . '_' . $term_id;
+
+ }
+
+
+ // return
+ return 'term_' . $term_id;
+
+}
+
+
/*
* acf_upload_files
*
@@ -3845,7 +3952,8 @@ function acf_validate_attachment( $attachment, $field, $context = 'prepare' ) {
// custom
} else {
- $file = wp_parse_args($file, $attachment);
+ $file = array_merge($file, $attachment);
+ $file['type'] = pathinfo($attachment['url'], PATHINFO_EXTENSION);
}
@@ -4105,7 +4213,8 @@ function acf_translate( $string ) {
function acf_maybe_add_action( $tag, $function_to_add, $priority = 10, $accepted_args = 1 ) {
// if action has already run, execute it
- if( did_action($tag) ) {
+ // - if currently doing action, allow $tag to be added as per usual to allow $priority ordering needed for 3rd party asset compatibility
+ if( did_action($tag) && !doing_action($tag) ) {
call_user_func( $function_to_add );
@@ -4913,4 +5022,151 @@ function _acf_settings_slug( $v ) {
return $slug;
}
+
+
+
+/*
+* acf_strip_protocol
+*
+* This function will remove the proticol from a url
+* Used to allow licences to remain active if a site is switched to https
+*
+* @type function
+* @date 10/01/2017
+* @since 5.5.4
+* @author Aaron
+*
+* @param $url (string)
+* @return (string)
+*/
+
+function acf_strip_protocol( $url ) {
+
+ // strip the protical
+ return str_replace(array('http://','https://'), '', $url);
+
+}
+
+
+/*
+* acf_connect_attachment_to_post
+*
+* This function will connect an attacment (image etc) to the post
+* Used to connect attachements uploaded directly to media that have not been attaced to a post
+*
+* @type function
+* @date 11/01/2017
+* @since 5.5.4
+*
+* @param $attachment_id (int)
+* @param $post_id (int)
+* @return (boolean)
+*/
+
+function acf_connect_attachment_to_post( $attachment_id = 0, $post_id = 0 ) {
+
+ // bail ealry if $attachment_id is not valid
+ if( !$attachment_id || !is_numeric($attachment_id) ) return false;
+
+
+ // bail ealry if $post_id is not valid
+ if( !$post_id || !is_numeric($post_id) ) return false;
+
+
+ // vars
+ $post = get_post( $attachment_id );
+
+
+ // check if valid post
+ if( $post && $post->post_type == 'attachment' && $post->post_parent == 0 ) {
+
+ // update
+ wp_update_post( array('ID' => $post->ID, 'post_parent' => $post_id) );
+
+
+ // return
+ return true;
+
+ }
+
+
+ // return
+ return true;
+
+}
+
+
+/*
+* acf_encrypt
+*
+* This function will encrypt a string using PHP
+* https://bhoover.com/using-php-openssl_encrypt-openssl_decrypt-encrypt-decrypt-data/
+*
+* @type function
+* @date 27/2/17
+* @since 5.5.8
+*
+* @param $data (string)
+* @return (string)
+*/
+
+
+function acf_encrypt( $data = '' ) {
+
+ // bail ealry if no encrypt function
+ if( !function_exists('openssl_encrypt') ) return base64_encode($data);
+
+
+ // generate a key
+ $key = wp_hash('acf_encrypt');
+
+
+ // Generate an initialization vector
+ $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-cbc'));
+
+
+ // Encrypt the data using AES 256 encryption in CBC mode using our encryption key and initialization vector.
+ $encrypted_data = openssl_encrypt($data, 'aes-256-cbc', $key, 0, $iv);
+
+
+ // The $iv is just as important as the key for decrypting, so save it with our encrypted data using a unique separator (::)
+ return base64_encode($encrypted_data . '::' . $iv);
+
+}
+
+
+/*
+* acf_decrypt
+*
+* This function will decrypt an encrypted string using PHP
+* https://bhoover.com/using-php-openssl_encrypt-openssl_decrypt-encrypt-decrypt-data/
+*
+* @type function
+* @date 27/2/17
+* @since 5.5.8
+*
+* @param $data (string)
+* @return (string)
+*/
+
+function acf_decrypt( $data = '' ) {
+
+ // bail ealry if no decrypt function
+ if( !function_exists('openssl_decrypt') ) return base64_decode($data);
+
+
+ // generate a key
+ $key = wp_hash('acf_encrypt');
+
+
+ // To decrypt, split the encrypted data from our IV - our unique separator used was "::"
+ list($encrypted_data, $iv) = explode('::', base64_decode($data), 2);
+
+
+ // decrypt
+ return openssl_decrypt($encrypted_data, 'aes-256-cbc', $key, 0, $iv);
+
+}
+
+
?>
diff --git a/api/api-template.php b/api/api-template.php
index ad970cc..5e8c520 100644
--- a/api/api-template.php
+++ b/api/api-template.php
@@ -627,10 +627,11 @@ function get_row_index() {
// vars
$i = acf_get_loop('active', 'i');
+ $offset = acf_get_setting('row_index_offset');
// return
- return $i + 1;
+ return $offset + $i;
}
@@ -946,8 +947,8 @@ function get_row_layout() {
* @return (string)
*/
-function acf_shortcode( $atts )
-{
+function acf_shortcode( $atts ) {
+
// extract attributs
extract( shortcode_atts( array(
'field' => '',
@@ -960,594 +961,20 @@ function acf_shortcode( $atts )
$value = get_field( $field, $post_id, $format_value );
- if( is_array($value) )
- {
+ // array
+ if( is_array($value) ) {
+
$value = @implode( ', ', $value );
+
}
+ // return
return $value;
-}
-add_shortcode( 'acf', 'acf_shortcode' );
-
-
-
-/*
-* acf_template_form
-*
-* This class contains funcitonality for a template form to work
-*
-* @type function
-* @date 7/09/2016
-* @since 5.4.0
-*
-* @param $post_id (int)
-* @return $post_id (int)
-*/
-
-if( ! class_exists('acf_template_form') ) :
-
-class acf_template_form {
-
- // vars
- var $fields;
-
-
- /*
- * __construct
- *
- * This function will setup the class functionality
- *
- * @type function
- * @date 5/03/2014
- * @since 5.0.0
- *
- * @param n/a
- * @return n/a
- */
-
- function __construct() {
-
- // vars
- $this->fields = array(
-
- '_post_title' => array(
- 'prefix' => 'acf',
- 'name' => '_post_title',
- 'key' => '_post_title',
- 'label' => __('Title', 'acf'),
- 'type' => 'text',
- 'required' => true,
- ),
-
- '_post_content' => array(
- 'prefix' => 'acf',
- 'name' => '_post_content',
- 'key' => '_post_content',
- 'label' => __('Content', 'acf'),
- 'type' => 'wysiwyg',
- ),
-
- '_validate_email' => array(
- 'prefix' => 'acf',
- 'name' => '_validate_email',
- 'key' => '_validate_email',
- 'label' => __('Validate Email', 'acf'),
- 'type' => 'text',
- 'value' => '',
- 'wrapper' => array('style' => 'display:none !important;')
- )
-
- );
-
-
- // actions
- add_action('acf/validate_save_post', array($this, 'validate_save_post'), 1);
-
-
- // filters
- add_filter('acf/pre_save_post', array($this, 'pre_save_post'), 5, 2);
-
- }
-
-
- /*
- * validate_save_post
- *
- * This function will validate fields from the above array
- *
- * @type function
- * @date 7/09/2016
- * @since 5.4.0
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- function validate_save_post() {
-
- // register field if isset in $_POST
- foreach( $this->fields as $k => $field ) {
-
- // bail early if no in $_POST
- if( !isset($_POST['acf'][ $k ]) ) continue;
-
-
- // register
- acf_add_local_field($field);
-
- }
-
-
- // honeypot
- if( !empty($_POST['acf']['_validate_email']) ) {
-
- acf_add_validation_error( '', __('Spam Detected', 'acf') );
-
- }
-
- }
-
-
- /*
- * pre_save_post
- *
- * description
- *
- * @type function
- * @date 7/09/2016
- * @since 5.4.0
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- function pre_save_post( $post_id, $form ) {
-
- // vars
- $save = array(
- 'ID' => 0
- );
-
-
- // determine save data
- if( is_numeric($post_id) ) {
-
- // update post
- $save['ID'] = $post_id;
-
- } elseif( $post_id == 'new_post' ) {
-
- // new post
- $form['new_post'] = wp_parse_args( $form['new_post'], array(
- 'post_type' => 'post',
- 'post_status' => 'draft',
- ));
-
-
- // merge in new post data
- $save = array_merge($save, $form['new_post']);
-
- } else {
-
- // not post
- return $post_id;
-
- }
-
-
- // save post_title
- if( isset($_POST['acf']['_post_title']) ) {
-
- $save['post_title'] = acf_extract_var($_POST['acf'], '_post_title');
-
- }
-
-
- // save post_content
- if( isset($_POST['acf']['_post_content']) ) {
-
- $save['post_content'] = acf_extract_var($_POST['acf'], '_post_content');
-
- }
-
-
- // honeypot
- if( !empty($_POST['acf']['_validate_email']) ) return;
-
-
- // validate
- if( count($save) == 1 ) {
-
- return $post_id;
-
- }
-
-
- if( $save['ID'] ) {
-
- wp_update_post( $save );
-
- } else {
-
- $post_id = wp_insert_post( $save );
-
- }
-
-
- // return
- return $post_id;
-
- }
-
-
- /*
- * enqueue
- *
- * This function will enqueue a form
- *
- * @type function
- * @date 7/09/2016
- * @since 5.4.0
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- function enqueue_form() {
-
- // verify nonce
- if( acf_verify_nonce('acf_form') ) {
-
- // validate data
- if( acf_validate_save_post(true) ) {
-
- // form
- $GLOBALS['acf_form'] = acf_extract_var($_POST, '_acf_form');
- $GLOBALS['acf_form'] = @json_decode(base64_decode($GLOBALS['acf_form']), true);
-
-
- // validate
- if( empty($GLOBALS['acf_form']) ) return;
-
-
- // vars
- $post_id = acf_maybe_get( $GLOBALS['acf_form'], 'post_id', 0 );
-
-
- // allow for custom save
- $post_id = apply_filters('acf/pre_save_post', $post_id, $GLOBALS['acf_form']);
-
-
- // save
- acf_save_post( $post_id );
-
-
- // vars
- $return = acf_maybe_get( $GLOBALS['acf_form'], 'return', '' );
-
-
- // redirect
- if( $return ) {
-
- // update %placeholders%
- $return = str_replace('%post_url%', get_permalink($post_id), $return);
-
-
- // redirect
- wp_redirect( $return );
- exit;
- }
-
- }
- // if
-
- }
- // if
-
-
- // load acf scripts
- acf_enqueue_scripts();
-
- }
-
-
- /*
- * render
- *
- * description
- *
- * @type function
- * @date 7/09/2016
- * @since 5.4.0
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- function render_form( $args = array() ) {
-
- // vars
- $url = acf_get_current_url();
-
-
- // defaults
- $args = wp_parse_args( $args, array(
- 'id' => 'acf-form',
- 'post_id' => false,
- 'new_post' => false,
- 'field_groups' => false,
- 'fields' => false,
- 'post_title' => false,
- 'post_content' => false,
- 'form' => true,
- 'form_attributes' => array(),
- 'return' => add_query_arg( 'updated', 'true', $url ),
- 'html_before_fields' => '',
- 'html_after_fields' => '',
- 'submit_value' => __("Update", 'acf'),
- 'updated_message' => __("Post updated", 'acf'),
- 'label_placement' => 'top',
- 'instruction_placement' => 'label',
- 'field_el' => 'div',
- 'uploader' => 'wp',
- 'honeypot' => true
- ));
-
- $args['form_attributes'] = wp_parse_args( $args['form_attributes'], array(
- 'id' => $args['id'],
- 'class' => 'acf-form',
- 'action' => '',
- 'method' => 'post',
- ));
-
-
- // filter post_id
- $args['post_id'] = acf_get_valid_post_id( $args['post_id'] );
-
-
- // load values from this post
- $post_id = $args['post_id'];
-
-
- // new post?
- if( $post_id == 'new_post' ) {
-
- // dont load values
- $post_id = false;
-
-
- // new post defaults
- $args['new_post'] = wp_parse_args( $args['new_post'], array(
- 'post_type' => 'post',
- 'post_status' => 'draft',
- ));
-
- }
-
-
- // register local fields
- foreach( $this->fields as $k => $field ) {
-
- acf_add_local_field($field);
-
- }
-
-
- // vars
- $field_groups = array();
- $fields = array();
-
-
- // post_title
- if( $args['post_title'] ) {
-
- // load local field
- $_post_title = acf_get_field('_post_title');
- $_post_title['value'] = $post_id ? get_post_field('post_title', $post_id) : '';
-
-
- // append
- $fields[] = $_post_title;
-
- }
-
-
- // post_content
- if( $args['post_content'] ) {
-
- // load local field
- $_post_content = acf_get_field('_post_content');
- $_post_content['value'] = $post_id ? get_post_field('post_content', $post_id) : '';
-
-
- // append
- $fields[] = $_post_content;
-
- }
-
-
- // specific fields
- if( $args['fields'] ) {
-
- foreach( $args['fields'] as $selector ) {
-
- // append field ($strict = false to allow for better compatibility with field names)
- $fields[] = acf_maybe_get_field( $selector, $post_id, false );
-
- }
-
- } elseif( $args['field_groups'] ) {
-
- foreach( $args['field_groups'] as $selector ) {
-
- $field_groups[] = acf_get_field_group( $selector );
-
- }
-
- } elseif( $args['post_id'] == 'new_post' ) {
-
- $field_groups = acf_get_field_groups( $args['new_post'] );
-
- } else {
-
- $field_groups = acf_get_field_groups(array(
- 'post_id' => $args['post_id']
- ));
-
- }
-
-
- //load fields based on field groups
- if( !empty($field_groups) ) {
-
- foreach( $field_groups as $field_group ) {
-
- $field_group_fields = acf_get_fields( $field_group );
-
- if( !empty($field_group_fields) ) {
-
- foreach( array_keys($field_group_fields) as $i ) {
-
- $fields[] = acf_extract_var($field_group_fields, $i);
- }
-
- }
-
- }
-
- }
-
-
- // honeypot
- if( $args['honeypot'] ) {
-
- $fields[] = acf_get_field('_validate_email');
-
- }
-
-
- // updated message
- if( !empty($_GET['updated']) && $args['updated_message'] ) {
-
- echo '
' . $args['updated_message'] . '
';
-
- }
-
-
- // uploader (always set incase of multiple forms on the page)
- acf_update_setting('uploader', $args['uploader']);
-
-
- // display form
- if( $args['form'] ): ?>
-
-
- template_form = new acf_template_form();
-
-endif; // class_exists check
-
-
-/*
-* acf_form_head()
-*
-* This function is placed at the very top of a template (before any HTML is rendered) and saves the $_POST data sent by acf_form.
-*
-* @type function
-* @since 1.1.4
-* @date 29/01/13
-*
-* @param n/a
-* @return n/a
-*/
-
-function acf_form_head() {
-
- acf()->template_form->enqueue_form();
-
-}
-
-
-/*
-* acf_form()
-*
-* This function is used to create an ACF form.
-*
-* @type function
-* @since 1.1.4
-* @date 29/01/13
-*
-* @param array $options: an array containing many options to customize the form
-* string + post_id: post id to get field groups from and save data to. Default is false
-* array + field_groups: an array containing field group ID's. If this option is set,
-* the post_id will not be used to dynamically find the field groups
-* boolean + form: display the form tag or not. Defaults to true
-* array + form_attributes: an array containg attributes which will be added into the form tag
-* string + return: the return URL
-* string + html_before_fields: html inside form before fields
-* string + html_after_fields: html inside form after fields
-* string + submit_value: value of submit button
-* string + updated_message: default updated message. Can be false
-*
-* @return N/A
-*/
-
-function acf_form( $args = array() ) {
-
- acf()->template_form->render_form($args);
-
-}
+add_shortcode('acf', 'acf_shortcode');
/*
@@ -1576,13 +1003,14 @@ function update_field( $selector, $value, $post_id = false ) {
// create dummy field
- if( !$field )
- {
+ if( !$field ) {
+
$field = acf_get_valid_field(array(
'name' => $selector,
'key' => '',
'type' => '',
));
+
}
@@ -1613,17 +1041,15 @@ function update_sub_field( $selector, $value, $post_id = false ) {
$sub_field = false;
- // filter post_id
- $post_id = acf_get_valid_post_id( $post_id );
-
-
// get sub field
if( is_array($selector) ) {
+ $post_id = acf_get_valid_post_id( $post_id );
$sub_field = acf_maybe_get_sub_field( $selector, $post_id, false );
-
+
} else {
+ $post_id = acf_get_loop('active', 'post_id');
$sub_field = get_row_sub_field( $selector );
}
@@ -1713,7 +1139,7 @@ function add_row( $selector, $row = false, $post_id = false ) {
// get field
- $field = acf_maybe_get_field( $selector, $post_id );
+ $field = acf_maybe_get_field( $selector, $post_id, false );
// bail early if no field
@@ -1733,7 +1159,11 @@ function add_row( $selector, $row = false, $post_id = false ) {
// update value
- return acf_update_value( $value, $post_id, $field );
+ acf_update_value( $value, $post_id, $field );
+
+
+ // return
+ return count($value);
}
@@ -1759,17 +1189,15 @@ function add_sub_row( $selector, $row = false, $post_id = false ) {
$sub_field = false;
- // filter post_id
- $post_id = acf_get_valid_post_id( $post_id );
-
-
// get sub field
if( is_array($selector) ) {
+ $post_id = acf_get_valid_post_id( $post_id );
$sub_field = acf_maybe_get_sub_field( $selector, $post_id, false );
} else {
+ $post_id = acf_get_loop('active', 'post_id');
$sub_field = get_row_sub_field( $selector );
}
@@ -1792,7 +1220,11 @@ function add_sub_row( $selector, $row = false, $post_id = false ) {
// update
- return acf_update_value( $value, $post_id, $sub_field );
+ acf_update_value( $value, $post_id, $sub_field );
+
+
+ // return
+ return count($value);
}
@@ -1816,7 +1248,8 @@ function add_sub_row( $selector, $row = false, $post_id = false ) {
function update_row( $selector, $i = 1, $row = false, $post_id = false ) {
// vars
- $i--;
+ $offset = acf_get_setting('row_index_offset');
+ $i = $i - $offset;
// filter post_id
@@ -1824,7 +1257,7 @@ function update_row( $selector, $i = 1, $row = false, $post_id = false ) {
// get field
- $field = acf_maybe_get_field( $selector, $post_id );
+ $field = acf_maybe_get_field( $selector, $post_id, false );
// bail early if no field
@@ -1872,20 +1305,19 @@ function update_sub_row( $selector, $i = 1, $row = false, $post_id = false ) {
// vars
$sub_field = false;
- $i--;
-
-
- // filter post_id
- $post_id = acf_get_valid_post_id( $post_id );
+ $offset = acf_get_setting('row_index_offset');
+ $i = $i - $offset;
// get sub field
if( is_array($selector) ) {
+ $post_id = acf_get_valid_post_id( $post_id );
$sub_field = acf_maybe_get_sub_field( $selector, $post_id, false );
} else {
+ $post_id = acf_get_loop('active', 'post_id');
$sub_field = get_row_sub_field( $selector );
}
@@ -1935,7 +1367,8 @@ function update_sub_row( $selector, $i = 1, $row = false, $post_id = false ) {
function delete_row( $selector, $i = 1, $post_id = false ) {
// vars
- $i--;
+ $offset = acf_get_setting('row_index_offset');
+ $i = $i - $offset;
// filter post_id
@@ -1957,13 +1390,21 @@ function delete_row( $selector, $i = 1, $post_id = false ) {
// ensure array
$value = acf_get_array($value);
+
+ // bail early if index doesn't exist
+ if( !isset($value[ $i ]) ) return false;
+
// unset
unset( $value[ $i ] );
// update
- return acf_update_value( $value, $post_id, $field );
+ acf_update_value( $value, $post_id, $field );
+
+
+ // return
+ return true;
}
@@ -1987,20 +1428,19 @@ function delete_sub_row( $selector, $i = 1, $post_id = false ) {
// vars
$sub_field = false;
- $i--;
-
-
- // filter post_id
- $post_id = acf_get_valid_post_id( $post_id );
+ $offset = acf_get_setting('row_index_offset');
+ $i = $i - $offset;
// get sub field
if( is_array($selector) ) {
+ $post_id = acf_get_valid_post_id( $post_id );
$sub_field = acf_maybe_get_sub_field( $selector, $post_id, false );
} else {
+ $post_id = acf_get_loop('active', 'post_id');
$sub_field = get_row_sub_field( $selector );
}
@@ -2018,12 +1458,20 @@ function delete_sub_row( $selector, $i = 1, $post_id = false ) {
$value = acf_get_array( $value );
+ // bail early if index doesn't exist
+ if( !isset($value[ $i ]) ) return false;
+
+
// append
unset( $value[ $i ] );
// update
- return acf_update_value( $value, $post_id, $sub_field );
+ acf_update_value( $value, $post_id, $sub_field );
+
+
+ // return
+ return true;
}
@@ -2041,12 +1489,6 @@ function delete_sub_row( $selector, $i = 1, $post_id = false ) {
* @return n/a
*/
-function register_field_group( $field_group ) {
-
- acf_add_local_field_group( $field_group );
-
-}
-
function create_field( $field ) {
acf_render_field( $field );
diff --git a/api/api-value.php b/api/api-value.php
index 82378ed..9ba6239 100644
--- a/api/api-value.php
+++ b/api/api-value.php
@@ -351,7 +351,15 @@ function acf_update_value( $value = null, $post_id = 0, $field ) {
$value = apply_filters( "acf/update_value/name={$field['name']}", $value, $post_id, $field );
$value = apply_filters( "acf/update_value/key={$field['key']}", $value, $post_id, $field );
-
+
+ // allow null to delete
+ if( $value === null ) {
+
+ return acf_delete_value( $post_id, $field );
+
+ }
+
+
// update value
$return = acf_update_metadata( $post_id, $field['name'], $value );
diff --git a/assets/css/acf-field-group.css b/assets/css/acf-field-group.css
index be17e24..8072912 100644
--- a/assets/css/acf-field-group.css
+++ b/assets/css/acf-field-group.css
@@ -37,6 +37,15 @@
* Postbox: Fields
*
*---------------------------------------------------------------------------------------------*/
+.acf-field p.description {
+ margin: 0;
+ padding: 0;
+ font-style: normal;
+ font-size: 12px;
+ line-height: 1.4em;
+ color: #777777;
+ display: block;
+}
#acf-field-group-fields > .inside,
#acf-field-group-locations > .inside,
#acf-field-group-options > .inside {
diff --git a/assets/css/acf-global.css b/assets/css/acf-global.css
index 324d193..eb42c78 100644
--- a/assets/css/acf-global.css
+++ b/assets/css/acf-global.css
@@ -636,48 +636,53 @@ a.acf-icon.-cancel.grey:hover {
margin: 0;
width: 100%;
clear: both;
+ /* defaults */
+ /* thead */
+ /* tbody */
+ /* -clear */
}
-.acf-table > tbody > tr {
- z-index: 1;
-}
+.acf-table > tbody > tr > th,
.acf-table > thead > tr > th,
-.acf-table > tbody > tr > td {
+.acf-table > tbody > tr > td,
+.acf-table > thead > tr > td {
padding: 8px;
vertical-align: top;
background: #fff;
text-align: left;
- font-size: 14px;
- line-height: 1.4em;
border-style: solid;
- border-color: #EDEDED;
- border-width: 1px 0 0 1px;
+ font-weight: normal;
}
-/* th */
+.acf-table > tbody > tr > th,
.acf-table > thead > tr > th {
position: relative;
color: #333333;
- font-weight: normal;
+}
+.acf-table > thead > tr > th {
border-color: #E1E1E1;
border-width: 0 0 1px 1px;
}
.acf-table > thead > tr > th:first-child {
border-left-width: 0;
}
-/* td */
-.acf-table > tbody > tr > td {
- font-size: 13px;
+.acf-table > tbody > tr {
+ z-index: 1;
}
-.acf-table > tbody > tr:first-child > td {
- border-top-width: 0;
+.acf-table > tbody > tr > td {
+ border-color: #EDEDED;
+ border-width: 1px 0 0 1px;
}
.acf-table > tbody > tr > td:first-child {
border-left-width: 0;
}
-/* clear table */
+.acf-table > tbody > tr:first-child > td {
+ border-top-width: 0;
+}
.acf-table.-clear {
border: 0 none;
}
.acf-table.-clear > tbody > tr > td,
+.acf-table.-clear > thead > tr > td,
+.acf-table.-clear > tbody > tr > th,
.acf-table.-clear > thead > tr > th {
border: 0 none;
padding: 4px;
diff --git a/assets/css/acf-input.css b/assets/css/acf-input.css
index ff7eefd..4966a66 100644
--- a/assets/css/acf-input.css
+++ b/assets/css/acf-input.css
@@ -24,6 +24,11 @@
/* input */
/* error */
}
+.acf-field p.description {
+ display: block;
+ margin: 0;
+ padding: 0;
+}
.acf-field .acf-label {
vertical-align: top;
margin: 0 0 10px;
@@ -31,22 +36,15 @@
.acf-field .acf-label label {
display: block;
font-weight: bold;
- font-size: 13px;
- line-height: 1.4em;
margin: 0 0 3px;
-}
-.acf-field .acf-label p {
- color: #777777;
- display: block;
- font-size: 12px;
- line-height: 1.4em;
- font-style: normal;
- margin: 3px 0 0 !important;
- padding: 0 !important;
+ padding: 0;
}
.acf-field .acf-input {
vertical-align: top;
}
+.acf-field .acf-input > p.description {
+ margin-top: 5px;
+}
.acf-field .acf-error-message {
background: #F55E4F;
color: #fff;
@@ -497,9 +495,6 @@ html[dir="rtl"] input.acf-is-prepended.acf-is-appended {
margin: 0;
padding: 5px 5px 5px 7px;
}
-.select2-container.-acf .select2-search-choice-close {
- margin-top: -1px;
-}
.select2-container.-acf .select2-choice {
border-color: #BBBBBB;
}
@@ -520,6 +515,17 @@ html[dir="rtl"] input.acf-is-prepended.acf-is-appended {
background: #fff;
border-color: #5B9DD9;
}
+/* rtl */
+html[dir="rtl"] .select2-container.-acf .select2-search-choice-close {
+ left: 24px;
+}
+html[dir="rtl"] .select2-container.-acf .select2-choice > .select2-chosen {
+ margin-left: 42px;
+}
+html[dir="rtl"] .select2-container.-acf .select2-choice .select2-arrow {
+ padding-left: 0;
+ padding-right: 1px;
+}
/* description */
.select2-drop {
/* search*/
@@ -637,6 +643,7 @@ html[dir="rtl"] ul.acf-checkbox-list input[type="radio"] {
transition: background 0.25s ease;
/* hover */
/* active */
+ /* focus */
/* message */
}
.acf-switch span {
@@ -681,9 +688,23 @@ html[dir="rtl"] ul.acf-checkbox-list input[type="radio"] {
right: 3px;
border-color: #1f7db1;
}
+.acf-switch.-focus .acf-switch-slider {
+ border-color: #5b9dd9;
+ box-shadow: 0 0 2px rgba(30, 140, 190, 0.5);
+}
+.acf-switch.-focus.-on .acf-switch-slider {
+ border-color: #185e85;
+ box-shadow: 0 0 2px #1f7db1;
+}
.acf-switch + span {
margin-left: 6px;
}
+/* checkbox */
+.acf-switch-input {
+ opacity: 0;
+ position: absolute;
+ margin: 0;
+}
/*
.acf-field[data-name="alt"] .acf-switch {
background: #fff;
@@ -1021,6 +1042,10 @@ html[dir="rtl"] .acf-relationship .selection .values .acf-icon {
.acf-editor-wrap.tmce-active .wp-editor-area {
color: #333 !important;
}
+/* fix z-index behind media modal */
+div.mce-toolbar-grp.mce-inline-toolbar-grp {
+ z-index: 170000;
+}
/*---------------------------------------------------------------------------------------------
*
* Tab
@@ -1667,19 +1692,22 @@ html[dir="rtl"] .acf-taxonomy-field[data-type="select"] .acf-icon {
float: left;
}
.media-modal .compat-attachment-fields > tbody > .acf-field > .acf-label > label {
- padding-top: 7px;
- margin: 5px 0 0;
+ padding-top: 6px;
+ margin: 0;
color: #666666;
font-weight: 400;
line-height: 16px;
}
.media-modal .compat-attachment-fields > tbody > .acf-field > .acf-input {
width: 65%;
- margin: 5px 0 0;
+ margin: 0;
padding: 0;
float: right;
display: block;
}
+.media-modal .compat-attachment-fields > tbody > .acf-field p.description {
+ margin: 0;
+}
/* restricted selection (copy of WP .upload-errors)*/
.acf-selection-error {
background: #ffebe8;
@@ -1718,8 +1746,7 @@ html[dir="rtl"] .acf-taxonomy-field[data-type="select"] .acf-icon {
/* fix % margin which causes .acf-uploadedTo to drop down below select */
/* allow line breaks in upload error */
/* fix required span */
- /* Sidebar: Collapse */
- /* Create gallery fix */
+ /* sidebar */
/* mobile md */
}
.media-modal .compat-field-acf-form-data,
@@ -1747,28 +1774,8 @@ html[dir="rtl"] .acf-taxonomy-field[data-type="select"] .acf-icon {
float: none !important;
color: #f00 !important;
}
-.media-modal .compat-item .label {
- margin: 0;
-}
-.media-modal .media-sidebar .setting span,
-.media-modal .compat-item label span,
-.media-modal .media-sidebar .setting input,
-.media-modal .media-sidebar .setting textarea,
-.media-modal .compat-item .field {
- min-height: 0;
- margin: 5px 0 0;
-}
-.media-modal .media-sidebar .setting span,
-.media-modal .compat-item label span {
- padding-top: 7px;
-}
-.media-modal .attachment-display-settings .setting span {
- margin-top: 0;
- margin-right: 3%;
-}
-.media-modal .media-modal .media-sidebar .collection-settings .setting span {
- padding-top: 8px;
- margin: 0 10px 0 0;
+.media-modal .media-sidebar .compat-item {
+ padding-bottom: 20px;
}
@media (max-width: 900px) {
.media-modal {
@@ -1844,14 +1851,12 @@ html[dir="rtl"] .acf-taxonomy-field[data-type="select"] .acf-icon {
.media-modal.acf-expanded .acf-expand-details .is-closed {
display: none;
}
-.media-modal.acf-expanded .attachments-browser .media-toolbar {
- right: 700px;
-}
+.media-modal.acf-expanded .media-toolbar,
.media-modal.acf-expanded .attachments {
- right: 700px;
+ right: 740px;
}
.media-modal.acf-expanded .media-sidebar {
- width: 667px;
+ width: 708px;
}
.media-modal.acf-expanded .media-sidebar {
/* label */
@@ -1869,6 +1874,9 @@ html[dir="rtl"] .acf-taxonomy-field[data-type="select"] .acf-icon {
.media-modal.acf-expanded .media-sidebar .compat-attachment-fields > tbody > .acf-field > .acf-input {
min-width: 77%;
}
+.media-modal.acf-expanded .media-sidebar .setting span {
+ margin-right: 2%;
+}
.media-modal.acf-expanded .media-sidebar .attachment-info .thumbnail {
max-height: none;
}
@@ -1964,8 +1972,8 @@ body.major-4 .acf-media-modal.-edit .media-frame-content {
}
.acf-media-modal.-edit .media-sidebar {
padding: 0 16px;
- /* reposition thumbnail */
- /* add missing padding below fields */
+ /* WP details */
+ /* ACF fields */
}
.acf-media-modal.-edit .media-sidebar .attachment-details {
overflow: visible;
@@ -1986,14 +1994,21 @@ body.major-4 .acf-media-modal.-edit .media-frame-content {
.acf-media-modal.-edit .media-sidebar .attachment-details .thumbnail {
margin: 0 16px 0 0;
}
-.acf-media-modal.-edit .media-sidebar .attachment-details label {
+.acf-media-modal.-edit .media-sidebar .attachment-details .setting {
display: block;
overflow: hidden;
float: none;
width: auto;
+ margin: 0 0 5px;
}
-.acf-media-modal.-edit .media-sidebar .compat-item {
- padding-bottom: 16px;
+.acf-media-modal.-edit .media-sidebar .attachment-details .setting span {
+ margin: 0;
+}
+.acf-media-modal.-edit .media-sidebar .compat-attachment-fields > tbody > .acf-field {
+ margin: 0 0 5px;
+}
+.acf-media-modal.-edit .media-sidebar .compat-attachment-fields > tbody > .acf-field p.description {
+ margin-top: 3px;
}
@media (max-width: 900px) {
.acf-media-modal.-edit {
@@ -2092,11 +2107,19 @@ p.submit .acf-spinner {
* Widget
*
*--------------------------------------------------------------------------------------------*/
+#widgets-right .widget .acf-field .description {
+ padding-left: 0;
+ padding-right: 0;
+}
+.widget .acf-field {
+ margin: 1em 0;
+}
.widget .acf-field .acf-label {
- margin: 0;
+ margin-bottom: 5px;
}
.widget .acf-field .acf-label label {
font-weight: normal;
+ margin: 0;
}
.widget .widget-inside > form > .acf-error-message {
margin-top: 15px;
diff --git a/assets/js/acf-field-group.js b/assets/js/acf-field-group.js
index d124c10..02daf76 100644
--- a/assets/js/acf-field-group.js
+++ b/assets/js/acf-field-group.js
@@ -1308,7 +1308,7 @@
parent : acf.o.post_id,
field_group : acf.o.post_id,
prefix : $select.attr('name').replace('[type]', ''),
- type : new_type,
+ type : new_type
};
@@ -2315,7 +2315,7 @@
'change_field_type' : '_change_field_type',
'change_field_label' : '_change_field_label',
'change_field_name' : '_change_field_name',
- 'render_field_settings' : '_render_field_settings',
+ 'render_field_settings' : '_render_field_settings'
},
_save_field: function( $el ){
@@ -2405,7 +2405,7 @@
acf.field_group.append = acf.model.extend({
actions: {
- 'render_field_settings' : '_render_field_settings',
+ 'render_field_settings' : '_render_field_settings'
},
render: function( $el ){
@@ -2491,7 +2491,7 @@
type: 'select',
actions: {
- 'render_settings': 'render',
+ 'render_settings': 'render'
},
events: {
@@ -2536,7 +2536,7 @@
type: 'radio',
actions: {
- 'render_settings': 'render',
+ 'render_settings': 'render'
},
events: {
@@ -2581,7 +2581,7 @@
type: 'true_false',
actions: {
- 'render_settings': 'render',
+ 'render_settings': 'render'
},
events: {
@@ -2627,7 +2627,7 @@
type: 'date_picker',
actions: {
- 'render_settings': 'render',
+ 'render_settings': 'render'
},
events: {
@@ -2720,7 +2720,7 @@
type: 'tab',
actions: {
- 'render_settings': 'render',
+ 'render_settings': 'render'
},
render: function( $el ){
@@ -2844,8 +2844,244 @@
}
+ }
+
+ });
+
+
+ /*
+ * sub fields
+ *
+ * description
+ *
+ * @type function
+ * @date 31/1/17
+ * @since 5.5.6
+ *
+ * @param $post_id (int)
+ * @return $post_id (int)
+ */
+
+ acf.field_group.sub_fields = acf.model.extend({
+
+ actions: {
+ 'open_field': 'update_field_parent',
+ 'sortstop': 'update_field_parent',
+ 'duplicate_field': 'duplicate_field',
+ 'delete_field': 'delete_field',
+ 'change_field_type': 'change_field_type'
},
+
+ /*
+ * fix_conditional_logic
+ *
+ * This function will update sub field conditional logic rules after duplication
+ *
+ * @type function
+ * @date 10/06/2014
+ * @since 5.0.0
+ *
+ * @param $fields (jquery selection)
+ * @return n/a
+ */
+
+ fix_conditional_logic : function( $fields ){
+
+ // build refernce
+ var ref = {};
+
+ $fields.each(function(){
+
+ ref[ $(this).attr('data-orig') ] = $(this).attr('data-key');
+
+ });
+
+
+ $fields.find('.conditional-rule-param').each(function(){
+
+ // vars
+ var key = $(this).val();
+
+
+ // bail early if val is not a ref key
+ if( !(key in ref) ) {
+
+ return;
+
+ }
+
+
+ // add option if doesn't yet exist
+ if( ! $(this).find('option[value="' + ref[key] + '"]').exists() ) {
+
+ $(this).append('
');
+
+ }
+
+
+ // set new val
+ $(this).val( ref[key] );
+
+ });
+
+ },
+
+
+ /*
+ * update_field_parent
+ *
+ * This function will update field meta such as parent
+ *
+ * @type function
+ * @date 8/04/2014
+ * @since 5.0.0
+ *
+ * @param $el
+ * @return n/a
+ */
+
+ update_field_parent: function( $el ){
+
+ // bail early if not div.field (flexible content tr)
+ if( !$el.hasClass('acf-field-object') ) return;
+
+
+ // vars
+ var $parent = $el.parent().closest('.acf-field-object'),
+ val = acf.get('post_id');
+
+
+ // find parent
+ if( $parent.exists() ) {
+
+ // set as parent ID
+ val = acf.field_group.get_field_meta( $parent, 'ID' );
+
+
+ // if parent is new, no ID exists
+ if( !val ) {
+
+ val = acf.field_group.get_field_meta( $parent, 'key' );
+
+ }
+
+ }
+
+
+ // update parent
+ acf.field_group.update_field_meta( $el, 'parent', val );
+
+
+ // action for 3rd party customization
+ acf.do_action('update_field_parent', $el, $parent);
+
+ },
+
+
+ /*
+ * duplicate_field
+ *
+ * This function is triggered when duplicating a field
+ *
+ * @type function
+ * @date 8/04/2014
+ * @since 5.0.0
+ *
+ * @param $el
+ * @return n/a
+ */
+
+ duplicate_field: function( $el ) {
+
+ // vars
+ var $fields = $el.find('.acf-field-object');
+
+
+ // bail early if $fields are empty
+ if( !$fields.exists() ) {
+
+ return;
+
+ }
+
+
+ // loop over sub fields
+ $fields.each(function(){
+
+ // vars
+ var $parent = $(this).parent().closest('.acf-field-object'),
+ key = acf.field_group.get_field_meta( $parent, 'key');
+
+
+ // wipe field
+ acf.field_group.wipe_field( $(this) );
+
+
+ // update parent
+ acf.field_group.update_field_meta( $(this), 'parent', key );
+
+
+ // save field
+ acf.field_group.save_field( $(this) );
+
+
+ });
+
+
+ // fix conditional logic rules
+ this.fix_conditional_logic( $fields );
+
+ },
+
+
+ /*
+ * delete_field
+ *
+ * This function is triggered when deleting a field
+ *
+ * @type function
+ * @date 8/04/2014
+ * @since 5.0.0
+ *
+ * @param $el
+ * @return n/a
+ */
+
+ delete_field : function( $el ){
+
+ $el.find('.acf-field-object').each(function(){
+
+ acf.field_group.delete_field( $(this), false );
+
+ });
+
+ },
+
+
+ /*
+ * change_field_type
+ *
+ * This function is triggered when changing a field type
+ *
+ * @type function
+ * @date 7/06/2014
+ * @since 5.0.0
+ *
+ * @param $post_id (int)
+ * @return $post_id (int)
+ */
+
+ change_field_type : function( $el ) {
+
+ $el.find('.acf-field-object').each(function(){
+
+ acf.field_group.delete_field( $(this), false );
+
+ });
+
+ }
+
});
})(jQuery);
diff --git a/assets/js/acf-field-group.min.js b/assets/js/acf-field-group.min.js
index 0a97bdb..63fccfb 100644
--- a/assets/js/acf-field-group.min.js
+++ b/assets/js/acf-field-group.min.js
@@ -1 +1 @@
-!function($){acf.field_group=acf.model.extend({$fields:null,$locations:null,$options:null,actions:{ready:"init"},events:{"submit #post":"submit",'click a[href="#"]':"preventDefault","click .submitdelete":"trash","mouseenter .acf-field-list":"sortable"},init:function(){this.$fields=$("#acf-field-group-fields"),this.$locations=$("#acf-field-group-locations"),this.$options=$("#acf-field-group-options"),acf.validation.active=0},sortable:function(e){if(!e.$el.hasClass("ui-sortable")){var t=this;e.$el.sortable({handle:".acf-sortable-handle",connectWith:".acf-field-list",update:function(e,i){var a=i.item;t.render_fields(),acf.do_action("sortstop",a)}})}},preventDefault:function(e){e.preventDefault()},get_selector:function(e){e=e||"";var t=".acf-field-object";return e&&(t+="-"+e,t=t.split("_").join("-")),t},render_fields:function(){var e=this;$(".acf-field-list").each(function(){var t=$(this).children(".acf-field-object");t.each(function(t){e.update_field_meta($(this),"menu_order",t),$(this).children(".handle").find(".acf-icon").html(t+1)}),t.exists()?$(this).children(".no-fields-message").hide():$(this).children(".no-fields-message").show()})},get_field_meta:function(e,t){var i=e.find("> .meta > .input-"+t);return!!i.exists()&&i.val()},update_field_meta:function(e,t,i){var a=e.find("> .meta > .input-"+t);if(!a.exists()){var n=e.find("> .meta > .input-ID").outerHTML();n=acf.str_replace("ID",t,n),a=$(n),a.val(i),e.children(".meta").append(a)}a.val()!=i&&(a.val(i),"save"!=t&&this.save_field(e,"meta"))},delete_field_meta:function(e,t){var i=e.find("> .meta > .input-"+t);i.exists()&&(i.remove(),this.save_field(e,"meta"))},save_field:function(e,t){t=t||"settings";var i=this.get_field_meta(e,"save");"settings"!=i&&i!=t&&(this.update_field_meta(e,"save",t),acf.do_action("save_field",e,t))},submit:function(e){var t=this,i=$("#titlewrap #title");i.val()||(e.preventDefault(),acf.validation.toggle(e.$el,"unlock"),alert(acf._e("title_is_required")),i.focus()),$(".acf-field-object").each(function(){var e=t.get_field_meta($(this),"save"),i=t.get_field_meta($(this),"ID"),a=$(this).hasClass("open");a&&t.close_field($(this)),"settings"==e||("meta"==e?$(this).children(".settings").find('[name^="acf_fields['+i+']"]').remove():$(this).find('[name^="acf_fields['+i+']"]').remove())})},trash:function(e){var t=confirm(acf._e("move_to_trash"));t||e.preventDefault()},render_field:function(e){var t=e.find(".field-label:first").val(),i=e.find(".field-name:first").val(),a=e.find(".field-type:first option:selected").text(),n=e.find(".field-required:first").prop("checked"),d=e.children(".handle");d.find(".li-field-label strong a").text(t),d.find(".li-field-label .acf-required").remove(),n&&d.find(".li-field-label strong").append('
*'),d.find(".li-field-name").text(i),d.find(".li-field-type").text(a),acf.do_action("render_field_handle",e,d)},edit_field:function(e){e.hasClass("open")?this.close_field(e):this.open_field(e)},open_field:function(e){return!e.hasClass("open")&&(e.addClass("open"),acf.do_action("open_field",e),void e.children(".settings").animate({height:"toggle"},250))},close_field:function(e){return!!e.hasClass("open")&&(e.removeClass("open"),acf.do_action("close_field",e),void e.children(".settings").animate({height:"toggle"},250))},wipe_field:function(e){var t=e.attr("data-id"),i=e.attr("data-key"),a=acf.get_uniqid(),n="field_"+a;e.attr("data-id",a),e.attr("data-key",n),e.attr("data-orig",i),this.update_field_meta(e,"ID",""),this.update_field_meta(e,"key",n),e.find('[id*="'+t+'"]').each(function(){$(this).attr("id",$(this).attr("id").replace(t,a))}),e.find('[name*="'+t+'"]').each(function(){$(this).attr("name",$(this).attr("name").replace(t,a))}),e.find("> .handle .pre-field-key").text(n),e.find(".ui-sortable").removeClass("ui-sortable"),acf.do_action("wipe_field",e)},add_field:function(e){var t=$($("#tmpl-acf-field").html()),i=t.find(".field-label:first"),a=t.find(".field-name:first");this.wipe_field(t),e.append(t),i.val(""),a.val(""),setTimeout(function(){i.focus()},251),this.render_fields(),acf.do_action("append",t),this.edit_field(t),acf.do_action("add_field",t)},duplicate_field:function(e){acf.do_action("before_duplicate",e);var t=e.clone(),i=t.find(".field-label:first"),a=t.find(".field-name:first");acf.do_action("remove",t),this.wipe_field(t),acf.do_action("after_duplicate",e,t),e.after(t),acf.do_action("append",t),setTimeout(function(){i.focus()},251),this.render_fields(),e.hasClass("open")?this.close_field(e):this.open_field(t);var n=i.val(),d=a.val(),l=d.split("_").pop(),f=acf._e("copy");if(0===l.indexOf(f)){var c=1*l.replace(f,"");c=c?c+1:2,n=n.replace(l,f+c),d=d.replace(l,f+c)}else n+=" ("+f+")",d+="_"+f;return i.val(n),a.val(d),this.save_field(t),this.render_field(t),acf.do_action("duplicate_field",t),t},move_field:function(e){var t=this,i=acf.prepare_for_ajax({action:"acf/field_group/move_field",field_id:this.get_field_meta(e,"ID")}),a=!1;return i.field_id?"settings"==this.get_field_meta(e,"save")?a=!0:e.find(".acf-field-object").each(function(){return t.get_field_meta($(this),"ID")?void("settings"==t.get_field_meta($(this),"save")&&(a=!0)):(a=!0,!1)}):a=!0,a?void alert(acf._e("move_field_warning")):(acf.open_popup({title:acf._e("move_field"),loading:!0,height:145}),void $.ajax({url:acf.get("ajaxurl"),data:i,type:"post",dataType:"html",success:function(i){t.move_field_confirm(e,i)}}))},move_field_confirm:function(e,t){var i=this;acf.update_popup({content:t});var a=acf.prepare_for_ajax({action:"acf/field_group/move_field",field_id:this.get_field_meta(e,"ID"),field_group_id:0});$("#acf-move-field-form").on("submit",function(){return a.field_group_id=$(this).find("select").val(),$.ajax({url:acf.get("ajaxurl"),data:a,type:"post",dataType:"html",success:function(t){acf.update_popup({content:t}),i.remove_field(e)}}),!1})},delete_field:function(e,t){t=t||!0;var i=this.get_field_meta(e,"ID");i&&$("#input-delete-fields").val($("#input-delete-fields").val()+"|"+i),acf.do_action("delete_field",e),t&&this.remove_field(e)},remove_field:function(e){var t=this,i=e.closest(".acf-field-list");e.css({height:e.height(),width:e.width(),position:"absolute"}),e.wrap('
'),e.animate({opacity:0},250);var a=0,n=!1;i.children(".acf-field-object").length||(n=i.children(".no-fields-message"),a=n.outerHeight()),e.parent(".temp-field-wrap").animate({height:a},250,function(){n&&n.show(),acf.do_action("remove",$(this)),$(this).remove(),t.render_fields()})},change_field_type:function(e){var t=e.closest("tbody"),i=t.closest(".acf-field-object"),a=i.parent().closest(".acf-field-object"),n=i.attr("data-key"),d=i.attr("data-type"),l=e.val();i.removeClass("acf-field-object-"+acf.str_replace("_","-",d)),i.addClass("acf-field-object-"+acf.str_replace("_","-",l)),i.attr("data-type",l),i.data("type",l),i.data("xhr")&&i.data("xhr").abort();var f=t.children('.acf-field[data-setting="'+d+'"]'),c="";if(f.each(function(){c+=$(this).outerHTML()}),f.remove(),acf.update(n+"_settings_"+d,c),this.render_field(i),c=acf.get(n+"_settings_"+l))return t.children('.acf-field[data-name="conditional_logic"]').before(c),acf.update(n+"_settings_"+l,""),void acf.do_action("change_field_type",i);var r=$('
| |
');t.children('.acf-field[data-name="conditional_logic"]').before(r);var o={action:"acf/field_group/render_field_settings",nonce:acf.o.nonce,parent:acf.o.post_id,field_group:acf.o.post_id,prefix:e.attr("name").replace("[type]",""),type:l};a.exists()&&(o.parent=this.get_field_meta(a,"ID"));var s=$.ajax({url:acf.o.ajaxurl,data:o,type:"post",dataType:"html",success:function(e){if(e){var t=$(e);r.after(t),acf.do_action("append",t),acf.do_action("change_field_type",i)}},complete:function(){r.remove()}});i.data("xhr",s)},change_field_label:function(e){var t=e.find(".field-label:first"),i=e.find(".field-name:first"),a=e.attr("data-type");if(""==i.val()){var n=t.val();n=acf.str_sanitize(n),i.val(n).trigger("change")}this.render_field(e),acf.do_action("change_field_label",e)},change_field_name:function(e){var t=e.find(".field-name:first");"field_"===t.val().substr(0,6)&&(alert(acf._e("field_name_start")),setTimeout(function(){t.focus()},1)),acf.do_action("change_field_name",e)}}),acf.field_group.field=acf.model.extend({events:{"click .edit-field":"edit","click .duplicate-field":"duplicate","click .move-field":"move","click .delete-field":"delete","click .add-field":"add","change .field-type":"change_type","blur .field-label":"change_label","blur .field-name":"change_name","keyup .field-label":"render","keyup .field-name":"render","change .field-required":"render","change .acf-field-object input":"save","change .acf-field-object textarea":"save","change .acf-field-object select":"save"},event:function(e){return e.$field=e.$el.closest(".acf-field-object"),e},edit:function(e){acf.field_group.edit_field(e.$field)},duplicate:function(e){acf.field_group.duplicate_field(e.$field)},move:function(e){acf.field_group.move_field(e.$field)},delete:function(e){acf.field_group.delete_field(e.$field)},add:function(e){var t=e.$el.closest(".acf-field-list-wrap").children(".acf-field-list");acf.field_group.add_field(t)},change_type:function(e){acf.field_group.change_field_type(e.$el)},change_label:function(e){acf.field_group.change_field_label(e.$field)},change_name:function(e){acf.field_group.change_field_name(e.$field)},render:function(e){acf.field_group.render_field(e.$field)},save:function(e){acf.field_group.save_field(e.$field)}}),acf.field_group.conditional_logic=acf.model.extend({actions:{open_field:"render_field",change_field_label:"render_fields",change_field_type:"render_fields"},events:{"click .add-conditional-rule":"add_rule","click .add-conditional-group":"add_group","click .remove-conditional-rule":"remove_rule","change .conditional-toggle":"change_toggle","change .conditional-rule-param":"change_param"},render_fields:function(){var e=this;$(".acf-field-object.open").each(function(){e.render_field($(this))})},render_field:function(e){var t=this,i=e.attr("data-key"),a=e.parents(".acf-field-list"),n=e.find('.acf-field[data-name="conditional_logic"]:last'),d=[];$.each(a,function(e){var t=0==e?acf._e("sibling_fields"):acf._e("parent_fields");$(this).children(".acf-field-object").each(function(){var e=$(this),a=e.attr("data-key"),n=e.attr("data-type"),l=e.find(".field-label:first").val();$.inArray(n,["select","checkbox","true_false","radio"])!==-1&&a!=i&&d.push({value:a,label:l,group:t})})}),d.length||d.push({value:"",label:acf._e("no_fields")}),n.find(".rule").each(function(){t.render_rule($(this),d)})},render_rule:function(e,t){var i=e.find(".conditional-rule-param"),a=e.find(".conditional-rule-value");t&&acf.render_select(i,t);var n=$('.acf-field-object[data-key="'+i.val()+'"]'),d=n.attr("data-type"),l=[];if("true_false"==d)l.push({value:1,label:acf._e("checked")});else if("select"==d||"checkbox"==d||"radio"==d){var f=n.find('.acf-field[data-name="choices"] textarea').val().split("\n");$.each(f,function(e,t){t=t.split(":"),t[1]=t[1]||t[0],l.push({value:$.trim(t[0]),label:$.trim(t[1])})});var c=n.find('.acf-field[data-name="allow_null"]');c.exists()&&"1"==c.find("input:checked").val()&&l.unshift({value:"",label:acf._e("null")})}acf.render_select(a,l)},change_toggle:function(e){var t=e.$el,i=e.$el.prop("checked"),a=t.closest(".acf-input");i?(a.find(".rule-groups").show(),a.find(".rule-groups").find("[name]").prop("disabled",!1)):(a.find(".rule-groups").hide(),a.find(".rule-groups").find("[name]").prop("disabled",!0))},change_param:function(e){var t=e.$el.closest(".rule");this.render_rule(t)},add_rule:function(e){var t=e.$el.closest("tr");$tr2=acf.duplicate(t),$tr2.find("select:first").trigger("change")},remove_rule:function(e){var t=e.$el.closest("tr");t.find("select:first").trigger("change"),0==t.siblings("tr").length&&t.closest(".rule-group").remove(),t.remove()},add_group:function(e){var t=e.$el.closest(".rule-groups"),i=t.find(".rule-group:last");$group2=acf.duplicate(i),$group2.find("h4").text(acf._e("or")),$group2.find("tr:not(:first)").remove(),$group2.find("select:first").trigger("change")}}),acf.field_group.locations=acf.model.extend({events:{"click .add-location-rule":"add_rule","click .add-location-group":"add_group","click .remove-location-rule":"remove_rule","change .location-rule-param":"change_rule"},add_rule:function(e){var t=e.$el.closest("tr");$tr2=acf.duplicate(t)},remove_rule:function(e){var t=e.$el.closest("tr");t.find("select:first").trigger("change"),0==t.siblings("tr").length&&t.closest(".rule-group").remove(),t.remove()},add_group:function(e){var t=e.$el.closest(".rule-groups"),i=t.find(".rule-group:last");$group2=acf.duplicate(i),$group2.find("h4").text(acf._e("or")),$group2.find("tr:not(:first)").remove()},change_rule:function(e){var t=e.$el,i=t.closest("tr"),a=i.attr("data-id"),n=i.closest(".rule-group"),d=n.attr("data-id"),l=$('
');i.find("td.value").html(l),$.ajax({url:acf.get("ajaxurl"),data:acf.prepare_for_ajax({action:"acf/field_group/render_location_value",rule_id:a,group_id:d,param:t.val(),value:""}),type:"post",dataType:"html",success:function(e){l.replaceWith(e)}})}}),acf.field_group.field_object=acf.model.extend({type:"",o:{},$field:null,$settings:null,_add_action:function(e,t){var i=this,a=e.split("_");a.splice(1,0,"field"),e=a.join("_")+"/type="+i.type,acf.add_action(e,function(e){i.set("$field",e),i[t].apply(i,arguments)})},_add_filter:function(e,t){var i=this,a=e.split("_");a.splice(1,0,"field"),e=a.join("_")+"/type="+i.type,acf.add_filter(e,function(e){i.set("$field",e),i[t].apply(i,arguments)})},_add_event:function(e,t){var i=this,a=e.substr(0,e.indexOf(" ")),n=e.substr(e.indexOf(" ")+1),d=acf.field_group.get_selector(i.type);$(document).on(a,d+" "+n,function(e){e.$el=$(this),e.$field=e.$el.closest(".acf-field-object"),i.set("$field",e.$field),i[t].apply(i,[e])})},_set_$field:function(){this.o=this.$field.data(),this.$settings=this.$field.find("> .settings > table > tbody"),this.focus()},focus:function(){},setting:function(e){return this.$settings.find("> .acf-field-setting-"+e)}}),acf.field_group.field_objects=acf.model.extend({actions:{save_field:"_save_field",open_field:"_open_field",close_field:"_close_field",wipe_field:"_wipe_field",add_field:"_add_field",duplicate_field:"_duplicate_field",delete_field:"_delete_field",change_field_type:"_change_field_type",change_field_label:"_change_field_label",change_field_name:"_change_field_name",render_field_settings:"_render_field_settings"},_save_field:function(e){acf.do_action("save_field/type="+e.data("type"),e)},_open_field:function(e){acf.do_action("open_field/type="+e.data("type"),e),acf.do_action("render_field_settings",e)},_close_field:function(e){acf.do_action("close_field/type="+e.data("type"),e)},_wipe_field:function(e){acf.do_action("wipe_field/type="+e.data("type"),e)},_add_field:function(e){acf.do_action("add_field/type="+e.data("type"),e)},_duplicate_field:function(e){acf.do_action("duplicate_field/type="+e.data("type"),e)},_delete_field:function(e){acf.do_action("delete_field/type="+e.data("type"),e)},_change_field_type:function(e){acf.do_action("change_field_type/type="+e.data("type"),e),acf.do_action("render_field_settings",e)},_change_field_label:function(e){acf.do_action("change_field_label/type="+e.data("type"),e)},_change_field_name:function(e){acf.do_action("change_field_name/type="+e.data("type"),e)},_render_field_settings:function(e){acf.do_action("render_field_settings/type="+e.data("type"),e)}}),acf.field_group.append=acf.model.extend({actions:{render_field_settings:"_render_field_settings"},render:function(e){var t=e.data("append");if($sibling=e.siblings('[data-name="'+t+'"]'),$sibling.exists()){var i=$sibling.children(".acf-input"),a=i.children(".acf-hl");a.exists()||(i.wrapInner('
'),a=i.children(".acf-hl"));var n=$("
").append(e.children(".acf-input").children());a.append(n),a.attr("data-cols",a.children().length),e.remove()}},_render_field_settings:function(e){var t=this;e.find(".acf-field[data-append]").each(function(){t.render($(this))})}});var e=acf.field_group.field_object.extend({type:"select",actions:{render_settings:"render"},events:{"change .acf-field-setting-ui input":"render"},render:function(e){this.setting('ui input[type="checkbox"]').prop("checked")?this.setting("ajax").show():(this.setting("ajax").hide(),this.setting('ajax input[type="checkbox"]').prop("checked",!1).trigger("change"))}}),t=acf.field_group.field_object.extend({type:"radio",actions:{render_settings:"render"},events:{"change .acf-field-setting-other_choice input":"render"},render:function(e){this.setting('other_choice input[type="checkbox"]').prop("checked")?this.setting("save_other_choice").show():(this.setting("save_other_choice").hide(),this.setting('save_other_choice input[type="checkbox"]').prop("checked",!1).trigger("change"))}}),i=acf.field_group.field_object.extend({type:"true_false",actions:{render_settings:"render"},events:{"change .acf-field-setting-ui input":"render"},render:function(e){this.setting('ui input[type="checkbox"]').prop("checked")?(this.setting("ui_on_text").show(),this.setting("ui_off_text").show()):(this.setting("ui_on_text").hide(),this.setting("ui_off_text").hide())}}),a=acf.field_group.field_object.extend({type:"date_picker",actions:{render_settings:"render"},events:{"change .acf-field-setting-display_format input":"render","change .acf-field-setting-return_format input":"render"},render:function(e){this.render_list(this.setting("display_format")),this.render_list(this.setting("return_format"))},render_list:function(e){var t=e.find("ul"),i=t.find('input[type="radio"]:checked'),a=t.find('input[type="text"]');"other"!=i.val()&&a.val(i.val())}}),n=a.extend({type:"date_time_picker"}),n=a.extend({type:"time_picker"}),d=acf.field_group.field_object.extend({type:"tab",actions:{render_settings:"render"},render:function(e){this.setting("name input").val("").trigger("change"),this.setting('required input[type="checkbox"]').prop("checked",!1).trigger("change")}}),l=d.extend({type:"message"});acf.field_group.screen=acf.model.extend({actions:{ready:"ready"},events:{"click #acf-field-key-hide":"toggle"},ready:function(){var e=$("#adv-settings"),t=e.find("#acf-append-show-on-screen");e.find(".metabox-prefs").append(t.html()),e.find(".metabox-prefs br").remove(),t.remove(),this.render()},toggle:function(e){var t=e.$el.prop("checked")?1:0;acf.update_user_setting("show_field_keys",t),this.render()},render:function(){var e=acf.serialize_form($("#adv-settings"));e.show_field_keys=parseInt(e.show_field_keys);var t=acf.field_group.$fields;e.show_field_keys?t.addClass("show-field-keys"):t.removeClass("show-field-keys")}})}(jQuery);
+!function($){acf.field_group=acf.model.extend({$fields:null,$locations:null,$options:null,actions:{ready:"init"},events:{"submit #post":"submit",'click a[href="#"]':"preventDefault","click .submitdelete":"trash","mouseenter .acf-field-list":"sortable"},init:function(){this.$fields=$("#acf-field-group-fields"),this.$locations=$("#acf-field-group-locations"),this.$options=$("#acf-field-group-options"),acf.validation.active=0},sortable:function(e){if(!e.$el.hasClass("ui-sortable")){var i=this;e.$el.sortable({handle:".acf-sortable-handle",connectWith:".acf-field-list",update:function(e,t){var a=t.item;i.render_fields(),acf.do_action("sortstop",a)}})}},preventDefault:function(e){e.preventDefault()},get_selector:function(e){e=e||"";var i=".acf-field-object";return e&&(i+="-"+e,i=i.split("_").join("-")),i},render_fields:function(){var e=this;$(".acf-field-list").each(function(){var i=$(this).children(".acf-field-object");i.each(function(i){e.update_field_meta($(this),"menu_order",i),$(this).children(".handle").find(".acf-icon").html(i+1)}),i.exists()?$(this).children(".no-fields-message").hide():$(this).children(".no-fields-message").show()})},get_field_meta:function(e,i){var t=e.find("> .meta > .input-"+i);return!!t.exists()&&t.val()},update_field_meta:function(e,i,t){var a=e.find("> .meta > .input-"+i);if(!a.exists()){var d=e.find("> .meta > .input-ID").outerHTML();d=acf.str_replace("ID",i,d),a=$(d),a.val(t),e.children(".meta").append(a)}a.val()!=t&&(a.val(t),"save"!=i&&this.save_field(e,"meta"))},delete_field_meta:function(e,i){var t=e.find("> .meta > .input-"+i);t.exists()&&(t.remove(),this.save_field(e,"meta"))},save_field:function(e,i){i=i||"settings";var t=this.get_field_meta(e,"save");"settings"!=t&&t!=i&&(this.update_field_meta(e,"save",i),acf.do_action("save_field",e,i))},submit:function(e){var i=this,t=$("#titlewrap #title");t.val()||(e.preventDefault(),acf.validation.toggle(e.$el,"unlock"),alert(acf._e("title_is_required")),t.focus()),$(".acf-field-object").each(function(){var e=i.get_field_meta($(this),"save"),t=i.get_field_meta($(this),"ID"),a=$(this).hasClass("open");a&&i.close_field($(this)),"settings"==e||("meta"==e?$(this).children(".settings").find('[name^="acf_fields['+t+']"]').remove():$(this).find('[name^="acf_fields['+t+']"]').remove())})},trash:function(e){var i=confirm(acf._e("move_to_trash"));i||e.preventDefault()},render_field:function(e){var i=e.find(".field-label:first").val(),t=e.find(".field-name:first").val(),a=e.find(".field-type:first option:selected").text(),d=e.find(".field-required:first").prop("checked"),n=e.children(".handle");n.find(".li-field-label strong a").text(i),n.find(".li-field-label .acf-required").remove(),d&&n.find(".li-field-label strong").append('
*'),n.find(".li-field-name").text(t),n.find(".li-field-type").text(a),acf.do_action("render_field_handle",e,n)},edit_field:function(e){e.hasClass("open")?this.close_field(e):this.open_field(e)},open_field:function(e){return!e.hasClass("open")&&(e.addClass("open"),acf.do_action("open_field",e),void e.children(".settings").animate({height:"toggle"},250))},close_field:function(e){return!!e.hasClass("open")&&(e.removeClass("open"),acf.do_action("close_field",e),void e.children(".settings").animate({height:"toggle"},250))},wipe_field:function(e){var i=e.attr("data-id"),t=e.attr("data-key"),a=acf.get_uniqid(),d="field_"+a;e.attr("data-id",a),e.attr("data-key",d),e.attr("data-orig",t),this.update_field_meta(e,"ID",""),this.update_field_meta(e,"key",d),e.find('[id*="'+i+'"]').each(function(){$(this).attr("id",$(this).attr("id").replace(i,a))}),e.find('[name*="'+i+'"]').each(function(){$(this).attr("name",$(this).attr("name").replace(i,a))}),e.find("> .handle .pre-field-key").text(d),e.find(".ui-sortable").removeClass("ui-sortable"),acf.do_action("wipe_field",e)},add_field:function(e){var i=$($("#tmpl-acf-field").html()),t=i.find(".field-label:first"),a=i.find(".field-name:first");this.wipe_field(i),e.append(i),t.val(""),a.val(""),setTimeout(function(){t.focus()},251),this.render_fields(),acf.do_action("append",i),this.edit_field(i),acf.do_action("add_field",i)},duplicate_field:function(e){acf.do_action("before_duplicate",e);var i=e.clone(),t=i.find(".field-label:first"),a=i.find(".field-name:first");acf.do_action("remove",i),this.wipe_field(i),acf.do_action("after_duplicate",e,i),e.after(i),acf.do_action("append",i),setTimeout(function(){t.focus()},251),this.render_fields(),e.hasClass("open")?this.close_field(e):this.open_field(i);var d=t.val(),n=a.val(),l=n.split("_").pop(),f=acf._e("copy");if(0===l.indexOf(f)){var c=1*l.replace(f,"");c=c?c+1:2,d=d.replace(l,f+c),n=n.replace(l,f+c)}else d+=" ("+f+")",n+="_"+f;return t.val(d),a.val(n),this.save_field(i),this.render_field(i),acf.do_action("duplicate_field",i),i},move_field:function(e){var i=this,t=acf.prepare_for_ajax({action:"acf/field_group/move_field",field_id:this.get_field_meta(e,"ID")}),a=!1;return t.field_id?"settings"==this.get_field_meta(e,"save")?a=!0:e.find(".acf-field-object").each(function(){return i.get_field_meta($(this),"ID")?void("settings"==i.get_field_meta($(this),"save")&&(a=!0)):(a=!0,!1)}):a=!0,a?void alert(acf._e("move_field_warning")):(acf.open_popup({title:acf._e("move_field"),loading:!0,height:145}),void $.ajax({url:acf.get("ajaxurl"),data:t,type:"post",dataType:"html",success:function(t){i.move_field_confirm(e,t)}}))},move_field_confirm:function(e,i){var t=this;acf.update_popup({content:i});var a=acf.prepare_for_ajax({action:"acf/field_group/move_field",field_id:this.get_field_meta(e,"ID"),field_group_id:0});$("#acf-move-field-form").on("submit",function(){return a.field_group_id=$(this).find("select").val(),$.ajax({url:acf.get("ajaxurl"),data:a,type:"post",dataType:"html",success:function(i){acf.update_popup({content:i}),t.remove_field(e)}}),!1})},delete_field:function(e,i){i=i||!0;var t=this.get_field_meta(e,"ID");t&&$("#input-delete-fields").val($("#input-delete-fields").val()+"|"+t),acf.do_action("delete_field",e),i&&this.remove_field(e)},remove_field:function(e){var i=this,t=e.closest(".acf-field-list");e.css({height:e.height(),width:e.width(),position:"absolute"}),e.wrap('
'),e.animate({opacity:0},250);var a=0,d=!1;t.children(".acf-field-object").length||(d=t.children(".no-fields-message"),a=d.outerHeight()),e.parent(".temp-field-wrap").animate({height:a},250,function(){d&&d.show(),acf.do_action("remove",$(this)),$(this).remove(),i.render_fields()})},change_field_type:function(e){var i=e.closest("tbody"),t=i.closest(".acf-field-object"),a=t.parent().closest(".acf-field-object"),d=t.attr("data-key"),n=t.attr("data-type"),l=e.val();t.removeClass("acf-field-object-"+acf.str_replace("_","-",n)),t.addClass("acf-field-object-"+acf.str_replace("_","-",l)),t.attr("data-type",l),t.data("type",l),t.data("xhr")&&t.data("xhr").abort();var f=i.children('.acf-field[data-setting="'+n+'"]'),c="";if(f.each(function(){c+=$(this).outerHTML()}),f.remove(),acf.update(d+"_settings_"+n,c),this.render_field(t),c=acf.get(d+"_settings_"+l))return i.children('.acf-field[data-name="conditional_logic"]').before(c),acf.update(d+"_settings_"+l,""),void acf.do_action("change_field_type",t);var o=$('
| |
');i.children('.acf-field[data-name="conditional_logic"]').before(o);var r={action:"acf/field_group/render_field_settings",nonce:acf.o.nonce,parent:acf.o.post_id,field_group:acf.o.post_id,prefix:e.attr("name").replace("[type]",""),type:l};a.exists()&&(r.parent=this.get_field_meta(a,"ID"));var s=$.ajax({url:acf.o.ajaxurl,data:r,type:"post",dataType:"html",success:function(e){if(e){var i=$(e);o.after(i),acf.do_action("append",i),acf.do_action("change_field_type",t)}},complete:function(){o.remove()}});t.data("xhr",s)},change_field_label:function(e){var i=e.find(".field-label:first"),t=e.find(".field-name:first"),a=e.attr("data-type");if(""==t.val()){var d=i.val();d=acf.str_sanitize(d),t.val(d).trigger("change")}this.render_field(e),acf.do_action("change_field_label",e)},change_field_name:function(e){var i=e.find(".field-name:first");"field_"===i.val().substr(0,6)&&(alert(acf._e("field_name_start")),setTimeout(function(){i.focus()},1)),acf.do_action("change_field_name",e)}}),acf.field_group.field=acf.model.extend({events:{"click .edit-field":"edit","click .duplicate-field":"duplicate","click .move-field":"move","click .delete-field":"delete","click .add-field":"add","change .field-type":"change_type","blur .field-label":"change_label","blur .field-name":"change_name","keyup .field-label":"render","keyup .field-name":"render","change .field-required":"render","change .acf-field-object input":"save","change .acf-field-object textarea":"save","change .acf-field-object select":"save"},event:function(e){return e.$field=e.$el.closest(".acf-field-object"),e},edit:function(e){acf.field_group.edit_field(e.$field)},duplicate:function(e){acf.field_group.duplicate_field(e.$field)},move:function(e){acf.field_group.move_field(e.$field)},delete:function(e){acf.field_group.delete_field(e.$field)},add:function(e){var i=e.$el.closest(".acf-field-list-wrap").children(".acf-field-list");acf.field_group.add_field(i)},change_type:function(e){acf.field_group.change_field_type(e.$el)},change_label:function(e){acf.field_group.change_field_label(e.$field)},change_name:function(e){acf.field_group.change_field_name(e.$field)},render:function(e){acf.field_group.render_field(e.$field)},save:function(e){acf.field_group.save_field(e.$field)}}),acf.field_group.conditional_logic=acf.model.extend({actions:{open_field:"render_field",change_field_label:"render_fields",change_field_type:"render_fields"},events:{"click .add-conditional-rule":"add_rule","click .add-conditional-group":"add_group","click .remove-conditional-rule":"remove_rule","change .conditional-toggle":"change_toggle","change .conditional-rule-param":"change_param"},render_fields:function(){var e=this;$(".acf-field-object.open").each(function(){e.render_field($(this))})},render_field:function(e){var i=this,t=e.attr("data-key"),a=e.parents(".acf-field-list"),d=e.find('.acf-field[data-name="conditional_logic"]:last'),n=[];$.each(a,function(e){var i=0==e?acf._e("sibling_fields"):acf._e("parent_fields");$(this).children(".acf-field-object").each(function(){var e=$(this),a=e.attr("data-key"),d=e.attr("data-type"),l=e.find(".field-label:first").val();$.inArray(d,["select","checkbox","true_false","radio"])!==-1&&a!=t&&n.push({value:a,label:l,group:i})})}),n.length||n.push({value:"",label:acf._e("no_fields")}),d.find(".rule").each(function(){i.render_rule($(this),n)})},render_rule:function(e,i){var t=e.find(".conditional-rule-param"),a=e.find(".conditional-rule-value");i&&acf.render_select(t,i);var d=$('.acf-field-object[data-key="'+t.val()+'"]'),n=d.attr("data-type"),l=[];if("true_false"==n)l.push({value:1,label:acf._e("checked")});else if("select"==n||"checkbox"==n||"radio"==n){var f=d.find('.acf-field[data-name="choices"] textarea').val().split("\n");$.each(f,function(e,i){i=i.split(":"),i[1]=i[1]||i[0],l.push({value:$.trim(i[0]),label:$.trim(i[1])})});var c=d.find('.acf-field[data-name="allow_null"]');c.exists()&&"1"==c.find("input:checked").val()&&l.unshift({value:"",label:acf._e("null")})}acf.render_select(a,l)},change_toggle:function(e){var i=e.$el,t=e.$el.prop("checked"),a=i.closest(".acf-input");t?(a.find(".rule-groups").show(),a.find(".rule-groups").find("[name]").prop("disabled",!1)):(a.find(".rule-groups").hide(),a.find(".rule-groups").find("[name]").prop("disabled",!0))},change_param:function(e){var i=e.$el.closest(".rule");this.render_rule(i)},add_rule:function(e){var i=e.$el.closest("tr");$tr2=acf.duplicate(i),$tr2.find("select:first").trigger("change")},remove_rule:function(e){var i=e.$el.closest("tr");i.find("select:first").trigger("change"),0==i.siblings("tr").length&&i.closest(".rule-group").remove(),i.remove()},add_group:function(e){var i=e.$el.closest(".rule-groups"),t=i.find(".rule-group:last");$group2=acf.duplicate(t),$group2.find("h4").text(acf._e("or")),$group2.find("tr:not(:first)").remove(),$group2.find("select:first").trigger("change")}}),acf.field_group.locations=acf.model.extend({events:{"click .add-location-rule":"add_rule","click .add-location-group":"add_group","click .remove-location-rule":"remove_rule","change .location-rule-param":"change_rule"},add_rule:function(e){var i=e.$el.closest("tr");$tr2=acf.duplicate(i)},remove_rule:function(e){var i=e.$el.closest("tr");i.find("select:first").trigger("change"),0==i.siblings("tr").length&&i.closest(".rule-group").remove(),i.remove()},add_group:function(e){var i=e.$el.closest(".rule-groups"),t=i.find(".rule-group:last");$group2=acf.duplicate(t),$group2.find("h4").text(acf._e("or")),$group2.find("tr:not(:first)").remove()},change_rule:function(e){var i=e.$el,t=i.closest("tr"),a=t.attr("data-id"),d=t.closest(".rule-group"),n=d.attr("data-id"),l=$('
');t.find("td.value").html(l),$.ajax({url:acf.get("ajaxurl"),data:acf.prepare_for_ajax({action:"acf/field_group/render_location_value",rule_id:a,group_id:n,param:i.val(),value:""}),type:"post",dataType:"html",success:function(e){l.replaceWith(e)}})}}),acf.field_group.field_object=acf.model.extend({type:"",o:{},$field:null,$settings:null,_add_action:function(e,i){var t=this,a=e.split("_");a.splice(1,0,"field"),e=a.join("_")+"/type="+t.type,acf.add_action(e,function(e){t.set("$field",e),t[i].apply(t,arguments)})},_add_filter:function(e,i){var t=this,a=e.split("_");a.splice(1,0,"field"),e=a.join("_")+"/type="+t.type,acf.add_filter(e,function(e){t.set("$field",e),t[i].apply(t,arguments)})},_add_event:function(e,i){var t=this,a=e.substr(0,e.indexOf(" ")),d=e.substr(e.indexOf(" ")+1),n=acf.field_group.get_selector(t.type);$(document).on(a,n+" "+d,function(e){e.$el=$(this),e.$field=e.$el.closest(".acf-field-object"),t.set("$field",e.$field),t[i].apply(t,[e])})},_set_$field:function(){this.o=this.$field.data(),this.$settings=this.$field.find("> .settings > table > tbody"),this.focus()},focus:function(){},setting:function(e){return this.$settings.find("> .acf-field-setting-"+e)}}),acf.field_group.field_objects=acf.model.extend({actions:{save_field:"_save_field",open_field:"_open_field",close_field:"_close_field",wipe_field:"_wipe_field",add_field:"_add_field",duplicate_field:"_duplicate_field",delete_field:"_delete_field",change_field_type:"_change_field_type",change_field_label:"_change_field_label",change_field_name:"_change_field_name",render_field_settings:"_render_field_settings"},_save_field:function(e){acf.do_action("save_field/type="+e.data("type"),e)},_open_field:function(e){acf.do_action("open_field/type="+e.data("type"),e),acf.do_action("render_field_settings",e)},_close_field:function(e){acf.do_action("close_field/type="+e.data("type"),e)},_wipe_field:function(e){acf.do_action("wipe_field/type="+e.data("type"),e)},_add_field:function(e){acf.do_action("add_field/type="+e.data("type"),e)},_duplicate_field:function(e){acf.do_action("duplicate_field/type="+e.data("type"),e)},_delete_field:function(e){acf.do_action("delete_field/type="+e.data("type"),e)},_change_field_type:function(e){acf.do_action("change_field_type/type="+e.data("type"),e),acf.do_action("render_field_settings",e)},_change_field_label:function(e){acf.do_action("change_field_label/type="+e.data("type"),e)},_change_field_name:function(e){acf.do_action("change_field_name/type="+e.data("type"),e)},_render_field_settings:function(e){acf.do_action("render_field_settings/type="+e.data("type"),e)}}),acf.field_group.append=acf.model.extend({actions:{render_field_settings:"_render_field_settings"},render:function(e){var i=e.data("append");if($sibling=e.siblings('[data-name="'+i+'"]'),$sibling.exists()){var t=$sibling.children(".acf-input"),a=t.children(".acf-hl");a.exists()||(t.wrapInner('
'),a=t.children(".acf-hl"));var d=$("
").append(e.children(".acf-input").children());a.append(d),a.attr("data-cols",a.children().length),e.remove()}},_render_field_settings:function(e){var i=this;e.find(".acf-field[data-append]").each(function(){i.render($(this))})}});var e=acf.field_group.field_object.extend({type:"select",actions:{render_settings:"render"},events:{"change .acf-field-setting-ui input":"render"},render:function(e){this.setting('ui input[type="checkbox"]').prop("checked")?this.setting("ajax").show():(this.setting("ajax").hide(),this.setting('ajax input[type="checkbox"]').prop("checked",!1).trigger("change"))}}),i=acf.field_group.field_object.extend({type:"radio",actions:{render_settings:"render"},events:{"change .acf-field-setting-other_choice input":"render"},render:function(e){this.setting('other_choice input[type="checkbox"]').prop("checked")?this.setting("save_other_choice").show():(this.setting("save_other_choice").hide(),this.setting('save_other_choice input[type="checkbox"]').prop("checked",!1).trigger("change"))}}),t=acf.field_group.field_object.extend({type:"true_false",actions:{render_settings:"render"},events:{"change .acf-field-setting-ui input":"render"},render:function(e){this.setting('ui input[type="checkbox"]').prop("checked")?(this.setting("ui_on_text").show(),this.setting("ui_off_text").show()):(this.setting("ui_on_text").hide(),this.setting("ui_off_text").hide())}}),a=acf.field_group.field_object.extend({type:"date_picker",actions:{render_settings:"render"},events:{"change .acf-field-setting-display_format input":"render","change .acf-field-setting-return_format input":"render"},render:function(e){this.render_list(this.setting("display_format")),this.render_list(this.setting("return_format"))},render_list:function(e){var i=e.find("ul"),t=i.find('input[type="radio"]:checked'),a=i.find('input[type="text"]');"other"!=t.val()&&a.val(t.val())}}),d=a.extend({type:"date_time_picker"}),d=a.extend({type:"time_picker"}),n=acf.field_group.field_object.extend({type:"tab",actions:{render_settings:"render"},render:function(e){this.setting("name input").val("").trigger("change"),this.setting('required input[type="checkbox"]').prop("checked",!1).trigger("change")}}),l=n.extend({type:"message"});acf.field_group.screen=acf.model.extend({actions:{ready:"ready"},events:{"click #acf-field-key-hide":"toggle"},ready:function(){var e=$("#adv-settings"),i=e.find("#acf-append-show-on-screen");e.find(".metabox-prefs").append(i.html()),e.find(".metabox-prefs br").remove(),i.remove(),this.render()},toggle:function(e){var i=e.$el.prop("checked")?1:0;acf.update_user_setting("show_field_keys",i),this.render()},render:function(){var e=acf.serialize_form($("#adv-settings"));e.show_field_keys=parseInt(e.show_field_keys);var i=acf.field_group.$fields;e.show_field_keys?i.addClass("show-field-keys"):i.removeClass("show-field-keys")}}),acf.field_group.sub_fields=acf.model.extend({actions:{open_field:"update_field_parent",sortstop:"update_field_parent",duplicate_field:"duplicate_field",delete_field:"delete_field",change_field_type:"change_field_type"},fix_conditional_logic:function(e){var i={};e.each(function(){i[$(this).attr("data-orig")]=$(this).attr("data-key")}),e.find(".conditional-rule-param").each(function(){var e=$(this).val();e in i&&($(this).find('option[value="'+i[e]+'"]').exists()||$(this).append('
"),$(this).val(i[e]))})},update_field_parent:function(e){if(e.hasClass("acf-field-object")){var i=e.parent().closest(".acf-field-object"),t=acf.get("post_id");i.exists()&&(t=acf.field_group.get_field_meta(i,"ID"),t||(t=acf.field_group.get_field_meta(i,"key"))),acf.field_group.update_field_meta(e,"parent",t),acf.do_action("update_field_parent",e,i)}},duplicate_field:function(e){var i=e.find(".acf-field-object");i.exists()&&(i.each(function(){var e=$(this).parent().closest(".acf-field-object"),i=acf.field_group.get_field_meta(e,"key");acf.field_group.wipe_field($(this)),acf.field_group.update_field_meta($(this),"parent",i),acf.field_group.save_field($(this))}),this.fix_conditional_logic(i))},delete_field:function(e){e.find(".acf-field-object").each(function(){acf.field_group.delete_field($(this),!1)})},change_field_type:function(e){e.find(".acf-field-object").each(function(){acf.field_group.delete_field($(this),!1)})}})}(jQuery);
diff --git a/assets/js/acf-input.js b/assets/js/acf-input.js
index 16475dd..8adfcc9 100644
--- a/assets/js/acf-input.js
+++ b/assets/js/acf-input.js
@@ -682,6 +682,11 @@ var acf;
// filter out fields
if( !all ) {
+ // remove clone fields
+ $fields = $fields.not('.acf-clone .acf-field');
+
+
+ // filter
$fields = acf.apply_filters('get_fields', $fields);
}
@@ -1259,8 +1264,7 @@ var acf;
$el.css({
height : $el.height(),
width : $el.width(),
- position : 'absolute',
- //padding : 0
+ position : 'absolute'
});
@@ -1505,7 +1509,7 @@ var acf;
$popup.find('.acf-popup-box').css({
'width' : args.width,
- 'margin-left' : 0 - (args.width / 2),
+ 'margin-left' : 0 - (args.width / 2)
});
}
@@ -1517,7 +1521,7 @@ var acf;
$popup.find('.acf-popup-box').css({
'height' : args.height,
- 'margin-top' : 0 - (args.height / 2),
+ 'margin-top' : 0 - (args.height / 2)
});
}
@@ -1915,6 +1919,27 @@ var acf;
},
+ /*
+ * addslashes
+ *
+ * This function mimics the PHP addslashes function.
+ * Returns a string with backslashes before characters that need to be escaped.
+ *
+ * @type function
+ * @date 9/1/17
+ * @since 5.5.0
+ *
+ * @param text (string)
+ * @return (string)
+ */
+
+ addslashes: function(text){
+
+ return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
+
+ },
+
+
/*
* render_select
*
@@ -2515,7 +2540,7 @@ var acf;
'show' : '_show',
'show_field' : '_show_field',
'hide' : '_hide',
- 'hide_field' : '_hide_field',
+ 'hide_field' : '_hide_field'
},
// prepare
@@ -2735,116 +2760,286 @@ var acf;
active: 0,
actions: {
- 'refresh': 'refresh',
+ 'prepare 99': 'prepare',
+ 'refresh': 'refresh'
},
- refresh: function( $el ){
+ prepare: function(){
+
+ // vars
+ this.active = 1;
+
+
+ // render
+ this.refresh();
+
+ },
+
+ refresh: function( $el ){
+
+ // bail early if not yet active
+ if( !this.active ) return;
- //console.log('acf.layout.refresh', $el);
// defaults
- $el = $el || false;
+ $el = $el || $('body');
- // if is '.acf-fields'
- if( $el && $el.is('.acf-fields') ) {
+ // reference
+ var self = this;
+
+
+ // render
+ this.render_tables( $el );
+ this.render_groups( $el );
+
+ },
+
+ render_tables: function( $el ){
+
+ // reference
+ var self = this;
+
+
+ // vars
+ var $tables = $el.find('.acf-table:visible');
+
+
+ // appent self if is tr
+ if( $el.is('tr') ) {
- $el = $el.parent();
+ $tables = $el.parent().parent();
}
- // loop over visible fields
- $('.acf-fields:visible', $el).each(function(){
-
- // vars
- var $els = $(),
- top = 0,
- height = 0,
- cell = -1;
-
-
- // get fields
- var $fields = $(this).children('.acf-field[data-width]:visible');
-
-
- // bail early if no fields
- if( !$fields.exists() ) {
-
- return;
-
- }
-
-
- // reset fields
- $fields.removeClass('acf-r0 acf-c0').css({'min-height': 0});
-
-
- $fields.each(function( i ){
-
- // vars
- var $el = $(this),
- this_top = $el.position().top;
-
-
- // set top
- if( i == 0 ) {
-
- top = this_top;
-
- }
-
-
- // detect new row
- if( this_top != top ) {
-
- // set previous heights
- $els.css({'min-height': (height+1)+'px'});
-
- // reset
- $els = $();
- top = $el.position().top; // don't use variable as this value may have changed due to min-height css
- height = 0;
- cell = -1;
-
- }
-
-
- // increase
- cell++;
-
- // set height
- height = ($el.outerHeight() > height) ? $el.outerHeight() : height;
-
- // append
- $els = $els.add( $el );
-
- // add classes
- if( this_top == 0 ) {
-
- $el.addClass('acf-r0');
-
- } else if( cell == 0 ) {
-
- $el.addClass('acf-c0');
-
- }
-
- });
-
-
- // clean up
- if( $els.exists() ) {
-
- $els.css({'min-height': (height+1)+'px'});
-
- }
+ // loop
+ $tables.each(function(){
+ self.render_table( $(this) );
});
- //console.timeEnd('acf.width.render');
-
+ },
+
+ render_table: function( $table ){
+
+ // vars
+ var $ths = $table.find('> thead th.acf-th'),
+ colspan = 1,
+ available_width = 100;
+
+
+ // bail early if no $ths
+ if( !$ths.exists() ) return;
+
+
+ // vars
+ var $trs = $table.find('> tbody > tr'),
+ $tds = $trs.find('> td.acf-field');
+
+
+ // remove clones if has visible rows
+ if( $trs.hasClass('acf-clone') && $trs.length > 1 ) {
+
+ $tds = $trs.not('.acf-clone').find('> td.acf-field');
+
+ }
+
+
+ // render th/td visibility
+ $ths.each(function(){
+
+ // vars
+ var $th = $(this),
+ key = $th.attr('data-key'),
+ $td = $tds.filter('[data-key="'+key+'"]');
+
+ // clear class
+ $td.removeClass('appear-empty');
+ $th.removeClass('hidden-by-conditional-logic');
+
+
+ // no td
+ if( !$td.exists() ) {
+
+ // do nothing
+
+ // if all td are hidden
+ } else if( $td.not('.hidden-by-conditional-logic').length == 0 ) {
+
+ $th.addClass('hidden-by-conditional-logic');
+
+ // if 1 or more td are visible
+ } else {
+
+ $td.filter('.hidden-by-conditional-logic').addClass('appear-empty');
+
+ }
+
+ });
+
+
+
+ // clear widths
+ $ths.css('width', 'auto');
+
+
+ // update $ths
+ $ths = $ths.not('.hidden-by-conditional-logic');
+
+
+ // set colspan
+ colspan = $ths.length;
+
+
+ // set custom widths first
+ $ths.filter('[data-width]').each(function(){
+
+ // vars
+ var width = parseInt( $(this).attr('data-width') );
+
+
+ // remove from available
+ available_width -= width;
+
+
+ // set width
+ $(this).css('width', width + '%');
+
+ });
+
+
+ // update $ths
+ $ths = $ths.not('[data-width]');
+
+
+ // set custom widths first
+ $ths.each(function(){
+
+ // cal width
+ var width = available_width / $ths.length;
+
+
+ // set width
+ $(this).css('width', width + '%');
+
+ });
+
+
+ // update colspan
+ $table.find('.acf-row .acf-field.-collapsed-target').removeAttr('colspan');
+ $table.find('.acf-row.-collapsed .acf-field.-collapsed-target').attr('colspan', colspan);
+
+ },
+
+ render_groups: function( $el ){
+
+ // reference
+ var self = this;
+
+
+ // vars
+ var $groups = $el.find('.acf-fields:visible');
+
+
+ // appent self if is '.acf-fields'
+ if( $el && $el.is('.acf-fields') ) {
+
+ $groups = $groups.add( $el );
+
+ }
+
+
+ // loop
+ $groups.each(function(){
+
+ self.render_group( $(this) );
+
+ });
+
+ },
+
+ render_group: function( $el ){
+
+ // vars
+ var $els = $(),
+ top = 0,
+ height = 0,
+ cell = -1;
+
+
+ // get fields
+ var $fields = $el.children('.acf-field[data-width]:visible');
+
+
+ // bail early if no fields
+ if( !$fields.exists() ) return;
+
+
+ // reset fields
+ $fields.removeClass('acf-r0 acf-c0').css({'min-height': 0});
+
+
+ // loop
+ $fields.each(function( i ){
+
+ // vars
+ var $el = $(this),
+ this_top = $el.position().top;
+
+
+ // set top
+ if( i == 0 ) top = this_top;
+
+
+ // detect new row
+ if( this_top != top ) {
+
+ // set previous heights
+ $els.css({'min-height': (height+1)+'px'});
+
+ // reset
+ $els = $();
+ top = $el.position().top; // don't use variable as this value may have changed due to min-height css
+ height = 0;
+ cell = -1;
+
+ }
+
+
+ // increase
+ cell++;
+
+
+ // set height
+ height = ($el.outerHeight() > height) ? $el.outerHeight() : height;
+
+
+ // append
+ $els = $els.add( $el );
+
+
+ // add classes
+ if( this_top == 0 ) {
+
+ $el.addClass('acf-r0');
+
+ } else if( cell == 0 ) {
+
+ $el.addClass('acf-c0');
+
+ }
+
+ });
+
+
+ // clean up
+ if( $els.exists() ) {
+
+ $els.css({'min-height': (height+1)+'px'});
+
+ }
}
@@ -2928,7 +3123,7 @@ var acf;
},
events: {
- 'submit form': 'off',
+ 'submit form': 'off'
},
validation_complete: function( json, $form ){
@@ -2990,7 +3185,7 @@ var acf;
events: {
'mouseenter .acf-js-tooltip': 'on',
- 'mouseleave .acf-js-tooltip': 'off',
+ 'mouseleave .acf-js-tooltip': 'off'
},
on: function( e ){
@@ -3102,7 +3297,7 @@ var acf;
events: {
'mouseenter .acf-postbox .handlediv': 'on',
- 'mouseleave .acf-postbox .handlediv': 'off',
+ 'mouseleave .acf-postbox .handlediv': 'off'
},
on: function( e ){
@@ -3304,6 +3499,28 @@ var acf;
}, 999);
*/
+
+
+ /*
+ * indexOf
+ *
+ * This function will provide compatibility for ie8
+ *
+ * @type function
+ * @date 5/3/17
+ * @since 5.5.10
+ *
+ * @param n/a
+ * @return n/a
+ */
+
+ if( !Array.prototype.indexOf ) {
+
+ Array.prototype.indexOf = function(val) {
+ return $.inArray(val, this);
+ };
+
+ }
})(jQuery);
@@ -3330,7 +3547,7 @@ var acf;
//'page_parent': 0,
//'page_type': 0,
//'post_format': 0,
- //'post_taxonomy': 0,
+ //'post_taxonomy': 0
},
xhr: null,
@@ -4103,13 +4320,13 @@ var acf;
// calculate visibility
- for( var i in groups ) {
+ for( var i = 0; i < groups.length; i++ ) {
// vars
var group = groups[i],
match_group = true;
- for( var k in group ) {
+ for( var k = 0; k < group.length; k++ ) {
// vars
var rule = group[k];
@@ -4420,7 +4637,7 @@ var acf;
acf.datepicker = acf.model.extend({
actions: {
- 'ready 1': 'ready',
+ 'ready 1': 'ready'
},
ready: function(){
@@ -4524,7 +4741,7 @@ var acf;
},
events: {
- 'blur input[type="text"]': 'blur',
+ 'blur input[type="text"]': 'blur'
},
focus: function(){
@@ -4570,6 +4787,10 @@ var acf;
// add date picker
acf.datepicker.init( this.$input, args );
+
+ // action for 3rd party customization
+ acf.do_action('date_picker_init', this.$input, args, this.$field);
+
},
initialize2: function(){
@@ -4610,6 +4831,10 @@ var acf;
// now change the format back to how it should be.
this.$input.datepicker( 'option', 'dateFormat', dateFormat );
+
+ // action for 3rd party customization
+ acf.do_action('date_picker_init', this.$input, args, this.$field);
+
},
blur: function(){
@@ -4644,7 +4869,7 @@ var acf;
acf.datetimepicker = acf.model.extend({
actions: {
- 'ready 1': 'ready',
+ 'ready 1': 'ready'
},
ready: function(){
@@ -4729,7 +4954,7 @@ var acf;
// do nothing
- },
+ }
});
@@ -4749,7 +4974,7 @@ var acf;
},
events: {
- 'blur input[type="text"]': 'blur',
+ 'blur input[type="text"]': 'blur'
},
focus: function(){
@@ -4792,6 +5017,10 @@ var acf;
// add date time picker
acf.datetimepicker.init( this.$input, args );
+
+ // action for 3rd party customization
+ acf.do_action('date_time_picker_init', this.$input, args, this.$field);
+
},
blur: function(){
@@ -4911,7 +5140,7 @@ var acf;
alt: '',
title: '',
filename: '',
- filesize: '',
+ filesizeHumanReadable: '',
icon: '/wp-includes/images/media/default.png'
};
@@ -4921,7 +5150,7 @@ var acf;
// update data
data = attachment.attributes;
-
+
}
@@ -4962,7 +5191,7 @@ var acf;
});
this.$el.find('[data-name="title"]').text( data.title );
this.$el.find('[data-name="filename"]').text( data.filename ).attr( 'href', data.url );
- this.$el.find('[data-name="filesize"]').text( data.filesize );
+ this.$el.find('[data-name="filesize"]').text( data.filesizeHumanReadable );
// vars
@@ -5171,10 +5400,83 @@ var acf;
},
+ /*
+ * get_file_info
+ *
+ * This function will find basic file info and store it in a hidden input
+ *
+ * @type function
+ * @date 18/1/17
+ * @since 5.5.0
+ *
+ * @param $file_input (jQuery)
+ * @param $hidden_input (jQuery)
+ * @return n/a
+ */
+
+ get_file_info: function( $file_input, $hidden_input ){
+
+ // vars
+ var attachment = {};
+
+
+ // url
+ attachment.url = $file_input.val();
+
+
+ // modern browsers
+ var files = $file_input[0].files;
+
+ if( files ){
+
+ // vars
+ var file = files[0];
+
+
+ // update
+ attachment.size = file.size;
+ attachment.type = file.type;
+
+
+ // image
+ if( file.type.indexOf('image') > -1 ) {
+
+ // vars
+ var _url = window.URL || window.webkitURL;
+
+
+ // temp image
+ var img = new Image();
+
+ img.onload = function () {
+
+ // update
+ attachment.width = this.width;
+ attachment.height = this.height;
+
+
+ // set hidden input value
+ $hidden_input.val( jQuery.param(attachment) );
+
+ };
+
+ img.src = _url.createObjectURL(file);
+
+ }
+
+ }
+
+
+ // set hidden input value
+ $hidden_input.val( jQuery.param(attachment) );
+
+ },
+
+
/*
* change
*
- * This function will update the hidden input when selecting a basic file to clear validation errors
+ * This function will update the hidden input when selecting a basic file to add basic validation
*
* @type function
* @date 12/04/2016
@@ -5186,7 +5488,7 @@ var acf;
change: function( e ){
- this.$input.val( e.$el.val() );
+ this.get_file_info( e.$el, this.$input );
}
@@ -5212,6 +5514,7 @@ var acf;
$pending: $(),
actions: {
+ // have considered changing to 'load', however, could cause issues with devs expecting the API to exist earlier
'ready': 'initialize',
'append': 'initialize',
'show': 'show'
@@ -5226,7 +5529,7 @@ var acf;
'focus .search': '_focus',
'blur .search': '_blur',
//'paste .search': '_paste',
- 'mousedown .acf-google-map': '_mousedown',
+ 'mousedown .acf-google-map': '_mousedown'
},
focus: function(){
@@ -6324,7 +6627,7 @@ var acf;
/*
* change
*
- * This function will update the hidden input when selecting a basic file to clear validation errors
+ * This function will update the hidden input when selecting a basic file to add basic validation
*
* @type function
* @date 12/04/2016
@@ -6336,7 +6639,7 @@ var acf;
change: function( e ){
- this.$input.val( e.$el.val() );
+ acf.fields.file.get_file_info( e.$el, this.$input );
}
@@ -6904,7 +7207,7 @@ var acf;
title: settings.title,
multiple: settings.multiple,
library: {},
- states: [],
+ states: []
};
@@ -6944,7 +7247,7 @@ var acf;
// If the user isn't allowed to edit fields,
// can they still edit it locally?
- allowLocalEdits: true,
+ allowLocalEdits: true
})
];
@@ -7469,7 +7772,7 @@ var acf;
'click [data-name="value-title"]': '_edit',
'keypress [data-name="search-input"]': '_keypress',
'keyup [data-name="search-input"]': '_keyup',
- 'blur [data-name="search-input"]': '_blur',
+ 'blur [data-name="search-input"]': '_blur'
},
@@ -7525,7 +7828,7 @@ var acf;
// bail early if no value
if( !new_url ) {
- this.clear( $el );
+ this.clear();
return;
}
@@ -7577,8 +7880,7 @@ var acf;
var ajax_data = acf.prepare_for_ajax({
'action' : 'acf/fields/oembed/search',
's' : s,
- 'width' : this.$el.data('width'),
- 'height' : this.$el.data('height')
+ 'field_key' : this.$field.data('key')
});
@@ -7591,7 +7893,7 @@ var acf;
url: acf.get('ajaxurl'),
data: ajax_data,
type: 'post',
- dataType: 'html',
+ dataType: 'json',
context: this,
success: this.search_success
});
@@ -7602,7 +7904,7 @@ var acf;
},
- search_success: function( html ){
+ search_success: function( json ){
// vars
var s = this.$search.val();
@@ -7613,7 +7915,7 @@ var acf;
// error
- if( !html ) {
+ if( !json || !json.html ) {
this.$el.removeClass('has-value').addClass('has-error');
return;
@@ -7628,7 +7930,7 @@ var acf;
// update vars
this.$input.val( s );
this.$title.html( s );
- this.$embed.html( html );
+ this.$embed.html( json.html );
},
@@ -7696,7 +7998,7 @@ var acf;
},
- _keyup: function( e ){ console.log('_keypress', e.which);
+ _keyup: function( e ){ //console.log('_keypress', e.which);
// bail early if no value
if( !this.$search.val() ) return;
@@ -7711,7 +8013,7 @@ var acf;
this.blur();
- },
+ }
});
@@ -7731,7 +8033,7 @@ var acf;
},
events: {
- 'click input[type="radio"]': 'click',
+ 'click input[type="radio"]': 'click'
},
focus: function(){
@@ -8115,8 +8417,15 @@ var acf;
// Looks like Select2 v4 has moved away from highlighting results, so perhaps we should too
if( this.o.s ) {
+ // vars
var s = this.o.s;
+
+ // allow special characters to be used within regex
+ s = acf.addslashes(s);
+
+
+ // loop
$new.find('.acf-rel-item').each(function(){
// vars
@@ -8346,7 +8655,7 @@ var acf;
// actions
actions: {
- 'ready 1': 'ready',
+ 'ready 1': 'ready'
},
@@ -8482,31 +8791,36 @@ var acf;
* @return (mixed)
*/
- init: function( $select, args ){
+ init: function( $select, args, $field ){
// bail early if no version found
if( !this.version ) return;
// defaults
+ args = args || {};
+ $field = $field || null;
+
+
+ // merge
args = $.extend({
allow_null: false,
placeholder: '',
multiple: false,
ajax: false,
- ajax_action: '',
+ ajax_action: ''
}, args);
// v3
if( this.version == 3 ) {
- return this.init_v3( $select, args );
+ return this.init_v3( $select, args, $field );
// v4
} else if( this.version == 4 ) {
- return this.init_v4( $select, args );
+ return this.init_v4( $select, args, $field );
}
@@ -8676,19 +8990,19 @@ var acf;
* @return $post_id (int)
*/
- get_ajax_data: function( args, params ){
+ get_ajax_data: function( args, params, $el, $field ){
// vars
var data = acf.prepare_for_ajax({
action: args.ajax_action,
field_key: args.key,
- s: params.term,
- paged: params.page
+ s: params.term || '',
+ paged: params.page || 1
});
// filter
- data = acf.apply_filters( 'select2_ajax_data', data, args, params );
+ data = acf.apply_filters( 'select2_ajax_data', data, args, $el, $field );
// return
@@ -8817,7 +9131,7 @@ var acf;
* @return args (object)
*/
- init_v3: function( $select, args ){
+ init_v3: function( $select, args, $field ){
// vars
var $input = $select.siblings('input');
@@ -8936,7 +9250,7 @@ var acf;
// return
- return acf.select2.get_ajax_data(args, params);
+ return acf.select2.get_ajax_data(args, params, $input, $field);
},
results: function( data, page ){
@@ -8973,7 +9287,7 @@ var acf;
// filter for 3rd party customization
- select2_args = acf.apply_filters( 'select2_args', select2_args, $select, args );
+ select2_args = acf.apply_filters( 'select2_args', select2_args, $select, args, $field );
// add select2
@@ -9031,6 +9345,10 @@ var acf;
});
+
+ // action for 3rd party customization
+ acf.do_action('select2_init', $input, select2_args, args, $field);
+
},
@@ -9083,7 +9401,7 @@ var acf;
},
- init_v4: function( $select, args ){
+ init_v4: function( $select, args, $field ){
// vars
var $input = $select.siblings('input');
@@ -9101,7 +9419,7 @@ var acf;
multiple: args.multiple,
separator: '||',
data: [],
- escapeMarkup: function( m ){ return m; },
+ escapeMarkup: function( m ){ return m; }
/*
sorter: function (data) { console.log('sorter %o', data);
return data;
@@ -9177,7 +9495,7 @@ var acf;
data: function( params ) {
// return
- return acf.select2.get_ajax_data(args, params);
+ return acf.select2.get_ajax_data(args, params, $select, $field);
},
processResults: function( data, params ){
@@ -9245,17 +9563,24 @@ var acf;
// filter for 3rd party customization
- select2_args = acf.apply_filters( 'select2_args', select2_args, $select, args );
+ select2_args = acf.apply_filters( 'select2_args', select2_args, $select, args, $field );
// add select2
- //console.log( '%o %o ', $select, select2_args );
var $container = $select.select2( select2_args );
+ // clear value (allows null to be saved)
+ $input.val('');
+
+
// add class
$container.addClass('-acf');
+
+ // action for 3rd party customization
+ acf.do_action('select2_init', $select, select2_args, args, $field);
+
},
@@ -9410,7 +9735,7 @@ var acf;
}
- acf.select2.init( this.$select, this.o );
+ acf.select2.init( this.$select, this.o, this.$field );
},
@@ -9435,7 +9760,7 @@ var acf;
// user
acf.fields.user = acf.fields.select.extend({
- type: 'user',
+ type: 'user'
});
@@ -9443,7 +9768,7 @@ var acf;
// post_object
acf.fields.post_object = acf.fields.select.extend({
- type: 'post_object',
+ type: 'post_object'
});
@@ -9451,7 +9776,7 @@ var acf;
// page_link
acf.fields.page_link = acf.fields.select.extend({
- type: 'page_link',
+ type: 'page_link'
});
@@ -9919,7 +10244,7 @@ var acf;
},
events: {
- 'blur input[type="text"]': 'blur',
+ 'blur input[type="text"]': 'blur'
},
focus: function(){
@@ -9986,7 +10311,7 @@ var acf;
// add date picker
- this.$input.addClass('active').timepicker( args );
+ this.$input.timepicker( args );
// wrap the datepicker (only if it hasn't already been wrapped)
@@ -9996,6 +10321,10 @@ var acf;
}
+
+ // action for 3rd party customization
+ acf.do_action('time_picker_init', this.$input, args, this.$field);
+
},
blur: function(){
@@ -10027,7 +10356,10 @@ var acf;
},
events: {
- 'change .acf-switch-input': 'change'
+ 'change .acf-switch-input': '_change',
+ 'focus .acf-switch-input': '_focus',
+ 'blur .acf-switch-input': '_blur',
+ 'keypress .acf-switch-input': '_keypress'
},
@@ -10089,6 +10421,48 @@ var acf;
},
+ /*
+ * on
+ *
+ * description
+ *
+ * @type function
+ * @date 10/1/17
+ * @since 5.5.0
+ *
+ * @param $post_id (int)
+ * @return $post_id (int)
+ */
+
+ on: function() { //console.log('on');
+
+ this.$input.prop('checked', true);
+ this.$switch.addClass('-on');
+
+ },
+
+
+ /*
+ * off
+ *
+ * description
+ *
+ * @type function
+ * @date 10/1/17
+ * @since 5.5.0
+ *
+ * @param $post_id (int)
+ * @return $post_id (int)
+ */
+
+ off: function() { //console.log('off');
+
+ this.$input.prop('checked', false);
+ this.$switch.removeClass('-on');
+
+ },
+
+
/*
* change
*
@@ -10102,7 +10476,7 @@ var acf;
* @return $post_id (int)
*/
- change: function( e ){
+ _change: function( e ){
// vars
var checked = e.$el.prop('checked');
@@ -10111,15 +10485,88 @@ var acf;
// enable
if( checked ) {
- this.$switch.addClass('-on');
+ this.on();
// disable
} else {
- this.$switch.removeClass('-on');
+ this.off();
}
+ },
+
+
+ /*
+ * _focus
+ *
+ * description
+ *
+ * @type function
+ * @date 10/1/17
+ * @since 5.5.0
+ *
+ * @param $post_id (int)
+ * @return $post_id (int)
+ */
+
+ _focus: function( e ){
+
+ this.$switch.addClass('-focus');
+
+ },
+
+
+ /*
+ * _blur
+ *
+ * description
+ *
+ * @type function
+ * @date 10/1/17
+ * @since 5.5.0
+ *
+ * @param $post_id (int)
+ * @return $post_id (int)
+ */
+
+ _blur: function( e ){
+
+ this.$switch.removeClass('-focus');
+
+ },
+
+
+ /*
+ * _keypress
+ *
+ * description
+ *
+ * @type function
+ * @date 10/1/17
+ * @since 5.5.0
+ *
+ * @param $post_id (int)
+ * @return $post_id (int)
+ */
+
+ _keypress: function( e ){
+
+ // left
+ if( e.keyCode === 37 ) {
+
+ return this.off();
+
+ }
+
+
+ // right
+ if( e.keyCode === 39 ) {
+
+ return this.on();
+
+ }
+
}
});
@@ -10140,7 +10587,7 @@ var acf;
'remove': 'remove'
},
events: {
- 'click a[data-name="add"]': 'add_term',
+ 'click a[data-name="add"]': 'add_term'
},
focus: function(){
@@ -11627,8 +12074,17 @@ var acf;
// initialize
try {
+ // init
tinymce.init( mceInit );
+
+ // vars
+ var ed = tinyMCE.get( mceInit.id );
+
+
+ // action for 3rd party customization
+ acf.do_action('wysiwyg_tinymce_init', ed, ed.id, mceInit, this.$field);
+
} catch(e){}
},
@@ -11649,11 +12105,18 @@ var acf;
// initialize
try {
-
+
+ // init
var qtag = quicktags( qtInit );
+
+ // buttons
this._buttonsInit( qtag );
+
+ // action for 3rd party customization
+ acf.do_action('wysiwyg_quicktags_init', qtag, qtag.id, qtInit, this.$field);
+
} catch(e){}
},
@@ -11776,7 +12239,7 @@ ed.on('ResizeEditor', function(e) {
// hook for 3rd party customization
- mceInit = acf.apply_filters('wysiwyg_tinymce_settings', mceInit, mceInit.id);
+ mceInit = acf.apply_filters('wysiwyg_tinymce_settings', mceInit, mceInit.id, this.$field);
// return
@@ -11795,7 +12258,7 @@ ed.on('ResizeEditor', function(e) {
// hook for 3rd party customization
- qtInit = acf.apply_filters('wysiwyg_quicktags_settings', qtInit, qtInit.id);
+ qtInit = acf.apply_filters('wysiwyg_quicktags_settings', qtInit, qtInit.id, this.$field);
// return
@@ -11839,12 +12302,16 @@ ed.on('ResizeEditor', function(e) {
enable: function(){
- // bail early if html mode
- if( this.$el.hasClass('tmce-active') && acf.isset(window,'switchEditors') ) {
+ try {
- switchEditors.go( this.o.id, 'tmce');
-
- }
+ // bail early if html mode
+ if( this.$el.hasClass('tmce-active') ) {
+
+ switchEditors.go( this.o.id, 'tmce');
+
+ }
+
+ } catch(e) {}
},
@@ -11926,7 +12393,7 @@ ed.on('ResizeEditor', function(e) {
ed.toolbar.innerHTML = html;
ed.theButtons = theButtons;
- },
+ }
});
diff --git a/assets/js/acf-input.min.js b/assets/js/acf-input.min.js
index d837f02..cd3c099 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(){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&&o("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 r(e,t){return"string"==typeof e&&o("filters",e,t),f}function o(e,t,i,a){if(u[e][t])if(i){var n=u[e][t],s;if(a)for(s=n.length;s--;){var r=n[s];r.callback===i&&r.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},r=u[e][t];r?(r.push(s),r=c(r)):r=[s],u[e][t]=r}function c(e){for(var t,i,a,n=1,s=e.length;n
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];var n=0,s=a.length;if("filters"===e)for(;n0},$.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;ie.length?Array(1+(t-e.length)).join("0")+e:e};return this.php_js||(this.php_js={}),this.php_js.uniqidSeed||(this.php_js.uniqidSeed=Math.floor(123456789*Math.random())),this.php_js.uniqidSeed++,i=e,i+=a(parseInt((new Date).getTime()/1e3,10),8),i+=a(this.php_js.uniqidSeed,5),t&&(i+=(10*Math.random()).toFixed(8).toString()),i},serialize_form:function(e){var t={},i={};return $selector=e.find("select, textarea, input"),$.each($selector.serializeArray(),function(e,a){"[]"===a.name.slice(-2)&&(a.name=a.name.replace("[]",""),"undefined"==typeof i[a.name]&&(i[a.name]=-1),i[a.name]++,a.name+="["+i[a.name]+"]"),t[a.name]=a.value}),t},serialize:function(e){return this.serialize_form(e)},disable:function(e,t){if(t=t||"",e.hasClass("acf-disabled"))return!1;if(e.prop("disabled",!0),t){var i=e.data("acf_disabled")||[],a=i.indexOf(t);a<0&&(i.push(t),e.data("acf_disabled",i))}return!0},enable:function(e,t){if(t=t||"",e.hasClass("acf-disabled"))return!1;var i=e.data("acf_disabled")||[];if(t){var a=i.indexOf(t);a>-1&&(i.splice(a,1),e.data("acf_disabled",i))}return!i.length&&(e.prop("disabled",!1),!0)},disable_el:function(e,t){t=t||"",e.find("select, textarea, input").each(function(){acf.disable($(this),t)})},disable_form:function(e,t){this.disable_el.apply(this,arguments)},enable_el:function(e,t){t=t||"",e.find("select, textarea, input").each(function(){acf.enable($(this),t)})},enable_form:function(e,t){this.enable_el.apply(this,arguments)},remove_tr:function(e,t){var i=e.height(),a=e.children().length;e.addClass("acf-remove-element"),setTimeout(function(){e.removeClass("acf-remove-element"),e.html(' | '),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-popup"),$popup.exists())return update_popup(e);var t=['"].join("");return $("body").append(t),$("#acf-popup").on("click",".bg, .acf-close-popup",function(e){e.preventDefault(),acf.close_popup()}),this.update_popup(e)},update_popup:function(e){return $popup=$("#acf-popup"),!!$popup.exists()&&(e=$.extend({},{title:"",content:"",width:0,height:0,loading:!1},e),e.title&&$popup.find(".title h3").html(e.title),e.content&&($inner=$popup.find(".inner:first"),$inner.html(e.content),acf.do_action("append",$inner),$inner.attr("style","position: relative;"),e.height=$inner.outerHeight(),$inner.removeAttr("style")),e.width&&$popup.find(".acf-popup-box").css({width:e.width,"margin-left":0-e.width/2}),e.height&&(e.height+=44,$popup.find(".acf-popup-box").css({height:e.height,"margin-top":0-e.height/2})),e.loading?$popup.find(".loading").show():$popup.find(".loading").hide(),$popup)},close_popup:function(){$popup=$("#acf-popup"),$popup.exists()&&$popup.remove()},update_user_setting:function(e,t){$.ajax({url:acf.get("ajaxurl"),dataType:"html",type:"post",data:acf.prepare_for_ajax({action:"acf/update_user_setting",name:e,value:t})})},prepare_for_ajax:function(e){return e.nonce=acf.get("nonce"),e.post_id=acf.get("post_id"),e=acf.apply_filters("prepare_for_ajax",e)},is_ajax_success:function(e){return!(!e||!e.success)},get_ajax_message:function(e){var t={text:"",type:"error"};return e?(e.success&&(t.type="success"),e.data&&e.data.message&&(t.text=e.data.message),e.data&&e.data.error&&(t.text=e.data.error),t):t},is_in_view:function(e){var t=e.offset().top,i=t+e.height();if(t===i)return!1;var a=$(window).scrollTop(),n=a+$(window).height();return i<=n&&t>=a},val:function(e,t){var i=e.val();e.val(t),t!=i&&e.trigger("change")},str_replace:function(e,t,i){return i.split(e).join(t)},str_sanitize:function(e){var t="",a={"æ":"a","å":"a","á":"a","ä":"a","č":"c","ď":"d","è":"e","é":"e","ě":"e","ë":"e","í":"i","ĺ":"l","ľ":"l","ň":"n","ø":"o","ó":"o","ô":"o","ő":"o","ö":"o","ŕ":"r","š":"s","ť":"t","ú":"u","ů":"u","ű":"u","ü":"u","ý":"y","ř":"r","ž":"z"," ":"_","'":"","?":"","/":"","\\":"",".":"",",":"",">":"","<":"",'"':"","[":"","]":"","|":"","{":"","}":"","(":"",")":""};for(e=e.toLowerCase(),i=0;i'),e.append(n))),n.append('"),i==a.value&&e.prop("selectedIndex",t)})},duplicate:function(e){"undefined"!=typeof e.length&&(e={$el:e}),e=acf.parse_args(e,{$el:!1,search:"",replace:"",before:function(e){},after:function(e,t){},append:function(e,t){e.after(t)}});var t=e.$el,i;e.search||(e.search=t.attr("data-id")),e.replace||(e.replace=acf.get_uniqid()),e.before.apply(this,[t]),acf.do_action("before_duplicate",t);var i=t.clone();return i.removeClass("acf-clone"),acf.do_action("remove",i),e.search&&(i.attr("data-id",e.replace),i.find('[id*="'+e.search+'"]').each(function(){$(this).attr("id",$(this).attr("id").replace(e.search,e.replace))}),i.find('[name*="'+e.search+'"]').each(function(){$(this).attr("name",$(this).attr("name").replace(e.search,e.replace))}),i.find('label[for*="'+e.search+'"]').each(function(){$(this).attr("for",$(this).attr("for").replace(e.search,e.replace))})),i.find(".ui-sortable").removeClass("ui-sortable"),acf.do_action("after_duplicate",t,i),e.after.apply(this,[t,i]),e.append.apply(this,[t,i]),setTimeout(function(){acf.do_action("append",i)},1),i},decode:function(e){return $("").html(e).text()},parse_args:function(e,t){return $.extend({},t,e)},enqueue_script:function(e,t){var i=document.createElement("script");i.type="text/javascript",i.src=e,i.async=!0,i.readyState?i.onreadystatechange=function(){"loaded"!=i.readyState&&"complete"!=i.readyState||(i.onreadystatechange=null,t())}:i.onload=function(){t()},document.body.appendChild(i)}},acf.model={actions:{},filters:{},events:{},extend:function(e){var t=$.extend({},this,e);return $.each(t.actions,function(e,i){t._add_action(e,i)}),$.each(t.filters,function(e,i){t._add_filter(e,i)}),$.each(t.events,function(e,i){t._add_event(e,i)}),t},_add_action:function(e,t){var i=this,a=e.split(" "),e=a[0]||"",n=a[1]||10;acf.add_action(e,i[t],n,i)},_add_filter:function(e,t){var i=this,a=e.split(" "),e=a[0]||"",n=a[1]||10;acf.add_filter(e,i[t],n,i)},_add_event:function(e,t){var i=this,a=e.substr(0,e.indexOf(" ")),n=e.substr(e.indexOf(" ")+1);$(document).on(a,n,function(e){e.$el=$(this),"function"==typeof i.event&&(e=i.event(e)),i[t].apply(i,[e])})},get:function(e,t){return t=t||null,"undefined"!=typeof this[e]&&(t=this[e]),t},set:function(e,t){return this[e]=t,"function"==typeof this["_set_"+e]&&this["_set_"+e].apply(this),this}},acf.field=acf.model.extend({type:"",o:{},$field:null,_add_action:function(e,t){var i=this;e=e+"_field/type="+i.type,acf.add_action(e,function(e){i.set("$field",e),i[t].apply(i,arguments)})},_add_filter:function(e,t){var i=this;e=e+"_field/type="+i.type,acf.add_filter(e,function(e){i.set("$field",e),i[t].apply(i,arguments)})},_add_event:function(e,t){var i=this,a=e.substr(0,e.indexOf(" ")),n=e.substr(e.indexOf(" ")+1),s=acf.get_selector(i.type);$(document).on(a,s+" "+n,function(e){e.$el=$(this),e.$field=acf.get_closest_field(e.$el,i.type),i.set("$field",e.$field),i[t].apply(i,[e])})},_set_$field:function(){"function"==typeof this.focus&&this.focus()},doFocus:function(e){return this.set("$field",e)}}),acf.fields=acf.model.extend({actions:{prepare:"_prepare",prepare_field:"_prepare_field",ready:"_ready",ready_field:"_ready_field",append:"_append",append_field:"_append_field",load:"_load",load_field:"_load_field",remove:"_remove",remove_field:"_remove_field",sortstart:"_sortstart",sortstart_field:"_sortstart_field",sortstop:"_sortstop",sortstop_field:"_sortstop_field",show:"_show",show_field:"_show_field",hide:"_hide",hide_field:"_hide_field"},_prepare:function(e){acf.get_fields("",e).each(function(){acf.do_action("prepare_field",$(this))})},_prepare_field:function(e){acf.do_action("prepare_field/type="+e.data("type"),e)},_ready:function(e){acf.get_fields("",e).each(function(){acf.do_action("ready_field",$(this))})},_ready_field:function(e){acf.do_action("ready_field/type="+e.data("type"),e)},_append:function(e){acf.get_fields("",e).each(function(){acf.do_action("append_field",$(this))})},_append_field:function(e){acf.do_action("append_field/type="+e.data("type"),e)},_load:function(e){acf.get_fields("",e).each(function(){acf.do_action("load_field",$(this))})},_load_field:function(e){acf.do_action("load_field/type="+e.data("type"),e)},_remove:function(e){acf.get_fields("",e).each(function(){acf.do_action("remove_field",$(this))})},_remove_field:function(e){acf.do_action("remove_field/type="+e.data("type"),e)},_sortstart:function(e,t){acf.get_fields("",e).each(function(){acf.do_action("sortstart_field",$(this),t)})},_sortstart_field:function(e,t){acf.do_action("sortstart_field/type="+e.data("type"),e,t)},_sortstop:function(e,t){acf.get_fields("",e).each(function(){acf.do_action("sortstop_field",$(this),t)})},_sortstop_field:function(e,t){acf.do_action("sortstop_field/type="+e.data("type"),e,t)},_hide:function(e,t){acf.get_fields("",e).each(function(){acf.do_action("hide_field",$(this),t)})},_hide_field:function(e,t){acf.do_action("hide_field/type="+e.data("type"),e,t)},_show:function(e,t){acf.get_fields("",e).each(function(){acf.do_action("show_field",$(this),t)})},_show_field:function(e,t){acf.do_action("show_field/type="+e.data("type"),e,t)}}),$(document).ready(function(){acf.do_action("ready",$("body"))}),$(window).on("load",function(){acf.do_action("load",$("body"))}),acf.layout=acf.model.extend({active:0,actions:{refresh:"refresh"},refresh:function(e){e=e||!1,e&&e.is(".acf-fields")&&(e=e.parent()),$(".acf-fields:visible",e).each(function(){var e=$(),t=0,i=0,a=-1,n=$(this).children(".acf-field[data-width]:visible");n.exists()&&(n.removeClass("acf-r0 acf-c0").css({"min-height":0}),n.each(function(n){var s=$(this),r=s.position().top;0==n&&(t=r),r!=t&&(e.css({"min-height":i+1+"px"}),e=$(),t=s.position().top,i=0,a=-1),a++,i=s.outerHeight()>i?s.outerHeight():i,e=e.add(s),0==r?s.addClass("acf-r0"):0==a&&s.addClass("acf-c0")}),e.exists()&&e.css({"min-height":i+1+"px"}))})}}),$(document).on("change",".acf-field input, .acf-field textarea, .acf-field select",function(){$('#acf-form-data input[name="_acfchanged"]').exists()&&$('#acf-form-data input[name="_acfchanged"]').val(1),acf.do_action("change",$(this))}),$(document).on("click",'.acf-field a[href="#"]',function(e){e.preventDefault()}),acf.unload=acf.model.extend({active:1,changed:0,filters:{validation_complete:"validation_complete"},actions:{change:"on",submit:"off"},events:{"submit form":"off"},validation_complete:function(e,t){return e&&e.errors&&this.on(),e},on:function(){!this.changed&&this.active&&(this.changed=1,$(window).on("beforeunload",this.unload))},off:function(){this.changed=0,$(window).off("beforeunload",this.unload)},unload:function(){return acf._e("unload")}}),acf.tooltip=acf.model.extend({$el:null,events:{"mouseenter .acf-js-tooltip":"on","mouseleave .acf-js-tooltip":"off"},on:function(e){var t=e.$el.attr("title");if(t){this.$el=$(''+t+"
"),$("body").append(this.$el);var i=10;target_w=e.$el.outerWidth(),target_h=e.$el.outerHeight(),target_t=e.$el.offset().top,target_l=e.$el.offset().left,tooltip_w=this.$el.outerWidth(),tooltip_h=this.$el.outerHeight();var a=target_t-tooltip_h,n=target_l+target_w/2-tooltip_w/2;n$(window).width()?(this.$el.addClass("left"),n=target_l-tooltip_w,a=target_t+target_h/2-tooltip_h/2):a-$(window).scrollTop()')}}),acf.add_action("sortstart",function(e,t){e.is("tr")&&(e.css("position","relative"),e.children().each(function(){$(this).width($(this).width())}),e.css("position","absolute"),t.html(' | '))}),acf.add_action("before_duplicate",function(e){e.find("select option:selected").addClass("selected")}),acf.add_action("after_duplicate",function(e,t){t.find("select").each(function(){var e=$(this),t=[];e.find("option.selected").each(function(){t.push($(this).val())}),e.val(t)}),e.find("select option.selected").removeClass("selected"),t.find("select option.selected").removeClass("selected")})}(jQuery),function($){acf.ajax=acf.model.extend({active:!1,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 .categorychecklist select":"_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")),this.active=!0},fetch:function(){if(this.active&&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"),$("#acf-style").html(""),$.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","click .acf-add-checkbox":"_add"},focus:function(){this.$ul=this.$field.find("ul"),this.$input=this.$field.find('input[type="hidden"]')},add:function(){var e=this.$input.attr("name")+"[]",t='';this.$ul.find(".acf-add-checkbox").parent("li").before(t)},_change:function(e){var t=this.$ul,i=t.find('input[type="checkbox"]').not(".acf-checkbox-toggle"),a=e.$el.is(":checked");if(e.$el.hasClass("acf-checkbox-toggle"))return void i.prop("checked",a).trigger("change");if(e.$el.hasClass("acf-checkbox-custom")){var n=e.$el.next('input[type="text"]');e.$el.next('input[type="text"]').prop("disabled",!a),a||""!=n.val()||e.$el.parent("li").remove()}if(t.find(".acf-checkbox-toggle").exists()){var a=0==i.not(":checked").length;t.find(".acf-checkbox-toggle").prop("checked",a)}},_add:function(e){this.add()}})}(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],r=s.field,o=this.triggers[r]||{};o[e]=e,this.triggers[r]=o}}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],r=acf.get_fields(s,$parent,!0);this.render_fields(r)}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],r=!0;for(var o in s){var l=s[o],c=this.get_trigger(e,l.field);if(!this.calculate(l,c,e)){r=!1;break}}if(r){i=!0;break}}i?this.show_field(e):this.hide_field(e)},show_field:function(e){var t=e.data("key");e.removeClass("hidden-by-conditional-logic"),acf.enable_form(e,"condition_"+t),acf.do_action("show_field",e,"conditional_logic")},hide_field:function(e){var t=e.data("key");e.addClass("hidden-by-conditional-logic"),acf.disable_form(e,"condition_"+t),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(){if(a=$(this).siblings(i),a.exists())return!1})}return!!a.exists()&&a},calculate:function(e,t,i){if(!t||!i)return!1;var a=!1,n=t.data("type");return"true_false"==n||"checkbox"==n||"radio"==n?a=this.calculate_checkbox(e,t):"select"==n&&(a=this.calculate_select(e,t)),"!="===e.operator&&(a=!a),a},calculate_checkbox:function(e,t){var i=t.find('input[value="'+e.value+'"]:checked').exists();return""!==e.value||t.find("input:checked").exists()||(i=!0),i},calculate_select:function(e,t){var i=t.find("select"),a=i.val();return a||$.isNumeric(a)||(a=""),$.isArray(a)||(a=[a]),match=$.inArray(e.value,a)>-1,match}})}(jQuery),function($){acf.datepicker=acf.model.extend({actions:{"ready 1":"ready"},ready:function(){var e=acf.get("locale"),t=acf.get("rtl");l10n=acf._e("date_picker"),l10n&&"undefined"!=typeof $.datepicker&&(l10n.isRTL=t,$.datepicker.regional[e]=l10n,$.datepicker.setDefaults(l10n))},init:function(e,t){"undefined"!=typeof $.datepicker&&(t=t||{},e.datepicker(t),$("body > #ui-datepicker-div").exists()&&$("body > #ui-datepicker-div").wrap(''))},destroy:function(e){}}),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(){if(this.o.save_format)return this.initialize2();var e={dateFormat:this.o.date_format,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),acf.datepicker.init(this.$input,e)},initialize2:function(){this.$input.val(this.$hidden.val());var e={dateFormat:this.o.date_format,altField:this.$hidden,altFormat:this.o.save_format,changeYear:!0,yearRange:"-100:+100",changeMonth:!0,showButtonPanel:!0,firstDay:this.o.first_day};e=acf.apply_filters("date_picker_args",e,this.$field);var t=e.dateFormat;e.dateFormat=this.o.save_format,acf.datepicker.init(this.$input,e),this.$input.datepicker("option","dateFormat",t)},blur:function(){this.$input.val()||this.$hidden.val("")}})}(jQuery),function($){acf.datetimepicker=acf.model.extend({actions:{"ready 1":"ready"},ready:function(){var e=acf.get("locale"),t=acf.get("rtl");l10n=acf._e("date_time_picker"),l10n&&"undefined"!=typeof $.timepicker&&(l10n.isRTL=t,$.timepicker.regional[e]=l10n,$.timepicker.setDefaults(l10n))},init:function(e,t){"undefined"!=typeof $.timepicker&&(t=t||{},e.datetimepicker(t),$("body > #ui-datepicker-div").exists()&&$("body > #ui-datepicker-div").wrap(''))},destroy:function(e){}}),acf.fields.date_time_picker=acf.field.extend({type:"date_time_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-time-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(){var e={dateFormat:this.o.date_format,timeFormat:this.o.time_format,altField:this.$hidden,altFieldTimeOnly:!1,altFormat:"yy-mm-dd",altTimeFormat:"HH:mm:ss",changeYear:!0,yearRange:"-100:+100",changeMonth:!0,showButtonPanel:!0,firstDay:this.o.first_day,controlType:"select",oneLine:!0};e=acf.apply_filters("date_time_picker_args",e,this.$field),acf.datetimepicker.init(this.$input,e)},blur:function(){this.$input.val()||this.$hidden.val("")}})}(jQuery),function($){acf.fields.file=acf.field.extend({type:"file",$el:null,$input: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.$input=this.$el.find('input[type="hidden"]'),this.o=acf.get_data(this.$el)},initialize:function(){"basic"==this.o.uploader&&this.$el.closest("form").attr("enctype","multipart/form-data")},prepare:function(e){if(e=e||{},e._valid)return e;var t={url:"",alt:"",title:"",filename:"",filesize:"",icon:"/wp-includes/images/media/default.png"};return e.id&&(t=e.attributes),t._valid=!0,t},render:function(e){e=this.prepare(e),this.$el.find("img").attr({src:e.icon,alt:e.alt,title:e.title}),this.$el.find('[data-name="title"]').text(e.title),this.$el.find('[data-name="filename"]').text(e.filename).attr("href",e.url),this.$el.find('[data-name="filesize"]').text(e.filesize);var t="";e.id&&(t=e.id),acf.val(this.$input,t),t?this.$el.addClass("has-value"):this.$el.removeClass("has-value")},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"),r=t.closest(".acf-row");if(t=!1,r.nextAll(".acf-row:visible").each(function(){if(t=acf.get_field(s,$(this)))return!!t.find(".acf-file-uploader.has-value").exists()&&void(t=!1)}),!t){if(r=acf.fields.repeater.doFocus(i).add(),!r)return!1;t=acf.get_field(s,r)}}e.set("$field",t).render(a)}})},edit:function(){var e=this,t=this.$field,i=this.$input.val();if(i)var a=acf.media.popup({title:acf._e("file","edit"),button:acf._e("file","update"),mode:"edit",attachment:i,select:function(i,a){e.set("$field",t).render(i)}})},remove:function(){var e={};this.render(e)},change:function(e){this.$input.val(e.$el.val())}})}(jQuery),function($){acf.fields.google_map=acf.field.extend({type:"google_map",url:"",$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.o.id=this.$el.attr("id"),this.maps[this.o.id]&&(this.map=this.maps[this.o.id])},is_ready:function(){var e=this;return"ready"==this.status||"loading"!=this.status&&(acf.isset(window,"google","maps","places")?(this.status="ready",!0):(acf.isset(window,"google","maps")&&(this.status="ready"),this.url&&(this.status="loading",acf.enqueue_script(this.url,function(){e.status="ready",e.initialize_pending()})),"ready"==this.status))},initialize_pending:function(){var e=this;this.$pending.each(function(){e.set("$field",$(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",{scrollwheel:!1,zoom:parseInt(this.o.zoom),center:new google.maps.LatLng(this.o.lat,this.o.lng),mapTypeId:google.maps.MapTypeId.ROADMAP},this.$field);if(this.map=new google.maps.Map(this.$el.find(".canvas")[0],n),acf.isset(window,"google","maps","places","Autocomplete")){var s=new google.maps.places.Autocomplete(this.$search[0]);s.bindTo("bounds",this.map),google.maps.event.addListener(s,"place_changed",function(t){var i=this.getPlace();e.search(i)}),this.map.autocomplete=s}var r=acf.apply_filters("google_map_marker_args",{draggable:!0,raiseOnDrag:!0,map:this.map},this.$field);this.map.marker=new google.maps.Marker(r),
-this.map.$el=i,this.map.$field=t;var o=i.find(".input-lat").val(),l=i.find(".input-lng").val();o&&l&&this.update(o,l).center(),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())},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.$el.find('input[type="hidden"]'),this.$img=this.$el.find("img"),this.o=acf.get_data(this.$el)},initialize:function(){"basic"==this.o.uploader&&this.$el.closest("form").attr("enctype","multipart/form-data")},prepare:function(e){if(e=e||{},e._valid)return e;var t={url:"",alt:"",title:"",caption:"",description:"",width:0,height:0};return e.id&&(t=e.attributes,t.url=acf.maybe_get(t,"sizes."+this.o.preview_size+".url",t.url)),t._valid=!0,t},render:function(e){e=this.prepare(e),this.$img.attr({src:e.url,alt:e.alt,title:e.title});var t="";e.id&&(t=e.id),acf.val(this.$input,t),t?this.$el.addClass("has-value"):this.$el.removeClass("has-value")},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"),r=t.closest(".acf-row");if(t=!1,r.nextAll(".acf-row:visible").each(function(){if(t=acf.get_field(s,$(this)))return!!t.find(".acf-image-uploader.has-value").exists()&&void(t=!1)}),!t){if(r=acf.fields.repeater.doFocus(i).add(),!r)return!1;t=acf.get_field(s,r)}}e.set("$field",t).render(a)}})},edit:function(){var e=this,t=this.$field,i=this.$input.val();if(i)var a=acf.media.popup({title:acf._e("image","edit"),button:acf._e("image","update"),mode:"edit",attachment:i,select:function(i,a){e.set("$field",t).render(i)}})},remove:function(){var e={};this.render(e)},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!(e<0)&&this.frames[e]},destroy:function(e){e.detach(),e.dispose(),e=null,this.frames.pop()},popup:function(e){var t=acf.get("post_id"),i=!1;$.isNumeric(t)||(t=0);var a=acf.parse_args(e,{mode:"select",title:"",button:"",type:"",field:"",mime_types:"",library:"all",multiple:!1,attachment:0,post_id:t,select:function(){}});a.id&&(a.attachment=a.id);var i=this.new_media_frame(a);return this.frames.push(i),setTimeout(function(){i.open()},1),i},_get_media_frame_settings:function(e,t){return"select"===t.mode?e=this._get_select_frame_settings(e,t):"edit"===t.mode&&(e=this._get_edit_frame_settings(e,t)),e},_get_select_frame_settings:function(e,t){return t.type&&(e.library.type=t.type),"uploadedTo"===t.library&&(e.library.uploadedTo=t.post_id),e._button=acf._e("media","select"),e},_get_edit_frame_settings:function(e,t){return e.library.post__in=[t.attachment],e._button=acf._e("media","update"),e},_add_media_frame_events:function(e,t){return e.on("open",function(){this.$el.closest(".media-modal").addClass("acf-media-modal -"+t.mode)},e),e.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()},e),e.on("toolbar:create:select",function(t){t.view=new wp.media.view.Toolbar.Select({text:e.options._button,controller:this})},e),e.on("select",function(){var i=e.state(),a=i.get("image"),n=i.get("selection");if(a)return void t.select.apply(e,[a,0]);if(n){var s=0;return void n.each(function(i){t.select.apply(e,[i,s]),s++})}}),e.on("close",function(){setTimeout(function(){acf.media.destroy(e)},500)}),"select"===t.mode?e=this._add_select_frame_events(e,t):"edit"===t.mode&&(e=this._add_edit_frame_events(e,t)),e},_add_select_frame_events:function(e,t){var i=this;return acf.isset(_wpPluploadSettings,"defaults","multipart_params")&&(_wpPluploadSettings.defaults.multipart_params._acfuploader=t.field,e.on("open",function(){delete _wpPluploadSettings.defaults.multipart_params._acfuploader})),e.on("content:activate:browse",function(){try{var a=e.content.get().toolbar,n=a.get("filters"),s=a.get("search")}catch(e){return}if("image"==t.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")})),t.mime_types){var r=t.mime_types.split(" ").join("").split(".").join("").split(",");$.each(r,function(e,t){$.each(i.mime_types,function(e,i){if(e.indexOf(t)!==-1){var a={text:t,props:{status:null,type:i,uploadedTo:null,orderby:"date",order:"DESC"},priority:20};n.filters[i]=a}})})}"uploadedTo"==t.library&&(delete n.filters.unattached,delete n.filters.uploaded,n.$el.parent().append(''+acf._e("image","uploadedTo")+""),$.each(n.filters,function(e,i){i.props.uploadedTo=t.post_id})),$.each(n.filters,function(e,i){i.props._acfuploader=t.field}),s.model.attributes._acfuploader=t.field,"function"==typeof n.refresh&&n.refresh()}),e},_add_edit_frame_events:function(e,t){return e.on("open",function(){this.$el.closest(".media-modal").addClass("acf-expanded"),"browse"!=this.content.mode()&&this.content.mode("browse");var e=this.state(),i=e.get("selection"),a=wp.media.attachment(t.attachment);i.add(a)},e),e},new_media_frame:function(e){var t={title:e.title,multiple:e.multiple,library:{},states:[]};t=this._get_media_frame_settings(t,e);var i=wp.media.query(t.library);acf.isset(i,"mirroring","args")&&(i.mirroring.args._acfuploader=e.field),t.states=[new wp.media.controller.Library({library:i,multiple:t.multiple,title:t.title,priority:20,filterable:"all",editable:!0,allowLocalEdits:!0})],acf.isset(wp,"media","controller","EditImage")&&t.states.push(new wp.media.controller.EditImage);var a=wp.media(t);return a.acf=e,a=this._add_media_frame_events(a,e)},ready:function(){var e=acf.get("wp_version"),t=acf.get("browser"),i=acf.get("post_id");acf.isset(window,"wp","media","view","settings","post")&&$.isNumeric(i)&&(wp.media.view.settings.post.id=i),t&&$("body").addClass("browser-"+t),e&&(e+="",major=e.substr(0,1),$("body").addClass("major-"+major)),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=this.collection,a=this.options.selection,n=this.model,s=a.single(),r=acf.media.frame(),o=acf.maybe_get(this,"model.attributes.acf_errors"),l=this.controller.$el.find(".media-frame-content .media-sidebar");if(l.children(".acf-selection-error").remove(),l.children().removeClass("acf-hidden"),r&&o){var c=acf.maybe_get(this,"model.attributes.filename","");return l.children().addClass("acf-hidden"),l.prepend(['',''+acf._e("restricted")+"",''+c+"",''+o+"","
"].join("")),a.reset(),void a.single(n)}e.prototype.toggleSelection.apply(this,arguments)}})},customize_AttachmentFiltersAll:function(){wp.media.view.AttachmentFilters.All.prototype.refresh=function(){this.$el.html(_.chain(this.filters).map(function(e,t){return{el:$("").val(t).html(e.text)[0],priority:e.priority||50}},this).sortBy("priority").pluck("el").value())}},customize_AttachmentCompat:function(){var e=wp.media.view.AttachmentCompat;wp.media.view.AttachmentCompat=e.extend({render:function(){var t=this;return this.ignore_render?this:(setTimeout(function(){var e=t.$el.closest(".media-modal");if(!e.find(".media-frame-router .acf-expand-details").exists()){var i=$(['',''+acf._e("expand_details")+"",''+acf._e("collapse_details")+"",""].join(""));i.on("click",function(t){t.preventDefault(),e.hasClass("acf-expanded")?e.removeClass("acf-expanded"):e.addClass("acf-expanded")}),e.find(".media-frame-router").append(i)}},0),clearTimeout(acf.media.render_timout),acf.media.render_timout=setTimeout(function(){acf.do_action("append",t.$el)},50),e.prototype.render.apply(this,arguments))},dispose:function(){return acf.do_action("remove",this.$el),e.prototype.dispose.apply(this,arguments)},save:function(e){e&&e.preventDefault();var t=acf.serialize_form(this.$el);this.ignore_render=!0,this.model.saveCompat(t)}})}})}(jQuery),function($){acf.fields.oembed=acf.field.extend({type:"oembed",$el:null,events:{'click [data-name="search-button"]':"_search",'click [data-name="clear-button"]':"_clear",'click [data-name="value-title"]':"_edit",'keypress [data-name="search-input"]':"_keypress",'keyup [data-name="search-input"]':"_keyup",'blur [data-name="search-input"]':"_blur"},focus:function(){this.$el=this.$field.find(".acf-oembed"),this.$search=this.$el.find('[data-name="search-input"]'),this.$input=this.$el.find('[data-name="value-input"]'),this.$title=this.$el.find('[data-name="value-title"]'),this.$embed=this.$el.find('[data-name="value-embed"]'),this.o=acf.get_data(this.$el)},maybe_search:function(){var e=this.$input.val(),t=this.$search.val();return t?void(t!=e&&this.search()):void this.clear($el)},search:function(){var e=this.$search.val();"http"!=e.substr(0,4)&&(e="http://"+e,this.$search.val(e)),this.$el.addClass("is-loading");var t=acf.prepare_for_ajax({action:"acf/fields/oembed/search",s:e,width:this.$el.data("width"),height:this.$el.data("height")});this.$el.data("xhr")&&this.$el.data("xhr").abort();var i=$.ajax({url:acf.get("ajaxurl"),data:t,type:"post",dataType:"html",context:this,success:this.search_success});this.$el.data("xhr",i)},search_success:function(e){var t=this.$search.val();return this.$el.removeClass("is-loading"),e?(this.$el.removeClass("has-error").addClass("has-value"),this.$input.val(t),this.$title.html(t),void this.$embed.html(e)):void this.$el.removeClass("has-value").addClass("has-error")},clear:function(){this.$el.removeClass("has-error has-value"),this.$el.find('[data-name="search-input"]').val(""),this.$input.val(""),this.$title.html(""),this.$embed.html("")},edit:function(){this.$el.addClass("is-editing"),this.$search.val(this.$title.text()).focus()},blur:function(e){this.$el.removeClass("is-editing"),this.maybe_search()},_search:function(e){this.search()},_clear:function(e){this.clear()},_edit:function(e){this.edit()},_keypress:function(e){13==e.which&&e.preventDefault()},_keyup:function(e){console.log("_keypress",e.which),this.$search.val()&&this.maybe_search()},_blur:function(e){this.blur()}})}(jQuery),function($){acf.fields.radio=acf.field.extend({type:"radio",$ul:null,actions:{ready:"initialize",append:"initialize"},events:{'click input[type="radio"]':"click"},focus:function(){this.$ul=this.$field.find(".acf-radio-list"),this.o=acf.get_data(this.$ul)},initialize:function(){this.$ul.find(".selected input").prop("checked",!0)},click:function(e){var t=e.$el,i=t.parent("label"),a=i.hasClass("selected"),n=t.val();if(this.$ul.find(".selected").removeClass("selected"),i.addClass("selected"),this.o.allow_null&&a&&(e.$el.prop("checked",!1),i.removeClass("selected"),n=!1,e.$el.trigger("change")),this.o.other_choice){var s=this.$ul.find('input[type="text"]');"other"===n?s.prop("disabled",!1).attr("name",t.attr("name")):s.prop("disabled",!0).attr("name","")}}})}(jQuery),function($){acf.fields.relationship=acf.field.extend({type:"relationship",$el:null,$input:null,$filters:null,$choices:null,$values:null,actions:{ready:"initialize",append:"initialize"},events:{"keypress [data-filter]":"submit_filter","change [data-filter]":"change_filter","keyup [data-filter]":"change_filter","click .choices .acf-rel-item":"add_item",'click [data-name="remove_item"]':"remove_item"},focus:function(){this.$el=this.$field.find(".acf-relationship"),this.$input=this.$el.find(".acf-hidden input"),this.$choices=this.$el.find(".choices"),this.$values=this.$el.find(".values"),this.o=acf.get_data(this.$el)},initialize:function(){var e=this,t=this.$field,i=this.$el,a=this.$input;this.$values.children(".list").sortable({items:"li",forceHelperSize:!0,forcePlaceholderSize:!0,scroll:!0,update:function(){a.trigger("change")}}),this.$choices.children(".list").scrollTop(0).on("scroll",function(a){if(!i.hasClass("is-loading")&&!i.hasClass("is-empty")&&Math.ceil($(this).scrollTop())+$(this).innerHeight()>=$(this).get(0).scrollHeight){var n=i.data("paged")||1;i.data("paged",n+1),e.set("$field",t).fetch()}}),this.fetch()},maybe_fetch:function(){var e=this,t=this.$field;this.o.timeout&&clearTimeout(this.o.timeout);var i=setTimeout(function(){e.doFocus(t),e.fetch()},300);this.$el.data("timeout",i)},fetch:function(){var e=this,t=this.$field;this.$el.addClass("is-loading"),this.o.xhr&&(this.o.xhr.abort(),this.o.xhr=!1),this.o.action="acf/fields/relationship/query",this.o.field_key=t.data("key"),this.o.post_id=acf.get("post_id");var i=acf.prepare_for_ajax(this.o);1==i.paged&&this.$choices.children(".list").html(""),this.$choices.find("ul:last").append(' '+acf._e("relationship","loading")+"
");var a=$.ajax({url:acf.get("ajaxurl"),dataType:"json",type:"post",data:i,success:function(i){e.set("$field",t).render(i)}});this.$el.data("xhr",a)},render:function(e){if(this.$el.removeClass("is-loading is-empty"),this.$choices.find("p").remove(),!e||!e.results||!e.results.length)return this.$el.addClass("is-empty"),void(1==this.o.paged&&this.$choices.children(".list").append(""+acf._e("relationship","empty")+"
"));var t=$(this.walker(e.results));if(this.$values.find(".acf-rel-item").each(function(){t.find('.acf-rel-item[data-id="'+$(this).data("id")+'"]').addClass("disabled")}),this.o.s){var i=this.o.s;t.find(".acf-rel-item").each(function(){var e=$(this).text(),t=e.replace(new RegExp("("+i+")","gi"),"$1");$(this).html($(this).html().replace(e,t))})}this.$choices.children(".list").append(t);var a="",n=null;this.$choices.find(".acf-rel-label").each(function(){return $(this).text()==a?(n.append($(this).siblings("ul").html()),void $(this).parent().remove()):(a=$(this).text(),void(n=$(this).siblings("ul")))})},walker:function(e){var t="";if($.isArray(e))for(var i in e)t+=this.walker(e[i]);else $.isPlainObject(e)&&(void 0!==e.children?(t+=''+e.text+'',t+=this.walker(e.children),t+="
"):t+=''+e.text+"");return t},submit_filter:function(e){13==e.which&&e.preventDefault()},change_filter:function(e){var t=e.$el.val(),i=e.$el.data("filter");this.$el.data(i)!=t&&(this.$el.data(i,t),this.$el.data("paged",1),e.$el.is("select")?this.fetch():this.maybe_fetch())},add_item:function(e){if(this.o.max>0&&this.$values.find(".acf-rel-item").length>=this.o.max)return void alert(acf._e("relationship","max").replace("{max}",this.o.max));if(e.$el.hasClass("disabled"))return!1;e.$el.addClass("disabled");var t=["",'',''+e.$el.html(),'',"",""].join("");this.$values.children(".list").append(t),this.$input.trigger("change"),acf.validation.remove_error(this.$field)},remove_item:function(e){var t=e.$el.parent(),i=t.data("id");t.parent("li").remove(),this.$choices.find('.acf-rel-item[data-id="'+i+'"]').removeClass("disabled"),this.$input.trigger("change")}})}(jQuery),function($){acf.select2=acf.model.extend({version:0,actions:{"ready 1":"ready"},ready:function(){acf.maybe_get(window,"Select2")?(this.version=3,this.l10n_v3()):acf.maybe_get(window,"jQuery.fn.select2.amd")&&(this.version=4)},l10n_v3:function(){var e=acf.get("locale"),t=acf.get("rtl");if(l10n=acf._e("select"),l10n){var i={formatMatches:function(e){return 1===e?l10n.matches_1:l10n.matches_n.replace("%d",e)},formatNoMatches:function(){return l10n.matches_0},formatAjaxError:function(){return l10n.load_fail},formatInputTooShort:function(e,t){var i=t-e.length;return 1===i?l10n.input_too_short_1:l10n.input_too_short_n.replace("%d",i)},formatInputTooLong:function(e,t){var i=e.length-t;return 1===i?l10n.input_too_long_1:l10n.input_too_long_n.replace("%d",i)},formatSelectionTooBig:function(e){return 1===e?l10n.selection_too_long_1:l10n.selection_too_long_n.replace("%d",e)},formatLoadMore:function(){return l10n.load_more},formatSearching:function(){return l10n.searching}};$.fn.select2.locales=acf.maybe_get(window,"jQuery.fn.select2.locales",{}),$.fn.select2.locales[e]=i,$.extend($.fn.select2.defaults,i)}},init:function(e,t){if(this.version)return t=$.extend({allow_null:!1,placeholder:"",multiple:!1,ajax:!1,ajax_action:""},t),3==this.version?this.init_v3(e,t):4==this.version&&this.init_v4(e,t)},get_data:function(e,t){var i=this;return t=t||[],e.children().each(function(){var e=$(this);e.is("optgroup")?t.push({text:e.attr("label"),children:i.get_data(e)}):t.push({id:e.attr("value"),text:e.text()})}),t},decode_data:function(e){return e?($.each(e,function(t,i){e[t].text=acf.decode(i.text),"undefined"!=typeof i.children&&(e[t].children=acf.select2.decode_data(i.children))}),e):[]},count_data:function(e){var t=0;return e?($.each(e,function(e,i){t++,"undefined"!=typeof i.children&&(t+=i.children.length)}),t):t},get_ajax_data:function(e,t){var i=acf.prepare_for_ajax({action:e.ajax_action,field_key:e.key,s:t.term,paged:t.page});return i=acf.apply_filters("select2_ajax_data",i,e,t)},get_ajax_results:function(e,t){var i={results:[]};return e||(e=i),"undefined"==typeof e.results&&(i.results=e,e=i),e.results=this.decode_data(e.results),e=acf.apply_filters("select2_ajax_results",e,t)},get_value:function(e){var t=[],i=e.find("option:selected");return i.exists()?(i=i.sort(function(e,t){return+e.getAttribute("data-i")-+t.getAttribute("data-i")}),i.each(function(){var e=$(this);t.push({id:e.attr("value"),text:e.text()})}),t):t},init_v3:function(e,t){var i=e.siblings("input");if(i.exists()){var a={width:"100%",containerCssClass:"-acf",allowClear:t.allow_null,placeholder:t.placeholder,multiple:t.multiple,separator:"||",data:[],escapeMarkup:function(e){return e},formatResult:function(e,t,i,a){var n=$.fn.select2.defaults.formatResult(e,t,i,a);return e.description&&(n+=' '+e.description+""),n}},n=this.get_value(e);if(t.multiple){var s=e.attr("name");a.formatSelection=function(e,t){var a='";return t.parent().append(a),e.text}}else n=acf.maybe_get(n,0,!1),!t.allow_null&&n&&i.val(n.id);t.allow_null&&e.find('option[value=""]').remove(),a.data=this.get_data(e),a.initSelection=function(e,t){t(n)},t.ajax&&(a.ajax={url:acf.get("ajaxurl"),dataType:"json",type:"post",cache:!1,quietMillis:250,data:function(e,i){var a={term:e,page:i};return acf.select2.get_ajax_data(t,a)},results:function(e,t){var i={page:t};return setTimeout(function(){acf.select2.merge_results_v3()},1),acf.select2.get_ajax_results(e,i)}}),a.dropdownCss={"z-index":"999999999"},a.acf=t,a=acf.apply_filters("select2_args",a,e,t),i.select2(a);var r=i.select2("container");r.before(e),r.before(i),t.multiple&&r.find("ul.select2-choices").sortable({start:function(){i.select2("onSortStart")},stop:function(){i.select2("onSortEnd")}}),e.prop("disabled",!0).addClass("acf-disabled acf-hidden"),i.on("change",function(t){t.added&&e.append('"),e.val(t.val)})}},merge_results_v3:function(){var e="",t=null;$("#select2-drop .select2-result-with-children").each(function(){var i=$(this).children(".select2-result-label"),a=$(this).children(".select2-result-sub");return i.text()==e?(t.append(a.children()),void $(this).remove()):(e=i.text(),void(t=a))})},init_v4:function(e,t){var i=e.siblings("input");if(i.exists()){var a={width:"100%",allowClear:t.allow_null,placeholder:t.placeholder,multiple:t.multiple,separator:"||",data:[],escapeMarkup:function(e){return e}},n=this.get_value(e);t.multiple||(n=acf.maybe_get(n,0,"")),t.allow_null&&e.find('option[value=""]').remove(),a.data=this.get_data(e),t.ajax?a.ajax={url:acf.get("ajaxurl"),delay:250,dataType:"json",type:"post",cache:!1,data:function(e){return acf.select2.get_ajax_data(t,e)},processResults:function(e,t){var i=acf.select2.get_ajax_results(e,t);return i.more&&(i.pagination={more:!0}),setTimeout(function(){acf.select2.merge_results_v4()},1),i}}:(e.removeData("ajax"),e.removeAttr("data-ajax")),a=acf.apply_filters("select2_args",a,e,t);var s=e.select2(a);s.addClass("-acf")}},merge_results_v4:function(){var e=null,t=null;$('.select2-results__option[role="group"]').each(function(){var i=$(this).children("ul"),a=$(this).children("strong");return null!==t&&a.text()==t.text()?(e.append(i.children()),void $(this).remove()):(e=i,void(t=a))})},destroy:function(e){e.siblings(".select2-container").remove(),e.siblings("input").show(),e.prop("disabled",!1).removeClass("acf-disabled acf-hidden")}}),acf.add_select2=function(e,t){acf.select2.init(e,t)},acf.remove_select2=function(e){acf.select2.destroy(e)},acf.fields.select=acf.field.extend({type:"select",$select:null,actions:{ready:"render",append:"render",remove:"remove"},focus:function(){this.$select=this.$field.find("select"),this.$select.exists()&&(this.o=acf.get_data(this.$select),this.o=acf.parse_args(this.o,{ajax_action:"acf/fields/"+this.type+"/query",key:this.$field.data("key")}))},render:function(){return!(!this.$select.exists()||!this.o.ui)&&void acf.select2.init(this.$select,this.o)},remove:function(){return!(!this.$select.exists()||!this.o.ui)&&void acf.select2.destroy(this.$select)}}),acf.fields.user=acf.fields.select.extend({type:"user"}),acf.fields.post_object=acf.fields.select.extend({type:"post_object"}),acf.fields.page_link=acf.fields.select.extend({type:"page_link"})}(jQuery),function($){acf.fields.tab=acf.field.extend({type:"tab",$el:null,$wrap:null,actions:{prepare:"initialize",append:"initialize",hide:"hide",show:"show"},focus:function(){this.$el=this.$field.find(".acf-tab"),this.o=this.$el.data(),this.o.key=this.$field.data("key"),this.o.text=this.$el.text()},initialize:function(){this.$field.is("td")||e.add_tab(this.$field,this.o)},hide:function(e,t){if("conditional_logic"==t){var i=e.data("key"),a=e.prevAll(".acf-tab-wrap"),n=a.find('a[data-key="'+i+'"]'),s=n.parent();a.exists()&&(s.addClass("hidden-by-conditional-logic"),setTimeout(function(){e.nextUntil(".acf-field-tab",".acf-field").each(function(){$(this).hasClass("hidden-by-conditional-logic")||(acf.conditional_logic.hide_field($(this)),$(this).addClass("-hbcl-"+i))}),s.hasClass("active")&&a.find("li:not(.hidden-by-conditional-logic):first a").trigger("click")},0))}},show:function(e,t){if("conditional_logic"==t){var i=e.data("key"),a=e.prevAll(".acf-tab-wrap"),n=a.find('a[data-key="'+i+'"]'),s=n.parent();a.exists()&&(s.removeClass("hidden-by-conditional-logic"),setTimeout(function(){e.siblings(".acf-field.-hbcl-"+i).each(function(){acf.conditional_logic.show_field($(this)),$(this).removeClass("-hbcl-"+i)});var t=s.siblings(".active");t.exists()&&!t.hasClass("hidden-by-conditional-logic")||n.trigger("click")},0))}}});var e=acf.model.extend({actions:{"prepare 15":"render","append 15":"render","refresh 15":"render"},events:{"click .acf-tab-button":"_click"},render:function(e){$(".acf-tab-wrap",e).each(function(){var e=$(this),t=e.parent();if(e.find("li.active").exists()||e.find("li:not(.hidden-by-conditional-logic):first a").trigger("click"),t.hasClass("-sidebar")){var i=t.is("td")?"height":"min-height",a=e.position().top+e.children("ul").outerHeight(!0)-1;t.css(i,a)}})},add_group:function(e,t){var i=e.parent(),a="";return i.hasClass("acf-fields")&&"left"==t.placement?i.addClass("-sidebar"):t.placement="top",a=i.is("tbody")?' |
':'',$group=$(a),e.before($group),$group},add_tab:function(e,t){var i=e.siblings(".acf-tab-wrap").last();i.exists()?t.endpoint&&(i=this.add_group(e,t)):i=this.add_group(e,t);var a=$(''+t.text+"");""===t.text&&a.hide(),i.find("ul").append(a),e.hasClass("hidden-by-conditional-logic")&&a.addClass("hidden-by-conditional-logic")},_click:function(e){e.preventDefault();var t=this,i=e.$el,a=i.closest(".acf-tab-wrap"),n=i.data("key"),s="";i.parent().addClass("active").siblings().removeClass("active"),a.nextUntil(".acf-tab-wrap",".acf-field").each(function(){var e=$(this);return("tab"!=e.data("type")||(s=e.data("key"),!e.hasClass("endpoint")))&&void(s===n?e.hasClass("hidden-by-tab")&&(e.removeClass("hidden-by-tab"),acf.do_action("show_field",$(this),"tab")):e.hasClass("hidden-by-tab")||(e.addClass("hidden-by-tab"),acf.do_action("hide_field",$(this),"tab")))}),acf.do_action("refresh",a.parent()),i.trigger("blur")}}),t=acf.model.extend({active:1,actions:{add_field_error:"add_field_error"},add_field_error:function(e){if(this.active&&e.hasClass("hidden-by-tab")){var t=this,i=e.prevAll(".acf-field-tab:first"),a=e.prevAll(".acf-tab-wrap:first");a.find('a[data-key="'+i.data("key")+'"]').trigger("click"),this.active=0,setTimeout(function(){t.active=1},1e3)}}})}(jQuery),function($){acf.fields.time_picker=acf.field.extend({type:"time_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-time-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(){if("undefined"!=typeof $.timepicker){var e={timeFormat:this.o.time_format,altField:this.$hidden,altFieldTimeOnly:!1,altTimeFormat:"HH:mm:ss",showButtonPanel:!0,controlType:"select",oneLine:!0,closeText:acf._e("date_time_picker","selectText")};e.onClose=function(e,t){var i=t.dpDiv,a=i.find(".ui-datepicker-close");if(!e&&a.is(":hover")){if(e=acf.maybe_get(t,"settings.timepicker.formattedTime"),!e)return;$.datepicker._setTime(t)}},e=acf.apply_filters("time_picker_args",e,this.$field),this.$input.addClass("active").timepicker(e),$("body > #ui-datepicker-div").exists()&&$("body > #ui-datepicker-div").wrap('')}},blur:function(){this.$input.val()||this.$hidden.val("")}})}(jQuery),function($){acf.fields.true_false=acf.field.extend({type:"true_false",$switch:null,$input:null,actions:{prepare:"render",append:"render",show:"render"},events:{"change .acf-switch-input":"change"},focus:function(){this.$input=this.$field.find(".acf-switch-input"),this.$switch=this.$field.find(".acf-switch")},render:function(){if(this.$switch.exists()){var e=this.$switch.children(".acf-switch-on"),t=this.$switch.children(".acf-switch-off");width=Math.max(e.width(),t.width()),width&&(e.css("min-width",width),t.css("min-width",width))}},change:function(e){var t=e.$el.prop("checked");t?this.$switch.addClass("-on"):this.$switch.removeClass("-on")}})}(jQuery),function($){acf.fields.taxonomy=acf.field.extend({type:"taxonomy",$el:null,actions:{ready:"render",append:"render",remove:"remove"},events:{'click a[data-name="add"]':"add_term"},focus:function(){this.$el=this.$field.find(".acf-taxonomy-field"),this.o=acf.get_data(this.$el),this.o.key=this.$field.data("key")},render:function(){var e=this.$field.find("select");if(e.exists()){var t=acf.get_data(e);t=acf.parse_args(t,{pagination:!0,ajax_action:"acf/fields/taxonomy/query",key:this.o.key}),acf.select2.init(e,t)}},remove:function(){var e=this.$field.find("select");return!!e.exists()&&void acf.select2.destroy(e)},add_term:function(e){var t=this;acf.open_popup({title:e.$el.attr("title")||e.$el.data("title"),loading:!0,height:220});var i=acf.prepare_for_ajax({action:"acf/fields/taxonomy/add_term",field_key:this.o.key});$.ajax({url:acf.get("ajaxurl"),data:i,type:"post",dataType:"html",success:function(e){t.add_term_confirm(e)}})},add_term_confirm:function(e){
-var t=this;acf.update_popup({content:e}),$('#acf-popup input[name="term_name"]').focus(),$("#acf-popup form").on("submit",function(e){e.preventDefault(),t.add_term_submit($(this))})},add_term_submit:function(e){var t=this,i=e.find(".acf-submit"),a=e.find('input[name="term_name"]'),n=e.find('select[name="term_parent"]');if(""===a.val())return a.focus(),!1;i.find("button").attr("disabled","disabled"),i.find(".acf-spinner").addClass("is-active");var s=acf.prepare_for_ajax({action:"acf/fields/taxonomy/add_term",field_key:this.o.key,term_name:a.val(),term_parent:n.exists()?n.val():0});$.ajax({url:acf.get("ajaxurl"),data:s,type:"post",dataType:"json",success:function(e){var n=acf.get_ajax_message(e);acf.is_ajax_success(e)&&(a.val(""),t.append_new_term(e.data)),n.text&&i.find("span").html(n.text)},complete:function(){i.find("button").removeAttr("disabled"),i.find(".acf-spinner").removeClass("is-active"),i.find("span").delay(1500).fadeOut(250,function(){$(this).html(""),$(this).show()}),a.focus()}})},append_new_term:function(e){var t={id:e.term_id,text:e.term_label};switch($('.acf-taxonomy-field[data-taxonomy="'+this.o.taxonomy+'"]').each(function(){var t=$(this).data("type");if("radio"==t||"checkbox"==t){var i=$(this).children('input[type="hidden"]'),a=$(this).find("ul:first"),n=i.attr("name");"checkbox"==t&&(n+="[]");var s=$(['',"",""].join(""));if(e.term_parent){var r=a.find('li[data-id="'+e.term_parent+'"]');a=r.children("ul"),a.exists()||(a=$(''),r.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+'"]'),r=n.get(0).scrollTop+(s.offset().top-n.offset().top);s.find("input").prop("checked",!0),n.animate({scrollTop:r},"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(e.indexOf("://")!==-1);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){if(!this.errors.length)return e;e.valid=0,e.errors=e.errors||[];var a=[];if(e.errors.length)for(i in e.errors)a.push(e.errors[i].input);if(this.errors.length)for(i in this.errors){var n=this.errors[i];$.inArray(n.input,a)===-1&&e.errors.push(n)}return 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;acf.do_action("validation_begin");var i=acf.serialize_form(e);i.action="acf/validate_save_post",i=acf.prepare_for_ajax(i),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")),setTimeout(function(){acf.remove_el(t)},2e3)),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 this.valid=!0,void acf.do_action("validation_success");acf.do_action("validation_failure"),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 r=t.errors[s];if(r.input){var o=e.find('[name="'+r.input+'"]').first();if(o.exists()||(o=e.find('[name^="'+r.input+'"]').first()),o.exists()){a++;var l=acf.get_field_wrap(o);this.add_error(l,r.message),null===i&&(i=l)}}else n+=". "+r.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){var t=e.children(".acf-input").children("."+this.message_class);e.removeClass(this.error_class),setTimeout(function(){acf.remove_el(t)},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:{},events:{"mousedown .acf-editor-wrap.delay":"mousedown"},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")},mousedown:function(e){e.preventDefault(),this.$el.removeClass("delay"),this.$el.find(".acf-editor-toolbar").remove(),this.initialize()},initialize:function(){if(!this.$el.hasClass("delay")&&"undefined"!=typeof tinyMCEPreInit){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,this.initialize_tinymce(),this.initialize_quicktags()}},initialize_tinymce:function(){if("undefined"!=typeof tinymce){var e=this.get_mceInit();if(tinyMCEPreInit.mceInit[e.id]=e,this.$el.hasClass("tmce-active"))try{tinymce.init(e)}catch(e){}}},initialize_quicktags:function(){if("undefined"!=typeof quicktags){var e=this.get_qtInit();tinyMCEPreInit.qtInit[e.id]=e;try{var t=quicktags(e);this._buttonsInit(t)}catch(e){}}},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;n<5;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("change",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(e){}},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]},_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&&t.indexOf(","+id+",")!==-1&&use.indexOf(","+id+",")===-1||edButtons[i].instance&&edButtons[i].instance!==inst||(theButtons[id]=edButtons[i],edButtons[i].html&&(html+=edButtons[i].html(name+"_"))));use&&use.indexOf(",fullscreen,")!==-1&&(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}});var e=acf.model.extend({$div:null,actions:{ready:"ready"},ready:function(){this.$div=$("#acf-hidden-wp-editor"),this.$div.exists()&&(this.$div.appendTo("body"),"undefined"!=typeof tinymce&&tinymce.on("AddEditor",function(e){var t=e.editor;"acf"===t.id.substr(0,3)&&(t=tinymce.editors.content||t,tinymce.activeEditor=t,wpActiveEditor=t.id)}))}})}(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&&o("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 r(e,t){return"string"==typeof e&&o("filters",e,t),f}function o(e,t,i,a){if(u[e][t])if(i){var n=u[e][t],s;if(a)for(s=n.length;s--;){var r=n[s];r.callback===i&&r.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},r=u[e][t];r?(r.push(s),r=c(r)):r=[s],u[e][t]=r}function c(e){for(var t,i,a,n=1,s=e.length;nt.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];var n=0,s=a.length;if("filters"===e)for(;n0},$.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;ie.length?Array(1+(t-e.length)).join("0")+e:e};return this.php_js||(this.php_js={}),this.php_js.uniqidSeed||(this.php_js.uniqidSeed=Math.floor(123456789*Math.random())),this.php_js.uniqidSeed++,i=e,i+=a(parseInt((new Date).getTime()/1e3,10),8),i+=a(this.php_js.uniqidSeed,5),t&&(i+=(10*Math.random()).toFixed(8).toString()),i},serialize_form:function(e){var t={},i={};return $selector=e.find("select, textarea, input"),$.each($selector.serializeArray(),function(e,a){"[]"===a.name.slice(-2)&&(a.name=a.name.replace("[]",""),"undefined"==typeof i[a.name]&&(i[a.name]=-1),i[a.name]++,a.name+="["+i[a.name]+"]"),t[a.name]=a.value}),t},serialize:function(e){return this.serialize_form(e)},disable:function(e,t){if(t=t||"",e.hasClass("acf-disabled"))return!1;if(e.prop("disabled",!0),t){var i=e.data("acf_disabled")||[],a=i.indexOf(t);a<0&&(i.push(t),e.data("acf_disabled",i))}return!0},enable:function(e,t){if(t=t||"",e.hasClass("acf-disabled"))return!1;var i=e.data("acf_disabled")||[];if(t){var a=i.indexOf(t);a>-1&&(i.splice(a,1),e.data("acf_disabled",i))}return!i.length&&(e.prop("disabled",!1),!0)},disable_el:function(e,t){t=t||"",e.find("select, textarea, input").each(function(){acf.disable($(this),t)})},disable_form:function(e,t){this.disable_el.apply(this,arguments)},enable_el:function(e,t){t=t||"",e.find("select, textarea, input").each(function(){acf.enable($(this),t)})},enable_form:function(e,t){this.enable_el.apply(this,arguments)},remove_tr:function(e,t){var i=e.height(),a=e.children().length;e.addClass("acf-remove-element"),setTimeout(function(){e.removeClass("acf-remove-element"),e.html(' | '),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-popup"),$popup.exists())return update_popup(e);var t=['"].join("");return $("body").append(t),$("#acf-popup").on("click",".bg, .acf-close-popup",function(e){e.preventDefault(),acf.close_popup()}),this.update_popup(e)},update_popup:function(e){return $popup=$("#acf-popup"),!!$popup.exists()&&(e=$.extend({},{title:"",content:"",width:0,height:0,loading:!1},e),e.title&&$popup.find(".title h3").html(e.title),e.content&&($inner=$popup.find(".inner:first"),$inner.html(e.content),acf.do_action("append",$inner),$inner.attr("style","position: relative;"),e.height=$inner.outerHeight(),$inner.removeAttr("style")),e.width&&$popup.find(".acf-popup-box").css({width:e.width,"margin-left":0-e.width/2}),e.height&&(e.height+=44,$popup.find(".acf-popup-box").css({height:e.height,"margin-top":0-e.height/2})),e.loading?$popup.find(".loading").show():$popup.find(".loading").hide(),$popup)},close_popup:function(){$popup=$("#acf-popup"),$popup.exists()&&$popup.remove()},update_user_setting:function(e,t){$.ajax({url:acf.get("ajaxurl"),dataType:"html",type:"post",data:acf.prepare_for_ajax({action:"acf/update_user_setting",name:e,value:t})})},prepare_for_ajax:function(e){return e.nonce=acf.get("nonce"),e.post_id=acf.get("post_id"),e=acf.apply_filters("prepare_for_ajax",e)},is_ajax_success:function(e){return!(!e||!e.success)},get_ajax_message:function(e){var t={text:"",type:"error"};return e?(e.success&&(t.type="success"),e.data&&e.data.message&&(t.text=e.data.message),e.data&&e.data.error&&(t.text=e.data.error),t):t},is_in_view:function(e){var t=e.offset().top,i=t+e.height();if(t===i)return!1;var a=$(window).scrollTop(),n=a+$(window).height();return i<=n&&t>=a},val:function(e,t){var i=e.val();e.val(t),t!=i&&e.trigger("change")},str_replace:function(e,t,i){return i.split(e).join(t)},str_sanitize:function(e){var t="",a={"æ":"a","å":"a","á":"a","ä":"a","č":"c","ď":"d","è":"e","é":"e","ě":"e","ë":"e","í":"i","ĺ":"l","ľ":"l","ň":"n","ø":"o","ó":"o","ô":"o","ő":"o","ö":"o","ŕ":"r","š":"s","ť":"t","ú":"u","ů":"u","ű":"u","ü":"u","ý":"y","ř":"r","ž":"z"," ":"_","'":"","?":"","/":"","\\":"",".":"",",":"",">":"","<":"",'"':"","[":"","]":"","|":"","{":"","}":"","(":"",")":""};for(e=e.toLowerCase(),i=0;i'),e.append(n))),n.append('"),i==a.value&&e.prop("selectedIndex",t)})},duplicate:function(e){"undefined"!=typeof e.length&&(e={$el:e}),e=acf.parse_args(e,{$el:!1,search:"",replace:"",before:function(e){},after:function(e,t){},append:function(e,t){e.after(t)}});var t=e.$el,i;e.search||(e.search=t.attr("data-id")),e.replace||(e.replace=acf.get_uniqid()),e.before.apply(this,[t]),acf.do_action("before_duplicate",t);var i=t.clone();return i.removeClass("acf-clone"),acf.do_action("remove",i),e.search&&(i.attr("data-id",e.replace),i.find('[id*="'+e.search+'"]').each(function(){$(this).attr("id",$(this).attr("id").replace(e.search,e.replace))}),i.find('[name*="'+e.search+'"]').each(function(){$(this).attr("name",$(this).attr("name").replace(e.search,e.replace))}),i.find('label[for*="'+e.search+'"]').each(function(){$(this).attr("for",$(this).attr("for").replace(e.search,e.replace))})),i.find(".ui-sortable").removeClass("ui-sortable"),acf.do_action("after_duplicate",t,i),e.after.apply(this,[t,i]),e.append.apply(this,[t,i]),setTimeout(function(){acf.do_action("append",i)},1),i},decode:function(e){return $("").html(e).text()},parse_args:function(e,t){return $.extend({},t,e)},enqueue_script:function(e,t){var i=document.createElement("script");i.type="text/javascript",i.src=e,i.async=!0,i.readyState?i.onreadystatechange=function(){"loaded"!=i.readyState&&"complete"!=i.readyState||(i.onreadystatechange=null,t())}:i.onload=function(){t()},document.body.appendChild(i)}},acf.model={actions:{},filters:{},events:{},extend:function(e){var t=$.extend({},this,e);return $.each(t.actions,function(e,i){t._add_action(e,i)}),$.each(t.filters,function(e,i){t._add_filter(e,i)}),$.each(t.events,function(e,i){t._add_event(e,i)}),t},_add_action:function(e,t){var i=this,a=e.split(" "),e=a[0]||"",n=a[1]||10;acf.add_action(e,i[t],n,i)},_add_filter:function(e,t){var i=this,a=e.split(" "),e=a[0]||"",n=a[1]||10;acf.add_filter(e,i[t],n,i)},_add_event:function(e,t){var i=this,a=e.substr(0,e.indexOf(" ")),n=e.substr(e.indexOf(" ")+1);$(document).on(a,n,function(e){e.$el=$(this),"function"==typeof i.event&&(e=i.event(e)),i[t].apply(i,[e])})},get:function(e,t){return t=t||null,"undefined"!=typeof this[e]&&(t=this[e]),t},set:function(e,t){return this[e]=t,"function"==typeof this["_set_"+e]&&this["_set_"+e].apply(this),this}},acf.field=acf.model.extend({type:"",o:{},$field:null,_add_action:function(e,t){var i=this;e=e+"_field/type="+i.type,acf.add_action(e,function(e){i.set("$field",e),i[t].apply(i,arguments)})},_add_filter:function(e,t){var i=this;e=e+"_field/type="+i.type,acf.add_filter(e,function(e){i.set("$field",e),i[t].apply(i,arguments)})},_add_event:function(e,t){var i=this,a=e.substr(0,e.indexOf(" ")),n=e.substr(e.indexOf(" ")+1),s=acf.get_selector(i.type);$(document).on(a,s+" "+n,function(e){e.$el=$(this),e.$field=acf.get_closest_field(e.$el,i.type),i.set("$field",e.$field),i[t].apply(i,[e])})},_set_$field:function(){"function"==typeof this.focus&&this.focus()},doFocus:function(e){return this.set("$field",e)}}),acf.fields=acf.model.extend({actions:{prepare:"_prepare",prepare_field:"_prepare_field",ready:"_ready",ready_field:"_ready_field",append:"_append",append_field:"_append_field",load:"_load",load_field:"_load_field",remove:"_remove",remove_field:"_remove_field",sortstart:"_sortstart",sortstart_field:"_sortstart_field",sortstop:"_sortstop",sortstop_field:"_sortstop_field",show:"_show",show_field:"_show_field",hide:"_hide",hide_field:"_hide_field"},_prepare:function(e){acf.get_fields("",e).each(function(){acf.do_action("prepare_field",$(this))})},_prepare_field:function(e){acf.do_action("prepare_field/type="+e.data("type"),e)},_ready:function(e){acf.get_fields("",e).each(function(){acf.do_action("ready_field",$(this))})},_ready_field:function(e){acf.do_action("ready_field/type="+e.data("type"),e)},_append:function(e){acf.get_fields("",e).each(function(){acf.do_action("append_field",$(this))})},_append_field:function(e){acf.do_action("append_field/type="+e.data("type"),e)},_load:function(e){acf.get_fields("",e).each(function(){acf.do_action("load_field",$(this))})},_load_field:function(e){acf.do_action("load_field/type="+e.data("type"),e)},_remove:function(e){acf.get_fields("",e).each(function(){acf.do_action("remove_field",$(this))})},_remove_field:function(e){acf.do_action("remove_field/type="+e.data("type"),e)},_sortstart:function(e,t){acf.get_fields("",e).each(function(){acf.do_action("sortstart_field",$(this),t)})},_sortstart_field:function(e,t){acf.do_action("sortstart_field/type="+e.data("type"),e,t)},_sortstop:function(e,t){acf.get_fields("",e).each(function(){acf.do_action("sortstop_field",$(this),t)})},_sortstop_field:function(e,t){acf.do_action("sortstop_field/type="+e.data("type"),e,t)},_hide:function(e,t){acf.get_fields("",e).each(function(){acf.do_action("hide_field",$(this),t)})},_hide_field:function(e,t){acf.do_action("hide_field/type="+e.data("type"),e,t)},_show:function(e,t){acf.get_fields("",e).each(function(){acf.do_action("show_field",$(this),t)})},_show_field:function(e,t){acf.do_action("show_field/type="+e.data("type"),e,t)}}),$(document).ready(function(){acf.do_action("ready",$("body"))}),$(window).on("load",function(){acf.do_action("load",$("body"))}),acf.layout=acf.model.extend({active:0,actions:{"prepare 99":"prepare",refresh:"refresh"},prepare:function(){this.active=1,this.refresh()},refresh:function(e){if(this.active){e=e||$("body");var t=this;this.render_tables(e),this.render_groups(e)}},render_tables:function(e){var t=this,i=e.find(".acf-table:visible");e.is("tr")&&(i=e.parent().parent()),i.each(function(){t.render_table($(this))})},render_table:function(e){var t=e.find("> thead th.acf-th"),i=1,a=100;if(t.exists()){var n=e.find("> tbody > tr"),s=n.find("> td.acf-field");n.hasClass("acf-clone")&&n.length>1&&(s=n.not(".acf-clone").find("> td.acf-field")),t.each(function(){var e=$(this),t=e.attr("data-key"),i=s.filter('[data-key="'+t+'"]');i.removeClass("appear-empty"),e.removeClass("hidden-by-conditional-logic"),i.exists()&&(0==i.not(".hidden-by-conditional-logic").length?e.addClass("hidden-by-conditional-logic"):i.filter(".hidden-by-conditional-logic").addClass("appear-empty"))}),t.css("width","auto"),t=t.not(".hidden-by-conditional-logic"),i=t.length,t.filter("[data-width]").each(function(){var e=parseInt($(this).attr("data-width"));a-=e,$(this).css("width",e+"%")}),t=t.not("[data-width]"),t.each(function(){var e=a/t.length;$(this).css("width",e+"%")}),e.find(".acf-row .acf-field.-collapsed-target").removeAttr("colspan"),e.find(".acf-row.-collapsed .acf-field.-collapsed-target").attr("colspan",i)}},render_groups:function(e){var t=this,i=e.find(".acf-fields:visible");e&&e.is(".acf-fields")&&(i=i.add(e)),i.each(function(){t.render_group($(this))})},render_group:function(e){var t=$(),i=0,a=0,n=-1,s=e.children(".acf-field[data-width]:visible");s.exists()&&(s.removeClass("acf-r0 acf-c0").css({"min-height":0}),s.each(function(e){var s=$(this),r=s.position().top;0==e&&(i=r),r!=i&&(t.css({"min-height":a+1+"px"}),t=$(),i=s.position().top,a=0,n=-1),n++,a=s.outerHeight()>a?s.outerHeight():a,t=t.add(s),0==r?s.addClass("acf-r0"):0==n&&s.addClass("acf-c0")}),t.exists()&&t.css({"min-height":a+1+"px"}))}}),$(document).on("change",".acf-field input, .acf-field textarea, .acf-field select",function(){$('#acf-form-data input[name="_acfchanged"]').exists()&&$('#acf-form-data input[name="_acfchanged"]').val(1),acf.do_action("change",$(this))}),$(document).on("click",'.acf-field a[href="#"]',function(e){e.preventDefault()}),acf.unload=acf.model.extend({active:1,changed:0,filters:{validation_complete:"validation_complete"},actions:{change:"on",submit:"off"},events:{"submit form":"off"},validation_complete:function(e,t){return e&&e.errors&&this.on(),e},on:function(){!this.changed&&this.active&&(this.changed=1,$(window).on("beforeunload",this.unload))},off:function(){this.changed=0,$(window).off("beforeunload",this.unload)},unload:function(){return acf._e("unload")}}),acf.tooltip=acf.model.extend({$el:null,events:{"mouseenter .acf-js-tooltip":"on","mouseleave .acf-js-tooltip":"off"},on:function(e){var t=e.$el.attr("title");if(t){this.$el=$(''+t+"
"),$("body").append(this.$el);var i=10;target_w=e.$el.outerWidth(),target_h=e.$el.outerHeight(),target_t=e.$el.offset().top,target_l=e.$el.offset().left,tooltip_w=this.$el.outerWidth(),tooltip_h=this.$el.outerHeight();var a=target_t-tooltip_h,n=target_l+target_w/2-tooltip_w/2;n$(window).width()?(this.$el.addClass("left"),n=target_l-tooltip_w,a=target_t+target_h/2-tooltip_h/2):a-$(window).scrollTop()')}}),acf.add_action("sortstart",function(e,t){e.is("tr")&&(e.css("position","relative"),e.children().each(function(){$(this).width($(this).width())}),e.css("position","absolute"),t.html(' | '))}),acf.add_action("before_duplicate",function(e){e.find("select option:selected").addClass("selected")}),acf.add_action("after_duplicate",function(e,t){t.find("select").each(function(){var e=$(this),t=[];e.find("option.selected").each(function(){t.push($(this).val())}),e.val(t)}),e.find("select option.selected").removeClass("selected"),t.find("select option.selected").removeClass("selected")}),Array.prototype.indexOf||(Array.prototype.indexOf=function(e){return $.inArray(e,this)})}(jQuery),function($){acf.ajax=acf.model.extend({active:!1,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 .categorychecklist select":"_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")),this.active=!0},fetch:function(){if(this.active&&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"),$("#acf-style").html(""),$.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","click .acf-add-checkbox":"_add"},focus:function(){this.$ul=this.$field.find("ul"),this.$input=this.$field.find('input[type="hidden"]')},add:function(){var e=this.$input.attr("name")+"[]",t='';this.$ul.find(".acf-add-checkbox").parent("li").before(t)},_change:function(e){var t=this.$ul,i=t.find('input[type="checkbox"]').not(".acf-checkbox-toggle"),a=e.$el.is(":checked");if(e.$el.hasClass("acf-checkbox-toggle"))return void i.prop("checked",a).trigger("change");if(e.$el.hasClass("acf-checkbox-custom")){var n=e.$el.next('input[type="text"]');e.$el.next('input[type="text"]').prop("disabled",!a),a||""!=n.val()||e.$el.parent("li").remove()}if(t.find(".acf-checkbox-toggle").exists()){var a=0==i.not(":checked").length;t.find(".acf-checkbox-toggle").prop("checked",a)}},_add:function(e){this.add()}})}(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],r=s.field,o=this.triggers[r]||{};o[e]=e,this.triggers[r]=o}}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],r=acf.get_fields(s,$parent,!0);this.render_fields(r)}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;for(var i=!1,a=this.items[t],n=0;n-1,match}})}(jQuery),function($){acf.datepicker=acf.model.extend({actions:{"ready 1":"ready"},ready:function(){var e=acf.get("locale"),t=acf.get("rtl");l10n=acf._e("date_picker"),l10n&&"undefined"!=typeof $.datepicker&&(l10n.isRTL=t,$.datepicker.regional[e]=l10n,$.datepicker.setDefaults(l10n))},init:function(e,t){"undefined"!=typeof $.datepicker&&(t=t||{},e.datepicker(t),$("body > #ui-datepicker-div").exists()&&$("body > #ui-datepicker-div").wrap(''))},destroy:function(e){}}),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(){if(this.o.save_format)return this.initialize2();var e={dateFormat:this.o.date_format,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),acf.datepicker.init(this.$input,e),acf.do_action("date_picker_init",this.$input,e,this.$field)},initialize2:function(){this.$input.val(this.$hidden.val());var e={dateFormat:this.o.date_format,altField:this.$hidden,altFormat:this.o.save_format,changeYear:!0,yearRange:"-100:+100",changeMonth:!0,showButtonPanel:!0,firstDay:this.o.first_day};e=acf.apply_filters("date_picker_args",e,this.$field);var t=e.dateFormat;e.dateFormat=this.o.save_format,acf.datepicker.init(this.$input,e),this.$input.datepicker("option","dateFormat",t),acf.do_action("date_picker_init",this.$input,e,this.$field)},blur:function(){this.$input.val()||this.$hidden.val("")}})}(jQuery),function($){acf.datetimepicker=acf.model.extend({actions:{"ready 1":"ready"},ready:function(){var e=acf.get("locale"),t=acf.get("rtl");l10n=acf._e("date_time_picker"),l10n&&"undefined"!=typeof $.timepicker&&(l10n.isRTL=t,$.timepicker.regional[e]=l10n,$.timepicker.setDefaults(l10n))},init:function(e,t){"undefined"!=typeof $.timepicker&&(t=t||{},e.datetimepicker(t),$("body > #ui-datepicker-div").exists()&&$("body > #ui-datepicker-div").wrap(''))},destroy:function(e){}}),acf.fields.date_time_picker=acf.field.extend({type:"date_time_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-time-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(){var e={dateFormat:this.o.date_format,timeFormat:this.o.time_format,altField:this.$hidden,altFieldTimeOnly:!1,altFormat:"yy-mm-dd",altTimeFormat:"HH:mm:ss",changeYear:!0,yearRange:"-100:+100",changeMonth:!0,showButtonPanel:!0,firstDay:this.o.first_day,controlType:"select",oneLine:!0};e=acf.apply_filters("date_time_picker_args",e,this.$field),acf.datetimepicker.init(this.$input,e),acf.do_action("date_time_picker_init",this.$input,e,this.$field)},blur:function(){this.$input.val()||this.$hidden.val("")}})}(jQuery),function($){acf.fields.file=acf.field.extend({type:"file",$el:null,$input: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.$input=this.$el.find('input[type="hidden"]'),this.o=acf.get_data(this.$el)},initialize:function(){"basic"==this.o.uploader&&this.$el.closest("form").attr("enctype","multipart/form-data")},prepare:function(e){if(e=e||{},e._valid)return e;var t={url:"",alt:"",title:"",filename:"",filesizeHumanReadable:"",icon:"/wp-includes/images/media/default.png"};return e.id&&(t=e.attributes),t._valid=!0,t},render:function(e){e=this.prepare(e),this.$el.find("img").attr({src:e.icon,alt:e.alt,title:e.title}),this.$el.find('[data-name="title"]').text(e.title),this.$el.find('[data-name="filename"]').text(e.filename).attr("href",e.url),this.$el.find('[data-name="filesize"]').text(e.filesizeHumanReadable);var t="";e.id&&(t=e.id),acf.val(this.$input,t),t?this.$el.addClass("has-value"):this.$el.removeClass("has-value")},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"),r=t.closest(".acf-row");if(t=!1,r.nextAll(".acf-row:visible").each(function(){if(t=acf.get_field(s,$(this)))return!!t.find(".acf-file-uploader.has-value").exists()&&void(t=!1)}),!t){if(r=acf.fields.repeater.doFocus(i).add(),!r)return!1;t=acf.get_field(s,r)}}e.set("$field",t).render(a)}})},edit:function(){var e=this,t=this.$field,i=this.$input.val();if(i)var a=acf.media.popup({title:acf._e("file","edit"),button:acf._e("file","update"),mode:"edit",attachment:i,select:function(i,a){e.set("$field",t).render(i)}})},remove:function(){var e={};this.render(e)},get_file_info:function(e,t){var i={};i.url=e.val();var a=e[0].files;if(a){var n=a[0];if(i.size=n.size,i.type=n.type,n.type.indexOf("image")>-1){var s=window.URL||window.webkitURL,r=new Image;r.onload=function(){i.width=this.width,i.height=this.height,t.val(jQuery.param(i))},r.src=s.createObjectURL(n)}}t.val(jQuery.param(i))},change:function(e){
+this.get_file_info(e.$el,this.$input)}})}(jQuery),function($){acf.fields.google_map=acf.field.extend({type:"google_map",url:"",$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.o.id=this.$el.attr("id"),this.maps[this.o.id]&&(this.map=this.maps[this.o.id])},is_ready:function(){var e=this;return"ready"==this.status||"loading"!=this.status&&(acf.isset(window,"google","maps","places")?(this.status="ready",!0):(acf.isset(window,"google","maps")&&(this.status="ready"),this.url&&(this.status="loading",acf.enqueue_script(this.url,function(){e.status="ready",e.initialize_pending()})),"ready"==this.status))},initialize_pending:function(){var e=this;this.$pending.each(function(){e.set("$field",$(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",{scrollwheel:!1,zoom:parseInt(this.o.zoom),center:new google.maps.LatLng(this.o.lat,this.o.lng),mapTypeId:google.maps.MapTypeId.ROADMAP},this.$field);if(this.map=new google.maps.Map(this.$el.find(".canvas")[0],n),acf.isset(window,"google","maps","places","Autocomplete")){var s=new google.maps.places.Autocomplete(this.$search[0]);s.bindTo("bounds",this.map),google.maps.event.addListener(s,"place_changed",function(t){var i=this.getPlace();e.search(i)}),this.map.autocomplete=s}var r=acf.apply_filters("google_map_marker_args",{draggable:!0,raiseOnDrag:!0,map:this.map},this.$field);this.map.marker=new google.maps.Marker(r),this.map.$el=i,this.map.$field=t;var o=i.find(".input-lat").val(),l=i.find(".input-lng").val();o&&l&&this.update(o,l).center(),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())},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.$el.find('input[type="hidden"]'),this.$img=this.$el.find("img"),this.o=acf.get_data(this.$el)},initialize:function(){"basic"==this.o.uploader&&this.$el.closest("form").attr("enctype","multipart/form-data")},prepare:function(e){if(e=e||{},e._valid)return e;var t={url:"",alt:"",title:"",caption:"",description:"",width:0,height:0};return e.id&&(t=e.attributes,t.url=acf.maybe_get(t,"sizes."+this.o.preview_size+".url",t.url)),t._valid=!0,t},render:function(e){e=this.prepare(e),this.$img.attr({src:e.url,alt:e.alt,title:e.title});var t="";e.id&&(t=e.id),acf.val(this.$input,t),t?this.$el.addClass("has-value"):this.$el.removeClass("has-value")},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"),r=t.closest(".acf-row");if(t=!1,r.nextAll(".acf-row:visible").each(function(){if(t=acf.get_field(s,$(this)))return!!t.find(".acf-image-uploader.has-value").exists()&&void(t=!1)}),!t){if(r=acf.fields.repeater.doFocus(i).add(),!r)return!1;t=acf.get_field(s,r)}}e.set("$field",t).render(a)}})},edit:function(){var e=this,t=this.$field,i=this.$input.val();if(i)var a=acf.media.popup({title:acf._e("image","edit"),button:acf._e("image","update"),mode:"edit",attachment:i,select:function(i,a){e.set("$field",t).render(i)}})},remove:function(){var e={};this.render(e)},change:function(e){acf.fields.file.get_file_info(e.$el,this.$input)}})}(jQuery),function($){acf.media=acf.model.extend({frames:[],mime_types:{},actions:{ready:"ready"},frame:function(){var e=this.frames.length-1;return!(e<0)&&this.frames[e]},destroy:function(e){e.detach(),e.dispose(),e=null,this.frames.pop()},popup:function(e){var t=acf.get("post_id"),i=!1;$.isNumeric(t)||(t=0);var a=acf.parse_args(e,{mode:"select",title:"",button:"",type:"",field:"",mime_types:"",library:"all",multiple:!1,attachment:0,post_id:t,select:function(){}});a.id&&(a.attachment=a.id);var i=this.new_media_frame(a);return this.frames.push(i),setTimeout(function(){i.open()},1),i},_get_media_frame_settings:function(e,t){return"select"===t.mode?e=this._get_select_frame_settings(e,t):"edit"===t.mode&&(e=this._get_edit_frame_settings(e,t)),e},_get_select_frame_settings:function(e,t){return t.type&&(e.library.type=t.type),"uploadedTo"===t.library&&(e.library.uploadedTo=t.post_id),e._button=acf._e("media","select"),e},_get_edit_frame_settings:function(e,t){return e.library.post__in=[t.attachment],e._button=acf._e("media","update"),e},_add_media_frame_events:function(e,t){return e.on("open",function(){this.$el.closest(".media-modal").addClass("acf-media-modal -"+t.mode)},e),e.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()},e),e.on("toolbar:create:select",function(t){t.view=new wp.media.view.Toolbar.Select({text:e.options._button,controller:this})},e),e.on("select",function(){var i=e.state(),a=i.get("image"),n=i.get("selection");if(a)return void t.select.apply(e,[a,0]);if(n){var s=0;return void n.each(function(i){t.select.apply(e,[i,s]),s++})}}),e.on("close",function(){setTimeout(function(){acf.media.destroy(e)},500)}),"select"===t.mode?e=this._add_select_frame_events(e,t):"edit"===t.mode&&(e=this._add_edit_frame_events(e,t)),e},_add_select_frame_events:function(e,t){var i=this;return acf.isset(_wpPluploadSettings,"defaults","multipart_params")&&(_wpPluploadSettings.defaults.multipart_params._acfuploader=t.field,e.on("open",function(){delete _wpPluploadSettings.defaults.multipart_params._acfuploader})),e.on("content:activate:browse",function(){try{var a=e.content.get().toolbar,n=a.get("filters"),s=a.get("search")}catch(e){return}if("image"==t.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")})),t.mime_types){var r=t.mime_types.split(" ").join("").split(".").join("").split(",");$.each(r,function(e,t){$.each(i.mime_types,function(e,i){if(e.indexOf(t)!==-1){var a={text:t,props:{status:null,type:i,uploadedTo:null,orderby:"date",order:"DESC"},priority:20};n.filters[i]=a}})})}"uploadedTo"==t.library&&(delete n.filters.unattached,delete n.filters.uploaded,n.$el.parent().append(''+acf._e("image","uploadedTo")+""),$.each(n.filters,function(e,i){i.props.uploadedTo=t.post_id})),$.each(n.filters,function(e,i){i.props._acfuploader=t.field}),s.model.attributes._acfuploader=t.field,"function"==typeof n.refresh&&n.refresh()}),e},_add_edit_frame_events:function(e,t){return e.on("open",function(){this.$el.closest(".media-modal").addClass("acf-expanded"),"browse"!=this.content.mode()&&this.content.mode("browse");var e=this.state(),i=e.get("selection"),a=wp.media.attachment(t.attachment);i.add(a)},e),e},new_media_frame:function(e){var t={title:e.title,multiple:e.multiple,library:{},states:[]};t=this._get_media_frame_settings(t,e);var i=wp.media.query(t.library);acf.isset(i,"mirroring","args")&&(i.mirroring.args._acfuploader=e.field),t.states=[new wp.media.controller.Library({library:i,multiple:t.multiple,title:t.title,priority:20,filterable:"all",editable:!0,allowLocalEdits:!0})],acf.isset(wp,"media","controller","EditImage")&&t.states.push(new wp.media.controller.EditImage);var a=wp.media(t);return a.acf=e,a=this._add_media_frame_events(a,e)},ready:function(){var e=acf.get("wp_version"),t=acf.get("browser"),i=acf.get("post_id");acf.isset(window,"wp","media","view","settings","post")&&$.isNumeric(i)&&(wp.media.view.settings.post.id=i),t&&$("body").addClass("browser-"+t),e&&(e+="",major=e.substr(0,1),$("body").addClass("major-"+major)),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=this.collection,a=this.options.selection,n=this.model,s=a.single(),r=acf.media.frame(),o=acf.maybe_get(this,"model.attributes.acf_errors"),l=this.controller.$el.find(".media-frame-content .media-sidebar");if(l.children(".acf-selection-error").remove(),l.children().removeClass("acf-hidden"),r&&o){var c=acf.maybe_get(this,"model.attributes.filename","");return l.children().addClass("acf-hidden"),l.prepend(['',''+acf._e("restricted")+"",''+c+"",''+o+"","
"].join("")),a.reset(),void a.single(n)}e.prototype.toggleSelection.apply(this,arguments)}})},customize_AttachmentFiltersAll:function(){wp.media.view.AttachmentFilters.All.prototype.refresh=function(){this.$el.html(_.chain(this.filters).map(function(e,t){return{el:$("").val(t).html(e.text)[0],priority:e.priority||50}},this).sortBy("priority").pluck("el").value())}},customize_AttachmentCompat:function(){var e=wp.media.view.AttachmentCompat;wp.media.view.AttachmentCompat=e.extend({render:function(){var t=this;return this.ignore_render?this:(setTimeout(function(){var e=t.$el.closest(".media-modal");if(!e.find(".media-frame-router .acf-expand-details").exists()){var i=$(['',''+acf._e("expand_details")+"",''+acf._e("collapse_details")+"",""].join(""));i.on("click",function(t){t.preventDefault(),e.hasClass("acf-expanded")?e.removeClass("acf-expanded"):e.addClass("acf-expanded")}),e.find(".media-frame-router").append(i)}},0),clearTimeout(acf.media.render_timout),acf.media.render_timout=setTimeout(function(){acf.do_action("append",t.$el)},50),e.prototype.render.apply(this,arguments))},dispose:function(){return acf.do_action("remove",this.$el),e.prototype.dispose.apply(this,arguments)},save:function(e){e&&e.preventDefault();var t=acf.serialize_form(this.$el);this.ignore_render=!0,this.model.saveCompat(t)}})}})}(jQuery),function($){acf.fields.oembed=acf.field.extend({type:"oembed",$el:null,events:{'click [data-name="search-button"]':"_search",'click [data-name="clear-button"]':"_clear",'click [data-name="value-title"]':"_edit",'keypress [data-name="search-input"]':"_keypress",'keyup [data-name="search-input"]':"_keyup",'blur [data-name="search-input"]':"_blur"},focus:function(){this.$el=this.$field.find(".acf-oembed"),this.$search=this.$el.find('[data-name="search-input"]'),this.$input=this.$el.find('[data-name="value-input"]'),this.$title=this.$el.find('[data-name="value-title"]'),this.$embed=this.$el.find('[data-name="value-embed"]'),this.o=acf.get_data(this.$el)},maybe_search:function(){var e=this.$input.val(),t=this.$search.val();return t?void(t!=e&&this.search()):void this.clear()},search:function(){var e=this.$search.val();"http"!=e.substr(0,4)&&(e="http://"+e,this.$search.val(e)),this.$el.addClass("is-loading");var t=acf.prepare_for_ajax({action:"acf/fields/oembed/search",s:e,field_key:this.$field.data("key")});this.$el.data("xhr")&&this.$el.data("xhr").abort();var i=$.ajax({url:acf.get("ajaxurl"),data:t,type:"post",dataType:"json",context:this,success:this.search_success});this.$el.data("xhr",i)},search_success:function(e){var t=this.$search.val();return this.$el.removeClass("is-loading"),e&&e.html?(this.$el.removeClass("has-error").addClass("has-value"),this.$input.val(t),this.$title.html(t),void this.$embed.html(e.html)):void this.$el.removeClass("has-value").addClass("has-error")},clear:function(){this.$el.removeClass("has-error has-value"),this.$el.find('[data-name="search-input"]').val(""),this.$input.val(""),this.$title.html(""),this.$embed.html("")},edit:function(){this.$el.addClass("is-editing"),this.$search.val(this.$title.text()).focus()},blur:function(e){this.$el.removeClass("is-editing"),this.maybe_search()},_search:function(e){this.search()},_clear:function(e){this.clear()},_edit:function(e){this.edit()},_keypress:function(e){13==e.which&&e.preventDefault()},_keyup:function(e){this.$search.val()&&this.maybe_search()},_blur:function(e){this.blur()}})}(jQuery),function($){acf.fields.radio=acf.field.extend({type:"radio",$ul:null,actions:{ready:"initialize",append:"initialize"},events:{'click input[type="radio"]':"click"},focus:function(){this.$ul=this.$field.find(".acf-radio-list"),this.o=acf.get_data(this.$ul)},initialize:function(){this.$ul.find(".selected input").prop("checked",!0)},click:function(e){var t=e.$el,i=t.parent("label"),a=i.hasClass("selected"),n=t.val();if(this.$ul.find(".selected").removeClass("selected"),i.addClass("selected"),this.o.allow_null&&a&&(e.$el.prop("checked",!1),i.removeClass("selected"),n=!1,e.$el.trigger("change")),this.o.other_choice){var s=this.$ul.find('input[type="text"]');"other"===n?s.prop("disabled",!1).attr("name",t.attr("name")):s.prop("disabled",!0).attr("name","")}}})}(jQuery),function($){acf.fields.relationship=acf.field.extend({type:"relationship",$el:null,$input:null,$filters:null,$choices:null,$values:null,actions:{ready:"initialize",append:"initialize"},events:{"keypress [data-filter]":"submit_filter","change [data-filter]":"change_filter","keyup [data-filter]":"change_filter","click .choices .acf-rel-item":"add_item",'click [data-name="remove_item"]':"remove_item"},focus:function(){this.$el=this.$field.find(".acf-relationship"),this.$input=this.$el.find(".acf-hidden input"),this.$choices=this.$el.find(".choices"),this.$values=this.$el.find(".values"),this.o=acf.get_data(this.$el)},initialize:function(){var e=this,t=this.$field,i=this.$el,a=this.$input;this.$values.children(".list").sortable({items:"li",forceHelperSize:!0,forcePlaceholderSize:!0,scroll:!0,update:function(){a.trigger("change")}}),this.$choices.children(".list").scrollTop(0).on("scroll",function(a){if(!i.hasClass("is-loading")&&!i.hasClass("is-empty")&&Math.ceil($(this).scrollTop())+$(this).innerHeight()>=$(this).get(0).scrollHeight){var n=i.data("paged")||1;i.data("paged",n+1),e.set("$field",t).fetch()}}),this.fetch()},maybe_fetch:function(){var e=this,t=this.$field;this.o.timeout&&clearTimeout(this.o.timeout);var i=setTimeout(function(){e.doFocus(t),e.fetch()},300);this.$el.data("timeout",i)},fetch:function(){var e=this,t=this.$field;this.$el.addClass("is-loading"),this.o.xhr&&(this.o.xhr.abort(),this.o.xhr=!1),this.o.action="acf/fields/relationship/query",this.o.field_key=t.data("key"),this.o.post_id=acf.get("post_id");var i=acf.prepare_for_ajax(this.o);1==i.paged&&this.$choices.children(".list").html(""),this.$choices.find("ul:last").append(' '+acf._e("relationship","loading")+"
");var a=$.ajax({url:acf.get("ajaxurl"),dataType:"json",type:"post",data:i,success:function(i){e.set("$field",t).render(i)}});this.$el.data("xhr",a)},render:function(e){if(this.$el.removeClass("is-loading is-empty"),this.$choices.find("p").remove(),!e||!e.results||!e.results.length)return this.$el.addClass("is-empty"),void(1==this.o.paged&&this.$choices.children(".list").append(""+acf._e("relationship","empty")+"
"));var t=$(this.walker(e.results));if(this.$values.find(".acf-rel-item").each(function(){t.find('.acf-rel-item[data-id="'+$(this).data("id")+'"]').addClass("disabled")}),this.o.s){var i=this.o.s;i=acf.addslashes(i),t.find(".acf-rel-item").each(function(){var e=$(this).text(),t=e.replace(new RegExp("("+i+")","gi"),"$1");$(this).html($(this).html().replace(e,t))})}this.$choices.children(".list").append(t);var a="",n=null;this.$choices.find(".acf-rel-label").each(function(){return $(this).text()==a?(n.append($(this).siblings("ul").html()),void $(this).parent().remove()):(a=$(this).text(),void(n=$(this).siblings("ul")))})},walker:function(e){var t="";if($.isArray(e))for(var i in e)t+=this.walker(e[i]);else $.isPlainObject(e)&&(void 0!==e.children?(t+=''+e.text+'',t+=this.walker(e.children),t+="
"):t+=''+e.text+"");return t},submit_filter:function(e){13==e.which&&e.preventDefault()},change_filter:function(e){var t=e.$el.val(),i=e.$el.data("filter");this.$el.data(i)!=t&&(this.$el.data(i,t),this.$el.data("paged",1),e.$el.is("select")?this.fetch():this.maybe_fetch())},add_item:function(e){if(this.o.max>0&&this.$values.find(".acf-rel-item").length>=this.o.max)return void alert(acf._e("relationship","max").replace("{max}",this.o.max));if(e.$el.hasClass("disabled"))return!1;e.$el.addClass("disabled");var t=["",'',''+e.$el.html(),'',"",""].join("");this.$values.children(".list").append(t),this.$input.trigger("change"),acf.validation.remove_error(this.$field)},remove_item:function(e){var t=e.$el.parent(),i=t.data("id");t.parent("li").remove(),this.$choices.find('.acf-rel-item[data-id="'+i+'"]').removeClass("disabled"),this.$input.trigger("change")}})}(jQuery),function($){acf.select2=acf.model.extend({version:0,actions:{"ready 1":"ready"},ready:function(){acf.maybe_get(window,"Select2")?(this.version=3,this.l10n_v3()):acf.maybe_get(window,"jQuery.fn.select2.amd")&&(this.version=4)},l10n_v3:function(){var e=acf.get("locale"),t=acf.get("rtl");if(l10n=acf._e("select"),l10n){var i={formatMatches:function(e){return 1===e?l10n.matches_1:l10n.matches_n.replace("%d",e)},formatNoMatches:function(){return l10n.matches_0},formatAjaxError:function(){return l10n.load_fail},formatInputTooShort:function(e,t){var i=t-e.length;return 1===i?l10n.input_too_short_1:l10n.input_too_short_n.replace("%d",i)},formatInputTooLong:function(e,t){var i=e.length-t;return 1===i?l10n.input_too_long_1:l10n.input_too_long_n.replace("%d",i)},formatSelectionTooBig:function(e){return 1===e?l10n.selection_too_long_1:l10n.selection_too_long_n.replace("%d",e)},formatLoadMore:function(){return l10n.load_more},formatSearching:function(){return l10n.searching}};$.fn.select2.locales=acf.maybe_get(window,"jQuery.fn.select2.locales",{}),$.fn.select2.locales[e]=i,$.extend($.fn.select2.defaults,i)}},init:function(e,t,i){if(this.version)return t=t||{},i=i||null,t=$.extend({allow_null:!1,placeholder:"",multiple:!1,ajax:!1,ajax_action:""},t),3==this.version?this.init_v3(e,t,i):4==this.version&&this.init_v4(e,t,i)},get_data:function(e,t){var i=this;return t=t||[],e.children().each(function(){var e=$(this);e.is("optgroup")?t.push({text:e.attr("label"),children:i.get_data(e)}):t.push({id:e.attr("value"),text:e.text()})}),t},decode_data:function(e){return e?($.each(e,function(t,i){e[t].text=acf.decode(i.text),"undefined"!=typeof i.children&&(e[t].children=acf.select2.decode_data(i.children))}),e):[]},count_data:function(e){var t=0;return e?($.each(e,function(e,i){t++,"undefined"!=typeof i.children&&(t+=i.children.length)}),t):t},get_ajax_data:function(e,t,i,a){var n=acf.prepare_for_ajax({action:e.ajax_action,field_key:e.key,s:t.term||"",paged:t.page||1});return n=acf.apply_filters("select2_ajax_data",n,e,i,a)},get_ajax_results:function(e,t){var i={results:[]};return e||(e=i),"undefined"==typeof e.results&&(i.results=e,e=i),e.results=this.decode_data(e.results),e=acf.apply_filters("select2_ajax_results",e,t)},get_value:function(e){var t=[],i=e.find("option:selected");return i.exists()?(i=i.sort(function(e,t){return+e.getAttribute("data-i")-+t.getAttribute("data-i")}),i.each(function(){var e=$(this);t.push({id:e.attr("value"),text:e.text()})}),t):t},init_v3:function(e,t,i){var a=e.siblings("input");if(a.exists()){var n={width:"100%",containerCssClass:"-acf",allowClear:t.allow_null,placeholder:t.placeholder,multiple:t.multiple,separator:"||",data:[],escapeMarkup:function(e){return e},formatResult:function(e,t,i,a){var n=$.fn.select2.defaults.formatResult(e,t,i,a);return e.description&&(n+=' '+e.description+""),n}},s=this.get_value(e);if(t.multiple){var r=e.attr("name");n.formatSelection=function(e,t){var i='";return t.parent().append(i),e.text}}else s=acf.maybe_get(s,0,!1),!t.allow_null&&s&&a.val(s.id);t.allow_null&&e.find('option[value=""]').remove(),n.data=this.get_data(e),n.initSelection=function(e,t){t(s)},t.ajax&&(n.ajax={url:acf.get("ajaxurl"),dataType:"json",type:"post",cache:!1,quietMillis:250,data:function(e,n){var s={term:e,page:n};return acf.select2.get_ajax_data(t,s,a,i)},results:function(e,t){var i={page:t};return setTimeout(function(){acf.select2.merge_results_v3()},1),acf.select2.get_ajax_results(e,i)}}),n.dropdownCss={"z-index":"999999999"},n.acf=t,n=acf.apply_filters("select2_args",n,e,t,i),a.select2(n);var o=a.select2("container");o.before(e),o.before(a),t.multiple&&o.find("ul.select2-choices").sortable({start:function(){a.select2("onSortStart")},stop:function(){a.select2("onSortEnd")}}),e.prop("disabled",!0).addClass("acf-disabled acf-hidden"),a.on("change",function(t){t.added&&e.append('"),e.val(t.val)}),acf.do_action("select2_init",a,n,t,i)}},merge_results_v3:function(){var e="",t=null;$("#select2-drop .select2-result-with-children").each(function(){var i=$(this).children(".select2-result-label"),a=$(this).children(".select2-result-sub");return i.text()==e?(t.append(a.children()),void $(this).remove()):(e=i.text(),void(t=a))})},init_v4:function(e,t,i){var a=e.siblings("input");if(a.exists()){var n={width:"100%",allowClear:t.allow_null,placeholder:t.placeholder,multiple:t.multiple,separator:"||",data:[],escapeMarkup:function(e){return e}},s=this.get_value(e);t.multiple||(s=acf.maybe_get(s,0,"")),t.allow_null&&e.find('option[value=""]').remove(),n.data=this.get_data(e),t.ajax?n.ajax={url:acf.get("ajaxurl"),delay:250,dataType:"json",type:"post",cache:!1,data:function(a){return acf.select2.get_ajax_data(t,a,e,i)},processResults:function(e,t){var i=acf.select2.get_ajax_results(e,t);return i.more&&(i.pagination={more:!0}),setTimeout(function(){acf.select2.merge_results_v4()},1),i}}:(e.removeData("ajax"),e.removeAttr("data-ajax")),n=acf.apply_filters("select2_args",n,e,t,i);var r=e.select2(n);a.val(""),r.addClass("-acf"),acf.do_action("select2_init",e,n,t,i)}},merge_results_v4:function(){var e=null,t=null;$('.select2-results__option[role="group"]').each(function(){var i=$(this).children("ul"),a=$(this).children("strong");return null!==t&&a.text()==t.text()?(e.append(i.children()),void $(this).remove()):(e=i,void(t=a))})},destroy:function(e){e.siblings(".select2-container").remove(),e.siblings("input").show(),e.prop("disabled",!1).removeClass("acf-disabled acf-hidden")}}),acf.add_select2=function(e,t){acf.select2.init(e,t)},acf.remove_select2=function(e){acf.select2.destroy(e)},acf.fields.select=acf.field.extend({type:"select",$select:null,actions:{ready:"render",append:"render",remove:"remove"},focus:function(){this.$select=this.$field.find("select"),this.$select.exists()&&(this.o=acf.get_data(this.$select),this.o=acf.parse_args(this.o,{ajax_action:"acf/fields/"+this.type+"/query",key:this.$field.data("key")}))},render:function(){return!(!this.$select.exists()||!this.o.ui)&&void acf.select2.init(this.$select,this.o,this.$field)},remove:function(){return!(!this.$select.exists()||!this.o.ui)&&void acf.select2.destroy(this.$select)}}),acf.fields.user=acf.fields.select.extend({type:"user"}),acf.fields.post_object=acf.fields.select.extend({type:"post_object"}),acf.fields.page_link=acf.fields.select.extend({type:"page_link"})}(jQuery),function($){acf.fields.tab=acf.field.extend({type:"tab",$el:null,$wrap:null,actions:{prepare:"initialize",append:"initialize",hide:"hide",show:"show"},focus:function(){this.$el=this.$field.find(".acf-tab"),this.o=this.$el.data(),this.o.key=this.$field.data("key"),this.o.text=this.$el.text()},initialize:function(){this.$field.is("td")||e.add_tab(this.$field,this.o)},hide:function(e,t){if("conditional_logic"==t){var i=e.data("key"),a=e.prevAll(".acf-tab-wrap"),n=a.find('a[data-key="'+i+'"]'),s=n.parent();a.exists()&&(s.addClass("hidden-by-conditional-logic"),setTimeout(function(){e.nextUntil(".acf-field-tab",".acf-field").each(function(){$(this).hasClass("hidden-by-conditional-logic")||(acf.conditional_logic.hide_field($(this)),$(this).addClass("-hbcl-"+i))}),s.hasClass("active")&&a.find("li:not(.hidden-by-conditional-logic):first a").trigger("click")},0))}},show:function(e,t){if("conditional_logic"==t){var i=e.data("key"),a=e.prevAll(".acf-tab-wrap"),n=a.find('a[data-key="'+i+'"]'),s=n.parent();a.exists()&&(s.removeClass("hidden-by-conditional-logic"),setTimeout(function(){e.siblings(".acf-field.-hbcl-"+i).each(function(){acf.conditional_logic.show_field($(this)),$(this).removeClass("-hbcl-"+i)});var t=s.siblings(".active");t.exists()&&!t.hasClass("hidden-by-conditional-logic")||n.trigger("click")},0))}}});var e=acf.model.extend({actions:{"prepare 15":"render","append 15":"render","refresh 15":"render"},events:{"click .acf-tab-button":"_click"},render:function(e){$(".acf-tab-wrap",e).each(function(){var e=$(this),t=e.parent();if(e.find("li.active").exists()||e.find("li:not(.hidden-by-conditional-logic):first a").trigger("click"),t.hasClass("-sidebar")){var i=t.is("td")?"height":"min-height",a=e.position().top+e.children("ul").outerHeight(!0)-1;t.css(i,a)}})},add_group:function(e,t){var i=e.parent(),a="";return i.hasClass("acf-fields")&&"left"==t.placement?i.addClass("-sidebar"):t.placement="top",a=i.is("tbody")?' |
':'',$group=$(a),e.before($group),$group},add_tab:function(e,t){var i=e.siblings(".acf-tab-wrap").last();i.exists()?t.endpoint&&(i=this.add_group(e,t)):i=this.add_group(e,t);var a=$(''+t.text+"");""===t.text&&a.hide(),i.find("ul").append(a),e.hasClass("hidden-by-conditional-logic")&&a.addClass("hidden-by-conditional-logic")},_click:function(e){e.preventDefault();var t=this,i=e.$el,a=i.closest(".acf-tab-wrap"),n=i.data("key"),s="";i.parent().addClass("active").siblings().removeClass("active"),a.nextUntil(".acf-tab-wrap",".acf-field").each(function(){var e=$(this);return("tab"!=e.data("type")||(s=e.data("key"),!e.hasClass("endpoint")))&&void(s===n?e.hasClass("hidden-by-tab")&&(e.removeClass("hidden-by-tab"),acf.do_action("show_field",$(this),"tab")):e.hasClass("hidden-by-tab")||(e.addClass("hidden-by-tab"),acf.do_action("hide_field",$(this),"tab")))}),acf.do_action("refresh",a.parent()),i.trigger("blur")}}),t=acf.model.extend({active:1,actions:{add_field_error:"add_field_error"},add_field_error:function(e){if(this.active&&e.hasClass("hidden-by-tab")){var t=this,i=e.prevAll(".acf-field-tab:first"),a=e.prevAll(".acf-tab-wrap:first");a.find('a[data-key="'+i.data("key")+'"]').trigger("click"),this.active=0,setTimeout(function(){t.active=1},1e3)}}})}(jQuery),function($){acf.fields.time_picker=acf.field.extend({type:"time_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-time-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(){if("undefined"!=typeof $.timepicker){
+var e={timeFormat:this.o.time_format,altField:this.$hidden,altFieldTimeOnly:!1,altTimeFormat:"HH:mm:ss",showButtonPanel:!0,controlType:"select",oneLine:!0,closeText:acf._e("date_time_picker","selectText")};e.onClose=function(e,t){var i=t.dpDiv,a=i.find(".ui-datepicker-close");if(!e&&a.is(":hover")){if(e=acf.maybe_get(t,"settings.timepicker.formattedTime"),!e)return;$.datepicker._setTime(t)}},e=acf.apply_filters("time_picker_args",e,this.$field),this.$input.timepicker(e),$("body > #ui-datepicker-div").exists()&&$("body > #ui-datepicker-div").wrap(''),acf.do_action("time_picker_init",this.$input,e,this.$field)}},blur:function(){this.$input.val()||this.$hidden.val("")}})}(jQuery),function($){acf.fields.true_false=acf.field.extend({type:"true_false",$switch:null,$input:null,actions:{prepare:"render",append:"render",show:"render"},events:{"change .acf-switch-input":"_change","focus .acf-switch-input":"_focus","blur .acf-switch-input":"_blur","keypress .acf-switch-input":"_keypress"},focus:function(){this.$input=this.$field.find(".acf-switch-input"),this.$switch=this.$field.find(".acf-switch")},render:function(){if(this.$switch.exists()){var e=this.$switch.children(".acf-switch-on"),t=this.$switch.children(".acf-switch-off");width=Math.max(e.width(),t.width()),width&&(e.css("min-width",width),t.css("min-width",width))}},on:function(){this.$input.prop("checked",!0),this.$switch.addClass("-on")},off:function(){this.$input.prop("checked",!1),this.$switch.removeClass("-on")},_change:function(e){var t=e.$el.prop("checked");t?this.on():this.off()},_focus:function(e){this.$switch.addClass("-focus")},_blur:function(e){this.$switch.removeClass("-focus")},_keypress:function(e){return 37===e.keyCode?this.off():39===e.keyCode?this.on():void 0}})}(jQuery),function($){acf.fields.taxonomy=acf.field.extend({type:"taxonomy",$el:null,actions:{ready:"render",append:"render",remove:"remove"},events:{'click a[data-name="add"]':"add_term"},focus:function(){this.$el=this.$field.find(".acf-taxonomy-field"),this.o=acf.get_data(this.$el),this.o.key=this.$field.data("key")},render:function(){var e=this.$field.find("select");if(e.exists()){var t=acf.get_data(e);t=acf.parse_args(t,{pagination:!0,ajax_action:"acf/fields/taxonomy/query",key:this.o.key}),acf.select2.init(e,t)}},remove:function(){var e=this.$field.find("select");return!!e.exists()&&void acf.select2.destroy(e)},add_term:function(e){var t=this;acf.open_popup({title:e.$el.attr("title")||e.$el.data("title"),loading:!0,height:220});var i=acf.prepare_for_ajax({action:"acf/fields/taxonomy/add_term",field_key:this.o.key});$.ajax({url:acf.get("ajaxurl"),data:i,type:"post",dataType:"html",success:function(e){t.add_term_confirm(e)}})},add_term_confirm:function(e){var t=this;acf.update_popup({content:e}),$('#acf-popup input[name="term_name"]').focus(),$("#acf-popup form").on("submit",function(e){e.preventDefault(),t.add_term_submit($(this))})},add_term_submit:function(e){var t=this,i=e.find(".acf-submit"),a=e.find('input[name="term_name"]'),n=e.find('select[name="term_parent"]');if(""===a.val())return a.focus(),!1;i.find("button").attr("disabled","disabled"),i.find(".acf-spinner").addClass("is-active");var s=acf.prepare_for_ajax({action:"acf/fields/taxonomy/add_term",field_key:this.o.key,term_name:a.val(),term_parent:n.exists()?n.val():0});$.ajax({url:acf.get("ajaxurl"),data:s,type:"post",dataType:"json",success:function(e){var n=acf.get_ajax_message(e);acf.is_ajax_success(e)&&(a.val(""),t.append_new_term(e.data)),n.text&&i.find("span").html(n.text)},complete:function(){i.find("button").removeAttr("disabled"),i.find(".acf-spinner").removeClass("is-active"),i.find("span").delay(1500).fadeOut(250,function(){$(this).html(""),$(this).show()}),a.focus()}})},append_new_term:function(e){var t={id:e.term_id,text:e.term_label};switch($('.acf-taxonomy-field[data-taxonomy="'+this.o.taxonomy+'"]').each(function(){var t=$(this).data("type");if("radio"==t||"checkbox"==t){var i=$(this).children('input[type="hidden"]'),a=$(this).find("ul:first"),n=i.attr("name");"checkbox"==t&&(n+="[]");var s=$(['',"",""].join(""));if(e.term_parent){var r=a.find('li[data-id="'+e.term_parent+'"]');a=r.children("ul"),a.exists()||(a=$(''),r.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+'"]'),r=n.get(0).scrollTop+(s.offset().top-n.offset().top);s.find("input").prop("checked",!0),n.animate({scrollTop:r},"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(e.indexOf("://")!==-1);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){if(!this.errors.length)return e;e.valid=0,e.errors=e.errors||[];var a=[];if(e.errors.length)for(i in e.errors)a.push(e.errors[i].input);if(this.errors.length)for(i in this.errors){var n=this.errors[i];$.inArray(n.input,a)===-1&&e.errors.push(n)}return 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;acf.do_action("validation_begin");var i=acf.serialize_form(e);i.action="acf/validate_save_post",i=acf.prepare_for_ajax(i),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")),setTimeout(function(){acf.remove_el(t)},2e3)),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 this.valid=!0,void acf.do_action("validation_success");acf.do_action("validation_failure"),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 r=t.errors[s];if(r.input){var o=e.find('[name="'+r.input+'"]').first();if(o.exists()||(o=e.find('[name^="'+r.input+'"]').first()),o.exists()){a++;var l=acf.get_field_wrap(o);this.add_error(l,r.message),null===i&&(i=l)}}else n+=". "+r.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){var t=e.children(".acf-input").children("."+this.message_class);e.removeClass(this.error_class),setTimeout(function(){acf.remove_el(t)},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:{},events:{"mousedown .acf-editor-wrap.delay":"mousedown"},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")},mousedown:function(e){e.preventDefault(),this.$el.removeClass("delay"),this.$el.find(".acf-editor-toolbar").remove(),this.initialize()},initialize:function(){if(!this.$el.hasClass("delay")&&"undefined"!=typeof tinyMCEPreInit){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,this.initialize_tinymce(),this.initialize_quicktags()}},initialize_tinymce:function(){if("undefined"!=typeof tinymce){var e=this.get_mceInit();if(tinyMCEPreInit.mceInit[e.id]=e,this.$el.hasClass("tmce-active"))try{tinymce.init(e);var t=tinyMCE.get(e.id);acf.do_action("wysiwyg_tinymce_init",t,t.id,e,this.$field)}catch(e){}}},initialize_quicktags:function(){if("undefined"!=typeof quicktags){var e=this.get_qtInit();tinyMCEPreInit.qtInit[e.id]=e;try{var t=quicktags(e);this._buttonsInit(t),acf.do_action("wysiwyg_quicktags_init",t,t.id,e,this.$field)}catch(e){}}},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;n<5;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("change",function(i){t.save(),e.find("textarea").trigger("change")})},i.wp_autoresize_on=!1,i=acf.apply_filters("wysiwyg_tinymce_settings",i,i.id,this.$field)},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,this.$field)},disable:function(){try{var e=tinyMCE.get(this.o.id);e.save(),e.destroy()}catch(e){}},enable:function(){try{this.$el.hasClass("tmce-active")&&switchEditors.go(this.o.id,"tmce")}catch(e){}},get_toolbar:function(e){return"undefined"!=typeof this.toolbars[e]&&this.toolbars[e]},_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&&t.indexOf(","+id+",")!==-1&&use.indexOf(","+id+",")===-1||edButtons[i].instance&&edButtons[i].instance!==inst||(theButtons[id]=edButtons[i],edButtons[i].html&&(html+=edButtons[i].html(name+"_"))));use&&use.indexOf(",fullscreen,")!==-1&&(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}});var e=acf.model.extend({$div:null,actions:{ready:"ready"},ready:function(){this.$div=$("#acf-hidden-wp-editor"),this.$div.exists()&&(this.$div.appendTo("body"),"undefined"!=typeof tinymce&&tinymce.on("AddEditor",function(e){var t=e.editor;"acf"===t.id.substr(0,3)&&(t=tinymce.editors.content||t,tinymce.activeEditor=t,wpActiveEditor=t.id)}))}})}(jQuery);
diff --git a/core/cache.php b/core/cache.php
index 84e4e30..7aee5bc 100644
--- a/core/cache.php
+++ b/core/cache.php
@@ -6,7 +6,11 @@ if( ! class_exists('acf_cache') ) :
class acf_cache {
-
+ // vars
+ var $cache = array(),
+ $reference = array();
+
+
/*
* __construct
*
@@ -22,11 +26,6 @@ class acf_cache {
function __construct() {
- // vars
- $this->cache = array();
- $this->reference = array();
-
-
// prevent ACF from persistent cache
wp_cache_add_non_persistent_groups('acf');
diff --git a/core/compatibility.php b/core/compatibility.php
index f7fa7cd..8501a7a 100644
--- a/core/compatibility.php
+++ b/core/compatibility.php
@@ -18,78 +18,28 @@ class acf_compatibility {
function __construct() {
// fields
- add_filter('acf/get_valid_field', array($this, 'get_valid_field'), 20, 1);
- add_filter('acf/get_valid_field/type=textarea', array($this, 'get_valid_textarea_field'), 20, 1);
- add_filter('acf/get_valid_field/type=relationship', array($this, 'get_valid_relationship_field'), 20, 1);
- add_filter('acf/get_valid_field/type=post_object', array($this, 'get_valid_relationship_field'), 20, 1);
- add_filter('acf/get_valid_field/type=page_link', array($this, 'get_valid_relationship_field'), 20, 1);
- add_filter('acf/get_valid_field/type=image', array($this, 'get_valid_image_field'), 20, 1);
- add_filter('acf/get_valid_field/type=file', array($this, 'get_valid_image_field'), 20, 1);
- add_filter('acf/get_valid_field/type=wysiwyg', array($this, 'get_valid_wysiwyg_field'), 20, 1);
- add_filter('acf/get_valid_field/type=date_picker', array($this, 'get_valid_date_picker_field'), 20, 1);
- add_filter('acf/get_valid_field/type=taxonomy', array($this, 'get_valid_taxonomy_field'), 20, 1);
- add_filter('acf/get_valid_field/type=date_time_picker', array($this, 'get_valid_date_time_picker_field'), 20, 1);
- add_filter('acf/get_valid_field/type=user', array($this, 'get_valid_user_field'), 20, 1);
+ add_filter('acf/validate_field', array($this, 'validate_field'), 20, 1);
+ add_filter('acf/validate_field/type=textarea', array($this, 'validate_textarea_field'), 20, 1);
+ add_filter('acf/validate_field/type=relationship', array($this, 'validate_relationship_field'), 20, 1);
+ add_filter('acf/validate_field/type=post_object', array($this, 'validate_relationship_field'), 20, 1);
+ add_filter('acf/validate_field/type=page_link', array($this, 'validate_relationship_field'), 20, 1);
+ add_filter('acf/validate_field/type=image', array($this, 'validate_image_field'), 20, 1);
+ add_filter('acf/validate_field/type=file', array($this, 'validate_image_field'), 20, 1);
+ add_filter('acf/validate_field/type=wysiwyg', array($this, 'validate_wysiwyg_field'), 20, 1);
+ add_filter('acf/validate_field/type=date_picker', array($this, 'validate_date_picker_field'), 20, 1);
+ add_filter('acf/validate_field/type=taxonomy', array($this, 'validate_taxonomy_field'), 20, 1);
+ add_filter('acf/validate_field/type=date_time_picker', array($this, 'validate_date_time_picker_field'), 20, 1);
+ add_filter('acf/validate_field/type=user', array($this, 'validate_user_field'), 20, 1);
// field groups
- add_filter('acf/get_valid_field_group', array($this, 'get_valid_field_group'), 20, 1);
-
-
- // settings
- add_filter('acf/settings/show_admin', array($this, 'settings_acf_lite'), 5, 1);
- add_filter('acf/settings/l10n_textdomain', array($this, 'settings_export_textdomain'), 5, 1);
- add_filter('acf/settings/l10n_field', array($this, 'settings_export_translate'), 5, 1);
- add_filter('acf/settings/l10n_field_group', array($this, 'settings_export_translate'), 5, 1);
+ add_filter('acf/validate_field_group', array($this, 'validate_field_group'), 20, 1);
}
/*
- * settings
- *
- * description
- *
- * @type function
- * @date 19/05/2014
- * @since 5.0.0
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- function settings_acf_lite( $setting ) {
-
- // 5.0.0 - removed ACF_LITE
- if( defined('ACF_LITE') && ACF_LITE ) {
-
- $setting = false;
-
- }
-
-
- // return
- return $setting;
-
- }
-
- function settings_export_textdomain( $setting ) {
-
- // 5.3.3 - changed filter name
- return acf_get_setting( 'export_textdomain', $setting );
-
- }
-
- function settings_export_translate( $setting ) {
-
- // 5.3.3 - changed filter name
- return acf_get_setting( 'export_translate', $setting );
-
- }
-
-
- /*
- * get_valid_field
+ * validate_field
*
* This function will provide compatibility with ACF4 fields
*
@@ -101,7 +51,7 @@ class acf_compatibility {
* @return $field
*/
- function get_valid_field( $field ) {
+ function validate_field( $field ) {
// conditional logic has changed
if( isset($field['conditional_logic']['status']) ) {
@@ -163,7 +113,7 @@ class acf_compatibility {
/*
- * get_valid_relationship_field
+ * validate_relationship_field
*
* This function will provide compatibility with ACF4 fields
*
@@ -175,7 +125,7 @@ class acf_compatibility {
* @return $field
*/
- function get_valid_relationship_field( $field ) {
+ function validate_relationship_field( $field ) {
// force array
$field['post_type'] = acf_get_array($field['post_type']);
@@ -213,7 +163,7 @@ class acf_compatibility {
/*
- * get_valid_textarea_field
+ * validate_textarea_field
*
* This function will provide compatibility with ACF4 fields
*
@@ -225,7 +175,7 @@ class acf_compatibility {
* @return $field
*/
- function get_valid_textarea_field( $field ) {
+ function validate_textarea_field( $field ) {
// formatting has been removed
$formatting = acf_extract_var( $field, 'formatting' );
@@ -243,7 +193,7 @@ class acf_compatibility {
/*
- * get_valid_image_field
+ * validate_image_field
*
* This function will provide compatibility with ACF4 fields
*
@@ -255,7 +205,7 @@ class acf_compatibility {
* @return $field
*/
- function get_valid_image_field( $field ) {
+ function validate_image_field( $field ) {
// save_format is now return_format
if( !empty($field['save_format']) ) {
@@ -279,7 +229,7 @@ class acf_compatibility {
/*
- * get_valid_wysiwyg_field
+ * validate_wysiwyg_field
*
* This function will provide compatibility with ACF4 fields
*
@@ -291,7 +241,7 @@ class acf_compatibility {
* @return $field
*/
- function get_valid_wysiwyg_field( $field ) {
+ function validate_wysiwyg_field( $field ) {
// media_upload is now numeric
if( $field['media_upload'] === 'yes' ) {
@@ -311,7 +261,7 @@ class acf_compatibility {
/*
- * get_valid_date_picker_field
+ * validate_date_picker_field
*
* This function will provide compatibility with ACF4 fields
*
@@ -323,7 +273,7 @@ class acf_compatibility {
* @return $field
*/
- function get_valid_date_picker_field( $field ) {
+ function validate_date_picker_field( $field ) {
// v4 used date_format
if( !empty($field['date_format']) ) {
@@ -356,7 +306,7 @@ class acf_compatibility {
/*
- * get_valid_taxonomy_field
+ * validate_taxonomy_field
*
* This function will provide compatibility with ACF4 fields
*
@@ -368,7 +318,7 @@ class acf_compatibility {
* @return $field
*/
- function get_valid_taxonomy_field( $field ) {
+ function validate_taxonomy_field( $field ) {
// 5.2.7
if( isset($field['load_save_terms']) ) {
@@ -385,7 +335,7 @@ class acf_compatibility {
/*
- * get_valid_date_time_picker_field
+ * validate_date_time_picker_field
*
* This function will provide compatibility with existing 3rd party fields
*
@@ -397,7 +347,7 @@ class acf_compatibility {
* @return $field
*/
- function get_valid_date_time_picker_field( $field ) {
+ function validate_date_time_picker_field( $field ) {
// 3rd party date time picker
// https://github.com/soderlind/acf-field-date-time-picker
@@ -436,7 +386,7 @@ class acf_compatibility {
/*
- * get_valid_user_field
+ * validate_user_field
*
* This function will provide compatibility with ACF4 fields
*
@@ -448,7 +398,7 @@ class acf_compatibility {
* @return $field
*/
- function get_valid_user_field( $field ) {
+ function validate_user_field( $field ) {
// remove 'all' from roles
if( acf_in_array('all', $field['role']) ) {
@@ -481,7 +431,7 @@ class acf_compatibility {
/*
- * get_valid_field_group
+ * validate_field_group
*
* This function will provide compatibility with ACF4 field groups
*
@@ -493,21 +443,17 @@ class acf_compatibility {
* @return $field_group
*/
- function get_valid_field_group( $field_group ) {
-
- // global
- global $wpdb;
-
+ function validate_field_group( $field_group ) {
// vars
- $v = 5;
+ $version = 5;
// add missing 'key' (v5.0.0)
if( empty($field_group['key']) ) {
// update version
- $v = 4;
+ $version = 4;
// add missing key
@@ -547,11 +493,7 @@ class acf_compatibility {
foreach( $location['rules'] as $rule ) {
// sperate groups?
- if( $all_or_any == 'any' ) {
-
- $group++;
-
- }
+ if( $all_or_any == 'any' ) $group++;
// add to group
@@ -572,7 +514,7 @@ class acf_compatibility {
if( !empty($field_group['location']) ) {
// param changes
- $param_replace = array(
+ $replace = array(
'taxonomy' => 'post_taxonomy',
'ef_media' => 'attachment',
'ef_taxonomy' => 'taxonomy',
@@ -582,75 +524,43 @@ class acf_compatibility {
// remove conflicting param
- if( $v == 5 ) {
+ if( $version == 5 ) {
- unset($param_replace['taxonomy']);
+ unset($replace['taxonomy']);
}
// loop over location groups
- foreach( array_keys($field_group['location']) as $i ) {
-
- // extract group
- $group = acf_extract_var( $field_group['location'], $i );
-
+ foreach( $field_group['location'] as $i => $group ) {
// bail early if group is empty
- if( empty($group) ) {
-
- continue;
-
- }
+ if( empty($group) ) continue;
// loop over group rules
- foreach( array_keys($group) as $j ) {
-
- // extract rule
- $rule = acf_extract_var( $group, $j );
-
+ foreach( $group as $ii => $rule ) {
// migrate param
- if( isset($param_replace[ $rule['param'] ]) ) {
+ if( isset($replace[ $rule['param'] ]) ) {
- $rule['param'] = $param_replace[ $rule['param'] ];
+ $rule['param'] = $replace[ $rule['param'] ];
}
-
-
- // category / taxonomy terms are saved differently
- if( $rule['param'] == 'post_category' || $rule['param'] == 'post_taxonomy' ) {
-
- if( is_numeric($rule['value']) ) {
-
- $term_id = $rule['value'];
- $taxonomy = $wpdb->get_var( $wpdb->prepare( "SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d LIMIT 1", $term_id) );
- $term = get_term( $term_id, $taxonomy );
-
- // update rule value
- $rule['value'] = "{$term->taxonomy}:{$term->slug}";
-
- }
-
- }
+
-
- // append rule
- $group[ $j ] = $rule;
+ // update
+ $group[ $ii ] = $rule;
}
- // foreach
- // append group
+ // update
$field_group['location'][ $i ] = $group;
}
- // foreach
}
- // if
// change layout to style (v5.0.0)
diff --git a/core/deprecated.php b/core/deprecated.php
new file mode 100644
index 0000000..10a7aeb
--- /dev/null
+++ b/core/deprecated.php
@@ -0,0 +1,185 @@
+deprecated = new acf_deprecated();
+
+endif; // class_exists check
+
+?>
diff --git a/core/field.php b/core/field.php
index 7e52be8..c4e1853 100644
--- a/core/field.php
+++ b/core/field.php
@@ -41,7 +41,7 @@ class acf_field {
// field
- $this->add_field_filter('acf/get_valid_field', array($this, 'get_valid_field'), 10, 1);
+ $this->add_field_filter('acf/validate_field', array($this, 'validate_field'), 10, 1);
$this->add_field_filter('acf/load_field', array($this, 'load_field'), 10, 1);
$this->add_field_filter('acf/update_field', array($this, 'update_field'), 10, 1);
$this->add_field_filter('acf/duplicate_field', array($this, 'duplicate_field'), 10, 1);
@@ -211,11 +211,11 @@ class acf_field {
/*
- * get_valid_field
+ * validate_field
*
* This function will append default settings to a field
*
- * @type filter ("acf/get_valid_field/type={$this->name}")
+ * @type filter ("acf/validate_field/type={$this->name}")
* @since 3.6
* @date 23/01/13
*
@@ -223,14 +223,22 @@ class acf_field {
* @return $field (array)
*/
- function get_valid_field( $field ) {
+ function validate_field( $field ) {
// bail early if no defaults
if( !is_array($this->defaults) ) return $field;
- // merge in defaults
- return array_merge($this->defaults, $field);
+ // merge in defaults but keep order of $field keys
+ foreach( $this->defaults as $k => $v ) {
+
+ if( !isset($field[ $k ]) ) $field[ $k ] = $v;
+
+ }
+
+
+ // return
+ return $field;
}
diff --git a/core/form.php b/core/form.php
new file mode 100644
index 0000000..504c366
--- /dev/null
+++ b/core/form.php
@@ -0,0 +1,697 @@
+fields = array(
+
+ '_post_title' => array(
+ 'prefix' => 'acf',
+ 'name' => '_post_title',
+ 'key' => '_post_title',
+ 'label' => __('Title', 'acf'),
+ 'type' => 'text',
+ 'required' => true,
+ ),
+
+ '_post_content' => array(
+ 'prefix' => 'acf',
+ 'name' => '_post_content',
+ 'key' => '_post_content',
+ 'label' => __('Content', 'acf'),
+ 'type' => 'wysiwyg',
+ ),
+
+ '_validate_email' => array(
+ 'prefix' => 'acf',
+ 'name' => '_validate_email',
+ 'key' => '_validate_email',
+ 'label' => __('Validate Email', 'acf'),
+ 'type' => 'text',
+ 'value' => '',
+ 'wrapper' => array('style' => 'display:none !important;')
+ )
+
+ );
+
+
+ // actions
+ add_action('acf/validate_save_post', array($this, 'validate_save_post'), 1);
+
+
+ // filters
+ add_filter('acf/pre_save_post', array($this, 'pre_save_post'), 5, 2);
+
+ }
+
+
+ /*
+ * validate_form
+ *
+ * description
+ *
+ * @type function
+ * @date 28/2/17
+ * @since 5.5.8
+ *
+ * @param $post_id (int)
+ * @return $post_id (int)
+ */
+
+ function validate_form( $args ) {
+
+ // defaults
+ $args = wp_parse_args( $args, array(
+ 'id' => 'acf-form',
+ 'post_id' => false,
+ 'new_post' => false,
+ 'field_groups' => false,
+ 'fields' => false,
+ 'post_title' => false,
+ 'post_content' => false,
+ 'form' => true,
+ 'form_attributes' => array(),
+ 'return' => add_query_arg( 'updated', 'true', acf_get_current_url() ),
+ 'html_before_fields' => '',
+ 'html_after_fields' => '',
+ 'submit_value' => __("Update", 'acf'),
+ 'updated_message' => __("Post updated", 'acf'),
+ 'label_placement' => 'top',
+ 'instruction_placement' => 'label',
+ 'field_el' => 'div',
+ 'uploader' => 'wp',
+ 'honeypot' => true,
+ 'html_updated_message' => '', // 5.5.10
+ 'html_submit_button' => '', // 5.5.10
+ 'html_submit_spinner' => '' // 5.5.10
+ ));
+
+ $args['form_attributes'] = wp_parse_args( $args['form_attributes'], array(
+ 'id' => $args['id'],
+ 'class' => 'acf-form',
+ 'action' => '',
+ 'method' => 'post',
+ ));
+
+
+ // filter post_id
+ $args['post_id'] = acf_get_valid_post_id( $args['post_id'] );
+
+
+ // new post?
+ if( $args['post_id'] === 'new_post' ) {
+
+ $args['new_post'] = wp_parse_args( $args['new_post'], array(
+ 'post_type' => 'post',
+ 'post_status' => 'draft',
+ ));
+
+ }
+
+
+ // filter
+ $args = apply_filters('acf/validate_form', $args);
+
+
+ // return
+ return $args;
+
+ }
+
+
+ /*
+ * add_form
+ *
+ * description
+ *
+ * @type function
+ * @date 28/2/17
+ * @since 5.5.8
+ *
+ * @param $post_id (int)
+ * @return $post_id (int)
+ */
+
+ function add_form( $args = array() ) {
+
+ // validate
+ $args = $this->validate_form( $args );
+
+
+ // append
+ $this->forms[ $args['id'] ] = $args;
+
+ }
+
+
+ /*
+ * get_form
+ *
+ * description
+ *
+ * @type function
+ * @date 28/2/17
+ * @since 5.5.8
+ *
+ * @param $post_id (int)
+ * @return $post_id (int)
+ */
+
+ function get_form( $id = '' ) {
+
+ // bail early if not set
+ if( !isset($this->forms[ $id ]) ) return false;
+
+
+ // return
+ return $this->forms[ $id ];
+
+ }
+
+
+ /*
+ * validate_save_post
+ *
+ * This function will validate fields from the above array
+ *
+ * @type function
+ * @date 7/09/2016
+ * @since 5.4.0
+ *
+ * @param $post_id (int)
+ * @return $post_id (int)
+ */
+
+ function validate_save_post() {
+
+ // register field if isset in $_POST
+ foreach( $this->fields as $k => $field ) {
+
+ // bail early if no in $_POST
+ if( !isset($_POST['acf'][ $k ]) ) continue;
+
+
+ // register
+ acf_add_local_field($field);
+
+ }
+
+
+ // honeypot
+ if( !empty($_POST['acf']['_validate_email']) ) {
+
+ acf_add_validation_error( '', __('Spam Detected', 'acf') );
+
+ }
+
+ }
+
+
+ /*
+ * pre_save_post
+ *
+ * description
+ *
+ * @type function
+ * @date 7/09/2016
+ * @since 5.4.0
+ *
+ * @param $post_id (int)
+ * @return $post_id (int)
+ */
+
+ function pre_save_post( $post_id, $form ) {
+
+ // vars
+ $save = array(
+ 'ID' => 0
+ );
+
+
+ // determine save data
+ if( is_numeric($post_id) ) {
+
+ // update post
+ $save['ID'] = $post_id;
+
+ } elseif( $post_id == 'new_post' ) {
+
+ // merge in new post data
+ $save = array_merge($save, $form['new_post']);
+
+ } else {
+
+ // not post
+ return $post_id;
+
+ }
+
+
+ // save post_title
+ if( isset($_POST['acf']['_post_title']) ) {
+
+ $save['post_title'] = acf_extract_var($_POST['acf'], '_post_title');
+
+ }
+
+
+ // save post_content
+ if( isset($_POST['acf']['_post_content']) ) {
+
+ $save['post_content'] = acf_extract_var($_POST['acf'], '_post_content');
+
+ }
+
+
+ // honeypot
+ if( !empty($_POST['acf']['_validate_email']) ) return false;
+
+
+ // validate
+ if( count($save) == 1 ) {
+
+ return $post_id;
+
+ }
+
+
+ if( $save['ID'] ) {
+
+ wp_update_post( $save );
+
+ } else {
+
+ $post_id = wp_insert_post( $save );
+
+ }
+
+
+ // return
+ return $post_id;
+
+ }
+
+
+ /*
+ * enqueue
+ *
+ * This function will enqueue a form
+ *
+ * @type function
+ * @date 7/09/2016
+ * @since 5.4.0
+ *
+ * @param $post_id (int)
+ * @return $post_id (int)
+ */
+
+ function enqueue_form() {
+
+ // check
+ $this->check_submit_form();
+
+
+ // load acf scripts
+ acf_enqueue_scripts();
+
+ }
+
+
+ /*
+ * check_submit_form
+ *
+ * This function will maybe submit form data
+ *
+ * @type function
+ * @date 3/3/17
+ * @since 5.5.10
+ *
+ * @param n/a
+ * @return n/a
+ */
+
+ function check_submit_form() {
+
+ // bail ealry if form not submit
+ if( !isset($_POST['_acfform']) ) return;
+
+
+ // verify nonce
+ if( !acf_verify_nonce('acf_form') ) return;
+
+
+ // validate data
+ acf_validate_save_post(true);
+
+
+ // submit
+ $this->submit_form();
+
+ }
+
+
+ /*
+ * submit_form
+ *
+ * This function will submit form data
+ *
+ * @type function
+ * @date 3/3/17
+ * @since 5.5.10
+ *
+ * @param n/a
+ * @return n/a
+ */
+
+ function submit_form() {
+
+ // vars
+ $form = @json_decode(acf_decrypt($_POST['_acfform']), true);
+
+
+ // bail ealry if form is corrupt
+ if( empty($form) ) return;
+
+
+ // filter
+ $form = apply_filters('acf/pre_submit_form', $form);
+
+
+ // vars
+ $post_id = acf_maybe_get($form, 'post_id', 0);
+
+
+ // add global for backwards compatibility
+ $GLOBALS['acf_form'] = $form;
+
+
+ // allow for custom save
+ $post_id = apply_filters('acf/pre_save_post', $post_id, $form);
+
+
+ // save
+ acf_save_post( $post_id );
+
+
+ // restore form (potentially modified)
+ $form = $GLOBALS['acf_form'];
+
+
+ // action
+ do_action('acf/submit_form', $form, $post_id);
+
+
+ // vars
+ $return = acf_maybe_get($form, 'return', '');
+
+
+ // redirect
+ if( $return ) {
+
+ // update %placeholders%
+ $return = str_replace('%post_id%', $post_id, $return);
+ $return = str_replace('%post_url%', get_permalink($post_id), $return);
+
+
+ // redirect
+ wp_redirect( $return );
+ exit;
+
+ }
+
+ }
+
+
+ /*
+ * render
+ *
+ * description
+ *
+ * @type function
+ * @date 7/09/2016
+ * @since 5.4.0
+ *
+ * @param $post_id (int)
+ * @return $post_id (int)
+ */
+
+ function render_form( $args = array() ) {
+
+ // array
+ if( is_array($args) ) {
+
+ $args = $this->validate_form( $args );
+
+ // id
+ } else {
+
+ $args = $this->get_form( $args );
+
+ }
+
+
+ // bail early if no args
+ if( !$args ) return false;
+
+
+ // load values from this post
+ $post_id = $args['post_id'];
+
+
+ // dont load values for 'new_post'
+ if( $post_id === 'new_post' ) $post_id = false;
+
+
+ // register local fields
+ foreach( $this->fields as $k => $field ) {
+
+ acf_add_local_field($field);
+
+ }
+
+
+ // vars
+ $field_groups = array();
+ $fields = array();
+
+
+ // post_title
+ if( $args['post_title'] ) {
+
+ // load local field
+ $_post_title = acf_get_field('_post_title');
+ $_post_title['value'] = $post_id ? get_post_field('post_title', $post_id) : '';
+
+
+ // append
+ $fields[] = $_post_title;
+
+ }
+
+
+ // post_content
+ if( $args['post_content'] ) {
+
+ // load local field
+ $_post_content = acf_get_field('_post_content');
+ $_post_content['value'] = $post_id ? get_post_field('post_content', $post_id) : '';
+
+
+ // append
+ $fields[] = $_post_content;
+
+ }
+
+
+ // specific fields
+ if( $args['fields'] ) {
+
+ foreach( $args['fields'] as $selector ) {
+
+ // append field ($strict = false to allow for better compatibility with field names)
+ $fields[] = acf_maybe_get_field( $selector, $post_id, false );
+
+ }
+
+ } elseif( $args['field_groups'] ) {
+
+ foreach( $args['field_groups'] as $selector ) {
+
+ $field_groups[] = acf_get_field_group( $selector );
+
+ }
+
+ } elseif( $args['post_id'] == 'new_post' ) {
+
+ $field_groups = acf_get_field_groups( $args['new_post'] );
+
+ } else {
+
+ $field_groups = acf_get_field_groups(array(
+ 'post_id' => $args['post_id']
+ ));
+
+ }
+
+
+ //load fields based on field groups
+ if( !empty($field_groups) ) {
+
+ foreach( $field_groups as $field_group ) {
+
+ $field_group_fields = acf_get_fields( $field_group );
+
+ if( !empty($field_group_fields) ) {
+
+ foreach( array_keys($field_group_fields) as $i ) {
+
+ $fields[] = acf_extract_var($field_group_fields, $i);
+ }
+
+ }
+
+ }
+
+ }
+
+
+ // honeypot
+ if( $args['honeypot'] ) {
+
+ $fields[] = acf_get_field('_validate_email');
+
+ }
+
+
+ // updated message
+ if( !empty($_GET['updated']) && $args['updated_message'] ) {
+
+ printf( $args['html_updated_message'], $args['updated_message'] );
+
+ }
+
+
+ // uploader (always set incase of multiple forms on the page)
+ acf_update_setting('uploader', $args['uploader']);
+
+
+ // display form
+ if( $args['form'] ): ?>
+
+
+ form = new acf_form();
+
+endif; // class_exists check
+
+
+/*
+* Functions
+*
+* alias of acf()->form->functions
+*
+* @type function
+* @date 11/06/2014
+* @since 5.0.0
+*
+* @param n/a
+* @return n/a
+*/
+
+
+function acf_form_head() {
+
+ acf()->form->enqueue_form();
+
+}
+
+function acf_form( $args = array() ) {
+
+ acf()->form->render_form( $args );
+
+}
+
+function acf_get_form( $id = '' ) {
+
+ acf()->form->get_form( $id );
+
+}
+
+function acf_register_form( $args ) {
+
+ acf()->form->add_form( $args );
+
+}
+
+?>
diff --git a/core/input.php b/core/input.php
index ca9b5e3..db9df89 100644
--- a/core/input.php
+++ b/core/input.php
@@ -456,10 +456,26 @@ function acf_form_data( $args = array() ) {
$args = acf_set_form_data( $args );
+ // hidden inputs
+ $inputs = array(
+ '_acfnonce' => wp_create_nonce($args['nonce']),
+ '_acfchanged' => 0
+ );
+
+
+ // append custom
+ foreach( $args as $k => $v ) {
+
+ if( substr($k, 0, 4) === '_acf' ) $inputs[ $k ] = $v;
+
+ }
+
+
?>
-
-
+ $v ): ?>
+
+
json = new acf_json();
+
+endif; // class_exists check
/*
diff --git a/core/local.php b/core/local.php
index 5a3246d..1f748f6 100644
--- a/core/local.php
+++ b/core/local.php
@@ -7,8 +7,10 @@ if( ! class_exists('acf_local') ) :
class acf_local {
// vars
- var $groups = array(),
+ var $temp = array(),
+ $groups = array(),
$fields = array(),
+ $reference = array(),
$parents = array();
@@ -32,7 +34,7 @@ class acf_local {
// actions
- add_action('acf/delete_field', array($this, 'acf_delete_field'), 20, 1);
+ add_action('acf/include_fields', array($this, 'acf_include_fields'), 5, 0);
// filters
@@ -41,6 +43,35 @@ class acf_local {
}
+ /*
+ * get_key
+ *
+ * This function will check for references and modify the key
+ *
+ * @type function
+ * @date 30/06/2016
+ * @since 5.4.0
+ *
+ * @param $key (string)
+ * @return $key
+ */
+
+ function get_key( $key = '' ) {
+
+ // check for reference
+ if( isset($this->reference[ $key ]) ) {
+
+ $key = $this->reference[ $key ];
+
+ }
+
+
+ // return
+ return $key;
+
+ }
+
+
/*
* reset
*
@@ -57,8 +88,10 @@ class acf_local {
function reset() {
// vars
+ $this->temp = array();
$this->groups = array();
$this->fields = array();
+ $this->reference = array();
$this->parents = array();
}
@@ -160,21 +193,28 @@ class acf_local {
function add_field( $field ) {
- // vars
- $key = acf_maybe_get($field, 'key', '');
- $parent = acf_maybe_get($field, 'parent', '');
+ // defaults
+ $field = wp_parse_args($field, array(
+ 'key' => '',
+ 'name' => '',
+ 'parent' => 0
+ ));
// add parent reference
- $this->add_parent_reference( $parent, $key );
+ $this->add_parent_reference( $field['parent'], $field['key'] );
// add in menu order
- $field['menu_order'] = count( $this->parents[ $parent ] ) - 1;
+ $field['menu_order'] = $this->count_fields( $field['parent'] ) - 1;
// add field
- $this->fields[ $key ] = $field;
+ $this->fields[ $field['key'] ] = $field;
+
+
+ // add reference for field name
+ $this->reference[ $field['name'] ] = $field['key'];
}
@@ -194,6 +234,10 @@ class acf_local {
function is_field( $key = '' ) {
+ // vars
+ $key = $this->get_key($key);
+
+
// bail early if not enabled
if( !$this->is_enabled() ) return false;
@@ -203,6 +247,28 @@ class acf_local {
}
+ function is_field_key( $key ) {
+
+ // bail early if not enabled
+ if( !$this->is_enabled() ) return false;
+
+
+ // return
+ return isset( $this->fields[ $key ] );
+
+ }
+
+ function is_field_name( $name ) {
+
+ // bail early if not enabled
+ if( !$this->is_enabled() ) return false;
+
+
+ // return
+ return isset( $this->reference[ $name ] );
+
+ }
+
/*
* get_field
@@ -219,6 +285,10 @@ class acf_local {
function get_field( $key = '' ) {
+ // vars
+ $key = $this->get_key($key);
+
+
// bail early if no group
if( !$this->is_field($key) ) return false;
@@ -257,19 +327,95 @@ class acf_local {
// remove field
- unset( $this->fields[ $key ] );
+ unset( $this->fields[ $field['key'] ] );
+
+
+ // remove reference for field name
+ unset( $this->reference[ $field['name'] ] );
// remove children
- if( acf_have_local_fields( $key) ) {
+ if( $this->have_fields($key) ) {
- acf_remove_local_fields( $key );
+ $this->remove_fields( $key );
}
}
+ /*
+ * acf_include_fields
+ *
+ * This function include any $temp field groups during the 'acf/include_fields' action
+ *
+ * @type function
+ * @date 8/2/17
+ * @since 5.5.6
+ *
+ * @param n/a
+ * @return n/a
+ */
+
+ function acf_include_fields() {
+
+ // bail ealry if no temp
+ if( empty($this->temp) ) return;
+
+
+ // loop
+ foreach( $this->temp as $i => $temp ) {
+
+ // add
+ $this->add_field_group($temp);
+
+
+ // unset
+ unset($this->temp[ $i ]);
+
+ }
+
+ }
+
+
+ /*
+ * maybe_add_field_group
+ *
+ * This function will determine if it is too early to 'add' a field group and if so will add to $temp
+ * Field groups added to $temp will be included during the 'acf/include_fields' action which ensures all field types exist
+ *
+ * @type function
+ * @date 9/2/17
+ * @since 5.5.6
+ *
+ * @param $post_id (int)
+ * @return $post_id (int)
+ */
+
+ function maybe_add_field_group( $field_group ) {
+
+ // add to temp if too early
+ if( !did_action('acf/include_fields') ) {
+
+ // append
+ $this->temp[] = $field_group;
+
+
+ // return
+ return false;
+ }
+
+
+ // add
+ $this->add_field_group( $field_group );
+
+
+ // return
+ return true;
+
+ }
+
+
/*
* add_field_group
*
@@ -285,6 +431,10 @@ class acf_local {
function add_field_group( $field_group ) {
+ // vars
+ $fields = acf_extract_var($field_group, 'fields');
+
+
// validate
$field_group = acf_get_valid_field_group($field_group);
@@ -293,35 +443,27 @@ class acf_local {
if( $this->is_field_group($field_group['key']) ) return;
- // add local
- if( empty($field_group['local']) ) {
-
- $field_group['local'] = 'php';
-
- }
-
-
- // remove fields
- $fields = acf_extract_var($field_group, 'fields');
-
-
- // format fields
- $fields = acf_prepare_fields_for_import( $fields );
+ // add local (may be set to json)
+ if( empty($field_group['local']) ) $field_group['local'] = 'php';
// add field group
$this->groups[ $field_group['key'] ] = $field_group;
+ // bail ealry if no fields
+ if( !$fields ) return;
+
+
+ // format fields
+ $fields = acf_prepare_fields_for_import( $fields );
+
+
// add fields
foreach( $fields as $field ) {
// add parent
- if( empty($field['parent']) ) {
-
- $field['parent'] = $field_group['key'];
-
- }
+ if( empty($field['parent']) ) $field['parent'] = $field_group['key'];
// add field
@@ -444,7 +586,24 @@ class acf_local {
function get_field_groups() {
- return array_values($this->groups);
+ // bail early if no parent
+ if( !$this->have_field_groups() ) return false;
+
+
+ // vars
+ $field_groups = array();
+
+
+ // append
+ foreach( array_keys($this->groups) as $field_group_key ) {
+
+ $field_groups[] = acf_get_field_group( $field_group_key );
+
+ }
+
+
+ // return
+ return $field_groups;
}
@@ -650,26 +809,6 @@ class acf_local {
}
-
- /*
- * acf_delete_field
- *
- * description
- *
- * @type function
- * @date 10/12/2014
- * @since 5.1.5
- *
- * @param $post_id (int)
- * @return $post_id (int)
- */
-
- function acf_delete_field( $field ) {
-
- $this->remove_field( $field['key'] );
-
- }
-
}
@@ -720,7 +859,7 @@ function acf_reset_local() {
// field group
function acf_add_local_field_group( $field_group ) {
- return acf_local()->add_field_group( $field_group );
+ return acf_local()->maybe_add_field_group( $field_group );
}
@@ -782,6 +921,18 @@ function acf_is_local_field( $key = '' ) {
}
+function acf_is_local_field_key( $key = '' ) {
+
+ return acf_local()->is_field_key( $key );
+
+}
+
+function acf_is_local_field_name( $name = '' ) {
+
+ return acf_local()->is_field_name( $name );
+
+}
+
function acf_get_local_field( $key = '' ) {
return acf_local()->get_field( $key );
@@ -815,4 +966,12 @@ function acf_remove_local_fields( $key = '' ) {
}
+// deprecated
+function register_field_group( $field_group ) {
+
+ acf_add_local_field_group( $field_group );
+
+}
+
+
?>
diff --git a/core/revisions.php b/core/revisions.php
index 6ce61c3..7767047 100644
--- a/core/revisions.php
+++ b/core/revisions.php
@@ -5,7 +5,11 @@ if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if( ! class_exists('acf_revisions') ) :
class acf_revisions {
-
+
+ // vars
+ var $cache = array();
+
+
/*
* __construct
*
@@ -28,6 +32,7 @@ class acf_revisions {
add_filter('wp_save_post_revision_check_for_changes', array($this, 'wp_save_post_revision_check_for_changes'), 10, 3);
add_filter('_wp_post_revision_fields', array($this, 'wp_preview_post_fields'), 10, 2 );
add_filter('_wp_post_revision_fields', array($this, 'wp_post_revision_fields'), 10, 2 );
+ add_filter('acf/validate_post_id', array($this, 'acf_validate_post_id'), 10, 2 );
}
@@ -333,6 +338,80 @@ class acf_revisions {
}
+
+ /*
+ * acf_validate_post_id
+ *
+ * This function will modify the $post_id and allow loading values from a revision
+ *
+ * @type function
+ * @date 6/3/17
+ * @since 5.5.10
+ *
+ * @param $post_id (int)
+ * @param $_post_id (int)
+ * @return $post_id (int)
+ */
+
+ function acf_validate_post_id( $post_id, $_post_id ) {
+
+ // bail early if no preview in URL
+ if( !isset($_GET['preview']) ) return $post_id;
+
+
+ // bail early if $post_id is not numeric
+ if( !is_numeric($post_id) ) return $post_id;
+
+
+ // vars
+ $k = $post_id;
+ $preview_id = 0;
+
+
+ // check cache
+ if( isset($this->cache[$k]) ) return $this->cache[$k];
+
+
+ // validate
+ if( isset($_GET['preview_id']) ) {
+
+ $preview_id = (int) $_GET['preview_id'];
+
+ } elseif( isset($_GET['p']) ) {
+
+ $preview_id = (int) $_GET['p'];
+
+ } elseif( isset($_GET['page_id']) ) {
+
+ $preview_id = (int) $_GET['page_id'];
+
+ }
+
+
+ // bail early id $preview_id does not match $post_id
+ if( $preview_id != $post_id ) return $post_id;
+
+
+ // attempt find revision
+ $revision = acf_get_post_latest_revision( $post_id );
+
+
+ // save
+ if( $revision && $revision->post_parent == $post_id) {
+
+ $post_id = (int) $revision->ID;
+
+ }
+
+
+ // set cache
+ $this->cache[$k] = $post_id;
+
+
+ // return
+ return $post_id;
+
+ }
}
diff --git a/fields/file.php b/fields/file.php
index 469f8ce..6ae173c 100644
--- a/fields/file.php
+++ b/fields/file.php
@@ -52,7 +52,6 @@ class acf_field_file extends acf_field {
// filters
add_filter('get_media_item_args', array($this, 'get_media_item_args'));
- add_filter('wp_prepare_attachment_for_js', array($this, 'wp_prepare_attachment_for_js'), 10, 3);
// do not delete!
@@ -133,9 +132,7 @@ class acf_field_file extends acf_field {
?>
>
-
- $field['name'], 'value' => $field['value'], 'data-name' => 'id' )); ?>
-
+ $field['name'], 'value' => $field['value'], 'data-name' => 'id' )); ?>

@@ -364,16 +361,32 @@ class acf_field_file extends acf_field {
function update_value( $value, $post_id, $field ) {
- // numeric
- if( is_numeric($value) ) return $value;
+ // bail early if is empty
+ if( empty($value) ) return false;
- // array?
- if( is_array($value) && isset($value['ID']) ) return $value['ID'];
+ // validate
+ if( is_array($value) && isset($value['ID']) ) {
+
+ $value = $value['ID'];
+
+ } elseif( is_object($value) && isset($value->ID) ) {
+
+ $value = $value->ID;
+
+ }
- // object?
- if( is_object($value) && isset($value->ID) ) return $value->ID;
+ // bail early if not attachment ID
+ if( !$value || !is_numeric($value) ) return false;
+
+
+ // confirm type
+ $value = (int) $value;
+
+
+ // maybe connect attacment to post
+ acf_connect_attachment_to_post( $value, $post_id );
// return
@@ -382,38 +395,57 @@ class acf_field_file extends acf_field {
}
+
/*
- * wp_prepare_attachment_for_js
+ * validate_value
*
- * this filter allows ACF to add in extra data to an attachment JS object
+ * This function will validate a basic file input
*
* @type function
- * @date 1/06/13
+ * @date 11/02/2014
+ * @since 5.0.0
*
- * @param {int} $post_id
- * @return {int} $post_id
+ * @param $post_id (int)
+ * @return $post_id (int)
*/
- function wp_prepare_attachment_for_js( $response, $attachment, $meta ) {
+ function validate_value( $valid, $value, $field, $input ){
- // default
- $fs = '0 kb';
+ // bail early if empty
+ if( empty($value) ) return $valid;
- // supress PHP warnings caused by corrupt images
- if( $i = @filesize( get_attached_file( $attachment->ID ) ) ) {
+ // bail ealry if is numeric
+ if( is_numeric($value) ) return $valid;
- $fs = size_format( $i );
+
+ // bail ealry if not basic string
+ if( !is_string($value) ) return $valid;
+
+
+ // decode value
+ $file = null;
+ parse_str($value, $file);
+
+
+ // bail early if no attachment
+ if( empty($file) ) return $valid;
+
+
+ // get errors
+ $errors = acf_validate_attachment( $file, $field, 'basic_upload' );
+
+
+ // append error
+ if( !empty($errors) ) {
+
+ $valid = implode("\n", $errors);
}
- // update JSON
- $response['filesize'] = $fs;
-
-
- // return
- return $response;
+ // return
+ return $valid;
}
diff --git a/fields/image.php b/fields/image.php
index 949fe50..330b5d0 100644
--- a/fields/image.php
+++ b/fields/image.php
@@ -132,9 +132,7 @@ class acf_field_image extends acf_field {
?>
>
-
- $field['name'], 'value' => $field['value'] )); ?>
-
+ $field['name'], 'value' => $field['value'] )); ?>
>
@@ -457,20 +455,27 @@ class acf_field_image extends acf_field {
function update_value( $value, $post_id, $field ) {
- // numeric
- if( is_numeric($value) ) return $value;
+ return acf_get_field_type('file')->update_value( $value, $post_id, $field );
+ }
+
+
+ /*
+ * validate_value
+ *
+ * This function will validate a basic file input
+ *
+ * @type function
+ * @date 11/02/2014
+ * @since 5.0.0
+ *
+ * @param $post_id (int)
+ * @return $post_id (int)
+ */
+
+ function validate_value( $valid, $value, $field, $input ){
- // array?
- if( is_array($value) && isset($value['ID']) ) return $value['ID'];
-
-
- // object?
- if( is_object($value) && isset($value->ID) ) return $value->ID;
-
-
- // return
- return $value;
+ return acf_get_field_type('file')->validate_value( $valid, $value, $field, $input );
}
diff --git a/fields/oembed.php b/fields/oembed.php
index 8ce861d..c135b26 100644
--- a/fields/oembed.php
+++ b/fields/oembed.php
@@ -39,15 +39,13 @@ class acf_field_oembed extends acf_field {
'width' => '',
'height' => '',
);
- $this->default_values = array(
- 'width' => 640,
- 'height' => 390
- );
-
+ $this->width = 640;
+ $this->height = 390;
+
// extra
- add_action('wp_ajax_acf/fields/oembed/search', array($this, 'ajax_search'));
- add_action('wp_ajax_nopriv_acf/fields/oembed/search', array($this, 'ajax_search'));
+ add_action('wp_ajax_acf/fields/oembed/search', array($this, 'ajax_query'));
+ add_action('wp_ajax_nopriv_acf/fields/oembed/search', array($this, 'ajax_query'));
// do not delete!
@@ -56,6 +54,32 @@ class acf_field_oembed extends acf_field {
}
+ /*
+ * prepare_field
+ *
+ * This function will prepare the field for input
+ *
+ * @type function
+ * @date 14/2/17
+ * @since 5.5.8
+ *
+ * @param $field (array)
+ * @return (int)
+ */
+
+ function prepare_field( $field ) {
+
+ // defaults
+ if( !$field['width'] ) $field['width'] = $this->width;
+ if( !$field['height'] ) $field['height'] = $this->height;
+
+
+ // return
+ return $field;
+
+ }
+
+
/*
* wp_oembed_get
*
@@ -102,7 +126,7 @@ class acf_field_oembed extends acf_field {
/*
- * ajax_search
+ * ajax_query
*
* description
*
@@ -114,40 +138,62 @@ class acf_field_oembed extends acf_field {
* @return $post_id (int)
*/
- function ajax_search() {
+ function ajax_query() {
// validate
if( !acf_verify_ajax() ) die();
- // options
- $args = acf_parse_args( $_POST, array(
- 's' => '',
- 'width' => 0,
- 'height' => 0,
+ // get choices
+ $response = $this->get_ajax_query( $_POST );
+
+
+ // return
+ wp_send_json($response);
+
+ }
+
+
+ /*
+ * get_ajax_query
+ *
+ * This function will return an array of data formatted for use in a select2 AJAX response
+ *
+ * @type function
+ * @date 15/10/2014
+ * @since 5.0.9
+ *
+ * @param $options (array)
+ * @return (array)
+ */
+
+ function get_ajax_query( $args = array() ) {
+
+ // defaults
+ $args = acf_parse_args($args, array(
+ 's' => '',
+ 'field_key' => '',
));
- // width and height
- if( !$args['width'] ) {
-
- $args['width'] = $this->default_values['width'];
-
- }
-
- if( !$args['height'] ) {
-
- $args['height'] = $this->default_values['height'];
-
- }
+ // load field
+ $field = acf_get_field( $args['field_key'] );
+ if( !$field ) return false;
- // get oembed
- echo $this->wp_oembed_get($args['s'], $args['width'], $args['height']);
+ // prepare field to correct width and height
+ $field = $this->prepare_field($field);
- // die
- die();
+ // vars
+ $response = array(
+ 'url' => $args['s'],
+ 'html' => $this->wp_oembed_get($args['s'], $field['width'], $field['height'])
+ );
+
+
+ // return
+ return $response;
}
@@ -166,30 +212,14 @@ class acf_field_oembed extends acf_field {
function render_field( $field ) {
- // default options
- foreach( $this->default_values as $k => $v ) {
-
- if( empty($field[ $k ]) ) {
-
- $field[ $k ] = $v;
-
- }
-
- }
-
-
// atts
$atts = array(
- 'class' => 'acf-oembed',
- 'data-width' => $field['width'],
- 'data-height' => $field['height']
+ 'class' => 'acf-oembed',
);
- if( $field['value'] ) {
- $atts['class'] .= ' has-value';
-
- }
+ // value
+ if( $field['value'] ) $atts['class'] .= ' has-value';
?>
>
@@ -221,15 +251,12 @@ class acf_field_oembed extends acf_field {
-
- wp_oembed_get($field['value'], $field['width'], $field['height']); ?>
-
+ wp_oembed_get($field['value'], $field['width'], $field['height']); ?>
-
'width',
'prepend' => __('Width', 'acf'),
'append' => 'px',
- 'placeholder' => $this->default_values['width']
+ 'placeholder' => $this->width
));
@@ -269,7 +296,7 @@ class acf_field_oembed extends acf_field {
'name' => 'height',
'prepend' => __('Height', 'acf'),
'append' => 'px',
- 'placeholder' => $this->default_values['height'],
+ 'placeholder' => $this->height,
'_append' => 'width'
));
@@ -295,11 +322,11 @@ class acf_field_oembed extends acf_field {
function format_value( $value, $post_id, $field ) {
// bail early if no value
- if( empty($value) ) {
-
- return $value;
+ if( empty($value) ) return $value;
- }
+
+ // prepare field to correct width and height
+ $field = $this->prepare_field($field);
// get oembed
diff --git a/fields/select.php b/fields/select.php
index 2ad0d48..de53357 100644
--- a/fields/select.php
+++ b/fields/select.php
@@ -103,6 +103,15 @@ class acf_field_select extends acf_field {
$style = '';
+ // attempt to find 3rd party Select2 version
+ // - avoid including v3 CSS when v4 JS is already enququed
+ if( isset($wp_scripts->registered['select2']) ) {
+
+ $major = (int) $wp_scripts->registered['select2']->ver;
+
+ }
+
+
// v4
if( $major == 4 ) {
diff --git a/fields/true_false.php b/fields/true_false.php
index 2815bfd..6cd2c68 100644
--- a/fields/true_false.php
+++ b/fields/true_false.php
@@ -97,7 +97,7 @@ class acf_field_true_false extends acf_field {
// update input
$input['class'] .= ' acf-switch-input';
- $input['style'] = 'display:none;';
+ //$input['style'] = 'display:none;';
$switch .= '
';
$switch .= ''.$field['ui_on_text'].'';
diff --git a/fields/user.php b/fields/user.php
index 762bf61..b1a0782 100644
--- a/fields/user.php
+++ b/fields/user.php
@@ -72,8 +72,33 @@ class acf_field_user extends acf_field {
if( !acf_verify_ajax() ) die();
+ // get choices
+ $response = $this->get_ajax_query( $_POST );
+
+
+ // return
+ acf_send_ajax_results($response);
+
+ }
+
+
+ /*
+ * get_ajax_query
+ *
+ * This function will return an array of data formatted for use in a select2 AJAX response
+ *
+ * @type function
+ * @date 15/10/2014
+ * @since 5.0.9
+ *
+ * @param $options (array)
+ * @return (array)
+ */
+
+ function get_ajax_query( $options = array() ) {
+
// defaults
- $options = acf_parse_args($_POST, array(
+ $options = acf_parse_args($options, array(
'post_id' => 0,
's' => '',
'field_key' => '',
@@ -81,6 +106,11 @@ class acf_field_user extends acf_field {
));
+ // load field
+ $field = acf_get_field( $options['field_key'] );
+ if( !$field ) return false;
+
+
// vars
$results = array();
$args = array();
@@ -107,11 +137,6 @@ class acf_field_user extends acf_field {
}
- // load field
- $field = acf_get_field( $options['field_key'] );
- if( !$field ) die();
-
-
// role
if( !empty($field['role']) ) {
@@ -203,11 +228,15 @@ class acf_field_user extends acf_field {
}
- // return
- acf_send_ajax_results(array(
+ // vars
+ $response = array(
'results' => $results,
'limit' => $args['users_per_page']
- ));
+ );
+
+
+ // return
+ return $response;
}
diff --git a/forms/taxonomy.php b/forms/taxonomy.php
index dabb24c..4962831 100644
--- a/forms/taxonomy.php
+++ b/forms/taxonomy.php
@@ -136,10 +136,7 @@ class acf_form_taxonomy {
function add_term( $taxonomy ) {
// vars
- $post_id = "{$taxonomy}_0";
- $args = array(
- 'taxonomy' => $taxonomy
- );
+ $post_id = acf_get_term_post_id( $taxonomy, 0 );
// update vars
@@ -147,17 +144,22 @@ class acf_form_taxonomy {
// get field groups
- $field_groups = acf_get_field_groups( $args );
+ $field_groups = acf_get_field_groups(array(
+ 'taxonomy' => $taxonomy
+ ));
// render
if( !empty($field_groups) ) {
+ // data
acf_form_data(array(
'post_id' => $post_id,
'nonce' => 'taxonomy',
));
+
+ // loop
foreach( $field_groups as $field_group ) {
$fields = acf_get_fields( $field_group );
@@ -187,10 +189,7 @@ class acf_form_taxonomy {
function edit_term( $term, $taxonomy ) {
// vars
- $post_id = "{$taxonomy}_{$term->term_id}";
- $args = array(
- 'taxonomy' => $taxonomy
- );
+ $post_id = acf_get_term_post_id( $term->taxonomy, $term->term_id );
// update vars
@@ -198,7 +197,9 @@ class acf_form_taxonomy {
// get field groups
- $field_groups = acf_get_field_groups( $args );
+ $field_groups = acf_get_field_groups(array(
+ 'taxonomy' => $taxonomy
+ ));
// render
@@ -386,6 +387,10 @@ class acf_form_taxonomy {
function save_term( $term_id, $tt_id, $taxonomy ) {
+ // vars
+ $post_id = acf_get_term_post_id( $taxonomy, $term_id );
+
+
// verify and remove nonce
if( !acf_verify_nonce('taxonomy') ) return $term_id;
@@ -395,7 +400,7 @@ class acf_form_taxonomy {
// save
- acf_save_post('term_' . $term_id);
+ acf_save_post( $post_id );
}
@@ -449,4 +454,5 @@ new acf_form_taxonomy();
endif;
+
?>
diff --git a/forms/widget.php b/forms/widget.php
index b3a2c23..a758d46 100644
--- a/forms/widget.php
+++ b/forms/widget.php
@@ -136,11 +136,13 @@ class acf_form_widget {
$fields = acf_get_fields( $field_group );
- acf_render_fields( $post_id, $fields, 'div', 'field' );
+ acf_render_fields( $post_id, $fields, 'div', $field_group['instruction_placement'] );
}
+ // jQuery selector looks odd, but is necessary due to WP adding an incremental number into the ID
+ // - not possible to find number via PHP parameters
if( $widget->updated ): ?>