=== OnPage Speed Checker ===
Contributors: mangcodingdev
Tags: pagespeed, performance, lighthouse, seo, admin dashboard
Requires at least: 6.4
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Check PageSpeed Insights performance for homepage, pages, and posts directly from your WordPress dashboard.

== Description ==

OnPage Speed Checker helps you monitor content performance without leaving wp-admin.

This plugin provides:

* Homepage performance snapshot for Mobile and Desktop.
* Content performance table for published pages and posts.
* One-click audit action from dashboard rows.
* Detailed modal view with score breakdown, Core Web Vitals, and recommendations.
* Settings page to control content scope, table results per page, and timeout.
* Stored latest snapshot results for faster dashboard review.

Important behavior:

* Homepage is treated as primary and shown in the top summary section.
* Front page entries are excluded from the content list table to avoid duplication.
* API key is configured and verified directly from plugin settings.
* Dashboard audit actions are disabled until API key verification is successful.

== Installation ==

1. Upload the plugin folder to `/wp-content/plugins/`, or install it from the WordPress Plugins screen.
2. Activate **OnPage Speed Checker** through the `Plugins` screen in WordPress.
3. Open `OnPage Speed Checker > Settings`.
4. Enter your Google PageSpeed API key.
5. Click **Test API Connection** and ensure the status is **Connected**.
6. Click **Save Changes**.
7. Open `OnPage Speed Checker > Dashboard`.
8. Run your first audit using the **Check Now** or **Check** button.

== Frequently Asked Questions ==

= Does this plugin use Google PageSpeed Insights API? =

Yes. The plugin integrates with PageSpeed Insights API and stores the latest audit snapshot for each target.

= Where do I set the API key? =

You can set the key in `OnPage Speed Checker > Settings`.

= Can I test API key before saving settings? =

Yes. You can run **Test API Connection** directly from Settings before clicking **Save Changes**.

= Why are the "Check Now" and "Check" buttons disabled? =

Audit actions are disabled when API key status is not verified. Open `OnPage Speed Checker > Settings`, run **Test API Connection**, make sure status is **Connected**, then save changes.

= Why is the homepage not listed in the table? =

Homepage performance is displayed in the dedicated top section. The list table focuses on content pages/posts to keep the dashboard clean.

= Can I filter and paginate results in the dashboard table? =

Yes. You can search, filter by type and score status, and navigate paginated entries. Current filter state is preserved after audit actions.

== External Services ==

This plugin connects to a third-party service:

* Service name: Google PageSpeed Insights API
* Service URL: https://pagespeedonline.googleapis.com/pagespeedonline/v5/runPagespeed
* Trigger: Only when an administrator runs an audit from the plugin dashboard.
* Data sent: The audited page URL and selected strategy (`mobile` or `desktop`).
* Purpose: Retrieve Lighthouse/PageSpeed performance results for the target URL.
* Service privacy policy: https://policies.google.com/privacy
* Service terms: https://policies.google.com/terms

== Screenshots ==

1. Dashboard overview with homepage performance, summary cards, and content table.
2. Detail modal with Mobile/Desktop tabs, Core Web Vitals, and recommendations.
3. Settings page for audit behavior and recommendation display.

== Changelog ==

= 1.0.0 =

* Initial stable release.
* Added API key verification workflow in plugin settings.
* Added **Test API Connection** action with connected/disconnected status handling.
* Added support for testing unsaved API key values before saving settings.
* Dashboard audit buttons are disabled until API key is verified.
* Added dashboard notice with direct link to Settings when API key is not verified.
* Added local environment API test fallback to public probe URL (`https://wordpress.org/`).
* Improved API status persistence after test/save to avoid false "Needs Verification" state.
* Dashboard UI for homepage + content performance overview.
* Audit actions for homepage, pages, and posts.
* Detail modal for score breakdown and recommendations.
* Settings page for audit scope, pagination size, timeout, and Best Practices visibility.
* Performance-focused PageSpeed request with Best Practices category support.
* Improved content listing logic for large sites and multilingual setups (pages + posts loaded per type, merged, and sorted).
* Front page exclusion logic in content table.
* Simplified table pagination UI to compact navigation (`<<`, `<`, current/total, `>`, `>>`).
* Homepage loading overlay (5 animated dots, blur + dark backdrop) while homepage audit is running.
* Homepage Check Now button is disabled during in-progress checks.
* Row-level audit UX for pages/posts:
  - Check button is disabled while checking.
  - Status changes to Checking... during request.
  - Status changes to Error when request fails.
* Improved API reliability on live servers:
  - Retry on timeout (`cURL error 28`) with extended second-attempt timeout.
  - Better HTTP request args (`httpversion`, redirection, custom user-agent).
  - More descriptive API error messages per strategy (mobile/desktop).
* Persisted audit state in DB:
  - Added `last_audit_status` and `last_audit_message`.
  - Error status remains visible after page refresh.
* Automatic DB schema upgrade routine for existing installations.
