manual_check_for_updates(); } // Handle test notification if (isset($_POST['twp_test_notification']) && check_admin_referer('twp_mobile_settings')) { require_once TWP_PLUGIN_DIR . 'includes/class-twp-fcm.php'; $fcm = new TWP_FCM(); $test_user_id = get_current_user_id(); $notification_sent = $fcm->send_test_notification($test_user_id); if ($notification_sent) { $notification_result = array('success' => true, 'message' => 'Test notification sent successfully!'); } else { $notification_result = array('success' => false, 'message' => 'Failed to send test notification. Check FCM configuration.'); } } // Save settings if (isset($_POST['twp_save_mobile_settings']) && check_admin_referer('twp_mobile_settings')) { update_option('twp_fcm_project_id', sanitize_text_field($_POST['twp_fcm_project_id'])); // Service account JSON — validate it parses as JSON before saving $sa_json_raw = isset($_POST['twp_fcm_service_account_json']) ? wp_unslash($_POST['twp_fcm_service_account_json']) : ''; if (!empty($sa_json_raw)) { $sa_parsed = json_decode($sa_json_raw, true); if ($sa_parsed && isset($sa_parsed['client_email'], $sa_parsed['private_key'])) { update_option('twp_fcm_service_account_json', $sa_json_raw); } else { $sa_json_error = 'Invalid service account JSON — must contain client_email and private_key fields.'; } } else { update_option('twp_fcm_service_account_json', ''); } update_option('twp_auto_update_enabled', isset($_POST['twp_auto_update_enabled']) ? '1' : '0'); update_option('twp_gitea_repo', sanitize_text_field($_POST['twp_gitea_repo'])); update_option('twp_gitea_token', sanitize_text_field($_POST['twp_gitea_token'])); $settings_saved = true; } // Get current settings $fcm_project_id = get_option('twp_fcm_project_id', ''); $fcm_service_account_json = get_option('twp_fcm_service_account_json', ''); $fcm_sa_configured = !empty($fcm_service_account_json) && !empty($fcm_project_id); $auto_update_enabled = get_option('twp_auto_update_enabled', '1') === '1'; $gitea_repo = get_option('twp_gitea_repo', 'wp-plugins/twilio-wp-plugin'); $gitea_token = get_option('twp_gitea_token', ''); // Get update status require_once TWP_PLUGIN_DIR . 'includes/class-twp-auto-updater.php'; $updater = new TWP_Auto_Updater(); $update_status = $updater->get_update_status(); // Get mobile app statistics global $wpdb; $sessions_table = $wpdb->prefix . 'twp_mobile_sessions'; $active_sessions = $wpdb->get_var("SELECT COUNT(*) FROM $sessions_table WHERE is_active = 1 AND expires_at > NOW()"); $total_sessions = $wpdb->get_var("SELECT COUNT(*) FROM $sessions_table"); ?>
Settings saved successfully!
| API Endpoint: | |
| Active Sessions: | active / total |
| Plugin Version: |
| User | Device | Last Activity |
|---|---|---|
| display_name ?: $session->user_login); ?> | device_info ?: 'Unknown device'); ?> | last_used), current_time('timestamp')) . ' ago'); ?> |