Automattic\WooCommerce\Internal\Features

FeaturesController::process_updated_option()privateWC 1.0

Handler for the updated_option

It fires FEATURE_ENABLED_CHANGED_ACTION when a feature is enabled or disabled.

{} Это метод класса: FeaturesController{}

Хуки из метода

Возвращает

null. Ничего.

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

// private - только в коде основоного (родительского) класса
$result = $this->process_updated_option( $option, $old_value, $value );
$option(строка) (обязательный)
The option that has been modified.
$old_value(разное) (обязательный)
The old value of the option.
$value(разное) (обязательный)
The new value of the option.

Код FeaturesController::process_updated_option() WC 7.1.0

private function process_updated_option( string $option, $old_value, $value ) {
	$matches = array();
	$success = preg_match( '/^woocommerce_feature_([a-zA-Z0-9_]+)_enabled$/', $option, $matches );

	if ( ! $success && Analytics::TOGGLE_OPTION_NAME !== $option && Init::TOGGLE_OPTION_NAME !== $option ) {
		return;
	}

	if ( $value === $old_value ) {
		return;
	}

	if ( Analytics::TOGGLE_OPTION_NAME === $option ) {
		$feature_id = 'analytics';
	} elseif ( Init::TOGGLE_OPTION_NAME === $option ) {
		$feature_id = 'new_navigation';
	} else {
		$feature_id = $matches[1];
	}

	/**
	 * Action triggered when a feature is enabled or disabled (the value of the corresponding setting option is changed).
	 *
	 * @param string $feature_id The id of the feature.
	 * @param bool $enabled True if the feature has been enabled, false if it has been disabled.
	 *
	 * @since 7.0.0
	 */
	do_action( self::FEATURE_ENABLED_CHANGED_ACTION, $feature_id, 'yes' === $value );
}