Advanced Custom Fields - Version 5.11.1

Version Description

Release Date - 18 November 2021

  • Enhancement - Added "acf/admin/license_key_constant_message" filter to allow changing of the "Your license key is defined in wp-config.php" message
  • Fix - Added warning for when get_field() or similar functions are called before ACF has initialized. Learn more
  • Fix - Fixed fields not appearing on user REST API endpoints if their field group location was set to a user form other than "all"
  • Fix - Fixed warning in REST API if a custom field type did not have the "show_in_rest" property
  • Fix - Fixed an error that could occur if value of WYSIWYG field was not a string
Download this release

Release Info

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

Code changes from version 5.11 to 5.11.1

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.11
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.11';
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.11.1
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.11.1';
23
 
24
  /** @var array The plugin settings array. */
25
  var $settings = array();
includes/acf-value-functions.php CHANGED
@@ -72,6 +72,8 @@ function acf_get_value( $post_id, $field ) {
72
  * to protect against multiple fields with same name.
73
  */
74
  $strict = true;
 
 
75
  if ( empty( $field['type'] ) && empty( $field['key'] ) ) {
76
  $field = acf_get_field( $field_name );
77
  $strict = false;
@@ -79,7 +81,29 @@ function acf_get_value( $post_id, $field ) {
79
 
80
  // At least we tried.
81
  if ( ! $field ) {
82
- return null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  }
84
 
85
  // Load value from database.
72
  * to protect against multiple fields with same name.
73
  */
74
  $strict = true;
75
+ $_field = $field;
76
+
77
  if ( empty( $field['type'] ) && empty( $field['key'] ) ) {
78
  $field = acf_get_field( $field_name );
79
  $strict = false;
81
 
82
  // At least we tried.
83
  if ( ! $field ) {
84
+ // If ACF was initialized before init, show a notice and log the error unless told otherwise.
85
+ if ( ! did_action( 'init' ) && apply_filters( 'acf/admin/show_early_init_notice', true ) ) {
86
+ $error_text = sprintf(
87
+ __( '<strong>%1$s</strong> - We\'ve detected one or more calls to retrieve ACF field values before ACF has been initialized, resulting in missing data. <a href="%2$s" target="_blank">Learn how to fix this</a>.', 'acf'),
88
+ acf_get_setting( 'name' ),
89
+ 'https://www.advancedcustomfields.com/resources/acf-field-functions/'
90
+ );
91
+
92
+ _doing_it_wrong( __FUNCTION__, $error_text, '5.11.1' );
93
+ set_site_transient( 'acf_early_init_notice', $error_text );
94
+ }
95
+
96
+ /**
97
+ * Filters the $value after it has been loaded.
98
+ *
99
+ * @date 28/09/13
100
+ * @since 5.0.0
101
+ *
102
+ * @param mixed $value The value to preview.
103
+ * @param string $post_id The post ID for this value.
104
+ * @param array $field The field array.
105
+ */
106
+ return apply_filters( 'acf/load_value', null, $post_id, $_field );
107
  }
108
 
109
  // Load value from database.
includes/admin/admin.php CHANGED
@@ -18,12 +18,12 @@ if ( ! class_exists( 'ACF_Admin' ) ) :
18
  * @return void
19
  */
20
  function __construct() {
21
-
22
  // Add actions.
23
  add_action( 'admin_menu', array( $this, 'admin_menu' ) );
24
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
25
  add_action( 'admin_body_class', array( $this, 'admin_body_class' ) );
26
  add_action( 'current_screen', array( $this, 'current_screen' ) );
 
27
  }
28
 
29
  /**
@@ -201,6 +201,27 @@ if ( ! class_exists( 'ACF_Admin' ) ) :
201
  // Use RegExp to append "ACF" after the <a> element allowing translations to read correctly.
202
  return preg_replace( '/(<a[\S\s]+?\/a>)/', '$1 ' . __( 'and', 'acf' ) . ' <a href="https://www.advancedcustomfields.com" target="_blank">ACF</a>', $text, 1 );
203
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
  }
205
 
206
  // Instantiate.
18
  * @return void
19
  */
20
  function __construct() {
 
21
  // Add actions.
22
  add_action( 'admin_menu', array( $this, 'admin_menu' ) );
23
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
24
  add_action( 'admin_body_class', array( $this, 'admin_body_class' ) );
25
  add_action( 'current_screen', array( $this, 'current_screen' ) );
26
+ add_action( 'admin_init', array( $this, 'maybe_show_early_init_notice' ) );
27
  }
28
 
29
  /**
201
  // Use RegExp to append "ACF" after the <a> element allowing translations to read correctly.
202
  return preg_replace( '/(<a[\S\s]+?\/a>)/', '$1 ' . __( 'and', 'acf' ) . ' <a href="https://www.advancedcustomfields.com" target="_blank">ACF</a>', $text, 1 );
203
  }
204
+
205
+ /**
206
+ * Displays the notice that can be shown when calling `get_field()`, etc. before `acf/init`.
207
+ *
208
+ * @since 5.11.1
209
+ *
210
+ * @return void
211
+ */
212
+ function maybe_show_early_init_notice() {
213
+ if ( ! acf_get_setting( 'show_admin' ) || ! acf_current_user_can_admin() ) {
214
+ return;
215
+ }
216
+
217
+ $notice = get_site_transient( 'acf_early_init_notice' );
218
+ if ( ! $notice ) {
219
+ return;
220
+ }
221
+
222
+ acf_add_admin_notice( (string) $notice, 'warning', false );
223
+ delete_site_transient( 'acf_early_init_notice' );
224
+ }
225
  }
226
 
227
  // Instantiate.
includes/fields/class-acf-field-wysiwyg.php CHANGED
@@ -179,18 +179,15 @@ if ( ! class_exists( 'acf_field_wysiwyg' ) ) :
179
  );
180
  }
181
 
182
- /*
183
- * render_field()
184
- *
185
- * Create the HTML interface for your field
186
- *
187
- * @param $field - an array holding all the field's data
188
- *
189
- * @type action
190
- * @since 3.6
191
- * @date 23/01/13
192
- */
193
-
194
  function render_field( $field ) {
195
 
196
  // enqueue
@@ -240,6 +237,8 @@ if ( ! class_exists( 'acf_field_wysiwyg' ) ) :
240
 
241
  // filter
242
  add_filter( 'acf_the_editor_content', 'format_for_editor', 10, 2 );
 
 
243
  $field['value'] = apply_filters( 'acf_the_editor_content', $field['value'], $default_editor );
244
 
245
  // attr
@@ -403,39 +402,29 @@ if ( ! class_exists( 'acf_field_wysiwyg' ) ) :
403
 
404
  }
405
 
406
-
407
- /*
408
- * format_value()
409
- *
410
- * This filter is appied to the $value after it is loaded from the db and before it is returned to the template
411
- *
412
- * @type filter
413
- * @since 3.6
414
- * @date 23/01/13
415
- *
416
- * @param $value (mixed) the value which was loaded from the database
417
- * @param $post_id (mixed) the $post_id from which the value was loaded
418
- * @param $field (array) the field array holding all the field options
419
- *
420
- * @return $value (mixed) the modified value
421
- */
422
-
423
  function format_value( $value, $post_id, $field ) {
424
-
425
- // bail early if no value
426
- if ( empty( $value ) ) {
427
-
428
  return $value;
429
-
430
  }
431
 
432
- // apply filters
433
  $value = apply_filters( 'acf_the_content', $value );
434
 
435
- // follow the_content function in /wp-includes/post-template.php
436
- $value = str_replace( ']]>', ']]&gt;', $value );
437
-
438
- return $value;
439
  }
440
 
441
  }
