=== Live Auto Refresh (Hot Reload / Live Reload for WordPress Developers) ===
Contributors: perron
Donate link: https://paypal.me/perronuk/
Tags: reload, refresh, live reload, hot reload, auto refresh
Requires at least: 4.7
Tested up to: 7.0
Stable tag: 4.2
Requires PHP: 7.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Instantly reloads the browser when theme or plugin files are edited, or when content is saved.

== Description ==

**Instant live reload for WordPress development.**

Eliminate manual browser refreshes. See your code changes immediately across all devices as you work.

**Key Features:**
- **Instant Feedback** - Changes to themes and selected plugins appear immediately
- **CSS Hot Reload** - Stylesheet updates without full page refresh
- **Content Sync** - Auto-reload when posts, pages, or builder content is saved
- **Multi-Device** - All logged-in browsers reload simultaneously
- **Smart Transport** - Server-Sent Events with automatic fallback to AJAX polling
- **Shared Connections** - Multiple tabs share one server connection (no worker exhaustion)

**Security:**
- Administrator/editor only (filterable capability)
- Nonce-protected endpoints
- Clean uninstall removes all data

== Installation ==

1. Install from the WordPress Plugin Directory
2. Activate the plugin
3. Go to **Settings → Live Auto Refresh** to configure monitoring
4. Use the admin bar toggle to quickly enable/disable while working

== Frequently Asked Questions ==

= What files are monitored? =

By default: `.php`, `.js`, and `.css` files in your active theme (parent and child) plus any plugins you select in settings. Changes are detected via modification time and file size.

= Which page builders are supported? =

Gutenberg, Elementor, Beaver Builder, Bricks Builder, WPBakery, Divi, Visual Composer, and ACF.

= Can I monitor my own plugin during development? =

Yes. Select it in Settings → Live Auto Refresh.

= How do I add support for a custom builder? =

Use the `perron_auto_refresh_custom_hooks` filter:

    add_filter( 'perron_auto_refresh_custom_hooks', function( $hooks ) {
        $hooks[] = 'my_builder_save_action';
        return $hooks;
    } );

= Available filters =

- `perron_auto_refresh_capability` - required capability (default: `edit_others_posts`)
- `perron_auto_refresh_reload_mode` - `'hard'` (full reload) or `'soft'` (CSS hot reload only)
- `perron_auto_refresh_poll_interval` - seconds between filesystem checks (default: the Poll Interval setting; filter takes precedence)
- `perron_auto_refresh_scan_budget_seconds` - max scan time per check (default: the Scan Budget setting; filter takes precedence)
- `perron_auto_refresh_sse_max_runtime` - SSE connection lifetime (default: `180`)
- `perron_auto_refresh_follow_symlinks` - return `true` to monitor symlinked themes/plugins, e.g. when symlinking projects into wp-content during local development (default: `false`; cycles are guarded)

= Host Configuration Tips =

For best SSE performance, ensure your host supports:
- PHP execution time of 180s+ (or `set_time_limit(0)`)
- Idle timeouts > 30s (for keep-alive pings)
- Disabled proxy buffering on SSE endpoints

If SSE fails, the plugin automatically falls back to AJAX polling.

= Do you accept donations? =

Yes! [Donate here](https://paypal.me/perronuk/)

== Screenshots ==

1. Admin bar toggle for quick enable/disable
2. Console notifications showing active monitoring and change detection
3. Settings page with monitoring status and cache controls

== Changelog ==

= 4.2 =
* Security: Capability-based access control (filterable via `perron_auto_refresh_capability`)
* Fixed: File rename detection, builder save normalization
* Improved: Database writes only on actual changes, leader-tab connection sharing, better error handling
* New: Settings page rebuilt on Settings API, JavaScript translations
* New: Poll Interval and Scan Budget are configurable on the settings page (filters still take precedence)
* New: After the inactivity timeout, clicking the PAUSED admin-bar button resumes monitoring in place - no page reload needed (all tabs resume together)
* New: `perron_auto_refresh_follow_symlinks` filter to monitor symlinked themes/plugins

= 4.1 =
* Fixed: PHP stat cache clearing, hash stability on large themes
* New: WP.org-compliant SSE streaming (admin-ajax primary, REST fallback, then AJAX polling)
* New: Leader-tab streaming to prevent worker exhaustion
* Improved: Builder save hook reliability, session expiration handling

= 4.0 =
* Major: Full refactor to singleton class architecture
* New: SSE transport with automatic AJAX fallback
* Improved: Hash-based change detection with performance safeguards

= 3.0 - 3.3 =
* Added: Plugin monitoring, page builder support, CSS hot reload improvements
* Switched to filemtime-based detection for better performance

= 2.0 =
* Added: Settings page, configurable intervals, nonce security

= 1.0 =
* Initial release: AJAX polling with theme file monitoring and CSS hot reload