=== NCB Diagnosis ===
Contributors: ncbsoftware, freemius
Tags: diagnostics, troubleshooting, woocommerce, health-check, performance
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 8.1
Stable tag: 1.15.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Diagnose WordPress & WooCommerce problems in plain language, with a suggested fix for every finding. Read-only and safe on live sites.

== Description ==

NCB Diagnosis scans your WordPress and WooCommerce site and explains what is wrong in plain language, with a severity level, a confidence estimate and a suggested fix for each finding. It is read-only by default, so it is safe to run on a live production site. WooCommerce is optional — the store-specific checks activate automatically when WooCommerce is present.

= Included modules (free) =

* System Health — PHP, database, memory, extensions, REST API, cron, HTTPS, caches, debug status, writable paths.
* Plugin Conflicts — heuristic detection of multiple plugins modifying the same sensitive hooks (incl. payment hooks).
* Payment Gateways (WooCommerce) — per-gateway checks: enabled, available at checkout, test mode, missing merchant IDs / API keys, currency & country.
* Email Deliverability — checks whether transactional/order emails will actually arrive: sending method (PHP mail vs SMTP), From-address domain alignment and free-provider misuse, a best-effort SPF DNS check, and (on WooCommerce) whether the key customer order emails are enabled.
* PHP Errors — parses debug.log, groups fatals/warnings/notices/deprecations and attributes a probable source.
* Scripts & Styles — duplicate libraries (e.g. multiple jQuery copies) and missing script dependencies.
* Performance — query counts, duplicate/slow queries (with SAVEQUERIES), memory, load time, autoloaded options.
* Log Center — unified view of WordPress and WooCommerce logs.
* Compatibility Score — per-area percentages and an overall site-health figure.
* Developer tools — WP-CLI commands (wp ncbdi list / run / export) and one-click JSON or text report export for CI, staging checks and support tickets.

= NCB Diagnosis Pro (upgrade) =

The free plugin is fully functional on its own. Upgrading to NCB Diagnosis Pro adds deeper WooCommerce and monitoring tools:

* Safe Test Mode — isolate a plugin for your own admin session only (Disable / Restore / Restore all). Never permanently disables plugins; visitors are unaffected.
* Checkout Doctor (WooCommerce) — diagnoses the environment-level causes that silently break checkout: SSL, checkout/cart page setup, block vs classic compatibility, JS-optimisation conflicts and selling-location restrictions, with a top-line "can customers pay right now?" answer.
* Action Scheduler (WooCommerce) — surfaces failed background tasks, an overdue/stalled queue, and stuck workers behind renewals, order emails and webhooks.
* Stock & Orders (WooCommerce) — negative stock, stock/status mismatches, recent failed orders, and orders stuck in a status. HPOS-compatible.
* Live Monitor + Root-Cause Timeline — optional background monitoring with a health history, an over-time chart, email alerts when something breaks and recovers, and correlation of problems with recent plugin/theme/core changes.
* Guided Fix — selected findings offer a one-click, reversible fix with a preview, explicit confirmation, an audit log and Undo.

== Updating ==

The plugin folder/slug stays "ncb-diagnosis" across releases, so you can update by uploading the new zip and choosing **"Replace current with uploaded"** (WordPress 5.5+). Existing settings are kept; no uninstall is required. The plugin runs any needed migrations automatically based on the stored version.

== General principles ==

* Never modifies WordPress or WooCommerce core.
* Read-only diagnostics by default.
* Any repair action requires explicit administrator confirmation.
* Confidence percentages on conflict/payment findings are heuristic estimates, not guarantees.

== Frequently Asked Questions ==

= Does it modify WordPress or WooCommerce core? =
No. All diagnostics are read-only by default and core is never modified.

= How do I update to a new version? =
Upload the new zip and choose "Replace current with uploaded". Your settings are kept.

= Does Safe Test Mode disable my plugins permanently? =
No. It isolates a plugin only for your own admin session and never permanently disables anything. Safe Test Mode is part of NCB Diagnosis Pro.

= Will the plugin ask me for a review? =
Once, and only after you have been using it for a while — never straight after installation. You can postpone it or turn it off for good, and your choice is remembered for your account.

== External services ==

This plugin relies on the following third-party services. No data is sent to either of them while you simply browse the plugin's screens or run a scan.

= Freemius =

Freemius handles licensing, plan management and plugin updates for NCB Diagnosis.

What is sent and when: nothing at all unless you choose to opt in. On activation the plugin shows an opt-in screen with Allow and Skip. If you click Skip, no data leaves your site. If you click Allow, Freemius receives your site URL, admin email address, and basic environment details (WordPress and PHP version, plugin version and active plan) so that licence checks and update notices work. The same data is sent when you activate a licence key, and periodically afterwards to verify the licence is still valid. You can revoke consent at any time from NCB Diagnosis -> Account.

Service provider: Freemius, Inc. (api.freemius.com)
Terms of service: https://freemius.com/terms/
Privacy policy: https://freemius.com/privacy/

= Public DNS (SPF record lookup) =

The Email Deliverability module checks whether your site's sending domain publishes an SPF record, a common reason order and notification emails are rejected as spam.

