wordpress无需插件实现回复评论可见

添加以下代码到functions.php。


//回复可见
function reply_to_read($atts, $content=null) {
        extract(shortcode_atts(array("notice" => '<p class="vihide reply-to-read ">隐藏内容<b class="xiaoy a"><a href="#respond" title="需要评论">需要评论</a></b>并刷新,才能查看.</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 = "xxxxxx@qq.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');
// 添加编辑器按钮 - 回复可见
function reply_view_tags($mce_settings) {
?>
<script type="text/javascript">
QTags.addButton( 'qiuzhuti_reply_view', '回复可见', '[reply]', '[/reply]' );
</script>
<?php
}
add_action('after_wp_tiny_mce', 'reply_view_tags');


[tip type="tip success" ]

古腾堡编辑器需要通过短代码添加[reply]隐藏内容[/reply]实现。

[/tip]

WordPress

wordpress无需代码实现视频播放和支持m3u8

2020-3-11 22:36:42

WordPress

WordPress部署H5播放器,支持m3u8/MP4/WebM和Ogg格式

2020-3-13 15:45:12

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