ACF\AI\GEO

Schema::get_default_output_formatpublic staticACF 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.

Method of the class: Schema{}

No Hooks.

Returns

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

Usage

$result = Schema::get_default_output_format( $field_type, $property );
$field_type(string) (required)
The ACF field type name.
$property(string) (required)
The Schema.org property name.

Changelog

Since 6.8.0 Introduced.

Schema::get_default_output_format() code ACF 6.8.8

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];
}