Changeset 3423267
- Timestamp:
- 12/18/2025 11:20:31 PM (4 months ago)
- Location:
- pushrelay/trunk
- Files:
-
- 3 added
- 7 edited
-
assets/js/sw-register.js (modified) (1 diff)
-
includes/Admin/Page.php (added)
-
includes/Admin/SettingsPage.php (added)
-
includes/Api/Client.php (modified) (1 diff)
-
includes/Core/Plugin.php (modified) (3 diffs)
-
includes/Push/Worker.php (modified) (2 diffs)
-
includes/Utils/Health.php (modified) (1 diff)
-
includes/bootstrap.php (added)
-
pushrelay.php (modified) (2 diffs)
-
readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pushrelay/trunk/assets/js/sw-register.js
r3423210 r3423267 1 // Placeholder script for PushRelay Service Worker registration. 2 // Actual registration logic is injected inline for WordPress standards compliance. 1 if ('serviceWorker' in navigator) { 2 window.addEventListener('load', () => { 3 navigator.serviceWorker 4 .register('/pushrelay-sw.js') 5 .then(reg => { 6 console.log('PushRelay Service Worker registered:', reg.scope); 7 }) 8 .catch(err => { 9 console.warn('PushRelay Service Worker failed:', err); 10 }); 11 }); 12 } -
pushrelay/trunk/includes/Api/Client.php
r3423191 r3423267 1 1 <?php 2 namespace PushRelay\A pi;2 namespace PushRelay\API; 3 3 4 if ( ! defined( 'ABSPATH' ) ) exit; 4 if ( ! defined( 'ABSPATH' ) ) { 5 exit; 6 } 5 7 6 class Client {8 final class Client { 7 9 8 protected $base = 'https://pushrelay.com/api'; 10 public static function test_connection( string $api_key ): bool { 11 if ( empty( $api_key ) ) { 12 return false; 13 } 9 14 10 protected function request( $method, $endpoint ) { 11 $key = get_option( 'pushrelay_user_api_key' ); 12 if ( empty( $key ) ) return false; 15 $response = wp_remote_get( 16 'https://pushrelay.com/api/user', 17 [ 18 'timeout' => 10, 19 'headers' => [ 20 'Authorization' => 'Bearer ' . $api_key, 21 ], 22 ] 23 ); 13 24 14 $response = wp_remote_request( $this->base . $endpoint, [ 15 'method' => $method, 16 'timeout' => 15, 17 'headers' => [ 18 'Authorization' => 'Bearer ' . $key, 19 'Accept' => 'application/json', 20 ], 21 ]); 25 if ( is_wp_error( $response ) ) { 26 return false; 27 } 22 28 23 if ( is_wp_error( $response ) ) return false; 24 25 return json_decode( wp_remote_retrieve_body( $response ), true ); 29 return wp_remote_retrieve_response_code( $response ) === 200; 26 30 } 27 31 } -
pushrelay/trunk/includes/Core/Plugin.php
r3423229 r3423267 1 1 <?php 2 2 namespace PushRelay\Core; 3 4 use PushRelay\Admin\Page; 5 use PushRelay\Utils\Health; 3 6 4 7 if ( ! defined( 'ABSPATH' ) ) { … … 6 9 } 7 10 8 /**9 * Core plugin bootstrap.10 */11 11 final class Plugin { 12 12 13 private static $instance = null;13 private static $instance; 14 14 15 15 public static function instance(): self { 16 if ( null ===self::$instance ) {16 if ( ! self::$instance ) { 17 17 self::$instance = new self(); 18 18 } … … 21 21 22 22 private function __construct() { 23 $this->load_dependencies(); 24 $this->load_textdomain(); 23 $this->init_admin(); 25 24 $this->init_health(); 26 $this->init_worker();27 25 } 28 26 29 /** 30 * Manually load required class files. 31 */ 32 private function load_dependencies(): void { 33 require_once PUSHRELAY_PLUGIN_DIR . 'includes/Utils/Health.php'; 34 require_once PUSHRELAY_PLUGIN_DIR . 'includes/Push/Worker.php'; 35 } 36 37 private function load_textdomain(): void { 38 load_plugin_textdomain( 39 'pushrelay', 40 false, 41 dirname( plugin_basename( PUSHRELAY_PLUGIN_FILE ) ) . '/languages' 42 ); 27 private function init_admin(): void { 28 if ( is_admin() ) { 29 Page::init(); 30 } 43 31 } 44 32 45 33 private function init_health(): void { 46 \PushRelay\Utils\Health::init(); 47 } 48 49 private function init_worker(): void { 50 \PushRelay\Push\Worker::init(); 34 Health::init(); 51 35 } 52 36 } -
pushrelay/trunk/includes/Push/Worker.php
r3423220 r3423267 9 9 10 10 public static function init(): void { 11 add_action( 'wp_enqueue_scripts', [ __CLASS__, 'register_worker' ] );11 add_action( 'wp_enqueue_scripts', [ self::class, 'enqueue' ] ); 12 12 } 13 13 14 public static function register_worker(): void {14 public static function enqueue(): void { 15 15 if ( ! is_ssl() ) { 16 16 return; 17 17 } 18 18 19 $handle = 'pushrelay-sw-register';20 21 19 wp_register_script( 22 $handle,20 'pushrelay-sw', 23 21 PUSHRELAY_PLUGIN_URL . 'assets/js/sw-register.js', 24 22 [], … … 27 25 ); 28 26 29 wp_enqueue_script( $handle ); 30 31 wp_add_inline_script( 32 $handle, 33 self::inline_registration_script() 34 ); 35 } 36 37 private static function inline_registration_script(): string { 38 $sw_url = esc_url_raw( PUSHRELAY_PLUGIN_URL . 'pushrelay-sw.js' ); 39 40 return <<<JS 41 if ('serviceWorker' in navigator) { 42 window.addEventListener('load', function() { 43 navigator.serviceWorker.register('{$sw_url}') 44 .then(function(reg) { 45 console.log('PushRelay Service Worker registered:', reg.scope); 46 }) 47 .catch(function(error) { 48 console.warn('PushRelay Service Worker registration failed:', error); 49 }); 50 }); 51 } 52 JS; 27 wp_enqueue_script( 'pushrelay-sw' ); 53 28 } 54 29 } -
pushrelay/trunk/includes/Utils/Health.php
r3423210 r3423267 9 9 10 10 public static function init(): void { 11 add_action( 'admin_notices', [ __CLASS__, ' maybe_show_notice' ] );11 add_action( 'admin_notices', [ __CLASS__, 'notice' ] ); 12 12 } 13 13 14 public static function maybe_show_notice(): void {14 public static function notice(): void { 15 15 if ( ! current_user_can( 'manage_options' ) ) { 16 16 return; 17 17 } 18 18 19 if ( ! is_ssl() ) {20 echo '<div class="notice notice-error"><p>' .21 esc_html__( 'PushRelay requires HTTPS to enable push notifications.', 'pushrelay' ) .22 '</p></div>';23 return;24 }25 26 19 echo '<div class="notice notice-success"><p>' . 27 esc_html__( 'PushRelay is ready. Service Worker support enabled.', 'pushrelay' ) .20 esc_html__( 'PushRelay is ready. Core system loaded successfully.', 'pushrelay' ) . 28 21 '</p></div>'; 29 22 } -
pushrelay/trunk/pushrelay.php
r3423239 r3423267 4 4 * Plugin URI: https://pushrelay.com 5 5 * Description: Native Push Notifications for WordPress powered by PushRelay. 6 * Version: 1. 2.26 * Version: 1.4.0 7 7 * Author: PushRelay 8 8 * Author URI: https://pushrelay.com 9 9 * Text Domain: pushrelay 10 * Domain Path: /languages11 10 * Requires at least: 6.0 12 11 * Tested up to: 6.9 … … 15 14 */ 16 15 17 18 16 if ( ! defined( 'ABSPATH' ) ) { 19 17 exit; 20 18 } 21 19 22 define( 'PUSHRELAY_VERSION', '1. 2.1' );20 define( 'PUSHRELAY_VERSION', '1.4.0' ); 23 21 define( 'PUSHRELAY_PLUGIN_FILE', __FILE__ ); 24 22 define( 'PUSHRELAY_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); 25 23 define( 'PUSHRELAY_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); 26 24 27 /* 28 |-------------------------------------------------------------------------- 29 | Load required classes (manual loader, WordPress-friendly) 30 |-------------------------------------------------------------------------- 31 */ 32 33 // Utils 34 require_once PUSHRELAY_PLUGIN_DIR . 'includes/Utils/Health.php'; 35 36 // Push 37 require_once PUSHRELAY_PLUGIN_DIR . 'includes/Push/Worker.php'; 38 39 // Core 40 require_once PUSHRELAY_PLUGIN_DIR . 'includes/Core/Plugin.php'; 25 require_once PUSHRELAY_PLUGIN_DIR . 'includes/bootstrap.php'; 41 26 42 27 add_action( 'plugins_loaded', function () { 43 28 \PushRelay\Core\Plugin::instance(); 44 } );29 }); -
pushrelay/trunk/readme.txt
r3423239 r3423267 5 5 Tested up to: 6.9 6 6 Requires PHP: 7.4 7 Stable tag: 1. 2.27 Stable tag: 1.4.0 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 13 13 14 14 == Description == 15 PushRelay i ntegrates web push notifications directly into WordPress with zero manual setup.15 PushRelay is a native WordPress plugin that provides a solid and standards-compliant foundation for web push notifications powered by the PushRelay platform. 16 16 17 The plugin provides: 18 * Automatic Service Worker registration 19 * Health checks for HTTPS and browser support 20 * A foundation for WooCommerce and automation integrations 17 This release represents the first stable architecture of the plugin after an internal rebuild, focusing on reliability, compatibility, and long-term extensibility. 18 19 Current features include: 20 * Clean and secure plugin architecture 21 * WordPress admin menu integration 22 * Core system health checks 23 * Compatibility with WordPress coding standards 24 25 Planned features for upcoming releases: 26 * Automatic service worker injection 27 * Push notification delivery via PushRelay API 28 * WooCommerce native automation 29 * Language-based subscriber segmentation 30 * Manual and automated push notifications 31 * Subscriber analytics and notification flows 32 * No external dashboard required 21 33 22 34 == External Services == … … 24 36 25 37 Data sent may include: 26 * Website identifiers27 * Configuration data required to deliverpush notifications38 * Site identifiers 39 * Configuration data required to initialize push notifications 28 40 29 41 This service is provided by PushRelay. … … 32 44 33 45 == Installation == 34 1. Install the plugin from the WordPress Plugin Directory.35 2. Activate the plugin .36 3. Ensure your website is running on HTTPS.46 1. Upload the plugin to the `/wp-content/plugins/` directory, or install it via the WordPress Plugins screen. 47 2. Activate the plugin through the “Plugins” menu in WordPress. 48 3. Go to **PushRelay** in the WordPress admin menu to verify system status. 37 49 38 50 == Changelog == 51 = 1.4.0 = 52 * Major refactor and stabilization release 53 * Rebuilt plugin architecture 54 * Admin menu integration 55 * Core system health check 56 * Clean foundation for future push features 39 57 40 = 1.2.2 = 41 * Fixed fatal error caused by missing class loading. 42 * Ensured Health and Service Worker classes are properly loaded. 43 * Improved plugin stability on fresh installations. 58 = Earlier versions = 59 * Initial experimental releases and internal hotfixes 44 60 45 = 1.2.1 = 46 * Internal fixes to Service Worker registration. 47 * Initial health notice for HTTPS validation. 48 * Minor internal cleanup. 49 50 = 1.2.0 = 51 * Initial public release. 61 == Upgrade Notice == 62 = 1.4.0 = 63 First stable release after architectural rebuild.
Note: See TracChangeset
for help on using the changeset viewer.