Skip to content

Commit

Permalink
Merge pull request #119 from taotecode/preview
Browse files Browse the repository at this point in the history
计算天数支持文章,完善文章底部版权信息功能,支持变量
  • Loading branch information
Tokinx authored Sep 14, 2023
2 parents 6bc95ef + 7ad0bcc commit 8bb93c0
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 2 deletions.
15 changes: 13 additions & 2 deletions inc/core-rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,17 @@ function ajax_affiliate_info_callback() {
"avatar" => get_avatar_url( $post->post_author ),
];

//底部版权信息
$licenseHtml=get_theme_mod( 'biji_setting_article_bottom_cc_license' );
// 对里面的内容进行替换,%title%替换为文章标题,%link%替换为文章链接,%author%替换为作者名字
$licenseHtml=str_replace("%title%",$post->post_title,$licenseHtml);
$licenseHtml=str_replace("%link%",get_permalink($post->ID),$licenseHtml);
$licenseHtml=str_replace("%author%",$data->author->display_name,$licenseHtml);
$data->license = (object) [
"enable" => get_theme_mod( 'biji_setting_article_bottom_cc_license_enable' ),
"html" => $licenseHtml,
];

wp_send_json_success( $data );
} else {
wp_send_json_error( "Parameter error", 400 );
Expand Down Expand Up @@ -471,9 +482,9 @@ function ajax_get_heatmap_callback() {
$_posts = wp_count_posts( 'post' );
// 获取笔记总数
$_notes = wp_count_posts( 'note' );
// 最老一篇笔记
// 最老一篇文章和笔记
$last = get_posts( [
'post_type' => 'note',
'post_type' => [ 'post', 'note' ],
'posts_per_rows' => 1,
'orderby' => 'date',
'order' => 'ASC',
Expand Down
18 changes: 18 additions & 0 deletions inc/core-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,24 @@ function bijiHandleExcludeChange(result = []) {
'type' => 'checkbox',
]
],
[
"id" => "biji_setting_article_bottom_cc_license_enable",
"setting" => [ "default" => false ],
"control" => [
'label' => '开启文章底部版权信息',
'description' => '开启后文章底部显示版权信息',
'type' => 'checkbox',
]
],
[
"id" =>"biji_setting_article_bottom_cc_license",
"setting" => [ "default" => "" ],
"control" => [
'label' => '文章底部版权信息',
'description' => '文章底部版权信息,支持HTML代码,如:本页采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。<br><b>%title%</b>为文章标题<br><b>%link%</b>为文章链接<br><b>%author%</b>为作者名字',
'type' => 'textarea',
]
],
[
"id" => "biji_setting_article_foot",
"setting" => [ "default" => "" ],
Expand Down
14 changes: 14 additions & 0 deletions static/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@ const $modules = new function () {
<i class="czs-setting-l"></i>
</button>
</div>
</div>
</div>
<div v-if="license.enable" class="license tile tile-centered my-4 p-0">
<p v-html="license.html"></p>
</div>
<ul v-if="adjacent_articles && adjacent" class="pagination">
<li v-for="key of Object.keys(adjacent)" :key="key" :class="'page-item w-0 page-' + key">
<a :href="adjacent[key].permalink || 'javascript: void(0);'" class="w-100 text-gray">
Expand Down Expand Up @@ -73,6 +78,9 @@ const $modules = new function () {
},
settings() {
return !!document.querySelector("#Links");
},
license() {
return this.affiliateInfo.license;
}
},
created() {
Expand Down Expand Up @@ -666,6 +674,12 @@ const $modules = new function () {
pagination: { rows: 10, rolling: true, autoload: true },
visitor: {},
author: {},

// 版权
license: {
enable: false,
html: null,
}
};
},
computed: {
Expand Down
9 changes: 9 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2996,6 +2996,11 @@ a.text-error:visited {
margin-top: 0.4rem !important;
}

.my-4 {
margin-bottom: 1.6rem !important;
margin-top: 1.6rem !important;
}

.p-0 {
padding: 0 !important;
}
Expand Down Expand Up @@ -4351,6 +4356,10 @@ body .layout .affiliate .pagination li {
body .layout .affiliate .pagination li:first-child {
border-right: 1px solid rgba(188, 195, 206, 0.2);
}
body .layout .affiliate .license p{
font-size: 12px;
color: #797979;
}
body .layout .modal-links .modal {
background: #000;
}
Expand Down

0 comments on commit 8bb93c0

Please sign in to comment.