【发布时间】:2015-02-04 10:40:46
【问题描述】:
我认为问题是有太多人试图回答一个问题,比如这里https://wordpress.stackexchange.com/questions/48085/add-action-reference-a-class
就我而言,我在主题模板中使用了 do_action
哪个最好....
class mytheme_do_header_content{
public function __construct() {
add_action( 'mytheme_do_header', array( $this, 'mytheme_do_header_content_make' ) );
}
function mytheme_do_header_content_make(){
//some code goes here
}
public function __destruct() {
}
}
new mytheme_do_header_content();
或者这个
class mytheme_do_header_content{
public function __construct() {
//some code goes here
}
public function __destruct() {
}
}
add_action( 'mytheme_do_header', array( $this, 'mytheme_do_header_content_make' ) );
或者其他什么,比如根本不用上课?
谢谢
【问题讨论】: