Skip to content

Commit 89421ce

Browse files
committed
ACF 5.9.5
1 parent 691bae3 commit 89421ce

File tree

10 files changed

+1048
-842
lines changed

10 files changed

+1048
-842
lines changed

acf.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: Advanced Custom Fields
44
Plugin URI: https://www.advancedcustomfields.com
55
Description: Customize WordPress with powerful, professional and intuitive fields.
6-
Version: 5.9.4
6+
Version: 5.9.5
77
Author: Elliot Condon
88
Author URI: https://www.advancedcustomfields.com
99
Text Domain: acf
@@ -17,7 +17,7 @@
1717
class ACF {
1818

1919
/** @var string The plugin version number. */
20-
var $version = '5.9.4';
20+
var $version = '5.9.5';
2121

2222
/** @var array The plugin settings array. */
2323
var $settings = array();

includes/acf-field-functions.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,6 +1203,24 @@ function acf_untrash_field( $id = 0 ) {
12031203
return true;
12041204
}
12051205

1206+
/**
1207+
* Filter callback which returns the previous post_status instead of "draft" for the "acf-field" post type.
1208+
*
1209+
* Prior to WordPress 5.6.0, this filter was not needed as restored posts were always assigned their original status.
1210+
*
1211+
* @since 5.9.5
1212+
*
1213+
* @param string $new_status The new status of the post being restored.
1214+
* @param int $post_id The ID of the post being restored.
1215+
* @param string $previous_status The status of the post at the point where it was trashed.
1216+
* @return string.
1217+
*/
1218+
function _acf_untrash_field_post_status( $new_status, $post_id, $previous_status ) {
1219+
return ( get_post_type( $post_id ) === 'acf-field' ) ? $previous_status : $new_status;
1220+
}
1221+
1222+
add_action( 'wp_untrash_post_status', '_acf_untrash_field_post_status', 10, 3 );
1223+
12061224
/**
12071225
* acf_prefix_fields
12081226
*

includes/acf-field-group-functions.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,24 @@ function acf_untrash_field_group( $id = 0 ) {
763763
return true;
764764
}
765765

766+
/**
767+
* Filter callback which returns the previous post_status instead of "draft" for the "acf-field-group" post type.
768+
*
769+
* Prior to WordPress 5.6.0, this filter was not needed as restored posts were always assigned their original status.
770+
*
771+
* @since 5.9.5
772+
*
773+
* @param string $new_status The new status of the post being restored.
774+
* @param int $post_id The ID of the post being restored.
775+
* @param string $previous_status The status of the post at the point where it was trashed.
776+
* @return string.
777+
*/
778+
function _acf_untrash_field_group_post_status( $new_status, $post_id, $previous_status ) {
779+
return ( get_post_type( $post_id ) === 'acf-field-group' ) ? $previous_status : $new_status;
780+
}
781+
782+
add_action( 'wp_untrash_post_status', '_acf_untrash_field_group_post_status', 10, 3 );
783+
766784
/**
767785
* acf_is_field_group
768786
*

includes/acf-value-functions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ function acf_format_value( $value, $post_id, $field ) {
161161
* @param array $field The field array.
162162
* @return bool.
163163
*/
164-
function acf_update_value( $value = null, $post_id = 0, $field ) {
164+
function acf_update_value( $value, $post_id, $field ) {
165165

166166
// Allow filter to short-circuit update_value logic.
167167
$check = apply_filters( "acf/pre_update_value", null, $value, $post_id, $field );
@@ -215,7 +215,7 @@ function acf_update_value( $value = null, $post_id = 0, $field ) {
215215
* @param (int|string) $post_id The post id.
216216
* @return void
217217
*/
218-
function acf_update_values( $values = array(), $post_id = 0 ) {
218+
function acf_update_values( $values, $post_id ) {
219219

220220
// Loop over values.
221221
foreach( $values as $key => $value ) {

includes/acf-wp-functions.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ function acf_decode_post_id( $post_id = 0 ) {
133133
$id = substr($post_id, $i+1);
134134
} else {
135135
$type = $post_id;
136+
$id = '';
136137
}
137138

138139
// Handle incorrect param type.

includes/api/api-helpers.php

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3163,9 +3163,11 @@ function acf_get_attachment( $attachment ) {
31633163
case 'image':
31643164
$sizes_id = $attachment->ID;
31653165
$src = wp_get_attachment_image_src( $attachment->ID, 'full' );
3166-
$response['url'] = $src[0];
3167-
$response['width'] = $src[1];
3168-
$response['height'] = $src[2];
3166+
if ( $src ) {
3167+
$response['url'] = $src[0];
3168+
$response['width'] = $src[1];
3169+
$response['height'] = $src[2];
3170+
}
31693171
break;
31703172
case 'video':
31713173
$response['width'] = acf_maybe_get( $meta, 'width', 0 );
@@ -3184,14 +3186,16 @@ function acf_get_attachment( $attachment ) {
31843186
// Load array of image sizes.
31853187
if( $sizes_id ) {
31863188
$sizes = get_intermediate_image_sizes();
3187-
$data = array();
3189+
$sizes_data = array();
31883190
foreach( $sizes as $size ) {
31893191
$src = wp_get_attachment_image_src( $sizes_id, $size );
3190-
$data[ $size ] = $src[ 0 ];
3191-
$data[ $size . '-width' ] = $src[ 1 ];
3192-
$data[ $size . '-height' ] = $src[ 2 ];
3192+
if ( $src ) {
3193+
$sizes_data[ $size ] = $src[0];
3194+
$sizes_data[ $size . '-width' ] = $src[1];
3195+
$sizes_data[ $size . '-height' ] = $src[2];
3196+
}
31933197
}
3194-
$response['sizes'] = $data;
3198+
$response['sizes'] = $sizes_data;
31953199
}
31963200

31973201
/**
@@ -4822,20 +4826,17 @@ function acf_array_camel_case( $array = array() ) {
48224826
}
48234827

48244828
/**
4825-
* acf_is_block_editor
4826-
*
4827-
* Returns true if the current screen uses the block editor.
4829+
* Returns true if the current screen is using the block editor.
48284830
*
4829-
* @date 13/12/18
4830-
* @since 5.8.0
4831+
* @date 13/12/18
4832+
* @since 5.8.0
48314833
*
4832-
* @param void
4833-
* @return bool
4834+
* @return bool
48344835
*/
48354836
function acf_is_block_editor() {
4836-
if( function_exists('get_current_screen') ) {
4837+
if ( function_exists( 'get_current_screen' ) ) {
48374838
$screen = get_current_screen();
4838-
if( method_exists($screen, 'is_block_editor') ) {
4839+
if( $screen && method_exists( $screen, 'is_block_editor' ) ) {
48394840
return $screen->is_block_editor();
48404841
}
48414842
}

includes/local-json.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public function save_file( $key, $field_group ) {
213213
if( $field_group['ID'] ) {
214214
$field_group['modified'] = get_post_modified_time( 'U', true, $field_group['ID'] );
215215
} else {
216-
$field_group['modified'] = strtotime();
216+
$field_group['modified'] = strtotime( 'now' );
217217
}
218218

219219
// Prepare for export.

lang/acf-fi.mo

-3.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)