=== Foxes Spanish Mortgage Calculator ===
Contributors: foxesfinance
Tags: mortgage, calculator, spain, property, real estate
Requires at least: 5.8
Tested up to: 6.8
Requires PHP: 7.4
Stable tag: 2.1.7
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Adds the Foxes quick-estimate Spanish mortgage calculator to your site, with the visitor's enquiry captured on your own site or sent to Foxes, your choice.

== Description ==

Visitors choose where they pay tax, enter a purchase price and see what they could borrow, the monthly payment, the deposit, the buying costs and the cash they need, using the lending limits and desk rate Foxes Finance & Legal (Bank of Spain registered credit intermediary, D470) publishes.

The button under the results does one of three things, your choice in Settings:

* **Collect the enquiry on your site.** The button expands to name, email and phone. Enquiries are stored on your own website under Mortgage leads (with the full scenario: price, deposit, mortgage, monthly payment, buying costs, cash needed), emailed to you, optionally emailed to the visitor, exported to CSV, and POSTed to a webhook URL so they can flow into your CRM through Zapier, Make, n8n or a direct inbound webhook. From the Mortgage leads screen you can send any enquiry to Foxes with one click, credited to your partner code.
* **Send visitors to Foxes.** "Get my real assessment" takes them to a full pre-qualification on foxes.es with their figures filled in and your partner code attached.
* **No button.** The calculator is a tool only.

Seven languages: English, Spanish, Dutch, German, French, Norwegian, Swedish.

Place it with the shortcode `[foxes_calculator]`, the "Foxes mortgage calculator" block, or the "Add to every page" setting.

== External service ==

