修复RiPro-V2主题评论后可见内容功能
前言说明
在使用RiPro-V2主题的过程中,发现在发布文章时使用“评论后可见内容”组件后,除了管理员,一般用户评论回复了也无法查看内容,这个BUG我也反馈了油条,不知道他后期会不会修复,这里我先除个修复教程吧,因为这个BUG还是挺严重的。

修复教程
1.打开“/wp-content/themes/ripro-v2/inc/options/shortcode-options.php”文件,搜索“评论可见”,将如下代码:
//评论可见
function ripro_reply_hide_shortcode($atts, $content = '') {
$notice = '<div class="card text-center border-danger mb-4"><div class="card-body"> <h5 class="card-title">' . __('***此处内容评论后可见***', 'ripro-v2') . '</h5> <p class="card-text"><small class="text-muted">' . esc_html__('温馨提示:此处为隐藏内容,需要评论或回复留言后可见', 'ripro-v2') . '</small></p> <a href="#respond" class="btn btn-secondary btn-sm"><i class="fa fa-comments-o"></i> ' . esc_html__('评论查看', 'ripro-v2') . '</a> </div> </div>';
$content = '<div class="card border-shortcode mb-4"><div class="card-body">' . do_shortcode($content) . '</div></div>';
$user_id = is_user_logged_in() ? get_current_user_id() : 0;
$email = null;
if ($user_id > 0) {
$user = get_userdata($user_id);
$email = $user->user_email;
//管理员直接可见
// if (!empty($user->roles) && in_array('administrator', $user->roles)) {
// return $content;
// }
} else if (isset($_COOKIE['comment_author_email_' . COOKIEHASH])) {
$email = str_replace('%40', '@', $_COOKIE['comment_author_email_' . COOKIEHASH]);
} else {
return $notice;
}
if (empty($email)) {
return $notice;
}
global $wpdb;
$post_id = get_the_ID();
$query = "SELECT `comment_ID` FROM {$wpdb->comments} WHERE `comment_post_ID`={$post_id} and `comment_approved`='1' and `comment_author_email`='{$email}' LIMIT 1";
if ($wpdb->get_results($query)) {
return do_shortcode($content);
} else {
return $notice;
}
}
add_shortcode('ri-reply-hide', 'ripro_reply_hide_shortcode');
2.把上述代码替换为如下代码,并把管理员邮箱改为自己的,这样使用评论后可见内容功能的文章管理员就可以直接显示了!
隐藏内容
此处内容需要权限查看
会员免费查看公告: 本站提供的源码、模板、插件等等其他资源,除资源本身问题外,都不包含免费技术服务,如需技术支持需支付100+技术服务费一次,具体依客服说明为准,请大家谅解!
说明: 本站资源解压密码见“常见问题”,一般都为“www.360mb.net”!
申明: 模板吧提供资源仅供学习用途,禁止用于搭建非法网站,本站不为涉黄、涉毒、涉赌等不法分子提供任何技术便利。
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
说明: 本站资源解压密码见“常见问题”,一般都为“www.360mb.net”!
申明: 模板吧提供资源仅供学习用途,禁止用于搭建非法网站,本站不为涉黄、涉毒、涉赌等不法分子提供任何技术便利。
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。