Plugin Directory

Changeset 3423267


Ignore:
Timestamp:
12/18/2025 11:20:31 PM (4 months ago)
Author:
pushrelay
Message:

PushRelay 1.4.0 – initial stable release

Location:
pushrelay/trunk
Files:
3 added
7 edited

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.
     1if ('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  
    11<?php
    2 namespace PushRelay\Api;
     2namespace PushRelay\API;
    33
    4 if ( ! defined( 'ABSPATH' ) ) exit;
     4if ( ! defined( 'ABSPATH' ) ) {
     5    exit;
     6}
    57
    6 class Client {
     8final class Client {
    79
    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        }
    914
    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        );
    1324
    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        }
    2228
    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;
    2630    }
    2731}
  • pushrelay/trunk/includes/Core/Plugin.php

    r3423229 r3423267  
    11<?php
    22namespace PushRelay\Core;
     3
     4use PushRelay\Admin\Page;
     5use PushRelay\Utils\Health;
    36
    47if ( ! defined( 'ABSPATH' ) ) {
     
    69}
    710
    8 /**
    9  * Core plugin bootstrap.
    10  */
    1111final class Plugin {
    1212
    13     private static $instance = null;
     13    private static $instance;
    1414
    1515    public static function instance(): self {
    16         if ( null === self::$instance ) {
     16        if ( ! self::$instance ) {
    1717            self::$instance = new self();
    1818        }
     
    2121
    2222    private function __construct() {
    23         $this->load_dependencies();
    24         $this->load_textdomain();
     23        $this->init_admin();
    2524        $this->init_health();
    26         $this->init_worker();
    2725    }
    2826
    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        }
    4331    }
    4432
    4533    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();
    5135    }
    5236}
  • pushrelay/trunk/includes/Push/Worker.php

    r3423220 r3423267  
    99
    1010    public static function init(): void {
    11         add_action( 'wp_enqueue_scripts', [ __CLASS__, 'register_worker' ] );
     11        add_action( 'wp_enqueue_scripts', [ self::class, 'enqueue' ] );
    1212    }
    1313
    14     public static function register_worker(): void {
     14    public static function enqueue(): void {
    1515        if ( ! is_ssl() ) {
    1616            return;
    1717        }
    1818
    19         $handle = 'pushrelay-sw-register';
    20 
    2119        wp_register_script(
    22             $handle,
     20            'pushrelay-sw',
    2321            PUSHRELAY_PLUGIN_URL . 'assets/js/sw-register.js',
    2422            [],
     
    2725        );
    2826
    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' );
    5328    }
    5429}
  • pushrelay/trunk/includes/Utils/Health.php

    r3423210 r3423267  
    99
    1010    public static function init(): void {
    11         add_action( 'admin_notices', [ __CLASS__, 'maybe_show_notice' ] );
     11        add_action( 'admin_notices', [ __CLASS__, 'notice' ] );
    1212    }
    1313
    14     public static function maybe_show_notice(): void {
     14    public static function notice(): void {
    1515        if ( ! current_user_can( 'manage_options' ) ) {
    1616            return;
    1717        }
    1818
    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 
    2619        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' ) .
    2821        '</p></div>';
    2922    }
  • pushrelay/trunk/pushrelay.php

    r3423239 r3423267  
    44 * Plugin URI: https://pushrelay.com
    55 * Description: Native Push Notifications for WordPress powered by PushRelay.
    6  * Version: 1.2.2
     6 * Version: 1.4.0
    77 * Author: PushRelay
    88 * Author URI: https://pushrelay.com
    99 * Text Domain: pushrelay
    10  * Domain Path: /languages
    1110 * Requires at least: 6.0
    1211 * Tested up to: 6.9
     
    1514 */
    1615
    17 
    1816if ( ! defined( 'ABSPATH' ) ) {
    1917    exit;
    2018}
    2119
    22 define( 'PUSHRELAY_VERSION', '1.2.1' );
     20define( 'PUSHRELAY_VERSION', '1.4.0' );
    2321define( 'PUSHRELAY_PLUGIN_FILE', __FILE__ );
    2422define( 'PUSHRELAY_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
    2523define( 'PUSHRELAY_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
    2624
    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';
     25require_once PUSHRELAY_PLUGIN_DIR . 'includes/bootstrap.php';
    4126
    4227add_action( 'plugins_loaded', function () {
    4328    \PushRelay\Core\Plugin::instance();
    44 } );
     29});
  • pushrelay/trunk/readme.txt

    r3423239 r3423267  
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 1.2.2
     7Stable tag: 1.4.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    1313
    1414== Description ==
    15 PushRelay integrates web push notifications directly into WordPress with zero manual setup.
     15PushRelay is a native WordPress plugin that provides a solid and standards-compliant foundation for web push notifications powered by the PushRelay platform.
    1616
    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
     17This release represents the first stable architecture of the plugin after an internal rebuild, focusing on reliability, compatibility, and long-term extensibility.
     18
     19Current 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
     25Planned 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
    2133
    2234== External Services ==
     
    2436
    2537Data sent may include:
    26 * Website identifiers
    27 * Configuration data required to deliver push notifications
     38* Site identifiers
     39* Configuration data required to initialize push notifications
    2840
    2941This service is provided by PushRelay.
     
    3244
    3345== 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.
     461. Upload the plugin to the `/wp-content/plugins/` directory, or install it via the WordPress Plugins screen.
     472. Activate the plugin through the “Plugins” menu in WordPress.
     483. Go to **PushRelay** in the WordPress admin menu to verify system status.
    3749
    3850== 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
    3957
    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
    4460
    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 =
     63First stable release after architectural rebuild.
Note: See TracChangeset for help on using the changeset viewer.