WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

acf_field_radio::update_value() public ACF 3.6

This filter is appied to the $value before it is updated in the db

{} Это метод класса: acf_field_radio{}

Хуков нет.


$value. - the modified value


$acf_field_radio = new acf_field_radio();
$acf_field_radio->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_radio::update_value() ACF 5.9.1

function update_value( $value, $post_id, $field ) {
	// bail early if no value (allow 0 to be saved)
	if( !$value && !is_numeric($value) ) return $value;
	// save_other_choice
	if( $field['save_other_choice'] ) {
		// value isn't in choices yet
		if( !isset($field['choices'][ $value ]) ) {
			// get raw $field (may have been changed via repeater field)
			// if field is local, it won't have an ID
			$selector = $field['ID'] ? $field['ID'] : $field['key'];
			$field = acf_get_field( $selector, true );
			// bail early if no ID (JSON only)
			if( !$field['ID'] ) return $value;
			// unslash (fixes serialize single quote issue)
			$value = wp_unslash($value);
			// sanitize (remove tags)
			$value = sanitize_text_field($value);
			// update $field
			$field['choices'][ $value ] = $value;
			// save
			acf_update_field( $field );
	// return
	return $value;