| @@ -128,9 +128,13 @@ | ||
| 128 | 128 | if ( null !== $this->enabled_cache ) { |
| 129 | 129 | return $this->enabled_cache; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - $consent = Settings::instance()->tracking_consent(); | |
| 132 | + // The PERSISTED consent, not the filtered read view — otherwise any | |
| 133 | + // plugin filtering woocommerce_pos_general_settings could switch | |
| 134 | + // telemetry on for a merchant who declined it. Same gate as | |
| 135 | + // Services\Error_Reporter. | |
| 136 | + $consent = Settings::instance()->raw_tracking_consent(); | |
| 133 | 137 | $this->enabled_cache = ( 'allowed' === $consent ); |
| 134 | 138 | |
| 135 | 139 | return $this->enabled_cache; |
| 136 | 140 | } |
| @@ -414,11 +418,27 @@ | ||
| 414 | 418 | */ |
| 415 | 419 | private function get_default_properties(): array { |
| 416 | 420 | return array( |
| 417 | 421 | 'plugin_version' => PLUGIN_VERSION, |
| 418 | - 'pro_active' => class_exists( '\WCPOS\WooCommercePOSPro\WooCommercePOSPro' ), | |
| 422 | + 'pro_active' => $this->is_pro_active(), | |
| 419 | 423 | 'locale' => get_locale(), |
| 420 | 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(); | |
| 421 | 441 | } |
| 422 | 442 | |
| 423 | 443 | /** |
| 424 | 444 | * Dispatch a non-blocking HTTPS POST to the PostHog ingestion host. |