Plugin Directory

Changeset 3458420


Ignore:
Timestamp:
02/10/2026 08:57:20 PM (7 weeks ago)
Author:
zubbin
Message:

Update trunk to 1.4.46

Location:
zubbin-uptime-node/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • zubbin-uptime-node/trunk/includes/admin.php

    r3456245 r3458420  
    605605
    606606    $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    }
    607610    if ((int)$r['http'] !== 200) {
    608611    }
     
    652655    $r = ZUBBIN_UN_Client::plans($s);
    653656    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      }
    654661      $node = is_array($r['body']['node'] ?? null) ? $r['body']['node'] : [];
    655662      $plan_key = (string)($node['plan_key'] ?? $plan_key);
     
    677684    }
    678685
     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
    679691    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    }
    680704
    681705    // Helpful for support troubleshooting (do not show full key).
  • zubbin-uptime-node/trunk/includes/cron.php

    r3456135 r3458420  
    8888    $hb = ZUBBIN_UN_Client::heartbeat($s, $check['status'], $check['http'], $check['ms'], $check['msg'], $health);
    8989
     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
    9095    if (class_exists('ZUBBIN_UN_Logger')) {
    9196      $ok = ((int)$hb['http'] === 200 && !empty($hb['body']['ok']));
  • zubbin-uptime-node/trunk/includes/settings.php

    r3456245 r3458420  
    44class ZUBBIN_UN_Settings {
    55  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  }
    688
    789  static function defaults() {
     
    27109      'billing_status' => '',
    28110      'plan_limits' => [],
     111      'plan_features' => [],
     112      'block_reason' => '',
     113      'entitlement_enabled' => 1,
     114      'entitlement_checked_at' => '',
    29115
    30116      // stored on central, used by central alerts engine
  • zubbin-uptime-node/trunk/readme.txt

    r3458338 r3458420  
    1 === Z UpTime – WordPress Uptime Monitoring Node ===
     1=== Z UpTime – Uptime Monitoring Node ===
    22Contributors: zubbin
    33Tags: uptime, monitoring, wordpress uptime, health, alerts
     
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 1.4.45
     7Stable tag: 1.4.46
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1010
    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.
     11Lightweight uptime and health monitoring node that reports status securely to a Central dashboard.
    1212
    1313== Description ==
     
    8888== Changelog ==
    8989
     90= 1.4.46 =
     91* Adds plan entitlement syncing from Central (billing status, plan, limits).
     92* Improves upgrade screen to display billing state.
     93
    9094= 1.4.45 =
    9195* Branding update to Z UpTime
  • zubbin-uptime-node/trunk/zubbin-uptime-node.php

    r3456245 r3458420  
    11<?php
    22/**
    3  * Plugin Name: Zubbin Uptime Node Agent
    4  * Description: Lightweight node agent that reports uptime and health to your configured Central dashboard. Alerts are sent by Central.
    5  * Version: 1.4.45
     3 * 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
    66 * Author: Zubbin
    77 * Text Domain: zubbin-uptime-node
     
    1313if (!defined('ABSPATH')) exit;
    1414
    15 define('ZUBBIN_UN_VERSION','1.4.44');
     15define('ZUBBIN_UN_VERSION','1.4.46');
    1616
    1717// Default Central URL for client installs (override in wp-config.php if needed)
Note: See TracChangeset for help on using the changeset viewer.