feat: add article display feature (#472)

pull/480/head^2
Seaton Jiang 2022-02-20 22:37:55 +08:00
parent 699946eabf
commit 355ff3ee0e
No known key found for this signature in database
GPG Key ID: B79682F6FE8D30E3
3 changed files with 48 additions and 24 deletions

View File

@ -4,7 +4,7 @@
* 主题选项
* @author Seaton Jiang <hi@seatonjiang.com>
* @license GPL-3.0 License
* @version 2022.01.26
* @version 2022.02.20
*/
defined('ABSPATH') || exit;
@ -597,6 +597,34 @@ CSF::createSection($prefix, array(
'subtitle' => __('启用/禁用网易云音乐自动播放功能', 'kratos'),
'default' => false,
),
array(
'id' => 'g_post_comments',
'type' => 'switcher',
'title' => __('评论数量展示', 'kratos'),
'subtitle' => __('启用/禁用首页及文章页面展示阅读数量的功能', 'kratos'),
'default' => true,
),
array(
'id' => 'g_post_views',
'type' => 'switcher',
'title' => __('热度数量展示', 'kratos'),
'subtitle' => __('启用/禁用首页及文章页面展示热度数量的功能', 'kratos'),
'default' => true,
),
array(
'id' => 'g_post_loves',
'type' => 'switcher',
'title' => __('点赞数量展示', 'kratos'),
'subtitle' => __('启用/禁用首页及文章页面展示点赞数量的功能', 'kratos'),
'default' => true,
),
array(
'id' => 'g_post_author',
'type' => 'switcher',
'title' => __('作者名称展示', 'kratos'),
'subtitle' => __('启用/禁用首页展示作者名称的功能', 'kratos'),
'default' => true,
),
array(
'id' => 'g_post_revision',
'type' => 'switcher',

View File

@ -4,7 +4,7 @@
* 文章列表
* @author Seaton Jiang <hi@seatonjiang.com>
* @license GPL-3.0 License
* @version 2022.01.26
* @version 2022.02.20
*/
?>
<div class="article-panel">
@ -43,19 +43,18 @@
<div class="a-meta">
<span class="float-left d-none d-md-block">
<span class="mr-2"><i class="kicon i-calendar"></i><?php echo get_the_date(); ?></span>
<span class="mr-2"><i class="kicon i-comments"></i><?php comments_number('0', '1', '%');
_e('条评论', 'kratos'); ?></span>
<?php if (kratos_option('g_post_comments', true)) { ?>
<span class="mr-2"><i class="kicon i-comments"></i><?php comments_number('0', '1', '%'); _e('条评论', 'kratos'); ?></span>
<?php } ?>
</span>
<span class="float-left d-block">
<span class="mr-2"><i class="kicon i-hot"></i><?php echo get_post_views();
_e('点热度', 'kratos'); ?></span>
<span class="mr-2"><i class="kicon i-good"></i><?php if (get_post_meta($post->ID, 'love', true)) {
echo get_post_meta($post->ID, 'love', true);
} else {
echo '0';
}
_e('人点赞', 'kratos'); ?></span>
<span class="mr-2"><i class="kicon i-author"></i><?php echo get_the_author_meta('display_name'); ?></span>
<?php if (kratos_option('g_post_views', true)) { ?>
<span class="mr-2"><i class="kicon i-hot"></i><?php echo get_post_views(); _e('点热度', 'kratos'); ?></span>
<?php } if (kratos_option('g_post_loves', true)) { ?>
<span class="mr-2"><i class="kicon i-good"></i><?php if (get_post_meta($post->ID, 'love', true)) { echo get_post_meta($post->ID, 'love', true); } else { echo '0'; } _e('人点赞', 'kratos'); ?></span>
<?php } if (kratos_option('g_post_author', true)) { ?>
<span class="mr-2"><i class="kicon i-author"></i><?php echo get_the_author_meta('display_name'); ?></span>
<?php } ?>
</span>
<span class="float-right">
<a href="<?php the_permalink(); ?>"><?php _e('阅读全文', 'kratos'); ?><i class="kicon i-rightbutton"></i></a>

View File

@ -4,7 +4,7 @@
* 文章内容
* @author Seaton Jiang <hi@seatonjiang.com>
* @license GPL-3.0 License
* @version 2022.01.26
* @version 2022.02.20
*/
get_header();
@ -50,16 +50,13 @@ $col_array = array(
<h1 class="title"><?php the_title(); ?></h1>
<div class="meta">
<span><?php echo get_the_date(); ?></span>
<span><?php echo get_post_views();
_e('点热度', 'kratos'); ?></span>
<span><?php if (get_post_meta($post->ID, 'love', true)) {
echo get_post_meta($post->ID, 'love', true);
} else {
echo '0';
}
_e('人点赞', 'kratos'); ?></span>
<span><?php comments_number('0', '1', '%');
_e('条评论', 'kratos'); ?></span>
<?php if (kratos_option('g_post_views', true)) { ?>
<span><?php echo get_post_views(); _e('点热度', 'kratos'); ?></span>
<?php } if (kratos_option('g_post_loves', true)) { ?>
<span><?php if (get_post_meta($post->ID, 'love', true)) { echo get_post_meta($post->ID, 'love', true); } else { echo '0'; } _e('人点赞', 'kratos'); ?></span>
<?php } if (kratos_option('g_post_comments', true)) { ?>
<span><?php comments_number('0', '1', '%'); _e('条评论', 'kratos'); ?></span>
<?php } ?>
<?php if (current_user_can('edit_posts')) {
echo '<span>';
edit_post_link(__('编辑文章', 'kratos'));