Automattic\WooCommerce\Internal\PushNotifications\Services

DriverAvailabilityService::is_jetpack_sync_enabled │ protected │ WC 11.2.0

Determines whether Jetpack Sync is enabled. Treated as not enabled when the package isn't installed, or when the package throws.

The call reaches third-party package code, so it is guarded: an Error from an incompatible Jetpack would otherwise escape \Automattic\WooCommerce\Internal\RestApiControllerBase::run(), which catches Exception only, and turn an endpoint whose purpose is to stay reachable into a 500.

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

Хуков нет.

Возвращает

bool.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->is_jetpack_sync_enabled(): bool;

Список изменений

С версии 11.2.0 Введена.

Код DriverAvailabilityService::is_jetpack_sync_enabled() WC 11.2.2

protected function is_jetpack_sync_enabled(): bool {
	$is_sync_enabled = array( self::JETPACK_SYNC_SETTINGS_CLASS, 'is_sync_enabled' );

	if ( ! is_callable( $is_sync_enabled ) ) {
		// class_exists() already passed, so the class is present but the method
		// is not: an incompatible Jetpack Sync rather than a merchant choice.
		// Recorded so this reports as undetermined rather than a definitive no.
		$this->failed_checks[ self::CHECK_SYNC_ENABLED ] = true;

		return false;
	}

	try {
		return (bool) call_user_func( $is_sync_enabled );
	} catch ( Throwable $e ) {
		$this->failed_checks[ self::CHECK_SYNC_ENABLED ] = true;

		$this->log_throwable( 'Error determining Jetpack Sync state for push notifications', $e );

		return false;
	}
}