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')){?>


分享到:


相關文章: