function reply_to_read($atts, $content=null) {
extract(shortcode_atts(array("notice" => '<p>温馨提示: 此处内容需要<a href="#respond" title="评论本文">评论本文</a>后才能查看.</p>'), $atts));
$email = null;
$user_ID = (int) wp_get_current_user()->ID;
if ($user_ID > 0) {
$email = get_userdata($user_ID)->user_email;
//对博主直接显示内容
$admin_email = "xxx@aaa.com"; //博主 Email
if ($email == $admin_email) {
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('reply', 'reply_to_read');
将代码里的博主邮箱替换成自己的;
编写文章的时候添加短代码
[@reply]评论可见的内容[@/reply]
使用的时候把@去掉!
每当我们写文章的时候,都需要手动给 WordPress 文章添加标签,这样既能给访问者明确这篇文章的…
适用WordPress、Typecho、ZBlog、Emlog、多说等平台的评论神器 javascr…
登陆数据库,然后执行 sql 命令: UPDATE Wp_links SET link_target…
共有0条评论
评论本文