acf_field_flexible_content::format_value()
This filter is appied to the $value after it is loaded from the db and before it is returned to the template
Метод класса: acf_field_flexible_content{}
Хуков нет.
Возвращает
$value
. (mixed) the modified value
Использование
$acf_field_flexible_content = new acf_field_flexible_content(); $acf_field_flexible_content->format_value( $value, $post_id, $field );
- $value (обязательный)
- -
- $post_id (обязательный)
- -
- $field (обязательный)
- -
Список изменений
С версии 3.6 | Введена. |
Код acf_field_flexible_content::format_value() acf field flexible content::format value ACF 6.0.4
function format_value( $value, $post_id, $field ) { // bail early if no value if ( empty( $value ) || empty( $field['layouts'] ) ) { return false; } // sort layouts into names $layouts = array(); foreach ( $field['layouts'] as $k => $layout ) { $layouts[ $layout['name'] ] = $layout['sub_fields']; } // loop over rows foreach ( array_keys( $value ) as $i ) { // get layout name $l = $value[ $i ]['acf_fc_layout']; // bail early if layout deosnt exist if ( empty( $layouts[ $l ] ) ) { continue; } // get layout $layout = $layouts[ $l ]; // loop through sub fields foreach ( array_keys( $layout ) as $j ) { // get sub field $sub_field = $layout[ $j ]; // bail early if no name (tab) if ( acf_is_empty( $sub_field['name'] ) ) { continue; } // extract value $sub_value = acf_extract_var( $value[ $i ], $sub_field['key'] ); // update $sub_field name $sub_field['name'] = "{$field['name']}_{$i}_{$sub_field['name']}"; // format value $sub_value = acf_format_value( $sub_value, $post_id, $sub_field ); // append to $row $value[ $i ][ $sub_field['_name'] ] = $sub_value; } } // return return $value; }