Yoast\WP\SEO\Abilities\Application

Site_Representation_Updater::update │ public │ Yoast 1.0

Updates the site representation settings in the input and returns the new state of all of them.

Only fields present in the input are changed (patch semantics). Settings that cannot be applied or saved are reported in a warning, while the other settings are still saved.

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

Хуков нет.

Возвращает

array<string, mixed>. The new site representation settings, plus a warning when some could not be changed.

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

$Site_Representation_Updater = new Site_Representation_Updater();
$Site_Representation_Updater->update( $input ): array;
$input(array<string, mixed>) (обязательный)
The site representation settings to change, keyed by option name.

Код Site_Representation_Updater::update() Yoast 28.8

public function update( array $input ): array {
	$fields    = $this->field_map->get_fields();
	$warnings  = [];
	$saved_any = false;

	foreach ( \array_keys( \array_intersect_key( $fields, $input ) ) as $field_name ) {
		$warning = $this->update_field( $field_name, $input[ $field_name ] );
		if ( $warning === null ) {
			$saved_any = true;
			continue;
		}

		$warnings[] = $warning;
	}

	$result = $this->get_settings( $fields );

	if ( $warnings !== [] ) {
		$warnings[]        = ( $saved_any ) ? \__( 'The other settings were saved.', 'wordpress-seo' ) : \__( 'No other settings were saved.', 'wordpress-seo' );
		$result['warning'] = \implode( ' ', $warnings );
	}

	return $result;
}