Yoast\WP\SEO\Abilities\Infrastructure

Author_Schema_Field_Map::resolve_extra_keys │ protected │ Yoast 1.0

Resolves the repository of a field, which defaults to the user meta repository.

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

Хуков нет.

Возвращает

array<string, mixed>|null. The JSON schema without the 'repository' key, or null to drop the field when its repository is not one, or when it is not a string field stored by the user meta repository.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->resolve_extra_keys( $field_name, $schema ): ?array;
$field_name(строка) (обязательный)
The name of the field.
$schema(array<string, mixed>) (обязательный)
The JSON schema of the field, along with its 'repository' key.

Код Author_Schema_Field_Map::resolve_extra_keys() Yoast 28.9

protected function resolve_extra_keys( string $field_name, array $schema ): ?array {
	$repository = ( $schema['repository'] ?? $this->user_meta_repository );
	if ( ! $repository instanceof Author_Schema_Field_Repository_Interface ) {
		return null;
	}

	// The user meta repository sanitizes the value as text, so it would mangle values of any other type.
	if ( $repository === $this->user_meta_repository && ( $schema['type'] ?? null ) !== 'string' ) {
		return null;
	}

	$this->repositories[ $field_name ] = $repository;

	// The repository is not part of the JSON schema that is published to agents.
	unset( $schema['repository'] );

	return $schema;
}