acf_field_taxonomy::update_value()publicACF 3.6

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

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

Хуков нет.

Возвращает

$value. - the modified value

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

$acf_field_taxonomy = new acf_field_taxonomy();
$acf_field_taxonomy->update_value( $value, $post_id, $field );
$value (обязательный)
-
$post_id (обязательный)
-
$field (обязательный)
-

Список изменений

С версии 3.6 Введена.

Код acf_field_taxonomy::update_value() ACF 6.0.4

function update_value( $value, $post_id, $field ) {

	// vars
	if ( is_array( $value ) ) {

		$value = array_filter( $value );

	}

	// save_terms
	if ( $field['save_terms'] ) {

		// vars
		$taxonomy = $field['taxonomy'];

		// force value to array
		$term_ids = acf_get_array( $value );

		// convert to int
		$term_ids = array_map( 'intval', $term_ids );

		// get existing term id's (from a previously saved field)
		$old_term_ids = isset( $this->save_post_terms[ $taxonomy ] ) ? $this->save_post_terms[ $taxonomy ] : array();

		// append
		$this->save_post_terms[ $taxonomy ] = array_merge( $old_term_ids, $term_ids );

		// if called directly from frontend update_field()
		if ( ! did_action( 'acf/save_post' ) ) {

			$this->save_post( $post_id );

			return $value;

		}
	}

	// return
	return $value;

}