Move auto-update settings from Mobile App page to Settings page
All checks were successful
Create Release / build (push) Successful in 5s
All checks were successful
Create Release / build (push) Successful in 5s
- 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 <noreply@anthropic.com>
This commit is contained in:
@@ -13,13 +13,6 @@ if (!current_user_can('manage_options')) {
|
||||
wp_die(__('You do not have sufficient permissions to access this page.'));
|
||||
}
|
||||
|
||||
// Handle manual update check
|
||||
if (isset($_POST['twp_check_updates']) && check_admin_referer('twp_mobile_settings')) {
|
||||
require_once TWP_PLUGIN_DIR . 'includes/class-twp-auto-updater.php';
|
||||
$updater = new TWP_Auto_Updater();
|
||||
$update_result = $updater->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");
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (isset($update_result)): ?>
|
||||
<div class="notice notice-<?php echo $update_result['update_available'] ? 'warning' : 'success'; ?> is-dismissible">
|
||||
<p><strong><?php echo esc_html($update_result['message']); ?></strong></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (isset($notification_result)): ?>
|
||||
<div class="notice notice-<?php echo $notification_result['success'] ? 'success' : 'error'; ?> is-dismissible">
|
||||
<p><strong><?php echo esc_html($notification_result['message']); ?></strong></p>
|
||||
@@ -183,91 +157,6 @@ $total_sessions = $wpdb->get_var("SELECT COUNT(*) FROM $sessions_table");
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- Auto-Update Settings -->
|
||||
<div class="card" style="max-width: 100%; margin-bottom: 20px;">
|
||||
<h2>Automatic Updates</h2>
|
||||
|
||||
<table class="form-table">
|
||||
<tr>
|
||||
<th scope="row">Current Version</th>
|
||||
<td>
|
||||
<strong><?php echo esc_html($update_status['current_version']); ?></strong>
|
||||
<?php if ($update_status['update_available']): ?>
|
||||
<span style="color: #d63638; margin-left: 10px;">
|
||||
⚠ Update available: <?php echo esc_html($update_status['latest_version']); ?>
|
||||
</span>
|
||||
<?php else: ?>
|
||||
<span style="color: #00a32a; margin-left: 10px;">✓ Up to date</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="twp_auto_update_enabled">Enable Auto-Updates</label>
|
||||
</th>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox"
|
||||
id="twp_auto_update_enabled"
|
||||
name="twp_auto_update_enabled"
|
||||
value="1"
|
||||
<?php checked($auto_update_enabled); ?>>
|
||||
Automatically check for updates every 12 hours
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="twp_gitea_repo">Gitea Repository</label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="text"
|
||||
id="twp_gitea_repo"
|
||||
name="twp_gitea_repo"
|
||||
value="<?php echo esc_attr($gitea_repo); ?>"
|
||||
class="regular-text"
|
||||
placeholder="org/repo-name">
|
||||
<p class="description">
|
||||
Format: organization/repository (e.g., wp-plugins/twilio-wp-plugin)
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="twp_gitea_token">Gitea Access Token</label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="password"
|
||||
id="twp_gitea_token"
|
||||
name="twp_gitea_token"
|
||||
value="<?php echo esc_attr($gitea_token); ?>"
|
||||
class="regular-text"
|
||||
placeholder="">
|
||||
<p class="description">
|
||||
Optional. Required only for private repositories. Create token at:
|
||||
<a href="https://repo.anhonesthost.net/user/settings/applications" target="_blank">Gitea Settings > Applications</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Last Update Check</th>
|
||||
<td>
|
||||
<?php
|
||||
$last_check = $update_status['last_check'];
|
||||
if ($last_check > 0) {
|
||||
echo esc_html(human_time_diff($last_check, current_time('timestamp')) . ' ago');
|
||||
} else {
|
||||
echo 'Never';
|
||||
}
|
||||
?>
|
||||
<button type="submit" name="twp_check_updates" class="button" style="margin-left: 15px;">
|
||||
Check Now
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- API Documentation -->
|
||||
<div class="card" style="max-width: 100%; margin-bottom: 20px;">
|
||||
<h2>API Endpoints</h2>
|
||||
|
||||
Reference in New Issue
Block a user