WordPress文章加密

在主题的functions.php文件添加以下代码:

//部分内容登录可见 湖畔网 — www.huusvip.com
add_shortcode('hide','loginvisible');
function loginvisible($atts,$content=null){
if(is_user_logged_in() && !is_null($content) && !is_feed())
return $content;
return '';
}

如何实现?在编辑文章是使用短码包围要隐藏的内容,注意:把下面中文括号改为英文括号【】→[]

【hide】
登陆才可以看到的内容
【/hide】

最终效果

[hide] 654[/hide]

是不是很简单

2、美化版
在主题function.php文件里加入以下代码。其中可用于直接将href=”#respond”后的“#respond”替换为自己站点的登录地址,以方便用户快速登录。


//部分内容登录可见 湖畔网 — www.huusvip.com
function login_to_read($atts, $content=null) {
extract(shortcode_atts(array("notice" => '
<span style="color: red;">温馨提示:</span>此处内容需要<a title="登录后可见" href="#respond">登录</a>后才能查看!
'), $atts));
if ( is_user_logged_in() && !is_null( $content ) && !is_feed() )
return $content;
return $notice;
}
add_shortcode('vip', 'login_to_read');

如何实现?在编辑文章是使用短码包围要隐藏的内容,下面列举。
注意:把下面中文括号改为英文括号【】→[]
最终效果
温馨提示:此处内容需要登录后才能查看!

3、输入密码显示
首先在主题functions.php文件中添加下面代码。

//部分内容输入密码可见 湖畔网 — www.huusvip.com
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');

第二步到在自己主题main.css样式文件里添加下面代码。


/*e-secret*/
.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;}

如何实现?在编辑文章是使用短码包围要隐藏的内容,如下即可。
注意:把下面中文括号改为英文括号【】→[]

【secret key=”密码”】
加密内容
【/secret]

很難在頂樓弄天幕阿!

頂樓防水弄好,但發現這次材料比較偏軟,硬度不足。 但因為天幕還有點潮,就乾脆拉打天幕看看了。。。 嗯,感覺不錯,開放預約頂樓偽露營。。。。。
頂樓防水弄好,但發現這次材料比較偏軟,硬度不足。
但因為天幕還有點潮,就乾脆拉打天幕看看了。。。嗯,感覺不錯,開放預約頂樓偽露營。。。。。
閱讀全文

98分 還是 負2分-小四成績

看了老朋友幫孩子寫的紀錄文
既然今天在咖啡店值班…也來寫寫好啦。我們家基本上不會因為考試成績罵小孩…嗯!因為我很幸福….我兒子自己很用功

重點是因為他老爸從小不念書…..
就覺得兒子有唸書已經比自己棒很多….
就沒什麼立場再去碎碎念
特別是平常寫作業的時候
閱讀全文

小易愛考試

媽媽在考哥哥聽寫,大班的小易說他也要一起。 一邊寫還一邊問好了沒,下一個,不斷催促他哥快一點。 嫌棄他哥寫太慢,弄的哥哥又好氣又好笑的說,你只要寫注音 我還要寫國字也。。。。。
 
媽媽認真的幫他改了注音。。。。
沒想到今天早上一看這傢伙自己補上 100 分。。。和中文姓名。。。。。。
真的是個皮蛋。。。。

#字有夠醜
閱讀全文