【发布时间】:2020-02-25 19:41:33
【问题描述】:
我在 WordPress 插件中遇到过这样的情况 -
这是插件的父类-
class parent_class {
public function __construct() {
$this->initiate();
}
public static function init() {
$instance = new parent_class ();
return $instance;
}
public function initiate() {
new child_class();
}
}
子类在另一个文件中定义-
class child_class {
public function __construct() {
add_action( 'action_from_other_plugin', array( $this, 'function_i_want_to_remove' ), 32 );
}
}
现在,我的目标是 remove_action 像这样的动作 -
remove_action( 'action_from_other_plugin', array( child_class::init(), 'function_i_want_to_remove' ), 3200 );
不幸的是,它给出了一个未定义函数的错误。在这种情况下我缺少什么?
【问题讨论】:
标签: php wordpress class object