Have you ever wanted to calculate some values dynamically to display in your posts?
您是否曾经想过动态计算一些值以显示在帖子中?
Let’s say you have some shortcodes that retrieve values in real time from the database.
假设您有一些短代码可以从数据库中实时检索值。
Now you want to perform some calculations on those shortcodes and display the results in your posts or pages.
现在,您要对这些短代码执行一些计算,并将结果显示在您的帖子或页面中。
This plugin allows you to use a simple [calculate] shortcode with the expression inside to display these values in real time!
此插件可让您使用带有内部表达式的简单[计算]短代码实时显示这些值! p>
So an expression like [calculate]2+3*4[/calculate] will return the value “14”.
因此,像[计算] 2 + 3 * 4 [/ calculate]这样的表达式将返回值“ 14”。
Now just replace any numeric value with a shortcode that returns a number and you’re set.
现在,只需将任何数字值替换为返回数字的简码即可,就可以设置好了。 p>
Attributes
属性 h3>
You can use the “dec” attribute to specify the number of decimal digits you want to round the result up to.
您可以使用“ dec”属性来指定要舍入到结果的小数位数。
The default is “0”.
默认值为“ 0”。
Meaning that by default, all results will be rounded to an integer.
这意味着默认情况下,所有结果都将四舍五入为整数。 p>
For international number formatting, you can use the “int” attribute to specify a locale.
对于国际数字格式设置,可以使用“ int”属性来指定语言环境。
For example, int=”fr_FR” will format the numbers according to the french locale!
例如,int =” fr_FR”将根据法语区域设置数字格式! p>
See screenshots for illustrations.
请参阅屏幕截图以获取插图。 p>
For example, you can use this to display values in a table that are constantly changing.
例如,您可以使用它来显示表格中不断变化的值。
Or refer to dynamic prices multiplied by some value.
或参考动态价格乘以某个值。
The possibilities are endless.
可能性是无限的。 p>
You can see a real world example of this plugin at work here:
“ rel =” nofollow“>此处: p>
The best part is, it doesn’t use dangerous functions like “eval” to work – which means all authors can use it safely.
最好的部分是,它不会使用“ eval”之类的危险功能,这意味着所有作者都可以安全地使用它。
There’s no danger of it breaking your site.
它不会破坏您的网站。 p>