ACF\AI\GEO

Schema::get_default_output_format │ public static │ ACF 6.8.0

Get the default output format for a field/property combination

When multiple formats are valid, returns the most appropriate default. Prefers object types over primitives when both are available.

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

Хуков нет.

Возвращает

string|null. The default format type, or null if none valid

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

$result = Schema::get_default_output_format( $field_type, $property );
$field_type(строка) (обязательный)
The ACF field type name.
$property(строка) (обязательный)
The Schema.org property name.

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

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

Код Schema::get_default_output_format() ACF 6.8.11

public static function get_default_output_format( $field_type, $property ) {
	$valid_formats = self::get_valid_output_formats( $field_type, $property );

	if ( empty( $valid_formats ) ) {
		return null;
	}

	// If only one format, use it
	if ( count( $valid_formats ) === 1 ) {
		return $valid_formats[0];
	}

	// Prefer object types over primitives (richer data)
	$object_formats = array_diff( $valid_formats, self::$primitive_types );

	if ( ! empty( $object_formats ) ) {
		return reset( $object_formats );
	}

	// Fall back to first primitive
	return $valid_formats[0];
}