Advanced Custom Fields - Version 5.12.2

Version Description

Release Date 6th April 2022

  • Fix - Cloned fields in custom named options pages now behave correctly
  • Fix - Default values and the acf/load_value filter are now applied if a field value load fails security validation
  • Fix - The ACF field is no longer present in REST responses if the ACF REST API setting is disabled
  • Fix - Duplicating a flexible content layout or repeater row now also replaces the field ID in for attributes
Download this release

Release Info

Developer deliciousbrains
Plugin Icon 128x128 Advanced Custom Fields
Version 5.12.2
Comparing to
See all releases

Code changes from version 5.12.1 to 5.12.2

acf.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Advanced Custom Fields
4
  Plugin URI: https://www.advancedcustomfields.com
5
  Description: Customize WordPress with powerful, professional and intuitive fields.
6
- Version: 5.12.1
7
  Author: Delicious Brains
8
  Author URI: https://www.advancedcustomfields.com
9
  Text Domain: acf
@@ -19,7 +19,7 @@ if ( ! class_exists( 'ACF' ) ) :
19
  class ACF {
20
 
21
  /** @var string The plugin version number. */
22
- var $version = '5.12.1';
23
 
24
  /** @var array The plugin settings array. */
25
  var $settings = array();
3
  Plugin Name: Advanced Custom Fields
4
  Plugin URI: https://www.advancedcustomfields.com
5
  Description: Customize WordPress with powerful, professional and intuitive fields.
6
+ Version: 5.12.2
7
  Author: Delicious Brains
8
  Author URI: https://www.advancedcustomfields.com
9
  Text Domain: acf
19
  class ACF {
20
 
21
  /** @var string The plugin version number. */
22
+ var $version = '5.12.2';
23
 
24
  /** @var array The plugin settings array. */
25
  var $settings = array();
includes/acf-value-functions.php CHANGED
@@ -63,32 +63,42 @@ function acf_get_value( $post_id, $field ) {
63
  // Get field ID & type.
64
  $decoded = acf_decode_post_id( $post_id );
65
 
 
 
66
  // If we don't have a proper field array, the field doesn't exist currently.
67
  if ( empty( $field['type'] ) && empty( $field['key'] ) ) {
68
 
 
 
 
69
  if ( apply_filters( 'acf/prevent_access_to_unknown_fields', false ) || ( 'option' === $decoded['type'] && 'options' !== $decoded['id'] ) ) {
70
- return null;
71
  }
72
-
73
- do_action( 'acf/get_invalid_field_value', $field, __FUNCTION__ );
74
  }
75
 
76
  // If we're using a non options_ option key, ensure we have a valid reference key.
77
  if ( 'option' === $decoded['type'] && 'options' !== $decoded['id'] ) {
78
  $meta = acf_get_metadata( $post_id, $field_name, true );
79
- if ( ! $meta || $meta !== $field['key'] ) {
80
- return null;
 
 
 
 
81
  }
82
  }
83
 
84
- // Check store.
85
  $store = acf_get_store( 'values' );
86
- if ( $store->has( "$post_id:$field_name" ) ) {
87
- return $store->get( "$post_id:$field_name" );
88
- }
89
 
90
- // Load value from database.
91
- $value = acf_get_metadata( $post_id, $field_name );
 
 
 
 
 
 
92
 
93
  // Use field's default_value if no meta was found.
94
  if ( $value === null && isset( $field['default_value'] ) ) {
@@ -107,8 +117,10 @@ function acf_get_value( $post_id, $field ) {
107
  */
108
  $value = apply_filters( 'acf/load_value', $value, $post_id, $field );
109
 
110
- // Update store.
111
- $store->set( "$post_id:$field_name", $value );
 
 
112
 
113
  // Return value.
114
  return $value;
63
  // Get field ID & type.
64
  $decoded = acf_decode_post_id( $post_id );
65
 
66
+ $allow_load = true;
67
+
68
  // If we don't have a proper field array, the field doesn't exist currently.
69
  if ( empty( $field['type'] ) && empty( $field['key'] ) ) {
70
 
71
+ // Check if we should trigger warning about accessing fields too early via action.
72
+ do_action( 'acf/get_invalid_field_value', $field, __FUNCTION__ );
73
+
74
  if ( apply_filters( 'acf/prevent_access_to_unknown_fields', false ) || ( 'option' === $decoded['type'] && 'options' !== $decoded['id'] ) ) {
75
+ $allow_load = false;
76
  }
 
 
77
  }
78
 
79
  // If we're using a non options_ option key, ensure we have a valid reference key.
80
  if ( 'option' === $decoded['type'] && 'options' !== $decoded['id'] ) {
81
  $meta = acf_get_metadata( $post_id, $field_name, true );
82
+ if ( ! $meta ) {
83
+ $allow_load = false;
84
+ } elseif ( $meta !== $field['key'] ) {
85
+ if ( ! isset( $field['__key'] ) || $meta !== $field['__key'] ) {
86
+ $allow_load = false;
87
+ }
88
  }
89
  }
90
 
91
+ // Load Store.
92
  $store = acf_get_store( 'values' );
 
 
 
93
 
94
+ // If we're allowing load, check the store or load value from database.
95
+ if ( $allow_load ) {
96
+ if ( $store->has( "$post_id:$field_name" ) ) {
97
+ return $store->get( "$post_id:$field_name" );
98
+ }
99
+
100
+ $value = acf_get_metadata( $post_id, $field_name );
101
+ }
102
 
103
  // Use field's default_value if no meta was found.
104
  if ( $value === null && isset( $field['default_value'] ) ) {
117
  */
118
  $value = apply_filters( 'acf/load_value', $value, $post_id, $field );
119
 
120
+ // Update store if we allowed the value load.
121
+ if ( $allow_load ) {
122
+ $store->set( "$post_id:$field_name", $value );
123
+ }
124
 
125
  // Return value.
126
  return $value;
includes/rest-api/class-acf-rest-api.php CHANGED
@@ -46,6 +46,10 @@ class ACF_Rest_Api {
46
  * Register our custom property as a REST field.
47
  */
48
  public function register_field() {
 
 
 
 
49
  if ( ! $this->request instanceof ACF_Rest_Request ) {
50
  $this->request = new ACF_Rest_Request();
51
  $this->request->parse_request( null );
46
  * Register our custom property as a REST field.
47
  */
48
  public function register_field() {
49
+ if ( ! acf_get_setting( 'rest_api_enabled' ) ) {
50
+ return;
51
+ }
52
+
53
  if ( ! $this->request instanceof ACF_Rest_Request ) {
54
  $this->request = new ACF_Rest_Request();
55
  $this->request->parse_request( null );
lang/acf.pot CHANGED
@@ -138,7 +138,7 @@ msgstr ""
138
  msgid "copy"
139
  msgstr ""
140
 
141
- #: includes/acf-value-functions.php:353
142
  msgid "<strong>%1$s</strong> - We've detected one or more calls to retrieve ACF field values before ACF has been initialized. This is not supported and can result in malformed or missing data. <a href=\"%2$s\" target=\"_blank\">Learn how to fix this</a>."
143
  msgstr ""
144
 
@@ -329,20 +329,20 @@ msgstr ""
329
  msgid "Block type \"%s\" is already registered."
330
  msgstr ""
331
 
332
- #: pro/blocks.php:495
333
  msgid "Switch to Edit"
334
  msgstr ""
335
 
336
- #: pro/blocks.php:496
337
  msgid "Switch to Preview"
338
  msgstr ""
339
 
340
- #: pro/blocks.php:497
341
  msgid "Change content alignment"
342
  msgstr ""
343
 
344
  #. translators: %s: Block type title
345
- #: pro/blocks.php:500
346
  msgid "%s settings"
347
  msgstr ""
348
 
138
  msgid "copy"
139
  msgstr ""
140
 
141
+ #: includes/acf-value-functions.php:374
142
  msgid "<strong>%1$s</strong> - We've detected one or more calls to retrieve ACF field values before ACF has been initialized. This is not supported and can result in malformed or missing data. <a href=\"%2$s\" target=\"_blank\">Learn how to fix this</a>."
143
  msgstr ""
144
 
329
  msgid "Block type \"%s\" is already registered."
330
  msgstr ""
331
 
332
+ #: pro/blocks.php:496
333
  msgid "Switch to Edit"
334
  msgstr ""
335
 
336
+ #: pro/blocks.php:497
337
  msgid "Switch to Preview"
338
  msgstr ""
339
 
340
+ #: pro/blocks.php:498
341
  msgid "Change content alignment"
342
  msgstr ""
343
 
344
  #. translators: %s: Block type title
345
+ #: pro/blocks.php:501
346
  msgid "%s settings"
347
  msgstr ""
348
 
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: deliciousbrains, bradt, elliotcondon
3
  Tags: acf, fields, custom fields, meta, repeater
4
  Requires at least: 4.7
5
- Tested up to: 5.9.2
6
  Requires PHP: 5.6
7
- Stable tag: 5.12.1
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -14,6 +14,8 @@ Customize WordPress with powerful, professional and intuitive fields. Proudly po
14
 
15
  Advanced Custom Fields turns WordPress sites into a fully-fledged content management system by giving you all the tools to do more with your data.
16
 
 
 
17
  Use the Advanced Custom Fields plugin to take full control of your WordPress edit screens & custom field data.
18
 
19
  **Add fields on demand.** Our field builder allows you to quickly and easily add fields to WP edit screens with only the click of a few buttons!
@@ -76,6 +78,14 @@ From your WordPress dashboard
76
 
77
  == Changelog ==
78
 
 
 
 
 
 
 
 
 
79
  = 5.12.1 =
80
  *Release Date 23rd March 2022*
81
 
2
  Contributors: deliciousbrains, bradt, elliotcondon
3
  Tags: acf, fields, custom fields, meta, repeater
4
  Requires at least: 4.7
5
+ Tested up to: 6.0
6
  Requires PHP: 5.6
7
+ Stable tag: 5.12.2
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
14
 
15
  Advanced Custom Fields turns WordPress sites into a fully-fledged content management system by giving you all the tools to do more with your data.
16
 
17
+ https://deliciousbrains.wistia.com/medias/md7ea4ep8z
18
+
19
  Use the Advanced Custom Fields plugin to take full control of your WordPress edit screens & custom field data.
20
 
21
  **Add fields on demand.** Our field builder allows you to quickly and easily add fields to WP edit screens with only the click of a few buttons!
78
 
79
  == Changelog ==
80
 
81
+ = 5.12.2 =
82
+ *Release Date 6th April 2022*
83
+
84
+ * Fix - Cloned fields in custom named options pages now behave correctly
85
+ * Fix - Default values and the `acf/load_value` filter are now applied if a field value load [fails security validation](https://www.advancedcustomfields.com/resources/acf-field-functions/#non-acf-data)
86
+ * Fix - The ACF field is no longer present in REST responses if the ACF REST API setting is disabled
87
+ * Fix - Duplicating a flexible content layout or repeater row now also replaces the field ID in `for` attributes
88
+
89
  = 5.12.1 =
90
  *Release Date 23rd March 2022*
91