Automattic\WooCommerce\Internal\PushNotifications\Services
NotificationPreferencesService::get_preferences
Retrieve a user's notification preferences.
Falls back to defaults for users with no stored preferences. Stored preferences are overlaid on top of the defaults so that any newer keys not yet on disk are filled in.
Метод класса: NotificationPreferencesService{}
Хуков нет.
Возвращает
Массив<Строку,. array<string, mixed>> Map of preference key => sub-options.
Использование
$NotificationPreferencesService = new NotificationPreferencesService(); $NotificationPreferencesService->get_preferences( $user_id ): array;
- $user_id(int) (обязательный)
- The user ID.
Список изменений
| С версии 10.8.0 | Введена. |
Код NotificationPreferencesService::get_preferences() NotificationPreferencesService::get preferences WC 11.0.1
public function get_preferences( int $user_id ): array {
$envelope = $this->data_store->read( $user_id );
if ( null === $envelope ) {
return $this->get_defaults();
}
$stored = isset( $envelope['preferences'] ) && is_array( $envelope['preferences'] )
? $envelope['preferences']
: array();
return $this->sanitize( array_replace_recursive( $this->get_defaults(), $stored ) );
}