The calculator itself is loaded from foxes.es (https://foxes.es/embed/calculator/js/) so the figures are always current. When a page containing the calculator loads, your site's hostname and partner code are sent to foxes.es (https://foxes.es/wp-json/foxes/v1/widget-hit), at most once per hour, so Foxes can confirm the calculator is live. No visitor data is sent to foxes.es by the calculator itself; a visitor's figures only travel to foxes.es if they click through to the assessment. Enquiries a visitor submits through the button in "Collect the enquiry on my site" mode are stored on YOUR website only, in a table this plugin creates, and are emailed to the address you set. Nothing about them is sent to Foxes unless you click Send to Foxes on a lead, in which case the contact details and the scenario go to https://foxes.es/wp-json/foxes/v1/partner-lead with your partner code. Deleting the plugin removes the table. Foxes privacy policy: https://foxes.es/privacy/

== Updates ==

Updates come from foxes.es, not WordPress.org: the plugin checks https://foxes.es/wp-json/foxes/v1/partner-plugin twice a day and installs new versions automatically. The check sends your site's address and the plugin version number, so Foxes can see which sites run the calculator and whether they are up to date. Nothing about your visitors is sent. Switch auto-updates off in Plugins > Auto-updates if you prefer, or use the "Check for updates" link under the plugin.

== Credit link ==

A line reading "Powered by Foxes", linking to https://foxes.es/calculator/, appears under the calculator by default. You can switch it off under Foxes > Settings > Appearance; the calculator works exactly the same without it.

== Installation ==

1. Upload the plugin zip via Plugins > Add New > Upload, or copy the folder into wp-content/plugins.
2. Activate it.
3. Foxes > Settings: enter your partner code, optional title, subtitle and colours.
4. Add `[foxes_calculator]` to a page, or choose "Add to every page".

== Changelog ==

= 2.1.7 =
* The update check now sends your site's address and the plugin version, and always reaches foxes.es directly rather than a cached copy.

= 2.1.6 =
* The email check shows which SMTP plugin is active, or one-click install links for WP Mail SMTP and FluentSMTP when none is.

= 2.1.5 =
* The PDF preview button saves your changes first, so what you see is what you have set. The test email now says where to confirm it (Foxes > Settings > Enquiries) and links there.

= 2.1.3 =
* The visitor's PDF download starts on the spot after they send the form, with the button as fallback. Email check on the Enquiries tab (send a test, confirm it arrived); until it is confirmed the visitor is not promised an email copy.

= 2.1.2 =
* The estimate PDF can carry two explainer pages (what each figure means, and the buying process step by step), on by default, switchable on the PDF tab.

= 2.1.1 =
* The estimate PDF has its own PDF tab in settings, with a Preview the PDF button that shows a sample in your saved branding.
* The visitor email's opening line and sign-off are editable under Enquiries ({name} and {site} placeholders). The email no longer carries a Foxes line.

= 2.1.0 =
* The visitor's estimate as a one-page PDF in your branding: your logo (PNG or JPG), company name, phone, email and website, your calculator colours. Attached to the alert and visitor emails, downloadable from the thank-you message and from Leads. Settings under Enquiries. Only the visitor's first name and figures are sent to foxes.es to lay the page out; their email and phone stay on your site.

= 2.0.5 =
* The credit line is now just "Powered by Foxes".

= 2.0.4 =
* The "Powered by Foxes Finance & Legal" line under the calculator can now be switched off (Appearance > Powered by line). It stays on by default; existing installs are unchanged.

= 2.0.3 =
* Redesigned settings screen: status at a glance, Setup / Appearance / Enquiries / Add to your site sections, colour presets, live preview beside the settings, getting-started checklist.

= 2.0.2 =
* One "Foxes" menu in the WordPress sidebar with Leads and Settings under it (settings moved out of Settings > Foxes calculator).

= 2.0.1 =
* Consent line wording: the visitor agrees to being passed to a regulated mortgage adviser (no company named).

= 2.0.0 =
* Collect enquiries on your own site: the button can expand to a short form (name, email, phone, consent). Enquiries are stored under a new Mortgage leads screen with status, search, CSV export and delete.
* Email alerts to one or more addresses, in a plain-text format CRM lead inboxes can parse; optional copy to the visitor.
* Webhook: every new enquiry POSTed as signed JSON to a URL of your choice (Zapier, Make, n8n, any CRM with an inbound webhook), with one automatic retry and a Send a test button.
* Send to Foxes: one click per lead forwards it to Foxes with your partner code. Never automatic.
* Retention setting (6, 12, 24 months or keep) with daily cleanup; uninstall removes the table.
* Developers: `do_action( 'foxes_calculator_lead', $lead, $scenario )` after every new enquiry.
* Settings: "Show the button" becomes "What the button does" with three choices. Existing installs keep their current behaviour.

= 1.7.0 =
* The "Powered by Foxes Finance & Legal" credit is now printed by the plugin in your page's own HTML, below the calculator, in the language you have chosen. It no longer depends on JavaScript running.
* The calculator button no longer adds an "(in English)" note in other languages. The assessment step itself is still in English.

= 1.6.0 =
* Language setting: English, Spanish, Dutch, German, French, Norwegian, Swedish. Default matches your WordPress site language. Every label, tooltip, region name and number format follows it. Shortcode attribute lang="nl".

= 1.5.0 =
* New Accent colour: the highlighted term pill, the Resale / New build chips, the chosen tax tile border and the slider knob. Leave it empty and it follows your Button colour, then your Text colour.
* Property type setting: start on Resale or New build. Visitors can switch inside the calculator. New build buying costs are VAT plus stamp duty instead of transfer tax. Shortcode attribute ptype="new".

= 1.4.0 =
Option to hide the assessment button and use the calculator purely as a tool.

= 1.3.1 =
Install instructions and a copy button for the shortcode on the settings page.

= 1.3.0 =
Region for buying costs (visitors can change it too). Font choice (site default, common system fonts, or a font your theme already loads). Separate colour for the figures inside the results panel; labels inside the panel adjust to light or dark panels automatically.

= 1.2.1 =
Reset to default colours link.

= 1.2.0 =
Colour settings: text, results panel and button, with a live preview on the settings page.

= 1.1.1 =
Partner code field tidies FXP references (FXP-1001 style).

= 1.1.0 =
Updates served from foxes.es with auto-update on by default; "Check for updates" link; FXPC_ORIGIN can be overridden in wp-config.php.

= 1.0.0 =
First release.
