Yoast\WP\SEO\Schema_Aggregator\Application
Properties_Merger::merge_types
Merge @type values from two entities
JSON-LD allows @type to be either a string or an array of strings. This method combines types from both entities, deduplicates them, and normalizes the result (string if 1 type, array if multiple).
Examples:
- merge_types("Person", "Person") → "Person"
- merge_types("Person", "Author") → ["Person", "Author"]
- merge_types("Person", ["Author", "Employee"]) → ["Person", "Author", "Employee"]
- merge_types(["Person"], "Person") → "Person"
- merge_types(["Person", "Author"], ["Author", "Employee"]) → ["Person", "Author", "Employee"]
Метод класса: Properties_Merger{}
Хуков нет.
Возвращает
Строку|Массив<Строку>. Merged and normalized @type value.
Использование
// private - только в коде основоного (родительского) класса $result = $this->merge_types( $type1, $type2 );
- $type1(строка|array
|null) (обязательный) - First @type value.
- $type2(строка|array
|null) (обязательный) - Second @type value.
Код Properties_Merger::merge_types() Properties Merger::merge types Yoast 27.7
private function merge_types( $type1, $type2 ) {
$types1 = $this->normalize_type_to_array( $type1 );
$types2 = $this->normalize_type_to_array( $type2 );
$merged = \array_unique( \array_merge( $types1, $types2 ), \SORT_REGULAR );
return $this->normalize_type_from_array( $merged );
}