Yoast\WP\SEO\Abilities\Infrastructure
Global_Setting_Field_Map::resolve_extra_keys
Resolves the option patterns of a field.
Метод класса: Global_Setting_Field_Map{}
Хуков нет.
Возвращает
array<string, mixed>|null. The JSON schema without the 'option_patterns' key, or null to drop the field when it has no valid option patterns.
Использование
// 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
'option_patterns'key.
Код Global_Setting_Field_Map::resolve_extra_keys() Global Setting Field Map::resolve extra keys Yoast 28.9
protected function resolve_extra_keys( string $field_name, array $schema ): ?array {
$option_patterns = ( $schema['option_patterns'] ?? null );
if ( ! \is_array( $option_patterns ) || $option_patterns === [] ) {
return null;
}
foreach ( $option_patterns as $target_name => $option_pattern ) {
if ( ! \is_string( $target_name ) || ! \is_string( $option_pattern ) || $option_pattern === '' ) {
return null;
}
}
$this->option_patterns[ $field_name ] = $option_patterns;
// The option patterns are not part of the JSON schema that is published to agents.
unset( $schema['option_patterns'] );
return $schema;
}