acf_rest_apply_reference_sanitizer()
Reduces reference-field REST responses (Relationship, Post Object, Image, Gallery, File) to light-format IDs when the current caller cannot read one or more of the referenced resources. Hooked into acf/rest/format_value_for_rest so the sanitizer only runs for field types that can carry reference data (either directly or via containers).
Хуков нет.
Возвращает
mixed.
Использование
acf_rest_apply_reference_sanitizer( $value_formatted, $post_id, $field, $value, $format );
- $value_formatted(разное) (обязательный)
- The formatted field value.
- $post_id(строка|int) (обязательный)
- The post ID of the current object.
- $field(массив) (обязательный)
- The field array.
- $value(разное) (обязательный)
- The raw/unformatted value.
- $format(строка) (обязательный)
- The format applied to the field value.
Список изменений
| С версии 6.8.10 | Введена. |
Код acf_rest_apply_reference_sanitizer() acf rest apply reference sanitizer ACF 6.8.11
function acf_rest_apply_reference_sanitizer( $value_formatted, $post_id, $field, $value, $format ) {
unset( $post_id );
if ( 'standard' !== $format || empty( $field['type'] ) ) {
return $value_formatted;
}
$reducible_types = array_merge(
acf_rest_reducible_reference_leaf_types(),
array( 'group', 'clone', 'repeater', 'flexible_content' )
);
if ( ! in_array( $field['type'], $reducible_types, true ) ) {
return $value_formatted;
}
return acf_rest_sanitize_reference_data( $value_formatted, $value, $field );
}