python 有没有类似WordPress的这种库?
例如:WordPress博客这种插件Eyes Only: User Access Shortcode
https://www.wpdaxue.com/eyes-...
/**
* WordPress 根据用户名/用户角色/能力/是否登录等隐藏部分文章内容
* https://www.wpdaxue.com/eyes-only-user-access-shortcode.html
*/
add_shortcode('eyesonly', 'sc_eyesonly');
function sc_eyesonly($atts, $content = null) {
extract(shortcode_atts(array('username' => null, 'level' => null, 'logged' => null,'hide' => null,),$atts));
if (!$hide || $hide === 'no' || $hide === 'false'){$pre = null; $thecontent = do_shortcode($content);}
if ($hide && $hide !== 'no' && $hide !== 'false'){$pre = do_shortcode($content); $thecontent = null;}
$showcontent = $pre;
$current_user = wp_get_current_user();
$users = preg_split("/[\s,]+/",$username);
$levels = preg_split("/[\s,]+/",$level);
foreach($users as $name){if($username && $current_user->user_login === $name){$showcontent = $thecontent;}}
foreach($levels as $value){if($level && current_user_can($value)){$showcontent = $thecontent;}}
if($logged && is_user_logged_in() && $logged === 'in'){$showcontent = $thecontent;}
if($logged && !is_user_logged_in() && $logged === 'out'){$showcontent = $thecontent;}
return $showcontent;
}
python 中怎样实现
相关阅读:
symfony项目如果不用composer安装第三方库,而是手动安装,需要改哪些文件呢?
腾讯云 小程序解决方案 有个问题
salt cp.push提示false异常
javascript中数组索引为负值,数组长度为 结束索引-开始索引(区间长度)
pyspider一下生成几千条链接爬取是否合适
大家中午好,xcode 中如何查看一个对象是在堆区还是在栈区?
[微信小程序] 为什么点击手机设备上的back按键会导致小程序关闭?
求一个可以上传zip文件的jq插件,zip里是excel文件
微信开发工具登陆问题
关于Python的问题
关于Python的问题
java jdbc addBatch()提交mysql速度过慢
如何选择一个容器下的第几到第几个元素
hexo博客在本地查看为啥是localhost :4000,4000是什么意思
jquery如何解析这样的json字符串的键,值,谢谢
下面代码,flex自适应布局,但是图片宽度变窄了而不是文字的宽度变窄,我测试过是文字影响了导致没法自适应,为什么,应该怎么改?
Android用XUtils下载apk文件被运营商劫持,如何处理.
nodejs如何提供本地文件的http访问路径?
seajs.use会在seajs.cache里面生产脏数据 急!在线等!!
canvas绘制出的三角形,如何设置旋转角度呢?
关于python beautifullsoup解析网页内容丢失的问题?