修复留言板关于私密评论的bug
之前忘记在评论处增加判断了,现在修复一下(修改mo_comments_list.php这个文件):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
<?php /** * [mo_comments_list description] * @param [type] $comment [description] * @param [type] $args [description] * @param [type] $depth [description] * @return [type] [description] */ function mo_comments_list($comment, $args, $depth) { $GLOBALS['comment'] = $comment; global $commentcount, $wpdb, $post; if(!$commentcount) { //初始化楼层计数器 $page = get_query_var('cpage');//获取当前评论列表页码 $cpp = get_option('comments_per_page');//获取每页评论显示数量 $pcs = get_option('page_comments');//分页开关 $page=$page?$page:0; $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $post->ID AND comment_type = '' AND comment_approved = '1' AND !comment_parent"); $cnt = count($comments);//获取主评论总数量 if ( get_option('comment_order') === 'desc' ) { //倒序 if (!$pcs || ceil($cnt / $cpp) == 1 || ($page > 1 && $page == ceil($cnt / $cpp))) { $commentcount = $cnt + 1;//如果评论只有1页或者是最后一页,初始值为主评论总数 } else { $commentcount = $cpp * $page + 1; } }else{ //顺序 if( !$pcs ){ $commentcount = 0; }else{ $page = $page-1; $commentcount = $cpp * $page; } } } echo '<li '; comment_class(); echo ' id="comment-'.get_comment_ID().'">'; if(!$parent_id = $comment->comment_parent ) { echo '<span class="comt-f">#'. (get_option('comment_order') === 'desc'?--$commentcount:++$commentcount) .'</span>'; } echo '<div class="comt-avatar">'; echo _get_the_avatar($user_id=$comment->user_id, $user_email=$comment->comment_author_email); echo '</div>'; echo '<div class="comt-main" id="div-comment-'.get_comment_ID().'">'; // 检查是否为私密评论 $is_private = get_comment_meta($comment->comment_ID, '_private', true); $comment_ID = $comment->comment_ID; $parent_ID = $comment->comment_parent; $parent_email = get_comment_author_email($parent_ID); $is_private = get_comment_meta($comment_ID,'_private',true); $email = $comment->comment_author_email; //echo "parent_email:".$parent_email; $current_commenter = wp_get_current_commenter(); if ($is_private == 'true'){ if ($current_commenter['comment_author_email'] == $email || $parent_email == $current_commenter['comment_author_email'] || current_user_can('delete_user') ){ comment_text(); }else{echo '<span style="color:#A6A6A6"><i class="fa fa-lock fa-fw"></i>该评论为私密评论</span>';} } else { // 非私密评论,正常显示评论内容 comment_text(); if ($comment->comment_approved == '0'){ echo '<span class="comt-approved">待审核</span>'; } } // comment_text(); // if ($comment->comment_approved == '0'){ // echo '<span class="comt-approved">待审核</span>'; // } echo '<div class="comt-meta"><span class="comt-author">'.get_comment_author_link().'</span>'; get_author_class($comment->comment_author_email,$comment->user_id); if($comment->user_id == 1){echo "<a title='博主' class='vip'></a>";}; echo ' ';echo _get_time_ago($comment->comment_date); echo ' ';CID_print_comment_flag(); echo ' ';CID_print_comment_browser(); if ($comment->comment_approved !== '0'){ $replyText = get_comment_reply_link( array_merge( $args, array('add_below' => 'div-comment', 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); // echo str_replace(' href', ' href="javascript:;" data-href', $replyText ); if( strstr($replyText, 'reply-login') ){ echo preg_replace('# class="[\s\S]*?" href="[\s\S]*?"#', ' class="signin-loader" href="javascript:;"', $replyText ); }else{ echo preg_replace('# href=[\s\S]*? onclick=#', ' href="javascript:;" onclick=', $replyText ); } } echo '</div>'; echo '</div>'; } |
本文最后更新于2024年2月28日,已超过 1 年没有更新, […]
crossover中的D3DMetal DXVK ESync MSync什么意思?
CrossOver 是一款允许在 macOS、Linux 和 Chrome OS 上运行 Windows 应用程序的软件,它基于开源的 Wine 项目但提供了更多的特性和更好的用户支持。在 CrossOver 中,有几个关键技术和功能帮助提 […]
iOS15.7-16.1.2设备如何安装巨魔2?
之前介绍了如何安装巨魔2(TrollStore): 但是当时刚出来,还不是很完善,所以有很多问题,现在已经好几个月过去了,已经很成熟了~~下面我用iPhone13 iOS15.7系统进行测试,介绍下完整的流程: 需求: 运行 iOS/iPa […]
[开源项目] Typecho插件-PushDeer评论推送-Comment2PushDeer
写了一个利用PushDeer推送Typecho博客评论的插件。 目前开源在GitHub和Gitee: GitHub:https://github.com/ma3252788/Comment2PushDeer Gitee:https://gi […]
今天体验了一把比亚迪的取送车服务
车子该保养了,昨天刚回到学校,本来想送去保养的,结果4S店不上班,所以只能选择今天~ 本来约的是晚上7点的保养,不过估计这次我提的注意点比较多,所以时间不太够,客服问我能否白天去,可是白天事情实在太多,分身乏术,于是客服让我干脆约个取送车得 […]
Exception managing chrome: error sending request for url
今天在运行一个自动化脚本的时候,提示:
1 |
Exception managing chrome: error sending request for url (https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json): error trying to connect: Connection reset by peer (os error 54) |
这显然是selenium在访问*.github.io的时候出现了问题~ 解决方案: pip install selenium==4.5 […]
如何隐藏macOS下Dock栏中的某个图标?
主要是用于隐藏PushDeer,当然,该方法也适用于其他应用~ 步骤: 在访达的应用程序中找到待隐藏的程序–右键显示包内容,打开Contents/Info.plist文件,在这里加上两句话: <key>LSUIEle […]
Tun模式和系统代理的区别
有时候可能需要远程访问学校的资源,这时候就需要使用代理了,注意哈,这种是正规代理。下面介绍下代理软件中的两种代理模式区别: 代理软件中的TUN模式和系统代理是两种不同的网络流量转发机制,它们在实现上和适用场景上各有特点。下面是它们之间的一些 […]
群晖网速突然由1000M降为100M | 群晖如何重启网卡
今天发现群晖的网速突然由千兆变成百兆了,但是硬件没有动过,这种基本上可以确定是自动协商出现问题了~ 一个简单的解决方法是重启NAS,不过如果你有一些服务是不想重启的,那就需要另一种方法了。 重启网络服务: 先ssh连接NAS,然后输入: s […]
macOS下Tailscale如何通过命令行进行操作
通过安装包安装的Tailscale是无法直接使用命令行的,因为Tailscale的命令行工具没有被添加到系统的PATH环境变量中~ 所以在命令行中使用Tailscale的两种方式是: 第一种: /Applications/Tailscale […]