settings_repository = $settings_repository; $this->integration_status_provider = $integration_status_provider; $this->event_store = $event_store; $this->build_profile_resolver = $build_profile_resolver instanceof BuildProfileResolver ? $build_profile_resolver : new BuildProfileResolver(); $this->commercial_bootstrap = $commercial_bootstrap; } /** * Get safe diagnostics data. * * @return array */ public function get_data(): array { $settings = $this->settings_repository->get_settings(); $commercial_bootstrap = $this->get_commercial_bootstrap(); $build_profile = $commercial_bootstrap->get_profile(); $data = array( 'plugin_version' => defined( 'TWOOTWOCODE_ZSF_VERSION' ) ? TWOOTWOCODE_ZSF_VERSION : '1.0.0', 'build_profile' => $build_profile->get_value(), 'commercial_provider' => $commercial_bootstrap->get_license_provider()->get_key(), 'pro_module_count_loaded' => $commercial_bootstrap->get_loaded_module_count(), 'wordpress_version' => $this->get_wordpress_version(), 'php_version' => PHP_VERSION, 'protection_mode' => (string) $settings['protection_mode'], 'strictness' => (string) $settings['strictness'], 'event_logging_enabled' => (bool) $settings['event_logging_enabled'], 'log_allowed_events' => (bool) $settings['log_allowed_events'], 'event_retention_days' => (int) $settings['event_retention_days'], 'max_event_records' => (int) $settings['max_event_records'], 'stored_event_count' => $this->get_stored_event_count(), 'integrations' => $this->integration_status_provider->get_statuses(), 'vendor_autoload_available' => $this->is_vendor_autoload_available(), 'php_extensions' => array( 'json' => extension_loaded( 'json' ), ), ); if ( ! $build_profile->is_free() ) { $data['pro_module_skeletons'] = $commercial_bootstrap->get_pro_module_metadata(); } return $data; } /** * Get WordPress version without exposing environment details. */ private function get_wordpress_version(): string { global $wp_version; if ( isset( $wp_version ) && is_scalar( $wp_version ) ) { return (string) $wp_version; } return ''; } /** * Check whether Composer autoload is present. */ private function is_vendor_autoload_available(): bool { if ( ! defined( 'TWOOTWOCODE_ZSF_PATH' ) ) { return false; } return file_exists( TWOOTWOCODE_ZSF_PATH . 'vendor/autoload.php' ); } /** * Get stored event count without exposing event data. */ private function get_stored_event_count(): int { if ( ! $this->event_store instanceof EventStoreInterface ) { return 0; } return $this->event_store->count_events(); } /** * Get commercial bootstrap. */ private function get_commercial_bootstrap(): CommercialBootstrap { if ( $this->commercial_bootstrap instanceof CommercialBootstrap ) { return $this->commercial_bootstrap; } $commercial_bootstrap = CommercialBootstrap::create_default( $this->build_profile_resolver ); $commercial_bootstrap->boot(); return $commercial_bootstrap; } }