What is sent and when: only when you run the Email Deliverability module or a full scan. The plugin performs a standard DNS TXT lookup, through your server's configured resolver, for the domain part of the site's From address only. No site content, no personal data and no email addresses are transmitted, and no third-party API is contacted — this is the same kind of lookup your mail server performs.

Terms and privacy: the resolver is whichever one your hosting provider has configured; no separate account, registration or agreement is involved.

== Changelog ==

= 1.15.2 =
* Declared compatibility with WordPress 7.1.
* Plugin Check pass: the suppression around the one-off user meta rename now covers the whole statement, and the deliberate core-hook invocation in the Scripts & Styles module is documented inline.

= 1.15.1 =
* Every global name the plugin declares now uses the NCBDI prefix suggested by the WordPress.org review team: constants (NCBDI_VERSION, NCBDI_PATH and so on), the NCBDI\Diagnosis namespace, options, AJAX actions, hooks, the cron event, the transient, the cookie, script handles, the WP-CLI command (now `wp ncbdi`), the Live Monitor history table and the review notice's stored keys.
* Existing installations are migrated automatically on the first admin page load after updating, from either earlier naming generation: settings, Live Monitor configuration, schedule and recorded history, the repair log, the change timeline and each administrator's review-notice answer all carry across untouched. No reconfiguration is needed.
* Added an External services section to the readme documenting the Freemius licensing service and the SPF DNS lookup used by the Email Deliverability module.
* The REST API check no longer forwards the administrator's cookies to the loopback request and no longer disables SSL certificate verification; an invalid certificate is now reported instead of being silently accepted.
* Escaped a conditional CSS class in the dashboard template and documented the read-only diagnostic database queries.

= 1.15.0 =
* Internal naming pass (released through Freemius only, superseded by 1.15.1).

= 1.14.8 =
* The review notice's stylesheet/script handle now begins with the plugin slug (ncb-diagnosis-review-notice). No other changes.

= 1.14.7 =
* Renamed the review-notice class to NCBDI_Review_Notice and its file to ncbdi-review-notice.php so the plugin's own prefix is used throughout. Stored data (option and per-user meta keys) is unchanged, so existing dismissals are preserved.

= 1.14.6 =
* The review notice now registers its styles and script through the WordPress enqueue API (wp_add_inline_style / wp_add_inline_script on a registered handle) instead of printing inline style and script tags. No change to how or when the notice appears.

= 1.14.5 =
* Annotated the namespace declarations and plugin hook names so static analysis no longer reports them: the plugin slug contains a hyphen, which PHP does not permit in a namespace, so the underscore form is the correct prefix. No functional changes.

= 1.14.4 =
* Code-quality pass on the review notice: annotated the uninstall-time database cleanup and the two shared function/hook names so static analysis reports them accurately. No functional changes.

= 1.14.3 =
* Locations are now resolved entirely through the WordPress and WooCommerce APIs: the error log is found via WP_DEBUG_LOG / the PHP error_log directive, the WooCommerce log folder is read from WooCommerce itself, and the uploads folder is asked for rather than assumed. Nothing is written outside the uploads directory any more — WP-CLI report exports are saved to uploads/ncb-diagnosis and go through WP_Filesystem.
* Removed the explicit translation loader; WordPress resolves the text domain automatically.
* Safe Test Mode has moved to NCB Diagnosis Pro.
* Added a one-time, dismissible review request in the admin area, remembered per user.

= 1.14.2 =
* Cleaned up for the WordPress.org Plugin Check: added translators comments, replaced the placeholder Plugin URI with the real one, switched file deletion to wp_delete_file(), set "Tested up to" to the current WordPress version, and documented the read-only diagnostic database calls and the nonce-verified AJAX handlers. No functional changes.

= 1.14.1 =
* readme.txt: corrected the feature list so the free version lists only its included modules, with premium modules shown as a clearly-labelled Pro upgrade. No code changes.

= 1.14.0 =
* Made the codebase WordPress.org-ready: the premium-only modules (Checkout Doctor, Action Scheduler, Stock & Orders, Live Monitor + Root-Cause Timeline, Guided Fix) are now marked so they are stripped from the free build, and every reference to them in the core is guarded so the free version runs fully without them. The premium build is unchanged in behaviour. No changes to the free modules' diagnostic logic.

= 1.13.1 =
* Moved the plugin's delete-time cleanup from uninstall.php to the Freemius after_uninstall hook and removed the standalone uninstall.php, so the plugin lifecycle is managed entirely through Freemius. No change to what is cleaned up on deletion (options, Live Monitor history table, scheduled cron and the Safe Test Mode dropin).

= 1.13.0 =
* Integrated the Freemius WordPress SDK (bundled in vendor/freemius) to power license activation, secure premium gating and automatic updates. The free tier (System Health, Plugin Conflicts, Payment Gateways, Email Deliverability, PHP Errors, Scripts & Styles, Performance, Log Center, Compatibility Score, Safe Test Mode, reports and WP-CLI) stays fully functional; the premium areas (Checkout Doctor, Action Scheduler, Stock & Orders, Live Monitor + Root-Cause Timeline, Guided Fix) unlock with a valid license. Plans and pricing are managed entirely in the Freemius dashboard — no code changes are needed to adjust them. No functional changes to the diagnostic logic.

