WordPress文章内容部分加密输入密码可见

WordPress28181

WordPress文章如何部分加密?我们知道WordPress自带的文章密码保护功能是将文章的全部内容进行加密,那么如何将文章部分内容加密呢?用户可以看见部分内容,输入密码可以看见全部内容,解决方法:

WordPress自带密码保护

想要使用WordPress自带的密码保护功能,请参考:WordPress文章加密输入密码可见(密码保护)文章源自新手站长-https://xinshouzhanzhang.com/wpbufenjiami.html

文章部分加密解决方法

1、粘贴下列代码到你的WordPress主题目录下的functions.php中文章源自新手站长-https://xinshouzhanzhang.com/wpbufenjiami.html

//文章内容部分可见,输入密码可查看全部
function e_secret($atts, $content=null){
 extract(shortcode_atts(array('key'=>null), $atts));
 if(isset($_POST['e_secret_key']) && $_POST['e_secret_key']==$key){
 return '
<div class="e-secret">'.$content.'</div>
';
 }
 else{
 return '
<form class="e-secret" action="'.get_permalink().'" method="post" name="e-secret"><label>输入密码查看加密内容:</label><input type="password" name="e_secret_key" class="euc-y-i" maxlength="50"><input type="submit" class="euc-y-s" value="确定">
<div class="euc-clear"></div>
</form>
';
 }
}
add_shortcode('secret','e_secret');

2、复制样式到主题目录下的style.css中
可以自定义样式:文章源自新手站长-https://xinshouzhanzhang.com/wpbufenjiami.html

// 可修改下列CSS,自定义样式
.e-secret {
 margin: 20px 0;
 padding: 20px;
 background: #f8f8f8;
}
.e-secret input.euc-y-i[type="password"] {
 float: left;
 background: #fff;
 width: 100%;
 line-height: 36px;
 margin-top: 5px;
 border-radius: 3px;
}
.e-secret input.euc-y-s[type="submit"] {
 float: right;
 margin-top: -47px;
 width: 30%;
 margin-right: 1px;
 border-radius: 0 3px 3px 0;
}
input.euc-y-s[type="submit"]{background-color:#3498db;color:#fff;font-size:21px;box-shadow:none;-webkit-transition: .4s;-moz-transition: .4s;-o-transition: .4s;transition:.4s;-webkit-backface-visibility:hidden;position:relative;cursor:pointer;padding: 13px 20px;text-align: center;border-radius: 50px;-webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none;border: 0;height: auto;outline: medium;line-height: 20px;margin: 0;}
input.euc-y-s[type="submit"]:hover{background-color:#5dade2;}
input.euc-y-i[type="text"],input.euc-y-i[type="password"]{border:1px solid #F2EFEF;color:#777;display:block;background: #FCFCFC;font-size:18px;transition:all .5s ease 0;outline:0;box-sizing:border-box;-webkit-border-radius:25px;-moz-border-radius:25px;border-radius:25px;padding:5px 16px; margin: 0;height: auto;line-height: 30px;}
input.euc-y-i[type="text"]:hover,input.euc-y-i[type="password"]:hover{border:1px solid #56b4ef;box-shadow:0 0 4px #56b4ef;}

3、调用方法文章源自新手站长-https://xinshouzhanzhang.com/wpbufenjiami.html

[secret key="woshimima"]
我是加密内容呦
[/secret]

写文章时,将需要加密的部分放到secret短标签中即可!文章源自新手站长-https://xinshouzhanzhang.com/wpbufenjiami.html 文章源自新手站长-https://xinshouzhanzhang.com/wpbufenjiami.html

【阿里云99元服务器】入口2核2G3M带宽、新老用户同享、99元/年续费到2027年

【腾讯云特价】:2核2G3M 88元一年、2核2G4M 108元1年 366元3年、2核4G5M 166元/年 566元3年、4核8G12M 446元一年 更多配置8核16G18M和16核32G28M 点我直达 >>

2023阿里云优惠活动:xinshouzhanzhang.com/go/aliyun

注意:以上特价轻量服务器限制条件为“产品首单特惠”,如果你的腾讯云账号已经是老用户,建议重新注册一个腾讯云账号,如果你是新用户符合条件,那么无脑入,确实值得。

 最后更新:2018-4-10
腾讯云优惠活动

腾讯云轻量应用服务器镜像是什么?怎么选镜像比较好?

腾讯云轻量应用服务器镜像是什么?镜像是轻量服务器的装机盘,镜像用户按照云服务器的操作系统。腾讯云轻量应用服务器镜像如何选择?可以选择宝塔Linux面板8.0.4腾讯云专享版,如果需要Win系统建议选择...
评论  2  访客  2
    • 极客影院 0

      :!: uuuggg个

      • 攒外快网 0

        非常有用,谢谢分享

      评论已关闭!