acf_field_select::update_valuepublicACF 3.6

Filters the $value before it is updated in the db.

Метод класса: acf_field_select{}

Хуков нет.

Возвращает

mixed.

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

$acf_field_select = new acf_field_select();
$acf_field_select->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_select::update_value() ACF 6.8.8

public function update_value( $value, $post_id, $field ) {
	// Bail early if no value.
	if ( empty( $value ) ) {
		return $value;
	}

	// Format array of values.
	// - Parse each value as string for SQL LIKE queries.
	if ( is_array( $value ) ) {
		$value = array_map( 'strval', $value );
	}

	// Save custom options back to the field definition if configured.
	if ( ! empty( $field['save_options'] ) && is_array( $value ) ) {
		// Get the raw field, using the ID if present or the key otherwise (i.e. when using JSON).
		$selector = $field['ID'] ? $field['ID'] : $field['key'];
		$field    = acf_get_field( $selector );

		// Bail if we don't have a valid field or field ID (JSON only).
		if ( empty( $field['ID'] ) ) {
			return $value;
		}

		$this->append_user_choices_to_field( $value, $post_id, $field );
	}

	return $value;
}