{"id":114101,"date":"2019-12-05T13:54:06","date_gmt":"2019-12-05T13:54:06","guid":{"rendered":"https:\/\/wordpress.org\/plugins\/calculated-fields-for-acf\/"},"modified":"2022-02-02T15:30:37","modified_gmt":"2022-02-02T15:30:37","slug":"calculated-fields-for-acf","status":"publish","type":"plugin","link":"https:\/\/gu.wordpress.org\/plugins\/calculated-fields-for-acf\/","author":17607635,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"1.3.2","stable_tag":"1.3.2","tested":"5.9.13","requires":"4.7","requires_php":"7.0","requires_plugins":"","header_name":"Calculated fields for ACF","header_author":"Wundermatics","header_description":"Simple field math for Advanced Custom Fields","assets_banners_color":"","last_updated":"2022-02-02 15:30:37","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"https:\/\/www.wundermatics.com\/product\/calculated-fields-for-acf","header_author_uri":"https:\/\/wundermatics.com","rating":4.1,"author_block_rating":0,"active_installs":1000,"downloads":20037,"num_ratings":14,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","changelog"],"tags":{"1.0.0":{"tag":"1.0.0","author":"wundermatics","date":"2019-12-05 15:52:22"},"1.0.1":{"tag":"1.0.1","author":"wundermatics","date":"2019-12-05 17:13:57"},"1.1.0":{"tag":"1.1.0","author":"wundermatics","date":"2019-12-08 13:29:02"},"1.1.1":{"tag":"1.1.1","author":"wundermatics","date":"2019-12-08 15:10:35"},"1.1.3":{"tag":"1.1.3","author":"wundermatics","date":"2019-12-16 17:18:10"},"1.2.0":{"tag":"1.2.0","author":"wundermatics","date":"2019-12-22 15:52:19"},"1.2.1":{"tag":"1.2.1","author":"wundermatics","date":"2019-12-22 17:05:21"},"1.2.2":{"tag":"1.2.2","author":"wundermatics","date":"2019-12-23 08:58:13"},"1.2.3":{"tag":"1.2.3","author":"wundermatics","date":"2020-02-20 21:58:50"},"1.2.4":{"tag":"1.2.4","author":"wundermatics","date":"2020-02-24 22:38:05"},"1.3.0":{"tag":"1.3.0","author":"wundermatics","date":"2020-11-15 19:52:48"},"1.3.1":{"tag":"1.3.1","author":"wundermatics","date":"2022-01-26 22:47:07"},"1.3.2":{"tag":"1.3.2","author":"wundermatics","date":"2022-02-02 15:30:37"}},"upgrade_notice":[],"ratings":{"1":2,"2":1,"3":0,"4":2,"5":9},"assets_icons":{"icon-256x256.png":{"filename":"icon-256x256.png","revision":2206639,"resolution":"256x256","location":"assets","locale":""}},"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.0.0","1.0.1","1.1.0","1.1.1","1.1.3","1.2.0","1.2.1","1.2.2","1.2.3","1.2.4","1.3.0","1.3.1","1.3.2"],"block_files":[],"assets_screenshots":{"screenshot-1.png":{"filename":"screenshot-1.png","revision":2208024,"resolution":"1","location":"assets","locale":""},"screenshot-2.png":{"filename":"screenshot-2.png","revision":2208024,"resolution":"2","location":"assets","locale":""},"screenshot-3.png":{"filename":"screenshot-3.png","revision":2208024,"resolution":"3","location":"assets","locale":""}},"screenshots":[],"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[2211,83],"plugin_category":[59],"plugin_contributors":[179982,178633],"plugin_business_model":[],"class_list":["post-114101","plugin","type-plugin","status-publish","hentry","plugin_tags-acf","plugin_tags-admin","plugin_category-utilities-and-tools","plugin_contributors-nick6352683","plugin_contributors-wundermatics","plugin_committers-wundermatics"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/ps.w.org\/calculated-fields-for-acf\/assets\/icon-256x256.png?rev=2206639","icon_2x":"https:\/\/ps.w.org\/calculated-fields-for-acf\/assets\/icon-256x256.png?rev=2206639","generated":false},"screenshots":[{"src":"https:\/\/ps.w.org\/calculated-fields-for-acf\/assets\/screenshot-1.png?rev=2208024","caption":""},{"src":"https:\/\/ps.w.org\/calculated-fields-for-acf\/assets\/screenshot-2.png?rev=2208024","caption":""},{"src":"https:\/\/ps.w.org\/calculated-fields-for-acf\/assets\/screenshot-3.png?rev=2208024","caption":""}],"raw_content":"<!--section=description-->\n<p>Adds a formula fields ot Advanced Custom Fields that allows you to perform simple math based on field values. Calculations are updated dynamically via ajax while editing a post on the backend post editor as well as on front end forms.<\/p>\n\n<h3>Requirements<\/h3>\n\n<p>Calculated fields requires Advanced Custom Fields 5.0 or later and works with Pro as well as the standard version.<\/p>\n\n<h3>Frontend forms<\/h3>\n\n<p>Beginning in version 1.2.3, Calculated fields for ACF supports frontend forms created using the acf_form() function (built in to Advanced Custom Fields).<\/p>\n\n<h4>Formulas<\/h4>\n\n<p>Calculated fields adds a new setting \"Formula\" to the the ACF field editor. Formulas supports referring to other fields in the same Field group using the field name. If a formula is added to a sub field inside a repeater field, the name refers to another sub field in the same repeater.<\/p>\n\n<p>A sub field inside a repeater field can also refer to a parent field using the \"parent.\"\" prefix.<\/p>\n\n<p>A formula can contain the basic mathematical operations: plus (+), minus (-), multiply (*), division (\/) and power of (^). Formulas can also contains functions like sin, cos, arcsin, log, ln, sqrt, abs. Parentheses are supported.<\/p>\n\n<p>If an expression can't be evaluated due to invalid syntax or referring to undefined field names, it will silently return zero.<\/p>\n\n<p>Examples of valid expressions (note, no equal sign at the beginning):<\/p>\n\n<ul>\n<li>fieldA * 2<\/li>\n<li>fieldA * fieldB<\/li>\n<li>abs(fieldA) * (2 + sqrt(fieldB))<\/li>\n<li>amount * parent.price<\/li>\n<\/ul>\n\n<h4>Conditional operators<\/h4>\n\n<p>An expression can also contain a conditional expression that will return either 0 or 1. The supported operators are:<\/p>\n\n<ul>\n<li>Equals (==) - Returns 1 when two values are equal, 0 otherwise<\/li>\n<li>Not equals (!=) - Returns 1 when two values are not equal, 0 otherwise<\/li>\n<li>Greater than (&gt;) - Returns 1 when the first operand is greater than the second, 0 otherwise<\/li>\n<li>Greater than or equal (&gt;=) - Returns 1 when the first operand is greater than or equal to the second, 0 otherwise<\/li>\n<li>Less than (&lt;) - Returns 1 when the first operand is less than the second, 0 otherwise<\/li>\n<li>Less than or equal (&lt;=) - Returns 1 when the first operand is less than or equal to the second, 0 otherwise<\/li>\n<\/ul>\n\n<p>Examples of valid expressions using conditional operators:<\/p>\n\n<ul>\n<li>10 == 10 (returns 1)<\/li>\n<li>10 == 2 (returns 0)<\/li>\n<li>10 &gt; 2 (returns 1)<\/li>\n<li>10 &lt; 2 (returns 0)<\/li>\n<li>10 &lt;= 10 (returns 1)<\/li>\n<\/ul>\n\n<h4>Rounding functions<\/h4>\n\n<p>Round a decimal value to the nearest integer. Supported functions are:<\/p>\n\n<ul>\n<li>round() - Uses standard mathematical rounding rules to round to nearest integer<\/li>\n<li>ceil() - Rounds the value to the next higher integer<\/li>\n<li>floor() - Rounds the value to the next lower integer<\/li>\n<\/ul>\n\n<p>Examples of valid expressions using rounding functions:<\/p>\n\n<ul>\n<li>round(10.2) (returns 10)<\/li>\n<li>round(10.9)  (returns 11)<\/li>\n<li>round(10.888888 * 10) \/ 10 (returns 10.9)<\/li>\n<li>ceil(10.2) (returns 11)<\/li>\n<li>floor(10.2) (returns 10)<\/li>\n<\/ul>\n\n<p>Note that the round() function only takes one parameter and always round to an integer. If you need to round to a higher precision, multiply and divide as shown in third example above.<\/p>\n\n<h4>Group fields (new from 1.2.4)<\/h4>\n\n<p>Fields defined as part of a group, subfields, can be addressed using the group name as a prefix. Inside the group, a field defined on the parent level can be addressed using the \"parent\" prefix. See examples below:<\/p>\n\n<p>Valid formula to use the value of field \"foobar\" defined inside the group \"group2\":\n* group2.foobar + 10<\/p>\n\n<p>Valid formula in a field inside a group (assuming the parent has a field named count):\n* parent.count * 22<\/p>\n\n<h4>Array functions for repeater fields<\/h4>\n\n<p>If repeater fields are used, a calculated field in the parent field group can summarize a specific repeater sub fields using the aggregation functions sum, count, average, min or max. For example, the expression: \"Sum(orderlines.amount)\"\" will return the sum of all the \"amount\" fields in the repeater field \"orderlines\".<\/p>\n\n<p>The available array functions are:<\/p>\n\n<ul>\n<li>sum()<\/li>\n<li>average()<\/li>\n<li>count()<\/li>\n<li>min()<\/li>\n<li>max()<\/li>\n<\/ul>\n\n<p>Note that anything after the dot (.) in the aggregate expression is an expression in itself. It's perfectly OK to write a formula like: \"Sum(orderlines.price * amount)\". This expression will walk over all lines in the \"orderlines\" repeater field, perform the calculation \"price * amount\" and return the sum of all lines.<\/p>\n\n<p>Note that when working with aggregate functions, parentheses can not be used. If you need to aggregate a more complex calculation, you should add an extra field in the repeater group and let the aggregate function work on this extra field.<\/p>\n\n<h4>Data type and calculation order<\/h4>\n\n<p>Calculated fields works with the assumption that all fields are defined as numeric in the ACF editor. Using a text field in a formula WILL PRODUCE UNPREDICTABLE RESULTS.<\/p>\n\n<p>Calculations are made as the custom field is stored to the database. To minimize the impact of performance, Calculated fields rely on field order. A formula field can only refer to fields ordered BEFORE itself. A formula field that refers to a field ordered after it WILL PRODUCE UNPREDICTABLE RESULTS.<\/p>\n\n<!--section=installation-->\n<h4>Minimum requirements<\/h4>\n\n<ul>\n<li>PHP 7.3 or newer<\/li>\n<\/ul>\n\n<p>Calculated fields will for ACF run on PHP 5.6 or newer, but we highly recommend following the official <a href=\"https:\/\/wordpress.org\/about\/requirements\/\">WordPress guidelines<\/a> that currently recommends PHP 7.3.<\/p>\n\n<h4>Install from within WordPress<\/h4>\n\n<ul>\n<li>Visit the plugins page within your dashboard and select \u2018Add New\u2019<\/li>\n<li>Search for \u2018Calculated Fields for ACF\u2019<\/li>\n<li>Click 'Install' and wait until the button caption changes to 'Activate'<\/li>\n<li>Click 'Activate'<\/li>\n<\/ul>\n\n<h4>Install manually<\/h4>\n\n<ul>\n<li>Download the zip file<\/li>\n<li>Upload the calculated-fields-for-acf folder from the zip to the \/wp-content\/plugins\/ directory on your server<\/li>\n<li>Navigate to the Plugins page in WordPress admin and locate the plugin\nClick 'Activate'<\/li>\n<\/ul>\n\n<!--section=changelog-->\n<h4>1.3.2<\/h4>\n\n<ul>\n<li>Fix Improves input sanitation and output escaping<\/li>\n<\/ul>\n\n<h4>1.3.0<\/h4>\n\n<ul>\n<li>Feature: Support for formatting numeric output using PHP sprintf syntax<\/li>\n<li>Feature: Optionally let formula return empty string instead of zero<\/li>\n<li>Fix \"empty needle\" bug that emits PHP warning messages to the error log in certain field groups<\/li>\n<\/ul>\n\n<h4>1.2.4<\/h4>\n\n<ul>\n<li>Fixes problem with calculations of fields inside a group<\/li>\n<\/ul>\n\n<h4>1.2.3<\/h4>\n\n<ul>\n<li>Fixes problem with calculations not working in front end forms created with acf_form()<\/li>\n<\/ul>\n\n<h4>1.2.2<\/h4>\n\n<ul>\n<li>Fixes issue with operator == always returning false<\/li>\n<\/ul>\n\n<h4>1.2.1<\/h4>\n\n<ul>\n<li>Adds support for conditional operators &gt;=, &lt;=<\/li>\n<\/ul>\n\n<h4>1.2.0<\/h4>\n\n<ul>\n<li>Adds support for conditional operators ==, !=, &gt; and &lt;<\/li>\n<li>Adds support for rounding functions floor, ceil and round<\/li>\n<\/ul>\n\n<h4>1.1.3<\/h4>\n\n<ul>\n<li>Fixes issue with ajax recalculation not triggered by removing a row from a repeater field<\/li>\n<li>Fixes issue with ajax recalculation not triggered by changing a dropdown\/select field<\/li>\n<li>Fixes multiple issues related to ACF Blocks. Should work as expected now, but we're considering support for ACF blocks \"beta\" for now<\/li>\n<\/ul>\n\n<h4>1.1.1<\/h4>\n\n<ul>\n<li>Fixes typo in javascript file that causes more ajax recalculations that needed<\/li>\n<li>Fixes issue with some PHP versions and empty object keys (https:\/\/bugs.php.net\/bug.php?id=46600)<\/li>\n<li>Fixes issue with ACF enumerating rows using alphanumeric keys in some cases (older versions)<\/li>\n<\/ul>\n\n<h4>1.1.0<\/h4>\n\n<ul>\n<li>Adds in-edit recalculations. Calculated fields are updated while still in edit mode<\/li>\n<li>Adds read only option. All fields can be set as read only in the ACF field editor (not just calculated fields)<\/li>\n<li>Adds parent. prefix for formulas in sub fields in a repeater field.<\/li>\n<\/ul>\n\n<h4>1.0.1<\/h4>\n\n<ul>\n<li>Fixes issue with complex custom fields types that can't be converted to string\/numeric<\/li>\n<\/ul>","raw_excerpt":"Simple field math for Advanced Custom Fields.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/gu.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/114101","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gu.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/gu.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/gu.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=114101"}],"author":[{"embeddable":true,"href":"https:\/\/gu.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/wundermatics"}],"wp:attachment":[{"href":"https:\/\/gu.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=114101"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/gu.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=114101"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/gu.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=114101"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/gu.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=114101"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/gu.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=114101"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/gu.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=114101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}