Skip to content

Commit

Permalink
0.961
Browse files Browse the repository at this point in the history
  • Loading branch information
solstice23 committed May 21, 2020
1 parent 5d786d1 commit 3eb8a48
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 12 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Argon - 一个轻盈、简洁、美观的 WordPress 主题
# 特性

+ **轻盈美观** - 使用 Argon Design System 前端框架,细节精致,轻盈美观
+ **高度可定制化** - 可自定义主题色、页面布局、顶栏、侧栏、Banner、背景图、日夜间模式不同背景、背景沉浸、浮动操作按钮等,提供了丰富的自定义选项
+ **高度可定制化** - 可自定义主题色、布局(双栏/单栏/三栏)、顶栏、侧栏、Banner、背景图、日夜间模式不同背景、背景沉浸、浮动操作按钮等,提供了丰富的自定义选项
+ **夜间模式** - 支持日间、夜间、纯黑三种模式,并可以根据时间自动切换或跟随系统夜间模式
+ **功能繁多** - Tag 和分类统计、作者链接、额外链接、文章字数和预计阅读时间、文章过时信息显示
+ **Pjax** - 支持 Pjax 无刷新加载,提高浏览体验
Expand Down Expand Up @@ -63,6 +63,12 @@ Argon 使用 [GPL V3.0](https://github.com/solstice23/argon-theme/blob/master/LI

# 更新日志

## 20200521 v0.961
+ 新增首页隐藏特定分类文章选项
+ 新增文章 Meta 显示作者选项
+ 优化分类、标签和文章中的 SEO Keywords
+ 其他小改进

## 20200518 v0.960
+ 新增三栏布局模式

Expand Down
2 changes: 2 additions & 0 deletions argontheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,7 @@ $(document).on("submit" , ".post-password-form" , function(){
$("body,html").animate({
scrollTop: $("#comments").offset().top - 100
}, 300);
calcHumanTimesOnPage();
},
error : function(){
pjaxLoading = false;
Expand Down Expand Up @@ -925,6 +926,7 @@ $(document).on("submit" , ".post-password-form" , function(){
$("#comments_more").attr("href", $("#comments_more", $vdom).attr("href"));
$("#comments_more").removeAttr("disabled");
}
calcHumanTimesOnPage();
},
error : function(){
pjaxLoading = false;
Expand Down
101 changes: 98 additions & 3 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,47 @@ function get_seo_description(){
}
if (!post_password_required()){
return
htmlspecialchars(mb_substr(str_replace("\n", '', strip_tags(get_post($post -> ID) -> post_content)), 0, 50)) . "...";
htmlspecialchars(mb_substr(str_replace("\n", '', strip_tags($post -> post_content)), 0, 50)) . "...";
}else{
return "这是一个加密页面,需要密码来查看";
}
}else{
return get_option('argon_seo_description');
}
}
//页面 Keywords
function get_seo_keywords(){
if (is_single()){
global $post;
$tags = get_the_tags('', ',', '', $post -> ID);
if ($tags != null){
$res = "";
foreach ($tags as $tag){
if ($res != ""){
$res .= ",";
}
$res .= $tag -> name;
}
return $res;
}
}
if (is_category()){
return single_cat_title('', false);
}
if (is_tag()){
return single_tag_title('', false);
}
if (is_author()){
return get_the_author();
}
if (is_post_type_archive()){
return post_type_archive_title('', false);
}
if (is_tax()){
return single_term_title('', false);
}
return get_option('argon_seo_keywords');
}
//页面浏览量
function get_post_views($post_id){
$count_key = 'views';
Expand Down Expand Up @@ -1484,6 +1517,18 @@ function argon_home_add_post_type_shuoshuo($query){
if (get_option("argon_home_show_shuoshuo") == "true"){
add_action('pre_get_posts', 'argon_home_add_post_type_shuoshuo');
}
//首页隐藏特定分类文章
function argon_home_hide_categories($query){
if (is_home() && $query -> is_main_query()){
$excludeCategories = explode(",", get_option("argon_hide_categories"));
$excludeCategories = array_map(create_function('$cat', 'return "-$cat";'), $excludeCategories);
$query -> set('cat', $excludeCategories);
}
return $query;
}
if (get_option("argon_hide_categories") != ""){
add_action('pre_get_posts', 'argon_home_hide_categories');
}
//文章过时信息显示
function argon_get_post_outdated_info(){
if (get_option("argon_outdated_info_tip_type") == "toast"){
Expand Down Expand Up @@ -2518,7 +2563,16 @@ function themeoptions_page(){
</td>
</tr>
<tr><th class="subtitle"><h2>文章</h2></th></tr>
<tr><th class="subtitle"><h3>文章 Meta 信息</h3></th></tr>
<tr><th class="subtitle"><h3>文章 Meta 信息</h3></th></tr><tr>
<th><label>显示作者</label></th>
<td>
<select name="argon_show_author">
<?php $argon_show_author = get_option('argon_show_author'); ?>
<option value="false" <?php if ($argon_show_author=='false'){echo 'selected';} ?>>不显示</option>
<option value="true" <?php if ($argon_show_author=='true'){echo 'selected';} ?>>显示</option>
</select>
</td>
</tr>
<tr>
<th><label>显示字数和预计阅读时间</label></th>
<td>
Expand Down Expand Up @@ -3002,7 +3056,7 @@ function themeoptions_page(){
<p class="description">设置是否在评论区显示评论者 UA 及显示哪些部分</p>
</td>
</tr>
<tr><th class="subtitle"><h2>其他</h2></th></tr>
<tr><th class="subtitle"><h2>杂项</h2></th></tr>
<tr>
<th><label>是否启用 Pjax</label></th>
<td>
Expand All @@ -3014,6 +3068,45 @@ function themeoptions_page(){
<p class="description">Pjax 可以增强页面的跳转体验</p>
</td>
</tr>
<tr>
<th><label>首页隐藏特定 分类/Tag 下的文章</label></th>
<td>
<input type="text" class="regular-text" name="argon_hide_categories" value="<?php echo get_option('argon_hide_categories'); ?>"/>
<p class="description">输入要隐藏的 分类/Tag 的 ID,用英文逗号分隔,留空则不隐藏</br><a onclick="$('#id_of_categories_and_tags').slideDown(500);" style="cursor: pointer;">点此查看</a>所有分类和 Tag 的 ID
<?php
echo "<div id='id_of_categories_and_tags' style='display: none;'><div style='font-size: 22px;margin-bottom: 10px;margin-top: 10px;'>分类</div>";
$categories = get_categories(array(
'hide_empty' => 0,
'hierarchical' => 0,
'taxonomy' => 'category'
));
foreach($categories as $category) {
echo "<span>".$category -> name ." -> ". $category -> term_id ."</span>";
}
echo "<div style='font-size: 22px;margin-bottom: 10px;'>Tag</div>";
$categories = get_categories(array(
'hide_empty' => 0,
'hierarchical' => 0,
'taxonomy' => 'post_tag'
));
foreach($categories as $category) {
echo "<span>".$category -> name ." -> ". $category -> term_id ."</span>";
}
echo "</div>";
?>
<style>
#id_of_categories_and_tags > span {
display: inline-block;
background: rgba(0, 0, 0, .08);
border-radius: 2px;
margin-right: 5px;
margin-bottom: 8px;
padding: 5px 10px;
}
</style>
</p>
</td>
</tr>
<tr>
<th><label>美化登录界面</label></th>
<td>
Expand Down Expand Up @@ -3446,6 +3539,8 @@ function argon_update_themeoptions(){
argon_update_option('argon_code_theme');
argon_update_option('argon_comment_enable_qq_avatar');
argon_update_option('argon_enable_login_css');
argon_update_option('argon_hide_categories');
argon_update_option('argon_show_author');

//LazyLoad 相关
argon_update_option('argon_enable_lazyload');
Expand Down
12 changes: 7 additions & 5 deletions header.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@
<meta property="og:description" content="<?php echo $seo_description?>">
<?php } ?>

<?php if (get_option('argon_seo_keywords') != ''){ ?>
<meta name="keywords" content="<?php echo get_option('argon_seo_keywords');?>">
<?php
$seo_keywords = get_seo_keywords();
if ($seo_keywords != ''){ ?>
<meta name="keywords" content="<?php echo get_seo_keywords();?>">
<?php } ?>

<meta name="theme-color" content="<?php echo $themecolor; ?>">
Expand Down Expand Up @@ -364,11 +366,11 @@ public function end_el( &$output, $object, $depth = 0, $args = array(), $current
?>
<div id="banner_container" class="banner-container container text-center">
<?php if ($enable_banner_title_typing_effect != "true"){?>
<h1 class="banner-title text-white"><span class="banner-title-inner"><?php echo $banner_title; ?></span>
<div class="banner-title text-white"><span class="banner-title-inner"><?php echo $banner_title; ?></span>
<?php } else {?>
<h1 class="banner-title text-white" data-text="<?php echo $banner_title; ?>" data-interval="<?php echo (get_option('argon_banner_typing_effect_interval') == '' ? '100' : get_option('argon_banner_typing_effect_interval')); ?>"><span class="banner-title-inner">&nbsp;</span>
<div class="banner-title text-white" data-text="<?php echo $banner_title; ?>" data-interval="<?php echo (get_option('argon_banner_typing_effect_interval') == '' ? '100' : get_option('argon_banner_typing_effect_interval')); ?>"><span class="banner-title-inner">&nbsp;</span>
<?php }?>
<?php echo get_option('argon_banner_subtitle') == '' ? '' : '<span class="banner-subtitle d-block">' . get_option('argon_banner_subtitle') . '</span>'; ?></h1>
<?php echo get_option('argon_banner_subtitle') == '' ? '' : '<span class="banner-subtitle d-block">' . get_option('argon_banner_subtitle') . '</span>'; ?></div>
</div>
<?php if (get_option('argon_banner_background_url') != '') { ?>
<style>
Expand Down
4 changes: 2 additions & 2 deletions info.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version" : "0.960",
"version" : "0.961",
"details_url" : "https://github.com/solstice23/argon-theme/releases",
"download_url" : "https://github.com/solstice23/argon-theme/releases/download/v0.960/argon.zip"
"download_url" : "https://github.com/solstice23/argon-theme/releases/download/v0.961/argon.zip"
}
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Theme Name: argon
Author: solstice23
Author URI: https://solstice23.top/
Description: 轻盈、简洁、美观的 Wordpress 主题
Version: 0.960
Version: 0.961
License: GNU General Public License v3.0
License URI: https://www.gnu.org/licenses/gpl-3.0.html
Tags: 简约, 两栏, 侧栏在左边, 浮动侧栏, 文章目录, 自适应, 夜间模式, 可自定义
Expand Down
10 changes: 10 additions & 0 deletions template-parts/content-single.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@
}
?>
</div>
<?php if (get_option("argon_show_author") == "true") { ?>
<div class="post-meta-devide">|</div>
<div class="post-meta-detail post-meta-detail-author">
<i class="fa fa-user-circle-o" aria-hidden="true"></i>
<?php
global $authordata;
echo "<a href='" . get_author_posts_url($authordata -> ID, $authordata -> user_nicename) . "' target='_blank'>" . get_the_author() . "</a>";
?>
</div>
<?php } ?>
<?php if (!post_password_required() && get_option("argon_show_readingtime") != "false" && is_readingtime_meta_hidden() == False) { ?>
</br>
<div class="post-meta-detail post-meta-detail-words">
Expand Down
10 changes: 10 additions & 0 deletions template-parts/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@
}
?>
</div>
<?php if (get_option("argon_show_author") == "true") { ?>
<div class="post-meta-devide">|</div>
<div class="post-meta-detail post-meta-detail-author">
<i class="fa fa-user-circle-o" aria-hidden="true"></i>
<?php
global $authordata;
echo "<a href='" . get_author_posts_url($authordata -> ID, $authordata -> user_nicename) . "' target='_blank'>" . get_the_author() . "</a>";
?>
</div>
<?php } ?>
<?php if (!post_password_required() && get_option("argon_show_readingtime") != "false" && is_readingtime_meta_hidden() == False) { ?>
</br>
<div class="post-meta-detail post-meta-detail-words">
Expand Down

0 comments on commit 3eb8a48

Please sign in to comment.