Skip to content

Commit ecabc30

Browse files
committed
v1.2.0
更新说明: - 增加评论功能及样式 - 可选回复评论框跟随,默认禁用 - 部分样式优化
1 parent b6cf354 commit ecabc30

File tree

4 files changed

+45
-12
lines changed

4 files changed

+45
-12
lines changed

README.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010

1111
作者网站: https://yayu.net/
1212

13-
最新版本: 1.1.0
13+
最新版本: 1.2.0
1414

1515
授权方式: CC BY-NC-SA 4.0 DEED
1616

1717
授权介绍: https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh-hans
1818

19-
主题声明: 主题复刻于 Bear Blog 示例主题 (https://herman.bearblog.dev/),并在原基础上进行改造及中文优化。既然是复刻“b”ear,那本主题就姑且叫 “d”ear 吧,亲爱的。
19+
主题声明: 主题复刻于 Bear Blog 示例主题 ( https://herman.bearblog.dev/ ),并在原基础上进行改造及中文优化。既然是复刻“b”ear,那本主题就姑且叫 “d”ear 吧,亲爱的。
2020

2121

2222
## 使用方法
@@ -47,13 +47,18 @@
4747

4848
使用代码编辑器修改主题内 funcitons.php 文件,按提示修改第22行“文章数设置”部分的数量,上传文件替换即可。
4949

50-
### 如何让主题支持评论
50+
### 如何回复评论时让评论框跟随
5151

52-
使用代码编辑器修改主题内 index.php 文件的21和22行之间换行插入以下代码 ```<p><br /><?php if (comments_open()) {comments_template();}?></p>``` 即可。显示出来的样式是可以接受的,可按个人喜好另行补充样式
52+
主题从 v1.2.0 版本增加评论功能及样式,为减少 JS 文件加载,默认禁用评论框跟随。如需启用,请修改主题 functions.php 文件163行,把 add_action 前面的注释符 // 移除即可
5353

5454

5555
## 迭代日志
5656

57+
### Version 1.2.0 (2025-01-15)
58+
- 增加评论功能及样式
59+
- 可选回复评论框跟随,默认禁用
60+
- 部分样式优化
61+
5762
### Version 1.1.0 (2024-09-22)
5863
- 增加独立“搜索模板”
5964
- CSS 样式移至 style.css 文件

functions.php

+14
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,18 @@ function disable_embeds_tiny_mce_plugin( $plugins ) {
148148
add_action( 'wp_enqueue_scripts', function() {
149149
wp_dequeue_style( 'classic-theme-styles' );
150150
}, 20 );
151+
152+
//回复评论框跟随。如需启用,去掉 add_action 前面的注释符 //
153+
if (!function_exists('yayu_enqueue_scripts')) :
154+
function yayu_enqueue_scripts()
155+
{
156+
if ((!is_admin()) && is_singular()) {
157+
wp_enqueue_script('jquery', '', 'jquery', '', true);
158+
if (comments_open() && get_option('thread_comments')) {
159+
wp_enqueue_script('comment-reply');
160+
};
161+
};
162+
}
163+
//add_action('wp_enqueue_scripts', 'yayu_enqueue_scripts');
164+
endif;
151165
?>

index.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
<?php } else { if (have_posts()) { while (have_posts()) { the_post(); ?>
1717
<h1><?php the_title(); ?></h1>
1818
<?php if ( is_single() ) : ?><p><?php the_category( ', ' );?>&nbsp · &nbsp<time datetime="<?php the_time('Y-m-d'); ?>"><?php the_date( get_option( 'date_format' ) ); ?></time></p><?php endif; ?>
19-
<p><?php the_content(); ?></p>
19+
<div class="content"><?php the_content(); ?></div>
2020
<p><?php wp_link_pages(); ?></p>
2121
<?php if ( is_single() && get_the_tags() ) : ?><p class="tags"><?php the_tags( ' #', ' #', '' ); ?></p><?php endif; ?>
22+
<?php if ( comments_open() ) { ?><div class="comlist"><?php comments_template();?></div><?php } ?>
2223
<?php }}} ?>
2324
<?php get_footer();?>

style.css

+20-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Author: Jeff Chen
55
Author URI: https://yayu.net/
66
Description: Dear 是一款 WordPress & Typecho 纯文本极极简主题,样式复刻于 Bear Blog 示例主题。主题支持自定义背景、自定义菜单、自定义首页内容,支持黑暗模式和自适应;内置文章归档和搜索模板;已作中文字体优化,内置3种字体方案可选。力求极简,对程序自带功能进行禁用及优化,主题无 JS、图片文件引用。
77
Tags: blog, plaintext, one-column, full-width-template, minimalism, responsive, dark-mode, free
8-
Version: 1.1.0
8+
Version: 1.2.0
99
License: CC BY-NC-SA 4.0 DEED
1010
License URI: https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh-hans
1111
*/
@@ -23,7 +23,7 @@ License URI: https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh-hans
2323
--code-background-color: #f2f2f2;
2424
--code-color: #222;
2525
--blockquote-color: #222;
26-
--gray-color: #999;
26+
--gray-color: #aaa;
2727
}
2828
@media (prefers-color-scheme: dark) {
2929
:root {
@@ -35,7 +35,7 @@ License URI: https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh-hans
3535
--code-background-color: #000;
3636
--code-color: #ddd;
3737
--blockquote-color: #ccc;
38-
--gray-color: #999;
38+
--gray-color: #888;
3939
}
4040
}
4141
body {
@@ -64,10 +64,11 @@ img{max-width:100%;height:auto}
6464
time,.intro{color:var(--gray-color);}
6565
code{font-family:monospace;padding:2px;background-color:var(--code-background-color);color:var(--code-color);border-radius:4px}
6666
blockquote{border-left:1px solid #999;color:var(--code-color);padding-left:20px;font-style:italic}
67-
input{border-radius:4px;border:1px solid var(--gray-color);margin:0 0 15px 0;padding:10px;width:50%}
68-
input:focus{outline:0}
69-
input[type="submit"]{padding:9px 10px 10px;text-align:center;width:80px;display:inline-flex;background-color:var(--heading-color);color:var(--code-background-color);border:none}
67+
input{border-radius:4px;border:1px solid var(--gray-color);margin:0 0 15px 0;padding:10px;width:50%;font-size:0.9em;background:var(--background-color);color:var(--heading-color)}
68+
input[type="submit"]{border:none;padding:9px 16px 10px;text-align:center;width:80px;display:inline-flex;background-color:var(--heading-color);color:var(--code-background-color);}
7069
input[type="submit"]:hover{cursor:pointer;opacity:.7}
70+
textarea{border-radius:4px;border:1px solid var(--gray-color);display:block;margin:0 0 10px;padding:10px;width:calc(100% - 25px);background:var(--background-color);color:var(--code-color);}
71+
input:focus,textarea:focus{border:1px solid var(--text-color);outline:0}
7172
header,footer{padding:20px 0}
7273
.title:hover{text-decoration:none;border:none}
7374
.title h1,.title h2{font-size:1.5em}
@@ -76,4 +77,16 @@ ul.posts li{display:flex;margin:3px 0}
7677
ul.posts li span{flex:0 0 115px}
7778
ul.posts li a:visited{color:var(--visited-color)}
7879
.tags{margin-top:30px;color:var(--gray-color)}
79-
.tags a{margin:0 5px 0 2px}
80+
.tags a{margin:0 5px 0 2px}
81+
.comment-respond{text-align:left;padding-top:40px;}
82+
.comlist{margin:80px auto 0;}
83+
.commentlist,.commentlist .children{list-style: none;padding:0;margin-bottom:40px;}
84+
.comment{margin:30px 0;list-style: none;text-align:left;}
85+
.comment .comment{margin-left:35px;}
86+
.comment-author cite{font-weight:bold;font-style:normal;}
87+
.comment-author .says,.comment-author .avatar,.screen-reader-text{display:none}
88+
.comment-meta a{color: var(--gray-color);font-size: 0.9rem;}
89+
.comlist input{display:block;width:calc(100% - 25px);}
90+
.comlist input[type="submit"]{width:initial;}
91+
.comlist input[type="checkbox"]{display:inline-block;width: initial;}
92+
#cancel-comment-reply-link{margin-left:15px;font-weight: normal;}

0 commit comments

Comments
 (0)