Skip to content

Commit

Permalink
修复ajax提交评论不显示UA、IP的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jd82k committed Apr 22, 2024
1 parent 15395f0 commit bf8f421
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions inc/fun/comment-ajax.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use function donatj\UserAgent\parse_user_agent;
function pk_comment_err($msg, $refresh_code = true)
{
$protocol = $_SERVER['SERVER_PROTOCOL'];
Expand Down Expand Up @@ -174,7 +175,7 @@ function pk_comment_ajax()
$comment_approved_str = '';

if ($comment->comment_approved == '0') {
$comment_approved_str = '<p class="c-sub mt-1"><i class="fa fa-warning mr-1"></i>您的评论正在等待审核!</p>';
$comment_approved_str = '<p class="c-sub mt-1 t-sm"><i class="fa fa-warning mr-1"></i>您的评论正在等待审核!</p>';
}

wp_set_comment_cookies($comment, $user);
Expand All @@ -190,10 +191,29 @@ function pk_comment_ajax()
<div class="t-sm c-sub">' . get_comment_date('Y-m-d H:i:s', $comment_id) . '</div>
</div>
</div>
<div class="content t-sm mt10 puock-text">
<div class="content-text">
' . get_comment_text($comment_id) . '
<div class="content">
<div class="content-text t-md mt10 puock-text">
<p>' . get_comment_text($comment_id) . '</p>
' . $comment_approved_str . '
<div class="comment-os c-sub">';

if (pk_is_checked('comment_show_ua', true)):
$commentUserAgent = parse_user_agent($comment->comment_agent);
$commentOsIcon = pk_get_comment_ua_os_icon($commentUserAgent['platform']);
$commentBrowserIcon = pk_get_comment_ua_os_icon($commentUserAgent['browser']);
echo "<span class='mt10' title='{$commentUserAgent['platform']}'><i class='$commentOsIcon'></i>&nbsp;<span>{$commentUserAgent['platform']}&nbsp;</span></span>";
echo "<span class='mt10' title='{$commentUserAgent['browser']} {$commentUserAgent['version']}'><i class='$commentBrowserIcon'></i>&nbsp;<span>{$commentUserAgent['browser']}</span></span>";
endif;
?>
<?php
if (pk_is_checked('comment_show_ip', true)) {
if (!pk_is_checked('comment_dont_show_owner_ip') || (pk_is_checked('comment_dont_show_owner_ip') && $comment->user_id != 1)) {
$ip = pk_get_ip_region_str($comment->comment_author_IP);
echo "<span class='mt10' title='IP'><i class='fa-solid fa-location-dot'></i>&nbsp;$ip</span>";
}
}

echo ' </div>
</div>
</div>
</div>';
Expand Down

0 comments on commit bf8f421

Please sign in to comment.