Automattic\WooCommerce\Internal\PushNotifications\Services
NotificationPreferencesService::get_defaults
Return the default preferences for a new user.
Each preference is a small object so future fields (thresholds, sub-toggles) can be added without bumping the schema version. The keyset is derived from Notification::NOTIFICATION_CLASSES so adding a new notification type automatically opts it into preferences — no parallel list to keep in sync.
Метод класса: NotificationPreferencesService{}
Хуков нет.
Возвращает
Массив<Строку,. array<string, mixed>> Map of preference key => default sub-options.
Использование
$NotificationPreferencesService = new NotificationPreferencesService(); $NotificationPreferencesService->get_defaults(): array;
Список изменений
| С версии 10.8.0 | Введена. |
Код NotificationPreferencesService::get_defaults() NotificationPreferencesService::get defaults WC 11.0.1
public function get_defaults(): array {
$defaults = array();
foreach ( array_keys( Notification::NOTIFICATION_CLASSES ) as $type ) {
$defaults[ $type ] = array( 'enabled' => true );
}
$defaults['store_order']['min_amount'] = null;
$defaults['store_review']['max_rating'] = null;
$defaults['store_stock']['low_stock'] = true;
$defaults['store_stock']['out_of_stock'] = true;
$defaults['store_stock']['on_backorder'] = true;
return $defaults;
}