功能说明
为WordPress指定内容设置评论回复可见这个功能经常在一些网站上看到,如果用到自己网站是不是很不错呢,于是也使用过一段时间,但效果并不理想就取消了。
鉴于一些站长朋友可能会需求,本文白天就来给大家分享一下WordPress指定内容设置评论回复可见的方法。
方法很简单,在当前网站主题下的functions.php文件内加入以下代码:
/* Name: 部分内容输入密码可见(短代码) * 作者:MC百科网https://www.mcbke.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 ''; } } add_shortcode('secret','e_secret');'.$content.''; } else{ return '
有几位小伙伴需要样式代码,下面附上,细节需要自己修改。用手机贴的代码,确实不便。
/*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调用,示例:
【secret key="密码"】加密内容【/secret】
效果显示
© 版权声明
THE END
喜欢就支持一下吧