Changeset 3458420
- Timestamp:
- 02/10/2026 08:57:20 PM (7 weeks ago)
- Location:
- zubbin-uptime-node/trunk
- Files:
-
- 5 edited
-
includes/admin.php (modified) (3 diffs)
-
includes/cron.php (modified) (1 diff)
-
includes/settings.php (modified) (2 diffs)
-
readme.txt (modified) (3 diffs)
-
zubbin-uptime-node.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
zubbin-uptime-node/trunk/includes/admin.php
r3456245 r3458420 605 605 606 606 $r = ZUBBIN_UN_Client::sync($s); 607 if ((int)($r['http'] ?? 0) === 200 && !empty($r['body']) && is_array($r['body'])) { 608 ZUBBIN_UN_Settings::apply_remote_state($r['body']); 609 } 607 610 if ((int)$r['http'] !== 200) { 608 611 } … … 652 655 $r = ZUBBIN_UN_Client::plans($s); 653 656 if ((int)$r['http'] === 200 && !empty($r['body']['ok'])) { 657 // Cache entitlement/plan state if provided. 658 if (is_array($r['body'])) { 659 ZUBBIN_UN_Settings::apply_remote_state($r['body']); 660 } 654 661 $node = is_array($r['body']['node'] ?? null) ? $r['body']['node'] : []; 655 662 $plan_key = (string)($node['plan_key'] ?? $plan_key); … … 677 684 } 678 685 686 // Refresh local cache after any remote updates. 687 $s = ZUBBIN_UN_Settings::get(); 688 $billing_status = isset($s['billing_status']) ? (string)$s['billing_status'] : ''; 689 $block_reason = isset($s['block_reason']) ? (string)$s['block_reason'] : ''; 690 679 691 echo '<p><strong>' . esc_html__('Current plan:', 'zubbin-uptime-node') . '</strong> ' . esc_html($plan_key) . '</p>'; 692 693 if ($billing_status !== '') { 694 echo '<p><strong>' . esc_html__('Billing status:', 'zubbin-uptime-node') . '</strong> ' . esc_html($billing_status) . '</p>'; 695 } 696 697 if ($billing_status === 'blocked' || $billing_status === 'inactive' || $billing_status === 'past_due' || $billing_status === 'unpaid') { 698 $msg = esc_html__('This site is not currently entitled to paid features. If you believe this is a mistake, open the billing portal or contact support.', 'zubbin-uptime-node'); 699 if ($block_reason !== '') { 700 $msg .= ' ' . esc_html($block_reason); 701 } 702 self::notice('warning', $msg); 703 } 680 704 681 705 // Helpful for support troubleshooting (do not show full key). -
zubbin-uptime-node/trunk/includes/cron.php
r3456135 r3458420 88 88 $hb = ZUBBIN_UN_Client::heartbeat($s, $check['status'], $check['http'], $check['ms'], $check['msg'], $health); 89 89 90 // Best-effort: apply entitlement/plan state returned by Central. 91 if (class_exists('ZUBBIN_UN_Settings') && isset($hb['body']) && is_array($hb['body'])) { 92 ZUBBIN_UN_Settings::apply_remote_state($hb['body']); 93 } 94 90 95 if (class_exists('ZUBBIN_UN_Logger')) { 91 96 $ok = ((int)$hb['http'] === 200 && !empty($hb['body']['ok'])); -
zubbin-uptime-node/trunk/includes/settings.php
r3456245 r3458420 4 4 class ZUBBIN_UN_Settings { 5 5 static function opt() { return 'zubbin_un_settings'; } 6 7 /** 8 * Apply remote state returned by Central (heartbeat/sync/plans). 9 * Keeps Node backwards-compatible with older Central versions. 10 * 11 * Supported shapes: 12 * - body.entitlement.{billing_status,plan_key,limits,features,block_reason,enabled,plan{limits,features}} 13 * - body.node.{billing_status,plan_key,limits,plan_limits} 14 */ 15 static function apply_remote_state($body) { 16 if (!is_array($body)) return; 17 18 $ent = is_array($body['entitlement'] ?? null) ? $body['entitlement'] : null; 19 $node = is_array($body['node'] ?? null) ? $body['node'] : null; 20 21 $plan_key = ''; 22 $billing_status = ''; 23 $block_reason = ''; 24 $enabled = null; 25 $limits = null; 26 $features = null; 27 28 if (is_array($ent)) { 29 $plan_key = sanitize_key((string)($ent['plan_key'] ?? ($ent['plan']['key'] ?? ''))); 30 $billing_status = (string)($ent['billing_status'] ?? ($ent['status'] ?? '')); 31 $block_reason = (string)($ent['block_reason'] ?? ''); 32 if (array_key_exists('enabled', $ent)) { 33 $enabled = (int)$ent['enabled']; 34 } 35 36 if (is_array($ent['limits'] ?? null)) { 37 $limits = $ent['limits']; 38 } elseif (is_array($ent['plan']['limits'] ?? null)) { 39 $limits = $ent['plan']['limits']; 40 } 41 42 if (is_array($ent['features'] ?? null)) { 43 $features = $ent['features']; 44 } elseif (is_array($ent['plan']['features'] ?? null)) { 45 $features = $ent['plan']['features']; 46 } 47 } 48 49 if ($plan_key === '' && is_array($node)) { 50 $plan_key = sanitize_key((string)($node['plan_key'] ?? '')); 51 } 52 if ($billing_status === '' && is_array($node)) { 53 $billing_status = (string)($node['billing_status'] ?? ''); 54 } 55 if ($limits === null && is_array($node)) { 56 if (is_array($node['plan_limits'] ?? null)) { 57 $limits = $node['plan_limits']; 58 } elseif (is_array($node['limits'] ?? null)) { 59 $limits = $node['limits']; 60 } 61 } 62 63 $updates = [ 64 'entitlement_checked_at' => current_time('mysql'), 65 ]; 66 67 if ($plan_key !== '') { 68 $updates['plan_key'] = $plan_key; 69 } 70 if ($billing_status !== '') { 71 $updates['billing_status'] = sanitize_text_field($billing_status); 72 } 73 if ($block_reason !== '') { 74 $updates['block_reason'] = sanitize_text_field($block_reason); 75 } 76 if ($enabled !== null) { 77 $updates['entitlement_enabled'] = (int)$enabled; 78 } 79 if (is_array($limits)) { 80 $updates['plan_limits'] = $limits; 81 } 82 if (is_array($features)) { 83 $updates['plan_features'] = $features; 84 } 85 86 self::save($updates); 87 } 6 88 7 89 static function defaults() { … … 27 109 'billing_status' => '', 28 110 'plan_limits' => [], 111 'plan_features' => [], 112 'block_reason' => '', 113 'entitlement_enabled' => 1, 114 'entitlement_checked_at' => '', 29 115 30 116 // stored on central, used by central alerts engine -
zubbin-uptime-node/trunk/readme.txt
r3458338 r3458420 1 === Z UpTime – WordPressUptime Monitoring Node ===1 === Z UpTime – Uptime Monitoring Node === 2 2 Contributors: zubbin 3 3 Tags: uptime, monitoring, wordpress uptime, health, alerts … … 5 5 Tested up to: 6.9 6 6 Requires PHP: 7.4 7 Stable tag: 1.4.4 57 Stable tag: 1.4.46 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html 10 10 11 Z UpTime Node is a lightweight WordPress plugin that monitors site uptime and health, and securely reports status to a managed Central monitoring service.11 Lightweight uptime and health monitoring node that reports status securely to a Central dashboard. 12 12 13 13 == Description == … … 88 88 == Changelog == 89 89 90 = 1.4.46 = 91 * Adds plan entitlement syncing from Central (billing status, plan, limits). 92 * Improves upgrade screen to display billing state. 93 90 94 = 1.4.45 = 91 95 * Branding update to Z UpTime -
zubbin-uptime-node/trunk/zubbin-uptime-node.php
r3456245 r3458420 1 1 <?php 2 2 /** 3 * Plugin Name: Z ubbin Uptime Node Agent4 * Description: Lightweight node agent that reports uptime and health to your configured Central dashboard. Alerts are sentby Central.5 * Version: 1.4.4 53 * Plugin Name: Z UpTime – Uptime Monitoring Node 4 * Description: Lightweight WordPress uptime monitoring node that reports heartbeat and health to a Central dashboard. Alerts are handled by Central. 5 * Version: 1.4.46 6 6 * Author: Zubbin 7 7 * Text Domain: zubbin-uptime-node … … 13 13 if (!defined('ABSPATH')) exit; 14 14 15 define('ZUBBIN_UN_VERSION','1.4.4 4');15 define('ZUBBIN_UN_VERSION','1.4.46'); 16 16 17 17 // Default Central URL for client installs (override in wp-config.php if needed)
Note: See TracChangeset
for help on using the changeset viewer.