Emlog非安装插件来实现隐藏内容登录查看,这次教程加代码,加代码,加代码。
什么是登录查看隐藏内容?必须你在本站注册并登录上才可查看文章隐藏内容,没登录代表的就是游客,无法查看隐藏内容的。
带有邀请码的注册可以用这个来赚点红牛钱啥的不废话了。
第一步:
module.php核心文件添加以下代码
//登录查看隐藏内容
function slyc($content){
if(preg_match_all('/<yc\>([\s\S]*?)<\/yc\>/i', $content, $hide_words)){
if(ISLOGIN ){
$content = str_replace($hide_words[0], $hide_words[1], $content);
}else{
$hide_notice = '<div style="text-align:center;border:1px dashed #19b5fe;padding:8px;margin:10px auto;color:#2196f3;">您必须先<a href="'.BLOG_URL.'admin">登录</a>才能查看隐藏内容</div>';
$content = str_replace($hide_words[0], $hide_notice, $content);
}
}
return $content;
}
第二步:
echo_log.php文件中找到代码:
<?php echo $log_content; ?>
替换为:
<?php echo slyc($log_content); ?>
如何隐藏?
编辑文章的时候切换到HTML模式在要隐藏的地方放上以下隐藏代码
<yc> 此处是要隐藏的内容 </yc>