Skip to content
This repository has been archived by the owner on May 29, 2022. It is now read-only.

Commit

Permalink
fix: ver 1.5 fix liked bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
Innei committed Jun 24, 2019
1 parent a2e448a commit baa95d8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
12 changes: 12 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,16 @@ function themeFields($layout) {
$intro = new Typecho_Widget_Helper_Form_Element_Text('intro', NULL, NULL, _t('介绍'), _t('首页模板功能'));
$layout->addItem($intro);
}
}

function isLiked ($cid) {
$likes = Typecho_Cookie::get('__post_likes');
if (empty($likes)) {
return false;
} else {
$likes = explode(',', $likes);
}
if (in_array($cid, $likes)) {
return true;
}
}
4 changes: 2 additions & 2 deletions page-note.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function allpostnum($id)
title="参与评论">评论 <?php $posts->commentsNum('%d '); ?></span>
</a>
<span class="like" data-cid="<?php $posts->cid();
?>" title="已有 <?php get_like_num($posts) ?> 人点赞" <?php if (Typecho_Cookie::get('__post_likes')) print_r("style='color: var(--red)'") ?>><?php get_like_num($posts) ?></span>
?>" title="已有 <?php get_like_num($posts) ?> 人点赞" <?php if (isLiked($posts->cid)) print_r("style='color: var(--red)'") ?>><?php get_like_num($posts) ?></span>
</div>
</div>
<?php if (!$posts->allow('comment')) : ?>
Expand Down Expand Up @@ -149,7 +149,7 @@ function allpostnum($id)
<span class="comment" data-cid="<?php $posts->cid(); ?>" data-year="<?php $posts->year(); ?>"
title="参与评论">评论 <?php $posts->commentsNum('%d '); ?></span>
<span class="like" data-cid="<?php $posts->cid();
?>" title="已有 <?php get_like_num($posts) ?> 人点赞" <?php if (Typecho_Cookie::get('__post_likes')) print_r("style='color: var(--red)'") ?>><?php get_like_num($posts) ?></span>
?>" title="已有 <?php get_like_num($posts) ?> 人点赞" <?php if (isLiked($posts->cid)) print_r("style='color: red'") ?>><?php get_like_num($posts) ?></span>
</div>
</div>
<?php if (!$posts->allow('comment')) : ?>
Expand Down
2 changes: 1 addition & 1 deletion post.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
<div class="note-action">
<span class="comment" data-cid="<?php $this->cid(); ?>" data-year="<?php $this->year(); ?>" title="参与评论">评论</span>
<span class="like" data-cid="<?php $this->cid();
?>" title="已有 <?php get_like_num($this) ?> 人点赞"><?php get_like_num($this) ?></span>
?>" title="已有 <?php get_like_num($this) ?> 人点赞" <?php if (isLiked($this->cid)) print_r('class="color: red"') ?>><?php get_like_num($this) ?></span>
</div>
</div>
</article>
Expand Down

0 comments on commit baa95d8

Please sign in to comment.