ACF\AI\GEO
GEO::determine_schema_type
Determine the final "@type" value for JSON-LD output
Merges provided types (from post type/block settings) with field types (from qualified properties like "Recipe.prepTime"). Falls back to the default type if neither source provides any types.
Method of the class: GEO{}
No Hooks.
Returns
String|Array. Final @type value (string for single type, array for multiple).
Usage
$result = GEO::determine_schema_type( $provided_types, $field_types, $default_type );
- $provided_types(string|array|null) (required)
- Types explicitly set in settings (can be string, array, or null).
- $field_types(array) (required)
- Types extracted from qualified properties.
- $default_type(string)
- Fallback type if no types provided.
Default:'Thing'
Changelog
| Since 6.8.0 | Introduced. |
GEO::determine_schema_type() GEO::determine schema type code ACF 6.8.8
public static function determine_schema_type( $provided_types, $field_types, $default_type = 'Thing' ) {
$types = array();
// Add provided types from post type/block settings.
if ( ! empty( $provided_types ) ) {
$types = is_array( $provided_types ) ? $provided_types : array( $provided_types );
}
// Merge in field types from qualified properties.
if ( ! empty( $field_types ) && is_array( $field_types ) ) {
$types = array_merge( $types, $field_types );
}
$types = array_values( array_unique( $types ) );
if ( empty( $types ) ) {
return $default_type;
}
return count( $types ) === 1 ? $types[0] : $types;
}