=== Craft Quantities Calculators ===
Contributors: craftquantities
Tags: calculator, construction, concrete, estimate, embed
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.1.0
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Embed free construction calculators (concrete, framing, roofing, tile and more) from Craft Quantities with a block or a shortcode.

== Description ==

Craft Quantities publishes free construction quantity calculators, each with its formula, its sources and worked examples. This plugin puts any of them in a post or a page:

* **A block**, "Craft Quantities Calculator", with a searchable list of every calculator, and settings for units, language, theme and height.
* **A shortcode** for the classic editor and widgets:

`[craftquantities calc="concrete-calculator" units="imperial" lang="en" theme="auto" height="auto"]`

The calculator runs inside an iframe served from craftquantities.com, the same frame the site offers on its [embed page](https://craftquantities.com/embeds/). With `height="auto"` the frame grows and shrinks to fit the calculator.

**What the plugin does not do**

* No tracking, no analytics, no cookies, no ads — in the plugin, and in the embedded frame (the frame's own security policy forbids third-party scripts and outbound requests).
* No account and no API key.
* It does not size or certify anything. The calculators estimate quantities; structural sizing belongs to your engineer and your building department.
* No prices. The calculators work out quantities, never costs.

**Credit**

The calculators and their content are published under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which asks for credit. Every embed shows a line under the frame, "Calculator by Craft Quantities", linking to the calculator's full page, where its sources and method are. The link is a normal link by default; each block (or `credit="nofollow"` on a shortcode) can make it `rel="nofollow"`. The line itself is always shown.

**Shortcode options**

* `calc` (required): the calculator's slug, the last part of its address on craftquantities.com (for example `concrete-calculator`).
* `units`: `imperial`, `metric`, or `auto` (default: the reader's own setting).
* `lang`: `en`, `es`, `fr`, `pt`, or `auto` (default: the site's language). Where the calculator's Spanish, French or Portuguese page is published on craftquantities.com, the frame shows the calculator in that language and the credit links to that page. Translated pages are published a group at a time, so until a calculator's page is out, the frame shows the English calculator with the credit line in your language; it switches by itself once the page is published.
* `theme`: `light`, `dark`, or `auto` (default: follows the reader's system setting).
* `height`: `auto` (default: fits the calculator) or a number of pixels between 200 and 6000.
* `heading`: `0` hides the calculator's own heading inside the frame, for a page whose heading already names it.
* `credit`: `follow` (default) or `nofollow`.

== External services ==

This plugin connects to Craft Quantities (https://craftquantities.com), the site that publishes the calculators. It is needed for the plugin to do anything at all.

* **The embedded calculator.** Every page that shows a calculator loads an iframe from `https://craftquantities.com/embed/`. The reader's browser requests the calculator page and its scripts and styles from craftquantities.com, which receives the usual request data (IP address, browser user agent, and the address of the page as the referrer, under the `strict-origin-when-cross-origin` policy). The inputs typed into the calculator are worked out in the reader's browser and are not sent anywhere.
* **The calculator list.** When an editor opens the block's calculator picker, your WordPress server requests `https://craftquantities.com/api/v1/calculators.json` (the public list of calculators: slug, title, category) and `https://craftquantities.com/api/v1/embed-languages.json` (which calculators are published in Spanish, French or Portuguese) and keeps them for a week. No data about your site or its users is sent beyond the request itself. Pages shown to visitors never make this request; if the list cannot be fetched, the plugin uses the copy bundled with it.

Craft Quantities: [terms of use](https://craftquantities.com/terms/), [privacy policy](https://craftquantities.com/privacy-policy/).

== Installation ==

1. In WordPress, go to Plugins → Add New → Upload Plugin, choose `craft-quantities.zip` and click Install Now. (Or unzip it into `wp-content/plugins/`.)
2. Activate "Craft Quantities Calculators".
3. In the block editor, add the "Craft Quantities Calculator" block and choose a calculator. In the classic editor, use the `[craftquantities]` shortcode.

== Frequently Asked Questions ==

= Is it free? =

Yes. The plugin, the calculators and the embed are free, with no account, key or quota.

= Does the calculator slow my page down? =

The frame loads lazily (only when it nears the screen) and its files come from craftquantities.com, not your server. The plugin adds one small stylesheet and, for auto-height frames, a script of about 1 KB.

= Can I read the result from my own page? =

Yes. The frame posts its result to the host page with `postMessage`; the message format is documented on https://craftquantities.com/embeds/.

= Where do the calculators' formulas and figures come from? =

Each calculator's page on craftquantities.com lists its method and its sources. The credit link under every embed goes there.

= What does uninstalling remove? =

The cached calculator list. The plugin stores no other options, tables or files. Blocks and shortcodes already in your posts stay in the posts' content.

== Screenshots ==

1. The block in the editor, with the searchable calculator picker.
2. The concrete calculator on a page, with the credit line.

== Changelog ==

= 1.1.0 =
* Translated calculators: with `lang="es"`, `"fr"` or `"pt"` (or the site's language), the frame shows the Spanish, French or Portuguese calculator once its page is published on craftquantities.com, and the credit links to that page. The block's Language setting lists only the languages the chosen calculator is published in.
* The plugin also reads the public list of published languages (embed-languages.json) with the calculator list, editor only, cached for a week; a copy is bundled.

= 1.0.0 =
* First release: block with searchable picker, shortcode, auto-height, units, theme, language and credit options; translations for Spanish, French and Portuguese.

== Upgrade Notice ==

= 1.1.0 =
Shows translated calculators (Spanish, French, Portuguese) where they are published.

= 1.0.0 =
First release.
