acf_field__group::format_value_for_rest()publicACF 1.0

Apply basic formatting to prepare the value for default REST output.

{} Это метод класса: acf_field__group{}

Хуков нет.

Возвращает

Массив|Разное.

Использование

$acf_field__group = new acf_field__group();
$acf_field__group->format_value_for_rest( $value, $post_id, $field );
$value(разное) (обязательный)
-
$post_id(int|строка) (обязательный)
-
$field(массив) (обязательный)
-

Код acf_field__group::format_value_for_rest() ACF 6.0.4

public function format_value_for_rest( $value, $post_id, array $field ) {
	if ( empty( $value ) || ! is_array( $value ) || empty( $field['sub_fields'] ) ) {
		return $value;
	}

	// Loop through each row and within that, each sub field to process sub fields individually.
	foreach ( $field['sub_fields'] as $sub_field ) {

		// Extract the sub field 'field_key'=>'value' pair from the $value and format it.
		$sub_value = acf_extract_var( $value, $sub_field['key'] );
		$sub_value = acf_format_value_for_rest( $sub_value, $post_id, $sub_field );

		// Add the sub field value back to the $value but mapped to the field name instead
		// of the key reference.
		$value[ $sub_field['name'] ] = $sub_value;
	}

	return $value;
}