acf_update_value()
acf_update_value
Updates the value for a given field and post_id.
Хуки из функции
Возвращает
true|false.
Использование
acf_update_value( $value, $post_id, $field );
- $value(разное) (обязательный)
- The new value.
- $post_id((int|string)) (обязательный)
- The post id.
- $field(массив) (обязательный)
- The field array.
Список изменений
| С версии 5.0.0 | Введена. |
Код acf_update_value() acf update value ACF 6.4.2
function acf_update_value( $value, $post_id, $field ) {
// Allow filter to short-circuit update_value logic.
$check = apply_filters( 'acf/pre_update_value', null, $value, $post_id, $field );
if ( $check !== null ) {
return $check;
}
/**
* Filters the $value before it is updated.
*
* @date 28/09/13
* @since 5.0.0
*
* @param mixed $value The value to update.
* @param string $post_id The post ID for this value.
* @param array $field The field array.
* @param mixed $original The original value before modification.
*/
$value = apply_filters( 'acf/update_value', $value, $post_id, $field, $value );
// Allow null to delete value.
if ( $value === null ) {
return acf_delete_value( $post_id, $field );
}
// Update value and reference key.
$return = acf_update_metadata_by_field( $post_id, $field, $value );
acf_update_metadata_by_field( $post_id, $field, $field['key'], true );
// Delete stored data.
acf_flush_value_cache( $post_id, $field['name'] );
// Return update status.
return $return;
}