179
  );
180
  }
181
 
182
+ /**
183
+ * Create the HTML interface for your field
184
+ *
185
+ * @param array $field An array holding all the field's data
186
+ *
187
+ * @type action
188
+ * @since 3.6
189
+ * @date 23/01/13
190
+ */
 
 
 
191
  function render_field( $field ) {
192
 
193
  // enqueue
237
 
238
  // filter
239
  add_filter( 'acf_the_editor_content', 'format_for_editor', 10, 2 );
240
+
241
+ $field['value'] = is_string( $field['value'] ) ? $field['value'] : '';
242
  $field['value'] = apply_filters( 'acf_the_editor_content', $field['value'], $default_editor );
243
 
244
  // attr
402
 
403
  }
404
 
405
+ /**
406
+ * This filter is applied to the $value after it is loaded from the db, and before it is returned to the template
407
+ *
408
+ * @type filter
409
+ * @since 3.6
410
+ * @date 23/01/13
411
+ *
412
+ * @param mixed $value The value which was loaded from the database
413
+ * @param mixed $post_id The $post_id from which the value was loaded
414
+ * @param array $field The field array holding all the field options
415
+ *
416
+ * @return mixed $value The modified value
417
+ */
 
 
 
 
418
  function format_value( $value, $post_id, $field ) {
419
+ // Bail early if no value or not a string.
420
+ if ( empty( $value ) || ! is_string( $value ) ) {
 
 
421
  return $value;
 
422
  }
423
 
 
424
  $value = apply_filters( 'acf_the_content', $value );
425
 
426
+ // Follow the_content function in /wp-includes/post-template.php
427
+ return str_replace( ']]>', ']]&gt;', $value );
 
 
428
  }
