Automattic\WooCommerce\Internal\PushNotifications
PushNotifications::should_be_enabled
Determines if local push notification functionality should be enabled. Push notifications require both the feature flag to be enabled and Jetpack to be connected. Memoize the value so we only check once per request.
Метод класса: PushNotifications{}
Хуков нет.
Возвращает
true|false.
Использование
$PushNotifications = new PushNotifications(); $PushNotifications->should_be_enabled(): bool;
Список изменений
| С версии 10.4.0 | Введена. |
Код PushNotifications::should_be_enabled() PushNotifications::should be enabled WC 10.5.1
public function should_be_enabled(): bool {
if ( null !== $this->enabled ) {
return $this->enabled;
}
if ( ! FeaturesUtil::feature_is_enabled( self::FEATURE_NAME ) ) {
$this->enabled = false;
return $this->enabled;
}
try {
$proxy = wc_get_container()->get( LegacyProxy::class );
$this->enabled = (
class_exists( JetpackConnectionManager::class )
&& $proxy->get_instance_of( JetpackConnectionManager::class )->is_connected()
);
} catch ( Exception $e ) {
$logger = wc_get_container()->get( LegacyProxy::class )->call_function( 'wc_get_logger' );
if ( $logger instanceof WC_Logger ) {
$logger->error(
'Error determining if PushNotifications feature should be enabled: ' . $e->getMessage()
);
}
$this->enabled = false;
}
return $this->enabled;
}