Skip to content

Commit

Permalink
fix: category description not working in Typecho 1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
KawaiiZapic committed Mar 27, 2024
1 parent 44c8524 commit d5d33f3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
20 changes: 20 additions & 0 deletions pages/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,26 @@ static function toComment(\Widget\Comments\Archive &$comments): void {
<?php }
}

static function tpVersion($version) {
$version1Parts = explode('.', \Typecho\Common::VERSION);
$version2Parts = explode('.', $version);

$length = max(count($version1Parts), count($version2Parts));

for ($i = 0; $i < $length; $i++) {
$part1 = isset($version1Parts[$i]) ? intval($version1Parts[$i]) : 0;
$part2 = isset($version2Parts[$i]) ? intval($version2Parts[$i]) : 0;

if ($part1 < $part2) {
return -1;
} elseif ($part1 > $part2) {
return 1;
}
}

return 0;
}

static function links(): array {
$options = \Typecho\Widget::widget('Widget_Options');
if (!isset($options->plugins['activated']['Links'])) {
Expand Down
5 changes: 3 additions & 2 deletions pages/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
if ($this->archiveType === 'index') {
$this->options->description();
} else if ($this->archiveType === "category" || $this->archiveType == "tag" || $this->archiveType === "search") {
if ($this->description) {
echo $this->description;
$description = Matecho::tpVersion("1.2.1") > 0 ? $this->archiveDescription : $this->description;
if ($description) {
echo $description;
} else {
printf("共 %d 篇文章", $this->getTotal());
}
Expand Down

0 comments on commit d5d33f3

Please sign in to comment.