Tags: gravityview, math, calculation, gravity forms
Requires at least: 5.1
Tested up to: 7.0.0
Requires PHP: 7.2.0
Contributors: The GravityKit Team
License: GPLv2 or later

Calculations. Uses the [Hoa Math](https://github.com/hoaproject/Math) library.

== Installation ==

1. Upload plugin files to your plugins folder, or install using WordPress' built-in Add New Plugin installer
2. Activate the plugin
3. Follow the instructions on [the GravityMath documentation page](https://docs.gravitykit.com/category/794-gravitymath)

== Changelog ==

= 2.11.0 on June 4, 2026 =

This release includes internal component updates and bug fixes for improved stability and compatibility.

#### 🔄 Updated
* [Foundation](https://www.gravitykit.com/foundation/) to version 1.21.0.

= 2.10.4 on April 29, 2026 =

This release fixes a fatal error in the GravityMath summary shortcode and block, and corrects how integer values with thousands separators are handled in the GravityView Calculation field.

#### 🐛 Fixed
* A fatal error occurred when using the `[gravitymath action="summary"]` shortcode or `gk-gravitymath/summary` block without GravityView active.
* Integer values with a thousands separator (e.g., 1,123) in the GravityView Calculation field were misread as decimals.

#### 🔄 Updated
* [Foundation](https://www.gravitykit.com/foundation/) to version 1.16.1.

= 2.10.3 on March 27, 2026 =

* Fixes fatal error on activation introduced in 2.10.2.

= 2.10.2 on March 26, 2026 =

This release fixes filtered calculations returning incorrect results on sites with many form entries.

#### 🐛 Fixed
* Filtered `scope="form"` calculations in the `[gravitymath]` shortcode and GravityView table footer now return correct results on forms with a large number of entries.

#### 🔄 Updated
* [Foundation](https://www.gravitykit.com/foundation/) to version 1.13.0.

= 2.10.1 on February 5, 2026 =

This update fixes merge tags not working in `[gravitymath]` shortcode attributes inside GravityView Custom Content fields.

#### 🐛 Fixed
* Merge tags in `[gravitymath]` shortcode attributes (e.g., `filter`) are now correctly replaced when used inside a GravityView Custom Content field.

#### 🔄 Updated
* [Foundation](https://www.gravitykit.com/foundation/) to version 1.9.0.

= 2.10 on January 22, 2026 =

This release adds alphabetical sorting of data sources (form or View) in the GravityMath Summary block and fixes issues affecting the `[gravitymath]` shortcode.

#### ✨ Improved
* Forms and Views are now sorted alphabetically in the GravityMath Summary block source selection dropdown.

#### 🐛 Fixed
* The `[gravitymath]` shortcode now respects the `scope` and `id` attributes when used inside GravityView Views (e.g., Custom Content field).
* The `filter` attribute now correctly restricts summary results when using `action="summary"` in the `[gravitymath]` shortcode.

#### 🔄 Updated
* [Foundation](https://www.gravitykit.com/foundation/) to version 1.7.2.

= 2.9.2 on November 13, 2025 =

This release resolves a fatal shortcode error and fixes multiple issues affecting currency formatting and calculations.

#### 🐛 Fixed
* Fatal error when the `[gravitymath]` shortcode referenced a View ID that did not exist.
* Inconsistent behavior between Number fields using the "Currency" format and Product fields.
* Incorrect parsing of currency values when using the DataTables [client-side rendering](https://docs.gravitykit.com/article/957-client-side-processing) with comma-decimal currencies (e.g., DKK, EUR), where values like "47.000,00 kr." were treated as 47 instead of 47000.
* Currency calculations now correctly use the currency stored with each entry rather than the WordPress locale, ensuring accuracy when site-wide currency settings change or when displaying entries with mixed currencies.

#### 🔄 Updated
* [Foundation](https://www.gravitykit.com/foundation/) to version 1.6.2.

= 2.9.1 on October 9, 2025 =

This update fixes calculation issues involving currency-formatted fields.

#### 🐛 Fixed
* Calculation field not working with currency-formatted Number fields and Product (price) fields.

= 2.9 on October 2, 2025 =

This release introduces a [new Calculation field for GravityView](https://docs.gravitykit.com/article/1104-gravitymath-calculation-field), removing the need to use the `[gravitymath]` shortcode inside Custom Content fields. Also fixes some minor bugs.

#### 🚀 Added
* New Calculation field for GravityView that displays formula-based calculations with professional formatting. ([Read about the Calculation field](https://docs.gravitykit.com/article/1104-gravitymath-calculation-field)).
  - Removes the need to use the `[gravitymath]` shortcode inside Custom Content fields.
  - Supports number and currency formatting.
  - Includes customizable decimal places, thousands separators, and prefix/suffix options.

#### 🐛 Fixed
* Math Summary blocks now properly validate View IDs before processing.
* REST API endpoints for Math Summary now handle invalid View IDs gracefully with proper error messages.
* Improved compatibility with GravityView Maps layout when rendering Math Summary blocks outside of GravityView post contexts.

#### 🔄 Updated
* [Foundation](https://www.gravitykit.com/foundation/) to version 1.6.0.

= 2.8.1 on August 6, 2025 =

This release adds compatibility with the GravityView Dashboard Views plugin.

#### 🚀 Added
* Compatibility with the [GravityView Dashboard Views](https://www.gravitykit.com/products/dashboard-views/) extension.

= 2.8 on May 8, 2025 =

This release adds dynamic Math Summary widget updates in GravityView’s DataTables layout, improves Date field filter handling in the `[gravitymath]` shortcode, and resolves footer calculation inaccuracies and a PHP notice in WordPress 6.8.

#### 🚀 Added
* Support for GravityView's DataTables layout, enabling dynamic Math Summary widget updates during table filtering and sorting.

#### ✨ Improved
* Date field filters in the `[gravitymath]` shortcode now accept field's display format values instead of requiring `yyyy-mm-dd` format.

#### 🐛 Fixed
* Sum calculations for Number fields using comma decimal separators in locales with period thousands separators.
* Incorrect footer calculations in GravityView's DataTables layout.
* PHP notice in WordPress 6.8 related to early product translation initialization.

#### 🔄 Updated
* [Foundation](https://www.gravitykit.com/foundation/) to version 1.2.25.

#### 💻 Developer Updates
* Added: `gk/gravitymath/summary/entries` filter to modify the entries object used for calculations.

= 2.7.1 on January 30, 2025 =

This update fixes an issue with configuring multiple Math Summary widgets in a View.

#### 🐛 Fixed
* Adding more than one Math Summary widget to a View caused the "Group By" selection in the widget settings to be empty.

#### 🔄 Updated
* [Foundation](https://www.gravitykit.com/foundation/) to version 1.2.22.

= 2.7 on November 21, 2024 =

This release adds support for Hidden fields in summary reports and addresses a non-critical PHP notice in WordPress 6.7 and newer.

#### 🚀 Added
* Support for Hidden fields in summary reports.

#### 🐛 Fixed
* PHP notice in WordPress 6.7 caused by initializing product translations too early.

#### 🔄 Updated
* [Foundation](https://www.gravitykit.com/foundation/) to version 1.2.21.

= 2.6.1 on November 1, 2024 =

This release resolves issues with displaying currency-formatted fields in summary reports and fixes footer calculations not working in embedded Views.

#### 🐛 Fixed
* Error when displaying a Number field formatted as currency in summary reports.
* Footer calculations not working when an embedded View is displayed in a Single Entry layout.

#### 🔄 Updated
* [Foundation](https://www.gravitykit.com/foundation/) to version 1.2.20.

= 2.6 on October 14, 2024 =

This release adds support for additional fields in summaries, addresses various issues, and updates internal components.

#### 🚀 Added
* Support for Checkboxes and Radio Buttons fields in summaries.

#### 🐛 Fixed
* Fatal error when creating a new View under certain conditions.
* Summary blocks and shortcodes would break when GravityView is not active.
* Shortcodes with `visible` or `view` scopes would not return results when filtering multi-input fields without providing input IDs.

#### 🔄 Updated
* [Foundation](https://www.gravitykit.com/foundation/) to version 1.2.19.

= 2.5.1 on October 2, 2024 =

This hotfix release addresses a fatal error that can occur when creating a new View.

#### 🐛 Fixed
* Fatal error when creating a new View under certain conditions.

= 2.5 on October 1, 2024 =

This release introduces new tools for creating summary reports from your form data, enabling you to perform calculations across entries for deeper insights. It also includes minor fixes and security improvements. [Read the announcement](https://www.gravitykit.com/announcing-gravitymath-2-5/).

#### 🚀 Added
* Option to display calculation summaries using a block, shortcode, or widget.
  - Supports grouping entries by fields, performing mathematical operations (e.g., Count, Sum, Average), sorting and displaying top results.
  - The summaries can be shown for all View entries or only those displayed on the current page.

#### 🐛 Fixed
* PHP 8.2 deprecation notice.

#### 🔐 Security
* The `[gravitymath]` shortcode now requires a `secret` attribute when the scope is set to `view` and the View has Enhanced Security enabled.

#### 🔄 Updated
* [Foundation](https://www.gravitykit.com/foundation/) and [TrustedLogin](https://www.trustedlogin.com/) to versions 1.2.18 and 1.9.0, respectively.

#### 💻 Developer Updates
* Added: `gk/gravitymath/summary/data` filter to modify the calculation data before rendering the summary table.
* Added: `gk/gravitymath/summary/template` filter to modify the template used to display the summary table.
* Added: `gk/gravitymath/summary/headers` filter to modify the table headers before rendering the summary table.

= 2.4.1 on January 25, 2024 =

This release fixes a bug in the `[gravitymath]` shortcode's math calculations and updates the [Foundation](https://www.gravitykit.com/foundation/) framework to improve support for sites that use object caching plugins.

#### 🐛 Fixed
* An issue with math calculations in the `[gravitymath]` shortcode not functioning correctly unless scoped to a specific form or View.

#### 🔄 Updated
* [Foundation](https://www.gravitykit.com/foundation/) was updated to version 1.2.7.
  - Improved the setting and retrieval of transients when using object cache plugins.
  - Fixed a JavaScript warning that appeared during the deactivation of license keys.

= 2.4.0 on January 11, 2024 =

This release introduces new functionality for multi-select fields and resolves several issues related to footer calculations. It also features an updated version of [Foundation](https://www.gravitykit.com/foundation/) that offers performance improvements and enhanced translation management.

#### 🚀 Added
* Ability to calculate individual selected or unselected choices of a multi-select field.
* New option to position the footer calculation row either above or below the table's footer row.

#### 🐛 Fixed
* Survey field (Likert type) score not being calculated correctly.
* Duration (text field with "hh:mm:ss" or "mm:ss" input mask) calculations not working correctly when scope is set to "form".
* Counting unselected or unchecked radio/checkbox/select field inputs would return "0" when scope is set to "form".
* Shipping field calculation producing incorrect results when scope is set to "form".

#### 🔄 Updated
[Foundation](https://www.gravitykit.com/foundation/) to version 1.2.6
- Improved performance.
- Enhanced the loading and caching of plugin translations.
    - All translations are now loaded from the `wp-content/languages/plugins/<site ID>` directory.
- Added support for installing plugin translations via WP-CLI (WordPress Command Line Interface).
- Fixed an issue where deactivating a product on one site in a multisite environment caused this product's translations to be deleted across all sites.
- Fixed PHP 8.2 deprecation warnings.
- Fixed a PHP warning encountered when updating plugins from the WordPress Plugins page.

= 2.3.5 on September 7, 2023 =

* Improved: Support for RTL languages
* Updated: [Foundation](https://www.gravitykit.com/foundation/) to version 1.2.2

= 2.3.4 on July 12, 2023 =

* Updated: [Foundation](https://www.gravitykit.com/foundation/) to version 1.1.1

= 2.3.3 on May 30, 2023 =

* Fixed: Incorrect calculation results for Survey fields (Likert type) with multiple rows that use score values
* Fixed: Calculation for Product fields with "user-defined price" not working when using the "filter" parameter in the [[gravitymath] shortcode](https://docs.gravitykit.com/article/295-math-shortcode)
* Fixed: Incompatibility with some plugins/themes that use Laravel components
* Updated: [Foundation](https://www.gravitykit.com/foundation/) to version 1.0.12

__Developer Updates:__

* Added: `gk/gravitymath/scope/form/transform-meta-value` filter to modify the SQL statement used to transform the meta value for complex fields such as multi-row Survey (Likert) or Product with user-defined price
* Added: `gk/gravitymath/table-footer-calculation/supported-fields-schema` filter to modify the list of View fields that support table footer calculations

= 2.3.2 on February 20, 2023 =

**Note: GravityMath now requires PHP 7.2 or newer**

* Updated: [Foundation](https://www.gravitykit.com/foundation/) to version 1.0.9

= 2.3.1 on January 30, 2023 =

* Fixed: Changing View settings or filters would not affect cached calculations
* Fixed: Calculations would be cached for Views connected to the same form
* Fixed: Pricing field calculations may not be accurate for values over 999 when using `view` and `visible` scopes

= 2.3 on January 5, 2023 =

* Updated: [Foundation](https://www.gravitykit.com/foundation/) to version 1.0.8

= 2.2 on December 21, 2022 =

* Added: Support for nesting shortcodes! Perform calculations inside calcuations using multiple forms ([read more about nested calculations](https://docs.gravitykit.com/article/900-nested-calcuations))
    * Added: `[gravitymath2]` and `[gravitymath3]` shortcodes for use inside a `[gravitymath]` shortcode
* Fixed: Multiple filters, separated by `&` in the shortcode `filter` attribute, were not working correctly
* Cache improvements:
    * Improved cache speed by returning object cache before checking GravityView cache (if GravityView is active)
    * Don't use cache when a form has been submitted on the page or if `?nocache`, `?cache=0`, or `?gform_debug` are in the URL
    * Fixed cache showing the wrong value when using the `:count` modifier in certain cases
* Fixed: Fatal error on some hosts due to a conflict with one of the plugin dependencies (psr/log)
* Fixed: PHP 8.1 notices

__Developer Updates:__

* Added: `gk/gravitymath/use_db_cache` filter to modify whether or not to use the database cache if GravityView is enabled. Default is `true`.

= 2.1.4 on December 15, 2022 =

* Fixed: Count operation not working for multiple input fields (e.g., First Name [1.3])
* Fixed: Multiple PHP 8.x warnings
* Fixed: Fatal error on some hosts that use weak security keys and salts

= 2.1.3 on December 1, 2022 =

* Fixed: It was not possible to remove an expired license key

= 2.1.2 on November 29, 2022 =

* Fixed: "Undefined index" PHP notice
* Fixed: Product quantity footer calculation was being formatted as currency
* Fixed: Footer calculations were added in the Single Entry layout

= 2.1.1 on November 14, 2022 =

* Fixed: Fatal error when loading plugin translations
* Fixed: Slow loading times on some hosts
* Fixed: Plugin failing to install on some hosts

= 2.1.0.3 on October 31, 2022 =

* Fixed: Plugin was not appearing in the "Add-Ons" section of the Gravity Forms System Status page

= 2.1.0.2 on October 20, 2022 =

* Fixed: Potential error when the plugin tries to log an unsuccessful operation

= 2.1.0.1 on October 19, 2022 =

* Fixed: Error when trying to activate license keys

= 2.1 on October 19, 2022 =

* Added: New WordPress admin menu where you can now centrally manage all your GravityKit product licenses and settings ([learn more about the new GravityKit menu](https://www.gravitykit.com/foundation/))
    - Go to the WordPress sidebar and check out the GravityKit menu!
    - We have automatically migrated your existing GravityMath license, which was previously entered in the Gravity Forms settings page
    - Request support using the "Grant Support Access" menu item
* Added: A new `[gravitymath]` shortcode—it works exactly the same as `[gv_math]`, but it's named properly
* Fixed: PHP 8 warnings

= 2.0.6 on June 21, 2022 =

* [GravityView (the company) is now GravityKit](https://www.gravitykit.com/rebrand/) and this plugin is now called GravityMath!
* Added: Support for product field with "Radio Buttons", "Drop Down" and "User Defined Price" field types

__Developer Updates:__

**IMPORTANT: `GravityView_Math_*` classes were renamed to `GravityMath_*` and future versions will see `gravityview/math/*` hooks renamed to `gk/gravitymath/*`**

= 2.0.5 on February 21, 2022 =

* Fixed: "Trying to get property of non-object" notice when displaying a View with footer calculations
* Fixed: Incorrect calculation of the average Quiz Score
* Added: Option to calculate a sum of the Quiz Score

= 2.0.4 on October 25, 2021  =

* Fixed: Filters using CONTAINS or NOTCONTAINS operators would not work
* Fixed: Filters would not work with multi-input fields unless the exact input is specified

= 2.0.3 on June 9, 2021 =

* Fixed: Fatal error if performing calculations using Gravity Forms data, using the shortcode's `filter` attribute, and GravityView is not installed
* Fixed: Filter conditions using fields with multiple input did not work

= 2.0.2 on May 13, 2021 =

* Fixed: Incorrect formatting of calculation results with certain locales
* Added: Option to specify the number of decimal places for footer calculations

= 2.0.1 on March 8, 2021 =

* Fixed: PHP fatal error when the plugin is used without GravityView
* Added: Footer calculations for Custom Content fields

= 2.0 on February 25, 2021 =

* Added: Easily add footer calculations to your GravityView Table and DataTables layouts! [Learn how to add calculations](https://docs.gravitykit.com/article/750-how-to-add-field-calculations-to-the-table-footer).
    - Effortlessly calculate field values
    - Quiz: # Passed, # Failed, % Passed, % Failed, Average Score
    - High, low, average, sum, checked
    - Count of checked and unchecked checkboxes, radio inputs, consent fields
    - Time duration: Fastest, slowest, average time
* Added: Perform duration calculations, great for races and time sheets! [See a video for setting up duration calculations](https://docs.gravitykit.com/article/756-gravity-forms-duration-calculations).
* Added: Filter support for `scope="visible"`. [Read more about filters](https://docs.gravitykit.com/article/295-math-shortcode#filters).
* Added: An `{entry_count}` Merge Tag you can use inside math formula as well as throughout Gravity Forms and GravityView! [Read about the `{entry_count}` Merge Tag](https://docs.gravitykit.com/article/754-entry-count-merge-tag)
* Improved: Execution time when a Math filter is used on large data sets
* Fixed: Incorrect results returned by `min`/`max`/`avg`/`sum` operations
* Fixed: Calculations on non-numeric fields (e.g., product price) would not work in View widget areas
* Fixed: Only using one page of results were used when calculating `scope="view"`
* Logging improvements!
    * New: Not sure why your Math formula isn't working, but you don't want to modify the shortcode? Administrators can now debug Math formulae from the front-end by adding `?gv_math_debug=true` to the URL.
    * Added: Better debugging information is now shown, including the contents of the formula before and after it was processed.
    * Improved: Notices are now grouped for each shortcode, making it easy to debug.
    * Fixed: "Additional info" shown when debugging results not displaying when clicked.
    * Fixed: Math by GravityView wasn't showing in the [Gravity Forms "Logging" screen](https://docs.gravityforms.com/logging-and-debugging/#viewing-logs).
    * Fixed: Display user notices only when `notices` shortcode attribute is set.

= 1.3.2 on April 6, 2020 =

* Fixed: If using `scope=form` as well as a filter, only the first 20 entries in the form were used in calculations

= 1.3.1 on March 5, 2020 =

* Fixed: Shortcode not working when used inside GravityView DataTables layouts
* Updated: French translation

= 1.3 on January 29, 2020 =

* Fixed: The `[gvmath]` shortcode not working properly inside GravityView `[gvlogic]` shortcodes
* Fixed: Potential errors when editing content in Gutenberg editor
* Fixed: Potential error when using Math while running Gravity Forms < 2.3 and GravityView < 2.5
* Fixed: Properly handles dates passed via Merge Tags
* Added: Support for Gravity Forms Merge Tags in the `filter` attribute (when using `scope="form"`)

_Developer Updates:_

* Added: `gravityview/math/debug` filter to modify whether debugging is on or off. Return `false` to disable debugging. Note: Viewing debugging requires `edit_others_posts` capability.

= 1.2 on May 10, 2019 =

* **The plugin now requires PHP 7.1**
* Added: Filtering on `form` and `view` scopes. This will filter the entries in the scope by the specified values. [Read more about filtering](https://docs.gravitykit.com/article/295-math-shortcode#scope-filtering).
* Fixed: `SQRT_PI`, `SQRT_{Number}` functionality
* Added: Russian Translation (thanks, Viktor S) and Ukrainian translation (thanks, Dariusz Zielonka!)
* Updated: Chinese translation (thanks, Edi Weigh!)

= 1.1.1 on May 8, 2018 =

* Fixed: Aggregate form data not calculating with Gravity Forms 2.3
* Fixed: `.mo` translation files weren't being generated
* Updated: Dutch, Turkish, and Spanish translations (thanks, jplobaton, SilverXp, and suhakaralar!)

= 1.1 on April 28, 2018 =

* Fixed: Compatibility with Gravity Forms 2.3
* Updated: Dutch and Turkish translations

= 1.0.3 on May 24, 2017 =

* Fixed: Don't link to entry in debug mode if the entry doesn't exist 👻
* Fixed: Incorrect argument passed to Gravity Forms Add-On registration function
* Fixed: Compatibility issue with the Gravity Forms Utility plugin - thanks, Naomi C Bush!

= 1.0.2 on December 15 =

* Fixed PHP error when there are no values to calculate
* Updated German translation (Thank you, Hubert Test!)

= 1.0.1 on September 14 =

* Fix potential error blocking activation

= 1.0 =

* Launch!
