acf_field_post_object::update_value
Filters the field value before it is saved into the database.
Метод класса: acf_field_post_object{}
Хуков нет.
Возвращает
Разное. $value The modified value.
Использование
$acf_field_post_object = new acf_field_post_object(); $acf_field_post_object->update_value( $value, $post_id, $field );
- $value(разное) (обязательный)
- The value which will be saved in the database.
- $post_id(int) (обязательный)
- The post_id of which the value will be saved.
- $field(массив) (обязательный)
- The field array holding all the field options.
Список изменений
| С версии 3.6 | Введена. |
Код acf_field_post_object::update_value() acf field post object::update value ACF 6.4.2
public function update_value( $value, $post_id, $field ) {
// Bail early if no value.
if ( empty( $value ) ) {
acf_update_bidirectional_values( array(), $post_id, $field );
return $value;
}
// Format array of values.
// - ensure each value is an id.
// - Parse each id as string for SQL LIKE queries.
if ( acf_is_sequential_array( $value ) ) {
$value = array_map( 'acf_idval', $value );
$value = array_map( 'strval', $value );
// Parse single value for id.
} else {
$value = acf_idval( $value );
}
acf_update_bidirectional_values( acf_get_array( $value ), $post_id, $field );
return $value;
}