如何删除使用当前对象 $this 的 WordPress 操作? [英] How to remove a WordPress action which uses the current object - $this?
本文介绍了如何删除使用当前对象 $this 的 WordPress 操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 WordPress 中删除操作时,我熟悉 remove_action
.
I'm familiar with remove_action
when removing an action in WordPress.
创建动作:add_action( 'action_hook', 'function_name', 10, 3 );
要删除操作:remove_action('action_hook', 'function_name', 10, 3);
但是如何删除使用当前对象的操作?例如 $this
But how can I remove an action which uses the current object? e.g $this
add_action( 'some_action_hook', array( $this, 'some_function' ) );
参考:
http://codex.wordpress.org/Function_Reference/add_action
http://codex.wordpress.org/Function_Reference/remove_action
推荐答案
Inside class
add_action( 'some_action_hook', array( $this, 'some_function' ) );
课外,
使用全局变量:
global $my_class;
remove_action( 'some_action_hook', array( $my_class, 'some_function' ) );
使用类名:
remove_action( 'some_action_hook', array( 'MyClass', 'some_function' ) );
参考.
这篇关于如何删除使用当前对象 $this 的 WordPress 操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文