Automattic\WooCommerce\Internal\PushNotifications\Services

NotificationPreferencesService::sanitizeprivateWC 1.0

Drop unknown top-level keys and unknown sub-fields per key, coercing known sub-fields to their expected types.

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

Хуков нет.

Возвращает

Массив<Строку,. array<string, mixed>> Sanitized preferences.

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

// private - только в коде основоного (родительского) класса
$result = $this->sanitize( $preferences ): array;
$preferences(массив) (обязательный)
Arbitrary preferences map.

Код NotificationPreferencesService::sanitize() WC 10.9.1

private function sanitize( array $preferences ): array {
	$allowed   = $this->get_defaults();
	$sanitized = array();

	foreach ( $allowed as $key => $default_shape ) {
		$value             = $preferences[ $key ] ?? array();
		$value             = is_array( $value ) ? $value : array();
		$sanitized[ $key ] = $this->sanitize_value( $key, $value, $default_shape );
	}

	return $sanitized;
}