acf_format_value_for_rest()
Format a given field's value for output in the REST API.
Хуки из функции
Возвращает
Разное
.
Использование
acf_format_value_for_rest( $value, $post_id, $field, $format );
- $value (обязательный)
- -
- $post_id (обязательный)
- -
- $field (обязательный)
- -
- $format(строка)
- 'light' for normal REST API formatting or 'standard' to apply ACF's normal field formatting.
По умолчанию: 'light'
Код acf_format_value_for_rest() acf format value for rest ACF 6.0.4
function acf_format_value_for_rest( $value, $post_id, $field, $format = 'light' ) { if ( $format === 'standard' ) { $value_formatted = acf_format_value( $value, $post_id, $field ); } else { $type = acf_get_field_type( $field['type'] ); $value_formatted = $type->format_value_for_rest( $value, $post_id, $field ); } /** * Filter the formatted value for a given field. * * @param mixed $value_formatted The formatted value. * @param string|int $post_id The post ID of the current object. * @param array $field The field array. * @param mixed $value The raw/unformatted value. * @param string $format The format applied to the field value. */ return apply_filters( 'acf/rest/format_value_for_rest', $value_formatted, $post_id, $field, $value, $format ); }