热门 Wordpress

WordPress免插件开启公众号回复验证码查看隐藏内容功能 提供两个CSS样式

WordPress免插件开启公众号回复验证码查看隐藏内容功能 提供两个CSS样式

一直想找一款微信公众号回复验证码的插件,奈何 wechat-fans 插件不够人性化,只能设置一个验证码,所以就整合了一些大佬的文章,得出以下代码。

在 functions.php 文件中加入以下代码      这个代码必须用 UTF-8-BOM 编码格式(因为有中文),不然直接用主题编辑器修改会错位!!

// WordPress免插件开启公众号涨粉(验证码查看隐藏内容)功能function secret($atts, $content=null){ extract(shortcode_atts(array('key'=>null,'keyword'=>null), $atts)); if(isset($_POST['secret_key']) && $_POST['secret_key']==$key){ return '<div class="secret-password">'.$content.'</div>'; }else { return ' <div class="post_hide_box"> <img class="erweima" align="right" src="https://www.5v13.com/wp-content/uploads/2020/08/1597807861-6bdcdcab801e009.webp" alt="微信公众号:走客" style=" width: 380px; margin-top: 20px;"><div class="post-secret"><i class="fa fa-exclamation-circle"></i>此处内容已经被隐藏,请输入验证码查看内容</div> <form action="'.get_permalink().'" method="post"> <span>验证码:</span><input id="pwbox" type="password" size="20" name="secret_key"> <a class="a2" href="javascript:;"><input type="submit" value="提交" name="Submit"></a> </form> <div class="details">请关注“走客”官方公众号,回复关键字“<span>'.$keyword.'</span>”,获取验证码。<br /> <span>【注】</span>手机扫描二维码快速关注“走客”微信公众号。 </div> </div>'; }}add_shortcode('ghide', 'secret');// 文章文本编辑器添加自定义按钮,免得每次都要输入短代码。function appthemes_add_quicktags() {?><script type="text/javascript">QTags.addButton( '公众号隐藏', '公众号隐藏', '[ghide keyword="微信验证码" key="163163"]','[/ghide]' ); //实际使用时这里的【】都改成[]</script><?php}add_action('admin_print_footer_scripts', 'appthemes_add_quicktags' );

CSS样式文件修改

将下面的代码添加到主题的 style.css 文件中去即可,如果放进 style.css 里边无效的话,可以放进 外观——自定义——额外css  里边

.post_hide_box, .secret-password{background: none repeat scroll 0 0 #fcffff;border: 1px dashed #24b4f0;color: #123456;padding: 10px;border-radius: 9px;margin: 18px 0px;overflow:hidden;clear:both;}.post_hide_box .post-secret{font-size: 18px;line-height:20px;color:#24b4f0;margin:5px;}.post_hide_box form{ margin:15px 5px;}.post_hide_box form span{ font-size:18px; font-weight:bold;}.post_hide_box .erweima{ margin: 15px;}.post_hide_box input[type=password]{color: #00a0f0;background-color: #fff;border: 1px solid #24b4f0;border-radius: 4px;font-size: 12px;margin: 0px 5px;width: 200px;-moz-transition: border .25s linear,color .25s linear,background-color .25s linear;-webkit-transition: border .25s linear,color .25s linear,background-color .25s linear; -o-transition: border .25s linear,color .25s linear,background-color .25s linear;transition: border .25s linear,color .25s linear,background-color .25s linear;}.post_hide_box input[type=submit] { background: #24b4f0; border: none; padding: 12px; width: 88px; color: #fff; border-radius: 5px; font-size: 16px; font-weight: bold;}.details{color:#123456; font-size: 13px;line-height: 30px;margin: 5px;padding: 3px;}.post_hide_box .details span{color:#e74c3c;}

 

 

声明:本站所有软件资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。
Mac软件

Longshot 1.4.2 激活版/ macOS轻量截图工具

2025-3-8 8:04:23

Mac软件

iReal Pro for Mac v2025.10.1 激活版 优秀的音乐练习参考工具

2025-11-8 8:24:11

0 条回复A文章作者M管理员
    暂无讨论,说说你的看法吧
个人中心
今日签到
有新私信 私信列表
搜索