Merge branch 'release/5.8.7'

This commit is contained in:
Remco Tolsma 2019-12-24 15:23:30 +01:00
commit 459c0ea0a1
37 changed files with 1700 additions and 1913 deletions

View File

@ -3,7 +3,7 @@
Plugin Name: Advanced Custom Fields PRO Plugin Name: Advanced Custom Fields PRO
Plugin URI: https://www.advancedcustomfields.com Plugin URI: https://www.advancedcustomfields.com
Description: Customize WordPress with powerful, professional and intuitive fields. Description: Customize WordPress with powerful, professional and intuitive fields.
Version: 5.8.4 Version: 5.8.7
Author: Elliot Condon Author: Elliot Condon
Author URI: https://www.advancedcustomfields.com Author URI: https://www.advancedcustomfields.com
Text Domain: acf Text Domain: acf
@ -17,7 +17,7 @@ if( ! class_exists('ACF') ) :
class ACF { class ACF {
/** @var string The plugin version number. */ /** @var string The plugin version number. */
var $version = '5.8.4'; var $version = '5.8.7';
/** @var array The plugin settings array. */ /** @var array The plugin settings array. */
var $settings = array(); var $settings = array();
@ -165,7 +165,6 @@ class ACF {
acf_include('includes/admin/admin-notices.php'); acf_include('includes/admin/admin-notices.php');
acf_include('includes/admin/admin-tools.php'); acf_include('includes/admin/admin-tools.php');
acf_include('includes/admin/admin-upgrade.php'); acf_include('includes/admin/admin-upgrade.php');
acf_include('includes/admin/settings-info.php');
} }
// Include PRO. // Include PRO.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -412,10 +412,6 @@ class acf_admin_field_group {
// remove edit links // remove edit links
$('#misc-publishing-actions a').remove(); $('#misc-publishing-actions a').remove();
// remove editables (fixes status text changing on submit)
$('#misc-publishing-actions .hide-if-js').remove();
})(jQuery); })(jQuery);
</script> </script>
<?php <?php

View File

@ -52,50 +52,67 @@ class ACF_Admin_Upgrade {
} }
/** /**
* network_admin_menu * network_admin_menu
* *
* Setus up logic if DB Upgrade is needed on a multi site. * Sets up admin logic if DB Upgrade is required on a multi site.
* *
* @date 24/8/18 * @date 24/8/18
* @since 5.7.4 * @since 5.7.4
* *
* @param void * @param void
* @return void * @return void
*/ */
function network_admin_menu() { function network_admin_menu() {
// vars // Vars.
$has_upgrade = false; $upgrade = false;
// loop over sites // Loop over sites and check for upgrades.
$sites = acf_get_sites(); $sites = get_sites( array( 'number' => 0 ) );
if( $sites ) { if( $sites ) {
foreach( $sites as $site ) {
// Unhook action to avoid memory issue (as seen in wp-includes/ms-site.php).
remove_action( 'switch_blog', 'wp_switch_roles_and_user', 1 );
foreach( $sites as $site ) {
// switch blog // Switch site.
switch_to_blog( $site['blog_id'] ); switch_to_blog( $site->blog_id );
// check for upgrade // Check for upgrade.
if( acf_has_upgrade() ) { $site_upgrade = acf_has_upgrade();
$has_upgrade = true;
} // Restore site.
// Ideally, we would switch back to the original site at after looping, however,
// restore blog // the restore_current_blog() is needed to modify global vars.
restore_current_blog(); restore_current_blog();
}}
// Check if upgrade was found.
// check if upgrade is avaialble if( $site_upgrade ) {
if( $has_upgrade ) { $upgrade = true;
break;
// add notice }
add_action('network_admin_notices', array($this, 'network_admin_notices')); }
add_action( 'switch_blog', 'wp_switch_roles_and_user', 1, 2 );
// add page
$page = add_submenu_page('index.php', __('Upgrade Database','acf'), __('Upgrade Database','acf'), acf_get_setting('capability'), 'acf-upgrade-network', array($this,'network_admin_html'));
// actions
add_action('load-' . $page, array($this,'network_admin_load'));
} }
// Bail early if no upgrade is needed.
if( !$upgrade ) {
return;
}
// Add notice.
add_action('network_admin_notices', array($this, 'network_admin_notices'));
// Add page.
$page = add_submenu_page(
'index.php',
__('Upgrade Database','acf'),
__('Upgrade Database','acf'),
acf_get_setting('capability'),
'acf-upgrade-network',
array( $this,'network_admin_html' )
);
add_action( "load-$page", array( $this, 'network_admin_load' ) );
} }
/** /**

View File

@ -2,88 +2,140 @@
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if( ! class_exists('acf_admin') ) : if( ! class_exists('ACF_Admin') ) :
class acf_admin { class ACF_Admin {
/* /**
* __construct * __construct
* *
* Initialize filters, action, variables and includes * Sets up the class functionality.
* *
* @type function * @date 23/06/12
* @date 23/06/12 * @since 5.0.0
* @since 5.0.0 *
* * @param void
* @param n/a * @return void
* @return n/a */
*/ function __construct() {
function __construct() { // Add hooks.
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
// actions add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
add_action('admin_menu', array($this, 'admin_menu')); add_action( 'admin_body_class', array( $this, 'admin_body_class' ) );
add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'), 0);
} }
/* /**
* admin_menu * admin_menu
* *
* This function will add the ACF menu item to the WP admin * Adds the ACF menu item.
* *
* @type action (admin_menu) * @date 28/09/13
* @date 28/09/13 * @since 5.0.0
* @since 5.0.0 *
* * @param void
* @param n/a * @return void
* @return n/a */
*/ function admin_menu() {
function admin_menu() {
// bail early if no show_admin // Bail early if ACF is hidden.
if( !acf_get_setting('show_admin') ) return; if( !acf_get_setting('show_admin') ) {
return;
}
// Vars.
// vars
$slug = 'edit.php?post_type=acf-field-group'; $slug = 'edit.php?post_type=acf-field-group';
$cap = acf_get_setting('capability'); $cap = acf_get_setting('capability');
// Add menu items.
add_menu_page( __("Custom Fields",'acf'), __("Custom Fields",'acf'), $cap, $slug, false, 'dashicons-welcome-widgets-menus', '80.025' );
add_submenu_page( $slug, __('Field Groups','acf'), __('Field Groups','acf'), $cap, $slug );
add_submenu_page( $slug, __('Add New','acf'), __('Add New','acf'), $cap, 'post-new.php?post_type=acf-field-group' );
// add parent // Only register info page when needed.
add_menu_page(__("Custom Fields",'acf'), __("Custom Fields",'acf'), $cap, $slug, false, 'dashicons-welcome-widgets-menus', '80.025'); if( isset($_GET['page']) && $_GET['page'] === 'acf-settings-info' ) {
add_submenu_page( $slug, __('Info','acf'), __('Info','acf'), $cap,'acf-settings-info', array($this,'info_page_html') );
}
// add children
add_submenu_page($slug, __('Field Groups','acf'), __('Field Groups','acf'), $cap, $slug );
add_submenu_page($slug, __('Add New','acf'), __('Add New','acf'), $cap, 'post-new.php?post_type=acf-field-group' );
} }
/**
/* * admin_enqueue_scripts
* admin_enqueue_scripts *
* * Enqueues global admin styling.
* This function will add the already registered css *
* * @date 28/09/13
* @type function * @since 5.0.0
* @date 28/09/13 *
* @since 5.0.0 * @param void
* * @return void
* @param n/a */
* @return n/a
*/
function admin_enqueue_scripts() { function admin_enqueue_scripts() {
// Enqueue global style. To-do: Change to admin.
wp_enqueue_style( 'acf-global' ); wp_enqueue_style( 'acf-global' );
}
/**
* admin_body_class
*
* Appends the determined body_class.
*
* @date 5/11/19
* @since 5.8.7
*
* @param string $classes Space-separated list of CSS classes.
* @return string
*/
function admin_body_class( $classes ) {
global $wp_version;
// Determine body class version.
$wp_minor_version = floatval( $wp_version );
if( $wp_minor_version >= 5.3 ) {
$body_class = 'acf-admin-5-3';
} else {
$body_class = 'acf-admin-3-8';
}
// Append and return.
return $classes . ' ' . $body_class;
}
/**
* info_page_html
*
* Renders the Info page HTML.
*
* @date 5/11/19
* @since 5.8.7
*
* @param void
* @return void
*/
function info_page_html() {
// Vars.
$view = array(
'version' => acf_get_setting('version'),
'have_pro' => acf_get_setting('pro'),
'tabs' => array(
'new' => __("What's New", 'acf'),
'changelog' => __("Changelog", 'acf')
),
'active' => 'new'
);
// Find active tab.
if( isset($_GET['tab']) && $_GET['tab'] === 'changelog' ) {
$view['active'] = 'changelog';
}
// Load view.
acf_get_view('settings-info', $view);
} }
} }
// initialize // Instantiate.
acf()->admin = new acf_admin(); acf_new_instance('ACF_Admin');
endif; // class_exists check endif; // class_exists check
?>

