Merge branch 'release/5.9.7'

This commit is contained in:
Titouan Mathis 2021-06-23 13:08:34 +02:00
commit a9323f424a
No known key found for this signature in database
GPG Key ID: A292A3DB3103F19D
40 changed files with 168 additions and 151 deletions

View File

@ -3,8 +3,8 @@
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.9.6 Version: 5.9.7
Author: Elliot Condon Author: Delicious Brains
Author URI: https://www.advancedcustomfields.com Author URI: https://www.advancedcustomfields.com
Text Domain: acf Text Domain: acf
Domain Path: /lang Domain Path: /lang
@ -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.9.6'; var $version = '5.9.7';
/** @var array The plugin settings array. */ /** @var array The plugin settings array. */
var $settings = array(); var $settings = array();

0
assets/inc/select2/3/select2-spinner.gif Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

0
assets/inc/select2/3/select2.css vendored Normal file → Executable file
View File

0
assets/inc/select2/3/select2.js vendored Normal file → Executable file
View File

0
assets/inc/select2/3/select2.min.js vendored Normal file → Executable file
View File

0
assets/inc/select2/3/select2.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 525 B

After

Width:  |  Height:  |  Size: 525 B

0
assets/inc/select2/3/select2x2.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 653 B

After

Width:  |  Height:  |  Size: 653 B

0
assets/inc/select2/4/select2.css vendored Normal file → Executable file
View File

0
assets/inc/select2/4/select2.full.js vendored Normal file → Executable file
View File

0
assets/inc/select2/4/select2.full.min.js vendored Normal file → Executable file
View File

0
assets/inc/select2/4/select2.js vendored Normal file → Executable file
View File

0
assets/inc/select2/4/select2.min.css vendored Normal file → Executable file
View File

0
assets/inc/select2/4/select2.min.js vendored Normal file → Executable file
View File

0
assets/inc/timepicker/jquery-ui-timepicker-addon.css Normal file → Executable file
View File

0
assets/inc/timepicker/jquery-ui-timepicker-addon.js vendored Normal file → Executable file
View File

0
assets/inc/timepicker/jquery-ui-timepicker-addon.min.css vendored Normal file → Executable file
View File

0
assets/inc/timepicker/jquery-ui-timepicker-addon.min.js vendored Normal file → Executable file
View File

View File

@ -45,7 +45,7 @@ class ACF_Admin {
$cap = acf_get_setting('capability'); $cap = acf_get_setting('capability');
// Add menu items. // Add menu items.
add_menu_page( __("Custom Fields",'acf'), __("Custom Fields",'acf'), $cap, $slug, false, 'dashicons-welcome-widgets-menus', '80.025' ); add_menu_page( __("Custom Fields",'acf'), __("Custom Fields",'acf'), $cap, $slug, false, 'dashicons-welcome-widgets-menus', 80 );
add_submenu_page( $slug, __('Field Groups','acf'), __('Field Groups','acf'), $cap, $slug ); 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_submenu_page( $slug, __('Add New','acf'), __('Add New','acf'), $cap, 'post-new.php?post_type=acf-field-group' );
} }

View File

