Changeset 3389220
- Timestamp:
- 11/03/2025 10:19:22 PM (5 months ago)
- Location:
- sitepulse/trunk
- Files:
-
- 5 edited
-
assets/js/sitepulse_global.js (modified) (1 diff)
-
class/backend.php (modified) (2 diffs)
-
inc/api_backend.php (modified) (4 diffs)
-
loader.php (modified) (5 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
sitepulse/trunk/assets/js/sitepulse_global.js
r3374045 r3389220 4 4 * 5 5 * Plugin : SitePulse 6 * Version: 1. 06 * Version: 1.1.0 7 7 * 8 8 */ 9 10 jQuery(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 }); 9 41 10 42 // Create or return alerts container -
sitepulse/trunk/class/backend.php
r3383675 r3389220 33 33 // Global for all backend dashboard 34 34 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 35 41 if( ! $this->isSettingsPage ) { 36 42 return; … … 40 46 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'); 41 47 // 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);43 48 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); 44 49 wp_localize_script( $this->plugin->setPrefix( SITEPULSE_PREFIX . '_backend_script'), 'SitePulse', [ -
sitepulse/trunk/inc/api_backend.php
r3383675 r3389220 261 261 } ); 262 262 263 add_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 263 281 // sitepulse_get_realtime_mode 264 282 function sitepulse_get_realtime_mode( WP_REST_Request $request ) { … … 374 392 } 375 393 394 //trackers_disabled_notice/dismiss 395 function 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 376 409 /** 377 410 * Sets the active status of dark mode. … … 416 449 update_option( "sitepulse_curl_api_enabled", $wpslowhttp ); 417 450 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 418 458 return rest_ensure_response( [ 419 459 'success' => true, … … 447 487 add_action('shutdown', function () use ( $sitepulse_profiler_enabled ) { 448 488 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 ); 449 495 }); 450 496 -
sitepulse/trunk/loader.php
r3383675 r3389220 3 3 * Plugin Name: SitePulse - See What’s Powering (or Slowing) Your Site 4 4 * 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. 05 * Version: 1.1.1 6 6 * Author: Frederic Guzman 7 7 * Author URI: https://www.nilbug.com … … 27 27 } 28 28 29 define( 'SITEPULSE_VERSION', '1.1. 0' );29 define( 'SITEPULSE_VERSION', '1.1.1' ); 30 30 define( 'SITEPULSE_NAME', 'SitePulse' ); 31 31 define( 'SITEPULSE_SLUG', 'sitepulse' ); … … 73 73 require_once SITEPULSE_CLASS_PATH . 'curloader.php'; 74 74 require_once SITEPULSE_PATH . 'inc/api_backend.php'; 75 require_once SITEPULSE_CLASS_PATH . '/plugin.php'; 75 76 76 77 // Enabling plugin profiler … … 105 106 */ 106 107 private function init() { 107 require_once SITEPULSE_CLASS_PATH . '/plugin.php'; 108 $plugin = new Sitepulse_Plugin(); 108 new Sitepulse_Plugin(); 109 109 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' ] ); 112 114 } 113 115 … … 149 151 */ 150 152 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; 153 173 } 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 ) ); 154 191 } 155 192 } -
sitepulse/trunk/readme.txt
r3383675 r3389220 1 1 === SitePulse - See What’s Powering (or Slowing) Your Site === 2 2 Contributors: nilbug, frederickgzmn 3 Tags: performance, profiler, optimization, speed, insight, monitoring, hooks, load time 3 Tags: performance, speed, optimization, monitoring, profiler 4 Requires at least: 5.5 4 5 Tested up to: 6.8 5 6 Requires PHP: 7.4 6 Stable tag: 1.1. 07 Stable tag: 1.1.1 7 8 License: GPLv2 or later 8 9 License 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 11 See 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. 10 12 11 13 == 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.13 14 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. 16 You’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? 27 Most performance plugins *optimize* — SitePulse helps you **understand**. 28 Before 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 --- 20 31 21 32 == 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. 33 1. Upload the `sitepulse` folder to `/wp-content/plugins/` 34 2. Activate **SitePulse** from the Plugins screen. 35 3. Open the **SitePulse → Dashboard** menu to view metrics and configure options. 36 4. (Optional) Set up scheduled checks using WP-Cron or your hosting panel’s cron jobs. 37 38 --- 26 39 27 40 == 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.30 41 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? = 43 No. SitePulse is built to be lightweight and runs asynchronously. Profiling is optional and can be toggled off anytime. 33 44 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? = 46 No 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? = 49 Yes. SitePulse tracks any page or post type, including WooCommerce product pages and multisite environments. 50 51 = Can I export performance data? = 52 Yes. You can export logs and hook profiles for backup or to analyze on your local computer. 53 54 --- 36 55 37 56 == 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 57 1. Admin dashboard showing page-load metrics 58 2. Hook profiler highlighting slow actions 59 3. Settings screen for configuring API checks 60 4. Resource usage and memory stats 61 5. Real-time tracker running in admin bar 62 63 --- 43 64 44 65 == 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 45 72 = 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 47 76 48 77 = 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 --- 50 81 51 82 == Upgrade Notice == 52 = 1. 0.0=53 Initial release.83 = 1.1.1 = 84 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. 54 85 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 --- 58 87 59 88 == Support == 60 For support, open an issue at the plugin repository or use the WordPress.org support forums for SitePulse. 89 Having trouble or have suggestions? 90 → Visit the [SitePulse Support Forum](https://wordpress.org/support/plugin/sitepulse/) or open an issue on GitHub. 91 We respond quickly and love feedback that helps improve performance visibility for everyone.
Note: See TracChangeset
for help on using the changeset viewer.