View File

@ -1,102 +0,0 @@
<?php
class acf_settings_info {
/*
* __construct
*
* Initialize filters, action, variables and includes
*
* @type function
* @date 23/06/12
* @since 5.0.0
*
* @param n/a
* @return n/a
*/
function __construct() {
// actions
add_action('admin_menu', array($this, 'admin_menu'));
}
/*
* admin_menu
*
* This function will add the ACF menu item to the WP admin
*
* @type action (admin_menu)
* @date 28/09/13
* @since 5.0.0
*
* @param n/a
* @return n/a
*/
function admin_menu() {
// bail early if no show_admin
if( !acf_get_setting('show_admin') ) {
return;
}
// add page
add_submenu_page('edit.php?post_type=acf-field-group', __('Info','acf'), __('Info','acf'), acf_get_setting('capability'),'acf-settings-info', array($this,'html'));
}
/*
* html
*
* description
*
* @type function
* @date 7/01/2014
* @since 5.0.0
*
* @param $post_id (int)
* @return $post_id (int)
*/
function html() {
// vars
$view = array(
'version' => acf_get_setting('version'),
'have_pro' => acf_get_setting('pro'),
'tabs' => array(
'new' => __("What's New", 'acf'),
'changelog' => __("Changelog", 'acf')
),
'active' => 'new'
);
// set active tab
$tab = acf_maybe_get_GET('tab');
if( $tab && isset($view['tabs'][ $tab ]) ) {
$view['active'] = $tab;
}
// load view
acf_get_view('settings-info', $view);
}
}
// initialize
new acf_settings_info();
?>

View File

@ -1,54 +0,0 @@
<div class="wrap acf-settings-wrap">
<h1><?php _e("Add-ons",'acf'); ?></h1>
<div class="add-ons-list">
<?php if( !empty($json) ): ?>
<?php foreach( $json as $addon ):
$addon = wp_parse_args($addon, array(
"title" => "",
"slug" => "",
"description" => "",
"thumbnail" => "",
"url" => "",
"btn" => __("Download & Install",'acf'),
"btn_color" => ""
));
?>
<div class="acf-box add-on add-on-<?php echo $addon['slug']; ?>">
<div class="thumbnail">
<a target="_blank" href="<?php echo $addon['url']; ?>">
<img src="<?php echo $addon['thumbnail']; ?>" />
</a>
</div>
<div class="inner">
<h3><a target="_blank" href="<?php echo $addon['url']; ?>"><?php echo $addon['title']; ?></a></h3>
<p><?php echo $addon['description']; ?></p>
</div>
<div class="footer">
<?php if( apply_filters("acf/is_add_on_active/slug={$addon['slug']}", false ) ): ?>
<a class="button" disabled="disabled"><?php _e("Installed",'acf'); ?></a>
<?php else: ?>
<a class="button <?php echo $addon['btn_color']; ?>" target="_blank" href="<?php echo $addon['url']; ?>" ><?php _e($addon['btn']); ?></a>
<?php endif; ?>
<?php if( !empty($addon['footer']) ): ?>
<p><?php echo $addon['footer']; ?></p>
<?php endif; ?>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
</div>

View File

