From 3704666d5ea672e63049b3275880b099c55e3257 Mon Sep 17 00:00:00 2001 From: Seaton Jiang Date: Fri, 29 Apr 2022 12:22:58 +0800 Subject: [PATCH] feat: use wp_date() to replace date() --- footer.php | 6 +++--- inc/theme-options.php | 4 ++-- inc/theme-smtp.php | 6 +++--- inc/theme-widgets.php | 11 ++++++----- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/footer.php b/footer.php index 85216eb2..513e3e32 100644 --- a/footer.php +++ b/footer.php @@ -4,7 +4,7 @@ * 主题页脚 * @author Seaton Jiang * @license GPL-3.0 License - * @version 2022.01.26 + * @version 2022.04.29 */ ?> @@ -118,7 +118,7 @@ function comment_notify($comment_id)
' . __('该邮件由系统自动发出,如果不是您本人操作,请忽略此邮件。', 'kratos') . '

' . htmlspecialchars_decode(get_option('blogname'), ENT_QUOTES) . '

-

' . date("Y年m月d日", time()) . '

+

' . wp_date("Y年m月d日", time()) . '

diff --git a/inc/theme-widgets.php b/inc/theme-widgets.php index 13ac9d2f..e7ec3a5d 100644 --- a/inc/theme-widgets.php +++ b/inc/theme-widgets.php @@ -4,7 +4,7 @@ * 侧栏小工具 * @author Seaton Jiang * @license GPL-3.0 License - * @version 2022.01.26 + * @version 2022.04.29 */ // 添加小工具 @@ -77,11 +77,12 @@ function archive_count_span($links) function most_comm_posts($days = 30, $nums = 6) { global $wpdb; - date_default_timezone_set("PRC"); - $today = date("Y-m-d H:i:s"); - $daysago = date("Y-m-d H:i:s", strtotime($today) - ($days * 24 * 60 * 60)); + + $today = wp_date("Y-m-d H:i:s"); + $daysago = wp_date("Y-m-d H:i:s", strtotime($today) - ($days * 24 * 60 * 60)); $result = $wpdb->get_results($wpdb->prepare("SELECT comment_count, ID, post_title, post_date FROM $wpdb->posts WHERE post_date BETWEEN %s AND %s and post_type = 'post' AND post_status = 'publish' ORDER BY comment_count DESC LIMIT 0, %d", $daysago, $today, $nums)); $output = ''; + if (!empty($result)) { foreach ($result as $topten) { $postid = $topten->ID; @@ -150,7 +151,7 @@ function latest_comments($list_number = 5, $cut_length = 50)
' . get_avatar($comment, 60) . '
- ' . $nickname . ' ' . __('发布于 ', 'kratos') . timeago($comment->comment_date) . '(' . date(__('m月d日', 'kratos'), strtotime($comment->comment_date)) . ') + ' . $nickname . ' ' . __('发布于 ', 'kratos') . timeago($comment->comment_date) . '(' . wp_date(__('m月d日', 'kratos'), strtotime($comment->comment_date)) . ') ' . convert_smilies(esc_attr(string_cut(strip_tags($comment->comment_content), $cut_length))) . '