acf_field_flexible_content::update_value
This filter is appied to the $value before it is updated in the db
Метод класса: acf_field_flexible_content{}
Хуков нет.
Возвращает
Разное
. $value The modified value
Использование
$acf_field_flexible_content = new acf_field_flexible_content(); $acf_field_flexible_content->update_value( $value, $post_id, $field );
- $value(разное) (обязательный)
- The value which will be saved in the database.
- $post_id(разное) (обязательный)
- The post_id of which the value will be saved.
- $field(массив) (обязательный)
- The field array holding all the field options.
Список изменений
С версии 3.6 | Введена. |
Код acf_field_flexible_content::update_value() acf field flexible content::update value ACF 6.4.2
public function update_value( $value, $post_id, $field ) { // bail early if no layouts if ( empty( $field['layouts'] ) ) { return $value; } // vars $new_value = array(); $old_value = acf_get_metadata_by_field( $post_id, $field ); $old_value = is_array( $old_value ) ? $old_value : array(); // update if ( ! empty( $value ) ) { $i = -1; // remove acfcloneindex if ( isset( $value['acfcloneindex'] ) ) { unset( $value['acfcloneindex'] ); } // loop through rows foreach ( $value as $row ) { ++$i; // bail early if no layout reference if ( ! is_array( $row ) || ! isset( $row['acf_fc_layout'] ) ) { continue; } // delete old row if layout has changed if ( isset( $old_value[ $i ] ) && $old_value[ $i ] !== $row['acf_fc_layout'] ) { $this->delete_row( $i, $field, $post_id ); } // update row $this->update_row( $row, $i, $field, $post_id ); // append to order $new_value[] = $row['acf_fc_layout']; } } // vars $old_count = empty( $old_value ) ? 0 : count( $old_value ); $new_count = empty( $new_value ) ? 0 : count( $new_value ); // remove old rows if ( $old_count > $new_count ) { // loop for ( $i = $new_count; $i < $old_count; $i++ ) { $this->delete_row( $i, $field, $post_id ); } } // save false for empty value if ( empty( $new_value ) ) { $new_value = ''; } // return return $new_value; }