Merge branch 'release/5.8.7' into develop

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

View File

@ -3,7 +3,7 @@
Plugin Name: Advanced Custom Fields PRO
Plugin URI: https://www.advancedcustomfields.com
Description: Customize WordPress with powerful, professional and intuitive fields.
Version: 5.8.4
Version: 5.8.7
Author: Elliot Condon
Author URI: https://www.advancedcustomfields.com
Text Domain: acf
@ -17,7 +17,7 @@ if( ! class_exists('ACF') ) :
class ACF {
/** @var string The plugin version number. */
var $version = '5.8.4';
var $version = '5.8.7';
/** @var array The plugin settings array. */
var $settings = array();
@ -165,7 +165,6 @@ class ACF {
acf_include('includes/admin/admin-notices.php');
acf_include('includes/admin/admin-tools.php');
acf_include('includes/admin/admin-upgrade.php');
acf_include('includes/admin/settings-info.php');
}
// 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
$('#misc-publishing-actions a').remove();
// remove editables (fixes status text changing on submit)
$('#misc-publishing-actions .hide-if-js').remove();
})(jQuery);
</script>
<?php

View File

@ -52,50 +52,67 @@ class ACF_Admin_Upgrade {
}
/**
* network_admin_menu
*
* Setus up logic if DB Upgrade is needed on a multi site.
*
* @date 24/8/18
* @since 5.7.4
*
* @param void
* @return void
*/
* network_admin_menu
*
* Sets up admin logic if DB Upgrade is required on a multi site.
*
* @date 24/8/18
* @since 5.7.4
*
* @param void
* @return void
*/
function network_admin_menu() {
// vars
$has_upgrade = false;
// Vars.
$upgrade = false;
// loop over sites
$sites = acf_get_sites();
// Loop over sites and check for upgrades.
$sites = get_sites( array( 'number' => 0 ) );
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_to_blog( $site['blog_id'] );
// check for upgrade
if( acf_has_upgrade() ) {
$has_upgrade = true;
}
// restore blog
restore_current_blog();
}}
// check if upgrade is avaialble
if( $has_upgrade ) {
// 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'));
// actions
add_action('load-' . $page, array($this,'network_admin_load'));
// Switch site.
switch_to_blog( $site->blog_id );
// Check for upgrade.
$site_upgrade = acf_has_upgrade();
// Restore site.
// Ideally, we would switch back to the original site at after looping, however,
// the restore_current_blog() is needed to modify global vars.
restore_current_blog();
// Check if upgrade was found.
if( $site_upgrade ) {
$upgrade = true;
break;
}
}
add_action( 'switch_blog', 'wp_switch_roles_and_user', 1, 2 );
}
// 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( ! class_exists('acf_admin') ) :
if( ! class_exists('ACF_Admin') ) :
class acf_admin {
class ACF_Admin {
/*
* __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'));
add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'), 0);
/**
* __construct
*
* Sets up the class functionality.
*
* @date 23/06/12
* @since 5.0.0
*
* @param void
* @return void
*/
function __construct() {
// Add hooks.
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
add_action( 'admin_body_class', array( $this, 'admin_body_class' ) );
}
/*
* 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() {
/**
* admin_menu
*
* Adds the ACF menu item.
*
* @date 28/09/13
* @since 5.0.0
*
* @param void
* @return void
*/
function admin_menu() {
// bail early if no show_admin
if( !acf_get_setting('show_admin') ) return;
// Bail early if ACF is hidden.
if( !acf_get_setting('show_admin') ) {
return;
}
// vars
// Vars.
$slug = 'edit.php?post_type=acf-field-group';
$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
add_menu_page(__("Custom Fields",'acf'), __("Custom Fields",'acf'), $cap, $slug, false, 'dashicons-welcome-widgets-menus', '80.025');
// 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' );
// Only register info page when needed.
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') );
}
}
/*
* admin_enqueue_scripts
*
* This function will add the already registered css
*
* @type function
* @date 28/09/13
* @since 5.0.0
*
* @param n/a
* @return n/a
*/
/**
* admin_enqueue_scripts
*
* Enqueues global admin styling.
*
* @date 28/09/13
* @since 5.0.0
*
* @param void
* @return void
*/
function admin_enqueue_scripts() {
// Enqueue global style. To-do: Change to admin.
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
acf()->admin = new acf_admin();
// Instantiate.
acf_new_instance('ACF_Admin');
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
} elseif( $type === 'video' ) {
// dimentions
// dimensions
$response['width'] = acf_maybe_get($meta, 'width', 0);
$response['height'] = acf_maybe_get($meta, 'height', 0);

View File

@ -160,8 +160,24 @@ class ACF_Assets {
if( $args['uploader'] ) {
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(
// unload
@ -205,22 +221,6 @@ class ACF_Assets {
// misc
'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
wp_enqueue_script('acf-input');

View File

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

View File

@ -128,13 +128,13 @@ acf.unload.active = 0;
$is_page = acf_is_screen('attachment');
$post_id = $post->ID;
$el = 'tr';
$args = array(
'attachment' => $post_id
);
// 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

View File

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

View File

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

View File

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

View File

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

View File

@ -94,47 +94,52 @@ class ACF_Updates {
}
/*
* request
*
* Makes a request to the ACF connect server.
*
* @date 8/4/17
* @since 5.5.10
*
* @param string $query The api path. Defaults to 'index.php'
* @param array $body The body to post
* @return array|string|WP_Error
*/
function request( $query = 'index.php', $body = null ) {
* request
*
* Makes a request to the ACF connect server.
*
* @date 8/4/17
* @since 5.5.10
*
* @param string $endpoint The API endpoint.
* @param array $body The body to post.
* @return (array|string|WP_Error)
*/
function request( $endpoint = '', $body = null ) {
// vars
$url = 'https://connect.advancedcustomfields.com/' . $query;
// Determine URL.
$url = "https://connect.advancedcustomfields.com/$endpoint";
// Development mode
if( defined('ACF_DEV') && ACF_DEV ) {
$url = 'http://connect/' . $query;
// Staging environment.
if( defined('ACF_DEV_API') && ACF_DEV_API === 'STAGE' ) {
$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(
'timeout' => 10,
'body' => $body
));
// wp error
// Handle response error.
if( is_wp_error($raw_response) ) {
return $raw_response;
// http error
// Handle http error.
} elseif( wp_remote_retrieve_response_code($raw_response) != 200 ) {
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 );
// allow non json value
// Allow non json value.
if( $json === null ) {
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"
"Report-Msgid-Bugs-To: http://support.advancedcustomfields.com\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"
"Language-Team: Elliot Condon <e@elliotcondon.com>\n"
"Language: ro_RO\n"
@ -12,7 +12,7 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n==1?0:(((n%100>19)||((n%100==0)&&(n!=0)))?"
"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-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;"
@ -38,7 +38,7 @@ msgstr "Grup de câmp"
#: acf.php:390 acf.php:422 includes/admin/admin.php:118
#: pro/fields/class-acf-field-flexible-content.php:551
msgid "Add New"
msgstr "Adaungă"
msgstr "Adaugă"
#: acf.php:391
msgid "Add New Field Group"
@ -1436,7 +1436,8 @@ msgstr "Relațional"
msgid "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-group.php:474
#: includes/fields/class-acf-field-radio.php:290
@ -2724,8 +2725,8 @@ msgstr "Editează Grupul de Câmpuri"
msgid "Validate Email"
msgstr ""
#: includes/forms/form-front.php:103 pro/fields/class-acf-field-gallery.php:573
#: pro/options-page.php:81
#: includes/forms/form-front.php:103
#: pro/fields/class-acf-field-gallery.php:573 pro/options-page.php:81
msgid "Update"
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.
$post = array(
'acf_license' => $_POST['acf_pro_licence'],
'acf_license' => trim($_POST['acf_pro_licence']),
'acf_version' => acf_get_setting('version'),
'wp_name' => get_bloginfo('name'),
'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 );
});
// Extract vars.
var $controll = this.$control();
var $button = this.$button();
// empty
if( this.val() == 0 ) {
this.$control().addClass('-empty');
$controll.addClass('-empty');
} else {
this.$control().removeClass('-empty');
$controll.removeClass('-empty');
}
// max
if( this.allowAdd() ) {
this.$button().removeClass('disabled');
// Reached max rows.
if( !this.allowAdd() ) {
$controll.addClass('-max');
$button.addClass('disabled');
} 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(){
@ -1407,23 +1420,26 @@
// vars
var $el = this.$attachment( attachment.id );
// image
// Image type.
if( attachment.type == 'image' ) {
// remove filename
// Remove filename.
$el.find('.filename').remove();
// other (video)
// Other file type.
} else {
// attempt to find attachment thumbnail
attachment.url = acf.isget(attachment, 'thumb', 'src');
// Check for attachment featured image.
var image = acf.isget(attachment, 'image', 'src');
if( image !== null ) {
attachment.url = image;
}
// update filename
// Update filename text.
$el.find('.filename').text( attachment.filename );
}
// default icon
// Default to mimetype icon.
if( !attachment.url ) {
attachment.url = acf.get('mimeTypeIcon');
$el.addClass('-icon');
@ -1593,10 +1609,13 @@
onChangeSort: function( e, $el ){
// vars
var val = $el.val();
// Bail early if is disabled.
if( $el.hasClass('disabled') ) {
return;
}
// validate
// Get sort val.
var val = $el.val();
if( !val ) {
return;
}
@ -1607,6 +1626,7 @@
ids.push( $(this).data('id') );
});
// step 1
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
*
* Registeres a block type.
* Registers a block type.
*
* @date 18/2/19
* @since 5.7.12
@ -188,8 +188,10 @@ function acf_validate_block_type( $block ) {
'enqueue_assets' => false,
));
// Restrict keywords to 3 max to avoid JS error.
$block['keywords'] = array_slice($block['keywords'], 0, 3);
// Restrict keywords to 3 max to avoid JS error in older versions.
if( acf_version_compare('wp', '<', '5.2') ) {
$block['keywords'] = array_slice($block['keywords'], 0, 3);
}
// Generate name with prefix.
$block['name'] = 'acf/' . acf_slugify($block['name']);
@ -560,6 +562,7 @@ function acf_parse_save_blocks_callback( $matches ) {
// Defaults
$name = isset($matches['name']) ? $matches['name'] : '';
$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.
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 );
// 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 );
}
// Get attachment dimentions / time / size.
// Get attachment dimensions / time / size.
$dimensions = '';
if( $attachment['type'] === 'audio' ) {
$dimentions = __('Length', 'acf') . ': ' . $attachment['fileLength'];
$dimensions = __('Length', 'acf') . ': ' . $attachment['fileLength'];
} elseif( !empty($attachment['width']) ) {
$dimentions = $attachment['width'] . ' x ' . $attachment['height'];
$dimensions = $attachment['width'] . ' x ' . $attachment['height'];
}
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']); ?>" />
<p class="filename"><strong><?php echo esc_html($attachment['filename']); ?></strong></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">
<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>

View File

@ -2,7 +2,7 @@
Contributors: elliotcondon
Tags: acf, advanced, custom, field, fields, form, repeater, content
Requires at least: 4.7.0
Tested up to: 5.2
Tested up to: 5.3.0
Requires PHP: 5.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
@ -67,6 +67,38 @@ From your WordPress dashboard
== 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 =
*Release Date - 3 September 2019*