acf_field_icon_picker::format_valuepublicACF 6.3

This filter is appied to the $value after it is loaded from the db and before it is returned to the template

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

Хуков нет.

Возвращает

Разное. $value The modified value.

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

$acf_field_icon_picker = new acf_field_icon_picker();
$acf_field_icon_picker->format_value( $value, $post_id, $field );
$value(разное) (обязательный)
The value which was loaded from the database.
$post_id(int) (обязательный)
The $post_id from which the value was loaded.
$field(массив) (обязательный)
The field array holding all the field options.

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

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

Код acf_field_icon_picker::format_value() ACF 6.4.2

public function format_value( $value, $post_id, $field ) {
	// Handle empty values.
	if ( empty( $value ) ) {
		// Return the default value if there is one.
		if ( isset( $field['default_value'] ) ) {
			return $field['default_value'];
		} else {
			// Otherwise return false.
			return false;
		}
	}

	// If media_library, behave the same as an image field.
	if ( $value['type'] === 'media_library' ) {
		// convert to int
		$value['value'] = intval( $value['value'] );

		// format
		if ( $field['return_format'] === 'string' ) {
			return wp_get_attachment_url( $value['value'] );
		} elseif ( $field['return_format'] === 'array' ) {
			$value['value'] = acf_get_attachment( $value['value'] );
			return $value;
		}
	}

	// If the desired return format is a string
	if ( $field['return_format'] === 'string' ) {
		return $value['value'];
	}

	// If nothing specific matched the return format, just return the value.
	return $value;
}