429
 
430
  }
includes/locations/class-acf-location-user-form.php CHANGED
@@ -36,6 +36,10 @@ if ( ! class_exists( 'ACF_Location_User_Form' ) ) :
36
  * @return bool
37
  */
38
  public function match( $rule, $screen, $field_group ) {
 
 
 
 
39
 
40
  // Check screen args.
41
  if ( isset( $screen['user_form'] ) ) {
36
  * @return bool
37
  */
38
  public function match( $rule, $screen, $field_group ) {
39
+ // REST API has no forms, so we should always allow it.
40
+ if ( ! empty( $screen['rest'] ) ) {
41
+ return true;
42
+ }
43
 
44
  // Check screen args.
45
  if ( isset( $screen['user_form'] ) ) {
includes/rest-api/class-acf-rest-api.php CHANGED
@@ -456,8 +456,8 @@ class ACF_Rest_Api {
456
  switch ( $object_type ) {
457
  case 'user':
458
  $args = array(
459
- 'user_form' => 'all',
460
  'user_id' => $object_id,
 
461
  );
462
  break;
463
  case 'term':
@@ -498,7 +498,8 @@ class ACF_Rest_Api {
498
  $fields = array_filter(
499
  acf_get_fields( $field_group ),
500
  function ( $field ) {
501
- return (bool) acf_get_field_type( $field['type'] )->show_in_rest;
 
502
  }
503
  );
504
 
456
  switch ( $object_type ) {
457
  case 'user':
458
  $args = array(
 
459
  'user_id' => $object_id,
460
+ 'rest' => true,
461
  );
462
  break;
463
  case 'term':
498
  $fields = array_filter(
499
  acf_get_fields( $field_group ),
500
  function ( $field ) {
501
+ $field_type = acf_get_field_type( $field['type'] );
502
+ return isset( $field_type->show_in_rest ) && $field_type->show_in_rest;
503
  }
504
  );
505
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: acf, fields, custom fields, meta, repeater
4
  Requires at least: 4.7
5
  Tested up to: 5.8.1
6
  Requires PHP: 5.6
7
- Stable tag: 5.11
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -76,6 +76,15 @@ From your WordPress dashboard
76
 
77
  == Changelog ==
78
 
 
 
 
 
 
 
 
 
 
79
  = 5.11 =
80
  *Release Date - 10 November 2021*
81
 
4
  Requires at least: 4.7
5
  Tested up to: 5.8.1
6
  Requires PHP: 5.6
7
+ Stable tag: 5.11.1
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
76
 
77
  == Changelog ==
78
 
79
+ = 5.11.1 =
80
+ *Release Date - 18 November 2021*
81
+
82
+ * Enhancement - Added "acf/admin/license_key_constant_message" filter to allow changing of the "Your license key is defined in wp-config.php" message
83
+ * Fix - Added warning for when get_field() or similar functions are called before ACF has initialized. [Learn more](https://www.advancedcustomfields.com/resources/acf-field-functions/)
84
+ * Fix - Fixed fields not appearing on user REST API endpoints if their field group location was set to a user form other than "all"
85
+ * Fix - Fixed warning in REST API if a custom field type did not have the "show_in_rest" property
86
+ * Fix - Fixed an error that could occur if value of WYSIWYG field was not a string
87
+
88
  = 5.11 =
89
  *Release Date - 10 November 2021*
90