您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
免费发信息

typecho 插件接口怎样使用?

2024/3/29 8:26:18发布4次查看
有以下两中接口形式,第一种:
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
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录