在 Z-BlogPHP 中读取文章对象的 CommentPostUrl 属性(评论表单的提交地址)时会触发 Filter_Plugin_Post_CommentPostUrl 接口,可以接管默认的 cmd.php?act=cmt 地址,把评论提交到自定义的处理脚本。
CommentPostUrl
Filter_Plugin_Post_CommentPostUrl
cmd.php?act=cmt
$post
下例把全站文章的评论提交地址改为插件自带的处理脚本:
<?php RegisterPlugin("demoAPP", "ActivePlugin_demoAPP"); function ActivePlugin_demoAPP() { Add_Filter_Plugin('Filter_Plugin_Post_CommentPostUrl', 'demoAPP_Post_CommentPostUrl', PLUGIN_EXITSIGNAL_RETURN); } function demoAPP_Post_CommentPostUrl($post) { global $zbp; return $zbp->host . 'zb_users/plugin/demoAPP/comment.php?postid=' . $post->ID; }
action
PLUGIN_EXITSIGNAL_RETURN
key
CommentPostKey
评论提交地址接口
在 Z-BlogPHP 中读取文章对象的
CommentPostUrl属性(评论表单的提交地址)时会触发Filter_Plugin_Post_CommentPostUrl接口,可以接管默认的cmd.php?act=cmt地址,把评论提交到自定义的处理脚本。接口信息
Filter_Plugin_Post_CommentPostUrl$post完整案例
下例把全站文章的评论提交地址改为插件自带的处理脚本:
注意事项
CommentPostUrl属性时,模板中评论表单的action一般输出的就是该属性。PLUGIN_EXITSIGNAL_RETURN信号无条件使用回调返回值,会完全替代默认地址;默认地址带有key参数(CommentPostKey)用于防垃圾提交,自定义地址需自行处理同等的安全校验。