Yoast\WP\SEO\Abilities\Application
Archive_And_Special_Page_SEO_Settings_Updater::update_field
Validates and saves a single field, unless the target does not have it, which is never saved, whatever its own validator would say.
Метод класса: Archive_And_Special_Page_SEO_Settings_Updater{}
Хуков нет.
Возвращает
string|null. A warning when the field could not be saved, null otherwise.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->update_field( $validators, $field_name, $value, $context ): ?string;
- $validators(array<string, callable>) (обязательный)
- The validator of each field that has one, keyed by field name.
- $field_name(строка) (обязательный)
- The name of the field.
- $value(разное) (обязательный)
- The value to save.
- $context(array<string, mixed>) (обязательный)
- The target, under
'target'.
Код Archive_And_Special_Page_SEO_Settings_Updater::update_field() Archive And Special Page SEO Settings Updater::update field Yoast 28.9
protected function update_field( array $validators, string $field_name, $value, array $context ): ?string {
if ( ! $this->field_map->target_has_field( $field_name, $context['target'] ) ) {
return \sprintf(
/* translators: 1: the name of a setting, 2: the name of a target. */
\__( 'The %1$s setting is not available for %2$s, so it was not saved.', 'wordpress-seo' ),
$field_name,
$context['target']->get_name(),
);
}
return parent::update_field( $validators, $field_name, $value, $context );
}