= 1.12.0 =
* Rebranded from WP Diagnosis to NCB Diagnosis (plugin name, slug, text domain, namespaces, constants, options, hooks, asset handles and documentation). No functional changes: architecture, logic, database structure and features are identical.

= 1.11.0 =
* Added the free/premium framework. Diagnostics, Safe Test Mode and reports stay free; the WooCommerce depth (Checkout Doctor, Action Scheduler, Stock & Orders), Live Monitor + Root-Cause Timeline, and Guided Fix are premium. Premium areas show a clear upgrade prompt for free sites. Licensing/pricing are handled entirely outside the code (via Freemius); without an SDK everything stays unlocked, and NCBDI_SIMULATE_FREE previews the free experience.

= 1.10.0 =
* Guided Fix catalogue expanded: correct stock status for products marked "in stock" with zero/negative quantity, and assign an existing published checkout page when none is set. Both preview first, are reversible, and are logged. Fix buttons now appear across the Email, Stock & Orders and Checkout Doctor findings.

= 1.9.0 =
* New: Guided Fix engine. Fixable findings now show a Fix button that previews the change, asks for explicit confirmation, applies a reversible fix, records it in an audit log, and offers Undo. The first fix re-enables disabled WooCommerce order emails; the catalogue will expand. Requires the manage_options capability.

= 1.8.0 =
* New: Root-Cause Timeline. NCB Diagnosis now records site changes (plugin/theme/core updates, activations, theme switches) and correlates them with the Live Monitor health history — when the site develops a problem shortly after a change, it points to the likely cause, with event markers on the chart. Read-only.

= 1.7.0 =
* New module: Stock & Orders integrity (WooCommerce). Detects negative stock, stock/status mismatches, recent failed orders, and orders stuck in pending/on-hold/processing — with an actionable fix per finding. HPOS-compatible.

= 1.6.1 =
* Export report now offers a human-readable .txt version in the dashboard (alongside the JSON download), and the WP-CLI export supports --format=text.

= 1.6.0 =
* New module: Email Deliverability. Diagnoses the top reasons order/site emails don't arrive — PHP mail() vs SMTP, From-address domain/SPF alignment, and disabled WooCommerce order emails — each with a plain-language fix. Works with or without WooCommerce.

= 1.5.0 =
* New module: Action Scheduler (WooCommerce) — detects failed actions, an overdue/stalled queue, and stuck workers behind renewals, emails and webhooks.
* New developer tools: WP-CLI commands (`wp ncbdi list`, `wp ncbdi run [module] [--format=json]`, `wp ncbdi export [--file=]`) and a dashboard "Export report" button that downloads a full JSON diagnostic report.

= 1.4.0 =
* New module: Checkout Doctor (WooCommerce). Focuses on the "money path" — the five classic reasons a checkout silently breaks (SSL, checkout/cart page setup, block vs classic compatibility, JavaScript optimisation conflicts, and geographic selling restrictions), plus enabled-gateway test-mode detection and a top-line pay-readiness check. Read-only, with an actionable fix per finding. Complements the existing Payment Gateways module.

= 1.3.4 =
* Branding: enlarged the dashboard header icon (crisper on high-DPI screens).

= 1.3.3 =
* Branding: the dashboard header now uses the NCB Diagnosis app icon instead of the placeholder heart.

= 1.3.2 =
* Safe Test Mode: disabled plugins now surface at the top of the list (right under the summary) instead of sinking to the bottom, so each plugin's own Restore button is immediately visible next to Restore all.

= 1.3.1 =
* Fixed: Safe Test Mode now keeps a Restore button on each isolated plugin and shows the Restore all bar while anything is disabled. Previously an isolated plugin disappeared from the list (because it is hidden from the current session), leaving no way to restore it from that screen. Plugins are also listed alphabetically now.

= 1.3.0 =
* New module: Live Monitor. Adds an On-demand/Live switch, scheduled background checks (configurable 5/15/60 min), a health history table with configurable retention (default 5 days), an over-time chart, an events timeline, and email alerts on state changes. Includes a concurrency lock and a ready-to-copy server-cron command for reliable scheduling on quiet or shared hosts. All monitoring writes only to the plugin's own table; core is never modified and visitors are never affected.

= 1.2.0 =
* Safe Test Mode is now fully interactive: each active plugin has Disable (test) / Restore buttons, plus a Restore all control, wired to the existing session-only isolation engine. Visitors are never affected.
* Added an on-screen confirmation (toast) for every safe-mode action.

= 1.1.1 =
* Set the plugin Author to NCB Software across the plugin header and metadata.
* Added a Frequently Asked Questions section to the readme. No functional changes to the diagnostic modules.

= 1.1.0 =
* Renamed the plugin to NCB Diagnosis (brand, namespace, options, AJAX actions and text domain updated). No functional changes to the diagnostic modules.

= 1.0.0 =
* Initial release: core engine, admin dashboard (light/dark), AJAX scans, and the nine modules listed above.
