【发布时间】:2016-10-20 03:42:59
【问题描述】:
我想重写插件事件管理器的 EM_Tickets 类中的函数 get_post()
class EM_Tickets extends EM_Object implements Iterator{
/**
* Retrieve multiple ticket info via POST
* @return boolean
*/
function get_post(){
// something here
return apply_filters('em_tickets_get_post', count($this->errors) == 0, $this);
}
}
所以我创建了自己的插件并在下面添加了代码但没有运气,虽然我阅读并遵循了一些手册,例如 Is it possible to replace a function within a PHP class?
,但不知道为什么它不起作用class EM_Tickets_Child extends EM_Tickets implements Iterator{
public function get_post(){
file_put_contents('log.txt', 'in child class', FILE_APPEND | LOCK_EX);
//something here
}
}
【问题讨论】:
标签: php wordpress overriding