有以下两中接口形式,第一种:
navbar(); ?>
可以通过navbar = array('插件名称', '方法名称')来实现,例如:
typecho_plugin::factory('admin/menu.php')->navbar = array('helloworld_plugin', 'render');
问题是typecho更多的是第二形式接口,该接口带有参数,例如:
// 完成发布插件接口 $this->pluginhandle()->finishpublish($contents, $this);
请问,第二种形式接口跟第一种有什么区别,插件中应该怎样去写?
回复内容: 有以下两中接口形式,第一种:
navbar(); ?>
可以通过navbar = array('插件名称', '方法名称')来实现,例如:
typecho_plugin::factory('admin/menu.php')->navbar = array('helloworld_plugin', 'render');
问题是typecho更多的是第二形式接口,该接口带有参数,例如:
// 完成发布插件接口 $this->pluginhandle()->finishpublish($contents, $this);
请问,第二种形式接口跟第一种有什么区别,插件中应该怎样去写?
使用方法与第一种类似,例如:
typecho_plugin::factory('widget_contents_post_edit')->finishpublish = array('helloworld_plugin', 'render');
第二种widget接口还可以传入参数,例如下面的$contents数组及widget_contents_post_edit对象
public static function render($contents, $edit){ #code...}
参考文档:http://docs.typecho.org/plugins/hooks