删除由Wordpress中的插件添加的操作 [英] Removing action added by a plugin in Wordpress
问题描述
我正在为Wordpress使用 Popup Maker 插件,但我试图阻止其加载在特定页面上使用子主题的functions.php文件.
I am using Popup Maker plugin for Wordpress and I am trying to prevent it to load on a particular page using the functions.php file of a child theme.
我在插件的目录中找到了文件popup-maker.php,该文件的末尾包含以下行:
I've located in the plugin's directory the file popup-maker.php which contains the following line at the end:
add_action( 'plugins_loaded', 'popmake_initialize', 0 );
如果我删除/注释此行,则不会触发弹出窗口,因此我想这是我需要删除的操作.我已经阅读了WP Codex和许多帖子,但仍然无法使它正常工作.
If I remove / comment this line, the popup will not fire, so I guess this is the action I need to remove. I have read the WP codex and numerous posts but still can't get it to work.
现在,我被这个问题困住了(我在子主题的functions.php文件中添加的函数):
Right now I am stuck at this (function I have added in my child theme's functions.php file):
function remove_popmaker() {
remove_action('plugins_loaded', 'popmake_initialize', 0);
}
add_action( 'init', 'remove_popmaker', 1 );
PS:我正在使用 shopkeeper 主题和Woocommerce.
PS: I am using shopkeeper theme and Woocommerce.
感谢所有帮助,谢谢.
推荐答案
您要将操作添加到 init
中,该操作在 plugins_loaded
之后,因此您无法在其后删除操作已经跑了.
you are adding a action to init
which is after plugins_loaded
so you cannot remove a action after it has run.
您可以尝试相同的操作,但是您必须通过插件执行此操作
you can try the same action but you will have to do this from a plugin
remove_action( 'plugins_loaded', 'remove_popmaker', 0 );
但是我怀疑在您的操作之前添加的操作将在之后运行,如果不是这样,您可能必须对MUplugin进行编码(这是Google的代码),这可能是无法预测的.
But i suspect actions added before yours will be run after, this may be unpredictable if not you may have to code a MUplugin (google this).
这篇关于删除由Wordpress中的插件添加的操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!