Yoast\WP\SEO\Abilities\Application

Site_Representation_Updater::update_field │ private │ Yoast 1.0

Validates and saves a single field.

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

Хуков нет.

Возвращает

string|null. A warning when the field could not be saved, null otherwise.

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

// private - только в коде основоного (родительского) класса
$result = $this->update_field( $field_name, $value ): ?string;
$field_name(строка) (обязательный)
The option name of the field.
$value(разное) (обязательный)
The value to save.

Код Site_Representation_Updater::update_field() Yoast 28.8

private function update_field( string $field_name, $value ): ?string {
	$warning = $this->validate_field( $field_name, $value );
	if ( $warning !== null ) {
		return $warning;
	}

	if ( ! $this->save_field( $field_name, $value ) ) {
		// A failed save is also reported when the value was invalid or the option sanitized it into
		// something else, so the warning points to the returned value rather than claiming nothing was stored.
		return \sprintf(
			/* translators: %s expands to the name of a setting. */
			\__( 'The %s setting could not be saved as provided, so its current value is returned.', 'wordpress-seo' ),
			$field_name,
		);
	}

	return null;
}