前言介紹
- 這款 WordPress 外掛「Calculated fields for ACF」是 2019-12-04 上架。
- 目前有 1000 個安裝啟用數。
- 上一次更新是 2022-02-02,距離現在已有 1187 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 4.7 以上版本才可以安裝。
- 外掛要求網站主機運作至少需要 PHP 版本 7.0 以上。
- 有 14 人給過評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
外掛標籤
內容簡介
Advanced Custom Fields的一個外掛,可添加公式欄位,可根據欄位值進行簡單的數學運算。在編輯後端文章編輯器以及前端表單上通過ajax動態更新計算。
要求
Calculated fields需要Advanced Custom Fields 5.0或更高版本,並與Pro版本以及標準版本兼容。
前端表單
從1.2.3版本開始,Calculated fields for ACF支持使用acf_form()函數(內置於Advanced Custom Fields)創建的前端表單。
公式
Calculated fields為ACF字段編輯器添加了一個新的設置“Formula”。公式支持使用字段名引用同一字段組中的其他字段。如果在重複字段內添加公式,則字段名引用同一重複字段內的另一個字段。
重複字段內的子字段還可以使用“parent. ”前綴引用父字段。
公式可以包含基本的數學運算:加(+)、減(-)、乘(*)、除(/)和次方(^)。公式還可以包含像 sin、cos、arcsin、log、ln、sqrt、abs 等函數。支持括號。
如果由於無效的語法或參考未定義的字段名而無法評估表達式,它將悄悄地返回零。
有效表達式示例(注意,開頭沒有等號):
fieldA * 2
fieldA * fieldB
abs(fieldA) * (2 + sqrt(fieldB))
amount * parent.price
條件運算符
表達式還可以包含條件式,將返回0或1。支持的運算符有:
等於 (==) - 當兩個值相等時返回1,否則返回0
不等於 (! =) - 當兩個值不相等時返回1,否則返回0
大於 (>) - 當第一個操作數大於第二個時返回1,否則返回0
大於等於 (> =) - 當第一個操作數大於或等於第二個時返回1,否則返回0
小於 (<) - 當第一個操作數小於第二個時返回1,否則返回0
小於等於 (< =) - 當第一個操作數小於或等於第二個時返回1,否則返回0
使用條件運算符的有效表達式示例:
10 == 10(返回1)
10 == 2(返回0)
10 > 2(返回1)
10 < 2(返回0)
10 <= 10(返回1)
四捨五入函數
將十進制值四捨五入到最近的整數。支持的函數有:
round() - 使用標準數學捨入規則四捨五入到最近的整數
ceil() - 將值捨入到下一個更高的整數
floor() - 將值捨入到下一個更低的整數
使用四捨五入函數的有效表達式示例:
round(10.2)(返回10)
round(10.9)(返回11)
round(10.888888 * 10) / 10(返回10.9)
ceil(10.2)(返回11)
floor(10.2)(返回10)
請注意,round() 函數只接受一個參數,並始終捨入為整數。如果您需要捨入到更高的精度,請像上面的第三個示例一樣進行乘法和除法。
群組字段
從1.2.4版本開始加入了群組字段(subfields),可以使用組名作為前綴並且可以使用“parent”前綴在該組內引用parent level的字段。請參閱
原文外掛簡介
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.
Requirements
Calculated fields requires Advanced Custom Fields 5.0 or later and works with Pro as well as the standard version.
Frontend forms
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).
Formulas
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.
A sub field inside a repeater field can also refer to a parent field using the “parent.”” prefix.
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.
If an expression can’t be evaluated due to invalid syntax or referring to undefined field names, it will silently return zero.
Examples of valid expressions (note, no equal sign at the beginning):
fieldA * 2
fieldA * fieldB
abs(fieldA) * (2 + sqrt(fieldB))
amount * parent.price
Conditional operators
An expression can also contain a conditional expression that will return either 0 or 1. The supported operators are:
Equals (==) – Returns 1 when two values are equal, 0 otherwise
Not equals (!=) – Returns 1 when two values are not equal, 0 otherwise
Greater than (>) – Returns 1 when the first operand is greater than the second, 0 otherwise
Greater than or equal (>=) – Returns 1 when the first operand is greater than or equal to the second, 0 otherwise
Less than ( 2 (returns 1)
10
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Calculated fields for ACF」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
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 | trunk |
延伸相關外掛(你可能也想知道)
Advanced Custom Fields (ACF®) 》Advanced Custom Fields 可以讓 WordPress 網站成為一個完整的內容管理系統,提供您所有工具以更好管理您的數據。, 使用 Advanced Custom Fields 外掛,完全...。
Advanced Custom Fields: Font Awesome Field 》在 Advanced Custom Fields 中添加一個Font Awesome 圖標字段類型。, , 指定要使用哪些 Font Awesome...。
ACF Content Analysis for Yoast SEO 》此外掛確保 Yoast SEO 分析包括所有 ACF 內容,包括彈性內容和重複器。, Yoast SEO for WordPress 內容和 SEO 分析不會考慮一篇文章的Advanced Custom Fields...。
Advanced Custom Fields: Extended 》🚀 全方位增強套件,可改進WordPress和Advanced Custom Fields。此外掛旨在提供一個強大的管理框架,涵蓋了眾多改進和優化。, 此外掛需要至少 ACF Pro 5.8。,...。
ACF Photo Gallery Field 》t; 'Status', , 'name' => 'status', , 'choices' => array(, 'public' => 'Public', , 'private' => ...。
Table Field Add-on for ACF and SCF 》表格欄位外掛程式增強了Advanced Custom Fields外掛程式的功能,讓表格編輯更易於使用。, 此外掛程式需要Advanced Custom Fields外掛程式或專業版!, 表格欄...。
Really Simple CSV Importer 》替代 CSV 導入外掛程式。簡單而強大,最適合於技術狂熱者。, , 類別支援, 標籤支援, 自訂欄位支援, Smart Custom Fields 支援, Custom Field Suite 支援, Adv...。
ACF to REST API 》此 WordPress 外掛在WordPress REST API中提供了Advanced Custom Fields的端點, 詳細資訊請參閱GitHub:https://github.com/airesvsg/acf-to-rest-api/。
ACF Quick Edit Fields 》這個 WordPress 外掛為 Advanced Custom Fields Plugin(Pro 和 Free 5+)增加了快速編輯功能。, 特色, , 在清單檢視中顯示 ACF 欄位值, 支援的 ACF 欄位類型...。
Advanced Custom Fields: Gravity Forms Add-on 》提供進階自訂欄位 (Advanced Custom Field),讓 WordPress 編輯使用者或管理員可以在欄位群組配置中選擇 Gravity Form。, 可以在 外掛的 GitHub 存儲庫 中找...。
Advanced Custom Fields: Image Aspect Ratio Crop Field 》這是一個進階自訂欄位 (Advanced Custom Fields) 的外掛,會在使用者上傳圖片後強制執行特定的長寬比例或像素大小裁剪。使用長寬比例對於回應式圖片的使用情...。
Advanced Custom Fields: Nav Menu Field 》使用 Nav Menu Field 外掛將導覽選單加入Advanced Custom Fields (ACF)。此外掛會在 ACF(版本 5 和 4)加入 Nav Menu 欄位類型,讓您從 WordPress 管理後台...。
ACF Theme Code for Advanced Custom Fields 》ACF Theme Code 外掛可以自動生成在主題中實現 Advanced Custom Fields 所需的程式碼。以下是該外掛的功能特色:, , - 縮短網站開發時間。, - 當您發布、編輯...。
ACF qTranslate 》此外掛提供 qTranslate-X 相容的 ACF4 和 ACF5PRO 欄位類型,包括文字、文字區域、所見即所得編輯器、影像和檔案。新增欄位至群組時,這些新的欄位類型將在欄...。
ACF Options For Polylang 》您使用了高級自訂欄位來建立選項頁面,並且安裝了 Polylang 外掛以獲得令人驚嘆的多語言網站嗎?, 可惜的是,Polylang 並不處理 ACF 的選項頁面。這意味著您...。