@ -3436,13 +3436,13 @@ function acf_get_valid_terms( $terms = false, $taxonomy = 'category' ) {
/* /*
* acf_validate_attachment * acf_validate_attachment
* *
* This function will validate an attachment based on a field's resrictions and return an array of errors * This function will validate an attachment based on a field's restrictions and return an array of errors
* *
* @type function * @type function
* @date 3/07/2015 * @date 3/07/2015
* @since 5.2.3 * @since 5.2.3
* *
* @param $attachment (array) attachment data. Cahnges based on context * @param $attachment (array) attachment data. Changes based on context
* @param $field (array) field settings containing restrictions * @param $field (array) field settings containing restrictions
* @param $context (string) $file is different when uploading / preparing * @param $context (string) $file is different when uploading / preparing
* @return $errors (array) * @return $errors (array)
@ -3478,7 +3478,7 @@ function acf_validate_attachment( $attachment, $field, $context = 'prepare' ) {
// prepare // prepare
} elseif( $context == 'prepare' ) { } elseif( $context == 'prepare' ) {
$file['type'] = pathinfo($attachment['url'], PATHINFO_EXTENSION); $file['type'] = pathinfo($attachment['filename'], PATHINFO_EXTENSION);
$file['size'] = acf_maybe_get($attachment, 'filesizeInBytes', 0); $file['size'] = acf_maybe_get($attachment, 'filesizeInBytes', 0);
$file['width'] = acf_maybe_get($attachment, 'width', 0); $file['width'] = acf_maybe_get($attachment, 'width', 0);
$file['height'] = acf_maybe_get($attachment, 'height', 0); $file['height'] = acf_maybe_get($attachment, 'height', 0);
@ -3487,7 +3487,7 @@ function acf_validate_attachment( $attachment, $field, $context = 'prepare' ) {
} else { } else {
$file = array_merge($file, $attachment); $file = array_merge($file, $attachment);
$file['type'] = pathinfo($attachment['url'], PATHINFO_EXTENSION); $file['type'] = pathinfo($attachment['filename'], PATHINFO_EXTENSION);
} }

0
includes/fields.php Normal file → Executable file
View File

View File

@ -163,7 +163,9 @@ class acf_field_email extends acf_field {
* @return bool|string * @return bool|string
*/ */
public function validate_value( $valid, $value, $field, $input ) { public function validate_value( $valid, $value, $field, $input ) {
if ( $value && filter_var( wp_unslash($value), FILTER_VALIDATE_EMAIL ) === false ) { $flags = defined( 'FILTER_FLAG_EMAIL_UNICODE' ) ? FILTER_FLAG_EMAIL_UNICODE : 0;
if ( $value && filter_var( wp_unslash($value), FILTER_VALIDATE_EMAIL, $flags ) === false ) {
return sprintf( __( "'%s' is not a valid email address", 'acf' ), esc_html( $value ) ); return sprintf( __( "'%s' is not a valid email address", 'acf' ), esc_html( $value ) );
} }

View File

@ -237,7 +237,7 @@ class acf_field_wysiwyg extends acf_field {
} }
// must be logged in tp upload // must be logged in to upload
if( !current_user_can('upload_files') ) { if( !current_user_can('upload_files') ) {
$field['media_upload'] = 0; $field['media_upload'] = 0;
@ -250,6 +250,7 @@ class acf_field_wysiwyg extends acf_field {
// filter // filter
add_filter( 'acf_the_editor_content', 'format_for_editor', 10, 2 );
$field['value'] = apply_filters( 'acf_the_editor_content', $field['value'], $default_editor ); $field['value'] = apply_filters( 'acf_the_editor_content', $field['value'], $default_editor );

0
includes/fields/class-acf-field.php Normal file → Executable file
View File

0
includes/local-meta.php Normal file → Executable file
View File

View File

@ -6,49 +6,40 @@ if( ! class_exists('ACF_Media') ) :
class ACF_Media { class ACF_Media {
/**
/* * Constructor.
* __construct *
* * @date 23/06/12
* Initialize filters, action, variables and includes * @since 5.0.0
* *
* @type function * @param void
* @date 23/06/12 * @return void
* @since 5.0.0 */
* public function __construct() {
* @param N/A
* @return N/A
*/
function __construct() {
// actions // Localize media strings.
add_action('acf/enqueue_scripts', array($this, 'enqueue_scripts')); add_action( 'acf/enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_action('acf/save_post', array($this, 'save_files'), 5, 1);
// Save files uploaded from basic `$_FILE` field.
add_action( 'acf/save_post', array( $this, 'save_files' ), 5, 1 );
// filters // Hook into Media Upload to run additional logic.
add_filter('wp_handle_upload_prefilter', array($this, 'handle_upload_prefilter'), 10, 1); add_filter( 'wp_handle_upload_prefilter', array( $this, 'handle_upload_prefilter' ), 10, 1 );
// Hook into Media Modal Query to run additional logic.
// ajax add_action( 'wp_ajax_query-attachments', array( $this, 'wp_ajax_query_attachments' ), -1 );
add_action('wp_ajax_query-attachments', array($this, 'wp_ajax_query_attachments'), -1);
} }
/** /**
* enqueue_scripts * Fires when ACF scrtips are enqueued.
* *
* Localizes data * @date 27/4/18
* * @since 5.6.9
* @date 27/4/18 *
* @since 5.6.9 * @param void
* * @return void
* @param void */
* @return void public function enqueue_scripts(){
*/
function enqueue_scripts(){
if( wp_script_is('acf-input') ) { if( wp_script_is('acf-input') ) {
acf_localize_text(array( acf_localize_text(array(
'Select.verb' => _x('Select', 'verb', 'acf'), 'Select.verb' => _x('Select', 'verb', 'acf'),
@ -66,149 +57,162 @@ class ACF_Media {
)); ));
} }
} }
/*
* handle_upload_prefilter
*
* description
*
* @type function
* @date 16/02/2015
* @since 5.1.5
*
* @param $post_id (int)
* @return $post_id (int)
*/
function handle_upload_prefilter( $file ) { /**
* Uploads attachments found in the basic `$_FILES` array.
// bail early if no acf field *
if( empty($_POST['_acfuploader']) ) { * @date 24/10/2014
return $file; * @since 5.0.9
*
* @param string|int $post_id The post ID being saved.
* @return void
*/
public function save_files( $post_id = 0 ) {
if( isset( $_FILES['acf']['name'] ) ) {
acf_upload_files();
} }
}
// load field /**
$field = acf_get_field( $_POST['_acfuploader'] ); * Filters data for the current file being uploaded.
*
* @date 16/02/2015
* @since 5.1.5
*
* @param array $file An array of data for a single file.
* @return array
*/
public function handle_upload_prefilter( $file ) {
$field = $this->get_source_field();
if( !$field ) { if( !$field ) {
return $file; return $file;
} }
// Validate the attachment and append any errors.
// get errors
$errors = acf_validate_attachment( $file, $field, 'upload' ); $errors = acf_validate_attachment( $file, $field, 'upload' );
/** /**
* Filters the errors for a file before it is uploaded to WordPress. * Filters the errors for a file before it is uploaded to WordPress.
* *
* @date 16/02/2015 * @date 16/02/2015
* @since 5.1.5 * @since 5.1.5
* *
* @param array $errors An array of errors. * @param array $errors An array of errors.
* @param array $file An array of data for a single file. * @param array $file An array of data for a single file.
* @param array $field The field array. * @param array $field The field array.
*/ */
$errors = apply_filters( "acf/upload_prefilter/type={$field['type']}", $errors, $file, $field ); $errors = apply_filters( "acf/upload_prefilter/type={$field['type']}", $errors, $file, $field );
$errors = apply_filters( "acf/upload_prefilter/name={$field['_name']}", $errors, $file, $field ); $errors = apply_filters( "acf/upload_prefilter/name={$field['_name']}", $errors, $file, $field );
$errors = apply_filters( "acf/upload_prefilter/key={$field['key']}", $errors, $file, $field ); $errors = apply_filters( "acf/upload_prefilter/key={$field['key']}", $errors, $file, $field );
$errors = apply_filters( "acf/upload_prefilter", $errors, $file, $field ); $errors = apply_filters( "acf/upload_prefilter", $errors, $file, $field );
// Append errors.
// append error
if( !empty($errors) ) { if( !empty($errors) ) {
$file['error'] = implode("\n", $errors); $file['error'] = implode("\n", $errors);
} }
// Ensure newly uploaded image contains "preview_size" within the "size" data.
add_filter( 'image_size_names_choose', array( $this, 'image_size_names_choose' ), 10, 1 );
// return // Return.
return $file; return $file;
} }
/*
* save_files
*
* This function will save the $_FILES data
*
* @type function
* @date 24/10/2014
* @since 5.0.9
*
* @param $post_id (int)
* @return $post_id (int)
*/
function save_files( $post_id = 0 ) {
/**
* Returns the field responsible for the current Media query or upload context.
*
* @date 21/5/21
* @since 5.9.7
*
* @param void
* @return array| false.
*/
private function get_source_field() {
$field = false;
// bail early if no $_FILES data // Search for field key within available data.
if( empty($_FILES['acf']['name']) ) { // Case 1) Media modal query.
return; if( isset( $_POST['query']['_acfuploader'] ) ) {
$field_key = (string) $_POST['query']['_acfuploader'];
// Case 2) Media modal upload.
} elseif( isset( $_POST['_acfuploader'] ) ) {
$field_key = (string) $_POST['_acfuploader'];
} }
// Attempt to load field.
// upload files // Note the `acf_get_field()` function will return false if not found.
acf_upload_files(); if( isset( $field_key ) ) {
$field = acf_get_field( $field_key );
}
return $field;
} }
/**
/* * Fires during the WP Modal Query AJAX call.
* wp_ajax_query_attachments *
* * @date 26/06/2015
* description * @since 5.2.3
* *
* @type function * @param void
* @date 26/06/2015 * @return void
* @since 5.2.3 */
*
* @param $post_id (int)
* @return $post_id (int)
*/
function wp_ajax_query_attachments() { function wp_ajax_query_attachments() {
if( $this->get_source_field() ) {
add_filter('wp_prepare_attachment_for_js', array($this, 'wp_prepare_attachment_for_js'), 10, 3); add_filter( 'wp_prepare_attachment_for_js', array( $this, 'wp_prepare_attachment_for_js' ), 10, 3 );
add_filter( 'image_size_names_choose', array( $this, 'image_size_names_choose' ), 10, 1 );
}
} }
/**
* Filters attachment data as it is being prepared for JS.
*
* @date 21/5/21
* @since 5.9.7
*
* @param array $response Array of prepared attachment data.
* @param WP_Post $attachment Attachment object.
* @param array|false $meta Array of attachment meta data, or false if there is none.
* @return array
*/
function wp_prepare_attachment_for_js( $response, $attachment, $meta ) { function wp_prepare_attachment_for_js( $response, $attachment, $meta ) {
$field = $this->get_source_field();
// append attribute // Validate the attachment and append any errors.
$response['acf_errors'] = false;
// bail early if no acf field
if( empty($_POST['query']['_acfuploader']) ) {
return $response;
}
// load field
$field = acf_get_field( $_POST['query']['_acfuploader'] );
if( !$field ) {
return $response;
}
// get errors
$errors = acf_validate_attachment( $response, $field, 'prepare' ); $errors = acf_validate_attachment( $response, $field, 'prepare' );
// append errors
if( !empty($errors) ) { if( !empty($errors) ) {
$response['acf_errors'] = implode('<br />', $errors); $response['acf_errors'] = implode('<br />', $errors);
} }
// Return.
// return
return $response; return $response;
} }
/**
* Filters the names and labels of the default image sizes.
*
* @date 21/5/21
* @since 5.9.7
*
* @param array $size_names Array of image size labels keyed by their name.
* @return array
*/
function image_size_names_choose( $size_names ) {
$field = $this->get_source_field();
// Append "preview_size" setting to array of image sizes so WP will include in prepared JS data.
if( isset( $field['preview_size'] ) ) {
$name = (string) $field['preview_size'];
$size_names[ $name ] = $name; // Don't worry about size label, it is never used.
}
return $size_names;
}
} }
// instantiate // Instantiate.
acf_new_instance('ACF_Media'); acf_new_instance( 'ACF_Media' );
endif; // class_exists check endif; // class_exists check
?>

0
lang/acf-ar.mo Normal file → Executable file
View File

0
lang/acf-cs_CZ.mo Normal file → Executable file
View File

0
lang/acf-de_CH.mo Normal file → Executable file
View File

0
lang/acf-de_DE.mo Normal file → Executable file
View File

0
lang/acf-de_DE_formal.mo Normal file → Executable file
View File

0
lang/acf-fr_FR.mo Normal file → Executable file
View File

0
lang/acf-id_ID.mo Normal file → Executable file
View File

0
lang/acf-it_IT.mo Normal file → Executable file
View File

0
lang/acf-ja.mo Normal file → Executable file
View File

0
lang/acf-pt_BR.mo Normal file → Executable file
View File

0
lang/acf-sk_SK.mo Normal file → Executable file
View File

0
pro/blocks.php Normal file → Executable file
View File

0
pro/locations/class-acf-location-block.php Normal file → Executable file
View File

View File

@ -96,7 +96,10 @@ class acf_options_page {
if( empty($page['menu_slug']) ) { if( empty($page['menu_slug']) ) {
$page['menu_slug'] = 'acf-options-' . sanitize_title( $page['menu_title'] ); $page['menu_slug'] = 'acf-options-' . sanitize_title( $page['menu_title'] );
} }
// Standardize on position being either null or int.
$page['position'] = is_numeric( $page['position'] ) ? (int) $page['position'] : null;
/** /**
* Filters the $page array after it has been validated. * Filters the $page array after it has been validated.
* *

View File

@ -51,8 +51,6 @@ From your WordPress dashboard
= What kind of support do you provide? = = What kind of support do you provide? =
**Help Desk.** Support is currently provided via our email help desk. Questions are generally answered within 24 hours, with the exception of weekends and holidays. We answer questions related to ACF, its usage and provide minor customization guidance. We cannot guarantee support for questions which include custom theme code, or 3rd party plugin conflicts & compatibility. [Open a Support Ticket](https://www.advancedcustomfields.com/support/)
**Support Forums.** Our Community Forums provide a great resource for searching and finding previously answered and asked support questions. You may create a new thread on these forums, however, it is not guaranteed that you will receive an answer from our support team. This is more of an area for developers to talk to one another, post ideas, plugins and provide basic help. [View the Support Forum](https://support.advancedcustomfields.com/) **Support Forums.** Our Community Forums provide a great resource for searching and finding previously answered and asked support questions. You may create a new thread on these forums, however, it is not guaranteed that you will receive an answer from our support team. This is more of an area for developers to talk to one another, post ideas, plugins and provide basic help. [View the Support Forum](https://support.advancedcustomfields.com/)
@ -67,6 +65,15 @@ From your WordPress dashboard
== Changelog == == Changelog ==
= 5.9.7 =
*Release Date - 22 June 2021*
* Fix - Fixed PHP warnings logged due to incorrect parameter type for `add_menu_page()`/`add_submenu_page()`
* Fix - Fixed bug causing WYSIWYG field to not keep line breaks
* Fix - Fixed bug causing Email field to incorrectly invalidate emails with unicode characters
* Fix - Fixed bug causing file type validation to fail in some cases
* Fix - Fixed bug where newly uploaded or selected images do not contain custom preview size data
= 5.9.6 = = 5.9.6 =
*Release Date - 20 May 2021* *Release Date - 20 May 2021*