我在用toscho的Plugin Class Demo 代码作为我正在开发的插件的基础。除此之外,我的插件还注册了一个自定义的帖子类型。
public function plugin_setup() {
$this->plugin_url = plugins_url( \'/\', __FILE__ );
$this->plugin_path = plugin_dir_path( __FILE__ );
$this->load_language( \'myplugindomain\' );
// more stuff: register actions and filters
add_action( \'init\', array( \'MyPluginClass\', \'register_my_post_types\' ) );
}
public function register_my_post_types() {
$labels = array( ..... );
$args = array(
\'show_ui\' => true,
\'public\' => true,
\'labels\' => $labels,
\'supports\' => array(\'title\', \'editor\', \'thumbnail\'),
\'has_archive\' => true
);
register_post_type(\'mycustomtype\', $args);
}
我的问题是,钩住我的
register_my_post_types() 功能到
init 钩还是直接在
plugin_setup() 作用
提前感谢