Override Plugin Function in WordPress(覆盖 WordPress 中的插件功能)
问题描述
我的 WordPress 网站上安装了插件.
I have a Plugin installed on my WordPress site.
我想覆盖插件中的一个功能.我是否在我的主题的 functions.php
中覆盖它,如果是,我该怎么做?
I'd like to override a function within the Plugin. Do I override this in my theme's functions.php
and if so, how do I do this?
这是我插件中的原始函数:
Here's the original function in my plugin:
推荐答案
你不能真正覆盖"一个函数.如果定义了函数,则不能重新定义或更改它.您最好的选择是创建插件的副本并直接更改功能.当然,每次插件更新时,您都必须重复此操作.
You can't really "override" a function. If a function is defined, you can't redefine or change it. Your best option is to create a copy of the plugin and change the function directly. Of course you will have to repeat this everytime the plugin is updated.
给插件一个不同的名字以在插件列表中区分它们.禁用原件,启用您的副本.
Give the plugin a different name to distinguish them in the plugin listing. Disable the original, enable your copy.
这篇关于覆盖 WordPress 中的插件功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!