mirror of https://github.com/vtrois/kratos
refactor: formatting code
parent
da84d9c478
commit
c248897937
3
404.php
3
404.php
|
@ -1,9 +1,10 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* 404 模板
|
||||
* @author Seaton Jiang <seatonjiang@vtrois.com>
|
||||
* @license MIT License
|
||||
* @version 2021.06.25
|
||||
* @version 2021.08.19
|
||||
*/
|
||||
|
||||
get_header(); ?>
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* 评论模板
|
||||
* @author Seaton Jiang <seatonjiang@vtrois.com>
|
||||
* @license MIT License
|
||||
* @version 2021.06.25
|
||||
* @version 2021.08.19
|
||||
*/
|
||||
|
||||
if (isset($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME'])) {
|
||||
|
@ -12,7 +13,11 @@ if (isset($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['S
|
|||
require get_template_directory() . '/pages/page-smilies.php';
|
||||
if (comments_open()) { ?>
|
||||
<div class="comments" id="comments">
|
||||
<h3 class="title"><?php if (is_single()) {_e('文章评论', 'kratos');} else {_e('评论内容', 'kratos');}?></h3>
|
||||
<h3 class="title"><?php if (is_single()) {
|
||||
_e('文章评论', 'kratos');
|
||||
} else {
|
||||
_e('评论内容', 'kratos');
|
||||
} ?></h3>
|
||||
<div class="list">
|
||||
<?php wp_list_comments('type=comment&callback=comment_callbacks'); ?>
|
||||
</div>
|
||||
|
|
13
header.php
13
header.php
|
@ -1,13 +1,15 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* 主题页眉
|
||||
* @author Seaton Jiang <seatonjiang@vtrois.com>
|
||||
* @license MIT License
|
||||
* @version 2021.06.25
|
||||
* @version 2021.08.19
|
||||
*/
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-cn">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
|
@ -19,12 +21,17 @@
|
|||
<meta name="theme-color" content="<?php echo kratos_option('g_chrome', '#282a2c'); ?>">
|
||||
<meta itemprop="image" content="<?php echo share_thumbnail_url(); ?>" />
|
||||
<?php if (kratos_option('g_icon')) echo '<link rel="shortcut icon" href="' . kratos_option("g_icon") . '">' ?>
|
||||
<?php wp_head(); wp_print_scripts('jquery'); mourning(); ?>
|
||||
<?php wp_head();
|
||||
wp_print_scripts('jquery');
|
||||
mourning(); ?>
|
||||
</head>
|
||||
<?php flush(); ?>
|
||||
|
||||
<body>
|
||||
<div class="k-header">
|
||||
<nav class="k-nav navbar navbar-expand-lg navbar-light fixed-top" <?php if(kratos_option('top_select', 'banner') !== 'banner'){ echo 'style="background:' . kratos_option('top_color', '#24292e') .'"';} ?>>
|
||||
<nav class="k-nav navbar navbar-expand-lg navbar-light fixed-top" <?php if (kratos_option('top_select', 'banner') !== 'banner') {
|
||||
echo 'style="background:' . kratos_option('top_color', '#24292e') . '"';
|
||||
} ?>>
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="<?php echo get_option('home'); ?>">
|
||||
<?php
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* dogecloud 对象存储
|
||||
* @author Seaton Jiang <seatonjiang@vtrois.com>
|
||||
* @license MIT License
|
||||
* @version 2021.06.25
|
||||
* @version 2021.08.19
|
||||
*/
|
||||
|
||||
if (kratos_option('g_cos', false)) {
|
||||
function dogcloud_upload($object, $file, $mime){
|
||||
function dogcloud_upload($object, $file, $mime)
|
||||
{
|
||||
if (!@file_exists($file)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* 站点相关函数
|
||||
* @author Seaton Jiang <seatonjiang@vtrois.com>
|
||||
* @license MIT License
|
||||
* @version 2021.06.25
|
||||
* @version 2021.08.19
|
||||
*/
|
||||
|
||||
// 标题配置
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* 文章短代码
|
||||
* @author Seaton Jiang <seatonjiang@vtrois.com>
|
||||
* @license MIT License
|
||||
* @version 2021.06.25
|
||||
* @version 2021.08.19
|
||||
*/
|
||||
|
||||
function h2title($atts, $content = null, $code = "")
|
||||
|
@ -212,7 +213,8 @@ function reply($atts, $content = null)
|
|||
}
|
||||
add_shortcode('reply', 'reply');
|
||||
|
||||
function accordion($atts, $content=null, $code=""){
|
||||
function accordion($atts, $content = null, $code = "")
|
||||
{
|
||||
extract(shortcode_atts(array("title" => __('标题内容', 'kratos')), $atts));
|
||||
$return = '<div class="accordion"><div class="acheader"><div class="icon"><i class="kicon i-plus"></i></div><span>';
|
||||
$return .= $title;
|
||||
|
@ -223,7 +225,8 @@ function accordion($atts, $content=null, $code=""){
|
|||
}
|
||||
add_shortcode('accordion', 'accordion');
|
||||
|
||||
function dplayer($atts = array(), $content = ''){
|
||||
function dplayer($atts = array(), $content = '')
|
||||
{
|
||||
static $instance = 0;
|
||||
$instance++;
|
||||
|
||||
|
@ -238,7 +241,10 @@ function dplayer($atts = array(), $content = ''){
|
|||
'type' => 'auto',
|
||||
'mutex' => 'true',
|
||||
'iconsColor' => '#ffffff'
|
||||
), $atts, 'dplayer');
|
||||
),
|
||||
$atts,
|
||||
'dplayer'
|
||||
);
|
||||
|
||||
$atts['autoplay'] = wp_validate_boolean($atts['autoplay']);
|
||||
$atts['theme'] = esc_attr($atts['theme']);
|
||||
|
@ -252,7 +258,8 @@ function dplayer($atts = array(), $content = ''){
|
|||
|
||||
if (empty($atts['src'])) return;
|
||||
|
||||
$output = sprintf( '<script> const dp%u = new DPlayer({ container: document.getElementById("dplayer-%u"), autoplay: %b, theme: "%s", loop: %b, preload: "%s", video: { url: "%s", type: "%s", pic: "%s", }, mutex: %b, iconsColor: "%s" }); </script>',
|
||||
$output = sprintf(
|
||||
'<script> const dp%u = new DPlayer({ container: document.getElementById("dplayer-%u"), autoplay: %b, theme: "%s", loop: %b, preload: "%s", video: { url: "%s", type: "%s", pic: "%s", }, mutex: %b, iconsColor: "%s" }); </script>',
|
||||
$instance,
|
||||
$instance,
|
||||
$atts['autoplay'],
|
||||
|
@ -266,7 +273,8 @@ function dplayer($atts = array(), $content = ''){
|
|||
$atts['iconsColor']
|
||||
);
|
||||
|
||||
$html = sprintf( '<p><div id="dplayer-%u"></div></p>',
|
||||
$html = sprintf(
|
||||
'<p><div id="dplayer-%u"></div></p>',
|
||||
$instance
|
||||
);
|
||||
|
||||
|
@ -278,7 +286,8 @@ function dplayer($atts = array(), $content = ''){
|
|||
}
|
||||
add_shortcode('dplayer', 'dplayer');
|
||||
|
||||
function override_wp_video_shortcode( $html = '', $atts = array() ) {
|
||||
function override_wp_video_shortcode($html = '', $atts = array())
|
||||
{
|
||||
if (empty($atts['src'])) {
|
||||
if (!empty($atts['mp4'])) {
|
||||
$atts['src'] = $atts['mp4'];
|
||||
|
@ -322,7 +331,8 @@ function more_button()
|
|||
}
|
||||
}
|
||||
|
||||
function add_more_buttons($buttons) {
|
||||
function add_more_buttons($buttons)
|
||||
{
|
||||
$buttons[] = 'hr';
|
||||
$buttons[] = 'wp_page';
|
||||
$buttons[] = 'fontsizeselect';
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* SMTP 配置
|
||||
* @author Seaton Jiang <seatonjiang@vtrois.com>
|
||||
* @license MIT License
|
||||
* @version 2021.06.25
|
||||
* @version 2021.08.19
|
||||
*/
|
||||
|
||||
if (kratos_option('m_smtp', false)) {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* ImageX 图片服务
|
||||
* @author Seaton Jiang <seatonjiang@vtrois.com>
|
||||
* @license MIT License
|
||||
* @version 2021.06.25
|
||||
* @version 2021.08.19
|
||||
*/
|
||||
require_once 'volcengine-imagex/vendor/autoload.php';
|
||||
|
||||
|
@ -20,7 +21,8 @@ if (kratos_option('g_imgx', false)) {
|
|||
return $imagex_client;
|
||||
}
|
||||
|
||||
function imagex_upload($object, $file){
|
||||
function imagex_upload($object, $file)
|
||||
{
|
||||
if (!@file_exists($file)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* 侧栏小工具
|
||||
* @author Seaton Jiang <seatonjiang@vtrois.com>
|
||||
* @license MIT License
|
||||
* @version 2021.06.26
|
||||
* @version 2021.08.19
|
||||
*/
|
||||
|
||||
// 添加小工具
|
||||
|
@ -55,7 +56,8 @@ function widgets_init()
|
|||
add_action('widgets_init', 'widgets_init');
|
||||
|
||||
// 分类目录计数
|
||||
function cat_count_span( $links ) {
|
||||
function cat_count_span($links)
|
||||
{
|
||||
$links = str_replace('</a> (', '<span> / ', $links);
|
||||
$links = str_replace(')', __('篇', 'kratos') . '</span></a>', $links);
|
||||
return $links;
|
||||
|
@ -63,7 +65,8 @@ function cat_count_span( $links ) {
|
|||
add_filter('wp_list_categories', 'cat_count_span');
|
||||
|
||||
// 文章归档计数
|
||||
function archive_count_span( $links ) {
|
||||
function archive_count_span($links)
|
||||
{
|
||||
$links = str_replace('</a> (', '<span> / ', $links);
|
||||
$links = str_replace(')', __('篇', 'kratos') . '</span></a>', $links);
|
||||
return $links;
|
||||
|
@ -94,7 +97,8 @@ function most_comm_posts($days = 30, $nums = 6)
|
|||
echo $output;
|
||||
}
|
||||
|
||||
function timeago($time) {
|
||||
function timeago($time)
|
||||
{
|
||||
$time = strtotime($time);
|
||||
$dtime = time() - $time;
|
||||
if ($dtime < 1) return __('刚刚', 'kratos');
|
||||
|
@ -113,7 +117,8 @@ function timeago($time) {
|
|||
}
|
||||
}
|
||||
|
||||
function string_cut($string, $sublen, $start = 0, $code = 'UTF-8') {
|
||||
function string_cut($string, $sublen, $start = 0, $code = 'UTF-8')
|
||||
{
|
||||
if ($code == 'UTF-8') {
|
||||
$pa = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xef][\x80-\xbf][\x80-\xbf]|\xf0[\x90-\xbf][\x80-\xbf][\x80-\xbf]|[\xf1-\xf7][\x80-\xbf][\x80-\xbf][\x80-\xbf]/";
|
||||
preg_match_all($pa, $string, $t_string);
|
||||
|
@ -157,7 +162,8 @@ function latest_comments($list_number=5, $cut_length=50)
|
|||
class widget_search extends WP_Widget
|
||||
{
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$widget_ops = array(
|
||||
'classname' => 'widget_search',
|
||||
'description' => __('A search form for your site.'),
|
||||
|
@ -166,7 +172,8 @@ class widget_search extends WP_Widget
|
|||
parent::__construct('search', _x('Search', 'Search widget'), $widget_ops);
|
||||
}
|
||||
|
||||
public function widget( $args, $instance ) {
|
||||
public function widget($args, $instance)
|
||||
{
|
||||
$title = !empty($instance['title']) ? $instance['title'] : '';
|
||||
$title = apply_filters('widget_title', $title, $instance, $this->id_base);
|
||||
|
||||
|
@ -178,7 +185,8 @@ class widget_search extends WP_Widget
|
|||
echo '</div></div>';
|
||||
}
|
||||
|
||||
public function form( $instance ) {
|
||||
public function form($instance)
|
||||
{
|
||||
$instance = wp_parse_args((array) $instance, array('title' => ''));
|
||||
$title = $instance['title'];
|
||||
?>
|
||||
|
@ -186,13 +194,13 @@ class widget_search extends WP_Widget
|
|||
<?php
|
||||
}
|
||||
|
||||
public function update( $new_instance, $old_instance ) {
|
||||
public function update($new_instance, $old_instance)
|
||||
{
|
||||
$instance = $old_instance;
|
||||
$new_instance = wp_parse_args((array) $new_instance, array('title' => ''));
|
||||
$instance['title'] = sanitize_text_field($new_instance['title']);
|
||||
return $instance;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class widget_ad extends WP_Widget
|
||||
|
@ -350,7 +358,8 @@ class widget_tags extends WP_Widget
|
|||
{
|
||||
$number = !empty($instance['number']) ? $instance['number'] : '8';
|
||||
$order = !empty($instance['order']) ? $instance['order'] : 'RAND';
|
||||
$tags = wp_tag_cloud(array(
|
||||
$tags = wp_tag_cloud(
|
||||
array(
|
||||
'unit' => 'px',
|
||||
'smallest' => 14,
|
||||
'largest' => 14,
|
||||
|
@ -433,15 +442,19 @@ class widget_posts extends WP_Widget
|
|||
</div>
|
||||
<div class="tab-content" id="nav-tabContent">
|
||||
<div class="tab-pane fade <?php echo $active = ($order == 'new') ? 'show active' : null; ?>" id="nav-new" role="tabpanel" aria-labelledby="nav-new-tab">
|
||||
<?php $myposts = get_posts('numberposts=' . $number . ' & offset=0');foreach ($myposts as $post): ?>
|
||||
<?php $myposts = get_posts('numberposts=' . $number . ' & offset=0');
|
||||
foreach ($myposts as $post) : ?>
|
||||
<a class="bookmark-item" rel="bookmark" title="<?php echo esc_attr(strip_tags($post->post_title)); ?>" href="<?php echo get_permalink($post->ID); ?>"><i class="kicon i-book"></i><?php echo esc_attr(strip_tags($post->post_title)); ?></a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<div class="tab-pane fade <?php echo $active = ($order == 'hot') ? 'show active' : null; ?>" id="nav-hot" role="tabpanel" aria-labelledby="nav-hot-tab">
|
||||
<?php if (function_exists('most_comm_posts')) {most_comm_posts($days, $number);}?>
|
||||
<?php if (function_exists('most_comm_posts')) {
|
||||
most_comm_posts($days, $number);
|
||||
} ?>
|
||||
</div>
|
||||
<div class="tab-pane fade <?php echo $active = ($order == 'random') ? 'show active' : null; ?>" id="nav-random" role="tabpanel" aria-labelledby="nav-random-tab">
|
||||
<?php $myposts = get_posts('numberposts=' . $number . ' & offset=0 & orderby=rand');foreach ($myposts as $post): ?>
|
||||
<?php $myposts = get_posts('numberposts=' . $number . ' & offset=0 & orderby=rand');
|
||||
foreach ($myposts as $post) : ?>
|
||||
<a class="bookmark-item" rel="bookmark" title="<?php echo esc_attr(strip_tags($post->post_title)); ?>" href="<?php echo get_permalink($post->ID); ?>"><i class="kicon i-book"></i><?php echo esc_attr(strip_tags($post->post_title)); ?></a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* 首页模板
|
||||
* @author Seaton Jiang <seatonjiang@vtrois.com>
|
||||
* @license MIT License
|
||||
* @version 2021.06.26
|
||||
* @version 2021.08.19
|
||||
*/
|
||||
|
||||
get_header(); ?>
|
||||
|
@ -13,9 +14,11 @@ get_header(); ?>
|
|||
<div class="col-lg-8 board">
|
||||
<?php if (is_home() && kratos_option('g_carousel', false)) {
|
||||
kratos_carousel();
|
||||
} if(is_search()){ ?>
|
||||
}
|
||||
if (is_search()) { ?>
|
||||
<div class="article-panel">
|
||||
<div class="search-title"><?php _e('搜索内容:', 'kratos');the_search_query(); ?></div>
|
||||
<div class="search-title"><?php _e('搜索内容:', 'kratos');
|
||||
the_search_query(); ?></div>
|
||||
</div>
|
||||
<?php }
|
||||
if (have_posts()) {
|
||||
|
|
6
page.php
6
page.php
|
@ -1,9 +1,10 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* 页面模板
|
||||
* @author Seaton Jiang <seatonjiang@vtrois.com>
|
||||
* @license MIT License
|
||||
* @version 2021.06.26
|
||||
* @version 2021.08.19
|
||||
*/
|
||||
|
||||
get_header(); ?>
|
||||
|
@ -11,7 +12,8 @@ get_header(); ?>
|
|||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 details">
|
||||
<?php if (have_posts()) : the_post(); update_post_caches($posts); ?>
|
||||
<?php if (have_posts()) : the_post();
|
||||
update_post_caches($posts); ?>
|
||||
<div class="article py-4">
|
||||
<div class="header text-center">
|
||||
<h1 class="title m-0"><?php the_title(); ?></h1>
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* 文章列表
|
||||
* @author Seaton Jiang <seatonjiang@vtrois.com>
|
||||
* @license MIT License
|
||||
* @version 2021.06.25
|
||||
* @version 2021.08.19
|
||||
*/
|
||||
?>
|
||||
<div class="article-panel">
|
||||
<span class="a-card d-none d-md-block d-lg-block">
|
||||
<?php $article_comment = kratos_option('g_article_comment', '20'); $article_love = kratos_option('g_article_love', '200'); if (is_sticky()) { ?>
|
||||
<?php $article_comment = kratos_option('g_article_comment', '20');
|
||||
$article_love = kratos_option('g_article_love', '200');
|
||||
if (is_sticky()) { ?>
|
||||
<i class="kicon i-card-top"></i>
|
||||
<?php } elseif (findSinglecomments($post->ID) >= $article_comment || get_post_meta($post->ID, 'love', true) >= $article_love) { ?>
|
||||
<i class="kicon i-card-hot"></i>
|
||||
|
@ -21,7 +24,9 @@
|
|||
</a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div class="a-post <?php if (!kratos_option('g_thumbnail',true)) { echo 'a-none'; } ?>">
|
||||
<div class="a-post <?php if (!kratos_option('g_thumbnail', true)) {
|
||||
echo 'a-none';
|
||||
} ?>">
|
||||
<div class="header">
|
||||
<?php
|
||||
$category = get_the_category();
|
||||
|
@ -40,11 +45,18 @@
|
|||
<div class="a-meta">
|
||||
<span class="float-left d-none d-md-block">
|
||||
<span class="mr-2"><i class="kicon i-calendar"></i><?php echo get_the_date(); ?></span>
|
||||
<span class="mr-2"><i class="kicon i-comments"></i><?php comments_number('0', '1', '%'); _e('条评论', 'kratos'); ?></span>
|
||||
<span class="mr-2"><i class="kicon i-comments"></i><?php comments_number('0', '1', '%');
|
||||
_e('条评论', 'kratos'); ?></span>
|
||||
</span>
|
||||
<span class="float-left d-block">
|
||||
<span class="mr-2"><i class="kicon i-hot"></i><?php echo get_post_views(); _e('点热度', 'kratos'); ?></span>
|
||||
<span class="mr-2"><i class="kicon i-good"></i><?php if (get_post_meta($post->ID, 'love', true)) {echo get_post_meta($post->ID, 'love', true);} else {echo '0';} _e('人点赞', 'kratos'); ?></span>
|
||||
<span class="mr-2"><i class="kicon i-hot"></i><?php echo get_post_views();
|
||||
_e('点热度', 'kratos'); ?></span>
|
||||
<span class="mr-2"><i class="kicon i-good"></i><?php if (get_post_meta($post->ID, 'love', true)) {
|
||||
echo get_post_meta($post->ID, 'love', true);
|
||||
} else {
|
||||
echo '0';
|
||||
}
|
||||
_e('人点赞', 'kratos'); ?></span>
|
||||
<span class="mr-2"><i class="kicon i-author"></i><?php echo get_the_author_meta('display_name'); ?></span>
|
||||
</span>
|
||||
<span class="float-right">
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* 表情图标
|
||||
* @author Seaton Jiang <seatonjiang@vtrois.com>
|
||||
* @license MIT License
|
||||
* @version 2021.06.25
|
||||
* @version 2021.08.19
|
||||
*/
|
||||
$smilies = '
|
||||
<a href="javascript:grin(\':razz:\')"><img src="' . ASSET_PATH . '/assets/img/smilies/razz.png" alt="" class="d-block"/></a>
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* 文章工具栏
|
||||
* @author Seaton Jiang <seatonjiang@vtrois.com>
|
||||
* @license MIT License
|
||||
* @version 2021.06.25
|
||||
* @version 2021.08.19
|
||||
*/
|
||||
?>
|
||||
<div class="toolbar clearfix">
|
||||
|
|
Loading…
Reference in New Issue