5.6.10
This commit is contained in:
parent
27fed4e4a6
commit
34ce18384e
26
acf.php
26
acf.php
|
|
@ -3,7 +3,7 @@
|
|||
Plugin Name: Advanced Custom Fields PRO
|
||||
Plugin URI: https://www.advancedcustomfields.com/
|
||||
Description: Customise WordPress with powerful, professional and intuitive fields.
|
||||
Version: 5.6.9
|
||||
Version: 5.6.10
|
||||
Author: Elliot Condon
|
||||
Author URI: http://www.elliotcondon.com/
|
||||
Copyright: Elliot Condon
|
||||
|
|
@ -18,7 +18,7 @@ if( ! class_exists('ACF') ) :
|
|||
class ACF {
|
||||
|
||||
/** @var string The plugin version number */
|
||||
var $version = '5.6.9';
|
||||
var $version = '5.6.10';
|
||||
|
||||
/** @var array The plugin settings array */
|
||||
var $settings = array();
|
||||
|
|
@ -66,17 +66,26 @@ class ACF {
|
|||
function initialize() {
|
||||
|
||||
// vars
|
||||
$version = $this->version;
|
||||
$basename = plugin_basename( __FILE__ );
|
||||
$path = plugin_dir_path( __FILE__ );
|
||||
$url = plugin_dir_url( __FILE__ );
|
||||
$slug = dirname($basename);
|
||||
|
||||
|
||||
// settings
|
||||
$this->settings = array(
|
||||
|
||||
// basic
|
||||
'name' => __('Advanced Custom Fields', 'acf'),
|
||||
'version' => $this->version,
|
||||
'version' => $version,
|
||||
|
||||
// urls
|
||||
'file' => __FILE__,
|
||||
'basename' => plugin_basename( __FILE__ ),
|
||||
'path' => plugin_dir_path( __FILE__ ),
|
||||
'url' => plugin_dir_url( __FILE__ ),
|
||||
'basename' => $basename,
|
||||
'path' => $path,
|
||||
'url' => $url,
|
||||
'slug' => $slug,
|
||||
|
||||
// options
|
||||
'show_admin' => true,
|
||||
|
|
@ -107,8 +116,8 @@ class ACF {
|
|||
|
||||
// constants
|
||||
$this->define( 'ACF', true );
|
||||
$this->define( 'ACF_VERSION', $this->settings['version'] );
|
||||
$this->define( 'ACF_PATH', $this->settings['path'] );
|
||||
$this->define( 'ACF_VERSION', $version );
|
||||
$this->define( 'ACF_PATH', $path );
|
||||
|
||||
|
||||
// api
|
||||
|
|
@ -191,7 +200,6 @@ class ACF {
|
|||
// filters
|
||||
add_filter('posts_where', array($this, 'posts_where'), 10, 2 );
|
||||
//add_filter('posts_request', array($this, 'posts_request'), 10, 1 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2670,14 +2670,26 @@ p.submit .acf-spinner {
|
|||
* Gutenberg
|
||||
*
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
#editor .editor-meta-boxes-area {
|
||||
max-width: 80%;
|
||||
}
|
||||
#editor .editor-meta-boxes-area .postbox {
|
||||
border: #e2e4e7 solid 1px;
|
||||
border-bottom: none;
|
||||
margin: 20px 0;
|
||||
}
|
||||
#editor .editor-meta-boxes-area input {
|
||||
max-width: none;
|
||||
/*
|
||||
#editor {
|
||||
|
||||
.edit-post-layout__metaboxes {
|
||||
//border-top: none;
|
||||
}
|
||||
|
||||
.edit-post-meta-boxes-area {
|
||||
max-width: 80%;
|
||||
|
||||
.postbox {
|
||||
border: #e2e4e7 solid 1px;
|
||||
border-bottom: none;
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
input {
|
||||
max-width: none;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1252,41 +1252,29 @@
|
|||
|
||||
|
||||
// get settings
|
||||
var $settings = $tbody.children('.acf-field[data-setting="' + old_type + '"]'),
|
||||
html = '';
|
||||
|
||||
|
||||
// populate settings html
|
||||
$settings.each(function(){
|
||||
|
||||
html += $(this).outerHTML();
|
||||
|
||||
});
|
||||
|
||||
|
||||
// remove settings
|
||||
$settings.remove();
|
||||
|
||||
var $settings = $tbody.children('.acf-field[data-setting="' + old_type + '"]');
|
||||
|
||||
// save field settings html
|
||||
acf.update( key + '_settings_' + old_type, html );
|
||||
|
||||
acf.update( key + '_settings_' + old_type, $settings );
|
||||
|
||||
// remove settings
|
||||
$settings.detach();
|
||||
|
||||
// render field
|
||||
this.render_field( $el );
|
||||
|
||||
|
||||
// show field options if they already exist
|
||||
html = acf.get( key + '_settings_' + new_type );
|
||||
$newettings = acf.get( key + '_settings_' + new_type );
|
||||
|
||||
if( html ) {
|
||||
if( $newettings ) {
|
||||
|
||||
// append settings
|
||||
$tbody.children('.acf-field[data-name="conditional_logic"]').before( html );
|
||||
$tbody.children('.acf-field[data-name="conditional_logic"]').before( $newettings );
|
||||
|
||||
|
||||
// remove field settings html
|
||||
acf.update( key + '_settings_' + new_type, '' );
|
||||
acf.update( key + '_settings_' + new_type, false );
|
||||
|
||||
|
||||
// trigger event
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -247,7 +247,7 @@
|
|||
};
|
||||
|
||||
window.wp = window.wp || {};
|
||||
window.wp.hooks = new EventManager();
|
||||
window.wp.hooks = window.wp.hooks || new EventManager();
|
||||
|
||||
} )( window );
|
||||
|
||||
|
|
@ -1024,265 +1024,6 @@ var acf;
|
|||
|
||||
},
|
||||
|
||||
/*
|
||||
serialize: function( $el, prefix ){
|
||||
|
||||
// defaults
|
||||
prefix = prefix || '';
|
||||
|
||||
|
||||
// vars
|
||||
var data = {};
|
||||
var $inputs = $el.find('select, textarea, input');
|
||||
|
||||
|
||||
// loop
|
||||
$inputs.each(function(){
|
||||
|
||||
// vars
|
||||
var $el = $(this);
|
||||
var name = $el.attr('name');
|
||||
var val = $el.val();
|
||||
|
||||
|
||||
// is array
|
||||
var is_array = ( name.slice(-2) === '[]' );
|
||||
if( is_array ) {
|
||||
name = name.slice(0, -2);
|
||||
}
|
||||
|
||||
|
||||
// explode name
|
||||
var bits = name.split('[');
|
||||
var depth = bits.length;
|
||||
|
||||
|
||||
// loop
|
||||
for( var i = 0; i < depth; i++ ) {
|
||||
|
||||
// vars
|
||||
var k = bits[i];
|
||||
|
||||
|
||||
// end
|
||||
if( i == depth-1 ) {
|
||||
|
||||
|
||||
|
||||
|
||||
// not end
|
||||
} else {
|
||||
|
||||
// must be object
|
||||
if( typeof data[k] !== 'object' ) {
|
||||
data[k] = {};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
bits.map(function( s ){ return s.replace(']', ''); })
|
||||
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* disable
|
||||
*
|
||||
* This function will disable an input
|
||||
*
|
||||
* @type function
|
||||
* @date 22/09/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param $el (jQuery)
|
||||
* @param context (string)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
disable: function( $input, context ){
|
||||
|
||||
// defaults
|
||||
context = context || '';
|
||||
|
||||
|
||||
// bail early if is .acf-disabled
|
||||
if( $input.hasClass('acf-disabled') ) return false;
|
||||
|
||||
|
||||
// always disable input
|
||||
$input.prop('disabled', true);
|
||||
|
||||
|
||||
// context
|
||||
if( context ) {
|
||||
|
||||
// vars
|
||||
var disabled = $input.data('acf_disabled') || [],
|
||||
i = disabled.indexOf(context);
|
||||
|
||||
|
||||
// append context if not found
|
||||
if( i < 0 ) {
|
||||
|
||||
// append
|
||||
disabled.push( context );
|
||||
|
||||
|
||||
// update
|
||||
$input.data('acf_disabled', disabled);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return true;
|
||||
|
||||
},
|
||||
|
||||
|
||||
/*
|
||||
* enable
|
||||
*
|
||||
* This function will enable an input
|
||||
*
|
||||
* @type function
|
||||
* @date 22/09/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param $el (jQuery)
|
||||
* @param context (string)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
enable: function( $input, context ){
|
||||
|
||||
// defaults
|
||||
context = context || '';
|
||||
|
||||
|
||||
// bail early if is .acf-disabled
|
||||
if( $input.hasClass('acf-disabled') ) return false;
|
||||
|
||||
|
||||
// vars
|
||||
var disabled = $input.data('acf_disabled') || [];
|
||||
|
||||
|
||||
// context
|
||||
if( context ) {
|
||||
|
||||
// vars
|
||||
var i = disabled.indexOf(context);
|
||||
|
||||
|
||||
// remove context if found
|
||||
if( i > -1 ) {
|
||||
|
||||
// delete
|
||||
disabled.splice(i, 1);
|
||||
|
||||
|
||||
// update
|
||||
$input.data('acf_disabled', disabled);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// bail early if other disabled exist
|
||||
if( disabled.length ) return false;
|
||||
|
||||
|
||||
// enable input
|
||||
$input.prop('disabled', false);
|
||||
|
||||
|
||||
// return
|
||||
return true;
|
||||
|
||||
},
|
||||
|
||||
|
||||
/*
|
||||
* disable_el
|
||||
*
|
||||
* This function will disable all inputs within an element
|
||||
*
|
||||
* @type function
|
||||
* @date 22/09/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param $el (jQuery)
|
||||
* @param context (string)
|
||||
* @return na
|
||||
*/
|
||||
|
||||
disable_el: function( $el, context ) {
|
||||
|
||||
// defaults
|
||||
context = context || '';
|
||||
|
||||
|
||||
// loop
|
||||
$el.find('select, textarea, input').each(function(){
|
||||
|
||||
acf.disable( $(this), context );
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
disable_form: function( $el, context ) {
|
||||
|
||||
this.disable_el.apply( this, arguments );
|
||||
|
||||
},
|
||||
|
||||
|
||||
/*
|
||||
* enable_el
|
||||
*
|
||||
* This function will enable all inputs within an element
|
||||
*
|
||||
* @type function
|
||||
* @date 22/09/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param $el (jQuery)
|
||||
* @param context (string)
|
||||
* @return na
|
||||
*/
|
||||
|
||||
enable_el: function( $el, context ) {
|
||||
|
||||
// defaults
|
||||
context = context || '';
|
||||
|
||||
|
||||
// loop
|
||||
$el.find('select, textarea, input').each(function(){
|
||||
|
||||
acf.enable( $(this), context );
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
enable_form: function( $el, context ) {
|
||||
|
||||
this.enable_el.apply( this, arguments );
|
||||
|
||||
},
|
||||
|
||||
|
||||
/*
|
||||
* remove_tr
|
||||
|
|
@ -4089,15 +3830,25 @@ var acf;
|
|||
/**
|
||||
* acf.lock
|
||||
*
|
||||
* Creates a lock on an element
|
||||
* Creates a "lock" on an element for a given type and key
|
||||
*
|
||||
* @date 22/2/18
|
||||
* @since 5.6.9
|
||||
*
|
||||
* @param type $var Description. Default.
|
||||
* @return type Description.
|
||||
* @param jQuery $el The element to lock.
|
||||
* @param string type The type of lock such as "condition" or "visibility".
|
||||
* @param string key The key that will be used to unlock.
|
||||
* @return void
|
||||
*/
|
||||
|
||||
var getLocks = function( $el, type ){
|
||||
return $el.data('acf-lock-'+type) || [];
|
||||
};
|
||||
|
||||
var setLocks = function( $el, type, locks ){
|
||||
$el.data('acf-lock-'+type, locks);
|
||||
}
|
||||
|
||||
acf.lock = function( $el, type, key ){
|
||||
var locks = getLocks( $el, type );
|
||||
var i = locks.indexOf(key);
|
||||
|
|
@ -4107,6 +3858,20 @@ var acf;
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* acf.unlock
|
||||
*
|
||||
* Unlocks a "lock" on an element for a given type and key
|
||||
*
|
||||
* @date 22/2/18
|
||||
* @since 5.6.9
|
||||
*
|
||||
* @param jQuery $el The element to lock.
|
||||
* @param string type The type of lock such as "condition" or "visibility".
|
||||
* @param string key The key that will be used to unlock.
|
||||
* @return void
|
||||
*/
|
||||
|
||||
acf.unlock = function( $el, type, key ){
|
||||
var locks = getLocks( $el, type );
|
||||
var i = locks.indexOf(key);
|
||||
|
|
@ -4114,37 +3879,269 @@ var acf;
|
|||
locks.splice(i, 1);
|
||||
setLocks( $el, type, locks );
|
||||
}
|
||||
|
||||
// return true if is unlocked (no locks)
|
||||
return (locks.length === 0);
|
||||
};
|
||||
|
||||
/**
|
||||
* acf.isLocked
|
||||
*
|
||||
* Returns true if a lock exists for a given type
|
||||
*
|
||||
* @date 22/2/18
|
||||
* @since 5.6.9
|
||||
*
|
||||
* @param jQuery $el The element to lock.
|
||||
* @param string type The type of lock such as "condition" or "visibility".
|
||||
* @return void
|
||||
*/
|
||||
|
||||
acf.isLocked = function( $el, type ){
|
||||
return ( getLocks( $el, type ).length > 0 );
|
||||
};
|
||||
|
||||
var getLocks = function( $el, type ){
|
||||
return $el.data('acf-lock-'+type) || [];
|
||||
/**
|
||||
* acf.show
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @date 9/2/18
|
||||
* @since 5.6.5
|
||||
*
|
||||
* @param type $var Description. Default.
|
||||
* @return type Description.
|
||||
*/
|
||||
|
||||
acf.show = function( $el, lockKey ){
|
||||
|
||||
// unlock
|
||||
if( lockKey ) {
|
||||
acf.unlock($el, 'hidden', lockKey);
|
||||
}
|
||||
|
||||
// bail early if $el is still locked
|
||||
if( acf.isLocked($el, 'hidden') ) {
|
||||
//console.log( 'still locked', getLocks( $el, 'hidden' ));
|
||||
return false;
|
||||
}
|
||||
|
||||
// $el is hidden, remove class and return true due to change in visibility
|
||||
if( $el.hasClass('acf-hidden') ) {
|
||||
$el.removeClass('acf-hidden');
|
||||
return true;
|
||||
|
||||
// $el is visible, return false due to no change in visibility
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
var setLocks = function( $el, type, locks ){
|
||||
$el.data('acf-lock-'+type, locks);
|
||||
}
|
||||
/**
|
||||
* enable
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @date 12/3/18
|
||||
* @since 5.6.9
|
||||
*
|
||||
* @param type $var Description. Default.
|
||||
* @return type Description.
|
||||
*/
|
||||
|
||||
/*
|
||||
$(document).ready(function(){
|
||||
var enable = function( $el, lockKey ){
|
||||
|
||||
var $el = $('#page_template');
|
||||
// check class. Allow .acf-disabled to overrule all JS
|
||||
if( $el.hasClass('acf-disabled') ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
console.log( 'isLocked', acf.isLocked($el, 'visible') );
|
||||
console.log( 'getLocks', getLocks($el, 'visible') );
|
||||
// unlock
|
||||
if( lockKey ) {
|
||||
acf.unlock($el, 'disabled', lockKey);
|
||||
}
|
||||
|
||||
console.log( 'lock', acf.lock($el, 'visible', 'me') );
|
||||
console.log( 'getLocks', getLocks($el, 'visible') );
|
||||
console.log( 'isLocked', acf.isLocked($el, 'visible') );
|
||||
// bail early if $el is still locked
|
||||
if( acf.isLocked($el, 'disabled') ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
console.log( 'unlock', acf.unlock($el, 'visible', 'me') );
|
||||
console.log( 'isLocked', acf.isLocked($el, 'visible') );
|
||||
// $el is disabled, remove prop and return true due to change
|
||||
if( $el.prop('disabled') ) {
|
||||
$el.prop('disabled', false);
|
||||
return true;
|
||||
|
||||
});
|
||||
*/
|
||||
// $el is enabled, return false due to no change
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* acf.enable
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @date 9/2/18
|
||||
* @since 5.6.5
|
||||
*
|
||||
* @param type $var Description. Default.
|
||||
* @return type Description.
|
||||
*/
|
||||
|
||||
acf.enable = function( $el, lockKey ){
|
||||
|
||||
// enable single input
|
||||
if( $el.attr('name') ) {
|
||||
return enable( $el, lockKey );
|
||||
}
|
||||
|
||||
// find and enable child inputs
|
||||
// return false if 'any' inputs are still disabled
|
||||
var results = true;
|
||||
$el.find('[name]').each(function(){
|
||||
var result = enable( $(this), lockKey );
|
||||
if( !result ) {
|
||||
results = false;
|
||||
}
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* disable
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @date 12/3/18
|
||||
* @since 5.6.9
|
||||
*
|
||||
* @param type $var Description. Default.
|
||||
* @return type Description.
|
||||
*/
|
||||
|
||||
var disable = function( $el, lockKey ){
|
||||
|
||||
// lock
|
||||
if( lockKey ) {
|
||||
acf.lock($el, 'disabled', lockKey);
|
||||
}
|
||||
|
||||
// $el is disabled, return false due to no change
|
||||
if( $el.prop('disabled') ) {
|
||||
return false;
|
||||
|
||||
// $el is enabled, add prop and return true due to change
|
||||
} else {
|
||||
$el.prop('disabled', true);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* acf.disable
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @date 9/2/18
|
||||
* @since 5.6.5
|
||||
*
|
||||
* @param type $var Description. Default.
|
||||
* @return type Description.
|
||||
*/
|
||||
|
||||
acf.disable = function( $el, lockKey ){
|
||||
|
||||
// disable single input
|
||||
if( $el.attr('name') ) {
|
||||
return disable( $el, lockKey );
|
||||
}
|
||||
|
||||
// find and enable child inputs
|
||||
// return false if 'any' inputs did not change
|
||||
var results = true;
|
||||
$el.find('[name]').each(function(){
|
||||
var result = disable( $(this), lockKey );
|
||||
if( !result ) {
|
||||
results = false;
|
||||
}
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
// compatibility
|
||||
acf.enable_el = acf.enable;
|
||||
acf.enable_form = acf.enable;
|
||||
|
||||
acf.disable_el = acf.disable;
|
||||
acf.disable_form = acf.disable;
|
||||
|
||||
|
||||
/**
|
||||
* acf.hide
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @date 9/2/18
|
||||
* @since 5.6.5
|
||||
*
|
||||
* @param type $var Description. Default.
|
||||
* @return type Description.
|
||||
*/
|
||||
|
||||
acf.hide = function( $el, lockKey ){
|
||||
|
||||
// lock
|
||||
if( lockKey ) {
|
||||
acf.lock($el, 'hidden', lockKey);
|
||||
}
|
||||
|
||||
// $el is hidden, return false due to no change in visibility
|
||||
if( $el.hasClass('acf-hidden') ) {
|
||||
return false;
|
||||
|
||||
// $el is visible, add class and return true due to change in visibility
|
||||
} else {
|
||||
$el.addClass('acf-hidden');
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* acf.isHidden
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @date 9/2/18
|
||||
* @since 5.6.5
|
||||
*
|
||||
* @param type $var Description. Default.
|
||||
* @return type Description.
|
||||
*/
|
||||
|
||||
acf.isHidden = function( $el ){
|
||||
return $el.hasClass('acf-hidden');
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* acf.isVisible
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @date 9/2/18
|
||||
* @since 5.6.5
|
||||
*
|
||||
* @param type $var Description. Default.
|
||||
* @return type Description.
|
||||
*/
|
||||
|
||||
acf.isVisible = function( $el ){
|
||||
return !acf.isHidden( $el );
|
||||
};
|
||||
|
||||
/*
|
||||
* Sortable
|
||||
|
|
@ -5321,9 +5318,9 @@ var acf;
|
|||
|
||||
// hide / show
|
||||
if( visibility ) {
|
||||
this.showField( $target );
|
||||
this.showField( $target, key );
|
||||
} else {
|
||||
this.hideField( $target );
|
||||
this.hideField( $target, key );
|
||||
}
|
||||
|
||||
},
|
||||
|
|
@ -5343,34 +5340,23 @@ var acf;
|
|||
*/
|
||||
|
||||
showField: function( $field, lockKey ){
|
||||
//console.log('showField', lockKey, $field.data('name'), $field.data('type') );
|
||||
// defaults
|
||||
lockKey = lockKey || 'default';
|
||||
|
||||
// bail early if field is not locked (does not need to be unlocked)
|
||||
if( !acf.isLocked($field, CONTEXT) ) {
|
||||
//console.log('- not locked, no need to show');
|
||||
return false;
|
||||
}
|
||||
|
||||
// unlock
|
||||
acf.unlock($field, CONTEXT, lockKey);
|
||||
|
||||
// bail early if field is still locked (by another field)
|
||||
if( acf.isLocked($field, CONTEXT) ) {
|
||||
//console.log('- is still locked, cant show', acf.getLocks($field, CONTEXT));
|
||||
return false;
|
||||
}
|
||||
|
||||
// remove class
|
||||
$field.removeClass( CLASS );
|
||||
|
||||
// enable
|
||||
acf.enable_form( $field, CONTEXT );
|
||||
acf.enable( $field, lockKey );
|
||||
|
||||
// action for 3rd party customization
|
||||
acf.do_action('show_field', $field, CONTEXT );
|
||||
// show field and store result
|
||||
var changed = acf.show( $field, lockKey );
|
||||
|
||||
// use changed to set cl class
|
||||
if( changed ) {
|
||||
$field.removeClass( CLASS );
|
||||
}
|
||||
|
||||
// always do action to avoid tab field bugs (fixed in 5.7)
|
||||
acf.do_action('show_field', $field, CONTEXT);
|
||||
|
||||
// return
|
||||
return changed;
|
||||
},
|
||||
|
||||
|
||||
|
|
@ -5388,31 +5374,23 @@ var acf;
|
|||
*/
|
||||
|
||||
hideField: function( $field, lockKey ){
|
||||
//console.log('hideField', lockKey, $field.data('name'), $field.data('type') );
|
||||
// defaults
|
||||
lockKey = lockKey || 'default';
|
||||
|
||||
// vars
|
||||
var isLocked = acf.isLocked($field, CONTEXT);
|
||||
|
||||
// unlock
|
||||
acf.lock($field, CONTEXT, lockKey);
|
||||
|
||||
// bail early if field is already locked (by another field)
|
||||
if( isLocked ) {
|
||||
//console.log('- is already locked');
|
||||
return false;
|
||||
}
|
||||
|
||||
// add class
|
||||
$field.addClass( CLASS );
|
||||
|
||||
// disable
|
||||
acf.disable_form( $field, CONTEXT );
|
||||
|
||||
// action for 3rd party customization
|
||||
acf.do_action('hide_field', $field, CONTEXT );
|
||||
acf.disable( $field, lockKey );
|
||||
|
||||
// hide field and store result
|
||||
var changed = acf.hide( $field, lockKey );
|
||||
|
||||
// use changed to set cl class
|
||||
if( changed ) {
|
||||
$field.addClass( CLASS );
|
||||
}
|
||||
|
||||
// always do action to avoid tab field bugs (fixed in 5.7)
|
||||
acf.do_action('hide_field', $field, CONTEXT);
|
||||
|
||||
// return
|
||||
return changed;
|
||||
},
|
||||
|
||||
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -769,7 +769,8 @@ function acf_get_fields_by_id( $parent_id = 0 ) {
|
|||
'suppress_filters' => true, // DO NOT allow WPML to modify the query
|
||||
'post_parent' => $parent_id,
|
||||
'post_status' => 'publish, trash', // 'any' won't get trashed fields
|
||||
'update_post_meta_cache' => false
|
||||
'update_post_meta_cache' => false,
|
||||
'update_post_term_cache' => false
|
||||
));
|
||||
|
||||
|
||||
|
|
@ -1047,7 +1048,9 @@ function _acf_get_field_by_name( $name = '', $db_only = false ) {
|
|||
'orderby' => 'menu_order title',
|
||||
'order' => 'ASC',
|
||||
'suppress_filters' => false,
|
||||
'acf_field_name' => $name
|
||||
'acf_field_name' => $name,
|
||||
'update_post_meta_cache' => false,
|
||||
'update_post_term_cache' => false
|
||||
);
|
||||
|
||||
|
||||
|
|
@ -1157,7 +1160,9 @@ function acf_get_field_id( $key = '' ) {
|
|||
'orderby' => 'menu_order title',
|
||||
'order' => 'ASC',
|
||||
'suppress_filters' => false,
|
||||
'acf_field_key' => $key
|
||||
'acf_field_key' => $key,
|
||||
'update_post_meta_cache' => false,
|
||||
'update_post_term_cache' => false
|
||||
);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1823,8 +1823,8 @@ function acf_get_grouped_posts( $args ) {
|
|||
|
||||
|
||||
// attachment doesn't work if it is the only item in an array
|
||||
if( $is_single_post_type) {
|
||||
$args['post_type'] = current($post_types);
|
||||
if( $is_single_post_type ) {
|
||||
$args['post_type'] = reset($post_types);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -3530,98 +3530,116 @@ function acf_maybe_get_GET( $key = '', $default = null ) {
|
|||
* @return (array)
|
||||
*/
|
||||
|
||||
function acf_get_attachment( $post ) {
|
||||
function acf_get_attachment( $attachment ) {
|
||||
|
||||
// post
|
||||
$post = get_post($post);
|
||||
|
||||
|
||||
// bail early if no post
|
||||
if( !$post ) return false;
|
||||
// get post
|
||||
if( !$attachment = get_post($attachment) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// validate post_type
|
||||
if( $attachment->post_type !== 'attachment' ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// vars
|
||||
$thumb_id = 0;
|
||||
$id = $post->ID;
|
||||
$a = array(
|
||||
'ID' => $id,
|
||||
'id' => $id,
|
||||
'title' => $post->post_title,
|
||||
'filename' => wp_basename( $post->guid ),
|
||||
'url' => wp_get_attachment_url( $id ),
|
||||
'alt' => get_post_meta($id, '_wp_attachment_image_alt', true),
|
||||
'author' => $post->post_author,
|
||||
'description' => $post->post_content,
|
||||
'caption' => $post->post_excerpt,
|
||||
'name' => $post->post_name,
|
||||
'date' => $post->post_date_gmt,
|
||||
'modified' => $post->post_modified_gmt,
|
||||
'mime_type' => $post->post_mime_type,
|
||||
'type' => acf_maybe_get( explode('/', $post->post_mime_type), 0, '' ),
|
||||
'icon' => wp_mime_type_icon( $id )
|
||||
$sizes_id = 0;
|
||||
$meta = wp_get_attachment_metadata( $attachment->ID );
|
||||
$attached_file = get_attached_file( $attachment->ID );
|
||||
$attachment_url = wp_get_attachment_url( $attachment->ID );
|
||||
|
||||
// get mime types
|
||||
if( strpos( $attachment->post_mime_type, '/' ) !== false ) {
|
||||
list( $type, $subtype ) = explode( '/', $attachment->post_mime_type );
|
||||
} else {
|
||||
list( $type, $subtype ) = array( $attachment->post_mime_type, '' );
|
||||
}
|
||||
|
||||
// vars
|
||||
$response = array(
|
||||
'ID' => $attachment->ID,
|
||||
'id' => $attachment->ID,
|
||||
'title' => $attachment->post_title,
|
||||
'filename' => wp_basename( $attached_file ),
|
||||
'filesize' => 0,
|
||||
'url' => $attachment_url,
|
||||
'link' => get_attachment_link( $attachment->ID ),
|
||||
'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ),
|
||||
'author' => $attachment->post_author,
|
||||
'description' => $attachment->post_content,
|
||||
'caption' => $attachment->post_excerpt,
|
||||
'name' => $attachment->post_name,
|
||||
'status' => $attachment->post_status,
|
||||
'uploaded_to' => $attachment->post_parent,
|
||||
'date' => $attachment->post_date_gmt,
|
||||
'modified' => $attachment->post_modified_gmt,
|
||||
'menu_order' => $attachment->menu_order,
|
||||
'mime_type' => $attachment->post_mime_type,
|
||||
'type' => $type,
|
||||
'subtype' => $subtype,
|
||||
'icon' => wp_mime_type_icon( $attachment->ID )
|
||||
);
|
||||
|
||||
// filesize
|
||||
if( isset($meta['filesize']) ) {
|
||||
$response['filesize'] = $meta['filesize'];
|
||||
} elseif( file_exists($attached_file) ) {
|
||||
$response['filesize'] = filesize( $attached_file );
|
||||
}
|
||||
|
||||
// video may use featured image
|
||||
if( $a['type'] === 'image' ) {
|
||||
// image
|
||||
if( $type === 'image' ) {
|
||||
|
||||
$thumb_id = $id;
|
||||
$src = wp_get_attachment_image_src( $id, 'full' );
|
||||
$sizes_id = $attachment->ID;
|
||||
$src = wp_get_attachment_image_src( $attachment->ID, 'full' );
|
||||
|
||||
$a['url'] = $src[0];
|
||||
$a['width'] = $src[1];
|
||||
$a['height'] = $src[2];
|
||||
$response['url'] = $src[0];
|
||||
$response['width'] = $src[1];
|
||||
$response['height'] = $src[2];
|
||||
|
||||
// video
|
||||
} elseif( $type === 'video' ) {
|
||||
|
||||
// dimentions
|
||||
$response['width'] = acf_maybe_get($meta, 'width', 0);
|
||||
$response['height'] = acf_maybe_get($meta, 'height', 0);
|
||||
|
||||
} elseif( $a['type'] === 'audio' || $a['type'] === 'video' ) {
|
||||
|
||||
// video dimentions
|
||||
if( $a['type'] == 'video' ) {
|
||||
|
||||
$meta = wp_get_attachment_metadata( $id );
|
||||
$a['width'] = acf_maybe_get($meta, 'width', 0);
|
||||
$a['height'] = acf_maybe_get($meta, 'height', 0);
|
||||
|
||||
// featured image
|
||||
if( $featured_id = get_post_thumbnail_id($attachment->ID) ) {
|
||||
$sizes_id = $featured_id;
|
||||
}
|
||||
|
||||
// audio
|
||||
} elseif( $type === 'audio' ) {
|
||||
|
||||
// feature image
|
||||
if( $featured_id = get_post_thumbnail_id($id) ) {
|
||||
|
||||
$thumb_id = $featured_id;
|
||||
|
||||
}
|
||||
|
||||
// featured image
|
||||
if( $featured_id = get_post_thumbnail_id($attachment->ID) ) {
|
||||
$sizes_id = $featured_id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// sizes
|
||||
if( $thumb_id ) {
|
||||
if( $sizes_id ) {
|
||||
|
||||
// find all image sizes
|
||||
if( $sizes = get_intermediate_image_sizes() ) {
|
||||
|
||||
$a['sizes'] = array();
|
||||
|
||||
foreach( $sizes as $size ) {
|
||||
|
||||
// url
|
||||
$src = wp_get_attachment_image_src( $thumb_id, $size );
|
||||
|
||||
// add src
|
||||
$a['sizes'][ $size ] = $src[0];
|
||||
$a['sizes'][ $size . '-width' ] = $src[1];
|
||||
$a['sizes'][ $size . '-height' ] = $src[2];
|
||||
|
||||
}
|
||||
|
||||
// vars
|
||||
$sizes = get_intermediate_image_sizes();
|
||||
$data = array();
|
||||
|
||||
// loop
|
||||
foreach( $sizes as $size ) {
|
||||
$src = wp_get_attachment_image_src( $sizes_id, $size );
|
||||
$data[ $size ] = $src[0];
|
||||
$data[ $size . '-width' ] = $src[1];
|
||||
$data[ $size . '-height' ] = $src[2];
|
||||
}
|
||||
|
||||
// append
|
||||
$response['sizes'] = $data;
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $a;
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -5100,22 +5118,6 @@ function acf_remove_array_key_prefix( $array, $prefix ) {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
add_filter("acf/settings/slug", '_acf_settings_slug');
|
||||
|
||||
function _acf_settings_slug( $v ) {
|
||||
|
||||
$basename = acf_get_setting('basename');
|
||||
$slug = explode('/', $basename);
|
||||
$slug = current($slug);
|
||||
|
||||
return $slug;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* acf_strip_protocol
|
||||
*
|
||||
|
|
|
|||
|
|
@ -386,9 +386,9 @@ function acf_update_value( $value = null, $post_id = 0, $field ) {
|
|||
|
||||
|
||||
// allow filter to short-circuit update_value logic
|
||||
$value = apply_filters( "acf/pre_update_value", $value, $post_id, $field );
|
||||
if( $value === null ) {
|
||||
return false;
|
||||
$check = apply_filters( "acf/pre_update_value", null, $value, $post_id, $field );
|
||||
if( $check !== null ) {
|
||||
return $check;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -78,8 +78,8 @@ class acf_field_file extends acf_field {
|
|||
'icon' => '',
|
||||
'title' => '',
|
||||
'url' => '',
|
||||
'filesize' => '',
|
||||
'filename' => '',
|
||||
'filesize' => ''
|
||||
);
|
||||
|
||||
$div = array(
|
||||
|
|
@ -93,26 +93,21 @@ class acf_field_file extends acf_field {
|
|||
// has value?
|
||||
if( $field['value'] ) {
|
||||
|
||||
$file = get_post( $field['value'] );
|
||||
|
||||
if( $file ) {
|
||||
$attachment = acf_get_attachment($field['value']);
|
||||
if( $attachment ) {
|
||||
|
||||
$o['icon'] = wp_mime_type_icon( $file->ID );
|
||||
$o['title'] = $file->post_title;
|
||||
$o['filesize'] = @size_format(filesize( get_attached_file( $file->ID ) ));
|
||||
$o['url'] = wp_get_attachment_url( $file->ID );
|
||||
|
||||
$explode = explode('/', $o['url']);
|
||||
$o['filename'] = end( $explode );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// url exists
|
||||
if( $o['url'] ) {
|
||||
// has value
|
||||
$div['class'] .= ' has-value';
|
||||
}
|
||||
|
||||
|
||||
// update
|
||||
$o['icon'] = $attachment['icon'];
|
||||
$o['title'] = $attachment['title'];
|
||||
$o['url'] = $attachment['url'];
|
||||
$o['filename'] = $attachment['filename'];
|
||||
if( $attachment['filesize'] ) {
|
||||
$o['filesize'] = size_format($attachment['filesize']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -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:50+0200\n"
|
||||
"PO-Revision-Date: 2018-02-06 10:07+1000\n"
|
||||
"PO-Revision-Date: 2018-03-14 09:58+1000\n"
|
||||
"Last-Translator: Elliot Condon <e@elliotcondon.com>\n"
|
||||
"Language-Team: Amos Lee <470266798@qq.com>\n"
|
||||
"Language: zh_CN\n"
|
||||
|
|
@ -2486,7 +2486,7 @@ msgstr "已到最小行数 ({min} 行)"
|
|||
|
||||
#: pro/fields/repeater.php:47
|
||||
msgid "Maximum rows reached ({max} rows)"
|
||||
msgstr "已到最大行数 ({min} 行)"
|
||||
msgstr "已到最大行数 ({max} 行)"
|
||||
|
||||
#: pro/fields/repeater.php:259
|
||||
msgid "Drag to reorder"
|
||||
|
|
|
|||
|
|
@ -66,6 +66,9 @@ From your WordPress dashboard
|
|||
|
||||
== Changelog ==
|
||||
|
||||
= 5.6.10 =
|
||||
* Core: Minor fixes and improvements
|
||||
|
||||
= 5.6.9 =
|
||||
* User field: Added new 'Return Format' setting (Array, Object, ID)
|
||||
* Core: Added basic compatibility with Gutenberg - values now save
|
||||
|
|
|
|||
Loading…
Reference in New Issue