WordPress纯代码实现文章内容微信关注后获取验证码可见

WordPress纯代码实现文章内容微信关注后获取验证码可见

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

食用代码:

/**
* 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 '
'.$content.'
';} else {return'

你的二维码名字
此处内容已经被作者无情的隐藏,请输入验证码查看内容


请关注“你的名字”官方QQ公众号,回复关键字“'.$keyword.'”,获取验证码。【注】用手机QQ扫描右侧二维码都可以关注“你的名字”官方QQ公众号。

';}}add_shortcode('gzh2v', 'lxtx_secret_content');* WinGup (for Notepad++) v5.0.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;}

方便短码

// 为了方便使用,在后台文本编辑器中集成该短代码。将以下代码放入 functions.php 中即可:function lxtx_wpsites_add_gzh_quicktags() {if (wp_script_is('quicktags')){?>


分享到:


相關文章: