1414 * @package SparxstarUserEnvironmentCheck
1515 */
1616
17- // Prevent direct access to the file
17+ declare (strict_types=1 );
18+
19+ // Prevent direct access to the file.
1820if (!defined ('ABSPATH ' )) {
19- exit ;
21+ exit ;
2022}
2123
2224// --- 1. Define Plugin Constants ---
25+ /**
26+ * Absolute path to the main plugin file.
27+ *
28+ * @var string
29+ */
2330define ('SPX_ENV_CHECK_PLUGIN_FILE ' , __FILE__ );
31+
32+ /**
33+ * Absolute path to the plugin directory.
34+ *
35+ * @var string
36+ */
2437define ('SPX_ENV_CHECK_PLUGIN_PATH ' , plugin_dir_path (__FILE__ ));
38+
39+ /**
40+ * Current plugin version identifier.
41+ *
42+ * @var string
43+ */
2544define ('SPX_ENV_CHECK_VERSION ' , '6.0.0 ' );
45+
46+ /**
47+ * Text domain used for localization.
48+ *
49+ * @var string
50+ */
2651define ('SPX_ENV_CHECK_TEXT_DOMAIN ' , 'sparxstar-user-environment-check ' );
2752
2853// --- 2. Include the Main Plugin and Utility Classes ---
2954require_once SPX_ENV_CHECK_PLUGIN_PATH . 'src/SparxstarUserEnvironmentCheck.php ' ;
3055require_once SPX_ENV_CHECK_PLUGIN_PATH . 'src/StarUserUtils.php ' ;
3156
3257// --- 3. Register Activation & Deactivation Hooks ---
33- register_activation_hook (__FILE__ , function () {
34- require_once SPX_ENV_CHECK_PLUGIN_PATH . 'src/api/SparxstarUECAPI.php ' ;
35- \Starisian \SparxstarUEC \api \SparxstarUECAPI::init ()->create_db_table ();
36- });
58+ register_activation_hook (
59+ __FILE__ ,
60+ static function (): void {
61+ require_once SPX_ENV_CHECK_PLUGIN_PATH . 'src/Api/SparxstarUECAPI.php ' ;
62+ \Starisian \SparxstarUEC \Api \SparxstarUECAPI::init ()->create_db_table ();
63+ }
64+ );
3765
38- register_deactivation_hook (__FILE__ , function () {
39- if (function_exists ('as_unschedule_all_actions ' )) {
40- as_unschedule_all_actions ('sparxstar_env_cleanup_snapshots ' );
41- }
42- });
66+ register_deactivation_hook (
67+ __FILE__ ,
68+ static function (): void {
69+ if (function_exists ('as_unschedule_all_actions ' )) {
70+ as_unschedule_all_actions ('sparxstar_env_cleanup_snapshots ' );
71+ }
72+ }
73+ );
4374
4475// --- 4. Global Helper Function ---
4576if (!function_exists ('sparxstar_get_env_snapshot ' )) {
46- function sparxstar_get_env_snapshot (?int $ user_id = null , ?string $ session_id = null ): ?array
47- {
48- return \Starisian \SparxstarUEC \StarUserUtils::get_snapshot ($ user_id , $ session_id );
49- }
77+ /**
78+ * Retrieve the latest environment snapshot for a user/session combination.
79+ *
80+ * @param int|null $user_id Optional WordPress user identifier.
81+ * @param string|null $session_id Optional client session identifier.
82+ *
83+ * @return array|null Snapshot payload when available.
84+ */
85+ function sparxstar_get_env_snapshot (?int $ user_id = null , ?string $ session_id = null ): ?array
86+ {
87+ return \Starisian \SparxstarUEC \StarUserUtils::get_snapshot ($ user_id , $ session_id );
88+ }
5089}
5190
5291// --- 5. Initialize the Plugin ---
53- \Starisian \SparxstarUEC \SparxstarUserEnvironmentCheck::get_instance ();
92+ \Starisian \SparxstarUEC \SparxstarUserEnvironmentCheck::get_instance ();
0 commit comments