[wordpress插件] Calculate Values with Shortcodes用简码计算值

wordpress 插件 文章 2020-03-15 16:20 522 0 全屏看文

AI助手支持GPT4.0

评分
94
描述

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!

此插件可让您使用带有内部表达式的简单[计算]短代码实时显示这些值!

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.

现在,只需将任何数字值替换为返回数字的简码即可,就可以设置好了。

Attributes

属性

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.

这意味着默认情况下,所有结果都将四舍五入为整数。

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”将根据法语区域设置数字格式!

See screenshots for illustrations.

请参阅屏幕截图以获取插图。

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.

可能性是无限的。

You can see a real world example of this plugin at work here:

“ rel =” nofollow“>此处:

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.

它不会破坏您的网站。

安装步骤

    1. You can install the plugin from WordPress’s plugin repository.
    2. 您可以从WordPress的插件存储库中安装插件。

    3. Just click “Activate” to enable the shortcode.
    4. 只需单击“激活”即可启用简码。

    5. Or download the zipped file
    6. 或下载压缩文件

    7. Then go to Plugins -> Add New
    8. 然后转到插件->添加新

    9. Click “Upload Plugin” at the top of the screen
    10. 点击屏幕顶部的“上传插件”

    11. Use “Choose File” , select the zip file you just downloaded, and click “Install Now”
    12. 使用“选择文件”,选择您刚刚下载的zip文件,然后单击“立即安装”

    13. On the next screen, click “Activate”
    14. 在下一个屏幕上,单击“激活”

下载地址
https://downloads.wordpress.org/plugin/calculate-values-with-shortcodes.zip
-EOF-

AI助手支持GPT4.0