From 78e23a77330e550350826a90f554567e16d124e0 Mon Sep 17 00:00:00 2001 From: Phi Phan Date: Sat, 30 Aug 2025 14:37:57 +0700 Subject: [PATCH 1/2] Get the `formatted_value` from the original field value not the formatted value for rest The `formatted_value` property of the $field['name'] . '_source' should come from the original value, not the REST value. Other plugins might change the REST value using the filter `acf/rest/format_value_for_rest`, which can cause the `formatted_value` to be incorrect. --- includes/rest-api/class-acf-rest-api.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/rest-api/class-acf-rest-api.php b/includes/rest-api/class-acf-rest-api.php index 40005b6b..4d9842e8 100644 --- a/includes/rest-api/class-acf-rest-api.php +++ b/includes/rest-api/class-acf-rest-api.php @@ -232,10 +232,10 @@ public function load_fields( $object, $field_name, $request, $object_sub_type ) // Format the field value according to the request params. $format = $request->get_param( 'acf_format' ) ?: acf_get_setting( 'rest_api_format' ); - $value = acf_format_value_for_rest( $value, $post_id, $field, $format ); + $rest_value = acf_format_value_for_rest( $value, $post_id, $field, $format ); // We keep this one for backward compatibility with existing code that expects the field value to be. - $fields[ $field['name'] ] = $value; + $fields[ $field['name'] ] = $rest_value; $fields[ $field['name'] . '_source' ] = array( 'label' => $field['label'], 'type' => $field['type'], From b2d71af4ebe2ffe9443e02847f01180b79e94381 Mon Sep 17 00:00:00 2001 From: Phi Phan Date: Sat, 30 Aug 2025 14:44:21 +0700 Subject: [PATCH 2/2] Get the formatted_value from the original field value The formatted_value property of the $field['name'] . '_source' should come from the original value, not the REST value. Other plugins might change the REST value using the filter acf/rest/format_value_for_rest, which can cause the formatted_value to be incorrect. --- includes/rest-api/class-acf-rest-api.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/rest-api/class-acf-rest-api.php b/includes/rest-api/class-acf-rest-api.php index 4d9842e8..93ef5d12 100644 --- a/includes/rest-api/class-acf-rest-api.php +++ b/includes/rest-api/class-acf-rest-api.php @@ -231,8 +231,8 @@ public function load_fields( $object, $field_name, $request, $object_sub_type ) } // Format the field value according to the request params. - $format = $request->get_param( 'acf_format' ) ?: acf_get_setting( 'rest_api_format' ); - $rest_value = acf_format_value_for_rest( $value, $post_id, $field, $format ); + $format = $request->get_param( 'acf_format' ) ?: acf_get_setting( 'rest_api_format' ); + $rest_value = acf_format_value_for_rest( $value, $post_id, $field, $format ); // We keep this one for backward compatibility with existing code that expects the field value to be. $fields[ $field['name'] ] = $rest_value;