回复可见
直接丢代码,在 functions.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 | function reply_to_read($atts, $content=null) { extract(shortcode_atts(array("notice" => '<p class="reply-to-read">温馨提示: 此处内容需要<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'); function reply_tags($mce_settings) { ?> <script type="text/javascript"> QTags.addButton( '回复可见', '回复可见', '[reply]', '[/reply]' ); function shortcode() { } </script> <?php } add_action('after_wp_tiny_mce', 'reply_tags'); |
短代码
编写文章的时候添加短代码就可以实现回复可见的功能了
1 2 3 | //两种方法都可以 [reply]回复可见的内容[/reply] [reply notice="自定义的提示信息"]回复可见的内容[/reply] |
回复可见效果
密码可见
直接丢代码,在 functions.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 | function e_secret($atts, $content=null){ extract(shortcode_atts(array('key'=>null), $atts)); if(isset($_POST['e_secret_key']) && $_POST['e_secret_key']==$key){ return ' <div class="e-secret">'.$content.'</div> '; } else{ return ' <form action="'.get_permalink().'" method="post" name="e-secret" ><p>输入密码查看内容:</p><p><label for="pwbox-26">密码:<input type="password" name="e_secret_key" id="pwbox-26" size="20"></label><input type="submit" value="确定"></p> <div class="euc-clear"></div> </form> '; } } add_shortcode('secret','e_secret'); function mmkj_tags($mce_settings) { ?> <script type="text/javascript"> QTags.addButton( '密码可见', '密码可见', '[secret key="1235"]', '[/secret]' );//密码可修改 function shortcode() { } </script> <?php } add_action('after_wp_tiny_mce', 'mmkj_tags'); |
短代码
编写文章的时候添加短代码就可以实现密码可见的功能了
1 | [secret key="密码"]加密内容[/secret] |
密码可见效果
测试密码:1235