纯代码实现关注微信微信官方账号——WordPress美化后可以看到文章的一部分

当前位置: 首页 > 常见问题

感谢在绿野仙踪分享(转自绿野仙踪)。在分享之前,有这样一个WordPress插件。关注微信官方账号,回复关键词获取验证码后,就可以看到文章中隐藏的内容。一直没找到这个代码版本。前几天想起了这个功能,所以今天找了这个跟大家分享一下。

一、核心代码 将以下代码放入functions.php(具体效果请上门户):

/**  * 

WordPress

文章部分内容关注微信公众号后可见 &#; 龙笑天下  * http://www.ilxtx.com/view-contents-by-following-wechat-official-accounts.html  */ 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=&#;&#; height=&#;&#; 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=&#;&#; name=&#;secret_key&#;>  <a class=&#;a&#; href=&#;javascript:;&#;><input type=&#;submit&#; value=&#;提交&#; name=&#;Submit&#;></a>  </form>  <div class=&#;details&#;>请关注“你的名字”官方QQ公众号,回复关键字“<span>&#;.$keyword.'</span>”,获取验证码。【注】用手机QQ扫描右侧二维码都可以关注“你的名字”官方QQ公众号。</div>  </div>&#;;  } } add_shortcode(&#;gzhv&#;, &#;lxtx_secret_content&#;);

PS:注意修改代码中的相关内容!

关注微信微信官方账号& #后可以看到部分WordPress文章;笑看世界 * http://www . ilxtx . com/view-contents-by-following-微信-官方-accounts . html */[h/]functionlxtx _ secret _ content($ atts,$ content key & #;= & gtnull,& #;关键词& #;= & gtnull),$ atts)); if(isset($ _ POST[& #;secret _ key & #;])& amp;& amp$ _ POST[& #;secret _ key & #;]= = $ key){ return & #;& ltdiv class = & #;秘密密码& #;& gt&#;。$内容。& lt/div & gt;&#;; } else { return & #;& ltdiv class = & #;post _ hide _ box & #;& gt & lt;img class = & #;尔威马& #;align = & #;右& #;src = & #;换成二维码图片的网址& #;width = & #;&#;height = & #;&#;alt = & #;您的二维码名称& #;& gt& ltdiv class = & #;后密& #;& gt& ltI class = & #;fa fa-感叹号-圆圈& #;& gt& lt/I & gt;此处内容已被作者无情隐藏,请输入验证码查看内容

二、前端CSS style 把下面的代码放到你的主题的style.css文件中:

.post_hide_box, .secret-password{background: none repeat scroll   #efe;border-left: px solid #ecc;color: #;padding: px  px px;border-radius: px;margin-bottom: px;overflow:hidden; clear:both;} .post_hide_box .post-secret{font-size: px; line-height:px; color:#ecc; margin:px;} .post_hide_box form{ margin:px ;} .post_hide_box form span{ font-size:px; font-weight:;} .post_hide_box .erweima{ margin-left:px; margin-right:px;} .post_hide_box input[type=password]{ color: #baa; padding: px; background-color: #fff; border: px solid #eee; font-size: px;-moz-transition: border .s linear,color .s linear,background-color .s linear; -webkit-transition: border .s linear,color .s linear,background-color .s linear; -o-transition: border .s linear,color .s linear,background-color .s linear; transition: border .s linear,color .s linear,background-color .s linear;} .post_hide_box input[type=submit] { background: #FC; border: none; border: px solid;border-color: #FC; border-left: none; border-top: none; padding: px;width: px; height: px; color: #fff; outline: ;border-radius:   px ; font-size: px;} .post_hide_box .details span{color:#ecc;}

三。短代码的集成 为了方便,短代码集成在后台文本编辑器中。只需将以下代码放入functions.php中:

// 后台文本编辑框中添加公众号隐藏简码按钮 function lxtx_wpsites_add_gzh_quicktags() {     if (wp_script_is(&#;quicktags&#;)){ ?>     <script type=&#;text/javascript&#;>     QTags.addButton( &#;gzhv&#;, &#; 公众号隐藏&#;, &#;\n[gzhv keyword=&#;关键字&#; key=&#;验证码&#;]隐藏内容[/gzhv]&#;, &#;&#; );     </script> <?php     } } add_action( &#;admin_print_footer_scripts&#;, &#;lxtx_wpsites_add_gzh_quicktags&#; );

四。用法 。在文章中使用简短代码

插入以下代码并修改相关内容:

[gzhv keyword=&#;关键字&#; key=&#;验证码&#;]隐藏内容[/gzhv]

。微信微信官方账号

这里以微信微信官方账号为例(QQ微信官方账号也应该是这样的)。在微信微信官方账号的“关键词自动回复”中设置关键词(对应上述代码中的关键词)和验证码(对应上述代码中的密钥)。

动词 (verb的缩写)效果图

不及物动词扩展 其实这篇文章符合“回复后可以看到文章的一部分”或者“登录后可以看到文章的一部分”的常用代码原理,只不过是微信官方账号的组合而已。可以手动融入自己的主题!

这个函数先收集到这里。需要用吗?这个功能对微信官方账号吸粉有好处。

七。相关链接 查看隐藏内容必须关注微信微信官方账号——WordPress插件。

作者:徐州百都网络 | 来源: | 发布于:2022-03-20 01:09:24