From f8c9c2307793cb3ec6f1fc022ff8acf114dc28c2 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 6 Mar 2026 18:57:34 -0800 Subject: [PATCH] Move auto-update settings from Mobile App page to Settings page - Relocate update section (version check, repo config, token) to Settings - Fix download URL for private repos: append Gitea auth token - Mobile App page now only has FCM/notification settings Co-Authored-By: Claude Opus 4.6 --- admin/class-twp-admin.php | 119 +++++++++++++++++++++++++++- admin/mobile-app-settings.php | 111 -------------------------- includes/class-twp-auto-updater.php | 6 ++ 3 files changed, 124 insertions(+), 112 deletions(-) diff --git a/admin/class-twp-admin.php b/admin/class-twp-admin.php index 06c0991..3b21a87 100644 --- a/admin/class-twp-admin.php +++ b/admin/class-twp-admin.php @@ -1580,10 +1580,127 @@ class TWP_Admin { } }); + +
+ +

Automatic Updates

+ manual_check_for_updates(); + if (isset($update_result)) { + echo '
'; + echo '

' . esc_html($update_result['message']) . '

'; + } + } + + // Handle save update settings + if (isset($_POST['twp_save_update_settings']) && check_admin_referer('twp_update_settings')) { + 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'])); + echo '

Update settings saved.

'; + } + + $update_status = $updater->get_update_status(); + $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', ''); + ?> +
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Current Version + + + + Update available: + + + Up to date + +
+ + + +
+ + + +

+ Format: organization/repository (e.g., wp-plugins/twilio-wp-plugin) +

+
+ + + +

+ Optional. Required only for private repositories. +

+
Last Update Check + 0) { + echo esc_html(human_time_diff($last_check, current_time('timestamp')) . ' ago'); + } else { + echo 'Never'; + } + ?> + +
+

+ +

+
+
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'; @@ -49,10 +42,6 @@ if (isset($_POST['twp_save_mobile_settings']) && check_admin_referer('twp_mobile } 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; } @@ -60,15 +49,6 @@ if (isset($_POST['twp_save_mobile_settings']) && check_admin_referer('twp_mobile $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'; @@ -86,12 +66,6 @@ $total_sessions = $wpdb->get_var("SELECT COUNT(*) FROM $sessions_table"); - -
-

-
- -

@@ -183,91 +157,6 @@ $total_sessions = $wpdb->get_var("SELECT COUNT(*) FROM $sessions_table");
- -
-

Automatic Updates

- - - - - - - - - - - - - - - - - - - - - - -
Current Version - - - - ⚠ Update available: - - - ✓ Up to date - -
- - - -
- - - -

- Format: organization/repository (e.g., wp-plugins/twilio-wp-plugin) -

-
- - - -

- Optional. Required only for private repositories. Create token at: - Gitea Settings > Applications -

-
Last Update Check - 0) { - echo esc_html(human_time_diff($last_check, current_time('timestamp')) . ' ago'); - } else { - echo 'Never'; - } - ?> - -
-
-

API Endpoints

diff --git a/includes/class-twp-auto-updater.php b/includes/class-twp-auto-updater.php index 2d462d9..d13f265 100644 --- a/includes/class-twp-auto-updater.php +++ b/includes/class-twp-auto-updater.php @@ -210,6 +210,12 @@ class TWP_Auto_Updater { $download_url = $release->zipball_url; } + // Append auth token to download URL for private repos + if (!empty($gitea_token) && $download_url) { + $separator = (strpos($download_url, '?') !== false) ? '&' : '?'; + $download_url .= $separator . 'token=' . urlencode($gitea_token); + } + // Format changelog $changelog = !empty($release->body) ? $release->body : 'No changelog provided for this release.';