官网: https://github.com/Licoy/wordpress-theme-puock
首页随机头图
准备头图,copy 到主题目录:
sudo copy /usr/share/nginx/html/uploads/*.jpg /usr/share/nginx/html/wp-content/themes/wordpress-theme-puock-2.7.6/assets/img/random/
主题模板函数 functions.php:
function get_post_images($_post = null)
{
global $post;
if ($_post != null) {
$post = $_post;
}
$post_id = $post->ID;
// 如果有封面图取封面图
if (has_post_thumbnail()) {
$res = get_the_post_thumbnail_url($post, 'large');
if ($res != null) {
return $res;
}
}
if ($post_id == null && $post) {
$content = $post->post_content;
} else {
$content = get_post($post_id)->post_content;
}
preg_match_all('/<img.+src=[\'"](/p/148a59af602169aa0f2f4d3806871212);
if ($matches && $matches[1]) {
$res = $matches[1][0];
} else {
$res = get_stylesheet_directory_uri() . '/assets/img/random/' . mt_rand(1, 8) . '.jpg';
}
return $res;
}
修改为:
function get_post_images($_post = null)
{
global $post;
if ($_post != null) {
$post = $_post;
}
$post_id = $post->ID;
// 如果有封面图取封面图
if (has_post_thumbnail()) {
$res = get_the_post_thumbnail_url($post, 'large');
if ($res != null) {
return $res;
}
}
// if ($post_id == null && $post) {
// $content = $post->post_content;
// } else {
// $content = get_post($post_id)->post_content;
// }
// preg_match_all('/<img.+src=[\'"](/p/148a59af602169aa0f2f4d3806871212);
// if ($matches && $matches[1]) {
// $res = $matches[1][0];
// } else {
// $res = get_stylesheet_directory_uri() . '/assets/img/random/' . mt_rand(1, 8) . '.jpg';
// }
// return $res;
$res = get_stylesheet_directory_uri() . '/assets/img/random/' . mt_rand(1, 60) . '.jpg';
return $res;
}
主题基本设置
-
资源与更新:主题更新检测频率:876000 (100年,相当于不更新)
-
全局设置
- 禁止非管理员访问用户资料页
-
基础设置
-
图片懒加载
-
正文图片懒加载
-
留言头像懒加载
-
正文内容首行缩进: 不要打开,因为标题没有缩进
-
正文内容侧边目录菜单生成
-
异步浏览量统计
-
评论相关:全部开启
-
Gravatar头像源:cravatar
-
-
脚本及样式
-
底部关于我们,底部版权说明: 关闭
-
头部流量统计代码,可以用emoji 作为favicon:
-
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>:milky_way:</text></svg>">
-
脚本及样式
- 底部页脚信息: Puock: 主题页脚 (footer.php)
<div class="info"> <!-- <?php echo apply_filters('pk_footer_info','') ?> --> <div class="fs12 mt10 c-sub"> <span>Copyright :copyright: 2018-<?php echo date("Y")?><a target="_blank" class="c-sub" title="yinhe.co" href="https://yinhe.co">yinhe.co</a> All Rights Reserved.</span> </div> </div>
删除post列表中的分类
编辑 templates/module-post.php, 注释掉两条如下语句
<?php echo get_post_category_link('badge d-none d-md-inline-block bg-' . pk_get_color_tag(['danger', 'warning', 'dark']) . ' ahfff') ?>
外观,菜单
-
:house: 首页,
/
-
:milky_way: 关于,
/p/da6b9bd9ece356e6101ba1029bd5829a/
-
:man: 管理,
/wp-admin/
-
:ballot_box_with_check: to do ,
/p/983f805e0cb779b62752bdd24e11c0f5/
外观,小工具
-
删除默认
-
通用,侧边栏
-
文章搜索
-
最新文章
-
mathjax支持
参考:https://docs.mathjax.org/en/latest/web/start.html#configuring-mathjax
<!-- header 部分 -->
<script>
MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']]
}
};
</script>
<!-- footer 部分 -->
<script id="MathJax-script" async
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js">
</script>
引用固定边框
通过增加css完成: header.php
<style>
blockquote {
background: #f9f9f9;
border: 10px solid #ccc;
margin: 1.5em 10px;
padding: 0.5em 10px;
}
</style>
</head>
<body class="puock-<?php echo pk_theme_light() ? 'light' : 'dark';
echo current_theme_supports('custom-background') ? ' custom-background' : ''; ?>">
markdown代码:
> test
> $y=x^2$
> test
效果:
test
$y=x^2$
test
对emoji的支持
-
python预处理emoji为短代码
: smile :
-
使用js-emoji: https://github.com/iamcal/js-emoji
-
创建目录 /usr/share/nginx/html/js-emoji/lib,从 js-emoji/lib at master · iamcal/js-emoji · GitHub 获取 emoji.css, emoji.js ,copy 到新建目录下
-
编辑主题的 single.php
-
<link href="/js-emoji/lib/emoji.css" rel="stylesheet" type="text/css" />
<script src="/js-emoji/lib/emoji.js" type="text/javascript"></script>
...
<script>
jQuery(document).ready(function(){
var emoji = new EmojiConvertor();
// convert colons explicitly to unicode
emoji.replace_mode = 'unified';
emoji.allow_native = true;
// replaces :smile: with platform appropriate content
var post_html = emoji.replace_colons(jQuery('#post').html());
jQuery('#post').html(post_html);
});
</script>
存在的问题:emoji 对应的短代码不全,不过一般应该够用了。
在数据库中保存emoji是终极解决方案