Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 2 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,2 @@
# Adams

一套适用于 WordPress 的简洁、轻量的 Theme
![](https://wx1.sinaimg.cn/large/76679337ly1gcj1k23yf7j219r0u00wf.jpg)

# 发行

Github 默认为开发版,如果需要稳定发行版,请前往:https://github.com/Tokinx/Adams/releases

下载后进入 WordPress 后台进行安装并启用即可

主题设置项在:后台 -> 主题 -> 自定义

# 如何贡献

合理的改动的PR都会被合并,合理的 issues 都会被采纳并修改。

# 鸣谢

维护:[Tokin](https://biji.io)

贡献:[@Frank](https://github.com/w4o)、[@Abdul Wahab](https://github.com/abdulwahab610)、[@Sammy Liang](https://github.com/SammyLiang97)、[@刘明野](https://github.com/liumingye)、[@lizhimiao](https://github.com/zhimiaoli)、[@keinx](https://github.com/keinx)

# 讨论

https://github.com/Tokinx/Adams/issues
基于: https://github.com/Tokinx/Adams/
添加了阅读量和字数统计功能
48 changes: 48 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -590,3 +590,51 @@ public function toWpFormat()
);

// 全部配置完毕

//阅读数量计算
function get_post_views ($post_id) {

$count_key = 'views';
$count = get_post_meta($post_id, $count_key, true);

if ($count == '') {
delete_post_meta($post_id, $count_key);
add_post_meta($post_id, $count_key, '0');
$count = '0';
}

echo number_format_i18n($count);

}

function set_post_views () {

global $post;

$post_id = $post -> ID;
$count_key = 'views';
$count = get_post_meta($post_id, $count_key, true);

if (is_single() || is_page()) {

if ($count == '') {
delete_post_meta($post_id, $count_key);
add_post_meta($post_id, $count_key, '0');
} else {
update_post_meta($post_id, $count_key, $count + 1);
}

}

}
add_action('get_header', 'set_post_views');

//字数统计
function count_words ($text) {
global $post;
if ( '' == $text ) {
$text = $post->post_content;
if (mb_strlen($output, 'UTF-8') < mb_strlen($text, 'UTF-8')) $output .= '本文共' . mb_strlen(preg_replace('/\s/','',html_entity_decode(strip_tags($post->post_content))),'UTF-8') . '个字';
return $output;
}
}
4 changes: 3 additions & 1 deletion header.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@
<div class="fields">
<span><i class="czs-time-l"></i> <time datetime="<?php echo get_the_time('c'); ?>" title="<?php echo get_the_time('c'); ?>"
itemprop="datePublished" pubdate><?php the_time('Y-m-d') ?></time></span> /
<span><i class="czs-read-l"></i> <?php get_post_views($post -> ID); ?> 阅读</span> /
<span><i class="czs-talk-l"></i> <?php comments_number('0', '1', '%'); ?>评</span> /
<span><i class="czs-text-l"></i> <?php echo count_words ($text); ?>字</span> /
<a href="javascript:;" data-action="topTop" data-id="<?php the_ID(); ?>"
class="dot-good <?php echo isset($_COOKIE['dotGood_' . $post->ID]) ? 'done' : ''; ?>">
<i class="czs-thumbs-up-l"></i><i class="czs-thumbs-up"></i>
Expand Down Expand Up @@ -92,4 +94,4 @@ class="dot-good <?php echo isset($_COOKIE['dotGood_' . $post->ID]) ? 'done' : ''
<?php } ?>
</div>
</section>
</header>
</header>
1 change: 1 addition & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<footer>
<span class="time"><time datetime="<?php echo get_the_time('c'); ?>" title="<?php echo get_the_time('c'); ?>"
itemprop="datePublished" pubdate><?php the_time('Y-m-d'); ?></time>发布</span>
<span class="hr"></span><span class="read"><?php get_post_views($post -> ID); ?> 人阅读</span>
<span class="hr"></span>
<span class="comments"><?php comments_number('0', '1', '%'); ?> 条评论</span>
<?php echo get_post_meta($post->ID, 'dotGood', true) ? '<span class="hr"></span><span class="likes">' . get_post_meta($post->ID, 'dotGood', true) . ' 人喜欢</span>' : ''; ?>
Expand Down