mirror of https://github.com/vtrois/kratos
fix: add judgment for nickname being empty (#374)
parent
a3c3d681ea
commit
f91abeb96f
|
@ -3,7 +3,7 @@
|
||||||
* 侧栏小工具
|
* 侧栏小工具
|
||||||
* @author Seaton Jiang <seaton@vtrois.com>
|
* @author Seaton Jiang <seaton@vtrois.com>
|
||||||
* @license MIT License
|
* @license MIT License
|
||||||
* @version 2021.04.15
|
* @version 2021.05.18
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// 添加小工具
|
// 添加小工具
|
||||||
|
@ -112,7 +112,8 @@ function latest_comments($list_number=5, $cut_length=50)
|
||||||
global $wpdb, $output;
|
global $wpdb, $output;
|
||||||
$comments = $wpdb->get_results("SELECT comment_ID, comment_post_ID, comment_author, 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 {$list_number}");
|
$comments = $wpdb->get_results("SELECT comment_ID, comment_post_ID, comment_author, 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 {$list_number}");
|
||||||
foreach ($comments as $comment) {
|
foreach ($comments as $comment) {
|
||||||
$output .= '<a href="' . get_the_permalink($comment->comment_post_ID) . '#commentform"> <div class="meta clearfix"> <div class="avatar float-left">' . get_avatar($comment, 60) . '</div> <div class="profile d-block"> <span class="date">' . esc_attr($comment->comment_author) . ' ' . __('发布于 ', 'kratos') . timeago($comment->comment_date_gmt) . '</span> <span class="message d-block">' . convert_smilies(esc_attr(string_cut(strip_tags($comment->comment_content), $cut_length))) . '</span> </div> </div> </a>';
|
$nickname = esc_attr($comment->comment_author) ?: __('匿名', 'kratos');
|
||||||
|
$output .= '<a href="' . get_the_permalink($comment->comment_post_ID) . '#commentform"> <div class="meta clearfix"> <div class="avatar float-left">' . get_avatar($comment, 60) . '</div> <div class="profile d-block"> <span class="date">' . $nickname . ' ' . __('发布于 ', 'kratos') . timeago($comment->comment_date_gmt) . '</span> <span class="message d-block">' . convert_smilies(esc_attr(string_cut(strip_tags($comment->comment_content), $cut_length))) . '</span> </div> </div> </a>';
|
||||||
}
|
}
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue