Automattic\WooCommerce\Blueprint\Importers

ImportSetSiteOptions::processpublicWC 1.0

Process the step.

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

Хуков нет.

Возвращает

StepProcessorResult.

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

$ImportSetSiteOptions = new ImportSetSiteOptions();
$ImportSetSiteOptions->process( $schema ): StepProcessorResult;
$schema(объект) (обязательный)
The schema to process.

Код ImportSetSiteOptions::process() WC 10.0.2

public function process( $schema ): StepProcessorResult {
	$result = StepProcessorResult::success( SetSiteOptions::get_step_name() );
	foreach ( $schema->options as $key => $value ) {
		// Skip if the option should not be modified.
		if ( in_array( $key, self::RESTRICTED_OPTIONS, true ) ) {
			$result->add_warn( "Cannot modify '{$key}' option: Modifying is restricted for this key." );
			continue;
		}

		$value   = json_decode( wp_json_encode( $value ), true );
		$updated = $this->wp_update_option( $key, $value );

		if ( $updated ) {
			$result->add_info( "{$key} has been updated." );
			continue;
		}

		$current_value = $this->wp_get_option( $key );
		if ( $current_value === $value ) {
			$result->add_info( "{$key} has not been updated because the current value is already up to date." );
		}
	}

	return $result;
}