WordPress纯代码免插件开启公众号回复验证码查看隐藏内容功能 (提供两种样式代码)

释放双眼,带上耳机,听听看~!

实现简介

顾名思义,关注公众号并回复关键字获取验证码后,才能查看到文章中的隐藏内容,这个功能比较适合有价值的内容文章和有推广微信公众号的站长!

这里提供两种样式给大家

 

第一种样式

这里以微信公众号为例(QQ公众号应该也是这样),在微信公众号的“自动回复-关键字自动回复”中设置好关键字(对应上面代码中的keyword)及验证码(对应上面代码中的key)。

c7a7e4e55962308081db5814d1a2ebf5

1.代码

/**
 
     * 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=“改为二维码图片的网址” 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”>请关注“你的名字”官方QQ公众号,回复关键字“<span>’.$keyword.'</span>”,获取验证码。【注】用手机QQ扫描右侧二维码都可以关注“你的名字”官方QQ公众号。</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’ );  

2.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;  
}  

3.使用方法

在文章中插入以下简码,修改相关内容即可:

[gzh2v keyword=“关键字” key=“验证码”]隐藏内容[/gzh2v]  

 

第二种样式

b9003b9b39e1737c34363e71df9b05e5

1.代码

// 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.png" 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="验证码"]','[/ghide]' );
</script>
<?php
}
add_action('admin_print_footer_scripts', 'appthemes_add_quicktags' );

2.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;}

 

3.使用方法

在文章中插入以下简码,修改相关内容即可:

[ghide keyword=“关键字” key=“验证码”]隐藏内容[/ghide]  

 

温馨提示:本文最后更新于 2022-12-11 01:48 ,某些文章具有时效性,若有错误或已失效,请在下方留言或联系逆念

给TA打赏
共{{data.count}}人
人已打赏
网络技术

wordpress菜单栏添加Iconfont-阿里巴巴矢量图标库

2022-4-14 18:53:43

网络技术

一个可以摧毁任意网页的Javascript小游戏

2022-4-14 19:07:27

重要声明

本站资源大多来自网络,如有侵犯你的权益请联系管理员,QQ508044570 我们会第一时间进行审核删除。站内资源为网友个人学习或测试研究使用,未经原版权作者许可,禁止用于任何商业途径!请在下载24小时内删除!


如果遇到付费才可观看的文章,建议升级终身VIP。全站所有资源任意下免费看”。本站资源少部分采用7z压缩,为防止有人压缩软件不支持7z格式,7z解压,建议下载7-zip,zip、rar解压,建议下载WinRAR

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