comment_post_ID); if (!$post) { return; } $content = get_comment_text($comment); $content = preg_replace_callback( '/\[link=([^\]\s]+)(?:\s+target=_blank)?\](.*?)\[\/link\]/is', static function (array $matches): string { $url = esc_url(trim($matches[1])); $label = wp_kses_post($matches[2]); if ($url === '') { return $label; } $target = stripos($matches[0], 'target=_blank') !== false ? ' target="_blank" rel="noopener noreferrer"' : ''; return '' . $label . ''; }, (string) $content ); $content = preg_replace('/]*>/i', '[图片]', (string) $content); $content = preg_replace('/\[img=[^\]]*\]/i', '[图片]', (string) $content); $content = preg_replace('/\[code\][\s\S]*?\[\/code\]/i', '[代码]', (string) $content); $content = wp_kses_post((string) $content); $post_title = get_the_title($post); $comment_link = get_comment_link($comment); $post_link = get_permalink($post); $date_iso = get_comment_date('c', $comment); $date_label = get_comment_date('Y-m-d H:i:s', $comment); $time_diff = human_time_diff((int) get_comment_time('U', false, false, $comment), current_time('timestamp')); $parent = $comment->comment_parent ? get_comment((int) $comment->comment_parent) : null; ?>