Plugin Directory

Changeset 3389220


Ignore:
Timestamp:
11/03/2025 10:19:22 PM (5 months ago)
Author:
nilbug
Message:

Adds admin notices to surface important updates and status messages, automatically enables Tracker mode on activation so performance tracking starts immediately, and confirms compatibility with WordPress 6.8.

Location:
sitepulse/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • sitepulse/trunk/assets/js/sitepulse_global.js

    r3374045 r3389220  
    44 *
    55 * Plugin : SitePulse
    6  * Version: 1.0
     6 * Version: 1.1.0
    77 *
    88 */
     9
     10jQuery(function($) {
     11    // Dismiss SitePulse trackers disabled notice
     12    $('#sitepulse-trackers-disabled-notice').on('click', async function() {
     13        try {
     14            const result = await setSPTrackersDisabledNotice();
     15        } catch (err) {
     16            // Optionally handle error, e.g. show error message
     17            console.error('Failed to update SitePulse trackers disabled notice:', err);
     18        }
     19    });
     20
     21    // Dismiss SitePulse trackers disabled notice
     22    async function setSPTrackersDisabledNotice() {
     23        const url = SitePulse.rest_url.replace(/\/$/, '') + '/sitepulse/v1/trackers_disabled_notice/dismiss';
     24        const res = await fetch(url, {
     25            method: 'POST',
     26            headers: {
     27                'Content-Type': 'application/json',
     28                'X-WP-Nonce': SitePulse.nonce
     29            },
     30            body: JSON.stringify({ _wpnonce: SitePulse.nonce })
     31        });
     32
     33        if ( ! res.ok ) {
     34            const err = await res.json().catch(()=>null);
     35            throw new Error( 'Request failed: ' + (err?.message || res.status) );
     36        }
     37
     38        return res.json();
     39    }
     40});
    941
    1042// Create or return alerts container
  • sitepulse/trunk/class/backend.php

    r3383675 r3389220  
    3333        // Global for all backend dashboard
    3434        wp_enqueue_style($this->plugin->setPrefix('_wpsp_backend_style_global'), SITEPULSE_ADMIN_ASSETS_CSS_URL . 'backend_global.css', [], filemtime( SITEPULSE_ADMIN_ASSETS_CSS_PATH . 'backend_global.css'), 'all');
     35        wp_enqueue_script($this->plugin->setPrefix(  SITEPULSE_PREFIX . '_global_script'), SITEPULSE_ADMIN_ASSETS_JS_URL . 'sitepulse_global.js', ['jquery'], filemtime(SITEPULSE_ADMIN_ASSETS_JS_PATH . 'sitepulse_global.js'), false);
     36        wp_localize_script( $this->plugin->setPrefix( SITEPULSE_PREFIX . '_global_script'), 'SitePulse', [
     37            'rest_url' => esc_url_raw( rest_url() ),
     38            'nonce'    => wp_create_nonce( 'wp_rest' ),
     39        ] );
     40
    3541        if( ! $this->isSettingsPage ) {
    3642            return;
     
    4046        wp_enqueue_style($this->plugin->setPrefix( SITEPULSE_PREFIX . '_backend_style'), SITEPULSE_ADMIN_ASSETS_CSS_URL . 'backend.css', [], filemtime( SITEPULSE_ADMIN_ASSETS_CSS_PATH . 'backend.css'), 'all');
    4147        // JS sitepulse
    42         wp_enqueue_script($this->plugin->setPrefix(  SITEPULSE_PREFIX . '_global_script'), SITEPULSE_ADMIN_ASSETS_JS_URL . 'sitepulse_global.js', ['jquery'], filemtime(SITEPULSE_ADMIN_ASSETS_JS_PATH . 'sitepulse_global.js'), false);
    4348        wp_enqueue_script($this->plugin->setPrefix( SITEPULSE_PREFIX . '_backend_script'), SITEPULSE_ADMIN_ASSETS_JS_URL . 'backend.js', ['jquery'], filemtime(SITEPULSE_ADMIN_ASSETS_JS_PATH . 'backend.js'), true);
    4449        wp_localize_script( $this->plugin->setPrefix( SITEPULSE_PREFIX . '_backend_script'), 'SitePulse', [
  • sitepulse/trunk/inc/api_backend.php

    r3383675 r3389220  
    261261} );
    262262
     263add_action( 'rest_api_init', function() {
     264    register_rest_route( 'sitepulse/v1', '/trackers_disabled_notice/dismiss', [
     265        'methods'  => 'POST',
     266        'callback' => 'sitepulse_set_trackers_disabled_notice',
     267        'permission_callback' => function() {
     268            // adjust capability as needed
     269            return current_user_can( 'manage_options' );
     270        },
     271        'args' => [
     272            '_wpnonce' => [
     273                'required' => true,
     274                'description' => 'WP REST API nonce for authentication',
     275                'type' => 'string',
     276            ],
     277        ],
     278    ] );
     279} );
     280
    263281// sitepulse_get_realtime_mode
    264282function sitepulse_get_realtime_mode( WP_REST_Request $request ) {
     
    374392}
    375393
     394//trackers_disabled_notice/dismiss
     395function sitepulse_set_trackers_disabled_notice( WP_REST_Request $request ) {
     396    $user_id = get_current_user_id();
     397    if ( ! $user_id ) {
     398        return new WP_Error( 'unauthenticated', 'User not authenticated', [ 'status' => 401 ] );
     399    }
     400
     401    // Mark the notice as dismissed for the current user
     402    update_user_meta( $user_id, 'sitepulse_trackers_disabled_notice_dismissed', true );
     403
     404    return rest_ensure_response( [
     405        'success'     => true,
     406    ] );
     407}
     408
    376409/**
    377410 * Sets the active status of dark mode.
     
    416449    update_option( "sitepulse_curl_api_enabled", $wpslowhttp );
    417450
     451    // Reset the dismissal of the trackers disabled notice
     452    $user_id = get_current_user_id();
     453    if ( ! $user_id ) {
     454        return;
     455    }
     456    update_user_meta( $user_id, 'sitepulse_trackers_disabled_notice_dismissed', false );
     457
    418458    return rest_ensure_response( [
    419459        'success'     => true,
     
    447487    add_action('shutdown', function () use ( $sitepulse_profiler_enabled ) {
    448488        update_option( "sitepulse_profiler_enabled", $sitepulse_profiler_enabled, false );
     489
     490        $user_id = get_current_user_id();
     491        if ( ! $user_id ) {
     492            return;
     493        }
     494        update_user_meta( $user_id, 'sitepulse_trackers_disabled_notice_dismissed', false );
    449495    });
    450496
  • sitepulse/trunk/loader.php

    r3383675 r3389220  
    33 * Plugin Name:       SitePulse - See What’s Powering (or Slowing) Your Site
    44 * Description:       SitePulse gives you real-time insights into your WordPress site’s performance, slow queries, and bottlenecks - so you can keep your site fast, healthy, and optimized.
    5  * Version:           1.1.0
     5 * Version:           1.1.1
    66 * Author:            Frederic Guzman
    77 * Author URI:        https://www.nilbug.com
     
    2727}
    2828
    29 define( 'SITEPULSE_VERSION',               '1.1.0' );
     29define( 'SITEPULSE_VERSION',               '1.1.1' );
    3030define( 'SITEPULSE_NAME',                  'SitePulse' );
    3131define( 'SITEPULSE_SLUG',                  'sitepulse' );
     
    7373require_once SITEPULSE_CLASS_PATH . 'curloader.php';
    7474require_once SITEPULSE_PATH . 'inc/api_backend.php';
     75require_once SITEPULSE_CLASS_PATH . '/plugin.php';
    7576
    7677// Enabling plugin profiler
     
    105106     */
    106107    private function init() {
    107         require_once SITEPULSE_CLASS_PATH . '/plugin.php';
    108         $plugin = new Sitepulse_Plugin();
     108        new Sitepulse_Plugin();
    109109
    110         register_activation_hook(SITEPULSE_PLUGIN_FILE, [&$plugin, 'activate']);
    111         register_deactivation_hook(SITEPULSE_PLUGIN_FILE, [&$plugin, 'deactivate']);
     110        register_activation_hook(SITEPULSE_PLUGIN_FILE, [ $this, 'activate']);
     111        // register_deactivation_hook(SITEPULSE_PLUGIN_FILE, [ $this, 'deactivate']);
     112        // Admin dismissable notice when trackers are disabled
     113        add_action( 'admin_notices', [ $this, 'admin_notice_trackers_disabled' ] );
    112114    }
    113115
     
    149151     */
    150152    public function deactivate() {
    151         if(current_user_can('activate_plugins') && is_plugin_active(plugin_basename(SITEPULSE_PLUGIN_FILE))) {
    152             deactivate_plugins(plugin_basename(SITEPULSE_PLUGIN_FILE));
     153        // if(current_user_can('activate_plugins') && is_plugin_active(plugin_basename(SITEPULSE_PLUGIN_FILE))) {
     154        //  deactivate_plugins(plugin_basename(SITEPULSE_PLUGIN_FILE));
     155        // }
     156    }
     157
     158    /**
     159     * Activates the plugin enable the trackers.
     160     */
     161    public function activate() {
     162        update_option( SITEPULSE_PROFILER_ENABLED, true );
     163        update_option( SITEPULSE_CURL_API_ENABLED, true );
     164    }
     165
     166    // Admin dismissable notice when trackers are disabled
     167    public function admin_notice_trackers_disabled() {
     168        $profiler_enabled = ( get_option( SITEPULSE_PROFILER_ENABLED ) == '1' );
     169        $curl_enabled     = ( get_option( SITEPULSE_CURL_API_ENABLED ) == '1' );
     170
     171        if ( $profiler_enabled && $curl_enabled ) {
     172            return;
    153173        }
     174
     175        // check if notice was dismissed
     176        $dismissed = get_user_meta( get_current_user_id(), 'sitepulse_trackers_disabled_notice_dismissed', true );
     177        if ( $dismissed ) {
     178            return;
     179        }
     180
     181        $class = 'notice notice-warning is-dismissible';
     182        if ( ! $profiler_enabled && ! $curl_enabled ) {
     183            $message = esc_html__( 'Both SitePulse trackers (Load Sentinel and API/Request tracker) are disabled. Please enable them in the SitePulse dashboard to start monitoring your site\'s performance.', 'sitepulse' );
     184        } elseif ( ! $profiler_enabled ) {
     185            $message = esc_html__( 'SitePulse - Load Sentinel tracker is disabled. Please enable it in the SitePulse dashboard to start monitoring your site\'s performance.', 'sitepulse' );
     186        } else {
     187            $message = esc_html__( 'SitePulse - API/Request tracker is disabled. Please enable it in the SitePulse dashboard to start monitoring your site\'s performance.', 'sitepulse' );
     188        }
     189
     190        printf( '<div id="sitepulse-trackers-disabled-notice" class="%1$s"><p>%2$s</p></div>', esc_attr( $class ), esc_html( $message ) );
    154191    }
    155192}
  • sitepulse/trunk/readme.txt

    r3383675 r3389220  
    11=== SitePulse - See What’s Powering (or Slowing) Your Site ===
    22Contributors: nilbug, frederickgzmn
    3 Tags: performance, profiler, optimization, speed, insight, monitoring, hooks, load time
     3Tags: performance, speed, optimization, monitoring, profiler
     4Requires at least: 5.5
    45Tested up to: 6.8
    56Requires PHP: 7.4
    6 Stable tag: 1.1.0
     7Stable tag: 1.1.1
    78License: GPLv2 or later
    89License URI: https://www.gnu.org/licenses/gpl-2.0.html
    9 Understand what powers (or slows) your site - get real-time insights into page loads, plugins, and hooks directly from your dashboard.
     10
     11See what’s really happening under the hood of your WordPress site. Get instant, real-time performance insights, spot slow plugins or hooks, and keep your site running fast and stable.
    1012
    1113== Description ==
    12 SitePulse provides lightweight uptime monitoring, API-driven checks, and a simple performance profiling dashboard for WordPress sites. It includes backend and frontend assets, an admin dashboard for status and profiling, and a small API layer for integrations.
    1314
    14 Features:
    15 * Uptime and service checks via configurable API endpoints
    16 * Simple admin dashboard for current site status
    17 * Performance profiling hooks for page-level insights
    18 * Lightweight frontend and backend assets
    19 * Exportable logs and basic troubleshooting helpers
     15**SitePulse** helps you **understand what powers (or slows down) your site** — directly from your WordPress dashboard. 
     16You’ll instantly see load-time metrics, slow hooks, and plugin usage so you can keep your site optimized without extra tools.
     17
     18### 🚀 Key Features
     19- **Real-time load time tracker** – See how long each page takes to load.
     20- **Slow plugin & hook profiler** – Detect which plugin or hook is causing bottlenecks.
     21- **Uptime & API monitoring** – Verify your site’s health and response codes automatically.
     22- **Lightweight & privacy-friendly** – Runs locally, with minimal overhead and no data sharing.
     23- **Dashboard insights** – View charts, trends, and logs from your WordPress admin.
     24- **Exportable logs** – Download CSV logs for deeper analysis or reporting.
     25
     26### 💡 Why Choose SitePulse?
     27Most performance plugins *optimize* — SitePulse helps you **understand**. 
     28Before you install another caching or optimization tool, find out what’s *really* slowing your site down — themes, plugins, queries, or hooks — with clear data and no guesswork.
     29
     30---
    2031
    2132== Installation ==
    22 1. Upload the entire "sitepulse" folder to the /wp-content/plugins/ directory.
    23 2. Activate the plugin through the 'Plugins' screen in WordPress.
    24 3. Navigate to SitePulse in the WordPress admin menu to configure API keys and monitoring options.
    25 4. Optionally configure scheduled checks via your hosting cron or WP-Cron.
     331. Upload the `sitepulse` folder to `/wp-content/plugins/`
     342. Activate **SitePulse** from the Plugins screen.
     353. Open the **SitePulse → Dashboard** menu to view metrics and configure options.
     364. (Optional) Set up scheduled checks using WP-Cron or your hosting panel’s cron jobs.
     37
     38---
    2639
    2740== Frequently Asked Questions ==
    28 = How do I configure monitors? =
    29 Open the SitePulse dashboard in the admin area and use the provided UI to add or edit monitored endpoints and check intervals.
    3041
    31 = Will SitePulse affect site performance? =
    32 SitePulse is designed to be lightweight. Profiling is opt-in and monitoring requests are small and scheduled. Disable profiling if you notice any impact.
     42= Does SitePulse slow my site down? =
     43No. SitePulse is built to be lightweight and runs asynchronously. Profiling is optional and can be toggled off anytime.
    3344
    34 = Can I integrate SitePulse with external services? =
    35 Yes. SitePulse exposes minimal API hooks and a backend endpoint for integrations. See the plugin settings and included API files for details.
     45= Do I need external services? =
     46No external accounts are required. SitePulse runs 100% inside WordPress and uses the WP REST API for internal checks.
     47
     48= Can it work with WooCommerce or multisite? =
     49Yes. SitePulse tracks any page or post type, including WooCommerce product pages and multisite environments.
     50
     51= Can I export performance data? =
     52Yes. You can export logs and hook profiles for backup or to analyze on your local computer.
     53
     54---
    3655
    3756== Screenshots ==
    38 1. Dashboard overview (status and recent checks)
    39 2. insights screen
    40 3. Settings and system info
    41 4. Resources tracker
    42 5. Real time tracker running
     571. Admin dashboard showing page-load metrics
     582. Hook profiler highlighting slow actions
     593. Settings screen for configuring API checks
     604. Resource usage and memory stats
     615. Real-time tracker running in admin bar
     62
     63---
    4364
    4465== Changelog ==
     66
     67= 1.1.1 =
     68* Added admin notices to surface important updates and status messages
     69* Automatically enable Tracker mode when the plugin is activated
     70* Confirmed compatibility with WordPress 6.8
     71
    4572= 1.1.0 =
    46 * User-friendly focus: Settings page, block cronjobs, block emails from SMTP or send email, real-time tracking frontend interface, load time per page, plugin space usage improved etc.
     73* Added frontend tracking interface
     74* Block cronjobs and outgoing emails
     75* Load time tracking per page and plugin usage report
    4776
    4877= 1.0.0 =
    49 * Initial public release: uptime monitoring, admin dashboard, basic profiler, and API endpoints.
     78* Initial public release with uptime monitoring, dashboard, and basic profiler
     79
     80---
    5081
    5182== Upgrade Notice ==
    52 = 1.0.0 =
    53 Initial release.
     83= 1.1.1 =
     84Adds admin notices to surface important updates and status messages, automatically enables Tracker mode on activation so performance tracking starts immediately, and confirms compatibility with WordPress 6.8.
    5485
    55 == Additional Notes ==
    56 * Configuration and templates are located in the plugin folder under /templates and core PHP classes under /class.
    57 * For troubleshooting, enable debug logging and consult the plugin logs in the admin area.
     86---
    5887
    5988== Support ==
    60 For support, open an issue at the plugin repository or use the WordPress.org support forums for SitePulse.
     89Having trouble or have suggestions? 
     90→ Visit the [SitePulse Support Forum](https://wordpress.org/support/plugin/sitepulse/) or open an issue on GitHub. 
     91We respond quickly and love feedback that helps improve performance visibility for everyone.
Note: See TracChangeset for help on using the changeset viewer.