| @@ -418,11 +418,27 @@ | ||
| 418 | 418 | */ |
| 419 | 419 | private function get_default_properties(): array { |
| 420 | 420 | return array( |
| 421 | 421 | 'plugin_version' => PLUGIN_VERSION, |
| 422 | - 'pro_active' => class_exists( '\WCPOS\WooCommercePOSPro\WooCommercePOSPro' ), | |
| 422 | + 'pro_active' => $this->is_pro_active(), | |
| 423 | 423 | 'locale' => get_locale(), |
| 424 | 424 | ); |
| 425 | + } | |
| 426 | + | |
| 427 | + /** | |
| 428 | + * Whether the Pro plugin is active, safe to call before Init has run. | |
| 429 | + * | |
| 430 | + * Same situation as get_site_id(): the deactivation hook can fire in a | |
| 431 | + * request where the WooCommerce check failed, Init never ran, and | |
| 432 | + * wcpos-functions.php is not loaded. Fall back to the constant the helper | |
| 433 | + * itself reads rather than fataling on the way out. | |
| 434 | + */ | |
| 435 | + private function is_pro_active(): bool { | |
| 436 | + if ( ! \function_exists( 'wcpos_is_pro_active' ) ) { | |
| 437 | + return \defined( 'WCPOS\WooCommercePOSPro\VERSION' ); | |
| 438 | + } | |
| 439 | + | |
| 440 | + return wcpos_is_pro_active(); | |
| 425 | 441 | } |
| 426 | 442 | |
| 427 | 443 | /** |
| 428 | 444 | * Dispatch a non-blocking HTTPS POST to the PostHog ingestion host. |