【子比小功能】评论区添加私密功能

【子比小功能】评论区添加私密功能

功能简介

  1. 一级私密评论(用户A发)
    可见:文章作者、用户A、网站管理员
    其他人:只显示
    此条评论仅作者与评论相关用户可见

  2. 私密回复(A 与 B)
    可见:文章作者、网站管理员、用户A、用户B
    其他人:同样只显示提示文案

  3. 样式美化

    • 私密按钮增加了小锁图标
    • 可见的私密评论标签也增加小锁图标
    • 不可见时提示前也带小锁“私密”标识
  4. 后台 评论 列表现在会多一个:

    • 私密状态

    效果:

    • 私密评论:显示带小锁的 私密 标签
    • 普通评论:显示 
  5. . 后台评论列表支持按“私密评论”筛选

    我在后台评论页加了一个筛选下拉:

    • 全部评论
    • 仅私密评论
    • 仅普通评论

    进入 WordPress 后台 评论 页面就能看到。

  6. 增加对论坛帖子页面的评论区支持。

功能实现

主题添加对应的钩子

一共有两个地方需要修改:

  1. zibll\template\comments.php
  2. zibll\inc\functions\bbs\inc\comment.php
do_action('zib_comment_tools_left', $post_id, $user_id);

image

/**
 * @description: 获取回复模块编辑器扩展按钮
 * @param {*}
 * @return {*}
 */
function zib_bbs_get_respond_btns()
{
    global $post;

    $html = '';
    ob_start();
    do_action('zib_comment_tools_left', $post->ID, get_current_user_id());
    $html .= (string) ob_get_clean();
    if (_pz('bbs_comment_smilie', true)) {
        $html .= zib_get_input_expand_but('smilie');
    }
    if (_pz('bbs_comment_code', true)) {
        $html .= zib_get_input_expand_but('code');
    }
    if (_pz('bbs_comment_img', true)) {
        $html .= zib_get_input_expand_but('image', _pz('bbs_comment_upload_img', false), 'comment');
    }
    if (_pz('bbs_comment_quick_s', true)) {
        $html .= zib_get_input_expand_but('quick', _pz('bbs_comment_quick_often'), 'comment');
    }
    return $html;
}

这一块代码直接替换掉

image

上传插件

最后效果

image

更新日志:

1.6.1:优化了移动端布局。

© 版权声明
THE END
喜欢就支持一下吧
点赞11 分享
评论 共3条

请登录后发表评论