[wordpress插件] Custom Global Variables自定义全局变量

wordpress 插件 文章 2020-04-08 09:00 886 0 全屏看文

AI助手支持GPT4.0

评分
100
描述

Create your own custom variables to manage information on your website such as:

创建自己的自定义变量来管理您网站上的信息,例如:

    • Phone numbers
    • 电话号码

    • Addresses
    • 地址

    • Social media links
    • 社交媒体链接

    • HTML snippets
    • HTML片段

    • And anything else
    • 还有其他

    Easily access them globally in WordPress and PHP.

    在WordPress和PHP中轻松地全局访问它们。

    Why you need it

    为什么需要它

    Rather than having to change something like an email address across multiple pages, you can do it in one place.

    您不必在多个页面上更改电子邮件地址之类的东西,而是可以在一个地方进行。

    Avoid the pitfalls of hard coding information in your WordPress theme that is likely to change.

    避免可能会更改WordPress主题中的硬编码信息的陷阱。

    Why it’s better

    为什么更好

      • Your variables are stored and retrieved locally without any calls to the database.

      • 您的变量在本地存储和检索,而无需任何对数据库的调用。

        That means faster load times for your pages!

      • 这意味着页面加载速度更快!

      • Variables can be accessed easily in PHP from the global scope.
      • 可以在PHP中轻松地从全局范围访问变量。

      Usage

      用法

      Display your variables using the shortcode syntax:

      使用简码语法显示变量:

      [cgv variable-name]

        [cgv变量名称]

      Or using the superglobal in PHP:

      或在PHP中使用超全局变量:

        <?php echo $ GLOBALS ['cgv'] ['variable-name']?>

安装步骤

    1. Upload the plugin files to the /wp-content/plugins/plugin-name directory, or install the plugin through the WordPress plugins screen directly.
    2. 将插件文件上传到 / wp-content / plugins / plugin-name 目录,或直接通过WordPress插件屏幕安装插件。

    3. Activate the plugin through the ‘Plugins’ screen in WordPress
    4. 通过WordPress中的“插件”屏幕激活插件

    5. Use the Settings -> Custom Global Variables screen to define your variables
    6. 使用 Settings-> Custom Global Variables 屏幕定义变量

下载地址
https://downloads.wordpress.org/plugin/custom-global-variables.zip
-EOF-

AI助手支持GPT4.0