mirror of https://github.com/vtrois/kratos
refactor: formatting code
parent
da84d9c478
commit
c248897937
5
404.php
5
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(); ?>
|
||||
|
@ -12,7 +13,7 @@ get_header(); ?>
|
|||
<div class="row">
|
||||
<div class="col-12 page404">
|
||||
<div class="thumbnail" style="background-image: url(<?php
|
||||
if(!kratos_option('g_404')){
|
||||
if (!kratos_option('g_404')) {
|
||||
$img = ASSET_PATH . '/assets/img/404.jpg';
|
||||
} else {
|
||||
$img = kratos_option('g_404', ASSET_PATH . '/assets/img/404.jpg');
|
||||
|
|
43
comments.php
43
comments.php
|
@ -1,33 +1,38 @@
|
|||
<?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'])) {
|
||||
die();
|
||||
}
|
||||
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>
|
||||
if (comments_open()) { ?>
|
||||
<div class="comments" id="comments">
|
||||
<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');?>
|
||||
<?php wp_list_comments('type=comment&callback=comment_callbacks'); ?>
|
||||
</div>
|
||||
<div id="commentpage" class="nav text-center my-3">
|
||||
<?php previous_comments_link(__('加载更多', 'kratos'));?>
|
||||
<?php previous_comments_link(__('加载更多', 'kratos')); ?>
|
||||
</div>
|
||||
<div id="respond" class="comment-respond mt-2">
|
||||
<?php if (!comments_open()): elseif (get_option('comment_registration') && !is_user_logged_in()): ?>
|
||||
<?php if (!comments_open()) : elseif (get_option('comment_registration') && !is_user_logged_in()) : ?>
|
||||
<div class="error text-center">
|
||||
<?php printf(__('您需要 <a href="%s">登录</a> 之后才可以评论', 'kratos'), wp_login_url(get_permalink()));?>
|
||||
<?php printf(__('您需要 <a href="%s">登录</a> 之后才可以评论', 'kratos'), wp_login_url(get_permalink())); ?>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php else : ?>
|
||||
<form id="commentform" name="commentform" action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post">
|
||||
<div class="comment-form">
|
||||
<?php if (!is_user_logged_in()): ?>
|
||||
<?php if (!is_user_logged_in()) : ?>
|
||||
<div class="comment-info mb-3 row">
|
||||
<div class="col-md-6 comment-form-author">
|
||||
<div class="input-group">
|
||||
|
@ -54,7 +59,7 @@ if (comments_open()) {?>
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
<?php endif; ?>
|
||||
<div class="comment-textarea">
|
||||
<textarea class="form-control" id="comment" name="comment" rows="7" required="required"></textarea>
|
||||
<div class="text-bar clearfix">
|
||||
|
@ -67,17 +72,17 @@ if (comments_open()) {?>
|
|||
</div>
|
||||
</div>
|
||||
<div class="float-right">
|
||||
<?php cancel_comment_reply_link(__('取消回复', 'kratos'));?>
|
||||
<input name="submit" type="submit" id="submit" class="btn btn-primary" value="<?php _e('提交评论', 'kratos');?>">
|
||||
<?php cancel_comment_reply_link(__('取消回复', 'kratos')); ?>
|
||||
<input name="submit" type="submit" id="submit" class="btn btn-primary" value="<?php _e('提交评论', 'kratos'); ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php comment_id_fields();?>
|
||||
<?php do_action('comment_form_after');?>
|
||||
<?php do_action('comment_form', $post->ID);?>
|
||||
<?php comment_id_fields(); ?>
|
||||
<?php do_action('comment_form_after'); ?>
|
||||
<?php do_action('comment_form', $post->ID); ?>
|
||||
</form>
|
||||
<?php endif;?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php }?>
|
||||
</div>
|
||||
<?php } ?>
|
39
header.php
39
header.php
|
@ -1,49 +1,56 @@
|
|||
<?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">
|
||||
<title><?php wp_title( '-', true, 'right' ); ?></title>
|
||||
<title><?php wp_title('-', true, 'right'); ?></title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta name="format-detection" content="telphone=no, email=no">
|
||||
<meta name="keywords" content="<?php echo keywords(); ?>">
|
||||
<meta name="description" itemprop="description" content="<?php echo description(); ?>">
|
||||
<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(); ?>
|
||||
<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(); ?>
|
||||
</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') .'"';} ?>>
|
||||
<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') . '"';
|
||||
} ?>>
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="<?php echo get_option('home'); ?>">
|
||||
<?php
|
||||
if (kratos_option('g_logo')){
|
||||
if (kratos_option('g_logo')) {
|
||||
echo '<img src="' . kratos_option('g_logo') . '"><h1 style="display:none">' . get_bloginfo('name') . '</h1>';
|
||||
}else{
|
||||
} else {
|
||||
echo '<h1>' . get_bloginfo('name') . '</h1>';
|
||||
}
|
||||
?>
|
||||
</a>
|
||||
<?php if ( has_nav_menu('header_menu') ) { ?>
|
||||
<?php if (has_nav_menu('header_menu')) { ?>
|
||||
<button class="navbar-toggler navbar-toggler-right" id="navbutton" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="line first-line"></span>
|
||||
<span class="line second-line"></span>
|
||||
<span class="line third-line"></span>
|
||||
</button>
|
||||
<?php }
|
||||
if ( has_nav_menu('header_menu') ) {
|
||||
wp_nav_menu( array(
|
||||
if (has_nav_menu('header_menu')) {
|
||||
wp_nav_menu(array(
|
||||
'theme_location' => 'header_menu',
|
||||
'depth' => 2,
|
||||
'container' => 'div',
|
||||
|
@ -51,16 +58,16 @@
|
|||
'container_id' => 'navbarResponsive',
|
||||
'menu_class' => 'navbar-nav ml-auto',
|
||||
'walker' => new WP_Bootstrap_Navwalker(),
|
||||
) );
|
||||
));
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</nav>
|
||||
<?php if(kratos_option('top_select', 'banner') == 'banner'){ ?>
|
||||
<?php if (kratos_option('top_select', 'banner') == 'banner') { ?>
|
||||
<div class="banner">
|
||||
<div class="overlay"></div>
|
||||
<div class="content text-center" style="background-image: url(<?php
|
||||
if(!kratos_option('top_img')){
|
||||
if (!kratos_option('top_img')) {
|
||||
$img = ASSET_PATH . '/assets/img/background.png';
|
||||
} else {
|
||||
$img = kratos_option('top_img', ASSET_PATH . '/assets/img/background.png');
|
||||
|
@ -80,4 +87,4 @@
|
|||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
|
@ -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
|
||||
*/
|
||||
|
||||
// 标题配置
|
||||
|
@ -104,7 +105,7 @@ function mourning()
|
|||
function share_thumbnail_url()
|
||||
{
|
||||
global $post;
|
||||
if(!is_object($post))
|
||||
if (!is_object($post))
|
||||
return;
|
||||
if (has_post_thumbnail($post->ID)) {
|
||||
$post_thumbnail_id = get_post_thumbnail_id($post);
|
||||
|
|
|
@ -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 = "")
|
||||
|
@ -177,7 +178,7 @@ add_shortcode('bilibili', 'bilibili');
|
|||
|
||||
function reply($atts, $content = null)
|
||||
{
|
||||
extract(shortcode_atts(array("notice" => '<div class="alert alert-primary text-center" role="alert">'.__('温馨提示:此处内容已隐藏,<a href="#comments">回复</a>后刷新页面即可查看!', 'kratos').'</div>'), $atts));
|
||||
extract(shortcode_atts(array("notice" => '<div class="alert alert-primary text-center" role="alert">' . __('温馨提示:此处内容已隐藏,<a href="#comments">回复</a>后刷新页面即可查看!', 'kratos') . '</div>'), $atts));
|
||||
$userEmail = null;
|
||||
$user_ID = (int) wp_get_current_user()->ID;
|
||||
if ($user_ID > 0) {
|
||||
|
@ -212,8 +213,9 @@ function reply($atts, $content = null)
|
|||
}
|
||||
add_shortcode('reply', 'reply');
|
||||
|
||||
function accordion($atts, $content=null, $code=""){
|
||||
extract(shortcode_atts(array("title"=>__('标题内容','kratos')),$atts));
|
||||
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;
|
||||
$return .= '</span></div><div class="contents"><div class="inner">';
|
||||
|
@ -221,9 +223,10 @@ function accordion($atts, $content=null, $code=""){
|
|||
$return .= '</div></div></div>';
|
||||
return $return;
|
||||
}
|
||||
add_shortcode('accordion','accordion');
|
||||
add_shortcode('accordion', 'accordion');
|
||||
|
||||
function dplayer($atts = array(), $content = ''){
|
||||
function dplayer($atts = array(), $content = '')
|
||||
{
|
||||
static $instance = 0;
|
||||
$instance++;
|
||||
|
||||
|
@ -238,21 +241,25 @@ 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'] );
|
||||
$atts['loop'] = wp_validate_boolean( $atts['loop'] );
|
||||
$atts['preload'] = esc_attr( $atts['preload'] );
|
||||
$atts['src'] = esc_url_raw( $atts['src'] );
|
||||
$atts['poster'] = esc_url_raw( $atts['poster'] );
|
||||
$atts['type'] = strtolower( esc_attr( $atts['type'] ) );
|
||||
$atts['mutex'] = wp_validate_boolean( $atts['mutex'] );
|
||||
$atts['iconsColor'] = esc_attr( $atts['iconsColor'] );
|
||||
$atts['autoplay'] = wp_validate_boolean($atts['autoplay']);
|
||||
$atts['theme'] = esc_attr($atts['theme']);
|
||||
$atts['loop'] = wp_validate_boolean($atts['loop']);
|
||||
$atts['preload'] = esc_attr($atts['preload']);
|
||||
$atts['src'] = esc_url_raw($atts['src']);
|
||||
$atts['poster'] = esc_url_raw($atts['poster']);
|
||||
$atts['type'] = strtolower(esc_attr($atts['type']));
|
||||
$atts['mutex'] = wp_validate_boolean($atts['mutex']);
|
||||
$atts['iconsColor'] = esc_attr($atts['iconsColor']);
|
||||
|
||||
if ( empty( $atts['src'] ) ) return;
|
||||
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,48 +273,50 @@ 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
|
||||
);
|
||||
|
||||
add_action( 'wp_footer', function () use ( $output ) {
|
||||
add_action('wp_footer', function () use ($output) {
|
||||
echo ' ' . $output . "\n";
|
||||
}, 99999 );
|
||||
}, 99999);
|
||||
|
||||
return $html;
|
||||
}
|
||||
add_shortcode('dplayer','dplayer');
|
||||
add_shortcode('dplayer', 'dplayer');
|
||||
|
||||
function override_wp_video_shortcode( $html = '', $atts = array() ) {
|
||||
if ( empty( $atts['src'] ) ) {
|
||||
if (!empty( $atts['mp4'] )) {
|
||||
$atts['src']=$atts['mp4'];
|
||||
}elseif(!empty( $atts['m4v'] )) {
|
||||
$atts['src']=$atts['m4v'];
|
||||
}elseif(!empty( $atts['webm'] )) {
|
||||
$atts['src']=$atts['webm'];
|
||||
}elseif(!empty( $atts['ogv'] )) {
|
||||
$atts['src']=$atts['ogv'];
|
||||
}elseif(!empty( $atts['wmv'] )) {
|
||||
$atts['src']=$atts['wmv'];
|
||||
}elseif(!empty( $atts['flv'] )) {
|
||||
$atts['src']=$atts['flv'];
|
||||
function override_wp_video_shortcode($html = '', $atts = array())
|
||||
{
|
||||
if (empty($atts['src'])) {
|
||||
if (!empty($atts['mp4'])) {
|
||||
$atts['src'] = $atts['mp4'];
|
||||
} elseif (!empty($atts['m4v'])) {
|
||||
$atts['src'] = $atts['m4v'];
|
||||
} elseif (!empty($atts['webm'])) {
|
||||
$atts['src'] = $atts['webm'];
|
||||
} elseif (!empty($atts['ogv'])) {
|
||||
$atts['src'] = $atts['ogv'];
|
||||
} elseif (!empty($atts['wmv'])) {
|
||||
$atts['src'] = $atts['wmv'];
|
||||
} elseif (!empty($atts['flv'])) {
|
||||
$atts['src'] = $atts['flv'];
|
||||
}
|
||||
};
|
||||
|
||||
$video_attr_strings = array();
|
||||
foreach ( $atts as $k => $v ) {
|
||||
if ( $v == '' ) continue;
|
||||
$video_attr_strings[] = $k . '="' . esc_attr( $v ) . '"';
|
||||
foreach ($atts as $k => $v) {
|
||||
if ($v == '') continue;
|
||||
$video_attr_strings[] = $k . '="' . esc_attr($v) . '"';
|
||||
}
|
||||
|
||||
$html .= sprintf( '[dplayer %s]', join( ' ', $video_attr_strings ) );
|
||||
$html .= sprintf('[dplayer %s]', join(' ', $video_attr_strings));
|
||||
|
||||
return do_shortcode( $html );
|
||||
return do_shortcode($html);
|
||||
}
|
||||
|
||||
if ( ! is_admin() ){
|
||||
add_filter( 'wp_video_shortcode_override' , 'override_wp_video_shortcode', 1, 2 );
|
||||
if (!is_admin()) {
|
||||
add_filter('wp_video_shortcode_override', 'override_wp_video_shortcode', 1, 2);
|
||||
}
|
||||
|
||||
add_action('init', 'more_button');
|
||||
|
@ -322,12 +331,13 @@ function more_button()
|
|||
}
|
||||
}
|
||||
|
||||
function add_more_buttons($buttons) {
|
||||
function add_more_buttons($buttons)
|
||||
{
|
||||
$buttons[] = 'hr';
|
||||
$buttons[] = 'wp_page';
|
||||
$buttons[] = 'fontsizeselect';
|
||||
$buttons[] = 'styleselect';
|
||||
return $buttons;
|
||||
return $buttons;
|
||||
}
|
||||
add_filter("mce_buttons", "add_more_buttons");
|
||||
|
||||
|
|
|
@ -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,20 +56,22 @@ function widgets_init()
|
|||
add_action('widgets_init', 'widgets_init');
|
||||
|
||||
// 分类目录计数
|
||||
function cat_count_span( $links ) {
|
||||
$links = str_replace( '</a> (', '<span> / ', $links );
|
||||
$links = str_replace( ')', __('篇', 'kratos') . '</span></a>', $links );
|
||||
function cat_count_span($links)
|
||||
{
|
||||
$links = str_replace('</a> (', '<span> / ', $links);
|
||||
$links = str_replace(')', __('篇', 'kratos') . '</span></a>', $links);
|
||||
return $links;
|
||||
}
|
||||
add_filter( 'wp_list_categories', 'cat_count_span' );
|
||||
add_filter('wp_list_categories', 'cat_count_span');
|
||||
|
||||
// 文章归档计数
|
||||
function archive_count_span( $links ) {
|
||||
$links = str_replace( '</a> (', '<span> / ', $links );
|
||||
$links = str_replace( ')', __('篇', 'kratos') . '</span></a>', $links );
|
||||
function archive_count_span($links)
|
||||
{
|
||||
$links = str_replace('</a> (', '<span> / ', $links);
|
||||
$links = str_replace(')', __('篇', 'kratos') . '</span></a>', $links);
|
||||
return $links;
|
||||
}
|
||||
add_filter( 'get_archives_link', 'archive_count_span' );
|
||||
add_filter('get_archives_link', 'archive_count_span');
|
||||
|
||||
// 小工具文章聚合 - 热点文章
|
||||
function most_comm_posts($days = 30, $nums = 6)
|
||||
|
@ -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,29 +117,30 @@ function timeago($time) {
|
|||
}
|
||||
}
|
||||
|
||||
function string_cut($string, $sublen, $start = 0, $code = 'UTF-8') {
|
||||
if($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);
|
||||
if(count($t_string[0]) - $start > $sublen) return join('', array_slice($t_string[0], $start, $sublen)) . "...";
|
||||
if (count($t_string[0]) - $start > $sublen) return join('', array_slice($t_string[0], $start, $sublen)) . "...";
|
||||
return join('', array_slice($t_string[0], $start, $sublen));
|
||||
} else {
|
||||
$start = $start * 2;
|
||||
$sublen = $sublen * 2;
|
||||
$strlen = strlen($string);
|
||||
$tmpstr = '';
|
||||
for($i = 0; $i < $strlen; $i++) {
|
||||
if($i >= $start && $i < ($start + $sublen)) {
|
||||
if(ord(substr($string, $i, 1)) > 129) $tmpstr .= substr($string, $i, 2);
|
||||
for ($i = 0; $i < $strlen; $i++) {
|
||||
if ($i >= $start && $i < ($start + $sublen)) {
|
||||
if (ord(substr($string, $i, 1)) > 129) $tmpstr .= substr($string, $i, 2);
|
||||
else $tmpstr .= substr($string, $i, 1);
|
||||
}
|
||||
if(ord(substr($string, $i, 1)) > 129) $i++;
|
||||
if (ord(substr($string, $i, 1)) > 129) $i++;
|
||||
}
|
||||
return $tmpstr;
|
||||
}
|
||||
}
|
||||
|
||||
function latest_comments($list_number=5, $cut_length=50)
|
||||
function latest_comments($list_number = 5, $cut_length = 50)
|
||||
{
|
||||
global $wpdb, $output;
|
||||
$comments = $wpdb->get_results($wpdb->prepare("SELECT comment_ID, comment_post_ID, comment_author, comment_author_email, comment_date_gmt, comment_content FROM {$wpdb->comments} LEFT OUTER JOIN {$wpdb->posts} ON {$wpdb->comments}.comment_post_ID = {$wpdb->posts}.ID WHERE comment_approved = '1' AND (comment_type = '' OR comment_type = 'comment') AND user_id != '1' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT %d", $list_number));
|
||||
|
@ -157,42 +162,45 @@ 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.' ),
|
||||
'description' => __('A search form for your site.'),
|
||||
'customize_selective_refresh' => true,
|
||||
);
|
||||
parent::__construct( 'search', _x( 'Search', 'Search widget' ), $widget_ops );
|
||||
parent::__construct('search', _x('Search', 'Search widget'), $widget_ops);
|
||||
}
|
||||
|
||||
public function widget( $args, $instance ) {
|
||||
$title = ! empty( $instance['title'] ) ? $instance['title'] : '';
|
||||
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
|
||||
public function widget($args, $instance)
|
||||
{
|
||||
$title = !empty($instance['title']) ? $instance['title'] : '';
|
||||
$title = apply_filters('widget_title', $title, $instance, $this->id_base);
|
||||
|
||||
echo '<div class="widget w-search">';
|
||||
if ( $title ) {
|
||||
echo '<div class="title">'. $title .'</div>';
|
||||
if ($title) {
|
||||
echo '<div class="title">' . $title . '</div>';
|
||||
}
|
||||
echo '<div class="item"> <form role="search" method="get" id="searchform" class="searchform" action="'. home_url('/') .'"> <div class="input-group mt-2 mb-2"> <input type="text" name="s" id="search-widgets" class="form-control" placeholder="'. __('搜点什么呢?', 'kratos') .'"> <div class="input-group-append"> <button class="btn btn-primary btn-search" type="submit" id="searchsubmit">'. __('搜索', 'kratos') .'</button> </div> </div> </form>';
|
||||
echo '<div class="item"> <form role="search" method="get" id="searchform" class="searchform" action="' . home_url('/') . '"> <div class="input-group mt-2 mb-2"> <input type="text" name="s" id="search-widgets" class="form-control" placeholder="' . __('搜点什么呢?', 'kratos') . '"> <div class="input-group-append"> <button class="btn btn-primary btn-search" type="submit" id="searchsubmit">' . __('搜索', 'kratos') . '</button> </div> </div> </form>';
|
||||
echo '</div></div>';
|
||||
}
|
||||
|
||||
public function form( $instance ) {
|
||||
$instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
|
||||
public function form($instance)
|
||||
{
|
||||
$instance = wp_parse_args((array) $instance, array('title' => ''));
|
||||
$title = $instance['title'];
|
||||
?>
|
||||
<p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></label></p>
|
||||
?>
|
||||
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></label></p>
|
||||
<?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'] );
|
||||
$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
|
||||
|
@ -247,17 +255,17 @@ class widget_ad extends WP_Widget
|
|||
?>
|
||||
<div class="media-widget-control">
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id('subtitle'); ?>"><?php _e('副标题:', 'kratos');?></label>
|
||||
<label for="<?php echo $this->get_field_id('subtitle'); ?>"><?php _e('副标题:', 'kratos'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this->get_field_id('subtitle'); ?>" name="<?php echo $this->get_field_name('subtitle'); ?>" type="text" value="<?php echo esc_attr($subtitle); ?>">
|
||||
</p>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id('url'); ?>"><?php _e('链接地址:', 'kratos');?></label>
|
||||
<label for="<?php echo $this->get_field_id('url'); ?>"><?php _e('链接地址:', 'kratos'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this->get_field_id('url'); ?>" name="<?php echo $this->get_field_name('url'); ?>" type="text" value="<?php echo esc_attr($url); ?>">
|
||||
</p>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id('image'); ?>"><?php _e('广告图片:', 'kratos');?></label>
|
||||
<label for="<?php echo $this->get_field_id('image'); ?>"><?php _e('广告图片:', 'kratos'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this->get_field_id('image'); ?>" name="<?php echo $this->get_field_name('image'); ?>" type="text" value="<?php echo esc_url($image); ?>" />
|
||||
<button type="button" class="button-update-media upload_ad"><?php _e('选择图片', 'kratos');?></button>
|
||||
<button type="button" class="button-update-media upload_ad"><?php _e('选择图片', 'kratos'); ?></button>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
|
@ -306,7 +314,7 @@ class widget_about extends WP_Widget
|
|||
if (kratos_option('g_login', true)) {
|
||||
echo '</a>';
|
||||
}
|
||||
echo '</div><div class="textwidget text-center"><p class="username">'. $username .'</p><p class="about">' . $introduce . '</p></div>';
|
||||
echo '</div><div class="textwidget text-center"><p class="username">' . $username . '</p><p class="about">' . $introduce . '</p></div>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
|
@ -325,9 +333,9 @@ class widget_about extends WP_Widget
|
|||
?>
|
||||
<div class="media-widget-control">
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id('background'); ?>"><?php _e('背景图片:', 'kratos');?></label>
|
||||
<label for="<?php echo $this->get_field_id('background'); ?>"><?php _e('背景图片:', 'kratos'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this->get_field_id('background'); ?>" name="<?php echo $this->get_field_name('background'); ?>" type="text" value="<?php echo esc_attr($background); ?>">
|
||||
<button type="button" class="button-update-media upload_background"><?php _e('选择图片', 'kratos');?></button>
|
||||
<button type="button" class="button-update-media upload_background"><?php _e('选择图片', 'kratos'); ?></button>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
|
@ -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,
|
||||
|
@ -385,15 +394,15 @@ class widget_tags extends WP_Widget
|
|||
?>
|
||||
<div class="media-widget-control">
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('显示数量:', 'kratos');?></label>
|
||||
<label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('显示数量:', 'kratos'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo esc_attr($number); ?>" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id('order'); ?>"><?php _e('显示排序:', 'kratos');?></label>
|
||||
<label for="<?php echo $this->get_field_id('order'); ?>"><?php _e('显示排序:', 'kratos'); ?></label>
|
||||
<select name="<?php echo $this->get_field_name("order"); ?>" id='<?php echo $this->get_field_id("order"); ?>'>
|
||||
<option value="DESC" <?php echo ($order == 'DESC') ? 'selected' : ''; ?>><?php _e('降序', 'kratos');?></option>
|
||||
<option value="ASC" <?php echo ($order == 'ASC') ? 'selected' : ''; ?>><?php _e('升序', 'kratos');?></option>
|
||||
<option value="RAND" <?php echo ($order == 'RAND') ? 'selected' : ''; ?>><?php _e('随机', 'kratos');?></option>
|
||||
<option value="DESC" <?php echo ($order == 'DESC') ? 'selected' : ''; ?>><?php _e('降序', 'kratos'); ?></option>
|
||||
<option value="ASC" <?php echo ($order == 'ASC') ? 'selected' : ''; ?>><?php _e('升序', 'kratos'); ?></option>
|
||||
<option value="RAND" <?php echo ($order == 'RAND') ? 'selected' : ''; ?>><?php _e('随机', 'kratos'); ?></option>
|
||||
</select>
|
||||
</p>
|
||||
</div>
|
||||
|
@ -422,28 +431,32 @@ class widget_posts extends WP_Widget
|
|||
echo '<div class="widget w-recommended">';
|
||||
?>
|
||||
<div class="nav nav-tabs d-none d-xl-flex" id="nav-tab" role="tablist">
|
||||
<a class="nav-item nav-link <?php echo $active = ($order == 'new') ? 'active' : null; ?>" id="nav-new-tab" data-toggle="tab" href="#nav-new" role="tab" aria-controls="nav-new" aria-selected="<?php echo $selected = ($order == 'new') ? 'true' : 'false'; ?>"><i class="kicon i-tabnew"></i><?php _e('最新', 'kratos');?></a>
|
||||
<a class="nav-item nav-link <?php echo $active = ($order == 'hot') ? 'active' : null; ?>" id="nav-hot-tab" data-toggle="tab" href="#nav-hot" role="tab" aria-controls="nav-hot" aria-selected="<?php echo $selected = ($order == 'hot') ? 'true' : 'false'; ?>"><i class="kicon i-tabhot"></i><?php _e('热点', 'kratos');?></a>
|
||||
<a class="nav-item nav-link <?php echo $active = ($order == 'random') ? 'active' : null; ?>" id="nav-random-tab" data-toggle="tab" href="#nav-random" role="tab" aria-controls="nav-random" aria-selected="<?php echo $selected = ($order == 'random') ? 'true' : 'false'; ?>"><i class="kicon i-tabrandom"></i><?php _e('随机', 'kratos');?></a>
|
||||
<a class="nav-item nav-link <?php echo $active = ($order == 'new') ? 'active' : null; ?>" id="nav-new-tab" data-toggle="tab" href="#nav-new" role="tab" aria-controls="nav-new" aria-selected="<?php echo $selected = ($order == 'new') ? 'true' : 'false'; ?>"><i class="kicon i-tabnew"></i><?php _e('最新', 'kratos'); ?></a>
|
||||
<a class="nav-item nav-link <?php echo $active = ($order == 'hot') ? 'active' : null; ?>" id="nav-hot-tab" data-toggle="tab" href="#nav-hot" role="tab" aria-controls="nav-hot" aria-selected="<?php echo $selected = ($order == 'hot') ? 'true' : 'false'; ?>"><i class="kicon i-tabhot"></i><?php _e('热点', 'kratos'); ?></a>
|
||||
<a class="nav-item nav-link <?php echo $active = ($order == 'random') ? 'active' : null; ?>" id="nav-random-tab" data-toggle="tab" href="#nav-random" role="tab" aria-controls="nav-random" aria-selected="<?php echo $selected = ($order == 'random') ? 'true' : 'false'; ?>"><i class="kicon i-tabrandom"></i><?php _e('随机', 'kratos'); ?></a>
|
||||
</div>
|
||||
<div class="nav nav-tabs d-xl-none" id="nav-tab" role="tablist">
|
||||
<a class="nav-item nav-link <?php echo $active = ($order == 'new') ? 'active' : null; ?>" id="nav-new-tab" data-toggle="tab" href="#nav-new" role="tab" aria-controls="nav-new" aria-selected="<?php echo $selected = ($order == 'new') ? 'true' : 'false'; ?>"><?php _e('最新', 'kratos');?></a>
|
||||
<a class="nav-item nav-link <?php echo $active = ($order == 'hot') ? 'active' : null; ?>" id="nav-hot-tab" data-toggle="tab" href="#nav-hot" role="tab" aria-controls="nav-hot" aria-selected="<?php echo $selected = ($order == 'hot') ? 'true' : 'false'; ?>"><?php _e('热点', 'kratos');?></a>
|
||||
<a class="nav-item nav-link <?php echo $active = ($order == 'random') ? 'active' : null; ?>" id="nav-random-tab" data-toggle="tab" href="#nav-random" role="tab" aria-controls="nav-random" aria-selected="<?php echo $selected = ($order == 'random') ? 'true' : 'false'; ?>"><?php _e('随机', 'kratos');?></a>
|
||||
<a class="nav-item nav-link <?php echo $active = ($order == 'new') ? 'active' : null; ?>" id="nav-new-tab" data-toggle="tab" href="#nav-new" role="tab" aria-controls="nav-new" aria-selected="<?php echo $selected = ($order == 'new') ? 'true' : 'false'; ?>"><?php _e('最新', 'kratos'); ?></a>
|
||||
<a class="nav-item nav-link <?php echo $active = ($order == 'hot') ? 'active' : null; ?>" id="nav-hot-tab" data-toggle="tab" href="#nav-hot" role="tab" aria-controls="nav-hot" aria-selected="<?php echo $selected = ($order == 'hot') ? 'true' : 'false'; ?>"><?php _e('热点', 'kratos'); ?></a>
|
||||
<a class="nav-item nav-link <?php echo $active = ($order == 'random') ? 'active' : null; ?>" id="nav-random-tab" data-toggle="tab" href="#nav-random" role="tab" aria-controls="nav-random" aria-selected="<?php echo $selected = ($order == 'random') ? 'true' : 'false'; ?>"><?php _e('随机', 'kratos'); ?></a>
|
||||
</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;?>
|
||||
<?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;?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo '</div>';
|
||||
|
@ -468,19 +481,19 @@ class widget_posts extends WP_Widget
|
|||
?>
|
||||
<div class="media-widget-control">
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('展示数量:', 'kratos');?></label>
|
||||
<label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('展示数量:', 'kratos'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo esc_attr($number); ?>" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id('days'); ?>"><?php _e('统计天数:', 'kratos');?></label>
|
||||
<label for="<?php echo $this->get_field_id('days'); ?>"><?php _e('统计天数:', 'kratos'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this->get_field_id('days'); ?>" name="<?php echo $this->get_field_name('days'); ?>" type="text" value="<?php echo esc_attr($days); ?>" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id('order'); ?>"><?php _e('默认显示:', 'kratos');?></label>
|
||||
<label for="<?php echo $this->get_field_id('order'); ?>"><?php _e('默认显示:', 'kratos'); ?></label>
|
||||
<select name="<?php echo $this->get_field_name("order"); ?>" id='<?php echo $this->get_field_id("order"); ?>'>
|
||||
<option value="new" <?php echo ($order == 'new') ? 'selected' : ''; ?>><?php _e('最新', 'kratos');?></option>
|
||||
<option value="hot" <?php echo ($order == 'hot') ? 'selected' : ''; ?>><?php _e('热点', 'kratos');?></option>
|
||||
<option value="random" <?php echo ($order == 'random') ? 'selected' : ''; ?>><?php _e('随机', 'kratos');?></option>
|
||||
<option value="new" <?php echo ($order == 'new') ? 'selected' : ''; ?>><?php _e('最新', 'kratos'); ?></option>
|
||||
<option value="hot" <?php echo ($order == 'hot') ? 'selected' : ''; ?>><?php _e('热点', 'kratos'); ?></option>
|
||||
<option value="random" <?php echo ($order == 'random') ? 'selected' : ''; ?>><?php _e('随机', 'kratos'); ?></option>
|
||||
</select>
|
||||
</p>
|
||||
</div>
|
||||
|
@ -505,7 +518,7 @@ class widget_comments extends WP_Widget
|
|||
$number = !empty($instance['number']) ? $instance['number'] : '5';
|
||||
$title = !empty($instance['title']) ? $instance['title'] : __('最近评论', 'kratos');
|
||||
|
||||
echo '<div class="widget w-comments"><div class="title">'. $title .'</div><div class="comments">';
|
||||
echo '<div class="widget w-comments"><div class="title">' . $title . '</div><div class="comments">';
|
||||
echo latest_comments($number, 50);
|
||||
echo '</div></div>';
|
||||
}
|
||||
|
@ -527,15 +540,15 @@ class widget_comments extends WP_Widget
|
|||
?>
|
||||
<div class="media-widget-control">
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('栏目标题:', 'kratos');?></label>
|
||||
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('栏目标题:', 'kratos'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('展示数量:', 'kratos');?></label>
|
||||
<label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('展示数量:', 'kratos'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo esc_attr($number); ?>" />
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -578,7 +591,7 @@ class widget_toc extends WP_Widget
|
|||
$index .= '</li>' . "\n";
|
||||
} elseif ($toc_depth > $prev_depth) {
|
||||
$to_depth++;
|
||||
$index .= '<ul class="ul-'.$toc_depth.'">' . "\n";
|
||||
$index .= '<ul class="ul-' . $toc_depth . '">' . "\n";
|
||||
} else {
|
||||
$to_depth2 = $to_depth > $prev_depth - $toc_depth ? $prev_depth - $toc_depth : $to_depth;
|
||||
if ($to_depth2) {
|
||||
|
@ -590,7 +603,7 @@ class widget_toc extends WP_Widget
|
|||
$index .= '</li>';
|
||||
}
|
||||
}
|
||||
$index .= '<li class="li-'.$toc_depth.'"><a href="#toc-' . $toc_item['count'] . '">' . str_replace(array('[h2title]', '[/h2title]'),array('', ''),$toc_item['text']) . '</a>';
|
||||
$index .= '<li class="li-' . $toc_depth . '"><a href="#toc-' . $toc_item['count'] . '">' . str_replace(array('[h2title]', '[/h2title]'), array('', ''), $toc_item['text']) . '</a>';
|
||||
$prev_depth = $toc_item['depth'];
|
||||
}
|
||||
for ($i = 0; $i <= $to_depth; $i++) {
|
||||
|
|
19
index.php
19
index.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,23 +12,25 @@ get_header(); ?>
|
|||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 board">
|
||||
<?php if(is_home() && kratos_option('g_carousel', false)){
|
||||
<?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() ) {
|
||||
while ( have_posts() ){
|
||||
if (have_posts()) {
|
||||
while (have_posts()) {
|
||||
the_post();
|
||||
get_template_part('/pages/page-content', get_post_format());
|
||||
}
|
||||
}else{ ?>
|
||||
} else { ?>
|
||||
<div class="article-panel">
|
||||
<div class="nothing">
|
||||
<img src="<?php
|
||||
if(!kratos_option('g_nothing')){
|
||||
if (!kratos_option('g_nothing')) {
|
||||
$img = ASSET_PATH . '/assets/img/nothing.svg';
|
||||
} else {
|
||||
$img = kratos_option('g_nothing', ASSET_PATH . '/assets/img/nothing.svg');
|
||||
|
|
10
page.php
10
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>
|
||||
|
@ -33,8 +35,8 @@ get_header(); ?>
|
|||
'before' => '',
|
||||
'after' => '',
|
||||
'next_or_number' => 'number',
|
||||
'link_before' =>'<span>',
|
||||
'link_after'=>'</span>'
|
||||
'link_before' => '<span>',
|
||||
'link_after' => '</span>'
|
||||
)
|
||||
);
|
||||
wp_link_pages(
|
||||
|
|
|
@ -1,34 +1,39 @@
|
|||
<?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>
|
||||
<?php } ?>
|
||||
</span>
|
||||
<?php if (kratos_option('g_thumbnail',true)) { ?>
|
||||
<?php if (kratos_option('g_thumbnail', true)) { ?>
|
||||
<div class="a-thumb">
|
||||
<a href="<?php the_permalink(); ?>">
|
||||
<?php post_thumbnail(); ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php }?>
|
||||
<div class="a-post <?php if (!kratos_option('g_thumbnail',true)) { echo 'a-none'; } ?>">
|
||||
<?php } ?>
|
||||
<div class="a-post <?php if (!kratos_option('g_thumbnail', true)) {
|
||||
echo 'a-none';
|
||||
} ?>">
|
||||
<div class="header">
|
||||
<?php
|
||||
$category = get_the_category();
|
||||
if ($category) {
|
||||
echo '<a class="label" href="'. get_category_link($category[0]->term_id) . '">' . $category[0]->cat_name . '<i class="label-arrow"></i></a>';
|
||||
echo '<a class="label" href="' . get_category_link($category[0]->term_id) . '">' . $category[0]->cat_name . '<i class="label-arrow"></i></a>';
|
||||
} else {
|
||||
echo '<span class="label">'. __('页面','kratos') .'<i class="label-arrow"></i></span>';
|
||||
echo '<span class="label">' . __('页面', 'kratos') . '<i class="label-arrow"></i></span>';
|
||||
}
|
||||
?>
|
||||
<h3 class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
|
||||
|
@ -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,21 +1,22 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* 文章工具栏
|
||||
* @author Seaton Jiang <seatonjiang@vtrois.com>
|
||||
* @license MIT License
|
||||
* @version 2021.06.25
|
||||
* @version 2021.08.19
|
||||
*/
|
||||
?>
|
||||
<div class="toolbar clearfix">
|
||||
<div class="meta float-md-left">
|
||||
<img src="<?php echo get_avatar_url(get_the_author_meta('user_email')); ?>">
|
||||
<p class="name"><?php echo get_the_author_meta('display_name'); ?></p>
|
||||
<p class="motto mb-0"><?php echo $description=!empty(get_the_author_meta('description')) ? get_the_author_meta('description') : __('这个人很懒,什么都没留下', 'kratos'); ?></p>
|
||||
<p class="motto mb-0"><?php echo $description = !empty(get_the_author_meta('description')) ? get_the_author_meta('description') : __('这个人很懒,什么都没留下', 'kratos'); ?></p>
|
||||
</div>
|
||||
<div class="share float-md-right text-center">
|
||||
<?php if(kratos_option('g_donate',false)){ ?>
|
||||
<a href="javascript:;" id="donate" class="btn btn-donate mr-3" role="button"><i class="kicon i-donate"></i> <?php _e('打赏','kratos'); ?></a>
|
||||
<?php if (kratos_option('g_donate', false)) { ?>
|
||||
<a href="javascript:;" id="donate" class="btn btn-donate mr-3" role="button"><i class="kicon i-donate"></i> <?php _e('打赏', 'kratos'); ?></a>
|
||||
<?php } ?>
|
||||
<a href="javascript:;" id="thumbs" data-action="love" data-id="<?php the_ID(); ?>" role="button" class="btn btn-thumbs <?php if(isset($_COOKIE['love_'.$post->ID])) echo 'done'; ?>" ><i class="kicon i-like"></i><span class="ml-1"><?php _e('点赞','kratos'); ?></span></a>
|
||||
<a href="javascript:;" id="thumbs" data-action="love" data-id="<?php the_ID(); ?>" role="button" class="btn btn-thumbs <?php if (isset($_COOKIE['love_' . $post->ID])) echo 'done'; ?>"><i class="kicon i-like"></i><span class="ml-1"><?php _e('点赞', 'kratos'); ?></span></a>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in New Issue