WordPress免插件开启公众号回复验证码查看隐藏内容功能 提供两个CSS样式
一直想找一款微信公众号回复验证码的插件,奈何 wechat-fans 插件不够人性化,只能设置一个验证码,所以就整合了一些大佬的文章,得出以下代码。
嫌麻烦的可以用插件,参考《Wordpress公众号涨粉插件 隐藏关键内容 关注公众号获取验证码可见被隐藏内容》
WordPress免插件开启公众号回复验证码查看隐藏内容功能
在 functions.php 文件中加入以下代码 这个代码必须用 UTF-8-BOM 编码格式 修改中文,不然直接用主题编辑器修改会错位!!
/**
* WordPress文章部分内容关注微信公众号后可见
*/
function lxtx_secret_content($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="http://www.qq301.com/wp-content/uploads/oss/2019/09/7184682e2810cd0.jpg" width="150" height="150" alt="源码资源客"><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>”,获取验证码。</div>
<div>【注】用手机微信扫描右侧二维码都可以关注“源码资源客”官方微信公众号。</div>
</div>';
}
}
add_shortcode('gzh2v', 'lxtx_secret_content');
// 为了方便使用,在后台文本编辑器中集成该短代码。将以下代码放入 functions.php 中即可:
function lxtx_wpsites_add_gzh_quicktags() {
if (wp_script_is('quicktags')){
?>
<script type="text/javascript">
QTags.addButton( 'gzh2v', ' 公众号隐藏', '\n【gzh2v keyword="关键字" key="验证码"]隐藏内容[/gzh2v】', "" );
// 实际使用请把 上一行的【】改为[]
</script>
<?php
}
}
add_action( 'admin_print_footer_scripts', 'lxtx_wpsites_add_gzh_quicktags' );
CSS样式文件修改
将下面的代码添加到主题的 style.css 文件中去即可,如果放进 style.css 里边无效的话,可以放进 外观——自定义——额外css 里边
第一款:
css代码如下:
/* 网站添加公众号涨粉功能样式代码 */
/*资源客,http://www.qq301.com/,转载说明出处,谢谢*/
.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:#f0503c;
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;
padding: 5px;
background-color: #fff;
border: 1px solid #24b4f0;
border-radius: 5px;
font-size: 12px;
margin: 0px 5px;
-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: 5px;
width: 88px;
color: #fff;
border-radius: 5px;
font-size: 16px;
font-weight:bold;
}
.details{
color:#123456;
font-size: 16px;
line-height: 30px;
margin: 5px;
padding: 3px;
}
.post_hide_box .details span{color:#e74c3c;}
第二款:
css代码如下:
.post_hide_box, .secret-password {
background: none repeat scroll 0 0 #efe;
border-left: 5px solid #e74c3c;
color: #555;
padding: 10px 0 10px 10px;
border-radius: 5px;
margin-bottom: 15px;
overflow: hidden;
clear: both;
}
.post_hide_box .post-secret {
font-size: 18px;
line-height: 20px;
color: #e74c3c;
margin: 5px;
}
.post_hide_box form {
margin: 15px 0;
}
.post_hide_box form span {
font-size: 18px;
font-weight: 700;
}
.post_hide_box .erweima {
margin-left: 20px;
margin-right: 16px;
}
.post_hide_box input[type=password] {
color: #9ba1a8;
padding: 6px;
background-color: #f6f6f6;
border: 1px solid #e4e6e8;
font-size: 12px;
-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: #F88C00;
border: none;
border: 2px solid;
border-color: #F88C00;
border-left: none;
border-top: none;
padding: 0px;
width: 100px;
height: 38px;
color: #fff;
outline: 0;
border-radius: 0 0 2px 0;
font-size: 16px;
}
.post_hide_box .details span {
color: #e74c3c;
}
之后再写文章时,文本——点击公众号隐藏 按钮,将信息修改就行了
http://xzh.i3geek.com1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,请不要用于商业用途及非法用途,否则后果自负!
3. 如果你也有好源码或者教程,可以到审核区发布,分享有金币奖励和额外收入!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 如遇到加密压缩包,默认解压密码为"qq301.com",如遇到无法解压的请联系管理员!
资源客是一个优秀的分享资源站,本站资源均为各位友友分享而来,特殊原创会标明如有侵犯版权等可联系删除
资源客 » WordPress免插件开启公众号回复验证码查看隐藏内容功能 提供两个CSS样式
资源客 » WordPress免插件开启公众号回复验证码查看隐藏内容功能 提供两个CSS样式