@ -3167,7 +3167,7 @@ function acf_get_attachment( $attachment ) {
// video // video
} elseif( $type === 'video' ) { } elseif( $type === 'video' ) {
// dimentions // dimensions
$response['width'] = acf_maybe_get($meta, 'width', 0); $response['width'] = acf_maybe_get($meta, 'width', 0);
$response['height'] = acf_maybe_get($meta, 'height', 0); $response['height'] = acf_maybe_get($meta, 'height', 0);

View File

@ -160,8 +160,24 @@ class ACF_Assets {
if( $args['uploader'] ) { if( $args['uploader'] ) {
add_action($actions['admin_footer'], 'acf_enqueue_uploader', 5); add_action($actions['admin_footer'], 'acf_enqueue_uploader', 5);
} }
}
/**
* admin_enqueue_scripts
*
* description
*
* @date 16/4/18
* @since 5.6.9
*
* @param type $var Description. Default.
* @return type Description.
*/
function admin_enqueue_scripts() {
// localize text // Localize text.
acf_localize_text(array( acf_localize_text(array(
// unload // unload
@ -205,22 +221,6 @@ class ACF_Assets {
// misc // misc
'Edit field group' => __('Edit field group', 'acf'), 'Edit field group' => __('Edit field group', 'acf'),
)); ));
}
/**
* admin_enqueue_scripts
*
* description
*
* @date 16/4/18
* @since 5.6.9
*
* @param type $var Description. Default.
* @return type Description.
*/
function admin_enqueue_scripts() {
// enqueue // enqueue
wp_enqueue_script('acf-input'); wp_enqueue_script('acf-input');

View File

@ -111,32 +111,15 @@ class acf_field_google_map extends acf_field {
function render_field( $field ) { function render_field( $field ) {
// validate value // Apply defaults.
if( empty($field['value']) ) {
$field['value'] = array();
}
// value
$field['value'] = wp_parse_args($field['value'], array(
'address' => '',
'lat' => '',
'lng' => ''
));
// default options
foreach( $this->default_values as $k => $v ) { foreach( $this->default_values as $k => $v ) {
if( !$field[ $k ] ) {
if( empty($field[ $k ]) ) {
$field[ $k ] = $v; $field[ $k ] = $v;
} }
} }
// Attrs.
// vars $attrs = array(
$atts = array(
'id' => $field['id'], 'id' => $field['id'],
'class' => "acf-google-map {$field['class']}", 'class' => "acf-google-map {$field['class']}",
'data-lat' => $field['center_lat'], 'data-lat' => $field['center_lat'],
@ -144,20 +127,18 @@ class acf_field_google_map extends acf_field {
'data-zoom' => $field['zoom'], 'data-zoom' => $field['zoom'],
); );
$search = '';
// has value if( $field['value'] ) {
if( $field['value']['address'] ) { $attrs['class'] .= ' -value';
$atts['class'] .= ' -value'; $search = $field['value']['address'];
} else {
$field['value'] = '';
} }
?> ?>
<div <?php acf_esc_attr_e($atts); ?>> <div <?php acf_esc_attr_e($attrs); ?>>
<div class="acf-hidden"> <?php acf_hidden_input( array('name' => $field['name'], 'value' => $field['value']) ); ?>
<?php foreach( $field['value'] as $k => $v ):
acf_hidden_input(array( 'name' => $field['name'].'['.$k.']', 'value' => $v, 'data-name' => $k ));
endforeach; ?>
</div>
<div class="title"> <div class="title">
@ -167,7 +148,7 @@ class acf_field_google_map extends acf_field {
?><a href="#" data-name="locate" class="acf-icon -location grey" title="<?php _e("Find current location", 'acf'); ?>"></a> ?><a href="#" data-name="locate" class="acf-icon -location grey" title="<?php _e("Find current location", 'acf'); ?>"></a>
</div> </div>
<input class="search" type="text" placeholder="<?php _e("Search for address...",'acf'); ?>" value="<?php echo esc_attr($field['value']['address']); ?>" /> <input class="search" type="text" placeholder="<?php _e("Search for address...",'acf'); ?>" value="<?php echo esc_attr( $search ); ?>" />
<i class="acf-loading"></i> <i class="acf-loading"></i>
</div> </div>
@ -240,40 +221,32 @@ class acf_field_google_map extends acf_field {
} }
/**
/* * load_value
* validate_value *
* * Filters the value loaded from the database.
* description *
* * @date 16/10/19
* @type function * @since 5.8.1
* @date 11/02/2014 *
* @since 5.0.0 * @param mixed $value The value loaded from the database.
* * @param mixed $post_id The post ID where the value is saved.
* @param $post_id (int) * @param array $field The field settings array.
* @return $post_id (int) * @return (array|false)
*/ */
function load_value( $value, $post_id, $field ) {
function validate_value( $valid, $value, $field, $input ){
// bail early if not required // Ensure value is an array.
if( ! $field['required'] ) { if( $value ) {
return wp_parse_args($value, array(
return $valid; 'address' => '',
'lat' => 0,
'lng' => 0
));
} }
// Return default.
if( empty($value) || empty($value['lat']) || empty($value['lng']) ) { return false;
return false;
}
// return
return $valid;
} }
@ -292,16 +265,20 @@ class acf_field_google_map extends acf_field {
* *
* @return $value - the modified value * @return $value - the modified value
*/ */
function update_value( $value, $post_id, $field ) { function update_value( $value, $post_id, $field ) {
// Check if value is an empty array and convert to empty string. // decode JSON string.
if( empty($value) || empty($value['lat']) ) { if( is_string($value) ) {
$value = ""; $value = json_decode( wp_unslash($value), true );
} }
// return // Ensure value is an array.
return $value; if( $value ) {
return (array) $value;
}
// Return default.
return false;
} }
} }

View File

@ -132,7 +132,7 @@ class acf_field_radio extends acf_field {
// append other choice // append other choice
$field['choices']['other'] .= '</label><input type="text" ' . acf_esc_attr($input) . ' /><label>'; $field['choices']['other'] .= '</label> <input type="text" ' . acf_esc_attr($input) . ' /><label>';
} }

View File

@ -427,7 +427,7 @@ class acf_field_wysiwyg extends acf_field {
// delay // delay
acf_render_field_setting( $field, array( acf_render_field_setting( $field, array(
'label' => __('Delay initialization?','acf'), 'label' => __('Delay initialization?','acf'),
'instructions' => __('TinyMCE will not be initalized until field is clicked','acf'), 'instructions' => __('TinyMCE will not be initialized until field is clicked','acf'),
'name' => 'delay', 'name' => 'delay',
'type' => 'true_false', 'type' => 'true_false',
'ui' => 1, 'ui' => 1,

View File

@ -128,13 +128,13 @@ acf.unload.active = 0;
$is_page = acf_is_screen('attachment'); $is_page = acf_is_screen('attachment');
$post_id = $post->ID; $post_id = $post->ID;
$el = 'tr'; $el = 'tr';
$args = array(
'attachment' => $post_id
);
// get field groups // get field groups
$field_groups = acf_get_field_groups( $args ); $field_groups = acf_get_field_groups(array(
'attachment_id' => $post_id,
'attachment' => $post_id // Leave for backwards compatibility
));
// render // render

View File

@ -87,6 +87,7 @@ class acf_form_front {
function validate_form( $args ) { function validate_form( $args ) {
// defaults // defaults
// Todo: Allow message and button text to be generated by CPT settings.
$args = wp_parse_args( $args, array( $args = wp_parse_args( $args, array(
'id' => 'acf-form', 'id' => 'acf-form',
'post_id' => false, 'post_id' => false,
@ -360,35 +361,38 @@ class acf_form_front {
function check_submit_form() { function check_submit_form() {
// verify nonce // Verify nonce.
if( !acf_verify_nonce('acf_form') ) return; if( !acf_verify_nonce('acf_form') ) {
return false;
}
// Confirm form was submit.
if( !isset($_POST['_acf_form']) ) {
return false;
}
// bail ealry if form not submit // Load registered form using id.
if( empty($_POST['_acf_form']) ) return; $form = $this->get_form( $_POST['_acf_form'] );
// Fallback to encrypted JSON.
// load form if( !$form ) {
$form = json_decode( acf_decrypt($_POST['_acf_form']), true ); $form = json_decode( acf_decrypt($_POST['_acf_form']), true );
if( !$form ) {
return false;
// bail ealry if form is corrupt }
if( empty($form) ) return; }
// Run kses on all $_POST data.
// kses
if( $form['kses'] && isset($_POST['acf']) ) { if( $form['kses'] && isset($_POST['acf']) ) {
$_POST['acf'] = wp_kses_post_deep( $_POST['acf'] ); $_POST['acf'] = wp_kses_post_deep( $_POST['acf'] );
} }
// Validate data and show errors.
// Todo: Return WP_Error and show above form, keeping input values.
acf_validate_save_post( true );
// validate data // Submit form.
acf_validate_save_post(true);
// submit
$this->submit_form( $form ); $this->submit_form( $form );
} }
@ -471,191 +475,126 @@ class acf_form_front {
function render_form( $args = array() ) { function render_form( $args = array() ) {
// array // Vars.
if( is_array($args) ) { $is_registered = false;
$args = $this->validate_form( $args );
// id
} else {
$args = $this->get_form( $args );
}
// bail early if no args
if( !$args ) return false;
// load values from this post
$post_id = $args['post_id'];
// dont load values for 'new_post'
if( $post_id === 'new_post' ) $post_id = false;
// register local fields
foreach( $this->fields as $k => $field ) {
acf_add_local_field($field);
}
// vars
$field_groups = array(); $field_groups = array();
$fields = array(); $fields = array();
// Allow form settings to be directly provided.
// post_title if( is_array($args) ) {
if( $args['post_title'] ) { $args = $this->validate_form( $args );
// load local field // Otherwise, lookup registered form.
} else {
$is_registered = true;
$args = $this->get_form( $args );
if( !$args ) {
return false;
}
}
// Extract vars.
$post_id = $args['post_id'];
// Prevent ACF from loading values for "new_post".
if( $post_id === 'new_post' ) {
$post_id = false;
}
// Set uploader type.
acf_update_setting('uploader', $args['uploader']);
// Register local fields.
foreach( $this->fields as $k => $field ) {
acf_add_local_field($field);
}
// Append post_title field.
if( $args['post_title'] ) {
$_post_title = acf_get_field('_post_title'); $_post_title = acf_get_field('_post_title');
$_post_title['value'] = $post_id ? get_post_field('post_title', $post_id) : ''; $_post_title['value'] = $post_id ? get_post_field('post_title', $post_id) : '';
// append
$fields[] = $_post_title; $fields[] = $_post_title;
} }
// Append post_content field.
// post_content
if( $args['post_content'] ) { if( $args['post_content'] ) {
// load local field
$_post_content = acf_get_field('_post_content'); $_post_content = acf_get_field('_post_content');
$_post_content['value'] = $post_id ? get_post_field('post_content', $post_id) : ''; $_post_content['value'] = $post_id ? get_post_field('post_content', $post_id) : '';
$fields[] = $_post_content;
// append
$fields[] = $_post_content;
} }
// Load specific fields.
// specific fields
if( $args['fields'] ) { if( $args['fields'] ) {
// Lookup fields using $strict = false for better compatibility with field names.
foreach( $args['fields'] as $selector ) { foreach( $args['fields'] as $selector ) {
// append field ($strict = false to allow for better compatibility with field names)
$fields[] = acf_maybe_get_field( $selector, $post_id, false ); $fields[] = acf_maybe_get_field( $selector, $post_id, false );
} }
// Load specific field groups.
} elseif( $args['field_groups'] ) { } elseif( $args['field_groups'] ) {
foreach( $args['field_groups'] as $selector ) { foreach( $args['field_groups'] as $selector ) {
$field_groups[] = acf_get_field_group( $selector ); $field_groups[] = acf_get_field_group( $selector );
} }
// Load fields for the given "new_post" args.
} elseif( $args['post_id'] == 'new_post' ) { } elseif( $args['post_id'] == 'new_post' ) {
$field_groups = acf_get_field_groups( $args['new_post'] ); $field_groups = acf_get_field_groups( $args['new_post'] );
// Load fields for the given "post_id" arg.
} else { } else {
$field_groups = acf_get_field_groups(array( $field_groups = acf_get_field_groups(array(
'post_id' => $args['post_id'] 'post_id' => $args['post_id']
)); ));
} }
// load fields from the found field groups.
//load fields based on field groups if( $field_groups ) {
if( !empty($field_groups) ) {
foreach( $field_groups as $field_group ) { foreach( $field_groups as $field_group ) {
$_fields = acf_get_fields( $field_group );
$field_group_fields = acf_get_fields( $field_group ); if( $_fields ) {
foreach( $_fields as $_field ) {
if( !empty($field_group_fields) ) { $fields[] = $_field;
foreach( array_keys($field_group_fields) as $i ) {
$fields[] = acf_extract_var($field_group_fields, $i);
} }
} }
} }
} }
// Add honeypot field.
// honeypot
if( $args['honeypot'] ) { if( $args['honeypot'] ) {
$fields[] = acf_get_field('_validate_email'); $fields[] = acf_get_field('_validate_email');
} }
// Display updated_message
// updated message
if( !empty($_GET['updated']) && $args['updated_message'] ) { if( !empty($_GET['updated']) && $args['updated_message'] ) {
printf( $args['html_updated_message'], $args['updated_message'] ); printf( $args['html_updated_message'], $args['updated_message'] );
} }
// uploader (always set incase of multiple forms on the page)
acf_update_setting('uploader', $args['uploader']);
// display form // display form
if( $args['form'] ): ?> if( $args['form'] ): ?>
<form <?php echo acf_esc_attrs( $args['form_attributes'] ); ?>>
<form <?php acf_esc_attr_e( $args['form_attributes']); ?>>
<?php endif; <?php endif;
// render post data // Render hidde form data.
acf_form_data(array( acf_form_data(array(
'screen' => 'acf_form', 'screen' => 'acf_form',
'post_id' => $args['post_id'], 'post_id' => $args['post_id'],
'form' => acf_encrypt(json_encode($args)) 'form' => $is_registered ? $args['id'] : acf_encrypt(json_encode($args))
)); ));
?>
<div class="acf-fields acf-form-fields -<?php echo $args['label_placement']; ?>">
<?php
// html before fields
echo $args['html_before_fields'];
// render
acf_render_fields( $fields, $post_id, $args['field_el'], $args['instruction_placement'] );
// html after fields
echo $args['html_after_fields'];
?> ?>
</div> <div class="acf-fields acf-form-fields -<?php echo esc_attr($args['label_placement']); ?>">
<?php echo $args['html_before_fields']; ?>
<?php acf_render_fields( $fields, $post_id, $args['field_el'], $args['instruction_placement'] ); ?>
<?php echo $args['html_after_fields']; ?>
</div>
<?php if( $args['form'] ): ?> <?php if( $args['form'] ): ?>
<div class="acf-form-submit">
<div class="acf-form-submit"> <?php printf( $args['html_submit_button'], $args['submit_value'] ); ?>
<?php echo $args['html_submit_spinner']; ?>
<?php printf( $args['html_submit_button'], $args['submit_value'] ); ?> </div>
<?php echo $args['html_submit_spinner']; ?>
</div>
</form> </form>
<?php endif; <?php endif;
} }
} }
@ -694,7 +633,7 @@ function acf_form( $args = array() ) {
function acf_get_form( $id = '' ) { function acf_get_form( $id = '' ) {
acf()->form_front->get_form( $id ); return acf()->form_front->get_form( $id );
} }

View File

@ -366,6 +366,11 @@ function acf_add_local_field( $field, $prepared = false ) {
return acf_add_local_fields( array( $field ) ); return acf_add_local_fields( array( $field ) );
} }
// Set menu order.
if( !isset($field['menu_order']) ) {
$field['menu_order'] = acf_count_local_fields( $field['parent'] );
}
// Extract attributes. // Extract attributes.
$key = $field['key']; $key = $field['key'];
$name = $field['name']; $name = $field['name'];

View File

@ -50,6 +50,11 @@ class acf_location_post_taxonomy extends acf_location {
$post_id = acf_maybe_get( $screen, 'post_id' ); $post_id = acf_maybe_get( $screen, 'post_id' );
$post_terms = acf_maybe_get( $screen, 'post_terms' ); $post_terms = acf_maybe_get( $screen, 'post_terms' );
// Allow compatibility for attachments.
if( !$post_id ) {
$post_id = acf_maybe_get( $screen, 'attachment_id' );
}
// bail early if not a post // bail early if not a post
if( !$post_id ) return false; if( !$post_id ) return false;

View File

@ -2,115 +2,82 @@
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if( ! class_exists('acf_location_user_form') ) : if( ! class_exists('ACF_Location_User_Form') ) :
class acf_location_user_form extends acf_location { class ACF_Location_User_Form extends ACF_Location {
/*
* __construct
*
* This function will setup the class functionality
*
* @type function
* @date 5/03/2014
* @since 5.0.0
*
* @param n/a
* @return n/a
*/
/**
* initialize
*
* Sets up the class functionality.
*
* @date 5/03/2014
* @since 5.0.0
*
* @param void
* @return void
*/
function initialize() { function initialize() {
// vars
$this->name = 'user_form'; $this->name = 'user_form';
$this->label = __("User Form",'acf'); $this->label = __("User Form", 'acf');
$this->category = 'user'; $this->category = 'user';
} }
/**
/* * rule_match
* rule_match *
* * Determines if the given location $rule is a match for the current $screen.
* This function is used to match this location $rule to the current $screen *
* * @date 17/9/19
* @type function * @since 5.8.1
* @date 3/01/13 *
* @since 3.5.7 * @param bool $result Whether or not this location rule is a match.
* * @param array $rule The locatio rule data.
* @param $match (boolean) * @param array $screen The current screen data.
* @param $rule (array) * @return bool
* @return $options (array) */
*/
function rule_match( $result, $rule, $screen ) { function rule_match( $result, $rule, $screen ) {
// vars // Extract vars.
$user_form = acf_maybe_get( $screen, 'user_form' ); $user_form = acf_maybe_get($screen, 'user_form');
// Return false if no user_form data.
// bail early if no user form if( !$user_form ) {
if( !$user_form ) return false; return false;
// add is treated the same as edit
if( $user_form === 'add' ) {
$user_form = 'edit';
} }
// The "Add / Edit" choice (foolishly valued "edit") should match true for either "add" or "edit".
// match if( $rule['value'] === 'edit' && $user_form === 'add' ) {
$user_form = 'edit';
}
// Compare and return.
return $this->compare( $user_form, $rule ); return $this->compare( $user_form, $rule );
} }
/**
/* * rule_values
* rule_operators *
* * Returns an array of values for this location rule.
* This function returns the available values for this rule type *
* * @date 17/9/19
* @type function * @since 5.8.1
* @date 30/5/17 *
* @since 5.6.0 * @param array $choices An empty array.
* * @param array $rule The locatio rule data.
* @param n/a * @return type Description.
* @return (array) */
*/
function rule_values( $choices, $rule ) { function rule_values( $choices, $rule ) {
return array( return array(
'all' => __('All', 'acf'), 'all' => __('All', 'acf'),
'add' => __('Add', 'acf'),
'edit' => __('Add / Edit', 'acf'), 'edit' => __('Add / Edit', 'acf'),
'register' => __('Register', 'acf') 'register' => __('Register', 'acf')
); );
/*
// global
global $wp_roles;
// vars
$choices = array( 'all' => __('All', 'acf') );
$choices = array_merge( $choices, $wp_roles->get_names() );
// return
return $choices;
*/
} }
} }
// initialize // Register.
acf_register_location_rule( 'acf_location_user_form' ); acf_register_location_rule( 'ACF_Location_User_Form' );
endif; // class_exists check endif; // class_exists check
?>

View File

@ -2,126 +2,95 @@
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if( ! class_exists('acf_location_user_role') ) : if( ! class_exists('ACF_Location_User_Role') ) :
class acf_location_user_role extends acf_location { class ACF_Location_User_Role extends acf_location {
/*
* __construct
*
* This function will setup the class functionality
*
* @type function
* @date 5/03/2014
* @since 5.0.0
*
* @param n/a
* @return n/a
*/
/**
* initialize
*
* Sets up the class functionality.
*
* @date 5/03/2014
* @since 5.0.0
*
* @param void
* @return void
*/
function initialize() { function initialize() {
// vars
$this->name = 'user_role'; $this->name = 'user_role';
$this->label = __("User Role",'acf'); $this->label = __("User Role", 'acf');
$this->category = 'user'; $this->category = 'user';
} }
/**
/* * rule_match
* rule_match *
* * Determines if the given location $rule is a match for the current $screen.
* This function is used to match this location $rule to the current $screen *
* * @date 17/9/19
* @type function * @since 5.8.1
* @date 3/01/13 *
* @since 3.5.7 * @param bool $result Whether or not this location rule is a match.
* * @param array $rule The locatio rule data.
* @param $match (boolean) * @param array $screen The current screen data.
* @param $rule (array) * @return bool
* @return $options (array) */
*/
function rule_match( $result, $rule, $screen ) { function rule_match( $result, $rule, $screen ) {
// vars // Extract vars.
$user_id = acf_maybe_get( $screen, 'user_id' ); $user_id = acf_maybe_get( $screen, 'user_id' );
$user_role = acf_maybe_get( $screen, 'user_role' ); $user_role = acf_maybe_get( $screen, 'user_role' );
// Allow $user_role to be supplied (third-party compatibility).
// if user_role is supplied (3rd party compatibility)
if( $user_role ) { if( $user_role ) {
// Do nothing
// do nothing
// user_id (expected) // Determine $user_role from $user_id.
} elseif( $user_id ) { } elseif( $user_id ) {
// new user // Use default role for new user.
if( $user_id == 'new' ) { if( $user_id == 'new' ) {
// set to default role
$user_role = get_option('default_role'); $user_role = get_option('default_role');
// existing user // Check if user can, and if so, set the value allowing them to match.
} elseif( user_can($user_id, $rule['value']) ) { } elseif( user_can($user_id, $rule['value']) ) {
// set to value and allow match
$user_role = $rule['value']; $user_role = $rule['value'];
} }
// else // Return false if not a user.
} else { } else {
// not a user
return false; return false;
} }
// Compare and return.
// match
return $this->compare( $user_role, $rule ); return $this->compare( $user_role, $rule );
} }
/**
/* * rule_values
* rule_operators *
* * Returns an array of values for this location rule.
* This function returns the available values for this rule type *
* * @date 17/9/19
* @type function * @since 5.8.1
* @date 30/5/17 *
* @since 5.6.0 * @param array $choices An empty array.
* * @param array $rule The locatio rule data.
* @param n/a * @return array
* @return (array) */
*/
function rule_values( $choices, $rule ) { function rule_values( $choices, $rule ) {
// global
global $wp_roles; global $wp_roles;
// Merge roles with defaults and return.
// vars return wp_parse_args($wp_roles->get_names(), array(
$choices = array( 'all' => __('All', 'acf') ); 'all' => __('All', 'acf')
$choices = array_merge( $choices, $wp_roles->get_names() ); ));
// return
return $choices;
} }
} }
// initialize // initialize
acf_register_location_rule( 'acf_location_user_role' ); acf_register_location_rule( 'ACF_Location_User_Role' );
endif; // class_exists check endif; // class_exists check
?>

View File

@ -2,262 +2,110 @@
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if( ! class_exists('acf_location') ) : if( ! class_exists('ACF_Location') ) :
class acf_location { class ACF_Location {
/** @var string The location rule name. */
public $name = '';
/** @var string Rule name */ /** @var string The location rule label. */
var $name = ''; public $label = '';
/** @var string The location rule category. */
/** @var string Rule label */ public $category = 'post';
var $label = '';
/** @var string The location rule visibility. */
public $public = true;
/** @var string Rule category */ /**
var $category = 'post'; * __construct
*
* Sets up the class functionality.
/** @var bool Rule availability */ *
var $public = true; * @date 5/03/2014
* @since 5.0.0
*
/* * @param void
* __construct * @return void
* */
* 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() { function __construct() {
// initialize // Call initialize to setup props.
$this->initialize(); $this->initialize();
// Add filters.
// filters $this->add_filter( 'acf/location/rule_match/' . $this->name, array($this, 'rule_match'), 5, 3 );
$this->add_filter('acf/location/rule_match', true, array($this, 'rule_match'), 5, 3); $this->add_filter( 'acf/location/rule_operators/' . $this->name, array($this, 'rule_operators'), 5, 2 );
$this->add_filter('acf/location/rule_operators', true, array($this, 'rule_operators'), 5, 2); $this->add_filter( 'acf/location/rule_values/' . $this->name, array($this, 'rule_values'), 5, 2 );
$this->add_filter('acf/location/rule_values', true, array($this, 'rule_values'), 5, 2);
} }
/**
/* * add_filter
* initialize *
* * Maybe adds a filter callback.
* This function will initialize the location rule *
* * @date 17/9/19
* @type function * @since 5.8.1
* @date 27/6/17 *
* @since 5.6.0 * @param string $tag The filter name.
* * @param callable $function_to_add The callback function.
* @param n/a * @param int $priority The filter priority.
* @return n/a * @param int $accepted_args The number of args to accept.
*/ * @return void
*/
function initialize() { function add_filter( $tag = '', $function_to_add = '', $priority = 10, $accepted_args = 1 ) {
/* do nothing */
}
/*
* add_filter
*
* This function checks if the function is_callable before adding the filter
*
* @type function
* @date 5/03/2014
* @since 5.0.0
*
* @param $tag (string)
* @param $function_to_add (string)
* @param $priority (int)
* @param $accepted_args (int)
* @return n/a
*/
function add_filter( $tag = '', $specific = false, $function_to_add = '', $priority = 10, $accepted_args = 1 ) {
// specific
if( $specific ) {
$tag .= '/' . $this->name;
}
// add
if( is_callable($function_to_add) ) { if( is_callable($function_to_add) ) {
add_filter( $tag, $function_to_add, $priority, $accepted_args ); add_filter( $tag, $function_to_add, $priority, $accepted_args );
} }
} }
/**
/* * initialize
* add_action *
* * Sets up the class functionality.
* This function checks if the function is_callable before adding the action *
* * @date 5/03/2014
* @type function * @since 5.0.0
* @date 5/03/2014 *
* @since 5.0.0 * @param void
* * @return void
* @param $tag (string) */
* @param $function_to_add (string) function initialize() {
* @param $priority (int) // Do nothing.
* @param $accepted_args (int)
* @return n/a
*/
function add_action( $tag = '', $specific = false, $function_to_add = '', $priority = 10, $accepted_args = 1 ) {
// specific
if( $specific ) {
$tag .= '/' . $this->name;
}
// add
if( is_callable($function_to_add) ) {
add_action( $tag, $function_to_add, $priority, $accepted_args );
}
} }
/**
/* * compare
* compare *
* * Compares the given value and rule params returning true when they match.
* This function will compare a value to a location rule and return a boolean result *
* * @date 17/9/19
* @type function * @since 5.8.1
* @date 25/11/16 *
* @since 5.5.0 * @param mixed $value The value to compare against.
* * @param array $rule The locatio rule data.
* @param $value (mixed) * @return bool
* @param rule (array) */
* @return (boolean)
*/
function compare( $value, $rule ) { function compare( $value, $rule ) {
// match // Allow "all" to match any value.
$match = ( $value == $rule['value'] ); if( $rule['value'] === 'all' ) {
$match = true;
// override for "all" // Compare all other values.
if( $rule['value'] == 'all' ) $match = true; } else {
$match = ( $value == $rule['value'] );
// reverse if 'not equal to'
if( $rule['operator'] == '!=' ) {
$match = !$match;
} }
// return // Allow for "!=" operator.
if( $rule['operator'] == '!=' ) {
$match = !$match;
}
// Return.
return $match; return $match;
} }
/*
* rule_match
*
* This function is used to match this location $rule to the current $screen
*
* @type function
* @date 3/01/13
* @since 3.5.7
*
* @param $match (boolean)
* @param $rule (array)
* @return $options (array)
*/
/*
function rule_match( $result, $rule, $screen ) {
return $result;
}
*/
/*
* rule_operators
*
* This function returns the available operators for this rule type
*
* @type function
* @date 30/5/17
* @since 5.6.0
*
* @param n/a
* @return (array)
*/
/*
function rule_operators( $operators, $rule ) {
return $operators;
}
*/
/*
* rule_operators
*
* This function returns the available values for this rule type
*
* @type function
* @date 30/5/17
* @since 5.6.0
*
* @param n/a
* @return (array)
*/
/*
function rule_values( $values, $rule ) {
return $values;
}
*/
/*
function rule_listeners() {
// js
}
*/
} }
endif; // class_exists check endif; // class_exists check
?>

View File

@ -94,47 +94,52 @@ class ACF_Updates {
} }
/* /*
* request * request
* *
* Makes a request to the ACF connect server. * Makes a request to the ACF connect server.
* *
* @date 8/4/17 * @date 8/4/17
* @since 5.5.10 * @since 5.5.10
* *
* @param string $query The api path. Defaults to 'index.php' * @param string $endpoint The API endpoint.
* @param array $body The body to post * @param array $body The body to post.
* @return array|string|WP_Error * @return (array|string|WP_Error)
*/ */
function request( $endpoint = '', $body = null ) {
function request( $query = 'index.php', $body = null ) {
// vars // Determine URL.
$url = 'https://connect.advancedcustomfields.com/' . $query; $url = "https://connect.advancedcustomfields.com/$endpoint";
// Development mode // Staging environment.
if( defined('ACF_DEV') && ACF_DEV ) { if( defined('ACF_DEV_API') && ACF_DEV_API === 'STAGE' ) {
$url = 'http://connect/' . $query; $url = "https://staging.connect.advancedcustomfields.com/$endpoint";
acf_log( $url, $body );
// Dev environment.
} elseif( defined('ACF_DEV_API') && ACF_DEV_API ) {
$url = "http://connect/$endpoint";
acf_log( $url, $body );
} }
// post // Make request.
$raw_response = wp_remote_post( $url, array( $raw_response = wp_remote_post( $url, array(
'timeout' => 10, 'timeout' => 10,
'body' => $body 'body' => $body
)); ));
// wp error // Handle response error.
if( is_wp_error($raw_response) ) { if( is_wp_error($raw_response) ) {
return $raw_response; return $raw_response;
// http error // Handle http error.
} elseif( wp_remote_retrieve_response_code($raw_response) != 200 ) { } elseif( wp_remote_retrieve_response_code($raw_response) != 200 ) {
return new WP_Error( 'server_error', wp_remote_retrieve_response_message($raw_response) ); return new WP_Error( 'server_error', wp_remote_retrieve_response_message($raw_response) );
} }
// decode response // Decode JSON response.
$json = json_decode( wp_remote_retrieve_body($raw_response), true ); $json = json_decode( wp_remote_retrieve_body($raw_response), true );
// allow non json value // Allow non json value.
if( $json === null ) { if( $json === null ) {
return wp_remote_retrieve_body($raw_response); return wp_remote_retrieve_body($raw_response);
} }

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -3,7 +3,7 @@ msgstr ""
"Project-Id-Version: Advanced Custom Fields Pro v5.2.9\n" "Project-Id-Version: Advanced Custom Fields Pro v5.2.9\n"
"Report-Msgid-Bugs-To: http://support.advancedcustomfields.com\n" "Report-Msgid-Bugs-To: http://support.advancedcustomfields.com\n"
"POT-Creation-Date: 2018-04-16 17:11+1000\n" "POT-Creation-Date: 2018-04-16 17:11+1000\n"
"PO-Revision-Date: 2018-04-29 13:58+0300\n" "PO-Revision-Date: 2019-11-12 08:00+1000\n"
"Last-Translator: Elliot Condon <e@elliotcondon.com>\n" "Last-Translator: Elliot Condon <e@elliotcondon.com>\n"
"Language-Team: Elliot Condon <e@elliotcondon.com>\n" "Language-Team: Elliot Condon <e@elliotcondon.com>\n"
"Language: ro_RO\n" "Language: ro_RO\n"
@ -12,7 +12,7 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n==1?0:(((n%100>19)||((n%100==0)&&(n!=0)))?" "Plural-Forms: nplurals=3; plural=(n==1?0:(((n%100>19)||((n%100==0)&&(n!=0)))?"
"2:1));\n" "2:1));\n"
"X-Generator: Poedit 2.0.7\n" "X-Generator: Poedit 1.8.1\n"
"X-Poedit-SourceCharset: UTF-8\n" "X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;" "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;" "esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
@ -38,7 +38,7 @@ msgstr "Grup de câmp"
#: acf.php:390 acf.php:422 includes/admin/admin.php:118 #: acf.php:390 acf.php:422 includes/admin/admin.php:118
#: pro/fields/class-acf-field-flexible-content.php:551 #: pro/fields/class-acf-field-flexible-content.php:551
msgid "Add New" msgid "Add New"
msgstr "Adaungă" msgstr "Adaugă"
#: acf.php:391 #: acf.php:391
msgid "Add New Field Group" msgid "Add New Field Group"
@ -1436,7 +1436,8 @@ msgstr "Relațional"
msgid "jQuery" msgid "jQuery"
msgstr "jQuery" msgstr "jQuery"
#: includes/fields.php:149 includes/fields/class-acf-field-button-group.php:177 #: includes/fields.php:149
#: includes/fields/class-acf-field-button-group.php:177
#: includes/fields/class-acf-field-checkbox.php:389 #: includes/fields/class-acf-field-checkbox.php:389
#: includes/fields/class-acf-field-group.php:474 #: includes/fields/class-acf-field-group.php:474
#: includes/fields/class-acf-field-radio.php:290 #: includes/fields/class-acf-field-radio.php:290
@ -2724,8 +2725,8 @@ msgstr "Editează Grupul de Câmpuri"
msgid "Validate Email" msgid "Validate Email"
msgstr "" msgstr ""
#: includes/forms/form-front.php:103 pro/fields/class-acf-field-gallery.php:573 #: includes/forms/form-front.php:103
#: pro/options-page.php:81 #: pro/fields/class-acf-field-gallery.php:573 pro/options-page.php:81
msgid "Update" msgid "Update"
msgstr "Actualizează" msgstr "Actualizează"

File diff suppressed because it is too large Load Diff

View File

@ -218,7 +218,7 @@ class ACF_Admin_Updates {
// Connect to API. // Connect to API.
$post = array( $post = array(
'acf_license' => $_POST['acf_pro_licence'], 'acf_license' => trim($_POST['acf_pro_licence']),
'acf_version' => acf_get_setting('version'), 'acf_version' => acf_get_setting('version'),
'wp_name' => get_bloginfo('name'), 'wp_name' => get_bloginfo('name'),
'wp_url' => home_url(), 'wp_url' => home_url(),

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -135,19 +135,32 @@
$(this).find('> .order > span').html( i+1 ); $(this).find('> .order > span').html( i+1 );
}); });
// Extract vars.
var $controll = this.$control();
var $button = this.$button();
// empty // empty
if( this.val() == 0 ) { if( this.val() == 0 ) {
this.$control().addClass('-empty'); $controll.addClass('-empty');
} else { } else {
this.$control().removeClass('-empty'); $controll.removeClass('-empty');
} }
// max // Reached max rows.
if( this.allowAdd() ) { if( !this.allowAdd() ) {
this.$button().removeClass('disabled'); $controll.addClass('-max');
$button.addClass('disabled');
} else { } else {
this.$button().addClass('disabled'); $controll.removeClass('-max');
} $button.removeClass('disabled');
}
// Reached min rows (not used).
//if( !this.allowRemove() ) {
// $controll.addClass('-min');
//} else {
// $controll.removeClass('-min');
//}
}, },
validateAdd: function(){ validateAdd: function(){
@ -1407,23 +1420,26 @@
// vars // vars
var $el = this.$attachment( attachment.id ); var $el = this.$attachment( attachment.id );
// image // Image type.
if( attachment.type == 'image' ) { if( attachment.type == 'image' ) {
// remove filename // Remove filename.
$el.find('.filename').remove(); $el.find('.filename').remove();
// other (video) // Other file type.
} else { } else {
// attempt to find attachment thumbnail // Check for attachment featured image.
attachment.url = acf.isget(attachment, 'thumb', 'src'); var image = acf.isget(attachment, 'image', 'src');
if( image !== null ) {
attachment.url = image;
}
// update filename // Update filename text.
$el.find('.filename').text( attachment.filename ); $el.find('.filename').text( attachment.filename );
} }
// default icon // Default to mimetype icon.
if( !attachment.url ) { if( !attachment.url ) {
attachment.url = acf.get('mimeTypeIcon'); attachment.url = acf.get('mimeTypeIcon');
$el.addClass('-icon'); $el.addClass('-icon');
@ -1593,10 +1609,13 @@
onChangeSort: function( e, $el ){ onChangeSort: function( e, $el ){
// vars // Bail early if is disabled.
var val = $el.val(); if( $el.hasClass('disabled') ) {
return;
}
// validate // Get sort val.
var val = $el.val();
if( !val ) { if( !val ) {
return; return;
} }
@ -1607,6 +1626,7 @@
ids.push( $(this).data('id') ); ids.push( $(this).data('id') );
}); });
// step 1 // step 1
var step1 = this.proxy(function(){ var step1 = this.proxy(function(){

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ acf_register_store( 'block-types' );
/** /**
* acf_register_block_type * acf_register_block_type
* *
* Registeres a block type. * Registers a block type.
* *
* @date 18/2/19 * @date 18/2/19
* @since 5.7.12 * @since 5.7.12
@ -188,8 +188,10 @@ function acf_validate_block_type( $block ) {
'enqueue_assets' => false, 'enqueue_assets' => false,
)); ));
// Restrict keywords to 3 max to avoid JS error. // Restrict keywords to 3 max to avoid JS error in older versions.
$block['keywords'] = array_slice($block['keywords'], 0, 3); if( acf_version_compare('wp', '<', '5.2') ) {
$block['keywords'] = array_slice($block['keywords'], 0, 3);
}
// Generate name with prefix. // Generate name with prefix.
$block['name'] = 'acf/' . acf_slugify($block['name']); $block['name'] = 'acf/' . acf_slugify($block['name']);
@ -560,6 +562,7 @@ function acf_parse_save_blocks_callback( $matches ) {
// Defaults // Defaults
$name = isset($matches['name']) ? $matches['name'] : ''; $name = isset($matches['name']) ? $matches['name'] : '';
$attrs = isset($matches['attrs']) ? json_decode( $matches['attrs'], true) : ''; $attrs = isset($matches['attrs']) ? json_decode( $matches['attrs'], true) : '';
$void = isset($matches['void']) ? $matches['void'] : '';
// Bail early if missing data or not an ACF Block. // Bail early if missing data or not an ACF Block.
if( !$name || !$attrs || !acf_has_block_type($name) ) { if( !$name || !$attrs || !acf_has_block_type($name) ) {
@ -588,5 +591,5 @@ function acf_parse_save_blocks_callback( $matches ) {
$attrs = apply_filters( 'acf/pre_save_block', $attrs ); $attrs = apply_filters( 'acf/pre_save_block', $attrs );
// Return new comment // Return new comment
return '<!-- wp:' . $name . ' ' . acf_json_encode($attrs) . ' /-->'; return '<!-- wp:' . $name . ' ' . acf_json_encode($attrs) . ' ' . $void . '-->';
} }

View File

@ -316,14 +316,15 @@ class acf_field_gallery extends acf_field {
$thumb = wp_mime_type_icon( $id ); $thumb = wp_mime_type_icon( $id );
} }
// Get attachment dimentions / time / size. // Get attachment dimensions / time / size.
$dimensions = '';
if( $attachment['type'] === 'audio' ) { if( $attachment['type'] === 'audio' ) {
$dimentions = __('Length', 'acf') . ': ' . $attachment['fileLength']; $dimensions = __('Length', 'acf') . ': ' . $attachment['fileLength'];
} elseif( !empty($attachment['width']) ) { } elseif( !empty($attachment['width']) ) {
$dimentions = $attachment['width'] . ' x ' . $attachment['height']; $dimensions = $attachment['width'] . ' x ' . $attachment['height'];
} }
if( !empty($attachment['filesizeHumanReadable']) ) { if( !empty($attachment['filesizeHumanReadable']) ) {
$dimentions .= ' (' . $attachment['filesizeHumanReadable'] . ')'; $dimensions .= ' (' . $attachment['filesizeHumanReadable'] . ')';
} }
?> ?>
@ -331,7 +332,7 @@ class acf_field_gallery extends acf_field {
<img src="<?php echo esc_attr($thumb); ?>" alt="<?php echo esc_attr($attachment['alt']); ?>" /> <img src="<?php echo esc_attr($thumb); ?>" alt="<?php echo esc_attr($attachment['alt']); ?>" />
<p class="filename"><strong><?php echo esc_html($attachment['filename']); ?></strong></p> <p class="filename"><strong><?php echo esc_html($attachment['filename']); ?></strong></p>
<p class="uploaded"><?php echo esc_html($attachment['dateFormatted']); ?></p> <p class="uploaded"><?php echo esc_html($attachment['dateFormatted']); ?></p>
<p class="dimensions"><?php echo esc_html($dimentions); ?></p> <p class="dimensions"><?php echo esc_html($dimensions); ?></p>
<p class="actions"> <p class="actions">
<a href="#" class="acf-gallery-edit" data-id="<?php echo esc_attr($id); ?>"><?php _e('Edit', 'acf'); ?></a> <a href="#" class="acf-gallery-edit" data-id="<?php echo esc_attr($id); ?>"><?php _e('Edit', 'acf'); ?></a>
<a href="#" class="acf-gallery-remove" data-id="<?php echo esc_attr($id); ?>"><?php _e('Remove', 'acf'); ?></a> <a href="#" class="acf-gallery-remove" data-id="<?php echo esc_attr($id); ?>"><?php _e('Remove', 'acf'); ?></a>

View File

@ -2,7 +2,7 @@
Contributors: elliotcondon Contributors: elliotcondon
Tags: acf, advanced, custom, field, fields, form, repeater, content Tags: acf, advanced, custom, field, fields, form, repeater, content
Requires at least: 4.7.0 Requires at least: 4.7.0
Tested up to: 5.2 Tested up to: 5.3.0
Requires PHP: 5.4 Requires PHP: 5.4
License: GPLv2 or later License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html License URI: https://www.gnu.org/licenses/gpl-2.0.html
@ -67,6 +67,38 @@ From your WordPress dashboard
== Changelog == == Changelog ==
= 5.8.7 =
*Release Date - 12 November 2019*
* New - Updated admin CSS for new WordPress 5.3 styling.
* Fix - Fixed various issues affecting dynamic metaboxes in the block editor (requires WordPress 5.3)
* Fix - Fixed performance issue when checking network sites for upgrades.
* Fix - Fixed Select2 clones appearing after duplicating a Relationship field.
* Tweak - Repeater field "Add row" icons will now hide when maximum rows are reached.
* Tweak - Removed ACF Blocks keyword limit for later versions of Gutenberg.
= 5.8.6 =
*Release Date - 24 October 2019*
* New - Added more data to Google Maps field value including place_id, street_name, country and more.
* Fix - Fixed bug in Gallery field incorrectly displaying .pdf attachments as icons.
* Fix - Fixed bug in Checkbox field missing "selected" class after "Toggle All".
* Dev - Added compatibility for Attachments in the Post Taxonomy location rule.
* Dev - Added missing return statement from `acf_get_form()` function.
* Dev - Added "google_map_result" JS filter.
= 5.8.5 =
*Release Date - 8 October 2019*
* New - Added new choice "Add" to the User Form location rule.
* New - Optimized `acf_form()` logic when used in combination with `acf_register_form()`.
* Fix - Fixed bug causing incorrect field order after sync.
* Fix - Fixed bug reverting the first field type to Text in Firefox version 69.0.1.
* Fix - Fixed bug causing tinymce issues when changing between block modes.
* Fix - Fixed bug preventing block registration when category does not exist.
* Fix - Fixed bug preventing block registration when no icon is declared.
* Dev - Added RegExp compatibility for innerBlocks.
= 5.8.4 = = 5.8.4 =
*Release Date - 3 September 2019* *Release Date - 3 September 2019*