=== Yangra Calculator ===
Contributors: metalfreek
Tags: calculator, pricing, quote, estimator, roi
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Build pricing estimators, quote tools and ROI calculators from your own inputs and formulas, then add them to any page with a block or shortcode.

== Description ==

Yangra Calculator lets you build calculators for your visitors without writing code. Add the inputs you need, write a formula for each result, and place the calculator on any page. Results update as visitors type.

Use it for:

* **Price estimators**: cleaning, painting, printing, moving, catering, web design.
* **Quote tools**: a starting price plus options and add-ons.
* **ROI and savings calculators**: show what a customer gains by switching to you.
* **Finance and health tools**: loan repayments, tax, BMI, calories, unit conversions.

= Visual builder =

Build each calculator on its own screen in the admin, with a live preview of the result. Every change is checked before it is saved. If a formula has a mistake, the builder points to it and nothing you typed is lost. Calculators keep revisions, so you can go back to an earlier version.

= Inputs =

* **Number**: a typed value, with optional minimum, maximum and step.
* **Slider**: a range between a minimum and a maximum.
* **Dropdown**: options with a label for visitors and a number for formulas, such as "Premium" = 49.
* **Checkbox**: counts as 1 when ticked and 0 when not, which suits add-ons.

= Start from a template =

"Add New" opens a choice of ready-made calculators to change to fit: flooring estimate, hourly service quote, how much can I borrow, sales tax, profit margin and markup, return on investment, BMI, daily calories, tip and bill split, and trip fuel cost. Or start from scratch with an empty calculator.

= Formulas =

Formulas use the input names you choose, for example:

`area * price_per_m2 + if(rush, 50, 0)`

* Arithmetic: `+ - * / % ^` and brackets.
* Comparisons and logic: `== != < > <= >= && || !`
* Functions: `if`, `min`, `max`, `round`, `floor`, `ceil`, `abs`, `sqrt`, `clamp`.
* A result can use any result above it, so you can split long formulas into steps. Tick "Hide from visitors" on the in-between steps so visitors only see the final figure.
* Each result has its own decimal places, prefix and suffix, such as `$` or ` / month`. Numbers use your site language's decimal and thousands separators.

= Keep your formulas private =

Each calculator can compute results in one of two ways:

* **In the visitor's browser** (default): results update instantly. The formulas are included in the page.
* **On your server**: formulas and hidden results never leave your site. The page sends the values entered and shows the results that come back, after a short pause.

You can choose which mode new calculators start with under Yangra Calculator → Settings.

= Add it anywhere =

* **Calculator block**: pick a calculator in the block editor and style it with colours, spacing and font size.
* **Shortcode**: `[yangra_calculator id="123"]` works in classic content, widgets and page builders. The All Calculators screen shows each calculator's shortcode, ready to copy.

= Lightweight and private =

* No tracking or cookies on your visitors. Diagnostic data is shared with Freemius only if you opt in.
* Scripts and styles load only on pages that show a calculator.
* Values entered by visitors are not stored.

= Source code =

The minified files in `build/` are compiled from the human-readable source in `assets/src/` using @wordpress/scripts (`npm run build`).

The plugin includes the [Freemius WordPress SDK](https://github.com/Freemius/wordpress-sdk) (version 2.13.4, GPLv3) in `vendor/freemius/wordpress-sdk/`, which handles opt-in diagnostics and Pro licensing. Its source is available in that repository.

== Installation ==

1. In your admin, go to Plugins → Add New, search for "Yangra Calculator", then install and activate it. Or upload the `yangra-calculator` folder to `/wp-content/plugins/` and activate it on the Plugins screen.
2. Go to Yangra Calculator → Add New.
3. Give the calculator a title, add your inputs and results, and publish it.
4. Add the Calculator block to a page and choose your calculator, or paste its shortcode from the All Calculators screen.

== Frequently Asked Questions ==

= Does the plugin collect any data? =

Only if you agree. On activation, Yangra Calculator asks whether you want to share basic, non-sensitive diagnostic data with us through Freemius, which also handles Pro licences and updates. Click "Skip" and nothing is sent. You can opt in or out later from the plugin's Account page.

= Do I need to know how to code? =

No. Formulas look like spreadsheet formulas: `quantity * unit_price`. The builder checks every formula as you write it and explains anything it cannot understand.

= How do I add an option that changes the price? =

Use a dropdown, and give each option the number your formula needs. For example, "Standard" = 0 and "Express" = 25, then add `delivery` to your total. For an optional add-on, use a checkbox: `if(gift_wrap, 5, 0)`.

= Can I use the result of one formula in another? =

Yes. A result can use every input and any result listed above it. Tick "Hide from visitors" on in-between results so visitors only see the ones that matter.

= Can visitors see my formulas? =

That depends on each calculator's Calculation setting. "In the visitor's browser" (the default) updates results instantly, but the formulas are part of the page. "On the server" keeps formulas and hidden results private: the page sends the values to your site and shows the results it sends back, after a short pause.

= What happens if a formula cannot be calculated, such as dividing by zero? =

That result shows a dash instead of a number, and the other results still work. The builder warns you about formulas like this while you edit. In server mode, visitors see a general message instead of the exact reason, so nothing about your formulas is revealed.

= How do I format results as money or percentages? =

Each result has a prefix, a suffix and a number of decimal places. Use `$` as a prefix and 2 decimals for prices, or `%` as a suffix for rates. Decimal and thousands separators follow your site's language.

= Does it work with my theme or page builder? =

Yes. Calculators use plain HTML and inherit your theme's fonts and colours. Use the block in the block editor, or the shortcode in any page builder, widget or classic content.

= Does it store what visitors enter? =

No. Values are used to compute the results and then discarded. In server mode they are sent to your own site only, never to a third party.

= Does it work on multisite? =

Yes. Each site has its own calculators and settings.

= What happens to my calculators if I delete the plugin? =

Deactivating the plugin keeps everything. Deleting it from the Plugins screen permanently removes all calculators, their revisions and the plugin's settings, on every site of a multisite network. Pages that used the Calculator block show nothing in its place; any [yangra_calculator] shortcodes are left as plain text.

== Screenshots ==

1. A price estimator on the front end, with results updating as the visitor types.
2. The visual builder: each result has a formula, with buttons that insert input names and functions.
3. The All Calculators screen with each calculator's embed code.
4. Choosing a calculator in the Calculator block.
5. The settings screen.

== Changelog ==

= 1.0.0 (2026-10-30) =
* Initial release.
* Visual calculator builder with number, slider, dropdown and checkbox inputs.
* Formula engine with arithmetic, comparisons, logic and nine functions.
* Hidden intermediate results, prefixes, suffixes and decimal places.
* Ten calculator templates to start from.
* Browser and server calculation modes.
* Calculator block and `[yangra_calculator]` shortcode.
* Embed code column on the All Calculators screen.
