This commit is contained in:
Elliot Condon 2016-03-17 11:48:39 +01:00 committed by Remco Tolsma
parent 305ba91752
commit 70bb406dd0
37 changed files with 2039 additions and 1207 deletions

13
acf.php
View File

@ -3,7 +3,7 @@
Plugin Name: Advanced Custom Fields Pro
Plugin URI: http://www.advancedcustomfields.com/
Description: Customise WordPress with powerful, professional and intuitive fields
Version: 5.3.5
Version: 5.3.6.1
Author: elliot condon
Author URI: http://www.elliotcondon.com/
Copyright: Elliot Condon
@ -17,9 +17,6 @@ if( ! class_exists('acf') ) :
class acf {
// vars
var $settings;
/*
* __construct
@ -61,7 +58,7 @@ class acf {
// basic
'name' => __('Advanced Custom Fields', 'acf'),
'version' => '5.3.5',
'version' => '5.3.6.1',
// urls
'basename' => plugin_basename( __FILE__ ),
@ -82,9 +79,7 @@ class acf {
'uploader' => 'wp',
'autoload' => false,
'l10n' => true,
'l10n_textdomain' => '',
'l10n_field' => array('label', 'instructions'),
'l10n_field_group' => array('title'),
'l10n_textdomain' => ''
);
@ -103,9 +98,11 @@ class acf {
acf_include('core/ajax.php');
acf_include('core/field.php');
acf_include('core/input.php');
acf_include('core/validation.php');
acf_include('core/json.php');
acf_include('core/local.php');
acf_include('core/location.php');
acf_include('core/loop.php');
acf_include('core/media.php');
acf_include('core/revisions.php');
acf_include('core/compatibility.php');

View File

@ -638,14 +638,18 @@ if( typeof acf !== 'undefined' ) {
*/
case "post_type" :
// get post types
$choices = acf_get_pretty_post_types();
// all post types except attachment
$exclude = array('attachment');
$choices = acf_get_post_types( $exclude );
$choices = acf_get_pretty_post_types( $choices );
// remove attachments
unset( $choices['attachment'] );
// end
break;
case "post" :
@ -802,9 +806,10 @@ if( typeof acf !== 'undefined' ) {
case "page_template" :
$choices = array(
'default' => __("Default Template",'acf'),
'default' => apply_filters( 'default_page_template_title', __('Default Template', 'acf') ),
);
$templates = get_page_templates();
foreach( $templates as $k => $v ) {
@ -900,8 +905,17 @@ if( typeof acf !== 'undefined' ) {
case "comment" :
$choices = array('all' => __('All', 'acf'));
// vars
$choices = array(
'all' => __('All', 'acf')
);
// append post types
$choices = array_merge( $choices, acf_get_pretty_post_types() );
// end
break;

View File

@ -619,7 +619,7 @@ class acf_admin_field_groups {
<div class="acf-column-2">
<div class="acf-box">
<div class="inner">
<h2><?php echo acf_get_setting('name'); ?> <?php echo acf_get_setting('version'); ?></h2>
<h2><?php echo acf_get_setting('name'); ?></h2>
<h3><?php _e("Changelog",'acf'); ?></h3>
<p><?php _e("See what's new in",'acf'); ?> <a href="<?php echo admin_url('edit.php?post_type=acf-field-group&page=acf-settings-info&tab=changelog'); ?>"><?php _e("version",'acf'); ?> <?php echo acf_get_setting('version'); ?></a>

View File

@ -70,14 +70,53 @@ function acf_get_valid_field_group( $field_group = false ) {
));
// translate
$field_group = acf_translate_keys( $field_group, acf_get_setting('l10n_field_group') );
// filter
$field_group = apply_filters('acf/get_valid_field_group', $field_group);
// translate
$field_group = acf_translate_field_group( $field_group );
// return
return $field_group;
}
/*
* acf_translate_field_group
*
* This function will translate field group's settings
*
* @type function
* @date 8/03/2016
* @since 5.3.2
*
* @param $field_group (array)
* @return $field_group
*/
function acf_translate_field_group( $field_group ) {
// vars
$l10n = acf_get_setting('l10n');
$l10n_textdomain = acf_get_setting('l10n_textdomain');
// if
if( $l10n && $l10n_textdomain ) {
// translate
$field_group['title'] = acf_translate( $field_group['title'] );
// filters
$field_group = apply_filters( "acf/translate_field_group", $field_group );
}
// return
return $field_group;

View File

@ -177,10 +177,6 @@ function acf_get_valid_field( $field = false ) {
$field['_name'] = $field['name'];
// translate
$field = acf_translate_keys( $field, acf_get_setting('l10n_field') );
// field specific defaults
$field = apply_filters( "acf/get_valid_field", $field );
$field = apply_filters( "acf/get_valid_field/type={$field['type']}", $field );
@ -190,11 +186,58 @@ function acf_get_valid_field( $field = false ) {
$field['_valid'] = 1;
// translate
$field = acf_translate_field( $field );
// return
return $field;
}
/*
* acf_translate_field
*
* This function will translate field's settings
*
* @type function
* @date 8/03/2016
* @since 5.3.2
*
* @param $field (array)
* @return $field
*/
function acf_translate_field( $field ) {
// vars
$l10n = acf_get_setting('l10n');
$l10n_textdomain = acf_get_setting('l10n_textdomain');
// if
if( $l10n && $l10n_textdomain ) {
// translate
$field['label'] = acf_translate( $field['label'] );
$field['instructions'] = acf_translate( $field['instructions'] );
// filters
$field = apply_filters( "acf/translate_field", $field );
$field = apply_filters( "acf/translate_field/type={$field['type']}", $field );
}
// return
return $field;
}
/*
* acf_prepare_field
*
@ -1855,4 +1898,5 @@ function acf_get_sub_field( $selector, $field ) {
}
?>

View File

@ -574,6 +574,34 @@ function acf_extract_vars( &$array, $keys ) {
}
/*
* acf_get_sub_array
*
* This function will return a sub array of data
*
* @type function
* @date 15/03/2016
* @since 5.3.2
*
* @param $post_id (int)
* @return $post_id (int)
*/
function acf_get_sub_array( $array, $keys ) {
$r = array();
foreach( $keys as $key ) {
$r[ $key ] = $array[ $key ];
}
return $r;
}
/*
* acf_get_post_types
*
@ -2325,7 +2353,7 @@ function acf_encode_choices( $array = array(), $show_keys = true ) {
}
function acf_decode_choices( $string = '' ) {
function acf_decode_choices( $string = '', $array_keys = false ) {
// bail early if already array
if( is_array($string) ) {
@ -2383,6 +2411,14 @@ function acf_decode_choices( $string = '' ) {
}
// return only array keys? (good for checkbox default_value)
if( $array_keys ) {
return array_keys($array);
}
// return
return $array;
@ -2649,18 +2685,19 @@ function acf_in_array( $value, $array ) {
function acf_get_valid_post_id( $post_id = 0 ) {
// set post_id to global
// if not $post_id, load queried object
if( !$post_id ) {
// try for global post (needed for setup_postdata)
$post_id = (int) get_the_ID();
}
// allow for option == options
if( $post_id == 'option' ) {
$post_id = 'options';
// try for current screen
if( !$post_id ) {
$post_id = get_queried_object();
}
}
@ -2668,27 +2705,44 @@ function acf_get_valid_post_id( $post_id = 0 ) {
// $post_id may be an object
if( is_object($post_id) ) {
// user
if( isset($post_id->roles, $post_id->ID) ) {
$post_id = 'user_' . $post_id->ID;
// term
} elseif( isset($post_id->taxonomy, $post_id->term_id) ) {
$post_id = $post_id->taxonomy . '_' . $post_id->term_id;
// comment
} elseif( isset($post_id->comment_ID) ) {
$post_id = 'comment_' . $post_id->comment_ID;
// post
} elseif( isset($post_id->ID) ) {
$post_id = $post_id->ID;
// default
} else {
$post_id = 0;
}
}
// allow for option == options
if( $post_id === 'option' ) {
$post_id = 'options';
}
// append language code
if( $post_id == 'options' ) {
@ -3658,6 +3712,7 @@ function _acf_settings_uploader( $uploader ) {
* @return $post_id (int)
*/
/*
function acf_translate_keys( $array, $keys ) {
// bail early if no keys
@ -3681,6 +3736,7 @@ function acf_translate_keys( $array, $keys ) {
return $array;
}
*/
/*
@ -3767,6 +3823,49 @@ function acf_maybe_add_action( $tag, $function_to_add, $priority = 10, $accepted
}
/*
* acf_is_row_collapsed
*
* This function will return true if the field's row is collapsed
*
* @type function
* @date 2/03/2016
* @since 5.3.2
*
* @param $post_id (int)
* @return $post_id (int)
*/
function acf_is_row_collapsed( $field_key = '', $row_index = 0 ) {
// collapsed
$collapsed = acf_get_user_setting('collapsed_' . $field_key, '');
// cookie fallback ( version < 5.3.2 )
if( $collapsed === '' ) {
$collapsed = acf_extract_var($_COOKIE, "acf_collapsed_{$field_key}", '');
$collapsed = str_replace('|', ',', $collapsed);
// update
acf_update_user_setting( 'collapsed_' . $field_key, $collapsed );
}
// explode
$collapsed = explode(',', $collapsed);
$collapsed = array_filter($collapsed, 'is_numeric');
// collapsed class
return in_array($row_index, $collapsed);
}
/*
* Hacks
*

View File

@ -22,35 +22,6 @@ function acf_get_field_reference( $field_name, $post_id ) {
}
/*
* the_field()
*
* This function is the same as echo get_field().
*
* @type function
* @since 1.0.3
* @date 29/01/13
*
* @param $selector (string) the field name or key
* @param $post_id (mixed) the post_id of which the value is saved against
* @return n/a
*/
function the_field( $selector, $post_id = false, $format_value = true ) {
$value = get_field($selector, $post_id, $format_value);
if( is_array($value) ) {
$value = @implode( ', ', $value );
}
echo $value;
}
/*
* get_field()
*
@ -113,6 +84,35 @@ function get_field( $selector, $post_id = false, $format_value = true ) {
}
/*
* the_field()
*
* This function is the same as echo get_field().
*
* @type function
* @since 1.0.3
* @date 29/01/13
*
* @param $selector (string) the field name or key
* @param $post_id (mixed) the post_id of which the value is saved against
* @return n/a
*/
function the_field( $selector, $post_id = false, $format_value = true ) {
$value = get_field($selector, $post_id, $format_value);
if( is_array($value) ) {
$value = @implode( ', ', $value );
}
echo $value;
}
/*
* get_field_object()
*
@ -132,11 +132,7 @@ function get_field( $selector, $post_id = false, $format_value = true ) {
function get_field_object( $selector, $post_id = false, $format_value = true, $load_value = true ) {
// compatibilty
if( is_array($format_value) ) {
extract( $format_value );
}
if( is_array($format_value) ) extract( $format_value );
// get valid post_id
@ -148,11 +144,7 @@ function get_field_object( $selector, $post_id = false, $format_value = true, $l
// bail early if no field found
if( !$field ) {
return false;
}
if( !$field ) return false;
// load value
@ -197,23 +189,24 @@ function get_fields( $post_id = false, $format_value = true ) {
// vars
$fields = get_field_objects( $post_id, $format_value );
$return = array();
$meta = array();
// bail early
if( !$fields ) return false;
// populate
if( is_array($fields) ) {
foreach( $fields as $k => $field ) {
foreach( $fields as $k => $field ) {
$return[ $k ] = $field['value'];
}
$meta[ $k ] = $field['value'];
}
// return
return $return;
return $meta;
}
@ -287,30 +280,18 @@ function get_field_objects( $post_id = false, $format_value = true, $load_value
// bail early if no meta
if( empty($meta) ) {
return false;
}
if( empty($meta) ) return false;
// populate vars
foreach( $meta as $k => $v ) {
// Hopefuly improve efficiency: bail early if $k does start with an '_'
if( $k[0] === '_' ) {
continue;
}
if( $k[0] === '_' ) continue;
// does a field key exist for this value?
if( !array_key_exists("_{$k}", $meta) ) {
continue;
}
if( !array_key_exists("_{$k}", $meta) ) continue;
// get field
@ -319,11 +300,7 @@ function get_field_objects( $post_id = false, $format_value = true, $load_value
// bail early if not a parent field
if( !$field || acf_is_sub_field($field) ) {
continue;
}
if( !$field || acf_is_sub_field($field) ) continue;
// load value
@ -350,11 +327,7 @@ function get_field_objects( $post_id = false, $format_value = true, $load_value
// no value
if( empty($fields) ) {
return false;
}
if( empty($fields) ) return false;
// return
@ -380,11 +353,13 @@ function get_field_objects( $post_id = false, $format_value = true, $load_value
function have_rows( $selector, $post_id = false ) {
// vars
$row = array();
$active_loop = acf_get_loop('active');
$previous_loop = acf_get_loop('previous');
$new_parent_loop = false;
$new_child_loop = false;
$sub_field = false;
$sub_exists = false;
$change = false;
// reference
@ -396,29 +371,19 @@ function have_rows( $selector, $post_id = false ) {
// empty?
if( empty($GLOBALS['acf_field']) ) {
// reset
reset_rows( true );
if( !$active_loop ) {
// create a new loop
$new_parent_loop = true;
} else {
// vars
$row = end( $GLOBALS['acf_field'] );
$prev = prev( $GLOBALS['acf_field'] );
$change = false;
// detect change
if( $post_id != $row['post_id'] ) {
if( $post_id != $active_loop['post_id'] ) {
$change = 'post_id';
} elseif( $selector != $row['selector'] ) {
} elseif( $selector != $active_loop['selector'] ) {
$change = 'selector';
@ -428,11 +393,11 @@ function have_rows( $selector, $post_id = false ) {
// attempt to find sub field
if( $change ) {
$sub_field = acf_get_sub_field($selector, $row['field']);
$sub_field = acf_get_sub_field($selector, $active_loop['field']);
if( $sub_field ) {
$sub_exists = isset($row['value'][ $row['i'] ][ $sub_field['key'] ]);
$sub_exists = isset( $active_loop['value'][ $active_loop['i'] ][ $sub_field['key'] ] );
}
@ -448,11 +413,11 @@ function have_rows( $selector, $post_id = false ) {
// action: move down one level into a new loop
$new_child_loop = true;
} elseif( $prev && $prev['post_id'] == $post_id ) {
} elseif( $previous_loop && $previous_loop['post_id'] == $post_id ) {
// case: Change in $post_id was due to a nested loop ending
// action: move up one level through the loops
reset_rows();
acf_remove_loop('active');
} else {
@ -464,11 +429,11 @@ function have_rows( $selector, $post_id = false ) {
} elseif( $change == 'selector' ) {
if( $prev && $prev['selector'] == $selector && $prev['post_id'] == $post_id ) {
if( $previous_loop && $previous_loop['selector'] == $selector && $previous_loop['post_id'] == $post_id ) {
// case: Change in $field_name was due to a nested loop ending
// action: move up one level through the loops
reset_rows();
acf_remove_loop('active');
} elseif( $sub_exists ) {
@ -489,6 +454,7 @@ function have_rows( $selector, $post_id = false ) {
}
// add parent loop
if( $new_parent_loop ) {
// vars
@ -496,40 +462,42 @@ function have_rows( $selector, $post_id = false ) {
$value = acf_extract_var( $field, 'value' );
// add row
$GLOBALS['acf_field'][] = array(
// add loop
acf_add_loop(array(
'selector' => $selector,
'name' => $field['name'], // used by update_sub_field
'value' => $value,
'field' => $field,
'i' => -1,
'post_id' => $post_id,
);
));
// add child loop
} elseif( $new_child_loop ) {
// vars
$value = $row['value'][ $row['i'] ][ $sub_field['key'] ];
$value = $active_loop['value'][ $active_loop['i'] ][ $sub_field['key'] ];
$GLOBALS['acf_field'][] = array(
// add loop
acf_add_loop(array(
'selector' => $selector,
'name' => $row['name'] . '_' . $row['i'], // used by update_sub_field
'name' => $active_loop['name'] . '_' . $active_loop['i'], // used by update_sub_field
'value' => $value,
'field' => $sub_field,
'i' => -1,
'post_id' => $post_id,
);
));
}
// update vars
$row = end( $GLOBALS['acf_field'] );
$active_loop = acf_get_loop('active');
// return true if next row exists
if( is_array($row['value']) && array_key_exists($row['i']+1, $row['value']) ) {
if( $active_loop && is_array($active_loop['value']) && isset($active_loop['value'][ $active_loop['i']+1 ]) ) {
return true;
@ -537,7 +505,7 @@ function have_rows( $selector, $post_id = false ) {
// no next row!
reset_rows();
acf_remove_loop('active');
// return
@ -562,11 +530,15 @@ function have_rows( $selector, $post_id = false ) {
function the_row( $format = false ) {
// vars
$depth = count($GLOBALS['acf_field']) - 1;
$i = acf_get_loop('active', 'i');
// increase i of current row
$GLOBALS['acf_field'][ $depth ]['i']++;
// increase
$i++;
// update
acf_update_loop('active', 'i', $i);
// return
@ -577,19 +549,15 @@ function the_row( $format = false ) {
function get_row( $format = false ) {
// vars
$row = acf_get_row();
$loop = acf_get_loop('active');
// bail early if no row
if( !$row ) {
return false;
}
// bail early if no loop
if( !$loop ) return false;
// get value
$value = $row['value'][ $row['i'] ];
$value = $loop['value'][ $loop['i'] ];
// format
@ -598,8 +566,10 @@ function get_row( $format = false ) {
// temp wrap value in array
$value = array( $value );
// format the value (1 row of data)
$value = acf_format_value( $value, $row['post_id'], $row['field'] );
$value = acf_format_value( $value, $loop['post_id'], $loop['field'] );
// extract value from array
$value = $value[0];
@ -612,33 +582,14 @@ function get_row( $format = false ) {
}
function acf_get_row() {
// check and return row
if( !empty($GLOBALS['acf_field']) ) {
return end( $GLOBALS['acf_field'] );
}
// return
return false;
}
function get_row_index() {
// vars
$row = acf_get_row();
// bail early if no row
if( !$row ) return 0;
$i = acf_get_loop('active', 'i');
// return
return $row['i'] + 1;
return $i + 1;
}
@ -657,34 +608,15 @@ function get_row_index() {
* @return (boolean)
*/
function reset_rows( $hard_reset = false ) {
function reset_rows() {
// completely destroy?
if( $hard_reset ) {
$GLOBALS['acf_field'] = array();
// reset current row
} else {
// vars
$depth = count( $GLOBALS['acf_field'] ) - 1;
// remove
unset( $GLOBALS['acf_field'][$depth] );
// refresh index
$GLOBALS['acf_field'] = array_values($GLOBALS['acf_field']);
}
// remove last loop
acf_remove_loop('active');
// return
return true;
}
@ -746,7 +678,7 @@ function has_sub_fields( $field_name, $post_id = false ) {
function get_sub_field( $selector, $format_value = true ) {
// vars
$row = acf_get_row();
$row = acf_get_loop('active');
// bail early if no row
@ -842,7 +774,7 @@ function the_sub_field( $field_name, $format_value = true ) {
function get_sub_field_object( $selector, $format_value = true, $load_value = true ) {
// vars
$row = acf_get_row();
$row = acf_get_loop('active');
// bail early if no row
@ -975,6 +907,11 @@ function acf_form_head() {
// verify nonce
if( acf_verify_nonce('acf_form') ) {
// add actions
add_action('acf/validate_save_post', '_validate_save_post');
add_filter('acf/pre_save_post', '_acf_pre_save_post', 5, 2);
// validate data
if( acf_validate_save_post(true) ) {
@ -1041,8 +978,6 @@ function acf_form_head() {
* @return $post_id (int)
*/
add_action('acf/validate_save_post', '_validate_save_post');
function _validate_save_post() {
// save post_title
@ -1086,8 +1021,6 @@ function _validate_save_post() {
* @return $post_id (int)
*/
add_filter('acf/pre_save_post', '_acf_pre_save_post', 5, 2);
function _acf_pre_save_post( $post_id, $form ) {
// vars
@ -1491,7 +1424,7 @@ function update_sub_field( $selector, $value, $post_id = false ) {
if( is_string($selector) ) {
// get current row
$row = acf_get_row();
$row = acf_get_loop('active');
// override $post_id
@ -1828,139 +1761,6 @@ function delete_row( $selector, $row = 1, $post_id = false ) {
}
/*
* create_field()
*
* This function will creat the HTML for a field
*
* @type function
* @since 4.0.0
* @date 17/03/13
*
* @param array $field - an array containing all the field attributes
*
* @return N/A
*/
function create_field( $field ) {
acf_render_field( $field );
}
function render_field( $field ) {
acf_render_field( $field );
}
/*
* acf_convert_field_names_to_keys()
*
* Helper for the update_field function
*
* @type function
* @since 4.0.0
* @date 17/03/13
*
* @param array $value: the value returned via get_field
* @param array $field: the field or layout to find sub fields from
*
* @return N/A
*/
function acf_convert_field_names_to_keys( $value, $field ) {
// only if $field has sub fields
if( !isset($field['sub_fields']) ) {
return $value;
}
// define sub field keys
$sub_fields = array();
if( $field['sub_fields'] ) {
foreach( $field['sub_fields'] as $sub_field ) {
$sub_fields[ $sub_field['name'] ] = $sub_field;
}
}
// loop through the values and format the array to use sub field keys
if( is_array($value) ) {
foreach( $value as $row_i => $row) {
if( $row ) {
foreach( $row as $sub_field_name => $sub_field_value ) {
// sub field must exist!
if( !isset($sub_fields[ $sub_field_name ]) ) {
continue;
}
// vars
$sub_field = $sub_fields[ $sub_field_name ];
$sub_field_value = acf_convert_field_names_to_keys( $sub_field_value, $sub_field );
// set new value
$value[$row_i][ $sub_field['key'] ] = $sub_field_value;
// unset old value
unset( $value[$row_i][$sub_field_name] );
}
// foreach( $row as $sub_field_name => $sub_field_value )
}
// if( $row )
}
// foreach( $value as $row_i => $row)
}
// if( $value )
// return
return $value;
}
/*
* register_field_group
*
* description
*
* @type function
* @date 11/03/2014
* @since 5.0.0
*
* @param $post_id (int)
* @return $post_id (int)
*/
function register_field_group( $field_group ) {
// add local
acf_add_local_field_group( $field_group );
}
/*
* Depreceated Functions
*
@ -1974,6 +1774,24 @@ function register_field_group( $field_group ) {
* @return n/a
*/
function register_field_group( $field_group ) {
acf_add_local_field_group( $field_group );
}
function create_field( $field ) {
acf_render_field( $field );
}
function render_field( $field ) {
acf_render_field( $field );
}
function reset_the_repeater_field() {
return reset_rows();

View File

@ -575,32 +575,44 @@ a.acf-icon.-cancel.grey:hover {
position: relative;
display: block;
background: #F55E4F;
border-radius: 3px;
margin: 5px 0 15px;
padding: 1px 10px;
padding: 1px 12px;
min-height: 0px;
border-left: #dd4232 solid 4px;
}
.acf-error-message p {
font-size: 13px !important;
line-height: 1.4;
margin: 8px 0;
padding: 0;
line-height: 1.5;
margin: 0.5em 0;
padding: 2px;
text-shadow: none;
color: #fff;
text-shadow: 0 1px 0 #DD4232;
}
.acf-error-message .acf-icon {
position: absolute;
top: 8px;
right: 10px;
top: 9px;
right: 12px;
background-color: #dd4232;
border-color: transparent;
color: #fff;
}
.acf-error-message .acf-icon:hover {
background-color: #F1F1F1;
/* important to include .-cancel to override .acf-icon.-cancel class */
.acf-error-message .acf-icon.-cancel:hover {
background-color: #191e23;
color: #F55E4F;
}
/* success */
.acf-error-message.-success {
background-color: #46b450;
border-color: #32973b;
}
.acf-error-message.-success .acf-icon {
background-color: #32973b;
}
.acf-error-message.-success .acf-icon.-cancel:hover {
background-color: #191e23;
color: #46b450;
}
/*--------------------------------------------------------------------------------------------
*
* acf-table

View File

@ -47,6 +47,8 @@
color: #fff;
margin: 0 0 10px;
display: inline-block;
border-radius: 3px;
border-left: none;
}
.acf-field .acf-error-message:after {
content: "";
@ -1347,6 +1349,7 @@ html[dir="rtl"] .acf-image-uploader .view {
display: block;
padding: 0;
margin: 0;
max-width: 48px;
}
.acf-file-uploader .file-info {
padding: 10px;
@ -1361,21 +1364,19 @@ html[dir="rtl"] .acf-image-uploader .view {
.acf-file-uploader .file-info a {
text-decoration: none;
}
/*
* Hover
*/
.acf-file-uploader .acf-soh-target {
.acf-file-uploader .file-info ul {
position: absolute;
top: 5px;
right: 5px;
/* rtl */
}
html[dir="rtl"] .acf-file-uploader .acf-soh-target {
.acf-file-uploader .file-info ul li {
margin: 0 0 0 4px;
}
html[dir="rtl"] .acf-file-uploader .file-info ul {
right: auto;
left: 5px;
}
.acf-file-uploader .acf-soh-target li {
margin: 0 0 0 4px;
}
/*---------------------------------------------------------------------------------------------
*
* Date Picker

View File

@ -15,7 +15,8 @@
addFilter : addFilter,
removeAction : removeAction,
doAction : doAction,
addAction : addAction
addAction : addAction,
storage : getStorage
};
/**
@ -26,7 +27,13 @@
actions : {},
filters : {}
};
function getStorage() {
return STORAGE;
};
/**
* Adds an action to the event manager.
*
@ -397,17 +404,38 @@ var acf;
add_action: function() {
// allow multiple action parameters such as 'ready append'
var actions = arguments[0].split(' ');
// vars
var a = arguments[0].split(' '),
l = a.length;
for( k in actions ) {
// prefix action
arguments[0] = 'acf.' + actions[ k ];
// loop
for( var i = 0; i < l; i++) {
/*
// allow for special actions
if( a[i].indexOf('initialize') !== -1 ) {
a.push( a[i].replace('initialize', 'ready') );
a.push( a[i].replace('initialize', 'append') );
l = a.length;
continue;
}
*/
// prefix action
arguments[0] = 'acf/' + a[i];
// add
wp.hooks.addAction.apply(this, arguments);
}
// return
return this;
},
@ -429,7 +457,7 @@ var acf;
remove_action: function() {
// prefix action
arguments[0] = 'acf.' + arguments[0];
arguments[0] = 'acf/' + arguments[0];
wp.hooks.removeAction.apply(this, arguments);
@ -451,10 +479,10 @@ var acf;
* @return
*/
do_action: function() {
do_action: function() { //console.log('acf.do_action(%o)', arguments);
// prefix action
arguments[0] = 'acf.' + arguments[0];
arguments[0] = 'acf/' + arguments[0];
wp.hooks.doAction.apply(this, arguments);
@ -479,7 +507,7 @@ var acf;
add_filter: function() {
// prefix action
arguments[0] = 'acf.' + arguments[0];
arguments[0] = 'acf/' + arguments[0];
wp.hooks.addFilter.apply(this, arguments);
@ -504,7 +532,7 @@ var acf;
remove_filter: function() {
// prefix action
arguments[0] = 'acf.' + arguments[0];
arguments[0] = 'acf/' + arguments[0];
wp.hooks.removeFilter.apply(this, arguments);
@ -526,10 +554,10 @@ var acf;
* @return
*/
apply_filters: function() {
apply_filters: function() { //console.log('acf.apply_filters(%o)', arguments);
// prefix action
arguments[0] = 'acf.' + arguments[0];
arguments[0] = 'acf/' + arguments[0];
return wp.hooks.applyFilters.apply(this, arguments);
@ -770,7 +798,7 @@ var acf;
get_field_key: function( $field ){
return this.get_data( $field, 'key' );
return $field.data('key');
},
@ -790,7 +818,7 @@ var acf;
get_field_type: function( $field ){
return this.get_data( $field, 'type' );
return $field.data('type');
},
@ -902,22 +930,14 @@ var acf;
* @since 5.0.0
*
* @param $el (jQuery selection)
* @param prefix (string)
* @return $post_id (int)
*/
serialize_form : function( $el, prefix ){
// defaults
prefix = prefix || '';
serialize_form : function( $el ){
// vars
var data = {},
names = {},
prelen = prefix.length,
_prefix = '_' + prefix,
_prelen = _prefix.length;
names = {};
// selector
@ -927,14 +947,6 @@ var acf;
// populate data
$.each( $selector.serializeArray(), function( i, pair ) {
// bail early if name does not start with acf or _acf
if( prefix && pair.name.substring(0, prelen) != prefix && pair.name.substring(0, _prelen) != _prefix ) {
return;
}
// initiate name
if( pair.name.slice(-2) === '[]' ) {
@ -966,6 +978,13 @@ var acf;
// return
return data;
},
serialize: function( $el ){
return this.serialize_form( $el );
},
@ -1510,40 +1529,6 @@ var acf;
},
update_cookie : function( name, value, days ) {
// defaults
days = days || 31;
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
},
get_cookie : function( name ) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
},
delete_cookie : function( name ) {
this.update_cookie(name,"",-1);
},
/*
* is_in_view
@ -2243,8 +2228,8 @@ var acf;
},
_prepare_field: function( $el ){
acf.do_action('prepare_field/type=' + acf.get_field_type($el), $el);
acf.do_action('prepare_field/type=' + $el.data('type'), $el);
},
@ -2260,8 +2245,8 @@ var acf;
},
_ready_field: function( $el ){
acf.do_action('ready_field/type=' + acf.get_field_type($el), $el);
acf.do_action('ready_field/type=' + $el.data('type'), $el);
},
@ -2278,7 +2263,7 @@ var acf;
_append_field: function( $el ){
acf.do_action('append_field/type=' + acf.get_field_type($el), $el);
acf.do_action('append_field/type=' + $el.data('type'), $el);
},
@ -2295,7 +2280,7 @@ var acf;
_load_field: function( $el ){
acf.do_action('load_field/type=' + acf.get_field_type($el), $el);
acf.do_action('load_field/type=' + $el.data('type'), $el);
},
@ -2312,7 +2297,7 @@ var acf;
_remove_field: function( $el ){
acf.do_action('remove_field/type=' + acf.get_field_type($el), $el);
acf.do_action('remove_field/type=' + $el.data('type'), $el);
},
@ -2329,7 +2314,7 @@ var acf;
_sortstart_field: function( $el, $placeholder ){
acf.do_action('sortstart_field/type=' + acf.get_field_type($el), $el, $placeholder);
acf.do_action('sortstart_field/type=' + $el.data('type'), $el, $placeholder);
},
@ -2346,7 +2331,7 @@ var acf;
_sortstop_field: function( $el, $placeholder ){
acf.do_action('sortstop_field/type=' + acf.get_field_type($el), $el, $placeholder);
acf.do_action('sortstop_field/type=' + $el.data('type'), $el, $placeholder);
},
@ -2364,7 +2349,7 @@ var acf;
_hide_field: function( $el, context ){
acf.do_action('hide_field/type=' + acf.get_field_type($el), $el, context);
acf.do_action('hide_field/type=' + $el.data('type'), $el, context);
},
@ -2381,7 +2366,7 @@ var acf;
_show_field: function( $el, context ){
acf.do_action('show_field/type=' + acf.get_field_type($el), $el, context);
acf.do_action('show_field/type=' + $el.data('type'), $el, context);
}
@ -2986,25 +2971,25 @@ var acf;
});
/*
/*
//console.time("acf_test_ready");
//console.time("acf_test_load");
console.time("acf_test_ready");
console.time("acf_test_load");
acf.add_action('ready', function(){
//console.timeEnd("acf_test_ready");
console.timeEnd("acf_test_ready");
}, 999);
acf.add_action('load', function(){
//console.timeEnd("acf_test_load");
console.timeEnd("acf_test_load");
}, 999);
*/
})(jQuery);
(function($){
@ -3429,7 +3414,8 @@ var acf;
acf.fields.color_picker = acf.field.extend({
type: 'color_picker',
timeout: null,
$input: null,
$hidden: null,
actions: {
'ready': 'initialize',
@ -3439,59 +3425,53 @@ var acf;
focus: function(){
this.$input = this.$field.find('input[type="text"]');
this.$hidden = this.$field.find('input[type="hidden"]');
},
initialize: function(){
// reference
var self = this;
var $input = this.$input,
$hidden = this.$hidden;
// vars
var $hidden = this.$input.clone();
// trigger change function
var change_hidden = function(){
// timeout is required to ensure the $input val is correct
setTimeout(function(){
acf.val( $hidden, $input.val() );
}, 1);
}
// modify hidden
$hidden.attr({
'type' : 'hidden',
'class' : '',
'id' : '',
'value' : ''
});
// append hidden
this.$input.before( $hidden );
// args
var args = {
defaultColor: false,
palettes: true,
hide: true,
change: change_hidden,
clear: change_hidden
}
// filter
var args = acf.apply_filters('color_picker_args', args, this.$field);
// iris
this.$input.wpColorPicker({
change: function( event, ui ){
if( self.timeout ) {
clearTimeout( self.timeout );
}
self.timeout = setTimeout(function(){
$hidden.trigger('change');
}, 1000);
}
});
this.$input.wpColorPicker(args);
}
});
})(jQuery);
(function($){
@ -4198,7 +4178,7 @@ var acf;
title: acf._e('file', 'select'),
mode: 'select',
type: '',
field: acf.get_field_key($field),
field: $field.data('key'),
multiple: $repeater.exists(),
library: this.o.library,
mime_types: this.o.mime_types,
@ -4210,7 +4190,7 @@ var acf;
if( i > 0 ) {
// vars
var key = acf.get_field_key( $field ),
var key = $field.data('key'),
$tr = $field.closest('.acf-row');
@ -5198,7 +5178,7 @@ var acf;
title: acf._e('image', 'select'),
mode: 'select',
type: 'image',
field: acf.get_field_key($field),
field: $field.data('key'),
multiple: $repeater.exists(),
library: this.o.library,
mime_types: this.o.mime_types,
@ -5209,7 +5189,7 @@ var acf;
if( i > 0 ) {
// vars
var key = acf.get_field_key( $field ),
var key = $field.data('key'),
$tr = $field.closest('.acf-row');
@ -5580,7 +5560,9 @@ var acf;
// populate above vars making sure to allow for failure
try {
var filters = frame.content.get().toolbar.get('filters');
var toolbar = frame.content.get().toolbar,
filters = toolbar.get('filters'),
search = toolbar.get('search');
} catch(e) {
@ -5692,6 +5674,10 @@ var acf;
});
// add _acfuplaoder to search
search.model.attributes._acfuploader = args.field;
// render
if( typeof filters.refresh === 'function' ) {
@ -8763,7 +8749,7 @@ var acf;
events: {
'click #save-post': 'click_ignore',
'click input[type="submit"]': 'click_publish',
'click [type="submit"]': 'click_publish',
'submit form': 'submit_form',
'click .acf-error-message a': 'click_message'
},
@ -9093,11 +9079,7 @@ var acf;
fetch: function( $form ){
// bail aelry if already busy
if( this.busy ) {
return false;
}
if( this.busy ) return false;
// reference
@ -9105,7 +9087,7 @@ var acf;
// vars
var data = acf.serialize_form( $form, 'acf' );
var data = acf.serialize_form($form);
// append AJAX action
@ -9189,7 +9171,7 @@ var acf;
if( $message.exists() ) {
$message.removeClass('error');
$message.addClass('-success');
$message.children('p').html( acf._e('validation_successful') );
}
@ -9650,7 +9632,7 @@ var acf;
toolbars: {},
actions: {
'ready': 'initialize',
'load': 'initialize',
'append': 'initialize',
'remove': 'disable',
'sortstart': 'disable',

File diff suppressed because one or more lines are too long

View File

@ -45,6 +45,7 @@ class acf_field {
$this->add_action("acf/render_field/type={$this->name}", array($this, 'render_field'), 10, 1);
$this->add_action("acf/render_field_settings/type={$this->name}", array($this, 'render_field_settings'), 10, 1);
$this->add_action("acf/prepare_field/type={$this->name}", array($this, 'prepare_field'), 10, 1);
$this->add_action("acf/translate_field/type={$this->name}", array($this, 'translate_field'), 10, 1);
// input actions

View File

@ -1,30 +1,23 @@
<?php
/*
* ACF Input Class
*
* All the logic run on input pages (edit post)
*
* @class acf_input
* @package ACF
* @subpackage Core
*/
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if( ! class_exists('acf_input') ) :
class acf_input {
/*
* __construct
*
* Initialize filters, action, variables and includes
* This function will setup the class functionality
*
* @type function
* @date 23/06/12
* @date 5/03/2014
* @since 5.0.0
*
* @param N/A
* @return N/A
* @param n/a
* @return n/a
*/
function __construct() {
@ -33,23 +26,93 @@ class acf_input {
$this->admin_enqueue_scripts = 'admin_enqueue_scripts';
$this->admin_head = 'admin_head';
$this->admin_footer = 'admin_footer';
$this->enqueued = false;
$this->data = array();
// actions
add_action('acf/save_post', array($this, 'save_post'), 10, 1);
add_action('acf/input/admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'), 10, 0);
add_action('acf/input/admin_footer', array($this, 'admin_footer'), 10, 0);
// ajax
add_action( 'wp_ajax_acf/validate_save_post', array($this, 'ajax_validate_save_post') );
add_action( 'wp_ajax_nopriv_acf/validate_save_post', array($this, 'ajax_validate_save_post') );
add_action('acf/save_post', array($this, 'save_post'), 10, 1);
}
/*
* init
* get_data
*
* This function will return form data
*
* @type function
* @date 4/03/2016
* @since 5.3.2
*
* @param $key (mixed)
* @return (mixed)
*/
function get_data( $key = false ) {
// vars
$data = $this->data;
// key
if( $key && isset($data[ $key ]) ) {
$data = $data[ $key ];
}
// return
return $data;
}
/*
* set_data
*
* This function will se the form data
*
* @type function
* @date 4/03/2016
* @since 5.3.2
*
* @param $data (array)
* @return (array)
*/
function set_data( $data ) {
// defaults
$data = acf_parse_args($data, array(
'post_id' => 0, // ID of current post
'nonce' => 'post', // nonce used for $_POST validation
'validation' => 1, // runs AJAX validation
'ajax' => 0, // fetches new field groups via AJAX
));
// update
$this->data = $data;
// enqueue uploader if page allows AJAX fields to appear
if( $data['ajax'] ) {
add_action($this->admin_footer, 'acf_enqueue_uploader', 1);
}
// return
return $data;
}
/*
* enqueue
*
* This function will determin the actions to use for different pages
*
@ -61,7 +124,15 @@ class acf_input {
* @return n/a
*/
function init() {
function enqueue() {
// bail ealry if already enqueued
if( $this->enqueued ) return;
// update setting
$this->enqueued = true;
// global
global $pagenow;
@ -89,84 +160,28 @@ class acf_input {
// actions
acf_maybe_add_action($this->admin_enqueue_scripts, array($this, 'do_admin_enqueue_scripts'), 20 );
acf_maybe_add_action($this->admin_head, array($this, 'do_admin_head'), 20 );
acf_maybe_add_action($this->admin_footer, array($this, 'do_admin_footer'), 20 );
acf_maybe_add_action($this->admin_enqueue_scripts, array($this, 'admin_enqueue_scripts'), 20 );
acf_maybe_add_action($this->admin_head, array($this, 'admin_head'), 20 );
acf_maybe_add_action($this->admin_footer, array($this, 'admin_footer'), 20 );
}
function do_admin_enqueue_scripts() {
do_action('acf/input/admin_enqueue_scripts');
}
function do_admin_head() {
do_action('acf/input/admin_head');
}
function do_admin_footer() {
do_action('acf/input/admin_footer');
}
/*
* save_post
*
* This function will save the $_POST data
*
* @type function
* @date 24/10/2014
* @since 5.0.9
*
* @param $post_id (int)
* @return $post_id (int)
*/
function save_post( $post_id = 0 ) {
// bai learly if empty
if( empty($_POST['acf']) ) return;
// save $_POST data
foreach( $_POST['acf'] as $k => $v ) {
// get field
$field = acf_get_field( $k );
// continue if no field
if( !$field ) continue;
// update
acf_update_value( $v, $post_id, $field );
}
}
/*
* admin_enqueue_scripts
*
* This function will enqueue all the required scripts / styles for ACF
* The acf input screen admin_enqueue_scripts
*
* @type action (acf/input/admin_enqueue_scripts)
* @date 6/10/13
* @since 5.0.0
* @type function
* @date 4/03/2016
* @since 5.3.2
*
* @param n/a
* @param n/a
* @return n/a
*/
function admin_enqueue_scripts() {
// scripts
wp_enqueue_script('acf-input');
@ -174,41 +189,63 @@ class acf_input {
// styles
wp_enqueue_style('acf-input');
// do action
do_action('acf/input/admin_enqueue_scripts');
}
/*
* admin_head
*
* The acf input screen admin_head
*
* @type function
* @date 4/03/2016
* @since 5.3.2
*
* @param n/a
* @return n/a
*/
function admin_head() {
// do action
do_action('acf/input/admin_head');
}
/*
* admin_footer
*
* description
* The acf input screen admin_footer
*
* @type function
* @date 7/10/13
* @since 5.0.0
* @date 4/03/2016
* @since 5.3.2
*
* @param $post_id (int)
* @return $post_id (int)
* @param n/a
* @return n/a
*/
function admin_footer() {
// vars
$args = acf_get_setting('form_data');
// global
global $wp_version;
// options
$o = array(
'post_id' => $args['post_id'],
'post_id' => acf_get_form_data('post_id'),
'nonce' => wp_create_nonce( 'acf_nonce' ),
'admin_url' => admin_url(),
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'ajax' => $args['ajax'],
'validation' => $args['validation'],
'wp_version' => $wp_version
'ajax' => acf_get_form_data('ajax'),
'validation' => acf_get_form_data('validation'),
'wp_version' => $wp_version,
'acf_version' => acf_get_setting('version')
);
@ -240,77 +277,64 @@ class acf_input {
/* ]]> */
</script>
<?php
// do action
do_action('acf/input/admin_footer');
}
/*
* ajax_validate_save_post
* save_post
*
* This function will validate the $_POST data via AJAX
* This function will save the $_POST data
*
* @type function
* @date 27/10/2014
* @date 24/10/2014
* @since 5.0.9
*
* @param n/a
* @param $post_id (int)
* @return n/a
*/
function ajax_validate_save_post() {
function save_post( $post_id ) {
// bail early if _acfnonce is missing
if( !isset($_POST['_acfnonce']) ) {
// bail early if empty
if( empty($_POST['acf']) ) return;
// save $_POST data
foreach( $_POST['acf'] as $k => $v ) {
wp_send_json_error();
// get field
$field = acf_get_field( $k );
// continue if no field
if( !$field ) continue;
// update
acf_update_value( $v, $post_id, $field );
}
// vars
$json = array(
'valid' => 1,
'errors' => 0
);
// success
if( acf_validate_save_post() ) {
wp_send_json_success($json);
}
// update vars
$json['valid'] = 0;
$json['errors'] = acf_get_validation_errors();
// return
wp_send_json_success($json);
}
}
// global
global $acf_input;
// initialize
$acf_input = new acf_input();
acf()->input = new acf_input();
endif; // class_exists check
// class_exists check
endif;
/*
* acf_enqueue_scripts
*
* This function is used to setup all actions / functionality for an admin page which will contain ACF inputs
* alias of acf()->form->enqueue()
*
* @type function
* @date 6/10/13
@ -322,13 +346,48 @@ endif;
function acf_enqueue_scripts() {
// globals
global $acf_input;
return acf()->input->enqueue();
}
/*
* acf_get_form_data
*
* alias of acf()->form->get_data()
*
* @type function
* @date 6/10/13
* @since 5.0.0
*
* @param n/a
* @return n/a
*/
function acf_get_form_data( $key = false ) {
// init
$acf_input->init();
return acf()->input->get_data( $key );
}
/*
* acf_set_form_data
*
* alias of acf()->form->set_data()
*
* @type function
* @date 6/10/13
* @since 5.0.0
*
* @param n/a
* @return n/a
*/
function acf_set_form_data( $data = array() ) {
return acf()->input->set_data( $data );
}
@ -389,26 +448,10 @@ function acf_form_data( $args = array() ) {
acf_enqueue_scripts();
// defaults
$args = acf_parse_args($args, array(
'post_id' => 0, // ID of current post
'nonce' => 'post', // nonce used for $_POST validation
'validation' => 1, // runs AJAX validation
'ajax' => 0, // fetches new field groups via AJAX
));
// set form data
$args = acf_set_form_data( $args );
// save form_data for later actions
acf_update_setting('form_data', $args);
// enqueue uploader if page allows AJAX fields to appear
if( $args['ajax'] ) {
add_action('admin_footer', 'acf_enqueue_uploader', 1);
}
?>
<div id="acf-form-data" class="acf-hidden">
<input type="hidden" name="_acfnonce" value="<?php echo wp_create_nonce( $args['nonce'] ); ?>" />
@ -439,6 +482,12 @@ function acf_save_post( $post_id = 0 ) {
if( empty($_POST['acf']) ) return false;
// set form data
acf_set_form_data(array(
'post_id' => $post_id
));
// hook for 3rd party customization
do_action('acf/save_post', $post_id);
@ -447,198 +496,3 @@ function acf_save_post( $post_id = 0 ) {
return true;
}
/*
* acf_validate_save_post
*
* This function is run to validate post data
*
* @type function
* @date 25/11/2013
* @since 5.0.0
*
* @param $show_errors (boolean) if true, errors will be shown via a wo_die screen
* @return (boolean)
*/
function acf_validate_save_post( $show_errors = false ) {
// validate required fields
if( !empty($_POST['acf']) ) {
$keys = array_keys($_POST['acf']);
// loop through and save $_POST data
foreach( $keys as $key ) {
// get field
$field = acf_get_field( $key );
// validate
acf_validate_value( $_POST['acf'][ $key ], $field, "acf[{$key}]" );
}
// foreach($fields as $key => $value)
}
// if($fields)
// hook for 3rd party customization
do_action('acf/validate_save_post');
// check errors
if( $errors = acf_get_validation_errors() ) {
if( $show_errors ) {
$message = '<h2>Validation failed</h2><ul>';
foreach( $errors as $error ) {
$message .= '<li>' . $error['message'] . '</li>';
}
$message .= '</ul>';
wp_die( $message, 'Validation failed' );
}
return false;
}
// return
return true;
}
/*
* acf_validate_value
*
* This function will validate a value for a field
*
* @type function
* @date 27/10/2014
* @since 5.0.9
*
* @param $value (mixed)
* @param $field (array)
* @param $input (string) name attribute of DOM elmenet
* @return (boolean)
*/
function acf_validate_value( $value, $field, $input ) {
// vars
$valid = true;
$message = sprintf( __( '%s value is required', 'acf' ), $field['label'] );
// valid
if( $field['required'] ) {
// valid is set to false if the value is empty, but allow 0 as a valid value
if( empty($value) && !is_numeric($value) ) {
$valid = false;
}
}
// filter for 3rd party customization
$valid = apply_filters( "acf/validate_value", $valid, $value, $field, $input );
$valid = apply_filters( "acf/validate_value/type={$field['type']}", $valid, $value, $field, $input );
$valid = apply_filters( "acf/validate_value/name={$field['name']}", $valid, $value, $field, $input );
$valid = apply_filters( "acf/validate_value/key={$field['key']}", $valid, $value, $field, $input );
// allow $valid to be a custom error message
if( !empty($valid) && is_string($valid) ) {
$message = $valid;
$valid = false;
}
if( !$valid ) {
acf_add_validation_error( $input, $message );
return false;
}
// return
return true;
}
/*
* acf_add_validation_error
*
* This function will add an error message for a field
*
* @type function
* @date 25/11/2013
* @since 5.0.0
*
* @param $input (string) name attribute of DOM elmenet
* @param $message (string) error message
* @return $post_id (int)
*/
function acf_add_validation_error( $input, $message = '' ) {
// instantiate array if empty
if( empty($GLOBALS['acf_validation_errors']) ) {
$GLOBALS['acf_validation_errors'] = array();
}
// add to array
$GLOBALS['acf_validation_errors'][] = array(
'input' => $input,
'message' => $message
);
}
/*
* acf_add_validation_error
*
* This function will return any validation errors
*
* @type function
* @date 25/11/2013
* @since 5.0.0
*
* @param n/a
* @return (array|boolean)
*/
function acf_get_validation_errors() {
// bail early if no errors
if( empty($GLOBALS['acf_validation_errors']) ) return false;
// return
return $GLOBALS['acf_validation_errors'];
}
?>

View File

@ -1060,39 +1060,25 @@ class acf_location {
// validate
if( ! $comment ) {
return false;
}
if( !$comment ) return false;
// compare
if( $rule['operator'] == "==" ) {
$match = ( $comment == $rule['value'] );
// override for "all"
if( $rule['value'] == "all" ) {
$match = true;
}
} elseif( $rule['operator'] == "!=" ) {
$match = ( $comment != $rule['value'] );
// override for "all"
if( $rule['value'] == "all" ) {
$match = false;
}
// match
$match = ( $comment === $rule['value'] );
// override for "all"
if( $rule['value'] == "all" ) $match = true;
// reverse if 'not equal to'
if( $rule['operator'] === '!=' ) {
$match = !$match;
}
// return
return $match;

333
core/loop.php Normal file
View File

@ -0,0 +1,333 @@
<?php
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if( ! class_exists('acf_loop') ) :
class acf_loop {
/*
* __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->loops = array();
}
/*
* is_empty
*
* This function will return true if no loops exist
*
* @type function
* @date 3/03/2016
* @since 5.3.2
*
* @param n/a
* @return (boolean)
*/
function is_empty() {
return empty( $this->loops );
}
/*
* is_loop
*
* This function will return true if a loop exists for the given array index
*
* @type function
* @date 3/03/2016
* @since 5.3.2
*
* @param $i (int)
* @return (boolean)
*/
function is_loop( $i = 0 ) {
return isset( $this->loops[ $i ] );
}
/*
* get_i
*
* This function will return a valid array index for the given $i
*
* @type function
* @date 3/03/2016
* @since 5.3.2
*
* @param $i (mixed)
* @return (int)
*/
function get_i( $i = 0 ) {
// 'active'
if( $i === 'active' ) $i = -1;
// 'previous'
if( $i === 'previous' ) $i = -2;
// allow negative to look at end of loops
if( $i < 0 ) {
$i = count($this->loops) + $i;
}
// return
return $i;
}
/*
* add_loop
*
* This function will add a new loop
*
* @type function
* @date 3/03/2016
* @since 5.3.2
*
* @param $loop (array)
* @return n/a
*/
function add_loop( $loop = array() ) {
// defaults
$loop = wp_parse_args( $loop, array(
'selector' => '',
'name' => '',
'value' => false,
'field' => false,
'i' => -1,
'post_id' => 0,
));
// append
$this->loops[] = $loop;
}
/*
* update_loop
*
* This function will update a loop's setting
*
* @type function
* @date 3/03/2016
* @since 5.3.2
*
* @param $i (mixed)
* @param $key (string) the loop setting name
* @param $value (mixed) the loop setting value
* @return (boolean) true on success
*/
function update_loop( $i = 'active', $key = null, $value = null ) {
// i
$i = $this->get_i( $i );
// bail early if no set
if( !$this->is_loop($i) ) return false;
// set
$this->loops[ $i ][ $key ] = $value;
// return
return true;
}
/*
* get_loop
*
* This function will return a loop, or loop's setting for a given index & key
*
* @type function
* @date 3/03/2016
* @since 5.3.2
*
* @param $i (mixed)
* @param $key (string) the loop setting name
* @return (mixed) false on failure
*/
function get_loop( $i = 'active', $key = null ) {
// i
$i = $this->get_i( $i );
// bail early if no set
if( !$this->is_loop($i) ) return false;
// check for key
if( $key !== null ) {
return $this->loops[ $i ][ $key ];
}
// return
return $this->loops[ $i ];
}
/*
* remove_loop
*
* This function will remove a loop
*
* @type function
* @date 3/03/2016
* @since 5.3.2
*
* @param $i (mixed)
* @return (boolean) true on success
*/
function remove_loop( $i = 'active' ) {
// i
$i = $this->get_i( $i );
// bail early if no set
if( !$this->is_loop($i) ) return false;
// remove
unset($this->loops[ $i ]);
// reset keys
$this->loops = array_values( $this->loops );
}
}
// initialize
acf()->loop = new acf_loop();
endif; // class_exists check
/*
* acf_add_loop
*
* alias of acf()->loop->add_loop()
*
* @type function
* @date 6/10/13
* @since 5.0.0
*
* @param n/a
* @return n/a
*/
function acf_add_loop( $loop = array() ) {
return acf()->loop->add_loop( $loop );
}
/*
* acf_update_loop
*
* alias of acf()->loop->update_loop()
*
* @type function
* @date 6/10/13
* @since 5.0.0
*
* @param n/a
* @return n/a
*/
function acf_update_loop( $i = 'active', $key = null, $value = null ) {
return acf()->loop->update_loop( $i, $key, $value );
}
/*
* acf_get_loop
*
* alias of acf()->loop->get_loop()
*
* @type function
* @date 6/10/13
* @since 5.0.0
*
* @param n/a
* @return n/a
*/
function acf_get_loop( $i = 'active', $key = null ) {
return acf()->loop->get_loop( $i, $key );
}
/*
* acf_remove_loop
*
* alias of acf()->loop->remove_loop()
*
* @type function
* @date 6/10/13
* @since 5.0.0
*
* @param n/a
* @return n/a
*/
function acf_remove_loop( $i = 'active' ) {
return acf()->loop->remove_loop( $i );
}
?>

434
core/validation.php Normal file
View File

@ -0,0 +1,434 @@
<?php
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if( ! class_exists('acf_validation') ) :
class acf_validation {
/*
* __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->errors = array();
// ajax
add_action('wp_ajax_acf/validate_save_post', array($this, 'ajax_validate_save_post'));
add_action('wp_ajax_nopriv_acf/validate_save_post', array($this, 'ajax_validate_save_post'));
}
/*
* add_error
*
* This function will add an error message for a field
*
* @type function
* @date 25/11/2013
* @since 5.0.0
*
* @param $input (string) name attribute of DOM elmenet
* @param $message (string) error message
* @return $post_id (int)
*/
function add_error( $input, $message ) {
// add to array
$this->errors[] = array(
'input' => $input,
'message' => $message
);
}
/*
* get_error
*
* This function will return an error for a given input
*
* @type function
* @date 5/03/2016
* @since 5.3.2
*
* @param $input (string) name attribute of DOM elmenet
* @return (mixed)
*/
function get_error( $input ) {
// bail early if no errors
if( empty($this->errors) ) return false;
// loop
foreach( $this->errors as $error ) {
if( $error['input'] === $input ) return $error;
}
// return
return false;
}
/*
* get_errors
*
* This function will return validation errors
*
* @type function
* @date 25/11/2013
* @since 5.0.0
*
* @param n/a
* @return (array|boolean)
*/
function get_errors() {
// bail early if no errors
if( empty($this->errors) ) return false;
// return
return $this->errors;
}
/*
* reset_errors
*
* This function will remove all errors
*
* @type function
* @date 4/03/2016
* @since 5.3.2
*
* @param n/a
* @return n/a
*/
function reset_errors() {
$this->errors = array();
}
/*
* ajax_validate_save_post
*
* This function will validate the $_POST data via AJAX
*
* @type function
* @date 27/10/2014
* @since 5.0.9
*
* @param n/a
* @return n/a
*/
function ajax_validate_save_post() {
// bail early if _acfnonce is missing
if( !isset($_POST['_acfnonce']) ) {
wp_send_json_error();
}
// vars
$json = array(
'valid' => 1,
'errors' => 0
);
// success
if( acf_validate_save_post() ) {
wp_send_json_success($json);
}
// update vars
$json['valid'] = 0;
$json['errors'] = acf_get_validation_errors();
// return
wp_send_json_success($json);
}
/*
* validate_value
*
* This function will validate a field's value
*
* @type function
* @date 27/10/2014
* @since 5.0.9
*
* @param $value (mixed)
* @param $field (array)
* @param $input (string) name attribute of DOM elmenet
* @return (boolean)
*/
function validate_value( $value, $field, $input ) {
// vars
$valid = true;
$message = sprintf( __( '%s value is required', 'acf' ), $field['label'] );
// valid
if( $field['required'] ) {
// valid is set to false if the value is empty, but allow 0 as a valid value
if( empty($value) && !is_numeric($value) ) {
$valid = false;
}
}
// filter for 3rd party customization
$valid = apply_filters( "acf/validate_value", $valid, $value, $field, $input );
$valid = apply_filters( "acf/validate_value/type={$field['type']}", $valid, $value, $field, $input );
$valid = apply_filters( "acf/validate_value/name={$field['name']}", $valid, $value, $field, $input );
$valid = apply_filters( "acf/validate_value/key={$field['key']}", $valid, $value, $field, $input );
// allow $valid to be a custom error message
if( !empty($valid) && is_string($valid) ) {
$message = $valid;
$valid = false;
}
if( !$valid ) {
acf_add_validation_error( $input, $message );
return false;
}
// return
return true;
}
/*
* validate_save_post
*
* This function will validate $_POST data and add errors
*
* @type function
* @date 25/11/2013
* @since 5.0.0
*
* @param $show_errors (boolean) if true, errors will be shown via a wp_die screen
* @return (boolean)
*/
function validate_save_post( $show_errors = false ) {
// validate fields
if( !empty($_POST['acf']) ) {
// loop
foreach( $_POST['acf'] as $field_key => $value ) {
// get field
$field = acf_get_field( $field_key );
$input = 'acf[' . $field_key . ']';
// bail early if not found
if( !$field ) continue;
// validate
acf_validate_value( $value, $field, $input );
}
}
// action for 3rd party customization
do_action('acf/validate_save_post');
// vars
$errors = acf_get_validation_errors();
// bail ealry if no errors
if( !$errors ) return true;
// show errors
if( $show_errors ) {
$message = '<h2>Validation failed</h2>';
$message .= '<ul>';
foreach( $errors as $error ) {
$message .= '<li>' . $error['message'] . '</li>';
}
$message .= '</ul>';
// die
wp_die( $message, 'Validation failed' );
}
// return
return false;
}
}
// initialize
acf()->validation = new acf_validation();
endif; // class_exists check
/*
* acf_add_validation_error
*
* alias of acf()->validation->add_error()
*
* @type function
* @date 6/10/13
* @since 5.0.0
*
* @param n/a
* @return n/a
*/
function acf_add_validation_error( $input, $message = '' ) {
return acf()->validation->add_error( $input, $message );
}
/*
* acf_get_validation_errors
*
* alias of acf()->validation->get_errors()
*
* @type function
* @date 6/10/13
* @since 5.0.0
*
* @param n/a
* @return n/a
*/
function acf_get_validation_errors() {
return acf()->validation->get_errors();
}
/*
* acf_reset_validation_errors
*
* alias of acf()->validation->reset_errors()
*
* @type function
* @date 6/10/13
* @since 5.0.0
*
* @param n/a
* @return n/a
*/
function acf_reset_validation_errors() {
return acf()->validation->reset_errors();
}
/*
* acf_validate_save_post
*
* alias of acf()->validation->validate_save_post()
*
* @type function
* @date 6/10/13
* @since 5.0.0
*
* @param n/a
* @return n/a
*/
function acf_validate_save_post( $show_errors = false ) {
return acf()->validation->validate_save_post( $show_errors );
}
/*
* acf_validate_value
*
* alias of acf()->validation->validate_value()
*
* @type function
* @date 6/10/13
* @since 5.0.0
*
* @param n/a
* @return n/a
*/
function acf_validate_value( $value, $field, $input ) {
return acf()->validation->validate_value( $value, $field, $input );
}

View File

@ -271,11 +271,7 @@ class acf_field_checkbox extends acf_field {
// decode choices (convert to array)
$field['choices'] = acf_decode_choices($field['choices']);
$field['default_value'] = acf_decode_choices($field['default_value']);
// use only keys for default value
$field['default_value'] = array_keys($field['default_value']);
$field['default_value'] = acf_decode_choices($field['default_value'], true);
// return
@ -322,6 +318,31 @@ class acf_field_checkbox extends acf_field {
return $value;
}
/*
* translate_field
*
* This function will translate field settings
*
* @type function
* @date 8/03/2016
* @since 5.3.2
*
* @param $field (array)
* @return $field
*/
function translate_field( $field ) {
// translate
$field['choices'] = acf_translate( $field['choices'] );
// return
return $field;
}
}
new acf_field_checkbox();

View File

@ -112,26 +112,18 @@ class acf_field_color_picker extends acf_field {
function render_field( $field ) {
// vars
$atts = array();
$text = acf_get_sub_array( $field, array('id', 'class', 'name', 'value') );
$hidden = acf_get_sub_array( $field, array('name', 'value') );
$e = '';
// populate atts
foreach( array( 'id', 'class', 'name', 'value' ) as $k ) {
$atts[ $k ] = $field[ $k ];
}
// render
$e .= '<div class="acf-color_picker">';
$e .= '<input type="text" ' . acf_esc_attr($atts) . ' />';
$e .= '</div>';
// return
echo $e;
?>
<div class="acf-color_picker">
<?php acf_hidden_input($hidden); ?>
<input type="text" <?php echo acf_esc_attr($text); ?> />
</div>
<?php
}

View File

@ -149,6 +149,31 @@ class acf_field_message extends acf_field {
}
/*
* translate_field
*
* This function will translate field settings
*
* @type function
* @date 8/03/2016
* @since 5.3.2
*
* @param $field (array)
* @return $field
*/
function translate_field( $field ) {
// translate
$field['message'] = acf_translate( $field['message'] );
// return
return $field;
}
}
new acf_field_message();

View File

@ -323,21 +323,7 @@ class acf_field_page_link extends acf_field {
function get_post_title( $post, $field, $post_id = 0 ) {
// get post_id
if( !$post_id ) {
$form_data = acf_get_setting('form_data');
if( !empty($form_data['post_id']) ) {
$post_id = $form_data['post_id'];
} else {
$post_id = get_the_ID();
}
}
if( !$post_id ) $post_id = acf_get_form_data('post_id');
// vars

View File

@ -277,21 +277,7 @@ class acf_field_post_object extends acf_field {
function get_post_title( $post, $field, $post_id = 0 ) {
// get post_id
if( !$post_id ) {
$form_data = acf_get_setting('form_data');
if( !empty($form_data['post_id']) ) {
$post_id = $form_data['post_id'];
} else {
$post_id = get_the_ID();
}
}
if( !$post_id ) $post_id = acf_get_form_data('post_id');
// vars

View File

@ -358,6 +358,31 @@ class acf_field_radio extends acf_field {
}
/*
* translate_field
*
* This function will translate field settings
*
* @type function
* @date 8/03/2016
* @since 5.3.2
*
* @param $field (array)
* @return $field
*/
function translate_field( $field ) {
// translate
$field['choices'] = acf_translate( $field['choices'] );
// return
return $field;
}
}
new acf_field_radio();

View File

@ -470,11 +470,7 @@ class acf_field_select extends acf_field {
// decode choices (convert to array)
$field['choices'] = acf_decode_choices($field['choices']);
$field['default_value'] = acf_decode_choices($field['default_value']);
// use only keys for default value
$field['default_value'] = array_keys($field['default_value']);
$field['default_value'] = acf_decode_choices($field['default_value'], true);
// return
@ -522,6 +518,31 @@ class acf_field_select extends acf_field {
}
/*
* translate_field
*
* This function will translate field settings
*
* @type function
* @date 8/03/2016
* @since 5.3.2
*
* @param $field (array)
* @return $field
*/
function translate_field( $field ) {
// translate
$field['choices'] = acf_translate( $field['choices'] );
// return
return $field;
}
/*
* enqueue_assets
*

View File

@ -47,37 +47,6 @@ class acf_field_tab extends acf_field {
}
/*
* prepare_field
*
* description
*
* @type function
* @date 9/07/2015
* @since 5.2.3
*
* @param $post_id (int)
* @return $post_id (int)
*/
/*
function prepare_field( $field ) {
// append class
if( $field['endpoint'] ) {
$field['wrapper']['class'] .= ' acf-field-tab-endpoint';
}
// return
return $field;
}
*/
/*
* render_field()
*

View File

@ -231,20 +231,7 @@ class acf_field_taxonomy extends acf_field {
function get_term_title( $term, $field, $post_id = 0 ) {
// get post_id
if( !$post_id ) {
$form_data = acf_get_setting('form_data');
if( !empty($form_data['post_id']) ) {
$post_id = $form_data['post_id'];
} else {
$post_id = get_the_ID();
}
}
if( !$post_id ) $post_id = acf_get_form_data('post_id');
// vars

View File

@ -180,6 +180,31 @@ class acf_field_true_false extends acf_field {
}
/*
* translate_field
*
* This function will translate field settings
*
* @type function
* @date 8/03/2016
* @since 5.3.2
*
* @param $field (array)
* @return $field
*/
function translate_field( $field ) {
// translate
$field['message'] = acf_translate( $field['message'] );
// return
return $field;
}
}
new acf_field_true_false();

View File

@ -131,10 +131,10 @@ class acf_form_comment {
// vars
$post_id = "comment_{$comment->comment_ID}";
// get field groups
$field_groups = acf_get_field_groups(array(
'comment' => $comment->comment_ID
'comment' => get_post_type( $comment->comment_post_ID )
));
@ -199,13 +199,17 @@ class acf_form_comment {
function add_comment() {
// global
global $post;
// vars
$post_id = "comment_0";
// get field groups
$field_groups = acf_get_field_groups(array(
'comment' => 'new'
'comment' => $post->post_type
));

View File

@ -67,7 +67,7 @@ class acf_form_taxonomy {
// validate page
if( $pagenow == 'edit-tags.php' ) {
if( $pagenow === 'edit-tags.php' || $pagenow === 'term.php' ) {
return true;

Binary file not shown.

View File

@ -3,7 +3,7 @@ msgstr ""
"Project-Id-Version: Advanced Custom Fields Pro v5.2.9\n"
"Report-Msgid-Bugs-To: http://support.advancedcustomfields.com\n"
"POT-Creation-Date: 2015-08-11 23:35+0200\n"
"PO-Revision-Date: 2015-12-01 13:20+0100\n"
"PO-Revision-Date: 2016-03-09 12:48+0100\n"
"Last-Translator: Ralf Koller <r.koller@gmail.com>\n"
"Language-Team: Digital Factory <info@digitalfactory.pl>\n"
"Language: pl_PL\n"
@ -2578,7 +2578,7 @@ msgstr "Minimalna liczba rzędów"
#: pro/fields/repeater.php:382
msgid "Maximum Rows"
msgstr "Minimalna liczba rzędów"
msgstr "Maksymalna liczba rzędów"
#. Plugin Name of the plugin/theme
msgid "Advanced Custom Fields Pro"

View File

@ -3,7 +3,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Advanced Custom Fields\n"
"Report-Msgid-Bugs-To: http://support.advancedcustomfields.com\n"
"POT-Creation-Date: 2016-02-05 11:05+1000\n"
"POT-Creation-Date: 2016-03-15 10:53+1000\n"
"PO-Revision-Date: 2015-06-11 13:00+1000\n"
"Last-Translator: Elliot Condon <e@elliotcondon.com>\n"
"Language-Team: Elliot Condon <e@elliotcondon.com>\n"
@ -22,95 +22,95 @@ msgstr ""
"X-Poedit-SearchPath-0: .\n"
"X-Poedit-SearchPathExcluded-0: *.js\n"
#: acf.php:63
#: acf.php:60
msgid "Advanced Custom Fields"
msgstr ""
#: acf.php:266 admin/admin.php:61
#: acf.php:263 admin/admin.php:61
msgid "Field Groups"
msgstr ""
#: acf.php:267
#: acf.php:264
msgid "Field Group"
msgstr ""
#: acf.php:268 acf.php:300 admin/admin.php:62
#: pro/fields/flexible-content.php:506
#: acf.php:265 acf.php:297 admin/admin.php:62
#: pro/fields/flexible-content.php:496
msgid "Add New"
msgstr ""
#: acf.php:269
#: acf.php:266
msgid "Add New Field Group"
msgstr ""
#: acf.php:270
#: acf.php:267
msgid "Edit Field Group"
msgstr ""
#: acf.php:271
#: acf.php:268
msgid "New Field Group"
msgstr ""
#: acf.php:272
#: acf.php:269
msgid "View Field Group"
msgstr ""
#: acf.php:273
#: acf.php:270
msgid "Search Field Groups"
msgstr ""
#: acf.php:274
#: acf.php:271
msgid "No Field Groups found"
msgstr ""
#: acf.php:275
#: acf.php:272
msgid "No Field Groups found in Trash"
msgstr ""
#: acf.php:298 admin/field-group.php:176 admin/field-group.php:223
#: acf.php:295 admin/field-group.php:176 admin/field-group.php:223
#: admin/field-groups.php:528
msgid "Fields"
msgstr ""
#: acf.php:299
#: acf.php:296
msgid "Field"
msgstr ""
#: acf.php:301
#: acf.php:298
msgid "Add New Field"
msgstr ""
#: acf.php:302
#: acf.php:299
msgid "Edit Field"
msgstr ""
#: acf.php:303 admin/views/field-group-fields.php:18
#: acf.php:300 admin/views/field-group-fields.php:18
#: admin/views/settings-info.php:111
msgid "New Field"
msgstr ""
#: acf.php:304
#: acf.php:301
msgid "View Field"
msgstr ""
#: acf.php:305
#: acf.php:302
msgid "Search Fields"
msgstr ""
#: acf.php:306
#: acf.php:303
msgid "No Fields found"
msgstr ""
#: acf.php:307
#: acf.php:304
msgid "No Fields found in Trash"
msgstr ""
#: acf.php:346 admin/field-group.php:316 admin/field-groups.php:586
#: acf.php:343 admin/field-group.php:316 admin/field-groups.php:586
#: admin/views/field-group-options.php:13
msgid "Disabled"
msgstr ""
#: acf.php:351
#: acf.php:348
#, php-format
msgid "Disabled <span class=\"count\">(%s)</span>"
msgid_plural "Disabled <span class=\"count\">(%s)</span>"
@ -173,7 +173,7 @@ msgstr ""
msgid "Field group title is required"
msgstr ""
#: admin/field-group.php:221 api/api-field-group.php:581
#: admin/field-group.php:221 api/api-field-group.php:620
msgid "copy"
msgstr ""
@ -181,7 +181,7 @@ msgstr ""
#: admin/views/field-group-field-conditional-logic.php:62
#: admin/views/field-group-field-conditional-logic.php:162
#: admin/views/field-group-locations.php:59
#: admin/views/field-group-locations.php:135 api/api-helpers.php:3401
#: admin/views/field-group-locations.php:135 api/api-helpers.php:3639
msgid "or"
msgstr ""
@ -205,7 +205,7 @@ msgstr ""
msgid "Null"
msgstr ""
#: admin/field-group.php:229 core/input.php:217
#: admin/field-group.php:229 core/input.php:254
msgid "The changes you made will be lost if you navigate away from this page"
msgstr ""
@ -221,79 +221,79 @@ msgstr ""
msgid "Active"
msgstr ""
#: admin/field-group.php:785
#: admin/field-group.php:789
msgid "Front Page"
msgstr ""
#: admin/field-group.php:786
#: admin/field-group.php:790
msgid "Posts Page"
msgstr ""
#: admin/field-group.php:787
#: admin/field-group.php:791
msgid "Top Level Page (no parent)"
msgstr ""
#: admin/field-group.php:788
#: admin/field-group.php:792
msgid "Parent Page (has children)"
msgstr ""
#: admin/field-group.php:789
#: admin/field-group.php:793
msgid "Child Page (has parent)"
msgstr ""
#: admin/field-group.php:805
#: admin/field-group.php:809
msgid "Default Template"
msgstr ""
#: admin/field-group.php:827
#: admin/field-group.php:832
msgid "Logged in"
msgstr ""
#: admin/field-group.php:828
#: admin/field-group.php:833
msgid "Viewing front end"
msgstr ""
#: admin/field-group.php:829
#: admin/field-group.php:834
msgid "Viewing back end"
msgstr ""
#: admin/field-group.php:848
#: admin/field-group.php:853
msgid "Super Admin"
msgstr ""
#: admin/field-group.php:859 admin/field-group.php:867
#: admin/field-group.php:881 admin/field-group.php:888
#: admin/field-group.php:903 admin/field-group.php:913 fields/file.php:235
#: admin/field-group.php:864 admin/field-group.php:872
#: admin/field-group.php:886 admin/field-group.php:893
#: admin/field-group.php:910 admin/field-group.php:927 fields/file.php:235
#: fields/image.php:231 pro/fields/gallery.php:661
msgid "All"
msgstr ""
#: admin/field-group.php:868
#: admin/field-group.php:873
msgid "Add / Edit"
msgstr ""
#: admin/field-group.php:869
#: admin/field-group.php:874
msgid "Register"
msgstr ""
#: admin/field-group.php:1100
#: admin/field-group.php:1114
msgid "Move Complete."
msgstr ""
#: admin/field-group.php:1101
#: admin/field-group.php:1115
#, php-format
msgid "The %s field can now be found in the %s field group"
msgstr ""
#: admin/field-group.php:1103
#: admin/field-group.php:1117
msgid "Close Window"
msgstr ""
#: admin/field-group.php:1138
#: admin/field-group.php:1152
msgid "Please select the destination for this field"
msgstr ""
#: admin/field-group.php:1145
#: admin/field-group.php:1159
msgid "Move Field"
msgstr ""
@ -332,12 +332,13 @@ msgstr[1] ""
msgid "Sync available"
msgstr ""
#: admin/field-groups.php:525
#: admin/field-groups.php:525 pro/fields/gallery.php:374
msgid "Title"
msgstr ""
#: admin/field-groups.php:526 admin/views/field-group-options.php:93
#: admin/views/update-network.php:20 admin/views/update-network.php:28
#: pro/fields/gallery.php:401
msgid "Description"
msgstr ""
@ -404,7 +405,7 @@ msgid "Duplicate this item"
msgstr ""
#: admin/field-groups.php:684 admin/field-groups.php:700
#: admin/views/field-group-field.php:58 pro/fields/flexible-content.php:505
#: admin/views/field-group-field.php:58 pro/fields/flexible-content.php:495
msgid "Duplicate"
msgstr ""
@ -496,24 +497,24 @@ msgstr ""
#: admin/views/field-group-field-conditional-logic.php:40
#: admin/views/field-group-field.php:140 fields/checkbox.php:246
#: fields/message.php:144 fields/page_link.php:553 fields/page_link.php:567
#: fields/post_object.php:419 fields/post_object.php:433 fields/select.php:377
#: fields/message.php:144 fields/page_link.php:539 fields/page_link.php:553
#: fields/post_object.php:403 fields/post_object.php:417 fields/select.php:377
#: fields/select.php:391 fields/select.php:405 fields/select.php:419
#: fields/tab.php:161 fields/taxonomy.php:808 fields/taxonomy.php:822
#: fields/taxonomy.php:836 fields/taxonomy.php:850 fields/user.php:461
#: fields/user.php:475 fields/wysiwyg.php:415
#: fields/tab.php:130 fields/taxonomy.php:784 fields/taxonomy.php:798
#: fields/taxonomy.php:812 fields/taxonomy.php:826 fields/user.php:416
#: fields/user.php:430 fields/wysiwyg.php:415
#: pro/admin/views/settings-updates.php:93
msgid "Yes"
msgstr ""
#: admin/views/field-group-field-conditional-logic.php:41
#: admin/views/field-group-field.php:141 fields/checkbox.php:247
#: fields/message.php:145 fields/page_link.php:554 fields/page_link.php:568
#: fields/post_object.php:420 fields/post_object.php:434 fields/select.php:378
#: fields/message.php:145 fields/page_link.php:540 fields/page_link.php:554
#: fields/post_object.php:404 fields/post_object.php:418 fields/select.php:378
#: fields/select.php:392 fields/select.php:406 fields/select.php:420
#: fields/tab.php:162 fields/taxonomy.php:723 fields/taxonomy.php:809
#: fields/taxonomy.php:823 fields/taxonomy.php:837 fields/taxonomy.php:851
#: fields/user.php:462 fields/user.php:476 fields/wysiwyg.php:416
#: fields/tab.php:131 fields/taxonomy.php:699 fields/taxonomy.php:785
#: fields/taxonomy.php:799 fields/taxonomy.php:813 fields/taxonomy.php:827
#: fields/user.php:417 fields/user.php:431 fields/wysiwyg.php:416
#: pro/admin/views/settings-updates.php:103
msgid "No"
msgstr ""
@ -566,12 +567,12 @@ msgstr ""
msgid "Delete field"
msgstr ""
#: admin/views/field-group-field.php:60 pro/fields/flexible-content.php:504
#: admin/views/field-group-field.php:60 pro/fields/flexible-content.php:494
msgid "Delete"
msgstr ""
#: admin/views/field-group-field.php:68 fields/oembed.php:225
#: fields/taxonomy.php:924
#: fields/taxonomy.php:900
msgid "Error"
msgstr ""
@ -599,7 +600,7 @@ msgstr ""
msgid "Field Type"
msgstr ""
#: admin/views/field-group-field.php:121 fields/tab.php:134
#: admin/views/field-group-field.php:121 fields/tab.php:103
msgid "Instructions"
msgstr ""
@ -635,11 +636,11 @@ msgstr ""
msgid "Order"
msgstr ""
#: admin/views/field-group-fields.php:30 pro/fields/flexible-content.php:531
#: admin/views/field-group-fields.php:30 pro/fields/flexible-content.php:521
msgid "Label"
msgstr ""
#: admin/views/field-group-fields.php:31 pro/fields/flexible-content.php:544
#: admin/views/field-group-fields.php:31 pro/fields/flexible-content.php:534
msgid "Name"
msgstr ""
@ -785,11 +786,11 @@ msgstr ""
msgid "Label placement"
msgstr ""
#: admin/views/field-group-options.php:59 fields/tab.php:148
#: admin/views/field-group-options.php:59 fields/tab.php:117
msgid "Top aligned"
msgstr ""
#: admin/views/field-group-options.php:60 fields/tab.php:149
#: admin/views/field-group-options.php:60 fields/tab.php:118
msgid "Left Aligned"
msgstr ""
@ -1265,134 +1266,134 @@ msgstr ""
msgid "No updates available"
msgstr ""
#: api/api-helpers.php:909
#: api/api-helpers.php:937
msgid "Thumbnail"
msgstr ""
#: api/api-helpers.php:910
#: api/api-helpers.php:938
msgid "Medium"
msgstr ""
#: api/api-helpers.php:911
#: api/api-helpers.php:939
msgid "Large"
msgstr ""
#: api/api-helpers.php:959
#: api/api-helpers.php:987
msgid "Full Size"
msgstr ""
#: api/api-helpers.php:1149 api/api-helpers.php:1711
#: api/api-helpers.php:1177 api/api-helpers.php:1739
msgid "(no title)"
msgstr ""
#: api/api-helpers.php:3322
#: api/api-helpers.php:3560
#, php-format
msgid "Image width must be at least %dpx."
msgstr ""
#: api/api-helpers.php:3327
#: api/api-helpers.php:3565
#, php-format
msgid "Image width must not exceed %dpx."
msgstr ""
#: api/api-helpers.php:3343
#: api/api-helpers.php:3581
#, php-format
msgid "Image height must be at least %dpx."
msgstr ""
#: api/api-helpers.php:3348
#: api/api-helpers.php:3586
#, php-format
msgid "Image height must not exceed %dpx."
msgstr ""
#: api/api-helpers.php:3366
#: api/api-helpers.php:3604
#, php-format
msgid "File size must be at least %s."
msgstr ""
#: api/api-helpers.php:3371
#: api/api-helpers.php:3609
#, php-format
msgid "File size must must not exceed %s."
msgstr ""
#: api/api-helpers.php:3405
#: api/api-helpers.php:3643
#, php-format
msgid "File type must be %s."
msgstr ""
#: api/api-template.php:1069
#: api/api-template.php:1004
msgid "Spam Detected"
msgstr ""
#: api/api-template.php:1214 pro/fields/gallery.php:572
#: api/api-template.php:1147 pro/fields/gallery.php:572
msgid "Update"
msgstr ""
#: api/api-template.php:1215
#: api/api-template.php:1148
msgid "Post updated"
msgstr ""
#: core/field.php:131
#: core/field.php:132
msgid "Basic"
msgstr ""
#: core/field.php:132
#: core/field.php:133
msgid "Content"
msgstr ""
#: core/field.php:133
#: core/field.php:134
msgid "Choice"
msgstr ""
#: core/field.php:134
#: core/field.php:135
msgid "Relational"
msgstr ""
#: core/field.php:135
#: core/field.php:136
msgid "jQuery"
msgstr ""
#: core/field.php:136 fields/checkbox.php:226 fields/radio.php:231
#: pro/fields/flexible-content.php:501 pro/fields/flexible-content.php:550
#: pro/fields/repeater.php:467
#: core/field.php:137 fields/checkbox.php:226 fields/radio.php:231
#: pro/fields/flexible-content.php:491 pro/fields/flexible-content.php:540
#: pro/fields/repeater.php:459
msgid "Layout"
msgstr ""
#: core/input.php:218
#: core/input.php:255
msgid "Expand Details"
msgstr ""
#: core/input.php:219
#: core/input.php:256
msgid "Collapse Details"
msgstr ""
#: core/input.php:220
#: core/input.php:257
msgid "Validation successful"
msgstr ""
#: core/input.php:221
#: core/input.php:258
msgid "Validation failed"
msgstr ""
#: core/input.php:222
#: core/input.php:259
msgid "1 field requires attention"
msgstr ""
#: core/input.php:223
#: core/input.php:260
#, php-format
msgid "%d fields require attention"
msgstr ""
#: core/input.php:224
#: core/input.php:261
msgid "Restricted"
msgstr ""
#: core/input.php:541
#: core/validation.php:207
#, php-format
msgid "%s value is required"
msgstr ""
#: fields/checkbox.php:36 fields/taxonomy.php:790
#: fields/checkbox.php:36 fields/taxonomy.php:766
msgid "Checkbox"
msgstr ""
@ -1416,7 +1417,7 @@ msgstr ""
msgid "red : Red"
msgstr ""
#: fields/checkbox.php:217 fields/color_picker.php:155 fields/email.php:124
#: fields/checkbox.php:217 fields/color_picker.php:147 fields/email.php:124
#: fields/number.php:150 fields/radio.php:222 fields/select.php:363
#: fields/text.php:148 fields/textarea.php:145 fields/true_false.php:115
#: fields/url.php:117 fields/wysiwyg.php:376
@ -1571,7 +1572,7 @@ msgstr ""
msgid "Add File"
msgstr ""
#: fields/file.php:214 fields/image.php:200 fields/taxonomy.php:859
#: fields/file.php:214 fields/image.php:200 fields/taxonomy.php:835
msgid "Return Value"
msgstr ""
@ -1825,33 +1826,33 @@ msgstr ""
msgid "Archives"
msgstr ""
#: fields/page_link.php:520 fields/post_object.php:386
#: fields/page_link.php:506 fields/post_object.php:370
#: fields/relationship.php:689
msgid "Filter by Post Type"
msgstr ""
#: fields/page_link.php:528 fields/post_object.php:394
#: fields/page_link.php:514 fields/post_object.php:378
#: fields/relationship.php:697
msgid "All post types"
msgstr ""
#: fields/page_link.php:534 fields/post_object.php:400
#: fields/page_link.php:520 fields/post_object.php:384
#: fields/relationship.php:703
msgid "Filter by Taxonomy"
msgstr ""
#: fields/page_link.php:542 fields/post_object.php:408
#: fields/page_link.php:528 fields/post_object.php:392
#: fields/relationship.php:711
msgid "All taxonomies"
msgstr ""
#: fields/page_link.php:548 fields/post_object.php:414 fields/select.php:372
#: fields/taxonomy.php:803 fields/user.php:456
#: fields/page_link.php:534 fields/post_object.php:398 fields/select.php:372
#: fields/taxonomy.php:779 fields/user.php:411
msgid "Allow Null?"
msgstr ""
#: fields/page_link.php:562 fields/post_object.php:428 fields/select.php:386
#: fields/user.php:470
#: fields/page_link.php:548 fields/post_object.php:412 fields/select.php:386
#: fields/user.php:425
msgid "Select multiple values?"
msgstr ""
@ -1859,16 +1860,16 @@ msgstr ""
msgid "Password"
msgstr ""
#: fields/post_object.php:36 fields/post_object.php:447
#: fields/post_object.php:36 fields/post_object.php:431
#: fields/relationship.php:768
msgid "Post Object"
msgstr ""
#: fields/post_object.php:442 fields/relationship.php:763
#: fields/post_object.php:426 fields/relationship.php:763
msgid "Return Format"
msgstr ""
#: fields/post_object.php:448 fields/relationship.php:769
#: fields/post_object.php:432 fields/relationship.php:769
msgid "Post ID"
msgstr ""
@ -1924,7 +1925,7 @@ msgstr ""
msgid "Select taxonomy"
msgstr ""
#: fields/relationship.php:724 fields/taxonomy.php:36 fields/taxonomy.php:773
#: fields/relationship.php:724 fields/taxonomy.php:36 fields/taxonomy.php:749
msgid "Taxonomy"
msgstr ""
@ -1951,7 +1952,7 @@ msgid_plural "%s requires at least %s selections"
msgstr[0] ""
msgstr[1] ""
#: fields/select.php:36 fields/select.php:167 fields/taxonomy.php:795
#: fields/select.php:36 fields/select.php:167 fields/taxonomy.php:771
msgid "Select"
msgstr ""
@ -1967,117 +1968,117 @@ msgstr ""
msgid "Tab"
msgstr ""
#: fields/tab.php:128
#: fields/tab.php:97
msgid ""
"The tab field will display incorrectly when added to a Table style repeater "
"field or flexible content field layout"
msgstr ""
#: fields/tab.php:129
#: fields/tab.php:98
msgid ""
"Use \"Tab Fields\" to better organize your edit screen by grouping fields "
"together."
msgstr ""
#: fields/tab.php:130
#: fields/tab.php:99
msgid ""
"All fields following this \"tab field\" (or until another \"tab field\" is "
"defined) will be grouped together using this field's label as the tab "
"heading."
msgstr ""
#: fields/tab.php:144
#: fields/tab.php:113
msgid "Placement"
msgstr ""
#: fields/tab.php:156
#: fields/tab.php:125
msgid "End-point"
msgstr ""
#: fields/tab.php:157
#: fields/tab.php:126
msgid "Use this field as an end-point and start a new group of tabs"
msgstr ""
#: fields/taxonomy.php:742
#: fields/taxonomy.php:718
msgid "None"
msgstr ""
#: fields/taxonomy.php:774
#: fields/taxonomy.php:750
msgid "Select the taxonomy to be displayed"
msgstr ""
#: fields/taxonomy.php:783
#: fields/taxonomy.php:759
msgid "Appearance"
msgstr ""
#: fields/taxonomy.php:784
#: fields/taxonomy.php:760
msgid "Select the appearance of this field"
msgstr ""
#: fields/taxonomy.php:789
#: fields/taxonomy.php:765
msgid "Multiple Values"
msgstr ""
#: fields/taxonomy.php:791
#: fields/taxonomy.php:767
msgid "Multi Select"
msgstr ""
#: fields/taxonomy.php:793
#: fields/taxonomy.php:769
msgid "Single Value"
msgstr ""
#: fields/taxonomy.php:794
#: fields/taxonomy.php:770
msgid "Radio Buttons"
msgstr ""
#: fields/taxonomy.php:817
#: fields/taxonomy.php:793
msgid "Create Terms"
msgstr ""
#: fields/taxonomy.php:818
#: fields/taxonomy.php:794
msgid "Allow new terms to be created whilst editing"
msgstr ""
#: fields/taxonomy.php:831
#: fields/taxonomy.php:807
msgid "Save Terms"
msgstr ""
#: fields/taxonomy.php:832
#: fields/taxonomy.php:808
msgid "Connect selected terms to the post"
msgstr ""
#: fields/taxonomy.php:845
#: fields/taxonomy.php:821
msgid "Load Terms"
msgstr ""
#: fields/taxonomy.php:846
#: fields/taxonomy.php:822
msgid "Load value from posts terms"
msgstr ""
#: fields/taxonomy.php:864
#: fields/taxonomy.php:840
msgid "Term Object"
msgstr ""
#: fields/taxonomy.php:865
#: fields/taxonomy.php:841
msgid "Term ID"
msgstr ""
#: fields/taxonomy.php:924
#: fields/taxonomy.php:900
#, php-format
msgid "User unable to add new %s"
msgstr ""
#: fields/taxonomy.php:937
#: fields/taxonomy.php:913
#, php-format
msgid "%s already exists"
msgstr ""
#: fields/taxonomy.php:978
#: fields/taxonomy.php:954
#, php-format
msgid "%s added"
msgstr ""
#: fields/taxonomy.php:1023
#: fields/taxonomy.php:999
msgid "Add"
msgstr ""
@ -2121,11 +2122,11 @@ msgstr ""
msgid "Value must be a valid URL"
msgstr ""
#: fields/user.php:441
#: fields/user.php:396
msgid "Filter by role"
msgstr ""
#: fields/user.php:449
#: fields/user.php:404
msgid "All user roles"
msgstr ""
@ -2206,11 +2207,11 @@ msgstr ""
msgid "<b>Connection Error</b>. Sorry, please try again"
msgstr ""
#: pro/admin/views/options-page.php:48
#: pro/admin/views/options-page.php:44
msgid "Publish"
msgstr ""
#: pro/admin/views/options-page.php:54
#: pro/admin/views/options-page.php:50
msgid "Save Options"
msgstr ""
@ -2328,72 +2329,72 @@ msgstr ""
msgid "{required} {label} {identifier} required (min {min})"
msgstr ""
#: pro/fields/flexible-content.php:211
#: pro/fields/flexible-content.php:216
#, php-format
msgid "Click the \"%s\" button below to start creating your layout"
msgstr ""
#: pro/fields/flexible-content.php:357
#: pro/fields/flexible-content.php:346
msgid "Add layout"
msgstr ""
#: pro/fields/flexible-content.php:360
#: pro/fields/flexible-content.php:349
msgid "Remove layout"
msgstr ""
#: pro/fields/flexible-content.php:363 pro/fields/repeater.php:312
#: pro/fields/flexible-content.php:352 pro/fields/repeater.php:304
msgid "Click to toggle"
msgstr ""
#: pro/fields/flexible-content.php:503
#: pro/fields/flexible-content.php:493
msgid "Reorder Layout"
msgstr ""
#: pro/fields/flexible-content.php:503
#: pro/fields/flexible-content.php:493
msgid "Reorder"
msgstr ""
#: pro/fields/flexible-content.php:504
#: pro/fields/flexible-content.php:494
msgid "Delete Layout"
msgstr ""
#: pro/fields/flexible-content.php:505
#: pro/fields/flexible-content.php:495
msgid "Duplicate Layout"
msgstr ""
#: pro/fields/flexible-content.php:506
#: pro/fields/flexible-content.php:496
msgid "Add New Layout"
msgstr ""
#: pro/fields/flexible-content.php:560 pro/fields/repeater.php:474
#: pro/fields/flexible-content.php:550 pro/fields/repeater.php:466
msgid "Table"
msgstr ""
#: pro/fields/flexible-content.php:561 pro/fields/repeater.php:475
#: pro/fields/flexible-content.php:551 pro/fields/repeater.php:467
msgid "Block"
msgstr ""
#: pro/fields/flexible-content.php:562 pro/fields/repeater.php:476
#: pro/fields/flexible-content.php:552 pro/fields/repeater.php:468
msgid "Row"
msgstr ""
#: pro/fields/flexible-content.php:577
#: pro/fields/flexible-content.php:567
msgid "Min"
msgstr ""
#: pro/fields/flexible-content.php:590
#: pro/fields/flexible-content.php:580
msgid "Max"
msgstr ""
#: pro/fields/flexible-content.php:618 pro/fields/repeater.php:483
#: pro/fields/flexible-content.php:608 pro/fields/repeater.php:475
msgid "Button Label"
msgstr ""
#: pro/fields/flexible-content.php:627
#: pro/fields/flexible-content.php:617
msgid "Minimum Layouts"
msgstr ""
#: pro/fields/flexible-content.php:636
#: pro/fields/flexible-content.php:626
msgid "Maximum Layouts"
msgstr ""
@ -2417,6 +2418,14 @@ msgstr ""
msgid "Remove"
msgstr ""
#: pro/fields/gallery.php:383
msgid "Caption"
msgstr ""
#: pro/fields/gallery.php:392
msgid "Alt Text"
msgstr ""
#: pro/fields/gallery.php:543
msgid "Add to gallery"
msgstr ""
@ -2465,35 +2474,35 @@ msgstr ""
msgid "Maximum rows reached ({max} rows)"
msgstr ""
#: pro/fields/repeater.php:310
#: pro/fields/repeater.php:302
msgid "Drag to reorder"
msgstr ""
#: pro/fields/repeater.php:357
#: pro/fields/repeater.php:349
msgid "Add row"
msgstr ""
#: pro/fields/repeater.php:358
#: pro/fields/repeater.php:350
msgid "Remove row"
msgstr ""
#: pro/fields/repeater.php:406
#: pro/fields/repeater.php:398
msgid "Sub Fields"
msgstr ""
#: pro/fields/repeater.php:436
#: pro/fields/repeater.php:428
msgid "Collapsed"
msgstr ""
#: pro/fields/repeater.php:437
#: pro/fields/repeater.php:429
msgid "Select a sub field to show when row is collapsed"
msgstr ""
#: pro/fields/repeater.php:447
#: pro/fields/repeater.php:439
msgid "Minimum Rows"
msgstr ""
#: pro/fields/repeater.php:457
#: pro/fields/repeater.php:449
msgid "Maximum Rows"
msgstr ""

View File

@ -146,16 +146,16 @@ th.acf-row-handle span {
font-size: 14px;
line-height: 1.4em;
}
.acf-flexible-content .layout .fc-layout-order {
.acf-flexible-content .layout .acf-fc-layout-order {
display: block;
width: 20px;
height: 20px;
border-radius: 10px;
display: inline-block;
text-align: center;
line-height: 20px;
margin: 0 5px 0 0;
margin: 0 2px 0 0;
background: #F1F1F1;
float: left;
font-size: 12px;
color: #666;
}
@ -186,7 +186,7 @@ th.acf-row-handle span {
}
.acf-flexible-content > .values > .ui-sortable-placeholder {
visibility: visible !important;
border: #ccc dashed 2px;
border: 1px dashed #b4b9be;
box-shadow: none;
background: transparent;
}
@ -311,7 +311,7 @@ th.acf-row-handle span {
opacity: 0;
}
/* rtl */
html[dir="rtl"] .acf-flexible-content .layout .fc-layout-order {
html[dir="rtl"] .acf-flexible-content .layout .acf-fc-layout-order {
float: right;
margin-right: 0;
margin-left: 5px;
@ -422,7 +422,6 @@ html[dir="rtl"] .acf-flexible-content .layout .acf-fc-layout-controlls {
right: 0;
bottom: 0;
left: 0;
height: 28px;
padding: 10px;
border-top: #DFDFDF solid 1px;
}

View File

@ -592,10 +592,14 @@
render: function(){
// vars
var self = this;
// update order numbers
this.$values.children('.layout').each(function( i ){
$(this).find('> .acf-fc-layout-handle .fc-layout-order').html( i+1 );
$(this).find('> .acf-fc-layout-handle .acf-fc-layout-order').html( i+1 );
});
@ -624,6 +628,21 @@
}
},
render_layout: function( $layout ){
// update order number
// update text
/*
var data = acf.serialize_form($layout);
console.log( data );
*/
},
validate_add: function( layout ){
@ -1118,6 +1137,40 @@
// sync collapsed order
this.sync();
// vars
var data = acf.serialize( $layout );
// append
$.extend(data, {
action: 'acf/fields/flexible_content/layout_title',
field_key: this.$field.data('key'),
post_id: acf.get('post_id'),
i: $layout.index(),
layout: $layout.data('layout'),
});
// ajax get title HTML
$.ajax({
url : acf.get('ajaxurl'),
dataType : 'html',
type : 'post',
data : data,
success: function( html ){
// bail early if no html
if( !html ) return;
// update html
$layout.find('> .acf-fc-layout-handle').html( html );
}
});
}
});
@ -1300,7 +1353,7 @@
// vars
var data = acf.prepare_for_ajax({
action : 'acf/fields/gallery/get_sort_order',
field_key : acf.get_field_key(this.$field),
field_key : this.$field.data('key'),
post_id : acf.get('post_id'),
ids : [],
sort : sort
@ -1458,7 +1511,7 @@
// vars
var data = acf.prepare_for_ajax({
action : 'acf/fields/gallery/get_attachment',
field_key : acf.get_field_key(this.$field),
field_key : this.$field.data('key'),
nonce : acf.get('nonce'),
post_id : acf.get('post_id'),
id : id
@ -1775,7 +1828,7 @@
title: acf._e('gallery', 'select'),
mode: 'select',
type: '',
field: acf.get_field_key(this.$field),
field: this.$field.data('key'),
multiple: 'add',
library: this.o.library,
mime_types: this.o.mime_types,

File diff suppressed because one or more lines are too long

View File

@ -54,6 +54,11 @@ class acf_field_flexible_content extends acf_field {
);
// ajax
add_action('wp_ajax_acf/fields/flexible_content/layout_title', array($this, 'ajax_layout_title'));
add_action('wp_ajax_nopriv_acf/fields/flexible_content/layout_title', array($this, 'ajax_layout_title'));
// do not delete!
parent::__construct();
@ -195,7 +200,7 @@ class acf_field_flexible_content extends acf_field {
foreach( $field['layouts'] as $k => $layout ) {
$layouts[ $layout['name'] ] = acf_extract_var( $field['layouts'], $k );
$layouts[ $layout['name'] ] = $layout;
}
@ -300,29 +305,9 @@ class acf_field_flexible_content extends acf_field {
'data-layout' => $layout['name']
);
// collapsed
$collapsed = acf_get_user_setting('collapsed_' . $field['key'], '');
// cookie fallback ( version < 5.3.2 )
if( $collapsed === '' ) {
$collapsed = acf_extract_var($_COOKIE, "acf_collapsed_{$field['key']}", '');
$collapsed = str_replace('|', ',', $collapsed);
acf_update_user_setting( 'collapsed_' . $field['key'], $collapsed );
}
// explode
$collapsed = explode(',', $collapsed);
$collapsed = array_filter($collapsed, 'is_numeric');
// collapsed class
if( in_array($i, $collapsed) ) {
if( acf_is_row_collapsed($field['key'], $i) ) {
$div['class'] .= ' -collapsed';
@ -341,6 +326,12 @@ class acf_field_flexible_content extends acf_field {
}
// title
$title = $this->get_layout_title( $field, $layout, $i, $value );
// remove row
reset_rows();
?>
<div <?php acf_esc_attr_e($div); ?>>
@ -348,9 +339,7 @@ class acf_field_flexible_content extends acf_field {
<?php acf_hidden_input(array( 'name' => "{$field['name']}[{$i}][acf_fc_layout]", 'value' => $layout['name'] )); ?>
</div>
<div class="acf-fc-layout-handle">
<span class="fc-layout-order"><?php echo $order; ?></span> <?php echo $layout['label']; ?>
</div>
<div class="acf-fc-layout-handle"><?php echo $title; ?></div>
<ul class="acf-fc-layout-controlls acf-hl">
<li class="acf-fc-show-on-hover">
@ -479,8 +468,9 @@ class acf_field_flexible_content extends acf_field {
// load default layout
if( empty($field['layouts']) ) {
$field['layouts'] = array();
$field['layouts'][] = $this->get_valid_layout();
$field['layouts'] = array(
array()
);
}
@ -1223,6 +1213,121 @@ class acf_field_flexible_content extends acf_field {
}
/*
* ajax_layout_title
*
* description
*
* @type function
* @date 2/03/2016
* @since 5.3.2
*
* @param $post_id (int)
* @return $post_id (int)
*/
function ajax_layout_title() {
// options
$options = acf_parse_args( $_POST, array(
'post_id' => 0,
'i' => 0,
'field_key' => '',
'nonce' => '',
'layout' => '',
'acf' => array()
));
// load field
$field = acf_get_field( $options['field_key'] );
if( !$field ) die();
// vars
$layout = false;
foreach( $field['layouts'] as $k => $layout ) {
if( $layout['name'] === $options['layout'] ) break;
}
// bail ealry if no layout
if( !$layout ) die();
// value
// this flexible content field may be a sub field so it is important to
// loop though all $_POST data to find thi's field's row value
$value = $options['acf'];
while( is_array($value) ) {
// get first key
$k = key($value);
// update value
$value = array_pop( $value[ $k ] );
// stop looking if we have found the correct field's value
if( $k === $options['field_key'] ) break;
}
// title
$title = $this->get_layout_title( $field, $layout, $options['i'], $value );
// echo
echo $title;
die;
}
function get_layout_title( $field, $layout, $i, $value ) {
// add loop
acf_add_loop(array(
'selector' => $field['name'],
'name' => $field['name'],
'value' => array( $value ),
'field' => $field,
'i' => 0,
'post_id' => 0,
));
// vars
$title = $layout['label'];
// filters
$title = apply_filters('acf/fields/flexible_content/layout_title', $title, $field, $layout, $i);
$title = apply_filters('acf/fields/flexible_content/layout_title/name='.$field['_name'], $title, $field, $layout, $i);
$title = apply_filters('acf/fields/flexible_content/layout_title/key='.$field['key'], $title, $field, $layout, $i);
// remove loop
acf_remove_loop();
// prepend order
$title = '<span class="acf-fc-layout-order">' . ($i+1) . '</span> ' . $title;
// return
return $title;
}
}
new acf_field_flexible_content();

View File

@ -218,16 +218,8 @@ class acf_field_repeater extends acf_field {
// collapsed
$collapsed = array();
if( $field['collapsed'] ) {
// get user setting
$collapsed = acf_get_user_setting('collapsed_' . $field['key'], '');
$collapsed = explode(',', $collapsed);
$collapsed = array_filter($collapsed, 'is_numeric');
// add target class
foreach( array_keys($field['sub_fields']) as $i ) {
@ -297,7 +289,7 @@ class acf_field_repeater extends acf_field {
$row_class .= ' acf-clone';
} elseif( in_array($i, $collapsed) ) {
} elseif( acf_is_row_collapsed($field['key'], $i) ) {
$row_class .= ' -collapsed';

View File

@ -106,6 +106,25 @@ http://support.advancedcustomfields.com/
== Changelog ==
= 5.3.6.1 =
* Flexible Content field: Fixed PHP error in 'acf/fields/flexible_content/layout_title' filter (when used as a sub field)
* Core: Fixed bug causing `get_field()` to load from the incorrect post (when within a custom WP_Query loop)
= 5.3.6 =
* Flexible Content field: Added new 'acf/fields/flexible_content/layout_title' filter to customize layout title
* Image field: Fixed bug where searching within media library would ignore restriction settings
* File field: Same as above
* Field group: Added post types to comment form location rules
* Color Picker field: Added 'color_picker_args' JS filter to modify wpColorPicker args
* API: Improved `get_` functions to load value from the current queried object (post, user, term)
* Core: Added new 'acf/translate_field' filter to translate field settings text
* Core: Added new 'acf/translate_field_group' filter to translate field group settings text
* Core: Removed 'l10n_field' and 'l10n_field_group' settings
* Core: Fixed bug causing 'acf/input/admin_head' action to run twice
* Core: Added support for new WP 4.5 term edit page
* Core: Moved google map and wysiwyg JS initialisation later in the page load to help speed up edit screens
* Core: Minor fixes and improvements
= 5.3.5 =
* User field: Fixed pagination bug causing missing results
* Core: Added new filter 'acf/location/screen' to customize location rules matching args