ACF\AI\GEO
Schema::type_has_properties
Check if a Schema.org type has properties defined on it or its ancestors
Walks up the type hierarchy checking if the type or any parent (excluding Thing, which is too generic) has properties defined. This distinguishes structural types (Person, Place, Organization) from value types (Duration, Distance) that have no meaningful sub-properties.
Method of the class: Schema{}
No Hooks.
Returns
true|false. True if type or an ancestor has properties defined
Usage
$result = Schema::type_has_properties( $type );
- $type(string) (required)
- The Schema.org type name.
Changelog
| Since 6.8.0 | Introduced. |
Schema::type_has_properties() Schema::type has properties code ACF 6.8.8
public static function type_has_properties( $type ) {
$current = $type;
$property_domains = SchemaData::get_property_domains();
$type_hierarchy = SchemaData::get_type_hierarchy();
// Walk up the hierarchy, but stop before Thing (too generic).
while ( $current && 'Thing' !== $current ) {
foreach ( $property_domains as $domains ) {
if ( in_array( $current, $domains, true ) ) {
return true;
}
}
// Move to parent type.
$current = $type_hierarchy[ $current ] ?? null;
}
return false;
}